Class

BrowserPlatformApi

BrowserPlatformApi(clientId, agentUriopt, parentopt)

An instance of this class manages an underlying instance of the Zippie DID browser agent, it exposes a low-level API for communicating and interacting with a users identity in a secure sandboxed environment.
Developers should consider not using this directly, but instead use an appropriate toolkit component component library such as the @zippie/did-react-components instead.

Constructor

# new BrowserPlatformApi(clientId, agentUriopt, parentopt)

Parameters:
Name Type Attributes Description
clientId string

Application's identifier (provided by Zippie)

agentUri BrowserAgentLocation | string <optional>

Platform browser agent URI (default: BrowserAgentLocation.Sandbox)

parent HTMLElement <optional>

Element to be used to parent agent iframe with. (default: document.body)

Example
const platform = new BrowserPlatformApi("MyClientId", BrowserAgentLocation.Sandbox)

await platform.setup()

// Check to see if the user is currently logged in with their Decentralized Identity.
if (!platform.isUserSignedIn) {
  // Display SignUp/SignIn flows
  return
}

console.info(await platform.getApplicationData())

Classes

BrowserPlatformApi

Members

string

# agentOrigin

Browser agent enclave origin

BrowserAgentLocation | string

# agentUri

Zippie DID browser agent URI

boolean

# isAppSignedIn

Is the user registered to the application

boolean

# isReady

boolean

# isUserSignedIn

Is the user currently signed in to their Decentralized Identity

string

# sessionId

Multi-session sessionId (ADVANCED USAGE ONLY)

Methods

# async checkIfUserSignIn()

Allows an application to check if the user is currently signed in

If the user is signed in, it returns their data in an application. If they’re not, the function will return IUserData

# async getApplicationData() → {IAppData}

If the user is successfully enrolled in the current application, returns the users' appdata.

IAppData

# getComponentUri(name) → {string}

Used to get the iframe URI for a specific identities' secure field

Parameters:
Name Type Description
name ComponentName

Secure field specifier

string

# async getDerivedKeyInfo(derive, interactive) → {KeyInfo}

Obtains public key information from a derived key pair. The tree used to compute these public keys are the "interactive" keys used for user-interactive signing. This function requires authentication to succeed.

Parameters:
Name Type Description
derive string

HDKey tree path for calculating deterministic derived key.

interactive boolean

Use user-interactive or non-interactive signing tree.

A KeyInfo object which contains the PublicKey and ExtendedPublicKey specific to the user's application registration.

KeyInfo

# async getDerivedPublicKey(derive, interactive) → {Uint8Array}

Returns a Secp256k1 public key derived from the user's private key. The tree used to compute these public keys are the "interactive" keys used for user-interactive signing. This function requires authentication to succeed.

Parameters:
Name Type Description
derive string

HDKey tree path for calculating deterministic derived key.

interactive boolean

Use user-interactive or non-interactive signing tree.

Derived PublicKey

Uint8Array

# async getJsonWebToken() → {string}

If the user is successfully enrolled in the current application, returns a JsonWebToken which can be used to verify the user in backend services.

string

# async getPublicKey() → {Uint8Array}

Returns a Secp256k1 public key specific to the user's application registration. This function requires authentication to succeed.

Uint8Array

# isAppSignedIn()

Is the user registered to the application

# isReady()

# isUserSignedIn()

Is the user currently signed in to their Decentralized Identity

# logout() → {Promise.<void>}

Logs the application out by clearing the apps DID session state.

Promise.<void>

# sessionId()

Multi-session sessionId (ADVANCED USAGE ONLY)

# async setup(optionsopt) → {IAppData|PlatformError|null}

Initializes the DID browser agent service in a sandboxed iframe.

Parameters:
Name Type Attributes Description
options PlatformSetupOptions <optional>
permissions Array.<(PermissionDesc|string)>

Application permissions request

sessionId string <optional>

Unique agent session id (Advanced)

Returns null when a user is not registered to the application (isUserSignedIn returns true and isAppSignedIn returns false).

IAppData | PlatformError | null