@twin.org/trust-service 0.0.3-next.9 → 0.9.0

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Trust Service
2
2
 
3
- Trust service implementation.
3
+ This package is part of the trust repository and provides reusable trust building blocks so applications can issue, validate, and orchestrate trust artefacts with consistent behaviour.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"ITrustServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/ITrustServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITrustServiceConfig } from \"./ITrustServiceConfig.js\";\n\n/**\n * The options for the trust service.\n */\nexport interface ITrustServiceConstructorOptions {\n\t/**\n\t * The logging component type.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The trust service configuration.\n\t */\n\tconfig?: ITrustServiceConfig;\n}\n"]}
1
+ {"version":3,"file":"ITrustServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/ITrustServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITrustServiceConfig } from \"./ITrustServiceConfig.js\";\n\n/**\n * The options for the trust service.\n */\nexport interface ITrustServiceConstructorOptions {\n\t/**\n\t * The logging component type.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The trust service configuration.\n\t */\n\tconfig?: ITrustServiceConfig;\n}\n"]}
@@ -21,25 +21,25 @@ export class TrustService {
21
21
  */
22
22
  _defaultGeneratorType;
23
23
  /**
24
- * Create a new instance of TrustService.
24
+ * Creates a new instance of TrustService.
25
25
  * @param options The options for the service.
26
26
  */
27
27
  constructor(options) {
28
- this._loggingComponent = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
28
+ this._loggingComponent = ComponentFactory.getIfExists(options?.loggingComponentType);
29
29
  this._defaultGeneratorType = options?.config?.defaultGeneratorType;
30
30
  }
31
31
  /**
32
32
  * Returns the class name of the component.
33
- * @returns The class name of the component.
33
+ * @returns The runtime class name string
34
34
  */
35
35
  className() {
36
36
  return TrustService.CLASS_NAME;
37
37
  }
38
38
  /**
39
- * Verify a payload by checking the validity of its structure and content using the registered verifiers.
39
+ * Verifies a payload using all registered verifiers or an explicit override list.
40
40
  * @param payload The payload to verify.
41
- * @param overrideVerifiers List of verifiers to use instead of the default ones.
42
- * @returns Whether the payload is verified and any additional information extracted from the payload, or verification errors.
41
+ * @param overrideVerifiers List of verifiers to use instead of the registered defaults.
42
+ * @returns A promise that resolves to the verification result, including the verified flag, extracted info, and any errors.
43
43
  */
44
44
  async verify(payload, overrideVerifiers) {
45
45
  const verifierNames = overrideVerifiers ?? TrustVerifierFactory.names();
@@ -96,13 +96,16 @@ export class TrustService {
96
96
  };
97
97
  }
98
98
  /**
99
- * Generate a payload using the specified generators.
99
+ * Generates a trust payload using the specified or default generator.
100
100
  * @param identity The identity for which to generate the payload.
101
- * @param generatorType The type of generator to use, defaults to the default generator type or first in factory.
101
+ * @param generatorType The generator type to use; falls back to the configured default or the first registered generator.
102
102
  * @param info Optional information to include in the generated payload.
103
- * @returns The generated payload.
103
+ * @param options Per-call generation options.
104
+ * @param options.tokenTtlInSeconds TTL override in seconds for this token only; takes precedence over the config-level value when provided.
105
+ * @returns A promise that resolves to the generated payload.
106
+ * @throws GeneralError if no generators are registered.
104
107
  */
105
- async generate(identity, generatorType, info) {
108
+ async generate(identity, generatorType, info, options) {
106
109
  Guards.stringValue(TrustService.CLASS_NAME, "identity", identity);
107
110
  if (Is.empty(generatorType)) {
108
111
  generatorType = this._defaultGeneratorType;
@@ -115,7 +118,7 @@ export class TrustService {
115
118
  }
116
119
  }
117
120
  const generator = TrustGeneratorFactory.get(generatorType);
118
- return generator.generate(identity, info);
121
+ return generator.generate(identity, info, options);
119
122
  }
120
123
  }
121
124
  //# sourceMappingURL=trustService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trustService.js","sourceRoot":"","sources":["../../src/trustService.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, type IError } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype ITrustVerificationInfo,\n\tTrustGeneratorFactory,\n\tTrustVerifierFactory,\n\ttype ITrustComponent\n} from \"@twin.org/trust-models\";\nimport type { ITrustServiceConstructorOptions } from \"./models/ITrustServiceConstructorOptions.js\";\n\n/**\n * Class for performing trust operations.\n */\nexport class TrustService implements ITrustComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TrustService>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * The default generator type.\n\t * @internal\n\t */\n\tprivate readonly _defaultGeneratorType?: string;\n\n\t/**\n\t * Create a new instance of TrustService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: ITrustServiceConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._defaultGeneratorType = options?.config?.defaultGeneratorType;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn TrustService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Verify a payload by checking the validity of its structure and content using the registered verifiers.\n\t * @param payload The payload to verify.\n\t * @param overrideVerifiers List of verifiers to use instead of the default ones.\n\t * @returns Whether the payload is verified and any additional information extracted from the payload, or verification errors.\n\t */\n\tpublic async verify(\n\t\tpayload: unknown,\n\t\toverrideVerifiers?: string[]\n\t): Promise<{\n\t\tverified: boolean;\n\t\tinfo?: ITrustVerificationInfo;\n\t\terrors?: IError[];\n\t}> {\n\t\tconst verifierNames = overrideVerifiers ?? TrustVerifierFactory.names();\n\n\t\tlet verified = false;\n\t\tconst info: ITrustVerificationInfo = { identity: \"\" };\n\t\tconst errors: IError[] = [];\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\tmessage: \"verifying\",\n\t\t\tts: Date.now(),\n\t\t\tdata: {\n\t\t\t\tpayload: payload?.toString() ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\tif (verifierNames.length === 0) {\n\t\t\terrors.push(new GeneralError(TrustService.CLASS_NAME, \"noVerifiersRegistered\"));\n\t\t} else {\n\t\t\tfor (const verifierName of verifierNames) {\n\t\t\t\tconst verifier = TrustVerifierFactory.get(verifierName);\n\t\t\t\tconst verifierResult = await verifier.verify(payload, info, errors);\n\n\t\t\t\tif (!Is.empty(verifierResult)) {\n\t\t\t\t\tverified = verifierResult;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (verified) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\t\tmessage: \"verified\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tdata: {\n\t\t\t\t\tinfo\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\t\tmessage: \"notVerified\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tdata: {\n\t\t\t\t\terrors\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tverified,\n\t\t\tinfo: info.identity.length > 0 ? info : undefined,\n\t\t\terrors: errors.length > 0 ? errors : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Generate a payload using the specified generators.\n\t * @param identity The identity for which to generate the payload.\n\t * @param generatorType The type of generator to use, defaults to the default generator type or first in factory.\n\t * @param info Optional information to include in the generated payload.\n\t * @returns The generated payload.\n\t */\n\tpublic async generate(\n\t\tidentity: string,\n\t\tgeneratorType?: string,\n\t\tinfo?: {\n\t\t\t[key: string]: unknown;\n\t\t}\n\t): Promise<unknown> {\n\t\tGuards.stringValue(TrustService.CLASS_NAME, nameof(identity), identity);\n\n\t\tif (Is.empty(generatorType)) {\n\t\t\tgeneratorType = this._defaultGeneratorType;\n\n\t\t\tif (Is.empty(generatorType)) {\n\t\t\t\tconst names = TrustGeneratorFactory.names();\n\t\t\t\tif (names.length === 0) {\n\t\t\t\t\tthrow new GeneralError(TrustService.CLASS_NAME, \"noGeneratorsRegistered\");\n\t\t\t\t}\n\t\t\t\tgeneratorType = names[0];\n\t\t\t}\n\t\t}\n\n\t\tconst generator = TrustGeneratorFactory.get(generatorType);\n\n\t\treturn generator.generate(identity, info);\n\t}\n}\n"]}
1
+ {"version":3,"file":"trustService.js","sourceRoot":"","sources":["../../src/trustService.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, type IError } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype ITrustVerificationInfo,\n\tTrustGeneratorFactory,\n\tTrustVerifierFactory,\n\ttype ITrustComponent\n} from \"@twin.org/trust-models\";\nimport type { ITrustServiceConstructorOptions } from \"./models/ITrustServiceConstructorOptions.js\";\n\n/**\n * Class for performing trust operations.\n */\nexport class TrustService implements ITrustComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TrustService>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * The default generator type.\n\t * @internal\n\t */\n\tprivate readonly _defaultGeneratorType?: string;\n\n\t/**\n\t * Creates a new instance of TrustService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: ITrustServiceConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists(options?.loggingComponentType);\n\n\t\tthis._defaultGeneratorType = options?.config?.defaultGeneratorType;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The runtime class name string\n\t */\n\tpublic className(): string {\n\t\treturn TrustService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Verifies a payload using all registered verifiers or an explicit override list.\n\t * @param payload The payload to verify.\n\t * @param overrideVerifiers List of verifiers to use instead of the registered defaults.\n\t * @returns A promise that resolves to the verification result, including the verified flag, extracted info, and any errors.\n\t */\n\tpublic async verify(\n\t\tpayload: unknown,\n\t\toverrideVerifiers?: string[]\n\t): Promise<{\n\t\tverified: boolean;\n\t\tinfo?: ITrustVerificationInfo;\n\t\terrors?: IError[];\n\t}> {\n\t\tconst verifierNames = overrideVerifiers ?? TrustVerifierFactory.names();\n\n\t\tlet verified = false;\n\t\tconst info: ITrustVerificationInfo = { identity: \"\" };\n\t\tconst errors: IError[] = [];\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\tmessage: \"verifying\",\n\t\t\tts: Date.now(),\n\t\t\tdata: {\n\t\t\t\tpayload: payload?.toString() ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\tif (verifierNames.length === 0) {\n\t\t\terrors.push(new GeneralError(TrustService.CLASS_NAME, \"noVerifiersRegistered\"));\n\t\t} else {\n\t\t\tfor (const verifierName of verifierNames) {\n\t\t\t\tconst verifier = TrustVerifierFactory.get(verifierName);\n\t\t\t\tconst verifierResult = await verifier.verify(payload, info, errors);\n\n\t\t\t\tif (!Is.empty(verifierResult)) {\n\t\t\t\t\tverified = verifierResult;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (verified) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\t\tmessage: \"verified\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tdata: {\n\t\t\t\t\tinfo\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: TrustService.CLASS_NAME,\n\t\t\t\tmessage: \"notVerified\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tdata: {\n\t\t\t\t\terrors\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tverified,\n\t\t\tinfo: info.identity.length > 0 ? info : undefined,\n\t\t\terrors: errors.length > 0 ? errors : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Generates a trust payload using the specified or default generator.\n\t * @param identity The identity for which to generate the payload.\n\t * @param generatorType The generator type to use; falls back to the configured default or the first registered generator.\n\t * @param info Optional information to include in the generated payload.\n\t * @param options Per-call generation options.\n\t * @param options.tokenTtlInSeconds TTL override in seconds for this token only; takes precedence over the config-level value when provided.\n\t * @returns A promise that resolves to the generated payload.\n\t * @throws GeneralError if no generators are registered.\n\t */\n\tpublic async generate(\n\t\tidentity: string,\n\t\tgeneratorType?: string,\n\t\tinfo?: {\n\t\t\t[key: string]: unknown;\n\t\t},\n\t\toptions?: { tokenTtlInSeconds: number }\n\t): Promise<unknown> {\n\t\tGuards.stringValue(TrustService.CLASS_NAME, nameof(identity), identity);\n\n\t\tif (Is.empty(generatorType)) {\n\t\t\tgeneratorType = this._defaultGeneratorType;\n\n\t\t\tif (Is.empty(generatorType)) {\n\t\t\t\tconst names = TrustGeneratorFactory.names();\n\t\t\t\tif (names.length === 0) {\n\t\t\t\t\tthrow new GeneralError(TrustService.CLASS_NAME, \"noGeneratorsRegistered\");\n\t\t\t\t}\n\t\t\t\tgeneratorType = names[0];\n\t\t\t}\n\t\t}\n\n\t\tconst generator = TrustGeneratorFactory.get(generatorType);\n\n\t\treturn generator.generate(identity, info, options);\n\t}\n}\n"]}
@@ -5,7 +5,6 @@ import type { ITrustServiceConfig } from "./ITrustServiceConfig.js";
5
5
  export interface ITrustServiceConstructorOptions {
6
6
  /**
7
7
  * The logging component type.
8
- * @default logging
9
8
  */
10
9
  loggingComponentType?: string;
11
10
  /**
@@ -10,20 +10,20 @@ export declare class TrustService implements ITrustComponent {
10
10
  */
11
11
  static readonly CLASS_NAME: string;
12
12
  /**
13
- * Create a new instance of TrustService.
13
+ * Creates a new instance of TrustService.
14
14
  * @param options The options for the service.
15
15
  */
16
16
  constructor(options?: ITrustServiceConstructorOptions);
17
17
  /**
18
18
  * Returns the class name of the component.
19
- * @returns The class name of the component.
19
+ * @returns The runtime class name string
20
20
  */
21
21
  className(): string;
22
22
  /**
23
- * Verify a payload by checking the validity of its structure and content using the registered verifiers.
23
+ * Verifies a payload using all registered verifiers or an explicit override list.
24
24
  * @param payload The payload to verify.
25
- * @param overrideVerifiers List of verifiers to use instead of the default ones.
26
- * @returns Whether the payload is verified and any additional information extracted from the payload, or verification errors.
25
+ * @param overrideVerifiers List of verifiers to use instead of the registered defaults.
26
+ * @returns A promise that resolves to the verification result, including the verified flag, extracted info, and any errors.
27
27
  */
28
28
  verify(payload: unknown, overrideVerifiers?: string[]): Promise<{
29
29
  verified: boolean;
@@ -31,13 +31,18 @@ export declare class TrustService implements ITrustComponent {
31
31
  errors?: IError[];
32
32
  }>;
33
33
  /**
34
- * Generate a payload using the specified generators.
34
+ * Generates a trust payload using the specified or default generator.
35
35
  * @param identity The identity for which to generate the payload.
36
- * @param generatorType The type of generator to use, defaults to the default generator type or first in factory.
36
+ * @param generatorType The generator type to use; falls back to the configured default or the first registered generator.
37
37
  * @param info Optional information to include in the generated payload.
38
- * @returns The generated payload.
38
+ * @param options Per-call generation options.
39
+ * @param options.tokenTtlInSeconds TTL override in seconds for this token only; takes precedence over the config-level value when provided.
40
+ * @returns A promise that resolves to the generated payload.
41
+ * @throws GeneralError if no generators are registered.
39
42
  */
40
43
  generate(identity: string, generatorType?: string, info?: {
41
44
  [key: string]: unknown;
45
+ }, options?: {
46
+ tokenTtlInSeconds: number;
42
47
  }): Promise<unknown>;
43
48
  }
package/docs/changelog.md CHANGED
@@ -1,11 +1,258 @@
1
1
  # Changelog
2
2
 
3
- ## [0.0.3-next.9](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.8...trust-service-v0.0.3-next.9) (2026-02-26)
3
+ ## [0.9.0](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.9.0...trust-service-v0.9.0) (2026-06-25)
4
4
 
5
5
 
6
6
  ### Features
7
7
 
8
- * error if no verifiers registered ([aa1cef6](https://github.com/twinfoundation/trust/commit/aa1cef6a130b008144073696077fd0a41d4bc533))
8
+ * add verifier overrides ([bb16a35](https://github.com/iotaledger/twin-trust/commit/bb16a35e0d6966e050cbdcc9e32a8c78839431d4))
9
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
10
+ * release to production ([#51](https://github.com/iotaledger/twin-trust/issues/51)) ([998b21a](https://github.com/iotaledger/twin-trust/commit/998b21a2c4663b7d49fc11ed2866f34ef75de390))
11
+
12
+ ## [0.9.0-next.1](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.9.0-next.0...trust-service-v0.9.0-next.1) (2026-06-23)
13
+
14
+
15
+ ### Features
16
+
17
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
18
+ * add default generator config ([54d98ba](https://github.com/iotaledger/twin-trust/commit/54d98ba53b7450b56337daeda504437be0d21943))
19
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
20
+ * add optional tenantId + organizationId to trust VC payload ([#19](https://github.com/iotaledger/twin-trust/issues/19)) ([1e93f6b](https://github.com/iotaledger/twin-trust/commit/1e93f6b0eacbfa725f3c3515d4255b39dd122ce7))
21
+ * add verifier overrides ([bb16a35](https://github.com/iotaledger/twin-trust/commit/bb16a35e0d6966e050cbdcc9e32a8c78839431d4))
22
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
23
+ * error if no verifiers registered ([aa1cef6](https://github.com/iotaledger/twin-trust/commit/aa1cef6a130b008144073696077fd0a41d4bc533))
24
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
25
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
26
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
27
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
28
+ * ttl-token per generation ([#26](https://github.com/iotaledger/twin-trust/issues/26)) ([a35e925](https://github.com/iotaledger/twin-trust/commit/a35e925560d05f30dd8c02eb4184c0c503ca075a))
29
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
30
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
31
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
32
+
33
+
34
+ ### Dependencies
35
+
36
+ * The following workspace dependencies were updated
37
+ * dependencies
38
+ * @twin.org/trust-models bumped from 0.9.0-next.0 to 0.9.0-next.1
39
+
40
+ ## [0.0.3-next.24](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.23...trust-service-v0.0.3-next.24) (2026-06-18)
41
+
42
+
43
+ ### Miscellaneous Chores
44
+
45
+ * **trust-service:** Synchronize repo versions
46
+
47
+
48
+ ### Dependencies
49
+
50
+ * The following workspace dependencies were updated
51
+ * dependencies
52
+ * @twin.org/trust-models bumped from 0.0.3-next.23 to 0.0.3-next.24
53
+
54
+ ## [0.0.3-next.23](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.22...trust-service-v0.0.3-next.23) (2026-06-11)
55
+
56
+
57
+ ### Features
58
+
59
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
60
+ * add default generator config ([54d98ba](https://github.com/iotaledger/twin-trust/commit/54d98ba53b7450b56337daeda504437be0d21943))
61
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
62
+ * add optional tenantId + organizationId to trust VC payload ([#19](https://github.com/iotaledger/twin-trust/issues/19)) ([1e93f6b](https://github.com/iotaledger/twin-trust/commit/1e93f6b0eacbfa725f3c3515d4255b39dd122ce7))
63
+ * add verifier overrides ([bb16a35](https://github.com/iotaledger/twin-trust/commit/bb16a35e0d6966e050cbdcc9e32a8c78839431d4))
64
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
65
+ * error if no verifiers registered ([aa1cef6](https://github.com/iotaledger/twin-trust/commit/aa1cef6a130b008144073696077fd0a41d4bc533))
66
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
67
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
68
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
69
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
70
+ * ttl-token per generation ([#26](https://github.com/iotaledger/twin-trust/issues/26)) ([a35e925](https://github.com/iotaledger/twin-trust/commit/a35e925560d05f30dd8c02eb4184c0c503ca075a))
71
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
72
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
73
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
74
+
75
+
76
+ ### Dependencies
77
+
78
+ * The following workspace dependencies were updated
79
+ * dependencies
80
+ * @twin.org/trust-models bumped from 0.0.3-next.21 to 0.0.3-next.23
81
+
82
+ ## [0.0.3-next.21](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.20...trust-service-v0.0.3-next.21) (2026-06-11)
83
+
84
+
85
+ ### Features
86
+
87
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
88
+
89
+
90
+ ### Dependencies
91
+
92
+ * The following workspace dependencies were updated
93
+ * dependencies
94
+ * @twin.org/trust-models bumped from 0.0.3-next.20 to 0.0.3-next.21
95
+
96
+ ## [0.0.3-next.20](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.19...trust-service-v0.0.3-next.20) (2026-06-10)
97
+
98
+
99
+ ### Miscellaneous Chores
100
+
101
+ * **trust-service:** Synchronize repo versions
102
+
103
+
104
+ ### Dependencies
105
+
106
+ * The following workspace dependencies were updated
107
+ * dependencies
108
+ * @twin.org/trust-models bumped from 0.0.3-next.19 to 0.0.3-next.20
109
+
110
+ ## [0.0.3-next.19](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.18...trust-service-v0.0.3-next.19) (2026-06-05)
111
+
112
+
113
+ ### Miscellaneous Chores
114
+
115
+ * **trust-service:** Synchronize repo versions
116
+
117
+
118
+ ### Dependencies
119
+
120
+ * The following workspace dependencies were updated
121
+ * dependencies
122
+ * @twin.org/trust-models bumped from 0.0.3-next.18 to 0.0.3-next.19
123
+
124
+ ## [0.0.3-next.18](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.17...trust-service-v0.0.3-next.18) (2026-06-05)
125
+
126
+
127
+ ### Features
128
+
129
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
130
+
131
+
132
+ ### Dependencies
133
+
134
+ * The following workspace dependencies were updated
135
+ * dependencies
136
+ * @twin.org/trust-models bumped from 0.0.3-next.17 to 0.0.3-next.18
137
+
138
+ ## [0.0.3-next.17](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.16...trust-service-v0.0.3-next.17) (2026-06-02)
139
+
140
+
141
+ ### Miscellaneous Chores
142
+
143
+ * **trust-service:** Synchronize repo versions
144
+
145
+
146
+ ### Dependencies
147
+
148
+ * The following workspace dependencies were updated
149
+ * dependencies
150
+ * @twin.org/trust-models bumped from 0.0.3-next.16 to 0.0.3-next.17
151
+
152
+ ## [0.0.3-next.16](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.15...trust-service-v0.0.3-next.16) (2026-05-27)
153
+
154
+
155
+ ### Features
156
+
157
+ * ttl-token per generation ([#26](https://github.com/iotaledger/twin-trust/issues/26)) ([a35e925](https://github.com/iotaledger/twin-trust/commit/a35e925560d05f30dd8c02eb4184c0c503ca075a))
158
+
159
+
160
+ ### Dependencies
161
+
162
+ * The following workspace dependencies were updated
163
+ * dependencies
164
+ * @twin.org/trust-models bumped from 0.0.3-next.15 to 0.0.3-next.16
165
+
166
+ ## [0.0.3-next.15](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.14...trust-service-v0.0.3-next.15) (2026-05-26)
167
+
168
+
169
+ ### Miscellaneous Chores
170
+
171
+ * **trust-service:** Synchronize repo versions
172
+
173
+
174
+ ### Dependencies
175
+
176
+ * The following workspace dependencies were updated
177
+ * dependencies
178
+ * @twin.org/trust-models bumped from 0.0.3-next.14 to 0.0.3-next.15
179
+
180
+ ## [0.0.3-next.14](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.13...trust-service-v0.0.3-next.14) (2026-05-22)
181
+
182
+
183
+ ### Features
184
+
185
+ * add optional tenantId + organizationId to trust VC payload ([#19](https://github.com/iotaledger/twin-trust/issues/19)) ([1e93f6b](https://github.com/iotaledger/twin-trust/commit/1e93f6b0eacbfa725f3c3515d4255b39dd122ce7))
186
+
187
+
188
+ ### Dependencies
189
+
190
+ * The following workspace dependencies were updated
191
+ * dependencies
192
+ * @twin.org/trust-models bumped from 0.0.3-next.13 to 0.0.3-next.14
193
+
194
+ ## [0.0.3-next.13](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.12...trust-service-v0.0.3-next.13) (2026-05-20)
195
+
196
+
197
+ ### Features
198
+
199
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
200
+
201
+
202
+ ### Dependencies
203
+
204
+ * The following workspace dependencies were updated
205
+ * dependencies
206
+ * @twin.org/trust-models bumped from 0.0.3-next.12 to 0.0.3-next.13
207
+
208
+ ## [0.0.3-next.12](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.11...trust-service-v0.0.3-next.12) (2026-05-11)
209
+
210
+
211
+ ### Features
212
+
213
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
214
+
215
+
216
+ ### Dependencies
217
+
218
+ * The following workspace dependencies were updated
219
+ * dependencies
220
+ * @twin.org/trust-models bumped from 0.0.3-next.11 to 0.0.3-next.12
221
+
222
+ ## [0.0.3-next.11](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.10...trust-service-v0.0.3-next.11) (2026-03-04)
223
+
224
+
225
+ ### Miscellaneous Chores
226
+
227
+ * **trust-service:** Synchronize repo versions
228
+
229
+
230
+ ### Dependencies
231
+
232
+ * The following workspace dependencies were updated
233
+ * dependencies
234
+ * @twin.org/trust-models bumped from 0.0.3-next.10 to 0.0.3-next.11
235
+
236
+ ## [0.0.3-next.10](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.9...trust-service-v0.0.3-next.10) (2026-02-27)
237
+
238
+
239
+ ### Miscellaneous Chores
240
+
241
+ * **trust-service:** Synchronize repo versions
242
+
243
+
244
+ ### Dependencies
245
+
246
+ * The following workspace dependencies were updated
247
+ * dependencies
248
+ * @twin.org/trust-models bumped from 0.0.3-next.9 to 0.0.3-next.10
249
+
250
+ ## [0.0.3-next.9](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.8...trust-service-v0.0.3-next.9) (2026-02-26)
251
+
252
+
253
+ ### Features
254
+
255
+ * error if no verifiers registered ([aa1cef6](https://github.com/iotaledger/twin-trust/commit/aa1cef6a130b008144073696077fd0a41d4bc533))
9
256
 
10
257
 
11
258
  ### Dependencies
@@ -14,12 +261,12 @@
14
261
  * dependencies
15
262
  * @twin.org/trust-models bumped from 0.0.3-next.8 to 0.0.3-next.9
16
263
 
17
- ## [0.0.3-next.8](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.7...trust-service-v0.0.3-next.8) (2026-01-30)
264
+ ## [0.0.3-next.8](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.7...trust-service-v0.0.3-next.8) (2026-01-30)
18
265
 
19
266
 
20
267
  ### Features
21
268
 
22
- * verification info structure ([#10](https://github.com/twinfoundation/trust/issues/10)) ([8b09ec8](https://github.com/twinfoundation/trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
269
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
23
270
 
24
271
 
25
272
  ### Dependencies
@@ -28,7 +275,7 @@
28
275
  * dependencies
29
276
  * @twin.org/trust-models bumped from 0.0.3-next.7 to 0.0.3-next.8
30
277
 
31
- ## [0.0.3-next.7](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.6...trust-service-v0.0.3-next.7) (2025-12-04)
278
+ ## [0.0.3-next.7](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.6...trust-service-v0.0.3-next.7) (2025-12-04)
32
279
 
33
280
 
34
281
  ### Miscellaneous Chores
@@ -42,12 +289,12 @@
42
289
  * dependencies
43
290
  * @twin.org/trust-models bumped from 0.0.3-next.6 to 0.0.3-next.7
44
291
 
45
- ## [0.0.3-next.6](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.5...trust-service-v0.0.3-next.6) (2025-12-04)
292
+ ## [0.0.3-next.6](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.5...trust-service-v0.0.3-next.6) (2025-12-04)
46
293
 
47
294
 
48
295
  ### Features
49
296
 
50
- * always include identity in verification info ([9594d19](https://github.com/twinfoundation/trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
297
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
51
298
 
52
299
 
53
300
  ### Dependencies
@@ -56,12 +303,12 @@
56
303
  * dependencies
57
304
  * @twin.org/trust-models bumped from 0.0.3-next.5 to 0.0.3-next.6
58
305
 
59
- ## [0.0.3-next.5](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.4...trust-service-v0.0.3-next.5) (2025-12-04)
306
+ ## [0.0.3-next.5](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.4...trust-service-v0.0.3-next.5) (2025-12-04)
60
307
 
61
308
 
62
309
  ### Features
63
310
 
64
- * add default generator config ([54d98ba](https://github.com/twinfoundation/trust/commit/54d98ba53b7450b56337daeda504437be0d21943))
311
+ * add default generator config ([54d98ba](https://github.com/iotaledger/twin-trust/commit/54d98ba53b7450b56337daeda504437be0d21943))
65
312
 
66
313
 
67
314
  ### Dependencies
@@ -70,12 +317,12 @@
70
317
  * dependencies
71
318
  * @twin.org/trust-models bumped from 0.0.3-next.4 to 0.0.3-next.5
72
319
 
73
- ## [0.0.3-next.4](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.3...trust-service-v0.0.3-next.4) (2025-12-04)
320
+ ## [0.0.3-next.4](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.3...trust-service-v0.0.3-next.4) (2025-12-04)
74
321
 
75
322
 
76
323
  ### Features
77
324
 
78
- * add generators ([6228c88](https://github.com/twinfoundation/trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
325
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
79
326
 
80
327
 
81
328
  ### Dependencies
@@ -84,12 +331,12 @@
84
331
  * dependencies
85
332
  * @twin.org/trust-models bumped from 0.0.3-next.3 to 0.0.3-next.4
86
333
 
87
- ## [0.0.3-next.3](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.2...trust-service-v0.0.3-next.3) (2025-12-04)
334
+ ## [0.0.3-next.3](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.2...trust-service-v0.0.3-next.3) (2025-12-04)
88
335
 
89
336
 
90
337
  ### Features
91
338
 
92
- * flatten error structure ([5fdd665](https://github.com/twinfoundation/trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
339
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
93
340
 
94
341
 
95
342
  ### Dependencies
@@ -98,12 +345,12 @@
98
345
  * dependencies
99
346
  * @twin.org/trust-models bumped from 0.0.3-next.2 to 0.0.3-next.3
100
347
 
101
- ## [0.0.3-next.2](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.1...trust-service-v0.0.3-next.2) (2025-12-03)
348
+ ## [0.0.3-next.2](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.1...trust-service-v0.0.3-next.2) (2025-12-03)
102
349
 
103
350
 
104
351
  ### Features
105
352
 
106
- * support pass through of info between verifiers ([1ce64b9](https://github.com/twinfoundation/trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
353
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
107
354
 
108
355
 
109
356
  ### Dependencies
@@ -112,13 +359,13 @@
112
359
  * dependencies
113
360
  * @twin.org/trust-models bumped from 0.0.3-next.1 to 0.0.3-next.2
114
361
 
115
- ## [0.0.3-next.1](https://github.com/twinfoundation/trust/compare/trust-service-v0.0.3-next.0...trust-service-v0.0.3-next.1) (2025-12-02)
362
+ ## [0.0.3-next.1](https://github.com/iotaledger/twin-trust/compare/trust-service-v0.0.3-next.0...trust-service-v0.0.3-next.1) (2025-12-02)
116
363
 
117
364
 
118
365
  ### Features
119
366
 
120
- * add verifier overrides ([bb16a35](https://github.com/twinfoundation/trust/commit/bb16a35e0d6966e050cbdcc9e32a8c78839431d4))
121
- * initial commit ([d378ef4](https://github.com/twinfoundation/trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
367
+ * add verifier overrides ([bb16a35](https://github.com/iotaledger/twin-trust/commit/bb16a35e0d6966e050cbdcc9e32a8c78839431d4))
368
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
122
369
 
123
370
 
124
371
  ### Dependencies
@@ -127,4 +374,4 @@
127
374
  * dependencies
128
375
  * @twin.org/trust-models bumped from 0.0.3-next.0 to 0.0.3-next.1
129
376
 
130
- ## @twin.org/trust-service - Changelog
377
+ ## Changelog
package/docs/examples.md CHANGED
@@ -1 +1,69 @@
1
- # @twin.org/trust-service - Examples
1
+ # Trust Service Examples
2
+
3
+ The following snippets show a practical end-to-end flow where generators and verifiers are registered once and reused for trust operations.
4
+
5
+ ## TrustService
6
+
7
+ ```typescript
8
+ import { TrustService } from '@twin.org/trust-service';
9
+ import {
10
+ TrustGeneratorFactory,
11
+ TrustVerifierFactory,
12
+ type ITrustGenerator,
13
+ type ITrustVerifier
14
+ } from '@twin.org/trust-models';
15
+ import type { IError } from '@twin.org/core';
16
+
17
+ const generator: ITrustGenerator = {
18
+ className: () => 'JwtGenerator',
19
+ generate: async (identity, info) => ({
20
+ token: 'eyJhbGciOiJFZERTQSJ9.eyJpc3MiOiJkaWQ6ZXhhbXBsZTppc3N1ZXIifQ.signature',
21
+ identity,
22
+ subject: info?.subject
23
+ })
24
+ };
25
+
26
+ const verifier: ITrustVerifier = {
27
+ className: () => 'JwtVerifier',
28
+ verify: async (payload, info, _errors) => {
29
+ const hasToken = typeof payload === 'object' && payload !== null && 'token' in payload;
30
+ if (!hasToken) {
31
+ return false;
32
+ }
33
+
34
+ info.identity = 'did:example:issuer';
35
+ info.data = {
36
+ subject: {
37
+ id: 'did:example:subject',
38
+ status: 'active'
39
+ }
40
+ };
41
+ return true;
42
+ }
43
+ };
44
+
45
+ TrustGeneratorFactory.register('jwt', () => generator);
46
+ TrustVerifierFactory.register('jwt', () => verifier);
47
+
48
+ const trustService = new TrustService({
49
+ config: {
50
+ defaultGeneratorType: 'jwt'
51
+ }
52
+ });
53
+
54
+ console.log(trustService.className()); // TrustService
55
+
56
+ const payload = await trustService.generate('did:example:issuer', 'jwt', {
57
+ subject: {
58
+ id: 'did:example:subject',
59
+ level: 'gold'
60
+ }
61
+ });
62
+
63
+ console.log(payload); // { token: "eyJhbGciOiJFZERTQSJ9.eyJpc3MiOiJkaWQ6ZXhhbXBsZTppc3N1ZXIifQ.signature", identity: "did:example:issuer", subject: { id: "did:example:subject", level: "gold" } }
64
+
65
+ const verification = await trustService.verify(payload, ['jwt']);
66
+
67
+ console.log(verification.verified); // true
68
+ console.log(verification.info?.identity); // did:example:issuer
69
+ ```
@@ -12,7 +12,7 @@ Class for performing trust operations.
12
12
 
13
13
  > **new TrustService**(`options?`): `TrustService`
14
14
 
15
- Create a new instance of TrustService.
15
+ Creates a new instance of TrustService.
16
16
 
17
17
  #### Parameters
18
18
 
@@ -28,7 +28,7 @@ The options for the service.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -46,7 +46,7 @@ Returns the class name of the component.
46
46
 
47
47
  `string`
48
48
 
49
- The class name of the component.
49
+ The runtime class name string
50
50
 
51
51
  #### Implementation of
52
52
 
@@ -54,11 +54,11 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### verify()
57
+ ### verify() {#verify}
58
58
 
59
59
  > **verify**(`payload`, `overrideVerifiers?`): `Promise`\<\{ `verified`: `boolean`; `info?`: `ITrustVerificationInfo`; `errors?`: `IError`[]; \}\>
60
60
 
61
- Verify a payload by checking the validity of its structure and content using the registered verifiers.
61
+ Verifies a payload using all registered verifiers or an explicit override list.
62
62
 
63
63
  #### Parameters
64
64
 
@@ -72,13 +72,13 @@ The payload to verify.
72
72
 
73
73
  `string`[]
74
74
 
75
- List of verifiers to use instead of the default ones.
75
+ List of verifiers to use instead of the registered defaults.
76
76
 
77
77
  #### Returns
78
78
 
79
79
  `Promise`\<\{ `verified`: `boolean`; `info?`: `ITrustVerificationInfo`; `errors?`: `IError`[]; \}\>
80
80
 
81
- Whether the payload is verified and any additional information extracted from the payload, or verification errors.
81
+ A promise that resolves to the verification result, including the verified flag, extracted info, and any errors.
82
82
 
83
83
  #### Implementation of
84
84
 
@@ -86,11 +86,11 @@ Whether the payload is verified and any additional information extracted from th
86
86
 
87
87
  ***
88
88
 
89
- ### generate()
89
+ ### generate() {#generate}
90
90
 
91
- > **generate**(`identity`, `generatorType?`, `info?`): `Promise`\<`unknown`\>
91
+ > **generate**(`identity`, `generatorType?`, `info?`, `options?`): `Promise`\<`unknown`\>
92
92
 
93
- Generate a payload using the specified generators.
93
+ Generates a trust payload using the specified or default generator.
94
94
 
95
95
  #### Parameters
96
96
 
@@ -104,17 +104,31 @@ The identity for which to generate the payload.
104
104
 
105
105
  `string`
106
106
 
107
- The type of generator to use, defaults to the default generator type or first in factory.
107
+ The generator type to use; falls back to the configured default or the first registered generator.
108
108
 
109
109
  ##### info?
110
110
 
111
111
  Optional information to include in the generated payload.
112
112
 
113
+ ##### options?
114
+
115
+ Per-call generation options.
116
+
117
+ ###### tokenTtlInSeconds
118
+
119
+ `number`
120
+
121
+ TTL override in seconds for this token only; takes precedence over the config-level value when provided.
122
+
113
123
  #### Returns
114
124
 
115
125
  `Promise`\<`unknown`\>
116
126
 
117
- The generated payload.
127
+ A promise that resolves to the generated payload.
128
+
129
+ #### Throws
130
+
131
+ GeneralError if no generators are registered.
118
132
 
119
133
  #### Implementation of
120
134
 
@@ -4,8 +4,8 @@ The options for the trust service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### defaultGeneratorType?
7
+ ### defaultGeneratorType? {#defaultgeneratortype}
8
8
 
9
- > `optional` **defaultGeneratorType**: `string`
9
+ > `optional` **defaultGeneratorType?**: `string`
10
10
 
11
11
  The default generator type, uses first in factory if not specified.
@@ -4,22 +4,16 @@ The options for the trust service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### loggingComponentType?
7
+ ### loggingComponentType? {#loggingcomponenttype}
8
8
 
9
- > `optional` **loggingComponentType**: `string`
9
+ > `optional` **loggingComponentType?**: `string`
10
10
 
11
11
  The logging component type.
12
12
 
13
- #### Default
14
-
15
- ```ts
16
- logging
17
- ```
18
-
19
13
  ***
20
14
 
21
- ### config?
15
+ ### config? {#config}
22
16
 
23
- > `optional` **config**: [`ITrustServiceConfig`](ITrustServiceConfig.md)
17
+ > `optional` **config?**: [`ITrustServiceConfig`](ITrustServiceConfig.md)
24
18
 
25
19
  The trust service configuration.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/trust-service",
3
- "version": "0.0.3-next.9",
4
- "description": "Trust service implementation",
3
+ "version": "0.9.0",
4
+ "description": "Provides an orchestrating trust service that composes generators and verifiers into a unified API",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/trust.git",
7
+ "url": "git+https://github.com/iotaledger/twin-trust.git",
8
8
  "directory": "packages/trust-service"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,10 +14,10 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "next",
18
- "@twin.org/logging-models": "next",
19
- "@twin.org/nameof": "next",
20
- "@twin.org/trust-models": "0.0.3-next.9"
17
+ "@twin.org/core": "^0.9.0",
18
+ "@twin.org/logging-models": "^0.9.0",
19
+ "@twin.org/nameof": "^0.9.0",
20
+ "@twin.org/trust-models": "^0.9.0"
21
21
  },
22
22
  "main": "./dist/es/index.js",
23
23
  "types": "./dist/types/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "business-logic"
49
49
  ],
50
50
  "bugs": {
51
- "url": "git+https://github.com/twinfoundation/trust/issues"
51
+ "url": "git+https://github.com/iotaledger/twin-trust/issues"
52
52
  },
53
53
  "homepage": "https://twindev.org"
54
54
  }