@twin.org/trust-models 0.0.3-next.6 → 0.0.3-next.8

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,6 +1,6 @@
1
1
  // Copyright 2025 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { UnauthorizedError } from "@twin.org/core";
3
+ import { Is, UnauthorizedError } from "@twin.org/core";
4
4
  /**
5
5
  * Helper class for trust-related operations.
6
6
  */
@@ -19,7 +19,7 @@ export class TrustHelper {
19
19
  */
20
20
  static async verifyTrust(component, trustPayload, action, overrideVerifiers) {
21
21
  const trustResult = await component.verify(trustPayload, overrideVerifiers);
22
- if (!trustResult.verified) {
22
+ if (!trustResult.verified || !Is.stringValue(trustResult.info?.identity)) {
23
23
  throw new UnauthorizedError(TrustHelper.CLASS_NAME, "trustVerifyFailed", {
24
24
  action,
25
25
  errors: trustResult.errors
@@ -1 +1 @@
1
- {"version":3,"file":"trustHelper.js","sourceRoot":"","sources":["../../../src/helpers/trustHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;OAEG;IACI,MAAM,CAAU,UAAU,iBAAiC;IAElE;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAC9B,SAA0B,EAC1B,YAAqB,EACrB,MAAc,EACd,iBAA4B;QAE5B,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,iBAAiB,CAAC,WAAW,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACxE,MAAM;gBACN,MAAM,EAAE,WAAW,CAAC,MAAM;aAC1B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,CAAC;IACzB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { UnauthorizedError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { ITrustComponent } from \"../models/ITrustComponent.js\";\nimport type { ITrustVerificationInfo } from \"../models/ITrustVerificationInfo.js\";\n\n/**\n * Helper class for trust-related operations.\n */\nexport class TrustHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TrustHelper>();\n\n\t/**\n\t * Verify the trust payload for the action.\n\t * @param component The trust component to use.\n\t * @param trustPayload The trust payload to verify.\n\t * @param action The action being performed.\n\t * @param overrideVerifiers List of verifiers to use instead of the default ones.\n\t * @returns The information from the trust verification.\n\t */\n\tpublic static async verifyTrust(\n\t\tcomponent: ITrustComponent,\n\t\ttrustPayload: unknown,\n\t\taction: string,\n\t\toverrideVerifiers?: string[]\n\t): Promise<ITrustVerificationInfo | undefined> {\n\t\tconst trustResult = await component.verify(trustPayload, overrideVerifiers);\n\t\tif (!trustResult.verified) {\n\t\t\tthrow new UnauthorizedError(TrustHelper.CLASS_NAME, \"trustVerifyFailed\", {\n\t\t\t\taction,\n\t\t\t\terrors: trustResult.errors\n\t\t\t});\n\t\t}\n\t\treturn trustResult.info;\n\t}\n}\n"]}
1
+ {"version":3,"file":"trustHelper.js","sourceRoot":"","sources":["../../../src/helpers/trustHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKvD;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;OAEG;IACI,MAAM,CAAU,UAAU,iBAAiC;IAElE;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAC9B,SAA0B,EAC1B,YAAqB,EACrB,MAAc,EACd,iBAA4B;QAE5B,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC1E,MAAM,IAAI,iBAAiB,CAAC,WAAW,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACxE,MAAM;gBACN,MAAM,EAAE,WAAW,CAAC,MAAM;aAC1B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,CAAC;IACzB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is, UnauthorizedError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { ITrustComponent } from \"../models/ITrustComponent.js\";\nimport type { ITrustVerificationInfo } from \"../models/ITrustVerificationInfo.js\";\n\n/**\n * Helper class for trust-related operations.\n */\nexport class TrustHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TrustHelper>();\n\n\t/**\n\t * Verify the trust payload for the action.\n\t * @param component The trust component to use.\n\t * @param trustPayload The trust payload to verify.\n\t * @param action The action being performed.\n\t * @param overrideVerifiers List of verifiers to use instead of the default ones.\n\t * @returns The information from the trust verification.\n\t */\n\tpublic static async verifyTrust(\n\t\tcomponent: ITrustComponent,\n\t\ttrustPayload: unknown,\n\t\taction: string,\n\t\toverrideVerifiers?: string[]\n\t): Promise<ITrustVerificationInfo> {\n\t\tconst trustResult = await component.verify(trustPayload, overrideVerifiers);\n\t\tif (!trustResult.verified || !Is.stringValue(trustResult.info?.identity)) {\n\t\t\tthrow new UnauthorizedError(TrustHelper.CLASS_NAME, \"trustVerifyFailed\", {\n\t\t\t\taction,\n\t\t\t\terrors: trustResult.errors\n\t\t\t});\n\t\t}\n\t\treturn trustResult.info;\n\t}\n}\n"]}
@@ -1,4 +1,2 @@
1
- // Copyright 2025 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
1
  export {};
4
2
  //# sourceMappingURL=ITrustVerificationInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ITrustVerificationInfo.js","sourceRoot":"","sources":["../../../src/models/ITrustVerificationInfo.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Interface describing a trust verifier information.\n */\nexport interface ITrustVerificationInfo {\n\t[key: string]: unknown;\n\n\t/**\n\t * The identity associated with the payload.\n\t */\n\tidentity: string;\n}\n"]}
1
+ {"version":3,"file":"ITrustVerificationInfo.js","sourceRoot":"","sources":["../../../src/models/ITrustVerificationInfo.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\n\n/**\n * Interface describing a trust verifier information.\n */\nexport interface ITrustVerificationInfo {\n\t/**\n\t * The identity associated with the payload.\n\t */\n\tidentity: string;\n\n\t/**\n\t * Additional JSON-LD node objects associated with the verification.\n\t */\n\tdata?: {\n\t\t[key: string]: IJsonLdNodeObject;\n\t};\n}\n"]}
@@ -16,5 +16,5 @@ export declare class TrustHelper {
16
16
  * @param overrideVerifiers List of verifiers to use instead of the default ones.
17
17
  * @returns The information from the trust verification.
18
18
  */
19
- static verifyTrust(component: ITrustComponent, trustPayload: unknown, action: string, overrideVerifiers?: string[]): Promise<ITrustVerificationInfo | undefined>;
19
+ static verifyTrust(component: ITrustComponent, trustPayload: unknown, action: string, overrideVerifiers?: string[]): Promise<ITrustVerificationInfo>;
20
20
  }
@@ -1,10 +1,16 @@
1
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
1
2
  /**
2
3
  * Interface describing a trust verifier information.
3
4
  */
4
5
  export interface ITrustVerificationInfo {
5
- [key: string]: unknown;
6
6
  /**
7
7
  * The identity associated with the payload.
8
8
  */
9
9
  identity: string;
10
+ /**
11
+ * Additional JSON-LD node objects associated with the verification.
12
+ */
13
+ data?: {
14
+ [key: string]: IJsonLdNodeObject;
15
+ };
10
16
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.8](https://github.com/twinfoundation/trust/compare/trust-models-v0.0.3-next.7...trust-models-v0.0.3-next.8) (2026-01-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * verification info structure ([#10](https://github.com/twinfoundation/trust/issues/10)) ([8b09ec8](https://github.com/twinfoundation/trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
9
+
10
+ ## [0.0.3-next.7](https://github.com/twinfoundation/trust/compare/trust-models-v0.0.3-next.6...trust-models-v0.0.3-next.7) (2025-12-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * guarantee identity in helper return value ([8a582f3](https://github.com/twinfoundation/trust/commit/8a582f32125365a414dbd61c28dd870fb60d3acb))
16
+
3
17
  ## [0.0.3-next.6](https://github.com/twinfoundation/trust/compare/trust-models-v0.0.3-next.5...trust-models-v0.0.3-next.6) (2025-12-04)
4
18
 
5
19
 
@@ -24,7 +24,7 @@ Runtime name for the class.
24
24
 
25
25
  ### verifyTrust()
26
26
 
27
- > `static` **verifyTrust**(`component`, `trustPayload`, `action`, `overrideVerifiers?`): `Promise`\<[`ITrustVerificationInfo`](../interfaces/ITrustVerificationInfo.md) \| `undefined`\>
27
+ > `static` **verifyTrust**(`component`, `trustPayload`, `action`, `overrideVerifiers?`): `Promise`\<[`ITrustVerificationInfo`](../interfaces/ITrustVerificationInfo.md)\>
28
28
 
29
29
  Verify the trust payload for the action.
30
30
 
@@ -56,6 +56,6 @@ List of verifiers to use instead of the default ones.
56
56
 
57
57
  #### Returns
58
58
 
59
- `Promise`\<[`ITrustVerificationInfo`](../interfaces/ITrustVerificationInfo.md) \| `undefined`\>
59
+ `Promise`\<[`ITrustVerificationInfo`](../interfaces/ITrustVerificationInfo.md)\>
60
60
 
61
61
  The information from the trust verification.
@@ -2,10 +2,6 @@
2
2
 
3
3
  Interface describing a trust verifier information.
4
4
 
5
- ## Indexable
6
-
7
- \[`key`: `string`\]: `unknown`
8
-
9
5
  ## Properties
10
6
 
11
7
  ### identity
@@ -13,3 +9,15 @@ Interface describing a trust verifier information.
13
9
  > **identity**: `string`
14
10
 
15
11
  The identity associated with the payload.
12
+
13
+ ***
14
+
15
+ ### data?
16
+
17
+ > `optional` **data**: `object`
18
+
19
+ Additional JSON-LD node objects associated with the verification.
20
+
21
+ #### Index Signature
22
+
23
+ \[`key`: `string`\]: `IJsonLdNodeObject`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/trust-models",
3
- "version": "0.0.3-next.6",
3
+ "version": "0.0.3-next.8",
4
4
  "description": "Models which define the structure of the trust contracts",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
+ "@twin.org/data-json-ld": "next",
18
19
  "@twin.org/nameof": "next"
19
20
  },
20
21
  "main": "./dist/es/index.js",