# 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
Members
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.
# 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.
# 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
# isReady()
# logout() → {Promise.<void>}
Logs the application out by clearing the apps DID session state.
Promise.<void>
# 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).