@startbahn/startrail-sdk-js
TypeScript icon, indicating that this package has built-in type declarations

1.35.0 • Public • Published

startrail-sdk-js

npm version

Front-end Javascript/Typescript SDK

Startrail-sdk-js provides convenient access from your browser to Startrail API that sends transactions to Startrail Ethereum blockchain on behalf.

Install

yarn add @startbahn/startrail-sdk-js
# or
npm i @startbahn/startrail-sdk-js

Or as a script tag:

jsdeliver

<script src="https://cdn.jsdelivr.net/npm/@startbahn/startrail-sdk-js"></script>

unpkg

<script src="https://unpkg.com/@startbahn/startrail-sdk-js"></script>

Usage

const startrail = new Startrail(params)

Note: No need to pass params if you want to use Startrail production endpoint with associated Auth0 & TORUS features.

Parameters

[Common for all wallets]

  • apiPath (optional): API endpoint startrail-sdk-js calls. Default endpoint is set to production.
  • wallet (optional): Activate selected wallet. Default is startrail.
    • metamask: Your Metamask wallet.
    • startrail: Google or Email/Passord powered by TORUS.
  • env (optional): Environment that impacts on blockchain network, and EOA with startrail Email/Password
    • production: Matic network. TORUS production account and Startrail production Auth0 account. It is designed to communicate to Startrail production API.
    • staging: Amoy network. TORUS production account and Startrail staging Auth0 account. It is designed to communicate to Startrail staging API.
    • lrc: Amoy network. TORUS lrc account and Startrail qa Auth0 account. It is designed to communicate to Startrail qa API.
    • local: https://localhost:8545 network for local dev. TORUS lrc account and Startrail lrc Auth0 account. It is designed to communicate to localhost API.

[For Startrail wallet powered by TORUS]

  • authAction (optional): Activate only selected action tab on the Email popup. Wording is also changed based on your choice. It points to

    • signup
    • login
  • auth0ClientId (optional): Client ID of Auth0 account.

  • auth0Domain (optional): Domain of Auth0 associated with auth0ClientId.

  • auth0TorusConfigKey (optional): Config key name for TORUS initialisation to connect Auth0 domain and TORUS network. This key is only provided by TORUS.

  • lang (optional): Language preferences

    • en: English
    • ja: Japanese
  • loginProvider (optional): Login provider preference

    • email_password: Email Password login
    • google: Google Oauth Login
  • customUi: Customising UI. If no parameters are set, default values are applied.

    • logoUrl: Applied to all logos in Startrail-sdk-js
    • serviceName: Applied to all service name in Startrail-sdk-js
    • contactUrl: Applied to the contact email in signup Email
    • verificationEmailTitle: Applied to the title of the verification email when you select email_password
    • words: See more details in Example section
    • logoWhiteUrl: Applied to all white logos on black background in Startrail-sdk-js
  • callbackUrl (optional): Callback URL to redirect to from E-Mail template for signup verification

  • withModal (optional): Specifies if the Torus Login Provider Modal should be shown. Default value is set to false

  • rpcEndpoint (optional): RpcEndpoint that is accessed from the wallet you login/signup

  • chainId (optional): chainId of EVM based blockchain that is accessed from the wallet you login/signup

[To be deprecate]

  • torusBuildEnv (optional): Alias for env.

Example

sdk = new Startrail({
  apiPath:'http://localhost:3000/api/v1/',
  env: 'lrc',
  wallet: 'startrail',
  authAction: { login: true, signup: false },
  auth0ClientId: 'test-auth0-client-id',
  auth0Domain: 'test.auth0.com',
  auth0TorusConfigKey: 'test-auth0-key',
  lang: 'ja',
  loginProvider: 'email_password',
  callbackUrl: 'https://www.sample.com',
  withModal: true,
  customUi: {
    logoUrl: 'https://sample.com/logo',
    logoWhiteUrl: 'https://sample.com/white-logo',
    serviceName: 'your service',
    verificationEmailTitle: 'your title',
    contactUrl: 'contact@startrail.io',
    words: {
      en: {
        modal: {
          continueLogin: 'Login with previous {verifier} account', // {verifier} is optional but to be replaced programmatically with the login provider name if it exists in the sentence
          termsConditions: 'your termsConditions',
          termsConditionsLinkUrl: 'your termsConditionsLinkUrl',
          privacyPolicyLinkUrl: 'your privacyPolicyLinkUrl'
        },
        signPopup: {
          title: 'your title',
          requestFrom: 'your requestFrom',
          dataToSign: 'your dataToSign',
          confirm: 'your Confirm',
          cancel: 'your Cancel'
        },
        emailAuthPopup: {
          titleLogin: 'your titleLogin',
          titleSignup: 'your titleSignup'
        }
      },
      ja: {
        modal: {
          continueLogin: '前回の{verifier}アカウントを使う', // {verifier}は任意ですが、文言の中に存在していれば選択したログイン方法の名前へと自動的に置き換わります。
          termsConditions: 'あなたの termsConditions',
          termsConditionsLinkUrl: 'あなたの termsConditionsLinkUrl',
          privacyPolicyLinkUrl: 'あなたの privacyPolicyLinkUrl'
        },
        signPopup: {
          title: 'あなたの title',
          requestFrom: 'あなたの requestFrom',
          dataToSign: 'あなたの dataToSign',
          confirm: 'あなたの Confirm',
          cancel: 'あなたの Cancel'
        },
        emailAuthPopup: {
          titleLogin: 'あなたの titleLogin',
          titleSignup: 'あなたの titleSignup'
        }
      }
    }
  }
})

Tips

If you use Metamask, call sdk.login() before requesting users to sign or call API, in order to fetch currently active EOA and compare it in your web-application, because it is not possible by SDK to stop users from switching EOA.

Readme

Keywords

Package Sidebar

Install

npm i @startbahn/startrail-sdk-js

Weekly Downloads

8

Version

1.35.0

License

UNLICENSED

Unpacked Size

1.97 MB

Total Files

7

Last publish

Collaborators

  • startbahninc