Authentication Module
Version Authentication 1.5.0
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
[Deprecated] This method is deprecated as of since version 0.9.0. Please use Authentication module has individual methods for each token type.
as a replacement.
function token(
type: TokenType,
options: object,
): Promise<AuthenticationTokenResult>
Types
TokenType
TokenType: {
PLATFORM: 'platform',
DEVICE: 'device',
DISTRIBUTOR: 'distributor',
},
AuthenticationTokenResult
type AuthenticationTokenResult = {
value: string
expires?: string
type?: string
}