From 72c8cdbb57ce3ebec507d82fb607347a7764bfb6 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 13 Feb 2023 16:12:28 +0100 Subject: [PATCH 1/6] fix: jsdocs for public credential fetch* functions (#723) Update JSDocs for public credential fetch* functions --- .../src/publicCredential/PublicCredential.chain.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/core/src/publicCredential/PublicCredential.chain.ts b/packages/core/src/publicCredential/PublicCredential.chain.ts index cc4488892..2c3b1604e 100644 --- a/packages/core/src/publicCredential/PublicCredential.chain.ts +++ b/packages/core/src/publicCredential/PublicCredential.chain.ts @@ -152,12 +152,11 @@ function extractDidCallsFromBatchCall( } /** - * Decodes the public credential details returned by `api.call.publicCredentials.getById()`. + * Retrieves from the blockchain the [[IPublicCredential]] that is identified by the provided identifier. * * This is the **only** secure way for users to retrieve and verify a credential. - * Hence, calling `api.call.publicCredentials.getById(credentialId)` and then passing the result to this function is the only way to trust that a credential with a given ID is valid. * - * @param credentialId Credential ID to use for the query. It is required to complement the information stored on the blockchain in a [[PublicCredentialsCredentialsCredentialEntry]]. + * @param credentialId Credential ID to use for the query. * @returns The [[IPublicCredential]] as the result of combining the on-chain information and the information present in the tx history. */ export async function fetchCredentialFromChain( @@ -242,13 +241,12 @@ export async function fetchCredentialFromChain( } /** - * Decodes the public credential details returned by `api.call.publicCredentials.getBySubject()`. + * Retrieves from the blockchain the [[IPublicCredential]]s that have been issued to the provided AssetDID. * * This is the **only** secure way for users to retrieve and verify all the credentials issued to a given [[AssetDidUri]]. - * Hence, calling `api.call.publicCredentials.getBySubject(asset_id)` and then passing the result to this function is the only way to trust that the credentials for a given AssetDID are valid. * * @param subject The AssetDID of the subject. - * @returns An array of [[IPublicCredential]] as the result of combining the on-chain information and the information present in the tx history. If the result is an error, it maps it to the right error type. + * @returns An array of [[IPublicCredential]] as the result of combining the on-chain information and the information present in the tx history. */ export async function fetchCredentialsFromChain( subject: AssetDidUri From 1b3b0e75c5deddc5bdf5460323d8c57dd96bfb49 Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 14 Feb 2023 16:01:03 +0100 Subject: [PATCH 2/6] fix: light DID decoding logic (#725) * Fix light DID decoding logic * Remove irrelevant resolver unit test * Revert usage of ...rest --- .../did/src/DidDetails/LightDidDetails.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/did/src/DidDetails/LightDidDetails.ts b/packages/did/src/DidDetails/LightDidDetails.ts index 13eafa8b3..62331329b 100644 --- a/packages/did/src/DidDetails/LightDidDetails.ts +++ b/packages/did/src/DidDetails/LightDidDetails.ts @@ -110,7 +110,11 @@ const SERVICES_MAP_KEY = 's' interface SerializableStructure { [KEY_AGREEMENT_MAP_KEY]?: NewDidEncryptionKey - [SERVICES_MAP_KEY]?: Array & { id: string }> + [SERVICES_MAP_KEY]?: Array< + Partial> & { + id: string + } & { types?: string[]; urls?: string[] } // This below was mistakenly not accounted for during the SDK refactor, meaning there are light DIDs that contain these keys in their service endpoints. + > } /** @@ -167,10 +171,15 @@ function deserializeAdditionalLightDidDetails( const keyAgreement = deserialized[KEY_AGREEMENT_MAP_KEY] return { keyAgreement: keyAgreement && [keyAgreement], - service: deserialized[SERVICES_MAP_KEY]?.map(({ id, ...rest }) => ({ - id: `#${id}`, - ...rest, - })), + service: deserialized[SERVICES_MAP_KEY]?.map( + ({ id, type, serviceEndpoint, types, urls }) => ({ + id: `#${id}`, + // types for retro-compatibility + type: (type ?? types) as string[], + // urls for retro-compatibility + serviceEndpoint: (serviceEndpoint ?? urls) as string[], + }) + ), } } From bd35921f8da1e60a923940afb1ff33d25fba1209 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 15 Feb 2023 14:55:18 +0100 Subject: [PATCH 3/6] chore: move DidExporter snippets to docs (#722) * Add placeholder for DidExporter docs * Replace placeholder with actual docs link --- .../did/src/DidDocumentExporter/README.md | 55 +------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/packages/did/src/DidDocumentExporter/README.md b/packages/did/src/DidDocumentExporter/README.md index 2fc3653d8..216659f99 100644 --- a/packages/did/src/DidDocumentExporter/README.md +++ b/packages/did/src/DidDocumentExporter/README.md @@ -2,57 +2,4 @@ The DID Document exporter provides the functionality needed to convert an instance of a generic `DidDocument` into a document that is compliant with the [W3C specification](https://www.w3.org/TR/did-core/). This component is required for the KILT plugin for the [DIF Universal Resolver](https://dev.uniresolver.io/). -## How to use the exporter - -The exporter interface and used types are part of the `@kiltprotocol/types` package, while the actual `DidDocumentExporter` is part of this module. The following shows how to use the exporter to generate a DID Document for both a light and a full DID. - -Currently, the exporter supports DID Documents in `application/json` and `application/ld+json` format. - -```typescript -import * as Did from '@kiltprotocol/did' - -import type { - ConformingDidDocument, - DidDocument, -} from '@kiltprotocol/types' - -// Create `DidDocument` with the required information -const lightDid: DidDocument = Did.createLightDidDocument({ ... }) - -const lightDidDocument: ConformingDidDocument = Did.exportToDidDocument( - lightDid, - 'application/json' -) - -// Will print the light DID. -console.log(lightDidDocument.id) - -// Will print all the public keys associated with the light DID. -console.log(lightDidDocument.verificationMethod) - -// Will print all the assertion keys. -console.log(lightDidDocument.assertionMethod) - -// Will print all the encryption keys. -console.log(lightDidDocument.keyAgreement) - -// Will print all the delegation keys. -console.log(lightDidDocument.capabilityDelegation) - -// Will print all the external services referenced inside the `DidDocument` instance. -console.log(lightDidDocument.service) - -// Let's export `DidDocument` using the `application/ld+json` format. - -const fullDid = (await Did.resolve('...'))?.document -if (!fullDid) throw new Error('This DID does not exist or has been deactivated') - -// The document type will be a `JsonLDDidDocument`, which extends the simpler `ConformingDidDocument`. -const fullDidDocument: ConformingDidDocument = Did.exportToDidDocument( - fullDid, - 'application/ld+json' -) - -// The same properties of `ConformingDidDocument` can be accessed, plus a `@context` property required by the JSON-LD specification. -console.log(fullDidDocument['@context']) -``` +For a list of examples and code snippets, please refer to our [official documentation](https://docs.kilt.io/docs/develop/sdk/cookbook/dids/did-export). \ No newline at end of file From 8aeb9625e8923d3227058c9f2862b4ecd2f2b990 Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Wed, 15 Feb 2023 16:50:40 -0500 Subject: [PATCH 4/6] chore: fix styling --- packages/did/src/DidDocumentExporter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/did/src/DidDocumentExporter/README.md b/packages/did/src/DidDocumentExporter/README.md index 216659f99..e9c90965e 100644 --- a/packages/did/src/DidDocumentExporter/README.md +++ b/packages/did/src/DidDocumentExporter/README.md @@ -2,4 +2,4 @@ The DID Document exporter provides the functionality needed to convert an instance of a generic `DidDocument` into a document that is compliant with the [W3C specification](https://www.w3.org/TR/did-core/). This component is required for the KILT plugin for the [DIF Universal Resolver](https://dev.uniresolver.io/). -For a list of examples and code snippets, please refer to our [official documentation](https://docs.kilt.io/docs/develop/sdk/cookbook/dids/did-export). \ No newline at end of file +For a list of examples and code snippets, please refer to our [official documentation](https://docs.kilt.io/docs/develop/sdk/cookbook/dids/did-export). From 046df7ed6bd6c6f63cf2f86419a44844f5cba0fe Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Tue, 21 Feb 2023 11:59:55 -0500 Subject: [PATCH 5/6] chore: set version 0.31.1-rc.1 --- package.json | 2 +- packages/asset-did/package.json | 2 +- packages/augment-api/package.json | 2 +- packages/chain-helpers/package.json | 2 +- packages/config/package.json | 2 +- packages/core/package.json | 2 +- packages/did/package.json | 2 +- packages/messaging/package.json | 2 +- packages/sdk-js/package.json | 2 +- packages/testing/package.json | 2 +- packages/type-definitions/package.json | 2 +- packages/types/package.json | 2 +- packages/utils/package.json | 2 +- packages/vc-export/package.json | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index b3dabdef8..7015884b7 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,6 @@ "typedoc": "^0.22.15", "typescript": "^4.8.3" }, - "version": "0.31.0", + "version": "0.31.1-rc.1", "packageManager": "yarn@3.3.1" } diff --git a/packages/asset-did/package.json b/packages/asset-did/package.json index ac11535ab..b90314704 100644 --- a/packages/asset-did/package.json +++ b/packages/asset-did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/asset-did", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/augment-api/package.json b/packages/augment-api/package.json index 2acacfbb3..e2c5cffb1 100644 --- a/packages/augment-api/package.json +++ b/packages/augment-api/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/augment-api", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/chain-helpers/package.json b/packages/chain-helpers/package.json index a3c188286..9d9491abf 100644 --- a/packages/chain-helpers/package.json +++ b/packages/chain-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/chain-helpers", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/config/package.json b/packages/config/package.json index 7fbce323f..0a6520aac 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/config", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/core/package.json b/packages/core/package.json index f3d69719d..cb5e808d2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/core", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/did/package.json b/packages/did/package.json index 99e32eff0..4a506497a 100644 --- a/packages/did/package.json +++ b/packages/did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/did", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/messaging/package.json b/packages/messaging/package.json index 857d866d0..e8d28b1be 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/messaging", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/sdk-js/package.json b/packages/sdk-js/package.json index 92dcac97e..e3a304db3 100644 --- a/packages/sdk-js/package.json +++ b/packages/sdk-js/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/sdk-js", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/testing/package.json b/packages/testing/package.json index 3f0831625..b6cb02e37 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@kiltprotocol/testing", "private": true, - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/type-definitions/package.json b/packages/type-definitions/package.json index 781c7ea17..59ae91751 100644 --- a/packages/type-definitions/package.json +++ b/packages/type-definitions/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/type-definitions", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/types/package.json b/packages/types/package.json index b5819db5b..006944023 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/types", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/utils/package.json b/packages/utils/package.json index 6cc2008cc..cd2446152 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/utils", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/vc-export/package.json b/packages/vc-export/package.json index 7082d2c97..e09543989 100644 --- a/packages/vc-export/package.json +++ b/packages/vc-export/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/vc-export", - "version": "0.31.0", + "version": "0.31.1-rc.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", From b00b16e305da9f73ca6a38a82f56f1c1876a49a3 Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Wed, 22 Feb 2023 11:27:08 -0500 Subject: [PATCH 6/6] chore: v0.31.1 --- package.json | 2 +- packages/asset-did/package.json | 2 +- packages/augment-api/package.json | 2 +- packages/chain-helpers/package.json | 2 +- packages/config/package.json | 2 +- packages/core/package.json | 2 +- packages/did/package.json | 2 +- packages/messaging/package.json | 2 +- packages/sdk-js/package.json | 2 +- packages/testing/package.json | 2 +- packages/type-definitions/package.json | 2 +- packages/types/package.json | 2 +- packages/utils/package.json | 2 +- packages/vc-export/package.json | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 7015884b7..509b3df4e 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,6 @@ "typedoc": "^0.22.15", "typescript": "^4.8.3" }, - "version": "0.31.1-rc.1", + "version": "0.31.1", "packageManager": "yarn@3.3.1" } diff --git a/packages/asset-did/package.json b/packages/asset-did/package.json index b90314704..bc01d1480 100644 --- a/packages/asset-did/package.json +++ b/packages/asset-did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/asset-did", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/augment-api/package.json b/packages/augment-api/package.json index e2c5cffb1..7b19b1f32 100644 --- a/packages/augment-api/package.json +++ b/packages/augment-api/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/augment-api", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/chain-helpers/package.json b/packages/chain-helpers/package.json index 9d9491abf..5c1be608d 100644 --- a/packages/chain-helpers/package.json +++ b/packages/chain-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/chain-helpers", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/config/package.json b/packages/config/package.json index 0a6520aac..70ed719c4 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/config", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/core/package.json b/packages/core/package.json index cb5e808d2..68183626f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/core", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/did/package.json b/packages/did/package.json index 4a506497a..4a7ece206 100644 --- a/packages/did/package.json +++ b/packages/did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/did", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/messaging/package.json b/packages/messaging/package.json index e8d28b1be..254d10375 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/messaging", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/sdk-js/package.json b/packages/sdk-js/package.json index e3a304db3..d3e8b099a 100644 --- a/packages/sdk-js/package.json +++ b/packages/sdk-js/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/sdk-js", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/testing/package.json b/packages/testing/package.json index b6cb02e37..98c22a174 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@kiltprotocol/testing", "private": true, - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/type-definitions/package.json b/packages/type-definitions/package.json index 59ae91751..a1b2d8300 100644 --- a/packages/type-definitions/package.json +++ b/packages/type-definitions/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/type-definitions", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/types/package.json b/packages/types/package.json index 006944023..edb622587 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/types", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/utils/package.json b/packages/utils/package.json index cd2446152..33694f7b4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/utils", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/vc-export/package.json b/packages/vc-export/package.json index e09543989..0ffe3c36f 100644 --- a/packages/vc-export/package.json +++ b/packages/vc-export/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/vc-export", - "version": "0.31.1-rc.1", + "version": "0.31.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js",