@twin.org/identity-models 0.9.1 → 0.9.2-next.1

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,4 +1,4 @@
1
- import { Converter, HexHelper } from "@twin.org/core";
1
+ import { Converter, Is, HexHelper } from "@twin.org/core";
2
2
  import { Did } from "../types/did.js";
3
3
  /**
4
4
  * Context ID handler that treats context identifiers as DIDs.
@@ -29,6 +29,19 @@ export class DidContextIdHandler {
29
29
  }
30
30
  return parts.id;
31
31
  }
32
+ /**
33
+ * The long form version of the context ID, expanded from a short version.
34
+ * @param value The short form context ID value.
35
+ * @returns The long form version of the context ID.
36
+ */
37
+ long(value) {
38
+ if (Is.stringBase64Url(value)) {
39
+ const bytes = Converter.base64UrlToBytes(value);
40
+ const hex = Converter.bytesToHex(bytes, true);
41
+ return `did:internal:${hex}`;
42
+ }
43
+ return value;
44
+ }
32
45
  /**
33
46
  * Guard the value ensuring it is a valid DID.
34
47
  * @param value The value to guard.
@@ -1 +1 @@
1
- {"version":3,"file":"didContextIdHandler.js","sourceRoot":"","sources":["../../../src/contextIdHandlers/didContextIdHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC/B;;OAEG;IACI,MAAM,CAAU,UAAU,yBAAyC;IAE1E;;;OAGG;IACI,SAAS;QACf,OAAO,mBAAmB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAa;QACzB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,yEAAyE;QACzE,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;YACtE,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC7C,OAAO,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,KAAK,CAAC,EAAE,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAa;QACzB,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;IACjE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IContextIdHandler } from \"@twin.org/context\";\nimport { Converter, HexHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Did } from \"../types/did.js\";\n\n/**\n * Context ID handler that treats context identifiers as DIDs.\n */\nexport class DidContextIdHandler implements IContextIdHandler {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DidContextIdHandler>();\n\n\t/**\n\t * The class name of the component.\n\t * @returns The class name.\n\t */\n\tpublic className(): string {\n\t\treturn DidContextIdHandler.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the short form of the DID which is the last part.\n\t * @param value The full context id value.\n\t * @returns Short form string.\n\t */\n\tpublic short(value: string): string {\n\t\tconst parts = Did.parse(value);\n\t\t// If the ID part is hex, convert to base64 for a shorter representation.\n\t\tif (HexHelper.hasPrefix(parts.id) && HexHelper.isHex(parts.id, true)) {\n\t\t\tconst bytes = Converter.hexToBytes(parts.id);\n\t\t\treturn Converter.bytesToBase64Url(bytes);\n\t\t}\n\t\treturn parts.id;\n\t}\n\n\t/**\n\t * Guard the value ensuring it is a valid DID.\n\t * @param value The value to guard.\n\t * @throws GeneralError if the value is not a valid DID.\n\t */\n\tpublic guard(value: string): void {\n\t\tDid.guard(DidContextIdHandler.CLASS_NAME, nameof(value), value);\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AC,KAAK,CAAC,mBAAmB,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;IACjE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IContextIdHandler } from \"@twin.org/context\";\nimport { Converter, Is, HexHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Did } from \"../types/did.js\";\n\n/**\n * Context ID handler that treats context identifiers as DIDs.\n */\nexport class DidContextIdHandler implements IContextIdHandler {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DidContextIdHandler>();\n\n\t/**\n\t * The class name of the component.\n\t * @returns The class name.\n\t */\n\tpublic className(): string {\n\t\treturn DidContextIdHandler.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the short form of the DID which is the last part.\n\t * @param value The full context id value.\n\t * @returns Short form string.\n\t */\n\tpublic short(value: string): string {\n\t\tconst parts = Did.parse(value);\n\t\t// If the ID part is hex, convert to base64 for a shorter representation.\n\t\tif (HexHelper.hasPrefix(parts.id) && HexHelper.isHex(parts.id, true)) {\n\t\t\tconst bytes = Converter.hexToBytes(parts.id);\n\t\t\treturn Converter.bytesToBase64Url(bytes);\n\t\t}\n\t\treturn parts.id;\n\t}\n\n\t/**\n\t * The long form version of the context ID, expanded from a short version.\n\t * @param value The short form context ID value.\n\t * @returns The long form version of the context ID.\n\t */\n\tpublic long(value: string): string {\n\t\tif (Is.stringBase64Url(value)) {\n\t\t\tconst bytes = Converter.base64UrlToBytes(value);\n\t\t\tconst hex = Converter.bytesToHex(bytes, true);\n\t\t\treturn `did:internal:${hex}`;\n\t\t}\n\t\treturn value;\n\t}\n\n\t/**\n\t * Guard the value ensuring it is a valid DID.\n\t * @param value The value to guard.\n\t * @throws GeneralError if the value is not a valid DID.\n\t */\n\tpublic guard(value: string): void {\n\t\tDid.guard(DidContextIdHandler.CLASS_NAME, nameof(value), value);\n\t}\n}\n"]}
@@ -18,6 +18,12 @@ export declare class DidContextIdHandler implements IContextIdHandler {
18
18
  * @returns Short form string.
19
19
  */
20
20
  short(value: string): string;
21
+ /**
22
+ * The long form version of the context ID, expanded from a short version.
23
+ * @param value The short form context ID value.
24
+ * @returns The long form version of the context ID.
25
+ */
26
+ long(value: string): string;
21
27
  /**
22
28
  * Guard the value ensuring it is a valid DID.
23
29
  * @param value The value to guard.
package/docs/changelog.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.2-next.1](https://github.com/iotaledger/twin-identity/compare/identity-models-v0.9.2-next.0...identity-models-v0.9.2-next.1) (2026-07-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * add addAlsoKnownAs to identity connector ([#117](https://github.com/iotaledger/twin-identity/issues/117)) ([aa27cff](https://github.com/iotaledger/twin-identity/commit/aa27cff88e61e7c8c6e32aeb437fb01c6ee9f57a))
9
+ * add context id features ([#62](https://github.com/iotaledger/twin-identity/issues/62)) ([e02ecca](https://github.com/iotaledger/twin-identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
10
+ * add context id long method ([#182](https://github.com/iotaledger/twin-identity/issues/182)) ([8e04625](https://github.com/iotaledger/twin-identity/commit/8e04625812cd3b8680ce837fadbb0bce046a5c2f))
11
+ * add expiration date option to vc creation ([73e05e1](https://github.com/iotaledger/twin-identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
12
+ * add identity remove ([eebc13f](https://github.com/iotaledger/twin-identity/commit/eebc13f4c2cd994d2d9cce4da2128fb346c80ba7))
13
+ * add idHelper class ([57c8bdb](https://github.com/iotaledger/twin-identity/commit/57c8bdb81efaa163b5e83f8a7f16f3764d12fd75))
14
+ * add optional jwt payload and headers to vc and vp tokens ([#135](https://github.com/iotaledger/twin-identity/issues/135)) ([aa1de0f](https://github.com/iotaledger/twin-identity/commit/aa1de0f63be95ff62bae3c699aabc85ea93d74c2))
15
+ * add proof to vcs and verify vs documents ([#103](https://github.com/iotaledger/twin-identity/issues/103)) ([b60bf0c](https://github.com/iotaledger/twin-identity/commit/b60bf0cb7d453d67574c5c0e4f769e67cf7cd6d1))
16
+ * add telemetry metrics ([#132](https://github.com/iotaledger/twin-identity/issues/132)) ([b51cd78](https://github.com/iotaledger/twin-identity/commit/b51cd7816905fd55e250035daf1b8f2047cba83d))
17
+ * add validate-locales ([04d74b4](https://github.com/iotaledger/twin-identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
18
+ * common connector tests ([4f9642c](https://github.com/iotaledger/twin-identity/commit/4f9642ceb09843870909fc6819bf69fb20ef952a))
19
+ * eslint migration to flat config ([fd6246d](https://github.com/iotaledger/twin-identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
20
+ * expanded cli methods ([#121](https://github.com/iotaledger/twin-identity/issues/121)) ([80a52b7](https://github.com/iotaledger/twin-identity/commit/80a52b779237cd633d1f2813fa976585cef6e551))
21
+ * identity key separator use slash ([1319d0d](https://github.com/iotaledger/twin-identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
22
+ * remove auth generator ([#98](https://github.com/iotaledger/twin-identity/issues/98)) ([a8969e8](https://github.com/iotaledger/twin-identity/commit/a8969e85a5a2804abfc787406e2d12eb168dd978))
23
+ * separate vc verification routes with query and body ([ea7d891](https://github.com/iotaledger/twin-identity/commit/ea7d8910472150cf76dbd51e282625e70226d9b3))
24
+ * typescript 6 update ([e8806ad](https://github.com/iotaledger/twin-identity/commit/e8806ad6858c37be3c0f54c41cf654023773bef3))
25
+ * update did context handler definition ([02aa59a](https://github.com/iotaledger/twin-identity/commit/02aa59ae8100b1afb2325ea858411fc3e4d9d1e9))
26
+ * update framework core ([c824497](https://github.com/iotaledger/twin-identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
27
+ * use shared store mechanism ([#27](https://github.com/iotaledger/twin-identity/issues/27)) ([ce41f3f](https://github.com/iotaledger/twin-identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * didContextIdHandler tests ([dc7b555](https://github.com/iotaledger/twin-identity/commit/dc7b5558e47117475b7f1fa1686d3ed7e0906563))
33
+ * Import path and bump version ([#21](https://github.com/iotaledger/twin-identity/issues/21)) ([ccea845](https://github.com/iotaledger/twin-identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
34
+ * Install sdk-wasm ([#20](https://github.com/iotaledger/twin-identity/issues/20)) ([75ec14e](https://github.com/iotaledger/twin-identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
35
+ * query params force coercion ([d9347d2](https://github.com/iotaledger/twin-identity/commit/d9347d29d4a9cc58759f30f5d8526de864ea7522))
36
+ * stricter pathParam types ([a174cdf](https://github.com/iotaledger/twin-identity/commit/a174cdf0ca4272bee35fcf20ab7e8e4e17b8b6f4))
37
+ * use base64Url for tenant id short form so it doesn't include slash ([53b9e27](https://github.com/iotaledger/twin-identity/commit/53b9e27351f20e2689734581c252a23527657926))
38
+ * Use resolver component ([#22](https://github.com/iotaledger/twin-identity/issues/22)) ([d0b3a32](https://github.com/iotaledger/twin-identity/commit/d0b3a321c7f9f966d397a880d752e9f2c0a98a27))
39
+
3
40
  ## [0.9.1](https://github.com/iotaledger/twin-identity/compare/identity-models-v0.9.1...identity-models-v0.9.1) (2026-07-27)
4
41
 
5
42
 
@@ -70,6 +70,32 @@ Short form string.
70
70
 
71
71
  ***
72
72
 
73
+ ### long() {#long}
74
+
75
+ > **long**(`value`): `string`
76
+
77
+ The long form version of the context ID, expanded from a short version.
78
+
79
+ #### Parameters
80
+
81
+ ##### value
82
+
83
+ `string`
84
+
85
+ The short form context ID value.
86
+
87
+ #### Returns
88
+
89
+ `string`
90
+
91
+ The long form version of the context ID.
92
+
93
+ #### Implementation of
94
+
95
+ `IContextIdHandler.long`
96
+
97
+ ***
98
+
73
99
  ### guard() {#guard}
74
100
 
75
101
  > **guard**(`value`): `void`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-models",
3
- "version": "0.9.1",
3
+ "version": "0.9.2-next.1",
4
4
  "description": "Shared identity models and contracts for consistent data structures across services, connectors, and clients.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,14 +14,14 @@
14
14
  "node": ">=24.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/context": "^0.9.1",
18
- "@twin.org/core": "^0.9.1",
19
- "@twin.org/data-core": "^0.9.1",
20
- "@twin.org/data-json-ld": "^0.9.1",
21
- "@twin.org/entity": "^0.9.1",
22
- "@twin.org/standards-w3c-did": "^0.9.1",
23
- "@twin.org/telemetry-models": "^0.9.1",
24
- "@twin.org/web": "^0.9.1"
17
+ "@twin.org/context": "next",
18
+ "@twin.org/core": "next",
19
+ "@twin.org/data-core": "next",
20
+ "@twin.org/data-json-ld": "next",
21
+ "@twin.org/entity": "next",
22
+ "@twin.org/standards-w3c-did": "next",
23
+ "@twin.org/telemetry-models": "next",
24
+ "@twin.org/web": "next"
25
25
  },
26
26
  "main": "./dist/es/index.js",
27
27
  "types": "./dist/types/index.d.ts",