npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bitski-provider

v3.5.2

Published

Core Bitski provider

Downloads

2,607

Readme

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();