0.13.3 • Published 4 years ago

@affinityproject/wallet-browser-sdk v0.13.3

Weekly downloads
40
License
ISC
Repository
github
Last release
4 years ago

Affinity SDK for browser

Browser SDK extends CORE SDK. Make sure to check the CORE SDK documentation.

How to install

npm i --save @affinityproject/wallet-browser-sdk

Initialize

If you want to specify issuer's URL, pass it in the options.

You can also specify the stack environment to be used in env variable. env - (optional) is enum which can be dev | staging | prod (staging is used by default).

const options = {
  issuerUrl: 'https://affinity-issuer.staging.affinity-project.org'
}

const commonNetworkMember = new CommonNetworkMember(password, encryptedSeed, options)

options - (optional) if not defined, values posted above will be used.

Initialize from user access token

Returns SDK instance when user is logged in, and throws COR-9 / UnprocessableEntityError if user is logged out.

import { AffinityWallet } from '@affinityproject/wallet-browser-sdk'

const affinityWallet = await AffinityWallet.init(options)

options - optional, if not defined default settings will be used.

Create encrypted message

const encryptedMessage = await affinityWallet.createEncryptedMessage(toDid, object)

toDid - DID, string value of document to be resolved.

object - value to be encrypted by public key.

Read encrypted message

const message = await affinityWallet.readEncryptedMessage(encryptedMessage)

encryptedMessage - message to be decrypted.

Put credential to VC vault

await affinityWallet.saveCredentials([signedCredential])

accepts array of credentials to store in the vault.

Pull credential from VC vault

const credentials = await affinityWallet.getCredentials(shareRequestToken)

shareRequestToken - optional parameter (if passed - returns VC, which match the request, if not - then returns all VCs).

Get credential issued during signup process

Behaves the same as the wallet-core-sdk confirmSignIn method, but with the added option to issue a VC to the user's vault automatically upon signup with a verified email or phone number.

Confirm sign in (if using confirmSignIn for both sign up and login scenarios)

const issueSignupCredential = true
const { isNew, commonNetworkMember: affinityWallet } = await AffinityWallet.confirmSignIn(token, confirmationCode, options, issueSignupCredential)

token - AWS Cognito Access Token

confirmationCode - 6 digits code, generated and sent by AWS Cognito/SES.

options - (optional) if not defined defaults will be used.

issueVC - (optional) if not defined, set to false

Returns isNew flag, identifying whether new account was created, and initialized instance of SDK - affinityWallet.

Confirm sign up

const issueSignupCredential = true
const affinityWallet = await AffinityWallet.confirmSignUp(token, confirmationCode, options, issueSignupCredential)

token - AWS Cognito Access Token

confirmationCode - 6 digits code, generated and sent by AWS Cognito/SES.

options - (optional) used to specify environment stack (dev | staging | prod).

issueVC - (optional) if not defined, set to false

Delete credential by ID

await affinityWallet.deleteCredential(credentialId)

For example:

const credentials = await affinityWallet.getCredentials() // get all credentials

const credentialId = ... // select credential which should be deleted, f.e `claimId:12345678`

await affinityWallet.deleteCredential(credentialId)
0.13.3

4 years ago

0.13.2

4 years ago

0.13.1

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.12.1

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.7.2

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.3

4 years ago

0.6.1

4 years ago

0.5.5

4 years ago

0.6.0

4 years ago

0.5.4

4 years ago

0.5.2

4 years ago

0.5.0

4 years ago

0.4.12

4 years ago

0.4.11

4 years ago

0.4.10

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.3

4 years ago

0.4.1

4 years ago

0.3.19

4 years ago

0.3.17

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago