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

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"]}
@@ -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
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * guarantee identity in helper return value ([8a582f3](https://github.com/twinfoundation/trust/commit/8a582f32125365a414dbd61c28dd870fb60d3acb))
9
+
3
10
  ## [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
11
 
5
12
 
@@ -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.
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.7",
4
4
  "description": "Models which define the structure of the trust contracts",
5
5
  "repository": {
6
6
  "type": "git",