@ocap/mcrypto 1.27.16 → 1.28.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.
Files changed (66) hide show
  1. package/esm/crypter/aes-legacy.d.ts +8 -6
  2. package/esm/crypter/aes-legacy.js +27 -24
  3. package/esm/crypter/aes.d.ts +9 -7
  4. package/esm/crypter/aes.js +27 -25
  5. package/esm/crypter/rsa-browserify.d.ts +7 -6
  6. package/esm/crypter/rsa-browserify.js +34 -31
  7. package/esm/crypter/rsa.d.ts +11 -9
  8. package/esm/crypter/rsa.js +31 -28
  9. package/esm/encode.d.ts +12 -8
  10. package/esm/encode.js +13 -18
  11. package/esm/hasher/keccak.d.ts +8 -5
  12. package/esm/hasher/keccak.js +37 -36
  13. package/esm/hasher/sha2.d.ts +8 -5
  14. package/esm/hasher/sha2.js +42 -40
  15. package/esm/hasher/sha3.d.ts +8 -5
  16. package/esm/hasher/sha3.js +37 -36
  17. package/esm/index.d.ts +148 -143
  18. package/esm/index.js +172 -209
  19. package/esm/protocols/crypter.d.ts +3 -1
  20. package/esm/protocols/crypter.js +7 -4
  21. package/esm/protocols/hasher.d.ts +3 -1
  22. package/esm/protocols/hasher.js +7 -4
  23. package/esm/protocols/signer.d.ts +3 -1
  24. package/esm/protocols/signer.js +7 -4
  25. package/esm/signer/ed25519.d.ts +49 -46
  26. package/esm/signer/ed25519.js +80 -80
  27. package/esm/signer/ethereum.d.ts +11 -8
  28. package/esm/signer/ethereum.js +34 -34
  29. package/esm/signer/passkey.d.ts +21 -18
  30. package/esm/signer/passkey.js +49 -58
  31. package/esm/signer/secp256k1.d.ts +35 -32
  32. package/esm/signer/secp256k1.js +80 -93
  33. package/lib/_virtual/rolldown_runtime.js +29 -0
  34. package/lib/crypter/aes-legacy.d.ts +8 -6
  35. package/lib/crypter/aes-legacy.js +35 -52
  36. package/lib/crypter/aes.d.ts +9 -7
  37. package/lib/crypter/aes.js +29 -29
  38. package/lib/crypter/rsa-browserify.d.ts +7 -6
  39. package/lib/crypter/rsa-browserify.js +36 -33
  40. package/lib/crypter/rsa.d.ts +11 -9
  41. package/lib/crypter/rsa.js +33 -32
  42. package/lib/encode.d.ts +12 -8
  43. package/lib/encode.js +14 -21
  44. package/lib/hasher/keccak.d.ts +8 -5
  45. package/lib/hasher/keccak.js +40 -41
  46. package/lib/hasher/sha2.d.ts +8 -5
  47. package/lib/hasher/sha2.js +43 -42
  48. package/lib/hasher/sha3.d.ts +8 -5
  49. package/lib/hasher/sha3.js +40 -41
  50. package/lib/index.d.ts +148 -143
  51. package/lib/index.js +177 -216
  52. package/lib/protocols/crypter.d.ts +3 -1
  53. package/lib/protocols/crypter.js +10 -9
  54. package/lib/protocols/hasher.d.ts +3 -1
  55. package/lib/protocols/hasher.js +10 -9
  56. package/lib/protocols/signer.d.ts +3 -1
  57. package/lib/protocols/signer.js +10 -9
  58. package/lib/signer/ed25519.d.ts +49 -46
  59. package/lib/signer/ed25519.js +85 -86
  60. package/lib/signer/ethereum.d.ts +11 -8
  61. package/lib/signer/ethereum.js +38 -39
  62. package/lib/signer/passkey.d.ts +21 -18
  63. package/lib/signer/passkey.js +51 -63
  64. package/lib/signer/secp256k1.d.ts +35 -32
  65. package/lib/signer/secp256k1.js +85 -99
  66. package/package.json +21 -10
@@ -1,13 +1,16 @@
1
- import { BytesType, EncodingType } from '@ocap/util';
1
+ import { BytesType, EncodingType } from "@ocap/util";
2
+
3
+ //#region src/hasher/keccak.d.ts
4
+
2
5
  /**
3
6
  * Keccak support with different hash length
4
7
  *
5
8
  * @class KeccakHasher
6
9
  */
7
10
  declare class KeccakHasher {
8
- [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
9
- constructor();
11
+ [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
12
+ constructor();
10
13
  }
11
14
  declare const _default: KeccakHasher;
12
- export default _default;
13
- export { KeccakHasher };
15
+ //#endregion
16
+ export { KeccakHasher, _default as default };
@@ -1,43 +1,42 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KeccakHasher = void 0;
7
- /* eslint-disable @typescript-eslint/ban-ts-comment */
8
- const js_sha3_1 = __importDefault(require("js-sha3"));
9
- const util_1 = require("@ocap/util");
10
- const encode_1 = require("../encode");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
3
+ const require_encode = require('../encode.js');
4
+ let _ocap_util = require("@ocap/util");
5
+ let js_sha3 = require("js-sha3");
6
+ js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
7
+
8
+ //#region src/hasher/keccak.ts
11
9
  /**
12
- * Keccak support with different hash length
13
- *
14
- * @class KeccakHasher
15
- */
16
- class KeccakHasher {
17
- constructor() {
18
- [224, 256, 384, 512].forEach((x) => {
19
- const name = `hash${x}`;
20
- // @ts-ignore
21
- const hasher = (data) => js_sha3_1.default[`keccak${x}`](data);
22
- const hashFn = (input, round) => {
23
- if (round === 1) {
24
- return hasher(input);
25
- }
26
- return hashFn(hasher(input), round - 1);
27
- };
28
- this[name] = (data, round = 1, encoding = 'hex') => {
29
- let input = data;
30
- try {
31
- input = (0, util_1.toUint8Array)(data);
32
- }
33
- catch (err) {
34
- // Do nothing
35
- }
36
- const res = hashFn(input, round);
37
- return (0, encode_1.encode)(`0x${res}`, encoding);
38
- };
39
- });
40
- }
41
- }
10
+ * Keccak support with different hash length
11
+ *
12
+ * @class KeccakHasher
13
+ */
14
+ var KeccakHasher = class {
15
+ constructor() {
16
+ [
17
+ 224,
18
+ 256,
19
+ 384,
20
+ 512
21
+ ].forEach((x) => {
22
+ const name = `hash${x}`;
23
+ const hasher = (data) => js_sha3.default[`keccak${x}`](data);
24
+ const hashFn = (input, round) => {
25
+ if (round === 1) return hasher(input);
26
+ return hashFn(hasher(input), round - 1);
27
+ };
28
+ this[name] = (data, round = 1, encoding = "hex") => {
29
+ let input = data;
30
+ try {
31
+ input = (0, _ocap_util.toUint8Array)(data);
32
+ } catch (err) {}
33
+ return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
34
+ };
35
+ });
36
+ }
37
+ };
38
+ var keccak_default = new KeccakHasher();
39
+
40
+ //#endregion
42
41
  exports.KeccakHasher = KeccakHasher;
43
- exports.default = new KeccakHasher();
42
+ exports.default = keccak_default;
@@ -1,13 +1,16 @@
1
- import { BytesType, EncodingType } from '@ocap/util';
1
+ import { BytesType, EncodingType } from "@ocap/util";
2
+
3
+ //#region src/hasher/sha2.d.ts
4
+
2
5
  /**
3
6
  * Sha2 support with different hash length
4
7
  *
5
8
  * @class
6
9
  */
7
10
  declare class Sha2Hasher {
8
- [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
9
- constructor();
11
+ [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
12
+ constructor();
10
13
  }
11
14
  declare const _default: Sha2Hasher;
12
- export default _default;
13
- export { Sha2Hasher };
15
+ //#endregion
16
+ export { Sha2Hasher, _default as default };
@@ -1,46 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sha2Hasher = void 0;
4
- /* eslint-disable @typescript-eslint/ban-ts-comment */
5
- const util_1 = require("@ocap/util");
6
- const hash_js_1 = require("hash.js");
7
- const encode_1 = require("../encode");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
3
+ const require_encode = require('../encode.js');
4
+ let _ocap_util = require("@ocap/util");
5
+ let hash_js = require("hash.js");
6
+
7
+ //#region src/hasher/sha2.ts
8
8
  const hashFns = {
9
- sha224: hash_js_1.sha224,
10
- sha256: hash_js_1.sha256,
11
- sha384: hash_js_1.sha384,
12
- sha512: hash_js_1.sha512,
9
+ sha224: hash_js.sha224,
10
+ sha256: hash_js.sha256,
11
+ sha384: hash_js.sha384,
12
+ sha512: hash_js.sha512
13
13
  };
14
14
  /**
15
- * Sha2 support with different hash length
16
- *
17
- * @class
18
- */
19
- class Sha2Hasher {
20
- constructor() {
21
- [224, 256, 384, 512].forEach((x) => {
22
- const name = `hash${x}`;
23
- // @ts-ignore
24
- const hasher = hashFns[`sha${x}`];
25
- const hashFn = (input, round) => {
26
- let inputBytes = input;
27
- try {
28
- inputBytes = (0, util_1.toUint8Array)(input);
29
- }
30
- catch (err) {
31
- // Do nothing
32
- }
33
- if (round === 1) {
34
- return `0x${hasher().update(inputBytes).digest('hex')}`;
35
- }
36
- return hashFn(hashFn(inputBytes, 1), round - 1);
37
- };
38
- this[name] = (data, round = 2, encoding = 'hex') => {
39
- const res = hashFn(data, round);
40
- return (0, encode_1.encode)(res, encoding);
41
- };
42
- });
43
- }
44
- }
15
+ * Sha2 support with different hash length
16
+ *
17
+ * @class
18
+ */
19
+ var Sha2Hasher = class {
20
+ constructor() {
21
+ [
22
+ 224,
23
+ 256,
24
+ 384,
25
+ 512
26
+ ].forEach((x) => {
27
+ const name = `hash${x}`;
28
+ const hasher = hashFns[`sha${x}`];
29
+ const hashFn = (input, round) => {
30
+ let inputBytes = input;
31
+ try {
32
+ inputBytes = (0, _ocap_util.toUint8Array)(input);
33
+ } catch (err) {}
34
+ if (round === 1) return `0x${hasher().update(inputBytes).digest("hex")}`;
35
+ return hashFn(hashFn(inputBytes, 1), round - 1);
36
+ };
37
+ this[name] = (data, round = 2, encoding = "hex") => {
38
+ return require_encode.encode(hashFn(data, round), encoding);
39
+ };
40
+ });
41
+ }
42
+ };
43
+ var sha2_default = new Sha2Hasher();
44
+
45
+ //#endregion
45
46
  exports.Sha2Hasher = Sha2Hasher;
46
- exports.default = new Sha2Hasher();
47
+ exports.default = sha2_default;
@@ -1,13 +1,16 @@
1
- import { BytesType, EncodingType } from '@ocap/util';
1
+ import { BytesType, EncodingType } from "@ocap/util";
2
+
3
+ //#region src/hasher/sha3.d.ts
4
+
2
5
  /**
3
6
  * Sha3 support with different hash length
4
7
  *
5
8
  * @class Sha3Hasher
6
9
  */
7
10
  declare class Sha3Hasher {
8
- [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
9
- constructor();
11
+ [x: string]: (data: BytesType, round?: number, encoding?: EncodingType) => BytesType;
12
+ constructor();
10
13
  }
11
14
  declare const _default: Sha3Hasher;
12
- export default _default;
13
- export { Sha3Hasher };
15
+ //#endregion
16
+ export { Sha3Hasher, _default as default };
@@ -1,43 +1,42 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Sha3Hasher = void 0;
7
- const js_sha3_1 = __importDefault(require("js-sha3"));
8
- const util_1 = require("@ocap/util");
9
- const encode_1 = require("../encode");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
3
+ const require_encode = require('../encode.js');
4
+ let _ocap_util = require("@ocap/util");
5
+ let js_sha3 = require("js-sha3");
6
+ js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
7
+
8
+ //#region src/hasher/sha3.ts
10
9
  /**
11
- * Sha3 support with different hash length
12
- *
13
- * @class Sha3Hasher
14
- */
15
- class Sha3Hasher {
16
- constructor() {
17
- [224, 256, 384, 512].forEach((x) => {
18
- const name = `hash${x}`;
19
- /* eslint-disable @typescript-eslint/ban-ts-comment */
20
- // @ts-ignore
21
- const hasher = js_sha3_1.default[`sha3_${x}`];
22
- const hashFn = (input, round) => {
23
- if (round === 1) {
24
- return hasher(input);
25
- }
26
- return hashFn(hasher(input), round - 1);
27
- };
28
- this[name] = (data, round = 1, encoding = 'hex') => {
29
- let input = data;
30
- try {
31
- input = (0, util_1.toUint8Array)(data);
32
- }
33
- catch (err) {
34
- // Do nothing
35
- }
36
- const res = hashFn(input, round);
37
- return (0, encode_1.encode)(`0x${res}`, encoding);
38
- };
39
- });
40
- }
41
- }
10
+ * Sha3 support with different hash length
11
+ *
12
+ * @class Sha3Hasher
13
+ */
14
+ var Sha3Hasher = class {
15
+ constructor() {
16
+ [
17
+ 224,
18
+ 256,
19
+ 384,
20
+ 512
21
+ ].forEach((x) => {
22
+ const name = `hash${x}`;
23
+ const hasher = js_sha3.default[`sha3_${x}`];
24
+ const hashFn = (input, round) => {
25
+ if (round === 1) return hasher(input);
26
+ return hashFn(hasher(input), round - 1);
27
+ };
28
+ this[name] = (data, round = 1, encoding = "hex") => {
29
+ let input = data;
30
+ try {
31
+ input = (0, _ocap_util.toUint8Array)(data);
32
+ } catch (err) {}
33
+ return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
34
+ };
35
+ });
36
+ }
37
+ };
38
+ var sha3_default = new Sha3Hasher();
39
+
40
+ //#endregion
42
41
  exports.Sha3Hasher = Sha3Hasher;
43
- exports.default = new Sha3Hasher();
42
+ exports.default = sha3_default;