Bitski Provider
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',
});
In addition the following options can be passed:
interface BitskiProviderConfig {
clientId: string;
fetch?: typeof fetch;
additionalHeaders?: Record<string, string>;
pollingInterval?: number;
disableCaching?: boolean;
disableValidation?: boolean;
additionalSigningContext?: Record<string, string>;
apiBaseUrl?: string;
signerBaseUrl: string;
transactionCallbackUrl?: string;
store?: BitskiProviderStore;
sign?: SignFn;
getUser?(): Promise<User | undefined>;
getAccessToken?(): Promise<string>;
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();