@twin.org/trust-service 0.0.3-next.23 → 0.0.3-next.24
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/dist/es/trustService.js
CHANGED
|
@@ -21,7 +21,7 @@ export class TrustService {
|
|
|
21
21
|
*/
|
|
22
22
|
_defaultGeneratorType;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Creates a new instance of TrustService.
|
|
25
25
|
* @param options The options for the service.
|
|
26
26
|
*/
|
|
27
27
|
constructor(options) {
|
|
@@ -30,16 +30,16 @@ export class TrustService {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Returns the class name of the component.
|
|
33
|
-
* @returns The class name
|
|
33
|
+
* @returns The runtime class name string
|
|
34
34
|
*/
|
|
35
35
|
className() {
|
|
36
36
|
return TrustService.CLASS_NAME;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
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
|
|
42
|
-
* @returns
|
|
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,14 +96,14 @@ export class TrustService {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
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
|
|
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
103
|
* @param options Per-call generation options.
|
|
104
|
-
* @param options.tokenTtlInSeconds TTL override in seconds for this token only
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
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.
|
|
107
107
|
*/
|
|
108
108
|
async generate(identity, generatorType, info, options) {
|
|
109
109
|
Guards.stringValue(TrustService.CLASS_NAME, "identity", identity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trustService.js","sourceRoot":"","sources":["../../src/trustService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAe,MAAM,gBAAgB,CAAC;AAGzF,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EAEpB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;OAEG;IACI,MAAM,CAAU,UAAU,kBAAkC;IAEnE;;;OAGG;IACc,iBAAiB,CAAqB;IAEvD;;;OAGG;IACc,qBAAqB,CAAU;IAEhD;;;OAGG;IACH,YAAY,OAAyC;QACpD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAErF,IAAI,CAAC,qBAAqB,GAAG,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,YAAY,CAAC,UAAU,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAClB,OAAgB,EAChB,iBAA4B;QAM5B,MAAM,aAAa,GAAG,iBAAiB,IAAI,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAExE,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,IAAI,GAA2B,EAAE,QAAQ,E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PDX-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 *
|
|
1
|
+
{"version":3,"file":"trustService.js","sourceRoot":"","sources":["../../src/trustService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAe,MAAM,gBAAgB,CAAC;AAGzF,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EAEpB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;OAEG;IACI,MAAM,CAAU,UAAU,kBAAkC;IAEnE;;;OAGG;IACc,iBAAiB,CAAqB;IAEvD;;;OAGG;IACc,qBAAqB,CAAU;IAEhD;;;OAGG;IACH,YAAY,OAAyC;QACpD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAErF,IAAI,CAAC,qBAAqB,GAAG,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,YAAY,C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AC,CAAC,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;QAED,MAAM,SAAS,GAAG,qBAAqB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAE3D,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC","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"]}
|
|
@@ -10,20 +10,20 @@ export declare class TrustService implements ITrustComponent {
|
|
|
10
10
|
*/
|
|
11
11
|
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
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
|
|
19
|
+
* @returns The runtime class name string
|
|
20
20
|
*/
|
|
21
21
|
className(): string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
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
|
|
26
|
-
* @returns
|
|
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,14 +31,14 @@ export declare class TrustService implements ITrustComponent {
|
|
|
31
31
|
errors?: IError[];
|
|
32
32
|
}>;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
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
|
|
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
38
|
* @param options Per-call generation options.
|
|
39
|
-
* @param options.tokenTtlInSeconds TTL override in seconds for this token only
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
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.
|
|
42
42
|
*/
|
|
43
43
|
generate(identity: string, generatorType?: string, info?: {
|
|
44
44
|
[key: string]: unknown;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **trust-service:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/trust-models bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
16
|
+
|
|
3
17
|
## [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)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -12,7 +12,7 @@ Class for performing trust operations.
|
|
|
12
12
|
|
|
13
13
|
> **new TrustService**(`options?`): `TrustService`
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Creates a new instance of TrustService.
|
|
16
16
|
|
|
17
17
|
#### Parameters
|
|
18
18
|
|
|
@@ -46,7 +46,7 @@ Returns the class name of the component.
|
|
|
46
46
|
|
|
47
47
|
`string`
|
|
48
48
|
|
|
49
|
-
The class name
|
|
49
|
+
The runtime class name string
|
|
50
50
|
|
|
51
51
|
#### Implementation of
|
|
52
52
|
|
|
@@ -58,7 +58,7 @@ The class name of the component.
|
|
|
58
58
|
|
|
59
59
|
> **verify**(`payload`, `overrideVerifiers?`): `Promise`\<\{ `verified`: `boolean`; `info?`: `ITrustVerificationInfo`; `errors?`: `IError`[]; \}\>
|
|
60
60
|
|
|
61
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
|
@@ -90,7 +90,7 @@ Whether the payload is verified and any additional information extracted from th
|
|
|
90
90
|
|
|
91
91
|
> **generate**(`identity`, `generatorType?`, `info?`, `options?`): `Promise`\<`unknown`\>
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
Generates a trust payload using the specified or default generator.
|
|
94
94
|
|
|
95
95
|
#### Parameters
|
|
96
96
|
|
|
@@ -104,7 +104,7 @@ The identity for which to generate the payload.
|
|
|
104
104
|
|
|
105
105
|
`string`
|
|
106
106
|
|
|
107
|
-
The type
|
|
107
|
+
The generator type to use; falls back to the configured default or the first registered generator.
|
|
108
108
|
|
|
109
109
|
##### info?
|
|
110
110
|
|
|
@@ -118,14 +118,17 @@ Per-call generation options.
|
|
|
118
118
|
|
|
119
119
|
`number`
|
|
120
120
|
|
|
121
|
-
TTL override in seconds for this token only
|
|
122
|
-
config-level `tokenTtlInSeconds` when provided.
|
|
121
|
+
TTL override in seconds for this token only; takes precedence over the config-level value when provided.
|
|
123
122
|
|
|
124
123
|
#### Returns
|
|
125
124
|
|
|
126
125
|
`Promise`\<`unknown`\>
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
A promise that resolves to the generated payload.
|
|
128
|
+
|
|
129
|
+
#### Throws
|
|
130
|
+
|
|
131
|
+
GeneralError if no generators are registered.
|
|
129
132
|
|
|
130
133
|
#### Implementation of
|
|
131
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/trust-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.24",
|
|
4
4
|
"description": "Provides an orchestrating trust service that composes generators and verifiers into a unified API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
18
|
"@twin.org/logging-models": "next",
|
|
19
19
|
"@twin.org/nameof": "next",
|
|
20
|
-
"@twin.org/trust-models": "0.0.3-next.
|
|
20
|
+
"@twin.org/trust-models": "0.0.3-next.24"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/es/index.js",
|
|
23
23
|
"types": "./dist/types/index.d.ts",
|