@twin.org/trust-verifiers 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.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/dist/es/index.js +3 -0
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/es/models/IIdentityAllowDenyVerifierConfig.js +4 -0
  5. package/dist/es/models/IIdentityAllowDenyVerifierConfig.js.map +1 -0
  6. package/dist/es/models/IIdentityAllowDenyVerifierConstructorOptions.js +2 -0
  7. package/dist/es/models/IIdentityAllowDenyVerifierConstructorOptions.js.map +1 -0
  8. package/dist/es/models/IJwtVerifiableCredentialVerifierConstructorOptions.js.map +1 -1
  9. package/dist/es/verifiers/identityAllowDenyVerifier.js +70 -0
  10. package/dist/es/verifiers/identityAllowDenyVerifier.js.map +1 -0
  11. package/dist/es/verifiers/jwtVerifiableCredentialVerifier.js +3 -9
  12. package/dist/es/verifiers/jwtVerifiableCredentialVerifier.js.map +1 -1
  13. package/dist/types/index.d.ts +3 -0
  14. package/dist/types/models/IIdentityAllowDenyVerifierConfig.d.ts +15 -0
  15. package/dist/types/models/IIdentityAllowDenyVerifierConstructorOptions.d.ts +10 -0
  16. package/dist/types/models/IJwtVerifiableCredentialVerifierConstructorOptions.d.ts +0 -5
  17. package/dist/types/verifiers/identityAllowDenyVerifier.d.ts +31 -0
  18. package/dist/types/verifiers/jwtVerifiableCredentialVerifier.d.ts +3 -3
  19. package/docs/changelog.md +256 -16
  20. package/docs/examples.md +44 -1
  21. package/docs/reference/classes/IdentityAllowDenyVerifier.md +91 -0
  22. package/docs/reference/classes/JwtVerifiableCredentialVerifier.md +6 -6
  23. package/docs/reference/index.md +3 -0
  24. package/docs/reference/interfaces/IIdentityAllowDenyVerifierConfig.md +21 -0
  25. package/docs/reference/interfaces/IIdentityAllowDenyVerifierConstructorOptions.md +11 -0
  26. package/docs/reference/interfaces/IJwtVerifiableCredentialVerifierConstructorOptions.md +2 -16
  27. package/locales/en.json +5 -0
  28. package/package.json +11 -11
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Trust Verifiers
2
2
 
3
- Verifiers for trust.
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
 
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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IJwtVerifiableCredentialVerifierConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IJwtVerifiableCredentialVerifierConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The options for the JWT Verifiable Credential Verifier.\n */\nexport interface IJwtVerifiableCredentialVerifierConstructorOptions {\n\t/**\n\t * The logging component type.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The identity component type.\n\t * @default identity\n\t */\n\tidentityComponentType?: string;\n}\n"]}
1
+ {"version":3,"file":"IJwtVerifiableCredentialVerifierConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IJwtVerifiableCredentialVerifierConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The options for the JWT Verifiable Credential Verifier.\n */\nexport interface IJwtVerifiableCredentialVerifierConstructorOptions {\n\t/**\n\t * The identity component type.\n\t * @default identity\n\t */\n\tidentityComponentType?: string;\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
+ * Creates 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 runtime class name string
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+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AI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,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 * Creates 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 runtime class name string\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"]}
@@ -11,27 +11,21 @@ export class JwtVerifiableCredentialVerifier {
11
11
  * Runtime name for the class.
12
12
  */
13
13
  static CLASS_NAME = "JwtVerifiableCredentialVerifier";
14
- /**
15
- * The logging component.
16
- * @internal
17
- */
18
- _loggingComponent;
19
14
  /**
20
15
  * The identity component.
21
16
  * @internal
22
17
  */
23
18
  _identityComponent;
24
19
  /**
25
- * Create a new instance of JwtVerifiableCredentialVerifier.
26
- * @param options The options for the service.
20
+ * Creates a new instance of JwtVerifiableCredentialVerifier.
21
+ * @param options The options for the verifier.
27
22
  */
28
23
  constructor(options) {
29
- this._loggingComponent = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
30
24
  this._identityComponent = ComponentFactory.get(options?.identityComponentType ?? "identity");
31
25
  }
32
26
  /**
33
27
  * Returns the class name of the component.
34
- * @returns The class name of the component.
28
+ * @returns The runtime class name string
35
29
  */
36
30
  className() {
37
31
  return JwtVerifiableCredentialVerifier.CLASS_NAME;
@@ -1 +1 @@
1
- {"version":3,"file":"jwtVerifiableCredentialVerifier.js","sourceRoot":"","sources":["../../../src/verifiers/jwtVerifiableCredentialVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,EAAE,EAAe,MAAM,gBAAgB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,qCAAqD;IAEtF;;;OAGG;IACc,iBAAiB,CAAqB;IAEvD;;;OAGG;IACc,kBAAkB,CAAqB;IAExD;;;OAGG;IACH,YAAY,OAA4D;QACvE,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,WAAW,CACpD,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QAEF,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACnD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAClB,OAAgB,EAChB,IAA4B,EAC5B,MAAgB;QAEhB,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAA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,MAAM;wBAC9B,CAAC,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;wBACtB,MAAM,CAAC,IAAI,CACV,IAAI,YAAY,CAAC,+BAA+B,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAClF,CAAC;wBACF,UAAU,GAAG,KAAK,CAAC;oBACpB,CAAC;yBAAM,CAAC;wBACP,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;oBACxB,CAAC;oBAED,MAAM,OAAO,GAAG,oBAAoB,EAAE,iBAAiB,CAAC;oBACxD,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;wBACvB,MAAM,CAAC,IAAI,CACV,IAAI,YAAY,CAAC,+BAA+B,CAAC,UAAU,EAAE,qBAAqB,CAAC,CACnF,CAAC;wBACF,UAAU,GAAG,KAAK,CAAC;oBACpB,CAAC;yBAAM,CAAC;wBACP,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;wBACjB,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;oBACxD,CAAC;gBACF,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,UAAU,GAAG,KAAK,CAAC;oBACnB,MAAM,CAAC,IAAI,CACV,IAAI,YAAY,CACf,+BAA+B,CAAC,UAAU,EAC1C,qBAAqB,EACrB,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CACxB,CACD,CAAC;gBACH,CAAC;gBAED,OAAO,UAAU,CAAC;YACnB,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, Coerce, ComponentFactory, GeneralError, Is, type IError } from \"@twin.org/core\";\nimport { JsonLdHelper } from \"@twin.org/data-json-ld\";\nimport type { IIdentityComponent } from \"@twin.org/identity-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { ITrustVerificationInfo, ITrustVerifier } from \"@twin.org/trust-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IJwtVerifiableCredentialVerifierConstructorOptions } from \"../models/IJwtVerifiableCredentialVerifierConstructorOptions.js\";\n\n/**\n * Class to verify a JWT Verifiable Credential.\n */\nexport class JwtVerifiableCredentialVerifier implements ITrustVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JwtVerifiableCredentialVerifier>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * The identity component.\n\t * @internal\n\t */\n\tprivate readonly _identityComponent: IIdentityComponent;\n\n\t/**\n\t * Create a new instance of JwtVerifiableCredentialVerifier.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IJwtVerifiableCredentialVerifierConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._identityComponent = ComponentFactory.get(options?.identityComponentType ?? \"identity\");\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 JwtVerifiableCredentialVerifier.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\tif (Is.stringValue(payload)) {\n\t\t\tconst jwt = await Jwt.decode(payload);\n\n\t\t\tif (Is.objectValue(jwt.header) && Is.object(jwt.payload) && Is.uint8Array(jwt.signature)) {\n\t\t\t\tlet isVerified = true;\n\t\t\t\ttry {\n\t\t\t\t\tconst expiredMs = (Coerce.number(jwt.payload.exp) ?? 0) * 1000;\n\t\t\t\t\tif (expiredMs > 0 && expiredMs < Date.now()) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenExpired\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst verificationResult =\n\t\t\t\t\t\tawait this._identityComponent.verifiableCredentialVerify(payload);\n\n\t\t\t\t\tconst verifiableCredential = verificationResult.verifiableCredential;\n\t\t\t\t\tif (Is.empty(verifiableCredential)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingCredential\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.data ??= {};\n\t\t\t\t\t\tinfo.data.verifiableCredential = JsonLdHelper.toNodeObject(verifiableCredential);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst issuer: string | undefined = Is.stringValue(verifiableCredential?.issuer)\n\t\t\t\t\t\t? verifiableCredential?.issuer\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tif (Is.empty(issuer)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingIssuer\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.identity = issuer;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst subject = verifiableCredential?.credentialSubject;\n\t\t\t\t\tif (Is.empty(subject)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingSubject\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.data ??= {};\n\t\t\t\t\t\tinfo.data.subject = JsonLdHelper.toNodeObject(subject);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tisVerified = false;\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\tJwtVerifiableCredentialVerifier.CLASS_NAME,\n\t\t\t\t\t\t\t\"tokenDecodingFailed\",\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn isVerified;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"jwtVerifiableCredentialVerifier.js","sourceRoot":"","sources":["../../../src/verifiers/jwtVerifiableCredentialVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,EAAE,EAAe,MAAM,gBAAgB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,qCAAqD;IAEtF;;;OAGG;IACc,kBAAkB,CAAqB;IAExD;;;OAGG;IACH,YAAY,OAA4D;QACvE,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACnD,CAAC;IAED;;;;;;;OA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 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, Coerce, ComponentFactory, GeneralError, Is, type IError } from \"@twin.org/core\";\nimport { JsonLdHelper } from \"@twin.org/data-json-ld\";\nimport type { IIdentityComponent } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { ITrustVerificationInfo, ITrustVerifier } from \"@twin.org/trust-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IJwtVerifiableCredentialVerifierConstructorOptions } from \"../models/IJwtVerifiableCredentialVerifierConstructorOptions.js\";\n\n/**\n * Class to verify a JWT Verifiable Credential.\n */\nexport class JwtVerifiableCredentialVerifier implements ITrustVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JwtVerifiableCredentialVerifier>();\n\n\t/**\n\t * The identity component.\n\t * @internal\n\t */\n\tprivate readonly _identityComponent: IIdentityComponent;\n\n\t/**\n\t * Creates a new instance of JwtVerifiableCredentialVerifier.\n\t * @param options The options for the verifier.\n\t */\n\tconstructor(options?: IJwtVerifiableCredentialVerifierConstructorOptions) {\n\t\tthis._identityComponent = ComponentFactory.get(options?.identityComponentType ?? \"identity\");\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 JwtVerifiableCredentialVerifier.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\tif (Is.stringValue(payload)) {\n\t\t\tconst jwt = await Jwt.decode(payload);\n\n\t\t\tif (Is.objectValue(jwt.header) && Is.object(jwt.payload) && Is.uint8Array(jwt.signature)) {\n\t\t\t\tlet isVerified = true;\n\t\t\t\ttry {\n\t\t\t\t\tconst expiredMs = (Coerce.number(jwt.payload.exp) ?? 0) * 1000;\n\t\t\t\t\tif (expiredMs > 0 && expiredMs < Date.now()) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenExpired\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst verificationResult =\n\t\t\t\t\t\tawait this._identityComponent.verifiableCredentialVerify(payload);\n\n\t\t\t\t\tconst verifiableCredential = verificationResult.verifiableCredential;\n\t\t\t\t\tif (Is.empty(verifiableCredential)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingCredential\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.data ??= {};\n\t\t\t\t\t\tinfo.data.verifiableCredential = JsonLdHelper.toNodeObject(verifiableCredential);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst issuer: string | undefined = Is.stringValue(verifiableCredential?.issuer)\n\t\t\t\t\t\t? verifiableCredential?.issuer\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tif (Is.empty(issuer)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingIssuer\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.identity = issuer;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst subject = verifiableCredential?.credentialSubject;\n\t\t\t\t\tif (Is.empty(subject)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\tnew GeneralError(JwtVerifiableCredentialVerifier.CLASS_NAME, \"tokenMissingSubject\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\tisVerified = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinfo.data ??= {};\n\t\t\t\t\t\tinfo.data.subject = JsonLdHelper.toNodeObject(subject);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tisVerified = false;\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\tJwtVerifiableCredentialVerifier.CLASS_NAME,\n\t\t\t\t\t\t\t\"tokenDecodingFailed\",\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn isVerified;\n\t\t\t}\n\t\t}\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
+ }
@@ -2,11 +2,6 @@
2
2
  * The options for the JWT Verifiable Credential Verifier.
3
3
  */
4
4
  export interface IJwtVerifiableCredentialVerifierConstructorOptions {
5
- /**
6
- * The logging component type.
7
- * @default logging
8
- */
9
- loggingComponentType?: string;
10
5
  /**
11
6
  * The identity component type.
12
7
  * @default identity
@@ -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
+ * Creates 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 runtime class name string
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
+ }
@@ -10,13 +10,13 @@ export declare class JwtVerifiableCredentialVerifier implements ITrustVerifier {
10
10
  */
11
11
  static readonly CLASS_NAME: string;
12
12
  /**
13
- * Create a new instance of JwtVerifiableCredentialVerifier.
14
- * @param options The options for the service.
13
+ * Creates a new instance of JwtVerifiableCredentialVerifier.
14
+ * @param options The options for the verifier.
15
15
  */
16
16
  constructor(options?: IJwtVerifiableCredentialVerifierConstructorOptions);
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
  /**
package/docs/changelog.md CHANGED
@@ -1,6 +1,246 @@
1
1
  # Changelog
2
2
 
3
- ## [0.0.3-next.9](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.8...trust-verifiers-v0.0.3-next.9) (2026-02-26)
3
+ ## [0.9.0](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.9.0...trust-verifiers-v0.9.0) (2026-06-25)
4
+
5
+
6
+ ### Features
7
+
8
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
9
+ * release to production ([#51](https://github.com/iotaledger/twin-trust/issues/51)) ([998b21a](https://github.com/iotaledger/twin-trust/commit/998b21a2c4663b7d49fc11ed2866f34ef75de390))
10
+
11
+ ## [0.9.0-next.1](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.9.0-next.0...trust-verifiers-v0.9.0-next.1) (2026-06-23)
12
+
13
+
14
+ ### Features
15
+
16
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
17
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
18
+ * 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))
19
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
20
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
21
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
22
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
23
+ * remove logging component ([54b56cb](https://github.com/iotaledger/twin-trust/commit/54b56cb81a6cb0aac41e37e8edda9c36685f2adb))
24
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
25
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
26
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
27
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @twin.org/trust-models bumped from 0.9.0-next.0 to 0.9.0-next.1
35
+
36
+ ## [0.0.3-next.24](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.23...trust-verifiers-v0.0.3-next.24) (2026-06-18)
37
+
38
+
39
+ ### Miscellaneous Chores
40
+
41
+ * **trust-verifiers:** Synchronize repo versions
42
+
43
+
44
+ ### Dependencies
45
+
46
+ * The following workspace dependencies were updated
47
+ * dependencies
48
+ * @twin.org/trust-models bumped from 0.0.3-next.23 to 0.0.3-next.24
49
+
50
+ ## [0.0.3-next.23](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.22...trust-verifiers-v0.0.3-next.23) (2026-06-11)
51
+
52
+
53
+ ### Features
54
+
55
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
56
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
57
+ * 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))
58
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
59
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
60
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
61
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
62
+ * remove logging component ([54b56cb](https://github.com/iotaledger/twin-trust/commit/54b56cb81a6cb0aac41e37e8edda9c36685f2adb))
63
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
64
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
65
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
66
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
67
+
68
+
69
+ ### Dependencies
70
+
71
+ * The following workspace dependencies were updated
72
+ * dependencies
73
+ * @twin.org/trust-models bumped from 0.0.3-next.21 to 0.0.3-next.23
74
+
75
+ ## [0.0.3-next.21](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.20...trust-verifiers-v0.0.3-next.21) (2026-06-11)
76
+
77
+
78
+ ### Features
79
+
80
+ * organization identifiers ([#39](https://github.com/iotaledger/twin-trust/issues/39)) ([a5891b9](https://github.com/iotaledger/twin-trust/commit/a5891b9d57ef209c20f53302442d1910dce963d2))
81
+
82
+
83
+ ### Dependencies
84
+
85
+ * The following workspace dependencies were updated
86
+ * dependencies
87
+ * @twin.org/trust-models bumped from 0.0.3-next.20 to 0.0.3-next.21
88
+
89
+ ## [0.0.3-next.20](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.19...trust-verifiers-v0.0.3-next.20) (2026-06-10)
90
+
91
+
92
+ ### Miscellaneous Chores
93
+
94
+ * **trust-verifiers:** Synchronize repo versions
95
+
96
+
97
+ ### Dependencies
98
+
99
+ * The following workspace dependencies were updated
100
+ * dependencies
101
+ * @twin.org/trust-models bumped from 0.0.3-next.19 to 0.0.3-next.20
102
+
103
+ ## [0.0.3-next.19](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.18...trust-verifiers-v0.0.3-next.19) (2026-06-05)
104
+
105
+
106
+ ### Features
107
+
108
+ * remove logging component ([54b56cb](https://github.com/iotaledger/twin-trust/commit/54b56cb81a6cb0aac41e37e8edda9c36685f2adb))
109
+
110
+
111
+ ### Dependencies
112
+
113
+ * The following workspace dependencies were updated
114
+ * dependencies
115
+ * @twin.org/trust-models bumped from 0.0.3-next.18 to 0.0.3-next.19
116
+
117
+ ## [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)
118
+
119
+
120
+ ### Features
121
+
122
+ * add allow deny verifier ([#32](https://github.com/iotaledger/twin-trust/issues/32)) ([daf5d03](https://github.com/iotaledger/twin-trust/commit/daf5d033ffbe82e2228c48ca7ffea870a1ce956e))
123
+
124
+
125
+ ### Dependencies
126
+
127
+ * The following workspace dependencies were updated
128
+ * dependencies
129
+ * @twin.org/trust-models bumped from 0.0.3-next.17 to 0.0.3-next.18
130
+
131
+ ## [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)
132
+
133
+
134
+ ### Miscellaneous Chores
135
+
136
+ * **trust-verifiers:** Synchronize repo versions
137
+
138
+
139
+ ### Dependencies
140
+
141
+ * The following workspace dependencies were updated
142
+ * dependencies
143
+ * @twin.org/trust-models bumped from 0.0.3-next.16 to 0.0.3-next.17
144
+
145
+ ## [0.0.3-next.16](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.15...trust-verifiers-v0.0.3-next.16) (2026-05-27)
146
+
147
+
148
+ ### Miscellaneous Chores
149
+
150
+ * **trust-verifiers:** Synchronize repo versions
151
+
152
+
153
+ ### Dependencies
154
+
155
+ * The following workspace dependencies were updated
156
+ * dependencies
157
+ * @twin.org/trust-models bumped from 0.0.3-next.15 to 0.0.3-next.16
158
+
159
+ ## [0.0.3-next.15](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.14...trust-verifiers-v0.0.3-next.15) (2026-05-26)
160
+
161
+
162
+ ### Miscellaneous Chores
163
+
164
+ * **trust-verifiers:** Synchronize repo versions
165
+
166
+
167
+ ### Dependencies
168
+
169
+ * The following workspace dependencies were updated
170
+ * dependencies
171
+ * @twin.org/trust-models bumped from 0.0.3-next.14 to 0.0.3-next.15
172
+
173
+ ## [0.0.3-next.14](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.13...trust-verifiers-v0.0.3-next.14) (2026-05-22)
174
+
175
+
176
+ ### Features
177
+
178
+ * 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))
179
+
180
+
181
+ ### Dependencies
182
+
183
+ * The following workspace dependencies were updated
184
+ * dependencies
185
+ * @twin.org/trust-models bumped from 0.0.3-next.13 to 0.0.3-next.14
186
+
187
+ ## [0.0.3-next.13](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.12...trust-verifiers-v0.0.3-next.13) (2026-05-20)
188
+
189
+
190
+ ### Features
191
+
192
+ * update dependencies ([367d7fc](https://github.com/iotaledger/twin-trust/commit/367d7fc1f970522650c776d231bfacc84f97be67))
193
+
194
+
195
+ ### Dependencies
196
+
197
+ * The following workspace dependencies were updated
198
+ * dependencies
199
+ * @twin.org/trust-models bumped from 0.0.3-next.12 to 0.0.3-next.13
200
+
201
+ ## [0.0.3-next.12](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.11...trust-verifiers-v0.0.3-next.12) (2026-05-11)
202
+
203
+
204
+ ### Features
205
+
206
+ * typescript 6 update ([a232da2](https://github.com/iotaledger/twin-trust/commit/a232da293afbd3b42843e187e4952dabd7917397))
207
+
208
+
209
+ ### Dependencies
210
+
211
+ * The following workspace dependencies were updated
212
+ * dependencies
213
+ * @twin.org/trust-models bumped from 0.0.3-next.11 to 0.0.3-next.12
214
+
215
+ ## [0.0.3-next.11](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.10...trust-verifiers-v0.0.3-next.11) (2026-03-04)
216
+
217
+
218
+ ### Miscellaneous Chores
219
+
220
+ * **trust-verifiers:** Synchronize repo versions
221
+
222
+
223
+ ### Dependencies
224
+
225
+ * The following workspace dependencies were updated
226
+ * dependencies
227
+ * @twin.org/trust-models bumped from 0.0.3-next.10 to 0.0.3-next.11
228
+
229
+ ## [0.0.3-next.10](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.9...trust-verifiers-v0.0.3-next.10) (2026-02-27)
230
+
231
+
232
+ ### Miscellaneous Chores
233
+
234
+ * **trust-verifiers:** Synchronize repo versions
235
+
236
+
237
+ ### Dependencies
238
+
239
+ * The following workspace dependencies were updated
240
+ * dependencies
241
+ * @twin.org/trust-models bumped from 0.0.3-next.9 to 0.0.3-next.10
242
+
243
+ ## [0.0.3-next.9](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.8...trust-verifiers-v0.0.3-next.9) (2026-02-26)
4
244
 
5
245
 
6
246
  ### Miscellaneous Chores
@@ -14,12 +254,12 @@
14
254
  * dependencies
15
255
  * @twin.org/trust-models bumped from 0.0.3-next.8 to 0.0.3-next.9
16
256
 
17
- ## [0.0.3-next.8](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.7...trust-verifiers-v0.0.3-next.8) (2026-01-30)
257
+ ## [0.0.3-next.8](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.7...trust-verifiers-v0.0.3-next.8) (2026-01-30)
18
258
 
19
259
 
20
260
  ### Features
21
261
 
22
- * verification info structure ([#10](https://github.com/twinfoundation/trust/issues/10)) ([8b09ec8](https://github.com/twinfoundation/trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
262
+ * verification info structure ([#10](https://github.com/iotaledger/twin-trust/issues/10)) ([8b09ec8](https://github.com/iotaledger/twin-trust/commit/8b09ec8128214b659f427fc3a985eb8ced9ed5dc))
23
263
 
24
264
 
25
265
  ### Dependencies
@@ -28,7 +268,7 @@
28
268
  * dependencies
29
269
  * @twin.org/trust-models bumped from 0.0.3-next.7 to 0.0.3-next.8
30
270
 
31
- ## [0.0.3-next.7](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.6...trust-verifiers-v0.0.3-next.7) (2025-12-04)
271
+ ## [0.0.3-next.7](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.6...trust-verifiers-v0.0.3-next.7) (2025-12-04)
32
272
 
33
273
 
34
274
  ### Miscellaneous Chores
@@ -42,12 +282,12 @@
42
282
  * dependencies
43
283
  * @twin.org/trust-models bumped from 0.0.3-next.6 to 0.0.3-next.7
44
284
 
45
- ## [0.0.3-next.6](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.5...trust-verifiers-v0.0.3-next.6) (2025-12-04)
285
+ ## [0.0.3-next.6](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.5...trust-verifiers-v0.0.3-next.6) (2025-12-04)
46
286
 
47
287
 
48
288
  ### Features
49
289
 
50
- * always include identity in verification info ([9594d19](https://github.com/twinfoundation/trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
290
+ * always include identity in verification info ([9594d19](https://github.com/iotaledger/twin-trust/commit/9594d19e9d718bd42b82964750ae3bcfb7df51bf))
51
291
 
52
292
 
53
293
  ### Dependencies
@@ -56,7 +296,7 @@
56
296
  * dependencies
57
297
  * @twin.org/trust-models bumped from 0.0.3-next.5 to 0.0.3-next.6
58
298
 
59
- ## [0.0.3-next.5](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.4...trust-verifiers-v0.0.3-next.5) (2025-12-04)
299
+ ## [0.0.3-next.5](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.4...trust-verifiers-v0.0.3-next.5) (2025-12-04)
60
300
 
61
301
 
62
302
  ### Miscellaneous Chores
@@ -70,12 +310,12 @@
70
310
  * dependencies
71
311
  * @twin.org/trust-models bumped from 0.0.3-next.4 to 0.0.3-next.5
72
312
 
73
- ## [0.0.3-next.4](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.3...trust-verifiers-v0.0.3-next.4) (2025-12-04)
313
+ ## [0.0.3-next.4](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.3...trust-verifiers-v0.0.3-next.4) (2025-12-04)
74
314
 
75
315
 
76
316
  ### Features
77
317
 
78
- * add generators ([6228c88](https://github.com/twinfoundation/trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
318
+ * add generators ([6228c88](https://github.com/iotaledger/twin-trust/commit/6228c88a8f0244b7bdfc76b8624c427c81d23f7b))
79
319
 
80
320
 
81
321
  ### Dependencies
@@ -84,12 +324,12 @@
84
324
  * dependencies
85
325
  * @twin.org/trust-models bumped from 0.0.3-next.3 to 0.0.3-next.4
86
326
 
87
- ## [0.0.3-next.3](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.2...trust-verifiers-v0.0.3-next.3) (2025-12-04)
327
+ ## [0.0.3-next.3](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.2...trust-verifiers-v0.0.3-next.3) (2025-12-04)
88
328
 
89
329
 
90
330
  ### Features
91
331
 
92
- * flatten error structure ([5fdd665](https://github.com/twinfoundation/trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
332
+ * flatten error structure ([5fdd665](https://github.com/iotaledger/twin-trust/commit/5fdd665d0fc523a655563a0c20d1d82b634534e2))
93
333
 
94
334
 
95
335
  ### Dependencies
@@ -98,12 +338,12 @@
98
338
  * dependencies
99
339
  * @twin.org/trust-models bumped from 0.0.3-next.2 to 0.0.3-next.3
100
340
 
101
- ## [0.0.3-next.2](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.1...trust-verifiers-v0.0.3-next.2) (2025-12-03)
341
+ ## [0.0.3-next.2](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.1...trust-verifiers-v0.0.3-next.2) (2025-12-03)
102
342
 
103
343
 
104
344
  ### Features
105
345
 
106
- * support pass through of info between verifiers ([1ce64b9](https://github.com/twinfoundation/trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
346
+ * support pass through of info between verifiers ([1ce64b9](https://github.com/iotaledger/twin-trust/commit/1ce64b97a949278b447cc12b576ce5de537f30f3))
107
347
 
108
348
 
109
349
  ### Dependencies
@@ -112,12 +352,12 @@
112
352
  * dependencies
113
353
  * @twin.org/trust-models bumped from 0.0.3-next.1 to 0.0.3-next.2
114
354
 
115
- ## [0.0.3-next.1](https://github.com/twinfoundation/trust/compare/trust-verifiers-v0.0.3-next.0...trust-verifiers-v0.0.3-next.1) (2025-12-02)
355
+ ## [0.0.3-next.1](https://github.com/iotaledger/twin-trust/compare/trust-verifiers-v0.0.3-next.0...trust-verifiers-v0.0.3-next.1) (2025-12-02)
116
356
 
117
357
 
118
358
  ### Features
119
359
 
120
- * initial commit ([d378ef4](https://github.com/twinfoundation/trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
360
+ * initial commit ([d378ef4](https://github.com/iotaledger/twin-trust/commit/d378ef4cd66c98fa188aaf3b23152d1e47d88a37))
121
361
 
122
362
 
123
363
  ### Dependencies
@@ -126,4 +366,4 @@
126
366
  * dependencies
127
367
  * @twin.org/trust-models bumped from 0.0.3-next.0 to 0.0.3-next.1
128
368
 
129
- ## @twin.org/trust-verifiers - Changelog
369
+ ## Changelog
package/docs/examples.md CHANGED
@@ -1 +1,44 @@
1
- # @twin.org/trust-verifiers - Examples
1
+ # Trust Verifiers Examples
2
+
3
+ These snippets demonstrate how to initialise a JWT verifier and evaluate a token while collecting identity and subject details.
4
+
5
+ ## JwtVerifiableCredentialVerifier
6
+
7
+ ```typescript
8
+ import { ComponentFactory, type IError } from '@twin.org/core';
9
+ import type { IIdentityComponent } from '@twin.org/identity-models';
10
+ import type { ITrustVerificationInfo } from '@twin.org/trust-models';
11
+ import { JwtVerifiableCredentialVerifier } from '@twin.org/trust-verifiers';
12
+
13
+ const identityComponent: IIdentityComponent = {
14
+ verifiableCredentialVerify: async () => ({
15
+ verifiableCredential: {
16
+ issuer: 'did:example:issuer',
17
+ credentialSubject: {
18
+ id: 'did:example:subject',
19
+ role: 'supplier'
20
+ }
21
+ }
22
+ })
23
+ } as IIdentityComponent;
24
+
25
+ ComponentFactory.register('identity', () => identityComponent);
26
+
27
+ const verifier = new JwtVerifiableCredentialVerifier({
28
+ identityComponentType: 'identity'
29
+ });
30
+
31
+ console.log(verifier.className()); // JwtVerifiableCredentialVerifier
32
+
33
+ const info: ITrustVerificationInfo = { identity: '' };
34
+ const errors: IError[] = [];
35
+ const verified = await verifier.verify(
36
+ 'eyJhbGciOiJFZERTQSJ9.eyJleHAiOjQwMDAwMDAwMDB9.signature',
37
+ info,
38
+ errors
39
+ );
40
+
41
+ console.log(verified); // true
42
+ console.log(info.identity); // did:example:issuer
43
+ console.log(info.data?.subject); // { id: "did:example:subject", role: "supplier" }
44
+ ```
@@ -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
+ Creates 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 runtime class name string
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`
@@ -12,7 +12,7 @@ Class to verify a JWT Verifiable Credential.
12
12
 
13
13
  > **new JwtVerifiableCredentialVerifier**(`options?`): `JwtVerifiableCredentialVerifier`
14
14
 
15
- Create a new instance of JwtVerifiableCredentialVerifier.
15
+ Creates a new instance of JwtVerifiableCredentialVerifier.
16
16
 
17
17
  #### Parameters
18
18
 
@@ -20,7 +20,7 @@ Create a new instance of JwtVerifiableCredentialVerifier.
20
20
 
21
21
  [`IJwtVerifiableCredentialVerifierConstructorOptions`](../interfaces/IJwtVerifiableCredentialVerifierConstructorOptions.md)
22
22
 
23
- The options for the service.
23
+ The options for the verifier.
24
24
 
25
25
  #### Returns
26
26
 
@@ -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,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### verify()
57
+ ### verify() {#verify}
58
58
 
59
59
  > **verify**(`payload`, `info`, `errors`): `Promise`\<`boolean` \| `undefined`\>
60
60
 
@@ -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.
@@ -4,23 +4,9 @@ The options for the JWT Verifiable Credential Verifier.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### loggingComponentType?
7
+ ### identityComponentType? {#identitycomponenttype}
8
8
 
9
- > `optional` **loggingComponentType**: `string`
10
-
11
- The logging component type.
12
-
13
- #### Default
14
-
15
- ```ts
16
- logging
17
- ```
18
-
19
- ***
20
-
21
- ### identityComponentType?
22
-
23
- > `optional` **identityComponentType**: `string`
9
+ > `optional` **identityComponentType?**: `string`
24
10
 
25
11
  The identity component type.
26
12
 
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,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/trust-verifiers",
3
- "version": "0.0.3-next.9",
4
- "description": "Verifiers for trust",
3
+ "version": "0.9.0",
4
+ "description": "Implements trust verifiers that validate credentials and proofs against trust model requirements",
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-verifiers"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,13 +14,13 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "next",
18
- "@twin.org/data-json-ld": "next",
19
- "@twin.org/identity-models": "next",
20
- "@twin.org/logging-models": "next",
21
- "@twin.org/nameof": "next",
22
- "@twin.org/trust-models": "0.0.3-next.9",
23
- "@twin.org/web": "next"
17
+ "@twin.org/core": "^0.9.0",
18
+ "@twin.org/data-json-ld": "^0.9.0",
19
+ "@twin.org/identity-models": "^0.9.0-next.1",
20
+ "@twin.org/logging-models": "^0.9.0",
21
+ "@twin.org/nameof": "^0.9.0",
22
+ "@twin.org/trust-models": "^0.9.0",
23
+ "@twin.org/web": "^0.9.0"
24
24
  },
25
25
  "main": "./dist/es/index.js",
26
26
  "types": "./dist/types/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "schemas"
51
51
  ],
52
52
  "bugs": {
53
- "url": "git+https://github.com/twinfoundation/trust/issues"
53
+ "url": "git+https://github.com/iotaledger/twin-trust/issues"
54
54
  },
55
55
  "homepage": "https://twindev.org"
56
56
  }