@owf/eudi-attestation-schema 0.1.0 → 0.2.0-alpha-20260422114341

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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,325 @@
1
+ import { IdentityException, Verifier } from "@owf/identity-common";
2
+ import { z } from "zod";
3
+ import { Signer } from "@owf/crypto";
4
+
5
+ //#region src/schemas.d.ts
6
+ declare const AttestationFormatValues: readonly ["dc+sd-jwt", "mso_mdoc", "jwt_vc_json", "jwt_vc_json-ld", "ldp_vc"];
7
+ declare const AttestationFormatSchema: z.ZodEnum<{
8
+ "dc+sd-jwt": "dc+sd-jwt";
9
+ mso_mdoc: "mso_mdoc";
10
+ jwt_vc_json: "jwt_vc_json";
11
+ "jwt_vc_json-ld": "jwt_vc_json-ld";
12
+ ldp_vc: "ldp_vc";
13
+ }>;
14
+ declare const AttestationLoSValues: readonly ["iso_18045_high", "iso_18045_moderate", "iso_18045_enhanced-basic", "iso_18045_basic"];
15
+ declare const AttestationLoSSchema: z.ZodEnum<{
16
+ iso_18045_high: "iso_18045_high";
17
+ iso_18045_moderate: "iso_18045_moderate";
18
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
19
+ iso_18045_basic: "iso_18045_basic";
20
+ }>;
21
+ declare const BindingTypeValues: readonly ["claim", "key", "biometric", "none"];
22
+ declare const BindingTypeSchema: z.ZodEnum<{
23
+ claim: "claim";
24
+ key: "key";
25
+ biometric: "biometric";
26
+ none: "none";
27
+ }>;
28
+ declare const FrameworkTypeValues: readonly ["aki", "etsi_tl", "openid_federation"];
29
+ declare const FrameworkTypeSchema: z.ZodEnum<{
30
+ aki: "aki";
31
+ etsi_tl: "etsi_tl";
32
+ openid_federation: "openid_federation";
33
+ }>;
34
+ declare const TrustAuthoritySchema: z.ZodObject<{
35
+ frameworkType: z.ZodEnum<{
36
+ aki: "aki";
37
+ etsi_tl: "etsi_tl";
38
+ openid_federation: "openid_federation";
39
+ }>;
40
+ value: z.ZodString;
41
+ isLOTE: z.ZodOptional<z.ZodBoolean>;
42
+ }, z.core.$strip>;
43
+ declare const SchemaURISchema: z.ZodObject<{
44
+ formatIdentifier: z.ZodEnum<{
45
+ "dc+sd-jwt": "dc+sd-jwt";
46
+ mso_mdoc: "mso_mdoc";
47
+ jwt_vc_json: "jwt_vc_json";
48
+ "jwt_vc_json-ld": "jwt_vc_json-ld";
49
+ ldp_vc: "ldp_vc";
50
+ }>;
51
+ uri: z.ZodString;
52
+ integrity: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strip>;
54
+ declare const SchemaMetaSchema: z.ZodObject<{
55
+ id: z.ZodOptional<z.ZodString>;
56
+ iat: z.ZodOptional<z.ZodNumber>;
57
+ version: z.ZodString;
58
+ rulebookURI: z.ZodString;
59
+ rulebookIntegrity: z.ZodOptional<z.ZodString>;
60
+ trustedAuthorities: z.ZodOptional<z.ZodArray<z.ZodObject<{
61
+ frameworkType: z.ZodEnum<{
62
+ aki: "aki";
63
+ etsi_tl: "etsi_tl";
64
+ openid_federation: "openid_federation";
65
+ }>;
66
+ value: z.ZodString;
67
+ isLOTE: z.ZodOptional<z.ZodBoolean>;
68
+ }, z.core.$strip>>>;
69
+ attestationLoS: z.ZodEnum<{
70
+ iso_18045_high: "iso_18045_high";
71
+ iso_18045_moderate: "iso_18045_moderate";
72
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
73
+ iso_18045_basic: "iso_18045_basic";
74
+ }>;
75
+ bindingType: z.ZodEnum<{
76
+ claim: "claim";
77
+ key: "key";
78
+ biometric: "biometric";
79
+ none: "none";
80
+ }>;
81
+ supportedFormats: z.ZodArray<z.ZodEnum<{
82
+ "dc+sd-jwt": "dc+sd-jwt";
83
+ mso_mdoc: "mso_mdoc";
84
+ jwt_vc_json: "jwt_vc_json";
85
+ "jwt_vc_json-ld": "jwt_vc_json-ld";
86
+ ldp_vc: "ldp_vc";
87
+ }>>;
88
+ schemaURIs: z.ZodArray<z.ZodObject<{
89
+ formatIdentifier: z.ZodEnum<{
90
+ "dc+sd-jwt": "dc+sd-jwt";
91
+ mso_mdoc: "mso_mdoc";
92
+ jwt_vc_json: "jwt_vc_json";
93
+ "jwt_vc_json-ld": "jwt_vc_json-ld";
94
+ ldp_vc: "ldp_vc";
95
+ }>;
96
+ uri: z.ZodString;
97
+ integrity: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strip>;
100
+ //#endregion
101
+ //#region src/types.d.ts
102
+ type AttestationFormat = z.infer<typeof AttestationFormatSchema>;
103
+ type AttestationLoS = z.infer<typeof AttestationLoSSchema>;
104
+ type BindingType = z.infer<typeof BindingTypeSchema>;
105
+ type FrameworkType = z.infer<typeof FrameworkTypeSchema>;
106
+ type TrustAuthority = z.infer<typeof TrustAuthoritySchema>;
107
+ type SchemaURI = z.infer<typeof SchemaURISchema>;
108
+ type SchemaMeta = z.infer<typeof SchemaMetaSchema>;
109
+ interface SignOptions {
110
+ schemaMeta: SchemaMeta;
111
+ keyId: string;
112
+ algorithm?: 'ES256' | 'ES384' | 'ES512' | 'RS256' | 'RS384' | 'RS512';
113
+ certificates: string[];
114
+ signer: Signer;
115
+ }
116
+ interface SignedSchemaMeta {
117
+ jws: string;
118
+ header: {
119
+ alg: string;
120
+ typ: string;
121
+ kid: string;
122
+ x5c: string[];
123
+ };
124
+ payload: SchemaMeta;
125
+ iat: number;
126
+ }
127
+ interface VerifyOptions {
128
+ jws: string;
129
+ verifier: Verifier;
130
+ }
131
+ interface VerifiedSchemaMeta {
132
+ header: {
133
+ alg: string;
134
+ typ: string;
135
+ kid: string;
136
+ x5c: string[];
137
+ };
138
+ payload: SchemaMeta;
139
+ iat: number;
140
+ }
141
+ //#endregion
142
+ //#region src/builders.d.ts
143
+ /**
144
+ * Builder for creating TrustAuthority objects with a fluent API
145
+ */
146
+ declare class TrustAuthorityBuilder {
147
+ private data;
148
+ /**
149
+ * Set the trust framework type
150
+ */
151
+ frameworkType(type: FrameworkType): this;
152
+ /**
153
+ * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)
154
+ */
155
+ value(value: string): this;
156
+ /**
157
+ * Mark as a List of Trusted Entities (only for etsi_tl framework type)
158
+ */
159
+ isLoTE(value?: boolean): this;
160
+ /**
161
+ * Build the TrustAuthority object
162
+ */
163
+ build(): TrustAuthority;
164
+ }
165
+ /**
166
+ * Builder for creating SchemaURI objects with a fluent API
167
+ */
168
+ declare class SchemaURIBuilder {
169
+ private data;
170
+ /**
171
+ * Set the format identifier
172
+ */
173
+ format(format: AttestationFormat): this;
174
+ /**
175
+ * Set the schema URI
176
+ */
177
+ uri(uri: string): this;
178
+ /**
179
+ * Set the integrity metadata (W3C SRI format, e.g. "sha256-...")
180
+ */
181
+ integrity(integrity: string): this;
182
+ /**
183
+ * Build the SchemaURI object
184
+ */
185
+ build(): SchemaURI;
186
+ }
187
+ /**
188
+ * Builder for creating SchemaMeta objects with a fluent API
189
+ */
190
+ declare class SchemaMetaBuilder {
191
+ private data;
192
+ /**
193
+ * Set the schema identifier
194
+ */
195
+ id(id: string): this;
196
+ /**
197
+ * Set the schema version (SemVer)
198
+ */
199
+ version(version: string): this;
200
+ /**
201
+ * Set the Attestation Rulebook URI
202
+ */
203
+ rulebookURI(uri: string): this;
204
+ /**
205
+ * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)
206
+ */
207
+ rulebookIntegrity(integrity: string): this;
208
+ /**
209
+ * Add a trusted authority
210
+ */
211
+ addTrustAuthority(trustAuthority: TrustAuthority): this;
212
+ /**
213
+ * Set the level of security
214
+ */
215
+ attestationLoS(los: AttestationLoS): this;
216
+ /**
217
+ * Set the cryptographic binding type
218
+ */
219
+ bindingType(type: BindingType): this;
220
+ /**
221
+ * Add a supported attestation format
222
+ */
223
+ addFormat(format: AttestationFormat): this;
224
+ /**
225
+ * Add a schema URI
226
+ */
227
+ addSchemaURI(schemaURI: SchemaURI): this;
228
+ /**
229
+ * Build the SchemaMeta object
230
+ */
231
+ build(): SchemaMeta;
232
+ }
233
+ /**
234
+ * Create a new SchemaMetaBuilder
235
+ */
236
+ declare function schemaMeta(): SchemaMetaBuilder;
237
+ /**
238
+ * Create a new TrustAuthorityBuilder
239
+ */
240
+ declare function trustAuthority(): TrustAuthorityBuilder;
241
+ /**
242
+ * Create a new SchemaURIBuilder
243
+ */
244
+ declare function schemaURI(): SchemaURIBuilder;
245
+ //#endregion
246
+ //#region src/schema-meta-exception.d.ts
247
+ declare class SchemaMetaException extends IdentityException {
248
+ constructor(message: string, details?: unknown);
249
+ }
250
+ //#endregion
251
+ //#region src/signer.d.ts
252
+ /**
253
+ * Sign a SchemaMeta object as a JWS
254
+ *
255
+ * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects
256
+ * wrapped in JWS-signed JWTs.
257
+ *
258
+ * @example Using a local key via @owf/crypto:
259
+ * ```typescript
260
+ * import { ES256 } from '@owf/crypto'
261
+ * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'
262
+ *
263
+ * const { privateKey } = await ES256.generateKeyPair()
264
+ * const signer = await ES256.getSigner(privateKey)
265
+ *
266
+ * const meta = schemaMeta()
267
+ * .version('1.0.0')
268
+ * .rulebookURI('https://example.com/rulebook.md')
269
+ * .attestationLoS('iso_18045_basic')
270
+ * .bindingType('key')
271
+ * .addFormat('dc+sd-jwt')
272
+ * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())
273
+ * .build()
274
+ *
275
+ * const signed = await signSchemaMeta({
276
+ * schemaMeta: meta,
277
+ * keyId: 'catalog-signer-2025',
278
+ * certificates: [pemCertificate],
279
+ * signer,
280
+ * })
281
+ * ```
282
+ */
283
+ declare function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta>;
284
+ //#endregion
285
+ //#region src/validator.d.ts
286
+ interface ValidationError {
287
+ path: string;
288
+ message: string;
289
+ }
290
+ interface ValidationResult {
291
+ valid: boolean;
292
+ errors: ValidationError[];
293
+ }
294
+ /**
295
+ * Validate a SchemaMeta object against the TS11 schema
296
+ */
297
+ declare function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult;
298
+ /**
299
+ * Assert that a SchemaMeta object is valid, throwing if not
300
+ */
301
+ declare function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta;
302
+ //#endregion
303
+ //#region src/verifier.d.ts
304
+ /**
305
+ * Verify and decode a signed SchemaMeta JWS
306
+ *
307
+ * Decodes the JWS, verifies the signature using the provided verifier,
308
+ * and validates the payload against the TS11 SchemaMeta schema.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * import { ES256 } from '@owf/crypto'
313
+ * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
314
+ *
315
+ * const verifier = await ES256.getVerifier(publicKey)
316
+ * const { header, payload } = await verifySchemaMeta({
317
+ * jws: signedJws,
318
+ * verifier,
319
+ * })
320
+ * ```
321
+ */
322
+ declare function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta>;
323
+ //#endregion
324
+ export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, SchemaURISchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
325
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,378 @@
1
+ import { IdentityException, base64urlEncode, decodeJwt } from "@owf/identity-common";
2
+ import { z } from "zod";
3
+ import { parseCertificate } from "@owf/crypto";
4
+ //#region src/schema-meta-exception.ts
5
+ var SchemaMetaException = class SchemaMetaException extends IdentityException {
6
+ constructor(message, details) {
7
+ super(message, details);
8
+ Object.setPrototypeOf(this, SchemaMetaException.prototype);
9
+ this.name = "SchemaMetaException";
10
+ }
11
+ };
12
+ //#endregion
13
+ //#region src/schemas.ts
14
+ /**
15
+ * SchemaMeta Zod Schemas
16
+ *
17
+ * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.
18
+ * Based on TS11 specification for interfaces and formats for the catalogue of
19
+ * attributes and the catalogue of attestations.
20
+ *
21
+ * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md
22
+ */
23
+ const AttestationFormatValues = [
24
+ "dc+sd-jwt",
25
+ "mso_mdoc",
26
+ "jwt_vc_json",
27
+ "jwt_vc_json-ld",
28
+ "ldp_vc"
29
+ ];
30
+ const AttestationFormatSchema = z.enum(AttestationFormatValues);
31
+ const AttestationLoSValues = [
32
+ "iso_18045_high",
33
+ "iso_18045_moderate",
34
+ "iso_18045_enhanced-basic",
35
+ "iso_18045_basic"
36
+ ];
37
+ const AttestationLoSSchema = z.enum(AttestationLoSValues);
38
+ const BindingTypeValues = [
39
+ "claim",
40
+ "key",
41
+ "biometric",
42
+ "none"
43
+ ];
44
+ const BindingTypeSchema = z.enum(BindingTypeValues);
45
+ const FrameworkTypeValues = [
46
+ "aki",
47
+ "etsi_tl",
48
+ "openid_federation"
49
+ ];
50
+ const FrameworkTypeSchema = z.enum(FrameworkTypeValues);
51
+ const TrustAuthoritySchema = z.object({
52
+ frameworkType: FrameworkTypeSchema,
53
+ value: z.string().min(1),
54
+ isLOTE: z.boolean().optional()
55
+ }).refine((ta) => {
56
+ if (ta.isLOTE !== void 0 && ta.frameworkType !== "etsi_tl") return false;
57
+ return true;
58
+ }, { message: "isLOTE SHALL only be used with frameworkType \"etsi_tl\"" });
59
+ const SchemaURISchema = z.object({
60
+ formatIdentifier: AttestationFormatSchema,
61
+ uri: z.string().url(),
62
+ integrity: z.string().optional()
63
+ });
64
+ const SchemaMetaSchema = z.object({
65
+ id: z.string().optional(),
66
+ iat: z.number().optional(),
67
+ version: z.string().min(1),
68
+ rulebookURI: z.string().url(),
69
+ rulebookIntegrity: z.string().optional(),
70
+ trustedAuthorities: z.array(TrustAuthoritySchema).optional(),
71
+ attestationLoS: AttestationLoSSchema,
72
+ bindingType: BindingTypeSchema,
73
+ supportedFormats: z.array(AttestationFormatSchema).min(1),
74
+ schemaURIs: z.array(SchemaURISchema).min(1)
75
+ });
76
+ //#endregion
77
+ //#region src/builders.ts
78
+ /**
79
+ * Builder for creating TrustAuthority objects with a fluent API
80
+ */
81
+ var TrustAuthorityBuilder = class {
82
+ constructor() {
83
+ this.data = {};
84
+ }
85
+ /**
86
+ * Set the trust framework type
87
+ */
88
+ frameworkType(type) {
89
+ this.data.frameworkType = type;
90
+ return this;
91
+ }
92
+ /**
93
+ * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)
94
+ */
95
+ value(value) {
96
+ this.data.value = value;
97
+ return this;
98
+ }
99
+ /**
100
+ * Mark as a List of Trusted Entities (only for etsi_tl framework type)
101
+ */
102
+ isLoTE(value = true) {
103
+ this.data.isLOTE = value;
104
+ return this;
105
+ }
106
+ /**
107
+ * Build the TrustAuthority object
108
+ */
109
+ build() {
110
+ const result = TrustAuthoritySchema.safeParse(this.data);
111
+ if (!result.success) throw new SchemaMetaException(`Invalid TrustAuthority:\n${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
112
+ return result.data;
113
+ }
114
+ };
115
+ /**
116
+ * Builder for creating SchemaURI objects with a fluent API
117
+ */
118
+ var SchemaURIBuilder = class {
119
+ constructor() {
120
+ this.data = {};
121
+ }
122
+ /**
123
+ * Set the format identifier
124
+ */
125
+ format(format) {
126
+ this.data.formatIdentifier = format;
127
+ return this;
128
+ }
129
+ /**
130
+ * Set the schema URI
131
+ */
132
+ uri(uri) {
133
+ this.data.uri = uri;
134
+ return this;
135
+ }
136
+ /**
137
+ * Set the integrity metadata (W3C SRI format, e.g. "sha256-...")
138
+ */
139
+ integrity(integrity) {
140
+ this.data.integrity = integrity;
141
+ return this;
142
+ }
143
+ /**
144
+ * Build the SchemaURI object
145
+ */
146
+ build() {
147
+ const result = SchemaURISchema.safeParse(this.data);
148
+ if (!result.success) throw new SchemaMetaException(`Invalid SchemaURI:\n${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
149
+ return result.data;
150
+ }
151
+ };
152
+ /**
153
+ * Builder for creating SchemaMeta objects with a fluent API
154
+ */
155
+ var SchemaMetaBuilder = class {
156
+ constructor() {
157
+ this.data = {};
158
+ }
159
+ /**
160
+ * Set the schema identifier
161
+ */
162
+ id(id) {
163
+ this.data.id = id;
164
+ return this;
165
+ }
166
+ /**
167
+ * Set the schema version (SemVer)
168
+ */
169
+ version(version) {
170
+ this.data.version = version;
171
+ return this;
172
+ }
173
+ /**
174
+ * Set the Attestation Rulebook URI
175
+ */
176
+ rulebookURI(uri) {
177
+ this.data.rulebookURI = uri;
178
+ return this;
179
+ }
180
+ /**
181
+ * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)
182
+ */
183
+ rulebookIntegrity(integrity) {
184
+ this.data.rulebookIntegrity = integrity;
185
+ return this;
186
+ }
187
+ /**
188
+ * Add a trusted authority
189
+ */
190
+ addTrustAuthority(trustAuthority) {
191
+ this.data.trustedAuthorities = this.data.trustedAuthorities ?? [];
192
+ this.data.trustedAuthorities.push(trustAuthority);
193
+ return this;
194
+ }
195
+ /**
196
+ * Set the level of security
197
+ */
198
+ attestationLoS(los) {
199
+ this.data.attestationLoS = los;
200
+ return this;
201
+ }
202
+ /**
203
+ * Set the cryptographic binding type
204
+ */
205
+ bindingType(type) {
206
+ this.data.bindingType = type;
207
+ return this;
208
+ }
209
+ /**
210
+ * Add a supported attestation format
211
+ */
212
+ addFormat(format) {
213
+ this.data.supportedFormats = this.data.supportedFormats ?? [];
214
+ if (!this.data.supportedFormats.includes(format)) this.data.supportedFormats.push(format);
215
+ return this;
216
+ }
217
+ /**
218
+ * Add a schema URI
219
+ */
220
+ addSchemaURI(schemaURI) {
221
+ this.data.schemaURIs = this.data.schemaURIs ?? [];
222
+ this.data.schemaURIs.push(schemaURI);
223
+ return this;
224
+ }
225
+ /**
226
+ * Build the SchemaMeta object
227
+ */
228
+ build() {
229
+ const result = SchemaMetaSchema.safeParse(this.data);
230
+ if (!result.success) throw new SchemaMetaException(`Invalid SchemaMeta:\n${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
231
+ return result.data;
232
+ }
233
+ };
234
+ /**
235
+ * Create a new SchemaMetaBuilder
236
+ */
237
+ function schemaMeta() {
238
+ return new SchemaMetaBuilder();
239
+ }
240
+ /**
241
+ * Create a new TrustAuthorityBuilder
242
+ */
243
+ function trustAuthority() {
244
+ return new TrustAuthorityBuilder();
245
+ }
246
+ /**
247
+ * Create a new SchemaURIBuilder
248
+ */
249
+ function schemaURI() {
250
+ return new SchemaURIBuilder();
251
+ }
252
+ //#endregion
253
+ //#region src/signer.ts
254
+ /**
255
+ * Sign a SchemaMeta object as a JWS
256
+ *
257
+ * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects
258
+ * wrapped in JWS-signed JWTs.
259
+ *
260
+ * @example Using a local key via @owf/crypto:
261
+ * ```typescript
262
+ * import { ES256 } from '@owf/crypto'
263
+ * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'
264
+ *
265
+ * const { privateKey } = await ES256.generateKeyPair()
266
+ * const signer = await ES256.getSigner(privateKey)
267
+ *
268
+ * const meta = schemaMeta()
269
+ * .version('1.0.0')
270
+ * .rulebookURI('https://example.com/rulebook.md')
271
+ * .attestationLoS('iso_18045_basic')
272
+ * .bindingType('key')
273
+ * .addFormat('dc+sd-jwt')
274
+ * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())
275
+ * .build()
276
+ *
277
+ * const signed = await signSchemaMeta({
278
+ * schemaMeta: meta,
279
+ * keyId: 'catalog-signer-2025',
280
+ * certificates: [pemCertificate],
281
+ * signer,
282
+ * })
283
+ * ```
284
+ */
285
+ async function signSchemaMeta(options) {
286
+ const { schemaMeta, keyId, algorithm = "ES256", certificates, signer } = options;
287
+ const header = {
288
+ alg: algorithm,
289
+ typ: "attestation-schema+jwt",
290
+ kid: keyId,
291
+ x5c: certificates.map(parseCertificate)
292
+ };
293
+ const iat = Math.floor(Date.now() / 1e3);
294
+ const jwtPayload = {
295
+ ...schemaMeta,
296
+ iat
297
+ };
298
+ const signingInput = `${base64urlEncode(JSON.stringify(header))}.${base64urlEncode(JSON.stringify(jwtPayload))}`;
299
+ return {
300
+ jws: `${signingInput}.${await signer(signingInput)}`,
301
+ header: {
302
+ alg: algorithm,
303
+ typ: "attestation-schema+jwt",
304
+ kid: keyId,
305
+ x5c: header.x5c
306
+ },
307
+ payload: schemaMeta,
308
+ iat
309
+ };
310
+ }
311
+ //#endregion
312
+ //#region src/validator.ts
313
+ /**
314
+ * Validate a SchemaMeta object against the TS11 schema
315
+ */
316
+ function validateSchemaMeta(schemaMetaDocument) {
317
+ const result = SchemaMetaSchema.safeParse(schemaMetaDocument);
318
+ if (result.success) return {
319
+ valid: true,
320
+ errors: []
321
+ };
322
+ return {
323
+ valid: false,
324
+ errors: result.error.issues.map((issue) => ({
325
+ path: issue.path.join("."),
326
+ message: issue.message
327
+ }))
328
+ };
329
+ }
330
+ /**
331
+ * Assert that a SchemaMeta object is valid, throwing if not
332
+ */
333
+ function assertValidSchemaMeta(schemaMetaDocument) {
334
+ const result = validateSchemaMeta(schemaMetaDocument);
335
+ if (!result.valid) throw new SchemaMetaException(`Invalid SchemaMeta:\n${result.errors.map((e) => `${e.path}: ${e.message}`).join("\n")}`);
336
+ }
337
+ //#endregion
338
+ //#region src/verifier.ts
339
+ /**
340
+ * Verify and decode a signed SchemaMeta JWS
341
+ *
342
+ * Decodes the JWS, verifies the signature using the provided verifier,
343
+ * and validates the payload against the TS11 SchemaMeta schema.
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * import { ES256 } from '@owf/crypto'
348
+ * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
349
+ *
350
+ * const verifier = await ES256.getVerifier(publicKey)
351
+ * const { header, payload } = await verifySchemaMeta({
352
+ * jws: signedJws,
353
+ * verifier,
354
+ * })
355
+ * ```
356
+ */
357
+ async function verifySchemaMeta(options) {
358
+ const { jws, verifier } = options;
359
+ const { header, payload, signature } = decodeJwt(jws);
360
+ const [encodedHeader, encodedPayload] = jws.split(".");
361
+ if (!await verifier(`${encodedHeader}.${encodedPayload}`, signature)) throw new SchemaMetaException("Invalid signature");
362
+ const parsed = SchemaMetaSchema.safeParse(payload);
363
+ if (!parsed.success) throw new SchemaMetaException(`Invalid SchemaMeta payload:\n${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
364
+ return {
365
+ header: {
366
+ alg: header.alg,
367
+ typ: header.typ,
368
+ kid: header.kid,
369
+ x5c: header.x5c
370
+ },
371
+ payload: parsed.data,
372
+ iat: parsed.data.iat || Math.floor(Date.now() / 1e3)
373
+ };
374
+ }
375
+ //#endregion
376
+ export { AttestationFormatSchema, AttestationFormatValues, AttestationLoSSchema, AttestationLoSValues, BindingTypeSchema, BindingTypeValues, FrameworkTypeSchema, FrameworkTypeValues, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, SchemaURIBuilder, SchemaURISchema, TrustAuthorityBuilder, TrustAuthoritySchema, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
377
+
378
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/signer.ts","../src/validator.ts","../src/verifier.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\nexport class SchemaMetaException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SchemaMetaException.prototype)\n this.name = 'SchemaMetaException'\n }\n}\n","/**\n * SchemaMeta Zod Schemas\n *\n * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.\n * Based on TS11 specification for interfaces and formats for the catalogue of\n * attributes and the catalogue of attestations.\n *\n * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md\n */\n\nimport { z } from 'zod'\n\n// ============================================================================\n// Enumerations\n// ============================================================================\n\nexport const AttestationFormatValues = ['dc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'] as const\n\nexport const AttestationFormatSchema = z.enum(AttestationFormatValues)\n\nexport const AttestationLoSValues = [\n 'iso_18045_high',\n 'iso_18045_moderate',\n 'iso_18045_enhanced-basic',\n 'iso_18045_basic',\n] as const\n\nexport const AttestationLoSSchema = z.enum(AttestationLoSValues)\n\nexport const BindingTypeValues = ['claim', 'key', 'biometric', 'none'] as const\n\nexport const BindingTypeSchema = z.enum(BindingTypeValues)\n\nexport const FrameworkTypeValues = ['aki', 'etsi_tl', 'openid_federation'] as const\n\nexport const FrameworkTypeSchema = z.enum(FrameworkTypeValues)\n\n// ============================================================================\n// TrustAuthority Sub-class (Section 4.3.3)\n// ============================================================================\n\nexport const TrustAuthoritySchema = z\n .object({\n frameworkType: FrameworkTypeSchema,\n value: z.string().min(1),\n isLOTE: z.boolean().optional(),\n })\n .refine(\n (ta) => {\n if (ta.isLOTE !== undefined && ta.frameworkType !== 'etsi_tl') {\n return false\n }\n return true\n },\n { message: 'isLOTE SHALL only be used with frameworkType \"etsi_tl\"' }\n )\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nexport const SchemaURISchema = z.object({\n formatIdentifier: AttestationFormatSchema,\n uri: z.string().url(),\n integrity: z.string().optional(),\n})\n\n// ============================================================================\n// SchemaMeta Main Class (Section 4.3.1)\n// ============================================================================\n\nexport const SchemaMetaSchema = z.object({\n id: z.string().optional(),\n iat: z.number().optional(),\n version: z.string().min(1),\n rulebookURI: z.string().url(),\n rulebookIntegrity: z.string().optional(),\n trustedAuthorities: z.array(TrustAuthoritySchema).optional(),\n attestationLoS: AttestationLoSSchema,\n bindingType: BindingTypeSchema,\n supportedFormats: z.array(AttestationFormatSchema).min(1),\n schemaURIs: z.array(SchemaURISchema).min(1),\n})\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema, SchemaURISchema, TrustAuthoritySchema } from './schemas'\nimport type {\n AttestationFormat,\n AttestationLoS,\n BindingType,\n FrameworkType,\n SchemaMeta,\n SchemaURI,\n TrustAuthority,\n} from './types'\n\n/**\n * Builder for creating TrustAuthority objects with a fluent API\n */\nexport class TrustAuthorityBuilder {\n private data: Partial<TrustAuthority> = {}\n\n /**\n * Set the trust framework type\n */\n frameworkType(type: FrameworkType): this {\n this.data.frameworkType = type\n return this\n }\n\n /**\n * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)\n */\n value(value: string): this {\n this.data.value = value\n return this\n }\n\n /**\n * Mark as a List of Trusted Entities (only for etsi_tl framework type)\n */\n isLoTE(value = true): this {\n this.data.isLOTE = value\n return this\n }\n\n /**\n * Build the TrustAuthority object\n */\n build(): TrustAuthority {\n const result = TrustAuthoritySchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid TrustAuthority:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaURI objects with a fluent API\n */\nexport class SchemaURIBuilder {\n private data: Partial<SchemaURI> = {}\n\n /**\n * Set the format identifier\n */\n format(format: AttestationFormat): this {\n this.data.formatIdentifier = format\n return this\n }\n\n /**\n * Set the schema URI\n */\n uri(uri: string): this {\n this.data.uri = uri\n return this\n }\n\n /**\n * Set the integrity metadata (W3C SRI format, e.g. \"sha256-...\")\n */\n integrity(integrity: string): this {\n this.data.integrity = integrity\n return this\n }\n\n /**\n * Build the SchemaURI object\n */\n build(): SchemaURI {\n const result = SchemaURISchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaURI:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaMeta objects with a fluent API\n */\nexport class SchemaMetaBuilder {\n private data: Partial<SchemaMeta> = {}\n\n /**\n * Set the schema identifier\n */\n id(id: string): this {\n this.data.id = id\n return this\n }\n\n /**\n * Set the schema version (SemVer)\n */\n version(version: string): this {\n this.data.version = version\n return this\n }\n\n /**\n * Set the Attestation Rulebook URI\n */\n rulebookURI(uri: string): this {\n this.data.rulebookURI = uri\n return this\n }\n\n /**\n * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)\n */\n rulebookIntegrity(integrity: string): this {\n this.data.rulebookIntegrity = integrity\n return this\n }\n\n /**\n * Add a trusted authority\n */\n addTrustAuthority(trustAuthority: TrustAuthority): this {\n this.data.trustedAuthorities = this.data.trustedAuthorities ?? []\n this.data.trustedAuthorities.push(trustAuthority)\n return this\n }\n\n /**\n * Set the level of security\n */\n attestationLoS(los: AttestationLoS): this {\n this.data.attestationLoS = los\n return this\n }\n\n /**\n * Set the cryptographic binding type\n */\n bindingType(type: BindingType): this {\n this.data.bindingType = type\n return this\n }\n\n /**\n * Add a supported attestation format\n */\n addFormat(format: AttestationFormat): this {\n this.data.supportedFormats = this.data.supportedFormats ?? []\n if (!this.data.supportedFormats.includes(format)) {\n this.data.supportedFormats.push(format)\n }\n return this\n }\n\n /**\n * Add a schema URI\n */\n addSchemaURI(schemaURI: SchemaURI): this {\n this.data.schemaURIs = this.data.schemaURIs ?? []\n this.data.schemaURIs.push(schemaURI)\n return this\n }\n\n /**\n * Build the SchemaMeta object\n */\n build(): SchemaMeta {\n const result = SchemaMetaSchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Create a new SchemaMetaBuilder\n */\nexport function schemaMeta(): SchemaMetaBuilder {\n return new SchemaMetaBuilder()\n}\n\n/**\n * Create a new TrustAuthorityBuilder\n */\nexport function trustAuthority(): TrustAuthorityBuilder {\n return new TrustAuthorityBuilder()\n}\n\n/**\n * Create a new SchemaURIBuilder\n */\nexport function schemaURI(): SchemaURIBuilder {\n return new SchemaURIBuilder()\n}\n","import { parseCertificate } from '@owf/crypto'\nimport { base64urlEncode } from '@owf/identity-common'\nimport type { SignedSchemaMeta, SignOptions } from './types'\n\n/**\n * Sign a SchemaMeta object as a JWS\n *\n * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects\n * wrapped in JWS-signed JWTs.\n *\n * @example Using a local key via @owf/crypto:\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'\n *\n * const { privateKey } = await ES256.generateKeyPair()\n * const signer = await ES256.getSigner(privateKey)\n *\n * const meta = schemaMeta()\n * .version('1.0.0')\n * .rulebookURI('https://example.com/rulebook.md')\n * .attestationLoS('iso_18045_basic')\n * .bindingType('key')\n * .addFormat('dc+sd-jwt')\n * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())\n * .build()\n *\n * const signed = await signSchemaMeta({\n * schemaMeta: meta,\n * keyId: 'catalog-signer-2025',\n * certificates: [pemCertificate],\n * signer,\n * })\n * ```\n */\nexport async function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta> {\n const { schemaMeta, keyId, algorithm = 'ES256', certificates, signer } = options\n\n const header: Record<string, unknown> = {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: certificates.map(parseCertificate),\n }\n\n const iat = Math.floor(Date.now() / 1000)\n const jwtPayload = { ...schemaMeta, iat }\n\n const encodedHeader = base64urlEncode(JSON.stringify(header))\n const encodedPayload = base64urlEncode(JSON.stringify(jwtPayload))\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const signature = await signer(signingInput)\n const jws = `${signingInput}.${signature}`\n\n return {\n jws,\n header: {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: header.x5c as string[],\n },\n payload: schemaMeta,\n iat,\n }\n}\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { SchemaMeta } from './types'\n\nexport interface ValidationError {\n path: string\n message: string\n}\n\nexport interface ValidationResult {\n valid: boolean\n errors: ValidationError[]\n}\n\n/**\n * Validate a SchemaMeta object against the TS11 schema\n */\nexport function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult {\n const result = SchemaMetaSchema.safeParse(schemaMetaDocument)\n\n if (result.success) {\n return { valid: true, errors: [] }\n }\n\n const errors: ValidationError[] = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }))\n\n return { valid: false, errors }\n}\n\n/**\n * Assert that a SchemaMeta object is valid, throwing if not\n */\nexport function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta {\n const result = validateSchemaMeta(schemaMetaDocument)\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => `${e.path}: ${e.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${errorMessages}`)\n }\n}\n","import { decodeJwt } from '@owf/identity-common'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { VerifiedSchemaMeta, VerifyOptions } from './types'\n\n/**\n * Verify and decode a signed SchemaMeta JWS\n *\n * Decodes the JWS, verifies the signature using the provided verifier,\n * and validates the payload against the TS11 SchemaMeta schema.\n *\n * @example\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'\n *\n * const verifier = await ES256.getVerifier(publicKey)\n * const { header, payload } = await verifySchemaMeta({\n * jws: signedJws,\n * verifier,\n * })\n * ```\n */\nexport async function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta> {\n const { jws, verifier } = options\n\n const { header, payload, signature } = decodeJwt<Record<string, unknown>, Record<string, unknown>>(jws)\n\n const [encodedHeader, encodedPayload] = jws.split('.')\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const isValid = await verifier(signingInput, signature)\n if (!isValid) {\n throw new SchemaMetaException('Invalid signature')\n }\n\n const parsed = SchemaMetaSchema.safeParse(payload)\n if (!parsed.success) {\n const messages = parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta payload:\\n${messages}`)\n }\n\n return {\n header: {\n alg: header.alg as string,\n typ: header.typ as string,\n kid: header.kid as string,\n x5c: header.x5c as string[],\n },\n payload: parsed.data,\n iat: parsed.data.iat || Math.floor(Date.now() / 1000),\n }\n}\n"],"mappings":";;;;AAEA,IAAa,sBAAb,MAAa,4BAA4B,kBAAkB;CACzD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,oBAAoB,UAAU;AAC1D,OAAK,OAAO;;;;;;;;;;;;;;ACUhB,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;CAAS;AAE3G,MAAa,0BAA0B,EAAE,KAAK,wBAAwB;AAEtE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACD;AAED,MAAa,uB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AK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;EACtD"}
package/package.json CHANGED
@@ -1,27 +1,22 @@
1
1
  {
2
2
  "name": "@owf/eudi-attestation-schema",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-alpha-20260422114341",
4
4
  "description": "SDK for creating, signing, and validating attestation schema metadata (SchemaMeta) per EUDI TS11 Catalogue of Attestations",
5
5
  "experimental": true,
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
9
  "license": "Apache-2.0",
10
- "exports": "./src/index.ts",
10
+ "exports": {
11
+ ".": "./dist/index.mjs",
12
+ "./package.json": "./package.json"
13
+ },
11
14
  "homepage": "https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/eudi-attestation-schema",
12
15
  "repository": {
13
16
  "type": "git",
14
17
  "url": "https://github.com/openwallet-foundation-labs/identity-common-ts",
15
18
  "directory": "packages/eudi-attestation-schema"
16
19
  },
17
- "publishConfig": {
18
- "module": "./dist/index.mjs",
19
- "types": "./dist/index.d.mts",
20
- "exports": {
21
- ".": "./dist/index.mjs",
22
- "./package.json": "./package.json"
23
- }
24
- },
25
20
  "keywords": [
26
21
  "eudi",
27
22
  "attestation",
@@ -32,12 +27,14 @@
32
27
  "schema-meta",
33
28
  "ts11"
34
29
  ],
30
+ "dependencies": {
31
+ "zod": "^4.3.6",
32
+ "@owf/crypto": "0.2.0-alpha-20260422114341",
33
+ "@owf/identity-common": "0.2.0-alpha-20260422114341"
34
+ },
35
35
  "scripts": {
36
36
  "build": "tsdown src/index.ts --format esm --dts --sourcemap"
37
37
  },
38
- "dependencies": {
39
- "@owf/crypto": "workspace:*",
40
- "@owf/identity-common": "workspace:*",
41
- "zod": "^4.3.6"
42
- }
43
- }
38
+ "module": "./dist/index.mjs",
39
+ "types": "./dist/index.d.mts"
40
+ }