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

TokenIO

Main entry object. Allows creation of members, provisioning of devices, logging in, sending notifications, etc, as well as access to other SDK classes.

Static Method Summary

Static Public Methods
public static

If we're on a token page, this disables passthrough

public static

If we're on a token page, sets up an iframe to avoid CORS preflights. All requests in this window will be routed through the iframe.

Constructor Summary

Public Constructor
public

constructor(options: object)

Construct the Token SDK object, pointing to the given environment.

Member Summary

Public Members
public
public
public
public
public
public
public
public
public
Private Members
private

Method Summary

Public Methods
public

Checks if a given alias already exists

public

createAccessTokenRequest(resources: Array<ResourceTypeEnum>): TokenRequest

Create a TokenRequest for an access token

public

Creates a member with a alias and a keypair, using the provided engine

public

createClaimedMember(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, tokenRequestId: string): Promise<Member>

Creates a claimed member with a alias and a keypair, using the provided engine

public

createMember(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, memberType: string, tokenRequestId: string): Promise<Member>

Creates a member with a alias and a keypair, using the provided engine and member type.

public

Create a TokenRequest for a transfer token

public

generateTokenRequestUrl(requestId: string, state: string, csrfToken: string): string

Generate a token request authorization URL.

public

Gets a list of available banks for linking

public

getBlob(blobId: string): Promise<Blob>

Downloads a blob from the server.

public

Gets a list of available countries for linking

public

getMember(CryptoEngine: KeyStoreCryptoEngine, memberId: any): Member

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

public

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

public

invalidateNotification(notificationId: string): Promise<NotifyStatusEnum>

Invalidate a notification.

public

Normalizes an alias you probably won't need to call this as this is automatically called before addAlias()

public

notifyAddKey(alias: Alias, keys: Array<Key>, deviceMetadata: DeviceMetadata): Promise<NotifyStatusEnum>

Notifies subscribers that a key should be added and passes the public Key and optional name

public

notifyCreateAndEndorseToken(tokenRequestId: string, keys: Array<Key>, deviceMetadata: DeviceMetadata, receiptContact: ReceiptContact): Object

Notifies subscribed devices that a token should be created and endorsed.

public

notifyEndorseAndAddKey(tokenPayload: TokenPayload, keys: Array<Key>, deviceMetadata: DeviceMetadata, tokenRequestId: string, bankId: string, state: string, receiptContact: ReceiptContact): Promise<object>

this method was deprecated. use notifyCreateAndEndorseToken instead

Notifies subscribed devices that a token payload should be endorsed and keys should be added.

public

notifyPaymentRequest(tokenPayload: TokenPayload): Promise<NotifyStatusEnum>

Sends a notification to a user to request a payment.

public

Parse a token request callback URL, verify the state and signature, and return the inner state and token id.

public

Provisions a new device for an existing user.

public

provisionDeviceLow(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, expirationMs: number): Promise<object>

Provisions a new device for an existing user.

public

Resolve an alias to a member

public

Retrieves a request for a token.

public

updateTokenRequest(requestId: string, options: Object): Promise<void>

Updates an existing token request.

Static Public Methods

public static disableIframePassthrough(): void source

If we're on a token page, this disables passthrough

Return:

void

public static enableIframePassthrough(env: string): void source

If we're on a token page, sets up an iframe to avoid CORS preflights. All requests in this window will be routed through the iframe.

Params:

NameTypeAttributeDescription
env string

which environment (gateway) to use, (e.g. prd)

Return:

void

Public Constructors

public constructor(options: object) source

Construct the Token SDK object, pointing to the given environment.

Params:

NameTypeAttributeDescription
options object

see below

Public Members

public BrowserCryptoEngine: BrowserCryptoEngine source

public Crypto: Crypto source

public KeyLevel: object source

public ManualCryptoEngine: ManualCryptoEngine source

public MemoryCryptoEngine: MemoryCryptoEngine source

public TokenRequest: TokenRequest source

public UnsecuredFileCryptoEngine: UnsecuredFileCryptoEngine source

public Util: Util source

public options: Object source

Private Members

private _unauthenticatedClient: HttpClient source

Public Methods

public aliasExists(alias: Alias): Promise<boolean> source

Checks if a given alias already exists

Params:

NameTypeAttributeDescription
alias Alias

alias to check

Return:

Promise<boolean>

true if alias exists, false otherwise

public createAccessTokenRequest(resources: Array<ResourceTypeEnum>): TokenRequest source

Create a TokenRequest for an access token

Params:

NameTypeAttributeDescription
resources Array<ResourceTypeEnum>

resources to request access of

Return:

TokenRequest

The created TokenRequest

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

Creates a member with a alias and a keypair, using the provided engine

Params:

NameTypeAttributeDescription
alias Alias
  • nullable: true

alias - alias to set for member, falsy value or empty object for a temporary member without an alias

CryptoEngine KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

Return:

Promise<Member>

Promise of created Member

public createClaimedMember(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, tokenRequestId: string): Promise<Member> source

Creates a claimed member with a alias and a keypair, using the provided engine

Params:

NameTypeAttributeDescription
alias Alias
  • nullable: true

alias - alias to set for member, falsy value or empty object for a temporary member without an alias

CryptoEngine KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

tokenRequestId string

tokenRequestId - token request id

Return:

Promise<Member>

Promise of created Member

public createMember(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, memberType: string, tokenRequestId: string): Promise<Member> source

Creates a member with a alias and a keypair, using the provided engine and member type.

Params:

NameTypeAttributeDescription
alias Alias
  • nullable: true

alias - alias to set for member, falsy value or empty object for a temporary member without an alias

CryptoEngine KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

memberType string

memberType - type of member to create. "PERSONAL" if undefined

tokenRequestId string

tokenRequestId - (optional) token request id if the member is being claimed

Return:

Promise<Member>

Promise of created Member

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

Create a TokenRequest 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:

TokenRequest

The created TokenRequest

public generateTokenRequestUrl(requestId: string, state: string, csrfToken: string): string source

Generate a token request authorization URL.

Params:

NameTypeAttributeDescription
requestId string

request id

state string
  • optional
  • default: undefined

original state

csrfToken string
  • optional
  • default: undefined

CSRF token

Return:

string

token request URL

public getBanks(options: object): Promise<object> source

Gets a list of available banks for linking

Params:

NameTypeAttributeDescription
options object

optional parameters for getBanks

Return:

Promise<object>

list of banks

public getBlob(blobId: string): Promise<Blob> source

Downloads a blob from the server.

Params:

NameTypeAttributeDescription
blobId string

id of the blob

Return:

Promise<Blob>

downloaded blob

Throw:

*

error if blob not found

public getCountries(options: object): Promise<object> source

Gets a list of available countries for linking

Params:

NameTypeAttributeDescription
options object

optional parameters for getBanksCountries

Return:

Promise<object>

list of countries with linkable banks

public getMember(CryptoEngine: KeyStoreCryptoEngine, memberId: any): 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 KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

memberId any

optional id of the member we want to log in

Return:

Member

instantiated member

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

Get 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 invalidateNotification(notificationId: string): Promise<NotifyStatusEnum> source

Invalidate a notification.

Params:

NameTypeAttributeDescription
notificationId string

the notification id to invalidate

Return:

Promise<NotifyStatusEnum>

status

public normalizeAlias(alias: Alias): Promise<Alias> source

Normalizes an alias you probably won't need to call this as this is automatically called before addAlias()

Params:

NameTypeAttributeDescription
alias Alias

alias to normalize

Return:

Promise<Alias>

normalized alias

public notifyAddKey(alias: Alias, keys: Array<Key>, deviceMetadata: DeviceMetadata): Promise<NotifyStatusEnum> source

Notifies subscribers that a key should be added and passes the public Key and optional name

Params:

NameTypeAttributeDescription
alias Alias

alias to notify

keys Array<Key>

token keys to be added

deviceMetadata DeviceMetadata

device metadata of the keys

Return:

Promise<NotifyStatusEnum>

status

public notifyCreateAndEndorseToken(tokenRequestId: string, keys: Array<Key>, deviceMetadata: DeviceMetadata, receiptContact: ReceiptContact): Object source

Notifies subscribed devices that a token should be created and endorsed.

Params:

NameTypeAttributeDescription
tokenRequestId string

token request ID

keys Array<Key>

(optional) token keys to be added

deviceMetadata DeviceMetadata

device metadata of the keys

receiptContact ReceiptContact

(optional) receipt contact

Return:

Object

response to the API call

public notifyEndorseAndAddKey(tokenPayload: TokenPayload, keys: Array<Key>, deviceMetadata: DeviceMetadata, tokenRequestId: string, bankId: string, state: string, receiptContact: ReceiptContact): Promise<object> source

this method was deprecated. use notifyCreateAndEndorseToken instead

Notifies subscribed devices that a token payload should be endorsed and keys should be added.

Params:

NameTypeAttributeDescription
tokenPayload TokenPayload

the endorseAndAddKey payload to be sent

keys Array<Key>

token keys to be added

deviceMetadata DeviceMetadata

device metadata of the keys

tokenRequestId string

(optional) token request Id

bankId string

(optional) bank Id

state string

(optional) token request state for signing

receiptContact ReceiptContact

(optional) receipt contact

Return:

Promise<object>

notification Id and notify status

public notifyPaymentRequest(tokenPayload: TokenPayload): Promise<NotifyStatusEnum> source

Sends a notification to a user to request a payment.

Params:

NameTypeAttributeDescription
tokenPayload TokenPayload

requested transfer token

Return:

Promise<NotifyStatusEnum>

status

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

Parse a token request callback URL, verify the state and signature, and return the inner state and token id.

Params:

NameTypeAttributeDescription
callbackUrl string

callback URL

csrfToken string
  • optional
  • default: undefined

CSRF token

Return:

Promise<object>

inner state and token id

public provisionDevice(alias: Alias, CryptoEngine: KeyStoreCryptoEngine): Promise<object> source

Provisions a new device for an existing user. The call generates a set of keys that are returned back. The keys need to be approved by an existing device/keys.

Params:

NameTypeAttributeDescription
alias Alias

user to provision the device for

CryptoEngine KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

Return:

Promise<object>

information about the device provisioned

public provisionDeviceLow(alias: Alias, CryptoEngine: KeyStoreCryptoEngine, expirationMs: number): Promise<object> source

Provisions a new device for an existing user. The call generates a set of keys that are returned back. The keys need to be approved by an existing device/keys. This only generates one (LOW) key.

Params:

NameTypeAttributeDescription
alias Alias

user to provision the device for

CryptoEngine KeyStoreCryptoEngine

CryptoEngine - engine to use for key creation and storage

expirationMs number
  • optional
  • default: undefined

(optional) expiration duration of key in milliseconds

Return:

Promise<object>

information about the device provisioned

public resolveAlias(alias: Alias): Promise<TokenMember|undefined> source

Resolve an alias to a member

Params:

NameTypeAttributeDescription
alias Alias

alias to lookup

Return:

Promise<TokenMember|undefined>

TokenMember protobuf object

public retrieveTokenRequest(requestId: string): Promiseobject> source

Retrieves a request for a token. Called by the web(user) or by a TPP, to get request details.

Params:

NameTypeAttributeDescription
requestId string

token request id

Return:

Promiseobject>

information about the tokenRequest

public updateTokenRequest(requestId: string, options: Object): Promise<void> source

Updates an existing token request.

Params:

NameTypeAttributeDescription
requestId string

token request ID

options Object

new token request options

Return:

Promise<void>

empty promise