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

AuthHttpClient

Extends:

@token-io/core~CoreAuthHttpClient → AuthHttpClient

Client for making authenticated requests to the Token gateway.

Constructor Summary

Public Constructor
public

constructor(options: *)

Method Summary

Public Methods
public

async cancelToken(token: Object): Object

Cancels a token.

public

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

Creates customization.

public

async getBlob(blobId: string): Object

Gets a blob from the server.

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

async getToken(tokenId: string): Object

Gets a token by its ID.

public

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

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

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

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

Redeems a transfer token.

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 storeTokenRequest(tokenRequest: Object): Promise

Stores a request for a token.

public

useAccessToken(accessTokenId: string, customerInitiated: boolean)

Uses the given access token.

Private Methods
private

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

private

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

private

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

Public Constructors

public constructor(options: *) source

Params:

NameTypeAttributeDescription
options *

Public Methods

public async cancelToken(token: Object): Object source

Cancels a token.

Params:

NameTypeAttributeDescription
token Object

token to cancel

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 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 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 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 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 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 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 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 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 useAccessToken(accessTokenId: string, customerInitiated: boolean) source

Uses the given access token.

Params:

NameTypeAttributeDescription
accessTokenId string

Id of the access token

customerInitiated boolean

whether the user initiated this session / request

Private Methods

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

Params:

NameTypeAttributeDescription
token *
operation *
suffix *

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": *}