API Index

Overview of IdentityWallet SDK API methods

IdentityWallet SDK implements the 3ID protocol, which is exposed with the ThreeIdProvider. It also provides additional functionality that can be used within the wallet. 3ID is used for user identity, encryption, and data authorization.

ThreeIdProvider

IdentityWallet

Auth

Signing Verifiable Claims

Encrypt/Decrypt

ThreeIdProvider

threeIdProvider.send(rpcRequest, origin, callback)

Sends a request to the provider that is handled by the IdentityWallet instance the provider was retrieved from.

Kind: instance method of ThreeIdProvider Returns: Promise<Object> - The response to send back to the rpc requester

Param

Type

Description

rpcRequest

Object

The 3ID JSON-RPC request

origin

String

The URI origin of the request

callback

Function

(Optional) A callback function.

Takes two params, (error, response)

IdentityWallet

new IdentityWallet(config)

Creates an instance of IdentityWallet

Returns: this - An IdentityWallet instance

Param

Type

Description

config

Object

The configuration to be used

config.seed

String

The seed of the identity, 32 hex string

config.authSecret

String

The authSecret to use, 32 hex string

config.ethereumAddress

String

The ethereumAddress of the identity

identityWallet.get3idProvider()

Get the 3IDProvider

Kind: instance method of IdentityWallet Returns: ThreeIdProvider - The 3IDProvider for this IdentityWallet instance

identityWallet.linkAddress(address, provider)

Link a blockchain address to the identity. Usually the address would be an ethereum address (EOA or EIP1271 compatible contract) and the provider is an JSON-RPC provider that can sign a message with this address using personal_sign.

Param

Type

Description

address

String

The address to link

provider

Object

The provider that can sign a message for the given address

Kind: instance method of IdentityWallet Returns: Object - The link proof object

Auth

identityWallet.authenticate(spaces, opts)

Authenticate to given spaces

Kind: instance method of IdentityWallet Returns: Object - The public keys for the requested spaces of this identity

Param

Type

Description

spaces

Array.<String>

The desired spaces

opts

Object

Optional parameters

opts.authData

Array.<Object>

The authData for this identity

identityWallet.isAuthenticated(spaces)

Check if authenticated to given spaces

Kind: instance method of IdentityWallet Returns: Boolean - True if authenticated

Param

Type

Description

spaces

Array.<String>

The desired spaces

identityWallet.addAuthMethod(authSecret)

Add a new authentication method for this identity.

Kind: instance method of IdentityWallet

Param

Type

Description

authSecret

String

A 32 byte hex string used as authentication secret

Sign

identityWallet.signClaim(payload, opts)

Sign a verifiable credential. The format of the credential is did-jwt.

Kind: instance method of IdentityWallet Returns: String - The signed claim encoded as a JWT

Param

Type

Description

payload

Object

The payload of the claim

opts

Object

Optional parameters

opts.DID

String

The DID used as the issuer of this claim

opts.space

String

The space used to sign the claim

opts.expiresIn

String

Set an expiry date for the claim as unix timestamp

Encrypt/Decrypt

identityWallet.encrypt(message, space, opts)

Encrypt a message

Kind: instance method of IdentityWallet Returns: Object - The encrypted object (ciphertext and nonce)

Param

Type

Description

message

String

The message to be encrypted

space

String

The space used for encryption

opts

Object

Optional parameters

opts.nonce

String

The nonce used to encrypt the message

opts.blockSize

String

The blockSize used for padding (default 24)

identityWallet.decrypt(encryptedObject, space)

Decrypt a message

Kind: instance method of IdentityWallet Returns: String - The decrypted message

Param

Type

Description

encryptedObject

Object

The encrypted object (ciphertext and nonce)

space

String

The space used for encryption