internxt-crypto 1.3.0 → 1.3.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 (96) hide show
  1. package/dist/asymmetric-crypto.js +3 -4
  2. package/dist/asymmetric-crypto.js.map +1 -1
  3. package/dist/asymmetric-crypto.mjs +1 -2
  4. package/dist/asymmetric-crypto.mjs.map +1 -1
  5. package/dist/chunk-C13QxCFV.js +50 -0
  6. package/dist/chunk-CfYAbeIz.mjs +13 -0
  7. package/dist/constants.js +2 -3
  8. package/dist/constants.js.map +1 -1
  9. package/dist/constants.mjs +1 -1
  10. package/dist/derive-key.js +50 -5
  11. package/dist/derive-key.js.map +1 -0
  12. package/dist/derive-key.mjs +46 -2
  13. package/dist/derive-key.mjs.map +1 -0
  14. package/dist/{deriveKeysFromPassword-iMHv-tIA.js → derive-password-CbYRDq7V.js} +25 -30
  15. package/dist/derive-password-CbYRDq7V.js.map +1 -0
  16. package/dist/{deriveKeysFromPassword-DFzo2OII.mjs → derive-password-PED-YfwE.mjs} +27 -34
  17. package/dist/derive-password-PED-YfwE.mjs.map +1 -0
  18. package/dist/derive-password.js +5 -6
  19. package/dist/derive-password.mjs +2 -3
  20. package/dist/{emailKeys-BFI-paQq.js → email-crypto-Cr7znO1a.js} +116 -121
  21. package/dist/email-crypto-Cr7znO1a.js.map +1 -0
  22. package/dist/{emailKeys-BjIeINfC.mjs → email-crypto-cHDsjSb5.mjs} +7 -12
  23. package/dist/email-crypto-cHDsjSb5.mjs.map +1 -0
  24. package/dist/email-crypto.d.mts +1 -1
  25. package/dist/email-crypto.d.ts +1 -1
  26. package/dist/email-crypto.js +17 -18
  27. package/dist/email-crypto.mjs +2 -3
  28. package/dist/hash.js +3 -4
  29. package/dist/hash.js.map +1 -1
  30. package/dist/hash.mjs +1 -2
  31. package/dist/hash.mjs.map +1 -1
  32. package/dist/index.d.mts +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +55 -56
  35. package/dist/index.mjs +7 -8
  36. package/dist/{emailEncryptionKey-CYvr26FG.mjs → keystore-crypto-C6F-NQdX.mjs} +12 -15
  37. package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
  38. package/dist/{emailEncryptionKey-Ba95VuFO.js → keystore-crypto-CFiiGohl.js} +67 -70
  39. package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
  40. package/dist/keystore-crypto.d.mts +1 -1
  41. package/dist/keystore-crypto.d.ts +1 -1
  42. package/dist/keystore-crypto.js +11 -12
  43. package/dist/keystore-crypto.mjs +2 -3
  44. package/dist/post-quantum-crypto.js +3 -4
  45. package/dist/post-quantum-crypto.js.map +1 -1
  46. package/dist/post-quantum-crypto.mjs +1 -2
  47. package/dist/post-quantum-crypto.mjs.map +1 -1
  48. package/dist/storage-service.js +13 -15
  49. package/dist/storage-service.js.map +1 -1
  50. package/dist/storage-service.mjs +2 -4
  51. package/dist/storage-service.mjs.map +1 -1
  52. package/dist/symmetric-crypto.js +51 -5
  53. package/dist/symmetric-crypto.js.map +1 -0
  54. package/dist/symmetric-crypto.mjs +47 -2
  55. package/dist/symmetric-crypto.mjs.map +1 -0
  56. package/dist/types-4P0WII1D.d.ts +49 -0
  57. package/dist/types-4P0WII1D.d.ts.map +1 -0
  58. package/dist/types-DAPJQG8U.d.mts +49 -0
  59. package/dist/types-DAPJQG8U.d.mts.map +1 -0
  60. package/dist/types.d.mts +2 -49
  61. package/dist/types.d.ts +2 -49
  62. package/dist/types.js +2 -3
  63. package/dist/types.js.map +1 -1
  64. package/dist/types.mjs +1 -1
  65. package/dist/types.mjs.map +1 -1
  66. package/dist/utils.js +127 -14
  67. package/dist/utils.js.map +1 -0
  68. package/dist/utils.mjs +113 -2
  69. package/dist/utils.mjs.map +1 -0
  70. package/dist/{xwing-iRWVRtNE.js → xwing-7fEqAT7W.js} +18 -19
  71. package/dist/{xwing-iRWVRtNE.js.map → xwing-7fEqAT7W.js.map} +1 -1
  72. package/dist/{xwing-CQmQX6hn.mjs → xwing-B34h5e3Z.mjs} +2 -3
  73. package/dist/{xwing-CQmQX6hn.mjs.map → xwing-B34h5e3Z.mjs.map} +1 -1
  74. package/package.json +22 -22
  75. package/dist/aes-B8TA-JKq.mjs +0 -49
  76. package/dist/aes-B8TA-JKq.mjs.map +0 -1
  77. package/dist/aes-CuW_SPl-.js +0 -67
  78. package/dist/aes-CuW_SPl-.js.map +0 -1
  79. package/dist/chunk-DQk6qfdC.mjs +0 -18
  80. package/dist/chunk-EbLFQX5m.js +0 -60
  81. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs +0 -49
  82. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs.map +0 -1
  83. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js +0 -67
  84. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js.map +0 -1
  85. package/dist/deriveKeysFromPassword-DFzo2OII.mjs.map +0 -1
  86. package/dist/deriveKeysFromPassword-iMHv-tIA.js.map +0 -1
  87. package/dist/emailEncryptionKey-Ba95VuFO.js.map +0 -1
  88. package/dist/emailEncryptionKey-CYvr26FG.mjs.map +0 -1
  89. package/dist/emailKeys-BFI-paQq.js.map +0 -1
  90. package/dist/emailKeys-BjIeINfC.mjs.map +0 -1
  91. package/dist/genID-D08K7JPr.mjs +0 -117
  92. package/dist/genID-D08K7JPr.mjs.map +0 -1
  93. package/dist/genID-cWOPmspk.js +0 -190
  94. package/dist/genID-cWOPmspk.js.map +0 -1
  95. package/dist/types.d.mts.map +0 -1
  96. package/dist/types.d.ts.map +0 -1
package/dist/utils.js CHANGED
@@ -1,15 +1,128 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_genID = require('./genID-cWOPmspk.js');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-C13QxCFV.js");
3
+ require("./constants.js");
4
+ let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
5
+ let _scure_bip39 = require("@scure/bip39");
6
+ _scure_bip39 = require_chunk.__toESM(_scure_bip39);
7
+ let _scure_bip39_wordlists_english_js = require("@scure/bip39/wordlists/english.js");
8
+ let uuid = require("uuid");
9
+ //#region src/utils/converters.ts
10
+ /**
11
+ * Converts a Uint8Array into a hexadecimal string.
12
+ *
13
+ * @param array - The Uint8Array to convert.
14
+ * @returns The hexadecimal string representation of the array.
15
+ */
16
+ function uint8ArrayToHex(array) {
17
+ return (0, _noble_hashes_utils_js.bytesToHex)(array);
18
+ }
19
+ /**
20
+ * Converts a UTF-8 string into a Uint8Array.
21
+ *
22
+ * @param str - The UTF-8 string to convert.
23
+ * @returns A Uint8Array created from the UTF-8 string.
24
+ */
25
+ function UTF8ToUint8(str) {
26
+ return new TextEncoder().encode(str);
27
+ }
28
+ /**
29
+ * Converts an Uint8Array into a UTF-8 string.
30
+ *
31
+ * @param array - The Uint8Array to convert.
32
+ * @returns The UTF-8 string representation of the array.
33
+ */
34
+ function uint8ToUTF8(array) {
35
+ return new TextDecoder().decode(array);
36
+ }
37
+ /**
38
+ * Converts a hexadecimal string into a Uint8Array.
39
+ *
40
+ * @param hex - The hexadecimal string to convert.
41
+ * @returns A Uint8Array created from the hex string.
42
+ */
43
+ function hexToUint8Array(hex) {
44
+ return (0, _noble_hashes_utils_js.hexToBytes)(hex);
45
+ }
46
+ /**
47
+ * Converts a Uint8Array into a base64 string.
48
+ *
49
+ * @param array - The Uint8Array to convert.
50
+ * @returns The base64 string representation of the array.
51
+ */
52
+ function uint8ArrayToBase64(buffer) {
53
+ const array = Uint16Array.from(buffer);
54
+ const binaryString = new TextDecoder("UTF-16").decode(array);
55
+ return btoa(binaryString);
56
+ }
57
+ /**
58
+ * Converts a base64 string into a Uint8Array.
59
+ *
60
+ * @param str - The base64 string to convert.
61
+ * @returns A Uint8Array created from the base64 string.
62
+ */
63
+ function base64ToUint8Array(str) {
64
+ const binaryString = atob(str);
65
+ const len = binaryString.length;
66
+ const array = new Uint8Array(len);
67
+ for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
68
+ return new Uint8Array(array.buffer);
69
+ }
70
+ //#endregion
71
+ //#region src/utils/genMnemonic.ts
72
+ /**
73
+ * Generates a mnemonic
74
+ *
75
+ * @returns The generated mnemonic.
76
+ */
77
+ function genMnemonic() {
78
+ return _scure_bip39.generateMnemonic(_scure_bip39_wordlists_english_js.wordlist, 256);
79
+ }
80
+ /**
81
+ * Converts a mnemonic to Uint8Array
82
+ *
83
+ * @param mnemonic - The mnemonic to convert
84
+ * @returns The mnemonic as Uint8Array
85
+ */
86
+ function mnemonicToBytes(mnemonic) {
87
+ return _scure_bip39.mnemonicToEntropy(mnemonic, _scure_bip39_wordlists_english_js.wordlist);
88
+ }
89
+ /**
90
+ * Converts a Uint8Array to a mnemonic
91
+ *
92
+ * @param bytes - The bytes to convert
93
+ * @returns The mnemonic string
94
+ */
95
+ function bytesToMnemonic(bytes) {
96
+ return _scure_bip39.entropyToMnemonic(bytes, _scure_bip39_wordlists_english_js.wordlist);
97
+ }
98
+ //#endregion
99
+ //#region src/utils/genID.ts
100
+ /**
101
+ * Creates a random identifier.
102
+ *
103
+ * @returns The resulting auxilary string
104
+ */
105
+ function generateUuid() {
106
+ return (0, uuid.v4)();
107
+ }
108
+ function uuidToBytes(uuid$1) {
109
+ return (0, uuid.parse)(uuid$1);
110
+ }
111
+ function bytesToUuid(bytes) {
112
+ return (0, uuid.stringify)(bytes);
113
+ }
114
+ //#endregion
115
+ exports.UTF8ToUint8 = UTF8ToUint8;
116
+ exports.base64ToUint8Array = base64ToUint8Array;
117
+ exports.bytesToMnemonic = bytesToMnemonic;
118
+ exports.bytesToUuid = bytesToUuid;
119
+ exports.genMnemonic = genMnemonic;
120
+ exports.generateUuid = generateUuid;
121
+ exports.hexToUint8Array = hexToUint8Array;
122
+ exports.mnemonicToBytes = mnemonicToBytes;
123
+ exports.uint8ArrayToBase64 = uint8ArrayToBase64;
124
+ exports.uint8ArrayToHex = uint8ArrayToHex;
125
+ exports.uint8ToUTF8 = uint8ToUTF8;
126
+ exports.uuidToBytes = uuidToBytes;
3
127
 
4
- exports.UTF8ToUint8 = require_genID.UTF8ToUint8;
5
- exports.base64ToUint8Array = require_genID.base64ToUint8Array;
6
- exports.bytesToMnemonic = require_genID.bytesToMnemonic;
7
- exports.bytesToUuid = require_genID.bytesToUuid;
8
- exports.genMnemonic = require_genID.genMnemonic;
9
- exports.generateUuid = require_genID.generateUuid;
10
- exports.hexToUint8Array = require_genID.hexToUint8Array;
11
- exports.mnemonicToBytes = require_genID.mnemonicToBytes;
12
- exports.uint8ArrayToBase64 = require_genID.uint8ArrayToBase64;
13
- exports.uint8ArrayToHex = require_genID.uint8ArrayToHex;
14
- exports.uint8ToUTF8 = require_genID.uint8ToUTF8;
15
- exports.uuidToBytes = require_genID.uuidToBytes;
128
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["bip39","wordlist","uuid"],"sources":["../src/utils/converters.ts","../src/utils/genMnemonic.ts","../src/utils/genID.ts"],"sourcesContent":["import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\n/**\n * Converts a Uint8Array into a hexadecimal string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The hexadecimal string representation of the array.\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return bytesToHex(array);\n}\n\n/**\n * Converts a UTF-8 string into a Uint8Array.\n *\n * @param str - The UTF-8 string to convert.\n * @returns A Uint8Array created from the UTF-8 string.\n */\nexport function UTF8ToUint8(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts an Uint8Array into a UTF-8 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The UTF-8 string representation of the array.\n */\nexport function uint8ToUTF8(array: Uint8Array): string {\n return new TextDecoder().decode(array);\n}\n\n/**\n * Converts a hexadecimal string into a Uint8Array.\n *\n * @param hex - The hexadecimal string to convert.\n * @returns A Uint8Array created from the hex string.\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * Converts a Uint8Array into a base64 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The base64 string representation of the array.\n */\nexport function uint8ArrayToBase64(buffer: Uint8Array): string {\n const array = Uint16Array.from(buffer);\n const binaryString = new TextDecoder('UTF-16').decode(array);\n return btoa(binaryString);\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @param str - The base64 string to convert.\n * @returns A Uint8Array created from the base64 string.\n */\nexport function base64ToUint8Array(str: string): Uint8Array {\n const binaryString = atob(str);\n const len = binaryString.length;\n const array = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n array[i] = binaryString.codePointAt(i)!;\n }\n return new Uint8Array(array.buffer);\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english.js';\nimport { AES_KEY_BYTE_LENGTH } from '../constants';\n/**\n * Generates a mnemonic\n *\n * @returns The generated mnemonic.\n */\nexport function genMnemonic(): string {\n return bip39.generateMnemonic(wordlist, AES_KEY_BYTE_LENGTH * 8);\n}\n\n/**\n * Converts a mnemonic to Uint8Array\n *\n * @param mnemonic - The mnemonic to convert\n * @returns The mnemonic as Uint8Array\n */\nexport function mnemonicToBytes(mnemonic: string): Uint8Array {\n return bip39.mnemonicToEntropy(mnemonic, wordlist);\n}\n\n/**\n * Converts a Uint8Array to a mnemonic\n *\n * @param bytes - The bytes to convert\n * @returns The mnemonic string\n */\nexport function bytesToMnemonic(bytes: Uint8Array): string {\n return bip39.entropyToMnemonic(bytes, wordlist);\n}\n","import { v4 as uuidv4, parse, stringify } from 'uuid';\n/**\n * Creates a random identifier.\n *\n * @returns The resulting auxilary string\n */\nexport function generateUuid(): string {\n return uuidv4();\n}\n\nexport function uuidToBytes(uuid: string): Uint8Array {\n return parse(uuid);\n}\n\nexport function bytesToUuid(bytes: Uint8Array): string {\n return stringify(bytes);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAQA,SAAgB,gBAAgB,OAA2B;AACzD,SAAA,GAAA,uBAAA,YAAkB,MAAM;;;;;;;;AAS1B,SAAgB,YAAY,KAAyB;AACnD,QAAO,IAAI,aAAa,CAAC,OAAO,IAAI;;;;;;;;AAStC,SAAgB,YAAY,OAA2B;AACrD,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;;;;;;;;AASxC,SAAgB,gBAAgB,KAAyB;AACvD,SAAA,GAAA,uBAAA,YAAkB,IAAI;;;;;;;;AASxB,SAAgB,mBAAmB,QAA4B;CAC7D,MAAM,QAAQ,YAAY,KAAK,OAAO;CACtC,MAAM,eAAe,IAAI,YAAY,SAAS,CAAC,OAAO,MAAM;AAC5D,QAAO,KAAK,aAAa;;;;;;;;AAS3B,SAAgB,mBAAmB,KAAyB;CAC1D,MAAM,eAAe,KAAK,IAAI;CAC9B,MAAM,MAAM,aAAa;CACzB,MAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,OAAM,KAAK,aAAa,YAAY,EAAE;AAExC,QAAO,IAAI,WAAW,MAAM,OAAO;;;;;;;;;AC3DrC,SAAgB,cAAsB;AACpC,QAAOA,aAAM,iBAAiBC,kCAAAA,UAAAA,IAAkC;;;;;;;;AASlE,SAAgB,gBAAgB,UAA8B;AAC5D,QAAOD,aAAM,kBAAkB,UAAUC,kCAAAA,SAAS;;;;;;;;AASpD,SAAgB,gBAAgB,OAA2B;AACzD,QAAOD,aAAM,kBAAkB,OAAOC,kCAAAA,SAAS;;;;;;;;;ACvBjD,SAAgB,eAAuB;AACrC,SAAA,GAAA,KAAA,KAAe;;AAGjB,SAAgB,YAAY,QAA0B;AACpD,SAAA,GAAA,KAAA,OAAaC,OAAK;;AAGpB,SAAgB,YAAY,OAA2B;AACrD,SAAA,GAAA,KAAA,WAAiB,MAAM"}
package/dist/utils.mjs CHANGED
@@ -1,3 +1,114 @@
1
- import { a as genMnemonic, c as base64ToUint8Array, d as uint8ArrayToHex, f as uint8ToUTF8, i as bytesToMnemonic, l as hexToUint8Array, n as generateUuid, o as mnemonicToBytes, r as uuidToBytes, s as UTF8ToUint8, t as bytesToUuid, u as uint8ArrayToBase64 } from "./genID-D08K7JPr.mjs";
1
+ import "./constants.mjs";
2
+ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
3
+ import * as bip39 from "@scure/bip39";
4
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
5
+ import { parse, stringify, v4 } from "uuid";
6
+ //#region src/utils/converters.ts
7
+ /**
8
+ * Converts a Uint8Array into a hexadecimal string.
9
+ *
10
+ * @param array - The Uint8Array to convert.
11
+ * @returns The hexadecimal string representation of the array.
12
+ */
13
+ function uint8ArrayToHex(array) {
14
+ return bytesToHex(array);
15
+ }
16
+ /**
17
+ * Converts a UTF-8 string into a Uint8Array.
18
+ *
19
+ * @param str - The UTF-8 string to convert.
20
+ * @returns A Uint8Array created from the UTF-8 string.
21
+ */
22
+ function UTF8ToUint8(str) {
23
+ return new TextEncoder().encode(str);
24
+ }
25
+ /**
26
+ * Converts an Uint8Array into a UTF-8 string.
27
+ *
28
+ * @param array - The Uint8Array to convert.
29
+ * @returns The UTF-8 string representation of the array.
30
+ */
31
+ function uint8ToUTF8(array) {
32
+ return new TextDecoder().decode(array);
33
+ }
34
+ /**
35
+ * Converts a hexadecimal string into a Uint8Array.
36
+ *
37
+ * @param hex - The hexadecimal string to convert.
38
+ * @returns A Uint8Array created from the hex string.
39
+ */
40
+ function hexToUint8Array(hex) {
41
+ return hexToBytes(hex);
42
+ }
43
+ /**
44
+ * Converts a Uint8Array into a base64 string.
45
+ *
46
+ * @param array - The Uint8Array to convert.
47
+ * @returns The base64 string representation of the array.
48
+ */
49
+ function uint8ArrayToBase64(buffer) {
50
+ const array = Uint16Array.from(buffer);
51
+ const binaryString = new TextDecoder("UTF-16").decode(array);
52
+ return btoa(binaryString);
53
+ }
54
+ /**
55
+ * Converts a base64 string into a Uint8Array.
56
+ *
57
+ * @param str - The base64 string to convert.
58
+ * @returns A Uint8Array created from the base64 string.
59
+ */
60
+ function base64ToUint8Array(str) {
61
+ const binaryString = atob(str);
62
+ const len = binaryString.length;
63
+ const array = new Uint8Array(len);
64
+ for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
65
+ return new Uint8Array(array.buffer);
66
+ }
67
+ //#endregion
68
+ //#region src/utils/genMnemonic.ts
69
+ /**
70
+ * Generates a mnemonic
71
+ *
72
+ * @returns The generated mnemonic.
73
+ */
74
+ function genMnemonic() {
75
+ return bip39.generateMnemonic(wordlist, 256);
76
+ }
77
+ /**
78
+ * Converts a mnemonic to Uint8Array
79
+ *
80
+ * @param mnemonic - The mnemonic to convert
81
+ * @returns The mnemonic as Uint8Array
82
+ */
83
+ function mnemonicToBytes(mnemonic) {
84
+ return bip39.mnemonicToEntropy(mnemonic, wordlist);
85
+ }
86
+ /**
87
+ * Converts a Uint8Array to a mnemonic
88
+ *
89
+ * @param bytes - The bytes to convert
90
+ * @returns The mnemonic string
91
+ */
92
+ function bytesToMnemonic(bytes) {
93
+ return bip39.entropyToMnemonic(bytes, wordlist);
94
+ }
95
+ //#endregion
96
+ //#region src/utils/genID.ts
97
+ /**
98
+ * Creates a random identifier.
99
+ *
100
+ * @returns The resulting auxilary string
101
+ */
102
+ function generateUuid() {
103
+ return v4();
104
+ }
105
+ function uuidToBytes(uuid) {
106
+ return parse(uuid);
107
+ }
108
+ function bytesToUuid(bytes) {
109
+ return stringify(bytes);
110
+ }
111
+ //#endregion
112
+ export { UTF8ToUint8, base64ToUint8Array, bytesToMnemonic, bytesToUuid, genMnemonic, generateUuid, hexToUint8Array, mnemonicToBytes, uint8ArrayToBase64, uint8ArrayToHex, uint8ToUTF8, uuidToBytes };
2
113
 
3
- export { UTF8ToUint8, base64ToUint8Array, bytesToMnemonic, bytesToUuid, genMnemonic, generateUuid, hexToUint8Array, mnemonicToBytes, uint8ArrayToBase64, uint8ArrayToHex, uint8ToUTF8, uuidToBytes };
114
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":["uuidv4"],"sources":["../src/utils/converters.ts","../src/utils/genMnemonic.ts","../src/utils/genID.ts"],"sourcesContent":["import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\n/**\n * Converts a Uint8Array into a hexadecimal string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The hexadecimal string representation of the array.\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return bytesToHex(array);\n}\n\n/**\n * Converts a UTF-8 string into a Uint8Array.\n *\n * @param str - The UTF-8 string to convert.\n * @returns A Uint8Array created from the UTF-8 string.\n */\nexport function UTF8ToUint8(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts an Uint8Array into a UTF-8 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The UTF-8 string representation of the array.\n */\nexport function uint8ToUTF8(array: Uint8Array): string {\n return new TextDecoder().decode(array);\n}\n\n/**\n * Converts a hexadecimal string into a Uint8Array.\n *\n * @param hex - The hexadecimal string to convert.\n * @returns A Uint8Array created from the hex string.\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * Converts a Uint8Array into a base64 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The base64 string representation of the array.\n */\nexport function uint8ArrayToBase64(buffer: Uint8Array): string {\n const array = Uint16Array.from(buffer);\n const binaryString = new TextDecoder('UTF-16').decode(array);\n return btoa(binaryString);\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @param str - The base64 string to convert.\n * @returns A Uint8Array created from the base64 string.\n */\nexport function base64ToUint8Array(str: string): Uint8Array {\n const binaryString = atob(str);\n const len = binaryString.length;\n const array = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n array[i] = binaryString.codePointAt(i)!;\n }\n return new Uint8Array(array.buffer);\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english.js';\nimport { AES_KEY_BYTE_LENGTH } from '../constants';\n/**\n * Generates a mnemonic\n *\n * @returns The generated mnemonic.\n */\nexport function genMnemonic(): string {\n return bip39.generateMnemonic(wordlist, AES_KEY_BYTE_LENGTH * 8);\n}\n\n/**\n * Converts a mnemonic to Uint8Array\n *\n * @param mnemonic - The mnemonic to convert\n * @returns The mnemonic as Uint8Array\n */\nexport function mnemonicToBytes(mnemonic: string): Uint8Array {\n return bip39.mnemonicToEntropy(mnemonic, wordlist);\n}\n\n/**\n * Converts a Uint8Array to a mnemonic\n *\n * @param bytes - The bytes to convert\n * @returns The mnemonic string\n */\nexport function bytesToMnemonic(bytes: Uint8Array): string {\n return bip39.entropyToMnemonic(bytes, wordlist);\n}\n","import { v4 as uuidv4, parse, stringify } from 'uuid';\n/**\n * Creates a random identifier.\n *\n * @returns The resulting auxilary string\n */\nexport function generateUuid(): string {\n return uuidv4();\n}\n\nexport function uuidToBytes(uuid: string): Uint8Array {\n return parse(uuid);\n}\n\nexport function bytesToUuid(bytes: Uint8Array): string {\n return stringify(bytes);\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAgB,gBAAgB,OAA2B;AACzD,QAAO,WAAW,MAAM;;;;;;;;AAS1B,SAAgB,YAAY,KAAyB;AACnD,QAAO,IAAI,aAAa,CAAC,OAAO,IAAI;;;;;;;;AAStC,SAAgB,YAAY,OAA2B;AACrD,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;;;;;;;;AASxC,SAAgB,gBAAgB,KAAyB;AACvD,QAAO,WAAW,IAAI;;;;;;;;AASxB,SAAgB,mBAAmB,QAA4B;CAC7D,MAAM,QAAQ,YAAY,KAAK,OAAO;CACtC,MAAM,eAAe,IAAI,YAAY,SAAS,CAAC,OAAO,MAAM;AAC5D,QAAO,KAAK,aAAa;;;;;;;;AAS3B,SAAgB,mBAAmB,KAAyB;CAC1D,MAAM,eAAe,KAAK,IAAI;CAC9B,MAAM,MAAM,aAAa;CACzB,MAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,OAAM,KAAK,aAAa,YAAY,EAAE;AAExC,QAAO,IAAI,WAAW,MAAM,OAAO;;;;;;;;;AC3DrC,SAAgB,cAAsB;AACpC,QAAO,MAAM,iBAAiB,UAAA,IAAkC;;;;;;;;AASlE,SAAgB,gBAAgB,UAA8B;AAC5D,QAAO,MAAM,kBAAkB,UAAU,SAAS;;;;;;;;AASpD,SAAgB,gBAAgB,OAA2B;AACzD,QAAO,MAAM,kBAAkB,OAAO,SAAS;;;;;;;;;ACvBjD,SAAgB,eAAuB;AACrC,QAAOA,IAAQ;;AAGjB,SAAgB,YAAY,MAA0B;AACpD,QAAO,MAAM,KAAK;;AAGpB,SAAgB,YAAY,OAA2B;AACrD,QAAO,UAAU,MAAM"}
@@ -1,6 +1,5 @@
1
- const require_chunk = require('./chunk-EbLFQX5m.js');
1
+ require("./chunk-C13QxCFV.js");
2
2
  let _noble_post_quantum_hybrid_js = require("@noble/post-quantum/hybrid.js");
3
-
4
3
  //#region src/hybrid-crypto/xwing.ts
5
4
  function genHybridKeys(seed) {
6
5
  return _noble_post_quantum_hybrid_js.ml_kem768_x25519.keygen(seed);
@@ -11,24 +10,24 @@ function encapsulateHybrid(publicKey) {
11
10
  function decapsulateHybrid(cipherText, secretKey) {
12
11
  return _noble_post_quantum_hybrid_js.ml_kem768_x25519.decapsulate(cipherText, secretKey);
13
12
  }
14
-
15
13
  //#endregion
16
- Object.defineProperty(exports, 'decapsulateHybrid', {
17
- enumerable: true,
18
- get: function () {
19
- return decapsulateHybrid;
20
- }
14
+ Object.defineProperty(exports, "decapsulateHybrid", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return decapsulateHybrid;
18
+ }
21
19
  });
22
- Object.defineProperty(exports, 'encapsulateHybrid', {
23
- enumerable: true,
24
- get: function () {
25
- return encapsulateHybrid;
26
- }
20
+ Object.defineProperty(exports, "encapsulateHybrid", {
21
+ enumerable: true,
22
+ get: function() {
23
+ return encapsulateHybrid;
24
+ }
27
25
  });
28
- Object.defineProperty(exports, 'genHybridKeys', {
29
- enumerable: true,
30
- get: function () {
31
- return genHybridKeys;
32
- }
26
+ Object.defineProperty(exports, "genHybridKeys", {
27
+ enumerable: true,
28
+ get: function() {
29
+ return genHybridKeys;
30
+ }
33
31
  });
34
- //# sourceMappingURL=xwing-iRWVRtNE.js.map
32
+
33
+ //# sourceMappingURL=xwing-7fEqAT7W.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xwing-iRWVRtNE.js","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;;;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,+CAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,+CAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,+CAAa,YAAY,YAAY,UAAU"}
1
+ {"version":3,"file":"xwing-7fEqAT7W.js","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,8BAAAA,iBAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,8BAAAA,iBAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,8BAAAA,iBAAa,YAAY,YAAY,UAAU"}
@@ -1,5 +1,4 @@
1
1
  import { ml_kem768_x25519 } from "@noble/post-quantum/hybrid.js";
2
-
3
2
  //#region src/hybrid-crypto/xwing.ts
4
3
  function genHybridKeys(seed) {
5
4
  return ml_kem768_x25519.keygen(seed);
@@ -10,7 +9,7 @@ function encapsulateHybrid(publicKey) {
10
9
  function decapsulateHybrid(cipherText, secretKey) {
11
10
  return ml_kem768_x25519.decapsulate(cipherText, secretKey);
12
11
  }
13
-
14
12
  //#endregion
15
13
  export { encapsulateHybrid as n, genHybridKeys as r, decapsulateHybrid as t };
16
- //# sourceMappingURL=xwing-CQmQX6hn.mjs.map
14
+
15
+ //# sourceMappingURL=xwing-B34h5e3Z.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"xwing-CQmQX6hn.mjs","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,iBAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,iBAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,iBAAa,YAAY,YAAY,UAAU"}
1
+ {"version":3,"file":"xwing-B34h5e3Z.mjs","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,iBAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,iBAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,iBAAa,YAAY,YAAY,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "internxt-crypto",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -19,31 +19,31 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@eslint/js": "^10.0.1",
22
- "@internxt/eslint-config-internxt": "2.0.1",
23
- "@internxt/prettier-config": "https://github.com/internxt/prettier-config.git#v1.0.2",
24
- "@playwright/test": "^1.54.2",
25
- "@types/node": "^25.2.3",
26
- "@vitest/browser-playwright": "^4.0.10",
27
- "@vitest/coverage-istanbul": "^4.0.10",
28
- "@vitest/coverage-v8": "^4.0.18",
29
- "eslint": "^10.0.2",
30
- "knip": "^5.84.0",
31
- "lint-staged": "^16.1.4",
32
- "playwright": "^1.54.1",
33
- "prettier": "^3.6.2",
34
- "tsdown": "^0.20.1",
35
- "typescript": "^5.9.3",
36
- "vitest": "^4.0.0"
22
+ "@internxt/eslint-config-internxt": "^2.1.0",
23
+ "@internxt/prettier-config": "^2.0.1",
24
+ "@playwright/test": "^1.59.1",
25
+ "@types/node": "^25.6.0",
26
+ "@vitest/browser-playwright": "^4.1.5",
27
+ "@vitest/coverage-istanbul": "^4.1.5",
28
+ "@vitest/coverage-v8": "^4.1.5",
29
+ "eslint": "^10.3.0",
30
+ "knip": "^6.11.0",
31
+ "lint-staged": "^17.0.2",
32
+ "playwright": "^1.59.1",
33
+ "prettier": "^3.8.3",
34
+ "tsdown": "^0.21.10",
35
+ "typescript": "^6.0.3",
36
+ "vitest": "^4.1.5"
37
37
  },
38
38
  "dependencies": {
39
- "@noble/ciphers": "^2.1.1",
40
- "@noble/curves": "^2.0.1",
41
- "@noble/hashes": "^2.0.1",
42
- "@noble/post-quantum": "^0.5.2",
43
- "@scure/bip39": "^2.0.1",
39
+ "@noble/ciphers": "^2.2.0",
40
+ "@noble/curves": "^2.2.0",
41
+ "@noble/hashes": "^2.2.0",
42
+ "@noble/post-quantum": "^0.6.1",
43
+ "@scure/bip39": "^2.2.0",
44
44
  "hash-wasm": "^4.12.0",
45
45
  "husky": "^9.1.7",
46
- "uuid": "^13.0.0"
46
+ "uuid": "^14.0.0"
47
47
  },
48
48
  "exports": {
49
49
  ".": {
@@ -1,49 +0,0 @@
1
- import { AES_KEY_BYTE_LENGTH, IV_LEN_BYTES } from "./constants.mjs";
2
- import { concatBytes, randomBytes } from "@noble/hashes/utils.js";
3
- import { gcm } from "@noble/ciphers/webcrypto.js";
4
-
5
- //#region src/symmetric-crypto/aes.ts
6
- /**
7
- * Symmetrically encrypts the message
8
- *
9
- * @param encryptionKey - The symmetric key used for message encryption
10
- * @param message - The message to encrypt
11
- * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
12
- * @returns The resulting ciphertext.
13
- */
14
- async function encryptSymmetrically(encryptionKey, message, aux) {
15
- try {
16
- const iv = randomBytes(IV_LEN_BYTES);
17
- return concatBytes(await gcm(encryptionKey, iv, aux).encrypt(message), iv);
18
- } catch (error) {
19
- throw new Error("Failed to encrypt symmetrically", { cause: error });
20
- }
21
- }
22
- /**
23
- * Decryps symmetrically encrypted message
24
- *
25
- * @param encryptionKey - The symmetric key used for message encryption
26
- * @param encryptedMessage - The ciphertext
27
- * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
28
- * @returns The resulting ciphertext.
29
- */
30
- async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
31
- try {
32
- const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);
33
- return await gcm(encryptionKey, encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES), aux).decrypt(ciphertext);
34
- } catch (error) {
35
- throw new Error("Failed to decrypt symmetrically", { cause: error });
36
- }
37
- }
38
- /**
39
- * Generates symmetric key as Uint8Array
40
- *
41
- * @returns The generated Uint8Array.
42
- */
43
- function genSymmetricKey() {
44
- return randomBytes(AES_KEY_BYTE_LENGTH);
45
- }
46
-
47
- //#endregion
48
- export { encryptSymmetrically as n, genSymmetricKey as r, decryptSymmetrically as t };
49
- //# sourceMappingURL=aes-B8TA-JKq.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aes-B8TA-JKq.mjs","names":["aeadCipher"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,KAAK,YAAY,aAAa;AAEpC,SAAO,YADY,MAAMA,IAAW,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAAS,aAAa;AAGpF,SADe,MAAMA,IAAW,eADrB,iBAAiB,MAAM,iBAAiB,SAAS,aAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,QAAO,YAAY,oBAAoB"}
@@ -1,67 +0,0 @@
1
- const require_chunk = require('./chunk-EbLFQX5m.js');
2
- const require_constants = require('./constants.js');
3
- let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
4
- let _noble_ciphers_webcrypto_js = require("@noble/ciphers/webcrypto.js");
5
-
6
- //#region src/symmetric-crypto/aes.ts
7
- /**
8
- * Symmetrically encrypts the message
9
- *
10
- * @param encryptionKey - The symmetric key used for message encryption
11
- * @param message - The message to encrypt
12
- * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
13
- * @returns The resulting ciphertext.
14
- */
15
- async function encryptSymmetrically(encryptionKey, message, aux) {
16
- try {
17
- const iv = (0, _noble_hashes_utils_js.randomBytes)(require_constants.IV_LEN_BYTES);
18
- return (0, _noble_hashes_utils_js.concatBytes)(await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, iv, aux).encrypt(message), iv);
19
- } catch (error) {
20
- throw new Error("Failed to encrypt symmetrically", { cause: error });
21
- }
22
- }
23
- /**
24
- * Decryps symmetrically encrypted message
25
- *
26
- * @param encryptionKey - The symmetric key used for message encryption
27
- * @param encryptedMessage - The ciphertext
28
- * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
29
- * @returns The resulting ciphertext.
30
- */
31
- async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
32
- try {
33
- const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - require_constants.IV_LEN_BYTES);
34
- return await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, encryptedMessage.slice(encryptedMessage.length - require_constants.IV_LEN_BYTES), aux).decrypt(ciphertext);
35
- } catch (error) {
36
- throw new Error("Failed to decrypt symmetrically", { cause: error });
37
- }
38
- }
39
- /**
40
- * Generates symmetric key as Uint8Array
41
- *
42
- * @returns The generated Uint8Array.
43
- */
44
- function genSymmetricKey() {
45
- return (0, _noble_hashes_utils_js.randomBytes)(require_constants.AES_KEY_BYTE_LENGTH);
46
- }
47
-
48
- //#endregion
49
- Object.defineProperty(exports, 'decryptSymmetrically', {
50
- enumerable: true,
51
- get: function () {
52
- return decryptSymmetrically;
53
- }
54
- });
55
- Object.defineProperty(exports, 'encryptSymmetrically', {
56
- enumerable: true,
57
- get: function () {
58
- return encryptSymmetrically;
59
- }
60
- });
61
- Object.defineProperty(exports, 'genSymmetricKey', {
62
- enumerable: true,
63
- get: function () {
64
- return genSymmetricKey;
65
- }
66
- });
67
- //# sourceMappingURL=aes-CuW_SPl-.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aes-CuW_SPl-.js","names":["IV_LEN_BYTES","AES_KEY_BYTE_LENGTH"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,6CAAiBA,+BAAa;AAEpC,iDADmB,2CAAiB,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAASA,+BAAa;AAGpF,SADe,2CAAiB,eADrB,iBAAiB,MAAM,iBAAiB,SAASA,+BAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,gDAAmBC,sCAAoB"}
@@ -1,18 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
14
- return target;
15
- };
16
-
17
- //#endregion
18
- export { __exportAll as t };
@@ -1,60 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
- var __exportAll = (all, no_symbols) => {
10
- let target = {};
11
- for (var name in all) {
12
- __defProp(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- }
17
- if (!no_symbols) {
18
- __defProp(target, Symbol.toStringTag, { value: "Module" });
19
- }
20
- return target;
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
- key = keys[i];
26
- if (!__hasOwnProp.call(to, key) && key !== except) {
27
- __defProp(to, key, {
28
- get: ((k) => from[k]).bind(null, key),
29
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
30
- });
31
- }
32
- }
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
37
- value: mod,
38
- enumerable: true
39
- }) : target, mod));
40
-
41
- //#endregion
42
-
43
- Object.defineProperty(exports, '__commonJSMin', {
44
- enumerable: true,
45
- get: function () {
46
- return __commonJSMin;
47
- }
48
- });
49
- Object.defineProperty(exports, '__exportAll', {
50
- enumerable: true,
51
- get: function () {
52
- return __exportAll;
53
- }
54
- });
55
- Object.defineProperty(exports, '__toESM', {
56
- enumerable: true,
57
- get: function () {
58
- return __toESM;
59
- }
60
- });