0.0.9 • Published 9 months ago

@credenza3/core-web v0.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

CREDENZA WEB SDK Core

Registering client

Visit https://developers.credenza3.com/ sign in and create your Client

Installation

npm install @credenza3/core-web

Extensions

Usage

Create the SDK instance and Initialize

const sdk = new CredenzaSDK({
  clientId: <CLIENT_ID>,
  env?: CredenzaSDK.SDK_ENV.STAGING // LOCAL | STAGING | PROD,
  extensions: [
    new EvmExtension({chainConfig, extensions: [
      new MetamaskExtension()
    ]}),
    new OAuthExtension(),
    new AccountExtension(),
    new SuiExtension({ suiNetwork: suiNetworkName, extensions: [new ZkLoginExtension()] }),
  ],
})

// init all of the extensions and emits INIT event
await sdk.initialize()

Usage

Get access token

const token = sdk.getAccessToken(): string

Get login provider

const loginProvider = sdk.getLoginProvider(): string ("oauth" | "metamask")

Get is user logged in

const isLoggedIn = sdk.isLoggedIn(): boolean

Logout // destroy access token and emit LOGOUT event

sdk.logout()

Events

SDK_EVENT = {
  ERROR: 'ERROR',
  INIT: 'INIT',
  LOGIN: 'LOGIN',
  LOGOUT: 'LOGOUT',
}

const event = CredenzaSDK.SDK_EVENT.<EVENT_NAME>
const unsubscribe = sdk.on(event, (data) => {})
sdk.once(event, (data) => {})
0.0.9

9 months ago

0.0.8

10 months ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.2-rc.0

1 year ago

0.0.1

1 year ago