Skip to content

Commit

Permalink
Merge branch 'master' into feat/update-cheqd-libs
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello authored Jan 8, 2025
2 parents 2ebfe3a + aebd737 commit f496261
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 28 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -67,16 +67,16 @@ 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
[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/
[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)
Expand Down
8 changes: 4 additions & 4 deletions docs/biometric-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* Wrap the Dock API in your mobile API (which is usually protected with an app username / password)
* Create a [Truvera API key](https://docs.truvera.io/workspace/creating-api-keys-and-webhook-endpoints)
* 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 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.
Expand Down
2 changes: 1 addition & 1 deletion docs/cloud-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 7 additions & 9 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -91,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 {
Expand Down
20 changes: 12 additions & 8 deletions packages/wasm/src/services/credential/pex-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
203 changes: 203 additions & 0 deletions packages/wasm/src/services/credential/pex-helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

0 comments on commit f496261

Please sign in to comment.