@affinidi-tdk/wallets-client
TypeScript icon, indicating that this package has built-in type declarations

1.33.0 • Public • Published

@affinidi-tdk/wallets-client

Service API Endpoints and Models

Please check the documentation for API Endpoints and Models for more details.

Usage

npm install @affinidi-tdk/wallets-client --save

Http Client settings

We use Axios plugin that intercepts failed requests and retries them whenever possible.

You can configure some of retry parameters:

Name Type Default Description
retries Number 3 The number of times to retry before failing. 1 = One retry after first failure. The number can be between 0 and 3.
isExponentialDelay Boolean false By default there is no delay between retries. When option is set to true (See Exponential Backoff), the client will periodically retry a failed request over an increasing amount of time.

Please note that retry condition is not configurable and axios-retry default value is used isNetworkOrIdempotentRequestError. It retries if it is a network error or a 5xx error on an idempotent request (GET, HEAD, OPTIONS, PUT or DELETE).

With project scoped token and a custom Http client settings

import { SomeClassApi, Configuration } from '@affinidi-tdk/wallets-client'

const projectScopedToken = '...' // NOTE: you can get it after making Affinidi Login (via CLI, Dev Portal)

const retryConfig = {
  retries: 2,
  isExponentialDelay: true,
}

const api = new SomeClassApi(
  new Configuration({
    apiKey: projectScopedToken,
  }),
  retryConfig,
)

await api.oneOfMethods()

With PAT

💡 To create PAT, use Affinidi CLI's create-token command.

affinidi token create-token -n MyNewToken -w -p YOUR-SECRET-PASSPHRASE

This command will return you variables to initialize AuthProvider as required below.

import { SomeClassApi, Configuration } from '@affinidi-tdk/wallets-client'
import { AuthProvider } from '@affinidi-tdk/auth-provider'

const authProvider = new AuthProvider({
  apiGatewayUrl,
  keyId,
  tokenId,
  passphrase,
  privateKey,
  projectId,
  tokenEndpoint,
})

const api = new SomeClassApi(
  new Configuration({
    apiKey: authProvider.fetchProjectScopedToken.bind(authProvider),
  }),
)

await api.oneOfMethods()

With session ID via BFF

import { SomeClassApi, Configuration } from '@affinidi-tdk/wallets-client'
import { getBffHeaders } from '@affinidi-tdk/auth-provider'

const headers = getBffHeaders(cookieName, sessionId)

const baseOptions = { headers }

const api = new SomeClassApi(
  new Configuration({ basePath: `${bffHost}/cwe`, baseOptions }),
)

await api.oneOfMethods()

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.33.03latest

Version History

VersionDownloads (Last 7 Days)Published
1.33.03
1.32.02
1.31.04
1.30.03
1.29.02
1.28.01
1.27.02
1.26.01
1.25.11
1.25.01
1.24.01
1.22.12
1.22.02
1.21.02
1.20.01
1.19.01
1.18.03
1.17.02
1.16.02
1.15.01
1.14.01
1.13.11
1.13.02
1.12.01
1.11.01
1.10.01
1.9.12
1.9.01
1.8.01
1.7.01
1.6.01
1.5.01
1.4.01
1.3.01
1.2.01
1.1.01
1.0.01

Package Sidebar

Install

npm i @affinidi-tdk/wallets-client

Weekly Downloads

56

Version

1.33.0

License

Apache-2.0

Unpacked Size

356 kB

Total Files

71

Last publish

Collaborators

  • maratsh-affinidi
  • aeffinidi
  • carlos-affinidi
  • standemchuk
  • npmafad