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

Member

Member object. Allows member-wide actions. Some calls return a promise, and some return objects

Constructor Summary

Public Constructor
public

constructor(env: string, memberId: string, cryptoEngine: Object, developerKey: string, globalRpcErrorCallback: function, loggingEnabled: bool, customSdkUrl: string)

Represents a Member

Member Summary

Private Members
private

_client: *

private

_id: *

private

Method Summary

Public Methods
public

addAddress(name: string, address: object): Promise

Creates an address for this member, and saves it

public

addAlias(alias: Object, realm: string): Promise

Adds an alias to this member

public

addAliases(aliases: Array, realm: string): Promise

Adds aliases to this member

public

Gets all of the member's aliases

public

Approves a new key for this member

public

Approves new keys for this member

public

cancelToken(token: Token): Promise

Cancels a token.

public

Clears the access token id used with this client.

public

createAccessToken(alias: Object, resources: array, realm: string): Promise

Creates a new unendorsed access token.

public

Creates a new access token builder, that must be executed.

public

createBlob(ownerId: string, type: string, name: string, data: Buffer): Object

Uploads a blob to the server.

public

createTestBankAccount(balance: double, currency: string): Array

Creates a test bank account in a fake bank

public

createTestBankAccountOauth(balance: double, currency: string): Array

Creates a test bank account in a fake bank

public

createTransferToken(lifetimeAmount: double, currency: string): TransferTokenBuilder

this method was deprecated. - use createTransferTokenBuilder instead Creates a transfer token builder, that when executed, will create a transfer token by performing an API call.
public

createTransferTokenBuilder(lifetimeAmount: double, currency: string): TransferTokenBuilder

Creates a transfer token builder, that when executed, will create a transfer token by performing an API call.

public

Deletes a member's address by id

public

Deletes the member.

public

endorseToken(token: Token): Promise

Endorses a token.

public

Gets the member's first alias

public

getAccessTokens(offset: string, limit: int): Promise

Looks up all access tokens

public

getAccount(accountId: string): Promise

Looks up a member's account by Id

public

Looks up the member's accounts

public

Looks up a existing access token where the calling member is the grantor and given member is the grantee.

public

getAddress(addressId: string): Promise

Gets the member's address

public

Gets the member's addresses

public

getBalance(accountId: string, keyLevel: string): Promise

Looks up the balance of an account

public

getBalances(accountIds: Array, keyLevel: string): Promise

Looks up the balances of an array of accounts

public

Gets the info of a bank, including a link for pairing accounts at this bank

public

getBlob(blobId: string): Object

Downloads a blob from the server.

public

Generates a blocking function to cancel a token.

public

Gets the default bank account.

public

getNotification(notificationId: string): Promise

Gets a specific notification by Id

public

getNotifications(offset: string, limit: int): Promise

Gets all notifications for this member

public

Gets a member's public profile.

public

Gets a member's public profile picture.

public

Get member's receipt contact.

public

getSubscriber(subscriberId: string): Promise

Gets a specific subscriber by Id

public

Gets all subscribers for this member

public

getTestBankNotification(subscriberId: string, notificationId: string): Object

Gets test bank notification.

public

Gets test bank notifications.

public

getToken(tokenId: string): Promise

Looks up a token by its Id

public

getTokenBlob(tokenId: string, blobId: string): Object

Downloads a blob from the server, that is attached to a token.

public

getTransaction(accountId: string, transactionId: string, keyLevel: string): Promise

Looks up a transaction

public

getTransactions(accountId: string, offset: string, limit: int, keyLevel: string): Promise

Looks up all of the member's transactions for an account

public

getTransfer(transferId: string): Promise

Looks up a transfer

public

getTransferTokens(offset: string, limit: int): Promise

Looks up all transfer tokens

public

getTransfers(tokenId: string, offset: string, limit: int): Promise

Looks up all of the member's transfers

public

Looks up if this account is default.

public

Gets the member's public keys

public

linkAccounts(authorization: string): Promise

Links bank accounts to the member

public

Gets the memberId

public

redeemToken(token: object, amount: int, currency: string, description: string, destinations: Array, refId: string): Promise

Redeems a token.

public

Removes an alias from the memberId

public

Removes aliases from the memberId

public

Removes a key from this member

public

Removes keys from this member

public

replaceAccessToken(tokenToCancel: Object, newResources: Array): Promise

Cancels the existing token and creates a replacement for it.

public

replaceAndEndorseAccessToken(tokenToCancel: Object, newResources: Array): Promise

Cancels the existing token, creates a replacement and endorses it.

public

Sets the customer initiated request flag to true.

public

Sets the member's default bank account.

public

Replaces the authenticated member's public profile.

public

setProfilePicture(type: string, data: Buffer): Promise

Uploads the authenticated member's public profile.

public

Replaces member's receipt contact.

public

signTokenRequestState(tokenRequestId: string, tokenId: string, state: string): Object

Sign with a Token signature a token request state payload.

public

storeTokenRequest(tokenRequest: Object): Promise

Stores a request for a token.

public

subscribeToNotifications(handler: string, handlerInstructions: Object): Promise

Creates a subscriber to receive notifications of member events, such as step up auth, new device requests, linking account requests, or transfer notifications

public

Triggers a balance step up notification on the user's app

public

Triggers a token step up notification on the user's app

public

Triggers a transaction step up notification on the user's app

public

unlinkAccounts(accountIds: Array): Promise

Unlinks bank accounts previously linked by the linkAccounts call.

public

Unsubscribes from notifications (removes a subscriber)

public

useAccessToken(accessTokenId: string)

Sets the access token id to be used with this client.

public

Set the "normal consumer" rule as member's recovery rule. (As of Nov 2017, this rule was: To recover, verify an alias.)

Private Methods
private

_getMember(): *

private
private

_resolveToken(token: *): *

Public Constructors

public constructor(env: string, memberId: string, cryptoEngine: Object, developerKey: string, globalRpcErrorCallback: function, loggingEnabled: bool, customSdkUrl: string) source

Represents a Member

Params:

NameTypeAttributeDescription
env string

The environment to use for this member

memberId string

The id of this memberId

cryptoEngine Object

the cryptoEngine to use for signing and key storage

developerKey string

the developer key

globalRpcErrorCallback function

callback to invoke on any cross-cutting RPC

loggingEnabled bool

enable HTTP error logging if true call error. For example: SDK version mismatch

customSdkUrl string

set to override the default sdk url

Private Members

private _client: * source

private _id: * source

private _unauthenticatedClient: * source

Public Methods

public addAddress(name: string, address: object): Promise source

Creates an address for this member, and saves it

Params:

NameTypeAttributeDescription
name string

name of the address (e.g 'Home')

address object

address

Return:

Promise

promise of AddressRecord structure

public addAlias(alias: Object, realm: string): Promise source

Adds an alias to this member

Params:

NameTypeAttributeDescription
alias Object

alias to add

realm string

(optional) realm of the alias

Return:

Promise

empty - empty promise

public addAliases(aliases: Array, realm: string): Promise source

Adds aliases to this member

Params:

NameTypeAttributeDescription
aliases Array

aliases to add

realm string

(optional) realm of the aliases

Return:

Promise

empty - empty promise

public aliases(): Promise source

Gets all of the member's aliases

Return:

Promise

aliases - member's aliases

public approveKey(key: Object): Promise source

Approves a new key for this member

Params:

NameTypeAttributeDescription
key Object

key to add

Return:

Promise

empty - empty promise

public approveKeys(keys: Array): Promise source

Approves new keys for this member

Params:

NameTypeAttributeDescription
keys Array

keys to add

Return:

Promise

empty - empty promise

public cancelToken(token: Token): Promise source

Cancels a token. (Called by the payer or the redeemer)

Params:

NameTypeAttributeDescription
token Token

token to cancel. Can also be a {string} tokenId

Return:

Promise

TokenOperationResult - cancelled token

public clearAccessToken() source

Clears the access token id used with this client.

public createAccessToken(alias: Object, resources: array, realm: string): Promise source

Creates a new unendorsed access token.

Params:

NameTypeAttributeDescription
alias Object

the alias of the grantee of the Access Token

resources array

a list of resources to give access to

realm string

(optional) realm of the alias

Return:

Promise

token - promise of a created Access Token

public createAccessTokenBuilder(): Promise source

Creates a new access token builder, that must be executed.

Return:

Promise

token - promise of a created Access Token

public createBlob(ownerId: string, type: string, name: string, data: Buffer): Object source

Uploads a blob to the server.

Params:

NameTypeAttributeDescription
ownerId string

owner of the blob

type string

MIME type

name string

name of the file

data Buffer

data in bytes

Return:

Object

attachment - attachment

public createTestBankAccount(balance: double, currency: string): Array source

Creates a test bank account in a fake bank

Params:

NameTypeAttributeDescription
balance double

balance of the account

currency string

currency of the account

Return:

Array

bank authorization to use with linkAccounts

public createTestBankAccountOauth(balance: double, currency: string): Array source

Creates a test bank account in a fake bank

Params:

NameTypeAttributeDescription
balance double

balance of the account

currency string

currency of the account

Return:

Array

bank authorization to use with linkAccounts

public createTransferToken(lifetimeAmount: double, currency: string): TransferTokenBuilder source

this method was deprecated. - use createTransferTokenBuilder instead Creates a transfer token builder, that when executed, will create a transfer token by performing an API call.

Params:

NameTypeAttributeDescription
lifetimeAmount double

amount limit on the token

currency string

3 letter currency code ('EUR', 'USD', etc)

Return:

TransferTokenBuilder

builder - builder for the token

public createTransferTokenBuilder(lifetimeAmount: double, currency: string): TransferTokenBuilder source

Creates a transfer token builder, that when executed, will create a transfer token by performing an API call.

Params:

NameTypeAttributeDescription
lifetimeAmount double

amount limit on the token

currency string

3 letter currency code ('EUR', 'USD', etc)

Return:

TransferTokenBuilder

builder - builder for the token

public deleteAddress(addressId: string): Promise source

Deletes a member's address by id

Params:

NameTypeAttributeDescription
addressId string

the address id

Return:

Promise

empty - empty promise

public deleteMember(): Object source

Deletes the member.

Return:

Object

response - response to the api call

public endorseToken(token: Token): Promise source

Endorses a token. If this SDK client doesn't have a sufficiently privileged key to endorse the token, this will return MORE_SIGNATURES_NEEDED and the system pushes a notification to the member prompting them to use a higher-privilege key.

Params:

NameTypeAttributeDescription
token Token

Transfer token to endorse. Can also be a {string} tokenId

Return:

Promise

token - Promise of endorsed transfer token

public firstAlias(): Promise source

Gets the member's first alias

Return:

Promise

alias - member's alias

public getAccessTokens(offset: string, limit: int): Promise source

Looks up all access tokens

Params:

NameTypeAttributeDescription
offset string

where to start looking

limit int

how many to look for

Return:

Promise

access tokens - returns a list of access tokens

public getAccount(accountId: string): Promise source

Looks up a member's account by Id

Params:

NameTypeAttributeDescription
accountId string

accountId

Return:

Promise

account - Promise resolving to the account

public getAccounts(): Promise source

Looks up the member's accounts

Return:

Promise

accounts - Promise resolving to the accounts

public getActiveAccessToken(toMemberId: string): Promise source

Looks up a existing access token where the calling member is the grantor and given member is the grantee.

Params:

NameTypeAttributeDescription
toMemberId string

beneficiary of the active access token

Return:

Promise

token - access token returned by the server

public getAddress(addressId: string): Promise source

Gets the member's address

Params:

NameTypeAttributeDescription
addressId string

the address id

Return:

Promise

address - AddressRecord structure

public getAddresses(): Promise source

Gets the member's addresses

Return:

Promise

addresses - list of AddressRecord structures

public getBalance(accountId: string, keyLevel: string): Promise source

Looks up the balance of an account

Params:

NameTypeAttributeDescription
accountId string

id of the account

keyLevel string

key level

Return:

Promise

balance - Promise of get balance response object

public getBalances(accountIds: Array, keyLevel: string): Promise source

Looks up the balances of an array of accounts

Params:

NameTypeAttributeDescription
accountIds Array

array of account ids

keyLevel string

key level

Return:

Promise

balance - Promise of get balances response object

public getBankInfo(bankId: string): Object source

Gets the info of a bank, including a link for pairing accounts at this bank

Params:

NameTypeAttributeDescription
bankId string

id of the bank

Return:

Object

bankInfo - info

public getBlob(blobId: string): Object source

Downloads a blob from the server.

Params:

NameTypeAttributeDescription
blobId string

id of the blob

Return:

Object

blob - downloaded blob

public getBlockingCancelTokenFunction(token: Token): Function source

Generates a blocking function to cancel a token. (Called by the payer or the redeemer)

Params:

NameTypeAttributeDescription
token Token

token to cancel. Can also be a {string} tokenId

Return:

Function

blocking function to cancel the token

public getDefaultAccount(): Promise source

Gets the default bank account.

Return:

Promise

the default bank account

public getNotification(notificationId: string): Promise source

Gets a specific notification by Id

Params:

NameTypeAttributeDescription
notificationId string

id of the notification

Return:

Promise

notification

public getNotifications(offset: string, limit: int): Promise source

Gets all notifications for this member

Params:

NameTypeAttributeDescription
offset string

where to start looking

limit int

how many to look for

Return:

Promise

notifications

public getProfile(id: string): Promise source

Gets a member's public profile.

Params:

NameTypeAttributeDescription
id string

member id whose profile to get

Return:

Promise

profile - profile

public getProfilePicture(id: string, size: Object): Object source

Gets a member's public profile picture.

Params:

NameTypeAttributeDescription
id string

member id whose picture to get

size Object

desired size category SMALL/MEDIUM/LARGE/ORIGINAL

Return:

Object

blob - downloaded blob

public getReceiptContact(): Object source

Get member's receipt contact.

Return:

Object

contact - receipt contact: value + type

public getSubscriber(subscriberId: string): Promise source

Gets a specific subscriber by Id

Params:

NameTypeAttributeDescription
subscriberId string

id of the subscriber

Return:

Promise

subscriber

public getSubscribers(): Promise source

Gets all subscribers for this member

Return:

Promise

subscribers

public getTestBankNotification(subscriberId: string, notificationId: string): Object source

Gets test bank notification.

Params:

NameTypeAttributeDescription
subscriberId string

id of subscriber

notificationId string

id of notification

Return:

Object

response - response to the API call

public getTestBankNotifications(subscriberId: string): Object source

Gets test bank notifications.

Params:

NameTypeAttributeDescription
subscriberId string

id of subscriber

Return:

Object

response - response to the API call

public getToken(tokenId: string): Promise source

Looks up a token by its Id

Params:

NameTypeAttributeDescription
tokenId string

id of the token

Return:

Promise

token - token

public getTokenBlob(tokenId: string, blobId: string): Object source

Downloads a blob from the server, that is attached to a token.

Params:

NameTypeAttributeDescription
tokenId string

id of the token

blobId string

id of the blob

Return:

Object

blob - downloaded blob

public getTransaction(accountId: string, transactionId: string, keyLevel: string): Promise source

Looks up a transaction

Params:

NameTypeAttributeDescription
accountId string

id of the account

transactionId string

which transaction to look up

keyLevel string

key level

Return:

Promise

transaction - the Transaction

public getTransactions(accountId: string, offset: string, limit: int, keyLevel: string): Promise source

Looks up all of the member's transactions for an account

Params:

NameTypeAttributeDescription
accountId string

id of the account

offset string

where to start looking

limit int

how many to retrieve

keyLevel string

key level

Return:

Promise

transactions - Transactions

public getTransfer(transferId: string): Promise source

Looks up a transfer

Params:

NameTypeAttributeDescription
transferId string

id to look up

Return:

Promise

transfer - transfer if found

public getTransferTokens(offset: string, limit: int): Promise source

Looks up all transfer tokens

Params:

NameTypeAttributeDescription
offset string

where to start looking

limit int

how many to look for

Return:

Promise

tokens - returns a list of Transfer Tokens

public getTransfers(tokenId: string, offset: string, limit: int): Promise source

Looks up all of the member's transfers

Params:

NameTypeAttributeDescription
tokenId string

token to use for lookup

offset string

where to start looking

limit int

how many to retrieve

Return:

Promise

transfers - Transfers

public isDefaultAccount(accountId: string): Promise source

Looks up if this account is default.

Params:

NameTypeAttributeDescription
accountId string

the bank account id

Return:

Promise

response - true if the account is default; false otherwise

public keys(): Promise source

Gets the member's public keys

Return:

Promise

keys - keys objects

public linkAccounts(authorization: string): Promise source

Links bank accounts to the member

Params:

NameTypeAttributeDescription
authorization string

bankAuthorization obtained from bank, or oauthBankAuthorization

Return:

Promise

accounts - Promise resolving the the Accounts linked

public memberId(): string source

Gets the memberId

Return:

string

memberId

public redeemToken(token: object, amount: int, currency: string, description: string, destinations: Array, refId: string): Promise source

Redeems a token. (Called by the payee or redeemer)

Params:

NameTypeAttributeDescription
token object

token to redeem. Can also be a {string} tokenId

amount int

amount to redeemer

currency string

currency to redeem

description string

optional transfer description

destinations Array

transfer destinations

refId string

Id that will be set on created Transfer. Token uses this to detect duplicates. Caller might use this to recognize the transfer. If param empty, transfer will have random refId.

Return:

Promise

transfer - Transfer created as a result of this redeem call

public removeAlias(alias: Object): Promise source

Removes an alias from the memberId

Params:

NameTypeAttributeDescription
alias Object

alias to remove

Return:

Promise

empty - empty promise

public removeAliases(aliases: Array): Promise source

Removes aliases from the memberId

Params:

NameTypeAttributeDescription
aliases Array

aliases to remove

Return:

Promise

empty - empty promise

public removeKey(keyId: string): Promise source

Removes a key from this member

Params:

NameTypeAttributeDescription
keyId string

keyId to remove. Note, keyId is the hash of the pk

Return:

Promise

empty - empty promise

public removeKeys(keyIds: Array): Promise source

Removes keys from this member

Params:

NameTypeAttributeDescription
keyIds Array

keyIds to remove. Note, keyId is the hash of the pk

Return:

Promise

empty - empty promise

public replaceAccessToken(tokenToCancel: Object, newResources: Array): Promise source

Cancels the existing token and creates a replacement for it.

Params:

NameTypeAttributeDescription
tokenToCancel Object

the old token to cancel

newResources Array

the new resources for this token to grant access to

Return:

Promise

operationResult - the result of the operation

public replaceAndEndorseAccessToken(tokenToCancel: Object, newResources: Array): Promise source

Cancels the existing token, creates a replacement and endorses it.

Params:

NameTypeAttributeDescription
tokenToCancel Object

the old token to cancel

newResources Array

the new resources for this token to grant access to

Return:

Promise

operationResult - the result of the operation

public setCustomerInitiated() source

Sets the customer initiated request flag to true.

public setDefaultAccount(accountId: string): Promise source

Sets the member's default bank account.

Params:

NameTypeAttributeDescription
accountId string

the bank account id

Return:

Promise

account - the account if found

public setProfile(profile: Object): Promise source

Replaces the authenticated member's public profile.

Params:

NameTypeAttributeDescription
profile Object

profile to set

Return:

Promise

profile - newly-set profile

public setProfilePicture(type: string, data: Buffer): Promise source

Uploads the authenticated member's public profile.

Params:

NameTypeAttributeDescription
type string

MIME type

data Buffer

data in bytes

Return:

Promise

empty - empty promise

public setReceiptContact(contact: Object): Promise source

Replaces member's receipt contact.

Params:

NameTypeAttributeDescription
contact Object

receipt contact to set: value + type

Return:

Promise

empty - empty promise

public signTokenRequestState(tokenRequestId: string, tokenId: string, state: string): Object source

Sign with a Token signature a token request state payload.

Params:

NameTypeAttributeDescription
tokenRequestId string

token request id

tokenId string

token id

state string

url state

Return:

Object

response - response to the api call

public storeTokenRequest(tokenRequest: Object): Promise source

Stores a request for a token. Called by a merchant or a TPP that wants access from a user.

Params:

NameTypeAttributeDescription
tokenRequest Object

token request to store

Return:

Promise

requestId - requestId

public subscribeToNotifications(handler: string, handlerInstructions: Object): Promise source

Creates a subscriber to receive notifications of member events, such as step up auth, new device requests, linking account requests, or transfer notifications

Params:

NameTypeAttributeDescription
handler string

who is handling the notifications

handlerInstructions Object

map of strings with delivery options

Return:

Promise

subscriber - Subscriber

public triggerBalanceStepUpNotification(accountIds: Array): Promise source

Triggers a balance step up notification on the user's app

Params:

NameTypeAttributeDescription
accountIds Array

array of account ids

Return:

Promise

notification status

public triggerStepUpNotification(stepUp: Object): Promise source

Triggers a token step up notification on the user's app

Params:

NameTypeAttributeDescription
stepUp Object

token step up notification payload

Return:

Promise

notification status

public triggerTransactionStepUpNotification(accountId: String, transactionId: String): Promise source

Triggers a transaction step up notification on the user's app

Params:

NameTypeAttributeDescription
accountId String

account id

transactionId String

transaction id

Return:

Promise

notification status

public unlinkAccounts(accountIds: Array): Promise source

Unlinks bank accounts previously linked by the linkAccounts call.

Params:

NameTypeAttributeDescription
accountIds Array

account ids to unlink

Return:

Promise

empty - empty promise

public unsubscribeFromNotifications(subscriberId: string): Promise source

Unsubscribes from notifications (removes a subscriber)

Params:

NameTypeAttributeDescription
subscriberId string

subscriber to remove

Return:

Promise

empty - empty promise

public useAccessToken(accessTokenId: string) source

Sets the access token id to be used with this client.

Params:

NameTypeAttributeDescription
accessTokenId string

the access token id

public useDefaultRecoveryRule(): Promise source

Set the "normal consumer" rule as member's recovery rule. (As of Nov 2017, this rule was: To recover, verify an alias.)

Return:

Promise

promise containing RecoveryRule proto buffer.

Private Methods

private _getMember(): * source

Return:

*

private _getPreviousHash(): * source

Return:

*

private _resolveToken(token: *): * source

Params:

NameTypeAttributeDescription
token *

Return:

*