dcql 0.3.0-alpha-20250501093131 → 0.3.0-alpha-20250527162348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -102,10 +102,13 @@ var DcqlPresentationResultError = class extends DcqlError {
102
102
  };
103
103
 
104
104
  // src/dcql-presentation/m-dcql-credential-presentation.ts
105
- import * as v4 from "valibot";
105
+ import * as v5 from "valibot";
106
106
 
107
107
  // src/u-dcql-credential.ts
108
- import * as v3 from "valibot";
108
+ import * as v4 from "valibot";
109
+
110
+ // src/dcql-query/m-dcql-trusted-authorities.ts
111
+ import * as v2 from "valibot";
109
112
 
110
113
  // src/u-dcql.ts
111
114
  import * as v from "valibot";
@@ -123,6 +126,7 @@ var vIncludesAll = (subset) => {
123
126
  );
124
127
  };
125
128
  var vIdString = v.pipe(v.string(), v.regex(idRegex), v.nonEmpty());
129
+ var vBase64url = v.regex(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==)?|[\w-]{3}=?)?$/iu, "must be base64url");
126
130
  function isToJsonable(value) {
127
131
  if (value === null || typeof value !== "object") return false;
128
132
  const toJsonFn = value.toJson;
@@ -183,8 +187,75 @@ var vStringToJson = v.rawTransform(({ dataset, addIssue, NEVER }) => {
183
187
  }
184
188
  });
185
189
 
190
+ // src/dcql-query/m-dcql-trusted-authorities.ts
191
+ var vAuthorityKeyIdentifier = v2.object({
192
+ type: v2.literal("aki"),
193
+ value: v2.pipe(
194
+ v2.string(),
195
+ vBase64url,
196
+ v2.description(
197
+ "Contains the KeyIdentifier of the AuthorityKeyIdentifier as defined in Section 4.2.1.1 of [RFC5280], encoded as base64url. The raw byte representation of this element MUST match with the AuthorityKeyIdentifier element of an X.509 certificate in the certificate chain present in the credential (e.g., in the header of an mdoc or SD-JWT). Note that the chain can consist of a single certificate and the credential can include the entire X.509 chain or parts of it."
198
+ )
199
+ )
200
+ });
201
+ var vEtsiTrustedList = v2.object({
202
+ type: v2.literal("etsi_tl"),
203
+ value: v2.pipe(
204
+ v2.string(),
205
+ v2.url(),
206
+ v2.check(
207
+ (url2) => url2.startsWith("http://") || url2.startsWith("https://"),
208
+ "etsi_tl trusted authority value must be a valid https url"
209
+ ),
210
+ v2.description(
211
+ "The identifier of a Trusted List as specified in ETSI TS 119 612 [ETSI.TL]. An ETSI Trusted List contains references to other Trusted Lists, creating a list of trusted lists, or entries for Trust Service Providers with corresponding service description and X.509 Certificates. The trust chain of a matching Credential MUST contain at least one X.509 Certificate that matches one of the entries of the Trusted List or its cascading Trusted Lists."
212
+ )
213
+ )
214
+ });
215
+ var vOpenidFederation = v2.object({
216
+ type: v2.literal("openid_federation"),
217
+ value: v2.pipe(
218
+ v2.string(),
219
+ v2.url(),
220
+ // TODO: should we have a config similar to oid4vc-ts to support http for development?
221
+ v2.check(
222
+ (url2) => url2.startsWith("http://") || url2.startsWith("https://"),
223
+ "openid_federation trusted authority value must be a valid https url"
224
+ ),
225
+ v2.description(
226
+ "The Entity Identifier as defined in Section 1 of [OpenID.Federation] that is bound to an entity in a federation. While this Entity Identifier could be any entity in that ecosystem, this entity would usually have the Entity Configuration of a Trust Anchor. A valid trust path, including the given Entity Identifier, must be constructible from a matching credential."
227
+ )
228
+ )
229
+ });
230
+ var vTrustedAuthorities = [vAuthorityKeyIdentifier, vEtsiTrustedList, vOpenidFederation];
231
+ var DcqlTrustedAuthoritiesQuery;
232
+ ((DcqlTrustedAuthoritiesQuery2) => {
233
+ const vTrustedAuthoritiesQuery = vTrustedAuthorities.map(
234
+ (authority) => v2.object({
235
+ type: v2.pipe(
236
+ authority.entries.type,
237
+ v2.description(
238
+ "REQUIRED. A string uniquely identifying the type of information about the issuer trust framework."
239
+ )
240
+ ),
241
+ values: v2.pipe(
242
+ v2.array(authority.entries.value),
243
+ vNonEmptyArray(),
244
+ v2.description(
245
+ "REQUIRED. An array of strings, where each string (value) contains information specific to the used Trusted Authorities Query type that allows to identify an issuer, trust framework, or a federation that an issuer belongs to."
246
+ )
247
+ )
248
+ })
249
+ );
250
+ DcqlTrustedAuthoritiesQuery2.vModel = v2.variant("type", vTrustedAuthoritiesQuery);
251
+ })(DcqlTrustedAuthoritiesQuery || (DcqlTrustedAuthoritiesQuery = {}));
252
+ var DcqlCredentialTrustedAuthority;
253
+ ((DcqlCredentialTrustedAuthority2) => {
254
+ DcqlCredentialTrustedAuthority2.vModel = v2.variant("type", vTrustedAuthorities);
255
+ })(DcqlCredentialTrustedAuthority || (DcqlCredentialTrustedAuthority = {}));
256
+
186
257
  // src/u-model.ts
187
- import * as v2 from "valibot";
258
+ import * as v3 from "valibot";
188
259
  var Model = class {
189
260
  constructor(input) {
190
261
  this.input = input;
@@ -203,28 +274,32 @@ var Model = class {
203
274
  });
204
275
  }
205
276
  safeParse(input) {
206
- const res = v2.safeParse(this.input.vModel, input);
277
+ const res = v3.safeParse(this.input.vModel, input);
207
278
  if (res.success) {
208
279
  return { success: true, output: res.output };
209
280
  }
210
281
  return {
211
282
  success: false,
212
- error: new v2.ValiError(res.issues),
213
- flattened: v2.flatten(res.issues)
283
+ error: new v3.ValiError(res.issues),
284
+ flattened: v3.flatten(res.issues)
214
285
  };
215
286
  }
216
287
  is(input) {
217
- return v2.is(this.v, input);
288
+ return v3.is(this.v, input);
218
289
  }
219
290
  };
220
291
 
221
292
  // src/u-dcql-credential.ts
293
+ var vCredentialModelBase = v4.object({
294
+ authority: v4.optional(DcqlCredentialTrustedAuthority.vModel)
295
+ });
222
296
  var DcqlMdocCredential;
223
297
  ((DcqlMdocCredential2) => {
224
- DcqlMdocCredential2.vNamespaces = v3.record(v3.string(), v3.record(v3.string(), v3.unknown()));
225
- DcqlMdocCredential2.vModel = v3.object({
226
- credential_format: v3.literal("mso_mdoc"),
227
- doctype: v3.string(),
298
+ DcqlMdocCredential2.vNamespaces = v4.record(v4.string(), v4.record(v4.string(), v4.unknown()));
299
+ DcqlMdocCredential2.vModel = v4.object({
300
+ ...vCredentialModelBase.entries,
301
+ credential_format: v4.literal("mso_mdoc"),
302
+ doctype: v4.string(),
228
303
  namespaces: DcqlMdocCredential2.vNamespaces
229
304
  });
230
305
  DcqlMdocCredential2.model = new Model({ vModel: DcqlMdocCredential2.vModel });
@@ -232,9 +307,10 @@ var DcqlMdocCredential;
232
307
  var DcqlSdJwtVcCredential;
233
308
  ((DcqlSdJwtVcCredential2) => {
234
309
  DcqlSdJwtVcCredential2.vClaims = vJsonRecord;
235
- DcqlSdJwtVcCredential2.vModel = v3.object({
236
- credential_format: v3.picklist(["vc+sd-jwt", "dc+sd-jwt"]),
237
- vct: v3.string(),
310
+ DcqlSdJwtVcCredential2.vModel = v4.object({
311
+ ...vCredentialModelBase.entries,
312
+ credential_format: v4.picklist(["vc+sd-jwt", "dc+sd-jwt"]),
313
+ vct: v4.string(),
238
314
  claims: DcqlSdJwtVcCredential2.vClaims
239
315
  });
240
316
  DcqlSdJwtVcCredential2.model = new Model({ vModel: DcqlSdJwtVcCredential2.vModel });
@@ -242,35 +318,36 @@ var DcqlSdJwtVcCredential;
242
318
  var DcqlW3cVcCredential;
243
319
  ((DcqlW3cVcCredential2) => {
244
320
  DcqlW3cVcCredential2.vClaims = vJsonRecord;
245
- DcqlW3cVcCredential2.vModel = v3.object({
246
- credential_format: v3.picklist(["ldp_vc", "jwt_vc_json"]),
321
+ DcqlW3cVcCredential2.vModel = v4.object({
322
+ ...vCredentialModelBase.entries,
323
+ credential_format: v4.picklist(["ldp_vc", "jwt_vc_json"]),
247
324
  claims: DcqlW3cVcCredential2.vClaims,
248
- type: v3.array(v3.string())
325
+ type: v4.array(v4.string())
249
326
  });
250
327
  DcqlW3cVcCredential2.model = new Model({ vModel: DcqlW3cVcCredential2.vModel });
251
328
  })(DcqlW3cVcCredential || (DcqlW3cVcCredential = {}));
252
329
  var DcqlCredential;
253
330
  ((DcqlCredential2) => {
254
- DcqlCredential2.vModel = v3.variant("credential_format", [
331
+ DcqlCredential2.vModel = v4.variant("credential_format", [
255
332
  DcqlMdocCredential.vModel,
256
333
  DcqlSdJwtVcCredential.vModel,
257
334
  DcqlW3cVcCredential.vModel
258
335
  ]);
259
- DcqlCredential2.vParseSuccess = v3.object({
260
- success: v3.literal(true),
261
- typed: v3.literal(true),
262
- issues: v3.optional(v3.undefined()),
263
- input_credential_index: v3.number(),
264
- claim_set_index: v3.union([v3.number(), v3.undefined()]),
336
+ DcqlCredential2.vParseSuccess = v4.object({
337
+ success: v4.literal(true),
338
+ typed: v4.literal(true),
339
+ issues: v4.optional(v4.undefined()),
340
+ input_credential_index: v4.number(),
341
+ claim_set_index: v4.union([v4.number(), v4.undefined()]),
265
342
  output: DcqlCredential2.vModel
266
343
  });
267
- DcqlCredential2.vParseFailure = v3.object({
268
- success: v3.literal(false),
269
- typed: v3.boolean(),
270
- output: v3.unknown(),
271
- issues: v3.pipe(v3.array(v3.unknown()), vNonEmptyArray()),
272
- input_credential_index: v3.number(),
273
- claim_set_index: v3.union([v3.number(), v3.undefined()])
344
+ DcqlCredential2.vParseFailure = v4.object({
345
+ success: v4.literal(false),
346
+ typed: v4.boolean(),
347
+ output: v4.unknown(),
348
+ issues: v4.pipe(v4.array(v4.unknown()), vNonEmptyArray()),
349
+ input_credential_index: v4.number(),
350
+ claim_set_index: v4.union([v4.number(), v4.undefined()])
274
351
  });
275
352
  DcqlCredential2.model = new Model({ vModel: DcqlCredential2.vModel });
276
353
  })(DcqlCredential || (DcqlCredential = {}));
@@ -294,7 +371,7 @@ var DcqlW3cVcPresentation;
294
371
  var DcqlCredentialPresentation;
295
372
  ((DcqlCredentialPresentation2) => {
296
373
  DcqlCredentialPresentation2.model = new Model({
297
- vModel: v4.variant("credential_format", [
374
+ vModel: v5.variant("credential_format", [
298
375
  DcqlMdocPresentation.vModel,
299
376
  DcqlSdJwtVcPresentation.vModel,
300
377
  DcqlW3cVcPresentation.vModel
@@ -303,117 +380,126 @@ var DcqlCredentialPresentation;
303
380
  })(DcqlCredentialPresentation || (DcqlCredentialPresentation = {}));
304
381
 
305
382
  // src/dcql-presentation/m-dcql-presentation-result.ts
306
- import * as v11 from "valibot";
383
+ import * as v12 from "valibot";
307
384
 
308
385
  // src/dcql-parser/dcql-credential-query-result.ts
309
- import * as v7 from "valibot";
386
+ import * as v8 from "valibot";
310
387
 
311
388
  // src/dcql-parser/dcql-claims-query-result.ts
312
- import * as v6 from "valibot";
389
+ import * as v7 from "valibot";
313
390
 
314
391
  // src/dcql-query/m-dcql-claims-query.ts
315
- import * as v5 from "valibot";
392
+ import * as v6 from "valibot";
316
393
  var DcqlClaimsQuery;
317
394
  ((DcqlClaimsQuery2) => {
318
- DcqlClaimsQuery2.vValue = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer()), v5.boolean()]);
319
- DcqlClaimsQuery2.vPath = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer(), v5.minValue(0)), v5.null()]);
320
- DcqlClaimsQuery2.vW3cSdJwtVc = v5.object({
321
- id: v5.pipe(
322
- v5.optional(vIdString),
323
- v5.description(
395
+ DcqlClaimsQuery2.vValue = v6.union([v6.string(), v6.pipe(v6.number(), v6.integer()), v6.boolean()]);
396
+ DcqlClaimsQuery2.vPath = v6.union([v6.string(), v6.pipe(v6.number(), v6.integer(), v6.minValue(0)), v6.null()]);
397
+ DcqlClaimsQuery2.vW3cSdJwtVc = v6.object({
398
+ id: v6.pipe(
399
+ v6.optional(vIdString),
400
+ v6.description(
324
401
  "A string identifying the particular claim. The value MUST be a non-empty string consisting of alphanumeric, underscore (_) or hyphen (-) characters. Within the particular claims array, the same id MUST NOT be present more than once."
325
402
  )
326
403
  ),
327
- path: v5.pipe(
328
- v5.array(DcqlClaimsQuery2.vPath),
404
+ path: v6.pipe(
405
+ v6.array(DcqlClaimsQuery2.vPath),
329
406
  vNonEmptyArray(),
330
- v5.description(
407
+ v6.description(
331
408
  "A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential."
332
409
  )
333
410
  ),
334
- values: v5.pipe(
335
- v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
336
- v5.description(
411
+ values: v6.pipe(
412
+ v6.optional(v6.array(DcqlClaimsQuery2.vValue)),
413
+ v6.description(
337
414
  "An array of strings, integers or boolean values that specifies the expected values of the claim. If the values property is present, the Wallet SHOULD return the claim only if the type and value of the claim both match for at least one of the elements in the array."
338
415
  )
339
416
  )
340
417
  });
341
- const vMdocBase = v5.object({
342
- id: v5.pipe(
343
- v5.optional(vIdString),
344
- v5.description(
418
+ const vMdocBase = v6.object({
419
+ id: v6.pipe(
420
+ v6.optional(vIdString),
421
+ v6.description(
345
422
  "A string identifying the particular claim. The value MUST be a non-empty string consisting of alphanumeric, underscore (_) or hyphen (-) characters. Within the particular claims array, the same id MUST NOT be present more than once."
346
423
  )
347
424
  ),
348
- values: v5.pipe(
349
- v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
350
- v5.description(
425
+ values: v6.pipe(
426
+ v6.optional(v6.array(DcqlClaimsQuery2.vValue)),
427
+ v6.description(
351
428
  "An array of strings, integers or boolean values that specifies the expected values of the claim. If the values property is present, the Wallet SHOULD return the claim only if the type and value of the claim both match for at least one of the elements in the array."
352
429
  )
353
430
  )
354
431
  });
355
- DcqlClaimsQuery2.vMdocNamespace = v5.object({
432
+ DcqlClaimsQuery2.vMdocNamespace = v6.object({
356
433
  ...vMdocBase.entries,
357
- namespace: v5.pipe(
358
- v5.string(),
359
- v5.description(
434
+ namespace: v6.pipe(
435
+ v6.string(),
436
+ v6.description(
360
437
  "A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
361
438
  )
362
439
  ),
363
- claim_name: v5.pipe(
364
- v5.string(),
365
- v5.description(
440
+ claim_name: v6.pipe(
441
+ v6.string(),
442
+ v6.description(
366
443
  "A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
367
444
  )
368
445
  )
369
446
  });
370
- DcqlClaimsQuery2.vMdocPath = v5.object({
447
+ DcqlClaimsQuery2.vMdocPath = v6.object({
371
448
  ...vMdocBase.entries,
372
- intent_to_retain: v5.pipe(
373
- v5.optional(v5.boolean()),
374
- v5.description(
449
+ intent_to_retain: v6.pipe(
450
+ v6.optional(v6.boolean()),
451
+ v6.description(
375
452
  "A boolean that is equivalent to `IntentToRetain` variable defined in Section 8.3.2.1.2.1 of [@ISO.18013-5]."
376
453
  )
377
454
  ),
378
- path: v5.pipe(
379
- v5.tuple([
380
- v5.pipe(
381
- v5.string(),
382
- v5.description(
455
+ path: v6.pipe(
456
+ v6.tuple([
457
+ v6.pipe(
458
+ v6.string(),
459
+ v6.description(
383
460
  "A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
384
461
  )
385
462
  ),
386
- v5.pipe(
387
- v5.string(),
388
- v5.description(
463
+ v6.pipe(
464
+ v6.string(),
465
+ v6.description(
389
466
  "A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
390
467
  )
391
468
  )
392
469
  ]),
393
- v5.description(
470
+ v6.description(
394
471
  "An array defining a claims path pointer into an mdoc. It must contain two elements of type string. The first element refers to a namespace and the second element refers to a data element identifier."
395
472
  )
396
473
  )
397
474
  });
398
- DcqlClaimsQuery2.vMdoc = v5.union([DcqlClaimsQuery2.vMdocNamespace, DcqlClaimsQuery2.vMdocPath]);
399
- DcqlClaimsQuery2.vModel = v5.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
475
+ DcqlClaimsQuery2.vMdoc = v6.union([DcqlClaimsQuery2.vMdocNamespace, DcqlClaimsQuery2.vMdocPath]);
476
+ DcqlClaimsQuery2.vModel = v6.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
400
477
  })(DcqlClaimsQuery || (DcqlClaimsQuery = {}));
401
478
 
402
479
  // src/dcql-parser/dcql-claims-query-result.ts
480
+ var getTrustedAuthorityValue = (credentialQuery) => v7.object({
481
+ authority: credentialQuery.trusted_authorities ? v7.variant(
482
+ "type",
483
+ credentialQuery.trusted_authorities.map(
484
+ (t) => v7.object({ type: v7.literal(t.type), value: v7.union(t.values.map((value) => v7.literal(value))) })
485
+ ),
486
+ `Credential query '${credentialQuery.id}' requires the credential to be issued by a trusted authority of type ${credentialQuery.trusted_authorities.map((t) => t.type).join(" | ")}, but none of the type or values match.`
487
+ ) : v7.optional(DcqlCredentialTrustedAuthority.vModel)
488
+ });
403
489
  var getClaimParser = (input) => {
404
490
  const { value, values } = input;
405
491
  if (value) {
406
- return vWithJT(v6.literal(value));
492
+ return vWithJT(v7.literal(value));
407
493
  }
408
494
  if (values) {
409
- return vWithJT(v6.union(values.map((val) => v6.literal(val))));
495
+ return vWithJT(v7.union(values.map((val) => v7.literal(val))));
410
496
  }
411
- return v6.nonNullish(v6.any());
497
+ return v7.nonNullish(v7.any());
412
498
  };
413
499
  var getNamespacesParser = (claimsQueries) => {
414
500
  const claimsForNamespace = {};
415
501
  for (const claimQuery of claimsQueries) {
416
- const mdocPathQuery = v6.is(DcqlClaimsQuery.vMdocNamespace, claimQuery) ? {
502
+ const mdocPathQuery = v7.is(DcqlClaimsQuery.vMdocNamespace, claimQuery) ? {
417
503
  id: claimQuery.id,
418
504
  path: [claimQuery.namespace, claimQuery.claim_name],
419
505
  values: claimQuery.values
@@ -427,9 +513,9 @@ var getNamespacesParser = (claimsQueries) => {
427
513
  }
428
514
  const parsersForNamespaces = Object.entries(claimsForNamespace).map(([namespace, claims]) => {
429
515
  const claimParsers = Object.fromEntries(claims.map((claim) => [claim.path[1], getClaimParser(claim)]));
430
- return [namespace, v6.object(claimParsers)];
516
+ return [namespace, v7.object(claimParsers)];
431
517
  });
432
- return v6.object(Object.fromEntries(parsersForNamespaces));
518
+ return v7.object(Object.fromEntries(parsersForNamespaces));
433
519
  };
434
520
  var getClaimQueryParser = (claimQuery, ctx) => {
435
521
  const { index, presentation } = ctx;
@@ -439,31 +525,31 @@ var getClaimQueryParser = (claimQuery, ctx) => {
439
525
  if (typeof pathElement === "number") {
440
526
  const elementParser = isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 });
441
527
  if (presentation) {
442
- return v6.union([
443
- v6.pipe(
444
- v6.array(vJson),
445
- v6.length(1),
446
- v6.transform((input) => input[0]),
528
+ return v7.union([
529
+ v7.pipe(
530
+ v7.array(vJson),
531
+ v7.length(1),
532
+ v7.transform((input) => input[0]),
447
533
  elementParser
448
534
  ),
449
535
  elementParser
450
536
  ]);
451
537
  }
452
- return v6.pipe(
453
- v6.array(vJson),
454
- v6.transform((input) => input[pathElement]),
538
+ return v7.pipe(
539
+ v7.array(vJson),
540
+ v7.transform((input) => input[pathElement]),
455
541
  elementParser
456
542
  );
457
543
  }
458
544
  if (typeof pathElement === "string") {
459
- return v6.object({
545
+ return v7.object({
460
546
  [pathElement]: isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 })
461
547
  });
462
548
  }
463
- return isLast ? v6.array(vClaimParser) : v6.array(getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }));
549
+ return isLast ? v7.array(vClaimParser) : v7.array(getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }));
464
550
  };
465
551
  var getJsonClaimsParser = (claimsQueries, ctx) => {
466
- const claimParser = v6.intersect(
552
+ const claimParser = v7.intersect(
467
553
  claimsQueries.map(
468
554
  (claimQuery) => getClaimQueryParser(claimQuery, {
469
555
  ...ctx,
@@ -497,12 +583,13 @@ var getJsonClaimsQueriesForClaimSet = (claimsQueries, claimSet) => {
497
583
  };
498
584
  var getMdocParser = (credentialQuery, ctx) => {
499
585
  const { claimSet } = ctx;
500
- const vDoctype = credentialQuery.meta?.doctype_value ? v6.literal(credentialQuery.meta.doctype_value) : v6.string();
586
+ const vDoctype = credentialQuery.meta?.doctype_value ? v7.literal(credentialQuery.meta.doctype_value) : v7.string();
501
587
  const claimSetQueries = credentialQuery.claims && claimSet ? getMdocClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
502
- const credentialParser = v6.object({
503
- credential_format: v6.literal("mso_mdoc"),
588
+ const credentialParser = v7.object({
589
+ credential_format: v7.literal("mso_mdoc"),
504
590
  doctype: vDoctype,
505
- namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) : v6.record(v6.string(), v6.record(v6.string(), v6.unknown()))
591
+ namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) : v7.record(v7.string(), v7.record(v7.string(), v7.unknown())),
592
+ ...getTrustedAuthorityValue(credentialQuery).entries
506
593
  });
507
594
  return credentialParser;
508
595
  };
@@ -510,20 +597,28 @@ var getW3cVcSdJwtVcParser = (credentialQuery, ctx) => {
510
597
  const { claimSet } = ctx;
511
598
  const claimSetQueries = credentialQuery.claims && claimSet ? getJsonClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
512
599
  if (credentialQuery.format === "vc+sd-jwt" || credentialQuery.format === "dc+sd-jwt") {
513
- return v6.object({
514
- credential_format: v6.literal(credentialQuery.format),
515
- vct: credentialQuery.meta?.vct_values ? v6.picklist(credentialQuery.meta.vct_values) : v6.string(),
516
- claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord
600
+ return v7.object({
601
+ credential_format: v7.literal(credentialQuery.format),
602
+ vct: credentialQuery.meta?.vct_values ? v7.picklist(credentialQuery.meta.vct_values) : v7.string(),
603
+ claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord,
604
+ // TODO: we should split up the:
605
+ // - vct
606
+ // - claim value
607
+ // - trusted authorities
608
+ // into separate validations so we can make the match result richer with specifically
609
+ // which steps failed, also we should look at showing exactly which claim paths failed.
610
+ ...getTrustedAuthorityValue(credentialQuery).entries
517
611
  });
518
612
  }
519
613
  if (credentialQuery.format === "jwt_vc_json" || credentialQuery.format === "ldp_vc") {
520
- return v6.object({
521
- credential_format: v6.literal(credentialQuery.format),
614
+ return v7.object({
615
+ credential_format: v7.literal(credentialQuery.format),
522
616
  claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord,
523
- type: credentialQuery.meta?.type_values ? v6.union(
617
+ type: credentialQuery.meta?.type_values ? v7.union(
524
618
  credentialQuery.meta.type_values.map((values) => vIncludesAll(values)),
525
619
  `Type must include at least all values from one of the following subsets: ${credentialQuery.meta.type_values.map((values) => `[${values.join(", ")}]`).join(" | ")}`
526
- ) : v6.array(v6.string())
620
+ ) : v7.array(v7.string()),
621
+ ...getTrustedAuthorityValue(credentialQuery).entries
527
622
  });
528
623
  }
529
624
  throw new DcqlError({
@@ -562,11 +657,11 @@ var runCredentialQuery = (credentialQuery, ctx) => {
562
657
  continue;
563
658
  }
564
659
  }
565
- const parseResult = v7.safeParse(credentialParser, credential);
660
+ const parseResult = v8.safeParse(credentialParser, credential);
566
661
  claimSetResult.push({
567
662
  ...parseResult,
568
663
  ...parseResult.issues && {
569
- flattened: v7.flatten(parseResult.issues)
664
+ flattened: v8.flatten(parseResult.issues)
570
665
  },
571
666
  input_credential_index: credentialIndex,
572
667
  claim_set_index: credentialQuery.claim_sets ? claimSetIndex : void 0
@@ -578,101 +673,107 @@ var runCredentialQuery = (credentialQuery, ctx) => {
578
673
  };
579
674
 
580
675
  // src/dcql-query-result/m-dcql-query-result.ts
581
- import * as v10 from "valibot";
676
+ import * as v11 from "valibot";
582
677
 
583
678
  // src/dcql-query/m-dcql-credential-query.ts
584
- import * as v8 from "valibot";
679
+ import * as v9 from "valibot";
585
680
  var DcqlCredentialQuery;
586
681
  ((DcqlCredentialQuery2) => {
587
- const vBase = v8.object({
588
- id: v8.pipe(
589
- v8.string(),
590
- v8.regex(idRegex),
591
- v8.description(
682
+ const vBase = v9.object({
683
+ id: v9.pipe(
684
+ v9.string(),
685
+ v9.regex(idRegex),
686
+ v9.description(
592
687
  `REQUIRED. A string identifying the Credential in the response and, if provided, the constraints in 'credential_sets'.`
593
688
  )
594
689
  ),
595
- claim_sets: v8.pipe(
596
- v8.optional(v8.pipe(v8.array(v8.pipe(v8.array(vIdString), vNonEmptyArray())), vNonEmptyArray())),
597
- v8.description(
690
+ claim_sets: v9.pipe(
691
+ v9.optional(v9.pipe(v9.array(v9.pipe(v9.array(vIdString), vNonEmptyArray())), vNonEmptyArray())),
692
+ v9.description(
598
693
  `OPTIONAL. A non-empty array containing arrays of identifiers for elements in 'claims' that specifies which combinations of 'claims' for the Credential are requested.`
599
694
  )
695
+ ),
696
+ trusted_authorities: v9.pipe(
697
+ v9.optional(v9.pipe(v9.array(DcqlTrustedAuthoritiesQuery.vModel), vNonEmptyArray())),
698
+ v9.description(
699
+ "OPTIONAL. A non-empty array of objects as defined in Section 6.1.1 that specifies expected authorities or trust frameworks that certify Issuers, that the Verifier will accept. Every Credential returned by the Wallet SHOULD match at least one of the conditions present in the corresponding trusted_authorities array if present."
700
+ )
600
701
  )
601
702
  });
602
- DcqlCredentialQuery2.vMdoc = v8.object({
703
+ DcqlCredentialQuery2.vMdoc = v9.object({
603
704
  ...vBase.entries,
604
- format: v8.pipe(
605
- v8.literal("mso_mdoc"),
606
- v8.description("REQUIRED. A string that specifies the format of the requested Verifiable Credential.")
705
+ format: v9.pipe(
706
+ v9.literal("mso_mdoc"),
707
+ v9.description("REQUIRED. A string that specifies the format of the requested Verifiable Credential.")
607
708
  ),
608
- claims: v8.pipe(
609
- v8.optional(v8.pipe(v8.array(DcqlClaimsQuery.vMdoc), vNonEmptyArray())),
610
- v8.description("OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.")
709
+ claims: v9.pipe(
710
+ v9.optional(v9.pipe(v9.array(DcqlClaimsQuery.vMdoc), vNonEmptyArray())),
711
+ v9.description("OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.")
611
712
  ),
612
- meta: v8.pipe(
613
- v8.optional(
614
- v8.object({
615
- doctype_value: v8.pipe(
616
- v8.optional(v8.string()),
617
- v8.description(
713
+ meta: v9.pipe(
714
+ v9.optional(
715
+ v9.object({
716
+ doctype_value: v9.pipe(
717
+ v9.optional(v9.string()),
718
+ v9.description(
618
719
  "OPTIONAL. String that specifies an allowed value for the doctype of the requested Verifiable Credential."
619
720
  )
620
721
  )
621
722
  })
622
723
  ),
623
- v8.description(
724
+ v9.description(
624
725
  "OPTIONAL. An object defining additional properties requested by the Verifier that apply to the metadata and validity data of the Credential."
625
726
  )
626
727
  )
627
728
  });
628
- DcqlCredentialQuery2.vSdJwtVc = v8.object({
729
+ DcqlCredentialQuery2.vSdJwtVc = v9.object({
629
730
  ...vBase.entries,
630
- format: v8.pipe(
631
- v8.picklist(["vc+sd-jwt", "dc+sd-jwt"]),
632
- v8.description("REQUIRED. A string that specifies the format of the requested Verifiable Credential.")
731
+ format: v9.pipe(
732
+ v9.picklist(["vc+sd-jwt", "dc+sd-jwt"]),
733
+ v9.description("REQUIRED. A string that specifies the format of the requested Verifiable Credential.")
633
734
  ),
634
- claims: v8.pipe(
635
- v8.optional(v8.pipe(v8.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),
636
- v8.description("OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.")
735
+ claims: v9.pipe(
736
+ v9.optional(v9.pipe(v9.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),
737
+ v9.description("OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.")
637
738
  ),
638
- meta: v8.pipe(
639
- v8.optional(
640
- v8.pipe(
641
- v8.object({
642
- vct_values: v8.optional(v8.array(v8.string()))
739
+ meta: v9.pipe(
740
+ v9.optional(
741
+ v9.pipe(
742
+ v9.object({
743
+ vct_values: v9.optional(v9.array(v9.string()))
643
744
  }),
644
- v8.description(
745
+ v9.description(
645
746
  "OPTIONAL. An array of strings that specifies allowed values for the type of the requested Verifiable Credential."
646
747
  )
647
748
  )
648
749
  ),
649
- v8.description(
750
+ v9.description(
650
751
  "OPTIONAL. An object defining additional properties requested by the Verifier that apply to the metadata and validity data of the Credential."
651
752
  )
652
753
  )
653
754
  });
654
- DcqlCredentialQuery2.vW3cVc = v8.object({
755
+ DcqlCredentialQuery2.vW3cVc = v9.object({
655
756
  ...vBase.entries,
656
- format: v8.picklist(["jwt_vc_json", "ldp_vc"]),
657
- claims: v8.optional(v8.pipe(v8.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),
658
- meta: v8.pipe(
659
- v8.pipe(
660
- v8.object({
661
- type_values: v8.pipe(
662
- v8.array(v8.pipe(v8.array(v8.string()), vNonEmptyArray())),
757
+ format: v9.picklist(["jwt_vc_json", "ldp_vc"]),
758
+ claims: v9.optional(v9.pipe(v9.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),
759
+ meta: v9.pipe(
760
+ v9.pipe(
761
+ v9.object({
762
+ type_values: v9.pipe(
763
+ v9.array(v9.pipe(v9.array(v9.string()), vNonEmptyArray())),
663
764
  vNonEmptyArray(),
664
- v8.description(
765
+ v9.description(
665
766
  "REQUIRED. An array of string arrays that specifies the fully expanded types (IRIs) after the @context was applied that the Verifier accepts to be presented in the Presentation. Each of the top-level arrays specifies one alternative to match the type values of the Verifiable Credential against. Each inner array specifies a set of fully expanded types that MUST be present in the type property of the Verifiable Credential, regardless of order or the presence of additional types."
666
767
  )
667
768
  )
668
769
  })
669
770
  ),
670
- v8.description(
771
+ v9.description(
671
772
  "REQUIRED. An object defining additional properties requested by the Verifier that apply to the metadata and validity data of the Credential."
672
773
  )
673
774
  )
674
775
  });
675
- DcqlCredentialQuery2.vModel = v8.variant("format", [DcqlCredentialQuery2.vMdoc, DcqlCredentialQuery2.vSdJwtVc, DcqlCredentialQuery2.vW3cVc]);
776
+ DcqlCredentialQuery2.vModel = v9.variant("format", [DcqlCredentialQuery2.vMdoc, DcqlCredentialQuery2.vSdJwtVc, DcqlCredentialQuery2.vW3cVc]);
676
777
  DcqlCredentialQuery2.validate = (credentialQuery) => {
677
778
  claimSetIdsAreDefined(credentialQuery);
678
779
  };
@@ -696,26 +797,26 @@ var claimSetIdsAreDefined = (credentialQuery) => {
696
797
  };
697
798
 
698
799
  // src/dcql-query/m-dcql-credential-set-query.ts
699
- import * as v9 from "valibot";
800
+ import * as v10 from "valibot";
700
801
  var CredentialSetQuery;
701
802
  ((CredentialSetQuery2) => {
702
- CredentialSetQuery2.vModel = v9.object({
703
- options: v9.pipe(
704
- v9.array(v9.array(vIdString)),
803
+ CredentialSetQuery2.vModel = v10.object({
804
+ options: v10.pipe(
805
+ v10.array(v10.array(vIdString)),
705
806
  vNonEmptyArray(),
706
- v9.description(
807
+ v10.description(
707
808
  "REQUIRED. A non-empty array, where each value in the array is a list of Credential Query identifiers representing one set of Credentials that satisfies the use case."
708
809
  )
709
810
  ),
710
- required: v9.pipe(
711
- v9.optional(v9.boolean(), true),
712
- v9.description(
811
+ required: v10.pipe(
812
+ v10.optional(v10.boolean(), true),
813
+ v10.description(
713
814
  `OPTIONAL. Boolean which indicates whether this set of Credentials is required to satisfy the particular use case at the Verifier. If omitted, the default value is 'true'.`
714
815
  )
715
816
  ),
716
- purpose: v9.pipe(
717
- v9.optional(v9.union([v9.string(), v9.number(), v9.record(v9.string(), v9.unknown())])),
718
- v9.description("OPTIONAL. A string, number or object specifying the purpose of the query.")
817
+ purpose: v10.pipe(
818
+ v10.optional(v10.union([v10.string(), v10.number(), v10.record(v10.string(), v10.unknown())])),
819
+ v10.description("OPTIONAL. A string, number or object specifying the purpose of the query.")
719
820
  )
720
821
  });
721
822
  })(CredentialSetQuery || (CredentialSetQuery = {}));
@@ -723,39 +824,39 @@ var CredentialSetQuery;
723
824
  // src/dcql-query-result/m-dcql-query-result.ts
724
825
  var DcqlQueryResult;
725
826
  ((DcqlQueryResult2) => {
726
- DcqlQueryResult2.vCredentialQueryResult = v10.pipe(
727
- v10.array(v10.array(v10.union([v10.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure]))),
827
+ DcqlQueryResult2.vCredentialQueryResult = v11.pipe(
828
+ v11.array(v11.array(v11.union([v11.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure]))),
728
829
  vNonEmptyArray()
729
830
  );
730
- DcqlQueryResult2.vModel = v10.object({
731
- credentials: v10.pipe(
732
- v10.array(DcqlCredentialQuery.vModel),
831
+ DcqlQueryResult2.vModel = v11.object({
832
+ credentials: v11.pipe(
833
+ v11.array(DcqlCredentialQuery.vModel),
733
834
  vNonEmptyArray(),
734
- v10.description(
835
+ v11.description(
735
836
  "REQUIRED. A non-empty array of Credential Queries that specify the requested Verifiable Credentials."
736
837
  )
737
838
  ),
738
- credential_matches: v10.record(
739
- v10.pipe(vIdString),
740
- v10.union([
741
- v10.object({
839
+ credential_matches: v11.record(
840
+ v11.pipe(vIdString),
841
+ v11.union([
842
+ v11.object({
742
843
  ...DcqlCredential.vParseSuccess.entries,
743
- all: v10.pipe(
744
- v10.array(
745
- v10.pipe(
746
- v10.array(v10.union([v10.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),
844
+ all: v11.pipe(
845
+ v11.array(
846
+ v11.pipe(
847
+ v11.array(v11.union([v11.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),
747
848
  vNonEmptyArray()
748
849
  )
749
850
  ),
750
851
  vNonEmptyArray()
751
852
  )
752
853
  }),
753
- v10.object({
854
+ v11.object({
754
855
  success: DcqlCredential.vParseFailure.entries.success,
755
- all: v10.pipe(
756
- v10.array(
757
- v10.pipe(
758
- v10.array(v10.union([v10.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),
856
+ all: v11.pipe(
857
+ v11.array(
858
+ v11.pipe(
859
+ v11.array(v11.union([v11.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),
759
860
  vNonEmptyArray()
760
861
  )
761
862
  ),
@@ -764,49 +865,49 @@ var DcqlQueryResult;
764
865
  })
765
866
  ])
766
867
  ),
767
- credential_sets: v10.optional(
768
- v10.pipe(
769
- v10.array(
770
- v10.object({
868
+ credential_sets: v11.optional(
869
+ v11.pipe(
870
+ v11.array(
871
+ v11.object({
771
872
  ...CredentialSetQuery.vModel.entries,
772
- matching_options: v10.union([v10.undefined(), v10.pipe(v10.array(v10.array(v10.string())), vNonEmptyArray())])
873
+ matching_options: v11.union([v11.undefined(), v11.pipe(v11.array(v11.array(v11.string())), vNonEmptyArray())])
773
874
  })
774
875
  ),
775
876
  vNonEmptyArray(),
776
- v10.description(
877
+ v11.description(
777
878
  "OPTIONAL. A non-empty array of credential set queries that specifies additional constraints on which of the requested Verifiable Credentials to return."
778
879
  )
779
880
  )
780
881
  ),
781
- canBeSatisfied: v10.boolean()
882
+ canBeSatisfied: v11.boolean()
782
883
  });
783
884
  })(DcqlQueryResult || (DcqlQueryResult = {}));
784
885
 
785
886
  // src/dcql-presentation/m-dcql-presentation-result.ts
786
887
  var DcqlPresentationResult;
787
888
  ((DcqlPresentationResult2) => {
788
- DcqlPresentationResult2.vModel = v11.object({
789
- ...v11.omit(DcqlQueryResult.vModel, ["credential_matches"]).entries,
790
- invalid_matches: v11.union([
791
- v11.record(
792
- v11.pipe(vIdString),
793
- v11.object({
794
- ...v11.omit(DcqlCredential.vParseFailure, ["input_credential_index"]).entries,
795
- presentation_id: v11.pipe(vIdString)
889
+ DcqlPresentationResult2.vModel = v12.object({
890
+ ...v12.omit(DcqlQueryResult.vModel, ["credential_matches"]).entries,
891
+ invalid_matches: v12.union([
892
+ v12.record(
893
+ v12.pipe(vIdString),
894
+ v12.object({
895
+ ...v12.omit(DcqlCredential.vParseFailure, ["input_credential_index"]).entries,
896
+ presentation_id: v12.pipe(vIdString)
796
897
  })
797
898
  ),
798
- v11.undefined()
899
+ v12.undefined()
799
900
  ]),
800
- valid_matches: v11.record(
801
- v11.pipe(vIdString),
802
- v11.object({
803
- ...v11.omit(DcqlCredential.vParseSuccess, ["issues", "input_credential_index"]).entries,
804
- presentation_id: v11.pipe(vIdString)
901
+ valid_matches: v12.record(
902
+ v12.pipe(vIdString),
903
+ v12.object({
904
+ ...v12.omit(DcqlCredential.vParseSuccess, ["issues", "input_credential_index"]).entries,
905
+ presentation_id: v12.pipe(vIdString)
805
906
  })
806
907
  )
807
908
  });
808
909
  DcqlPresentationResult2.parse = (input) => {
809
- return v11.parse(DcqlPresentationResult2.vModel, input);
910
+ return v12.parse(DcqlPresentationResult2.vModel, input);
810
911
  };
811
912
  DcqlPresentationResult2.fromDcqlPresentation = (dcqlPresentation, ctx) => {
812
913
  const { dcqlQuery } = ctx;
@@ -861,7 +962,7 @@ var DcqlPresentationResult;
861
962
  ...dcqlQuery,
862
963
  canBeSatisfied: dqclQueryMatched,
863
964
  valid_matches: validMatches,
864
- invalid_matches: Object.keys(invalidMatches).length === 0 ? void 0 : {},
965
+ invalid_matches: Object.keys(invalidMatches).length === 0 ? void 0 : invalidMatches,
865
966
  credential_sets: credentialSetResults
866
967
  };
867
968
  };
@@ -877,15 +978,15 @@ var DcqlPresentationResult;
877
978
  })(DcqlPresentationResult || (DcqlPresentationResult = {}));
878
979
 
879
980
  // src/dcql-presentation/m-dcql-presentation.ts
880
- import * as v12 from "valibot";
981
+ import * as v13 from "valibot";
881
982
  var DcqlPresentation;
882
983
  ((DcqlPresentation2) => {
883
- DcqlPresentation2.vModel = v12.record(vIdString, v12.union([v12.string(), vJsonRecord]));
984
+ DcqlPresentation2.vModel = v13.record(vIdString, v13.union([v13.string(), vJsonRecord]));
884
985
  DcqlPresentation2.parse = (input) => {
885
986
  if (typeof input === "string") {
886
- return v12.parse(v12.pipe(v12.string(), vStringToJson, DcqlPresentation2.vModel), input);
987
+ return v13.parse(v13.pipe(v13.string(), vStringToJson, DcqlPresentation2.vModel), input);
887
988
  }
888
- return v12.parse(DcqlPresentation2.vModel, input);
989
+ return v13.parse(DcqlPresentation2.vModel, input);
889
990
  };
890
991
  DcqlPresentation2.encode = (input) => {
891
992
  return JSON.stringify(input);
@@ -937,20 +1038,20 @@ var runDcqlQuery = (dcqlQuery, ctx) => {
937
1038
  };
938
1039
 
939
1040
  // src/dcql-query/m-dcql-query.ts
940
- import * as v13 from "valibot";
1041
+ import * as v14 from "valibot";
941
1042
  var DcqlQuery;
942
1043
  ((DcqlQuery2) => {
943
- DcqlQuery2.vModel = v13.object({
944
- credentials: v13.pipe(
945
- v13.array(DcqlCredentialQuery.vModel),
1044
+ DcqlQuery2.vModel = v14.object({
1045
+ credentials: v14.pipe(
1046
+ v14.array(DcqlCredentialQuery.vModel),
946
1047
  vNonEmptyArray(),
947
- v13.description(
1048
+ v14.description(
948
1049
  "REQUIRED. A non-empty array of Credential Queries that specify the requested Verifiable Credentials."
949
1050
  )
950
1051
  ),
951
- credential_sets: v13.pipe(
952
- v13.optional(v13.pipe(v13.array(CredentialSetQuery.vModel), vNonEmptyArray())),
953
- v13.description(
1052
+ credential_sets: v14.pipe(
1053
+ v14.optional(v14.pipe(v14.array(CredentialSetQuery.vModel), vNonEmptyArray())),
1054
+ v14.description(
954
1055
  "OPTIONAL. A non-empty array of credential set queries that specifies additional constraints on which of the requested Verifiable Credentials to return."
955
1056
  )
956
1057
  )
@@ -964,7 +1065,7 @@ var DcqlQuery;
964
1065
  return runDcqlQuery(dcqlQuery, { credentials, presentation: false });
965
1066
  };
966
1067
  DcqlQuery2.parse = (input) => {
967
- return v13.parse(DcqlQuery2.vModel, input);
1068
+ return v14.parse(DcqlQuery2.vModel, input);
968
1069
  };
969
1070
  })(DcqlQuery || (DcqlQuery = {}));
970
1071
  var validateUniqueCredentialQueryIds = (query) => {
@@ -1002,6 +1103,7 @@ export {
1002
1103
  DcqlCredentialPresentation,
1003
1104
  DcqlCredentialQuery,
1004
1105
  DcqlCredentialSetError,
1106
+ DcqlCredentialTrustedAuthority,
1005
1107
  DcqlError,
1006
1108
  DcqlInvalidClaimsQueryIdError,
1007
1109
  DcqlInvalidPresentationRecordError,
@@ -1017,6 +1119,7 @@ export {
1017
1119
  DcqlQueryResult,
1018
1120
  DcqlSdJwtVcCredential,
1019
1121
  DcqlSdJwtVcPresentation,
1122
+ DcqlTrustedAuthoritiesQuery,
1020
1123
  DcqlUndefinedClaimSetIdError,
1021
1124
  DcqlW3cVcCredential,
1022
1125
  DcqlW3cVcPresentation,