@twin.org/trust-verifiers 0.0.3-next.17 → 0.0.3-next.18

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/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  // Copyright 2025 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./models/IIdentityAllowDenyVerifierConfig.js";
4
+ export * from "./models/IIdentityAllowDenyVerifierConstructorOptions.js";
3
5
  export * from "./models/IJwtVerifiableCredentialVerifierConstructorOptions.js";
6
+ export * from "./verifiers/identityAllowDenyVerifier.js";
4
7
  export * from "./verifiers/jwtVerifiableCredentialVerifier.js";
5
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gEAAgE,CAAC;AAC/E,cAAc,gDAAgD,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./models/IJwtVerifiableCredentialVerifierConstructorOptions.js\";\nexport * from \"./verifiers/jwtVerifiableCredentialVerifier.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0DAA0D,CAAC;AACzE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./models/IIdentityAllowDenyVerifierConfig.js\";\nexport * from \"./models/IIdentityAllowDenyVerifierConstructorOptions.js\";\nexport * from \"./models/IJwtVerifiableCredentialVerifierConstructorOptions.js\";\nexport * from \"./verifiers/identityAllowDenyVerifier.js\";\nexport * from \"./verifiers/jwtVerifiableCredentialVerifier.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IIdentityAllowDenyVerifierConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IIdentityAllowDenyVerifierConfig.js","sourceRoot":"","sources":["../../../src/models/IIdentityAllowDenyVerifierConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Identity Allow/Deny Verifier.\n */\nexport interface IIdentityAllowDenyVerifierConfig {\n\t/**\n\t * Identities that are permitted; all others are rejected.\n\t * Skipped when empty or absent.\n\t */\n\tallowIdentities?: string[];\n\n\t/**\n\t * Identities that are explicitly rejected.\n\t * Skipped when empty or absent.\n\t */\n\tdenyIdentities?: string[];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IIdentityAllowDenyVerifierConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IIdentityAllowDenyVerifierConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityAllowDenyVerifierConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IIdentityAllowDenyVerifierConfig } from \"./IIdentityAllowDenyVerifierConfig.js\";\n\n/**\n * The options for the Identity Allow/Deny Verifier.\n */\nexport interface IIdentityAllowDenyVerifierConstructorOptions {\n\t/**\n\t * The allow/deny configuration for the verifier.\n\t */\n\tconfig?: IIdentityAllowDenyVerifierConfig;\n}\n"]}
@@ -0,0 +1,70 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { GeneralError, Is } from "@twin.org/core";
4
+ /**
5
+ * Class to gate verification based on allowed and denied identity lists.
6
+ */
7
+ export class IdentityAllowDenyVerifier {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static CLASS_NAME = "IdentityAllowDenyVerifier";
12
+ /**
13
+ * The identities that are permitted.
14
+ * @internal
15
+ */
16
+ _allowIdentities;
17
+ /**
18
+ * The identities that are explicitly rejected.
19
+ * @internal
20
+ */
21
+ _denyIdentities;
22
+ /**
23
+ * Create a new instance of IdentityAllowDenyVerifier.
24
+ * @param options The options for the verifier.
25
+ */
26
+ constructor(options) {
27
+ this._allowIdentities = options?.config?.allowIdentities;
28
+ this._denyIdentities = options?.config?.denyIdentities;
29
+ }
30
+ /**
31
+ * Returns the class name of the component.
32
+ * @returns The class name of the component.
33
+ */
34
+ className() {
35
+ return IdentityAllowDenyVerifier.CLASS_NAME;
36
+ }
37
+ /**
38
+ * Verify a payload by checking the validity of its structure and content.
39
+ * @param payload The payload to verify.
40
+ * @param info Information extracted from previous verifiers and to be added by this verifier.
41
+ * @param info.identity The identity associated with the payload.
42
+ * @param errors Array to collect verification errors.
43
+ * @returns Whether the payload is verified, returns undefined if payload was not processed.
44
+ */
45
+ async verify(payload, info, errors) {
46
+ const hasAllow = Is.arrayValue(this._allowIdentities);
47
+ const hasDeny = Is.arrayValue(this._denyIdentities);
48
+ if (!hasAllow && !hasDeny) {
49
+ return undefined;
50
+ }
51
+ if (!Is.stringValue(info.identity)) {
52
+ errors.push(new GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, "identityMissing"));
53
+ return false;
54
+ }
55
+ if (hasAllow && !this._allowIdentities?.includes(info.identity)) {
56
+ errors.push(new GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, "identityNotAllowed", {
57
+ identity: info.identity
58
+ }));
59
+ return false;
60
+ }
61
+ if (hasDeny && this._denyIdentities?.includes(info.identity)) {
62
+ errors.push(new GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, "identityDenied", {
63
+ identity: info.identity
64
+ }));
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ }
70
+ //# sourceMappingURL=identityAllowDenyVerifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityAllowDenyVerifier.js","sourceRoot":"","sources":["../../../src/verifiers/identityAllowDenyVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAe,MAAM,gBAAgB,CAAC;AAK/D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACrC;;OAEG;IACI,MAAM,CAAU,UAAU,+BAA+C;IAEhF;;;OAGG;IACc,gBAAgB,CAAY;IAE7C;;;OAGG;IACc,eAAe,CAAY;IAE5C;;;OAGG;IACH,YAAY,OAAsD;QACjE,IAAI,CAAC,gBAAgB,GAAG,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC;QACzD,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,yBAAyB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAClB,OAAgB,EAChB,IAA4B,EAC5B,MAAgB;QAEhB,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAS,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAS,IAAI,CAAC,eAAe,CAAC,CAAC;QAE5D,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,yBAAyB,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;YACvF,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjE,MAAM,CAAC,IAAI,CACV,IAAI,YAAY,CAAC,yBAAyB,CAAC,UAAU,EAAE,oBAAoB,EAAE;gBAC5E,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACvB,CAAC,CACF,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CACV,IAAI,YAAY,CAAC,yBAAyB,CAAC,UAAU,EAAE,gBAAgB,EAAE;gBACxE,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACvB,CAAC,CACF,CAAC;YACF,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is, type IError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { ITrustVerificationInfo, ITrustVerifier } from \"@twin.org/trust-models\";\nimport type { IIdentityAllowDenyVerifierConstructorOptions } from \"../models/IIdentityAllowDenyVerifierConstructorOptions.js\";\n\n/**\n * Class to gate verification based on allowed and denied identity lists.\n */\nexport class IdentityAllowDenyVerifier implements ITrustVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityAllowDenyVerifier>();\n\n\t/**\n\t * The identities that are permitted.\n\t * @internal\n\t */\n\tprivate readonly _allowIdentities?: string[];\n\n\t/**\n\t * The identities that are explicitly rejected.\n\t * @internal\n\t */\n\tprivate readonly _denyIdentities?: string[];\n\n\t/**\n\t * Create a new instance of IdentityAllowDenyVerifier.\n\t * @param options The options for the verifier.\n\t */\n\tconstructor(options?: IIdentityAllowDenyVerifierConstructorOptions) {\n\t\tthis._allowIdentities = options?.config?.allowIdentities;\n\t\tthis._denyIdentities = options?.config?.denyIdentities;\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 IdentityAllowDenyVerifier.CLASS_NAME;\n\t}\n\n\t/**\n\t * Verify a payload by checking the validity of its structure and content.\n\t * @param payload The payload to verify.\n\t * @param info Information extracted from previous verifiers and to be added by this verifier.\n\t * @param info.identity The identity associated with the payload.\n\t * @param errors Array to collect verification errors.\n\t * @returns Whether the payload is verified, returns undefined if payload was not processed.\n\t */\n\tpublic async verify(\n\t\tpayload: unknown,\n\t\tinfo: ITrustVerificationInfo,\n\t\terrors: IError[]\n\t): Promise<boolean | undefined> {\n\t\tconst hasAllow = Is.arrayValue<string>(this._allowIdentities);\n\t\tconst hasDeny = Is.arrayValue<string>(this._denyIdentities);\n\n\t\tif (!hasAllow && !hasDeny) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (!Is.stringValue(info.identity)) {\n\t\t\terrors.push(new GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, \"identityMissing\"));\n\t\t\treturn false;\n\t\t}\n\n\t\tif (hasAllow && !this._allowIdentities?.includes(info.identity)) {\n\t\t\terrors.push(\n\t\t\t\tnew GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, \"identityNotAllowed\", {\n\t\t\t\t\tidentity: info.identity\n\t\t\t\t})\n\t\t\t);\n\t\t\treturn false;\n\t\t}\n\n\t\tif (hasDeny && this._denyIdentities?.includes(info.identity)) {\n\t\t\terrors.push(\n\t\t\t\tnew GeneralError(IdentityAllowDenyVerifier.CLASS_NAME, \"identityDenied\", {\n\t\t\t\t\tidentity: info.identity\n\t\t\t\t})\n\t\t\t);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n"]}
@@ -1,2 +1,5 @@
1
+ export * from "./models/IIdentityAllowDenyVerifierConfig.js";
2
+ export * from "./models/IIdentityAllowDenyVerifierConstructorOptions.js";
1
3
  export * from "./models/IJwtVerifiableCredentialVerifierConstructorOptions.js";
4
+ export * from "./verifiers/identityAllowDenyVerifier.js";
2
5
  export * from "./verifiers/jwtVerifiableCredentialVerifier.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Configuration for the Identity Allow/Deny Verifier.
3
+ */
4
+ export interface IIdentityAllowDenyVerifierConfig {
5
+ /**
6
+ * Identities that are permitted; all others are rejected.
7
+ * Skipped when empty or absent.
8
+ */
9
+ allowIdentities?: string[];
10
+ /**
11
+ * Identities that are explicitly rejected.
12
+ * Skipped when empty or absent.
13
+ */
14
+ denyIdentities?: string[];
15
+ }
@@ -0,0 +1,10 @@
1
+ import type { IIdentityAllowDenyVerifierConfig } from "./IIdentityAllowDenyVerifierConfig.js";
2
+ /**
3
+ * The options for the Identity Allow/Deny Verifier.
4
+ */
5
+ export interface IIdentityAllowDenyVerifierConstructorOptions {
6
+ /**
7
+ * The allow/deny configuration for the verifier.
8
+ */
9
+ config?: IIdentityAllowDenyVerifierConfig;
10
+ }
@@ -0,0 +1,31 @@
1
+ import { type IError } from "@twin.org/core";
2
+ import type { ITrustVerificationInfo, ITrustVerifier } from "@twin.org/trust-models";
3
+ import type { IIdentityAllowDenyVerifierConstructorOptions } from "../models/IIdentityAllowDenyVerifierConstructorOptions.js";
4
+ /**
5
+ * Class to gate verification based on allowed and denied identity lists.
6
+ */
7
+ export declare class IdentityAllowDenyVerifier implements ITrustVerifier {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
12
+ /**
13
+ * Create a new instance of IdentityAllowDenyVerifier.
14
+ * @param options The options for the verifier.
15
+ */
16
+ constructor(options?: IIdentityAllowDenyVerifierConstructorOptions);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
22
+ /**
23
+ * Verify a payload by checking the validity of its structure and content.
24
+ * @param payload The payload to verify.
25
+ * @param info Information extracted from previous verifiers and to be added by this verifier.
26
+ * @param info.identity The identity associated with the payload.
27
+ * @param errors Array to collect verification errors.
28
+ * @returns Whether the payload is verified, returns undefined if payload was not processed.
29
+ */
30
+ verify(payload: unknown, info: ITrustVerificationInfo, errors: IError[]): Promise<boolean | undefined>;
31
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.18](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.17...trust-verifiers-v0.0.3-next.18) (2026-06-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
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.17 to 0.0.3-next.18
16
+
3
17
  ## [0.0.3-next.17](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.16...trust-verifiers-v0.0.3-next.17) (2026-06-02)
4
18
 
5
19
 
@@ -0,0 +1,91 @@
1
+ # Class: IdentityAllowDenyVerifier
2
+
3
+ Class to gate verification based on allowed and denied identity lists.
4
+
5
+ ## Implements
6
+
7
+ - `ITrustVerifier`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new IdentityAllowDenyVerifier**(`options?`): `IdentityAllowDenyVerifier`
14
+
15
+ Create a new instance of IdentityAllowDenyVerifier.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IIdentityAllowDenyVerifierConstructorOptions`](../interfaces/IIdentityAllowDenyVerifierConstructorOptions.md)
22
+
23
+ The options for the verifier.
24
+
25
+ #### Returns
26
+
27
+ `IdentityAllowDenyVerifier`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `ITrustVerifier.className`
54
+
55
+ ***
56
+
57
+ ### verify() {#verify}
58
+
59
+ > **verify**(`payload`, `info`, `errors`): `Promise`\<`boolean` \| `undefined`\>
60
+
61
+ Verify a payload by checking the validity of its structure and content.
62
+
63
+ #### Parameters
64
+
65
+ ##### payload
66
+
67
+ `unknown`
68
+
69
+ The payload to verify.
70
+
71
+ ##### info
72
+
73
+ `ITrustVerificationInfo`
74
+
75
+ Information extracted from previous verifiers and to be added by this verifier.
76
+
77
+ ##### errors
78
+
79
+ `IError`[]
80
+
81
+ Array to collect verification errors.
82
+
83
+ #### Returns
84
+
85
+ `Promise`\<`boolean` \| `undefined`\>
86
+
87
+ Whether the payload is verified, returns undefined if payload was not processed.
88
+
89
+ #### Implementation of
90
+
91
+ `ITrustVerifier.verify`
@@ -2,8 +2,11 @@
2
2
 
3
3
  ## Classes
4
4
 
5
+ - [IdentityAllowDenyVerifier](classes/IdentityAllowDenyVerifier.md)
5
6
  - [JwtVerifiableCredentialVerifier](classes/JwtVerifiableCredentialVerifier.md)
6
7
 
7
8
  ## Interfaces
8
9
 
10
+ - [IIdentityAllowDenyVerifierConfig](interfaces/IIdentityAllowDenyVerifierConfig.md)
11
+ - [IIdentityAllowDenyVerifierConstructorOptions](interfaces/IIdentityAllowDenyVerifierConstructorOptions.md)
9
12
  - [IJwtVerifiableCredentialVerifierConstructorOptions](interfaces/IJwtVerifiableCredentialVerifierConstructorOptions.md)
@@ -0,0 +1,21 @@
1
+ # Interface: IIdentityAllowDenyVerifierConfig
2
+
3
+ Configuration for the Identity Allow/Deny Verifier.
4
+
5
+ ## Properties
6
+
7
+ ### allowIdentities? {#allowidentities}
8
+
9
+ > `optional` **allowIdentities?**: `string`[]
10
+
11
+ Identities that are permitted; all others are rejected.
12
+ Skipped when empty or absent.
13
+
14
+ ***
15
+
16
+ ### denyIdentities? {#denyidentities}
17
+
18
+ > `optional` **denyIdentities?**: `string`[]
19
+
20
+ Identities that are explicitly rejected.
21
+ Skipped when empty or absent.
@@ -0,0 +1,11 @@
1
+ # Interface: IIdentityAllowDenyVerifierConstructorOptions
2
+
3
+ The options for the Identity Allow/Deny Verifier.
4
+
5
+ ## Properties
6
+
7
+ ### config? {#config}
8
+
9
+ > `optional` **config?**: [`IIdentityAllowDenyVerifierConfig`](IIdentityAllowDenyVerifierConfig.md)
10
+
11
+ The allow/deny configuration for the verifier.
package/locales/en.json CHANGED
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "error": {
3
+ "identityAllowDenyVerifier": {
4
+ "identityMissing": "The identity is missing from the verification info.",
5
+ "identityNotAllowed": "The identity is not in the allowed identities list \"{identity}\".",
6
+ "identityDenied": "The identity is in the denied identities list \"{identity}\"."
7
+ },
3
8
  "jwtVerifiableCredentialVerifier": {
4
9
  "tokenMissingCredential": "The JWT token does not contain a verifiable credential.",
5
10
  "tokenMissingIssuer": "The verifiable credential in the JWT does not contain an issuer.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/trust-verifiers",
3
- "version": "0.0.3-next.17",
3
+ "version": "0.0.3-next.18",
4
4
  "description": "Implements trust verifiers that validate credentials and proofs against trust model requirements",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@twin.org/identity-models": "next",
20
20
  "@twin.org/logging-models": "next",
21
21
  "@twin.org/nameof": "next",
22
- "@twin.org/trust-models": "0.0.3-next.17",
22
+ "@twin.org/trust-models": "0.0.3-next.18",
23
23
  "@twin.org/web": "next"
24
24
  },
25
25
  "main": "./dist/es/index.js",