Authentication Module
Version Authentication 1.4.1
Table of Contents
Usage
To use the Authentication module, you can import it into your project from the Firebolt SDK:
import { Authentication } from '@firebolt-js/sdk'
Overview
A module for acquiring authentication tokens.
Methods
device
Get a device token scoped to the current app.
function device(): Promise<string>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:token:device |
Examples
Acquire a Firebolt device identity token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.device()
console.log(token)
Value of token
:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.device",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
root
Get a root device token.
function root(): Promise<string>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:token:root |
Examples
Acquire a Firebolt root device identity token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.root()
console.log(token)
Value of token
:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.root",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
session
Get a destributor session token.
function session(): Promise<string>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:token:session |
Examples
Acquire a distributor session token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.session()
console.log(token)
Value of token
:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.session",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
token
Get a specific type
of authentication token
function token(
type: TokenType,
options: object,
): Promise<AuthenticationTokenResult>
Parameters:
Param | Type | Required | Description |
---|---|---|---|
type |
TokenType |
true | What type of token to get values: 'platform' \| 'device' \| 'distributor' |
options |
object |
false | Additional options for acquiring the token. |
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:token:platform |
Examples
Acquire a Firebolt platform token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.token('platform', null)
console.log(token)
Value of token
:
{
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "platform"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.token",
"params": {
"type": "platform"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "platform"
}
}
Acquire a Firebolt device identity token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.token('device', null)
console.log(token)
Value of token
:
{
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "platform"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.token",
"params": {
"type": "device"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "device"
}
}
Acquire a Firebolt distributor token
JavaScript:
import { Authentication } from '@firebolt-js/sdk'
let token = await Authentication.token('distributor', { clientId: 'xyz' })
console.log(token)
Value of token
:
{
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "platform"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "Authentication.token",
"params": {
"type": "distributor",
"options": {
"clientId": "xyz"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires": "2022-04-23T18:25:43.511Z",
"type": "distributor",
"data": {
"tid": "EB00E9230AB2A35F57DB4EFDDC4908F6446D38F08F4FF0BD57FE6A61E21EEFD9",
"scope": "scope"
}
}
}
Types
TokenType
TokenType: {
PLATFORM: 'platform',
DEVICE: 'device',
DISTRIBUTOR: 'distributor',
},
AuthenticationTokenResult
type AuthenticationTokenResult = {
value: string
expires?: string
type?: string
}