3.5.2 • Published 2 months ago

bitski-provider v3.5.2

Weekly downloads
622
License
MIT
Repository
github
Last release
2 months ago

Bitski Provider

npm

Note: This package is for advanced users, as it lacks authentication/authorization logic. If you are looking for the simplest way to integrate Bitski into your application, checkout the full Bitski SDK.

This package includes the Bitski Web3 provider. The provider is strongly typed using eth-provider-types, and can be used with any Web3 library that supports the standard provider interface. Provider's require an Oauth clientId to be passed in, which can be created in the Bitski developer portal.

import { createBitskiProvider } from 'bitski-provider';

const provider = createBitskiProvider({
  clientId: 'your-client-id',
  signerMethod: 'popup',
});

In addition the following options can be passed:

interface BitskiProviderConfig {
  // Oauth clientId for the app, required
  clientId: string;

  // A custom fetch function. This can be useful when integrating with server
  // side javascript frameworks, or when testing.
  fetch?: typeof fetch;

  // Additional headers which should be included with RPC requests made by the
  // provider.
  additionalHeaders?: Record<string, string>;

  // The polling interval for subscriptions, in milliseconds. Defaults to 1000.
  pollingInterval?: number;

  // Whether or not the provider should cache responses from the API.
  // Defaults to true.
  disableCaching?: boolean;

  // Whether or not the provider should validate requests to the API.
  // Defaults to true.
  disableValidation?: boolean;

  // Additional parameters added to the context of a sign request, e.g. the origin
  // that is attempting to sign
  additionalSigningContext?: Record<string, unknown>;

  // The API base URL for RPC and other API requests. Defaults to
  // https://api.bitski.com
  apiBaseUrl?: string;

  // The base URL for Bitski's signer UI, used for signing transactions.
  // Defaults to https://signer.bitski.com
  signerBaseUrl: string;

  // The signer callback if the redirect flow is being used for signer.
  transactionCallbackUrl?: string;

  // A storage mechanism for storing provider state, such as current chain and
  // custom chain details.
  store?: BitskiProviderStore;

  // One of the default signer methods that are included with the provider
  signerMethod?: 'popup' | 'iframe' | 'redirect';

  // A signing function, see below for more details
  sign?: SignFn;

  // A function that provides the current user, if one exists
  getUser?(): Promise<User | undefined>;

  // A function that provides the current access token, if one exists
  getAccessToken?(): Promise<string>;

  // A function that clears the current access token, if one exists
  clearAccessToken?(): Promise<void>;
}

Sign Function

There are multiple ways to sign transactions with Bitski. The default is to use the Browser Signer function. This signer will open a popup window to the Bitski signer UI, and where users can see details about the transaction and confirm it or deny it. The result is then sent back to the original window and returned as the result of the request.

The other option that is available is to use the RPC signer.

import { createBitskiProvider, createRpcSigner } from 'bitski-provider';

const provider = createBitskiProvider({
  clientId: 'your-client-id',
  signFn: createRpcSigner(),
});

The RPC signer will send the transaction to the Bitski API and will not ask the user for confirmation. This flow requires a special access token and is typically used for programmatic wallets, not user wallets. If you want to use this flow, please contact us for more details and support.

Installation

npm install bitski-provider

Usage

import { BitskiEngine } from 'bitski-provider';

const provider = new BitskiEngine();
provider.start();
3.5.2

2 months ago

3.5.1

2 months ago

3.5.0

3 months ago

3.4.0

3 months ago

3.3.2

4 months ago

3.3.1

5 months ago

3.3.0

5 months ago

3.2.0

5 months ago

3.1.1

8 months ago

3.1.0

9 months ago

3.0.0

10 months ago

2.1.0

10 months ago

2.1.0-next.2

11 months ago

2.1.0-next.1

12 months ago

2.0.0

1 year ago

2.1.0-next.0

12 months ago

2.0.0-beta.14

1 year ago

2.0.0-beta.13

1 year ago

2.0.0-beta.11

1 year ago

2.0.0-beta.10

1 year ago

2.0.0-beta.12

1 year ago

2.0.0-beta.9

1 year ago

2.0.0-beta.8

1 year ago

2.0.0-beta.7

1 year ago

2.0.0-beta.2

1 year ago

2.0.0-beta.1

1 year ago

2.0.0-beta.0

1 year ago

2.0.0-beta.6

1 year ago

2.0.0-beta.5

1 year ago

2.0.0-beta.4

1 year ago

2.0.0-beta.3

1 year ago

1.2.0

2 years ago

1.2.0-beta.0

2 years ago

1.0.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

0.16.0

2 years ago

0.15.0

2 years ago

0.14.1

2 years ago

0.14.0

2 years ago

0.11.0

2 years ago

0.13.0

2 years ago

0.10.9

2 years ago

0.12.0

2 years ago

0.11.0-beta.5

2 years ago

0.11.0-beta.4

3 years ago

0.11.0-beta.2

3 years ago

0.11.0-beta.1

3 years ago

0.11.0-beta.0

4 years ago

0.10.8

4 years ago

0.10.6

5 years ago

0.10.5

5 years ago

0.10.4

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.1

5 years ago

0.7.0-alpha.0

5 years ago

0.6.1-alpha.4

5 years ago

0.6.1-alpha.3

5 years ago

0.6.1-alpha.2

5 years ago

0.6.1-alpha.1

5 years ago

0.6.1-alpha.0

5 years ago

0.6.0

5 years ago

0.6.0-alpha.1

5 years ago

0.6.0-alpha.0

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.0

5 years ago

0.2.0-beta.16

5 years ago

0.2.0-beta.15

5 years ago

0.2.0-beta.14

5 years ago

0.2.0-beta.13

5 years ago

0.2.0-beta.12

5 years ago

0.2.0-beta.11

5 years ago

0.2.0-beta.10

5 years ago