Bitski.js

Index

External modules


Bitski JS

This is our browser SDK package.

AuthenticationErrorCode

InvalidConfiguration

var InvalidConfiguration:  = 1005

Defined in browser/src/errors/authentication-error.ts:14

NoRefreshToken

var NoRefreshToken:  = 1002

Defined in browser/src/errors/authentication-error.ts:8

NotSignedIn

var NotSignedIn:  = 1000

Defined in browser/src/errors/authentication-error.ts:4

PopupBlocked

var PopupBlocked:  = 1006

Defined in browser/src/errors/authentication-error.ts:16

ServerError

var ServerError:  = 1004

Defined in browser/src/errors/authentication-error.ts:12

UnsupportedAuthenticationMethod

var UnsupportedAuthenticationMethod:  = 1003

Defined in browser/src/errors/authentication-error.ts:10

UserCancelled

var UserCancelled:  = 1001

Defined in browser/src/errors/authentication-error.ts:6

AuthenticationStatus

Connected

var Connected:  = "CONNECTED"

Defined in browser/src/bitski.ts:19

Expired

var Expired:  = "EXPIRED"

Defined in browser/src/bitski.ts:20

NotConnected

var NotConnected:  = "NOT_CONNECTED"

Defined in browser/src/bitski.ts:21

ConnectButtonSize

Sizing options for the Bitski connect button.

Large

var Large:  = "LARGE"

Defined in browser/src/components/connect-button.ts:11

Medium

var Medium:  = "MEDIUM"

Defined in browser/src/components/connect-button.ts:10

Small

var Small:  = "SMALL"

Defined in browser/src/components/connect-button.ts:9

OAuthSignInMethod

var Popup:  = "POPUP"

Defined in browser/src/bitski.ts:14

Redirect

var Redirect:  = "REDIRECT"

Defined in browser/src/bitski.ts:13

Silent

var Silent:  = "SILENT"

Defined in browser/src/bitski.ts:15

ParseErrorCode

InvalidJSON

var InvalidJSON:  = 2000

Defined in browser/src/errors/parse-error.ts:4

NoErrorBody

var NoErrorBody:  = 2001

Defined in browser/src/errors/parse-error.ts:7

SignerErrorCode

MissingFrom

var MissingFrom:  = 3004

Defined in browser/src/errors/signer-error.ts:14

MissingMessage

var MissingMessage:  = 3003

Defined in browser/src/errors/signer-error.ts:12

MissingTransaction

var MissingTransaction:  = 3002

Defined in browser/src/errors/signer-error.ts:9

MissingTypedData

var MissingTypedData:  = 3005

Defined in browser/src/errors/signer-error.ts:17

UnsupportedMethod

var UnsupportedMethod:  = 3000

Defined in browser/src/errors/signer-error.ts:4

UserCancelled

var UserCancelled:  = 3001

Defined in browser/src/errors/signer-error.ts:6

TransactionKind

SendTransaction

var SendTransaction:  = "ETH_SEND_TRANSACTION"

Defined in browser/src/subproviders/signature.ts:12

Sign

var Sign:  = "ETH_SIGN"

Defined in browser/src/subproviders/signature.ts:14

SignTransaction

var SignTransaction:  = "ETH_SIGN_TRANSACTION"

Defined in browser/src/subproviders/signature.ts:13

SignTypedData

var SignTypedData:  = "ETH_SIGN_TYPED_DATA"

Defined in browser/src/subproviders/signature.ts:15

AccessToken

Represents a Bitski access token

constructor

new AccessToken(token: string, expiresAt?: undefined | number, scope?: undefined | string): AccessToken
Parameters
Param Type Description
token string the access token
expiresAt (Optional) undefined ⎮number the token expiration date (in seconds) (optional)
scope (Optional) undefined ⎮string the scopes this token represents (optional)
Return Value

AccessToken


Properties

expiresAt

When the token expires (in seconds)

var expiresAt: undefined | number

Defined in browser/src/auth/access-token.ts:44

scope

Scopes this token has access to

var scope: undefined | string

Defined in browser/src/auth/access-token.ts:49

token

The actual access token

var token: string

Defined in browser/src/auth/access-token.ts:39


expired

Calculates if the token is still active

getexpired(): boolean

Return Value

boolean


Methods

toStorageString

Returns a JSON string suitable for writing in local storage

Declaration
function toStorageString(): string

Defined in browser/src/auth/access-token.ts:78

Return Value

string

fromString

Creates a token from a storage string

Declaration
function fromString(s: string): AccessToken | undefined

Defined in browser/src/auth/access-token.ts:23

Parameters
Param Type Description
s string JSON string representing the token
Return Value

AccessToken ⎮undefined

fromTokenResponse

Creates a token from a TokenResponse object

Declaration
function fromTokenResponse(tokenResponse: TokenResponse): AccessToken

Defined in browser/src/auth/access-token.ts:11

Parameters
Param Type Description
tokenResponse TokenResponse The token response object to build a token from
Return Value

AccessToken



AuthenticatedCacheSubprovider

constructor

new AuthenticatedCacheSubprovider(authProvider: AuthProvider): AuthenticatedCacheSubprovider
Parameters
Param Type Description
authProvider AuthProvider -
Return Value

AuthenticatedCacheSubprovider


Properties


Methods

handleRequest

Declaration
function handleRequest(payload: any, next: any, end: any): any

Defined in browser/src/subproviders/authenticated-cache.ts:18

Parameters
Param Type Description
payload any -
next any -
end any -
Return Value

any


Relationships

Extends
  • Subprovider

AuthenticationError

Represents an error that is thrown during the authentication process

constructor

new AuthenticationError(message: string, code: AuthenticationErrorCode): AuthenticationError
Parameters
Param Type Description
message string -
code AuthenticationErrorCode -
Return Value

AuthenticationError


Properties

code

var code: AuthenticationErrorCode

Defined in browser/src/errors/authentication-error.ts:63

description

var description: undefined | string

Defined in browser/src/errors/authentication-error.ts:64

name

var name: string = "AuthenticationError"

Defined in browser/src/errors/authentication-error.ts:62

Error

var Error: ErrorConstructor

Defined in /Users/jp/Work/Bitski/bitski-js/node_modules/typescript/lib/lib.es5.d.ts:974


Methods

InvalidConfiguration

Declaration
function InvalidConfiguration(reason: string): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:58

Parameters
Param Type Description
reason string -
Return Value

AuthenticationError

NoRefreshToken

Declaration
function NoRefreshToken(): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:35

Return Value

AuthenticationError

NotSignedIn

Declaration
function NotSignedIn(): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:25

Return Value

AuthenticationError

PopupBlocked

Declaration
function PopupBlocked(baseUrl: string): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:45

Parameters
Param Type Description
baseUrl string -
Return Value

AuthenticationError

ServerError

Declaration
function ServerError(message: string, description?: undefined | string): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:51

Parameters
Param Type Description
message string -
description (Optional) undefined ⎮string -
Return Value

AuthenticationError

UnsupportedAuthenticationMethod

Declaration
function UnsupportedAuthenticationMethod(): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:40

Return Value

AuthenticationError

UserCancelled

Declaration
function UserCancelled(): AuthenticationError

Defined in browser/src/errors/authentication-error.ts:30

Return Value

AuthenticationError


Relationships

Extends
  • Error

Bitski

Bitski SDK

constructor

new Bitski(clientId: string, redirectUri?: undefined | string, additionalScopes?: string[], options?: BitskiSDKOptions): Bitski
Parameters
Param Type Description
clientId string OAuth Client ID
redirectUri (Optional) undefined ⎮string Redirect uri, defaults to the current url. This should be the location of your callback html file.
additionalScopes (Optional) string[] To use custom scopes, add them here. The default value is [‘offline’].Note: Make sure your app is approved for the scopes you are requesting first.
options (Optional) BitskiSDKOptions Other OAuth settings. Don’t change these unless you know what you are doing.
Return Value

Bitski


authStatus

Check the logged in state of the user

getauthStatus(): AuthenticationStatus

Return Value

AuthenticationStatus


Methods

addSignOutHandler

Register a callback to be called on sign out. This is a good practice, since there may be situations where you are signed out unexpectedly.

Declaration
function addSignOutHandler(fn: function)

Defined in browser/src/bitski.ts:207

Parameters
Param Type Description
fn function Your callback function

connect

Connects to bitski to get a valid access token if possible.

Declaration
function connect(): Promise<User>

Defined in browser/src/bitski.ts:168

Return Value

Promise<User>

getConnectButton

Creates a sign in with bitski button to add to your app. If an HTML element is passed in as the first parameter, it will automatically add it to the DOM inside that element. Make sure to add a callback to get notified of login events.

Declaration
function getConnectButton(options?: ConnectButtonOptions, callback?: undefined | function): ConnectButton

Defined in browser/src/bitski.ts:122

Parameters
Param Type Description
options (Optional) ConnectButtonOptions Optional configuration for the button
callback (Optional) undefined ⎮function Post-login callback. Called when sign in is complete. Not applicable for redirect login method.
Return Value

ConnectButton

getCurrentAccessToken

Retrieves the current access token for the user, if logged in.

Declaration
function getCurrentAccessToken(): Promise<string>

Defined in browser/src/bitski.ts:190

Return Value

Promise<string>

getCurrentRefreshToken

Retrieves the current refresh token for the user, if logged in. Requires that the user has approved your application for offline access.

Declaration
function getCurrentRefreshToken(): Promise<string>

Defined in browser/src/bitski.ts:198

Return Value

Promise<string>

getProvider

Returns a new web3 provider for a given network.

Declaration
function getProvider(options?: ProviderOptions | string): BitskiEngine

Defined in browser/src/bitski.ts:96

Parameters
Param Type Description
options (Optional) ProviderOptions ⎮string options for the provider, or a network name
Return Value

BitskiEngine

getUser

Gets the current signed in user. Will reject if we are not signed in.

Declaration
function getUser(): Promise<User>

Defined in browser/src/bitski.ts:161

Return Value

Promise<User>

redirectCallback

Call from your oauth redirect page.

Declaration
function redirectCallback(): Promise<User>

Defined in browser/src/bitski.ts:183

Return Value

Promise<User>

removeSignOutHandler

Remove a registered signout callback

Declaration
function removeSignOutHandler(fn: function)

Defined in browser/src/bitski.ts:215

Parameters
Param Type Description
fn function Your callback function

signIn

Starts the sign in flow. Will trigger a popup window over your app, so it must be called within a user interaction handler such as a click.

Declaration
function signIn(options?: SignInOptions): Promise<User>

Defined in browser/src/bitski.ts:154

Parameters
Param Type Description
options (Optional) SignInOptions Optionally provide additional options for the sign in request.You can use the options parameter to request that we show the sign up form instead of the sign in form:javascriptimport { LOGIN_HINT_SIGNUP } from 'bitski';await bitski.signIn({ login_hint: LOGIN_HINT_SIGNUP });
Return Value

Promise<User>

signInRedirect

Starts redirect sign in flow. This is an alternative flow to the popup that all takes place in the same browser window.

Declaration
function signInRedirect(options?: SignInOptions)

Defined in browser/src/bitski.ts:176

Parameters
Param Type Description
options (Optional) SignInOptions Optionally provide additional options for the sign in request. See signIn() for more info.

signOut

Sign the current user out of your application.

Declaration
function signOut(): Promise<void>

Defined in browser/src/bitski.ts:225

Return Value

Promise<void>

start

Signs in or connects to bitski depending on the user’s auth state. Since it may open a popup, this method must be called from user interaction handler, such as a click or tap handler.

Declaration
function start(options?: SignInOptions): Promise<User>

Defined in browser/src/bitski.ts:132

Parameters
Param Type Description
options (Optional) SignInOptions Provide SignInOptions for the sign in request. See signIn() for more info.
Return Value

Promise<User>

callback

Alternative to using our static callback.html file. Call this from your own redirect page.

Declaration
function callback()

Defined in browser/src/bitski.ts:61



BitskiBrowserEngine

constructor

new BitskiBrowserEngine(clientId: string, tokenProvider: AccessTokenProvider, sdkVersion: string, network: Network, options?: ProviderOptions): BitskiBrowserEngine
Parameters
Param Type Default value Description
clientId string - -
tokenProvider AccessTokenProvider - -
sdkVersion string - -
network Network - -
options ProviderOptions {} -
Return Value

BitskiBrowserEngine


Properties


Methods


Relationships

Extends
  • BitskiEngine

BitskiTransactionSigner

This class is responsible for signing transactions. It only knows about Bitski’s proprietary transaction objects. It is also the only class that knows about the iframe signing implementation.

constructor

new BitskiTransactionSigner(webBaseUrl: string, apiBaseUrl: string, defaultHeaders: any): BitskiTransactionSigner
Parameters
Param Type Description
webBaseUrl string -
apiBaseUrl string -
defaultHeaders any -
Return Value

BitskiTransactionSigner


Methods

sign

Declaration
function sign(transaction: Transaction, accessToken: string): Promise<string>

Defined in browser/src/signing/transaction-signer.ts:41

Parameters
Param Type Description
transaction Transaction -
accessToken string -
Return Value

Promise<string>



ConnectButton

A button used to connect to Bitski.

constructor

new ConnectButton(authProvider: AuthProvider, options?: ConnectButtonOptions, callback?: undefined | function): ConnectButton
Parameters
Param Type Description
authProvider AuthProvider An instance of an AuthProvider to process sign in requests.
options (Optional) ConnectButtonOptions Optional ConnectButtonOptions to configure your button.
callback (Optional) undefined ⎮function Optional callback to be called after successful or failed log in attempt.You can also set this directly later with the callback property.
Return Value

ConnectButton


Properties

callback

var callback: undefined | function

Defined in browser/src/components/connect-button.ts:39

element

var element: HTMLElement

Defined in browser/src/components/connect-button.ts:33

onCancel

var onCancel: undefined | function

Defined in browser/src/components/connect-button.ts:42

size

var size: ConnectButtonSize

Defined in browser/src/components/connect-button.ts:36


Methods

remove

Removes the button from the page

Declaration
function remove()

Defined in browser/src/components/connect-button.ts:83



Dialog

Basic modal dialog

constructor

new Dialog(content: HTMLElement | string, dynamicContent?: boolean): Dialog
Parameters
Param Type Default value Description
content HTMLElement ⎮string - The content (HTMLElement, selector, or text) to embed in the dialog
dynamicContent boolean false Set to true to show loading state
Return Value

Dialog


Properties

onClose

var onClose: undefined | function

Defined in browser/src/components/dialog.ts:12


Methods

close

Cancels the dialog by dismissing and triggering the close handler.

Declaration
function close()

Defined in browser/src/components/dialog.ts:69

dismiss

Dismisses the dialog without triggering the close handler.

Declaration
function dismiss()

Defined in browser/src/components/dialog.ts:60

hide

Hides the dialog, but does not remove

Declaration
function hide()

Defined in browser/src/components/dialog.ts:53

setLoading

Show or hide the loading indicator

Declaration
function setLoading(loading: boolean)

Defined in browser/src/components/dialog.ts:80

Parameters
Param Type Description
loading boolean Whether or not to display the spinner

show

Show the dialog

Declaration
function show()

Defined in browser/src/components/dialog.ts:47



NoHashQueryStringUtils

Methods

parse

Declaration
function parse(input: LocationLike, useHash?: undefined | false | true): StringMap

Defined in browser/src/utils/no-hash-query-string-utils.ts:8

Parameters
Param Type Description
input LocationLike -
useHash (Optional) undefined ⎮false ⎮true -
Return Value

StringMap


Relationships

Extends
  • BasicQueryStringUtils
    Implements
  • QueryStringUtils

OAuthManager

Responsible for submitting requests to our OAuth server.

constructor

new OAuthManager(options: OAuthManagerOptions): OAuthManager
Parameters
Param Type Description
options OAuthManagerOptions Settings object
Return Value

OAuthManager


Properties

configuration

var configuration: AuthorizationServiceConfiguration

Defined in browser/src/auth/oauth-manager.ts:44


Methods

redirectCallback

Attempt to finalize auth request from a redirect flow. Called from your redirect url once you’ve been redirected back.

Declaration
function redirectCallback(): Promise<TokenResponse>

Defined in browser/src/auth/oauth-manager.ts:112

Return Value

Promise<TokenResponse>

refreshAccessToken

Request a new access token from a previous refresh token

Declaration
function refreshAccessToken(refreshToken: string): Promise<TokenResponse>

Defined in browser/src/auth/oauth-manager.ts:137

Parameters
Param Type Description
refreshToken string The refresh token to use for authorization
Return Value

Promise<TokenResponse>

requestAccessToken

Exchange an authorization code for an access token

Declaration
function requestAccessToken(code: string): Promise<TokenResponse>

Defined in browser/src/auth/oauth-manager.ts:128

Parameters
Param Type Description
code string The authorization code to exchange
Return Value

Promise<TokenResponse>

requestSignOut

Submit a sign out request on the oauth endpoint

Declaration
function requestSignOut(accessToken: string): Promise<any>

Defined in browser/src/auth/oauth-manager.ts:146

Parameters
Param Type Description
accessToken string The access token to sign out with
Return Value

Promise<any>

requestUserInfo

Request a user’s profile from the oauth server

Declaration
function requestUserInfo(accessToken: string): Promise<UserInfoResponse>

Defined in browser/src/auth/oauth-manager.ts:163

Parameters
Param Type Description
accessToken string The access token for the user
Return Value

Promise<UserInfoResponse>

signInPopup

Trigger a popup sign in flow (the default)

Declaration
function signInPopup(opts?: SignInOptions): Promise<TokenResponse>

Defined in browser/src/auth/oauth-manager.ts:77

Parameters
Param Type Description
opts (Optional) SignInOptions -
Return Value

Promise<TokenResponse>

signInRedirect

Trigger a redirect sign in flow. Promise should never fulfill, as you will be redirected.

Declaration
function signInRedirect(opts?: SignInOptions): Promise<AuthorizationResponse>

Defined in browser/src/auth/oauth-manager.ts:94

Parameters
Param Type Description
opts (Optional) SignInOptions -
Return Value

Promise<AuthorizationResponse>



OpenidAuthProvider

constructor

new OpenidAuthProvider(clientId: string, redirectUri: string, additionalScopes?: string[], opts?: BitskiSDKOptions): OpenidAuthProvider
Parameters
Param Type Description
clientId string -
redirectUri string -
additionalScopes (Optional) string[] -
opts (Optional) BitskiSDKOptions -
Return Value

OpenidAuthProvider


Properties

oauthManager

var oauthManager: OAuthManager

Defined in browser/src/auth/openid-auth-provider.ts:12

signOutCallback

var signOutCallback: undefined | function

Defined in browser/src/auth/openid-auth-provider.ts:15

tokenStore

var tokenStore: TokenStore

Defined in browser/src/auth/openid-auth-provider.ts:13

userStore

var userStore: UserStore

Defined in browser/src/auth/openid-auth-provider.ts:14


authStatus

getauthStatus(): AuthenticationStatus

Return Value

AuthenticationStatus


Methods

connect

Declaration
function connect(): Promise<User>

Defined in browser/src/auth/openid-auth-provider.ts:109

Return Value

Promise<User>

getAccessToken

Declaration
function getAccessToken(): Promise<string>

Defined in browser/src/auth/openid-auth-provider.ts:43

Return Value

Promise<string>

getRefreshToken

Declaration
function getRefreshToken(): Promise<string>

Defined in browser/src/auth/openid-auth-provider.ts:53

Return Value

Promise<string>

getUser

Declaration
function getUser(): Promise<User>

Defined in browser/src/auth/openid-auth-provider.ts:115

Return Value

Promise<User>

invalidateToken

Declaration
function invalidateToken(): Promise<void>

Defined in browser/src/auth/openid-auth-provider.ts:65

Return Value

Promise<void>

redirectCallback

Declaration
function redirectCallback(): Promise<User>

Defined in browser/src/auth/openid-auth-provider.ts:130

Return Value

Promise<User>

refreshAccessToken

Declaration
function refreshAccessToken(): Promise<string>

Defined in browser/src/auth/openid-auth-provider.ts:75

Return Value

Promise<string>

signIn

Declaration
function signIn(method: OAuthSignInMethod, opts?: SignInOptions): Promise<User>

Defined in browser/src/auth/openid-auth-provider.ts:90

Parameters
Param Type Description
method OAuthSignInMethod -
opts (Optional) SignInOptions -
Return Value

Promise<User>

signInOrConnect

Declaration
function signInOrConnect(signInMethod?: OAuthSignInMethod, opts?: SignInOptions): Promise<User>

Defined in browser/src/auth/openid-auth-provider.ts:119

Parameters
Param Type Default value Description
signInMethod OAuthSignInMethod OAuthSignInMethod.Popup -
opts (Optional) SignInOptions - -
Return Value

Promise<User>

signOut

Declaration
function signOut(): Promise<any>

Defined in browser/src/auth/openid-auth-provider.ts:137

Return Value

Promise<any>


Relationships

Implements

ParseError

Represents an error that is thrown during decoding

constructor

new ParseError(message: string, code: ParseErrorCode): ParseError
Parameters
Param Type Description
message string -
code ParseErrorCode -
Return Value

ParseError


Properties

code

var code: ParseErrorCode

Defined in browser/src/errors/parse-error.ts:23

name

var name: string = "ParseError"

Defined in browser/src/errors/parse-error.ts:22

Error

var Error: ErrorConstructor

Defined in /Users/jp/Work/Bitski/bitski-js/node_modules/typescript/lib/lib.es5.d.ts:974


Methods

InvalidJSON

Declaration
function InvalidJSON(): ParseError

Defined in browser/src/errors/parse-error.ts:14

Return Value

ParseError

UnknownError

Declaration
function UnknownError(): ParseError

Defined in browser/src/errors/parse-error.ts:18

Return Value

ParseError


Relationships

Extends
  • Error

PopupBlockedError

constructor

new PopupBlockedError(): PopupBlockedError
Return Value

PopupBlockedError


Properties


Methods


Relationships

Extends
  • AuthorizationError

PopupClosedError

constructor

new PopupClosedError(): PopupClosedError
Return Value

PopupClosedError


Properties


Methods


Relationships

Extends
  • AuthorizationError

PopupRequestHandler

constructor

new PopupRequestHandler(utils?: BasicQueryStringUtils, crypto?: DefaultCrypto): PopupRequestHandler
Parameters
Param Type Default value Description
utils BasicQueryStringUtils new BasicQueryStringUtils() -
crypto DefaultCrypto new DefaultCrypto() -
Return Value

PopupRequestHandler


Properties


Methods

callback

Declaration
function callback(url: Location)

Defined in browser/src/auth/popup-handler.ts:72

Parameters
Param Type Description
url Location -

completeAuthorizationRequest

Declaration
function completeAuthorizationRequest(): Promise<AuthorizationRequestResponse | null>

Defined in browser/src/auth/popup-handler.ts:86

Return Value

Promise<AuthorizationRequestResponse ⎮null>

completeAuthorizationRequestIfPossible

Declaration
function completeAuthorizationRequestIfPossible(): Promise<void>

Defined in browser/src/auth/popup-handler.ts:78

Return Value

Promise<void>

performAuthorizationRequest

Declaration
function performAuthorizationRequest(configuration: AuthorizationServiceConfiguration, request: AuthorizationRequest)

Defined in browser/src/auth/popup-handler.ts:54

Parameters
Param Type Description
configuration AuthorizationServiceConfiguration -
request AuthorizationRequest -

Relationships

Extends
  • AuthorizationRequestHandler

PopupValidator

A simple utility class that will check to see if a popup is blocked. Derived from info and examples on this page: https://stackoverflow.com/questions/2914/how-can-i-detect-if-a-browser-is-blocking-a-popup

constructor

new PopupValidator(errorHandler: function): PopupValidator
Parameters
Param Type Description
errorHandler function -
Return Value

PopupValidator


Methods

check

Declaration
function check(popup: Window | null)

Defined in browser/src/utils/popup-validator.ts:17

Parameters
Param Type Description
popup Window ⎮null -


RemoteAccountSubprovider


Properties


Methods

handleRequest

Declaration
function handleRequest(payload: any, next: any, end: any)

Defined in browser/src/subproviders/remote-accounts.ts:7

Parameters
Param Type Description
payload any -
next any -
end any -

Relationships

Extends
  • AuthenticatedFetchSubprovider

SignatureSubprovider

A Subprovider that manages the interface between JSON-RPC and Bitski’s proprietary transaction signing flow. This class is responsible for transforming the JSON-RPC request into a Transaction object that the Bitski signer understands. Also responsible for submitting the transaction to the network, and converting the response back into an RPC response.

Important: this class assumes the transaction has all the necessary fields populated. The TransactionValidatorSubprovider should be placed in front of this subprovider.

constructor

new SignatureSubprovider(network: Network, signer: BitskiTransactionSigner, tokenProvider: AccessTokenProvider, signatureMethods?: string[]): SignatureSubprovider
Parameters
Param Type Description
network Network -
signer BitskiTransactionSigner -
tokenProvider AccessTokenProvider -
signatureMethods (Optional) string[] -
Return Value

SignatureSubprovider


Properties


Methods

handleRequest

Handle RPC request from engine (called by)

Declaration
function handleRequest(payload: JSONRPCRequestPayload, next: function, end: JSONRPCResponseHandler)

Defined in browser/src/subproviders/signature.ts:136

Parameters
Param Type Description
payload JSONRPCRequestPayload RPC request payload
next function Callback to skip handling this request
end JSONRPCResponseHandler Completion handler

handleSignatureRequest

Called when a payload is received that needs a signature

Declaration
function handleSignatureRequest(payload: JSONRPCRequestPayload, callback: JSONRPCResponseHandler): Promise<void>

Defined in browser/src/subproviders/signature.ts:149

Parameters
Param Type Description
payload JSONRPCRequestPayload The JSON-RPC request
callback JSONRPCResponseHandler The callback to call when the request has been handled
Return Value

Promise<void>


Relationships

Extends
  • Subprovider

SignerError

constructor

new SignerError(message: string, code: SignerErrorCode): SignerError
Parameters
Param Type Description
message string -
code SignerErrorCode -
Return Value

SignerError


Properties

code

var code: SignerErrorCode

Defined in browser/src/errors/signer-error.ts:47

name

var name: string = "TransactionError"

Defined in browser/src/errors/signer-error.ts:46

Error

var Error: ErrorConstructor

Defined in /Users/jp/Work/Bitski/bitski-js/node_modules/typescript/lib/lib.es5.d.ts:974


Methods

MissingFrom

Declaration
function MissingFrom(): SignerError

Defined in browser/src/errors/signer-error.ts:38

Return Value

SignerError

MissingMessage

Declaration
function MissingMessage(): SignerError

Defined in browser/src/errors/signer-error.ts:34

Return Value

SignerError

MissingTransaction

Declaration
function MissingTransaction(): SignerError

Defined in browser/src/errors/signer-error.ts:30

Return Value

SignerError

MissingTypedData

Declaration
function MissingTypedData(): SignerError

Defined in browser/src/errors/signer-error.ts:42

Return Value

SignerError

UnsupportedMethod

Declaration
function UnsupportedMethod(): SignerError

Defined in browser/src/errors/signer-error.ts:22

Return Value

SignerError

UserCancelled

Declaration
function UserCancelled(): SignerError

Defined in browser/src/errors/signer-error.ts:26

Return Value

SignerError


Relationships

Extends
  • Error

TokenStore

constructor

new TokenStore(clientId: string): TokenStore
Parameters
Param Type Description
clientId string -
Return Value

TokenStore


currentToken

getcurrentToken(): string | undefined

Return Value

string ⎮undefined

refreshToken

getrefreshToken(): string | undefined

Return Value

string ⎮undefined


Methods

clear

Declaration
function clear()

Defined in browser/src/auth/token-store.ts:58

invalidateCurrentToken

Declaration
function invalidateCurrentToken()

Defined in browser/src/auth/token-store.ts:53

persistTokenResponse

Declaration
function persistTokenResponse(response: TokenResponse)

Defined in browser/src/auth/token-store.ts:44

Parameters
Param Type Description
response TokenResponse -


User

constructor

new User(id: string, accounts?: string[], email?: undefined | string, emailVerified?: undefined | false | true, phone?: undefined | string, phoneNumberVerified?: undefined | false | true): User
Parameters
Param Type Description
id string -
accounts (Optional) string[] -
email (Optional) undefined ⎮string -
emailVerified (Optional) undefined ⎮false ⎮true -
phone (Optional) undefined ⎮string -
phoneNumberVerified (Optional) undefined ⎮false ⎮true -
Return Value

User


Properties

accounts

var accounts: string[]

Defined in browser/src/auth/user.ts:30

email

var email: undefined | string

Defined in browser/src/auth/user.ts:31

emailVerified

var emailVerified: undefined | false | true

Defined in browser/src/auth/user.ts:32

id

var id: string

Defined in browser/src/auth/user.ts:29

phoneNumber

var phoneNumber: undefined | string

Defined in browser/src/auth/user.ts:33

phoneNumberVerified

var phoneNumberVerified: undefined | false | true

Defined in browser/src/auth/user.ts:34


Methods

toStorageString

Declaration
function toStorageString(): string

Defined in browser/src/auth/user.ts:45

Return Value

string

fromJson

Declaration
function fromJson(json: UserInfoResponse): User

Defined in browser/src/auth/user.ts:12

Parameters
Param Type Description
json UserInfoResponse -
Return Value

User

fromString

Declaration
function fromString(s: string): User | undefined

Defined in browser/src/auth/user.ts:16

Parameters
Param Type Description
s string -
Return Value

User ⎮undefined



UserStore

constructor

new UserStore(clientId: string): UserStore
Parameters
Param Type Description
clientId string -
Return Value

UserStore


currentUser

getcurrentUser(): User | undefined

Return Value

User ⎮undefined


Methods

clear

Declaration
function clear()

Defined in browser/src/auth/user-store.ts:27

set

Declaration
function set(user: User | undefined)

Defined in browser/src/auth/user-store.ts:22

Parameters
Param Type Description
user User ⎮undefined -


AuthProvider

Properties

authStatus

var authStatus: AuthenticationStatus

Defined in browser/src/auth/auth-provider.ts:6

Methods

connect

Declaration
function connect(): Promise<User>

Defined in browser/src/auth/auth-provider.ts:8

Return Value

Promise<User>

getUser

Declaration
function getUser(): Promise<User>

Defined in browser/src/auth/auth-provider.ts:10

Return Value

Promise<User>

redirectCallback

Declaration
function redirectCallback(): Promise<User>

Defined in browser/src/auth/auth-provider.ts:11

Return Value

Promise<User>

signIn

Declaration
function signIn(method: OAuthSignInMethod, opts?: SignInOptions): Promise<User>

Defined in browser/src/auth/auth-provider.ts:7

Parameters
Param Type Description
method OAuthSignInMethod -
opts (Optional) SignInOptions -
Return Value

Promise<User>

signInOrConnect

Declaration
function signInOrConnect(signInMethod?: OAuthSignInMethod, opts?: SignInOptions): Promise<User>

Defined in browser/src/auth/auth-provider.ts:9

Parameters
Param Type Description
signInMethod (Optional) OAuthSignInMethod -
opts (Optional) SignInOptions -
Return Value

Promise<User>

signOut

Declaration
function signOut(): Promise<User>

Defined in browser/src/auth/auth-provider.ts:12

Return Value

Promise<User>

BitskiSDKOptions

Properties

configuration

var configuration: AuthorizationServiceConfiguration

Defined in browser/src/bitski.ts:39

ConnectButtonOptions

Options for the connect button component

Properties

authMethod

var authMethod: OAuthSignInMethod

Defined in browser/src/components/connect-button.ts:19

container

var container: HTMLElement

Defined in browser/src/components/connect-button.ts:23

signInOptions

var signInOptions: SignInOptions

Defined in browser/src/components/connect-button.ts:21

size

var size: ConnectButtonSize

Defined in browser/src/components/connect-button.ts:25

JSONTransactionObject

Properties

transaction

var transaction: Transaction

Defined in browser/src/signing/transaction-signer.ts:9

OAuthManagerOptions

Properties

additionalScopes

var additionalScopes: string[]

Defined in browser/src/auth/oauth-manager.ts:28

clientId

var clientId: string

Defined in browser/src/auth/oauth-manager.ts:25

configuration

var configuration: AuthorizationServiceConfiguration

Defined in browser/src/auth/oauth-manager.ts:27

redirectUri

var redirectUri: string

Defined in browser/src/auth/oauth-manager.ts:26

ProviderOptions

Properties

additionalHeaders

var additionalHeaders: undefined | object

Defined in browser/src/bitski.ts:49

apiBaseUrl

var apiBaseUrl: undefined | string

Defined in browser/src/bitski.ts:51

disableBlockTracking

var disableBlockTracking: undefined | false | true

Defined in browser/src/bitski.ts:48

disableCaching

var disableCaching: undefined | false | true

Defined in browser/src/bitski.ts:46

disableValidation

var disableValidation: undefined | false | true

Defined in browser/src/bitski.ts:47

network

var network: Network

Defined in browser/src/bitski.ts:44

networkName

var networkName: undefined | string

Defined in browser/src/bitski.ts:43

pollingInterval

var pollingInterval: undefined | number

Defined in browser/src/bitski.ts:45

webBaseUrl

var webBaseUrl: undefined | string

Defined in browser/src/bitski.ts:50

SignInOptions

Properties

login_hint

var login_hint: undefined | string

Defined in browser/src/auth/oauth-manager.ts:32

SignaturePayload

Properties

from

var from: string

Defined in browser/src/subproviders/signature.ts:32

message

var message: string

Defined in browser/src/subproviders/signature.ts:33

Transaction

Properties

context

var context: TransactionContext

Defined in browser/src/subproviders/signature.ts:22

id

var id: string

Defined in browser/src/subproviders/signature.ts:19

kind

var kind: TransactionKind

Defined in browser/src/subproviders/signature.ts:20

payload

var payload: TransactionPayload | SignaturePayload

Defined in browser/src/subproviders/signature.ts:21

TransactionContext

Properties

chainId

var chainId: undefined | number

Defined in browser/src/subproviders/signature.ts:26

currentBalance

var currentBalance: undefined | string

Defined in browser/src/subproviders/signature.ts:27

from

var from: undefined | string

Defined in browser/src/subproviders/signature.ts:28

TransactionPayload

Properties

data

var data: undefined | string

Defined in browser/src/subproviders/signature.ts:40

from

var from: string

Defined in browser/src/subproviders/signature.ts:37

gas

var gas: undefined | string

Defined in browser/src/subproviders/signature.ts:42

gasPrice

var gasPrice: undefined | string

Defined in browser/src/subproviders/signature.ts:43

nonce

var nonce: undefined | string

Defined in browser/src/subproviders/signature.ts:41

to

var to: undefined | string

Defined in browser/src/subproviders/signature.ts:38

value

var value: undefined | string

Defined in browser/src/subproviders/signature.ts:39

TypedDataDefinition

Properties

name

var name: string

Defined in browser/src/subproviders/signature.ts:47

type

var type: string

Defined in browser/src/subproviders/signature.ts:48

TypedDataPayload

Example usage:

const payload: TypedDataPayload = {
  types: {
    EIP712Domain: [
      { name: 'name', type: 'string' },
      { name: 'version', type: 'string' },
      { name: 'chainId', type: 'uint256' },
      { name: 'verifyingContract', type: 'address' },
    ],
    Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' }
    ],
    Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'contents', type: 'string' }
    ],
  },
  primaryType: 'Mail',
  domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  },
  message: {
    from: {
      name: 'Cow',
      wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
      name: 'Bob',
      wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
  },
}

Properties

domain

var domain: object

Defined in browser/src/subproviders/signature.ts:98

message

var message: object

Defined in browser/src/subproviders/signature.ts:100

primaryType

var primaryType: string

Defined in browser/src/subproviders/signature.ts:99

types

var types: object

Defined in browser/src/subproviders/signature.ts:94

Type declaration

EIP712Domain: TypedDataDefinition[]

UserInfoResponse

Properties

accounts

var accounts: string[]

Defined in browser/src/auth/user.ts:3

email

var email: undefined | string

Defined in browser/src/auth/user.ts:4

email_verified

var email_verified: undefined | false | true

Defined in browser/src/auth/user.ts:7

phone_number

var phone_number: undefined | string

Defined in browser/src/auth/user.ts:5

phone_number_verified

var phone_number_verified: undefined | false | true

Defined in browser/src/auth/user.ts:6

sub

var sub: string

Defined in browser/src/auth/user.ts:2

JSONRPCResponseHandler

var JSONRPCResponseHandler: function

Defined in browser/src/subproviders/signature.ts:9

Type declaration

function (error?: JsonRpcError, result?: any)

Parameters
Param Type Description
error (Optional) JsonRpcError -
result (Optional) any -

«Const» ACCESS_TOKEN_KEY

var ACCESS_TOKEN_KEY: "bitski.access_token" = "bitski.access_token"

Defined in browser/src/constants.ts:27

«Const» BITSKI_RPC_BASE_URL

var BITSKI_RPC_BASE_URL: "https://api.bitski.com/v1/web3" = "https://api.bitski.com/v1/web3"

Defined in browser/src/constants.ts:7

«Const» BITSKI_TRANSACTION_API_BASE_URL

var BITSKI_TRANSACTION_API_BASE_URL: "https://api.bitski.com/v1" = "https://api.bitski.com/v1"

Defined in browser/src/constants.ts:6

«Const» BITSKI_USER_API_HOST

var BITSKI_USER_API_HOST: "https://www.bitski.com/v1" = "https://www.bitski.com/v1"

Defined in browser/src/constants.ts:5

«Const» BITSKI_WEB_BASE_URL

var BITSKI_WEB_BASE_URL: "https://sign.bitski.com" = "https://sign.bitski.com"

Defined in browser/src/constants.ts:8

«Const» CACHED_METHODS

var CACHED_METHODS: string[] =  ['eth_accounts']

Defined in browser/src/constants.ts:31

«Const» CHECK_FOR_POPUP_CLOSE_INTERVAL

var CHECK_FOR_POPUP_CLOSE_INTERVAL: 500 = 500

Defined in browser/src/constants.ts:22

«Const» DEFAULT_AUTHORIZED_METHODS

var DEFAULT_AUTHORIZED_METHODS: string[] =  [
  'eth_sendTransaction',
  'eth_signTransaction',
  'eth_sign',
  'personal_sign',
  'eth_signTypedData',
  'eth_signTypedData_v3', // For metamask compatibility
]

Defined in browser/src/constants.ts:32

«Const» DEFAULT_OPTIONAL_SCOPES

var DEFAULT_OPTIONAL_SCOPES: string[] =  ['offline']

Defined in browser/src/constants.ts:19

«Const» DEFAULT_POPUP_FEATURES

var DEFAULT_POPUP_FEATURES: "location=no,toolbar=no,width=500,height=500,left=100,top=100;" = "location=no,toolbar=no,width=500,height=500,left=100,top=100;"

Defined in browser/src/constants.ts:23

«Const» DEFAULT_SCOPES

var DEFAULT_SCOPES: string[] =  ['openid']

Defined in browser/src/constants.ts:18

«Const» IFRAME_MESSAGE_ORIGIN_INCLUDES

var IFRAME_MESSAGE_ORIGIN_INCLUDES: ".bitski.com" = ".bitski.com"

Defined in browser/src/constants.ts:9

«Const» LOGIN_HINT_SIGNUP

var LOGIN_HINT_SIGNUP: "signup" = "signup"

Defined in browser/src/auth/oauth-manager.ts:36

«Const» REFRESH_TOKEN_KEY

var REFRESH_TOKEN_KEY: "bitski.refresh_token" = "bitski.refresh_token"

Defined in browser/src/constants.ts:26

«Const» SDK_VERSION

var SDK_VERSION: "0.10.0" = "0.10.0"

Defined in browser/src/constants.ts:2

«Const» TEMPLATE

var TEMPLATE: "
  <div class='bitski-dialog'>
      <button class='bitski-close-button'>Close</button>
      <div class='bitski-dialog-body'></div>
  </div>
" =  `
  <div class='bitski-dialog'>
      <button class='bitski-close-button'>Close</button>
      <div class='bitski-dialog-body'></div>
  </div>
`

Defined in browser/src/components/dialog.ts:1

«Const» USER_KEY

var USER_KEY: "bitski.user" = "bitski.user"

Defined in browser/src/constants.ts:28

Functions

isAuthProvider

Declaration
function isAuthProvider(object: any): boolean

Defined in browser/src/providers/bitski-browser-engine.ts:11

Parameters
Param Type Description
object any -
Return Value

boolean

parseResponse

Parses a Fetch Response to extract either the result or the error

Declaration
function parseResponseT(response: Response): Promise<T>

Defined in browser/src/utils/request-utils.ts:8

Type parameters

T

Parameters
Param Type Description
response Response the fetch response to parse
Return Value

Promise<T>

DEFAULT_OAUTH_CONFIGURATION

authorization_endpoint

var authorization_endpoint: string = "https://account.bitski.com/oauth2/auth"

Defined in browser/src/constants.ts:13

revocation_endpoint

var revocation_endpoint: string = ""

Defined in browser/src/constants.ts:14

token_endpoint

var token_endpoint: string = "https://account.bitski.com/oauth2/token"

Defined in browser/src/constants.ts:15

userinfo_endpoint

var userinfo_endpoint: string = "https://account.bitski.com/userinfo"

Defined in browser/src/constants.ts:16


Bitski Provider

This package includes our base Web3 provider based on web3-provider-engine. It is intended to be extended for various platforms, as we do in bitski (our browser package), and bitski-node (our Node package).

Installation

npm install bitski-provider

Usage

import { BitskiEngine } from 'bitski-provider';

ProviderErrorCode

InvalidRequest

var InvalidRequest:  = 4001

Defined in provider/src/errors/provider-error.ts:5

SubscriptionsUnavailable

var SubscriptionsUnavailable:  = 4000

Defined in provider/src/errors/provider-error.ts:3

AccessToken

A token that provides access to Bitski on behalf of a user.

constructor

new AccessToken(token: string, expiresIn?: undefined | number): AccessToken
Parameters
Param Type Description
token string -
expiresIn (Optional) undefined ⎮number -
Return Value

AccessToken


Properties

expiresAt

var expiresAt: undefined | number =  undefined

Defined in provider/src/auth/access-token.ts:6

token

var token: string

Defined in provider/src/auth/access-token.ts:5


expired

getexpired(): boolean

Return Value

boolean



AuthenticatedFetchSubprovider

constructor

new AuthenticatedFetchSubprovider(rpcUrl: string, debug: boolean, accessTokenProvider: AccessTokenProvider, defaultHeaders?: object): AuthenticatedFetchSubprovider
Parameters
Param Type Default value Description
rpcUrl string - -
debug boolean - -
accessTokenProvider AccessTokenProvider - -
defaultHeaders object {} -
Return Value

AuthenticatedFetchSubprovider


Properties


Methods

handleAuthenticatedRequest

Declaration
function handleAuthenticatedRequest(payload: any, next: any, end: any)

Defined in provider/src/subproviders/authenticated-fetch.ts:30

Parameters
Param Type Description
payload any -
next any -
end any -

handleRequest

Declaration
function handleRequest(payload: any, next: any, end: any)

Defined in provider/src/subproviders/authenticated-fetch.ts:22

Parameters
Param Type Description
payload any -
next any -
end any -

handleUnauthenticatedRequest

Declaration
function handleUnauthenticatedRequest(payload: any, next: any, end: any)

Defined in provider/src/subproviders/authenticated-fetch.ts:39

Parameters
Param Type Description
payload any -
next any -
end any -

Relationships

Extends
  • FetchSubprovider

BitskiEngine

constructor

new BitskiEngine(options?: BitskiEngineOptions): BitskiEngine
Parameters
Param Type Description
options (Optional) BitskiEngineOptions -
Return Value

BitskiEngine


Properties


Methods

subscribe

Declaration
function subscribe(subscribeMethod?: string, subscriptionMethod: string, parameters: any[]): Promise<string>

Defined in provider/src/bitski-engine.ts:75

Parameters
Param Type Default value Description
subscribeMethod string "eth_subscribe" -
subscriptionMethod string - -
parameters any[] - -
Return Value

Promise<string>

supportsSubscriptions

Declaration
function supportsSubscriptions(): boolean

Defined in provider/src/bitski-engine.ts:71

Return Value

boolean

unsubscribe

Declaration
function unsubscribe(subscriptionId: string, unsubscribeMethod?: string): Promise<boolean>

Defined in provider/src/bitski-engine.ts:81

Parameters
Param Type Default value Description
subscriptionId string - -
unsubscribeMethod string "eth_unsubscribe" -
Return Value

Promise<boolean>


Relationships

Extends
  • Web3ProviderEngine

NonceTrackerSubprovider

A subprovider that tracks and automatically increments the nonce on the client. Heavily based on the provider-engine NonceTrackerSubprovider, but modified for Bitski’s transaction flow.

constructor

new NonceTrackerSubprovider(): NonceTrackerSubprovider
Return Value

NonceTrackerSubprovider


Properties


Methods

handleRequest

Declaration
function handleRequest(payload: any, next: any, end: any)

Defined in provider/src/subproviders/nonce-tracker.ts:17

Parameters
Param Type Description
payload any -
next any -
end any -

Relationships

Extends
  • Subprovider

ProviderError

constructor

new ProviderError(message: string, code: ProviderErrorCode): ProviderError
Parameters
Param Type Description
message string -
code ProviderErrorCode -
Return Value

ProviderError


Properties

code

var code: ProviderErrorCode

Defined in provider/src/errors/provider-error.ts:19

name

var name: string = "ProviderError"

Defined in provider/src/errors/provider-error.ts:18

Error

var Error: ErrorConstructor

Defined in /Users/jp/Work/Bitski/bitski-js/node_modules/typescript/lib/lib.es5.d.ts:974


Methods

InvalidRequest

Declaration
function InvalidRequest(reason: string): ProviderError

Defined in provider/src/errors/provider-error.ts:14

Parameters
Param Type Description
reason string -
Return Value

ProviderError

SubscriptionsUnavailable

Declaration
function SubscriptionsUnavailable(): ProviderError

Defined in provider/src/errors/provider-error.ts:10

Return Value

ProviderError


Relationships

Extends
  • Error

ServerError

Represents an error that is received from the server You can access the response code via the code property, and the URI from the requestURI property. The retried property will indicate whether or not the request failed after multiple tries.

constructor

new ServerError(message: string, code: number, requestURI: string, retried?: boolean): ServerError
Parameters
Param Type Default value Description
message string - -
code number - -
requestURI string - -
retried boolean false -
Return Value

ServerError


Properties

code

var code: number

Defined in provider/src/errors/server-error.ts:10

name

var name: string = "ServerError"

Defined in provider/src/errors/server-error.ts:7

requestURI

var requestURI: string

Defined in provider/src/errors/server-error.ts:16

retried

var retried: boolean

Defined in provider/src/errors/server-error.ts:13

Error

var Error: ErrorConstructor

Defined in /Users/jp/Work/Bitski/bitski-js/node_modules/typescript/lib/lib.es5.d.ts:974


Relationships

Extends
  • Error

TransactionValidatorSubprovider

A subprovider that automatically populates missing transaction details. This is needed because it has become common to submit transactions with only some of the parameters and rely on the provider or node to fill in the rest.

Properties


Methods

handleRequest

Declaration
function handleRequest(payload: any, next: any, _: any)

Defined in provider/src/subproviders/transaction-validator.ts:10

Parameters
Param Type Description
payload any -
next any -
_ any -

Relationships

Extends
  • Subprovider

TypedDataSanitizerSubprovider

Properties


Methods

handleRequest

Declaration
function handleRequest(payload: JSONRPCRequestPayload, next: function, end: function)

Defined in provider/src/subproviders/typed-data.ts:33

Parameters
Param Type Description
payload JSONRPCRequestPayload -
next function -
end function -

Relationships

Extends
  • Subprovider

AccessTokenProvider

Methods

getAccessToken

Declaration
function getAccessToken(): Promise<string>

Defined in provider/src/auth/access-token-provider.ts:2

Return Value

Promise<string>

invalidateToken

Declaration
function invalidateToken(): Promise<void>

Defined in provider/src/auth/access-token-provider.ts:3

Return Value

Promise<void>

BitskiEngineOptions

Properties

disableBlockTracking

var disableBlockTracking: undefined | false | true

Defined in provider/src/bitski-engine.ts:23

disableCaching

var disableCaching: undefined | false | true

Defined in provider/src/bitski-engine.ts:19

disableValidation

var disableValidation: undefined | false | true

Defined in provider/src/bitski-engine.ts:21

pollingInterval

var pollingInterval: undefined | number

Defined in provider/src/bitski-engine.ts:17

JSONRPCRequestPayload

Properties

id

var id: number

Defined in provider/src/index.ts:12

jsonrpc

var jsonrpc: string

Defined in provider/src/index.ts:13

method

var method: string

Defined in provider/src/index.ts:11

params

var params: any[]

Defined in provider/src/index.ts:10

JSONRPCResponsePayload

Properties

id

var id: number

Defined in provider/src/index.ts:18

jsonrpc

var jsonrpc: string

Defined in provider/src/index.ts:19

result

var result: any

Defined in provider/src/index.ts:17

Network

Properties

chainId

var chainId: number

Defined in provider/src/network.ts:3

rpcUrl

var rpcUrl: string

Defined in provider/src/network.ts:2

PropertyDef

Properties

name

var name: string

Defined in provider/src/subproviders/typed-data.ts:7

type

var type: string

Defined in provider/src/subproviders/typed-data.ts:8

TypeMapping

var TypeMapping: 

Defined in provider/src/subproviders/typed-data.ts:25

TypedData

Properties

domain

var domain: any

Defined in provider/src/subproviders/typed-data.ts:20

message

var message: any

Defined in provider/src/subproviders/typed-data.ts:22

primaryType

var primaryType: string

Defined in provider/src/subproviders/typed-data.ts:21

types

var types: TypedDataTypes

Defined in provider/src/subproviders/typed-data.ts:19

TypedDataTypes

Properties

EIP712Domain

var EIP712Domain: TypeDefinition

Defined in provider/src/subproviders/typed-data.ts:14

TypeDefinition

var TypeDefinition: PropertyDef[]

Defined in provider/src/subproviders/typed-data.ts:11

«Const» AUTHENTICATED_METHODS

var AUTHENTICATED_METHODS: string[] =  [
  'eth_accounts',
  'eth_sendTransaction',
  'eth_signTransaction',
  'eth_signTypedData',
  'personal_sign',
  'eth_sign',
]

Defined in provider/src/constants.ts:2

«Const» RETRIABLE_ERRORS

var RETRIABLE_ERRORS: string[] =  [
  // ignore server overload errors
  'Gateway timeout',
  'ETIMEDOUT',
  'ENOTFOUND', // DNS error
  // ignore server sent html error pages
  // or truncated json responses
  'SyntaxError',
  'ECONNRESET',
]

Defined in provider/src/constants.ts:12

«Const» UNAUTHORIZED_ERRORS

var UNAUTHORIZED_ERRORS: string[] =  [
  'Missing auth', // No token sent
  'Invalid client id', // Wrong client id, or invalid access token
  'Not Authorized',
]

Defined in provider/src/constants.ts:24

Functions

createTypeMapping

Maps the type definitions from the typed data for easy look-up. Top level keys represent the structs defined, while top-level values are an object keyed by property with string values of the type name.

For example: { EIP712Domain: { name: ‘string’, version: ‘string’, chainId: ‘uint256’ } }

Declaration
function createTypeMapping(typedData: TypedData): TypeMapping

Defined in provider/src/subproviders/typed-data.ts:175

Parameters
Param Type Description
typedData TypedData The TypedData to map
Return Value

TypeMapping

the mapped data schema

encodeNumber

encodeNumber Takes a decimal string, hex string, regular number, or BN instance and returns a hex string in the specified format. Typically these conversions are done in web3, but until web3 adds direct support, this is necessary for normalizing numbers eth_signTypedData payloads.

Declaration
function encodeNumber(num: string | number | BN, type: string, compact?: boolean): string

Defined in provider/src/utils/parse-utils.ts:53

Parameters
Param Type Default value Description
num string ⎮number ⎮BN - The value to convert
type string - The solidity ABI type to format the data as (eg. uint256, int8, etc). Only supports int and uint variants.
compact boolean false boolean (default false). Whether to use compact encoding for uints, or pad with zeroes.
Return Value

string

A hex string formatted as the specified type.

isArray

Returns true if type name indicates that an array

Declaration
function isArray(typeName: string): boolean

Defined in provider/src/subproviders/typed-data.ts:152

Parameters
Param Type Description
typeName string solidity type name
Return Value

boolean

parseBitWidth

Declaration
function parseBitWidth(type: string, offset: number): number

Defined in provider/src/utils/parse-utils.ts:30

Parameters
Param Type Description
type string -
offset number -
Return Value

number

parseNumber

parseNumber Converts a value that represents a number into a hex value.

Declaration
function parseNumber(arg: string | number | BN): BN

Defined in provider/src/utils/parse-utils.ts:12

Parameters
Param Type Description
arg string ⎮number ⎮BN A number value to convert to hex.Can be a regular number, base-10 string, base-16 string, or BN instance.
Return Value

BN

BN instance representing the number

(Adapted from ethereumjs-abi)

sanitizeDomain

Sanitizes the domain values from the TypedData

Declaration
function sanitizeDomain(typedData: TypedData, typeMapping: TypeMapping)

Defined in provider/src/subproviders/typed-data.ts:77

Parameters
Param Type Description
typedData TypedData TypedData payload
typeMapping TypeMapping a TypeMapping pre-generated from the TypedData

sanitizeMessage

Sanitizes the message values from the TypedData

Declaration
function sanitizeMessage(typedData: TypedData, typeMapping: TypeMapping)

Defined in provider/src/subproviders/typed-data.ts:93

Parameters
Param Type Description
typedData TypedData TypedData payload
typeMapping TypeMapping a TypeMapping pre-generated from the TypedData

sanitizeType

Recursively examines each value and determines type from the type mapping to format and sanitize the value if needed.

Currently this will only convert number values into a consistent hex format, but in the future additional transformations may be necessary.

Declaration
function sanitizeType(typeName: string, values: any, typeMapping: TypeMapping)

Defined in provider/src/subproviders/typed-data.ts:114

Parameters
Param Type Description
typeName string Name of the type we are starting from
values any The root object containing the keys and values
typeMapping TypeMapping The type mapping that represents this data

Kovan

chainId

var chainId: number = 42

Defined in provider/src/network.ts:17

rpcUrl

var rpcUrl: string = "https://api.bitski.com/v1/web3/kovan"

Defined in provider/src/network.ts:18

Mainnet

chainId

var chainId: number = 1

Defined in provider/src/network.ts:7

rpcUrl

var rpcUrl: string = "https://api.bitski.com/v1/web3/mainnet"

Defined in provider/src/network.ts:8

Rinkeby

chainId

var chainId: number = 4

Defined in provider/src/network.ts:12

rpcUrl

var rpcUrl: string = "https://api.bitski.com/v1/web3/rinkeby"

Defined in provider/src/network.ts:13