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.js
CHANGED
@@ -175,7 +175,7 @@ var idRegex = /^[a-zA-Z0-9_-]+$/;
|
|
175
175
|
var vNonEmptyArray = () => {
|
176
176
|
return v.custom((input) => input.length > 0);
|
177
177
|
};
|
178
|
-
var vIdString = v.pipe(v.string(), v.regex(idRegex));
|
178
|
+
var vIdString = v.pipe(v.string(), v.regex(idRegex), v.nonEmpty());
|
179
179
|
function isToJsonable(value) {
|
180
180
|
if (value === null || typeof value !== "object") return false;
|
181
181
|
const toJsonFn = value.toJson;
|
@@ -358,34 +358,130 @@ var DcqlCredentialPresentation;
|
|
358
358
|
var v11 = __toESM(require("valibot"));
|
359
359
|
|
360
360
|
// src/dcql-parser/dcql-credential-query-result.ts
|
361
|
-
var
|
361
|
+
var v7 = __toESM(require("valibot"));
|
362
362
|
|
363
363
|
// src/dcql-parser/dcql-claims-query-result.ts
|
364
|
+
var v6 = __toESM(require("valibot"));
|
365
|
+
|
366
|
+
// src/dcql-query/m-dcql-claims-query.ts
|
364
367
|
var v5 = __toESM(require("valibot"));
|
368
|
+
var DcqlClaimsQuery;
|
369
|
+
((DcqlClaimsQuery2) => {
|
370
|
+
DcqlClaimsQuery2.vValue = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer()), v5.boolean()]);
|
371
|
+
DcqlClaimsQuery2.vPath = v5.union([v5.string(), v5.pipe(v5.number(), v5.integer(), v5.minValue(0)), v5.null()]);
|
372
|
+
DcqlClaimsQuery2.vW3cSdJwtVc = v5.object({
|
373
|
+
id: v5.pipe(
|
374
|
+
v5.optional(vIdString),
|
375
|
+
v5.description(
|
376
|
+
"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."
|
377
|
+
)
|
378
|
+
),
|
379
|
+
path: v5.pipe(
|
380
|
+
v5.array(DcqlClaimsQuery2.vPath),
|
381
|
+
vNonEmptyArray(),
|
382
|
+
v5.description(
|
383
|
+
"A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential."
|
384
|
+
)
|
385
|
+
),
|
386
|
+
values: v5.pipe(
|
387
|
+
v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
|
388
|
+
v5.description(
|
389
|
+
"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."
|
390
|
+
)
|
391
|
+
)
|
392
|
+
});
|
393
|
+
const vMdocBase = v5.object({
|
394
|
+
id: v5.pipe(
|
395
|
+
v5.optional(vIdString),
|
396
|
+
v5.description(
|
397
|
+
"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."
|
398
|
+
)
|
399
|
+
),
|
400
|
+
values: v5.pipe(
|
401
|
+
v5.optional(v5.array(DcqlClaimsQuery2.vValue)),
|
402
|
+
v5.description(
|
403
|
+
"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."
|
404
|
+
)
|
405
|
+
)
|
406
|
+
});
|
407
|
+
DcqlClaimsQuery2.vMdocNamespace = v5.object({
|
408
|
+
...vMdocBase.entries,
|
409
|
+
namespace: v5.pipe(
|
410
|
+
v5.string(),
|
411
|
+
v5.description(
|
412
|
+
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
413
|
+
)
|
414
|
+
),
|
415
|
+
claim_name: v5.pipe(
|
416
|
+
v5.string(),
|
417
|
+
v5.description(
|
418
|
+
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
419
|
+
)
|
420
|
+
)
|
421
|
+
});
|
422
|
+
DcqlClaimsQuery2.vMdocPath = v5.object({
|
423
|
+
...vMdocBase.entries,
|
424
|
+
intent_to_retain: v5.pipe(
|
425
|
+
v5.optional(v5.boolean()),
|
426
|
+
v5.description(
|
427
|
+
"A boolean that is equivalent to `IntentToRetain` variable defined in Section 8.3.2.1.2.1 of [@ISO.18013-5]."
|
428
|
+
)
|
429
|
+
),
|
430
|
+
path: v5.pipe(
|
431
|
+
v5.tuple([
|
432
|
+
v5.pipe(
|
433
|
+
v5.string(),
|
434
|
+
v5.description(
|
435
|
+
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
436
|
+
)
|
437
|
+
),
|
438
|
+
v5.pipe(
|
439
|
+
v5.string(),
|
440
|
+
v5.description(
|
441
|
+
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
442
|
+
)
|
443
|
+
)
|
444
|
+
]),
|
445
|
+
v5.description(
|
446
|
+
"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."
|
447
|
+
)
|
448
|
+
)
|
449
|
+
});
|
450
|
+
DcqlClaimsQuery2.vMdoc = v5.union([DcqlClaimsQuery2.vMdocNamespace, DcqlClaimsQuery2.vMdocPath]);
|
451
|
+
DcqlClaimsQuery2.vModel = v5.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
|
452
|
+
})(DcqlClaimsQuery || (DcqlClaimsQuery = {}));
|
453
|
+
|
454
|
+
// src/dcql-parser/dcql-claims-query-result.ts
|
365
455
|
var getClaimParser = (input) => {
|
366
456
|
const { value, values } = input;
|
367
457
|
if (value) {
|
368
|
-
return vWithJT(
|
458
|
+
return vWithJT(v6.literal(value));
|
369
459
|
}
|
370
460
|
if (values) {
|
371
|
-
return vWithJT(
|
461
|
+
return vWithJT(v6.union(values.map((val) => v6.literal(val))));
|
372
462
|
}
|
373
|
-
return
|
463
|
+
return v6.nonNullish(v6.any());
|
374
464
|
};
|
375
465
|
var getNamespacesParser = (claimsQueries) => {
|
376
466
|
const claimsForNamespace = {};
|
377
467
|
for (const claimQuery of claimsQueries) {
|
378
|
-
|
379
|
-
|
468
|
+
const mdocPathQuery = v6.is(DcqlClaimsQuery.vMdocNamespace, claimQuery) ? {
|
469
|
+
id: claimQuery.id,
|
470
|
+
path: [claimQuery.namespace, claimQuery.claim_name],
|
471
|
+
values: claimQuery.values
|
472
|
+
} : claimQuery;
|
473
|
+
const namespace = mdocPathQuery.path[0];
|
474
|
+
if (claimsForNamespace[namespace]) {
|
475
|
+
claimsForNamespace[namespace]?.push({ ...mdocPathQuery });
|
380
476
|
} else {
|
381
|
-
claimsForNamespace[
|
477
|
+
claimsForNamespace[namespace] = [{ ...mdocPathQuery }];
|
382
478
|
}
|
383
479
|
}
|
384
480
|
const parsersForNamespaces = Object.entries(claimsForNamespace).map(([namespace, claims]) => {
|
385
|
-
const claimParsers = Object.fromEntries(claims.map((claim) => [claim.
|
386
|
-
return [namespace,
|
481
|
+
const claimParsers = Object.fromEntries(claims.map((claim) => [claim.path[1], getClaimParser(claim)]));
|
482
|
+
return [namespace, v6.object(claimParsers)];
|
387
483
|
});
|
388
|
-
return
|
484
|
+
return v6.object(Object.fromEntries(parsersForNamespaces));
|
389
485
|
};
|
390
486
|
var getClaimQueryParser = (claimQuery, ctx) => {
|
391
487
|
const { index, presentation } = ctx;
|
@@ -395,31 +491,31 @@ var getClaimQueryParser = (claimQuery, ctx) => {
|
|
395
491
|
if (typeof pathElement === "number") {
|
396
492
|
const elementParser = isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 });
|
397
493
|
if (presentation) {
|
398
|
-
return
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
494
|
+
return v6.union([
|
495
|
+
v6.pipe(
|
496
|
+
v6.array(vJson),
|
497
|
+
v6.length(1),
|
498
|
+
v6.transform((input) => input[0]),
|
403
499
|
elementParser
|
404
500
|
),
|
405
501
|
elementParser
|
406
502
|
]);
|
407
503
|
}
|
408
|
-
return
|
409
|
-
|
410
|
-
|
504
|
+
return v6.pipe(
|
505
|
+
v6.array(vJson),
|
506
|
+
v6.transform((input) => input[pathElement]),
|
411
507
|
elementParser
|
412
508
|
);
|
413
509
|
}
|
414
510
|
if (typeof pathElement === "string") {
|
415
|
-
return
|
511
|
+
return v6.object({
|
416
512
|
[pathElement]: isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 })
|
417
513
|
});
|
418
514
|
}
|
419
|
-
return isLast ?
|
515
|
+
return isLast ? v6.array(vClaimParser) : v6.array(getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }));
|
420
516
|
};
|
421
517
|
var getJsonClaimsParser = (claimsQueries, ctx) => {
|
422
|
-
const claimParser =
|
518
|
+
const claimParser = v6.intersect(
|
423
519
|
claimsQueries.map(
|
424
520
|
(claimQuery) => getClaimQueryParser(claimQuery, {
|
425
521
|
...ctx,
|
@@ -453,12 +549,12 @@ var getJsonClaimsQueriesForClaimSet = (claimsQueries, claimSet) => {
|
|
453
549
|
};
|
454
550
|
var getMdocParser = (credentialQuery, ctx) => {
|
455
551
|
const { claimSet } = ctx;
|
456
|
-
const vDoctype = credentialQuery.meta?.doctype_value ?
|
552
|
+
const vDoctype = credentialQuery.meta?.doctype_value ? v6.literal(credentialQuery.meta.doctype_value) : v6.string();
|
457
553
|
const claimSetQueries = credentialQuery.claims && claimSet ? getMdocClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
|
458
|
-
const credentialParser =
|
459
|
-
credential_format:
|
554
|
+
const credentialParser = v6.object({
|
555
|
+
credential_format: v6.literal("mso_mdoc"),
|
460
556
|
doctype: vDoctype,
|
461
|
-
namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) :
|
557
|
+
namespaces: claimSetQueries ? getNamespacesParser(claimSetQueries) : v6.record(v6.string(), v6.record(v6.string(), v6.unknown()))
|
462
558
|
});
|
463
559
|
return credentialParser;
|
464
560
|
};
|
@@ -466,14 +562,14 @@ var getW3cVcSdJwtVcParser = (credentialQuery, ctx) => {
|
|
466
562
|
const { claimSet } = ctx;
|
467
563
|
const claimSetQueries = credentialQuery.claims && claimSet ? getJsonClaimsQueriesForClaimSet(credentialQuery.claims, claimSet) : credentialQuery.claims;
|
468
564
|
if (credentialQuery.format === "vc+sd-jwt" || credentialQuery.format === "dc+sd-jwt") {
|
469
|
-
return
|
470
|
-
credential_format:
|
471
|
-
vct: credentialQuery.meta?.vct_values ?
|
565
|
+
return v6.object({
|
566
|
+
credential_format: v6.literal(credentialQuery.format),
|
567
|
+
vct: credentialQuery.meta?.vct_values ? v6.picklist(credentialQuery.meta.vct_values) : v6.string(),
|
472
568
|
claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord
|
473
569
|
});
|
474
570
|
}
|
475
|
-
const credentialParser =
|
476
|
-
credential_format:
|
571
|
+
const credentialParser = v6.object({
|
572
|
+
credential_format: v6.picklist(["jwt_vc_json", "jwt_vc_json-ld"]),
|
477
573
|
claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord
|
478
574
|
});
|
479
575
|
return credentialParser;
|
@@ -510,11 +606,11 @@ var runCredentialQuery = (credentialQuery, ctx) => {
|
|
510
606
|
continue;
|
511
607
|
}
|
512
608
|
}
|
513
|
-
const parseResult =
|
609
|
+
const parseResult = v7.safeParse(credentialParser, credential);
|
514
610
|
credentialQueryResult[claimSetIndex]?.push({
|
515
611
|
...parseResult,
|
516
612
|
...parseResult.issues && {
|
517
|
-
flattened:
|
613
|
+
flattened: v7.flatten(parseResult.issues)
|
518
614
|
},
|
519
615
|
input_credential_index: credentialIndex,
|
520
616
|
claim_set_index: credentialQuery.claim_sets ? claimSetIndex : void 0
|
@@ -529,63 +625,6 @@ var v10 = __toESM(require("valibot"));
|
|
529
625
|
|
530
626
|
// src/dcql-query/m-dcql-credential-query.ts
|
531
627
|
var v8 = __toESM(require("valibot"));
|
532
|
-
|
533
|
-
// src/dcql-query/m-dcql-claims-query.ts
|
534
|
-
var v7 = __toESM(require("valibot"));
|
535
|
-
var DcqlClaimsQuery;
|
536
|
-
((DcqlClaimsQuery2) => {
|
537
|
-
DcqlClaimsQuery2.vValue = v7.union([v7.string(), v7.pipe(v7.number(), v7.integer()), v7.boolean()]);
|
538
|
-
DcqlClaimsQuery2.vPath = v7.union([v7.string(), v7.pipe(v7.number(), v7.integer(), v7.minValue(0)), v7.null()]);
|
539
|
-
DcqlClaimsQuery2.vW3cSdJwtVc = v7.object({
|
540
|
-
id: v7.pipe(
|
541
|
-
v7.optional(v7.pipe(v7.string(), v7.regex(idRegex))),
|
542
|
-
v7.description(
|
543
|
-
"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."
|
544
|
-
)
|
545
|
-
),
|
546
|
-
path: v7.pipe(
|
547
|
-
v7.array(DcqlClaimsQuery2.vPath),
|
548
|
-
v7.description(
|
549
|
-
"A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential."
|
550
|
-
)
|
551
|
-
),
|
552
|
-
values: v7.pipe(
|
553
|
-
v7.optional(v7.array(DcqlClaimsQuery2.vValue)),
|
554
|
-
v7.description(
|
555
|
-
"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."
|
556
|
-
)
|
557
|
-
)
|
558
|
-
});
|
559
|
-
DcqlClaimsQuery2.vMdoc = v7.object({
|
560
|
-
id: v7.pipe(
|
561
|
-
v7.optional(v7.pipe(v7.string(), v7.regex(idRegex))),
|
562
|
-
v7.description(
|
563
|
-
"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."
|
564
|
-
)
|
565
|
-
),
|
566
|
-
namespace: v7.pipe(
|
567
|
-
v7.string(),
|
568
|
-
v7.description(
|
569
|
-
"A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1."
|
570
|
-
)
|
571
|
-
),
|
572
|
-
claim_name: v7.pipe(
|
573
|
-
v7.string(),
|
574
|
-
v7.description(
|
575
|
-
"A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name."
|
576
|
-
)
|
577
|
-
),
|
578
|
-
values: v7.pipe(
|
579
|
-
v7.optional(v7.array(DcqlClaimsQuery2.vValue)),
|
580
|
-
v7.description(
|
581
|
-
"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."
|
582
|
-
)
|
583
|
-
)
|
584
|
-
});
|
585
|
-
DcqlClaimsQuery2.vModel = v7.union([DcqlClaimsQuery2.vMdoc, DcqlClaimsQuery2.vW3cSdJwtVc]);
|
586
|
-
})(DcqlClaimsQuery || (DcqlClaimsQuery = {}));
|
587
|
-
|
588
|
-
// src/dcql-query/m-dcql-credential-query.ts
|
589
628
|
var DcqlCredentialQuery;
|
590
629
|
((DcqlCredentialQuery2) => {
|
591
630
|
const vBase = v8.object({
|
@@ -597,7 +636,7 @@ var DcqlCredentialQuery;
|
|
597
636
|
)
|
598
637
|
),
|
599
638
|
claim_sets: v8.pipe(
|
600
|
-
v8.optional(v8.pipe(v8.array(v8.
|
639
|
+
v8.optional(v8.pipe(v8.array(v8.pipe(v8.array(vIdString), vNonEmptyArray())), vNonEmptyArray())),
|
601
640
|
v8.description(
|
602
641
|
`OPTIONAL. A non-empty array containing arrays of identifiers for elements in 'claims' that specifies which combinations of 'claims' for the Credential are requested.`
|
603
642
|
)
|
@@ -724,7 +763,7 @@ var DcqlQueryResult;
|
|
724
763
|
)
|
725
764
|
),
|
726
765
|
credential_matches: v10.record(
|
727
|
-
v10.pipe(
|
766
|
+
v10.pipe(vIdString),
|
728
767
|
v10.union([
|
729
768
|
v10.object({
|
730
769
|
...DcqlCredential.vParseSuccess.entries,
|
@@ -777,19 +816,19 @@ var DcqlPresentationResult;
|
|
777
816
|
...v11.omit(DcqlQueryResult.vModel, ["credential_matches"]).entries,
|
778
817
|
invalid_matches: v11.union([
|
779
818
|
v11.record(
|
780
|
-
v11.pipe(
|
819
|
+
v11.pipe(vIdString),
|
781
820
|
v11.object({
|
782
821
|
...v11.omit(DcqlCredential.vParseFailure, ["input_credential_index"]).entries,
|
783
|
-
presentation_id: v11.pipe(
|
822
|
+
presentation_id: v11.pipe(vIdString)
|
784
823
|
})
|
785
824
|
),
|
786
825
|
v11.undefined()
|
787
826
|
]),
|
788
827
|
valid_matches: v11.record(
|
789
|
-
v11.pipe(
|
828
|
+
v11.pipe(vIdString),
|
790
829
|
v11.object({
|
791
830
|
...v11.omit(DcqlCredential.vParseSuccess, ["issues", "input_credential_index"]).entries,
|
792
|
-
presentation_id: v11.pipe(
|
831
|
+
presentation_id: v11.pipe(vIdString)
|
793
832
|
})
|
794
833
|
)
|
795
834
|
});
|
@@ -866,7 +905,7 @@ var DcqlPresentationResult;
|
|
866
905
|
var v12 = __toESM(require("valibot"));
|
867
906
|
var DcqlPresentation;
|
868
907
|
((DcqlPresentation2) => {
|
869
|
-
DcqlPresentation2.vModel = v12.record(
|
908
|
+
DcqlPresentation2.vModel = v12.record(vIdString, v12.union([v12.string(), vJsonRecord]));
|
870
909
|
DcqlPresentation2.parse = (input) => {
|
871
910
|
if (typeof input === "string") {
|
872
911
|
return v12.parse(v12.pipe(v12.string(), vStringToJson, DcqlPresentation2.vModel), input);
|