Skip to content

Commit

Permalink
chore: release 0.31.1 (#728)
Browse files Browse the repository at this point in the history
* fix: jsdocs for public credential fetch* functions (#723)
* fix: light DID decoding logic (#725)
* chore: move DidExporter snippets to docs (#722)
* chore: v0.31.1
---------

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
rflechtner and ntn-x2 authored Mar 1, 2023
2 parents 103597b + b00b16e commit 5c3d4d2
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 79 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"typedoc": "^0.22.15",
"typescript": "^4.8.3"
},
"version": "0.31.0",
"version": "0.31.1",
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/asset-did/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/asset-did",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/augment-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/augment-api",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/chain-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/chain-helpers",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/config",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/core",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/publicCredential/PublicCredential.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/did/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/did",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
19 changes: 14 additions & 5 deletions packages/did/src/DidDetails/LightDidDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ const SERVICES_MAP_KEY = 's'

interface SerializableStructure {
[KEY_AGREEMENT_MAP_KEY]?: NewDidEncryptionKey
[SERVICES_MAP_KEY]?: Array<Omit<DidServiceEndpoint, 'id'> & { id: string }>
[SERVICES_MAP_KEY]?: Array<
Partial<Omit<DidServiceEndpoint, 'id'>> & {
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.
>
}

/**
Expand Down Expand Up @@ -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[],
})
),
}
}

Expand Down
55 changes: 1 addition & 54 deletions packages/did/src/DidDocumentExporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
2 changes: 1 addition & 1 deletion packages/messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/messaging",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/sdk-js",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kiltprotocol/testing",
"private": true,
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/type-definitions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/type-definitions",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/types",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/utils",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/vc-export/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/vc-export",
"version": "0.31.0",
"version": "0.31.1",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down

0 comments on commit 5c3d4d2

Please sign in to comment.