Skip to content

Commit

Permalink
fix: Add context only for linkedDomains (#381)
Browse files Browse the repository at this point in the history
* fix: Add context only for linkedDomains

* Refactor

* npm update

* Revert "npm update"

This reverts commit 4243677.

* dont bump file-type

* Revert "dont bump file-type"

This reverts commit 5d2ff8c.

* actually dont bump file-type

* Revert "actually dont bump file-type"

This reverts commit fc8b350.

* npm install

* Revert "npm install"

This reverts commit cdacf64.

* Skip ts-jest

* bump typescript also

* Rename context variable to something more sensible

---------

Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
  • Loading branch information
DaevMithran and ankurdotb authored Sep 10, 2024
1 parent 96f14e8 commit be87fdd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
29 changes: 16 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": {
Expand Down
12 changes: 5 additions & 7 deletions src/modules/did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SpecValidationResult,
VerificationMethods,
DIDDocumentWithMetadata,
ServiceType,
} from '../types.js';
import {
MsgCreateDidDoc,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand All @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ export const ISignInputs = {
return object.some((x) => 'privateKeyHex' in x);
},
};

export enum ServiceType {
LinkedDomains = 'LinkedDomains',
}

0 comments on commit be87fdd

Please sign in to comment.