From 70037f653af0c98e6153f48d38bfd77c0cf595a1 Mon Sep 17 00:00:00 2001 From: Maycon Date: Mon, 9 Dec 2024 16:49:17 -0300 Subject: [PATCH 1/9] update wallet examples to use OID4VC --- docs/getting-started.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index c63145d5..a957405d 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -73,13 +73,11 @@ const credentialProvider = createCredentialProvider({ wallet, // Pass the wallet instance }); +const credentialOfferUrl = 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fapi-testnet.dock.io%2Fopenid%2Fissuers%2F7eff516f-69fb-4b9d-94dc-e88308ec0c4c%22%2C%22credentials%22%3A%5B%22ldp_vc%3AMyCredential%22%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22AAL4MPpEpWY6daBxVxJ8Q3chxOhvc9qIV3EAyj7dvps%22%2C%22user_pin_required%22%3Afalse%7D%7D%7D'; + await credentialProvider.importCredentialFromURI({ - uri: 'https://creds-testnet.dock.io/8489dc69b69a70c97646ad9b4f256acaddb57762b5a6f661f0c9dae3b7f72ea6', // Credential URL - getAuthCode: async () => { - // You can implement your own UI to get the password - // For this example it will be hardcoded - return 'test'; - }, + uri: credentialOfferUrl, + didProvider, }); const credentials = await credentialProvider.getCredentials(); // Retrieve all imported credentials From ca57ad5a484ad2ca86fd0baae037cbe702bcdb5f Mon Sep 17 00:00:00 2001 From: Maycon Date: Tue, 17 Dec 2024 11:17:22 -0300 Subject: [PATCH 2/9] handle undefined bounds --- .../src/services/credential/pex-helpers.js | 20 +- .../services/credential/pex-helpers.test.js | 203 ++++++++++++++++++ 2 files changed, 215 insertions(+), 8 deletions(-) diff --git a/packages/wasm/src/services/credential/pex-helpers.js b/packages/wasm/src/services/credential/pex-helpers.js index 90461747..e57e7d45 100644 --- a/packages/wasm/src/services/credential/pex-helpers.js +++ b/packages/wasm/src/services/credential/pex-helpers.js @@ -139,16 +139,20 @@ export function pexToBounds( index, }); - bounds.push({ - attributeName, - min, - max, - type, - format, - }); + if (attributeName !== undefined) { + bounds.push({ + attributeName, + min, + max, + type, + format, + }); + } }); - descriptorBounds.push(bounds); + if (bounds.length) { + descriptorBounds.push(bounds); + } }); return descriptorBounds; diff --git a/packages/wasm/src/services/credential/pex-helpers.test.js b/packages/wasm/src/services/credential/pex-helpers.test.js index 4f3b4cd2..502c0434 100644 --- a/packages/wasm/src/services/credential/pex-helpers.test.js +++ b/packages/wasm/src/services/credential/pex-helpers.test.js @@ -409,5 +409,208 @@ describe('pex helpers', () => { expect(bounds).toEqual([]); }); + + it('should not have undefined attributeNames, exclude not found bounds', () => { + const pexRequest = { + id: '3cb2c1db-54d7-427a-a6a2-4b8f73a33700', + input_descriptors: [ + { + id: 'Credential 1', + name: 'Mortgage Application Qualification', + group: ['A'], + purpose: + 'Proof of assets (>100k), employment, and credit score (>800)', + constraints: { + fields: [ + { + path: ['$.credentialSubject.id'], + optional: true, + }, + { + path: ['$.credentialSchema.id'], + filter: { + const: + 'https://schema.dock.io/ProofOfEmployment-V1-1703767227542.json', + }, + }, + { + path: ['$.expirationDate', '$.vc.expirationDate'], + filter: { + type: 'string', + format: 'date-time', + formatMinimum: '2024-12-10T00:00:00.000Z', + }, + optional: true, + predicate: 'required', + }, + ], + }, + }, + { + id: 'Credential 2', + name: 'Mortgage Application Qualification', + group: ['A'], + purpose: + 'Proof of assets (>100k), employment, and credit score (>800)', + constraints: { + fields: [ + { + path: ['$.credentialSubject.id'], + optional: true, + }, + { + path: ['$.expirationDate'], + optional: true, + }, + { + path: ['$.credentialSchema.id'], + filter: { + const: + 'https://schema.dock.io/CreditScore-V1-1732907844039.json', + }, + }, + { + path: ['$.credentialSubject.creditScore'], + filter: { + type: 'number', + minimum: 800, + }, + predicate: 'required', + }, + ], + }, + }, + { + id: 'Credential 3', + name: 'Mortgage Application Qualification', + group: ['A'], + purpose: + 'Proof of assets (>100k), employment, and credit score (>800)', + constraints: { + fields: [ + { + path: ['$.credentialSubject.id'], + optional: true, + }, + { + path: ['$.expirationDate'], + optional: true, + }, + { + path: ['$.credentialSchema.id'], + filter: { + const: + 'https://schema.dock.io/ProofOfAssets-V1-1733843536548.json', + }, + }, + { + path: ['$.credentialSubject.sIN'], + optional: true, + }, + { + path: ['$.credentialSubject.name'], + optional: true, + }, + { + path: ['$.credentialSubject.propertiesOwned'], + filter: { + type: 'number', + minimum: 1, + }, + predicate: 'required', + }, + { + path: ['$.credentialSubject.totalPropertyAssetValue'], + filter: { + type: 'number', + minimum: 100000, + }, + predicate: 'required', + }, + ], + }, + }, + ], + submission_requirements: [ + { + from: 'A', + name: 'Multi Credential Request', + rule: 'pick', + count: 1, + }, + ], + }; + + const bounds = pexToBounds(pexRequest, [ + { + '@context': [ + 'https://www.w3.org/2018/credentials/v1', + 'https://ld.dock.io/credentials/extensions-v1', + 'https://ld.dock.io/security/bbs23/v1', + { + CreditScore: 'dk:CreditScore', + bankruptcies: 'dk:bankruptcies', + creditScore: 'dk:creditScore', + dk: 'https://ld.dock.io/credentials#', + }, + ], + credentialStatus: { + id: 'dock:accumulator:0xb803980eb9433bb5d5d433f60c08fcd17e82eb2eb8ae3ac88fef79a3fb2f5fd9', + type: 'DockVBAccumulator2022', + revocationCheck: 'membership', + revocationId: '7', + }, + id: 'https://creds-testnet.dock.io/15ca3b92504514756671ab5377ef23f7407f1c26c692b60363c97ba4775abab3', + type: ['VerifiableCredential', 'CreditScore'], + credentialSubject: { + name: 'tester', + creditScore: 800, + bankruptcies: 0, + }, + issuanceDate: '2024-12-13T12:43:20.925Z', + issuer: { + name: 'CIBC', + description: 'CIBC - a bank', + logo: 'https://img.dock.io/e5715cbf78f2222924f5fe4e109d76a5', + id: 'did:dock:5CwdfTvda68vfdLu4yxNRFHuhdiXDzqLxw5TkoMfX6sC784a', + }, + credentialSchema: { + id: 'https://schema.dock.io/CreditScore-V1-1732907844039.json', + type: 'JsonSchemaValidator2018', + details: + '{"jsonSchema":{"$id":"https://schema.dock.io/CreditScore-V1-1732907844039.json","$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":true,"description":"Proof of Credit","name":"Credit Score","properties":{"@context":{"type":"string"},"credentialSchema":{"properties":{"details":{"type":"string"},"id":{"type":"string"},"type":{"type":"string"},"version":{"type":"string"}},"type":"object"},"credentialStatus":{"properties":{"id":{"type":"string"},"revocationCheck":{"type":"string"},"revocationId":{"type":"string"},"type":{"type":"string"}},"type":"object"},"credentialSubject":{"properties":{"bankruptcies":{"description":"How many times have you declared bankruptcy","title":"Bankruptcies","type":"integer"},"creditScore":{"description":"","title":"Credit Score","type":"number"},"name":{"description":"Name of individual","title":"Name","type":"string"}},"required":["creditScore","bankruptcies","name"],"type":"object"},"cryptoVersion":{"type":"string"},"id":{"type":"string"},"issuanceDate":{"format":"date-time","type":"string"},"issuer":{"properties":{"description":{"type":"string"},"id":{"type":"string"},"logo":{"type":"string"},"name":{"type":"string"}},"type":"object"},"name":{"type":"string"},"proof":{"properties":{"@context":{"items":[{"properties":{"proof":{"properties":{"@container":{"type":"string"},"@id":{"type":"string"},"@type":{"type":"string"}},"type":"object"},"sec":{"type":"string"}},"type":"object"},{"type":"string"}],"type":"array"},"created":{"format":"date-time","type":"string"},"proofPurpose":{"type":"string"},"type":{"type":"string"},"verificationMethod":{"type":"string"}},"type":"object"},"type":{"type":"string"}},"type":"object"},"parsingOptions":{"defaultDecimalPlaces":4,"defaultMinimumDate":-17592186044415,"defaultMinimumInteger":-4294967295,"useDefaults":true}}', + version: '0.4.0', + }, + name: 'Credit Score', + cryptoVersion: '0.6.0', + proof: { + '@context': [ + { + sec: 'https://w3id.org/security#', + proof: { + '@id': 'sec:proof', + '@type': '@id', + '@container': '@graph', + }, + }, + 'https://ld.dock.io/security/bbs23/v1', + ], + type: 'Bls12381BBSSignatureDock2023', + created: '2024-12-13T12:43:42Z', + verificationMethod: + 'did:dock:5CwdfTvda68vfdLu4yxNRFHuhdiXDzqLxw5TkoMfX6sC784a#keys-2', + proofPurpose: 'assertionMethod', + proofValue: + 'z2PyUbLtaHuMbrdJagELMtFqroKXSoxtMaKLshc3PvT7VXpCHWWeeDMkvGf8MoKjjhNfwGPEXn9zYZuyZv7JGETWXs2TU2aSaKAHkvcmnVXcu8D', + }, + }, + ]); + + bounds.forEach(() => { + expect( + bounds[0].every(bound => bound.attributeName !== undefined), + ).toBe(true); + }); + }); }); }); From c9cd2b272e8c2857fc485574c8129ce4b280d167 Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:04:32 +0200 Subject: [PATCH 3/9] Update README.md Changes to documentation related to rebranding to Truvera --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dbb7504f..ed368e57 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# Dock Wallet SDK +# Truvera Wallet SDK The [Wallet SDK](https://github.com/docknetwork/react-native-sdk) enables you to build a Verifiable Credentials wallet inside your app and allows your users to receive, store, and manage their DOCK tokens too. This was built for mobile applications with added support for Polkadot-JS. To use the wallet-sdk, all you need to do is wrap your app in a `WalletSDKProvider` and start building your wallet. Using [polkadot-js](https://polkadot.js.org/) libraries in React Native is a challenge, due to the lack of WebAssembly support. -The Dock Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer. +The Truvera Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer. -Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher. +Truvera Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher. ## Installation ```js @@ -67,7 +67,7 @@ export default App; ## Running on other platforms -Check the following repository for detailed examples for running the Dock Wallet SDK on NodeJS, Web, and Flutter. +Check the following repository for detailed examples for running the Truvera Wallet SDK on NodeJS, Web, and Flutter. https://github.com/docknetwork/wallet-sdk-examples @@ -76,7 +76,7 @@ https://github.com/docknetwork/wallet-sdk-examples For more details you can check the [getting started guide](https://github.com/docknetwork/react-native-sdk/blob/master/docs/getting-started.md) -https://docknetwork.github.io/react-native-sdk/ +[https://docknetwork.github.io/react-native-sdk/](https://docknetwork.github.io/react-native-sdk/) ## Features - [Biometric Plugin](https://github.com/docknetwork/react-native-sdk/blob/master/docs/biometric-plugin.md) From 37019c96a8fa697dbb0318a70b39c1f7b97557cb Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:29:29 +0200 Subject: [PATCH 4/9] Update biometric-plugin.md --- docs/biometric-plugin.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/biometric-plugin.md b/docs/biometric-plugin.md index d4d345e3..e095ad68 100644 --- a/docs/biometric-plugin.md +++ b/docs/biometric-plugin.md @@ -98,12 +98,12 @@ The biometric ID should not contain the user's actual biometric information. Whe ## Using the Biometric Service Plugin -* Create a [Dock API key](../../dock-certs/creating-api-keys-and-webhook-endpoints.md) +* Create a [Truvera API key](https://docs.truvera.io/workspace/creating-api-keys-and-webhook-endpoints) * Wrap the Dock API in your mobile API (which is usually protected with an app username / password) * When a specific install does a biometric check, call your mobile API to issue a biometric credential * The biometric binding nested attributes in the primary credential should include the ecosystem and biometric issuer alongside the biometric ID - * Your mobile API calls the Dock API to do issuance to the DID - * In order to use the ecosystem definition of the credentials, the Dock API should be used to query the ecosystem that is found in the credential for the “\*biometric check” schema + * Your mobile API calls the Truvera API to do issuance to the DID + * In order to use the ecosystem definition of the credentials, the Truvera API should be used to query the ecosystem that is found in the credential for the “\*biometric check” schema * Mobile API should include the DID that the credential is pushed to * This allows the biometric check credential to be managed in the ecosystem where other participants can rely on it and VPI can be enforced * Biometric Service Plugin monitors credentials received. When a new biometric check credential is received, old ones can be deleted from wallet storage. From 150750806170e70dfaf08da2c876861c48a1936d Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:31:50 +0200 Subject: [PATCH 5/9] Update cloud-wallet.md --- docs/cloud-wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cloud-wallet.md b/docs/cloud-wallet.md index f9a6565a..a913de2b 100644 --- a/docs/cloud-wallet.md +++ b/docs/cloud-wallet.md @@ -71,7 +71,7 @@ const {pullDocuments} = await initializeCloudWallet({ await pullDocuments(); ``` -The `pullDocuments` function synchronizes the EDV and the wallet by comparing documents and updating the data store accordingly.Documents can be credentials or messages. +The `pullDocuments` function synchronizes the EDV and the wallet by comparing documents and updating the data store accordingly. Documents can be credentials or messages. ### Step 4: Create a New Wallet From 2a1f4336a09e700679c1e51686deb6b4f896369e Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:34:46 +0200 Subject: [PATCH 6/9] Update getting-started.md --- docs/getting-started.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index a957405d..7ac16525 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,6 +1,6 @@ -# Dock Wallet SDK +# Truvera Wallet SDK -This guide walks you through the process of setting up the Dock Wallet SDK, creating a wallet, managing decentralized identifiers (DIDs), adding credentials, and verifying them. +This guide walks you through the process of setting up the Truvera Wallet SDK, creating a wallet, managing decentralized identifiers (DIDs), adding credentials, and verifying them. ## Installation @@ -89,7 +89,7 @@ In this example, the credential is fetched from a specified URI and imported int ### 5. Verify a Credential -The Dock Wallet SDK provides built-in functionality for verifying credentials. This is especially useful when interacting with third parties who need to verify your credentials. The verification controller manages this process. Below is an example of how to start a verification, select which credentials to reveal, create a presentation, and submit it for verification. +The Truvera Wallet SDK provides built-in functionality for verifying credentials. This is especially useful when interacting with third parties who need to verify your credentials. The verification controller manages this process. Below is an example of how to start a verification, select which credentials to reveal, create a presentation, and submit it for verification. ```ts const { From 68b679fe40148bf9a4ea608735a924d133397d4a Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:31:29 +0200 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed368e57..820c4681 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ export default App; Check the following repository for detailed examples for running the Truvera Wallet SDK on NodeJS, Web, and Flutter. -https://github.com/docknetwork/wallet-sdk-examples +[https://github.com/docknetwork/wallet-sdk-examples](https://github.com/docknetwork/wallet-sdk-examples) ## Docs From ff037dcff9a90bf6b8fead628ba0947c4a8def1a Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:27:33 +0200 Subject: [PATCH 8/9] Update README.md trying again to make the links work on gitbook --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 820c4681..911ce04e 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,14 @@ export default App; Check the following repository for detailed examples for running the Truvera Wallet SDK on NodeJS, Web, and Flutter. -[https://github.com/docknetwork/wallet-sdk-examples](https://github.com/docknetwork/wallet-sdk-examples) +[See the examples](https://github.com/docknetwork/wallet-sdk-examples) ## Docs For more details you can check the [getting started guide](https://github.com/docknetwork/react-native-sdk/blob/master/docs/getting-started.md) -[https://docknetwork.github.io/react-native-sdk/](https://docknetwork.github.io/react-native-sdk/) +[See the Github repository](https://docknetwork.github.io/react-native-sdk/) ## Features - [Biometric Plugin](https://github.com/docknetwork/react-native-sdk/blob/master/docs/biometric-plugin.md) From 0c6e7e287470db5e2979891d966c2bf7a1c1888a Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:01:27 +0200 Subject: [PATCH 9/9] Update biometric-plugin.md --- docs/biometric-plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/biometric-plugin.md b/docs/biometric-plugin.md index e095ad68..5eb5dec7 100644 --- a/docs/biometric-plugin.md +++ b/docs/biometric-plugin.md @@ -99,7 +99,7 @@ The biometric ID should not contain the user's actual biometric information. Whe ## Using the Biometric Service Plugin * Create a [Truvera API key](https://docs.truvera.io/workspace/creating-api-keys-and-webhook-endpoints) -* Wrap the Dock API in your mobile API (which is usually protected with an app username / password) +* Wrap the Truvera API in your mobile API (which is usually protected with an app username / password) * When a specific install does a biometric check, call your mobile API to issue a biometric credential * The biometric binding nested attributes in the primary credential should include the ecosystem and biometric issuer alongside the biometric ID * Your mobile API calls the Truvera API to do issuance to the DID