mol_crypto_lib 0.1.1409 → 0.1.1410

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/node.mjs CHANGED
@@ -28,26 +28,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
28
28
  var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
29
29
  $.$$ = $
30
30
 
31
- ;
32
- "use strict";
33
- var $;
34
- (function ($) {
35
- function $mol_fail(error) {
36
- throw error;
37
- }
38
- $.$mol_fail = $mol_fail;
39
- })($ || ($ = {}));
40
-
41
- ;
42
- "use strict";
43
- var $;
44
- (function ($) {
45
- function $mol_fail_hidden(error) {
46
- throw error;
47
- }
48
- $.$mol_fail_hidden = $mol_fail_hidden;
49
- })($ || ($ = {}));
50
-
51
31
  ;
52
32
  "use strict";
53
33
  var $;
@@ -142,6 +122,16 @@ var $;
142
122
  $.$mol_func_name_from = $mol_func_name_from;
143
123
  })($ || ($ = {}));
144
124
 
125
+ ;
126
+ "use strict";
127
+ var $;
128
+ (function ($) {
129
+ function $mol_fail(error) {
130
+ throw error;
131
+ }
132
+ $.$mol_fail = $mol_fail;
133
+ })($ || ($ = {}));
134
+
145
135
  ;
146
136
  "use strict";
147
137
  var $;
@@ -276,6 +266,16 @@ var $;
276
266
  $.$mol_promise_like = $mol_promise_like;
277
267
  })($ || ($ = {}));
278
268
 
269
+ ;
270
+ "use strict";
271
+ var $;
272
+ (function ($) {
273
+ function $mol_fail_hidden(error) {
274
+ throw error;
275
+ }
276
+ $.$mol_fail_hidden = $mol_fail_hidden;
277
+ })($ || ($ = {}));
278
+
279
279
  ;
280
280
  "use strict";
281
281
  var $;
@@ -2132,6 +2132,17 @@ var $;
2132
2132
  $.$mol_base64_url_decode = $mol_base64_url_decode;
2133
2133
  })($ || ($ = {}));
2134
2134
 
2135
+ ;
2136
+ "use strict";
2137
+ var $;
2138
+ (function ($) {
2139
+ function $mol_crypto_restack(error) {
2140
+ error = new Error(error instanceof Error ? error.message : String(error), { cause: error });
2141
+ $mol_fail_hidden(error);
2142
+ }
2143
+ $.$mol_crypto_restack = $mol_crypto_restack;
2144
+ })($ || ($ = {}));
2145
+
2135
2146
  ;
2136
2147
  "use strict";
2137
2148
  var $;
@@ -2195,10 +2206,6 @@ var $;
2195
2206
  "use strict";
2196
2207
  var $;
2197
2208
  (function ($) {
2198
- function restack(error) {
2199
- error = new Error(error instanceof Error ? error.message : String(error), { cause: error });
2200
- $mol_fail_hidden(error);
2201
- }
2202
2209
  class $mol_crypto_sacred extends $mol_buffer {
2203
2210
  static size = 16;
2204
2211
  static make() {
@@ -2219,7 +2226,7 @@ var $;
2219
2226
  return sacred;
2220
2227
  }
2221
2228
  static async from_native(native) {
2222
- const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch(restack);
2229
+ const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch($mol_crypto_restack);
2223
2230
  const sacred = this.from(new Uint8Array(buf));
2224
2231
  sacred._native = native;
2225
2232
  return sacred;
@@ -2237,7 +2244,7 @@ var $;
2237
2244
  return this._native ?? (this._native = await $mol_crypto_native.subtle.importKey('raw', this, {
2238
2245
  name: 'AES-CBC',
2239
2246
  length: 128,
2240
- }, true, ['encrypt', 'decrypt']).catch(restack));
2247
+ }, true, ['encrypt', 'decrypt']).catch($mol_crypto_restack));
2241
2248
  }
2242
2249
  async encrypt(open, salt) {
2243
2250
  return new Uint8Array(await $mol_crypto_native.subtle.encrypt({
@@ -2245,7 +2252,7 @@ var $;
2245
2252
  length: 128,
2246
2253
  tagLength: 32,
2247
2254
  iv: salt,
2248
- }, await this.native(), open).catch(restack));
2255
+ }, await this.native(), open).catch($mol_crypto_restack));
2249
2256
  }
2250
2257
  async decrypt(closed, salt) {
2251
2258
  return new Uint8Array(await $mol_crypto_native.subtle.decrypt({
@@ -2253,7 +2260,7 @@ var $;
2253
2260
  length: 128,
2254
2261
  tagLength: 32,
2255
2262
  iv: salt,
2256
- }, await this.native(), closed).catch(restack));
2263
+ }, await this.native(), closed).catch($mol_crypto_restack));
2257
2264
  }
2258
2265
  async close(sacred, salt) {
2259
2266
  const buf = new Uint8Array(sacred.buffer, sacred.byteOffset + 1, sacred.byteLength - 1);
@@ -2360,7 +2367,7 @@ var $;
2360
2367
  var $;
2361
2368
  (function ($) {
2362
2369
  async function $mol_crypto_sacred_pass(pass, salt) {
2363
- const raw = await $mol_crypto_native.subtle.importKey("raw", $mol_charset_encode(pass), "PBKDF2", false, ["deriveKey"]);
2370
+ const raw = await $mol_crypto_native.subtle.importKey("raw", $mol_charset_encode(pass), "PBKDF2", false, ["deriveKey"]).catch($mol_crypto_restack);
2364
2371
  const hard = await $mol_crypto_native.subtle.deriveKey({
2365
2372
  name: "PBKDF2",
2366
2373
  salt,
@@ -2369,7 +2376,7 @@ var $;
2369
2376
  }, raw, {
2370
2377
  name: 'AES-CBC',
2371
2378
  length: 128,
2372
- }, Boolean('extractable'), ['encrypt', 'decrypt']);
2379
+ }, Boolean('extractable'), ['encrypt', 'decrypt']).catch($mol_crypto_restack);
2373
2380
  return $mol_crypto_sacred.from_native(hard);
2374
2381
  }
2375
2382
  $.$mol_crypto_sacred_pass = $mol_crypto_sacred_pass;
@@ -2420,7 +2427,7 @@ var $;
2420
2427
  kty: "EC",
2421
2428
  x: str.slice(0, 43),
2422
2429
  y: str.slice(43, 86),
2423
- }, ecdsa, Boolean('extractable'), ['verify']);
2430
+ }, ecdsa, Boolean('extractable'), ['verify']).catch($mol_crypto_restack);
2424
2431
  }
2425
2432
  async native_derive() {
2426
2433
  const serial = this.toString();
@@ -2429,10 +2436,10 @@ var $;
2429
2436
  key_ops: [],
2430
2437
  x: serial.slice(0, 43),
2431
2438
  y: serial.slice(43, 86),
2432
- }, ecdh, true, []);
2439
+ }, ecdh, true, []).catch($mol_crypto_restack);
2433
2440
  }
2434
2441
  async verify(data, sign) {
2435
- return await $mol_crypto_native.subtle.verify(ecdsa, await this.native(), sign, data);
2442
+ return await $mol_crypto_native.subtle.verify(ecdsa, await this.native(), sign, data).catch($mol_crypto_restack);
2436
2443
  }
2437
2444
  }
2438
2445
  __decorate([
@@ -2447,8 +2454,8 @@ var $;
2447
2454
  static size_bin = 96;
2448
2455
  static size_sign = 64;
2449
2456
  static async generate() {
2450
- const pair = await $mol_crypto_native.subtle.generateKey(ecdsa, Boolean('extractable'), ['sign', 'verify']);
2451
- const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey);
2457
+ const pair = await $mol_crypto_native.subtle.generateKey(ecdsa, Boolean('extractable'), ['sign', 'verify']).catch($mol_crypto_restack);
2458
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey).catch($mol_crypto_restack);
2452
2459
  return this.from(x + y + d);
2453
2460
  }
2454
2461
  async native() {
@@ -2461,7 +2468,7 @@ var $;
2461
2468
  x: str.slice(0, 43),
2462
2469
  y: str.slice(43, 86),
2463
2470
  d: str.slice(86, 129),
2464
- }, ecdsa, Boolean('extractable'), ['sign']);
2471
+ }, ecdsa, Boolean('extractable'), ['sign']).catch($mol_crypto_restack);
2465
2472
  }
2466
2473
  async native_derive() {
2467
2474
  const serial = this.toString();
@@ -2471,13 +2478,13 @@ var $;
2471
2478
  x: serial.slice(0, 43),
2472
2479
  y: serial.slice(43, 86),
2473
2480
  d: serial.slice(86, 129),
2474
- }, ecdh, Boolean('extractable'), ['deriveKey', 'deriveBits']);
2481
+ }, ecdh, Boolean('extractable'), ['deriveKey', 'deriveBits']).catch($mol_crypto_restack);
2475
2482
  }
2476
2483
  public() {
2477
2484
  return new $mol_crypto_key_public(this.buffer, this.byteOffset, this.byteOffset + 64);
2478
2485
  }
2479
2486
  async sign(data) {
2480
- return new Uint8Array(await $mol_crypto_native.subtle.sign(ecdsa, await this.native(), data));
2487
+ return new Uint8Array(await $mol_crypto_native.subtle.sign(ecdsa, await this.native(), data).catch($mol_crypto_restack));
2481
2488
  }
2482
2489
  }
2483
2490
  __decorate([
@@ -2500,7 +2507,7 @@ var $;
2500
2507
  return $mol_crypto_sacred.from(new Uint8Array(await $mol_crypto_native.subtle.deriveBits({
2501
2508
  name: "ECDH",
2502
2509
  public: await pub.native_derive(),
2503
- }, await priv.native_derive(), $mol_crypto_sacred.size * 8)));
2510
+ }, await priv.native_derive(), $mol_crypto_sacred.size * 8).catch($mol_crypto_restack)));
2504
2511
  }
2505
2512
  $.$mol_crypto_sacred_shared = $mol_crypto_sacred_shared;
2506
2513
  })($ || ($ = {}));
package/node.test.js CHANGED
@@ -19,26 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
19
19
  var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
20
20
  $.$$ = $
21
21
 
22
- ;
23
- "use strict";
24
- var $;
25
- (function ($) {
26
- function $mol_fail(error) {
27
- throw error;
28
- }
29
- $.$mol_fail = $mol_fail;
30
- })($ || ($ = {}));
31
-
32
- ;
33
- "use strict";
34
- var $;
35
- (function ($) {
36
- function $mol_fail_hidden(error) {
37
- throw error;
38
- }
39
- $.$mol_fail_hidden = $mol_fail_hidden;
40
- })($ || ($ = {}));
41
-
42
22
  ;
43
23
  "use strict";
44
24
  var $;
@@ -133,6 +113,16 @@ var $;
133
113
  $.$mol_func_name_from = $mol_func_name_from;
134
114
  })($ || ($ = {}));
135
115
 
116
+ ;
117
+ "use strict";
118
+ var $;
119
+ (function ($) {
120
+ function $mol_fail(error) {
121
+ throw error;
122
+ }
123
+ $.$mol_fail = $mol_fail;
124
+ })($ || ($ = {}));
125
+
136
126
  ;
137
127
  "use strict";
138
128
  var $;
@@ -267,6 +257,16 @@ var $;
267
257
  $.$mol_promise_like = $mol_promise_like;
268
258
  })($ || ($ = {}));
269
259
 
260
+ ;
261
+ "use strict";
262
+ var $;
263
+ (function ($) {
264
+ function $mol_fail_hidden(error) {
265
+ throw error;
266
+ }
267
+ $.$mol_fail_hidden = $mol_fail_hidden;
268
+ })($ || ($ = {}));
269
+
270
270
  ;
271
271
  "use strict";
272
272
  var $;
@@ -2123,6 +2123,17 @@ var $;
2123
2123
  $.$mol_base64_url_decode = $mol_base64_url_decode;
2124
2124
  })($ || ($ = {}));
2125
2125
 
2126
+ ;
2127
+ "use strict";
2128
+ var $;
2129
+ (function ($) {
2130
+ function $mol_crypto_restack(error) {
2131
+ error = new Error(error instanceof Error ? error.message : String(error), { cause: error });
2132
+ $mol_fail_hidden(error);
2133
+ }
2134
+ $.$mol_crypto_restack = $mol_crypto_restack;
2135
+ })($ || ($ = {}));
2136
+
2126
2137
  ;
2127
2138
  "use strict";
2128
2139
  var $;
@@ -2186,10 +2197,6 @@ var $;
2186
2197
  "use strict";
2187
2198
  var $;
2188
2199
  (function ($) {
2189
- function restack(error) {
2190
- error = new Error(error instanceof Error ? error.message : String(error), { cause: error });
2191
- $mol_fail_hidden(error);
2192
- }
2193
2200
  class $mol_crypto_sacred extends $mol_buffer {
2194
2201
  static size = 16;
2195
2202
  static make() {
@@ -2210,7 +2217,7 @@ var $;
2210
2217
  return sacred;
2211
2218
  }
2212
2219
  static async from_native(native) {
2213
- const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch(restack);
2220
+ const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch($mol_crypto_restack);
2214
2221
  const sacred = this.from(new Uint8Array(buf));
2215
2222
  sacred._native = native;
2216
2223
  return sacred;
@@ -2228,7 +2235,7 @@ var $;
2228
2235
  return this._native ?? (this._native = await $mol_crypto_native.subtle.importKey('raw', this, {
2229
2236
  name: 'AES-CBC',
2230
2237
  length: 128,
2231
- }, true, ['encrypt', 'decrypt']).catch(restack));
2238
+ }, true, ['encrypt', 'decrypt']).catch($mol_crypto_restack));
2232
2239
  }
2233
2240
  async encrypt(open, salt) {
2234
2241
  return new Uint8Array(await $mol_crypto_native.subtle.encrypt({
@@ -2236,7 +2243,7 @@ var $;
2236
2243
  length: 128,
2237
2244
  tagLength: 32,
2238
2245
  iv: salt,
2239
- }, await this.native(), open).catch(restack));
2246
+ }, await this.native(), open).catch($mol_crypto_restack));
2240
2247
  }
2241
2248
  async decrypt(closed, salt) {
2242
2249
  return new Uint8Array(await $mol_crypto_native.subtle.decrypt({
@@ -2244,7 +2251,7 @@ var $;
2244
2251
  length: 128,
2245
2252
  tagLength: 32,
2246
2253
  iv: salt,
2247
- }, await this.native(), closed).catch(restack));
2254
+ }, await this.native(), closed).catch($mol_crypto_restack));
2248
2255
  }
2249
2256
  async close(sacred, salt) {
2250
2257
  const buf = new Uint8Array(sacred.buffer, sacred.byteOffset + 1, sacred.byteLength - 1);
@@ -2351,7 +2358,7 @@ var $;
2351
2358
  var $;
2352
2359
  (function ($) {
2353
2360
  async function $mol_crypto_sacred_pass(pass, salt) {
2354
- const raw = await $mol_crypto_native.subtle.importKey("raw", $mol_charset_encode(pass), "PBKDF2", false, ["deriveKey"]);
2361
+ const raw = await $mol_crypto_native.subtle.importKey("raw", $mol_charset_encode(pass), "PBKDF2", false, ["deriveKey"]).catch($mol_crypto_restack);
2355
2362
  const hard = await $mol_crypto_native.subtle.deriveKey({
2356
2363
  name: "PBKDF2",
2357
2364
  salt,
@@ -2360,7 +2367,7 @@ var $;
2360
2367
  }, raw, {
2361
2368
  name: 'AES-CBC',
2362
2369
  length: 128,
2363
- }, Boolean('extractable'), ['encrypt', 'decrypt']);
2370
+ }, Boolean('extractable'), ['encrypt', 'decrypt']).catch($mol_crypto_restack);
2364
2371
  return $mol_crypto_sacred.from_native(hard);
2365
2372
  }
2366
2373
  $.$mol_crypto_sacred_pass = $mol_crypto_sacred_pass;
@@ -2411,7 +2418,7 @@ var $;
2411
2418
  kty: "EC",
2412
2419
  x: str.slice(0, 43),
2413
2420
  y: str.slice(43, 86),
2414
- }, ecdsa, Boolean('extractable'), ['verify']);
2421
+ }, ecdsa, Boolean('extractable'), ['verify']).catch($mol_crypto_restack);
2415
2422
  }
2416
2423
  async native_derive() {
2417
2424
  const serial = this.toString();
@@ -2420,10 +2427,10 @@ var $;
2420
2427
  key_ops: [],
2421
2428
  x: serial.slice(0, 43),
2422
2429
  y: serial.slice(43, 86),
2423
- }, ecdh, true, []);
2430
+ }, ecdh, true, []).catch($mol_crypto_restack);
2424
2431
  }
2425
2432
  async verify(data, sign) {
2426
- return await $mol_crypto_native.subtle.verify(ecdsa, await this.native(), sign, data);
2433
+ return await $mol_crypto_native.subtle.verify(ecdsa, await this.native(), sign, data).catch($mol_crypto_restack);
2427
2434
  }
2428
2435
  }
2429
2436
  __decorate([
@@ -2438,8 +2445,8 @@ var $;
2438
2445
  static size_bin = 96;
2439
2446
  static size_sign = 64;
2440
2447
  static async generate() {
2441
- const pair = await $mol_crypto_native.subtle.generateKey(ecdsa, Boolean('extractable'), ['sign', 'verify']);
2442
- const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey);
2448
+ const pair = await $mol_crypto_native.subtle.generateKey(ecdsa, Boolean('extractable'), ['sign', 'verify']).catch($mol_crypto_restack);
2449
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey).catch($mol_crypto_restack);
2443
2450
  return this.from(x + y + d);
2444
2451
  }
2445
2452
  async native() {
@@ -2452,7 +2459,7 @@ var $;
2452
2459
  x: str.slice(0, 43),
2453
2460
  y: str.slice(43, 86),
2454
2461
  d: str.slice(86, 129),
2455
- }, ecdsa, Boolean('extractable'), ['sign']);
2462
+ }, ecdsa, Boolean('extractable'), ['sign']).catch($mol_crypto_restack);
2456
2463
  }
2457
2464
  async native_derive() {
2458
2465
  const serial = this.toString();
@@ -2462,13 +2469,13 @@ var $;
2462
2469
  x: serial.slice(0, 43),
2463
2470
  y: serial.slice(43, 86),
2464
2471
  d: serial.slice(86, 129),
2465
- }, ecdh, Boolean('extractable'), ['deriveKey', 'deriveBits']);
2472
+ }, ecdh, Boolean('extractable'), ['deriveKey', 'deriveBits']).catch($mol_crypto_restack);
2466
2473
  }
2467
2474
  public() {
2468
2475
  return new $mol_crypto_key_public(this.buffer, this.byteOffset, this.byteOffset + 64);
2469
2476
  }
2470
2477
  async sign(data) {
2471
- return new Uint8Array(await $mol_crypto_native.subtle.sign(ecdsa, await this.native(), data));
2478
+ return new Uint8Array(await $mol_crypto_native.subtle.sign(ecdsa, await this.native(), data).catch($mol_crypto_restack));
2472
2479
  }
2473
2480
  }
2474
2481
  __decorate([
@@ -2491,7 +2498,7 @@ var $;
2491
2498
  return $mol_crypto_sacred.from(new Uint8Array(await $mol_crypto_native.subtle.deriveBits({
2492
2499
  name: "ECDH",
2493
2500
  public: await pub.native_derive(),
2494
- }, await priv.native_derive(), $mol_crypto_sacred.size * 8)));
2501
+ }, await priv.native_derive(), $mol_crypto_sacred.size * 8).catch($mol_crypto_restack)));
2495
2502
  }
2496
2503
  $.$mol_crypto_sacred_shared = $mol_crypto_sacred_shared;
2497
2504
  })($ || ($ = {}));