@openeudi/openid4vp 0.5.0 → 0.6.0
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 +3 -1
- package/dist/index.cjs +105 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +105 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -116,12 +116,14 @@ if (result.valid) {
|
|
|
116
116
|
} else {
|
|
117
117
|
console.warn("mismatch reasons:", result.match.unmatched);
|
|
118
118
|
// each entry: { queryId, reason, detail? }
|
|
119
|
-
// reason ∈ { format_mismatch, vct_mismatch, doctype_mismatch, missing_claims, trusted_authority_mismatch, no_credential_found }
|
|
119
|
+
// reason ∈ { format_mismatch, vct_mismatch, doctype_mismatch, missing_claims, value_mismatch, trusted_authority_mismatch, no_credential_found /* only when the candidate list is empty */ }
|
|
120
120
|
}
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
Mismatches return `valid: false` — they do not throw. Only crypto/structural failures (malformed VP tokens, invalid signatures, expired credentials) and malformed DCQL queries throw exceptions.
|
|
124
124
|
|
|
125
|
+
> **Privacy — diagnostics are verifier-internal.** `match.unmatched[].reason` and `detail` (including `value_mismatch`) are intended for verifier-side logging, debugging, and admin UIs. OpenID4VP §11 warns that per-claim verification outcomes can reveal wallet contents to observers. Do NOT echo these diagnostics into the OpenID4VP wire response sent back to the wallet, into end-user-visible error messages that another party could correlate, or into public analytics/third-party logs. The protocol's own error codes are the public interface; these fields are your internal instrumentation.
|
|
126
|
+
|
|
125
127
|
### ParseOptions / VerifyOptions
|
|
126
128
|
|
|
127
129
|
Both `parsePresentation` and `verifyPresentation` accept:
|
package/dist/index.cjs
CHANGED
|
@@ -631,6 +631,9 @@ __export(index_es_exports, {
|
|
|
631
631
|
Choice: () => Choice,
|
|
632
632
|
Constructed: () => Constructed,
|
|
633
633
|
DATE: () => DATE,
|
|
634
|
+
DEFAULT_MAX_CONTENT_LENGTH: () => DEFAULT_MAX_CONTENT_LENGTH,
|
|
635
|
+
DEFAULT_MAX_DEPTH: () => DEFAULT_MAX_DEPTH,
|
|
636
|
+
DEFAULT_MAX_NODES: () => DEFAULT_MAX_NODES,
|
|
634
637
|
DateTime: () => DateTime,
|
|
635
638
|
Duration: () => Duration,
|
|
636
639
|
EndOfContent: () => EndOfContent,
|
|
@@ -725,7 +728,7 @@ function HexBlock(BaseClass) {
|
|
|
725
728
|
this.isHexOnly = (_b = params.isHexOnly) !== null && _b !== void 0 ? _b : false;
|
|
726
729
|
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
727
730
|
}
|
|
728
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
731
|
+
fromBER(inputBuffer, inputOffset, inputLength, _context) {
|
|
729
732
|
const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
|
|
730
733
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
731
734
|
return -1;
|
|
@@ -769,6 +772,49 @@ function prepareIndefiniteForm(baseBlock) {
|
|
|
769
772
|
}
|
|
770
773
|
return !!((_a2 = baseBlock.lenBlock) === null || _a2 === void 0 ? void 0 : _a2.isIndefiniteForm);
|
|
771
774
|
}
|
|
775
|
+
function createFromBerContext(options = {}) {
|
|
776
|
+
var _a2, _b, _c;
|
|
777
|
+
return {
|
|
778
|
+
depth: 0,
|
|
779
|
+
maxDepth: (_a2 = options.maxDepth) !== null && _a2 !== void 0 ? _a2 : DEFAULT_MAX_DEPTH,
|
|
780
|
+
nodesCount: 0,
|
|
781
|
+
maxNodes: (_b = options.maxNodes) !== null && _b !== void 0 ? _b : DEFAULT_MAX_NODES,
|
|
782
|
+
maxContentLength: (_c = options.maxContentLength) !== null && _c !== void 0 ? _c : DEFAULT_MAX_CONTENT_LENGTH
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function createErrorResult(error) {
|
|
786
|
+
const result = new BaseBlock({}, ValueBlock);
|
|
787
|
+
result.error = error;
|
|
788
|
+
return {
|
|
789
|
+
offset: -1,
|
|
790
|
+
result
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function checkNodesLimit(context) {
|
|
794
|
+
context.nodesCount += 1;
|
|
795
|
+
if (context.nodesCount > context.maxNodes) {
|
|
796
|
+
return MAX_NODES_EXCEEDED_ERROR;
|
|
797
|
+
}
|
|
798
|
+
return void 0;
|
|
799
|
+
}
|
|
800
|
+
function checkContentLengthLimit(inputLength, context) {
|
|
801
|
+
if (inputLength > context.maxContentLength) {
|
|
802
|
+
return MAX_CONTENT_LENGTH_EXCEEDED_ERROR;
|
|
803
|
+
}
|
|
804
|
+
return void 0;
|
|
805
|
+
}
|
|
806
|
+
function localFromBERWithChildContext(inputBuffer, inputOffset, inputLength, context) {
|
|
807
|
+
const childDepth = context.depth + 1;
|
|
808
|
+
if (childDepth > context.maxDepth) {
|
|
809
|
+
return createErrorResult(MAX_DEPTH_EXCEEDED_ERROR);
|
|
810
|
+
}
|
|
811
|
+
context.depth = childDepth;
|
|
812
|
+
try {
|
|
813
|
+
return localFromBER(inputBuffer, inputOffset, inputLength, context);
|
|
814
|
+
} finally {
|
|
815
|
+
context.depth -= 1;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
772
818
|
function localChangeType(inputObject, newType) {
|
|
773
819
|
if (inputObject instanceof newType) {
|
|
774
820
|
return inputObject;
|
|
@@ -780,7 +826,7 @@ function localChangeType(inputObject, newType) {
|
|
|
780
826
|
newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView;
|
|
781
827
|
return newObject;
|
|
782
828
|
}
|
|
783
|
-
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) {
|
|
829
|
+
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length, context = createFromBerContext()) {
|
|
784
830
|
const incomingOffset = inputOffset;
|
|
785
831
|
let returnObject = new BaseBlock({}, ValueBlock);
|
|
786
832
|
const baseBlock = new LocalBaseBlock();
|
|
@@ -799,6 +845,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
799
845
|
result: returnObject
|
|
800
846
|
};
|
|
801
847
|
}
|
|
848
|
+
const nodesLimitError = checkNodesLimit(context);
|
|
849
|
+
if (nodesLimitError) {
|
|
850
|
+
returnObject.error = nodesLimitError;
|
|
851
|
+
return {
|
|
852
|
+
offset: -1,
|
|
853
|
+
result: returnObject
|
|
854
|
+
};
|
|
855
|
+
}
|
|
802
856
|
let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);
|
|
803
857
|
if (returnObject.idBlock.warnings.length) {
|
|
804
858
|
returnObject.warnings.concat(returnObject.idBlock.warnings);
|
|
@@ -825,6 +879,15 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
825
879
|
}
|
|
826
880
|
inputOffset = resultOffset;
|
|
827
881
|
inputLength -= returnObject.lenBlock.blockLength;
|
|
882
|
+
const valueLength = returnObject.lenBlock.isIndefiniteForm ? inputLength : returnObject.lenBlock.length;
|
|
883
|
+
const contentLengthError = checkContentLengthLimit(valueLength, context);
|
|
884
|
+
if (contentLengthError) {
|
|
885
|
+
returnObject.error = contentLengthError;
|
|
886
|
+
return {
|
|
887
|
+
offset: -1,
|
|
888
|
+
result: returnObject
|
|
889
|
+
};
|
|
890
|
+
}
|
|
828
891
|
if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) {
|
|
829
892
|
returnObject.error = "Indefinite length form used for primitive encoding form";
|
|
830
893
|
return {
|
|
@@ -963,14 +1026,14 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
963
1026
|
}
|
|
964
1027
|
}
|
|
965
1028
|
returnObject = localChangeType(returnObject, newASN1Type);
|
|
966
|
-
resultOffset = returnObject.fromBER(inputBuffer, inputOffset,
|
|
1029
|
+
resultOffset = returnObject.fromBER(inputBuffer, inputOffset, valueLength, context);
|
|
967
1030
|
returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);
|
|
968
1031
|
return {
|
|
969
1032
|
offset: resultOffset,
|
|
970
1033
|
result: returnObject
|
|
971
1034
|
};
|
|
972
1035
|
}
|
|
973
|
-
function fromBER(inputBuffer) {
|
|
1036
|
+
function fromBER(inputBuffer, options = {}) {
|
|
974
1037
|
if (!inputBuffer.byteLength) {
|
|
975
1038
|
const result = new BaseBlock({}, ValueBlock);
|
|
976
1039
|
result.error = "Input buffer has zero length";
|
|
@@ -979,7 +1042,7 @@ function fromBER(inputBuffer) {
|
|
|
979
1042
|
result
|
|
980
1043
|
};
|
|
981
1044
|
}
|
|
982
|
-
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength);
|
|
1045
|
+
return localFromBER(BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength, createFromBerContext(options));
|
|
983
1046
|
}
|
|
984
1047
|
function checkLen(indefiniteLength, length) {
|
|
985
1048
|
if (indefiniteLength) {
|
|
@@ -1385,7 +1448,7 @@ function verifySchema(inputBuffer, inputSchema) {
|
|
|
1385
1448
|
}
|
|
1386
1449
|
return compareSchema(asn1.result, asn1.result, inputSchema);
|
|
1387
1450
|
}
|
|
1388
|
-
var ViewWriter, powers2, digitsString, NAME, VALUE_HEX_VIEW, IS_HEX_ONLY, ID_BLOCK, TAG_CLASS, TAG_NUMBER, IS_CONSTRUCTED, FROM_BER, TO_BER, LOCAL, EMPTY_STRING, EMPTY_BUFFER, EMPTY_VIEW, END_OF_CONTENT_NAME, OCTET_STRING_NAME, BIT_STRING_NAME, LocalBaseBlock, ValueBlock, LocalIdentificationBlock, LocalLengthBlock, typeStore, BaseBlock, BaseStringBlock, LocalPrimitiveValueBlock, _a$w, Primitive, LocalConstructedValueBlock, _a$v, Constructed, LocalEndOfContentValueBlock, _a$u, EndOfContent, _a$t, Null, LocalBooleanValueBlock, _a$s, Boolean2, LocalOctetStringValueBlock, _a$r, OctetString, LocalBitStringValueBlock, _a$q, BitString, _a$p, LocalIntegerValueBlock, _a$o, Integer, _a$n, Enumerated, LocalSidValueBlock, LocalObjectIdentifierValueBlock, _a$m, ObjectIdentifier, LocalRelativeSidValueBlock, LocalRelativeObjectIdentifierValueBlock, _a$l, RelativeObjectIdentifier, _a$k, Sequence, _a$j, Set2, LocalStringValueBlock, LocalSimpleStringValueBlock, LocalSimpleStringBlock, LocalUtf8StringValueBlock, _a$i, Utf8String, LocalBmpStringValueBlock, _a$h, BmpString, LocalUniversalStringValueBlock, _a$g, UniversalString, _a$f, NumericString, _a$e, PrintableString, _a$d, TeletexString, _a$c, VideotexString, _a$b, IA5String, _a$a, GraphicString, _a$9, VisibleString, _a$8, GeneralString, _a$7, CharacterString, _a$6, UTCTime, _a$5, GeneralizedTime, _a$4, DATE, _a$3, TimeOfDay, _a$2, DateTime, _a$1, Duration, _a, TIME, Any, Choice, Repeated, RawData;
|
|
1451
|
+
var ViewWriter, powers2, digitsString, NAME, VALUE_HEX_VIEW, IS_HEX_ONLY, ID_BLOCK, TAG_CLASS, TAG_NUMBER, IS_CONSTRUCTED, FROM_BER, TO_BER, LOCAL, EMPTY_STRING, EMPTY_BUFFER, EMPTY_VIEW, END_OF_CONTENT_NAME, OCTET_STRING_NAME, BIT_STRING_NAME, LocalBaseBlock, ValueBlock, LocalIdentificationBlock, LocalLengthBlock, typeStore, BaseBlock, BaseStringBlock, LocalPrimitiveValueBlock, _a$w, Primitive, DEFAULT_MAX_DEPTH, DEFAULT_MAX_NODES, DEFAULT_MAX_CONTENT_LENGTH, MAX_DEPTH_EXCEEDED_ERROR, MAX_NODES_EXCEEDED_ERROR, MAX_CONTENT_LENGTH_EXCEEDED_ERROR, LocalConstructedValueBlock, _a$v, Constructed, LocalEndOfContentValueBlock, _a$u, EndOfContent, _a$t, Null, LocalBooleanValueBlock, _a$s, Boolean2, LocalOctetStringValueBlock, _a$r, OctetString, LocalBitStringValueBlock, _a$q, BitString, _a$p, LocalIntegerValueBlock, _a$o, Integer, _a$n, Enumerated, LocalSidValueBlock, LocalObjectIdentifierValueBlock, _a$m, ObjectIdentifier, LocalRelativeSidValueBlock, LocalRelativeObjectIdentifierValueBlock, _a$l, RelativeObjectIdentifier, _a$k, Sequence, _a$j, Set2, LocalStringValueBlock, LocalSimpleStringValueBlock, LocalSimpleStringBlock, LocalUtf8StringValueBlock, _a$i, Utf8String, LocalBmpStringValueBlock, _a$h, BmpString, LocalUniversalStringValueBlock, _a$g, UniversalString, _a$f, NumericString, _a$e, PrintableString, _a$d, TeletexString, _a$c, VideotexString, _a$b, IA5String, _a$a, GraphicString, _a$9, VisibleString, _a$8, GeneralString, _a$7, CharacterString, _a$6, UTCTime, _a$5, GeneralizedTime, _a$4, DATE, _a$3, TimeOfDay, _a$2, DateTime, _a$1, Duration, _a, TIME, Any, Choice, Repeated, RawData;
|
|
1389
1452
|
var init_index_es2 = __esm({
|
|
1390
1453
|
"node_modules/asn1js/build/index.es.js"() {
|
|
1391
1454
|
init_index_es();
|
|
@@ -1447,7 +1510,7 @@ var init_index_es2 = __esm({
|
|
|
1447
1510
|
};
|
|
1448
1511
|
LocalBaseBlock.NAME = "baseBlock";
|
|
1449
1512
|
ValueBlock = class extends LocalBaseBlock {
|
|
1450
|
-
fromBER(_inputBuffer, _inputOffset, _inputLength) {
|
|
1513
|
+
fromBER(_inputBuffer, _inputOffset, _inputLength, _context) {
|
|
1451
1514
|
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
|
|
1452
1515
|
}
|
|
1453
1516
|
toBER(_sizeOnly, _writer) {
|
|
@@ -1560,31 +1623,21 @@ var init_index_es2 = __esm({
|
|
|
1560
1623
|
this.tagNumber = tagNumberMask;
|
|
1561
1624
|
this.blockLength = 1;
|
|
1562
1625
|
} else {
|
|
1563
|
-
let count =
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
intTagNumberBuffer[count - 1] = intBuffer[count] & 127;
|
|
1568
|
-
count++;
|
|
1569
|
-
if (count >= intBuffer.length) {
|
|
1626
|
+
let count = 0;
|
|
1627
|
+
while (true) {
|
|
1628
|
+
const tagByteIndex = count + 1;
|
|
1629
|
+
if (tagByteIndex >= intBuffer.length) {
|
|
1570
1630
|
this.error = "End of input reached before message was fully decoded";
|
|
1571
1631
|
return -1;
|
|
1572
1632
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
for (let i = 0; i < intTagNumberBuffer.length; i++)
|
|
1577
|
-
tempBufferView2[i] = intTagNumberBuffer[i];
|
|
1578
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength);
|
|
1579
|
-
}
|
|
1633
|
+
count++;
|
|
1634
|
+
if ((intBuffer[tagByteIndex] & 128) === 0)
|
|
1635
|
+
break;
|
|
1580
1636
|
}
|
|
1581
1637
|
this.blockLength = count + 1;
|
|
1582
|
-
intTagNumberBuffer
|
|
1583
|
-
const tempBufferView = new Uint8Array(count);
|
|
1638
|
+
const intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
1584
1639
|
for (let i = 0; i < count; i++)
|
|
1585
|
-
|
|
1586
|
-
intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
1587
|
-
intTagNumberBuffer.set(tempBufferView);
|
|
1640
|
+
intTagNumberBuffer[i] = intBuffer[i + 1] & 127;
|
|
1588
1641
|
if (this.blockLength <= 9)
|
|
1589
1642
|
this.tagNumber = utilFromBase(intTagNumberBuffer, 7);
|
|
1590
1643
|
else {
|
|
@@ -1734,8 +1787,8 @@ var init_index_es2 = __esm({
|
|
|
1734
1787
|
this.lenBlock = new LocalLengthBlock(parameters);
|
|
1735
1788
|
this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);
|
|
1736
1789
|
}
|
|
1737
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
1738
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
1790
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
1791
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
1739
1792
|
if (resultOffset === -1) {
|
|
1740
1793
|
this.error = this.valueBlock.error;
|
|
1741
1794
|
return resultOffset;
|
|
@@ -1859,14 +1912,21 @@ var init_index_es2 = __esm({
|
|
|
1859
1912
|
typeStore.Primitive = _a$w;
|
|
1860
1913
|
})();
|
|
1861
1914
|
Primitive.NAME = "PRIMITIVE";
|
|
1915
|
+
DEFAULT_MAX_DEPTH = 100;
|
|
1916
|
+
DEFAULT_MAX_NODES = 1e4;
|
|
1917
|
+
DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024 * 1024;
|
|
1918
|
+
MAX_DEPTH_EXCEEDED_ERROR = "Maximum ASN.1 nesting depth exceeded";
|
|
1919
|
+
MAX_NODES_EXCEEDED_ERROR = "Maximum ASN.1 node count exceeded";
|
|
1920
|
+
MAX_CONTENT_LENGTH_EXCEEDED_ERROR = "Maximum ASN.1 content length exceeded";
|
|
1862
1921
|
LocalConstructedValueBlock = class extends ValueBlock {
|
|
1863
1922
|
constructor({ value = [], isIndefiniteForm = false, ...parameters } = {}) {
|
|
1864
1923
|
super(parameters);
|
|
1865
1924
|
this.value = value;
|
|
1866
1925
|
this.isIndefiniteForm = isIndefiniteForm;
|
|
1867
1926
|
}
|
|
1868
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
1927
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
1869
1928
|
const view = BufferSourceConverter.toUint8Array(inputBuffer);
|
|
1929
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
1870
1930
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
1871
1931
|
return -1;
|
|
1872
1932
|
}
|
|
@@ -1877,7 +1937,7 @@ var init_index_es2 = __esm({
|
|
|
1877
1937
|
}
|
|
1878
1938
|
let currentOffset = inputOffset;
|
|
1879
1939
|
while (checkLen(this.isIndefiniteForm, inputLength) > 0) {
|
|
1880
|
-
const returnObject =
|
|
1940
|
+
const returnObject = localFromBERWithChildContext(view, currentOffset, inputLength, parseContext);
|
|
1881
1941
|
if (returnObject.offset === -1) {
|
|
1882
1942
|
this.error = returnObject.result.error;
|
|
1883
1943
|
this.warnings.concat(returnObject.result.warnings);
|
|
@@ -1928,9 +1988,9 @@ var init_index_es2 = __esm({
|
|
|
1928
1988
|
super(parameters, LocalConstructedValueBlock);
|
|
1929
1989
|
this.idBlock.isConstructed = true;
|
|
1930
1990
|
}
|
|
1931
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
1991
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
1932
1992
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
1933
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
1993
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
1934
1994
|
if (resultOffset === -1) {
|
|
1935
1995
|
this.error = this.valueBlock.error;
|
|
1936
1996
|
return resultOffset;
|
|
@@ -2093,11 +2153,11 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2093
2153
|
super(parameters);
|
|
2094
2154
|
this.isConstructed = isConstructed;
|
|
2095
2155
|
}
|
|
2096
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2156
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
2097
2157
|
let resultOffset = 0;
|
|
2098
2158
|
if (this.isConstructed) {
|
|
2099
2159
|
this.isHexOnly = false;
|
|
2100
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
2160
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
2101
2161
|
if (resultOffset === -1)
|
|
2102
2162
|
return resultOffset;
|
|
2103
2163
|
for (let i = 0; i < this.value.length; i++) {
|
|
@@ -2153,7 +2213,7 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2153
2213
|
this.idBlock.tagClass = 1;
|
|
2154
2214
|
this.idBlock.tagNumber = 4;
|
|
2155
2215
|
}
|
|
2156
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2216
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
2157
2217
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
2158
2218
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
2159
2219
|
if (inputLength === 0) {
|
|
@@ -2168,7 +2228,8 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2168
2228
|
const buf = view.subarray(inputOffset, inputOffset + inputLength);
|
|
2169
2229
|
try {
|
|
2170
2230
|
if (buf.byteLength) {
|
|
2171
|
-
const
|
|
2231
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
2232
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
2172
2233
|
if (asn.offset !== -1 && asn.offset === inputLength) {
|
|
2173
2234
|
this.valueBlock.value = [asn.result];
|
|
2174
2235
|
}
|
|
@@ -2176,7 +2237,7 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2176
2237
|
} catch {
|
|
2177
2238
|
}
|
|
2178
2239
|
}
|
|
2179
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
2240
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
2180
2241
|
}
|
|
2181
2242
|
onAsciiEncoding() {
|
|
2182
2243
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -2211,13 +2272,13 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2211
2272
|
this.isConstructed = isConstructed;
|
|
2212
2273
|
this.blockLength = this.valueHexView.byteLength;
|
|
2213
2274
|
}
|
|
2214
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2275
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
2215
2276
|
if (!inputLength) {
|
|
2216
2277
|
return inputOffset;
|
|
2217
2278
|
}
|
|
2218
2279
|
let resultOffset = -1;
|
|
2219
2280
|
if (this.isConstructed) {
|
|
2220
|
-
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength);
|
|
2281
|
+
resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength, context);
|
|
2221
2282
|
if (resultOffset === -1)
|
|
2222
2283
|
return resultOffset;
|
|
2223
2284
|
for (const value of this.value) {
|
|
@@ -2257,7 +2318,8 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2257
2318
|
const buf = intBuffer.subarray(1);
|
|
2258
2319
|
try {
|
|
2259
2320
|
if (buf.byteLength) {
|
|
2260
|
-
const
|
|
2321
|
+
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
2322
|
+
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
2261
2323
|
if (asn.offset !== -1 && asn.offset === inputLength - 1) {
|
|
2262
2324
|
this.value = [asn.result];
|
|
2263
2325
|
}
|
|
@@ -2313,10 +2375,10 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
2313
2375
|
this.idBlock.tagClass = 1;
|
|
2314
2376
|
this.idBlock.tagNumber = 3;
|
|
2315
2377
|
}
|
|
2316
|
-
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
2378
|
+
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
2317
2379
|
this.valueBlock.isConstructed = this.idBlock.isConstructed;
|
|
2318
2380
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
2319
|
-
return super.fromBER(inputBuffer, inputOffset, inputLength);
|
|
2381
|
+
return super.fromBER(inputBuffer, inputOffset, inputLength, context);
|
|
2320
2382
|
}
|
|
2321
2383
|
onAsciiEncoding() {
|
|
2322
2384
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) {
|
|
@@ -8871,38 +8933,6 @@ var INTERNAL_TO_DCQL_FORMAT = {
|
|
|
8871
8933
|
"sd-jwt-vc": "dc+sd-jwt",
|
|
8872
8934
|
mdoc: "mso_mdoc"
|
|
8873
8935
|
};
|
|
8874
|
-
function classifyMismatch(query, decoded, hasDetail) {
|
|
8875
|
-
if (decoded.format !== query.format) return "format_mismatch";
|
|
8876
|
-
if (query.format === "dc+sd-jwt") {
|
|
8877
|
-
const allowed = query.meta?.vct_values;
|
|
8878
|
-
if (allowed && allowed.length > 0 && !allowed.includes(decoded.vct ?? "")) {
|
|
8879
|
-
return "vct_mismatch";
|
|
8880
|
-
}
|
|
8881
|
-
}
|
|
8882
|
-
if (query.format === "mso_mdoc") {
|
|
8883
|
-
const expected = query.meta?.doctype_value;
|
|
8884
|
-
if (expected && expected !== decoded.doctype) return "doctype_mismatch";
|
|
8885
|
-
}
|
|
8886
|
-
if (query.trusted_authorities && query.trusted_authorities.length > 0) {
|
|
8887
|
-
const decodedAuthIds = decoded.trusted_authority_ids ?? [];
|
|
8888
|
-
const anyMatch = query.trusted_authorities.some(
|
|
8889
|
-
(ta) => ta.values.some((v) => decodedAuthIds.includes(v))
|
|
8890
|
-
);
|
|
8891
|
-
if (!anyMatch) return "trusted_authority_mismatch";
|
|
8892
|
-
}
|
|
8893
|
-
if (hasDetail) return "missing_claims";
|
|
8894
|
-
return "no_credential_found";
|
|
8895
|
-
}
|
|
8896
|
-
function refineUnmatched(query, decoded, match) {
|
|
8897
|
-
if (match.unmatched.length === 0) return match;
|
|
8898
|
-
const refined = match.unmatched.map((entry) => {
|
|
8899
|
-
const credentialQuery = query.credentials.find((c) => c.id === entry.queryId);
|
|
8900
|
-
if (!credentialQuery) return entry;
|
|
8901
|
-
const specific = classifyMismatch(credentialQuery, decoded, entry.detail !== void 0);
|
|
8902
|
-
return { ...entry, reason: specific };
|
|
8903
|
-
});
|
|
8904
|
-
return { ...match, unmatched: refined };
|
|
8905
|
-
}
|
|
8906
8936
|
async function verifyPresentation(vpToken, query, options) {
|
|
8907
8937
|
const parsed = await parsePresentation(vpToken, options);
|
|
8908
8938
|
const dcqlFormat = INTERNAL_TO_DCQL_FORMAT[parsed.format] ?? parsed.format;
|
|
@@ -8921,8 +8951,7 @@ async function verifyPresentation(vpToken, query, options) {
|
|
|
8921
8951
|
if (parsed.trust?.trustedAuthorityIds && parsed.trust.trustedAuthorityIds.length > 0) {
|
|
8922
8952
|
decoded.trusted_authority_ids = [...parsed.trust.trustedAuthorityIds];
|
|
8923
8953
|
}
|
|
8924
|
-
const
|
|
8925
|
-
const match = refineUnmatched(query, decoded, rawMatch);
|
|
8954
|
+
const match = dcql.matchQuery(query, [decoded]);
|
|
8926
8955
|
const submission = match.satisfied ? dcql.buildSubmission(query, match) : null;
|
|
8927
8956
|
return {
|
|
8928
8957
|
parsed,
|