Home Reference Source
import {AuthHttpClient} from '@token-io/core/src/http/AuthHttpClient.js'
public class | source

AuthHttpClient

Client for making authenticated requests to the Token gateway.

Constructor Summary

Public Constructor
public

constructor(undefined: *)

Member Summary

Private Members
private
private
private
private
private
private
private
private

Method Summary

Public Methods
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 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

Clears the security metadata.

public

async confirmFunds(accountId: string, amount: string, currency: string): boolean

Confirms if an account has sufficient funds for a purchase.

public

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

Creates a test bank account.

public

async deleteMember(): Object

Deletes the member.

public

async getAccount(accountId: string): Object

Gets an account.

public

async getAccounts(): Object

Gets all accounts linked to the member.

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

Get default recovery agent.

public

Returns the security metadata.

public

async getSigner(level: string): Promise

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

public

async getStandingOrder(accountId: string, standingOrderId: string, keyLevel: string): *

Gets information about a particular standing order.

public

async getStandingOrders(accountId: string, offset: string, limit: int, keyLevel: string): *

Gets information about several standing orders.

public

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

Gets test bank notification.

public

async getTestBankNotifications(subscriberId: string): Object

Gets test bank notifications.

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 linkAccountsOauth(authorization: string): Object

Links accounts to the member.

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

Resolves transfer destinations for the given account ID.

public

setSecurityMetadata(securityMetadata: object)

Sets the security metadata to be sent with each request.

public

async tokenOperationSignature(tokenPayload: Object, suffix: string, keyLevel: KeyLevel): Object

Signs a token payload with given key level and action.

public

useKeyLevel(keyLevel: string)

Use the given key level to sign the request.

Private Methods
private

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

private

Public Constructors

public constructor(undefined: *) source

Params:

NameTypeAttributeDescription
undefined *

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 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 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 clearSecurityMetadata() source

Clears the security metadata.

public async confirmFunds(accountId: string, amount: string, currency: string): boolean source

Confirms if an account has sufficient funds for a purchase.

Params:

NameTypeAttributeDescription
accountId string
amount string
currency string

Return:

boolean

true if account has sufficient funds

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 deleteMember(): Object source

Deletes the member.

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 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 getDefaultRecoveryAgent(): Object source

Get default recovery agent.

Return:

Object

GetDefaultAgentResponse proto buffer

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 getStandingOrder(accountId: string, standingOrderId: string, keyLevel: string): * source

Gets information about a particular standing order.

Params:

NameTypeAttributeDescription
accountId string
standingOrderId string
keyLevel string

Return:

*

public async getStandingOrders(accountId: string, offset: string, limit: int, keyLevel: string): * source

Gets information about several standing orders.

Params:

NameTypeAttributeDescription
accountId string
offset string
limit int
keyLevel string

Return:

*

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 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 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 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 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 setSecurityMetadata(securityMetadata: object) source

Sets the security metadata to be sent with each request.

Params:

NameTypeAttributeDescription
securityMetadata object

security metadata

public async tokenOperationSignature(tokenPayload: Object, suffix: string, keyLevel: KeyLevel): Object source

Signs a token payload with given key level and action.

Params:

NameTypeAttributeDescription
tokenPayload Object
suffix string
keyLevel KeyLevel

Return:

Object

token proto signature object

public useKeyLevel(keyLevel: string) source

Use the given key level to sign the request.

Params:

NameTypeAttributeDescription
keyLevel string

key level

Private Methods

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

Params:

NameTypeAttributeDescription
update *
prevHash *
metadata *

Return:

*

private _resetRequestInterceptor() source