@bcts/components 1.0.0-beta.0 → 1.0.0-beta.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/dist/index.cjs +1160 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +799 -816
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +992 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/dist/digest-B1bpgcdz.mjs +0 -943
- package/dist/digest-B1bpgcdz.mjs.map +0 -1
- package/dist/digest-DL5sTq8T.cjs +0 -996
- package/dist/digest-DL5sTq8T.cjs.map +0 -1
- package/dist/digest-DRakTOWS.cjs +0 -2
package/dist/index.iife.js
CHANGED
|
@@ -7,16 +7,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
11
|
-
var __exportAll = (all, no_symbols) => {
|
|
12
|
-
let target = {};
|
|
13
|
-
for (var name in all) __defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
10
|
var __copyProps = (to, from, except, desc) => {
|
|
21
11
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
12
|
key = keys[i];
|
|
@@ -35,6 +25,483 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
35
25
|
_scure_sr25519 = __toESM(_scure_sr25519, 1);
|
|
36
26
|
//#region src/error.ts
|
|
37
27
|
/**
|
|
28
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
29
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* Error types for cryptographic and component operations
|
|
33
|
+
*
|
|
34
|
+
* Ported from bc-components-rust/src/error.rs
|
|
35
|
+
*
|
|
36
|
+
* This module provides a unified error handling system that matches the Rust
|
|
37
|
+
* implementation's error variants with full structural parity:
|
|
38
|
+
*
|
|
39
|
+
* - InvalidSize: Invalid data size for the specified type
|
|
40
|
+
* - InvalidData: Invalid data format or content
|
|
41
|
+
* - DataTooShort: Data too short for the expected type
|
|
42
|
+
* - Crypto: Cryptographic operation failed
|
|
43
|
+
* - Cbor: CBOR encoding or decoding error
|
|
44
|
+
* - Sskr: SSKR error
|
|
45
|
+
* - Ssh: SSH key operation failed
|
|
46
|
+
* - Uri: URI parsing failed
|
|
47
|
+
* - Compression: Data compression/decompression failed
|
|
48
|
+
* - PostQuantum: Post-quantum cryptography library error
|
|
49
|
+
* - LevelMismatch: Signature level mismatch
|
|
50
|
+
* - SshAgent: SSH agent operation failed
|
|
51
|
+
* - Hex: Hex decoding error
|
|
52
|
+
* - Utf8: UTF-8 conversion error
|
|
53
|
+
* - Env: Environment variable error
|
|
54
|
+
* - SshAgentClient: SSH agent client error
|
|
55
|
+
* - General: General error with custom message
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Error kind enum matching Rust's Error variants.
|
|
59
|
+
*
|
|
60
|
+
* This enum allows programmatic checking of error types, matching the
|
|
61
|
+
* Rust enum variants exactly.
|
|
62
|
+
*/
|
|
63
|
+
let ErrorKind = /* @__PURE__ */ function(ErrorKind) {
|
|
64
|
+
/** Invalid data size for the specified type */
|
|
65
|
+
ErrorKind["InvalidSize"] = "InvalidSize";
|
|
66
|
+
/** Invalid data format or content */
|
|
67
|
+
ErrorKind["InvalidData"] = "InvalidData";
|
|
68
|
+
/** Data too short for the expected type */
|
|
69
|
+
ErrorKind["DataTooShort"] = "DataTooShort";
|
|
70
|
+
/** Cryptographic operation failed */
|
|
71
|
+
ErrorKind["Crypto"] = "Crypto";
|
|
72
|
+
/** CBOR encoding or decoding error */
|
|
73
|
+
ErrorKind["Cbor"] = "Cbor";
|
|
74
|
+
/** SSKR error */
|
|
75
|
+
ErrorKind["Sskr"] = "Sskr";
|
|
76
|
+
/** SSH key operation failed */
|
|
77
|
+
ErrorKind["Ssh"] = "Ssh";
|
|
78
|
+
/** URI parsing failed */
|
|
79
|
+
ErrorKind["Uri"] = "Uri";
|
|
80
|
+
/** Data compression/decompression failed */
|
|
81
|
+
ErrorKind["Compression"] = "Compression";
|
|
82
|
+
/** Post-quantum cryptography library error */
|
|
83
|
+
ErrorKind["PostQuantum"] = "PostQuantum";
|
|
84
|
+
/** Signature level mismatch */
|
|
85
|
+
ErrorKind["LevelMismatch"] = "LevelMismatch";
|
|
86
|
+
/** SSH agent operation failed */
|
|
87
|
+
ErrorKind["SshAgent"] = "SshAgent";
|
|
88
|
+
/** Hex decoding error */
|
|
89
|
+
ErrorKind["Hex"] = "Hex";
|
|
90
|
+
/** UTF-8 conversion error */
|
|
91
|
+
ErrorKind["Utf8"] = "Utf8";
|
|
92
|
+
/** Environment variable error */
|
|
93
|
+
ErrorKind["Env"] = "Env";
|
|
94
|
+
/** SSH agent client error */
|
|
95
|
+
ErrorKind["SshAgentClient"] = "SshAgentClient";
|
|
96
|
+
/** General error with custom message */
|
|
97
|
+
ErrorKind["General"] = "General";
|
|
98
|
+
return ErrorKind;
|
|
99
|
+
}({});
|
|
100
|
+
/**
|
|
101
|
+
* Error type for cryptographic and component operations.
|
|
102
|
+
*
|
|
103
|
+
* This class provides full structural parity with the Rust Error enum,
|
|
104
|
+
* including:
|
|
105
|
+
* - An `errorKind` property for programmatic error type checking
|
|
106
|
+
* - Structured `errorData` for accessing error-specific fields
|
|
107
|
+
* - Factory methods matching Rust's impl block
|
|
108
|
+
*/
|
|
109
|
+
var CryptoError = class CryptoError extends Error {
|
|
110
|
+
/** The error kind for programmatic type checking */
|
|
111
|
+
errorKind;
|
|
112
|
+
/** Structured error data matching Rust's error variants */
|
|
113
|
+
errorData;
|
|
114
|
+
constructor(message, errorData) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.name = "CryptoError";
|
|
117
|
+
this.errorKind = errorData.kind;
|
|
118
|
+
this.errorData = errorData;
|
|
119
|
+
const ErrorWithStackTrace = Error;
|
|
120
|
+
if (typeof ErrorWithStackTrace.captureStackTrace === "function") ErrorWithStackTrace.captureStackTrace(this, CryptoError);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create an invalid size error.
|
|
124
|
+
*
|
|
125
|
+
* Rust equivalent: `Error::InvalidSize { data_type, expected, actual }`
|
|
126
|
+
*
|
|
127
|
+
* @param expected - The expected size
|
|
128
|
+
* @param actual - The actual size received
|
|
129
|
+
*/
|
|
130
|
+
static invalidSize(expected, actual) {
|
|
131
|
+
return CryptoError.invalidSizeForType("data", expected, actual);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create an invalid size error with a data type name.
|
|
135
|
+
*
|
|
136
|
+
* Rust equivalent: `Error::invalid_size(data_type, expected, actual)`
|
|
137
|
+
*
|
|
138
|
+
* @param dataType - The name of the data type
|
|
139
|
+
* @param expected - The expected size
|
|
140
|
+
* @param actual - The actual size received
|
|
141
|
+
*/
|
|
142
|
+
static invalidSizeForType(dataType, expected, actual) {
|
|
143
|
+
return new CryptoError(`invalid ${dataType} size: expected ${expected}, got ${actual}`, {
|
|
144
|
+
kind: "InvalidSize",
|
|
145
|
+
dataType,
|
|
146
|
+
expected,
|
|
147
|
+
actual
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create an invalid data error.
|
|
152
|
+
*
|
|
153
|
+
* @param message - Description of what's invalid
|
|
154
|
+
*/
|
|
155
|
+
static invalidData(message) {
|
|
156
|
+
return CryptoError.invalidDataForType("data", message);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Create an invalid data error with a data type name.
|
|
160
|
+
*
|
|
161
|
+
* Rust equivalent: `Error::invalid_data(data_type, reason)`
|
|
162
|
+
*
|
|
163
|
+
* @param dataType - The name of the data type
|
|
164
|
+
* @param reason - The reason the data is invalid
|
|
165
|
+
*/
|
|
166
|
+
static invalidDataForType(dataType, reason) {
|
|
167
|
+
return new CryptoError(`invalid ${dataType}: ${reason}`, {
|
|
168
|
+
kind: "InvalidData",
|
|
169
|
+
dataType,
|
|
170
|
+
reason
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Create a data too short error.
|
|
175
|
+
*
|
|
176
|
+
* Rust equivalent: `Error::data_too_short(data_type, minimum, actual)`
|
|
177
|
+
*
|
|
178
|
+
* @param dataType - The name of the data type
|
|
179
|
+
* @param minimum - The minimum required size
|
|
180
|
+
* @param actual - The actual size received
|
|
181
|
+
*/
|
|
182
|
+
static dataTooShort(dataType, minimum, actual) {
|
|
183
|
+
return new CryptoError(`data too short: ${dataType} expected at least ${minimum}, got ${actual}`, {
|
|
184
|
+
kind: "DataTooShort",
|
|
185
|
+
dataType,
|
|
186
|
+
minimum,
|
|
187
|
+
actual
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Create an invalid format error.
|
|
192
|
+
*
|
|
193
|
+
* @param message - Description of the format error
|
|
194
|
+
*/
|
|
195
|
+
static invalidFormat(message) {
|
|
196
|
+
return CryptoError.invalidDataForType("format", message);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Create an invalid input error.
|
|
200
|
+
*
|
|
201
|
+
* @param message - Description of the invalid input
|
|
202
|
+
*/
|
|
203
|
+
static invalidInput(message) {
|
|
204
|
+
return CryptoError.invalidDataForType("input", message);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Create a cryptographic operation failed error.
|
|
208
|
+
*
|
|
209
|
+
* Rust equivalent: `Error::crypto(msg)`
|
|
210
|
+
*
|
|
211
|
+
* @param message - Description of the failure
|
|
212
|
+
*/
|
|
213
|
+
static cryptoOperation(message) {
|
|
214
|
+
return CryptoError.crypto(message);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Create a crypto error.
|
|
218
|
+
*
|
|
219
|
+
* Rust equivalent: `Error::Crypto(msg)`
|
|
220
|
+
*
|
|
221
|
+
* @param message - Description of the failure
|
|
222
|
+
*/
|
|
223
|
+
static crypto(message) {
|
|
224
|
+
return new CryptoError(`cryptographic operation failed: ${message}`, {
|
|
225
|
+
kind: "Crypto",
|
|
226
|
+
message
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Create a post-quantum cryptography error.
|
|
231
|
+
*
|
|
232
|
+
* Rust equivalent: `Error::post_quantum(msg)`
|
|
233
|
+
*
|
|
234
|
+
* @param message - Description of the failure
|
|
235
|
+
*/
|
|
236
|
+
static postQuantum(message) {
|
|
237
|
+
return new CryptoError(`post-quantum cryptography error: ${message}`, {
|
|
238
|
+
kind: "PostQuantum",
|
|
239
|
+
message
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create a signature level mismatch error.
|
|
244
|
+
*
|
|
245
|
+
* Rust equivalent: `Error::LevelMismatch`
|
|
246
|
+
*/
|
|
247
|
+
static levelMismatch() {
|
|
248
|
+
return new CryptoError("signature level does not match key level", { kind: "LevelMismatch" });
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Create a CBOR error.
|
|
252
|
+
*
|
|
253
|
+
* Rust equivalent: `Error::Cbor(err)`
|
|
254
|
+
*
|
|
255
|
+
* @param message - Description of the CBOR error
|
|
256
|
+
*/
|
|
257
|
+
static cbor(message) {
|
|
258
|
+
return new CryptoError(`CBOR error: ${message}`, {
|
|
259
|
+
kind: "Cbor",
|
|
260
|
+
message
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Create a hex decoding error.
|
|
265
|
+
*
|
|
266
|
+
* Rust equivalent: `Error::Hex(err)`
|
|
267
|
+
*
|
|
268
|
+
* @param message - Description of the hex error
|
|
269
|
+
*/
|
|
270
|
+
static hex(message) {
|
|
271
|
+
return new CryptoError(`hex decoding error: ${message}`, {
|
|
272
|
+
kind: "Hex",
|
|
273
|
+
message
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Create a UTF-8 conversion error.
|
|
278
|
+
*
|
|
279
|
+
* Rust equivalent: `Error::Utf8(err)`
|
|
280
|
+
*
|
|
281
|
+
* @param message - Description of the UTF-8 error
|
|
282
|
+
*/
|
|
283
|
+
static utf8(message) {
|
|
284
|
+
return new CryptoError(`UTF-8 conversion error: ${message}`, {
|
|
285
|
+
kind: "Utf8",
|
|
286
|
+
message
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Create a compression error.
|
|
291
|
+
*
|
|
292
|
+
* Rust equivalent: `Error::compression(msg)`
|
|
293
|
+
*
|
|
294
|
+
* @param message - Description of the compression error
|
|
295
|
+
*/
|
|
296
|
+
static compression(message) {
|
|
297
|
+
return new CryptoError(`compression error: ${message}`, {
|
|
298
|
+
kind: "Compression",
|
|
299
|
+
message
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Create a URI parsing error.
|
|
304
|
+
*
|
|
305
|
+
* Rust equivalent: `Error::Uri(err)`
|
|
306
|
+
*
|
|
307
|
+
* @param message - Description of the URI error
|
|
308
|
+
*/
|
|
309
|
+
static uri(message) {
|
|
310
|
+
return new CryptoError(`invalid URI: ${message}`, {
|
|
311
|
+
kind: "Uri",
|
|
312
|
+
message
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Create an SSKR error.
|
|
317
|
+
*
|
|
318
|
+
* Rust equivalent: `Error::Sskr(err)`
|
|
319
|
+
*
|
|
320
|
+
* @param message - Description of the SSKR error
|
|
321
|
+
*/
|
|
322
|
+
static sskr(message) {
|
|
323
|
+
return new CryptoError(`SSKR error: ${message}`, {
|
|
324
|
+
kind: "Sskr",
|
|
325
|
+
message
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Create an SSH operation error.
|
|
330
|
+
*
|
|
331
|
+
* Rust equivalent: `Error::ssh(msg)`
|
|
332
|
+
*
|
|
333
|
+
* @param message - Description of the SSH error
|
|
334
|
+
*/
|
|
335
|
+
static ssh(message) {
|
|
336
|
+
return new CryptoError(`SSH operation failed: ${message}`, {
|
|
337
|
+
kind: "Ssh",
|
|
338
|
+
message
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Create an SSH agent error.
|
|
343
|
+
*
|
|
344
|
+
* Rust equivalent: `Error::ssh_agent(msg)`
|
|
345
|
+
*
|
|
346
|
+
* @param message - Description of the SSH agent error
|
|
347
|
+
*/
|
|
348
|
+
static sshAgent(message) {
|
|
349
|
+
return new CryptoError(`SSH agent error: ${message}`, {
|
|
350
|
+
kind: "SshAgent",
|
|
351
|
+
message
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Create an SSH agent client error.
|
|
356
|
+
*
|
|
357
|
+
* Rust equivalent: `Error::ssh_agent_client(msg)`
|
|
358
|
+
*
|
|
359
|
+
* @param message - Description of the SSH agent client error
|
|
360
|
+
*/
|
|
361
|
+
static sshAgentClient(message) {
|
|
362
|
+
return new CryptoError(`SSH agent client error: ${message}`, {
|
|
363
|
+
kind: "SshAgentClient",
|
|
364
|
+
message
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Create an environment variable error.
|
|
369
|
+
*
|
|
370
|
+
* Rust equivalent: `Error::Env(err)`
|
|
371
|
+
*
|
|
372
|
+
* @param message - Description of the environment error
|
|
373
|
+
*/
|
|
374
|
+
static env(message) {
|
|
375
|
+
return new CryptoError(`environment variable error: ${message}`, {
|
|
376
|
+
kind: "Env",
|
|
377
|
+
message
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Create a general error with a custom message.
|
|
382
|
+
*
|
|
383
|
+
* Rust equivalent: `Error::general(msg)` / `Error::General(msg)`
|
|
384
|
+
*
|
|
385
|
+
* @param message - The error message
|
|
386
|
+
*/
|
|
387
|
+
static general(message) {
|
|
388
|
+
return new CryptoError(message, {
|
|
389
|
+
kind: "General",
|
|
390
|
+
message
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Check if this error is of a specific kind.
|
|
395
|
+
*
|
|
396
|
+
* @param kind - The error kind to check
|
|
397
|
+
*/
|
|
398
|
+
isKind(kind) {
|
|
399
|
+
return this.errorKind === kind;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Check if this is an InvalidSize error.
|
|
403
|
+
*/
|
|
404
|
+
isInvalidSize() {
|
|
405
|
+
return this.errorKind === "InvalidSize";
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Check if this is an InvalidData error.
|
|
409
|
+
*/
|
|
410
|
+
isInvalidData() {
|
|
411
|
+
return this.errorKind === "InvalidData";
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Check if this is a DataTooShort error.
|
|
415
|
+
*/
|
|
416
|
+
isDataTooShort() {
|
|
417
|
+
return this.errorKind === "DataTooShort";
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Check if this is a Crypto error.
|
|
421
|
+
*/
|
|
422
|
+
isCrypto() {
|
|
423
|
+
return this.errorKind === "Crypto";
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Check if this is a Cbor error.
|
|
427
|
+
*/
|
|
428
|
+
isCbor() {
|
|
429
|
+
return this.errorKind === "Cbor";
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Check if this is an Sskr error.
|
|
433
|
+
*/
|
|
434
|
+
isSskr() {
|
|
435
|
+
return this.errorKind === "Sskr";
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Check if this is an Ssh error.
|
|
439
|
+
*/
|
|
440
|
+
isSsh() {
|
|
441
|
+
return this.errorKind === "Ssh";
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Check if this is a Uri error.
|
|
445
|
+
*/
|
|
446
|
+
isUri() {
|
|
447
|
+
return this.errorKind === "Uri";
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Check if this is a Compression error.
|
|
451
|
+
*/
|
|
452
|
+
isCompression() {
|
|
453
|
+
return this.errorKind === "Compression";
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Check if this is a PostQuantum error.
|
|
457
|
+
*/
|
|
458
|
+
isPostQuantum() {
|
|
459
|
+
return this.errorKind === "PostQuantum";
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Check if this is a LevelMismatch error.
|
|
463
|
+
*/
|
|
464
|
+
isLevelMismatch() {
|
|
465
|
+
return this.errorKind === "LevelMismatch";
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Check if this is an SshAgent error.
|
|
469
|
+
*/
|
|
470
|
+
isSshAgent() {
|
|
471
|
+
return this.errorKind === "SshAgent";
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Check if this is a Hex error.
|
|
475
|
+
*/
|
|
476
|
+
isHex() {
|
|
477
|
+
return this.errorKind === "Hex";
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Check if this is a Utf8 error.
|
|
481
|
+
*/
|
|
482
|
+
isUtf8() {
|
|
483
|
+
return this.errorKind === "Utf8";
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Check if this is an Env error.
|
|
487
|
+
*/
|
|
488
|
+
isEnv() {
|
|
489
|
+
return this.errorKind === "Env";
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Check if this is an SshAgentClient error.
|
|
493
|
+
*/
|
|
494
|
+
isSshAgentClient() {
|
|
495
|
+
return this.errorKind === "SshAgentClient";
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Check if this is a General error.
|
|
499
|
+
*/
|
|
500
|
+
isGeneral() {
|
|
501
|
+
return this.errorKind === "General";
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
38
505
|
* Type guard to check if a result is an Error.
|
|
39
506
|
*/
|
|
40
507
|
function isError(result) {
|
|
@@ -52,444 +519,8 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
52
519
|
function isCryptoErrorKind(result, kind) {
|
|
53
520
|
return isCryptoError(result) && result.errorKind === kind;
|
|
54
521
|
}
|
|
55
|
-
var ErrorKind, CryptoError;
|
|
56
|
-
var init_error = __esmMin((() => {
|
|
57
|
-
ErrorKind = /* @__PURE__ */ function(ErrorKind) {
|
|
58
|
-
/** Invalid data size for the specified type */
|
|
59
|
-
ErrorKind["InvalidSize"] = "InvalidSize";
|
|
60
|
-
/** Invalid data format or content */
|
|
61
|
-
ErrorKind["InvalidData"] = "InvalidData";
|
|
62
|
-
/** Data too short for the expected type */
|
|
63
|
-
ErrorKind["DataTooShort"] = "DataTooShort";
|
|
64
|
-
/** Cryptographic operation failed */
|
|
65
|
-
ErrorKind["Crypto"] = "Crypto";
|
|
66
|
-
/** CBOR encoding or decoding error */
|
|
67
|
-
ErrorKind["Cbor"] = "Cbor";
|
|
68
|
-
/** SSKR error */
|
|
69
|
-
ErrorKind["Sskr"] = "Sskr";
|
|
70
|
-
/** SSH key operation failed */
|
|
71
|
-
ErrorKind["Ssh"] = "Ssh";
|
|
72
|
-
/** URI parsing failed */
|
|
73
|
-
ErrorKind["Uri"] = "Uri";
|
|
74
|
-
/** Data compression/decompression failed */
|
|
75
|
-
ErrorKind["Compression"] = "Compression";
|
|
76
|
-
/** Post-quantum cryptography library error */
|
|
77
|
-
ErrorKind["PostQuantum"] = "PostQuantum";
|
|
78
|
-
/** Signature level mismatch */
|
|
79
|
-
ErrorKind["LevelMismatch"] = "LevelMismatch";
|
|
80
|
-
/** SSH agent operation failed */
|
|
81
|
-
ErrorKind["SshAgent"] = "SshAgent";
|
|
82
|
-
/** Hex decoding error */
|
|
83
|
-
ErrorKind["Hex"] = "Hex";
|
|
84
|
-
/** UTF-8 conversion error */
|
|
85
|
-
ErrorKind["Utf8"] = "Utf8";
|
|
86
|
-
/** Environment variable error */
|
|
87
|
-
ErrorKind["Env"] = "Env";
|
|
88
|
-
/** SSH agent client error */
|
|
89
|
-
ErrorKind["SshAgentClient"] = "SshAgentClient";
|
|
90
|
-
/** General error with custom message */
|
|
91
|
-
ErrorKind["General"] = "General";
|
|
92
|
-
return ErrorKind;
|
|
93
|
-
}({});
|
|
94
|
-
CryptoError = class CryptoError extends Error {
|
|
95
|
-
/** The error kind for programmatic type checking */
|
|
96
|
-
errorKind;
|
|
97
|
-
/** Structured error data matching Rust's error variants */
|
|
98
|
-
errorData;
|
|
99
|
-
constructor(message, errorData) {
|
|
100
|
-
super(message);
|
|
101
|
-
this.name = "CryptoError";
|
|
102
|
-
this.errorKind = errorData.kind;
|
|
103
|
-
this.errorData = errorData;
|
|
104
|
-
const ErrorWithStackTrace = Error;
|
|
105
|
-
if (typeof ErrorWithStackTrace.captureStackTrace === "function") ErrorWithStackTrace.captureStackTrace(this, CryptoError);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Create an invalid size error.
|
|
109
|
-
*
|
|
110
|
-
* Rust equivalent: `Error::InvalidSize { data_type, expected, actual }`
|
|
111
|
-
*
|
|
112
|
-
* @param expected - The expected size
|
|
113
|
-
* @param actual - The actual size received
|
|
114
|
-
*/
|
|
115
|
-
static invalidSize(expected, actual) {
|
|
116
|
-
return CryptoError.invalidSizeForType("data", expected, actual);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Create an invalid size error with a data type name.
|
|
120
|
-
*
|
|
121
|
-
* Rust equivalent: `Error::invalid_size(data_type, expected, actual)`
|
|
122
|
-
*
|
|
123
|
-
* @param dataType - The name of the data type
|
|
124
|
-
* @param expected - The expected size
|
|
125
|
-
* @param actual - The actual size received
|
|
126
|
-
*/
|
|
127
|
-
static invalidSizeForType(dataType, expected, actual) {
|
|
128
|
-
return new CryptoError(`invalid ${dataType} size: expected ${expected}, got ${actual}`, {
|
|
129
|
-
kind: "InvalidSize",
|
|
130
|
-
dataType,
|
|
131
|
-
expected,
|
|
132
|
-
actual
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Create an invalid data error.
|
|
137
|
-
*
|
|
138
|
-
* @param message - Description of what's invalid
|
|
139
|
-
*/
|
|
140
|
-
static invalidData(message) {
|
|
141
|
-
return CryptoError.invalidDataForType("data", message);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Create an invalid data error with a data type name.
|
|
145
|
-
*
|
|
146
|
-
* Rust equivalent: `Error::invalid_data(data_type, reason)`
|
|
147
|
-
*
|
|
148
|
-
* @param dataType - The name of the data type
|
|
149
|
-
* @param reason - The reason the data is invalid
|
|
150
|
-
*/
|
|
151
|
-
static invalidDataForType(dataType, reason) {
|
|
152
|
-
return new CryptoError(`invalid ${dataType}: ${reason}`, {
|
|
153
|
-
kind: "InvalidData",
|
|
154
|
-
dataType,
|
|
155
|
-
reason
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Create a data too short error.
|
|
160
|
-
*
|
|
161
|
-
* Rust equivalent: `Error::data_too_short(data_type, minimum, actual)`
|
|
162
|
-
*
|
|
163
|
-
* @param dataType - The name of the data type
|
|
164
|
-
* @param minimum - The minimum required size
|
|
165
|
-
* @param actual - The actual size received
|
|
166
|
-
*/
|
|
167
|
-
static dataTooShort(dataType, minimum, actual) {
|
|
168
|
-
return new CryptoError(`data too short: ${dataType} expected at least ${minimum}, got ${actual}`, {
|
|
169
|
-
kind: "DataTooShort",
|
|
170
|
-
dataType,
|
|
171
|
-
minimum,
|
|
172
|
-
actual
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Create an invalid format error.
|
|
177
|
-
*
|
|
178
|
-
* @param message - Description of the format error
|
|
179
|
-
*/
|
|
180
|
-
static invalidFormat(message) {
|
|
181
|
-
return CryptoError.invalidDataForType("format", message);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Create an invalid input error.
|
|
185
|
-
*
|
|
186
|
-
* @param message - Description of the invalid input
|
|
187
|
-
*/
|
|
188
|
-
static invalidInput(message) {
|
|
189
|
-
return CryptoError.invalidDataForType("input", message);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Create a cryptographic operation failed error.
|
|
193
|
-
*
|
|
194
|
-
* Rust equivalent: `Error::crypto(msg)`
|
|
195
|
-
*
|
|
196
|
-
* @param message - Description of the failure
|
|
197
|
-
*/
|
|
198
|
-
static cryptoOperation(message) {
|
|
199
|
-
return CryptoError.crypto(message);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Create a crypto error.
|
|
203
|
-
*
|
|
204
|
-
* Rust equivalent: `Error::Crypto(msg)`
|
|
205
|
-
*
|
|
206
|
-
* @param message - Description of the failure
|
|
207
|
-
*/
|
|
208
|
-
static crypto(message) {
|
|
209
|
-
return new CryptoError(`cryptographic operation failed: ${message}`, {
|
|
210
|
-
kind: "Crypto",
|
|
211
|
-
message
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Create a post-quantum cryptography error.
|
|
216
|
-
*
|
|
217
|
-
* Rust equivalent: `Error::post_quantum(msg)`
|
|
218
|
-
*
|
|
219
|
-
* @param message - Description of the failure
|
|
220
|
-
*/
|
|
221
|
-
static postQuantum(message) {
|
|
222
|
-
return new CryptoError(`post-quantum cryptography error: ${message}`, {
|
|
223
|
-
kind: "PostQuantum",
|
|
224
|
-
message
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Create a signature level mismatch error.
|
|
229
|
-
*
|
|
230
|
-
* Rust equivalent: `Error::LevelMismatch`
|
|
231
|
-
*/
|
|
232
|
-
static levelMismatch() {
|
|
233
|
-
return new CryptoError("signature level does not match key level", { kind: "LevelMismatch" });
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Create a CBOR error.
|
|
237
|
-
*
|
|
238
|
-
* Rust equivalent: `Error::Cbor(err)`
|
|
239
|
-
*
|
|
240
|
-
* @param message - Description of the CBOR error
|
|
241
|
-
*/
|
|
242
|
-
static cbor(message) {
|
|
243
|
-
return new CryptoError(`CBOR error: ${message}`, {
|
|
244
|
-
kind: "Cbor",
|
|
245
|
-
message
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Create a hex decoding error.
|
|
250
|
-
*
|
|
251
|
-
* Rust equivalent: `Error::Hex(err)`
|
|
252
|
-
*
|
|
253
|
-
* @param message - Description of the hex error
|
|
254
|
-
*/
|
|
255
|
-
static hex(message) {
|
|
256
|
-
return new CryptoError(`hex decoding error: ${message}`, {
|
|
257
|
-
kind: "Hex",
|
|
258
|
-
message
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Create a UTF-8 conversion error.
|
|
263
|
-
*
|
|
264
|
-
* Rust equivalent: `Error::Utf8(err)`
|
|
265
|
-
*
|
|
266
|
-
* @param message - Description of the UTF-8 error
|
|
267
|
-
*/
|
|
268
|
-
static utf8(message) {
|
|
269
|
-
return new CryptoError(`UTF-8 conversion error: ${message}`, {
|
|
270
|
-
kind: "Utf8",
|
|
271
|
-
message
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Create a compression error.
|
|
276
|
-
*
|
|
277
|
-
* Rust equivalent: `Error::compression(msg)`
|
|
278
|
-
*
|
|
279
|
-
* @param message - Description of the compression error
|
|
280
|
-
*/
|
|
281
|
-
static compression(message) {
|
|
282
|
-
return new CryptoError(`compression error: ${message}`, {
|
|
283
|
-
kind: "Compression",
|
|
284
|
-
message
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Create a URI parsing error.
|
|
289
|
-
*
|
|
290
|
-
* Rust equivalent: `Error::Uri(err)`
|
|
291
|
-
*
|
|
292
|
-
* @param message - Description of the URI error
|
|
293
|
-
*/
|
|
294
|
-
static uri(message) {
|
|
295
|
-
return new CryptoError(`invalid URI: ${message}`, {
|
|
296
|
-
kind: "Uri",
|
|
297
|
-
message
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Create an SSKR error.
|
|
302
|
-
*
|
|
303
|
-
* Rust equivalent: `Error::Sskr(err)`
|
|
304
|
-
*
|
|
305
|
-
* @param message - Description of the SSKR error
|
|
306
|
-
*/
|
|
307
|
-
static sskr(message) {
|
|
308
|
-
return new CryptoError(`SSKR error: ${message}`, {
|
|
309
|
-
kind: "Sskr",
|
|
310
|
-
message
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Create an SSH operation error.
|
|
315
|
-
*
|
|
316
|
-
* Rust equivalent: `Error::ssh(msg)`
|
|
317
|
-
*
|
|
318
|
-
* @param message - Description of the SSH error
|
|
319
|
-
*/
|
|
320
|
-
static ssh(message) {
|
|
321
|
-
return new CryptoError(`SSH operation failed: ${message}`, {
|
|
322
|
-
kind: "Ssh",
|
|
323
|
-
message
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Create an SSH agent error.
|
|
328
|
-
*
|
|
329
|
-
* Rust equivalent: `Error::ssh_agent(msg)`
|
|
330
|
-
*
|
|
331
|
-
* @param message - Description of the SSH agent error
|
|
332
|
-
*/
|
|
333
|
-
static sshAgent(message) {
|
|
334
|
-
return new CryptoError(`SSH agent error: ${message}`, {
|
|
335
|
-
kind: "SshAgent",
|
|
336
|
-
message
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Create an SSH agent client error.
|
|
341
|
-
*
|
|
342
|
-
* Rust equivalent: `Error::ssh_agent_client(msg)`
|
|
343
|
-
*
|
|
344
|
-
* @param message - Description of the SSH agent client error
|
|
345
|
-
*/
|
|
346
|
-
static sshAgentClient(message) {
|
|
347
|
-
return new CryptoError(`SSH agent client error: ${message}`, {
|
|
348
|
-
kind: "SshAgentClient",
|
|
349
|
-
message
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Create an environment variable error.
|
|
354
|
-
*
|
|
355
|
-
* Rust equivalent: `Error::Env(err)`
|
|
356
|
-
*
|
|
357
|
-
* @param message - Description of the environment error
|
|
358
|
-
*/
|
|
359
|
-
static env(message) {
|
|
360
|
-
return new CryptoError(`environment variable error: ${message}`, {
|
|
361
|
-
kind: "Env",
|
|
362
|
-
message
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Create a general error with a custom message.
|
|
367
|
-
*
|
|
368
|
-
* Rust equivalent: `Error::general(msg)` / `Error::General(msg)`
|
|
369
|
-
*
|
|
370
|
-
* @param message - The error message
|
|
371
|
-
*/
|
|
372
|
-
static general(message) {
|
|
373
|
-
return new CryptoError(message, {
|
|
374
|
-
kind: "General",
|
|
375
|
-
message
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Check if this error is of a specific kind.
|
|
380
|
-
*
|
|
381
|
-
* @param kind - The error kind to check
|
|
382
|
-
*/
|
|
383
|
-
isKind(kind) {
|
|
384
|
-
return this.errorKind === kind;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Check if this is an InvalidSize error.
|
|
388
|
-
*/
|
|
389
|
-
isInvalidSize() {
|
|
390
|
-
return this.errorKind === "InvalidSize";
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Check if this is an InvalidData error.
|
|
394
|
-
*/
|
|
395
|
-
isInvalidData() {
|
|
396
|
-
return this.errorKind === "InvalidData";
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Check if this is a DataTooShort error.
|
|
400
|
-
*/
|
|
401
|
-
isDataTooShort() {
|
|
402
|
-
return this.errorKind === "DataTooShort";
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Check if this is a Crypto error.
|
|
406
|
-
*/
|
|
407
|
-
isCrypto() {
|
|
408
|
-
return this.errorKind === "Crypto";
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Check if this is a Cbor error.
|
|
412
|
-
*/
|
|
413
|
-
isCbor() {
|
|
414
|
-
return this.errorKind === "Cbor";
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Check if this is an Sskr error.
|
|
418
|
-
*/
|
|
419
|
-
isSskr() {
|
|
420
|
-
return this.errorKind === "Sskr";
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Check if this is an Ssh error.
|
|
424
|
-
*/
|
|
425
|
-
isSsh() {
|
|
426
|
-
return this.errorKind === "Ssh";
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Check if this is a Uri error.
|
|
430
|
-
*/
|
|
431
|
-
isUri() {
|
|
432
|
-
return this.errorKind === "Uri";
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Check if this is a Compression error.
|
|
436
|
-
*/
|
|
437
|
-
isCompression() {
|
|
438
|
-
return this.errorKind === "Compression";
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Check if this is a PostQuantum error.
|
|
442
|
-
*/
|
|
443
|
-
isPostQuantum() {
|
|
444
|
-
return this.errorKind === "PostQuantum";
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Check if this is a LevelMismatch error.
|
|
448
|
-
*/
|
|
449
|
-
isLevelMismatch() {
|
|
450
|
-
return this.errorKind === "LevelMismatch";
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Check if this is an SshAgent error.
|
|
454
|
-
*/
|
|
455
|
-
isSshAgent() {
|
|
456
|
-
return this.errorKind === "SshAgent";
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Check if this is a Hex error.
|
|
460
|
-
*/
|
|
461
|
-
isHex() {
|
|
462
|
-
return this.errorKind === "Hex";
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Check if this is a Utf8 error.
|
|
466
|
-
*/
|
|
467
|
-
isUtf8() {
|
|
468
|
-
return this.errorKind === "Utf8";
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Check if this is an Env error.
|
|
472
|
-
*/
|
|
473
|
-
isEnv() {
|
|
474
|
-
return this.errorKind === "Env";
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Check if this is an SshAgentClient error.
|
|
478
|
-
*/
|
|
479
|
-
isSshAgentClient() {
|
|
480
|
-
return this.errorKind === "SshAgentClient";
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Check if this is a General error.
|
|
484
|
-
*/
|
|
485
|
-
isGeneral() {
|
|
486
|
-
return this.errorKind === "General";
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
}));
|
|
490
522
|
//#endregion
|
|
491
523
|
//#region src/private-key-data-provider.ts
|
|
492
|
-
init_error();
|
|
493
524
|
/**
|
|
494
525
|
* Type guard to check if an object implements PrivateKeyDataProvider
|
|
495
526
|
*/
|
|
@@ -633,7 +664,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
633
664
|
for (let i = 0; i < a.length; i++) result |= a[i] ^ b[i];
|
|
634
665
|
return result === 0;
|
|
635
666
|
}
|
|
636
|
-
var init_utils = __esmMin((() => {}));
|
|
637
667
|
//#endregion
|
|
638
668
|
//#region src/json.ts
|
|
639
669
|
/**
|
|
@@ -671,7 +701,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
671
701
|
* console.log(json2.len()); // 9
|
|
672
702
|
* ```
|
|
673
703
|
*/
|
|
674
|
-
init_utils();
|
|
675
704
|
/**
|
|
676
705
|
* A CBOR-tagged container for UTF-8 JSON text.
|
|
677
706
|
*
|
|
@@ -859,269 +888,264 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
859
888
|
* console.log(digest2.hex()); // b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
|
|
860
889
|
* ```
|
|
861
890
|
*/
|
|
862
|
-
var
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
let offset = 0;
|
|
920
|
-
for (const part of imageParts) {
|
|
921
|
-
buf.set(part, offset);
|
|
922
|
-
offset += part.length;
|
|
923
|
-
}
|
|
924
|
-
return Digest.fromImage(buf);
|
|
925
|
-
}
|
|
926
|
-
/**
|
|
927
|
-
* Compute SHA-256 digest from an array of Digests.
|
|
928
|
-
*
|
|
929
|
-
* The digest bytes are concatenated and then hashed.
|
|
930
|
-
*
|
|
931
|
-
* @param digests - Array of Digests to combine
|
|
932
|
-
*/
|
|
933
|
-
static fromDigests(digests) {
|
|
934
|
-
const buf = new Uint8Array(digests.length * Digest.DIGEST_SIZE);
|
|
935
|
-
let offset = 0;
|
|
936
|
-
for (const digest of digests) {
|
|
937
|
-
buf.set(digest._data, offset);
|
|
938
|
-
offset += Digest.DIGEST_SIZE;
|
|
939
|
-
}
|
|
940
|
-
return Digest.fromImage(buf);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Compute SHA-256 digest of data (legacy alias for fromImage).
|
|
944
|
-
* @deprecated Use fromImage instead
|
|
945
|
-
*/
|
|
946
|
-
static hash(data) {
|
|
947
|
-
return Digest.fromImage(data);
|
|
948
|
-
}
|
|
949
|
-
/**
|
|
950
|
-
* Get the raw digest bytes as a copy.
|
|
951
|
-
*/
|
|
952
|
-
toData() {
|
|
953
|
-
return new Uint8Array(this._data);
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Get a reference to the raw digest bytes.
|
|
957
|
-
*/
|
|
958
|
-
asBytes() {
|
|
959
|
-
return this._data;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Get hex string representation.
|
|
963
|
-
*/
|
|
964
|
-
hex() {
|
|
965
|
-
return bytesToHex(this._data);
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Get hex string representation (alias for hex()).
|
|
969
|
-
*/
|
|
970
|
-
toHex() {
|
|
971
|
-
return this.hex();
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Get base64 representation.
|
|
975
|
-
*/
|
|
976
|
-
toBase64() {
|
|
977
|
-
return toBase64(this._data);
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Get the first four bytes of the digest as a hexadecimal string.
|
|
981
|
-
* Useful for short descriptions.
|
|
982
|
-
*/
|
|
983
|
-
shortDescription() {
|
|
984
|
-
return bytesToHex(this._data.slice(0, 4));
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Validate the digest against the given image.
|
|
988
|
-
*
|
|
989
|
-
* The image is hashed with SHA-256 and compared to this digest.
|
|
990
|
-
* @returns `true` if the digest matches the image.
|
|
991
|
-
*/
|
|
992
|
-
validate(image) {
|
|
993
|
-
return this.equals(Digest.fromImage(image));
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* Compare with another Digest.
|
|
997
|
-
*/
|
|
998
|
-
equals(other) {
|
|
999
|
-
if (this._data.length !== other._data.length) return false;
|
|
1000
|
-
for (let i = 0; i < this._data.length; i++) if (this._data[i] !== other._data[i]) return false;
|
|
1001
|
-
return true;
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Compare digests lexicographically.
|
|
1005
|
-
*/
|
|
1006
|
-
compare(other) {
|
|
1007
|
-
for (let i = 0; i < this._data.length; i++) {
|
|
1008
|
-
const a = this._data[i];
|
|
1009
|
-
const b = other._data[i];
|
|
1010
|
-
if (a < b) return -1;
|
|
1011
|
-
if (a > b) return 1;
|
|
1012
|
-
}
|
|
1013
|
-
return 0;
|
|
1014
|
-
}
|
|
1015
|
-
/**
|
|
1016
|
-
* Get string representation.
|
|
1017
|
-
*/
|
|
1018
|
-
toString() {
|
|
1019
|
-
return `Digest(${this.hex()})`;
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* A Digest is its own digest provider - returns itself.
|
|
1023
|
-
*/
|
|
1024
|
-
digest() {
|
|
1025
|
-
return this;
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Returns the CBOR tags associated with Digest.
|
|
1029
|
-
*/
|
|
1030
|
-
cborTags() {
|
|
1031
|
-
return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.DIGEST.value]);
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Returns the untagged CBOR encoding (as a byte string).
|
|
1035
|
-
*/
|
|
1036
|
-
untaggedCbor() {
|
|
1037
|
-
return (0, _bcts_dcbor.toByteString)(this._data);
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Returns the tagged CBOR encoding.
|
|
1041
|
-
*/
|
|
1042
|
-
taggedCbor() {
|
|
1043
|
-
return (0, _bcts_dcbor.createTaggedCbor)(this);
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Returns the tagged value in CBOR binary representation.
|
|
1047
|
-
*/
|
|
1048
|
-
taggedCborData() {
|
|
1049
|
-
return this.taggedCbor().toData();
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Creates a Digest by decoding it from untagged CBOR.
|
|
1053
|
-
*/
|
|
1054
|
-
fromUntaggedCbor(cbor) {
|
|
1055
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
1056
|
-
return Digest.fromData(data);
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Creates a Digest by decoding it from tagged CBOR.
|
|
1060
|
-
*/
|
|
1061
|
-
fromTaggedCbor(cbor) {
|
|
1062
|
-
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1063
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1064
|
-
return this.fromUntaggedCbor(content);
|
|
1065
|
-
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Static method to decode from tagged CBOR.
|
|
1068
|
-
*/
|
|
1069
|
-
static fromTaggedCbor(cbor) {
|
|
1070
|
-
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromTaggedCbor(cbor);
|
|
1071
|
-
}
|
|
1072
|
-
/**
|
|
1073
|
-
* Static method to decode from tagged CBOR binary data.
|
|
1074
|
-
*/
|
|
1075
|
-
static fromTaggedCborData(data) {
|
|
1076
|
-
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
1077
|
-
return Digest.fromTaggedCbor(cbor);
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Static method to decode from untagged CBOR binary data.
|
|
1081
|
-
*/
|
|
1082
|
-
static fromUntaggedCborData(data) {
|
|
1083
|
-
const bytes = (0, _bcts_dcbor.expectBytes)((0, _bcts_dcbor.decodeCbor)(data));
|
|
1084
|
-
return Digest.fromData(bytes);
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* Returns the UR representation of the Digest.
|
|
1088
|
-
* Note: URs use untagged CBOR since the type is conveyed by the UR type itself.
|
|
1089
|
-
*/
|
|
1090
|
-
ur() {
|
|
1091
|
-
return _bcts_uniform_resources.UR.new("digest", this.untaggedCbor());
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Returns the UR string representation.
|
|
1095
|
-
*/
|
|
1096
|
-
urString() {
|
|
1097
|
-
return this.ur().string();
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Creates a Digest from a UR.
|
|
1101
|
-
*/
|
|
1102
|
-
static fromUR(ur) {
|
|
1103
|
-
ur.checkType("digest");
|
|
1104
|
-
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromUntaggedCbor(ur.cbor());
|
|
891
|
+
var Digest = class Digest {
|
|
892
|
+
static DIGEST_SIZE = _bcts_crypto.SHA256_SIZE;
|
|
893
|
+
_data;
|
|
894
|
+
constructor(data) {
|
|
895
|
+
if (data.length !== Digest.DIGEST_SIZE) throw CryptoError.invalidSize(Digest.DIGEST_SIZE, data.length);
|
|
896
|
+
this._data = new Uint8Array(data);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Get the digest data.
|
|
900
|
+
*/
|
|
901
|
+
data() {
|
|
902
|
+
return this._data;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Create a Digest from a 32-byte array.
|
|
906
|
+
*/
|
|
907
|
+
static fromData(data) {
|
|
908
|
+
return new Digest(new Uint8Array(data));
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Create a Digest from data, validating the length.
|
|
912
|
+
* Alias for fromData for compatibility with Rust API.
|
|
913
|
+
*/
|
|
914
|
+
static fromDataRef(data) {
|
|
915
|
+
return Digest.fromData(data);
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Create a Digest from hex string.
|
|
919
|
+
*
|
|
920
|
+
* @throws Error if the hex string is not exactly 64 characters.
|
|
921
|
+
*/
|
|
922
|
+
static fromHex(hex) {
|
|
923
|
+
return new Digest(hexToBytes(hex));
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Compute SHA-256 digest of data (called "image" in Rust).
|
|
927
|
+
*
|
|
928
|
+
* @param image - The data to hash
|
|
929
|
+
*/
|
|
930
|
+
static fromImage(image) {
|
|
931
|
+
const hashData = (0, _bcts_crypto.sha256)(image);
|
|
932
|
+
return new Digest(new Uint8Array(hashData));
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Compute SHA-256 digest from multiple data parts.
|
|
936
|
+
*
|
|
937
|
+
* The parts are concatenated and then hashed.
|
|
938
|
+
*
|
|
939
|
+
* @param imageParts - Array of byte arrays to concatenate and hash
|
|
940
|
+
*/
|
|
941
|
+
static fromImageParts(imageParts) {
|
|
942
|
+
const totalLength = imageParts.reduce((sum, part) => sum + part.length, 0);
|
|
943
|
+
const buf = new Uint8Array(totalLength);
|
|
944
|
+
let offset = 0;
|
|
945
|
+
for (const part of imageParts) {
|
|
946
|
+
buf.set(part, offset);
|
|
947
|
+
offset += part.length;
|
|
1105
948
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
949
|
+
return Digest.fromImage(buf);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Compute SHA-256 digest from an array of Digests.
|
|
953
|
+
*
|
|
954
|
+
* The digest bytes are concatenated and then hashed.
|
|
955
|
+
*
|
|
956
|
+
* @param digests - Array of Digests to combine
|
|
957
|
+
*/
|
|
958
|
+
static fromDigests(digests) {
|
|
959
|
+
const buf = new Uint8Array(digests.length * Digest.DIGEST_SIZE);
|
|
960
|
+
let offset = 0;
|
|
961
|
+
for (const digest of digests) {
|
|
962
|
+
buf.set(digest._data, offset);
|
|
963
|
+
offset += Digest.DIGEST_SIZE;
|
|
1112
964
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
965
|
+
return Digest.fromImage(buf);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Compute SHA-256 digest of data (legacy alias for fromImage).
|
|
969
|
+
* @deprecated Use fromImage instead
|
|
970
|
+
*/
|
|
971
|
+
static hash(data) {
|
|
972
|
+
return Digest.fromImage(data);
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Get the raw digest bytes as a copy.
|
|
976
|
+
*/
|
|
977
|
+
toData() {
|
|
978
|
+
return new Uint8Array(this._data);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Get a reference to the raw digest bytes.
|
|
982
|
+
*/
|
|
983
|
+
asBytes() {
|
|
984
|
+
return this._data;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Get hex string representation.
|
|
988
|
+
*/
|
|
989
|
+
hex() {
|
|
990
|
+
return bytesToHex(this._data);
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Get hex string representation (alias for hex()).
|
|
994
|
+
*/
|
|
995
|
+
toHex() {
|
|
996
|
+
return this.hex();
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Get base64 representation.
|
|
1000
|
+
*/
|
|
1001
|
+
toBase64() {
|
|
1002
|
+
return toBase64(this._data);
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Get the first four bytes of the digest as a hexadecimal string.
|
|
1006
|
+
* Useful for short descriptions.
|
|
1007
|
+
*/
|
|
1008
|
+
shortDescription() {
|
|
1009
|
+
return bytesToHex(this._data.slice(0, 4));
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Validate the digest against the given image.
|
|
1013
|
+
*
|
|
1014
|
+
* The image is hashed with SHA-256 and compared to this digest.
|
|
1015
|
+
* @returns `true` if the digest matches the image.
|
|
1016
|
+
*/
|
|
1017
|
+
validate(image) {
|
|
1018
|
+
return this.equals(Digest.fromImage(image));
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Compare with another Digest.
|
|
1022
|
+
*/
|
|
1023
|
+
equals(other) {
|
|
1024
|
+
if (this._data.length !== other._data.length) return false;
|
|
1025
|
+
for (let i = 0; i < this._data.length; i++) if (this._data[i] !== other._data[i]) return false;
|
|
1026
|
+
return true;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Compare digests lexicographically.
|
|
1030
|
+
*/
|
|
1031
|
+
compare(other) {
|
|
1032
|
+
for (let i = 0; i < this._data.length; i++) {
|
|
1033
|
+
const a = this._data[i];
|
|
1034
|
+
const b = other._data[i];
|
|
1035
|
+
if (a < b) return -1;
|
|
1036
|
+
if (a > b) return 1;
|
|
1122
1037
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1038
|
+
return 0;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Get string representation.
|
|
1042
|
+
*/
|
|
1043
|
+
toString() {
|
|
1044
|
+
return `Digest(${this.hex()})`;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* A Digest is its own digest provider - returns itself.
|
|
1048
|
+
*/
|
|
1049
|
+
digest() {
|
|
1050
|
+
return this;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Returns the CBOR tags associated with Digest.
|
|
1054
|
+
*/
|
|
1055
|
+
cborTags() {
|
|
1056
|
+
return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.DIGEST.value]);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Returns the untagged CBOR encoding (as a byte string).
|
|
1060
|
+
*/
|
|
1061
|
+
untaggedCbor() {
|
|
1062
|
+
return (0, _bcts_dcbor.toByteString)(this._data);
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Returns the tagged CBOR encoding.
|
|
1066
|
+
*/
|
|
1067
|
+
taggedCbor() {
|
|
1068
|
+
return (0, _bcts_dcbor.createTaggedCbor)(this);
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Returns the tagged value in CBOR binary representation.
|
|
1072
|
+
*/
|
|
1073
|
+
taggedCborData() {
|
|
1074
|
+
return this.taggedCbor().toData();
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Creates a Digest by decoding it from untagged CBOR.
|
|
1078
|
+
*/
|
|
1079
|
+
fromUntaggedCbor(cbor) {
|
|
1080
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
1081
|
+
return Digest.fromData(data);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Creates a Digest by decoding it from tagged CBOR.
|
|
1085
|
+
*/
|
|
1086
|
+
fromTaggedCbor(cbor) {
|
|
1087
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1088
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1089
|
+
return this.fromUntaggedCbor(content);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Static method to decode from tagged CBOR.
|
|
1093
|
+
*/
|
|
1094
|
+
static fromTaggedCbor(cbor) {
|
|
1095
|
+
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromTaggedCbor(cbor);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Static method to decode from tagged CBOR binary data.
|
|
1099
|
+
*/
|
|
1100
|
+
static fromTaggedCborData(data) {
|
|
1101
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
1102
|
+
return Digest.fromTaggedCbor(cbor);
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Static method to decode from untagged CBOR binary data.
|
|
1106
|
+
*/
|
|
1107
|
+
static fromUntaggedCborData(data) {
|
|
1108
|
+
const bytes = (0, _bcts_dcbor.expectBytes)((0, _bcts_dcbor.decodeCbor)(data));
|
|
1109
|
+
return Digest.fromData(bytes);
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns the UR representation of the Digest.
|
|
1113
|
+
* Note: URs use untagged CBOR since the type is conveyed by the UR type itself.
|
|
1114
|
+
*/
|
|
1115
|
+
ur() {
|
|
1116
|
+
return _bcts_uniform_resources.UR.new("digest", this.untaggedCbor());
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Returns the UR string representation.
|
|
1120
|
+
*/
|
|
1121
|
+
urString() {
|
|
1122
|
+
return this.ur().string();
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Creates a Digest from a UR.
|
|
1126
|
+
*/
|
|
1127
|
+
static fromUR(ur) {
|
|
1128
|
+
ur.checkType("digest");
|
|
1129
|
+
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromUntaggedCbor(ur.cbor());
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Creates a Digest from a UR string.
|
|
1133
|
+
*/
|
|
1134
|
+
static fromURString(urString) {
|
|
1135
|
+
const ur = _bcts_uniform_resources.UR.fromURString(urString);
|
|
1136
|
+
return Digest.fromUR(ur);
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Validate the given data against the digest, if any.
|
|
1140
|
+
*
|
|
1141
|
+
* Returns `true` if the digest is `undefined` or if the digest matches the
|
|
1142
|
+
* image's digest. Returns `false` if the digest does not match.
|
|
1143
|
+
*/
|
|
1144
|
+
static validateOpt(image, digest) {
|
|
1145
|
+
if (digest === void 0) return true;
|
|
1146
|
+
return digest.validate(image);
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1125
1149
|
//#endregion
|
|
1126
1150
|
//#region src/compressed.ts
|
|
1127
1151
|
/**
|
|
@@ -1165,9 +1189,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
1165
1189
|
* const decompressed = compressed.decompress();
|
|
1166
1190
|
* ```
|
|
1167
1191
|
*/
|
|
1168
|
-
init_digest();
|
|
1169
|
-
init_error();
|
|
1170
|
-
init_utils();
|
|
1171
1192
|
/**
|
|
1172
1193
|
* A compressed binary object with integrity verification.
|
|
1173
1194
|
*
|
|
@@ -1626,15 +1647,48 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
1626
1647
|
//#endregion
|
|
1627
1648
|
//#region src/digest-provider.ts
|
|
1628
1649
|
/**
|
|
1650
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1651
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
1652
|
+
*
|
|
1653
|
+
*
|
|
1654
|
+
* DigestProvider interface for types that can provide a cryptographic digest.
|
|
1655
|
+
*
|
|
1656
|
+
* Ported from bc-components-rust/src/digest_provider.rs
|
|
1657
|
+
*
|
|
1658
|
+
* A type that can provide a single unique digest that characterizes its contents.
|
|
1659
|
+
* This trait is used to define a common interface for objects that can produce
|
|
1660
|
+
* a cryptographic digest (hash) of their content.
|
|
1661
|
+
*
|
|
1662
|
+
* @example
|
|
1663
|
+
* ```typescript
|
|
1664
|
+
* import { DigestProvider, Digest } from '@bcts/components';
|
|
1665
|
+
*
|
|
1666
|
+
* class Document implements DigestProvider {
|
|
1667
|
+
* private content: Uint8Array;
|
|
1668
|
+
* private cachedDigest?: Digest;
|
|
1669
|
+
*
|
|
1670
|
+
* constructor(content: Uint8Array) {
|
|
1671
|
+
* this.content = content;
|
|
1672
|
+
* }
|
|
1673
|
+
*
|
|
1674
|
+
* digest(): Digest {
|
|
1675
|
+
* if (!this.cachedDigest) {
|
|
1676
|
+
* this.cachedDigest = Digest.fromImage(this.content);
|
|
1677
|
+
* }
|
|
1678
|
+
* return this.cachedDigest;
|
|
1679
|
+
* }
|
|
1680
|
+
* }
|
|
1681
|
+
* ```
|
|
1682
|
+
*/
|
|
1683
|
+
/**
|
|
1629
1684
|
* Helper function to get a digest from a byte array.
|
|
1630
1685
|
* This provides DigestProvider-like functionality for raw bytes.
|
|
1631
1686
|
*
|
|
1632
1687
|
* @param data - The byte array to hash
|
|
1633
1688
|
* @returns A Promise resolving to a Digest of the data
|
|
1634
1689
|
*/
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
return Digest.fromImage(data);
|
|
1690
|
+
function digestFromBytes(data) {
|
|
1691
|
+
return Promise.resolve(Digest.fromImage(data));
|
|
1638
1692
|
}
|
|
1639
1693
|
//#endregion
|
|
1640
1694
|
//#region src/nonce.ts
|
|
@@ -1689,8 +1743,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
1689
1743
|
* const nonceData = nonce2.data();
|
|
1690
1744
|
* ```
|
|
1691
1745
|
*/
|
|
1692
|
-
init_error();
|
|
1693
|
-
init_utils();
|
|
1694
1746
|
var Nonce = class Nonce {
|
|
1695
1747
|
static NONCE_SIZE = _bcts_crypto.SYMMETRIC_NONCE_SIZE;
|
|
1696
1748
|
_data;
|
|
@@ -1939,8 +1991,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
1939
1991
|
* const salt3 = Salt.newInRange(16, 32);
|
|
1940
1992
|
* ```
|
|
1941
1993
|
*/
|
|
1942
|
-
init_error();
|
|
1943
|
-
init_utils();
|
|
1944
1994
|
const MIN_SALT_SIZE = 8;
|
|
1945
1995
|
var Salt = class Salt {
|
|
1946
1996
|
_data;
|
|
@@ -2231,8 +2281,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
2231
2281
|
* When serialized as a Uniform Resource (UR), a `Seed` is represented with the
|
|
2232
2282
|
* type "seed".
|
|
2233
2283
|
*/
|
|
2234
|
-
init_error();
|
|
2235
|
-
init_utils();
|
|
2236
2284
|
var Seed = class Seed {
|
|
2237
2285
|
/**
|
|
2238
2286
|
* Minimum seed length in bytes (matches Rust MIN_SEED_LENGTH).
|
|
@@ -2613,9 +2661,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
2613
2661
|
* Reference = #6.40025(bytes .size 32)
|
|
2614
2662
|
* ```
|
|
2615
2663
|
*/
|
|
2616
|
-
init_digest();
|
|
2617
|
-
init_error();
|
|
2618
|
-
init_utils();
|
|
2619
2664
|
/**
|
|
2620
2665
|
* Type guard to check if an object implements the ReferenceProvider interface.
|
|
2621
2666
|
*/
|
|
@@ -2860,8 +2905,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
2860
2905
|
* console.log(arid.hex());
|
|
2861
2906
|
* ```
|
|
2862
2907
|
*/
|
|
2863
|
-
init_error();
|
|
2864
|
-
init_utils();
|
|
2865
2908
|
var ARID = class ARID {
|
|
2866
2909
|
static ARID_SIZE = 32;
|
|
2867
2910
|
_data;
|
|
@@ -3103,8 +3146,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
3103
3146
|
* When serialized as a Uniform Resource (UR), a `UUID` is represented with the
|
|
3104
3147
|
* type "uuid".
|
|
3105
3148
|
*/
|
|
3106
|
-
init_error();
|
|
3107
|
-
init_utils();
|
|
3108
3149
|
const UUID_SIZE = 16;
|
|
3109
3150
|
var UUID = class UUID {
|
|
3110
3151
|
static UUID_SIZE = UUID_SIZE;
|
|
@@ -3342,9 +3383,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
3342
3383
|
* When serialized as a Uniform Resource (UR), a `XID` is represented with the
|
|
3343
3384
|
* type "xid".
|
|
3344
3385
|
*/
|
|
3345
|
-
init_error();
|
|
3346
|
-
init_utils();
|
|
3347
|
-
init_digest();
|
|
3348
3386
|
/**
|
|
3349
3387
|
* XID prefix glyph for the upper-case bytewords/bytemoji identifier.
|
|
3350
3388
|
*
|
|
@@ -3670,8 +3708,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
3670
3708
|
* When serialized as a Uniform Resource (UR), a `URI` is represented with the
|
|
3671
3709
|
* type "url".
|
|
3672
3710
|
*/
|
|
3673
|
-
init_error();
|
|
3674
|
-
init_utils();
|
|
3675
3711
|
var URI = class URI {
|
|
3676
3712
|
_uri;
|
|
3677
3713
|
constructor(uri) {
|
|
@@ -3874,9 +3910,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
3874
3910
|
* Ed25519 public key for EdDSA signature verification (32 bytes)
|
|
3875
3911
|
* Ported from bc-components-rust/src/ed25519/ed25519_public_key.rs
|
|
3876
3912
|
*/
|
|
3877
|
-
init_digest();
|
|
3878
|
-
init_error();
|
|
3879
|
-
init_utils();
|
|
3880
3913
|
var Ed25519PublicKey = class Ed25519PublicKey {
|
|
3881
3914
|
_data;
|
|
3882
3915
|
constructor(data) {
|
|
@@ -3974,8 +4007,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
3974
4007
|
* Ed25519 private key for EdDSA signatures (32 bytes seed)
|
|
3975
4008
|
* Ported from bc-components-rust/src/ed25519_private_key.rs
|
|
3976
4009
|
*/
|
|
3977
|
-
init_error();
|
|
3978
|
-
init_utils();
|
|
3979
4010
|
var Ed25519PrivateKey = class Ed25519PrivateKey {
|
|
3980
4011
|
seed;
|
|
3981
4012
|
_publicKey;
|
|
@@ -4093,8 +4124,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4093
4124
|
*
|
|
4094
4125
|
* Ported from bc-components-rust/src/sr25519/sr25519_public_key.rs
|
|
4095
4126
|
*/
|
|
4096
|
-
init_utils();
|
|
4097
|
-
init_error();
|
|
4098
4127
|
/**
|
|
4099
4128
|
* Sr25519PublicKey - Public key for Schnorr signatures over Ristretto25519.
|
|
4100
4129
|
*
|
|
@@ -4207,8 +4236,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4207
4236
|
*
|
|
4208
4237
|
* Ported from bc-components-rust/src/sr25519/sr25519_private_key.rs
|
|
4209
4238
|
*/
|
|
4210
|
-
init_utils();
|
|
4211
|
-
init_error();
|
|
4212
4239
|
/** Size of SR25519 private key (seed) in bytes */
|
|
4213
4240
|
const SR25519_PRIVATE_KEY_SIZE = 32;
|
|
4214
4241
|
/** Size of SR25519 public key in bytes */
|
|
@@ -4393,8 +4420,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4393
4420
|
*
|
|
4394
4421
|
* Ported from bc-components-rust/src/ec_key/ec_uncompressed_public_key.rs
|
|
4395
4422
|
*/
|
|
4396
|
-
init_error();
|
|
4397
|
-
init_utils();
|
|
4398
4423
|
var ECUncompressedPublicKey = class ECUncompressedPublicKey {
|
|
4399
4424
|
static KEY_SIZE = _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE;
|
|
4400
4425
|
_data;
|
|
@@ -4610,8 +4635,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4610
4635
|
*
|
|
4611
4636
|
* Ported from bc-components-rust/src/ec_key/ec_public_key.rs
|
|
4612
4637
|
*/
|
|
4613
|
-
init_error();
|
|
4614
|
-
init_utils();
|
|
4615
4638
|
var ECPublicKey = class ECPublicKey {
|
|
4616
4639
|
static KEY_SIZE = _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE;
|
|
4617
4640
|
_data;
|
|
@@ -4850,9 +4873,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4850
4873
|
*
|
|
4851
4874
|
* Ported from bc-components-rust/src/ec_key/schnorr_public_key.rs
|
|
4852
4875
|
*/
|
|
4853
|
-
init_digest();
|
|
4854
|
-
init_error();
|
|
4855
|
-
init_utils();
|
|
4856
4876
|
var SchnorrPublicKey = class SchnorrPublicKey {
|
|
4857
4877
|
static KEY_SIZE = _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE;
|
|
4858
4878
|
_data;
|
|
@@ -4983,8 +5003,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
4983
5003
|
*
|
|
4984
5004
|
* Ported from bc-components-rust/src/ec_key/ec_private_key.rs
|
|
4985
5005
|
*/
|
|
4986
|
-
init_error();
|
|
4987
|
-
init_utils();
|
|
4988
5006
|
var ECPrivateKey = class ECPrivateKey {
|
|
4989
5007
|
static KEY_SIZE = _bcts_crypto.ECDSA_PRIVATE_KEY_SIZE;
|
|
4990
5008
|
_data;
|
|
@@ -5471,7 +5489,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
5471
5489
|
*
|
|
5472
5490
|
* Ported from bc-components-rust/src/mldsa/mldsa_public_key.rs
|
|
5473
5491
|
*/
|
|
5474
|
-
init_utils();
|
|
5475
5492
|
/**
|
|
5476
5493
|
* MLDSAPublicKey - Post-quantum signature verification key using ML-DSA.
|
|
5477
5494
|
*/
|
|
@@ -5662,7 +5679,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
5662
5679
|
*
|
|
5663
5680
|
* Ported from bc-components-rust/src/mldsa/mldsa_signature.rs
|
|
5664
5681
|
*/
|
|
5665
|
-
init_utils();
|
|
5666
5682
|
/**
|
|
5667
5683
|
* MLDSASignature - Post-quantum digital signature using ML-DSA.
|
|
5668
5684
|
*/
|
|
@@ -5842,7 +5858,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
5842
5858
|
*
|
|
5843
5859
|
* Ported from bc-components-rust/src/mldsa/mldsa_private_key.rs
|
|
5844
5860
|
*/
|
|
5845
|
-
init_utils();
|
|
5846
5861
|
/**
|
|
5847
5862
|
* MLDSAPrivateKey - Post-quantum signing private key using ML-DSA.
|
|
5848
5863
|
*/
|
|
@@ -6074,6 +6089,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
6074
6089
|
*/
|
|
6075
6090
|
const MAX_UINT32 = 4294967295;
|
|
6076
6091
|
var SshBufferReader = class {
|
|
6092
|
+
bytes;
|
|
6077
6093
|
view;
|
|
6078
6094
|
offset;
|
|
6079
6095
|
constructor(bytes) {
|
|
@@ -7173,7 +7189,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7173
7189
|
if (pubBytes.length !== ED25519_PUBLIC_LEN) throw new Error(`SSHPrivateKey ed25519: public key length ${pubBytes.length} != ${ED25519_PUBLIC_LEN}`);
|
|
7174
7190
|
if (publicKey.data.kind !== "ed25519" || !bytesEqual$1(pubBytes, publicKey.data.pubBytes)) throw new Error("SSHPrivateKey ed25519: outer/inner public-key mismatch");
|
|
7175
7191
|
const combined = innerReader.readString();
|
|
7176
|
-
if (combined.length !==
|
|
7192
|
+
if (combined.length !== 64) throw new Error(`SSHPrivateKey ed25519: combined seed||public length ${combined.length} != 64`);
|
|
7177
7193
|
if (!bytesEqual$1(combined.subarray(ED25519_SEED_LEN), pubBytes)) throw new Error("SSHPrivateKey ed25519: combined-blob public tail does not match public field");
|
|
7178
7194
|
data = {
|
|
7179
7195
|
kind: "ed25519",
|
|
@@ -7264,7 +7280,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7264
7280
|
switch (this.data.kind) {
|
|
7265
7281
|
case "ed25519": {
|
|
7266
7282
|
w.writeString(this.data.pubBytes);
|
|
7267
|
-
const combined = new Uint8Array(
|
|
7283
|
+
const combined = new Uint8Array(64);
|
|
7268
7284
|
combined.set(this.data.seed, 0);
|
|
7269
7285
|
combined.set(this.data.pubBytes, ED25519_SEED_LEN);
|
|
7270
7286
|
w.writeString(combined);
|
|
@@ -7373,9 +7389,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7373
7389
|
*
|
|
7374
7390
|
* Ported from bc-components-rust/src/x25519/x25519_public_key.rs
|
|
7375
7391
|
*/
|
|
7376
|
-
init_digest();
|
|
7377
|
-
init_error();
|
|
7378
|
-
init_utils();
|
|
7379
7392
|
var X25519PublicKey = class X25519PublicKey {
|
|
7380
7393
|
static KEY_SIZE = _bcts_crypto.X25519_PUBLIC_KEY_SIZE;
|
|
7381
7394
|
_data;
|
|
@@ -7572,8 +7585,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7572
7585
|
*
|
|
7573
7586
|
* Ported from bc-components-rust/src/symmetric/authentication_tag.rs
|
|
7574
7587
|
*/
|
|
7575
|
-
init_error();
|
|
7576
|
-
init_utils();
|
|
7577
7588
|
const AUTHENTICATION_TAG_SIZE = 16;
|
|
7578
7589
|
var AuthenticationTag = class AuthenticationTag {
|
|
7579
7590
|
static AUTHENTICATION_TAG_SIZE = AUTHENTICATION_TAG_SIZE;
|
|
@@ -7725,8 +7736,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7725
7736
|
*
|
|
7726
7737
|
* Ported from bc-components-rust/src/symmetric/encrypted_message.rs
|
|
7727
7738
|
*/
|
|
7728
|
-
init_digest();
|
|
7729
|
-
init_utils();
|
|
7730
7739
|
var EncryptedMessage = class EncryptedMessage {
|
|
7731
7740
|
_ciphertext;
|
|
7732
7741
|
_aad;
|
|
@@ -7946,8 +7955,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
7946
7955
|
*
|
|
7947
7956
|
* Ported from bc-components-rust/src/symmetric/symmetric_key.rs
|
|
7948
7957
|
*/
|
|
7949
|
-
init_error();
|
|
7950
|
-
init_utils();
|
|
7951
7958
|
const SYMMETRIC_KEY_SIZE = 32;
|
|
7952
7959
|
var SymmetricKey = class SymmetricKey {
|
|
7953
7960
|
static SYMMETRIC_KEY_SIZE = SYMMETRIC_KEY_SIZE;
|
|
@@ -8194,8 +8201,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
8194
8201
|
*
|
|
8195
8202
|
* Ported from bc-components-rust/src/x25519/x25519_private_key.rs
|
|
8196
8203
|
*/
|
|
8197
|
-
init_error();
|
|
8198
|
-
init_utils();
|
|
8199
8204
|
var X25519PrivateKey = class X25519PrivateKey {
|
|
8200
8205
|
static KEY_SIZE = _bcts_crypto.X25519_PRIVATE_KEY_SIZE;
|
|
8201
8206
|
_data;
|
|
@@ -8757,7 +8762,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
8757
8762
|
*
|
|
8758
8763
|
* Ported from bc-components-rust/src/mlkem/mlkem_ciphertext.rs
|
|
8759
8764
|
*/
|
|
8760
|
-
init_utils();
|
|
8761
8765
|
/**
|
|
8762
8766
|
* MLKEMCiphertext - Post-quantum key encapsulation ciphertext using ML-KEM.
|
|
8763
8767
|
*/
|
|
@@ -8932,7 +8936,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
8932
8936
|
*
|
|
8933
8937
|
* Ported from bc-components-rust/src/encapsulation/encapsulation_ciphertext.rs
|
|
8934
8938
|
*/
|
|
8935
|
-
init_utils();
|
|
8936
8939
|
/**
|
|
8937
8940
|
* Convert MLKEMLevel to EncapsulationScheme
|
|
8938
8941
|
*/
|
|
@@ -9183,7 +9186,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
9183
9186
|
*
|
|
9184
9187
|
* Ported from bc-components-rust/src/mlkem/mlkem_public_key.rs
|
|
9185
9188
|
*/
|
|
9186
|
-
init_utils();
|
|
9187
9189
|
/**
|
|
9188
9190
|
* MLKEMPublicKey - Post-quantum key encapsulation public key using ML-KEM.
|
|
9189
9191
|
*/
|
|
@@ -9382,7 +9384,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
9382
9384
|
*
|
|
9383
9385
|
* Ported from bc-components-rust/src/encapsulation/encapsulation_public_key.rs
|
|
9384
9386
|
*/
|
|
9385
|
-
init_digest();
|
|
9386
9387
|
/**
|
|
9387
9388
|
* Convert MLKEMLevel to EncapsulationScheme
|
|
9388
9389
|
*/
|
|
@@ -9722,7 +9723,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
9722
9723
|
*
|
|
9723
9724
|
* Ported from bc-components-rust/src/mlkem/mlkem_private_key.rs
|
|
9724
9725
|
*/
|
|
9725
|
-
init_utils();
|
|
9726
9726
|
/**
|
|
9727
9727
|
* MLKEMPrivateKey - Post-quantum key decapsulation private key using ML-KEM.
|
|
9728
9728
|
*/
|
|
@@ -9965,9 +9965,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
9965
9965
|
*
|
|
9966
9966
|
* Ported from bc-components-rust/src/encapsulation/encapsulation_private_key.rs
|
|
9967
9967
|
*/
|
|
9968
|
-
init_error();
|
|
9969
|
-
init_utils();
|
|
9970
|
-
init_digest();
|
|
9971
9968
|
/**
|
|
9972
9969
|
* Convert MLKEMLevel to EncapsulationScheme
|
|
9973
9970
|
*/
|
|
@@ -10367,7 +10364,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
10367
10364
|
*
|
|
10368
10365
|
* Ported from bc-components-rust/src/private_key_base.rs
|
|
10369
10366
|
*/
|
|
10370
|
-
init_utils();
|
|
10371
10367
|
/** Default size of PrivateKeyBase key material in bytes (used for random generation) */
|
|
10372
10368
|
const PRIVATE_KEY_BASE_DEFAULT_SIZE = 32;
|
|
10373
10369
|
/** Key derivation salt string - must match Rust's bc-crypto derive functions */
|
|
@@ -10444,6 +10440,16 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
10444
10440
|
return EncapsulationPrivateKey.fromX25519PrivateKey(this.x25519PrivateKey());
|
|
10445
10441
|
}
|
|
10446
10442
|
/**
|
|
10443
|
+
* Decapsulate a shared secret from a ciphertext.
|
|
10444
|
+
*
|
|
10445
|
+
* Implements the `Decrypter` interface so a `PrivateKeyBase` can be used
|
|
10446
|
+
* directly as a recipient key, mirroring Rust `impl Decrypter for
|
|
10447
|
+
* PrivateKeyBase`.
|
|
10448
|
+
*/
|
|
10449
|
+
decapsulateSharedSecret(ciphertext) {
|
|
10450
|
+
return this.encapsulationPrivateKey().decapsulateSharedSecret(ciphertext);
|
|
10451
|
+
}
|
|
10452
|
+
/**
|
|
10447
10453
|
* Derive a PrivateKeys container with Ed25519 signing and X25519 agreement keys.
|
|
10448
10454
|
*
|
|
10449
10455
|
* @returns PrivateKeys containing the derived signing and encapsulation keys
|
|
@@ -10731,7 +10737,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
10731
10737
|
}
|
|
10732
10738
|
//#endregion
|
|
10733
10739
|
//#region src/signing/signature-scheme.ts
|
|
10734
|
-
init_error();
|
|
10735
10740
|
/**
|
|
10736
10741
|
* Supported digital signature schemes.
|
|
10737
10742
|
*
|
|
@@ -10982,8 +10987,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
10982
10987
|
*
|
|
10983
10988
|
* Ported from bc-components-rust/src/signing/signature.rs
|
|
10984
10989
|
*/
|
|
10985
|
-
init_error();
|
|
10986
|
-
init_utils();
|
|
10987
10990
|
/**
|
|
10988
10991
|
* A digital signature created with various signature algorithms.
|
|
10989
10992
|
*
|
|
@@ -11466,7 +11469,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
11466
11469
|
*
|
|
11467
11470
|
* Ported from bc-components-rust/src/signing/signing_public_key.rs
|
|
11468
11471
|
*/
|
|
11469
|
-
init_digest();
|
|
11470
11472
|
/**
|
|
11471
11473
|
* A public key used for verifying digital signatures.
|
|
11472
11474
|
*
|
|
@@ -11986,6 +11988,12 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
11986
11988
|
*/
|
|
11987
11989
|
static fromUntaggedCborData(data) {
|
|
11988
11990
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
11991
|
+
return SigningPublicKey.fromUntaggedCbor(cborValue);
|
|
11992
|
+
}
|
|
11993
|
+
/**
|
|
11994
|
+
* Static method to decode from untagged CBOR.
|
|
11995
|
+
*/
|
|
11996
|
+
static fromUntaggedCbor(cborValue) {
|
|
11989
11997
|
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
11990
11998
|
}
|
|
11991
11999
|
/**
|
|
@@ -11996,7 +12004,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
11996
12004
|
* Returns the UR representation of the signing public key.
|
|
11997
12005
|
*/
|
|
11998
12006
|
ur() {
|
|
11999
|
-
return _bcts_uniform_resources.UR.new(SigningPublicKey.UR_TYPE, this.
|
|
12007
|
+
return _bcts_uniform_resources.UR.new(SigningPublicKey.UR_TYPE, this.untaggedCbor());
|
|
12000
12008
|
}
|
|
12001
12009
|
/**
|
|
12002
12010
|
* Returns the UR string representation of the signing public key.
|
|
@@ -12009,7 +12017,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12009
12017
|
*/
|
|
12010
12018
|
static fromUR(ur) {
|
|
12011
12019
|
ur.checkType(SigningPublicKey.UR_TYPE);
|
|
12012
|
-
return SigningPublicKey.
|
|
12020
|
+
return SigningPublicKey.fromUntaggedCbor(ur.cbor());
|
|
12013
12021
|
}
|
|
12014
12022
|
/**
|
|
12015
12023
|
* Creates a SigningPublicKey from a UR string.
|
|
@@ -12063,7 +12071,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12063
12071
|
*
|
|
12064
12072
|
* Ported from bc-components-rust/src/signing/signing_private_key.rs
|
|
12065
12073
|
*/
|
|
12066
|
-
init_digest();
|
|
12067
12074
|
/**
|
|
12068
12075
|
* A private key used for creating digital signatures.
|
|
12069
12076
|
*
|
|
@@ -12734,6 +12741,12 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12734
12741
|
*/
|
|
12735
12742
|
static fromUntaggedCborData(data) {
|
|
12736
12743
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
12744
|
+
return SigningPrivateKey.fromUntaggedCbor(cborValue);
|
|
12745
|
+
}
|
|
12746
|
+
/**
|
|
12747
|
+
* Static method to decode from untagged CBOR.
|
|
12748
|
+
*/
|
|
12749
|
+
static fromUntaggedCbor(cborValue) {
|
|
12737
12750
|
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
12738
12751
|
}
|
|
12739
12752
|
/**
|
|
@@ -12744,7 +12757,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12744
12757
|
* Returns the UR representation of the signing private key.
|
|
12745
12758
|
*/
|
|
12746
12759
|
ur() {
|
|
12747
|
-
return _bcts_uniform_resources.UR.new(SigningPrivateKey.UR_TYPE, this.
|
|
12760
|
+
return _bcts_uniform_resources.UR.new(SigningPrivateKey.UR_TYPE, this.untaggedCbor());
|
|
12748
12761
|
}
|
|
12749
12762
|
/**
|
|
12750
12763
|
* Returns the UR string representation of the signing private key.
|
|
@@ -12757,7 +12770,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12757
12770
|
*/
|
|
12758
12771
|
static fromUR(ur) {
|
|
12759
12772
|
ur.checkType(SigningPrivateKey.UR_TYPE);
|
|
12760
|
-
return SigningPrivateKey.
|
|
12773
|
+
return SigningPrivateKey.fromUntaggedCbor(ur.cbor());
|
|
12761
12774
|
}
|
|
12762
12775
|
/**
|
|
12763
12776
|
* Creates a SigningPrivateKey from a UR string.
|
|
@@ -12812,7 +12825,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
12812
12825
|
*
|
|
12813
12826
|
* Ported from bc-components-rust/src/public_keys.rs
|
|
12814
12827
|
*/
|
|
12815
|
-
init_digest();
|
|
12816
12828
|
/**
|
|
12817
12829
|
* PublicKeys - Container for a signing public key and an encapsulation public key.
|
|
12818
12830
|
*
|
|
@@ -13046,7 +13058,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
13046
13058
|
*
|
|
13047
13059
|
* Ported from bc-components-rust/src/private_keys.rs
|
|
13048
13060
|
*/
|
|
13049
|
-
init_digest();
|
|
13050
13061
|
/**
|
|
13051
13062
|
* PrivateKeys - Container for a signing key and an encapsulation key.
|
|
13052
13063
|
*
|
|
@@ -13355,7 +13366,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
13355
13366
|
*
|
|
13356
13367
|
* Ported from bc-components-rust/src/encapsulation/sealed_message.rs
|
|
13357
13368
|
*/
|
|
13358
|
-
init_utils();
|
|
13359
13369
|
/**
|
|
13360
13370
|
* A sealed message providing anonymous authenticated encryption.
|
|
13361
13371
|
*/
|
|
@@ -14191,26 +14201,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
14191
14201
|
return new Argon2idParams(Salt.fromTaggedCbor(array[1]));
|
|
14192
14202
|
}
|
|
14193
14203
|
};
|
|
14194
|
-
//#endregion
|
|
14195
|
-
//#region src/encrypted-key/ssh-agent-params.ts
|
|
14196
|
-
/**
|
|
14197
|
-
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
14198
|
-
* Copyright © 2025-2026 Parity Technologies
|
|
14199
|
-
*
|
|
14200
|
-
*
|
|
14201
|
-
* SSH Agent key derivation parameters
|
|
14202
|
-
*
|
|
14203
|
-
* SSH Agent uses an SSH agent daemon for key derivation. The agent signs
|
|
14204
|
-
* a challenge derived from the salt to produce the encryption key.
|
|
14205
|
-
*
|
|
14206
|
-
* CDDL:
|
|
14207
|
-
* ```cddl
|
|
14208
|
-
* SSHAgentParams = [4, Salt, id: tstr]
|
|
14209
|
-
* ```
|
|
14210
|
-
*
|
|
14211
|
-
* Ported from bc-components-rust/src/encrypted_key/ssh_agent_params.rs
|
|
14212
|
-
*/
|
|
14213
|
-
init_error();
|
|
14214
14204
|
/**
|
|
14215
14205
|
* SSH Agent parameters for key derivation.
|
|
14216
14206
|
*
|
|
@@ -14535,7 +14525,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
14535
14525
|
*
|
|
14536
14526
|
* Ported from bc-components-rust/src/encrypted_key/encrypted_key_impl.rs
|
|
14537
14527
|
*/
|
|
14538
|
-
init_error();
|
|
14539
14528
|
/**
|
|
14540
14529
|
* Encrypted key providing secure storage of symmetric keys.
|
|
14541
14530
|
*
|
|
@@ -14769,7 +14758,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
14769
14758
|
*
|
|
14770
14759
|
* Ported from bc-components-rust/src/sskr_mod.rs
|
|
14771
14760
|
*/
|
|
14772
|
-
init_utils();
|
|
14773
14761
|
/** Metadata size in bytes (identifier + thresholds + indices) */
|
|
14774
14762
|
const METADATA_SIZE_BYTES = 5;
|
|
14775
14763
|
/**
|
|
@@ -14930,7 +14918,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
14930
14918
|
* Static method to decode from tagged CBOR.
|
|
14931
14919
|
*/
|
|
14932
14920
|
static fromTaggedCbor(cborValue) {
|
|
14933
|
-
return new SSKRShareCbor(new Uint8Array(
|
|
14921
|
+
return new SSKRShareCbor(new Uint8Array(21)).fromTaggedCbor(cborValue);
|
|
14934
14922
|
}
|
|
14935
14923
|
/**
|
|
14936
14924
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -14944,7 +14932,7 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
14944
14932
|
*/
|
|
14945
14933
|
static fromUntaggedCborData(data) {
|
|
14946
14934
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
14947
|
-
return new SSKRShareCbor(new Uint8Array(
|
|
14935
|
+
return new SSKRShareCbor(new Uint8Array(21)).fromUntaggedCbor(cborValue);
|
|
14948
14936
|
}
|
|
14949
14937
|
};
|
|
14950
14938
|
/**
|
|
@@ -15064,11 +15052,6 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
15064
15052
|
}
|
|
15065
15053
|
};
|
|
15066
15054
|
//#endregion
|
|
15067
|
-
//#region src/index.ts
|
|
15068
|
-
init_error();
|
|
15069
|
-
init_utils();
|
|
15070
|
-
init_digest();
|
|
15071
|
-
//#endregion
|
|
15072
15055
|
exports.ARID = ARID;
|
|
15073
15056
|
exports.Argon2idParams = Argon2idParams;
|
|
15074
15057
|
exports.AuthenticationTag = AuthenticationTag;
|