1.28.0 • Published 12 months ago

@affinidi-tdk/wallets-client v1.28.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 months ago

@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:

NameTypeDefaultDescription
retriesNumber3The number of times to retry before failing. 1 = One retry after first failure. The number can be between 0 and 3.
isExponentialDelayBooleanfalseBy 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()
1.21.0

1 year ago

1.22.0

1 year ago

1.25.0

12 months ago

1.26.0

12 months ago

1.25.1

12 months ago

1.22.1

1 year ago

1.24.0

12 months ago

1.27.0

12 months ago

1.28.0

12 months ago

1.20.0

1 year ago

1.19.0

1 year ago

1.18.0

1 year ago

1.17.0

1 year ago

1.16.0

1 year ago

1.15.0

1 year ago

1.14.0

1 year ago

1.13.1

1 year ago

1.13.0

1 year ago

1.12.0

1 year ago

1.11.0

1 year ago

1.10.0

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago