npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@affinityproject/wallet-expo-sdk

v0.13.2

Published

SDK monorepo for affinity DID solution for Expo

Downloads

122

Readme

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, 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)