@twin.org/standards-w3c-did 0.0.3-next.61 → 0.0.3-next.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"verifiableCredentialHelper.js","sourceRoot":"","sources":["../../../src/utils/verifiableCredentialHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;;OAIG;IACI,MAAM,CAAC,UAAU,CACvB,oBAA8C;QAE9C,MAAM,cAAc,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QAC1F,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;QACD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAC9B,oBAA8C;QAE9C,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAI,CAAC;YACb,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,oBAA8C;QACzE,OAAO,CACN,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,YAAY,CAAC;YAC5D,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAChE,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAC1B,oBAA8C,EAC9C,UAAkB;QAElB,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,oBAA8C;QACxE,OAAO,CACN,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,CAAC;YAC3D,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAC9D,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACzB,oBAA8C,EAC9C,SAAiB;QAEjB,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC3E,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDidVerifiableCredential } from \"../models/IDidVerifiableCredential.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class VerifiableCredentialHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<VerifiableCredentialHelper>();\n\n\t/**\n\t * Get the context for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context.\n\t */\n\tpublic static getContext(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): typeof DidContexts.ContextVCv1 | typeof DidContexts.ContextVCv2 | undefined {\n\t\tconst contextVersion = VerifiableCredentialHelper.getContextVersion(verifiableCredential);\n\t\tif (contextVersion === \"v1\") {\n\t\t\treturn DidContexts.ContextVCv1;\n\t\t}\n\t\tif (contextVersion === \"v2\") {\n\t\t\treturn DidContexts.ContextVCv2;\n\t\t}\n\t}\n\n\t/**\n\t * Get the context version for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context version.\n\t */\n\tpublic static getContextVersion(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): \"v1\" | \"v2\" | undefined {\n\t\tconst context = ArrayHelper.fromObjectOrArray(verifiableCredential[\"@context\"]);\n\t\tif (Is.arrayValue(context)) {\n\t\t\tif (context.includes(DidContexts.ContextVCv1)) {\n\t\t\t\treturn \"v1\";\n\t\t\t}\n\t\t\tif (context.includes(DidContexts.ContextVCv2)) {\n\t\t\t\treturn \"v2\";\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid until date from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The expiration date, if available.\n\t */\n\tpublic static getValidUntil(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validUntil\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"expirationDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid until date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the expiration date on.\n\t * @param validUntil The expiration date to set.\n\t */\n\tpublic static setValidUntil(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidUntil: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validUntil\", validUntil);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"expirationDate\", validUntil);\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid from from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the issuance date from.\n\t * @returns The issuance date, if available.\n\t */\n\tpublic static getValidFrom(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validFrom\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"issuanceDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid from date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the issuance date on.\n\t * @param validFrom The issuance date to set.\n\t */\n\tpublic static setValidFrom(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidFrom: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validFrom\", validFrom);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"issuanceDate\", validFrom);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"verifiableCredentialHelper.js","sourceRoot":"","sources":["../../../src/utils/verifiableCredentialHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BA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WAAW,CAAC,oBAAoB,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,oBAA8C;QACxE,OAAO,CACN,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,CAAC;YAC3D,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAC9D,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACzB,oBAA8C,EAC9C,SAAiB;QAEjB,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC3E,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDidVerifiableCredential } from \"../models/IDidVerifiableCredential.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class VerifiableCredentialHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<VerifiableCredentialHelper>();\n\n\t/**\n\t * Get the context for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context.\n\t */\n\tpublic static getContext(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): typeof DidContexts.ContextVCv1 | typeof DidContexts.ContextVCv2 | undefined {\n\t\tconst contextVersion = VerifiableCredentialHelper.getContextVersion(verifiableCredential);\n\t\tif (contextVersion === \"v1\") {\n\t\t\treturn DidContexts.ContextVCv1;\n\t\t}\n\t\tif (contextVersion === \"v2\") {\n\t\t\treturn DidContexts.ContextVCv2;\n\t\t}\n\t}\n\n\t/**\n\t * Get the context version for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context version.\n\t */\n\tpublic static getContextVersion(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): \"v1\" | \"v2\" | undefined {\n\t\tconst context = ArrayHelper.fromObjectOrArray(verifiableCredential[\"@context\"]);\n\t\tif (Is.arrayValue<string>(context)) {\n\t\t\tif (context.includes(DidContexts.ContextVCv1)) {\n\t\t\t\treturn \"v1\";\n\t\t\t}\n\t\t\tif (context.includes(DidContexts.ContextVCv2)) {\n\t\t\t\treturn \"v2\";\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid until date from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The expiration date, if available.\n\t */\n\tpublic static getValidUntil(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validUntil\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"expirationDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid until date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the expiration date on.\n\t * @param validUntil The expiration date to set.\n\t */\n\tpublic static setValidUntil(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidUntil: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validUntil\", validUntil);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"expirationDate\", validUntil);\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid from from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the issuance date from.\n\t * @returns The issuance date, if available.\n\t */\n\tpublic static getValidFrom(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validFrom\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"issuanceDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid from date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the issuance date on.\n\t * @param validFrom The issuance date to set.\n\t */\n\tpublic static setValidFrom(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidFrom: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validFrom\", validFrom);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"issuanceDate\", validFrom);\n\t\t}\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.63](https://github.com/iotaledger/twin-standards/compare/standards-w3c-did-v0.0.3-next.62...standards-w3c-did-v0.0.3-next.63) (2026-05-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * update dependencies ([e422ed3](https://github.com/iotaledger/twin-standards/commit/e422ed351fb09e2deea5ef741326c37b0802af3a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * devDependencies
15
+ * @twin.org/standards-ld-contexts bumped from 0.0.3-next.62 to 0.0.3-next.63
16
+
17
+ ## [0.0.3-next.62](https://github.com/iotaledger/twin-standards/compare/standards-w3c-did-v0.0.3-next.61...standards-w3c-did-v0.0.3-next.62) (2026-05-18)
18
+
19
+
20
+ ### Features
21
+
22
+ * update schemas with new enum format ([4851603](https://github.com/iotaledger/twin-standards/commit/4851603f26910fafd7fe22b46533814dba3b041c))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * devDependencies
29
+ * @twin.org/standards-ld-contexts bumped from 0.0.3-next.61 to 0.0.3-next.62
30
+
3
31
  ## [0.0.3-next.61](https://github.com/iotaledger/twin-standards/compare/standards-w3c-did-v0.0.3-next.60...standards-w3c-did-v0.0.3-next.61) (2026-05-11)
4
32
 
5
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-w3c-did",
3
- "version": "0.0.3-next.61",
3
+ "version": "0.0.3-next.63",
4
4
  "description": "Data models for the W3C DID Core specification.",
5
5
  "repository": {
6
6
  "type": "git",