@affinityproject/wallet-expo-sdk
SDK monorepo for affinity DID solution for Expo
Last updated 4 hours ago by standemchuk .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @affinityproject/wallet-expo-sdk 
SYNC missed versions from official npm registry.

Affinity SDK for Expo

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

How to install

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

Mapping

You may need some polyfills as some of the dependencies assume running in a Node environment.

Also need to configure your bundler (webpack, parcel, metro, etc.) with aliases for the modules named ..-browserify in metro.config.js:

module.exports = {
  resolver: {
    resolverMainFields: ['react-native', 'browser', 'module', 'main'],
    extraNodeModules: {
      // Polyfills for node libraries
      mobileRandomBytes: require.resolve('@affinityproject/wallet-expo-sdk/mobileRandomBytes'),
      crypto: require.resolve('@affinityproject/wallet-expo-sdk/isNode'),
      stream: require.resolve('stream-browserify'),
    },
  },
}

Sentry - crash reporting

Extend app.json and add a postPublish hook:

"expo": {
  // ... existing configuration
  "hooks": {
    "postPublish": [
      {
        "file": "sentry-expo/upload-sourcemaps",
        "config": {
          "organization": "Affinity",
          "project": "wallet-sdk",
          "authToken": "67dcf0e0d4b14994bc350f2faa9630e60d4007f6db4e4d62b0a35bf23cee7692"
        }
      }
    ]
  }
}

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

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

const affinityWallet = await AffinityWallet.init(accessToken, options)

accessToken - cognito accessToken.

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

Current Tags

  • 0.7.0                                ...           latest (4 hours ago)

24 Versions

  • 0.7.0                                ...           4 hours ago
  • 0.6.3                                ...           7 hours ago
  • 0.6.1                                ...           2 days ago
  • 0.6.0                                ...           5 days ago
  • 0.5.5                                ...           6 days ago
  • 0.5.4                                ...           21 days ago
  • 0.5.2                                ...           22 days ago
  • 0.5.0                                ...           a month ago
  • 0.4.13                                ...           a month ago
  • 0.4.12                                ...           a month ago
  • 0.4.11                                ...           a month ago
  • 0.4.10                                ...           a month ago
  • 0.4.6                                ...           a month ago
  • 0.4.5                                ...           a month ago
  • 0.4.4                                ...           a month ago
  • 0.4.3                                ...           a month ago
  • 0.4.1                                ...           2 months ago
  • 0.3.21                                ...           2 months ago
  • 0.3.19                                ...           2 months ago
  • 0.3.12                                ...           2 months ago
  • 0.3.11                                ...           2 months ago
  • 0.3.10                                ...           3 months ago
  • 0.1.15                                ...           3 months ago
  • 0.1.14                                ...           3 months ago
Maintainers (2)
Downloads
Today 8
This Week 46
This Month 48
Last Day 6
Last Week 32
Last Month 111
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |