Home Reference Source
import Token from 'token-io/src/main/Token.js'
public class | source

Token

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(env: string, developerKey: string, keyDir: string, globalRpcErrorCallback: function)

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

Member Summary

Public Members
public

Class for using the browser crypto engine

public

Crypto: *

Crypto utility functions

public

Available security levels for keys

public

Class for using the memory crypto engine

public

Class for the Unsecured filestore key root

public

Util: *

Other utility functions

Private Members
private

Developer key

private

_env: *

private
private

Method Summary

Public Methods
public

Checks if a given alias already exists

public

createMember(alias: Object, CryptoEngine: Class): Promise

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

public

Gets a list of available banks for linking

public

getMember(CryptoEngine: Class, memberId: string): Promise

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

public

notifyAddKey(alias: Object, keyName: string, key: Object, level: string, expiresMs: string): Promise

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

public

notifyLinkAccounts(alias: Object, bankAuthorization: string): Promise

Notifies subscribers that accounts should be linked, and passes the bank id and payload

public

notifyLinkAccountsAndAddKey(alias: Object, bankAuthorization: string, keyName: string, key: Object, level: string): Promise

Notifies subscribed devices that accounts should be linked, and passes the bank id and payload

public

Sends a notification to a user to request a payment.

public

provisionDevice(alias: string, CryptoEngine: Class): Promise

Provisions a new device for an existing user.

public

provisionDeviceLow(alias: string, CryptoEngine: Class): Promise

Provisions a new device for an existing user.

public

Resolve an alias to a member

Static Public Methods

public static disableIframePassthrough() source

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

public static enableIframePassthrough(env: string) 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)

Public Constructors

public constructor(env: string, developerKey: string, keyDir: string, globalRpcErrorCallback: function) source

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

Params:

NameTypeAttributeDescription
env string

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

developerKey string

the developer key

keyDir string

absolute directory name of key storage directory

globalRpcErrorCallback function

callback to invoke on any cross-cutting RPC call error. For example: SDK version mismatch

Public Members

public BrowserCryptoEngine: * source

Class for using the browser crypto engine

public Crypto: * source

Crypto utility functions

public KeyLevel: * source

Available security levels for keys

public MemoryCryptoEngine: * source

Class for using the memory crypto engine

public UnsecuredFileCryptoEngine: * source

Class for the Unsecured filestore key root

public Util: * source

Other utility functions

Private Members

private _developerKey: * source

Developer key

private _env: * source

private _globalRpcErrorCallback: * source

private _unauthenticatedClient: * source

Public Methods

public aliasExists(alias: Object): Promise source

Checks if a given alias already exists

Params:

NameTypeAttributeDescription
alias Object

alias to check

Return:

Promise

result - true if alias exists, false otherwise

public createMember(alias: Object, CryptoEngine: Class): Promise source

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

Params:

NameTypeAttributeDescription
alias Object

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

CryptoEngine Class

engine to use for key creation and storage

Return:

Promise

member - Promise of created Member

public getBanks(): Promise source

Gets a list of available banks for linking

Return:

Promise

banks - list of banks

public getMember(CryptoEngine: Class, memberId: string): Promise 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

engine to use for key creation and storage

memberId string

optional id of the member we want to log in

Return:

Promise

member - instantiated member

public notifyAddKey(alias: Object, keyName: string, key: Object, level: string, expiresMs: string): Promise source

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

Params:

NameTypeAttributeDescription
alias Object

alias to notify

keyName string

name for the new key, (e.g Chrome 53.0)

key Object

key

level string

key level

expiresMs string

when the UI will time out

Return:

Promise

NotifyStatus - status

public notifyLinkAccounts(alias: Object, bankAuthorization: string): Promise source

Notifies subscribers that accounts should be linked, and passes the bank id and payload

Params:

NameTypeAttributeDescription
alias Object

alias to notify

bankAuthorization string

bankAuthorization retrieved from bank

Return:

Promise

NotifyStatus - status

public notifyLinkAccountsAndAddKey(alias: Object, bankAuthorization: string, keyName: string, key: Object, level: string): Promise source

Notifies subscribed devices that accounts should be linked, and passes the bank id and payload

Params:

NameTypeAttributeDescription
alias Object

alias to notify

bankAuthorization string

bankAuthorization retrieved from bank

keyName string

name for the new key, (e.g Chrome 53.0)

key Object

key

level string

key level

Return:

Promise

NotifyStatus - status

public notifyPaymentRequest(tokenPayload: Object): Promise source

Sends a notification to a user to request a payment.

Params:

NameTypeAttributeDescription
tokenPayload Object

requested transfer token

Return:

Promise

NotifyStatus - status

public provisionDevice(alias: string, CryptoEngine: Class): Promise 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 string

user to provision the device for

CryptoEngine Class

engine to use for key creation and storage

Return:

Promise

deviceInfo - information about the device provisioned

public provisionDeviceLow(alias: string, CryptoEngine: Class): Promise 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 string

user to provision t he device for

CryptoEngine Class

engine to use for key creation and storage

Return:

Promise

deviceInfo - information about the device provisioned

public resolveAlias(alias: Object): Promise source

Resolve an alias to a member

Params:

NameTypeAttributeDescription
alias Object

alias to lookup

Return:

Promise

result - TokenMember protobuf object