Home Reference Source Test
import {TokenClient} from '@token-io/tpp/src/main/TokenClient.js'
public class | source

TokenClient

Extends:

@token-io/core~Core → TokenClient

Token SDK entry point.

Constructor Summary

Public Constructor
public

constructor(options: object)

Member Summary

Public Members
public

UnsecuredFileCryptoEngine: Class<KeyStoreCryptoEngine>

public

Util: *

Private Members
private

Method Summary

Public Methods
public

Creates a TokenRequestBuilder for an access token.

public

createMember(alias: Alias, CryptoEngine: Class<KeyStoreCryptoEngine>): Promise<Member>

Creates a business member with a alias and a key pair using the provided engine.

public

Creates a TokenRequestBuilder for a transfer token.

public

Generates a token request authorization URL.

public

getMember(CryptoEngine: Class<KeyStoreCryptoEngine>, memberId: string): Member

Returns 'logged-in' member that uses keys already in the CryptoEngine.

public

Gets the token request result based on its token request ID.

public

Parses a token request callback object and verifies the state and signature.

public

Parses a token request callback URL and verifies the state and signature.

public

Retrieves a request for a token to get request details.

Public Constructors

public constructor(options: object) source

Params:

NameTypeAttributeDescription
options object

Public Members

public UnsecuredFileCryptoEngine: Class<KeyStoreCryptoEngine> source

public Util: * source

Private Members

private _unauthenticatedClient: * source

Public Methods

public createAccessTokenRequest(resources: Array<ResourceType>): AccessTokenRequestBuilder source

Creates a TokenRequestBuilder for an access token.

Params:

NameTypeAttributeDescription
resources Array<ResourceType>

resources to request access of

Return:

AccessTokenRequestBuilder

The created TokenRequestBuilder

public createMember(alias: Alias, CryptoEngine: Class<KeyStoreCryptoEngine>): Promise<Member> source

Creates a business member with a alias and a key pair using the provided engine.

Params:

NameTypeAttributeDescription
alias Alias
  • nullable: true

alias - alias for the member

CryptoEngine Class<KeyStoreCryptoEngine>

CryptoEngine - engine to use for key creation and storage

Return:

Promise<Member>

Promise of created Member

public createTransferTokenRequest(lifetimeAmount: number | string, currency: string): TransferTokenRequestBuilder source

Creates a TokenRequestBuilder for a transfer token.

Params:

NameTypeAttributeDescription
lifetimeAmount number | string

lifetime amount of the token

currency string

3 letter currency code for the amount, e.g. 'USD'

Return:

TransferTokenRequestBuilder

The created TokenRequestBuilder

public generateTokenRequestUrl(requestId: string): string source

Generates a token request authorization URL.

Params:

NameTypeAttributeDescription
requestId string

request ID

Return:

string

token request URL

public getMember(CryptoEngine: Class<KeyStoreCryptoEngine>, memberId: string): Member source

Returns 'logged-in' member that uses keys already in the CryptoEngine. If memberId is not provided, the last member to 'log in' will be used.

Params:

NameTypeAttributeDescription
CryptoEngine Class<KeyStoreCryptoEngine>

engine to use for key creation and storage

memberId string

optional ID of the member we want to log in

Return:

Member

instantiated member

public getTokenRequestResult(tokenRequestId: string): Promise<object> source

Gets the token request result based on its token request ID.

Params:

NameTypeAttributeDescription
tokenRequestId string

token request ID

Return:

Promise<object>

token ID and signature

public parseTokenRequestCallbackParams(callback: object, csrfToken: string): Promise<object> source

Parses a token request callback object and verifies the state and signature. This is similar to parseTokenRequestCallbackUrl but used in the popup flow instead of redirect.

Params:

NameTypeAttributeDescription
callback object

callback

csrfToken string

csrfToken

Return:

Promise<object>

public parseTokenRequestCallbackUrl(callbackUrl: string, csrfToken: string): Promise<object> source

Parses a token request callback URL and verifies the state and signature. This is used at the end of the redirect flow before redeeming the token.

Params:

NameTypeAttributeDescription
callbackUrl string

callback URL

csrfToken string

CSRF token

Return:

Promise<object>

inner state and token ID

public retrieveTokenRequest(requestId: string): Promiseobject> source

Retrieves a request for a token to get request details.

Params:

NameTypeAttributeDescription
requestId string

token request ID

Return:

Promiseobject>

information about the tokenRequest