From be87fddd398fcc6a9995ad86855549b146baac28 Mon Sep 17 00:00:00 2001 From: DaevMithran <61043607+DaevMithran@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:34:40 +0530 Subject: [PATCH] fix: Add context only for linkedDomains (#381) * fix: Add context only for linkedDomains * Refactor * npm update * Revert "npm update" This reverts commit 4243677bdcbb65e2b35aa2e92b85d4ad1bfc8955. * dont bump file-type * Revert "dont bump file-type" This reverts commit 5d2ff8c4920c063f99987a168e05c792873147b2. * actually dont bump file-type * Revert "actually dont bump file-type" This reverts commit fc8b350608ba00ddcf90ab9950f5ab318ca5bc6d. * npm install * Revert "npm install" This reverts commit cdacf64a404c93a62570789f497d640bec502ac1. * Skip ts-jest * bump typescript also * Rename context variable to something more sensible --------- Co-authored-by: Ankur Banerjee --- package-lock.json | 29 ++++++++++++++++------------- package.json | 8 ++++---- src/modules/did.ts | 12 +++++------- src/types.ts | 4 ++++ 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0574c256..198d672c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "cosmjs-types": "^0.9.0", "did-jwt": "^8.0.4", "did-resolver": "^4.1.0", - "file-type": "^19.4.1", + "file-type": "^19.5.0", "multiformats": "^13.2.2", "secp256k1": "^5.0.0", "uuid": "^10.0.0" @@ -36,16 +36,16 @@ "@semantic-release/npm": "^12.0.1", "@semantic-release/release-notes-generator": "^14.0.1", "@types/jest": "^29.5.12", - "@types/node": "^20.16.1", + "@types/node": "^20.16.5", "@types/uuid": "^10.0.0", "conventional-changelog-conventionalcommits": "^8.0.0", "cross-env": "^7.0.3", "jest": "^29.7.0", "prettier": "^3.3.3", - "semantic-release": "^24.0.0", + "semantic-release": "^24.1.0", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", - "typescript": "^5.5.4", + "typescript": "^5.6.2", "uint8arrays": "^5.1.0" }, "engines": { @@ -2195,9 +2195,10 @@ "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "node_modules/@types/node": { - "version": "20.16.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", - "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", + "version": "20.16.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.5.tgz", + "integrity": "sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==", + "license": "MIT", "dependencies": { "undici-types": "~6.19.2" } @@ -3930,9 +3931,10 @@ } }, "node_modules/file-type": { - "version": "19.4.1", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-19.4.1.tgz", - "integrity": "sha512-RuWzwF2L9tCHS76KR/Mdh+DwJZcFCzrhrPXpOw6MlEfl/o31fjpTikzcKlYuyeV7e7ftdCGVJTNOCzkYD/aLbw==", + "version": "19.5.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-19.5.0.tgz", + "integrity": "sha512-dMuq6WWnP6BpQY0zYJNpTtQWgeCImSMG0BTIzUBXvxbwc1HWP/E7AE4UWU9XSCOPGJuOHda0HpDnwM2FW+d90A==", + "license": "MIT", "dependencies": { "get-stream": "^9.0.1", "strtok3": "^8.1.0", @@ -11200,10 +11202,11 @@ } }, "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 94dcaa77..856b9e61 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "cosmjs-types": "^0.9.0", "did-jwt": "^8.0.4", "did-resolver": "^4.1.0", - "file-type": "^19.4.1", + "file-type": "^19.5.0", "multiformats": "^13.2.2", "secp256k1": "^5.0.0", "uuid": "^10.0.0" @@ -79,16 +79,16 @@ "@semantic-release/npm": "^12.0.1", "@semantic-release/release-notes-generator": "^14.0.1", "@types/jest": "^29.5.12", - "@types/node": "^20.16.1", + "@types/node": "^20.16.5", "@types/uuid": "^10.0.0", "conventional-changelog-conventionalcommits": "^8.0.0", "cross-env": "^7.0.3", "jest": "^29.7.0", "prettier": "^3.3.3", - "semantic-release": "^24.0.0", + "semantic-release": "^24.1.0", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", - "typescript": "^5.5.4", + "typescript": "^5.6.2", "uint8arrays": "^5.1.0" }, "publishConfig": { diff --git a/src/modules/did.ts b/src/modules/did.ts index 42fa2130..6d440acc 100644 --- a/src/modules/did.ts +++ b/src/modules/did.ts @@ -10,6 +10,7 @@ import { SpecValidationResult, VerificationMethods, DIDDocumentWithMetadata, + ServiceType, } from '../types.js'; import { MsgCreateDidDoc, @@ -45,7 +46,7 @@ export const contexts = { W3CSuiteEd255192020: 'https://w3id.org/security/suites/ed25519-2020/v1', W3CSuiteEd255192018: 'https://w3id.org/security/suites/ed25519-2018/v1', W3CSuiteJws2020: 'https://w3id.org/security/suites/jws-2020/v1', - DIFDIDConfiguration: 'https://identity.foundation/.well-known/did-configuration/v1', + LinkedDomainsContext: 'https://identity.foundation/.well-known/did-configuration/v1', } as const; export const protobufLiterals = { @@ -538,6 +539,9 @@ export class DIDModule extends AbstractCheqdSDKModule { }); const service = protobufDidDocument.service.map((s) => { + if (s.serviceType === ServiceType.LinkedDomains) + protobufDidDocument.context = [...protobufDidDocument.context, contexts.LinkedDomainsContext]; + return { id: s.id, type: s.serviceType, @@ -546,12 +550,6 @@ export class DIDModule extends AbstractCheqdSDKModule { }); const context = (function () { - if ( - protobufDidDocument.service.length && - !protobufDidDocument.context.includes(contexts.DIFDIDConfiguration) - ) - protobufDidDocument.context.push(contexts.DIFDIDConfiguration); - if (protobufDidDocument.context.includes(contexts.W3CDIDv1)) return protobufDidDocument.context; return [contexts.W3CDIDv1, ...protobufDidDocument.context]; diff --git a/src/types.ts b/src/types.ts index 120d8d69..e04e4f17 100644 --- a/src/types.ts +++ b/src/types.ts @@ -102,3 +102,7 @@ export const ISignInputs = { return object.some((x) => 'privateKeyHex' in x); }, }; + +export enum ServiceType { + LinkedDomains = 'LinkedDomains', +}