@recoillink/cli 0.0.0-stage → 45.0.1
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/LICENSE.md +193 -0
- package/README.md +149 -2
- package/bundle/154.index.js +462 -0
- package/bundle/230.index.js +569 -0
- package/bundle/25.index.js +9569 -0
- package/bundle/267.index.js +1386 -0
- package/bundle/308.index.js +5121 -0
- package/bundle/367.index.js +4 -0
- package/bundle/369.index.js +3443 -0
- package/bundle/529.index.js +3596 -0
- package/bundle/576.index.js +36 -0
- package/bundle/610.index.js +86 -0
- package/bundle/617.index.js +1612 -0
- package/bundle/628.index.js +152 -0
- package/bundle/633.index.js +86 -0
- package/bundle/697.index.js +410 -0
- package/bundle/7183ea1c1bf0a5da980d.js +214 -0
- package/bundle/748.index.js +672 -0
- package/bundle/78.index.js +372 -0
- package/bundle/841.index.js +2093 -0
- package/bundle/868.index.js +290 -0
- package/bundle/902.index.js +173 -0
- package/bundle/956.index.js +9901 -0
- package/bundle/aleo_wasm.wasm +0 -0
- package/bundle/aleo_wasm1.wasm +0 -0
- package/bundle/build/Release/bigint_buffer.node +0 -0
- package/bundle/file.js +12 -0
- package/bundle/index.js +4 -0
- package/bundle/package.json +3 -0
- package/bundle/worker-pipeline.js +38 -0
- package/bundle/worker.js +54 -0
- package/bundle/worker1.js +171 -0
- package/bundle/worker2.js +19834 -0
- package/bundle/worker3.js +19834 -0
- package/examples/aleo/core-config.yaml +19 -0
- package/examples/ccip/ccip-warp-route.yaml +26 -0
- package/examples/ccip/multi-chain-ccip-warp-route.yaml +81 -0
- package/examples/chain-config.yaml +42 -0
- package/examples/contract-artifacts.yaml +20 -0
- package/examples/core-config.yaml +19 -0
- package/examples/cosmosnative/core-config.yaml +20 -0
- package/examples/cosmosnative/warp-route-deployment.yaml +21 -0
- package/examples/crosschain/README.md +31 -0
- package/examples/crosschain/cosmosnative/core-config.yaml +69 -0
- package/examples/crosschain/ethereum/core-config.yaml +70 -0
- package/examples/crosschain/radix/core-config.yaml +96 -0
- package/examples/fork/file-transactions.yaml +5 -0
- package/examples/fork/timelock-testing.yaml +36 -0
- package/examples/fork/warp-route-update.yaml +100 -0
- package/examples/hooks.yaml +70 -0
- package/examples/ism-advanced.yaml +33 -0
- package/examples/ism.yaml +13 -0
- package/examples/radix/core-config.yaml +29 -0
- package/examples/sealevel/core-config-apply.yaml +7 -0
- package/examples/sealevel/core-config-composite-ism.yaml +21 -0
- package/examples/sealevel/core-config.yaml +12 -0
- package/examples/sealevel/igp-hook-config.yaml +13 -0
- package/examples/sealevel/warp-config-routing-message-id-multisig-ism.yaml +21 -0
- package/examples/starknet/core-config.yaml +20 -0
- package/examples/submit/strategy/file-strategy.yaml +8 -0
- package/examples/submit/strategy/gnosis-chain-strategy.yaml +10 -0
- package/examples/submit/strategy/gnosis-chain-tx-builder-strategy.yaml +6 -0
- package/examples/submit/strategy/gnosis-strategy-avalanche.yaml +4 -0
- package/examples/submit/strategy/gnosis-tx-builder-ica-strategy.yaml +20 -0
- package/examples/submit/strategy/ica-timelock-strategy.yaml +15 -0
- package/examples/submit/strategy/impersonated-account-strategy.yaml +4 -0
- package/examples/submit/strategy/json-rpc-chain-strategy.yaml +8 -0
- package/examples/submit/strategy/json-rpc-ica-strategy.yaml +13 -0
- package/examples/submit/strategy/json-rpc-strategy.yaml +3 -0
- package/examples/submit/strategy/json-rpc-timelock-strategy.yaml +17 -0
- package/examples/submit/strategy/starknet-json-rpc-chain-strategy.yaml +11 -0
- package/examples/submit/transactions/anvil-transactions.yaml +10 -0
- package/examples/submit/transactions/avalanche-transactions.json +8 -0
- package/examples/submit/transactions/sepolia-transactions.json +8 -0
- package/examples/tron-core-config.yaml +18 -0
- package/examples/warp-base.yaml +24 -0
- package/examples/warp-config-predicate-mainnet.yaml +14 -0
- package/examples/warp-deployed-predicate-mainnet.yaml +19 -0
- package/examples/warp-ethereum.yaml +19 -0
- package/examples/warp-route-deployment.yaml +21 -0
- package/package.json +117 -3
|
@@ -0,0 +1,2093 @@
|
|
|
1
|
+
export const id = 841;
|
|
2
|
+
export const ids = [841];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 48841:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
AsnParser: () => (/* reexport */ parser_AsnParser),
|
|
12
|
+
AsnProp: () => (/* reexport */ AsnProp),
|
|
13
|
+
AsnPropTypes: () => (/* reexport */ enums_AsnPropTypes),
|
|
14
|
+
AsnType: () => (/* reexport */ AsnType),
|
|
15
|
+
AsnTypeTypes: () => (/* reexport */ enums_AsnTypeTypes)
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// UNUSED EXPORTS: AsnAnyConverter, AsnArray, AsnBitStringConverter, AsnBmpStringConverter, AsnBooleanConverter, AsnCharacterStringConverter, AsnChoiceType, AsnConstructedOctetStringConverter, AsnConvert, AsnEnumeratedConverter, AsnGeneralStringConverter, AsnGeneralizedTimeConverter, AsnGraphicStringConverter, AsnIA5StringConverter, AsnIntegerArrayBufferConverter, AsnIntegerBigIntConverter, AsnIntegerConverter, AsnNullConverter, AsnNumericStringConverter, AsnObjectIdentifierConverter, AsnOctetStringConverter, AsnPrintableStringConverter, AsnRelativeObjectIdentifierConverter, AsnSchemaValidationError, AsnSequenceType, AsnSerializer, AsnSetType, AsnTeletexStringConverter, AsnUTCTimeConverter, AsnUniversalStringConverter, AsnUtf8StringConverter, AsnVideotexStringConverter, AsnVisibleStringConverter, BitString, OctetString, defaultConverter
|
|
19
|
+
|
|
20
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/asn1js@3.0.10/node_modules/asn1js/build/index.js
|
|
21
|
+
var build = __webpack_require__(92452);
|
|
22
|
+
var build_namespaceObject = /*#__PURE__*/__webpack_require__.t(build, 2);
|
|
23
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/bytes/buffer-source.js
|
|
24
|
+
const ARRAY_BUFFER_TAG = "[object ArrayBuffer]";
|
|
25
|
+
const SHARED_ARRAY_BUFFER_TAG = "[object SharedArrayBuffer]";
|
|
26
|
+
function tagOf(value) {
|
|
27
|
+
return Object.prototype.toString.call(value);
|
|
28
|
+
}
|
|
29
|
+
function isDataViewConstructor(type) {
|
|
30
|
+
return type === DataView || type.prototype instanceof DataView;
|
|
31
|
+
}
|
|
32
|
+
function bytesPerElement(type) {
|
|
33
|
+
if (isDataViewConstructor(type)) {
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
const value = type.BYTES_PER_ELEMENT;
|
|
37
|
+
return value ?? 1;
|
|
38
|
+
}
|
|
39
|
+
function isArrayBufferViewLike(value) {
|
|
40
|
+
if (ArrayBuffer.isView(value)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (!value || typeof value !== "object") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const view = value;
|
|
47
|
+
return typeof view.byteOffset === "number"
|
|
48
|
+
&& typeof view.byteLength === "number"
|
|
49
|
+
&& isArrayBufferLike(view.buffer);
|
|
50
|
+
}
|
|
51
|
+
function copyBytes(data) {
|
|
52
|
+
const view = toUint8Array(data);
|
|
53
|
+
const copy = new Uint8Array(view.byteLength);
|
|
54
|
+
copy.set(view);
|
|
55
|
+
return copy;
|
|
56
|
+
}
|
|
57
|
+
function isArrayBuffer(value) {
|
|
58
|
+
return tagOf(value) === ARRAY_BUFFER_TAG;
|
|
59
|
+
}
|
|
60
|
+
function isSharedArrayBuffer(value) {
|
|
61
|
+
return typeof SharedArrayBuffer !== "undefined" && tagOf(value) === SHARED_ARRAY_BUFFER_TAG;
|
|
62
|
+
}
|
|
63
|
+
function isArrayBufferLike(value) {
|
|
64
|
+
return isArrayBuffer(value) || isSharedArrayBuffer(value);
|
|
65
|
+
}
|
|
66
|
+
function isArrayBufferView(value) {
|
|
67
|
+
return isArrayBufferViewLike(value);
|
|
68
|
+
}
|
|
69
|
+
function buffer_source_isBufferSource(value) {
|
|
70
|
+
return isArrayBufferLike(value) || isArrayBufferView(value);
|
|
71
|
+
}
|
|
72
|
+
function assertBufferSource(value) {
|
|
73
|
+
if (!buffer_source_isBufferSource(value)) {
|
|
74
|
+
throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function toUint8Array(data) {
|
|
78
|
+
assertBufferSource(data);
|
|
79
|
+
if (isArrayBufferLike(data)) {
|
|
80
|
+
return new Uint8Array(data);
|
|
81
|
+
}
|
|
82
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
83
|
+
}
|
|
84
|
+
function toUint8ArrayCopy(data) {
|
|
85
|
+
return copyBytes(data);
|
|
86
|
+
}
|
|
87
|
+
function buffer_source_toArrayBuffer(data) {
|
|
88
|
+
assertBufferSource(data);
|
|
89
|
+
if (isArrayBuffer(data)) {
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
92
|
+
const buffer = new ArrayBuffer(data.byteLength);
|
|
93
|
+
new Uint8Array(buffer).set(toUint8Array(data));
|
|
94
|
+
return buffer;
|
|
95
|
+
}
|
|
96
|
+
function toArrayBufferLike(data) {
|
|
97
|
+
assertBufferSource(data);
|
|
98
|
+
if (isArrayBufferLike(data)) {
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
101
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
102
|
+
return data.buffer;
|
|
103
|
+
}
|
|
104
|
+
return copyBytes(data).buffer;
|
|
105
|
+
}
|
|
106
|
+
function toView(data, type) {
|
|
107
|
+
assertBufferSource(data);
|
|
108
|
+
if (ArrayBuffer.isView(data) && data.constructor === type) {
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
const view = toUint8Array(data);
|
|
112
|
+
const elementSize = bytesPerElement(type);
|
|
113
|
+
if (view.byteOffset % elementSize !== 0 || view.byteLength % elementSize !== 0) {
|
|
114
|
+
throw new RangeError(`Cannot create ${type.name} over unaligned byte range`);
|
|
115
|
+
}
|
|
116
|
+
if (isDataViewConstructor(type)) {
|
|
117
|
+
return new type(view.buffer, view.byteOffset, view.byteLength);
|
|
118
|
+
}
|
|
119
|
+
return new type(view.buffer, view.byteOffset, view.byteLength / elementSize);
|
|
120
|
+
}
|
|
121
|
+
function toViewCopy(data, type) {
|
|
122
|
+
const copy = toUint8ArrayCopy(data);
|
|
123
|
+
return toView(copy, type);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/bytes/index.js
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/binary.js
|
|
133
|
+
|
|
134
|
+
function encode(data) {
|
|
135
|
+
const bytes = toUint8Array(data);
|
|
136
|
+
let result = "";
|
|
137
|
+
for (const byte of bytes) {
|
|
138
|
+
result += String.fromCharCode(byte);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
function decode(text) {
|
|
143
|
+
const result = new Uint8Array(text.length);
|
|
144
|
+
for (let i = 0; i < text.length; i++) {
|
|
145
|
+
result[i] = text.charCodeAt(i) & 0xff;
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function is(text) {
|
|
150
|
+
return typeof text === "string";
|
|
151
|
+
}
|
|
152
|
+
const binary = { encode, decode, is };
|
|
153
|
+
|
|
154
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/hex.js
|
|
155
|
+
|
|
156
|
+
const HEX_CHARACTER_REGEX = /^[0-9a-f]$/i;
|
|
157
|
+
const COMMON_SEPARATORS = [" ", "\t", "\n", "\r", ":", "-", "."];
|
|
158
|
+
function resolveSeparators(options) {
|
|
159
|
+
if (options.separators === "none") {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
if (!options.separators || options.separators === "common") {
|
|
163
|
+
return COMMON_SEPARATORS;
|
|
164
|
+
}
|
|
165
|
+
return options.separators;
|
|
166
|
+
}
|
|
167
|
+
function validateSeparator(separator) {
|
|
168
|
+
if (!separator) {
|
|
169
|
+
throw new TypeError("Hex separators must be non-empty strings");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function matchSeparator(text, index, separators) {
|
|
173
|
+
for (const separator of separators) {
|
|
174
|
+
if (text.startsWith(separator, index)) {
|
|
175
|
+
return separator;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
function detectCase(text) {
|
|
181
|
+
const hasUpper = /[A-F]/.test(text);
|
|
182
|
+
const hasLower = /[a-f]/.test(text);
|
|
183
|
+
return hasUpper && !hasLower ? "upper" : "lower";
|
|
184
|
+
}
|
|
185
|
+
function detectLineSeparator(text) {
|
|
186
|
+
const match = /\r\n|\n/.exec(text);
|
|
187
|
+
if (!match) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
return match[0] === "\r\n" ? "\r\n" : "\n";
|
|
191
|
+
}
|
|
192
|
+
function compactForDetection(text) {
|
|
193
|
+
return text.replace(/[^0-9a-f]/gi, "");
|
|
194
|
+
}
|
|
195
|
+
function detectGroup(text) {
|
|
196
|
+
const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
|
|
197
|
+
if (segments.length < 3) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
const hexSegments = segments.filter((_, index) => index % 2 === 0);
|
|
201
|
+
const separators = segments.filter((_, index) => index % 2 === 1);
|
|
202
|
+
const separator = separators[0];
|
|
203
|
+
if (!separator || separators.some((item) => item !== separator)) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
const firstLength = hexSegments[0]?.length ?? 0;
|
|
210
|
+
if (!firstLength) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
size: firstLength / 2,
|
|
221
|
+
separator,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function detectFormat(text) {
|
|
225
|
+
const trimmed = text.trim();
|
|
226
|
+
const prefix = /^0x/i.test(trimmed) ? "0x" : "";
|
|
227
|
+
const body = prefix ? trimmed.slice(2) : trimmed;
|
|
228
|
+
const lineSeparator = detectLineSeparator(body);
|
|
229
|
+
const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0);
|
|
230
|
+
const sampleLine = lines[0]?.trim() ?? "";
|
|
231
|
+
const group = detectGroup(sampleLine);
|
|
232
|
+
const format = {
|
|
233
|
+
case: detectCase(trimmed),
|
|
234
|
+
prefix,
|
|
235
|
+
};
|
|
236
|
+
if (group) {
|
|
237
|
+
format.group = group;
|
|
238
|
+
}
|
|
239
|
+
if (lineSeparator && lines.length > 1) {
|
|
240
|
+
const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2;
|
|
241
|
+
if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) {
|
|
242
|
+
format.line = {
|
|
243
|
+
bytesPerLine: firstLineBytes,
|
|
244
|
+
separator: lineSeparator,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return format;
|
|
249
|
+
}
|
|
250
|
+
function normalizeText(text, options) {
|
|
251
|
+
const allowPrefix = options.allowPrefix ?? true;
|
|
252
|
+
const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length);
|
|
253
|
+
for (const separator of separators) {
|
|
254
|
+
validateSeparator(separator);
|
|
255
|
+
}
|
|
256
|
+
let working = text.trim();
|
|
257
|
+
if (/^0x/i.test(working)) {
|
|
258
|
+
if (!allowPrefix) {
|
|
259
|
+
throw new TypeError("Hexadecimal text must not include a 0x prefix");
|
|
260
|
+
}
|
|
261
|
+
working = working.slice(2);
|
|
262
|
+
}
|
|
263
|
+
let normalized = "";
|
|
264
|
+
let lastTokenWasSeparator = false;
|
|
265
|
+
for (let index = 0; index < working.length;) {
|
|
266
|
+
const character = working[index] ?? "";
|
|
267
|
+
if (HEX_CHARACTER_REGEX.test(character)) {
|
|
268
|
+
normalized += character;
|
|
269
|
+
lastTokenWasSeparator = false;
|
|
270
|
+
index += 1;
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const separator = matchSeparator(working, index, separators);
|
|
274
|
+
if (!separator) {
|
|
275
|
+
throw new TypeError("Input is not valid hexadecimal text");
|
|
276
|
+
}
|
|
277
|
+
if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) {
|
|
278
|
+
throw new TypeError("Hexadecimal text contains misplaced separators");
|
|
279
|
+
}
|
|
280
|
+
lastTokenWasSeparator = true;
|
|
281
|
+
index += separator.length;
|
|
282
|
+
}
|
|
283
|
+
if (options.strict && lastTokenWasSeparator && normalized.length > 0) {
|
|
284
|
+
throw new TypeError("Hexadecimal text must not end with a separator");
|
|
285
|
+
}
|
|
286
|
+
if (normalized.length % 2 !== 0) {
|
|
287
|
+
if (!options.allowOddLength) {
|
|
288
|
+
throw new TypeError("Hexadecimal text must contain an even number of characters");
|
|
289
|
+
}
|
|
290
|
+
normalized = `0${normalized}`;
|
|
291
|
+
}
|
|
292
|
+
return normalized.toLowerCase();
|
|
293
|
+
}
|
|
294
|
+
function groupPairs(pairs, group) {
|
|
295
|
+
if (!group) {
|
|
296
|
+
return pairs.join("");
|
|
297
|
+
}
|
|
298
|
+
if (!Number.isInteger(group.size) || group.size < 1) {
|
|
299
|
+
throw new RangeError("Hex group size must be a positive integer");
|
|
300
|
+
}
|
|
301
|
+
const chunks = [];
|
|
302
|
+
for (let index = 0; index < pairs.length; index += group.size) {
|
|
303
|
+
chunks.push(pairs.slice(index, index + group.size).join(""));
|
|
304
|
+
}
|
|
305
|
+
return chunks.join(group.separator);
|
|
306
|
+
}
|
|
307
|
+
function normalize(text, options = {}) {
|
|
308
|
+
return normalizeText(text, options);
|
|
309
|
+
}
|
|
310
|
+
function hex_is(text, options = {}) {
|
|
311
|
+
if (typeof text !== "string") {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
normalize(text, options);
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function hex_encode(data, options = {}) {
|
|
323
|
+
const bytes = toUint8Array(data);
|
|
324
|
+
const casing = options.case ?? "lower";
|
|
325
|
+
const pairs = Array.from(bytes, (byte) => {
|
|
326
|
+
const text = byte.toString(16).padStart(2, "0");
|
|
327
|
+
return casing === "upper" ? text.toUpperCase() : text;
|
|
328
|
+
});
|
|
329
|
+
let body = "";
|
|
330
|
+
if (options.line) {
|
|
331
|
+
const bytesPerLine = options.line.bytesPerLine;
|
|
332
|
+
if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) {
|
|
333
|
+
throw new RangeError("Hex bytesPerLine must be a positive integer");
|
|
334
|
+
}
|
|
335
|
+
const separator = options.line.separator ?? "\n";
|
|
336
|
+
const lines = [];
|
|
337
|
+
for (let index = 0; index < pairs.length; index += bytesPerLine) {
|
|
338
|
+
lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group));
|
|
339
|
+
}
|
|
340
|
+
body = lines.join(separator);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
body = groupPairs(pairs, options.group);
|
|
344
|
+
}
|
|
345
|
+
return `${options.prefix ?? ""}${body}`;
|
|
346
|
+
}
|
|
347
|
+
function hex_decode(text, options = {}) {
|
|
348
|
+
const normalized = normalize(text, options);
|
|
349
|
+
const result = new Uint8Array(normalized.length / 2);
|
|
350
|
+
for (let i = 0; i < normalized.length; i += 2) {
|
|
351
|
+
result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
function parse(text, options = {}) {
|
|
356
|
+
const normalized = normalize(text, options);
|
|
357
|
+
return {
|
|
358
|
+
bytes: hex_decode(normalized),
|
|
359
|
+
format: detectFormat(text),
|
|
360
|
+
normalized,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function format(data, value) {
|
|
364
|
+
return hex_encode(data, value);
|
|
365
|
+
}
|
|
366
|
+
const formats = {
|
|
367
|
+
compact: Object.freeze({}),
|
|
368
|
+
upper: Object.freeze({ case: "upper" }),
|
|
369
|
+
colon: Object.freeze({ group: { size: 1, separator: ":" } }),
|
|
370
|
+
colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }),
|
|
371
|
+
groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }),
|
|
372
|
+
prefixed: Object.freeze({ prefix: "0x" }),
|
|
373
|
+
};
|
|
374
|
+
const hex = { encode: hex_encode, decode: hex_decode, format, formats, is: hex_is, normalize, parse };
|
|
375
|
+
|
|
376
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/utf8.js
|
|
377
|
+
|
|
378
|
+
function utf8_encode(text) {
|
|
379
|
+
return new TextEncoder().encode(text);
|
|
380
|
+
}
|
|
381
|
+
function utf8_decode(data) {
|
|
382
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(toUint8Array(data));
|
|
383
|
+
}
|
|
384
|
+
const utf8 = { encode: utf8_encode, decode: utf8_decode };
|
|
385
|
+
|
|
386
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/utf16.js
|
|
387
|
+
|
|
388
|
+
function utf16_encode(text, options = {}) {
|
|
389
|
+
const result = new ArrayBuffer(text.length * 2);
|
|
390
|
+
const view = new DataView(result);
|
|
391
|
+
for (let i = 0; i < text.length; i++) {
|
|
392
|
+
view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false);
|
|
393
|
+
}
|
|
394
|
+
return new Uint8Array(result);
|
|
395
|
+
}
|
|
396
|
+
function utf16_decode(data, options = {}) {
|
|
397
|
+
const buffer = buffer_source_toArrayBuffer(data);
|
|
398
|
+
const view = new DataView(buffer);
|
|
399
|
+
let result = "";
|
|
400
|
+
for (let i = 0; i < buffer.byteLength; i += 2) {
|
|
401
|
+
result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false));
|
|
402
|
+
}
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
405
|
+
const utf16 = { encode: utf16_encode, decode: utf16_decode };
|
|
406
|
+
|
|
407
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/base64.js
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
411
|
+
function nodeBuffer() {
|
|
412
|
+
return globalThis.Buffer;
|
|
413
|
+
}
|
|
414
|
+
function base64_normalize(text) {
|
|
415
|
+
return text.replace(/[\n\r\t ]/g, "");
|
|
416
|
+
}
|
|
417
|
+
function pad(text) {
|
|
418
|
+
const remainder = text.length % 4;
|
|
419
|
+
return remainder ? text + "=".repeat(4 - remainder) : text;
|
|
420
|
+
}
|
|
421
|
+
function base64_is(text) {
|
|
422
|
+
if (typeof text !== "string") {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
const normalized = base64_normalize(text);
|
|
426
|
+
return normalized === "" || BASE64_REGEX.test(normalized);
|
|
427
|
+
}
|
|
428
|
+
function base64_encode(data, _options) {
|
|
429
|
+
const bytes = toUint8Array(data);
|
|
430
|
+
const buffer = nodeBuffer();
|
|
431
|
+
if (buffer) {
|
|
432
|
+
return buffer.from(bytes).toString("base64");
|
|
433
|
+
}
|
|
434
|
+
return btoa(encode(bytes));
|
|
435
|
+
}
|
|
436
|
+
function base64_decode(text, _options) {
|
|
437
|
+
const normalized = base64_normalize(text);
|
|
438
|
+
if (!base64_is(normalized)) {
|
|
439
|
+
throw new TypeError("Input is not valid Base64 text");
|
|
440
|
+
}
|
|
441
|
+
const buffer = nodeBuffer();
|
|
442
|
+
if (buffer) {
|
|
443
|
+
return new Uint8Array(buffer.from(normalized, "base64"));
|
|
444
|
+
}
|
|
445
|
+
return decode(atob(normalized));
|
|
446
|
+
}
|
|
447
|
+
const base64 = { encode: base64_encode, decode: base64_decode, is: base64_is, normalize: base64_normalize, pad };
|
|
448
|
+
|
|
449
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/base64url.js
|
|
450
|
+
|
|
451
|
+
const BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/;
|
|
452
|
+
function base64url_normalize(text) {
|
|
453
|
+
return text.replace(/[\n\r\t ]/g, "");
|
|
454
|
+
}
|
|
455
|
+
function base64url_is(text) {
|
|
456
|
+
return typeof text === "string" && BASE64URL_REGEX.test(base64url_normalize(text));
|
|
457
|
+
}
|
|
458
|
+
function base64url_encode(data, _options) {
|
|
459
|
+
return base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
460
|
+
}
|
|
461
|
+
function base64url_decode(text, _options) {
|
|
462
|
+
const normalized = base64url_normalize(text);
|
|
463
|
+
if (!base64url_is(normalized)) {
|
|
464
|
+
throw new TypeError("Input is not valid Base64Url text");
|
|
465
|
+
}
|
|
466
|
+
return base64.decode(base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/")));
|
|
467
|
+
}
|
|
468
|
+
const base64url = { encode: base64url_encode, decode: base64url_decode, is: base64url_is, normalize: base64url_normalize };
|
|
469
|
+
|
|
470
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/encoding/index.js
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/pem/pem.js
|
|
479
|
+
|
|
480
|
+
const LABEL_REGEX = /^[A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]$/i;
|
|
481
|
+
const PEM_BLOCK_REGEX = /-----BEGIN ([^-]+)-----([\s\S]*?)-----END \1-----/g;
|
|
482
|
+
function assertLabel(label) {
|
|
483
|
+
if (!LABEL_REGEX.test(label)) {
|
|
484
|
+
throw new TypeError(`Invalid PEM label '${label}'`);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function wrap(text, lineLength) {
|
|
488
|
+
const result = [];
|
|
489
|
+
for (let i = 0; i < text.length; i += lineLength) {
|
|
490
|
+
result.push(text.slice(i, i + lineLength));
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
function parseBody(body) {
|
|
495
|
+
const normalized = body.trim().replace(/\r\n/g, "\n");
|
|
496
|
+
const lines = normalized.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
497
|
+
const headers = {};
|
|
498
|
+
let index = 0;
|
|
499
|
+
for (; index < lines.length; index++) {
|
|
500
|
+
const line = lines[index];
|
|
501
|
+
const separator = line.indexOf(":");
|
|
502
|
+
if (separator <= 0) {
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
headers[line.slice(0, separator).trim()] = line.slice(separator + 1).trim();
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
headers: Object.keys(headers).length ? headers : undefined,
|
|
509
|
+
base64Lines: lines.slice(index),
|
|
510
|
+
base64Text: lines.slice(index).join(""),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function detectNewline(text) {
|
|
514
|
+
return /\r\n/.test(text) ? "\r\n" : "\n";
|
|
515
|
+
}
|
|
516
|
+
function collectBlocks(text, options = {}) {
|
|
517
|
+
const blocks = [];
|
|
518
|
+
const requestedLabel = options.label;
|
|
519
|
+
let match;
|
|
520
|
+
PEM_BLOCK_REGEX.lastIndex = 0;
|
|
521
|
+
while ((match = PEM_BLOCK_REGEX.exec(text))) {
|
|
522
|
+
const label = match[1].trim();
|
|
523
|
+
if (requestedLabel && label !== requestedLabel) {
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
assertLabel(label);
|
|
527
|
+
const parsed = parseBody(match[2]);
|
|
528
|
+
blocks.push({
|
|
529
|
+
label,
|
|
530
|
+
data: base64.decode(parsed.base64Text),
|
|
531
|
+
headers: parsed.headers,
|
|
532
|
+
lineLength: parsed.base64Lines[0]?.length ?? 64,
|
|
533
|
+
newline: detectNewline(match[0]),
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
if (options.strict && blocks.length === 0) {
|
|
537
|
+
throw new TypeError(requestedLabel
|
|
538
|
+
? `No PEM block with label '${requestedLabel}' was found`
|
|
539
|
+
: "No PEM blocks were found");
|
|
540
|
+
}
|
|
541
|
+
return blocks;
|
|
542
|
+
}
|
|
543
|
+
function pem_encode(label, data, options = {}) {
|
|
544
|
+
assertLabel(label);
|
|
545
|
+
const lineLength = options.lineLength ?? 64;
|
|
546
|
+
if (!Number.isInteger(lineLength) || lineLength < 1) {
|
|
547
|
+
throw new RangeError("PEM lineLength must be a positive integer");
|
|
548
|
+
}
|
|
549
|
+
const newline = options.newline ?? "\n";
|
|
550
|
+
const lines = [`-----BEGIN ${label}-----`];
|
|
551
|
+
if (options.headers) {
|
|
552
|
+
for (const [name, value] of Object.entries(options.headers)) {
|
|
553
|
+
lines.push(`${name}: ${value}`);
|
|
554
|
+
}
|
|
555
|
+
lines.push("");
|
|
556
|
+
}
|
|
557
|
+
lines.push(...wrap(base64.encode(data), lineLength));
|
|
558
|
+
lines.push(`-----END ${label}-----`);
|
|
559
|
+
return `${lines.join(newline)}${newline}`;
|
|
560
|
+
}
|
|
561
|
+
function encodeMany(blocks, options = {}) {
|
|
562
|
+
return blocks.map((block) => pem_encode(block.label, block.data, { ...options, headers: block.headers ?? options.headers })).join("");
|
|
563
|
+
}
|
|
564
|
+
function pem_decode(text, options = {}) {
|
|
565
|
+
return collectBlocks(text, options).map(({ lineLength: _lineLength, newline: _newline, ...block }) => block);
|
|
566
|
+
}
|
|
567
|
+
function find(text, label) {
|
|
568
|
+
return pem_decode(text, { label })[0];
|
|
569
|
+
}
|
|
570
|
+
function findAll(text, label) {
|
|
571
|
+
return pem_decode(text, { label });
|
|
572
|
+
}
|
|
573
|
+
function decodeFirst(text, label) {
|
|
574
|
+
const [block] = pem_decode(text, { label, strict: true });
|
|
575
|
+
return block.data;
|
|
576
|
+
}
|
|
577
|
+
function pem_parse(text, options = {}) {
|
|
578
|
+
const [block] = collectBlocks(text, { ...options, strict: true });
|
|
579
|
+
const format = {
|
|
580
|
+
label: block.label,
|
|
581
|
+
headers: block.headers,
|
|
582
|
+
lineLength: block.lineLength,
|
|
583
|
+
newline: block.newline,
|
|
584
|
+
};
|
|
585
|
+
return {
|
|
586
|
+
bytes: block.data,
|
|
587
|
+
format,
|
|
588
|
+
normalized: pem_encode(block.label, block.data, format),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function pem_format(data, value) {
|
|
592
|
+
return pem_encode(value.label, data, value);
|
|
593
|
+
}
|
|
594
|
+
const pem = { decode: pem_decode, decodeFirst, encode: pem_encode, encodeMany, find, findAll, format: pem_format, parse: pem_parse };
|
|
595
|
+
const pemConverter = {
|
|
596
|
+
name: "pem",
|
|
597
|
+
encode: (data, options) => {
|
|
598
|
+
if (!options?.label) {
|
|
599
|
+
throw new TypeError("PEM label is required");
|
|
600
|
+
}
|
|
601
|
+
return pem_encode(options.label, data, options);
|
|
602
|
+
},
|
|
603
|
+
decode: (text, options) => decodeFirst(text, options?.label),
|
|
604
|
+
format: pem_format,
|
|
605
|
+
is: (text) => typeof text === "string" && /-----BEGIN [^-]+-----/.test(text),
|
|
606
|
+
parse: pem_parse,
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/pem/index.js
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/converters/registry.js
|
|
613
|
+
function keyOf(name) {
|
|
614
|
+
return name.trim().toLowerCase();
|
|
615
|
+
}
|
|
616
|
+
function toError(error) {
|
|
617
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
618
|
+
}
|
|
619
|
+
function removeConverter(converters, primaryNames, converter) {
|
|
620
|
+
for (const alias of [converter.name, ...(converter.aliases ?? [])]) {
|
|
621
|
+
converters.delete(keyOf(alias));
|
|
622
|
+
}
|
|
623
|
+
primaryNames.delete(keyOf(converter.name));
|
|
624
|
+
}
|
|
625
|
+
function requireCapability(converter, name, capability) {
|
|
626
|
+
const method = converter[capability];
|
|
627
|
+
if (typeof method !== "function") {
|
|
628
|
+
throw new Error(`Converter '${name}' does not support ${capability}()`);
|
|
629
|
+
}
|
|
630
|
+
return method;
|
|
631
|
+
}
|
|
632
|
+
function detectConfidence(name, text, converter) {
|
|
633
|
+
const normalizedName = keyOf(converter.name || name);
|
|
634
|
+
const trimmed = text.trim();
|
|
635
|
+
if (!trimmed) {
|
|
636
|
+
return 0;
|
|
637
|
+
}
|
|
638
|
+
let accepted = false;
|
|
639
|
+
if (converter.is) {
|
|
640
|
+
accepted = converter.is(text);
|
|
641
|
+
}
|
|
642
|
+
let decodable = false;
|
|
643
|
+
try {
|
|
644
|
+
converter.decode(text);
|
|
645
|
+
decodable = true;
|
|
646
|
+
}
|
|
647
|
+
catch {
|
|
648
|
+
decodable = false;
|
|
649
|
+
}
|
|
650
|
+
if (!accepted && !decodable) {
|
|
651
|
+
return 0;
|
|
652
|
+
}
|
|
653
|
+
switch (normalizedName) {
|
|
654
|
+
case "pem":
|
|
655
|
+
return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0;
|
|
656
|
+
case "hex": {
|
|
657
|
+
const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, "");
|
|
658
|
+
if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) {
|
|
659
|
+
return 0;
|
|
660
|
+
}
|
|
661
|
+
if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) {
|
|
662
|
+
return 0.95;
|
|
663
|
+
}
|
|
664
|
+
if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) {
|
|
665
|
+
return 0.8;
|
|
666
|
+
}
|
|
667
|
+
return 0.45;
|
|
668
|
+
}
|
|
669
|
+
case "base64url":
|
|
670
|
+
if (/[-_]/.test(trimmed)) {
|
|
671
|
+
return 0.95;
|
|
672
|
+
}
|
|
673
|
+
if (/=/.test(trimmed)) {
|
|
674
|
+
return 0.1;
|
|
675
|
+
}
|
|
676
|
+
return 0.6;
|
|
677
|
+
case "base64":
|
|
678
|
+
if (/[+/=]/.test(trimmed)) {
|
|
679
|
+
return 0.9;
|
|
680
|
+
}
|
|
681
|
+
return 0.55;
|
|
682
|
+
case "binary":
|
|
683
|
+
case "utf8":
|
|
684
|
+
case "utf16be":
|
|
685
|
+
case "utf16le":
|
|
686
|
+
return 0;
|
|
687
|
+
default:
|
|
688
|
+
return accepted && decodable ? 0.75 : 0.5;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function createConverterRegistry(initialConverters = []) {
|
|
692
|
+
const converters = new Map();
|
|
693
|
+
const primaryNames = new Set();
|
|
694
|
+
const api = {
|
|
695
|
+
register(converter, options = {}) {
|
|
696
|
+
if (!converter.name || !keyOf(converter.name)) {
|
|
697
|
+
throw new TypeError("Converter name is required");
|
|
698
|
+
}
|
|
699
|
+
const names = [...new Set([converter.name, ...(converter.aliases ?? [])].map(keyOf))];
|
|
700
|
+
const conflicts = new Set();
|
|
701
|
+
for (const name of names) {
|
|
702
|
+
const existing = converters.get(name);
|
|
703
|
+
if (!existing) {
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (!options.override) {
|
|
707
|
+
throw new Error(`Converter '${name}' is already registered`);
|
|
708
|
+
}
|
|
709
|
+
conflicts.add(existing);
|
|
710
|
+
}
|
|
711
|
+
for (const conflicting of conflicts) {
|
|
712
|
+
removeConverter(converters, primaryNames, conflicting);
|
|
713
|
+
}
|
|
714
|
+
for (const name of names) {
|
|
715
|
+
converters.set(name, converter);
|
|
716
|
+
}
|
|
717
|
+
primaryNames.add(keyOf(converter.name));
|
|
718
|
+
return this;
|
|
719
|
+
},
|
|
720
|
+
unregister(name) {
|
|
721
|
+
const converter = converters.get(keyOf(name));
|
|
722
|
+
if (!converter) {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
removeConverter(converters, primaryNames, converter);
|
|
726
|
+
return true;
|
|
727
|
+
},
|
|
728
|
+
has(name) {
|
|
729
|
+
return converters.has(keyOf(name));
|
|
730
|
+
},
|
|
731
|
+
get(name) {
|
|
732
|
+
const converter = converters.get(keyOf(name));
|
|
733
|
+
if (!converter) {
|
|
734
|
+
throw new Error(`Converter '${name}' is not registered`);
|
|
735
|
+
}
|
|
736
|
+
return converter;
|
|
737
|
+
},
|
|
738
|
+
list() {
|
|
739
|
+
return [...primaryNames].map((name) => this.get(name));
|
|
740
|
+
},
|
|
741
|
+
encode(name, data, options) {
|
|
742
|
+
return this.get(name).encode(data, options);
|
|
743
|
+
},
|
|
744
|
+
decode(name, text, options) {
|
|
745
|
+
return this.get(name).decode(text, options);
|
|
746
|
+
},
|
|
747
|
+
tryDecode(name, text, options) {
|
|
748
|
+
try {
|
|
749
|
+
return { ok: true, bytes: this.decode(name, text, options) };
|
|
750
|
+
}
|
|
751
|
+
catch (error) {
|
|
752
|
+
return { ok: false, error: toError(error) };
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
normalize(name, text, options) {
|
|
756
|
+
const converter = this.get(name);
|
|
757
|
+
return requireCapability(converter, name, "normalize").call(converter, text, options);
|
|
758
|
+
},
|
|
759
|
+
parse(name, text, options) {
|
|
760
|
+
const converter = this.get(name);
|
|
761
|
+
return requireCapability(converter, name, "parse").call(converter, text, options);
|
|
762
|
+
},
|
|
763
|
+
format(name, data, format) {
|
|
764
|
+
const converter = this.get(name);
|
|
765
|
+
return requireCapability(converter, name, "format").call(converter, data, format);
|
|
766
|
+
},
|
|
767
|
+
transcode(text, options) {
|
|
768
|
+
const bytes = this.decode(options.from, text, options.fromOptions);
|
|
769
|
+
return this.encode(options.to, bytes, options.toOptions);
|
|
770
|
+
},
|
|
771
|
+
detect(text, options = {}) {
|
|
772
|
+
const formatNames = options.formats?.length
|
|
773
|
+
? options.formats.map((name) => String(name))
|
|
774
|
+
: this.list()
|
|
775
|
+
.map((converter) => converter.name)
|
|
776
|
+
.filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name)));
|
|
777
|
+
const detections = new Map();
|
|
778
|
+
for (const requestedName of formatNames) {
|
|
779
|
+
const converter = this.get(requestedName);
|
|
780
|
+
const confidence = detectConfidence(requestedName, text, converter);
|
|
781
|
+
if (confidence <= 0) {
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
const format = converter.name;
|
|
785
|
+
const current = detections.get(format);
|
|
786
|
+
if (!current || confidence > current.confidence) {
|
|
787
|
+
detections.set(format, { format, confidence });
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return [...detections.values()].sort((left, right) => right.confidence - left.confidence);
|
|
791
|
+
},
|
|
792
|
+
};
|
|
793
|
+
for (const converter of initialConverters) {
|
|
794
|
+
api.register(converter);
|
|
795
|
+
}
|
|
796
|
+
return api;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/converters/defaults.js
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
const binaryConverter = {
|
|
805
|
+
name: "binary",
|
|
806
|
+
aliases: ["latin1"],
|
|
807
|
+
encode: encode,
|
|
808
|
+
decode: decode,
|
|
809
|
+
is: is,
|
|
810
|
+
};
|
|
811
|
+
const hexConverter = {
|
|
812
|
+
name: "hex",
|
|
813
|
+
encode: hex_encode,
|
|
814
|
+
decode: hex_decode,
|
|
815
|
+
format: format,
|
|
816
|
+
is: hex_is,
|
|
817
|
+
normalize: normalize,
|
|
818
|
+
parse: parse,
|
|
819
|
+
};
|
|
820
|
+
const base64Converter = {
|
|
821
|
+
name: "base64",
|
|
822
|
+
aliases: ["b64"],
|
|
823
|
+
encode: base64_encode,
|
|
824
|
+
decode: base64_decode,
|
|
825
|
+
is: base64_is,
|
|
826
|
+
normalize: base64_normalize,
|
|
827
|
+
};
|
|
828
|
+
const base64urlConverter = {
|
|
829
|
+
name: "base64url",
|
|
830
|
+
aliases: ["base64-url", "b64url"],
|
|
831
|
+
encode: base64url_encode,
|
|
832
|
+
decode: base64url_decode,
|
|
833
|
+
is: base64url_is,
|
|
834
|
+
normalize: base64url_normalize,
|
|
835
|
+
};
|
|
836
|
+
const utf8Converter = {
|
|
837
|
+
name: "utf8",
|
|
838
|
+
aliases: ["utf-8"],
|
|
839
|
+
encode: (data) => utf8_decode(data),
|
|
840
|
+
decode: (text) => utf8_encode(text),
|
|
841
|
+
is: (text) => typeof text === "string",
|
|
842
|
+
};
|
|
843
|
+
const utf16beConverter = {
|
|
844
|
+
name: "utf16be",
|
|
845
|
+
aliases: ["utf16", "utf-16", "utf-16be"],
|
|
846
|
+
encode: (data) => utf16_decode(data),
|
|
847
|
+
decode: (text) => utf16_encode(text),
|
|
848
|
+
is: (text) => typeof text === "string",
|
|
849
|
+
};
|
|
850
|
+
const utf16leConverter = {
|
|
851
|
+
name: "utf16le",
|
|
852
|
+
aliases: ["utf-16le", "ucs2", "usc2"],
|
|
853
|
+
encode: (data) => utf16_decode(data, { littleEndian: true }),
|
|
854
|
+
decode: (text) => utf16_encode(text, { littleEndian: true }),
|
|
855
|
+
is: (text) => typeof text === "string",
|
|
856
|
+
};
|
|
857
|
+
const defaultConverters = [
|
|
858
|
+
binaryConverter,
|
|
859
|
+
hexConverter,
|
|
860
|
+
base64Converter,
|
|
861
|
+
base64urlConverter,
|
|
862
|
+
utf8Converter,
|
|
863
|
+
utf16beConverter,
|
|
864
|
+
utf16leConverter,
|
|
865
|
+
pemConverter,
|
|
866
|
+
];
|
|
867
|
+
const defaultConverterRegistry = createConverterRegistry(defaultConverters);
|
|
868
|
+
|
|
869
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/converters/convert.js
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
function convert_encode(name, data, ...args) {
|
|
874
|
+
return defaultConverterRegistry.encode(name, data, ...args);
|
|
875
|
+
}
|
|
876
|
+
function convert_decode(name, text, ...args) {
|
|
877
|
+
return defaultConverterRegistry.decode(name, text, ...args);
|
|
878
|
+
}
|
|
879
|
+
function tryDecode(name, text, ...args) {
|
|
880
|
+
return defaultConverterRegistry.tryDecode(name, text, ...args);
|
|
881
|
+
}
|
|
882
|
+
function convert_normalize(name, text, ...args) {
|
|
883
|
+
return defaultConverterRegistry.normalize(name, text, ...args);
|
|
884
|
+
}
|
|
885
|
+
function convert_parse(name, text, ...args) {
|
|
886
|
+
return defaultConverterRegistry.parse(name, text, ...args);
|
|
887
|
+
}
|
|
888
|
+
function convert_format(name, data, value) {
|
|
889
|
+
return defaultConverterRegistry.format(name, data, value);
|
|
890
|
+
}
|
|
891
|
+
function transcode(text, options) {
|
|
892
|
+
return defaultConverterRegistry.transcode(text, options);
|
|
893
|
+
}
|
|
894
|
+
function detect(text, options) {
|
|
895
|
+
return defaultConverterRegistry.detect(text, options);
|
|
896
|
+
}
|
|
897
|
+
function normalizeEncodingName(encoding) {
|
|
898
|
+
return encoding.toLowerCase();
|
|
899
|
+
}
|
|
900
|
+
const convert_convert = {
|
|
901
|
+
encode: convert_encode,
|
|
902
|
+
decode: convert_decode,
|
|
903
|
+
tryDecode,
|
|
904
|
+
normalize: convert_normalize,
|
|
905
|
+
parse: convert_parse,
|
|
906
|
+
format: convert_format,
|
|
907
|
+
transcode,
|
|
908
|
+
detect,
|
|
909
|
+
to(format, data, ...args) {
|
|
910
|
+
return convert_encode(format, data, ...args);
|
|
911
|
+
},
|
|
912
|
+
from(format, text, ...args) {
|
|
913
|
+
return convert_decode(format, text, ...args);
|
|
914
|
+
},
|
|
915
|
+
toString(data, encoding = "utf8") {
|
|
916
|
+
return convert_encode(encoding, data);
|
|
917
|
+
},
|
|
918
|
+
fromString(text, encoding = "utf8") {
|
|
919
|
+
if (normalizeEncodingName(encoding) === "hex") {
|
|
920
|
+
return buffer_source_toArrayBuffer(hex_decode(text, { allowOddLength: true }));
|
|
921
|
+
}
|
|
922
|
+
return buffer_source_toArrayBuffer(convert_decode(encoding, text));
|
|
923
|
+
},
|
|
924
|
+
toBase64: base64_encode,
|
|
925
|
+
fromBase64: (text) => buffer_source_toArrayBuffer(base64_decode(text)),
|
|
926
|
+
toBase64Url: base64url_encode,
|
|
927
|
+
fromBase64Url: (text) => buffer_source_toArrayBuffer(base64url_decode(text)),
|
|
928
|
+
toHex: hex_encode,
|
|
929
|
+
fromHex: (text) => buffer_source_toArrayBuffer(hex_decode(text, { allowOddLength: true })),
|
|
930
|
+
toBinary: encode,
|
|
931
|
+
fromBinary: (text) => buffer_source_toArrayBuffer(decode(text)),
|
|
932
|
+
toUtf8String: utf8_decode,
|
|
933
|
+
fromUtf8String: (text) => buffer_source_toArrayBuffer(utf8_encode(text)),
|
|
934
|
+
toUtf16String: (data, littleEndian = false) => utf16_decode(data, { littleEndian }),
|
|
935
|
+
fromUtf16String: (text, littleEndian = false) => buffer_source_toArrayBuffer(utf16_encode(text, { littleEndian })),
|
|
936
|
+
isHex: hex_is,
|
|
937
|
+
isBase64: base64_is,
|
|
938
|
+
isBase64Url: base64url_is,
|
|
939
|
+
formatString: base64_normalize,
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/converters/index.js
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/legacy/convert.js
|
|
948
|
+
|
|
949
|
+
function normalizeTextEncoding(encoding) {
|
|
950
|
+
return encoding === "ascii" ? "binary" : encoding;
|
|
951
|
+
}
|
|
952
|
+
class Convert {
|
|
953
|
+
static DEFAULT_UTF8_ENCODING = (/* unused pure expression or super */ null && ("utf8"));
|
|
954
|
+
static isHex(data) {
|
|
955
|
+
return convert.isHex(data);
|
|
956
|
+
}
|
|
957
|
+
static isBase64(data) {
|
|
958
|
+
return convert.isBase64(data);
|
|
959
|
+
}
|
|
960
|
+
static isBase64Url(data) {
|
|
961
|
+
return convert.isBase64Url(data);
|
|
962
|
+
}
|
|
963
|
+
static ToString(buffer, enc = "utf8") {
|
|
964
|
+
return convert.toString(buffer, enc);
|
|
965
|
+
}
|
|
966
|
+
static FromString(str, enc = "utf8") {
|
|
967
|
+
if (!str) {
|
|
968
|
+
return new ArrayBuffer(0);
|
|
969
|
+
}
|
|
970
|
+
return convert.fromString(str, enc);
|
|
971
|
+
}
|
|
972
|
+
static ToBase64(buffer) {
|
|
973
|
+
return convert.toBase64(buffer);
|
|
974
|
+
}
|
|
975
|
+
static FromBase64(base64) {
|
|
976
|
+
return convert.fromBase64(base64);
|
|
977
|
+
}
|
|
978
|
+
static FromBase64Url(base64url) {
|
|
979
|
+
return convert.fromBase64Url(base64url);
|
|
980
|
+
}
|
|
981
|
+
static ToBase64Url(data) {
|
|
982
|
+
return convert.toBase64Url(data);
|
|
983
|
+
}
|
|
984
|
+
static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) {
|
|
985
|
+
return convert.fromString(text, normalizeTextEncoding(encoding));
|
|
986
|
+
}
|
|
987
|
+
static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) {
|
|
988
|
+
return convert.toString(buffer, normalizeTextEncoding(encoding));
|
|
989
|
+
}
|
|
990
|
+
static FromBinary(text) {
|
|
991
|
+
return convert.fromBinary(text);
|
|
992
|
+
}
|
|
993
|
+
static ToBinary(buffer) {
|
|
994
|
+
return convert.toBinary(buffer);
|
|
995
|
+
}
|
|
996
|
+
static ToHex(buffer) {
|
|
997
|
+
return convert.toHex(buffer);
|
|
998
|
+
}
|
|
999
|
+
static FromHex(hexString) {
|
|
1000
|
+
return convert.fromHex(hexString);
|
|
1001
|
+
}
|
|
1002
|
+
static ToUtf16String(buffer, littleEndian = false) {
|
|
1003
|
+
return convert.toUtf16String(buffer, littleEndian);
|
|
1004
|
+
}
|
|
1005
|
+
static FromUtf16String(text, littleEndian = false) {
|
|
1006
|
+
return convert.fromUtf16String(text, littleEndian);
|
|
1007
|
+
}
|
|
1008
|
+
static Base64Padding(base64) {
|
|
1009
|
+
const padCount = 4 - (base64.length % 4);
|
|
1010
|
+
return padCount < 4 ? base64 + "=".repeat(padCount) : base64;
|
|
1011
|
+
}
|
|
1012
|
+
static formatString(data) {
|
|
1013
|
+
return convert.formatString(data);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/legacy/index.js
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/esm/index.js
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/enums.js
|
|
1031
|
+
var enums_AsnTypeTypes;
|
|
1032
|
+
(function (AsnTypeTypes) {
|
|
1033
|
+
AsnTypeTypes[AsnTypeTypes["Sequence"] = 0] = "Sequence";
|
|
1034
|
+
AsnTypeTypes[AsnTypeTypes["Set"] = 1] = "Set";
|
|
1035
|
+
AsnTypeTypes[AsnTypeTypes["Choice"] = 2] = "Choice";
|
|
1036
|
+
})(enums_AsnTypeTypes || (enums_AsnTypeTypes = {}));
|
|
1037
|
+
var enums_AsnPropTypes;
|
|
1038
|
+
(function (AsnPropTypes) {
|
|
1039
|
+
AsnPropTypes[AsnPropTypes["Any"] = 1] = "Any";
|
|
1040
|
+
AsnPropTypes[AsnPropTypes["Boolean"] = 2] = "Boolean";
|
|
1041
|
+
AsnPropTypes[AsnPropTypes["OctetString"] = 3] = "OctetString";
|
|
1042
|
+
AsnPropTypes[AsnPropTypes["BitString"] = 4] = "BitString";
|
|
1043
|
+
AsnPropTypes[AsnPropTypes["Integer"] = 5] = "Integer";
|
|
1044
|
+
AsnPropTypes[AsnPropTypes["Enumerated"] = 6] = "Enumerated";
|
|
1045
|
+
AsnPropTypes[AsnPropTypes["ObjectIdentifier"] = 7] = "ObjectIdentifier";
|
|
1046
|
+
AsnPropTypes[AsnPropTypes["Utf8String"] = 8] = "Utf8String";
|
|
1047
|
+
AsnPropTypes[AsnPropTypes["BmpString"] = 9] = "BmpString";
|
|
1048
|
+
AsnPropTypes[AsnPropTypes["UniversalString"] = 10] = "UniversalString";
|
|
1049
|
+
AsnPropTypes[AsnPropTypes["NumericString"] = 11] = "NumericString";
|
|
1050
|
+
AsnPropTypes[AsnPropTypes["PrintableString"] = 12] = "PrintableString";
|
|
1051
|
+
AsnPropTypes[AsnPropTypes["TeletexString"] = 13] = "TeletexString";
|
|
1052
|
+
AsnPropTypes[AsnPropTypes["VideotexString"] = 14] = "VideotexString";
|
|
1053
|
+
AsnPropTypes[AsnPropTypes["IA5String"] = 15] = "IA5String";
|
|
1054
|
+
AsnPropTypes[AsnPropTypes["GraphicString"] = 16] = "GraphicString";
|
|
1055
|
+
AsnPropTypes[AsnPropTypes["VisibleString"] = 17] = "VisibleString";
|
|
1056
|
+
AsnPropTypes[AsnPropTypes["GeneralString"] = 18] = "GeneralString";
|
|
1057
|
+
AsnPropTypes[AsnPropTypes["CharacterString"] = 19] = "CharacterString";
|
|
1058
|
+
AsnPropTypes[AsnPropTypes["UTCTime"] = 20] = "UTCTime";
|
|
1059
|
+
AsnPropTypes[AsnPropTypes["GeneralizedTime"] = 21] = "GeneralizedTime";
|
|
1060
|
+
AsnPropTypes[AsnPropTypes["DATE"] = 22] = "DATE";
|
|
1061
|
+
AsnPropTypes[AsnPropTypes["TimeOfDay"] = 23] = "TimeOfDay";
|
|
1062
|
+
AsnPropTypes[AsnPropTypes["DateTime"] = 24] = "DateTime";
|
|
1063
|
+
AsnPropTypes[AsnPropTypes["Duration"] = 25] = "Duration";
|
|
1064
|
+
AsnPropTypes[AsnPropTypes["TIME"] = 26] = "TIME";
|
|
1065
|
+
AsnPropTypes[AsnPropTypes["Null"] = 27] = "Null";
|
|
1066
|
+
AsnPropTypes[AsnPropTypes["RelativeObjectIdentifier"] = 28] = "RelativeObjectIdentifier";
|
|
1067
|
+
})(enums_AsnPropTypes || (enums_AsnPropTypes = {}));
|
|
1068
|
+
|
|
1069
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/types/bit_string.js
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
class BitString {
|
|
1073
|
+
unusedBits = 0;
|
|
1074
|
+
value = new ArrayBuffer(0);
|
|
1075
|
+
constructor(params, unusedBits = 0) {
|
|
1076
|
+
if (params) {
|
|
1077
|
+
if (typeof params === "number") {
|
|
1078
|
+
this.fromNumber(params);
|
|
1079
|
+
}
|
|
1080
|
+
else if (isBufferSource(params)) {
|
|
1081
|
+
this.unusedBits = unusedBits;
|
|
1082
|
+
this.value = toArrayBuffer(params);
|
|
1083
|
+
}
|
|
1084
|
+
else {
|
|
1085
|
+
throw TypeError("Unsupported type of 'params' argument for BitString");
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
fromASN(asn) {
|
|
1090
|
+
if (!(asn instanceof asn1js.BitString)) {
|
|
1091
|
+
throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");
|
|
1092
|
+
}
|
|
1093
|
+
this.unusedBits = asn.valueBlock.unusedBits;
|
|
1094
|
+
this.value = toArrayBuffer(asn.valueBlock.valueHex);
|
|
1095
|
+
return this;
|
|
1096
|
+
}
|
|
1097
|
+
toASN() {
|
|
1098
|
+
return new asn1js.BitString({
|
|
1099
|
+
unusedBits: this.unusedBits,
|
|
1100
|
+
valueHex: this.value,
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
toSchema(name) {
|
|
1104
|
+
return new asn1js.BitString({ name });
|
|
1105
|
+
}
|
|
1106
|
+
toNumber() {
|
|
1107
|
+
let res = "";
|
|
1108
|
+
const uintArray = new Uint8Array(this.value);
|
|
1109
|
+
for (const octet of uintArray) {
|
|
1110
|
+
res += octet.toString(2).padStart(8, "0");
|
|
1111
|
+
}
|
|
1112
|
+
res = res.split("").reverse().join("");
|
|
1113
|
+
if (this.unusedBits) {
|
|
1114
|
+
res = res.slice(this.unusedBits).padStart(this.unusedBits, "0");
|
|
1115
|
+
}
|
|
1116
|
+
return parseInt(res, 2);
|
|
1117
|
+
}
|
|
1118
|
+
fromNumber(value) {
|
|
1119
|
+
let bits = value.toString(2);
|
|
1120
|
+
const octetSize = (bits.length + 7) >> 3;
|
|
1121
|
+
this.unusedBits = (octetSize << 3) - bits.length;
|
|
1122
|
+
const octets = new Uint8Array(octetSize);
|
|
1123
|
+
bits = bits
|
|
1124
|
+
.padStart(octetSize << 3, "0")
|
|
1125
|
+
.split("")
|
|
1126
|
+
.reverse()
|
|
1127
|
+
.join("");
|
|
1128
|
+
let index = 0;
|
|
1129
|
+
while (index < octetSize) {
|
|
1130
|
+
octets[index] = parseInt(bits.slice(index << 3, (index << 3) + 8), 2);
|
|
1131
|
+
index++;
|
|
1132
|
+
}
|
|
1133
|
+
this.value = octets.buffer;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/types/octet_string.js
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
class OctetString {
|
|
1141
|
+
buffer;
|
|
1142
|
+
get byteLength() {
|
|
1143
|
+
return this.buffer.byteLength;
|
|
1144
|
+
}
|
|
1145
|
+
get byteOffset() {
|
|
1146
|
+
return 0;
|
|
1147
|
+
}
|
|
1148
|
+
constructor(param) {
|
|
1149
|
+
if (typeof param === "number") {
|
|
1150
|
+
this.buffer = new ArrayBuffer(param);
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
if (buffer_source_isBufferSource(param)) {
|
|
1154
|
+
this.buffer = buffer_source_toArrayBuffer(param);
|
|
1155
|
+
}
|
|
1156
|
+
else if (Array.isArray(param)) {
|
|
1157
|
+
this.buffer = new Uint8Array(param).buffer;
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
this.buffer = new ArrayBuffer(0);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
fromASN(asn) {
|
|
1165
|
+
if (!(asn instanceof build.OctetString)) {
|
|
1166
|
+
throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");
|
|
1167
|
+
}
|
|
1168
|
+
this.buffer = buffer_source_toArrayBuffer(asn.valueBlock.valueHex);
|
|
1169
|
+
return this;
|
|
1170
|
+
}
|
|
1171
|
+
toASN() {
|
|
1172
|
+
return new build.OctetString({ valueHex: this.buffer });
|
|
1173
|
+
}
|
|
1174
|
+
toSchema(name) {
|
|
1175
|
+
return new build.OctetString({ name });
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/types/index.js
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/converters.js
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
const AsnAnyConverter = {
|
|
1189
|
+
fromASN: (value) => (value instanceof build.Null ? null : buffer_source_toArrayBuffer(value.valueBeforeDecodeView)),
|
|
1190
|
+
toASN: (value) => {
|
|
1191
|
+
if (value === null) {
|
|
1192
|
+
return new build.Null();
|
|
1193
|
+
}
|
|
1194
|
+
const schema = build.fromBER(value);
|
|
1195
|
+
if (schema.result.error) {
|
|
1196
|
+
throw new Error(schema.result.error);
|
|
1197
|
+
}
|
|
1198
|
+
return schema.result;
|
|
1199
|
+
},
|
|
1200
|
+
};
|
|
1201
|
+
const AsnIntegerConverter = {
|
|
1202
|
+
fromASN: (value) => value.valueBlock.valueHexView.byteLength >= 4
|
|
1203
|
+
? value.valueBlock.toString()
|
|
1204
|
+
: value.valueBlock.valueDec,
|
|
1205
|
+
toASN: (value) => new build.Integer({ value: +value }),
|
|
1206
|
+
};
|
|
1207
|
+
const AsnEnumeratedConverter = {
|
|
1208
|
+
fromASN: (value) => value.valueBlock.valueDec,
|
|
1209
|
+
toASN: (value) => new build.Enumerated({ value }),
|
|
1210
|
+
};
|
|
1211
|
+
const AsnIntegerArrayBufferConverter = {
|
|
1212
|
+
fromASN: (value) => buffer_source_toArrayBuffer(value.valueBlock.valueHexView),
|
|
1213
|
+
toASN: (value) => new build.Integer({ valueHex: value }),
|
|
1214
|
+
};
|
|
1215
|
+
const AsnIntegerBigIntConverter = {
|
|
1216
|
+
fromASN: (value) => value.toBigInt(),
|
|
1217
|
+
toASN: (value) => build.Integer.fromBigInt(value),
|
|
1218
|
+
};
|
|
1219
|
+
const AsnBitStringConverter = {
|
|
1220
|
+
fromASN: (value) => buffer_source_toArrayBuffer(value.valueBlock.valueHexView),
|
|
1221
|
+
toASN: (value) => new build.BitString({ valueHex: value }),
|
|
1222
|
+
};
|
|
1223
|
+
const AsnObjectIdentifierConverter = {
|
|
1224
|
+
fromASN: (value) => value.valueBlock.toString(),
|
|
1225
|
+
toASN: (value) => new build.ObjectIdentifier({ value }),
|
|
1226
|
+
};
|
|
1227
|
+
const AsnRelativeObjectIdentifierConverter = {
|
|
1228
|
+
fromASN: (value) => value.valueBlock.toString(),
|
|
1229
|
+
toASN: (value) => new build.RelativeObjectIdentifier({ value }),
|
|
1230
|
+
};
|
|
1231
|
+
const AsnBooleanConverter = {
|
|
1232
|
+
fromASN: (value) => value.valueBlock.value,
|
|
1233
|
+
toASN: (value) => new build.Boolean({ value }),
|
|
1234
|
+
};
|
|
1235
|
+
const AsnOctetStringConverter = {
|
|
1236
|
+
fromASN: (value) => buffer_source_toArrayBuffer(value.valueBlock.valueHexView),
|
|
1237
|
+
toASN: (value) => new build.OctetString({ valueHex: value }),
|
|
1238
|
+
};
|
|
1239
|
+
const AsnConstructedOctetStringConverter = {
|
|
1240
|
+
fromASN: (value) => new OctetString(value.getValue()),
|
|
1241
|
+
toASN: (value) => value.toASN(),
|
|
1242
|
+
};
|
|
1243
|
+
function createStringConverter(Asn1Type) {
|
|
1244
|
+
return {
|
|
1245
|
+
fromASN: (value) => value.valueBlock.value,
|
|
1246
|
+
toASN: (value) => new Asn1Type({ value }),
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
const AsnUtf8StringConverter = createStringConverter(build.Utf8String);
|
|
1250
|
+
const AsnBmpStringConverter = createStringConverter(build.BmpString);
|
|
1251
|
+
const AsnUniversalStringConverter = createStringConverter(build.UniversalString);
|
|
1252
|
+
const AsnNumericStringConverter = createStringConverter(build.NumericString);
|
|
1253
|
+
const AsnPrintableStringConverter = createStringConverter(build.PrintableString);
|
|
1254
|
+
const AsnTeletexStringConverter = createStringConverter(build.TeletexString);
|
|
1255
|
+
const AsnVideotexStringConverter = createStringConverter(build.VideotexString);
|
|
1256
|
+
const AsnIA5StringConverter = createStringConverter(build.IA5String);
|
|
1257
|
+
const AsnGraphicStringConverter = createStringConverter(build.GraphicString);
|
|
1258
|
+
const AsnVisibleStringConverter = createStringConverter(build.VisibleString);
|
|
1259
|
+
const AsnGeneralStringConverter = createStringConverter(build.GeneralString);
|
|
1260
|
+
const AsnCharacterStringConverter = createStringConverter(build.CharacterString);
|
|
1261
|
+
const AsnUTCTimeConverter = {
|
|
1262
|
+
fromASN: (value) => value.toDate(),
|
|
1263
|
+
toASN: (value) => new build.UTCTime({ valueDate: value }),
|
|
1264
|
+
};
|
|
1265
|
+
const AsnGeneralizedTimeConverter = {
|
|
1266
|
+
fromASN: (value) => value.toDate(),
|
|
1267
|
+
toASN: (value) => new build.GeneralizedTime({ valueDate: value }),
|
|
1268
|
+
};
|
|
1269
|
+
const AsnNullConverter = {
|
|
1270
|
+
fromASN: () => null,
|
|
1271
|
+
toASN: () => {
|
|
1272
|
+
return new build.Null();
|
|
1273
|
+
},
|
|
1274
|
+
};
|
|
1275
|
+
function converters_defaultConverter(type) {
|
|
1276
|
+
switch (type) {
|
|
1277
|
+
case enums_AsnPropTypes.Any:
|
|
1278
|
+
return AsnAnyConverter;
|
|
1279
|
+
case enums_AsnPropTypes.BitString:
|
|
1280
|
+
return AsnBitStringConverter;
|
|
1281
|
+
case enums_AsnPropTypes.BmpString:
|
|
1282
|
+
return AsnBmpStringConverter;
|
|
1283
|
+
case enums_AsnPropTypes.Boolean:
|
|
1284
|
+
return AsnBooleanConverter;
|
|
1285
|
+
case enums_AsnPropTypes.CharacterString:
|
|
1286
|
+
return AsnCharacterStringConverter;
|
|
1287
|
+
case enums_AsnPropTypes.Enumerated:
|
|
1288
|
+
return AsnEnumeratedConverter;
|
|
1289
|
+
case enums_AsnPropTypes.GeneralString:
|
|
1290
|
+
return AsnGeneralStringConverter;
|
|
1291
|
+
case enums_AsnPropTypes.GeneralizedTime:
|
|
1292
|
+
return AsnGeneralizedTimeConverter;
|
|
1293
|
+
case enums_AsnPropTypes.GraphicString:
|
|
1294
|
+
return AsnGraphicStringConverter;
|
|
1295
|
+
case enums_AsnPropTypes.IA5String:
|
|
1296
|
+
return AsnIA5StringConverter;
|
|
1297
|
+
case enums_AsnPropTypes.Integer:
|
|
1298
|
+
return AsnIntegerConverter;
|
|
1299
|
+
case enums_AsnPropTypes.Null:
|
|
1300
|
+
return AsnNullConverter;
|
|
1301
|
+
case enums_AsnPropTypes.NumericString:
|
|
1302
|
+
return AsnNumericStringConverter;
|
|
1303
|
+
case enums_AsnPropTypes.ObjectIdentifier:
|
|
1304
|
+
return AsnObjectIdentifierConverter;
|
|
1305
|
+
case enums_AsnPropTypes.RelativeObjectIdentifier:
|
|
1306
|
+
return AsnRelativeObjectIdentifierConverter;
|
|
1307
|
+
case enums_AsnPropTypes.OctetString:
|
|
1308
|
+
return AsnOctetStringConverter;
|
|
1309
|
+
case enums_AsnPropTypes.PrintableString:
|
|
1310
|
+
return AsnPrintableStringConverter;
|
|
1311
|
+
case enums_AsnPropTypes.TeletexString:
|
|
1312
|
+
return AsnTeletexStringConverter;
|
|
1313
|
+
case enums_AsnPropTypes.UTCTime:
|
|
1314
|
+
return AsnUTCTimeConverter;
|
|
1315
|
+
case enums_AsnPropTypes.UniversalString:
|
|
1316
|
+
return AsnUniversalStringConverter;
|
|
1317
|
+
case enums_AsnPropTypes.Utf8String:
|
|
1318
|
+
return AsnUtf8StringConverter;
|
|
1319
|
+
case enums_AsnPropTypes.VideotexString:
|
|
1320
|
+
return AsnVideotexStringConverter;
|
|
1321
|
+
case enums_AsnPropTypes.VisibleString:
|
|
1322
|
+
return AsnVisibleStringConverter;
|
|
1323
|
+
default:
|
|
1324
|
+
return null;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/helper.js
|
|
1329
|
+
function helper_isConvertible(target) {
|
|
1330
|
+
if (typeof target === "function" && target.prototype) {
|
|
1331
|
+
if (target.prototype.toASN && target.prototype.fromASN) {
|
|
1332
|
+
return true;
|
|
1333
|
+
}
|
|
1334
|
+
else {
|
|
1335
|
+
return helper_isConvertible(target.prototype);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
return !!(target && typeof target === "object" && "toASN" in target && "fromASN" in target);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
function isTypeOfArray(target) {
|
|
1343
|
+
if (target) {
|
|
1344
|
+
const proto = Object.getPrototypeOf(target);
|
|
1345
|
+
if (proto?.prototype?.constructor === Array) {
|
|
1346
|
+
return true;
|
|
1347
|
+
}
|
|
1348
|
+
return isTypeOfArray(proto);
|
|
1349
|
+
}
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
function helper_isArrayEqual(bytes1, bytes2) {
|
|
1353
|
+
if (!(bytes1 && bytes2)) {
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
if (bytes1.byteLength !== bytes2.byteLength) {
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
const b1 = new Uint8Array(bytes1);
|
|
1360
|
+
const b2 = new Uint8Array(bytes2);
|
|
1361
|
+
for (let i = 0; i < bytes1.byteLength; i++) {
|
|
1362
|
+
if (b1[i] !== b2[i]) {
|
|
1363
|
+
return false;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/schema.js
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
class AsnSchemaStorage {
|
|
1374
|
+
items = new WeakMap();
|
|
1375
|
+
has(target) {
|
|
1376
|
+
return this.items.has(target);
|
|
1377
|
+
}
|
|
1378
|
+
get(target, checkSchema = false) {
|
|
1379
|
+
const schema = this.items.get(target);
|
|
1380
|
+
if (!schema) {
|
|
1381
|
+
throw new Error(`Cannot get schema for '${target.prototype.constructor.name}' target`);
|
|
1382
|
+
}
|
|
1383
|
+
if (checkSchema && !schema.schema) {
|
|
1384
|
+
throw new Error(`Schema '${target.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);
|
|
1385
|
+
}
|
|
1386
|
+
return schema;
|
|
1387
|
+
}
|
|
1388
|
+
cache(target) {
|
|
1389
|
+
const schema = this.get(target);
|
|
1390
|
+
if (!schema.schema) {
|
|
1391
|
+
schema.schema = this.create(target, true);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
createDefault(target) {
|
|
1395
|
+
const schema = {
|
|
1396
|
+
type: enums_AsnTypeTypes.Sequence,
|
|
1397
|
+
items: {},
|
|
1398
|
+
};
|
|
1399
|
+
const parentSchema = this.findParentSchema(target);
|
|
1400
|
+
if (parentSchema) {
|
|
1401
|
+
Object.assign(schema, parentSchema);
|
|
1402
|
+
schema.items = Object.assign({}, schema.items, parentSchema.items);
|
|
1403
|
+
}
|
|
1404
|
+
return schema;
|
|
1405
|
+
}
|
|
1406
|
+
create(target, useNames) {
|
|
1407
|
+
const schema = this.items.get(target) || this.createDefault(target);
|
|
1408
|
+
const asn1Value = [];
|
|
1409
|
+
for (const key in schema.items) {
|
|
1410
|
+
const item = schema.items[key];
|
|
1411
|
+
const name = useNames ? key : "";
|
|
1412
|
+
let asn1Item;
|
|
1413
|
+
if (typeof item.type === "number") {
|
|
1414
|
+
const Asn1TypeName = enums_AsnPropTypes[item.type];
|
|
1415
|
+
const Asn1Type = build_namespaceObject[Asn1TypeName];
|
|
1416
|
+
if (!Asn1Type) {
|
|
1417
|
+
throw new Error(`Cannot get ASN1 class by name '${Asn1TypeName}'`);
|
|
1418
|
+
}
|
|
1419
|
+
asn1Item = new Asn1Type({ name });
|
|
1420
|
+
}
|
|
1421
|
+
else if (helper_isConvertible(item.type)) {
|
|
1422
|
+
const instance = new item.type();
|
|
1423
|
+
asn1Item = instance.toSchema(name);
|
|
1424
|
+
}
|
|
1425
|
+
else if (item.optional) {
|
|
1426
|
+
const itemSchema = this.get(item.type);
|
|
1427
|
+
if (itemSchema.type === enums_AsnTypeTypes.Choice) {
|
|
1428
|
+
asn1Item = new build.Any({ name });
|
|
1429
|
+
}
|
|
1430
|
+
else {
|
|
1431
|
+
asn1Item = this.create(item.type, false);
|
|
1432
|
+
asn1Item.name = name;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
else {
|
|
1436
|
+
asn1Item = new build.Any({ name });
|
|
1437
|
+
}
|
|
1438
|
+
const optional = !!item.optional || item.defaultValue !== undefined;
|
|
1439
|
+
if (item.repeated) {
|
|
1440
|
+
asn1Item.name = "";
|
|
1441
|
+
const Container = item.repeated === "set" ? build.Set : build.Sequence;
|
|
1442
|
+
asn1Item = new Container({
|
|
1443
|
+
name: "",
|
|
1444
|
+
value: [
|
|
1445
|
+
new build.Repeated({
|
|
1446
|
+
name,
|
|
1447
|
+
value: asn1Item,
|
|
1448
|
+
}),
|
|
1449
|
+
],
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
if (item.context !== null && item.context !== undefined) {
|
|
1453
|
+
if (item.implicit) {
|
|
1454
|
+
if (typeof item.type === "number" || helper_isConvertible(item.type)) {
|
|
1455
|
+
const Container = item.repeated ? build.Constructed : build.Primitive;
|
|
1456
|
+
asn1Value.push(new Container({
|
|
1457
|
+
name,
|
|
1458
|
+
optional,
|
|
1459
|
+
idBlock: {
|
|
1460
|
+
tagClass: 3,
|
|
1461
|
+
tagNumber: item.context,
|
|
1462
|
+
},
|
|
1463
|
+
}));
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
this.cache(item.type);
|
|
1467
|
+
const isRepeated = !!item.repeated;
|
|
1468
|
+
let value = !isRepeated ? this.get(item.type, true).schema : asn1Item;
|
|
1469
|
+
value = "valueBlock" in value ? value.valueBlock.value : value.value;
|
|
1470
|
+
asn1Value.push(new build.Constructed({
|
|
1471
|
+
name: !isRepeated ? name : "",
|
|
1472
|
+
optional,
|
|
1473
|
+
idBlock: {
|
|
1474
|
+
tagClass: 3,
|
|
1475
|
+
tagNumber: item.context,
|
|
1476
|
+
},
|
|
1477
|
+
value: value,
|
|
1478
|
+
}));
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
asn1Value.push(new build.Constructed({
|
|
1483
|
+
optional,
|
|
1484
|
+
idBlock: {
|
|
1485
|
+
tagClass: 3,
|
|
1486
|
+
tagNumber: item.context,
|
|
1487
|
+
},
|
|
1488
|
+
value: [asn1Item],
|
|
1489
|
+
}));
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
else {
|
|
1493
|
+
asn1Item.optional = optional;
|
|
1494
|
+
asn1Value.push(asn1Item);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
switch (schema.type) {
|
|
1498
|
+
case enums_AsnTypeTypes.Sequence:
|
|
1499
|
+
return new build.Sequence({
|
|
1500
|
+
value: asn1Value,
|
|
1501
|
+
name: "",
|
|
1502
|
+
});
|
|
1503
|
+
case enums_AsnTypeTypes.Set:
|
|
1504
|
+
return new build.Set({
|
|
1505
|
+
value: asn1Value,
|
|
1506
|
+
name: "",
|
|
1507
|
+
});
|
|
1508
|
+
case enums_AsnTypeTypes.Choice:
|
|
1509
|
+
return new build.Choice({
|
|
1510
|
+
value: asn1Value,
|
|
1511
|
+
name: "",
|
|
1512
|
+
});
|
|
1513
|
+
default:
|
|
1514
|
+
throw new Error("Unsupported ASN1 type in use");
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
set(target, schema) {
|
|
1518
|
+
this.items.set(target, schema);
|
|
1519
|
+
return this;
|
|
1520
|
+
}
|
|
1521
|
+
findParentSchema(target) {
|
|
1522
|
+
const parent = Object.getPrototypeOf(target);
|
|
1523
|
+
if (parent) {
|
|
1524
|
+
const schema = this.items.get(parent);
|
|
1525
|
+
return schema || this.findParentSchema(parent);
|
|
1526
|
+
}
|
|
1527
|
+
return null;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/storage.js
|
|
1532
|
+
|
|
1533
|
+
const storage_schemaStorage = new AsnSchemaStorage();
|
|
1534
|
+
|
|
1535
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
const AsnType = (options) => (target) => {
|
|
1540
|
+
let schema;
|
|
1541
|
+
if (!storage_schemaStorage.has(target)) {
|
|
1542
|
+
schema = storage_schemaStorage.createDefault(target);
|
|
1543
|
+
storage_schemaStorage.set(target, schema);
|
|
1544
|
+
}
|
|
1545
|
+
else {
|
|
1546
|
+
schema = storage_schemaStorage.get(target);
|
|
1547
|
+
}
|
|
1548
|
+
Object.assign(schema, options);
|
|
1549
|
+
};
|
|
1550
|
+
const AsnChoiceType = () => AsnType({ type: AsnTypeTypes.Choice });
|
|
1551
|
+
const AsnSetType = (options) => AsnType({
|
|
1552
|
+
type: AsnTypeTypes.Set,
|
|
1553
|
+
...options,
|
|
1554
|
+
});
|
|
1555
|
+
const AsnSequenceType = (options) => AsnType({
|
|
1556
|
+
type: AsnTypeTypes.Sequence,
|
|
1557
|
+
...options,
|
|
1558
|
+
});
|
|
1559
|
+
const AsnProp = (options) => (target, propertyKey) => {
|
|
1560
|
+
let schema;
|
|
1561
|
+
if (!storage_schemaStorage.has(target.constructor)) {
|
|
1562
|
+
schema = storage_schemaStorage.createDefault(target.constructor);
|
|
1563
|
+
storage_schemaStorage.set(target.constructor, schema);
|
|
1564
|
+
}
|
|
1565
|
+
else {
|
|
1566
|
+
schema = storage_schemaStorage.get(target.constructor);
|
|
1567
|
+
}
|
|
1568
|
+
const copyOptions = Object.assign({}, options);
|
|
1569
|
+
if (typeof copyOptions.type === "number" && !copyOptions.converter) {
|
|
1570
|
+
const defaultConverter = converters_defaultConverter(options.type);
|
|
1571
|
+
if (!defaultConverter) {
|
|
1572
|
+
throw new Error(`Cannot get default converter for property '${propertyKey}' of ${target.constructor.name}`);
|
|
1573
|
+
}
|
|
1574
|
+
copyOptions.converter = defaultConverter;
|
|
1575
|
+
}
|
|
1576
|
+
copyOptions.raw = options.raw;
|
|
1577
|
+
schema.items[propertyKey] = copyOptions;
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js
|
|
1581
|
+
class AsnSchemaValidationError extends Error {
|
|
1582
|
+
schemas = [];
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/parser.js
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
class parser_AsnParser {
|
|
1594
|
+
static parse(data, target, options) {
|
|
1595
|
+
const asn1Parsed = build.fromBER(buffer_source_toArrayBuffer(data), options?.berOptions);
|
|
1596
|
+
if (asn1Parsed.result.error) {
|
|
1597
|
+
throw new Error(asn1Parsed.result.error);
|
|
1598
|
+
}
|
|
1599
|
+
const res = this.fromASN(asn1Parsed.result, target, options);
|
|
1600
|
+
return res;
|
|
1601
|
+
}
|
|
1602
|
+
static fromASN(asn1Schema, target, options) {
|
|
1603
|
+
try {
|
|
1604
|
+
if (helper_isConvertible(target)) {
|
|
1605
|
+
const value = new target();
|
|
1606
|
+
return value.fromASN(asn1Schema);
|
|
1607
|
+
}
|
|
1608
|
+
const schema = storage_schemaStorage.get(target);
|
|
1609
|
+
storage_schemaStorage.cache(target);
|
|
1610
|
+
let targetSchema = schema.schema;
|
|
1611
|
+
const choiceResult = this.handleChoiceTypes(asn1Schema, schema, target, targetSchema, options);
|
|
1612
|
+
if (choiceResult?.result) {
|
|
1613
|
+
return choiceResult.result;
|
|
1614
|
+
}
|
|
1615
|
+
if (choiceResult?.targetSchema) {
|
|
1616
|
+
targetSchema = choiceResult.targetSchema;
|
|
1617
|
+
}
|
|
1618
|
+
const sequenceResult = this.handleSequenceTypes(asn1Schema, schema, target, targetSchema);
|
|
1619
|
+
const res = new target();
|
|
1620
|
+
if (isTypeOfArray(target)) {
|
|
1621
|
+
return this.handleArrayTypes(asn1Schema, schema, target, options);
|
|
1622
|
+
}
|
|
1623
|
+
this.processSchemaItems(schema, sequenceResult, res, options);
|
|
1624
|
+
return res;
|
|
1625
|
+
}
|
|
1626
|
+
catch (error) {
|
|
1627
|
+
if (error instanceof AsnSchemaValidationError) {
|
|
1628
|
+
error.schemas.push(target.name);
|
|
1629
|
+
}
|
|
1630
|
+
throw error;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
static handleChoiceTypes(asn1Schema, schema, target, targetSchema, options) {
|
|
1634
|
+
if (asn1Schema.constructor === build.Constructed && schema.type === enums_AsnTypeTypes.Choice && asn1Schema.idBlock.tagClass === 3) {
|
|
1635
|
+
for (const key in schema.items) {
|
|
1636
|
+
const schemaItem = schema.items[key];
|
|
1637
|
+
if (schemaItem.context === asn1Schema.idBlock.tagNumber && schemaItem.implicit) {
|
|
1638
|
+
if (typeof schemaItem.type === "function" && storage_schemaStorage.has(schemaItem.type)) {
|
|
1639
|
+
const fieldSchema = storage_schemaStorage.get(schemaItem.type);
|
|
1640
|
+
if (fieldSchema && fieldSchema.type === enums_AsnTypeTypes.Sequence) {
|
|
1641
|
+
const newSeq = new build.Sequence();
|
|
1642
|
+
if ("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value) && "value" in newSeq.valueBlock) {
|
|
1643
|
+
newSeq.valueBlock.value = asn1Schema.valueBlock.value;
|
|
1644
|
+
const fieldValue = this.fromASN(newSeq, schemaItem.type, options);
|
|
1645
|
+
const res = new target();
|
|
1646
|
+
res[key] = fieldValue;
|
|
1647
|
+
return { result: res };
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
else if (asn1Schema.constructor === build.Constructed && schema.type !== enums_AsnTypeTypes.Choice) {
|
|
1655
|
+
const newTargetSchema = new build.Constructed({
|
|
1656
|
+
idBlock: {
|
|
1657
|
+
tagClass: 3,
|
|
1658
|
+
tagNumber: asn1Schema.idBlock.tagNumber,
|
|
1659
|
+
},
|
|
1660
|
+
value: schema.schema.valueBlock.value,
|
|
1661
|
+
});
|
|
1662
|
+
for (const key in schema.items) {
|
|
1663
|
+
delete asn1Schema[key];
|
|
1664
|
+
}
|
|
1665
|
+
return { targetSchema: newTargetSchema };
|
|
1666
|
+
}
|
|
1667
|
+
return null;
|
|
1668
|
+
}
|
|
1669
|
+
static handleSequenceTypes(asn1Schema, schema, target, targetSchema) {
|
|
1670
|
+
if (schema.type === enums_AsnTypeTypes.Sequence) {
|
|
1671
|
+
const asn1ComparedSchema = build.compareSchema({}, asn1Schema, targetSchema);
|
|
1672
|
+
if (!asn1ComparedSchema.verified) {
|
|
1673
|
+
throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`);
|
|
1674
|
+
}
|
|
1675
|
+
return asn1ComparedSchema;
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
const asn1ComparedSchema = build.compareSchema({}, asn1Schema, targetSchema);
|
|
1679
|
+
if (!asn1ComparedSchema.verified) {
|
|
1680
|
+
throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema.${asn1ComparedSchema.result.error ? ` ${asn1ComparedSchema.result.error}` : ""}`);
|
|
1681
|
+
}
|
|
1682
|
+
return asn1ComparedSchema;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
static processRepeatedField(asn1Elements, asn1Index, schemaItem) {
|
|
1686
|
+
let elementsToProcess = asn1Elements.slice(asn1Index);
|
|
1687
|
+
if (elementsToProcess.length === 1 && elementsToProcess[0].constructor.name === "Sequence") {
|
|
1688
|
+
const seq = elementsToProcess[0];
|
|
1689
|
+
if (seq.valueBlock && seq.valueBlock.value && Array.isArray(seq.valueBlock.value)) {
|
|
1690
|
+
elementsToProcess = seq.valueBlock.value;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
if (typeof schemaItem.type === "number") {
|
|
1694
|
+
const converter = converters_defaultConverter(schemaItem.type);
|
|
1695
|
+
if (!converter)
|
|
1696
|
+
throw new Error(`No converter for ASN.1 type ${schemaItem.type}`);
|
|
1697
|
+
return elementsToProcess
|
|
1698
|
+
.filter((el) => el && el.valueBlock)
|
|
1699
|
+
.map((el) => {
|
|
1700
|
+
try {
|
|
1701
|
+
return converter.fromASN(el);
|
|
1702
|
+
}
|
|
1703
|
+
catch {
|
|
1704
|
+
return undefined;
|
|
1705
|
+
}
|
|
1706
|
+
})
|
|
1707
|
+
.filter((v) => v !== undefined);
|
|
1708
|
+
}
|
|
1709
|
+
else {
|
|
1710
|
+
return elementsToProcess
|
|
1711
|
+
.filter((el) => el && el.valueBlock)
|
|
1712
|
+
.map((el) => {
|
|
1713
|
+
try {
|
|
1714
|
+
return this.fromASN(el, schemaItem.type);
|
|
1715
|
+
}
|
|
1716
|
+
catch {
|
|
1717
|
+
return undefined;
|
|
1718
|
+
}
|
|
1719
|
+
})
|
|
1720
|
+
.filter((v) => v !== undefined);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
static processPrimitiveField(asn1Element, schemaItem) {
|
|
1724
|
+
const converter = converters_defaultConverter(schemaItem.type);
|
|
1725
|
+
if (!converter)
|
|
1726
|
+
throw new Error(`No converter for ASN.1 type ${schemaItem.type}`);
|
|
1727
|
+
return converter.fromASN(asn1Element);
|
|
1728
|
+
}
|
|
1729
|
+
static isOptionalChoiceField(schemaItem) {
|
|
1730
|
+
return (schemaItem.optional &&
|
|
1731
|
+
typeof schemaItem.type === "function" &&
|
|
1732
|
+
storage_schemaStorage.has(schemaItem.type) &&
|
|
1733
|
+
storage_schemaStorage.get(schemaItem.type).type === enums_AsnTypeTypes.Choice);
|
|
1734
|
+
}
|
|
1735
|
+
static processOptionalChoiceField(asn1Element, schemaItem) {
|
|
1736
|
+
try {
|
|
1737
|
+
const value = this.fromASN(asn1Element, schemaItem.type);
|
|
1738
|
+
return {
|
|
1739
|
+
processed: true,
|
|
1740
|
+
value,
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
catch (err) {
|
|
1744
|
+
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
1745
|
+
return { processed: false };
|
|
1746
|
+
}
|
|
1747
|
+
throw err;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
static handleArrayTypes(asn1Schema, schema, target, options) {
|
|
1751
|
+
if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) {
|
|
1752
|
+
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
1753
|
+
}
|
|
1754
|
+
const itemType = schema.itemType;
|
|
1755
|
+
if (typeof itemType === "number") {
|
|
1756
|
+
const converter = converters_defaultConverter(itemType);
|
|
1757
|
+
if (!converter) {
|
|
1758
|
+
throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`);
|
|
1759
|
+
}
|
|
1760
|
+
return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element));
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType, options));
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
static processSchemaItems(schema, asn1ComparedSchema, res, options) {
|
|
1767
|
+
for (const key in schema.items) {
|
|
1768
|
+
const asn1SchemaValue = asn1ComparedSchema.result[key];
|
|
1769
|
+
if (!asn1SchemaValue) {
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
const schemaItem = schema.items[key];
|
|
1773
|
+
const schemaItemType = schemaItem.type;
|
|
1774
|
+
let parsedValue;
|
|
1775
|
+
if (typeof schemaItemType === "number" || helper_isConvertible(schemaItemType)) {
|
|
1776
|
+
parsedValue = this.processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options);
|
|
1777
|
+
}
|
|
1778
|
+
else {
|
|
1779
|
+
parsedValue = this.processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options);
|
|
1780
|
+
}
|
|
1781
|
+
if (parsedValue && typeof parsedValue === "object" && "value" in parsedValue && "raw" in parsedValue) {
|
|
1782
|
+
res[key] = parsedValue.value;
|
|
1783
|
+
res[`${key}Raw`] = parsedValue.raw;
|
|
1784
|
+
}
|
|
1785
|
+
else {
|
|
1786
|
+
res[key] = parsedValue;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
static processPrimitiveSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) {
|
|
1791
|
+
const converter = schemaItem.converter ?? (helper_isConvertible(schemaItemType) ? new schemaItemType() : null);
|
|
1792
|
+
if (!converter) {
|
|
1793
|
+
throw new Error("Converter is empty");
|
|
1794
|
+
}
|
|
1795
|
+
if (schemaItem.repeated) {
|
|
1796
|
+
return this.processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options);
|
|
1797
|
+
}
|
|
1798
|
+
else {
|
|
1799
|
+
return this.processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
static processRepeatedPrimitiveItem(asn1SchemaValue, schemaItem, converter, options) {
|
|
1803
|
+
if (schemaItem.implicit) {
|
|
1804
|
+
const Container = schemaItem.repeated === "sequence" ? build.Sequence : build.Set;
|
|
1805
|
+
const newItem = new Container();
|
|
1806
|
+
newItem.valueBlock = asn1SchemaValue.valueBlock;
|
|
1807
|
+
const newItemAsn = build.fromBER(newItem.toBER(false), options?.berOptions);
|
|
1808
|
+
if (newItemAsn.offset === -1) {
|
|
1809
|
+
throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`);
|
|
1810
|
+
}
|
|
1811
|
+
if (!("value" in newItemAsn.result.valueBlock && Array.isArray(newItemAsn.result.valueBlock.value))) {
|
|
1812
|
+
throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");
|
|
1813
|
+
}
|
|
1814
|
+
const value = newItemAsn.result.valueBlock.value;
|
|
1815
|
+
return Array.from(value, (element) => converter.fromASN(element));
|
|
1816
|
+
}
|
|
1817
|
+
else {
|
|
1818
|
+
return Array.from(asn1SchemaValue, (element) => converter.fromASN(element));
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
static processSinglePrimitiveItem(asn1SchemaValue, schemaItem, schemaItemType, converter, options) {
|
|
1822
|
+
let value = asn1SchemaValue;
|
|
1823
|
+
if (schemaItem.implicit) {
|
|
1824
|
+
let newItem;
|
|
1825
|
+
if (helper_isConvertible(schemaItemType)) {
|
|
1826
|
+
newItem = new schemaItemType().toSchema("");
|
|
1827
|
+
}
|
|
1828
|
+
else {
|
|
1829
|
+
const Asn1TypeName = enums_AsnPropTypes[schemaItemType];
|
|
1830
|
+
const Asn1Type = build_namespaceObject[Asn1TypeName];
|
|
1831
|
+
if (!Asn1Type) {
|
|
1832
|
+
throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`);
|
|
1833
|
+
}
|
|
1834
|
+
newItem = new Asn1Type();
|
|
1835
|
+
}
|
|
1836
|
+
newItem.valueBlock = value.valueBlock;
|
|
1837
|
+
value = build.fromBER(newItem.toBER(false), options?.berOptions).result;
|
|
1838
|
+
}
|
|
1839
|
+
return converter.fromASN(value);
|
|
1840
|
+
}
|
|
1841
|
+
static processComplexSchemaItem(asn1SchemaValue, schemaItem, schemaItemType, options) {
|
|
1842
|
+
if (schemaItem.repeated) {
|
|
1843
|
+
if (!Array.isArray(asn1SchemaValue)) {
|
|
1844
|
+
throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");
|
|
1845
|
+
}
|
|
1846
|
+
return Array.from(asn1SchemaValue, (element) => this.fromASN(element, schemaItemType, options));
|
|
1847
|
+
}
|
|
1848
|
+
else {
|
|
1849
|
+
const valueToProcess = this.handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType);
|
|
1850
|
+
if (this.isOptionalChoiceField(schemaItem)) {
|
|
1851
|
+
try {
|
|
1852
|
+
return this.fromASN(valueToProcess, schemaItemType, options);
|
|
1853
|
+
}
|
|
1854
|
+
catch (err) {
|
|
1855
|
+
if (err instanceof AsnSchemaValidationError && /Wrong values for Choice type/.test(err.message)) {
|
|
1856
|
+
return undefined;
|
|
1857
|
+
}
|
|
1858
|
+
throw err;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
else {
|
|
1862
|
+
const parsedValue = this.fromASN(valueToProcess, schemaItemType, options);
|
|
1863
|
+
if (schemaItem.raw) {
|
|
1864
|
+
return {
|
|
1865
|
+
value: parsedValue,
|
|
1866
|
+
raw: asn1SchemaValue.valueBeforeDecodeView,
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
return parsedValue;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
static handleImplicitTagging(asn1SchemaValue, schemaItem, schemaItemType) {
|
|
1874
|
+
if (schemaItem.implicit && typeof schemaItem.context === "number") {
|
|
1875
|
+
const schema = storage_schemaStorage.get(schemaItemType);
|
|
1876
|
+
if (schema.type === enums_AsnTypeTypes.Sequence) {
|
|
1877
|
+
const newSeq = new build.Sequence();
|
|
1878
|
+
if ("value" in asn1SchemaValue.valueBlock && Array.isArray(asn1SchemaValue.valueBlock.value) && "value" in newSeq.valueBlock) {
|
|
1879
|
+
newSeq.valueBlock.value = asn1SchemaValue.valueBlock.value;
|
|
1880
|
+
return newSeq;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
else if (schema.type === enums_AsnTypeTypes.Set) {
|
|
1884
|
+
const newSet = new build.Set();
|
|
1885
|
+
if ("value" in asn1SchemaValue.valueBlock && Array.isArray(asn1SchemaValue.valueBlock.value) && "value" in newSet.valueBlock) {
|
|
1886
|
+
newSet.valueBlock.value = asn1SchemaValue.valueBlock.value;
|
|
1887
|
+
return newSet;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return asn1SchemaValue;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/serializer.js
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
|
|
1901
|
+
|
|
1902
|
+
class serializer_AsnSerializer {
|
|
1903
|
+
static serialize(obj) {
|
|
1904
|
+
if (obj instanceof asn1js.BaseBlock) {
|
|
1905
|
+
return obj.toBER(false);
|
|
1906
|
+
}
|
|
1907
|
+
return this.toASN(obj).toBER(false);
|
|
1908
|
+
}
|
|
1909
|
+
static toASN(obj) {
|
|
1910
|
+
if (obj && typeof obj === "object" && isConvertible(obj)) {
|
|
1911
|
+
return obj.toASN();
|
|
1912
|
+
}
|
|
1913
|
+
if (!(obj && typeof obj === "object")) {
|
|
1914
|
+
throw new TypeError("Parameter 1 should be type of Object.");
|
|
1915
|
+
}
|
|
1916
|
+
const target = obj.constructor;
|
|
1917
|
+
const schema = schemaStorage.get(target);
|
|
1918
|
+
schemaStorage.cache(target);
|
|
1919
|
+
let asn1Value = [];
|
|
1920
|
+
if (schema.itemType) {
|
|
1921
|
+
if (!Array.isArray(obj)) {
|
|
1922
|
+
throw new TypeError("Parameter 1 should be type of Array.");
|
|
1923
|
+
}
|
|
1924
|
+
if (typeof schema.itemType === "number") {
|
|
1925
|
+
const converter = converters.defaultConverter(schema.itemType);
|
|
1926
|
+
if (!converter) {
|
|
1927
|
+
throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`);
|
|
1928
|
+
}
|
|
1929
|
+
asn1Value = obj.map((o) => converter.toASN(o));
|
|
1930
|
+
}
|
|
1931
|
+
else {
|
|
1932
|
+
asn1Value = obj.map((o) => this.toAsnItem({ type: schema.itemType }, "[]", target, o));
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
else {
|
|
1936
|
+
for (const key in schema.items) {
|
|
1937
|
+
const schemaItem = schema.items[key];
|
|
1938
|
+
const objProp = obj[key];
|
|
1939
|
+
if (objProp === undefined ||
|
|
1940
|
+
schemaItem.defaultValue === objProp ||
|
|
1941
|
+
(typeof schemaItem.defaultValue === "object" && typeof objProp === "object" && isArrayEqual(this.serialize(schemaItem.defaultValue), this.serialize(objProp)))) {
|
|
1942
|
+
continue;
|
|
1943
|
+
}
|
|
1944
|
+
const asn1Item = serializer_AsnSerializer.toAsnItem(schemaItem, key, target, objProp);
|
|
1945
|
+
if (typeof schemaItem.context === "number") {
|
|
1946
|
+
if (schemaItem.implicit) {
|
|
1947
|
+
if (!schemaItem.repeated && (typeof schemaItem.type === "number" || isConvertible(schemaItem.type))) {
|
|
1948
|
+
const value = {};
|
|
1949
|
+
value.valueHex = asn1Item instanceof asn1js.Null ? toArrayBuffer(asn1Item.valueBeforeDecodeView) : asn1Item.valueBlock.toBER();
|
|
1950
|
+
asn1Value.push(new asn1js.Primitive({
|
|
1951
|
+
optional: schemaItem.optional,
|
|
1952
|
+
idBlock: {
|
|
1953
|
+
tagClass: 3,
|
|
1954
|
+
tagNumber: schemaItem.context,
|
|
1955
|
+
},
|
|
1956
|
+
...value,
|
|
1957
|
+
}));
|
|
1958
|
+
}
|
|
1959
|
+
else {
|
|
1960
|
+
asn1Value.push(new asn1js.Constructed({
|
|
1961
|
+
optional: schemaItem.optional,
|
|
1962
|
+
idBlock: {
|
|
1963
|
+
tagClass: 3,
|
|
1964
|
+
tagNumber: schemaItem.context,
|
|
1965
|
+
},
|
|
1966
|
+
value: asn1Item.valueBlock.value,
|
|
1967
|
+
}));
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
else {
|
|
1971
|
+
asn1Value.push(new asn1js.Constructed({
|
|
1972
|
+
optional: schemaItem.optional,
|
|
1973
|
+
idBlock: {
|
|
1974
|
+
tagClass: 3,
|
|
1975
|
+
tagNumber: schemaItem.context,
|
|
1976
|
+
},
|
|
1977
|
+
value: [asn1Item],
|
|
1978
|
+
}));
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
else if (schemaItem.repeated) {
|
|
1982
|
+
asn1Value = asn1Value.concat(asn1Item);
|
|
1983
|
+
}
|
|
1984
|
+
else {
|
|
1985
|
+
asn1Value.push(asn1Item);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
let asnSchema;
|
|
1990
|
+
switch (schema.type) {
|
|
1991
|
+
case AsnTypeTypes.Sequence:
|
|
1992
|
+
asnSchema = new asn1js.Sequence({ value: asn1Value });
|
|
1993
|
+
break;
|
|
1994
|
+
case AsnTypeTypes.Set:
|
|
1995
|
+
asnSchema = new asn1js.Set({ value: asn1Value });
|
|
1996
|
+
break;
|
|
1997
|
+
case AsnTypeTypes.Choice:
|
|
1998
|
+
if (!asn1Value[0]) {
|
|
1999
|
+
throw new Error(`Schema '${target.name}' has wrong data. Choice cannot be empty.`);
|
|
2000
|
+
}
|
|
2001
|
+
asnSchema = asn1Value[0];
|
|
2002
|
+
break;
|
|
2003
|
+
}
|
|
2004
|
+
return asnSchema;
|
|
2005
|
+
}
|
|
2006
|
+
static toAsnItem(schemaItem, key, target, objProp) {
|
|
2007
|
+
let asn1Item;
|
|
2008
|
+
if (typeof schemaItem.type === "number") {
|
|
2009
|
+
const converter = schemaItem.converter;
|
|
2010
|
+
if (!converter) {
|
|
2011
|
+
throw new Error(`Property '${key}' doesn't have converter for type ${AsnPropTypes[schemaItem.type]} in schema '${target.name}'`);
|
|
2012
|
+
}
|
|
2013
|
+
if (schemaItem.repeated) {
|
|
2014
|
+
if (!Array.isArray(objProp)) {
|
|
2015
|
+
throw new TypeError("Parameter 'objProp' should be type of Array.");
|
|
2016
|
+
}
|
|
2017
|
+
const items = Array.from(objProp, (element) => converter.toASN(element));
|
|
2018
|
+
const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set;
|
|
2019
|
+
asn1Item = new Container({ value: items });
|
|
2020
|
+
}
|
|
2021
|
+
else {
|
|
2022
|
+
asn1Item = converter.toASN(objProp);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
else {
|
|
2026
|
+
if (schemaItem.repeated) {
|
|
2027
|
+
if (!Array.isArray(objProp)) {
|
|
2028
|
+
throw new TypeError("Parameter 'objProp' should be type of Array.");
|
|
2029
|
+
}
|
|
2030
|
+
const items = Array.from(objProp, (element) => this.toASN(element));
|
|
2031
|
+
const Container = schemaItem.repeated === "sequence" ? asn1js.Sequence : asn1js.Set;
|
|
2032
|
+
asn1Item = new Container({ value: items });
|
|
2033
|
+
}
|
|
2034
|
+
else {
|
|
2035
|
+
asn1Item = this.toASN(objProp);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
return asn1Item;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/objects.js
|
|
2043
|
+
class AsnArray extends Array {
|
|
2044
|
+
constructor(items = []) {
|
|
2045
|
+
if (typeof items === "number") {
|
|
2046
|
+
super(items);
|
|
2047
|
+
}
|
|
2048
|
+
else {
|
|
2049
|
+
super();
|
|
2050
|
+
for (const item of items) {
|
|
2051
|
+
this.push(item);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/convert.js
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
class AsnConvert {
|
|
2063
|
+
static serialize(obj) {
|
|
2064
|
+
return AsnSerializer.serialize(obj);
|
|
2065
|
+
}
|
|
2066
|
+
static parse(data, target, options) {
|
|
2067
|
+
return AsnParser.parse(data, target, options);
|
|
2068
|
+
}
|
|
2069
|
+
static toString(data, options) {
|
|
2070
|
+
const buf = isBufferSource(data) ? toArrayBuffer(data) : AsnConvert.serialize(data);
|
|
2071
|
+
const asn = asn1js.fromBER(buf, options?.berOptions);
|
|
2072
|
+
if (asn.offset === -1) {
|
|
2073
|
+
throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`);
|
|
2074
|
+
}
|
|
2075
|
+
return asn.result.toString();
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@peculiar+asn1-schema@2.9.4/node_modules/@peculiar/asn1-schema/build/es2015/index.js
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
/***/ })
|
|
2092
|
+
|
|
2093
|
+
};
|