@owf/eudi-attestation-schema 0.3.0 → 0.3.1-alpha-20260613182022
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/README.md +89 -0
- package/dist/index.cjs +279 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -1
- package/dist/index.d.mts +61 -1
- package/dist/index.mjs +275 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -128,6 +128,95 @@ console.log(payload.version); // '1.0.0'
|
|
|
128
128
|
console.log(header.kid); // 'catalog-signer-2025'
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
+
### Verify, Resolve Referenced Schemas, and Build DCQL
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { ES256 } from '@owf/crypto';
|
|
135
|
+
import {
|
|
136
|
+
verifyResolveAndBuildDcql,
|
|
137
|
+
} from '@owf/eudi-attestation-schema';
|
|
138
|
+
|
|
139
|
+
const verifier = await ES256.getVerifier(publicKey);
|
|
140
|
+
|
|
141
|
+
const result = await verifyResolveAndBuildDcql({
|
|
142
|
+
jws: signed.jws,
|
|
143
|
+
verifier,
|
|
144
|
+
selectedFormats: ['dc+sd-jwt', 'mso_mdoc'],
|
|
145
|
+
resolve: async (uri) => {
|
|
146
|
+
const response = await fetch(uri);
|
|
147
|
+
const content = await response.text();
|
|
148
|
+
return { content, contentType: response.headers.get('content-type') ?? undefined };
|
|
149
|
+
},
|
|
150
|
+
verifyIntegrity: true,
|
|
151
|
+
includeTrustedAuthorities: true,
|
|
152
|
+
idPrefix: 'credential',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
console.log(result.verified.payload.version);
|
|
156
|
+
console.log(result.resolvedReferences.length);
|
|
157
|
+
console.log(result.dcql.credentials);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Integrity notes:
|
|
161
|
+
|
|
162
|
+
- `verifyIntegrity` supports SRI digests with `sha256`, `sha384`, and `sha512`.
|
|
163
|
+
- Integrity validation hashes UTF-8 bytes of the resolver content.
|
|
164
|
+
- If resolver content is an object (not a string), integrity is computed over `JSON.stringify(content)`.
|
|
165
|
+
|
|
166
|
+
### DCQL claims from referenced JSON Schemas
|
|
167
|
+
|
|
168
|
+
When a resolved schema document contains a JSON Schema with a `properties` object, `verifyResolveAndBuildDcql` (and `buildDcqlFromSchemaMeta` when `resolvedReferences` are provided) automatically populates the `claims` array of each DCQL credential with a path entry for every defined property.
|
|
169
|
+
|
|
170
|
+
Given a referenced schema document such as:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"type": "object",
|
|
175
|
+
"properties": {
|
|
176
|
+
"given_name": { "type": "string" },
|
|
177
|
+
"family_name": { "type": "string" },
|
|
178
|
+
"address": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"properties": {
|
|
181
|
+
"street_address": { "type": "string" },
|
|
182
|
+
"country": { "type": "string" }
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"nationalities": {
|
|
186
|
+
"type": "array",
|
|
187
|
+
"items": { "type": "string" }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The resulting DCQL credential will contain:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"id": "credential-1",
|
|
198
|
+
"format": "dc+sd-jwt",
|
|
199
|
+
"meta": { "vct_values": ["eu.europa.ec.eudi.pid.1"] },
|
|
200
|
+
"claims": [
|
|
201
|
+
{ "path": ["given_name"] },
|
|
202
|
+
{ "path": ["family_name"] },
|
|
203
|
+
{ "path": ["address", "street_address"] },
|
|
204
|
+
{ "path": ["address", "country"] },
|
|
205
|
+
{ "path": ["nationalities"] }
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Claim extraction rules:
|
|
211
|
+
|
|
212
|
+
- **Primitive properties** (`string`, `number`, `boolean`, …) produce a single-element path.
|
|
213
|
+
- **Nested object properties** are recursed into; each leaf produces a multi-element path.
|
|
214
|
+
- **Array properties with primitive items** produce a single path entry for the array field itself.
|
|
215
|
+
- **Array properties with object or array items** are recursed into with a `null` wildcard appended to the path per the DCQL spec.
|
|
216
|
+
- Combinator keywords (`allOf`, `anyOf`, `oneOf`) are merged transparently.
|
|
217
|
+
- Duplicate paths across combinators are deduplicated deterministically.
|
|
218
|
+
- If no `parsedSchema` is available for a resolved reference, no `claims` key is added to the credential.
|
|
219
|
+
|
|
131
220
|
## Data Model
|
|
132
221
|
|
|
133
222
|
### SchemaMeta (Main Class)
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _owf_identity_common = require("@owf/identity-common");
|
|
3
3
|
let zod = require("zod");
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
4
5
|
let _owf_crypto = require("@owf/crypto");
|
|
5
6
|
//#region src/schema-meta-exception.ts
|
|
6
7
|
var SchemaMetaException = class SchemaMetaException extends _owf_identity_common.IdentityException {
|
|
@@ -293,6 +294,279 @@ function schemaURI() {
|
|
|
293
294
|
return new SchemaURIBuilder();
|
|
294
295
|
}
|
|
295
296
|
//#endregion
|
|
297
|
+
//#region src/dcql.ts
|
|
298
|
+
function isPlainObject$1(value) {
|
|
299
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
300
|
+
}
|
|
301
|
+
function getVct(meta) {
|
|
302
|
+
if (meta && "vct" in meta && typeof meta.vct === "string") return meta.vct;
|
|
303
|
+
}
|
|
304
|
+
function getDocTypeValue(meta) {
|
|
305
|
+
if (meta && "doctype_value" in meta && typeof meta.doctype_value === "string") return meta.doctype_value;
|
|
306
|
+
}
|
|
307
|
+
function getFirstSchemaMetaByFormat(schemaMeta, format) {
|
|
308
|
+
return schemaMeta.schemaURIs.find((value) => value.formatIdentifier === format)?.meta;
|
|
309
|
+
}
|
|
310
|
+
function isArraySchema(node) {
|
|
311
|
+
if (!isPlainObject$1(node)) return false;
|
|
312
|
+
if (node.type === "array") return true;
|
|
313
|
+
if (Array.isArray(node.type) && node.type.includes("array")) return true;
|
|
314
|
+
return "items" in node;
|
|
315
|
+
}
|
|
316
|
+
function isObjectSchema(node) {
|
|
317
|
+
if (!isPlainObject$1(node)) return false;
|
|
318
|
+
if (isPlainObject$1(node.properties)) return true;
|
|
319
|
+
if (node.type === "object") return true;
|
|
320
|
+
if (Array.isArray(node.type) && node.type.includes("object")) return true;
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
function collectClaimsFromSchema(node, path, claims, seen) {
|
|
324
|
+
if (!isPlainObject$1(node)) {
|
|
325
|
+
if (path.length > 0) claims.push({ path });
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (seen.has(node)) return;
|
|
329
|
+
seen.add(node);
|
|
330
|
+
for (const key of [
|
|
331
|
+
"allOf",
|
|
332
|
+
"anyOf",
|
|
333
|
+
"oneOf"
|
|
334
|
+
]) {
|
|
335
|
+
const variants = node[key];
|
|
336
|
+
if (Array.isArray(variants)) for (const variant of variants) collectClaimsFromSchema(variant, path, claims, seen);
|
|
337
|
+
}
|
|
338
|
+
const properties = node.properties;
|
|
339
|
+
if (isPlainObject$1(properties)) {
|
|
340
|
+
const propertyEntries = Object.entries(properties);
|
|
341
|
+
for (const [propertyName, propertySchema] of propertyEntries) {
|
|
342
|
+
const propertyPath = [...path, propertyName];
|
|
343
|
+
if (isArraySchema(propertySchema)) {
|
|
344
|
+
const items = isPlainObject$1(propertySchema) ? propertySchema.items : void 0;
|
|
345
|
+
if (items !== void 0 && (isObjectSchema(items) || isArraySchema(items))) collectClaimsFromSchema(items, [...propertyPath, null], claims, seen);
|
|
346
|
+
else claims.push({ path: propertyPath });
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (isObjectSchema(propertySchema)) {
|
|
350
|
+
collectClaimsFromSchema(propertySchema, propertyPath, claims, seen);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
claims.push({ path: propertyPath });
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const items = node.items;
|
|
358
|
+
if (items !== void 0) {
|
|
359
|
+
if (isObjectSchema(items) || isArraySchema(items)) collectClaimsFromSchema(items, [...path, null], claims, seen);
|
|
360
|
+
else if (path.length > 0) claims.push({ path });
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (path.length > 0) claims.push({ path });
|
|
364
|
+
}
|
|
365
|
+
function getClaimsFromSchema(schemaRef) {
|
|
366
|
+
const schema = schemaRef?.parsedSchema;
|
|
367
|
+
if (!schema) return [];
|
|
368
|
+
const claims = [];
|
|
369
|
+
collectClaimsFromSchema(schema, [], claims, /* @__PURE__ */ new Set());
|
|
370
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
371
|
+
for (const claim of claims) {
|
|
372
|
+
const key = JSON.stringify(claim.path);
|
|
373
|
+
if (!deduped.has(key)) deduped.set(key, claim);
|
|
374
|
+
}
|
|
375
|
+
return [...deduped.values()];
|
|
376
|
+
}
|
|
377
|
+
function toDcqlTrustedAuthorities(schemaMeta) {
|
|
378
|
+
const valuesByType = /* @__PURE__ */ new Map();
|
|
379
|
+
for (const authority of schemaMeta.trustedAuthorities ?? []) {
|
|
380
|
+
if (authority.frameworkType !== "aki" && authority.frameworkType !== "etsi_tl") continue;
|
|
381
|
+
const existing = valuesByType.get(authority.frameworkType) ?? [];
|
|
382
|
+
if (!existing.includes(authority.value)) {
|
|
383
|
+
existing.push(authority.value);
|
|
384
|
+
valuesByType.set(authority.frameworkType, existing);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const result = [];
|
|
388
|
+
for (const [type, values] of valuesByType.entries()) if (values.length > 0) result.push({
|
|
389
|
+
type,
|
|
390
|
+
values
|
|
391
|
+
});
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
function toDcqlCredentialInput(params) {
|
|
395
|
+
const { schemaMeta, format, index, schemaRef, idPrefix } = params;
|
|
396
|
+
const credential = {
|
|
397
|
+
id: `${idPrefix ?? "credential"}-${index + 1}`,
|
|
398
|
+
format
|
|
399
|
+
};
|
|
400
|
+
const claims = getClaimsFromSchema(schemaRef);
|
|
401
|
+
if (claims.length > 0) credential.claims = claims;
|
|
402
|
+
if (format === "dc+sd-jwt") {
|
|
403
|
+
const value = getVct(schemaRef?.meta) ?? getVct(getFirstSchemaMetaByFormat(schemaMeta, format)) ?? schemaMeta.id;
|
|
404
|
+
if (!value) throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing vct value`);
|
|
405
|
+
credential.meta = { vct_values: [value] };
|
|
406
|
+
}
|
|
407
|
+
if (format === "mso_mdoc") {
|
|
408
|
+
const value = getDocTypeValue(schemaRef?.meta) ?? getDocTypeValue(getFirstSchemaMetaByFormat(schemaMeta, format));
|
|
409
|
+
if (!value) throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing doctype_value`);
|
|
410
|
+
credential.meta = { doctype_value: value };
|
|
411
|
+
}
|
|
412
|
+
return credential;
|
|
413
|
+
}
|
|
414
|
+
function buildDcqlFromSchemaMeta(options) {
|
|
415
|
+
const { schemaMeta, selectedFormats, resolvedReferences = [], includeTrustedAuthorities = false, idPrefix } = options;
|
|
416
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
417
|
+
const trustedAuthorities = includeTrustedAuthorities ? toDcqlTrustedAuthorities(schemaMeta) : [];
|
|
418
|
+
return { credentials: selectedFormats.map((format, index) => {
|
|
419
|
+
const referenceIndex = resolvedReferences.findIndex((reference, candidateIndex) => reference.format === format && !consumed.has(candidateIndex));
|
|
420
|
+
const schemaRef = referenceIndex >= 0 ? resolvedReferences[referenceIndex] : void 0;
|
|
421
|
+
if (referenceIndex >= 0) consumed.add(referenceIndex);
|
|
422
|
+
const credential = toDcqlCredentialInput({
|
|
423
|
+
schemaMeta,
|
|
424
|
+
format,
|
|
425
|
+
index,
|
|
426
|
+
schemaRef,
|
|
427
|
+
idPrefix
|
|
428
|
+
});
|
|
429
|
+
if (includeTrustedAuthorities && trustedAuthorities.length > 0) credential.trusted_authorities = trustedAuthorities;
|
|
430
|
+
return credential;
|
|
431
|
+
}) };
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/resolver.ts
|
|
435
|
+
function isPlainObject(value) {
|
|
436
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
437
|
+
}
|
|
438
|
+
function parseSri(integrity) {
|
|
439
|
+
const token = integrity.trim().split(/\s+/)[0];
|
|
440
|
+
const separatorIndex = token.indexOf("-");
|
|
441
|
+
if (separatorIndex <= 0 || separatorIndex >= token.length - 1) throw new SchemaMetaException(`integrity invalid format '${integrity}'`);
|
|
442
|
+
const algorithm = token.slice(0, separatorIndex);
|
|
443
|
+
const digestValue = token.slice(separatorIndex + 1);
|
|
444
|
+
if (algorithm !== "sha256" && algorithm !== "sha384" && algorithm !== "sha512") throw new SchemaMetaException(`integrity unsupported algorithm '${algorithm}'`);
|
|
445
|
+
let digest;
|
|
446
|
+
try {
|
|
447
|
+
digest = Buffer.from(digestValue, "base64");
|
|
448
|
+
} catch {
|
|
449
|
+
throw new SchemaMetaException(`integrity invalid base64 digest`);
|
|
450
|
+
}
|
|
451
|
+
if (digest.length === 0) throw new SchemaMetaException(`integrity invalid base64 digest`);
|
|
452
|
+
return {
|
|
453
|
+
algorithm,
|
|
454
|
+
digest
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function verifySriIntegrity(content, integrity) {
|
|
458
|
+
const { algorithm, digest } = parseSri(integrity);
|
|
459
|
+
const normalized = typeof content === "string" ? content : JSON.stringify(content);
|
|
460
|
+
const actual = (0, node_crypto.createHash)(algorithm).update(Buffer.from(normalized, "utf8")).digest();
|
|
461
|
+
if (actual.length !== digest.length || !(0, node_crypto.timingSafeEqual)(actual, digest)) throw new SchemaMetaException("integrity mismatch");
|
|
462
|
+
}
|
|
463
|
+
async function resolveSchemaReferences(options) {
|
|
464
|
+
const { schemaMeta, selectedFormats, resolve, verifyIntegrity = false } = options;
|
|
465
|
+
const selectedSet = selectedFormats ? new Set(selectedFormats) : void 0;
|
|
466
|
+
const resolved = [];
|
|
467
|
+
for (const [index, schemaURI] of schemaMeta.schemaURIs.entries()) {
|
|
468
|
+
if (selectedSet && !selectedSet.has(schemaURI.formatIdentifier)) continue;
|
|
469
|
+
let content;
|
|
470
|
+
try {
|
|
471
|
+
content = (await resolve(schemaURI.uri)).content;
|
|
472
|
+
} catch (error) {
|
|
473
|
+
throw new SchemaMetaException(`schemaURIs[${index}].uri resolve failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
474
|
+
}
|
|
475
|
+
if (verifyIntegrity && schemaURI.integrity) try {
|
|
476
|
+
verifySriIntegrity(content, schemaURI.integrity);
|
|
477
|
+
} catch (error) {
|
|
478
|
+
if (error instanceof SchemaMetaException) throw new SchemaMetaException(`schemaURIs[${index}].${error.message}`);
|
|
479
|
+
throw new SchemaMetaException(`schemaURIs[${index}].integrity verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
480
|
+
}
|
|
481
|
+
let rawSchema;
|
|
482
|
+
let parsedSchema;
|
|
483
|
+
if (typeof content === "string") try {
|
|
484
|
+
const parsed = JSON.parse(content);
|
|
485
|
+
rawSchema = parsed;
|
|
486
|
+
if (isPlainObject(parsed)) parsedSchema = parsed;
|
|
487
|
+
} catch {
|
|
488
|
+
rawSchema = content;
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
rawSchema = content;
|
|
492
|
+
if (isPlainObject(content)) parsedSchema = content;
|
|
493
|
+
}
|
|
494
|
+
resolved.push({
|
|
495
|
+
format: schemaURI.formatIdentifier,
|
|
496
|
+
uri: schemaURI.uri,
|
|
497
|
+
integrity: schemaURI.integrity,
|
|
498
|
+
meta: schemaURI.meta,
|
|
499
|
+
rawSchema,
|
|
500
|
+
parsedSchema
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
return resolved;
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/verifier.ts
|
|
507
|
+
/**
|
|
508
|
+
* Verify and decode a signed SchemaMeta JWS
|
|
509
|
+
*
|
|
510
|
+
* Decodes the JWS, verifies the signature using the provided verifier,
|
|
511
|
+
* and validates the payload against the TS11 SchemaMeta schema.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* import { ES256 } from '@owf/crypto'
|
|
516
|
+
* import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
|
|
517
|
+
*
|
|
518
|
+
* const verifier = await ES256.getVerifier(publicKey)
|
|
519
|
+
* const { header, payload } = await verifySchemaMeta({
|
|
520
|
+
* jws: signedJws,
|
|
521
|
+
* verifier,
|
|
522
|
+
* })
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
async function verifySchemaMeta(options) {
|
|
526
|
+
const { jws, verifier } = options;
|
|
527
|
+
const { header, payload, signature } = (0, _owf_identity_common.decodeJwt)(jws);
|
|
528
|
+
const [encodedHeader, encodedPayload] = jws.split(".");
|
|
529
|
+
if (!await verifier(`${encodedHeader}.${encodedPayload}`, signature)) throw new SchemaMetaException("Invalid signature");
|
|
530
|
+
const parsed = SchemaMetaSchema.safeParse(payload);
|
|
531
|
+
if (!parsed.success) throw new SchemaMetaException(`Invalid SchemaMeta payload:\n${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
|
|
532
|
+
return {
|
|
533
|
+
header: {
|
|
534
|
+
alg: header.alg,
|
|
535
|
+
typ: header.typ,
|
|
536
|
+
kid: header.kid,
|
|
537
|
+
x5c: header.x5c
|
|
538
|
+
},
|
|
539
|
+
payload: parsed.data,
|
|
540
|
+
iat: parsed.data.iat || Math.floor(Date.now() / 1e3)
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/orchestrator.ts
|
|
545
|
+
async function verifyResolveAndBuildDcql(options) {
|
|
546
|
+
const { jws, verifier, selectedFormats, resolve, verifyIntegrity, includeTrustedAuthorities, idPrefix } = options;
|
|
547
|
+
const verified = await verifySchemaMeta({
|
|
548
|
+
jws,
|
|
549
|
+
verifier
|
|
550
|
+
});
|
|
551
|
+
const resolvedReferences = await resolveSchemaReferences({
|
|
552
|
+
schemaMeta: verified.payload,
|
|
553
|
+
selectedFormats,
|
|
554
|
+
resolve,
|
|
555
|
+
verifyIntegrity
|
|
556
|
+
});
|
|
557
|
+
return {
|
|
558
|
+
verified,
|
|
559
|
+
resolvedReferences,
|
|
560
|
+
dcql: buildDcqlFromSchemaMeta({
|
|
561
|
+
schemaMeta: verified.payload,
|
|
562
|
+
selectedFormats,
|
|
563
|
+
resolvedReferences,
|
|
564
|
+
includeTrustedAuthorities,
|
|
565
|
+
idPrefix
|
|
566
|
+
})
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
//#endregion
|
|
296
570
|
//#region src/signer.ts
|
|
297
571
|
/**
|
|
298
572
|
* Sign a SchemaMeta object as a JWS
|
|
@@ -377,44 +651,6 @@ function assertValidSchemaMeta(schemaMetaDocument) {
|
|
|
377
651
|
if (!result.valid) throw new SchemaMetaException(`Invalid SchemaMeta:\n${result.errors.map((e) => `${e.path}: ${e.message}`).join("\n")}`);
|
|
378
652
|
}
|
|
379
653
|
//#endregion
|
|
380
|
-
//#region src/verifier.ts
|
|
381
|
-
/**
|
|
382
|
-
* Verify and decode a signed SchemaMeta JWS
|
|
383
|
-
*
|
|
384
|
-
* Decodes the JWS, verifies the signature using the provided verifier,
|
|
385
|
-
* and validates the payload against the TS11 SchemaMeta schema.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```typescript
|
|
389
|
-
* import { ES256 } from '@owf/crypto'
|
|
390
|
-
* import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
|
|
391
|
-
*
|
|
392
|
-
* const verifier = await ES256.getVerifier(publicKey)
|
|
393
|
-
* const { header, payload } = await verifySchemaMeta({
|
|
394
|
-
* jws: signedJws,
|
|
395
|
-
* verifier,
|
|
396
|
-
* })
|
|
397
|
-
* ```
|
|
398
|
-
*/
|
|
399
|
-
async function verifySchemaMeta(options) {
|
|
400
|
-
const { jws, verifier } = options;
|
|
401
|
-
const { header, payload, signature } = (0, _owf_identity_common.decodeJwt)(jws);
|
|
402
|
-
const [encodedHeader, encodedPayload] = jws.split(".");
|
|
403
|
-
if (!await verifier(`${encodedHeader}.${encodedPayload}`, signature)) throw new SchemaMetaException("Invalid signature");
|
|
404
|
-
const parsed = SchemaMetaSchema.safeParse(payload);
|
|
405
|
-
if (!parsed.success) throw new SchemaMetaException(`Invalid SchemaMeta payload:\n${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
|
|
406
|
-
return {
|
|
407
|
-
header: {
|
|
408
|
-
alg: header.alg,
|
|
409
|
-
typ: header.typ,
|
|
410
|
-
kid: header.kid,
|
|
411
|
-
x5c: header.x5c
|
|
412
|
-
},
|
|
413
|
-
payload: parsed.data,
|
|
414
|
-
iat: parsed.data.iat || Math.floor(Date.now() / 1e3)
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
//#endregion
|
|
418
654
|
exports.AttestationFormatSchema = AttestationFormatSchema;
|
|
419
655
|
exports.AttestationFormatValues = AttestationFormatValues;
|
|
420
656
|
exports.AttestationLoSSchema = AttestationLoSSchema;
|
|
@@ -434,11 +670,16 @@ exports.SdJwtMetaSchema = SdJwtMetaSchema;
|
|
|
434
670
|
exports.TrustAuthorityBuilder = TrustAuthorityBuilder;
|
|
435
671
|
exports.TrustAuthoritySchema = TrustAuthoritySchema;
|
|
436
672
|
exports.assertValidSchemaMeta = assertValidSchemaMeta;
|
|
673
|
+
exports.buildDcqlFromSchemaMeta = buildDcqlFromSchemaMeta;
|
|
674
|
+
exports.resolveSchemaReferences = resolveSchemaReferences;
|
|
437
675
|
exports.schemaMeta = schemaMeta;
|
|
438
676
|
exports.schemaURI = schemaURI;
|
|
439
677
|
exports.signSchemaMeta = signSchemaMeta;
|
|
678
|
+
exports.toDcqlCredentialInput = toDcqlCredentialInput;
|
|
679
|
+
exports.toDcqlTrustedAuthorities = toDcqlTrustedAuthorities;
|
|
440
680
|
exports.trustAuthority = trustAuthority;
|
|
441
681
|
exports.validateSchemaMeta = validateSchemaMeta;
|
|
682
|
+
exports.verifyResolveAndBuildDcql = verifyResolveAndBuildDcql;
|
|
442
683
|
exports.verifySchemaMeta = verifySchemaMeta;
|
|
443
684
|
|
|
444
685
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["IdentityException","z","parseCertificate"],"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// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\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 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 SchemaURIMeta,\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: Record<string, unknown> = {}\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 * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\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 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 * .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,4BAA4BA,qBAAAA,kBAAkB;CACzD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,oBAAoB,SAAS;EACzD,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;ACQA,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;AAAQ;AAE1G,MAAa,0BAA0BC,IAAAA,EAAE,KAAK,uBAAuB;AAErE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;AACF;AAEA,MAAa,uBAAuBA,IAAAA,EAAE,KAAK,oB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ta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/dcql.ts","../src/resolver.ts","../src/verifier.ts","../src/orchestrator.ts","../src/signer.ts","../src/validator.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// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\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 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 SchemaURIMeta,\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: Record<string, unknown> = {}\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 * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\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 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 { SchemaMetaException } from './schema-meta-exception'\nimport type {\n AttestationFormat,\n BuildDcqlFromSchemaMetaOptions,\n BuildDcqlFromSchemaMetaResult,\n DcqlTrustedAuthority,\n ResolvedSchemaReference,\n SchemaMeta,\n SchemaURIMeta,\n} from './types'\n\ntype DcqlClaim = { path: Array<string | null> }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction getVct(meta: SchemaURIMeta | undefined): string | undefined {\n if (meta && 'vct' in meta && typeof meta.vct === 'string') {\n return meta.vct\n }\n\n return undefined\n}\n\nfunction getDocTypeValue(meta: SchemaURIMeta | undefined): string | undefined {\n if (meta && 'doctype_value' in meta && typeof meta.doctype_value === 'string') {\n return meta.doctype_value\n }\n\n return undefined\n}\n\nfunction getFirstSchemaMetaByFormat(schemaMeta: SchemaMeta, format: AttestationFormat): SchemaURIMeta | undefined {\n const entry = schemaMeta.schemaURIs.find((value) => value.formatIdentifier === format)\n return entry?.meta\n}\n\nfunction isArraySchema(node: unknown): boolean {\n if (!isPlainObject(node)) {\n return false\n }\n\n if (node.type === 'array') {\n return true\n }\n\n if (Array.isArray(node.type) && node.type.includes('array')) {\n return true\n }\n\n return 'items' in node\n}\n\nfunction isObjectSchema(node: unknown): boolean {\n if (!isPlainObject(node)) {\n return false\n }\n\n if (isPlainObject(node.properties)) {\n return true\n }\n\n if (node.type === 'object') {\n return true\n }\n\n if (Array.isArray(node.type) && node.type.includes('object')) {\n return true\n }\n\n return false\n}\n\nfunction collectClaimsFromSchema(\n node: unknown,\n path: Array<string | null>,\n claims: DcqlClaim[],\n seen: Set<object>\n): void {\n if (!isPlainObject(node)) {\n if (path.length > 0) {\n claims.push({ path })\n }\n return\n }\n\n if (seen.has(node)) {\n return\n }\n seen.add(node)\n\n const combinatorKeys = ['allOf', 'anyOf', 'oneOf'] as const\n for (const key of combinatorKeys) {\n const variants = node[key]\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n collectClaimsFromSchema(variant, path, claims, seen)\n }\n }\n }\n\n const properties = node.properties\n if (isPlainObject(properties)) {\n const propertyEntries = Object.entries(properties)\n\n for (const [propertyName, propertySchema] of propertyEntries) {\n const propertyPath = [...path, propertyName]\n\n if (isArraySchema(propertySchema)) {\n const items = isPlainObject(propertySchema) ? propertySchema.items : undefined\n if (items !== undefined && (isObjectSchema(items) || isArraySchema(items))) {\n collectClaimsFromSchema(items, [...propertyPath, null], claims, seen)\n } else {\n claims.push({ path: propertyPath })\n }\n continue\n }\n\n if (isObjectSchema(propertySchema)) {\n collectClaimsFromSchema(propertySchema, propertyPath, claims, seen)\n continue\n }\n\n claims.push({ path: propertyPath })\n }\n\n return\n }\n\n const items = node.items\n if (items !== undefined) {\n if (isObjectSchema(items) || isArraySchema(items)) {\n collectClaimsFromSchema(items, [...path, null], claims, seen)\n } else if (path.length > 0) {\n claims.push({ path })\n }\n return\n }\n\n if (path.length > 0) {\n claims.push({ path })\n }\n}\n\nfunction getClaimsFromSchema(schemaRef?: ResolvedSchemaReference): DcqlClaim[] {\n const schema = schemaRef?.parsedSchema\n if (!schema) {\n return []\n }\n\n const claims: DcqlClaim[] = []\n collectClaimsFromSchema(schema, [], claims, new Set<object>())\n\n const deduped = new Map<string, DcqlClaim>()\n for (const claim of claims) {\n const key = JSON.stringify(claim.path)\n if (!deduped.has(key)) {\n deduped.set(key, claim)\n }\n }\n\n return [...deduped.values()]\n}\n\nexport function toDcqlTrustedAuthorities(schemaMeta: SchemaMeta): DcqlTrustedAuthority[] {\n const valuesByType = new Map<'aki' | 'etsi_tl', string[]>()\n\n for (const authority of schemaMeta.trustedAuthorities ?? []) {\n if (authority.frameworkType !== 'aki' && authority.frameworkType !== 'etsi_tl') {\n continue\n }\n\n const existing = valuesByType.get(authority.frameworkType) ?? []\n if (!existing.includes(authority.value)) {\n existing.push(authority.value)\n valuesByType.set(authority.frameworkType, existing)\n }\n }\n\n const result: DcqlTrustedAuthority[] = []\n\n for (const [type, values] of valuesByType.entries()) {\n if (values.length > 0) {\n result.push({ type, values })\n }\n }\n\n return result\n}\n\nexport function toDcqlCredentialInput(params: {\n schemaMeta: SchemaMeta\n format: AttestationFormat\n index: number\n schemaRef?: ResolvedSchemaReference\n idPrefix?: string\n}): Record<string, unknown> {\n const { schemaMeta, format, index, schemaRef, idPrefix } = params\n const credential: Record<string, unknown> = {\n id: `${idPrefix ?? 'credential'}-${index + 1}`,\n format,\n }\n const claims = getClaimsFromSchema(schemaRef)\n if (claims.length > 0) {\n credential.claims = claims\n }\n\n if (format === 'dc+sd-jwt') {\n const value = getVct(schemaRef?.meta) ?? getVct(getFirstSchemaMetaByFormat(schemaMeta, format)) ?? schemaMeta.id\n\n if (!value) {\n throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing vct value`)\n }\n\n credential.meta = { vct_values: [value] }\n }\n\n if (format === 'mso_mdoc') {\n const value = getDocTypeValue(schemaRef?.meta) ?? getDocTypeValue(getFirstSchemaMetaByFormat(schemaMeta, format))\n\n if (!value) {\n throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing doctype_value`)\n }\n\n credential.meta = { doctype_value: value }\n }\n\n return credential\n}\n\nexport function buildDcqlFromSchemaMeta(options: BuildDcqlFromSchemaMetaOptions): BuildDcqlFromSchemaMetaResult {\n const { schemaMeta, selectedFormats, resolvedReferences = [], includeTrustedAuthorities = false, idPrefix } = options\n const consumed = new Set<number>()\n const trustedAuthorities = includeTrustedAuthorities ? toDcqlTrustedAuthorities(schemaMeta) : []\n\n const credentials = selectedFormats.map((format, index) => {\n const referenceIndex = resolvedReferences.findIndex(\n (reference, candidateIndex) => reference.format === format && !consumed.has(candidateIndex)\n )\n\n const schemaRef = referenceIndex >= 0 ? resolvedReferences[referenceIndex] : undefined\n if (referenceIndex >= 0) {\n consumed.add(referenceIndex)\n }\n\n const credential = toDcqlCredentialInput({\n schemaMeta,\n format,\n index,\n schemaRef,\n idPrefix,\n })\n\n if (includeTrustedAuthorities && trustedAuthorities.length > 0) {\n credential.trusted_authorities = trustedAuthorities\n }\n\n return credential\n })\n\n return { credentials }\n}\n","import { createHash, timingSafeEqual } from 'node:crypto'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport type { ResolvedSchemaReference, ResolveSchemaReferencesOptions } from './types'\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction parseSri(integrity: string): { algorithm: string; digest: Buffer } {\n const token = integrity.trim().split(/\\s+/)[0]\n const separatorIndex = token.indexOf('-')\n\n if (separatorIndex <= 0 || separatorIndex >= token.length - 1) {\n throw new SchemaMetaException(`integrity invalid format '${integrity}'`)\n }\n\n const algorithm = token.slice(0, separatorIndex)\n const digestValue = token.slice(separatorIndex + 1)\n\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new SchemaMetaException(`integrity unsupported algorithm '${algorithm}'`)\n }\n\n let digest: Buffer\n try {\n digest = Buffer.from(digestValue, 'base64')\n } catch {\n throw new SchemaMetaException(`integrity invalid base64 digest`)\n }\n\n if (digest.length === 0) {\n throw new SchemaMetaException(`integrity invalid base64 digest`)\n }\n\n return { algorithm, digest }\n}\n\nfunction verifySriIntegrity(content: string | object, integrity: string): void {\n const { algorithm, digest } = parseSri(integrity)\n const normalized = typeof content === 'string' ? content : JSON.stringify(content)\n const actual = createHash(algorithm).update(Buffer.from(normalized, 'utf8')).digest()\n\n if (actual.length !== digest.length || !timingSafeEqual(actual, digest)) {\n throw new SchemaMetaException('integrity mismatch')\n }\n}\n\nexport async function resolveSchemaReferences(\n options: ResolveSchemaReferencesOptions\n): Promise<ResolvedSchemaReference[]> {\n const { schemaMeta, selectedFormats, resolve, verifyIntegrity = false } = options\n const selectedSet = selectedFormats ? new Set(selectedFormats) : undefined\n const resolved: ResolvedSchemaReference[] = []\n\n for (const [index, schemaURI] of schemaMeta.schemaURIs.entries()) {\n if (selectedSet && !selectedSet.has(schemaURI.formatIdentifier)) {\n continue\n }\n\n let content: string | object\n\n try {\n const result = await resolve(schemaURI.uri)\n content = result.content\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new SchemaMetaException(`schemaURIs[${index}].uri resolve failed: ${message}`)\n }\n\n if (verifyIntegrity && schemaURI.integrity) {\n try {\n verifySriIntegrity(content, schemaURI.integrity)\n } catch (error) {\n if (error instanceof SchemaMetaException) {\n throw new SchemaMetaException(`schemaURIs[${index}].${error.message}`)\n }\n\n const message = error instanceof Error ? error.message : String(error)\n throw new SchemaMetaException(`schemaURIs[${index}].integrity verification failed: ${message}`)\n }\n }\n\n let rawSchema: unknown\n let parsedSchema: Record<string, unknown> | undefined\n\n if (typeof content === 'string') {\n try {\n const parsed = JSON.parse(content) as unknown\n rawSchema = parsed\n if (isPlainObject(parsed)) {\n parsedSchema = parsed\n }\n } catch {\n rawSchema = content\n }\n } else {\n rawSchema = content\n if (isPlainObject(content)) {\n parsedSchema = content\n }\n }\n\n resolved.push({\n format: schemaURI.formatIdentifier,\n uri: schemaURI.uri,\n integrity: schemaURI.integrity,\n meta: schemaURI.meta,\n rawSchema,\n parsedSchema,\n })\n }\n\n return resolved\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","import { buildDcqlFromSchemaMeta } from './dcql'\nimport { resolveSchemaReferences } from './resolver'\nimport type {\n AttestationFormat,\n BuildDcqlFromSchemaMetaResult,\n ResolvedSchemaReference,\n ResolveSchemaReferencesOptions,\n VerifiedSchemaMeta,\n VerifyOptions,\n} from './types'\nimport { verifySchemaMeta } from './verifier'\n\nexport async function verifyResolveAndBuildDcql(options: {\n jws: string\n verifier: VerifyOptions['verifier']\n selectedFormats: AttestationFormat[]\n resolve: ResolveSchemaReferencesOptions['resolve']\n verifyIntegrity?: boolean\n includeTrustedAuthorities?: boolean\n idPrefix?: string\n}): Promise<{\n verified: VerifiedSchemaMeta\n resolvedReferences: ResolvedSchemaReference[]\n dcql: BuildDcqlFromSchemaMetaResult\n}> {\n const { jws, verifier, selectedFormats, resolve, verifyIntegrity, includeTrustedAuthorities, idPrefix } = options\n\n const verified = await verifySchemaMeta({ jws, verifier })\n\n const resolvedReferences = await resolveSchemaReferences({\n schemaMeta: verified.payload,\n selectedFormats,\n resolve,\n verifyIntegrity,\n })\n\n const dcql = buildDcqlFromSchemaMeta({\n schemaMeta: verified.payload,\n selectedFormats,\n resolvedReferences,\n includeTrustedAuthorities,\n idPrefix,\n })\n\n return {\n verified,\n resolvedReferences,\n dcql,\n }\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 * .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"],"mappings":";;;;;;AAEA,IAAa,sBAAb,MAAa,4BAA4BA,qBAAAA,kBAAkB;CACzD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,oBAAoB,SAAS;EACzD,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;ACQA,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;AAAQ;AAE1G,MAAa,0BAA0BC,IAAAA,EAAE,KAAK,uBAAuB;AAErE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;AACF;AAEA,MAAa,uBAAuBA,IAAAA,EAAE,KAAK,oBAAoB;AAE/D,MAAa,oBAAoB;CAAC;CAAS;CAAO;CAAa;AAAM;AAErE,MAAa,oBAAoBA,IAAAA,EAAE,KAAK,iBAAiB;AAEzD,MAAa,sBAAsB;CAAC;CAAO;CAAW;AAAmB;AAEzE,MAAa,sBAAsBA,IAAAA,EAAE,KAAK,mBAAmB;AAM7D,MAAa,uBAAu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ChF,MAAM,SAAS,iBAAiB,UAAU,kBAAkB;CAE5D,IAAI,OAAO,SACT,OAAO;EAAE,OAAO;EAAM,QAAQ,CAAC;CAAE;CAQnC,OAAO;EAAE,OAAO;EAAO,QALW,OAAO,MAAM,OAAO,KAAK,WAAW;GACpE,MAAM,MAAM,KAAK,KAAK,GAAG;GACzB,SAAS,MAAM;EACjB,EAE4B;CAAE;AAChC;;;;AAKA,SAAgB,sBAAsB,oBAAuE;CAC3G,MAAM,SAAS,mBAAmB,kBAAkB;CACpD,IAAI,CAAC,OAAO,OAEV,MAAM,IAAI,oBAAoB,wBADR,OAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,IACb,GAAG;AAEzE"}
|
package/dist/index.d.cts
CHANGED
|
@@ -192,6 +192,37 @@ interface VerifiedSchemaMeta {
|
|
|
192
192
|
payload: SchemaMeta;
|
|
193
193
|
iat: number;
|
|
194
194
|
}
|
|
195
|
+
interface ResolvedSchemaReference {
|
|
196
|
+
format: AttestationFormat;
|
|
197
|
+
uri: string;
|
|
198
|
+
integrity?: string;
|
|
199
|
+
meta?: SchemaURIMeta;
|
|
200
|
+
rawSchema: unknown;
|
|
201
|
+
parsedSchema?: Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
interface ResolveSchemaReferencesOptions {
|
|
204
|
+
schemaMeta: SchemaMeta;
|
|
205
|
+
selectedFormats?: AttestationFormat[];
|
|
206
|
+
resolve: (uri: string) => Promise<{
|
|
207
|
+
content: string | object;
|
|
208
|
+
contentType?: string;
|
|
209
|
+
}>;
|
|
210
|
+
verifyIntegrity?: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface DcqlTrustedAuthority {
|
|
213
|
+
type: 'aki' | 'etsi_tl';
|
|
214
|
+
values: string[];
|
|
215
|
+
}
|
|
216
|
+
interface BuildDcqlFromSchemaMetaOptions {
|
|
217
|
+
schemaMeta: SchemaMeta;
|
|
218
|
+
selectedFormats: AttestationFormat[];
|
|
219
|
+
resolvedReferences?: ResolvedSchemaReference[];
|
|
220
|
+
includeTrustedAuthorities?: boolean;
|
|
221
|
+
idPrefix?: string;
|
|
222
|
+
}
|
|
223
|
+
interface BuildDcqlFromSchemaMetaResult {
|
|
224
|
+
credentials: Array<Record<string, unknown>>;
|
|
225
|
+
}
|
|
195
226
|
//#endregion
|
|
196
227
|
//#region src/builders.d.ts
|
|
197
228
|
/**
|
|
@@ -300,6 +331,35 @@ declare function trustAuthority(): TrustAuthorityBuilder;
|
|
|
300
331
|
*/
|
|
301
332
|
declare function schemaURI(): SchemaURIBuilder;
|
|
302
333
|
//#endregion
|
|
334
|
+
//#region src/dcql.d.ts
|
|
335
|
+
declare function toDcqlTrustedAuthorities(schemaMeta: SchemaMeta): DcqlTrustedAuthority[];
|
|
336
|
+
declare function toDcqlCredentialInput(params: {
|
|
337
|
+
schemaMeta: SchemaMeta;
|
|
338
|
+
format: AttestationFormat;
|
|
339
|
+
index: number;
|
|
340
|
+
schemaRef?: ResolvedSchemaReference;
|
|
341
|
+
idPrefix?: string;
|
|
342
|
+
}): Record<string, unknown>;
|
|
343
|
+
declare function buildDcqlFromSchemaMeta(options: BuildDcqlFromSchemaMetaOptions): BuildDcqlFromSchemaMetaResult;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/orchestrator.d.ts
|
|
346
|
+
declare function verifyResolveAndBuildDcql(options: {
|
|
347
|
+
jws: string;
|
|
348
|
+
verifier: VerifyOptions['verifier'];
|
|
349
|
+
selectedFormats: AttestationFormat[];
|
|
350
|
+
resolve: ResolveSchemaReferencesOptions['resolve'];
|
|
351
|
+
verifyIntegrity?: boolean;
|
|
352
|
+
includeTrustedAuthorities?: boolean;
|
|
353
|
+
idPrefix?: string;
|
|
354
|
+
}): Promise<{
|
|
355
|
+
verified: VerifiedSchemaMeta;
|
|
356
|
+
resolvedReferences: ResolvedSchemaReference[];
|
|
357
|
+
dcql: BuildDcqlFromSchemaMetaResult;
|
|
358
|
+
}>;
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/resolver.d.ts
|
|
361
|
+
declare function resolveSchemaReferences(options: ResolveSchemaReferencesOptions): Promise<ResolvedSchemaReference[]>;
|
|
362
|
+
//#endregion
|
|
303
363
|
//#region src/schema-meta-exception.d.ts
|
|
304
364
|
declare class SchemaMetaException extends IdentityException {
|
|
305
365
|
constructor(message: string, details?: unknown);
|
|
@@ -377,5 +437,5 @@ declare function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts sch
|
|
|
377
437
|
*/
|
|
378
438
|
declare function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta>;
|
|
379
439
|
//#endregion
|
|
380
|
-
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
440
|
+
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type BuildDcqlFromSchemaMetaOptions, type BuildDcqlFromSchemaMetaResult, type DcqlTrustedAuthority, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type ResolveSchemaReferencesOptions, type ResolvedSchemaReference, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, buildDcqlFromSchemaMeta, resolveSchemaReferences, schemaMeta, schemaURI, signSchemaMeta, toDcqlCredentialInput, toDcqlTrustedAuthorities, trustAuthority, validateSchemaMeta, verifyResolveAndBuildDcql, verifySchemaMeta };
|
|
381
441
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -192,6 +192,37 @@ interface VerifiedSchemaMeta {
|
|
|
192
192
|
payload: SchemaMeta;
|
|
193
193
|
iat: number;
|
|
194
194
|
}
|
|
195
|
+
interface ResolvedSchemaReference {
|
|
196
|
+
format: AttestationFormat;
|
|
197
|
+
uri: string;
|
|
198
|
+
integrity?: string;
|
|
199
|
+
meta?: SchemaURIMeta;
|
|
200
|
+
rawSchema: unknown;
|
|
201
|
+
parsedSchema?: Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
interface ResolveSchemaReferencesOptions {
|
|
204
|
+
schemaMeta: SchemaMeta;
|
|
205
|
+
selectedFormats?: AttestationFormat[];
|
|
206
|
+
resolve: (uri: string) => Promise<{
|
|
207
|
+
content: string | object;
|
|
208
|
+
contentType?: string;
|
|
209
|
+
}>;
|
|
210
|
+
verifyIntegrity?: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface DcqlTrustedAuthority {
|
|
213
|
+
type: 'aki' | 'etsi_tl';
|
|
214
|
+
values: string[];
|
|
215
|
+
}
|
|
216
|
+
interface BuildDcqlFromSchemaMetaOptions {
|
|
217
|
+
schemaMeta: SchemaMeta;
|
|
218
|
+
selectedFormats: AttestationFormat[];
|
|
219
|
+
resolvedReferences?: ResolvedSchemaReference[];
|
|
220
|
+
includeTrustedAuthorities?: boolean;
|
|
221
|
+
idPrefix?: string;
|
|
222
|
+
}
|
|
223
|
+
interface BuildDcqlFromSchemaMetaResult {
|
|
224
|
+
credentials: Array<Record<string, unknown>>;
|
|
225
|
+
}
|
|
195
226
|
//#endregion
|
|
196
227
|
//#region src/builders.d.ts
|
|
197
228
|
/**
|
|
@@ -300,6 +331,35 @@ declare function trustAuthority(): TrustAuthorityBuilder;
|
|
|
300
331
|
*/
|
|
301
332
|
declare function schemaURI(): SchemaURIBuilder;
|
|
302
333
|
//#endregion
|
|
334
|
+
//#region src/dcql.d.ts
|
|
335
|
+
declare function toDcqlTrustedAuthorities(schemaMeta: SchemaMeta): DcqlTrustedAuthority[];
|
|
336
|
+
declare function toDcqlCredentialInput(params: {
|
|
337
|
+
schemaMeta: SchemaMeta;
|
|
338
|
+
format: AttestationFormat;
|
|
339
|
+
index: number;
|
|
340
|
+
schemaRef?: ResolvedSchemaReference;
|
|
341
|
+
idPrefix?: string;
|
|
342
|
+
}): Record<string, unknown>;
|
|
343
|
+
declare function buildDcqlFromSchemaMeta(options: BuildDcqlFromSchemaMetaOptions): BuildDcqlFromSchemaMetaResult;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/orchestrator.d.ts
|
|
346
|
+
declare function verifyResolveAndBuildDcql(options: {
|
|
347
|
+
jws: string;
|
|
348
|
+
verifier: VerifyOptions['verifier'];
|
|
349
|
+
selectedFormats: AttestationFormat[];
|
|
350
|
+
resolve: ResolveSchemaReferencesOptions['resolve'];
|
|
351
|
+
verifyIntegrity?: boolean;
|
|
352
|
+
includeTrustedAuthorities?: boolean;
|
|
353
|
+
idPrefix?: string;
|
|
354
|
+
}): Promise<{
|
|
355
|
+
verified: VerifiedSchemaMeta;
|
|
356
|
+
resolvedReferences: ResolvedSchemaReference[];
|
|
357
|
+
dcql: BuildDcqlFromSchemaMetaResult;
|
|
358
|
+
}>;
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/resolver.d.ts
|
|
361
|
+
declare function resolveSchemaReferences(options: ResolveSchemaReferencesOptions): Promise<ResolvedSchemaReference[]>;
|
|
362
|
+
//#endregion
|
|
303
363
|
//#region src/schema-meta-exception.d.ts
|
|
304
364
|
declare class SchemaMetaException extends IdentityException {
|
|
305
365
|
constructor(message: string, details?: unknown);
|
|
@@ -377,5 +437,5 @@ declare function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts sch
|
|
|
377
437
|
*/
|
|
378
438
|
declare function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta>;
|
|
379
439
|
//#endregion
|
|
380
|
-
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
440
|
+
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type BuildDcqlFromSchemaMetaOptions, type BuildDcqlFromSchemaMetaResult, type DcqlTrustedAuthority, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type ResolveSchemaReferencesOptions, type ResolvedSchemaReference, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, buildDcqlFromSchemaMeta, resolveSchemaReferences, schemaMeta, schemaURI, signSchemaMeta, toDcqlCredentialInput, toDcqlTrustedAuthorities, trustAuthority, validateSchemaMeta, verifyResolveAndBuildDcql, verifySchemaMeta };
|
|
381
441
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IdentityException, base64urlEncode, decodeJwt } from "@owf/identity-common";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
3
4
|
import { parseCertificate } from "@owf/crypto";
|
|
4
5
|
//#region src/schema-meta-exception.ts
|
|
5
6
|
var SchemaMetaException = class SchemaMetaException extends IdentityException {
|
|
@@ -292,6 +293,279 @@ function schemaURI() {
|
|
|
292
293
|
return new SchemaURIBuilder();
|
|
293
294
|
}
|
|
294
295
|
//#endregion
|
|
296
|
+
//#region src/dcql.ts
|
|
297
|
+
function isPlainObject$1(value) {
|
|
298
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
299
|
+
}
|
|
300
|
+
function getVct(meta) {
|
|
301
|
+
if (meta && "vct" in meta && typeof meta.vct === "string") return meta.vct;
|
|
302
|
+
}
|
|
303
|
+
function getDocTypeValue(meta) {
|
|
304
|
+
if (meta && "doctype_value" in meta && typeof meta.doctype_value === "string") return meta.doctype_value;
|
|
305
|
+
}
|
|
306
|
+
function getFirstSchemaMetaByFormat(schemaMeta, format) {
|
|
307
|
+
return schemaMeta.schemaURIs.find((value) => value.formatIdentifier === format)?.meta;
|
|
308
|
+
}
|
|
309
|
+
function isArraySchema(node) {
|
|
310
|
+
if (!isPlainObject$1(node)) return false;
|
|
311
|
+
if (node.type === "array") return true;
|
|
312
|
+
if (Array.isArray(node.type) && node.type.includes("array")) return true;
|
|
313
|
+
return "items" in node;
|
|
314
|
+
}
|
|
315
|
+
function isObjectSchema(node) {
|
|
316
|
+
if (!isPlainObject$1(node)) return false;
|
|
317
|
+
if (isPlainObject$1(node.properties)) return true;
|
|
318
|
+
if (node.type === "object") return true;
|
|
319
|
+
if (Array.isArray(node.type) && node.type.includes("object")) return true;
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
function collectClaimsFromSchema(node, path, claims, seen) {
|
|
323
|
+
if (!isPlainObject$1(node)) {
|
|
324
|
+
if (path.length > 0) claims.push({ path });
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (seen.has(node)) return;
|
|
328
|
+
seen.add(node);
|
|
329
|
+
for (const key of [
|
|
330
|
+
"allOf",
|
|
331
|
+
"anyOf",
|
|
332
|
+
"oneOf"
|
|
333
|
+
]) {
|
|
334
|
+
const variants = node[key];
|
|
335
|
+
if (Array.isArray(variants)) for (const variant of variants) collectClaimsFromSchema(variant, path, claims, seen);
|
|
336
|
+
}
|
|
337
|
+
const properties = node.properties;
|
|
338
|
+
if (isPlainObject$1(properties)) {
|
|
339
|
+
const propertyEntries = Object.entries(properties);
|
|
340
|
+
for (const [propertyName, propertySchema] of propertyEntries) {
|
|
341
|
+
const propertyPath = [...path, propertyName];
|
|
342
|
+
if (isArraySchema(propertySchema)) {
|
|
343
|
+
const items = isPlainObject$1(propertySchema) ? propertySchema.items : void 0;
|
|
344
|
+
if (items !== void 0 && (isObjectSchema(items) || isArraySchema(items))) collectClaimsFromSchema(items, [...propertyPath, null], claims, seen);
|
|
345
|
+
else claims.push({ path: propertyPath });
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (isObjectSchema(propertySchema)) {
|
|
349
|
+
collectClaimsFromSchema(propertySchema, propertyPath, claims, seen);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
claims.push({ path: propertyPath });
|
|
353
|
+
}
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const items = node.items;
|
|
357
|
+
if (items !== void 0) {
|
|
358
|
+
if (isObjectSchema(items) || isArraySchema(items)) collectClaimsFromSchema(items, [...path, null], claims, seen);
|
|
359
|
+
else if (path.length > 0) claims.push({ path });
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (path.length > 0) claims.push({ path });
|
|
363
|
+
}
|
|
364
|
+
function getClaimsFromSchema(schemaRef) {
|
|
365
|
+
const schema = schemaRef?.parsedSchema;
|
|
366
|
+
if (!schema) return [];
|
|
367
|
+
const claims = [];
|
|
368
|
+
collectClaimsFromSchema(schema, [], claims, /* @__PURE__ */ new Set());
|
|
369
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
370
|
+
for (const claim of claims) {
|
|
371
|
+
const key = JSON.stringify(claim.path);
|
|
372
|
+
if (!deduped.has(key)) deduped.set(key, claim);
|
|
373
|
+
}
|
|
374
|
+
return [...deduped.values()];
|
|
375
|
+
}
|
|
376
|
+
function toDcqlTrustedAuthorities(schemaMeta) {
|
|
377
|
+
const valuesByType = /* @__PURE__ */ new Map();
|
|
378
|
+
for (const authority of schemaMeta.trustedAuthorities ?? []) {
|
|
379
|
+
if (authority.frameworkType !== "aki" && authority.frameworkType !== "etsi_tl") continue;
|
|
380
|
+
const existing = valuesByType.get(authority.frameworkType) ?? [];
|
|
381
|
+
if (!existing.includes(authority.value)) {
|
|
382
|
+
existing.push(authority.value);
|
|
383
|
+
valuesByType.set(authority.frameworkType, existing);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const result = [];
|
|
387
|
+
for (const [type, values] of valuesByType.entries()) if (values.length > 0) result.push({
|
|
388
|
+
type,
|
|
389
|
+
values
|
|
390
|
+
});
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
function toDcqlCredentialInput(params) {
|
|
394
|
+
const { schemaMeta, format, index, schemaRef, idPrefix } = params;
|
|
395
|
+
const credential = {
|
|
396
|
+
id: `${idPrefix ?? "credential"}-${index + 1}`,
|
|
397
|
+
format
|
|
398
|
+
};
|
|
399
|
+
const claims = getClaimsFromSchema(schemaRef);
|
|
400
|
+
if (claims.length > 0) credential.claims = claims;
|
|
401
|
+
if (format === "dc+sd-jwt") {
|
|
402
|
+
const value = getVct(schemaRef?.meta) ?? getVct(getFirstSchemaMetaByFormat(schemaMeta, format)) ?? schemaMeta.id;
|
|
403
|
+
if (!value) throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing vct value`);
|
|
404
|
+
credential.meta = { vct_values: [value] };
|
|
405
|
+
}
|
|
406
|
+
if (format === "mso_mdoc") {
|
|
407
|
+
const value = getDocTypeValue(schemaRef?.meta) ?? getDocTypeValue(getFirstSchemaMetaByFormat(schemaMeta, format));
|
|
408
|
+
if (!value) throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing doctype_value`);
|
|
409
|
+
credential.meta = { doctype_value: value };
|
|
410
|
+
}
|
|
411
|
+
return credential;
|
|
412
|
+
}
|
|
413
|
+
function buildDcqlFromSchemaMeta(options) {
|
|
414
|
+
const { schemaMeta, selectedFormats, resolvedReferences = [], includeTrustedAuthorities = false, idPrefix } = options;
|
|
415
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
416
|
+
const trustedAuthorities = includeTrustedAuthorities ? toDcqlTrustedAuthorities(schemaMeta) : [];
|
|
417
|
+
return { credentials: selectedFormats.map((format, index) => {
|
|
418
|
+
const referenceIndex = resolvedReferences.findIndex((reference, candidateIndex) => reference.format === format && !consumed.has(candidateIndex));
|
|
419
|
+
const schemaRef = referenceIndex >= 0 ? resolvedReferences[referenceIndex] : void 0;
|
|
420
|
+
if (referenceIndex >= 0) consumed.add(referenceIndex);
|
|
421
|
+
const credential = toDcqlCredentialInput({
|
|
422
|
+
schemaMeta,
|
|
423
|
+
format,
|
|
424
|
+
index,
|
|
425
|
+
schemaRef,
|
|
426
|
+
idPrefix
|
|
427
|
+
});
|
|
428
|
+
if (includeTrustedAuthorities && trustedAuthorities.length > 0) credential.trusted_authorities = trustedAuthorities;
|
|
429
|
+
return credential;
|
|
430
|
+
}) };
|
|
431
|
+
}
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/resolver.ts
|
|
434
|
+
function isPlainObject(value) {
|
|
435
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
436
|
+
}
|
|
437
|
+
function parseSri(integrity) {
|
|
438
|
+
const token = integrity.trim().split(/\s+/)[0];
|
|
439
|
+
const separatorIndex = token.indexOf("-");
|
|
440
|
+
if (separatorIndex <= 0 || separatorIndex >= token.length - 1) throw new SchemaMetaException(`integrity invalid format '${integrity}'`);
|
|
441
|
+
const algorithm = token.slice(0, separatorIndex);
|
|
442
|
+
const digestValue = token.slice(separatorIndex + 1);
|
|
443
|
+
if (algorithm !== "sha256" && algorithm !== "sha384" && algorithm !== "sha512") throw new SchemaMetaException(`integrity unsupported algorithm '${algorithm}'`);
|
|
444
|
+
let digest;
|
|
445
|
+
try {
|
|
446
|
+
digest = Buffer.from(digestValue, "base64");
|
|
447
|
+
} catch {
|
|
448
|
+
throw new SchemaMetaException(`integrity invalid base64 digest`);
|
|
449
|
+
}
|
|
450
|
+
if (digest.length === 0) throw new SchemaMetaException(`integrity invalid base64 digest`);
|
|
451
|
+
return {
|
|
452
|
+
algorithm,
|
|
453
|
+
digest
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function verifySriIntegrity(content, integrity) {
|
|
457
|
+
const { algorithm, digest } = parseSri(integrity);
|
|
458
|
+
const normalized = typeof content === "string" ? content : JSON.stringify(content);
|
|
459
|
+
const actual = createHash(algorithm).update(Buffer.from(normalized, "utf8")).digest();
|
|
460
|
+
if (actual.length !== digest.length || !timingSafeEqual(actual, digest)) throw new SchemaMetaException("integrity mismatch");
|
|
461
|
+
}
|
|
462
|
+
async function resolveSchemaReferences(options) {
|
|
463
|
+
const { schemaMeta, selectedFormats, resolve, verifyIntegrity = false } = options;
|
|
464
|
+
const selectedSet = selectedFormats ? new Set(selectedFormats) : void 0;
|
|
465
|
+
const resolved = [];
|
|
466
|
+
for (const [index, schemaURI] of schemaMeta.schemaURIs.entries()) {
|
|
467
|
+
if (selectedSet && !selectedSet.has(schemaURI.formatIdentifier)) continue;
|
|
468
|
+
let content;
|
|
469
|
+
try {
|
|
470
|
+
content = (await resolve(schemaURI.uri)).content;
|
|
471
|
+
} catch (error) {
|
|
472
|
+
throw new SchemaMetaException(`schemaURIs[${index}].uri resolve failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
473
|
+
}
|
|
474
|
+
if (verifyIntegrity && schemaURI.integrity) try {
|
|
475
|
+
verifySriIntegrity(content, schemaURI.integrity);
|
|
476
|
+
} catch (error) {
|
|
477
|
+
if (error instanceof SchemaMetaException) throw new SchemaMetaException(`schemaURIs[${index}].${error.message}`);
|
|
478
|
+
throw new SchemaMetaException(`schemaURIs[${index}].integrity verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
479
|
+
}
|
|
480
|
+
let rawSchema;
|
|
481
|
+
let parsedSchema;
|
|
482
|
+
if (typeof content === "string") try {
|
|
483
|
+
const parsed = JSON.parse(content);
|
|
484
|
+
rawSchema = parsed;
|
|
485
|
+
if (isPlainObject(parsed)) parsedSchema = parsed;
|
|
486
|
+
} catch {
|
|
487
|
+
rawSchema = content;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
rawSchema = content;
|
|
491
|
+
if (isPlainObject(content)) parsedSchema = content;
|
|
492
|
+
}
|
|
493
|
+
resolved.push({
|
|
494
|
+
format: schemaURI.formatIdentifier,
|
|
495
|
+
uri: schemaURI.uri,
|
|
496
|
+
integrity: schemaURI.integrity,
|
|
497
|
+
meta: schemaURI.meta,
|
|
498
|
+
rawSchema,
|
|
499
|
+
parsedSchema
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
return resolved;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/verifier.ts
|
|
506
|
+
/**
|
|
507
|
+
* Verify and decode a signed SchemaMeta JWS
|
|
508
|
+
*
|
|
509
|
+
* Decodes the JWS, verifies the signature using the provided verifier,
|
|
510
|
+
* and validates the payload against the TS11 SchemaMeta schema.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* import { ES256 } from '@owf/crypto'
|
|
515
|
+
* import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
|
|
516
|
+
*
|
|
517
|
+
* const verifier = await ES256.getVerifier(publicKey)
|
|
518
|
+
* const { header, payload } = await verifySchemaMeta({
|
|
519
|
+
* jws: signedJws,
|
|
520
|
+
* verifier,
|
|
521
|
+
* })
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
async function verifySchemaMeta(options) {
|
|
525
|
+
const { jws, verifier } = options;
|
|
526
|
+
const { header, payload, signature } = decodeJwt(jws);
|
|
527
|
+
const [encodedHeader, encodedPayload] = jws.split(".");
|
|
528
|
+
if (!await verifier(`${encodedHeader}.${encodedPayload}`, signature)) throw new SchemaMetaException("Invalid signature");
|
|
529
|
+
const parsed = SchemaMetaSchema.safeParse(payload);
|
|
530
|
+
if (!parsed.success) throw new SchemaMetaException(`Invalid SchemaMeta payload:\n${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
|
|
531
|
+
return {
|
|
532
|
+
header: {
|
|
533
|
+
alg: header.alg,
|
|
534
|
+
typ: header.typ,
|
|
535
|
+
kid: header.kid,
|
|
536
|
+
x5c: header.x5c
|
|
537
|
+
},
|
|
538
|
+
payload: parsed.data,
|
|
539
|
+
iat: parsed.data.iat || Math.floor(Date.now() / 1e3)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/orchestrator.ts
|
|
544
|
+
async function verifyResolveAndBuildDcql(options) {
|
|
545
|
+
const { jws, verifier, selectedFormats, resolve, verifyIntegrity, includeTrustedAuthorities, idPrefix } = options;
|
|
546
|
+
const verified = await verifySchemaMeta({
|
|
547
|
+
jws,
|
|
548
|
+
verifier
|
|
549
|
+
});
|
|
550
|
+
const resolvedReferences = await resolveSchemaReferences({
|
|
551
|
+
schemaMeta: verified.payload,
|
|
552
|
+
selectedFormats,
|
|
553
|
+
resolve,
|
|
554
|
+
verifyIntegrity
|
|
555
|
+
});
|
|
556
|
+
return {
|
|
557
|
+
verified,
|
|
558
|
+
resolvedReferences,
|
|
559
|
+
dcql: buildDcqlFromSchemaMeta({
|
|
560
|
+
schemaMeta: verified.payload,
|
|
561
|
+
selectedFormats,
|
|
562
|
+
resolvedReferences,
|
|
563
|
+
includeTrustedAuthorities,
|
|
564
|
+
idPrefix
|
|
565
|
+
})
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
//#endregion
|
|
295
569
|
//#region src/signer.ts
|
|
296
570
|
/**
|
|
297
571
|
* Sign a SchemaMeta object as a JWS
|
|
@@ -376,44 +650,6 @@ function assertValidSchemaMeta(schemaMetaDocument) {
|
|
|
376
650
|
if (!result.valid) throw new SchemaMetaException(`Invalid SchemaMeta:\n${result.errors.map((e) => `${e.path}: ${e.message}`).join("\n")}`);
|
|
377
651
|
}
|
|
378
652
|
//#endregion
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Verify and decode a signed SchemaMeta JWS
|
|
382
|
-
*
|
|
383
|
-
* Decodes the JWS, verifies the signature using the provided verifier,
|
|
384
|
-
* and validates the payload against the TS11 SchemaMeta schema.
|
|
385
|
-
*
|
|
386
|
-
* @example
|
|
387
|
-
* ```typescript
|
|
388
|
-
* import { ES256 } from '@owf/crypto'
|
|
389
|
-
* import { verifySchemaMeta } from '@owf/eudi-attestation-schema'
|
|
390
|
-
*
|
|
391
|
-
* const verifier = await ES256.getVerifier(publicKey)
|
|
392
|
-
* const { header, payload } = await verifySchemaMeta({
|
|
393
|
-
* jws: signedJws,
|
|
394
|
-
* verifier,
|
|
395
|
-
* })
|
|
396
|
-
* ```
|
|
397
|
-
*/
|
|
398
|
-
async function verifySchemaMeta(options) {
|
|
399
|
-
const { jws, verifier } = options;
|
|
400
|
-
const { header, payload, signature } = decodeJwt(jws);
|
|
401
|
-
const [encodedHeader, encodedPayload] = jws.split(".");
|
|
402
|
-
if (!await verifier(`${encodedHeader}.${encodedPayload}`, signature)) throw new SchemaMetaException("Invalid signature");
|
|
403
|
-
const parsed = SchemaMetaSchema.safeParse(payload);
|
|
404
|
-
if (!parsed.success) throw new SchemaMetaException(`Invalid SchemaMeta payload:\n${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("\n")}`);
|
|
405
|
-
return {
|
|
406
|
-
header: {
|
|
407
|
-
alg: header.alg,
|
|
408
|
-
typ: header.typ,
|
|
409
|
-
kid: header.kid,
|
|
410
|
-
x5c: header.x5c
|
|
411
|
-
},
|
|
412
|
-
payload: parsed.data,
|
|
413
|
-
iat: parsed.data.iat || Math.floor(Date.now() / 1e3)
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
//#endregion
|
|
417
|
-
export { AttestationFormatSchema, AttestationFormatValues, AttestationLoSSchema, AttestationLoSValues, BindingTypeSchema, BindingTypeValues, FrameworkTypeSchema, FrameworkTypeValues, GenericMetaSchema, MsoMdocMetaSchema, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, SchemaURIBuilder, SchemaURISchema, SdJwtMetaSchema, TrustAuthorityBuilder, TrustAuthoritySchema, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
653
|
+
export { AttestationFormatSchema, AttestationFormatValues, AttestationLoSSchema, AttestationLoSValues, BindingTypeSchema, BindingTypeValues, FrameworkTypeSchema, FrameworkTypeValues, GenericMetaSchema, MsoMdocMetaSchema, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, SchemaURIBuilder, SchemaURISchema, SdJwtMetaSchema, TrustAuthorityBuilder, TrustAuthoritySchema, assertValidSchemaMeta, buildDcqlFromSchemaMeta, resolveSchemaReferences, schemaMeta, schemaURI, signSchemaMeta, toDcqlCredentialInput, toDcqlTrustedAuthorities, trustAuthority, validateSchemaMeta, verifyResolveAndBuildDcql, verifySchemaMeta };
|
|
418
654
|
|
|
419
655
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\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 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 SchemaURIMeta,\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: Record<string, unknown> = {}\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 * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\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 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 * .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;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,oBAAoB,SAAS;EACzD,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;ACQA,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;AAAQ;AAE1G,MAAa,0BAA0B,EAAE,KAAK,uBAAuB;AAErE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;AACF;AAEA,MAAa,uBAAuB,EAAE,KAAK,oBAAoB;AAE/D,MAAa,oBAAoB;CAAC;CAAS;CAAO;CAAa;AAAM;AAErE,MAAa,oBAAoB,EAAE,KAAK,iBAAiB;AAEzD,MAAa,sBAAsB;CAAC;CAAO;CAAW;AAAmB;AAEzE,MAAa,sBAAsB,EAAE,KAAK,mBAAmB;AAM7D,MAAa,uBAAuB,EACjC,OAAO;CACN,eAAe;CACf,OAAO,E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Q,SAAS,cAAc,UAA4D,GAAG;CAEtG,MAAM,CAAC,eAAe,kBAAkB,IAAI,MAAM,GAAG;CAIrD,IAAI,CAAC,MADiB,SAAS,GAFP,cAAc,GAAG,kBAEI,SAAS,GAEpD,MAAM,IAAI,oBAAoB,mBAAmB;CAGnD,MAAM,SAAS,iBAAiB,UAAU,OAAO;CACjD,IAAI,CAAC,OAAO,SAEV,MAAM,IAAI,oBAAoB,gCADb,OAAO,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,IACrB,GAAG;CAG1E,OAAO;EACL,QAAQ;GACN,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;EACd;EACA,SAAS,OAAO;EAChB,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;CACtD;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["isPlainObject"],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/dcql.ts","../src/resolver.ts","../src/verifier.ts","../src/orchestrator.ts","../src/signer.ts","../src/validator.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// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\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 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 SchemaURIMeta,\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: Record<string, unknown> = {}\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 * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\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 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 { SchemaMetaException } from './schema-meta-exception'\nimport type {\n AttestationFormat,\n BuildDcqlFromSchemaMetaOptions,\n BuildDcqlFromSchemaMetaResult,\n DcqlTrustedAuthority,\n ResolvedSchemaReference,\n SchemaMeta,\n SchemaURIMeta,\n} from './types'\n\ntype DcqlClaim = { path: Array<string | null> }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction getVct(meta: SchemaURIMeta | undefined): string | undefined {\n if (meta && 'vct' in meta && typeof meta.vct === 'string') {\n return meta.vct\n }\n\n return undefined\n}\n\nfunction getDocTypeValue(meta: SchemaURIMeta | undefined): string | undefined {\n if (meta && 'doctype_value' in meta && typeof meta.doctype_value === 'string') {\n return meta.doctype_value\n }\n\n return undefined\n}\n\nfunction getFirstSchemaMetaByFormat(schemaMeta: SchemaMeta, format: AttestationFormat): SchemaURIMeta | undefined {\n const entry = schemaMeta.schemaURIs.find((value) => value.formatIdentifier === format)\n return entry?.meta\n}\n\nfunction isArraySchema(node: unknown): boolean {\n if (!isPlainObject(node)) {\n return false\n }\n\n if (node.type === 'array') {\n return true\n }\n\n if (Array.isArray(node.type) && node.type.includes('array')) {\n return true\n }\n\n return 'items' in node\n}\n\nfunction isObjectSchema(node: unknown): boolean {\n if (!isPlainObject(node)) {\n return false\n }\n\n if (isPlainObject(node.properties)) {\n return true\n }\n\n if (node.type === 'object') {\n return true\n }\n\n if (Array.isArray(node.type) && node.type.includes('object')) {\n return true\n }\n\n return false\n}\n\nfunction collectClaimsFromSchema(\n node: unknown,\n path: Array<string | null>,\n claims: DcqlClaim[],\n seen: Set<object>\n): void {\n if (!isPlainObject(node)) {\n if (path.length > 0) {\n claims.push({ path })\n }\n return\n }\n\n if (seen.has(node)) {\n return\n }\n seen.add(node)\n\n const combinatorKeys = ['allOf', 'anyOf', 'oneOf'] as const\n for (const key of combinatorKeys) {\n const variants = node[key]\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n collectClaimsFromSchema(variant, path, claims, seen)\n }\n }\n }\n\n const properties = node.properties\n if (isPlainObject(properties)) {\n const propertyEntries = Object.entries(properties)\n\n for (const [propertyName, propertySchema] of propertyEntries) {\n const propertyPath = [...path, propertyName]\n\n if (isArraySchema(propertySchema)) {\n const items = isPlainObject(propertySchema) ? propertySchema.items : undefined\n if (items !== undefined && (isObjectSchema(items) || isArraySchema(items))) {\n collectClaimsFromSchema(items, [...propertyPath, null], claims, seen)\n } else {\n claims.push({ path: propertyPath })\n }\n continue\n }\n\n if (isObjectSchema(propertySchema)) {\n collectClaimsFromSchema(propertySchema, propertyPath, claims, seen)\n continue\n }\n\n claims.push({ path: propertyPath })\n }\n\n return\n }\n\n const items = node.items\n if (items !== undefined) {\n if (isObjectSchema(items) || isArraySchema(items)) {\n collectClaimsFromSchema(items, [...path, null], claims, seen)\n } else if (path.length > 0) {\n claims.push({ path })\n }\n return\n }\n\n if (path.length > 0) {\n claims.push({ path })\n }\n}\n\nfunction getClaimsFromSchema(schemaRef?: ResolvedSchemaReference): DcqlClaim[] {\n const schema = schemaRef?.parsedSchema\n if (!schema) {\n return []\n }\n\n const claims: DcqlClaim[] = []\n collectClaimsFromSchema(schema, [], claims, new Set<object>())\n\n const deduped = new Map<string, DcqlClaim>()\n for (const claim of claims) {\n const key = JSON.stringify(claim.path)\n if (!deduped.has(key)) {\n deduped.set(key, claim)\n }\n }\n\n return [...deduped.values()]\n}\n\nexport function toDcqlTrustedAuthorities(schemaMeta: SchemaMeta): DcqlTrustedAuthority[] {\n const valuesByType = new Map<'aki' | 'etsi_tl', string[]>()\n\n for (const authority of schemaMeta.trustedAuthorities ?? []) {\n if (authority.frameworkType !== 'aki' && authority.frameworkType !== 'etsi_tl') {\n continue\n }\n\n const existing = valuesByType.get(authority.frameworkType) ?? []\n if (!existing.includes(authority.value)) {\n existing.push(authority.value)\n valuesByType.set(authority.frameworkType, existing)\n }\n }\n\n const result: DcqlTrustedAuthority[] = []\n\n for (const [type, values] of valuesByType.entries()) {\n if (values.length > 0) {\n result.push({ type, values })\n }\n }\n\n return result\n}\n\nexport function toDcqlCredentialInput(params: {\n schemaMeta: SchemaMeta\n format: AttestationFormat\n index: number\n schemaRef?: ResolvedSchemaReference\n idPrefix?: string\n}): Record<string, unknown> {\n const { schemaMeta, format, index, schemaRef, idPrefix } = params\n const credential: Record<string, unknown> = {\n id: `${idPrefix ?? 'credential'}-${index + 1}`,\n format,\n }\n const claims = getClaimsFromSchema(schemaRef)\n if (claims.length > 0) {\n credential.claims = claims\n }\n\n if (format === 'dc+sd-jwt') {\n const value = getVct(schemaRef?.meta) ?? getVct(getFirstSchemaMetaByFormat(schemaMeta, format)) ?? schemaMeta.id\n\n if (!value) {\n throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing vct value`)\n }\n\n credential.meta = { vct_values: [value] }\n }\n\n if (format === 'mso_mdoc') {\n const value = getDocTypeValue(schemaRef?.meta) ?? getDocTypeValue(getFirstSchemaMetaByFormat(schemaMeta, format))\n\n if (!value) {\n throw new SchemaMetaException(`DCQL mapping failed for format '${format}': missing doctype_value`)\n }\n\n credential.meta = { doctype_value: value }\n }\n\n return credential\n}\n\nexport function buildDcqlFromSchemaMeta(options: BuildDcqlFromSchemaMetaOptions): BuildDcqlFromSchemaMetaResult {\n const { schemaMeta, selectedFormats, resolvedReferences = [], includeTrustedAuthorities = false, idPrefix } = options\n const consumed = new Set<number>()\n const trustedAuthorities = includeTrustedAuthorities ? toDcqlTrustedAuthorities(schemaMeta) : []\n\n const credentials = selectedFormats.map((format, index) => {\n const referenceIndex = resolvedReferences.findIndex(\n (reference, candidateIndex) => reference.format === format && !consumed.has(candidateIndex)\n )\n\n const schemaRef = referenceIndex >= 0 ? resolvedReferences[referenceIndex] : undefined\n if (referenceIndex >= 0) {\n consumed.add(referenceIndex)\n }\n\n const credential = toDcqlCredentialInput({\n schemaMeta,\n format,\n index,\n schemaRef,\n idPrefix,\n })\n\n if (includeTrustedAuthorities && trustedAuthorities.length > 0) {\n credential.trusted_authorities = trustedAuthorities\n }\n\n return credential\n })\n\n return { credentials }\n}\n","import { createHash, timingSafeEqual } from 'node:crypto'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport type { ResolvedSchemaReference, ResolveSchemaReferencesOptions } from './types'\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction parseSri(integrity: string): { algorithm: string; digest: Buffer } {\n const token = integrity.trim().split(/\\s+/)[0]\n const separatorIndex = token.indexOf('-')\n\n if (separatorIndex <= 0 || separatorIndex >= token.length - 1) {\n throw new SchemaMetaException(`integrity invalid format '${integrity}'`)\n }\n\n const algorithm = token.slice(0, separatorIndex)\n const digestValue = token.slice(separatorIndex + 1)\n\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new SchemaMetaException(`integrity unsupported algorithm '${algorithm}'`)\n }\n\n let digest: Buffer\n try {\n digest = Buffer.from(digestValue, 'base64')\n } catch {\n throw new SchemaMetaException(`integrity invalid base64 digest`)\n }\n\n if (digest.length === 0) {\n throw new SchemaMetaException(`integrity invalid base64 digest`)\n }\n\n return { algorithm, digest }\n}\n\nfunction verifySriIntegrity(content: string | object, integrity: string): void {\n const { algorithm, digest } = parseSri(integrity)\n const normalized = typeof content === 'string' ? content : JSON.stringify(content)\n const actual = createHash(algorithm).update(Buffer.from(normalized, 'utf8')).digest()\n\n if (actual.length !== digest.length || !timingSafeEqual(actual, digest)) {\n throw new SchemaMetaException('integrity mismatch')\n }\n}\n\nexport async function resolveSchemaReferences(\n options: ResolveSchemaReferencesOptions\n): Promise<ResolvedSchemaReference[]> {\n const { schemaMeta, selectedFormats, resolve, verifyIntegrity = false } = options\n const selectedSet = selectedFormats ? new Set(selectedFormats) : undefined\n const resolved: ResolvedSchemaReference[] = []\n\n for (const [index, schemaURI] of schemaMeta.schemaURIs.entries()) {\n if (selectedSet && !selectedSet.has(schemaURI.formatIdentifier)) {\n continue\n }\n\n let content: string | object\n\n try {\n const result = await resolve(schemaURI.uri)\n content = result.content\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new SchemaMetaException(`schemaURIs[${index}].uri resolve failed: ${message}`)\n }\n\n if (verifyIntegrity && schemaURI.integrity) {\n try {\n verifySriIntegrity(content, schemaURI.integrity)\n } catch (error) {\n if (error instanceof SchemaMetaException) {\n throw new SchemaMetaException(`schemaURIs[${index}].${error.message}`)\n }\n\n const message = error instanceof Error ? error.message : String(error)\n throw new SchemaMetaException(`schemaURIs[${index}].integrity verification failed: ${message}`)\n }\n }\n\n let rawSchema: unknown\n let parsedSchema: Record<string, unknown> | undefined\n\n if (typeof content === 'string') {\n try {\n const parsed = JSON.parse(content) as unknown\n rawSchema = parsed\n if (isPlainObject(parsed)) {\n parsedSchema = parsed\n }\n } catch {\n rawSchema = content\n }\n } else {\n rawSchema = content\n if (isPlainObject(content)) {\n parsedSchema = content\n }\n }\n\n resolved.push({\n format: schemaURI.formatIdentifier,\n uri: schemaURI.uri,\n integrity: schemaURI.integrity,\n meta: schemaURI.meta,\n rawSchema,\n parsedSchema,\n })\n }\n\n return resolved\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","import { buildDcqlFromSchemaMeta } from './dcql'\nimport { resolveSchemaReferences } from './resolver'\nimport type {\n AttestationFormat,\n BuildDcqlFromSchemaMetaResult,\n ResolvedSchemaReference,\n ResolveSchemaReferencesOptions,\n VerifiedSchemaMeta,\n VerifyOptions,\n} from './types'\nimport { verifySchemaMeta } from './verifier'\n\nexport async function verifyResolveAndBuildDcql(options: {\n jws: string\n verifier: VerifyOptions['verifier']\n selectedFormats: AttestationFormat[]\n resolve: ResolveSchemaReferencesOptions['resolve']\n verifyIntegrity?: boolean\n includeTrustedAuthorities?: boolean\n idPrefix?: string\n}): Promise<{\n verified: VerifiedSchemaMeta\n resolvedReferences: ResolvedSchemaReference[]\n dcql: BuildDcqlFromSchemaMetaResult\n}> {\n const { jws, verifier, selectedFormats, resolve, verifyIntegrity, includeTrustedAuthorities, idPrefix } = options\n\n const verified = await verifySchemaMeta({ jws, verifier })\n\n const resolvedReferences = await resolveSchemaReferences({\n schemaMeta: verified.payload,\n selectedFormats,\n resolve,\n verifyIntegrity,\n })\n\n const dcql = buildDcqlFromSchemaMeta({\n schemaMeta: verified.payload,\n selectedFormats,\n resolvedReferences,\n includeTrustedAuthorities,\n idPrefix,\n })\n\n return {\n verified,\n resolvedReferences,\n dcql,\n }\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 * .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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AAK,UAAU,MAAM,CAEvB,EAAE,GADf,gBAAgB,KAAK,UAAU,UAAU,CACV;CAKtD,OAAO;EACL,KAAA,GAHa,aAAa,GAAG,MADP,OAAO,YAAY;EAKzC,QAAQ;GACN,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK,OAAO;EACd;EACA,SAAS;EACT;CACF;AACF;;;;;;AChDA,SAAgB,mBAAmB,oBAA+C;CAChF,MAAM,SAAS,iBAAiB,UAAU,kBAAkB;CAE5D,IAAI,OAAO,SACT,OAAO;EAAE,OAAO;EAAM,QAAQ,CAAC;CAAE;CAQnC,OAAO;EAAE,OAAO;EAAO,QALW,OAAO,MAAM,OAAO,KAAK,WAAW;GACpE,MAAM,MAAM,KAAK,KAAK,GAAG;GACzB,SAAS,MAAM;EACjB,EAE4B;CAAE;AAChC;;;;AAKA,SAAgB,sBAAsB,oBAAuE;CAC3G,MAAM,SAAS,mBAAmB,kBAAkB;CACpD,IAAI,CAAC,OAAO,OAEV,MAAM,IAAI,oBAAoB,wBADR,OAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,IACb,GAAG;AAEzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owf/eudi-attestation-schema",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1-alpha-20260613182022",
|
|
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": [
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"zod": "^4.4.3",
|
|
43
|
-
"@owf/crypto": "0.3.
|
|
44
|
-
"@owf/identity-common": "0.3.
|
|
43
|
+
"@owf/crypto": "0.3.1-alpha-20260613182022",
|
|
44
|
+
"@owf/identity-common": "0.3.1-alpha-20260613182022"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"vitest": "^4.1.7"
|