Skip to content

Commit

Permalink
Merge branch 'master' into feat/cheqd-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello authored Dec 4, 2024
2 parents dab2cd1 + 41055b6 commit cfeab2a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
13 changes: 7 additions & 6 deletions docs/cloud-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ The Cloud Wallet integrates with an [Encrypted Data Vault (EDV)](https://digital

The example below demonstrates how to initialize and use the Cloud Wallet for managing documents.


### Step 1: Initialize the Data Store

First, you need to create local data storage to connect to the credential wallet.

#### For Mobile and Node.js

```ts
Expand All @@ -40,7 +41,7 @@ const dataStore = await createDataStore({

### Step 2: Generate Wallet Keys

Use the same Cloud Wallet keys across multiple devices to access the same documents. These keys are used to encrypt, decrypt, and locate documents in the EDV.
Next, we generate keys for interacting with the cloud wallet. Use the same Cloud Wallet keys across multiple devices to access the same documents. These keys are used to encrypt, decrypt, and locate documents in the EDV.

```ts
const {verificationKey, agreementKey, hmacKey} = await edvService.generateKeys();
Expand All @@ -52,7 +53,7 @@ The key generation returns an object with `agreementKey`, `verificationKey`, and

### Step 3: Initialize the Cloud Wallet

After setting up the data store and generating keys, initialize the Cloud Wallet. This ensures continuous synchronization between the EDV and the wallet.
After setting up the data store and generating keys, initialize the Cloud Wallet and connect it to the local data storage. This ensures continuous synchronization between the EDV and the wallet.

```ts
import {initializeCloudWallet} from '@docknetwork/wallet-sdk-core/lib/cloud-wallet';
Expand All @@ -70,11 +71,11 @@ const {pullDocuments} = await initializeCloudWallet({
await pullDocuments();
```

The `pullDocuments` function synchronizes the EDV and the wallet by comparing documents and updating the data store accordingly.
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

Now, create a wallet to manage your documents. This will allow you to add, update, and remove documents.
Now, create a credential wallet inside of the data storage. This will allow you to add, update, and remove documents.

```ts
import {createWallet} from '@docknetwork/wallet-sdk-core/lib/wallet';
Expand Down Expand Up @@ -142,4 +143,4 @@ async function example() {

example();

```
```
12 changes: 9 additions & 3 deletions packages/wasm/src/services/pex/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ export function removeOptionalAttribute(presentationDefinition) {
field => field.optional !== true,
);

// Removes the optinal attributes from the fields
// It applies in case optional: false
// The field is required, but pex doesn't support the attribute

inputDescriptor.constraints.fields.forEach(field => {
// Removes the optinal attributes from the fields
// It applies in case optional: false
// The field is required, but pex doesn't support the attribute
if (field.optional !== undefined) {
delete field.optional;
}

// Remove the did format attribute, that is not support by pex
if(field?.filter?.format === 'did') {
delete field.filter.format;
}
});

// There is a case where ALL fields are optional
Expand Down
6 changes: 6 additions & 0 deletions packages/wasm/src/services/pex/tests/pex-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ describe('Pex Examples', () => {
fields: [
{
path: ['$.credentialSubject.id'],
filter: {
format: 'did',
},
},
{
path: ['$.type[*]'],
Expand All @@ -441,6 +444,9 @@ describe('Pex Examples', () => {
result = removeOptionalAttribute(template);
expect(getFieldsWithOptionalAttributes(result)).toBe(0);
expect(result.input_descriptors[0].constraints.fields.length).toBe(1);
expect(
result.input_descriptors[0].constraints.fields[0].filter.format,
).toBeUndefined();

template = {
id: 'income_test',
Expand Down

0 comments on commit cfeab2a

Please sign in to comment.