Skip to content

Commit

Permalink
feat: enable storage service encrypted endpoint (#157)
Browse files Browse the repository at this point in the history
* feat: enable storage service encrypted endpoint

* chore: remove resultPath propety in  docs and unit tests

* docs: update verify-app documentation to describe the decryption process

* test: add additional test case for the constructVerifyURL function

* test: add additional test case for the constructVerifyURL function

* chore: update mock data

* chore: update scanning page to use the textHtml mime type link set

* chore: update the error message for the verify page and its unit tests

* Merge branch 'next' into feat/enable-storage-service-encrypted-endpoint

---------

Co-authored-by: Nam Hoang <[email protected]>
  • Loading branch information
huynguyen-hl and namhoang1604 authored Nov 28, 2024
1 parent c3d091f commit 97a4ca5
Show file tree
Hide file tree
Showing 53 changed files with 358 additions and 290 deletions.
57 changes: 9 additions & 48 deletions app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,24 +651,6 @@
"name": "CustomButton",
"type": "Submit",
"props": {}
},
{
"name": "BarcodeGenerator",
"type": "Result",
"props": {
"dataPath": {
"primary": {
"ai": "01",
"path": "/decodedEnvelopedVC/credentialSubject/registeredId"
},
"qualifiers": [
{
"ai": "10",
"path": "/decodedEnvelopedVC/credentialSubject/batchNumber"
}
]
}
}
}
],
"services": [
Expand Down Expand Up @@ -705,9 +687,8 @@
"linkRegisterPath": "/api/resolver"
},
"storage": {
"url": "http://localhost:3334/v1/documents",
"url": "http://localhost:3334/v1/credentials",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -1371,18 +1352,6 @@
"name": "CustomButton",
"type": "Submit",
"props": {}
},
{
"name": "BarcodeGenerator",
"type": "Result",
"props": {
"dataPath": {
"primary": {
"ai": "01",
"path": "/decodedEnvelopedVC/credentialSubject/registeredId"
}
}
}
}
],
"services": [
Expand Down Expand Up @@ -1647,7 +1616,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -2594,7 +2562,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -2771,7 +2738,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -2952,7 +2918,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -3133,7 +3098,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -3335,7 +3299,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -3836,7 +3799,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -4253,7 +4215,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -4916,7 +4877,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -5137,7 +5097,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -5818,7 +5777,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -6039,7 +5997,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand All @@ -6050,7 +6007,10 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "fumigation_and_freight_forwarding_facility_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": {
"storageKey": "fumigation_and_freight_forwarding_facility_dpps",
"keyPath": "/0/epcList/index/name"
}
}
]
},
Expand Down Expand Up @@ -6720,7 +6680,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -6941,7 +6900,6 @@
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand All @@ -6952,7 +6910,10 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "airport_terminal_facility_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": {
"storageKey": "airport_terminal_facility_dpps",
"keyPath": "/0/epcList/index/name"
}
}
]
},
Expand Down
2 changes: 0 additions & 2 deletions documentation/docs/mock-apps/common/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The `Storage` object is responsible for managing the configuration of the [Stora
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down Expand Up @@ -46,7 +45,6 @@ The `params` object contains specific parameters for the storage service.
| Property | Required | Description | Type |
| ---------- | -------- | -------------------------------------------------------------------- | ------ |
| bucket | Yes | The name of the storage bucket | String |
| resultPath | Yes | The path where the result (e.g., URI) will be stored in the response | String |

### options

Expand Down
5 changes: 3 additions & 2 deletions documentation/docs/mock-apps/common/verify-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ The general structure of the verify link is as follows:

### Decoded (Human-readable) Example:
```
http://localhost:3001/verify?q={payload:{uri:http://localhost:3001/conformity-credentials/steel-mill-1-emissions.json}}
http://localhost:3001/verify?q={payload:{uri:'http://localhost:3001/conformity-credentials/steel-mill-1-emissions.json', key:'secret', hash:'595d8d20c586c6f55f8a758f294674fa85069db5c518a0f4cbbd3fd61f46522f'}}
```

### Encoded (URL-safe) Example:
```
http://localhost:3001/verify?q%3D%7Bpayload%3A%7Buri%3Ahttp%3A%2F%2Flocalhost%3A3001%2Fconformity-credentials%2Fsteel-mill-1-emissions.json%7D%7D
http://localhost:3001/verify?q%3D%7B%22payload%22%3A%7B%22uri%22%3A%22http%3A%2F%2Flocalhost%3A3001%2Fconformity-credentials%2Fsteel-mill-1-emissions.json%22%2C%22key%22%3A%22secret%22%2C%22hash%22%3A%22595d8d20c586c6f55f8a758f294674fa85069db5c518a0f4cbbd3fd61f46522f%22%7D%7D
```

### Production Example:
```
https://www.example.com/verify?q=%7B%22payload%22%3A%7B%22uri%22%3A%22https%3A%2F%2Fstorage.googleapis.com%2Fverifiable-credentials%2Fconformity-credentials%2Ftop-line-steel-dcc.json%22%7D%7D
https://www.example.com/verify?q=%7B%22payload%22%3A%7B%22uri%22%3A%22https%3A%2F%2Fstorage.googleapis.com%2Fverifiable-credentials%2Fconformity-credentials%2Ftop-line-steel-dcc.json%22%2C%22key%22%3A%22secret%22%2C%22hash%22%3A%22595d8d20c586c6f55f8a758f294674fa85069db5c518a0f4cbbd3fd61f46522f%22%7D%7D
```
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ The ConformityCredential component allows users to request and manage conformity
"storedCredentialsConfig": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ graph TD
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
1 change: 0 additions & 1 deletion documentation/docs/mock-apps/conformity-credential.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ Example config snippet:
"storedCredentialsConfig": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
1 change: 0 additions & 1 deletion documentation/docs/mock-apps/services/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ graph TD
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ P-->>C: Return VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ P-->>C: Return association event VC and resolver URL
"url": "https://storage.example.com/upload",
"params": {
"bucket": "bucket-name",
"resultPath": "/url"
}
},
"dlr": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ P-->>C: Return digital conformity credential VC and resolver URL
"url": "https://storage.example.com/upload",
"params": {
"bucket": "bucket-name",
"resultPath": "/url"
}
},
"dlr": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ P-->>C: Return digital facility record VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ P-->>C: Return digital identity anchor VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
1 change: 0 additions & 1 deletion documentation/docs/mock-apps/services/process-dpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ P-->>C: Return VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ P-->>C: Return object event VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ P-->>C: Return event VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ P-->>C: Return VC and resolver URL
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ P-->>C: Return transformation event VC and resolver URL
"url": "https://storage.example.com/upload",
"params": {
"bucket": "bucket-name",
"resultPath": "/url"
}
},
"dlr": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ P-->>C: Return EPCIS VC
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
Expand Down
4 changes: 4 additions & 0 deletions documentation/docs/mock-apps/verify-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ To ensure the integrity of the credential, a hash value is included in the verif
Upon retrieval of the credential, the application will compute its hash and compare it with the provided value in the URL. If the computed hash matches the provided hash, the credential is considered valid and unaltered.

The hash is optional and can be omitted from the verification link. If the hash is not provided, the credential will not be validated against it.

## Decryption (if required)

If the credential is encrypted, the decryption key is included in the verification link. The application will use this key to decrypt the credential before proceeding with the verification process.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ describe('ConformityCredential', () => {

const storedCredentialsConfig = {
url: 'https://example.com',
params: {
resultPath: '',
},
params: {},
};

render(
Expand Down Expand Up @@ -82,9 +80,7 @@ describe('ConformityCredential', () => {

const storedCredentialsConfig = {
url: 'https://example.com',
params: {
resultPath: '',
},
params: {},
};

it('should save credential as string when trigger onClickStorageCredential function', async () => {
Expand Down
8 changes: 2 additions & 6 deletions packages/components/src/__tests__/ConformityUtils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ describe('checkStoredCredentials', () => {
it('should return the stored credentials if they are valid', () => {
const storedCredentials = {
url: 'https://example.com',
params: {
resultPath: '',
},
params: {},
};

const result = checkStoredCredentialsConfig(storedCredentials);
Expand All @@ -23,9 +21,7 @@ describe('checkStoredCredentials', () => {
it('should throw an error if the stored credentials url is invalid', () => {
const storedCredentials = {
url: '',
params: {
resultPath: '',
},
params: {},
};

const result = checkStoredCredentialsConfig(storedCredentials);
Expand Down
Loading

0 comments on commit 97a4ca5

Please sign in to comment.