@gramota/verifier 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @gramota/verifier
2
+
3
+ > Relying-party verifier for the EU Digital Identity Wallet. One client, one method, full IETF SD-JWT-VC + KB-JWT spec compliance.
4
+
5
+ Part of [Gramota](https://github.com/gramota-org/gramota) — the TypeScript
6
+ SDK for the EU Digital Identity Wallet (EUDIW).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @gramota/verifier
12
+ # or: npm install @gramota/verifier
13
+ # or: yarn add @gramota/verifier
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { Verifier } from "@gramota/verifier";
20
+
21
+ const verifier = new Verifier({ audience, trustResolver });
22
+ const result = await verifier.verify(presentationToken, { nonce });
23
+ if (result.ok) console.log(result.claims);
24
+ ```
25
+
26
+ For full docs, examples, and the high-level Verifier/Issuer/Holder API,
27
+ see the [main repo](https://github.com/gramota-org/gramota).
28
+
29
+ ## License
30
+
31
+ [Apache 2.0](https://github.com/gramota-org/gramota/blob/main/LICENSE)
@@ -0,0 +1,6 @@
1
+ export { Verifier, verify } from "./verifier.js";
2
+ export type { PresentationRequestOptions, PresentationRequest, VerifyResponseOptions, VerifyResponseResult, } from "./verifier.js";
3
+ export { inspect } from "./inspect.js";
4
+ export { VerificationError } from "./types.js";
5
+ export type { VerifierConfig, VerifyOptions, VerifyResult, SuccessResult, FailureResult, SecurityCheck, SecurityCheckName, VerificationMetadata, } from "./types.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { Verifier, verify } from "./verifier.js";
2
+ export { inspect } from "./inspect.js";
3
+ export { VerificationError } from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAOjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type ParsedSdJwt } from "@gramota/sd-jwt";
2
+ /**
3
+ * Parse an SD-JWT-VC presentation token without verifying anything.
4
+ * Useful for debug UIs, CLI tools, and admin dashboards. Never use the
5
+ * output to make trust decisions — that's `verifier.verify()`'s job.
6
+ */
7
+ export declare function inspect(presentationToken: string): ParsedSdJwt;
8
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAE9D"}
@@ -0,0 +1,10 @@
1
+ import { parseSdJwt } from "@gramota/sd-jwt";
2
+ /**
3
+ * Parse an SD-JWT-VC presentation token without verifying anything.
4
+ * Useful for debug UIs, CLI tools, and admin dashboards. Never use the
5
+ * output to make trust decisions — that's `verifier.verify()`'s job.
6
+ */
7
+ export function inspect(presentationToken) {
8
+ return parseSdJwt(presentationToken);
9
+ }
10
+ //# sourceMappingURL=inspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,iBAAyB;IAC/C,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,120 @@
1
+ import type { JsonWebKey, SupportedAlg } from "@gramota/jose";
2
+ import type { TrustResolver } from "@gramota/trust";
3
+ import type { CredentialStatusResult, StatusResolver } from "@gramota/status-list";
4
+ /** Configuration for a Verifier instance. */
5
+ export interface VerifierConfig {
6
+ /** The verifier's identifier. The KB-JWT's `aud` claim MUST equal this.
7
+ * Cross-verifier replay protection — pick a stable, app-specific URL. */
8
+ audience: string;
9
+ /** Exactly one of `issuerKey` (shorthand) OR `trust` (full resolver) is
10
+ * required. */
11
+ issuerKey?: JsonWebKey;
12
+ /** Pluggable trust resolution. Use `StaticTrustResolver` for hard-coded
13
+ * keys, `JwksUrlTrustResolver` for runtime JWKS fetching, or any custom
14
+ * implementation of the `TrustResolver` interface. */
15
+ trust?: TrustResolver;
16
+ /**
17
+ * Pluggable revocation/suspension resolution (Strategy pattern).
18
+ *
19
+ * When set, the verifier runs a 10th security check ("status.check")
20
+ * after all crypto checks pass. Default: omitted — no status check.
21
+ *
22
+ * Use `StatusListResolver` for IETF Token Status List (the typical EU
23
+ * choice). Custom resolvers (CRL, OCSP, EU Trusted Issuers Registry,
24
+ * deny-lists) implement the `StatusResolver` interface and plug in here.
25
+ */
26
+ statusResolver?: StatusResolver;
27
+ /** JWS algorithm allowlist for both issuer and KB-JWT signatures.
28
+ * Default: every IETF asymmetric algorithm we support.
29
+ * `alg=none` is *never* permitted, regardless of this list. */
30
+ algorithms?: readonly SupportedAlg[];
31
+ /** Maximum acceptable age of the KB-JWT, in seconds. Default 60. */
32
+ maxKbJwtAgeSeconds?: number;
33
+ /** Maximum acceptable clock skew (KB-JWT `iat` in the future), in seconds.
34
+ * Default 30. */
35
+ maxClockSkewSeconds?: number;
36
+ }
37
+ /** Per-call options for `verifier.verify(...)`. */
38
+ export interface VerifyOptions {
39
+ /** The challenge the verifier sent to the wallet. The KB-JWT's `nonce`
40
+ * claim MUST equal this. Within-verifier replay protection. */
41
+ nonce: string;
42
+ /** Override "now" — used for tests and time-frozen environments. Returns
43
+ * Unix seconds. Default: `Math.floor(Date.now() / 1000)`. */
44
+ now?: () => number;
45
+ /**
46
+ * Status-check policy for THIS verification.
47
+ *
48
+ * - When `false`/omitted, the configured `statusResolver` (if any)
49
+ * is still consulted; "skipped" is acceptable.
50
+ * - When `true`, a credential with no resolvable status fails the
51
+ * "status.check" gate. Useful for high-assurance flows where
52
+ * non-revocable credentials are unacceptable.
53
+ *
54
+ * Has no effect when no `statusResolver` is configured on the Verifier.
55
+ */
56
+ requireStatus?: boolean;
57
+ }
58
+ /** A single security check, recorded for observability. Every check is
59
+ * present in the result regardless of pass/fail, so customers can build
60
+ * audit dashboards. */
61
+ export interface SecurityCheck {
62
+ /** Stable identifier — useful for logs and dashboards. */
63
+ name: SecurityCheckName;
64
+ passed: boolean;
65
+ /** Human-readable detail when the check fails. */
66
+ message?: string;
67
+ }
68
+ /** Stable identifiers for the security checks we run, in execution order. */
69
+ export type SecurityCheckName = "structure.parse" | "trust.resolution" | "issuer.signature" | "hash-binding.disclosures" | "kb-jwt.present" | "kb-jwt.cnf-binding" | "kb-jwt.signature" | "kb-jwt.audience" | "kb-jwt.nonce" | "kb-jwt.time" | "kb-jwt.transcript" | "status.check";
70
+ /** Protocol metadata extracted alongside the user-facing claims. */
71
+ export interface VerificationMetadata {
72
+ issuer: string;
73
+ audience: string;
74
+ issuedAt: number | undefined;
75
+ expiresAt: number | undefined;
76
+ /** The holder's bound public JWK from cnf.jwk in the parent SD-JWT. After
77
+ * verification this is guaranteed to be a well-formed JWK that successfully
78
+ * verified the KB-JWT signature. */
79
+ holderKey: Readonly<Record<string, unknown>>;
80
+ }
81
+ export type VerifyResult<TClaims = Record<string, unknown>> = SuccessResult<TClaims> | FailureResult;
82
+ export interface SuccessResult<TClaims = Record<string, unknown>> {
83
+ ok: true;
84
+ /** The selectively-disclosed user claims with `_sd` / `_sd_alg` / `cnf`
85
+ * stripped — this is what the application actually consumes. */
86
+ claims: TClaims;
87
+ /** Protocol-level metadata that's not part of the user claims. */
88
+ metadata: VerificationMetadata;
89
+ /** Every check we ran, all passed. Useful for audit trails. */
90
+ checks: readonly SecurityCheck[];
91
+ /** When `options.status` was supplied, the resolved status (or
92
+ * "skipped" if the credential carried no status reference). Absent
93
+ * when status checking wasn't requested. */
94
+ status?: CredentialStatusResult | "skipped";
95
+ /** Returns claims; never throws on success. */
96
+ unwrap(): TClaims;
97
+ }
98
+ export interface FailureResult {
99
+ ok: false;
100
+ /** Human-readable reason — surfaces the message from the failed check. */
101
+ reason: string;
102
+ /** Stable identifier of the first check that failed. */
103
+ failedCheck: SecurityCheckName;
104
+ /** Every check up to and including the one that failed. */
105
+ checks: readonly SecurityCheck[];
106
+ /** Throws `VerificationError` carrying this result. */
107
+ unwrap(): never;
108
+ }
109
+ export declare class VerificationError extends Error {
110
+ /** The full failure record — stable for logging. */
111
+ readonly result: FailureResult;
112
+ readonly name = "VerificationError";
113
+ /** Equal to `result.failedCheck` — stable identifier for log filters,
114
+ * alerts, and dashboards. Same shape as the codes used by other packages. */
115
+ readonly code: SecurityCheckName;
116
+ constructor(message: string,
117
+ /** The full failure record — stable for logging. */
118
+ result: FailureResult);
119
+ }
120
+ //# sourceMapp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uBAAuB;IAC7C;iFAC6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;gBAE/B,OAAO,EAAE,MAAM;IACf,oDAAoD;IAC3C,MAAM,EAAE,aAAa;CAKjC"}
package/dist/types.js ADDED
@@ -0,0 +1,15 @@
1
+ export class VerificationError extends Error {
2
+ result;
3
+ name = "VerificationError";
4
+ /** Equal to `result.failedCheck` — stable identifier for log filters,
5
+ * alerts, and dashboards. Same shape as the codes used by other packages. */
6
+ code;
7
+ constructor(message,
8
+ /** The full failure record — stable for logging. */
9
+ result) {
10
+ super(message);
11
+ this.result = result;
12
+ this.code = result.failedCheck;
13
+ }
14
+ }
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8IA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAQ/B;IAPO,IAAI,GAAG,mBAAmB,CAAC;IAC7C;iFAC6E;IACpE,IAAI,CAAoB;IACjC,YACE,OAAe;IACf,oDAAoD;IAC3C,MAAqB;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAAe;QAG9B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IACjC,CAAC;CACF"}
@@ -0,0 +1,83 @@
1
+ import { type AuthorizationRequest, type AuthorizationResponse } from "@gramota/oid4vp";
2
+ import { type VerifierConfig, type VerifyOptions, type VerifyResult } from "./types.js";
3
+ export declare class Verifier {
4
+ private readonly audience;
5
+ private readonly trust;
6
+ private readonly statusResolver;
7
+ private readonly algorithms;
8
+ private readonly maxKbJwtAgeSeconds;
9
+ private readonly maxClockSkewSeconds;
10
+ constructor(config: VerifierConfig);
11
+ /**
12
+ * Verify an SD-JWT-VC presentation token end-to-end.
13
+ *
14
+ * Runs 9 security checks in order; stops at the first failure and reports
15
+ * which check failed. On success, returns the disclosed claims plus
16
+ * protocol metadata plus the full audit trail of checks performed.
17
+ */
18
+ verify<TClaims = Record<string, unknown>>(presentationToken: string, options: VerifyOptions): Promise<VerifyResult<TClaims>>;
19
+ /** Build an OID4VP Authorization Request URL to share with the wallet. */
20
+ request(options: PresentationRequestOptions): PresentationRequest;
21
+ /**
22
+ * Process an OID4VP Authorization Response body end-to-end:
23
+ * parse the form body, enforce CSRF state matching, and verify the
24
+ * vp_token cryptographically. Returns the same result shape as `verify()`
25
+ * plus the parsed transport envelope.
26
+ */
27
+ response<TClaims = Record<string, unknown>>(rawBody: string | URLSearchParams | Record<string, string>, options: VerifyResponseOptions): Promise<VerifyResponseResult<TClaims>>;
28
+ }
29
+ /** Result of `verifier.responses.verify()` — same shape as `VerifyResult`
30
+ * plus the parsed OID4VP transport envelope. */
31
+ export type VerifyResponseResult<TClaims = Record<string, unknown>> = VerifyResult<TClaims> & {
32
+ response?: AuthorizationResponse;
33
+ };
34
+ /** Options for `verifier.request()`. */
35
+ export interface PresentationRequestOptions {
36
+ /** Base URL or scheme: `openid4vp://authorize`, `https://wallet.example.com/...` */
37
+ baseUrl: string;
38
+ /** OID4VP nonce. */
39
+ nonce: string;
40
+ /** Optional opaque CSRF state echoed back unchanged in the response. */
41
+ state?: string;
42
+ /** `direct_post` callback URL (required when response_mode=direct_post). */
43
+ responseUri?: string;
44
+ /** Inline DIF Presentation Definition. */
45
+ presentationDefinition?: Readonly<Record<string, unknown>>;
46
+ /** Or a URL the wallet can fetch the PD from. Mutually exclusive with above. */
47
+ presentationDefinitionUri?: string;
48
+ /** Override response_mode (default: direct_post when responseUri is set,
49
+ * otherwise undefined). */
50
+ responseMode?: "direct_post" | "direct_post.jwt" | "fragment" | "query";
51
+ /** client_id_scheme (default: redirect_uri). */
52
+ clientIdScheme?: string;
53
+ /** Override the client_id (defaults to the verifier's audience). */
54
+ clientId?: string;
55
+ }
56
+ /** Result of `verifier.request()`. */
57
+ export interface PresentationRequest {
58
+ /** The full URL to share with the wallet (QR / deep link). */
59
+ url: string;
60
+ /** The structured AuthorizationRequest, useful for storage and logging. */
61
+ request: AuthorizationRequest;
62
+ /** Echoes the nonce so callers can persist it for later verification. */
63
+ nonce: string;
64
+ /** Echoes the state if one was supplied. */
65
+ state: string | undefined;
66
+ }
67
+ /** Options for `verifier.response()`. */
68
+ export interface VerifyResponseOptions {
69
+ /** Required — the nonce used in the original request. */
70
+ expectedNonce: string;
71
+ /** Optional — when supplied, response.state MUST equal this. */
72
+ expectedState?: string;
73
+ /** Override "now" — for tests. */
74
+ now?: () => number;
75
+ /** Forwarded to `verify()` — fail when credential has no resolvable
76
+ * status. Has effect only when the Verifier was constructed with a
77
+ * `statusResolver`. */
78
+ requireStatus?: boolean;
79
+ }
80
+ /** Standalone one-off verification — same semantics as Verifier.verify, but
81
+ * no instance to keep around. Pass everything inline. */
82
+ export declare function verify<TClaims = Record<string, unknown>>(presentationToken: string, options: VerifyOptions & VerifierConfig): Promise<VerifyResult<TClaims>>;
83
+ //# sourceMappingURL=verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../src/verifier.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAKpB,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;IAC5D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsC;IACjE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAEjC,MAAM,EAAE,cAAc;IAkClC;;;;;;OAMG;IACG,MAAM,CAAC,OAA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nB;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,OAAO,EAAE,oBAAoB,CAAC;IAC9B,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,yCAAyC;AACzC,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;2BAEuB;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;yDACyD;AACzD,wBAAsB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,aAAa,GAAG,cAAc,GACtC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAKhC"}
@@ -0,0 +1,381 @@
1
+ import { parseSdJwt, verifyHashBinding, verifyKeyBinding, SdJwtParseError, SdJwtVerificationError, SdJwtKeyBindingError, } from "@gramota/sd-jwt";
2
+ import { verifyJws, JoseVerificationError, } from "@gramota/jose";
3
+ import { StaticTrustResolver, TrustResolutionError, } from "@gramota/trust";
4
+ import { buildAuthorizationRequestUrl, parseAuthorizationResponseBody, } from "@gramota/oid4vp";
5
+ import { VerificationError, } from "./types.js";
6
+ const DEFAULT_MAX_AGE_S = 60;
7
+ const DEFAULT_CLOCK_SKEW_S = 30;
8
+ export class Verifier {
9
+ audience;
10
+ trust;
11
+ statusResolver;
12
+ algorithms;
13
+ maxKbJwtAgeSeconds;
14
+ maxClockSkewSeconds;
15
+ constructor(config) {
16
+ if (typeof config.audience !== "string" || config.audience.length === 0) {
17
+ throw new TypeError("Verifier: audience is required");
18
+ }
19
+ const hasKey = config.issuerKey !== undefined &&
20
+ config.issuerKey !== null &&
21
+ typeof config.issuerKey === "object";
22
+ const hasTrust = config.trust !== undefined;
23
+ if (hasKey && hasTrust) {
24
+ throw new TypeError("Verifier: pass exactly one of issuerKey (shorthand) OR trust (resolver), not both");
25
+ }
26
+ if (!hasKey && !hasTrust) {
27
+ throw new TypeError("Verifier: one of issuerKey (shorthand) or trust (resolver) is required");
28
+ }
29
+ this.audience = config.audience;
30
+ this.trust = hasTrust
31
+ ? config.trust
32
+ : new StaticTrustResolver([config.issuerKey]);
33
+ this.statusResolver = config.statusResolver;
34
+ this.algorithms = config.algorithms;
35
+ this.maxKbJwtAgeSeconds =
36
+ config.maxKbJwtAgeSeconds ?? DEFAULT_MAX_AGE_S;
37
+ this.maxClockSkewSeconds =
38
+ config.maxClockSkewSeconds ?? DEFAULT_CLOCK_SKEW_S;
39
+ }
40
+ /**
41
+ * Verify an SD-JWT-VC presentation token end-to-end.
42
+ *
43
+ * Runs 9 security checks in order; stops at the first failure and reports
44
+ * which check failed. On success, returns the disclosed claims plus
45
+ * protocol metadata plus the full audit trail of checks performed.
46
+ */
47
+ async verify(presentationToken, options) {
48
+ if (typeof options.nonce !== "string" || options.nonce.length === 0) {
49
+ throw new TypeError("verify: options.nonce is required");
50
+ }
51
+ const checks = [];
52
+ // 1. Parse the token
53
+ let parsed;
54
+ try {
55
+ parsed = parseSdJwt(presentationToken);
56
+ record(checks, "structure.parse", true);
57
+ }
58
+ catch (err) {
59
+ return makeFailure(checks, "structure.parse", describe(err));
60
+ }
61
+ // 2a. Resolve trusted issuer keys via the configured TrustResolver
62
+ let candidateKeys;
63
+ try {
64
+ const iss = typeof parsed.payload["iss"] === "string"
65
+ ? parsed.payload["iss"]
66
+ : undefined;
67
+ const kid = typeof parsed.header["kid"] === "string"
68
+ ? parsed.header["kid"]
69
+ : undefined;
70
+ const trustContext = {
71
+ iss,
72
+ kid,
73
+ header: parsed.header,
74
+ };
75
+ candidateKeys = await this.trust.resolveIssuerKeys(trustContext);
76
+ if (candidateKeys.length === 0) {
77
+ return makeFailure(checks, "trust.resolution", "trust resolver returned no candidate keys");
78
+ }
79
+ record(checks, "trust.resolution", true);
80
+ }
81
+ catch (err) {
82
+ return makeFailure(checks, "trust.resolution", describe(err));
83
+ }
84
+ // 2b. Verify the issuer signature against any of the candidate keys
85
+ const issuerJws = `${parsed.signedPayload}.${parsed.signature}`;
86
+ const verifyOpts = {};
87
+ if (this.algorithms !== undefined) {
88
+ verifyOpts.algorithms = this.algorithms;
89
+ }
90
+ let verifiedAny = false;
91
+ let lastSignatureError;
92
+ for (const key of candidateKeys) {
93
+ try {
94
+ await verifyJws(issuerJws, key, verifyOpts);
95
+ verifiedAny = true;
96
+ break;
97
+ }
98
+ catch (err) {
99
+ lastSignatureError = err;
100
+ }
101
+ }
102
+ if (!verifiedAny) {
103
+ return makeFailure(checks, "issuer.signature", describe(lastSignatureError));
104
+ }
105
+ record(checks, "issuer.signature", true);
106
+ // 3. Verify hash binding (disclosures match _sd digests, no forgery)
107
+ let verifiedSdJwt;
108
+ try {
109
+ verifiedSdJwt = verifyHashBinding(parsed);
110
+ if (verifiedSdJwt.unmatchedDisclosures.length > 0) {
111
+ const names = verifiedSdJwt.unmatchedDisclosures
112
+ .map((d) => d.name ?? "<array element>")
113
+ .join(", ");
114
+ return makeFailure(checks, "hash-binding.disclosures", `forged disclosures detected: ${names}`);
115
+ }
116
+ record(checks, "hash-binding.disclosures", true);
117
+ }
118
+ catch (err) {
119
+ return makeFailure(checks, "hash-binding.disclosures", describe(err));
120
+ }
121
+ // 4-9. KB-JWT (presence, cnf, signature, aud, nonce, time, transcript)
122
+ let verifiedKb;
123
+ try {
124
+ const kbOpts = {
125
+ expectedAudience: this.audience,
126
+ expectedNonce: options.nonce,
127
+ maxAgeSeconds: this.maxKbJwtAgeSeconds,
128
+ maxClockSkewSeconds: this.maxClockSkewSeconds,
129
+ };
130
+ if (this.algorithms !== undefined) {
131
+ kbOpts.algorithms = this.algorithms;
132
+ }
133
+ if (options.now !== undefined) {
134
+ kbOpts.now = options.now;
135
+ }
136
+ verifiedKb = await verifyKeyBinding(parsed, kbOpts);
137
+ // KB-JWT verifyKeyBinding short-circuits on first failure; if it
138
+ // returns successfully, all six sub-checks passed.
139
+ record(checks, "kb-jwt.present", true);
140
+ record(checks, "kb-jwt.cnf-binding", true);
141
+ record(checks, "kb-jwt.signature", true);
142
+ record(checks, "kb-jwt.audience", true);
143
+ record(checks, "kb-jwt.nonce", true);
144
+ record(checks, "kb-jwt.time", true);
145
+ record(checks, "kb-jwt.transcript", true);
146
+ }
147
+ catch (err) {
148
+ return makeFailure(checks, classifyKbFailure(err), describe(err));
149
+ }
150
+ // 10. Optional status check — delegated to the configured StatusResolver
151
+ // Strategy. The verifier knows POLICY (requireStatus); the resolver
152
+ // knows MECHANISM (status list, CRL, OCSP, ...).
153
+ let statusResult;
154
+ if (this.statusResolver !== undefined) {
155
+ const resolveOpts = {};
156
+ if (options.now !== undefined)
157
+ resolveOpts.now = options.now;
158
+ try {
159
+ statusResult = await this.statusResolver.resolveStatus(parsed, resolveOpts);
160
+ }
161
+ catch (err) {
162
+ return makeFailure(checks, "status.check", describe(err));
163
+ }
164
+ if (statusResult === "skipped") {
165
+ if (options.requireStatus) {
166
+ return makeFailure(checks, "status.check", "credential has no resolvable status but requireStatus=true");
167
+ }
168
+ record(checks, "status.check", true, "credential status was skipped (no reference resolved)");
169
+ }
170
+ else if (statusResult.state !== "valid") {
171
+ return makeFailure(checks, "status.check", `credential status is '${statusResult.state}' (code=${statusResult.code})`);
172
+ }
173
+ else {
174
+ record(checks, "status.check", true);
175
+ }
176
+ }
177
+ // All checks passed — assemble the success result.
178
+ const claims = stripMetadata(verifiedSdJwt.claims);
179
+ const metadata = extractMetadata(parsed, verifiedSdJwt.claims, this.audience, verifiedKb.holderKey);
180
+ const success = {
181
+ ok: true,
182
+ claims,
183
+ metadata,
184
+ checks: Object.freeze(checks),
185
+ unwrap: () => claims,
186
+ };
187
+ if (statusResult !== undefined)
188
+ success.status = statusResult;
189
+ return success;
190
+ }
191
+ /** Build an OID4VP Authorization Request URL to share with the wallet. */
192
+ request(options) {
193
+ if (typeof options.baseUrl !== "string" || options.baseUrl.length === 0) {
194
+ throw new TypeError("verifier.request: baseUrl is required");
195
+ }
196
+ if (typeof options.nonce !== "string" || options.nonce.length === 0) {
197
+ throw new TypeError("verifier.request: nonce is required");
198
+ }
199
+ if (options.presentationDefinition !== undefined &&
200
+ options.presentationDefinitionUri !== undefined) {
201
+ throw new TypeError("presentationDefinition and presentationDefinitionUri are mutually exclusive");
202
+ }
203
+ const responseMode = options.responseMode ??
204
+ (options.responseUri !== undefined ? "direct_post" : undefined);
205
+ const request = {
206
+ response_type: "vp_token",
207
+ client_id: options.clientId ?? this.audience,
208
+ client_id_scheme: options.clientIdScheme ?? "redirect_uri",
209
+ nonce: options.nonce,
210
+ };
211
+ if (options.state !== undefined)
212
+ request.state = options.state;
213
+ if (responseMode !== undefined)
214
+ request.response_mode = responseMode;
215
+ if (options.responseUri !== undefined) {
216
+ request.response_uri = options.responseUri;
217
+ }
218
+ if (options.presentationDefinition !== undefined) {
219
+ request.presentation_definition = options.presentationDefinition;
220
+ }
221
+ if (options.presentationDefinitionUri !== undefined) {
222
+ request.presentation_definition_uri = options.presentationDefinitionUri;
223
+ }
224
+ const url = buildAuthorizationRequestUrl(options.baseUrl, request);
225
+ return {
226
+ url,
227
+ request,
228
+ nonce: options.nonce,
229
+ state: options.state,
230
+ };
231
+ }
232
+ /**
233
+ * Process an OID4VP Authorization Response body end-to-end:
234
+ * parse the form body, enforce CSRF state matching, and verify the
235
+ * vp_token cryptographically. Returns the same result shape as `verify()`
236
+ * plus the parsed transport envelope.
237
+ */
238
+ async response(rawBody, options) {
239
+ if (typeof options.expectedNonce !== "string" ||
240
+ options.expectedNonce.length === 0) {
241
+ throw new TypeError("verifier.response: expectedNonce is required");
242
+ }
243
+ let response;
244
+ try {
245
+ response =
246
+ typeof rawBody === "string"
247
+ ? parseAuthorizationResponseBody(rawBody)
248
+ : (await import("@gramota/oid4vp")).parseAuthorizationResponseFromParams(rawBody);
249
+ }
250
+ catch (err) {
251
+ const checks = [];
252
+ return makeFailure(checks, "structure.parse", err instanceof Error ? err.message : String(err));
253
+ }
254
+ // CSRF state matching is application-level but we offer it as a default
255
+ // safety belt — opt out by omitting expectedState.
256
+ if (options.expectedState !== undefined &&
257
+ response.state !== options.expectedState) {
258
+ const checks = [];
259
+ return makeFailure(checks, "structure.parse", `OID4VP state mismatch — expected '${options.expectedState}', got '${response.state ?? "<missing>"}'`);
260
+ }
261
+ // v1 supports single-token responses; multi-token coming with full DIF PE.
262
+ if (typeof response.vp_token !== "string") {
263
+ const checks = [];
264
+ return makeFailure(checks, "structure.parse", "multi-credential vp_token arrays are not yet supported in v1");
265
+ }
266
+ const vpToken = response.vp_token;
267
+ const verifyOpts = { nonce: options.expectedNonce };
268
+ if (options.now !== undefined)
269
+ verifyOpts.now = options.now;
270
+ if (options.requireStatus !== undefined) {
271
+ verifyOpts.requireStatus = options.requireStatus;
272
+ }
273
+ const baseResult = await this.verify(vpToken, verifyOpts);
274
+ return Object.assign({}, baseResult, {
275
+ response,
276
+ });
277
+ }
278
+ }
279
+ /** Standalone one-off verification — same semantics as Verifier.verify, but
280
+ * no instance to keep around. Pass everything inline. */
281
+ export async function verify(presentationToken, options) {
282
+ const { nonce, ...config } = options;
283
+ const verifyOpts = { nonce };
284
+ if (options.now !== undefined)
285
+ verifyOpts.now = options.now;
286
+ return new Verifier(config).verify(presentationToken, verifyOpts);
287
+ }
288
+ // ---------------------------------------------------------------------------
289
+ // helpers
290
+ // ---------------------------------------------------------------------------
291
+ function record(checks, name, passed, message) {
292
+ const c = { name, passed };
293
+ if (message !== undefined)
294
+ c.message = message;
295
+ checks.push(c);
296
+ }
297
+ function makeFailure(checksSoFar, failedCheck, reason) {
298
+ const checks = [...checksSoFar];
299
+ checks.push({ name: failedCheck, passed: false, message: reason });
300
+ const failure = {
301
+ ok: false,
302
+ reason,
303
+ failedCheck,
304
+ checks: Object.freeze(checks),
305
+ unwrap: () => {
306
+ throw new VerificationError(reason, failure);
307
+ },
308
+ };
309
+ return failure;
310
+ }
311
+ /** Map a thrown error from verifyKeyBinding to a specific check name based on
312
+ * its message. We do this because verifyKeyBinding is a single function that
313
+ * checks 6 things; we want to surface the precise step that failed. */
314
+ function classifyKbFailure(err) {
315
+ const m = err instanceof Error ? err.message : String(err);
316
+ if (/required but absent/.test(m))
317
+ return "kb-jwt.present";
318
+ if (/cnf/.test(m))
319
+ return "kb-jwt.cnf-binding";
320
+ if (/aud/.test(m) && !/audi(en)?ce/i.test("audience"))
321
+ return "kb-jwt.audience";
322
+ if (/aud/.test(m))
323
+ return "kb-jwt.audience";
324
+ if (/nonce/.test(m))
325
+ return "kb-jwt.nonce";
326
+ if (/iat|future|old/i.test(m))
327
+ return "kb-jwt.time";
328
+ if (/sd_hash|transcript/i.test(m))
329
+ return "kb-jwt.transcript";
330
+ // Default: signature/typ/alg failures bucketed under signature.
331
+ return "kb-jwt.signature";
332
+ }
333
+ function describe(err) {
334
+ if (err instanceof SdJwtParseError ||
335
+ err instanceof SdJwtVerificationError ||
336
+ err instanceof SdJwtKeyBindingError ||
337
+ err instanceof JoseVerificationError ||
338
+ err instanceof TrustResolutionError ||
339
+ err instanceof Error) {
340
+ return err.message;
341
+ }
342
+ return String(err);
343
+ }
344
+ function stripMetadata(claims) {
345
+ const out = {};
346
+ for (const [key, value] of Object.entries(claims)) {
347
+ if (key === "iss" ||
348
+ key === "iat" ||
349
+ key === "exp" ||
350
+ key === "nbf" ||
351
+ key === "cnf" ||
352
+ key === "vct" ||
353
+ key === "status") {
354
+ continue;
355
+ }
356
+ out[key] = value;
357
+ }
358
+ return out;
359
+ }
360
+ function extractMetadata(parsed, resolvedClaims, audience, holderKey) {
361
+ return {
362
+ issuer: typeof resolvedClaims["iss"] === "string"
363
+ ? resolvedClaims["iss"]
364
+ : typeof parsed.payload["iss"] === "string"
365
+ ? parsed.payload["iss"]
366
+ : "<unknown>",
367
+ audience,
368
+ issuedAt: typeof resolvedClaims["iat"] === "number"
369
+ ? resolvedClaims["iat"]
370
+ : typeof parsed.payload["iat"] === "number"
371
+ ? parsed.payload["iat"]
372
+ : undefined,
373
+ expiresAt: typeof resolvedClaims["exp"] === "number"
374
+ ? resolvedClaims["exp"]
375
+ : typeof parsed.payload["exp"] === "number"
376
+ ? parsed.payload["exp"]
377
+ : undefined,
378
+ holderKey,
379
+ };
380
+ }
381
+ //# sourceMappingURL=verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifier.js","sourceRoot":"","sources":["../src/verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GAErB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,SAAS,EACT,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAG/B,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EACL,iBAAiB,GAQlB,MAAM,YAAY,CAAC;AAEpB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,MAAM,OAAO,QAAQ;IACF,QAAQ,CAAS;IACjB,KAAK,CAAgB;IACrB,cAAc,CAA6B;IAC3C,UAAU,CAAsC;IAChD,kBAAkB,CAAS;IAC3B,mBAAmB,CAAS;IAE7C,YAAY,MAAsB;QAChC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;QACxD,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gBACzC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;gBACvB,CAAC,CAAC,SAAS;QACjB,SAAS;KACV,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@gramota/verifier",
3
+ "version": "0.1.0",
4
+ "description": "Relying-party verifier for the EU Digital Identity Wallet. One client, one method, full IETF SD-JWT-VC + KB-JWT spec compliance.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@gramota/oid4vp": "0.1.0",
20
+ "@gramota/jose": "0.1.0",
21
+ "@gramota/status-list": "0.1.0",
22
+ "@gramota/sd-jwt": "0.1.0",
23
+ "@gramota/trust": "0.1.0"
24
+ },
25
+ "devDependencies": {
26
+ "jose": "^5.9.6",
27
+ "@gramota/issuer": "0.1.0"
28
+ },
29
+ "author": "Petromil Pavlov <petromilpavlov@gmail.com>",
30
+ "homepage": "https://github.com/gramota-org/gramota#readme",
31
+ "bugs": {
32
+ "url": "https://github.com/gramota-org/gramota/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">=20"
36
+ },
37
+ "sideEffects": false,
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "keywords": [
43
+ "verifier",
44
+ "relying-party",
45
+ "oid4vp",
46
+ "sd-jwt-vc",
47
+ "eudi",
48
+ "verifiable-credentials",
49
+ "eidas"
50
+ ],
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/gramota-org/gramota.git",
54
+ "directory": "packages/verifier"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc -p tsconfig.json",
58
+ "typecheck": "tsc -p tsconfig.json --noEmit"
59
+ }
60
+ }