cafe-utility 29.0.0 → 29.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +45 -21
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -543,6 +543,7 @@ declare function binaryPadStartToMultiple(bytes: Uint8Array, multiple: number, p
543
543
  declare function binaryPadEnd(bytes: Uint8Array, size: number, paddingByte?: number): Uint8Array;
544
544
  declare function binaryPadEndToMultiple(bytes: Uint8Array, multiple: number, paddingByte?: number): Uint8Array;
545
545
  declare function xorCypher(bytes: Uint8Array, key: Uint8Array): Uint8Array;
546
+ declare function isUtf8(bytes: Uint8Array): boolean;
546
547
  declare function binaryEquals(a: Uint8Array, b: Uint8Array): boolean;
547
548
  declare function privateKeyToPublicKey(privateKey: bigint): [bigint, bigint];
548
549
  declare function compressPublicKey(publicKey: [bigint, bigint]): Uint8Array;
@@ -702,6 +703,7 @@ export declare const Binary: {
702
703
  padEnd: typeof binaryPadEnd;
703
704
  padEndToMultiple: typeof binaryPadEndToMultiple;
704
705
  xorCypher: typeof xorCypher;
706
+ isUtf8: typeof isUtf8;
705
707
  };
706
708
  export declare const Elliptic: {
707
709
  privateKeyToPublicKey: typeof privateKeyToPublicKey;
package/index.js CHANGED
@@ -2301,10 +2301,10 @@ function keccakPermutate(n) {
2301
2301
  En = (c << 1) | (f >>> 31),
2302
2302
  Mn = (f << 1) | (c >>> 31),
2303
2303
  w = o ^ En,
2304
- y = i ^ Mn,
2304
+ x = i ^ Mn,
2305
2305
  On = (l << 1) | (a >>> 31),
2306
2306
  kn = (a << 1) | (l >>> 31),
2307
- x = u ^ On,
2307
+ y = u ^ On,
2308
2308
  b = s ^ kn,
2309
2309
  Tn = (t << 1) | (r >>> 31),
2310
2310
  Sn = (r << 1) | (t >>> 31),
@@ -2315,8 +2315,8 @@ function keccakPermutate(n) {
2315
2315
  (n[2] ^= m),
2316
2316
  (n[3] ^= g),
2317
2317
  (n[4] ^= w),
2318
- (n[5] ^= y),
2319
- (n[6] ^= x),
2318
+ (n[5] ^= x),
2319
+ (n[6] ^= y),
2320
2320
  (n[7] ^= b),
2321
2321
  (n[8] ^= $),
2322
2322
  (n[9] ^= A),
@@ -2325,8 +2325,8 @@ function keccakPermutate(n) {
2325
2325
  (n[12] ^= m),
2326
2326
  (n[13] ^= g),
2327
2327
  (n[14] ^= w),
2328
- (n[15] ^= y),
2329
- (n[16] ^= x),
2328
+ (n[15] ^= x),
2329
+ (n[16] ^= y),
2330
2330
  (n[17] ^= b),
2331
2331
  (n[18] ^= $),
2332
2332
  (n[19] ^= A),
@@ -2335,8 +2335,8 @@ function keccakPermutate(n) {
2335
2335
  (n[22] ^= m),
2336
2336
  (n[23] ^= g),
2337
2337
  (n[24] ^= w),
2338
- (n[25] ^= y),
2339
- (n[26] ^= x),
2338
+ (n[25] ^= x),
2339
+ (n[26] ^= y),
2340
2340
  (n[27] ^= b),
2341
2341
  (n[28] ^= $),
2342
2342
  (n[29] ^= A),
@@ -2345,8 +2345,8 @@ function keccakPermutate(n) {
2345
2345
  (n[32] ^= m),
2346
2346
  (n[33] ^= g),
2347
2347
  (n[34] ^= w),
2348
- (n[35] ^= y),
2349
- (n[36] ^= x),
2348
+ (n[35] ^= x),
2349
+ (n[36] ^= y),
2350
2350
  (n[37] ^= b),
2351
2351
  (n[38] ^= $),
2352
2352
  (n[39] ^= A),
@@ -2355,8 +2355,8 @@ function keccakPermutate(n) {
2355
2355
  (n[42] ^= m),
2356
2356
  (n[43] ^= g),
2357
2357
  (n[44] ^= w),
2358
- (n[45] ^= y),
2359
- (n[46] ^= x),
2358
+ (n[45] ^= x),
2359
+ (n[46] ^= y),
2360
2360
  (n[47] ^= b),
2361
2361
  (n[48] ^= $),
2362
2362
  (n[49] ^= A)
@@ -2408,18 +2408,18 @@ function keccakPermutate(n) {
2408
2408
  mn = (n[44] << 29) | (n[45] >>> 3),
2409
2409
  gn = (n[47] << 24) | (n[46] >>> 8),
2410
2410
  wn = (n[46] << 24) | (n[47] >>> 8),
2411
- yn = (n[48] << 14) | (n[49] >>> 18),
2412
- xn = (n[49] << 14) | (n[48] >>> 18)
2411
+ xn = (n[48] << 14) | (n[49] >>> 18),
2412
+ yn = (n[49] << 14) | (n[48] >>> 18)
2413
2413
  ;(n[0] = E ^ (~v & K)),
2414
2414
  (n[1] = M ^ (~U & Z)),
2415
2415
  (n[2] = v ^ (~K & un)),
2416
2416
  (n[3] = U ^ (~Z & cn)),
2417
- (n[4] = K ^ (~un & yn)),
2418
- (n[5] = Z ^ (~cn & xn)),
2419
- (n[6] = un ^ (~yn & E)),
2420
- (n[7] = cn ^ (~xn & M)),
2421
- (n[8] = yn ^ (~E & v)),
2422
- (n[9] = xn ^ (~M & U)),
2417
+ (n[4] = K ^ (~un & xn)),
2418
+ (n[5] = Z ^ (~cn & yn)),
2419
+ (n[6] = un ^ (~xn & E)),
2420
+ (n[7] = cn ^ (~yn & M)),
2421
+ (n[8] = xn ^ (~E & v)),
2422
+ (n[9] = yn ^ (~M & U)),
2423
2423
  (n[10] = R ^ (~z & q)),
2424
2424
  (n[11] = I ^ (~W & H)),
2425
2425
  (n[12] = z ^ (~q & en)),
@@ -2586,6 +2586,29 @@ function xorCypher(n, e) {
2586
2586
  for (let r = 0; r < n.length; r++) t[r] = n[r] ^ e[r % e.length]
2587
2587
  return t
2588
2588
  }
2589
+ function isUtf8(n) {
2590
+ for (let e = 0; e < n.length; e++) {
2591
+ const t = n[e]
2592
+ if (!(t < 128))
2593
+ if ((t & 224) === 192) {
2594
+ if (e + 1 >= n.length || (n[e + 1] & 192) !== 128) return !1
2595
+ e += 1
2596
+ } else if ((t & 240) === 224) {
2597
+ if (e + 2 >= n.length || (n[e + 1] & 192) !== 128 || (n[e + 2] & 192) !== 128) return !1
2598
+ e += 2
2599
+ } else if ((t & 248) === 240) {
2600
+ if (
2601
+ e + 3 >= n.length ||
2602
+ (n[e + 1] & 192) !== 128 ||
2603
+ (n[e + 2] & 192) !== 128 ||
2604
+ (n[e + 3] & 192) !== 128
2605
+ )
2606
+ return !1
2607
+ e += 3
2608
+ } else return !1
2609
+ }
2610
+ return !0
2611
+ }
2589
2612
  function binaryEquals(n, e) {
2590
2613
  if (n.length !== e.length) return !1
2591
2614
  for (let t = 0; t < n.length; t++) if (n[t] !== e[t]) return !1
@@ -3179,7 +3202,8 @@ class TrieRouter {
3179
3202
  padStartToMultiple: binaryPadStartToMultiple,
3180
3203
  padEnd: binaryPadEnd,
3181
3204
  padEndToMultiple: binaryPadEndToMultiple,
3182
- xorCypher
3205
+ xorCypher,
3206
+ isUtf8
3183
3207
  }),
3184
3208
  (exports.Elliptic = {
3185
3209
  privateKeyToPublicKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "29.0.0",
3
+ "version": "29.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {