0.8.0 • Published 1 year ago

@sphereon/ssi-sdk-waci-pex-qr-react v0.8.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Warning: This package still is in very early development. Breaking changes without notice will happen at this point!


waci-pex-qr-react

A Sphereon SSI-SDK plugin to create an SSI QR code and to verify using SIOPv2 or OIDC4. This plugin component is only supporting react and react-native frameworks.

It will be possible in future to request the issuer to issue credentials.

Installation

yarn add @sphereon/ssi-sdk-waci-pex-qr-react

Build

yarn build

Usage

The usage scenario will include the plugin code to be integrated in the client code. A party will be requesting the recipient to either:

  1. authenticate itself to the requester
  2. inviting the issuer to issue a credential

The data fields required to generate the QR code will depend on the type of request and the acceptable values. The possible accept value may be:

  1. oidc4vp
  2. siop+oidc4vp
  3. siopv2
  4. didcomm/v2 ( in future )

The data fields will need to be passed in SsiQrCodeProps.authenticationRequestOpts.state : string.

Importing the plugin

import {SsiQrCodeProvider} from "@sphereon/ssi-sdk-waci-pex-qr-react";

// Include in the interface
// const agent = createAgent<...  SsiQrCodeProvider>

Adding plugin to the agent

plugins: [
  ...
  new SsiQrCodeProvider()
],

Export for the function

export const createSsiQrCode = agent.ssiQrCode;

The function declared in agent can be imported for usage like below:

import { createSsiQrCode } from '../agent';
import {QRContent, QRMode, QRType} from "@sphereon/ssi-sdk-waci-pex-qr-react";

Inside the component we can declare or get the values to pass to QR Code plugin

    getSsiQrCodeProps(): SsiQrCodeProps {
    return {
      accept: AcceptValue.OIDC4VP,
      mode: QRMode.DID_AUTH_SIOP_V2,
      authenticationRequestOpts: {
        redirectUri: 'https://example.com/qrCode/callbacks',
        requestBy: {
          type: SIOP.PassBy.VALUE
        },
        signatureType: {
          hexPrivateKey: "e96d4bf41709c1bf9276ed784b39d6f6ae47e7e4091f849e5ab001452340acf7",
          did: "did:ethr:0x93e73FACcc011a8209B35d8c7950670B1a7bd902",
          kid: "did:ethr:0x93e73FACcc011a8209B35d8c7950670B1a7bd902#controller",
        },
        registration: {
          didMethodsSupported: ['did:ethr:'],
          subjectIdentifiersSupported: SubjectIdentifierType.DID,
          credentialFormatsSupported: [CredentialFormat.JWT],
          registrationBy: {
            type: SIOP.PassBy.VALUE,
          },
        },
        state: "State 2022-01-31 00"
      },
      onGenerate: (content: QRContent) => {
        // Example output of onGenerate:
        // {
        //   "nonce": "gMWABjAANoQ3LfScAF4HPW",
        //   "state": "State 2022-01-31 00",
        //   "qrValue": "openid://?response_type=id_token&scope=openid&client_id=did%3Aethr%3A0x93e73FACcc011a8209B35d8c7950670B1a7bd902&redirect_uri=https%3A%2F%2Fexample.com%2FqrCode%2Fcallbacks&iss=did%3Aethr%3A0x93e73FACcc011a8209B35d8c7950670B1a7bd902&response_mode=post&response_context=rp&nonce=rSwJ_-N_EUO-X7HX3dVAsKe2_jjrxlIMmZakKiTjDdY&state=State%202022-01-31%2000&registration=%7B%22did_methods_supported%22%3A%5B%22did%3Aethr%3A%22%5D%2C%22subject_identifiers_supported%22%3A%22did%22%2C%22credential_formats_supported%22%3A%5B%22jwt%22%5D%7D&request=eyJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6ZXRocjoweDkzZTczRkFDY2MwMTFhODIwOUIzNWQ4Yzc5NTA2NzBCMWE3YmQ5MDIjY29udHJvbGxlciIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDQ1MDUyODQsImV4cCI6MTY0NDUwNTg4NCwicmVzcG9uc2VfdHlwZSI6ImlkX3Rva2VuIiwic2NvcGUiOiJvcGVuaWQiLCJjbGllbnRfaWQiOiJkaWQ6ZXRocjoweDkzZTczRkFDY2MwMTFhODIwOUIzNWQ4Yzc5NTA2NzBCMWE3YmQ5MDIiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL2V4YW1wbGUuY29tL3FyQ29kZS9jYWxsYmFja3MiLCJpc3MiOiJkaWQ6ZXRocjoweDkzZTczRkFDY2MwMTFhODIwOUIzNWQ4Yzc5NTA2NzBCMWE3YmQ5MDIiLCJyZXNwb25zZV9tb2RlIjoicG9zdCIsInJlc3BvbnNlX2NvbnRleHQiOiJycCIsIm5vbmNlIjoiclN3Sl8tTl9FVU8tWDdIWDNkVkFzS2UyX2pqcnhsSU1tWmFrS2lUakRkWSIsInN0YXRlIjoiU3RhdGUgMjAyMi0wMS0zMSAwMCIsInJlZ2lzdHJhdGlvbiI6eyJkaWRfbWV0aG9kc19zdXBwb3J0ZWQiOlsiZGlkOmV0aHI6Il0sInN1YmplY3RfaWRlbnRpZmllcnNfc3VwcG9ydGVkIjoiZGlkIiwiY3JlZGVudGlhbF9mb3JtYXRzX3N1cHBvcnRlZCI6WyJqd3QiXX19.Sld1kZvV5NNL592MT16ssVVmNif4MhkxUtsRZcHxxUXWXgae4ilbgK1O_pY1ISi-dtQXES0Lp8pzkVj2w47sPA"
        // }
      },
      bgColor: 'white',
      fgColor: 'black',
      level: 'L',
      size: 128,
      title: 'title2021120903',
    }
  }

  delegateCreateSsiQRCode = () => {
    let qrCode = createSsiQrCode(this.getSsiQrCodeProps())
    return qrCode
    .then(qrCodeResolved => {
      return qrCodeResolved
    });
  }

For rendering add to the view

  <View>
  //...
  {
    this.delegateCreateSsiQRCode()
  }
  </View>
0.8.1-next.190

1 year ago

0.8.1-next.192

1 year ago

0.8.1-next.194

1 year ago

0.8.1-next.114

1 year ago

0.8.1-next.117

1 year ago

0.8.1-next.119

1 year ago

0.8.1-next.120

1 year ago

0.8.1-next.121

1 year ago

0.8.1-next.122

1 year ago

0.8.1-next.123

1 year ago

0.8.1-next.146

1 year ago

0.8.1-next.154

1 year ago

0.8.1-next.156

1 year ago

0.8.1-next.157

1 year ago

0.8.1-next.158

1 year ago

0.8.1-next.159

1 year ago

0.8.1-next.161

1 year ago

0.8.1-next.162

1 year ago

0.8.1-next.163

1 year ago

0.8.1-next.164

1 year ago

0.8.1-next.165

1 year ago

0.8.1-next.166

1 year ago

0.8.1-next.167

1 year ago

0.8.1-next.168

1 year ago

0.8.1-next.169

1 year ago

0.8.1-next.179

1 year ago

0.8.1-next.26

2 years ago

0.8.1-next.31

2 years ago

0.8.1-next.42

2 years ago

0.8.1-next.50

2 years ago

0.8.1-next.57

2 years ago

0.8.1-next.55

2 years ago

0.8.1-next.66

2 years ago

0.8.1-next.77

2 years ago

0.8.1-next.84

2 years ago

0.8.1-unstable.9

2 years ago

0.8.1-unstable.5

2 years ago

0.8.1-unstable.4

2 years ago

0.7.1-next.66

2 years ago

0.7.1-next.68

2 years ago

0.7.1-next.54

2 years ago

0.8.0

2 years ago

0.8.1-next.3

2 years ago

0.8.1-next.6

2 years ago

0.8.1-next.2

2 years ago

0.8.1-next.12

2 years ago

0.8.1-next.18

2 years ago

0.7.1-next.43

2 years ago

0.7.1-next.40

2 years ago

0.7.1-next.38

2 years ago

0.5.2-next.73

2 years ago

0.6.1-next.6

2 years ago

0.6.1-next.8

2 years ago

0.6.1-next.9

2 years ago

0.7.1-unstable.9

2 years ago

0.7.1-next.39

2 years ago

0.6.1-next.50

2 years ago

0.7.0

2 years ago

0.6.1-next.66

2 years ago

0.6.1-next.67

2 years ago

0.7.1-next.18

2 years ago

0.5.2-next.113

2 years ago

0.6.1-next.76

2 years ago

0.6.1-next.79

2 years ago

0.5.2-next.116

2 years ago

0.6.1-next.78

2 years ago

0.6.0

2 years ago

0.5.2-next.10

2 years ago

0.5.2-next.70

2 years ago

0.5.2-next.45

2 years ago

0.5.2-next.9

2 years ago

0.5.2-next.8

2 years ago

0.5.2-next.7

2 years ago

0.5.2-next.6

2 years ago

0.5.2-next.4

2 years ago

0.5.2-next.3

2 years ago

0.5.1-next.1

2 years ago

0.5.0

2 years ago

0.4.1-next.7

2 years ago

0.4.1-next.6

2 years ago

0.4.1-unstable.5

2 years ago

0.4.1-unstable.4

2 years ago

0.4.1-unstable.3

2 years ago

0.4.1-unstable.2

2 years ago

0.4.0

2 years ago

0.3.5-next.47

2 years ago

0.3.5-next.46

2 years ago