Home Reference Source Test
import AuthHttpClient from 'token-io/src/http/AuthHttpClient.js'
public class | source

AuthHttpClient

Client for making authenticated requests to the Token gateway.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Initializes the client for the environment, memberId, and CryptoEngine.

Member Summary

Private Members
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public

async addAddress(name: string, address: Object): Object

Adds an address to the member.

public

async addAlias(prevHash: string, alias: Object): Object

Adds an alias to the member.

public

async addAliases(prevHash: string, aliases: Array): Object

Adds aliases to the member.

public

async addRecoveryRule(prevHash: string, rule: Object): Object

Set member's recovery rule.

public

async addTrustedBeneficiary(memberId: string): Object

Adds a Token member to this member's list of trusted beneficiaries.

public

async approveKey(prevHash: string, key: Object): Object

Adds a key to the member.

public

async approveKeys(prevHash: string, keys: Array): Object

Adds keys to the member.

public

async cancelToken(token: Object, blocking: bool): Object

Cancels a token.

public
this method was deprecated.

Clears the AuthContext, so this client no longer acts on behalf of another member.

public

Clears the security metadata.

public

async createAccessToken(payload: Object, tokenRequestId: string): Object

Creates an access token.

public

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

Uploads a blob to the server.

public

async createCustomization(logo: Object, colors: Object, consentText: string, name: string, appName: string): Promise

Creates customization.

public

async createTestBankAccount(balance: Number, currency: string): Object

Creates a test bank account.

public

async createTransferToken(payload: Object, tokenRequestId: string): Object

Creates a transfer token.

public

async deleteAddress(addressId: string): Object

Deletes an address.

public

async deleteMember(): Object

Deletes the member.

public

async endorseToken(token: Object): Object

Endorses a token.

public

async getAccount(accountId: string): Object

Gets an account.

public

async getAccounts(): Object

Gets all accounts linked to the member.

public

async getActiveAccessToken(toMemberId: string): Object

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

public

async getAddress(addressId: string): Object

Gets an address by id.

public

async getAddresses(): Object

Gets all addresses.

public

async getAliases(): Object

Gets logged-in member's aliases, verified or not.

public

async getBalance(accountId: string, keyLevel: string): Object

Gets the balance of an account.

public

async getBalances(accountIds: Array, keyLevel: string): Object

Gets the balances of an array of accounts.

public

async getBankInfo(bankId: string): Object

Gets info about a bank.

public

async getBlob(blobId: string): Object

Gets a blob from the server.

public

Gets the default bank account.

public

Get default recovery agent.

public

async getNotification(notificationId: string): Object

Gets a notification by id.

public

async getNotifications(offset: string, limit: Number): Object

Gets all notifications.

public

async getProfile(id: string): Object

Gets a member's public profile.

public

async getProfilePicture(id: string, size: Object): Object

Gets a member's public profile picture.

public

Gets member's receipt contact.

public

Returns the security metadata.

public

async getSigner(level: string): Promise

Creates the necessary signer objects, based on the level requested.

public

async getSubscriber(subscriberId: string): Object

Gets a subscriber by id.

public

Gets all subscribers for a member.

public

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

Gets test bank notification.

public

async getTestBankNotifications(subscriberId: string): Object

Gets test bank notifications.

public

async getToken(tokenId: string): Object

Gets a token by its id.

public

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

Gets a blob that is a attached to a token.

public

async getTokens(type: string, offset: string, limit: Number): Object

Gets all tokens of the member, of a certain type.

public

async getTransaction(accountId: string, transactionId: string, keyLevel: string): Object

Gets a transaction for an account, by its id.

public

async getTransactions(accountId: string, offset: string, limit: Number, keyLevel: string): Object

Gets all transactions for an account.

public

async getTransfer(transferId: string): Object

Gets a transfer by id.

public

async getTransfers(tokenId: string, offset: string, limit: Number): Object

Gets all transfers on a token.

public

Get the member's list of trusted beneficiaries.

public

async linkAccounts(bankAuthorization: Object): Object

this method was deprecated. - use linkAccountsOauth

Links accounts to the member.

public

async linkAccountsOauth(authorization: string): Object

Links accounts to the member.

public

async redeemToken(transferToken: Object, amount: Number, currency: string, description: string, destinations: Array, refId: string): Object

Redeems a transfer token.

public

async removeAlias(prevHash: string, alias: Object): Object

Removes an alias from the member.

public

async removeAliases(prevHash: string, aliases: Array): Object

Removes aliases from the member.

public

async removeKey(prevHash: string, keyId: string): Object

Removes a key from the member.

public

async removeKeys(prevHash: string, keyIds: Array): Object

Removes keys from the member.

public

Removes a Token member from this member's list of trusted beneficiaries.

public

async replaceAndEndorseToken(tokenToCancel: Object, newResources: Array): Object

this method was deprecated. use replaceAccessToken and endorseToken instead Replaces an access token with one with updated resources, and endorses it.
public

async replaceToken(tokenToCancel: Object, newResources: Array): Object

Replaces an access token with one with updated resources.

public

Resolves transfer destinations for the given account ID.

public

async setAccountName(accountId: string, name: string): Object

Sets the name of an account.

public

Sets the customer initiated request flag to true.

public

async setDefaultAccount(accountId: string): Promise

Sets the member's default bank account.

public

async setProfile(profile: Object): Object

Replaces the authenticated member's public profile.

public

async setProfilePicture(type: string, data: Buffer): Object

Uploads member's public profile picture.

public

async setReceiptContact(contact: Object): Object

Replaces member's receipt contact.

public

setSecurityMetadata(securityMetadata: object)

Sets the security metadata to be sent with each request.

public

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

Sign with a Token signature a token request state payload.

public

async storeTokenRequest(tokenRequest: Object): Promise

Stores a request for a token.

public

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

Subscribes to push notifications.

public

Trigger a balance step up notification.

public

Trigger a token step up notification.

public

async triggerTransactionStepUpNotification(accountId: string, transactionId: string): Object

Trigger a transaction step up notification.

public

async unlinkAccounts(accountIds: Array): Object

Unlinks bank accounts previously linked by the linkAccounts call.

public

Unsubscribes from notifications (deletes a subscriber).

public

useAccessToken(accessTokenId: string)

Use the given access token.

public

useKeyLevel(keyLevel: string)

Use the given key level to sign the request.

public

async verifyAffiliate(memberId: string): Object

Verifies an affiliated TPP.

Private Methods
private

async _memberUpdate(update: *, prevHash: *, metadata: *): *

private
private

async _tokenOperation(token: *, operation: *, suffix: *, blocking: *): *

private

async _tokenOperationRequest(token: *, suffix: *): {"tokenId": *, "signature": *}

private

async _tokenOperationSignature(tokenPayload: *, suffix: *): {"memberId": *, "keyId": *, "signature": *}

Public Constructors

public constructor(options: Object) source

Initializes the client for the environment, memberId, and CryptoEngine. Sets up signers using the CryptoEngine, for Low, Standard, and Privileged keys, which will be used to sign appropriate requests.

Params:

NameTypeAttributeDescription
options Object

Private Members

private _authHeader: * source

private _context: * source

private _cryptoEngine: * source

private _developerKey: * source

private _instance: * source

private _interceptor: * source

private _memberId: * source

private _securityMetadata: * source

Public Methods

public async addAddress(name: string, address: Object): Object source

Adds an address to the member.

Params:

NameTypeAttributeDescription
name string

name of the address

address Object

address to add

Return:

Object

response to the API call

public async addAlias(prevHash: string, alias: Object): Object source

Adds an alias to the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

alias Object

alias to add

Return:

Object

response to the API call

public async addAliases(prevHash: string, aliases: Array): Object source

Adds aliases to the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

aliases Array

aliases to add

Return:

Object

response to the API call

public async addRecoveryRule(prevHash: string, rule: Object): Object source

Set member's recovery rule.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

rule Object

RecoveryRule proto buffer specifying behavior.

Return:

Object

UpdateMemberResponse proto buffer

public async addTrustedBeneficiary(memberId: string): Object source

Adds a Token member to this member's list of trusted beneficiaries.

Params:

NameTypeAttributeDescription
memberId string

member ID of the trusted beneficiary to add

Return:

Object

response to the API call

public async approveKey(prevHash: string, key: Object): Object source

Adds a key to the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

key Object

key to add

Return:

Object

response to the API call

public async approveKeys(prevHash: string, keys: Array): Object source

Adds keys to the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

keys Array

keys to add

Return:

Object

response to the API call

public async cancelToken(token: Object, blocking: bool): Object source

Cancels a token.

Params:

NameTypeAttributeDescription
token Object

token to cancel

blocking bool

creates a blocking request

Return:

Object

response to the API call

public clearAccessToken() source

this method was deprecated.

Clears the AuthContext, so this client no longer acts on behalf of another member.

public clearSecurityMetadata() source

Clears the security metadata.

public async createAccessToken(payload: Object, tokenRequestId: string): Object source

Creates an access token.

Params:

NameTypeAttributeDescription
payload Object

access token payload

tokenRequestId string

token request id

Return:

Object

response to the API call

public async 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

response to the API call

public async createCustomization(logo: Object, colors: Object, consentText: string, name: string, appName: string): Promise source

Creates customization.

Params:

NameTypeAttributeDescription
logo Object

logo

colors Object

colors map of ARGB colors #AARRGGBB

consentText string

consent text

name string

display name

appName string

corresponding app name

Return:

Promise

response to the API call

public async createTestBankAccount(balance: Number, currency: string): Object source

Creates a test bank account.

Params:

NameTypeAttributeDescription
balance Number

balance to put in the account

currency string

currency in the account

Return:

Object

response to the API call

public async createTransferToken(payload: Object, tokenRequestId: string): Object source

Creates a transfer token.

Params:

NameTypeAttributeDescription
payload Object

payload of the token

tokenRequestId string

token request id

Return:

Object

response to the API call

public async deleteAddress(addressId: string): Object source

Deletes an address.

Params:

NameTypeAttributeDescription
addressId string

address to delete

Return:

Object

response to the API call

public async deleteMember(): Object source

Deletes the member.

Return:

Object

response to the api call

public async endorseToken(token: Object): Object source

Endorses a token.

Params:

NameTypeAttributeDescription
token Object

token to endorse

Return:

Object

response to the API call

public async getAccount(accountId: string): Object source

Gets an account.

Params:

NameTypeAttributeDescription
accountId string

account to get

Return:

Object

response to the API call

public async getAccounts(): Object source

Gets all accounts linked to the member.

Return:

Object

response to the API call

public async getActiveAccessToken(toMemberId: string): Object 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:

Object

response to the API call

public async getAddress(addressId: string): Object source

Gets an address by id.

Params:

NameTypeAttributeDescription
addressId string

address to get

Return:

Object

response to the API call

public async getAddresses(): Object source

Gets all addresses.

Return:

Object

response to the API call

public async getAliases(): Object source

Gets logged-in member's aliases, verified or not.

Return:

Object

response object; has aliases, unverifiedAliases

public async getBalance(accountId: string, keyLevel: string): Object source

Gets the balance of an account.

Params:

NameTypeAttributeDescription
accountId string

accountId

keyLevel string

key level

Return:

Object

response to the API call

public async getBalances(accountIds: Array, keyLevel: string): Object source

Gets the balances of an array of accounts.

Params:

NameTypeAttributeDescription
accountIds Array

array of accountIds

keyLevel string

key level

Return:

Object

response to the API call

public async getBankInfo(bankId: string): Object source

Gets info about a bank.

Params:

NameTypeAttributeDescription
bankId string

id of the bank to lookup

Return:

Object

response to the API call

public async getBlob(blobId: string): Object source

Gets a blob from the server.

Params:

NameTypeAttributeDescription
blobId string

id of the blob

Return:

Object

response to the API call

public async getDefaultAccount(): Promise source

Gets the default bank account.

Return:

Promise

the default bank account

public async getDefaultRecoveryAgent(): Object source

Get default recovery agent.

Return:

Object

GetDefaultAgentResponse proto buffer

public async getNotification(notificationId: string): Object source

Gets a notification by id.

Params:

NameTypeAttributeDescription
notificationId string

Id of the notification to get

Return:

Object

response to the API call

public async getNotifications(offset: string, limit: Number): Object source

Gets all notifications.

Params:

NameTypeAttributeDescription
offset string

where to start looking

limit Number

how many to get

Return:

Object

response to the API call

public async getProfile(id: string): Object source

Gets a member's public profile.

Params:

NameTypeAttributeDescription
id string

member id whose profile to get

Return:

Object

response to the API call

public async 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

response to the API call

public async getReceiptContact(): Object source

Gets member's receipt contact.

Return:

Object

response to the API call

public getSecurityMetadata(): object source

Returns the security metadata.

Return:

object

security metadata

public async getSigner(level: string): Promise source

Creates the necessary signer objects, based on the level requested. If the level is not available, attempts to fetch a lower level.

Params:

NameTypeAttributeDescription
level string

requested level of key

Return:

Promise

object used to sign

public async getSubscriber(subscriberId: string): Object source

Gets a subscriber by id.

Params:

NameTypeAttributeDescription
subscriberId string

Id of the subscriber to get

Return:

Object

response to the API call

public async getSubscribers(): Object source

Gets all subscribers for a member.

Return:

Object

response to the API call

public async 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 to the API call

public async getTestBankNotifications(subscriberId: string): Object source

Gets test bank notifications.

Params:

NameTypeAttributeDescription
subscriberId string

id of subscriber

Return:

Object

response to the API call

public async getToken(tokenId: string): Object source

Gets a token by its id.

Params:

NameTypeAttributeDescription
tokenId string

id of the token to get

Return:

Object

response to the API call

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

Gets a blob that is a attached to a token.

Params:

NameTypeAttributeDescription
tokenId string

id of the token

blobId string

id of the blob

Return:

Object

response to the API call

public async getTokens(type: string, offset: string, limit: Number): Object source

Gets all tokens of the member, of a certain type.

Params:

NameTypeAttributeDescription
type string

type of tokens to get

offset string

where to start looking

limit Number

how many to get

Return:

Object

response to the API call

public async getTransaction(accountId: string, transactionId: string, keyLevel: string): Object source

Gets a transaction for an account, by its id.

Params:

NameTypeAttributeDescription
accountId string

account that initiated the transaction

transactionId string

id of the transaction

keyLevel string

key level

Return:

Object

response to the API call

public async getTransactions(accountId: string, offset: string, limit: Number, keyLevel: string): Object source

Gets all transactions for an account.

Params:

NameTypeAttributeDescription
accountId string

id of the account

offset string

where to start

limit Number

how many to get

keyLevel string

key level

Return:

Object

response to the API call

public async getTransfer(transferId: string): Object source

Gets a transfer by id.

Params:

NameTypeAttributeDescription
transferId string

id of the transfer

Return:

Object

response to the API call

public async getTransfers(tokenId: string, offset: string, limit: Number): Object source

Gets all transfers on a token.

Params:

NameTypeAttributeDescription
tokenId string

id of the token

offset string

where to start

limit Number

how many to get

Return:

Object

response to the API call

public async getTrustedBeneficiaries(): Object source

Get the member's list of trusted beneficiaries.

Return:

Object

response to the API call

public async linkAccounts(bankAuthorization: Object): Object source

this method was deprecated. - use linkAccountsOauth

Links accounts to the member.

Params:

NameTypeAttributeDescription
bankAuthorization Object

encrypted authorization to accounts

Return:

Object

response to the API call

public async linkAccountsOauth(authorization: string): Object source

Links accounts to the member.

Params:

NameTypeAttributeDescription
authorization string

oauthBankAuthorization continaing bank_id and access_token

Return:

Object

response to the API call

public async redeemToken(transferToken: Object, amount: Number, currency: string, description: string, destinations: Array, refId: string): Object source

Redeems a transfer token.

Params:

NameTypeAttributeDescription
transferToken Object

token to redeem

amount Number

amount to charge

currency string

currency to charge

description string

description of the transfer

destinations Array

destinations money should go to

refId string

reference Id to attach to the transfer

Return:

Object

response to the API call

public async removeAlias(prevHash: string, alias: Object): Object source

Removes an alias from the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

alias Object

alias to remove

Return:

Object

response to the API call

public async removeAliases(prevHash: string, aliases: Array): Object source

Removes aliases from the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

aliases Array

aliases to remove

Return:

Object

response to the API call

public async removeKey(prevHash: string, keyId: string): Object source

Removes a key from the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

keyId string

keyId to remove

Return:

Object

response to the API call

public async removeKeys(prevHash: string, keyIds: Array): Object source

Removes keys from the member.

Params:

NameTypeAttributeDescription
prevHash string

hash of the previous directory entry.

keyIds Array

keys to remove

Return:

Object

response to the API call

public async removeTrustedBeneficiary(memberId: string): Object source

Removes a Token member from this member's list of trusted beneficiaries.

Params:

NameTypeAttributeDescription
memberId string

member ID of the trusted beneficiary to remove

Return:

Object

response of the API

public async replaceAndEndorseToken(tokenToCancel: Object, newResources: Array): Object source

this method was deprecated. use replaceAccessToken and endorseToken instead Replaces an access token with one with updated resources, and endorses it.

Params:

NameTypeAttributeDescription
tokenToCancel Object

access token to replace

newResources Array

new resources

Return:

Object

response to the API call

public async replaceToken(tokenToCancel: Object, newResources: Array): Object source

Replaces an access token with one with updated resources.

Params:

NameTypeAttributeDescription
tokenToCancel Object

access token to replace

newResources Array

new resources

Return:

Object

response to the API call

public async resolveTransferDestinations(accountId: string): Object source

Resolves transfer destinations for the given account ID.

Params:

NameTypeAttributeDescription
accountId string

id of account to resolve destinations for

Return:

Object

api response

public async setAccountName(accountId: string, name: string): Object source

Sets the name of an account.

Params:

NameTypeAttributeDescription
accountId string

account

name string

new name

Return:

Object

response to the API call

public setCustomerInitiated() source

Sets the customer initiated request flag to true.

public async setDefaultAccount(accountId: string): Promise source

Sets the member's default bank account.

Params:

NameTypeAttributeDescription
accountId string

the bank account id

Return:

Promise

a promise

public async setProfile(profile: Object): Object source

Replaces the authenticated member's public profile.

Params:

NameTypeAttributeDescription
profile Object

profile to set

Return:

Object

response to the API call

public async setProfilePicture(type: string, data: Buffer): Object source

Uploads member's public profile picture.

Params:

NameTypeAttributeDescription
type string

MIME type

data Buffer

data in bytes

Return:

Object

response to the API call

public async setReceiptContact(contact: Object): Object source

Replaces member's receipt contact.

Params:

NameTypeAttributeDescription
contact Object

receipt contact to set: value + type

Return:

Object

response to the API call

public setSecurityMetadata(securityMetadata: object) source

Sets the security metadata to be sent with each request.

Params:

NameTypeAttributeDescription
securityMetadata object

security metadata

public async 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 to the api call

public async 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

response to the API call

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

Subscribes to push notifications.

Params:

NameTypeAttributeDescription
handler string

who is handling the notifications

handlerInstructions string

how to send the notification

Return:

Object

response to the API call

public async triggerBalanceStepUpNotification(accountIds: Array): Object source

Trigger a balance step up notification.

Params:

NameTypeAttributeDescription
accountIds Array

array of account ids

Return:

Object

response to the Api call

public async triggerStepUpNotification(tokenId: string): Object source

Trigger a token step up notification.

Params:

NameTypeAttributeDescription
tokenId string

token ID

Return:

Object

response to the Api call

public async triggerTransactionStepUpNotification(accountId: string, transactionId: string): Object source

Trigger a transaction step up notification.

Params:

NameTypeAttributeDescription
accountId string

account id

transactionId string

transaction id

Return:

Object

response to the Api call

public async unlinkAccounts(accountIds: Array): Object source

Unlinks bank accounts previously linked by the linkAccounts call.

Params:

NameTypeAttributeDescription
accountIds Array

account ids to unlink

Return:

Object

response to the API call

public async unsubscribeFromNotifications(subscriberId: string): Object source

Unsubscribes from notifications (deletes a subscriber).

Params:

NameTypeAttributeDescription
subscriberId string

subscriber to delete

Return:

Object

response to the API call

public useAccessToken(accessTokenId: string) source

Use the given access token. (Act on behalf of this member).

Params:

NameTypeAttributeDescription
accessTokenId string

Id of the access token

public useKeyLevel(keyLevel: string) source

Use the given key level to sign the request.

Params:

NameTypeAttributeDescription
keyLevel string

key level

public async verifyAffiliate(memberId: string): Object source

Verifies an affiliated TPP.

Params:

NameTypeAttributeDescription
memberId string

id of the member to verify

Return:

Object

response to the api call

Private Methods

private async _memberUpdate(update: *, prevHash: *, metadata: *): * source

Params:

NameTypeAttributeDescription
update *
prevHash *
metadata *

Return:

*

private _resetRequestInterceptor() source

private async _tokenOperation(token: *, operation: *, suffix: *, blocking: *): * source

Params:

NameTypeAttributeDescription
token *
operation *
suffix *
blocking *

Return:

*

private async _tokenOperationRequest(token: *, suffix: *): {"tokenId": *, "signature": *} source

Params:

NameTypeAttributeDescription
token *
suffix *

Return:

{"tokenId": *, "signature": *}

private async _tokenOperationSignature(tokenPayload: *, suffix: *): {"memberId": *, "keyId": *, "signature": *} source

Params:

NameTypeAttributeDescription
tokenPayload *
suffix *

Return:

{"memberId": *, "keyId": *, "signature": *}