dcql 0.2.20-alpha-20250114153338 → 0.2.20-alpha-20250212083101
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 +10 -4
- package/dist/index.d.mts +647 -298
- package/dist/index.d.ts +647 -298
- package/dist/index.js +136 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -113,7 +113,7 @@ var idRegex = /^[a-zA-Z0-9_-]+$/;
|
|
113
113
|
var vNonEmptyArray = () => {
|
114
114
|
return v.custom((input) => input.length > 0);
|
115
115
|
};
|
116
|
-
var vIdString = v.pipe(v.string(), v.regex(idRegex));
|
116
|
+
var vIdString = v.pipe(v.string(), v.regex(idRegex), v.nonEmpty());
|
117
117
|
function isToJsonable(value) {
|
118
118
|
if (value === null || typeof value !== "object") return false;
|
119
119
|
const toJsonFn = value.toJson;
|
@@ -296,34 +296,130 @@ var DcqlCredentialPresentation;
|
|
296
296
|
import * as v11 from "valibot";
|
297
297
|
|
298
298
|
// src/dcql-parser/dcql-credential-query-result.ts
|
299
|
-
import * as
|
299
|
+
import * as v7 from "valibot";
|
300
300
|
|
301
301
|
// src/dcql-parser/dcql-claims-query-result.ts
|
302
|
+
import * as v6 from "valibot";
|
303
|
+
|
304
|
+
// src/dcql-query/m-dcql-claims-query.ts
|
302
305
|
import * as v5 from "valibot";
|
306
|
+
var DcqlClaimsQuery;
|
307
|
+
((DcqlClaimsQuery2) => {
|
308
|
+
DcqlClaimsQuery2.vValue = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer()), v5.boolean()]);
|
309
|
+
DcqlClaimsQuery2.vPath = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer(), v5.minValue(0)), v5.null()]);
|
310
|
+
DcqlClaimsQuery2.vW3cSdJwtVc = v5.object({
|
311
|
+
id: v5.pipe(
|
312
|
+
v5.optional(vIdString),
|
313
|
+
v5.description(
|
314
|
+
"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."
|
315
|
+
)
|
316
|
+
),
|
317
|
+
path: v5.pipe(
|
318
|
+
v5.array(DcqlClaimsQuery2.vPath),
|
319
|
+
vNonEmptyArray(),
|
320
|
+
v5.description(
|
321
|
+
"A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential."
|
322
|
+
)
|
323
|
+
),
|
324
|
+
values: v5.pipe(
|
325
|
+
v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
|
326
|
+
v5.description(
|
327
|
+
"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."
|
328
|
+
)
|
329
|
+
)
|
330
|
+
});
|
331
|
+
const vMdocBase = v5.object({
|
332
|
+
id: v5.pipe(
|
333
|
+
v5.optional(vIdString),
|
334
|
+
v5.description(
|
335
|
+
"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."
|
336
|
+
)
|
337
|
+
),
|
338
|
+
values: v5.pipe(
|
339
|
+
v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
|
340
|
+
v5.description(
|
341
|
+
"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."
|
342
|
+
)
|
343
|
+
)
|
344
|
+
});
|
345
|
+
DcqlClaimsQuery2.vMdocNamespace = v5.object({
|
346
|
+
...vMdocBase.entries,
|
347
|
+
namespace: v5.pipe(
|
348
|
+
v5.string(),
|
349
|
+
v5.description(
|
350
|
+
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
351
|
+
)
|
352
|
+
),
|
353
|
+
claim_name: v5.pipe(
|
354
|
+
v5.string(),
|
355
|
+
v5.description(
|
356
|
+
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
357
|
+
)
|
358
|
+
)
|
359
|
+
});
|
360
|
+
DcqlClaimsQuery2.vMdocPath = v5.object({
|
361
|
+
...vMdocBase.entries,
|
362
|
+
intent_to_retain: v5.pipe(
|
363
|
+
v5.optional(v5.boolean()),
|
364
|
+
v5.description(
|
365
|
+
"A boolean that is equivalent to `IntentToRetain` variable defined in Section 8.3.2.1.2.1 of [@ISO.18013-5]."
|
366
|
+
)
|
367
|
+
),
|
368
|
+
path: v5.pipe(
|
369
|
+
v5.tuple([
|
370
|
+
v5.pipe(
|
371
|
+
v5.string(),
|
372
|
+
v5.description(
|
373
|
+
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
374
|
+
)
|
375
|
+
),
|
376
|
+
v5.pipe(
|
377
|
+
v5.string(),
|
378
|
+
v5.description(
|
379
|
+
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
380
|
+
)
|
381
|
+
)
|
382
|
+
]),
|
383
|
+
v5.description(
|
384
|
+
"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."
|
385
|
+
)
|
386
|
+
)
|
387
|
+
});
|
388
|
+
DcqlClaimsQuery2.vMdoc = v5.union([DcqlClaimsQuery2.vMdocNamespace, DcqlClaimsQuery2.vMdocPath]);
|
389
|
+
DcqlClaimsQuery2.vModel = v5.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
|
390
|
+
})(DcqlClaimsQuery || (DcqlClaimsQuery = {}));
|
391
|
+
|
392
|
+
// src/dcql-parser/dcql-claims-query-result.ts
|
303
393
|
var getClaimParser = (input) => {
|
304
394
|
const { value, values } = input;
|
305
395
|
if (value) {
|
306
|
-
return vWithJT(
|
396
|
+
return vWithJT(v6.literal(value));
|
307
397
|
}
|
308
398
|
if (values) {
|
309
|
-
return vWithJT(
|
399
|
+
return vWithJT(v6.union(values.map((val) => v6.literal(val))));
|
310
400
|
}
|
311
|
-
return
|
401
|
+
return v6.nonNullish(v6.any());
|
312
402
|
};
|
313
403
|
var getNamespacesParser = (claimsQueries) => {
|
314
404
|
const claimsForNamespace = {};
|
315
405
|
for (const claimQuery of claimsQueries) {
|
316
|
-
|
317
|
-
|
406
|
+
const mdocPathQuery = v6.is(DcqlClaimsQuery.vMdocNamespace, claimQuery) ? {
|
407
|
+
id: claimQuery.id,
|
408
|
+
path: [claimQuery.namespace, claimQuery.claim_name],
|
409
|
+
values: claimQuery.values
|
410
|
+
} : claimQuery;
|
411
|
+
const namespace = mdocPathQuery.path[0];
|
412
|
+
if (claimsForNamespace[namespace]) {
|
413
|
+
claimsForNamespace[namespace]?.push({ ...mdocPathQuery });
|
318
414
|
} else {
|
319
|
-
claimsForNamespace[
|
415
|
+
claimsForNamespace[namespace] = [{ ...mdocPathQuery }];
|
320
416
|
}
|
321
417
|
}
|
322
418
|
const parsersForNamespaces = Object.entries(claimsForNamespace).map(([namespace, claims]) => {
|
323
|
-
const claimParsers = Object.fromEntries(claims.map((claim) => [claim.
|
324
|
-
return [namespace,
|
419
|
+
const claimParsers = Object.fromEntries(claims.map((claim) => [claim.path[1], getClaimParser(claim)]));
|
420
|
+
return [namespace, v6.object(claimParsers)];
|
325
421
|
});
|
326
|
-
return
|
422
|
+
return v6.object(Object.fromEntries(parsersForNamespaces));
|
327
423
|
};
|
328
424
|
var getClaimQueryParser = (claimQuery, ctx) => {
|
329
425
|
const { index, presentation } = ctx;
|
@@ -333,31 +429,31 @@ var getClaimQueryParser = (claimQuery, ctx) => {
|
|
333
429
|
if (typeof pathElement === "number") {
|
334
430
|
const elementParser = isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 });
|
335
431
|
if (presentation) {
|
336
|
-
return
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
432
|
+
return v6.union([
|
433
|
+
v6.pipe(
|
434
|
+
v6.array(vJson),
|
435
|
+
v6.length(1),
|
436
|
+
v6.transform((input) => input[0]),
|
341
437
|
elementParser
|
342
438
|
),
|
343
439
|
elementParser
|
344
440
|
]);
|
345
441
|
}
|
346
|
-
return
|
347
|
-
|
348
|
-
|
442
|
+
return v6.pipe(
|
443
|
+
v6.array(vJson),
|
444
|
+
v6.transform((input) => input[pathElement]),
|
349
445
|
elementParser
|
350
446
|
);
|
351
447
|
}
|
352
448
|
if (typeof pathElement === "string") {
|
353
|
-
return
|
449
|
+
return v6.object({
|
354
450
|
[pathElement]: isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 })
|
355
451
|
});
|
356
452
|
}
|
357
|
-
return isLast ?
|
453
|
+
return isLast ? v6.array(vClaimParser) : v6.array(getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }));
|
358
454
|
};
|
359
455
|
var getJsonClaimsParser = (claimsQueries, ctx) => {
|
360
|
-
const claimParser =
|
456
|
+
const claimParser = v6.intersect(
|
361
457
|
claimsQueries.map(
|
362
458
|
(claimQuery) => getClaimQueryParser(claimQuery, {
|
363
459
|
...ctx,
|
@@ -391,12 +487,12 @@ var getJsonClaimsQueriesForClaimSet = (claimsQueries, claimSet) => {
|
|
391
487
|
};
|
392
488
|
var getMdocParser = (credentialQuery, ctx) => {
|
393
489
|
const { claimSet } = ctx;
|
394
|
-
const vDoctype = credentialQuery.meta?.doctype_value ?
|
490
|
+
const vDoctype = credentialQuery.meta?.doctype_value ? v6.literal(credentialQuery.meta.doctype_value) : v6.string();
|
395
491
|
const claimSetQueries = credentialQuery.claims && claimSet ? getMdocClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
|
396
|
-
const credentialParser =
|
397
|
-
credential_format:
|
492
|
+
const credentialParser = v6.object({
|
493
|
+
credential_format: v6.literal("mso_mdoc"),
|
398
494
|
doctype: vDoctype,
|
399
|
-
namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) :
|
495
|
+
namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) : v6.record(v6.string(), v6.record(v6.string(), v6.unknown()))
|
400
496
|
});
|
401
497
|
return credentialParser;
|
402
498
|
};
|
@@ -404,14 +500,14 @@ var getW3cVcSdJwtVcParser = (credentialQuery, ctx) => {
|
|
404
500
|
const { claimSet } = ctx;
|
405
501
|
const claimSetQueries = credentialQuery.claims && claimSet ? getJsonClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
|
406
502
|
if (credentialQuery.format === "vc+sd-jwt" || credentialQuery.format === "dc+sd-jwt") {
|
407
|
-
return
|
408
|
-
credential_format:
|
409
|
-
vct: credentialQuery.meta?.vct_values ?
|
503
|
+
return v6.object({
|
504
|
+
credential_format: v6.literal(credentialQuery.format),
|
505
|
+
vct: credentialQuery.meta?.vct_values ? v6.picklist(credentialQuery.meta.vct_values) : v6.string(),
|
410
506
|
claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord
|
411
507
|
});
|
412
508
|
}
|
413
|
-
const credentialParser =
|
414
|
-
credential_format:
|
509
|
+
const credentialParser = v6.object({
|
510
|
+
credential_format: v6.picklist(["jwt_vc_json", "jwt_vc_json-ld"]),
|
415
511
|
claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord
|
416
512
|
});
|
417
513
|
return credentialParser;
|
@@ -448,11 +544,11 @@ var runCredentialQuery = (credentialQuery, ctx) => {
|
|
448
544
|
continue;
|
449
545
|
}
|
450
546
|
}
|
451
|
-
const parseResult =
|
547
|
+
const parseResult = v7.safeParse(credentialParser, credential);
|
452
548
|
credentialQueryResult[claimSetIndex]?.push({
|
453
549
|
...parseResult,
|
454
550
|
...parseResult.issues && {
|
455
|
-
flattened:
|
551
|
+
flattened: v7.flatten(parseResult.issues)
|
456
552
|
},
|
457
553
|
input_credential_index: credentialIndex,
|
458
554
|
claim_set_index: credentialQuery.claim_sets ? claimSetIndex : void 0
|
@@ -467,63 +563,6 @@ import * as v10 from "valibot";
|
|
467
563
|
|
468
564
|
// src/dcql-query/m-dcql-credential-query.ts
|
469
565
|
import * as v8 from "valibot";
|
470
|
-
|
471
|
-
// src/dcql-query/m-dcql-claims-query.ts
|
472
|
-
import * as v7 from "valibot";
|
473
|
-
var DcqlClaimsQuery;
|
474
|
-
((DcqlClaimsQuery2) => {
|
475
|
-
DcqlClaimsQuery2.vValue = v7.union([v7.string(), v7.pipe(v7.number(), v7.integer()), v7.boolean()]);
|
476
|
-
DcqlClaimsQuery2.vPath = v7.union([v7.string(), v7.pipe(v7.number(), v7.integer(), v7.minValue(0)), v7.null()]);
|
477
|
-
DcqlClaimsQuery2.vW3cSdJwtVc = v7.object({
|
478
|
-
id: v7.pipe(
|
479
|
-
v7.optional(v7.pipe(v7.string(), v7.regex(idRegex))),
|
480
|
-
v7.description(
|
481
|
-
"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."
|
482
|
-
)
|
483
|
-
),
|
484
|
-
path: v7.pipe(
|
485
|
-
v7.array(DcqlClaimsQuery2.vPath),
|
486
|
-
v7.description(
|
487
|
-
"A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential."
|
488
|
-
)
|
489
|
-
),
|
490
|
-
values: v7.pipe(
|
491
|
-
v7.optional(v7.array(DcqlClaimsQuery2.vValue)),
|
492
|
-
v7.description(
|
493
|
-
"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."
|
494
|
-
)
|
495
|
-
)
|
496
|
-
});
|
497
|
-
DcqlClaimsQuery2.vMdoc = v7.object({
|
498
|
-
id: v7.pipe(
|
499
|
-
v7.optional(v7.pipe(v7.string(), v7.regex(idRegex))),
|
500
|
-
v7.description(
|
501
|
-
"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."
|
502
|
-
)
|
503
|
-
),
|
504
|
-
namespace: v7.pipe(
|
505
|
-
v7.string(),
|
506
|
-
v7.description(
|
507
|
-
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
508
|
-
)
|
509
|
-
),
|
510
|
-
claim_name: v7.pipe(
|
511
|
-
v7.string(),
|
512
|
-
v7.description(
|
513
|
-
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
514
|
-
)
|
515
|
-
),
|
516
|
-
values: v7.pipe(
|
517
|
-
v7.optional(v7.array(DcqlClaimsQuery2.vValue)),
|
518
|
-
v7.description(
|
519
|
-
"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."
|
520
|
-
)
|
521
|
-
)
|
522
|
-
});
|
523
|
-
DcqlClaimsQuery2.vModel = v7.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
|
524
|
-
})(DcqlClaimsQuery || (DcqlClaimsQuery = {}));
|
525
|
-
|
526
|
-
// src/dcql-query/m-dcql-credential-query.ts
|
527
566
|
var DcqlCredentialQuery;
|
528
567
|
((DcqlCredentialQuery2) => {
|
529
568
|
const vBase = v8.object({
|
@@ -535,7 +574,7 @@ var DcqlCredentialQuery;
|
|
535
574
|
)
|
536
575
|
),
|
537
576
|
claim_sets: v8.pipe(
|
538
|
-
v8.optional(v8.pipe(v8.array(v8.
|
577
|
+
v8.optional(v8.pipe(v8.array(v8.pipe(v8.array(vIdString), vNonEmptyArray())), vNonEmptyArray())),
|
539
578
|
v8.description(
|
540
579
|
`OPTIONAL. A non-empty array containing arrays of identifiers for elements in 'claims' that specifies which combinations of 'claims' for the Credential are requested.`
|
541
580
|
)
|
@@ -662,7 +701,7 @@ var DcqlQueryResult;
|
|
662
701
|
)
|
663
702
|
),
|
664
703
|
credential_matches: v10.record(
|
665
|
-
v10.pipe(
|
704
|
+
v10.pipe(vIdString),
|
666
705
|
v10.union([
|
667
706
|
v10.object({
|
668
707
|
...DcqlCredential.vParseSuccess.entries,
|
@@ -715,19 +754,19 @@ var DcqlPresentationResult;
|
|
715
754
|
...v11.omit(DcqlQueryResult.vModel, ["credential_matches"]).entries,
|
716
755
|
invalid_matches: v11.union([
|
717
756
|
v11.record(
|
718
|
-
v11.pipe(
|
757
|
+
v11.pipe(vIdString),
|
719
758
|
v11.object({
|
720
759
|
...v11.omit(DcqlCredential.vParseFailure, ["input_credential_index"]).entries,
|
721
|
-
presentation_id: v11.pipe(
|
760
|
+
presentation_id: v11.pipe(vIdString)
|
722
761
|
})
|
723
762
|
),
|
724
763
|
v11.undefined()
|
725
764
|
]),
|
726
765
|
valid_matches: v11.record(
|
727
|
-
v11.pipe(
|
766
|
+
v11.pipe(vIdString),
|
728
767
|
v11.object({
|
729
768
|
...v11.omit(DcqlCredential.vParseSuccess, ["issues", "input_credential_index"]).entries,
|
730
|
-
presentation_id: v11.pipe(
|
769
|
+
presentation_id: v11.pipe(vIdString)
|
731
770
|
})
|
732
771
|
)
|
733
772
|
});
|
@@ -804,7 +843,7 @@ var DcqlPresentationResult;
|
|
804
843
|
import * as v12 from "valibot";
|
805
844
|
var DcqlPresentation;
|
806
845
|
((DcqlPresentation2) => {
|
807
|
-
DcqlPresentation2.vModel = v12.record(
|
846
|
+
DcqlPresentation2.vModel = v12.record(vIdString, v12.union([v12.string(), vJsonRecord]));
|
808
847
|
DcqlPresentation2.parse = (input) => {
|
809
848
|
if (typeof input === "string") {
|
810
849
|
return v12.parse(v12.pipe(v12.string(), vStringToJson, DcqlPresentation2.vModel), input);
|