@ac-kit/format-asn1 0.3.0 → 0.4.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/CHANGELOG.md +81 -0
- package/README.md +132 -4
- package/dist/_encoding/constants.d.ts +2 -0
- package/dist/_encoding/constants.d.ts.map +1 -1
- package/dist/_encoding/constants.js +7 -0
- package/dist/_encoding/constants.js.map +1 -1
- package/dist/_encoding/decode-primitive.d.ts +39 -0
- package/dist/_encoding/decode-primitive.d.ts.map +1 -0
- package/dist/_encoding/decode-primitive.js +144 -0
- package/dist/_encoding/decode-primitive.js.map +1 -0
- package/dist/_encoding/def-tags.d.ts +36 -3
- package/dist/_encoding/def-tags.d.ts.map +1 -1
- package/dist/_encoding/def-tags.js +88 -3
- package/dist/_encoding/def-tags.js.map +1 -1
- package/dist/_encoding/encoded-tag-sort-key.d.ts +7 -0
- package/dist/_encoding/encoded-tag-sort-key.d.ts.map +1 -0
- package/dist/_encoding/encoded-tag-sort-key.js +13 -0
- package/dist/_encoding/encoded-tag-sort-key.js.map +1 -0
- package/dist/_encoding/tag.d.ts +1 -6
- package/dist/_encoding/tag.d.ts.map +1 -1
- package/dist/_encoding/tag.js +5 -43
- package/dist/_encoding/tag.js.map +1 -1
- package/dist/_encoding/tlv.d.ts +4 -25
- package/dist/_encoding/tlv.d.ts.map +1 -1
- package/dist/_encoding/tlv.js +12 -48
- package/dist/_encoding/tlv.js.map +1 -1
- package/dist/_encoding/values.d.ts.map +1 -1
- package/dist/_encoding/values.js +31 -19
- package/dist/_encoding/values.js.map +1 -1
- package/dist/_encoding/vlq.d.ts.map +1 -1
- package/dist/_encoding/vlq.js +2 -2
- package/dist/_encoding/vlq.js.map +1 -1
- package/dist/_encoding/with-offset.d.ts +12 -0
- package/dist/_encoding/with-offset.d.ts.map +1 -0
- package/dist/_encoding/with-offset.js +22 -0
- package/dist/_encoding/with-offset.js.map +1 -0
- package/dist/ber/_decode.d.ts +25 -0
- package/dist/ber/_decode.d.ts.map +1 -0
- package/dist/ber/_decode.js +409 -0
- package/dist/ber/_decode.js.map +1 -0
- package/dist/ber/codec.d.ts +3 -2
- package/dist/ber/codec.d.ts.map +1 -1
- package/dist/ber/codec.js +45 -16
- package/dist/ber/codec.js.map +1 -1
- package/dist/ber/decode.d.ts +30 -1
- package/dist/ber/decode.d.ts.map +1 -1
- package/dist/ber/decode.js +31 -221
- package/dist/ber/decode.js.map +1 -1
- package/dist/ber/encode.d.ts +7 -1
- package/dist/ber/encode.d.ts.map +1 -1
- package/dist/ber/encode.js +46 -53
- package/dist/ber/encode.js.map +1 -1
- package/dist/cer/decode.d.ts +20 -1
- package/dist/cer/decode.d.ts.map +1 -1
- package/dist/cer/decode.js +27 -221
- package/dist/cer/decode.js.map +1 -1
- package/dist/cer/encode.d.ts +22 -6
- package/dist/cer/encode.d.ts.map +1 -1
- package/dist/cer/encode.js +147 -136
- package/dist/cer/encode.js.map +1 -1
- package/dist/der/decode.d.ts +27 -21
- package/dist/der/decode.d.ts.map +1 -1
- package/dist/der/decode.js +323 -398
- package/dist/der/decode.js.map +1 -1
- package/dist/der/encode.js +5 -8
- package/dist/der/encode.js.map +1 -1
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +31 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/per/decode.d.ts +9 -0
- package/dist/per/decode.d.ts.map +1 -1
- package/dist/per/decode.js +114 -32
- package/dist/per/decode.js.map +1 -1
- package/dist/per/encode.js +1 -1
- package/dist/per/encode.js.map +1 -1
- package/dist/reader/_framing.d.ts +38 -0
- package/dist/reader/_framing.d.ts.map +1 -0
- package/dist/reader/_framing.js +144 -0
- package/dist/reader/_framing.js.map +1 -0
- package/dist/reader/_header.d.ts +49 -0
- package/dist/reader/_header.d.ts.map +1 -0
- package/dist/reader/_header.js +130 -0
- package/dist/reader/_header.js.map +1 -0
- package/dist/reader/ber-reader.d.ts +240 -0
- package/dist/reader/ber-reader.d.ts.map +1 -0
- package/dist/reader/ber-reader.js +567 -0
- package/dist/reader/ber-reader.js.map +1 -0
- package/dist/reader/inspect.d.ts +68 -0
- package/dist/reader/inspect.d.ts.map +1 -0
- package/dist/reader/inspect.js +104 -0
- package/dist/reader/inspect.js.map +1 -0
- package/dist/schema/universal-tag-name.d.ts +26 -0
- package/dist/schema/universal-tag-name.d.ts.map +1 -0
- package/dist/schema/universal-tag-name.js +74 -0
- package/dist/schema/universal-tag-name.js.map +1 -0
- package/package.json +9 -8
- package/dist/_encoding/errors.d.ts +0 -8
- package/dist/_encoding/errors.d.ts.map +0 -1
- package/dist/_encoding/errors.js +0 -15
- package/dist/_encoding/errors.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { universalTagFor } from "../ber/tags.js";
|
|
2
2
|
import { resolveLazyDef } from "../schema/_lazy-resolution.js";
|
|
3
3
|
import { resolveInstance } from "../schema/types/parameterized/parameterized-type.js";
|
|
4
|
+
import { tagSortKey } from "./tlv.js";
|
|
4
5
|
/**
|
|
5
6
|
* Strips the wrappers that never appear on the wire (`lazy`, `transform`, a
|
|
6
7
|
* parameterized-type instance) until a def that encodes itself is reached.
|
|
@@ -232,8 +233,92 @@ export function outerTagSet(def, fail) {
|
|
|
232
233
|
outerTagSetCache.set(def, { set: result.set });
|
|
233
234
|
return result.set;
|
|
234
235
|
}
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Whether a tag of this class and number may start an encoding of a def whose
|
|
238
|
+
* outer set is `set`. A tag number above `Number.MAX_SAFE_INTEGER` (`null`)
|
|
239
|
+
* matches no schema tag.
|
|
240
|
+
*/
|
|
241
|
+
export function outerTagSetHas(set, tagClass, tagNumber) {
|
|
242
|
+
return (set === undefined ||
|
|
243
|
+
(tagNumber !== null && set.has(`${tagClass}:${tagNumber}`)));
|
|
244
|
+
}
|
|
245
|
+
const STRING_KINDS = new Set([
|
|
246
|
+
"octetString",
|
|
247
|
+
"utf8String",
|
|
248
|
+
"numericString",
|
|
249
|
+
"printableString",
|
|
250
|
+
"teletexString",
|
|
251
|
+
"videotexString",
|
|
252
|
+
"ia5String",
|
|
253
|
+
"graphicString",
|
|
254
|
+
"visibleString",
|
|
255
|
+
"generalString",
|
|
256
|
+
"universalString",
|
|
257
|
+
"bmpString",
|
|
258
|
+
"utcTime",
|
|
259
|
+
"generalizedTime",
|
|
260
|
+
]);
|
|
261
|
+
/**
|
|
262
|
+
* Whether a def of this kind is encoded like an OCTET STRING: its contents are
|
|
263
|
+
* bytes that BER and CER may send as the segments of a constructed encoding
|
|
264
|
+
* (X.690 §8.7.3, §8.23, §8.25) and CER fragments above 1000 octets (§9.2). BIT
|
|
265
|
+
* STRING is encoded alike but its segments carry an unused-bits octet, so it is
|
|
266
|
+
* not one; TIME, DATE, TIME-OF-DAY, DATE-TIME and DURATION are primitive only
|
|
267
|
+
* (§8.26), so they are not either.
|
|
268
|
+
*/
|
|
269
|
+
export function isStringKind(kind) {
|
|
270
|
+
return STRING_KINDS.has(kind);
|
|
271
|
+
}
|
|
272
|
+
/** The components of a SEQUENCE or SET, extension addition groups flattened. */
|
|
273
|
+
export function componentList(items) {
|
|
274
|
+
const components = [];
|
|
275
|
+
for (const item of items) {
|
|
276
|
+
if (item.kind === "component") {
|
|
277
|
+
components.push(item);
|
|
278
|
+
}
|
|
279
|
+
else if (item.kind === "extensionAdditionGroup") {
|
|
280
|
+
components.push(...item.components);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return components;
|
|
284
|
+
}
|
|
285
|
+
/** Whether a SEQUENCE or SET has an extension marker. */
|
|
286
|
+
export function isExtensible(def) {
|
|
287
|
+
return def.components.some((item) => item.kind === "extensionMarker");
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The component of a SET an element with this tag belongs to: the first whose
|
|
291
|
+
* type may start with the tag, else the first not yet `present` whose type has
|
|
292
|
+
* no finite tag set (ANY, open type); -1 when none.
|
|
293
|
+
*/
|
|
294
|
+
export function findSetComponent(components, tagSets, present, tagClass, tagNumber) {
|
|
295
|
+
const index = tagSets.findIndex((tags) => tags !== undefined && outerTagSetHas(tags, tagClass, tagNumber));
|
|
296
|
+
if (index >= 0)
|
|
297
|
+
return index;
|
|
298
|
+
return tagSets.findIndex((tags, candidate) => tags === undefined && !present.has(components[candidate]));
|
|
299
|
+
}
|
|
300
|
+
const smallestTagSortKeyCache = new WeakMap();
|
|
301
|
+
/**
|
|
302
|
+
* The sort key of the smallest tag a def may start with, which orders a SET
|
|
303
|
+
* component in CER (X.690 §9.3): an untagged CHOICE counts as its smallest tag,
|
|
304
|
+
* those of the untagged CHOICEs nested in it included. `undefined` when the def
|
|
305
|
+
* has no finite tag set (ANY, open type): the tag of the element decides.
|
|
306
|
+
*/
|
|
307
|
+
export function smallestTagSortKey(def, fail) {
|
|
308
|
+
const cached = smallestTagSortKeyCache.get(def);
|
|
309
|
+
if (cached !== undefined)
|
|
310
|
+
return cached.key;
|
|
311
|
+
const tags = outerTagSet(def, fail);
|
|
312
|
+
let smallest;
|
|
313
|
+
if (tags !== undefined) {
|
|
314
|
+
for (const tag of tags) {
|
|
315
|
+
const separator = tag.indexOf(":");
|
|
316
|
+
const key = tagSortKey(tag.slice(0, separator), BigInt(tag.slice(separator + 1)));
|
|
317
|
+
if (smallest === undefined || key < smallest)
|
|
318
|
+
smallest = key;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
smallestTagSortKeyCache.set(def, { key: smallest });
|
|
322
|
+
return smallest;
|
|
238
323
|
}
|
|
239
324
|
//# sourceMappingURL=def-tags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"def-tags.js","sourceRoot":"","sources":["../../src/_encoding/def-tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBA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AG,CAAC;IAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,QAA4B,CAAC;IACjC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,GAAG,UAAU,CACrB,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAa,EACnC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAChC,CAAC;YACF,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,GAAG,QAAQ;gBAAE,QAAQ,GAAG,GAAG,CAAC;QAC9D,CAAC;IACF,CAAC;IACD,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sort key of the outermost tag of an encoded element: the order a SET
|
|
3
|
+
* component takes in DER, where an untagged CHOICE component sorts by the tag
|
|
4
|
+
* of the alternative it holds (X.690 §10.3).
|
|
5
|
+
*/
|
|
6
|
+
export declare function encodedTagSortKey(encoded: Uint8Array): bigint;
|
|
7
|
+
//# sourceMappingURL=encoded-tag-sort-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoded-tag-sort-key.d.ts","sourceRoot":"","sources":["../../src/_encoding/encoded-tag-sort-key.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAI7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BerReader } from "../reader/ber-reader.js";
|
|
2
|
+
import { tagSortKey } from "./tlv.js";
|
|
3
|
+
/**
|
|
4
|
+
* The sort key of the outermost tag of an encoded element: the order a SET
|
|
5
|
+
* component takes in DER, where an untagged CHOICE component sorts by the tag
|
|
6
|
+
* of the alternative it holds (X.690 §10.3).
|
|
7
|
+
*/
|
|
8
|
+
export function encodedTagSortKey(encoded) {
|
|
9
|
+
const header = new BerReader(encoded, "ber");
|
|
10
|
+
header.peekHeader();
|
|
11
|
+
return tagSortKey(header.tagClass, header.tagNumber ?? header.bigTagNumber());
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=encoded-tag-sort-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoded-tag-sort-key.js","sourceRoot":"","sources":["../../src/_encoding/encoded-tag-sort-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmB;IACpD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,CAAC,UAAU,EAAE,CAAC;IACpB,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
package/dist/_encoding/tag.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TagClass } from "../index.js";
|
|
1
|
+
import type { TagClass } from "../schema/metadata.js";
|
|
3
2
|
/**
|
|
4
3
|
* A resolved tag as it appears in the identifier octets (X.690 §8.1.2): class +
|
|
5
4
|
* number plus the constructed/primitive bit. Distinct from the schema-level
|
|
@@ -18,14 +17,10 @@ export interface EncodedTag {
|
|
|
18
17
|
* integer — the range every decoder of this package reads back.
|
|
19
18
|
*/
|
|
20
19
|
export declare function encodeTag(tag: EncodedTag): Uint8Array;
|
|
21
|
-
/** Decode identifier octets from a ByteReader (X.690 §8.1.2). */
|
|
22
|
-
export declare function decodeTag(reader: ByteReader): EncodedTag;
|
|
23
20
|
/** Encode a definite length (X.690 §8.1.3.3). */
|
|
24
21
|
export declare function encodeDefiniteLength(len: number): Uint8Array;
|
|
25
22
|
/** Encode indefinite-length terminator: two 0x00 bytes (X.690 §8.1.3.6). */
|
|
26
23
|
export declare const EOC_BYTES: Uint8Array;
|
|
27
24
|
/** Indefinite-length octet (X.690 §8.1.3.6 — BER/CER only). */
|
|
28
25
|
export declare const INDEFINITE_LENGTH_BYTE = 128;
|
|
29
|
-
/** Decode a length from a ByteReader. Returns `undefined` for indefinite form. */
|
|
30
|
-
export declare function decodeLength(reader: ByteReader): number | undefined;
|
|
31
26
|
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/_encoding/tag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/_encoding/tag.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAWtD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC9B;AAID;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAoBrD;AAID,iDAAiD;AACjD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAe5D;AAED,4EAA4E;AAC5E,eAAO,MAAM,SAAS,EAAE,UAAyC,CAAC;AAElE,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,MAAO,CAAC"}
|
package/dist/_encoding/tag.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ByteBuilder } from "@ac-kit/core";
|
|
2
2
|
import { encodeVlq } from "@ac-kit/format-varint";
|
|
3
|
+
import { EncodingError } from "../errors.js";
|
|
3
4
|
import { TAG_CLASS_APPLICATION, TAG_CLASS_CONTEXT, TAG_CLASS_PRIVATE, TAG_CLASS_UNIVERSAL, TAG_CONSTRUCTED, TAG_LONG_FORM, TAG_PRIMITIVE, } from "./constants.js";
|
|
4
|
-
import { DecodingError, EncodingError } from "./errors.js";
|
|
5
|
-
import { readVlqField } from "./vlq.js";
|
|
6
5
|
// ── Tag encoding ─────────────────────────────────────────────────────
|
|
7
6
|
/**
|
|
8
7
|
* Encode a tag into identifier octets (X.690 §8.1.2).
|
|
@@ -29,21 +28,12 @@ export function encodeTag(tag) {
|
|
|
29
28
|
}
|
|
30
29
|
return w.toBytes();
|
|
31
30
|
}
|
|
32
|
-
/** Decode identifier octets from a ByteReader (X.690 §8.1.2). */
|
|
33
|
-
export function decodeTag(reader) {
|
|
34
|
-
const offset = reader.position;
|
|
35
|
-
const first = reader.readByte();
|
|
36
|
-
const tagClass = byteToTagClass((first & 0xc0));
|
|
37
|
-
const constructed = (first & TAG_CONSTRUCTED) !== 0;
|
|
38
|
-
let tagNumber = first & 0x1f;
|
|
39
|
-
if (tagNumber === 31) {
|
|
40
|
-
tagNumber = readVlqField(reader, "Tag number", offset);
|
|
41
|
-
}
|
|
42
|
-
return { tagClass, tagNumber, constructed };
|
|
43
|
-
}
|
|
44
31
|
// ── Length encoding ───────────────────────────────────────────────────────────
|
|
45
32
|
/** Encode a definite length (X.690 §8.1.3.3). */
|
|
46
33
|
export function encodeDefiniteLength(len) {
|
|
34
|
+
if (!Number.isSafeInteger(len) || len < 0) {
|
|
35
|
+
throw new EncodingError(`Length ${len} is not a non-negative safe integer`);
|
|
36
|
+
}
|
|
47
37
|
if (len < 0x80) {
|
|
48
38
|
return new Uint8Array([len]);
|
|
49
39
|
}
|
|
@@ -52,7 +42,7 @@ export function encodeDefiniteLength(len) {
|
|
|
52
42
|
let remaining = len;
|
|
53
43
|
while (remaining > 0) {
|
|
54
44
|
bytes.unshift(remaining & 0xff);
|
|
55
|
-
remaining
|
|
45
|
+
remaining = Math.floor(remaining / 256);
|
|
56
46
|
}
|
|
57
47
|
return new Uint8Array([0x80 | bytes.length, ...bytes]);
|
|
58
48
|
}
|
|
@@ -60,22 +50,6 @@ export function encodeDefiniteLength(len) {
|
|
|
60
50
|
export const EOC_BYTES = new Uint8Array([0x00, 0x00]);
|
|
61
51
|
/** Indefinite-length octet (X.690 §8.1.3.6 — BER/CER only). */
|
|
62
52
|
export const INDEFINITE_LENGTH_BYTE = 0x80;
|
|
63
|
-
/** Decode a length from a ByteReader. Returns `undefined` for indefinite form. */
|
|
64
|
-
export function decodeLength(reader) {
|
|
65
|
-
const first = reader.readByte();
|
|
66
|
-
if (first < 0x80)
|
|
67
|
-
return first; // short form
|
|
68
|
-
if (first === 0x80)
|
|
69
|
-
return undefined; // indefinite form
|
|
70
|
-
if (first === 0xff)
|
|
71
|
-
throw new DecodingError("Reserved length octet 0xFF", reader.position);
|
|
72
|
-
const numBytes = first & 0x7f;
|
|
73
|
-
let len = 0;
|
|
74
|
-
for (let i = 0; i < numBytes; i++) {
|
|
75
|
-
len = (len << 8) | reader.readByte();
|
|
76
|
-
}
|
|
77
|
-
return len;
|
|
78
|
-
}
|
|
79
53
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
80
54
|
function tagClassToByte(cls) {
|
|
81
55
|
switch (cls) {
|
|
@@ -89,16 +63,4 @@ function tagClassToByte(cls) {
|
|
|
89
63
|
return TAG_CLASS_PRIVATE;
|
|
90
64
|
}
|
|
91
65
|
}
|
|
92
|
-
function byteToTagClass(b) {
|
|
93
|
-
switch (b) {
|
|
94
|
-
case TAG_CLASS_UNIVERSAL:
|
|
95
|
-
return "universal";
|
|
96
|
-
case TAG_CLASS_APPLICATION:
|
|
97
|
-
return "application";
|
|
98
|
-
case TAG_CLASS_CONTEXT:
|
|
99
|
-
return "context";
|
|
100
|
-
case TAG_CLASS_PRIVATE:
|
|
101
|
-
return "private";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
66
|
//# sourceMappingURL=tag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../src/_encoding/tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../src/_encoding/tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,GACb,MAAM,gBAAgB,CAAC;AAcxB,wEAAwE;AAExE;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAe;IACxC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,aAAa,CACtB,cAAc,GAAG,CAAC,SAAS,qCAAqC,CAChE,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC;IACzE,MAAM,CAAC,GAAG,IAAI,WAAW,EAAE,CAAC;IAE5B,IAAI,GAAG,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;QACxB,2BAA2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DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,iFAAiF;AAEjF,SAAS,cAAc,CAAC,GAAa;IACpC,QAAQ,GAAG,EAAE,CAAC;QACb,KAAK,WAAW;YACf,OAAO,mBAAmB,CAAC;QAC5B,KAAK,aAAa;YACjB,OAAO,qBAAqB,CAAC;QAC9B,KAAK,SAAS;YACb,OAAO,iBAAiB,CAAC;QAC1B,KAAK,SAAS;YACb,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACF,CAAC"}
|
package/dist/_encoding/tlv.d.ts
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TagClass } from "../schema/metadata.js";
|
|
2
2
|
import { type EncodedTag } from "./tag.js";
|
|
3
|
-
export interface TlvHeader {
|
|
4
|
-
readonly tag: EncodedTag;
|
|
5
|
-
/** `undefined` = indefinite-length (BER/CER only). */
|
|
6
|
-
readonly length: number | undefined;
|
|
7
|
-
/** Byte offset of the value within the source buffer. */
|
|
8
|
-
readonly valueOffset: number;
|
|
9
|
-
}
|
|
10
3
|
/** Build a TLV with definite-length encoding. */
|
|
11
4
|
export declare function writeTlv(tag: EncodedTag, contents: Uint8Array): Uint8Array;
|
|
12
5
|
/** Build a TLV with indefinite-length encoding (BER/CER constructed types). */
|
|
13
6
|
export declare function writeTlvIndefinite(tag: EncodedTag, contents: Uint8Array): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Read one TLV from a ByteReader. Returns the tag, the content slice, and the
|
|
16
|
-
* reader positioned after this TLV.
|
|
17
|
-
*/
|
|
18
|
-
export declare function readTlv(reader: ByteReader): {
|
|
19
|
-
tag: EncodedTag;
|
|
20
|
-
contents: Uint8Array;
|
|
21
|
-
};
|
|
22
|
-
/** Read just the TLV header (tag + length) without consuming the value. */
|
|
23
|
-
export declare function readTlvHeader(reader: ByteReader): TlvHeader;
|
|
24
|
-
/** Return all TLV elements from a buffer (for parsing constructed contents). */
|
|
25
|
-
export declare function readAllTlv(contents: Uint8Array): Array<{
|
|
26
|
-
tag: EncodedTag;
|
|
27
|
-
contents: Uint8Array;
|
|
28
|
-
}>;
|
|
29
7
|
/**
|
|
30
8
|
* Orders a tag for DER SET and SET OF sorting (X.690 §11.5-11.6).
|
|
31
9
|
*
|
|
32
10
|
* Class outranks tag number, and the constructed bit takes no part: a SET's
|
|
33
11
|
* components are ordered by their tags, and a tag is its class and number. Tag
|
|
34
12
|
* numbers are unbounded in principle, so this returns a `bigint` rather than
|
|
35
|
-
* packing both into one 32-bit integer
|
|
13
|
+
* packing both into one 32-bit integer; the class sits above bit 128, out of
|
|
14
|
+
* reach of the tag numbers a `BerReader` reads by default (below 2¹¹²).
|
|
36
15
|
*/
|
|
37
|
-
export declare function tagSortKey(
|
|
16
|
+
export declare function tagSortKey(tagClass: TagClass, tagNumber: number | bigint): bigint;
|
|
38
17
|
//# sourceMappingURL=tlv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tlv.d.ts","sourceRoot":"","sources":["../../src/_encoding/tlv.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tlv.d.ts","sourceRoot":"","sources":["../../src/_encoding/tlv.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAKN,KAAK,UAAU,EACf,MAAM,UAAU,CAAC;AAIlB,iDAAiD;AACjD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,UAAU,CAM1E;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,UAAU,GAClB,UAAU,CAOZ;AASD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,CAER"}
|
package/dist/_encoding/tlv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { concatBytes } from "@ac-kit/core";
|
|
2
|
+
import { encodeDefiniteLength, encodeTag, EOC_BYTES, INDEFINITE_LENGTH_BYTE, } from "./tag.js";
|
|
3
3
|
// ── Write ─────────────────────────────────────────────────────────────────────
|
|
4
4
|
/** Build a TLV with definite-length encoding. */
|
|
5
5
|
export function writeTlv(tag, contents) {
|
|
@@ -9,58 +9,22 @@ export function writeTlv(tag, contents) {
|
|
|
9
9
|
export function writeTlvIndefinite(tag, contents) {
|
|
10
10
|
return concatBytes(encodeTag(tag), new Uint8Array([INDEFINITE_LENGTH_BYTE]), contents, EOC_BYTES);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const tag = decodeTag(reader);
|
|
19
|
-
const length = decodeLength(reader);
|
|
20
|
-
if (length !== undefined) {
|
|
21
|
-
const contents = reader.read(length);
|
|
22
|
-
return { tag, contents };
|
|
23
|
-
}
|
|
24
|
-
// Indefinite-length: read until EOC (0x00 0x00)
|
|
25
|
-
const w = new ByteBuilder();
|
|
26
|
-
let depth = 1;
|
|
27
|
-
while (!reader.atEnd) {
|
|
28
|
-
const b0 = reader.readByte();
|
|
29
|
-
if (b0 === 0x00 && reader.peekByte() === 0x00) {
|
|
30
|
-
reader.readByte(); // consume the second 0x00
|
|
31
|
-
depth--;
|
|
32
|
-
if (depth === 0)
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
w.writeByte(b0);
|
|
36
|
-
}
|
|
37
|
-
return { tag, contents: w.toBytes() };
|
|
38
|
-
}
|
|
39
|
-
/** Read just the TLV header (tag + length) without consuming the value. */
|
|
40
|
-
export function readTlvHeader(reader) {
|
|
41
|
-
const tag = decodeTag(reader);
|
|
42
|
-
const length = decodeLength(reader);
|
|
43
|
-
return { tag, length, valueOffset: reader.position };
|
|
44
|
-
}
|
|
45
|
-
/** Return all TLV elements from a buffer (for parsing constructed contents). */
|
|
46
|
-
export function readAllTlv(contents) {
|
|
47
|
-
const reader = new ByteReader(contents);
|
|
48
|
-
const result = [];
|
|
49
|
-
while (!reader.atEnd) {
|
|
50
|
-
result.push(readTlv(reader));
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
12
|
+
const CLASS_RANK = {
|
|
13
|
+
universal: 0n,
|
|
14
|
+
application: 1n,
|
|
15
|
+
context: 2n,
|
|
16
|
+
private: 3n,
|
|
17
|
+
};
|
|
54
18
|
/**
|
|
55
19
|
* Orders a tag for DER SET and SET OF sorting (X.690 §11.5-11.6).
|
|
56
20
|
*
|
|
57
21
|
* Class outranks tag number, and the constructed bit takes no part: a SET's
|
|
58
22
|
* components are ordered by their tags, and a tag is its class and number. Tag
|
|
59
23
|
* numbers are unbounded in principle, so this returns a `bigint` rather than
|
|
60
|
-
* packing both into one 32-bit integer
|
|
24
|
+
* packing both into one 32-bit integer; the class sits above bit 128, out of
|
|
25
|
+
* reach of the tag numbers a `BerReader` reads by default (below 2¹¹²).
|
|
61
26
|
*/
|
|
62
|
-
export function tagSortKey(
|
|
63
|
-
|
|
64
|
-
return (BigInt(classRank) << 64n) | BigInt(tag.tagNumber);
|
|
27
|
+
export function tagSortKey(tagClass, tagNumber) {
|
|
28
|
+
return (CLASS_RANK[tagClass] << 128n) | BigInt(tagNumber);
|
|
65
29
|
}
|
|
66
30
|
//# sourceMappingURL=tlv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tlv.js","sourceRoot":"","sources":["../../src/_encoding/tlv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"tlv.js","sourceRoot":"","sources":["../../src/_encoding/tlv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EACN,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,sBAAsB,GAEtB,MAAM,UAAU,CAAC;AAElB,iFAAiF;AAEjF,iDAAiD;AACjD,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,QAAoB;IAC7D,OAAO,WAAW,CACjB,SAAS,CAAC,GAAG,CAAC,EACd,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,EACrC,QAAQ,CACR,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CACjC,GAAe,EACf,QAAoB;IAEpB,OAAO,WAAW,CACjB,SAAS,CAAC,GAAG,CAAC,EACd,IAAI,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC,EACxC,QAAQ,EACR,SAAS,CACT,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAA6B;IAC5C,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACX,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACzB,QAAkB,EAClB,SAA0B;IAE1B,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/_encoding/values.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/_encoding/values.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACN,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,MAAM,qBAAqB,CAAC;AAK7B;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,UAAU,CAW9D;AAED;;;;;;;GAOG;AACH,wBAAgB,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;GAOG;AACH,wBAAgB,wBAAwB,CACvC,CAAC,EAAE,oBAAoB,GACrB,oBAAoB,CAoBtB"}
|
package/dist/_encoding/values.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bigIntAbs, bigIntFromBytesBe, ctz32, ByteBuilder, ByteReader, decodeText, encodeTextLatin1, encodeTextUtf8, } from "@ac-kit/core";
|
|
2
2
|
import { encodeVlq } from "@ac-kit/format-varint";
|
|
3
3
|
import { decimalFromNumber, decimalToString } from "@ac-kit/math-numbers";
|
|
4
|
-
import { DecodingError, EncodingError } from "
|
|
4
|
+
import { DecodingError, EncodingError } from "../errors.js";
|
|
5
5
|
import { readVlqField } from "./vlq.js";
|
|
6
6
|
// ── BIT STRING ───────────────────────────────────────────────────────────────
|
|
7
7
|
/**
|
|
@@ -93,7 +93,7 @@ export function encodeOid(arcs) {
|
|
|
93
93
|
/** Decode BER/DER OID contents bytes to arc array. */
|
|
94
94
|
export function decodeOid(contents) {
|
|
95
95
|
if (contents.length === 0)
|
|
96
|
-
throw new DecodingError("OID contents must not be empty");
|
|
96
|
+
throw new DecodingError("OID contents must not be empty", 0, "invalid-contents");
|
|
97
97
|
const reader = new ByteReader(contents);
|
|
98
98
|
// The first subidentifier packs both leading arcs: 40 * c0 + c1.
|
|
99
99
|
const combined = readVlqField(reader, "OID arc", 0);
|
|
@@ -182,7 +182,7 @@ export function decodeReal(contents) {
|
|
|
182
182
|
if (exponentLenIndicator === 3) {
|
|
183
183
|
// §8.5.7.4 d: the second octet gives the exponent's octet count.
|
|
184
184
|
if (contents.length < 2) {
|
|
185
|
-
throw new DecodingError("REAL exponent length octet missing (X.690 §8.5.7.4)");
|
|
185
|
+
throw new DecodingError("REAL exponent length octet missing (X.690 §8.5.7.4)", 1, "invalid-contents");
|
|
186
186
|
}
|
|
187
187
|
expBytes = contents[1];
|
|
188
188
|
expOffset = 2;
|
|
@@ -192,10 +192,10 @@ export function decodeReal(contents) {
|
|
|
192
192
|
expOffset = 1;
|
|
193
193
|
}
|
|
194
194
|
if (expBytes === 0 || expOffset + expBytes > contents.length) {
|
|
195
|
-
throw new DecodingError("REAL exponent runs past the contents (X.690 §8.5.7.4)");
|
|
195
|
+
throw new DecodingError("REAL exponent runs past the contents (X.690 §8.5.7.4)", expOffset, "invalid-contents");
|
|
196
196
|
}
|
|
197
197
|
if (expOffset + expBytes === contents.length) {
|
|
198
|
-
throw new DecodingError("REAL mantissa missing after the exponent (X.690 §8.5.7.5)");
|
|
198
|
+
throw new DecodingError("REAL mantissa missing after the exponent (X.690 §8.5.7.5)", contents.length, "invalid-contents");
|
|
199
199
|
}
|
|
200
200
|
// Two's complement exponent, unsigned mantissa; both linear in length.
|
|
201
201
|
const exponent = bigIntFromBytesBe(contents.subarray(expOffset, expOffset + expBytes));
|
|
@@ -216,8 +216,9 @@ export function decodeReal(contents) {
|
|
|
216
216
|
const trimmed = text.trim();
|
|
217
217
|
// Parse ISO NR3: ±d.d*E±d*
|
|
218
218
|
const match = /^([+-]?\d+\.?\d*)(?:[Ee]([+-]?\d+))?$/.exec(trimmed);
|
|
219
|
-
if (!match)
|
|
220
|
-
throw new DecodingError(`Invalid REAL NR3 encoding: ${trimmed}
|
|
219
|
+
if (!match) {
|
|
220
|
+
throw new DecodingError(`Invalid REAL NR3 encoding: ${trimmed}`, 1, "invalid-contents");
|
|
221
|
+
}
|
|
221
222
|
const numStr = match[1].replace(".", "");
|
|
222
223
|
const dotPos = match[1].indexOf(".");
|
|
223
224
|
const fracDigits = dotPos >= 0 ? match[1].length - dotPos - 1 : 0;
|
|
@@ -248,15 +249,20 @@ function formatUtcOffset(offsetMinutes) {
|
|
|
248
249
|
const abs = Math.abs(offsetMinutes);
|
|
249
250
|
return `${sign}${pad2(Math.floor(abs / 60))}${pad2(abs % 60)}`;
|
|
250
251
|
}
|
|
251
|
-
/**
|
|
252
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Parse a trailing `Z` or `±HHMM` time zone suffix to signed offset minutes.
|
|
254
|
+
*
|
|
255
|
+
* @param suffix - The final characters of `text`.
|
|
256
|
+
* @throws {DecodingError} For an offset outside ±23:59, at the suffix.
|
|
257
|
+
*/
|
|
258
|
+
function parseTzOffset(suffix, text) {
|
|
253
259
|
if (suffix === "Z")
|
|
254
260
|
return 0;
|
|
255
261
|
const sign = suffix[0] === "-" ? -1 : 1;
|
|
256
262
|
const hours = Number(suffix.slice(1, 3));
|
|
257
263
|
const minutes = Number(suffix.slice(3, 5));
|
|
258
264
|
if (hours > 23 || minutes > 59) {
|
|
259
|
-
throw new DecodingError(`Invalid time zone suffix: "${suffix}"
|
|
265
|
+
throw new DecodingError(`Invalid time zone suffix: "${suffix}"`, text.length - suffix.length, "invalid-contents");
|
|
260
266
|
}
|
|
261
267
|
return sign * (hours * 60 + minutes);
|
|
262
268
|
}
|
|
@@ -279,7 +285,7 @@ function toPlainDateTime(fields) {
|
|
|
279
285
|
}
|
|
280
286
|
function checkDecodedFields(what, fields) {
|
|
281
287
|
if (toPlainDateTime(fields) === undefined) {
|
|
282
|
-
throw new DecodingError(`${what}: date or time field out of range (leap seconds are refused)
|
|
288
|
+
throw new DecodingError(`${what}: date or time field out of range (leap seconds are refused)`, 0, "invalid-contents");
|
|
283
289
|
}
|
|
284
290
|
}
|
|
285
291
|
function checkEncodedFields(what, fields) {
|
|
@@ -325,9 +331,12 @@ export function decodeUtcTime(b, canonical = false) {
|
|
|
325
331
|
const s = decodeText(b, "latin1");
|
|
326
332
|
const match = (canonical ? CANONICAL_UTC_TIME_PATTERN : UTC_TIME_PATTERN).exec(s);
|
|
327
333
|
if (match === null) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
if (canonical && UTC_TIME_PATTERN.test(s)) {
|
|
335
|
+
// What BER refuses is invalid before it is non-canonical.
|
|
336
|
+
decodeUtcTime(b, false);
|
|
337
|
+
throw new DecodingError(`UTCTime "${s}" is not in the DER form YYMMDDHHMMSSZ (X.690 §11.8)`, 0, "non-canonical");
|
|
338
|
+
}
|
|
339
|
+
throw new DecodingError(`Invalid UTCTime "${s}"`, 0, "invalid-contents");
|
|
331
340
|
}
|
|
332
341
|
const year2 = Number(match[1]);
|
|
333
342
|
const value = {
|
|
@@ -337,7 +346,7 @@ export function decodeUtcTime(b, canonical = false) {
|
|
|
337
346
|
hour: Number(match[4]),
|
|
338
347
|
minute: Number(match[5]),
|
|
339
348
|
second: match[6] === undefined || match[6] === "" ? 0 : Number(match[6]),
|
|
340
|
-
utcOffsetMinutes: parseTzOffset(match[7]),
|
|
349
|
+
utcOffsetMinutes: parseTzOffset(match[7], s),
|
|
341
350
|
};
|
|
342
351
|
checkDecodedFields("UTCTime", value);
|
|
343
352
|
return value;
|
|
@@ -427,9 +436,12 @@ export function decodeGeneralizedTime(b, canonical = false) {
|
|
|
427
436
|
const s = decodeText(b, "latin1");
|
|
428
437
|
const match = (canonical ? CANONICAL_GENERALIZED_TIME_PATTERN : GENERALIZED_TIME_PATTERN).exec(s);
|
|
429
438
|
if (match === null) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
439
|
+
if (canonical && GENERALIZED_TIME_PATTERN.test(s)) {
|
|
440
|
+
// What BER refuses is invalid before it is non-canonical.
|
|
441
|
+
decodeGeneralizedTime(b, false);
|
|
442
|
+
throw new DecodingError(`GeneralizedTime "${s}" is not in the DER form YYYYMMDDHHMMSS[.f]Z (X.690 §11.7)`, 0, "non-canonical");
|
|
443
|
+
}
|
|
444
|
+
throw new DecodingError(`Invalid GeneralizedTime "${s}"`, 0, "invalid-contents");
|
|
433
445
|
}
|
|
434
446
|
const fields = {
|
|
435
447
|
year: Number(match[1]),
|
|
@@ -444,7 +456,7 @@ export function decodeGeneralizedTime(b, canonical = false) {
|
|
|
444
456
|
const fraction = fractionDigits === undefined
|
|
445
457
|
? undefined
|
|
446
458
|
: Math.min(Number(`0.${fractionDigits}`), LARGEST_FRACTION);
|
|
447
|
-
const utcOffsetMinutes = match[8] === undefined ? undefined : parseTzOffset(match[8]);
|
|
459
|
+
const utcOffsetMinutes = match[8] === undefined ? undefined : parseTzOffset(match[8], s);
|
|
448
460
|
return {
|
|
449
461
|
...fields,
|
|
450
462
|
...(fraction !== undefined && fraction !== 0 ? { fraction } : {}),
|