react-native-quick-crypto 0.7.3 → 1.0.0-beta.2

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 (309) hide show
  1. package/QuickCrypto.podspec +34 -0
  2. package/README.md +13 -46
  3. package/android/CMakeLists.txt +32 -64
  4. package/android/build.gradle +52 -125
  5. package/android/gradle.properties +4 -4
  6. package/android/src/main/cpp/cpp-adapter.cpp +9 -54
  7. package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +38 -0
  8. package/cpp/random/HybridRandom.cpp +34 -0
  9. package/cpp/random/HybridRandom.hpp +44 -0
  10. package/cpp/utils/Utils.hpp +9 -0
  11. package/ios/QuickCryptoOnLoad.mm +19 -0
  12. package/lib/commonjs/index.js +39 -39
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/random.js +26 -12
  15. package/lib/commonjs/random.js.map +1 -1
  16. package/lib/commonjs/{NativeQuickCrypto/rsa.js → specs/random.nitro.js} +1 -1
  17. package/lib/commonjs/{NativeQuickCrypto/aes.js.map → specs/random.nitro.js.map} +1 -1
  18. package/lib/commonjs/utils/conversion.js +22 -0
  19. package/lib/commonjs/utils/conversion.js.map +1 -0
  20. package/lib/commonjs/utils/index.js +12 -0
  21. package/lib/commonjs/utils/index.js.map +1 -0
  22. package/lib/commonjs/utils/types.js +2 -0
  23. package/lib/{module/NativeQuickCrypto/aes.js.map → commonjs/utils/types.js.map} +1 -1
  24. package/lib/module/index.js +38 -38
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/random.js +26 -12
  27. package/lib/module/random.js.map +1 -1
  28. package/lib/module/specs/random.nitro.js +4 -0
  29. package/lib/module/{NativeQuickCrypto/rsa.js.map → specs/random.nitro.js.map} +1 -1
  30. package/lib/module/utils/conversion.js +16 -0
  31. package/lib/module/utils/conversion.js.map +1 -0
  32. package/lib/module/utils/index.js +8 -0
  33. package/lib/module/utils/index.js.map +1 -0
  34. package/lib/module/utils/types.js +2 -0
  35. package/lib/{commonjs/NativeQuickCrypto/rsa.js.map → module/utils/types.js.map} +1 -1
  36. package/lib/tsconfig.tsbuildinfo +1 -0
  37. package/lib/typescript/index.d.ts +10 -141
  38. package/lib/typescript/index.d.ts.map +1 -1
  39. package/lib/typescript/random.d.ts +4 -5
  40. package/lib/typescript/random.d.ts.map +1 -1
  41. package/lib/typescript/specs/random.nitro.d.ts +9 -0
  42. package/lib/typescript/specs/random.nitro.d.ts.map +1 -0
  43. package/lib/typescript/utils/conversion.d.ts +4 -0
  44. package/lib/typescript/utils/conversion.d.ts.map +1 -0
  45. package/lib/typescript/utils/index.d.ts +6 -0
  46. package/lib/typescript/utils/index.d.ts.map +1 -0
  47. package/lib/typescript/utils/types.d.ts +5 -0
  48. package/lib/typescript/utils/types.d.ts.map +1 -0
  49. package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +45 -0
  50. package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +26 -0
  51. package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +57 -0
  52. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +9 -0
  53. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +25 -0
  54. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +29 -0
  55. package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +23 -0
  56. package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +62 -0
  57. package/package.json +50 -106
  58. package/src/index.ts +38 -48
  59. package/src/random.ts +51 -48
  60. package/src/specs/random.nitro.ts +14 -0
  61. package/src/utils/conversion.ts +16 -0
  62. package/src/utils/index.ts +6 -0
  63. package/src/utils/types.ts +15 -0
  64. package/LICENSE +0 -27
  65. package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +0 -70
  66. package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoPackage.java +0 -25
  67. package/cpp/Cipher/MGLCipherHostObject.cpp +0 -663
  68. package/cpp/Cipher/MGLCipherHostObject.h +0 -90
  69. package/cpp/Cipher/MGLCreateCipherInstaller.cpp +0 -75
  70. package/cpp/Cipher/MGLCreateCipherInstaller.h +0 -22
  71. package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +0 -77
  72. package/cpp/Cipher/MGLCreateDecipherInstaller.h +0 -17
  73. package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +0 -134
  74. package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +0 -35
  75. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +0 -63
  76. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +0 -37
  77. package/cpp/Cipher/MGLPublicCipher.h +0 -124
  78. package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -107
  79. package/cpp/Cipher/MGLRsa.cpp +0 -573
  80. package/cpp/Cipher/MGLRsa.h +0 -109
  81. package/cpp/HMAC/MGLHmacHostObject.cpp +0 -95
  82. package/cpp/HMAC/MGLHmacHostObject.h +0 -39
  83. package/cpp/HMAC/MGLHmacInstaller.cpp +0 -43
  84. package/cpp/HMAC/MGLHmacInstaller.h +0 -20
  85. package/cpp/Hash/MGLHashHostObject.cpp +0 -147
  86. package/cpp/Hash/MGLHashHostObject.h +0 -53
  87. package/cpp/Hash/MGLHashInstaller.cpp +0 -44
  88. package/cpp/Hash/MGLHashInstaller.h +0 -20
  89. package/cpp/JSIUtils/MGLJSIMacros.h +0 -110
  90. package/cpp/JSIUtils/MGLJSIUtils.h +0 -41
  91. package/cpp/JSIUtils/MGLSmartHostObject.cpp +0 -43
  92. package/cpp/JSIUtils/MGLSmartHostObject.h +0 -46
  93. package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +0 -24
  94. package/cpp/JSIUtils/MGLThreadAwareHostObject.h +0 -43
  95. package/cpp/JSIUtils/MGLTypedArray.cpp +0 -325
  96. package/cpp/JSIUtils/MGLTypedArray.h +0 -160
  97. package/cpp/MGLKeys.cpp +0 -1426
  98. package/cpp/MGLKeys.h +0 -203
  99. package/cpp/MGLQuickCryptoHostObject.cpp +0 -127
  100. package/cpp/MGLQuickCryptoHostObject.h +0 -30
  101. package/cpp/Random/MGLRandomHostObject.cpp +0 -96
  102. package/cpp/Random/MGLRandomHostObject.h +0 -27
  103. package/cpp/Sig/MGLSignHostObjects.cpp +0 -757
  104. package/cpp/Sig/MGLSignHostObjects.h +0 -128
  105. package/cpp/Sig/MGLSignInstaller.cpp +0 -24
  106. package/cpp/Sig/MGLSignInstaller.h +0 -29
  107. package/cpp/Sig/MGLVerifyInstaller.cpp +0 -24
  108. package/cpp/Sig/MGLVerifyInstaller.h +0 -22
  109. package/cpp/Utils/MGLDispatchQueue.cpp +0 -75
  110. package/cpp/Utils/MGLDispatchQueue.h +0 -55
  111. package/cpp/Utils/MGLUtils.cpp +0 -295
  112. package/cpp/Utils/MGLUtils.h +0 -358
  113. package/cpp/Utils/base64.h +0 -320
  114. package/cpp/Utils/logs.h +0 -38
  115. package/cpp/Utils/node.h +0 -13
  116. package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +0 -164
  117. package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +0 -29
  118. package/cpp/fastpbkdf2/fastpbkdf2.c +0 -352
  119. package/cpp/fastpbkdf2/fastpbkdf2.h +0 -68
  120. package/cpp/webcrypto/MGLWebCrypto.cpp +0 -125
  121. package/cpp/webcrypto/MGLWebCrypto.h +0 -32
  122. package/cpp/webcrypto/crypto_aes.cpp +0 -516
  123. package/cpp/webcrypto/crypto_aes.h +0 -79
  124. package/cpp/webcrypto/crypto_ec.cpp +0 -424
  125. package/cpp/webcrypto/crypto_ec.h +0 -78
  126. package/cpp/webcrypto/crypto_keygen.cpp +0 -86
  127. package/cpp/webcrypto/crypto_keygen.h +0 -38
  128. package/ios/QuickCrypto.xcodeproj/project.pbxproj +0 -274
  129. package/ios/QuickCryptoModule.h +0 -5
  130. package/ios/QuickCryptoModule.mm +0 -42
  131. package/lib/commonjs/Cipher.js +0 -502
  132. package/lib/commonjs/Cipher.js.map +0 -1
  133. package/lib/commonjs/Hash.js +0 -99
  134. package/lib/commonjs/Hash.js.map +0 -1
  135. package/lib/commonjs/Hashnames.js +0 -87
  136. package/lib/commonjs/Hashnames.js.map +0 -1
  137. package/lib/commonjs/Hmac.js +0 -79
  138. package/lib/commonjs/Hmac.js.map +0 -1
  139. package/lib/commonjs/NativeQuickCrypto/Cipher.js +0 -30
  140. package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +0 -1
  141. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +0 -52
  142. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
  143. package/lib/commonjs/NativeQuickCrypto/aes.js +0 -6
  144. package/lib/commonjs/NativeQuickCrypto/hash.js +0 -2
  145. package/lib/commonjs/NativeQuickCrypto/hash.js.map +0 -1
  146. package/lib/commonjs/NativeQuickCrypto/hmac.js +0 -2
  147. package/lib/commonjs/NativeQuickCrypto/hmac.js.map +0 -1
  148. package/lib/commonjs/NativeQuickCrypto/keygen.js +0 -6
  149. package/lib/commonjs/NativeQuickCrypto/keygen.js.map +0 -1
  150. package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +0 -2
  151. package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +0 -1
  152. package/lib/commonjs/NativeQuickCrypto/random.js +0 -2
  153. package/lib/commonjs/NativeQuickCrypto/random.js.map +0 -1
  154. package/lib/commonjs/NativeQuickCrypto/sig.js +0 -19
  155. package/lib/commonjs/NativeQuickCrypto/sig.js.map +0 -1
  156. package/lib/commonjs/NativeQuickCrypto/webcrypto.js +0 -6
  157. package/lib/commonjs/NativeQuickCrypto/webcrypto.js.map +0 -1
  158. package/lib/commonjs/Utils.js +0 -608
  159. package/lib/commonjs/Utils.js.map +0 -1
  160. package/lib/commonjs/aes.js +0 -281
  161. package/lib/commonjs/aes.js.map +0 -1
  162. package/lib/commonjs/constants.js +0 -85
  163. package/lib/commonjs/constants.js.map +0 -1
  164. package/lib/commonjs/ec.js +0 -276
  165. package/lib/commonjs/ec.js.map +0 -1
  166. package/lib/commonjs/keygen.js +0 -56
  167. package/lib/commonjs/keygen.js.map +0 -1
  168. package/lib/commonjs/keys.js +0 -492
  169. package/lib/commonjs/keys.js.map +0 -1
  170. package/lib/commonjs/pbkdf2.js +0 -90
  171. package/lib/commonjs/pbkdf2.js.map +0 -1
  172. package/lib/commonjs/rsa.js +0 -248
  173. package/lib/commonjs/rsa.js.map +0 -1
  174. package/lib/commonjs/sig.js +0 -129
  175. package/lib/commonjs/sig.js.map +0 -1
  176. package/lib/commonjs/subtle.js +0 -448
  177. package/lib/commonjs/subtle.js.map +0 -1
  178. package/lib/commonjs/webcrypto.js +0 -14
  179. package/lib/commonjs/webcrypto.js.map +0 -1
  180. package/lib/module/Cipher.js +0 -491
  181. package/lib/module/Cipher.js.map +0 -1
  182. package/lib/module/Hash.js +0 -93
  183. package/lib/module/Hash.js.map +0 -1
  184. package/lib/module/Hashnames.js +0 -85
  185. package/lib/module/Hashnames.js.map +0 -1
  186. package/lib/module/Hmac.js +0 -74
  187. package/lib/module/Hmac.js.map +0 -1
  188. package/lib/module/NativeQuickCrypto/Cipher.js +0 -26
  189. package/lib/module/NativeQuickCrypto/Cipher.js.map +0 -1
  190. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +0 -49
  191. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
  192. package/lib/module/NativeQuickCrypto/aes.js +0 -4
  193. package/lib/module/NativeQuickCrypto/hash.js +0 -2
  194. package/lib/module/NativeQuickCrypto/hash.js.map +0 -1
  195. package/lib/module/NativeQuickCrypto/hmac.js +0 -2
  196. package/lib/module/NativeQuickCrypto/hmac.js.map +0 -1
  197. package/lib/module/NativeQuickCrypto/keygen.js +0 -4
  198. package/lib/module/NativeQuickCrypto/keygen.js.map +0 -1
  199. package/lib/module/NativeQuickCrypto/pbkdf2.js +0 -2
  200. package/lib/module/NativeQuickCrypto/pbkdf2.js.map +0 -1
  201. package/lib/module/NativeQuickCrypto/random.js +0 -2
  202. package/lib/module/NativeQuickCrypto/random.js.map +0 -1
  203. package/lib/module/NativeQuickCrypto/rsa.js +0 -4
  204. package/lib/module/NativeQuickCrypto/sig.js +0 -17
  205. package/lib/module/NativeQuickCrypto/sig.js.map +0 -1
  206. package/lib/module/NativeQuickCrypto/webcrypto.js +0 -4
  207. package/lib/module/NativeQuickCrypto/webcrypto.js.map +0 -1
  208. package/lib/module/Utils.js +0 -539
  209. package/lib/module/Utils.js.map +0 -1
  210. package/lib/module/aes.js +0 -274
  211. package/lib/module/aes.js.map +0 -1
  212. package/lib/module/constants.js +0 -81
  213. package/lib/module/constants.js.map +0 -1
  214. package/lib/module/ec.js +0 -267
  215. package/lib/module/ec.js.map +0 -1
  216. package/lib/module/keygen.js +0 -49
  217. package/lib/module/keygen.js.map +0 -1
  218. package/lib/module/keys.js +0 -477
  219. package/lib/module/keys.js.map +0 -1
  220. package/lib/module/pbkdf2.js +0 -84
  221. package/lib/module/pbkdf2.js.map +0 -1
  222. package/lib/module/rsa.js +0 -242
  223. package/lib/module/rsa.js.map +0 -1
  224. package/lib/module/sig.js +0 -124
  225. package/lib/module/sig.js.map +0 -1
  226. package/lib/module/subtle.js +0 -443
  227. package/lib/module/subtle.js.map +0 -1
  228. package/lib/module/webcrypto.js +0 -10
  229. package/lib/module/webcrypto.js.map +0 -1
  230. package/lib/typescript/Cipher.d.ts +0 -81
  231. package/lib/typescript/Cipher.d.ts.map +0 -1
  232. package/lib/typescript/Hash.d.ts +0 -44
  233. package/lib/typescript/Hash.d.ts.map +0 -1
  234. package/lib/typescript/Hashnames.d.ts +0 -11
  235. package/lib/typescript/Hashnames.d.ts.map +0 -1
  236. package/lib/typescript/Hmac.d.ts +0 -37
  237. package/lib/typescript/Hmac.d.ts.map +0 -1
  238. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +0 -44
  239. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts.map +0 -1
  240. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +0 -33
  241. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +0 -1
  242. package/lib/typescript/NativeQuickCrypto/aes.d.ts +0 -5
  243. package/lib/typescript/NativeQuickCrypto/aes.d.ts.map +0 -1
  244. package/lib/typescript/NativeQuickCrypto/hash.d.ts +0 -7
  245. package/lib/typescript/NativeQuickCrypto/hash.d.ts.map +0 -1
  246. package/lib/typescript/NativeQuickCrypto/hmac.d.ts +0 -6
  247. package/lib/typescript/NativeQuickCrypto/hmac.d.ts.map +0 -1
  248. package/lib/typescript/NativeQuickCrypto/keygen.d.ts +0 -4
  249. package/lib/typescript/NativeQuickCrypto/keygen.d.ts.map +0 -1
  250. package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts +0 -5
  251. package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts.map +0 -1
  252. package/lib/typescript/NativeQuickCrypto/random.d.ts +0 -5
  253. package/lib/typescript/NativeQuickCrypto/random.d.ts.map +0 -1
  254. package/lib/typescript/NativeQuickCrypto/rsa.d.ts +0 -5
  255. package/lib/typescript/NativeQuickCrypto/rsa.d.ts.map +0 -1
  256. package/lib/typescript/NativeQuickCrypto/sig.d.ts +0 -23
  257. package/lib/typescript/NativeQuickCrypto/sig.d.ts.map +0 -1
  258. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts +0 -39
  259. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts.map +0 -1
  260. package/lib/typescript/Utils.d.ts +0 -48
  261. package/lib/typescript/Utils.d.ts.map +0 -1
  262. package/lib/typescript/aes.d.ts +0 -22
  263. package/lib/typescript/aes.d.ts.map +0 -1
  264. package/lib/typescript/constants.d.ts +0 -76
  265. package/lib/typescript/constants.d.ts.map +0 -1
  266. package/lib/typescript/ec.d.ts +0 -7
  267. package/lib/typescript/ec.d.ts.map +0 -1
  268. package/lib/typescript/keygen.d.ts +0 -6
  269. package/lib/typescript/keygen.d.ts.map +0 -1
  270. package/lib/typescript/keys.d.ts +0 -206
  271. package/lib/typescript/keys.d.ts.map +0 -1
  272. package/lib/typescript/pbkdf2.d.ts +0 -12
  273. package/lib/typescript/pbkdf2.d.ts.map +0 -1
  274. package/lib/typescript/rsa.d.ts +0 -12
  275. package/lib/typescript/rsa.d.ts.map +0 -1
  276. package/lib/typescript/sig.d.ts +0 -21
  277. package/lib/typescript/sig.d.ts.map +0 -1
  278. package/lib/typescript/subtle.d.ts +0 -15
  279. package/lib/typescript/subtle.d.ts.map +0 -1
  280. package/lib/typescript/webcrypto.d.ts +0 -9
  281. package/lib/typescript/webcrypto.d.ts.map +0 -1
  282. package/react-native-quick-crypto.podspec +0 -40
  283. package/src/Cipher.ts +0 -832
  284. package/src/Hash.ts +0 -132
  285. package/src/Hashnames.ts +0 -93
  286. package/src/Hmac.ts +0 -106
  287. package/src/NativeQuickCrypto/Cipher.ts +0 -102
  288. package/src/NativeQuickCrypto/NativeQuickCrypto.ts +0 -102
  289. package/src/NativeQuickCrypto/aes.ts +0 -14
  290. package/src/NativeQuickCrypto/hash.ts +0 -10
  291. package/src/NativeQuickCrypto/hmac.ts +0 -9
  292. package/src/NativeQuickCrypto/keygen.ts +0 -7
  293. package/src/NativeQuickCrypto/pbkdf2.ts +0 -16
  294. package/src/NativeQuickCrypto/random.ts +0 -12
  295. package/src/NativeQuickCrypto/rsa.ts +0 -12
  296. package/src/NativeQuickCrypto/sig.ts +0 -44
  297. package/src/NativeQuickCrypto/webcrypto.ts +0 -72
  298. package/src/Utils.ts +0 -777
  299. package/src/aes.ts +0 -402
  300. package/src/constants.ts +0 -79
  301. package/src/ec.ts +0 -375
  302. package/src/keygen.ts +0 -80
  303. package/src/keys.ts +0 -787
  304. package/src/pbkdf2.ts +0 -169
  305. package/src/rsa.ts +0 -370
  306. package/src/sig.ts +0 -164
  307. package/src/subtle.ts +0 -639
  308. package/src/webcrypto.ts +0 -8
  309. /package/android/src/main/{AndroidManifestNew.xml → AndroidManifest.xml} +0 -0
@@ -1,491 +0,0 @@
1
- "use strict";
2
-
3
- import { NativeQuickCrypto } from './NativeQuickCrypto/NativeQuickCrypto';
4
- import Stream from 'readable-stream';
5
- import { binaryLikeToArrayBuffer, getDefaultEncoding, kEmptyObject, validateFunction, validateObject, validateString, validateUint32, validateInt32 } from './Utils';
6
- import { KeyVariant } from './NativeQuickCrypto/Cipher';
7
- // @types/node
8
- import { StringDecoder } from 'string_decoder';
9
- import { Buffer } from '@craftzdog/react-native-buffer';
10
- import { Buffer as SBuffer } from 'safe-buffer';
11
- import { constants } from './constants';
12
- import { parsePrivateKeyEncoding, parsePublicKeyEncoding, preparePrivateKey, preparePublicOrPrivateKey } from './keys';
13
- export let ECCurve = /*#__PURE__*/function (ECCurve) {
14
- ECCurve[ECCurve["OPENSSL_EC_EXPLICIT_CURVE"] = 0] = "OPENSSL_EC_EXPLICIT_CURVE";
15
- ECCurve[ECCurve["OPENSSL_EC_NAMED_CURVE"] = 1] = "OPENSSL_EC_NAMED_CURVE";
16
- return ECCurve;
17
- }({});
18
-
19
- // make sure that nextTick is there
20
- global.process.nextTick = setImmediate;
21
- const createInternalCipher = NativeQuickCrypto.createCipher;
22
- const createInternalDecipher = NativeQuickCrypto.createDecipher;
23
- const _publicEncrypt = NativeQuickCrypto.publicEncrypt;
24
- const _publicDecrypt = NativeQuickCrypto.publicDecrypt;
25
- const _privateDecrypt = NativeQuickCrypto.privateDecrypt;
26
- function getUIntOption(options, key) {
27
- let value;
28
- if (options && (value = options[key]) != null) {
29
- // >>> Turns any type into a positive integer (also sets the sign bit to 0)
30
- // eslint-disable-next-line no-bitwise
31
- if (value >>> 0 !== value) throw new Error(`options.${key}: ${value}`);
32
- return value;
33
- }
34
- return -1;
35
- }
36
- function normalizeEncoding(enc) {
37
- if (!enc) return 'utf8';
38
- var retried;
39
- while (true) {
40
- switch (enc) {
41
- case 'utf8':
42
- case 'utf-8':
43
- return 'utf8';
44
- case 'ucs2':
45
- case 'ucs-2':
46
- case 'utf16le':
47
- case 'utf-16le':
48
- return 'utf16le';
49
- case 'latin1':
50
- case 'binary':
51
- return 'latin1';
52
- case 'base64':
53
- case 'ascii':
54
- case 'hex':
55
- return enc;
56
- default:
57
- if (retried) return; // undefined
58
- enc = ('' + enc).toLowerCase();
59
- retried = true;
60
- }
61
- }
62
- }
63
- function validateEncoding(data, encoding) {
64
- const normalizedEncoding = normalizeEncoding(encoding);
65
- const length = data.length;
66
- if (normalizedEncoding === 'hex' && length % 2 !== 0) {
67
- throw new Error(`Encoding ${encoding} not valid for data length ${length}`);
68
- }
69
- }
70
- function getDecoder(decoder, encoding) {
71
- return decoder ?? new StringDecoder(encoding);
72
- }
73
- class CipherCommon extends Stream.Transform {
74
- constructor(cipherType, cipherKey, isCipher, options = {}, iv) {
75
- super(options);
76
- const cipherKeyBuffer = binaryLikeToArrayBuffer(cipherKey);
77
- // defaults to 16 bytes
78
- const authTagLength = getUIntOption(options, 'authTagLength') !== -1 ? getUIntOption(options, 'authTagLength') : 16;
79
- const args = {
80
- cipher_type: cipherType,
81
- cipher_key: cipherKeyBuffer,
82
- iv,
83
- ...options,
84
- auth_tag_len: authTagLength
85
- };
86
- this.internal = isCipher ? createInternalCipher(args) : createInternalDecipher(args);
87
- }
88
- update(data, inputEncoding, outputEncoding) {
89
- const defaultEncoding = getDefaultEncoding();
90
- inputEncoding = inputEncoding ?? defaultEncoding;
91
- outputEncoding = outputEncoding ?? defaultEncoding;
92
- if (typeof data === 'string') {
93
- validateEncoding(data, inputEncoding);
94
- } else if (!ArrayBuffer.isView(data)) {
95
- throw new Error('Invalid data argument');
96
- }
97
- if (typeof data === 'string') {
98
- // On node this is handled on the native side
99
- // on our case we need to correctly send the arraybuffer to the jsi side
100
- inputEncoding = inputEncoding === 'buffer' ? 'utf8' : inputEncoding;
101
- data = binaryLikeToArrayBuffer(data, inputEncoding);
102
- } else {
103
- data = binaryLikeToArrayBuffer(data, inputEncoding);
104
- }
105
- const ret = this.internal.update(data);
106
- if (outputEncoding && outputEncoding !== 'buffer') {
107
- this.decoder = getDecoder(this.decoder, outputEncoding);
108
- return this.decoder.write(SBuffer.from(ret));
109
- }
110
- return ret;
111
- }
112
- final(outputEncoding) {
113
- const ret = this.internal.final();
114
- if (outputEncoding && outputEncoding !== 'buffer') {
115
- this.decoder = getDecoder(this.decoder, outputEncoding);
116
- return this.decoder.end(SBuffer.from(ret));
117
- }
118
- return ret;
119
- }
120
- _transform(chunk, encoding, callback) {
121
- this.push(this.update(chunk, encoding));
122
- callback();
123
- }
124
- _flush(callback) {
125
- this.push(this.final());
126
- callback();
127
- }
128
- setAutoPadding(autoPadding) {
129
- this.internal.setAutoPadding(!!autoPadding);
130
- return this;
131
- }
132
- setAAD(buffer, options) {
133
- this.internal.setAAD({
134
- data: buffer.buffer,
135
- plaintextLength: options?.plaintextLength
136
- });
137
- return this;
138
- }
139
- getAuthTag() {
140
- return this.internal.getAuthTag();
141
- }
142
- setAuthTag(tag) {
143
- this.internal.setAuthTag(binaryLikeToArrayBuffer(tag));
144
- return this;
145
- }
146
- }
147
- class Cipher extends CipherCommon {
148
- constructor(cipherType, cipherKey, options = {}, iv) {
149
- if (iv != null) {
150
- iv = binaryLikeToArrayBuffer(iv);
151
- }
152
- super(cipherType, cipherKey, true, options, iv);
153
- }
154
- }
155
- class Decipher extends CipherCommon {
156
- constructor(cipherType, cipherKey, options = {}, iv) {
157
- if (iv != null) {
158
- iv = binaryLikeToArrayBuffer(iv);
159
- }
160
- super(cipherType, cipherKey, false, options, iv);
161
- }
162
- }
163
- export function createDecipher(algorithm, password, options) {
164
- return new Decipher(algorithm, password, options);
165
- }
166
- export function createDecipheriv(algorithm, key, iv, options) {
167
- return new Decipher(algorithm, key, options, iv);
168
- }
169
- export function createCipher(algorithm, password, options) {
170
- return new Cipher(algorithm, password, options);
171
- }
172
- export function createCipheriv(algorithm, key, iv, options) {
173
- return new Cipher(algorithm, key, options, iv);
174
- }
175
-
176
- // RSA Functions
177
- // Follows closely the model implemented in node
178
-
179
- // TODO(osp) types...
180
- function rsaFunctionFor(method, defaultPadding, keyType) {
181
- return (options, buffer) => {
182
- const {
183
- format,
184
- type,
185
- data,
186
- passphrase
187
- } = keyType === 'private' ? preparePrivateKey(options) : preparePublicOrPrivateKey(options);
188
- const padding = options.padding || defaultPadding;
189
- const {
190
- oaepHash,
191
- encoding
192
- } = options;
193
- let {
194
- oaepLabel
195
- } = options;
196
- if (oaepHash !== undefined) validateString(oaepHash, 'key.oaepHash');
197
- if (oaepLabel !== undefined) oaepLabel = binaryLikeToArrayBuffer(oaepLabel, encoding);
198
- buffer = binaryLikeToArrayBuffer(buffer, encoding);
199
- const rawRes = method(data, format, type, passphrase, buffer, padding, oaepHash, oaepLabel);
200
- return Buffer.from(rawRes);
201
- };
202
- }
203
- export const publicEncrypt = rsaFunctionFor(_publicEncrypt, constants.RSA_PKCS1_OAEP_PADDING, 'public');
204
- export const publicDecrypt = rsaFunctionFor(_publicDecrypt, constants.RSA_PKCS1_PADDING, 'public');
205
- // const privateEncrypt = rsaFunctionFor(_privateEncrypt, constants.RSA_PKCS1_PADDING,
206
- // 'private');
207
- export const privateDecrypt = rsaFunctionFor(_privateDecrypt, constants.RSA_PKCS1_OAEP_PADDING, 'private');
208
-
209
- // _ _ __ _____ _
210
- // | | | |/ / | __ \ (_)
211
- // __ _ ___ _ __ ___ _ __ __ _| |_ ___| ' / ___ _ _| |__) |_ _ _ _ __
212
- // / _` |/ _ \ '_ \ / _ \ '__/ _` | __/ _ \ < / _ \ | | | ___/ _` | | '__|
213
- // | (_| | __/ | | | __/ | | (_| | || __/ . \ __/ |_| | | | (_| | | |
214
- // \__, |\___|_| |_|\___|_| \__,_|\__\___|_|\_\___|\__, |_| \__,_|_|_|
215
- // __/ | __/ |
216
- // |___/ |___/
217
-
218
- function parseKeyEncoding(keyType, options = kEmptyObject) {
219
- const {
220
- publicKeyEncoding,
221
- privateKeyEncoding
222
- } = options;
223
- let publicFormat, publicType;
224
- if (publicKeyEncoding == null) {
225
- publicFormat = publicType = undefined;
226
- } else if (typeof publicKeyEncoding === 'object') {
227
- ({
228
- format: publicFormat,
229
- type: publicType
230
- } = parsePublicKeyEncoding(publicKeyEncoding, keyType, 'publicKeyEncoding'));
231
- } else {
232
- throw new Error('Invalid argument options.publicKeyEncoding', publicKeyEncoding);
233
- }
234
- let privateFormat, privateType, cipher, passphrase;
235
- if (privateKeyEncoding == null) {
236
- privateFormat = privateType = undefined;
237
- } else if (typeof privateKeyEncoding === 'object') {
238
- ({
239
- format: privateFormat,
240
- type: privateType,
241
- cipher,
242
- passphrase
243
- } = parsePrivateKeyEncoding(privateKeyEncoding, keyType, 'privateKeyEncoding'));
244
- } else {
245
- throw new Error('Invalid argument options.privateKeyEncoding', publicKeyEncoding);
246
- }
247
- return [publicFormat, publicType, privateFormat, privateType, cipher, passphrase];
248
- }
249
-
250
- /** On node a very complex "job" chain is created, we are going for a far simpler approach and calling
251
- * an internal function that basically executes the same byte shuffling on the native side
252
- */
253
- function internalGenerateKeyPair(isAsync, type, options, callback) {
254
- const encoding = parseKeyEncoding(type, options);
255
-
256
- // if (options !== undefined)
257
- // validateObject(options, 'options');
258
-
259
- switch (type) {
260
- case 'rsa-pss':
261
- // fallthrough
262
- case 'rsa':
263
- validateObject(options, 'options');
264
- const {
265
- modulusLength
266
- } = options;
267
- validateUint32(modulusLength, 'options.modulusLength');
268
- let {
269
- publicExponent
270
- } = options;
271
- if (publicExponent == null) {
272
- publicExponent = 0x10001;
273
- } else {
274
- validateUint32(publicExponent, 'options.publicExponent');
275
- }
276
- if (type === 'rsa') {
277
- if (isAsync) {
278
- NativeQuickCrypto.generateKeyPair(KeyVariant.RSA_SSA_PKCS1_v1_5,
279
- // Used also for RSA-OAEP
280
- modulusLength, publicExponent, ...encoding).then(([err, publicKey, privateKey]) => {
281
- if (publicKey instanceof Buffer) {
282
- publicKey = Buffer.from(publicKey);
283
- }
284
- if (privateKey instanceof Buffer) {
285
- privateKey = Buffer.from(privateKey);
286
- }
287
- callback(err, publicKey, privateKey);
288
- }).catch(err => {
289
- callback(err, undefined, undefined);
290
- });
291
- } else {
292
- let [err, publicKey, privateKey] = NativeQuickCrypto.generateKeyPairSync(KeyVariant.RSA_SSA_PKCS1_v1_5, modulusLength, publicExponent, ...encoding);
293
- if (publicKey instanceof Buffer) {
294
- publicKey = Buffer.from(publicKey);
295
- }
296
- if (privateKey instanceof Buffer) {
297
- privateKey = Buffer.from(privateKey);
298
- }
299
- return [err, publicKey, privateKey];
300
- }
301
- }
302
- const {
303
- hash,
304
- mgf1Hash,
305
- hashAlgorithm,
306
- mgf1HashAlgorithm,
307
- saltLength
308
- } = options;
309
-
310
- // // We don't have a process object on RN
311
- // // const pendingDeprecation = getOptionValue('--pending-deprecation');
312
-
313
- if (saltLength !== undefined) validateInt32(saltLength, 'options.saltLength', 0);
314
- if (hashAlgorithm !== undefined) validateString(hashAlgorithm, 'options.hashAlgorithm');
315
- if (mgf1HashAlgorithm !== undefined) validateString(mgf1HashAlgorithm, 'options.mgf1HashAlgorithm');
316
- if (hash !== undefined) {
317
- // pendingDeprecation && process.emitWarning(
318
- // '"options.hash" is deprecated, ' +
319
- // 'use "options.hashAlgorithm" instead.',
320
- // 'DeprecationWarning',
321
- // 'DEP0154');
322
- validateString(hash, 'options.hash');
323
- if (hashAlgorithm && hash !== hashAlgorithm) {
324
- throw new Error(`Invalid Argument options.hash ${hash}`);
325
- }
326
- }
327
- if (mgf1Hash !== undefined) {
328
- // pendingDeprecation && process.emitWarning(
329
- // '"options.mgf1Hash" is deprecated, ' +
330
- // 'use "options.mgf1HashAlgorithm" instead.',
331
- // 'DeprecationWarning',
332
- // 'DEP0154');
333
- validateString(mgf1Hash, 'options.mgf1Hash');
334
- if (mgf1HashAlgorithm && mgf1Hash !== mgf1HashAlgorithm) {
335
- throw new Error(`Invalid Argument options.mgf1Hash ${mgf1Hash}`);
336
- }
337
- }
338
- return NativeQuickCrypto.generateKeyPairSync(KeyVariant.RSA_PSS, modulusLength, publicExponent, hashAlgorithm || hash, mgf1HashAlgorithm || mgf1Hash, saltLength, ...encoding);
339
-
340
- // case 'dsa': {
341
- // validateObject(options, 'options');
342
- // const { modulusLength } = options!;
343
- // validateUint32(modulusLength, 'options.modulusLength');
344
-
345
- // let { divisorLength } = options!;
346
- // if (divisorLength == null) {
347
- // divisorLength = -1;
348
- // } else validateInt32(divisorLength, 'options.divisorLength', 0);
349
-
350
- // // return new DsaKeyPairGenJob(
351
- // // mode,
352
- // // modulusLength,
353
- // // divisorLength,
354
- // // ...encoding);
355
- // }
356
-
357
- case 'ec':
358
- validateObject(options, 'options');
359
- const {
360
- namedCurve
361
- } = options;
362
- validateString(namedCurve, 'options.namedCurve');
363
- let paramEncodingFlag = ECCurve.OPENSSL_EC_NAMED_CURVE;
364
- const {
365
- paramEncoding
366
- } = options;
367
- if (paramEncoding == null || paramEncoding === 'named') paramEncodingFlag = ECCurve.OPENSSL_EC_NAMED_CURVE;else if (paramEncoding === 'explicit') paramEncodingFlag = ECCurve.OPENSSL_EC_EXPLICIT_CURVE;else throw new Error(`Invalid Argument options.paramEncoding ${paramEncoding}`);
368
- if (isAsync) {
369
- NativeQuickCrypto.generateKeyPair(KeyVariant.EC, namedCurve, paramEncodingFlag, ...encoding).then(([err, publicKey, privateKey]) => {
370
- if (publicKey instanceof Buffer) {
371
- publicKey = Buffer.from(publicKey);
372
- }
373
- if (privateKey instanceof Buffer) {
374
- privateKey = Buffer.from(privateKey);
375
- }
376
- callback?.(err, publicKey, privateKey);
377
- }).catch(err => {
378
- callback?.(err, undefined, undefined);
379
- });
380
- }
381
- let [err, publicKey, privateKey] = NativeQuickCrypto.generateKeyPairSync(KeyVariant.EC, namedCurve, paramEncodingFlag, ...encoding);
382
- if (publicKey instanceof Buffer) {
383
- publicKey = Buffer.from(publicKey);
384
- }
385
- if (privateKey instanceof Buffer) {
386
- privateKey = Buffer.from(privateKey);
387
- }
388
- return [err, publicKey, privateKey];
389
-
390
- // case 'ed25519':
391
- // case 'ed448':
392
- // case 'x25519':
393
- // case 'x448': {
394
- // let id;
395
- // switch (type) {
396
- // case 'ed25519':
397
- // id = EVP_PKEY_ED25519;
398
- // break;
399
- // case 'ed448':
400
- // id = EVP_PKEY_ED448;
401
- // break;
402
- // case 'x25519':
403
- // id = EVP_PKEY_X25519;
404
- // break;
405
- // case 'x448':
406
- // id = EVP_PKEY_X448;
407
- // break;
408
- // }
409
- // return new NidKeyPairGenJob(mode, id, ...encoding);
410
- // }
411
- // case 'dh': {
412
- // validateObject(options, 'options');
413
- // const { group, primeLength, prime, generator } = options;
414
- // if (group != null) {
415
- // if (prime != null)
416
- // throw new ERR_INCOMPATIBLE_OPTION_PAIR('group', 'prime');
417
- // if (primeLength != null)
418
- // throw new ERR_INCOMPATIBLE_OPTION_PAIR('group', 'primeLength');
419
- // if (generator != null)
420
- // throw new ERR_INCOMPATIBLE_OPTION_PAIR('group', 'generator');
421
-
422
- // validateString(group, 'options.group');
423
-
424
- // return new DhKeyPairGenJob(mode, group, ...encoding);
425
- // }
426
-
427
- // if (prime != null) {
428
- // if (primeLength != null)
429
- // throw new ERR_INCOMPATIBLE_OPTION_PAIR('prime', 'primeLength');
430
-
431
- // validateBuffer(prime, 'options.prime');
432
- // } else if (primeLength != null) {
433
- // validateInt32(primeLength, 'options.primeLength', 0);
434
- // } else {
435
- // throw new ERR_MISSING_OPTION(
436
- // 'At least one of the group, prime, or primeLength options'
437
- // );
438
- // }
439
-
440
- // if (generator != null) {
441
- // validateInt32(generator, 'options.generator', 0);
442
- // }
443
- // return new DhKeyPairGenJob(
444
- // mode,
445
- // prime != null ? prime : primeLength,
446
- // generator == null ? 2 : generator,
447
- // ...encoding
448
- // );
449
- // }
450
- default:
451
- // Fall through
452
- }
453
- const err = new Error(`
454
- Invalid Argument options: '${type}' scheme not supported for generateKey().
455
- Currently not all encryption methods are supported in quick-crypto. Check
456
- implementation_coverage.md for status.
457
- `);
458
- return [err, undefined, undefined];
459
- }
460
- export const generateKeyPair = (type, options, callback) => {
461
- validateFunction(callback);
462
- internalGenerateKeyPair(true, type, options, callback);
463
- };
464
-
465
- // Promisify generateKeyPair
466
- // (attempted to use util.promisify, to no avail)
467
- export const generateKeyPairPromise = (type, options) => {
468
- return new Promise((resolve, reject) => {
469
- generateKeyPair(type, options, (err, publicKey, privateKey) => {
470
- if (err) {
471
- reject([err, undefined]);
472
- } else {
473
- resolve([undefined, {
474
- publicKey,
475
- privateKey
476
- }]);
477
- }
478
- });
479
- });
480
- };
481
-
482
- // generateKeyPairSync
483
-
484
- export function generateKeyPairSync(type, options) {
485
- const [_, publicKey, privateKey] = internalGenerateKeyPair(false, type, options, undefined);
486
- return {
487
- publicKey,
488
- privateKey
489
- };
490
- }
491
- //# sourceMappingURL=Cipher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["NativeQuickCrypto","Stream","binaryLikeToArrayBuffer","getDefaultEncoding","kEmptyObject","validateFunction","validateObject","validateString","validateUint32","validateInt32","KeyVariant","StringDecoder","Buffer","SBuffer","constants","parsePrivateKeyEncoding","parsePublicKeyEncoding","preparePrivateKey","preparePublicOrPrivateKey","ECCurve","global","process","nextTick","setImmediate","createInternalCipher","createCipher","createInternalDecipher","createDecipher","_publicEncrypt","publicEncrypt","_publicDecrypt","publicDecrypt","_privateDecrypt","privateDecrypt","getUIntOption","options","key","value","Error","normalizeEncoding","enc","retried","toLowerCase","validateEncoding","data","encoding","normalizedEncoding","length","getDecoder","decoder","CipherCommon","Transform","constructor","cipherType","cipherKey","isCipher","iv","cipherKeyBuffer","authTagLength","args","cipher_type","cipher_key","auth_tag_len","internal","update","inputEncoding","outputEncoding","defaultEncoding","ArrayBuffer","isView","ret","write","from","final","end","_transform","chunk","callback","push","_flush","setAutoPadding","autoPadding","setAAD","buffer","plaintextLength","getAuthTag","setAuthTag","tag","Cipher","Decipher","algorithm","password","createDecipheriv","createCipheriv","rsaFunctionFor","method","defaultPadding","keyType","format","type","passphrase","padding","oaepHash","oaepLabel","undefined","rawRes","RSA_PKCS1_OAEP_PADDING","RSA_PKCS1_PADDING","parseKeyEncoding","publicKeyEncoding","privateKeyEncoding","publicFormat","publicType","privateFormat","privateType","cipher","internalGenerateKeyPair","isAsync","modulusLength","publicExponent","generateKeyPair","RSA_SSA_PKCS1_v1_5","then","err","publicKey","privateKey","catch","generateKeyPairSync","hash","mgf1Hash","hashAlgorithm","mgf1HashAlgorithm","saltLength","RSA_PSS","namedCurve","paramEncodingFlag","OPENSSL_EC_NAMED_CURVE","paramEncoding","OPENSSL_EC_EXPLICIT_CURVE","EC","generateKeyPairPromise","Promise","resolve","reject","_"],"sourceRoot":"../../src","sources":["Cipher.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,uCAAuC;AACzE,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAEEC,uBAAuB,EAGvBC,kBAAkB,EAClBC,YAAY,EACZC,gBAAgB,EAChBC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,aAAa,QAER,SAAS;AAChB,SAA8BC,UAAU,QAAQ,4BAA4B;AAc3D;AACjB,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,MAAM,QAAQ,gCAAgC;AACvD,SAASA,MAAM,IAAIC,OAAO,QAAQ,aAAa;AAC/C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAEEC,uBAAuB,EACvBC,sBAAsB,EACtBC,iBAAiB,EACjBC,yBAAyB,QAIpB,QAAQ;AAGf,WAAYC,OAAO,0BAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;;AAKnB;AACAC,MAAM,CAACC,OAAO,CAACC,QAAQ,GAAGC,YAAY;AAEtC,MAAMC,oBAAoB,GAAGxB,iBAAiB,CAACyB,YAAY;AAC3D,MAAMC,sBAAsB,GAAG1B,iBAAiB,CAAC2B,cAAc;AAC/D,MAAMC,cAAc,GAAG5B,iBAAiB,C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sC,OAAO,CAAC,CAACtC,SAAS,EAAE;UAAEoB,SAAS;UAAEC;QAAW,CAAC,CAAC,CAAC;MACjD;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC;;AAED;;AAMA,OAAO,SAASE,mBAAmBA,CACjC5B,IAAiB,EACjBhE,OAAgC,EACjB;EACf,MAAM,CAAC6G,CAAC,EAAEpB,SAAS,EAAEC,UAAU,CAAC,GAAGT,uBAAuB,CACxD,KAAK,EACLjB,IAAI,EACJhE,OAAO,EACPqE,SACF,CAAE;EAEF,OAAO;IACLoB,SAAS;IACTC;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- import { NativeQuickCrypto } from './NativeQuickCrypto/NativeQuickCrypto';
4
- import { toArrayBuffer, validateMaxBufferLength, normalizeHashName, bufferLikeToArrayBuffer } from './Utils';
5
- import Stream from 'readable-stream';
6
- import { Buffer } from '@craftzdog/react-native-buffer';
7
- import { lazyDOMException } from './Utils';
8
- global.process.nextTick = setImmediate;
9
- const createInternalHash = NativeQuickCrypto.createHash;
10
- export function createHash(algorithm, options) {
11
- return new Hash(algorithm, options);
12
- }
13
- class Hash extends Stream.Transform {
14
- constructor(arg, options) {
15
- super(options ?? undefined);
16
- if (arg instanceof Hash) {
17
- this.internalHash = arg.internalHash.copy(options?.outputLength);
18
- } else {
19
- this.internalHash = createInternalHash(arg, options?.outputLength);
20
- }
21
- }
22
- copy(options) {
23
- const copy = new Hash(this, options);
24
- return copy;
25
- }
26
- /**
27
- * Updates the hash content with the given `data`, the encoding of which
28
- * is given in `inputEncoding`.
29
- * If `encoding` is not provided, and the `data` is a string, an
30
- * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
31
- *
32
- * This can be called many times with new data as it is streamed.
33
- * @since v0.1.92
34
- * @param inputEncoding The `encoding` of the `data` string.
35
- */
36
- update(data, inputEncoding) {
37
- if (data instanceof ArrayBuffer) {
38
- this.internalHash.update(data);
39
- return this;
40
- }
41
- const buffer = Buffer.from(data, inputEncoding);
42
- this.internalHash.update(toArrayBuffer(buffer));
43
- return this;
44
- }
45
- _transform(chunk, encoding, callback) {
46
- this.update(chunk, encoding);
47
- callback();
48
- }
49
- _flush(callback) {
50
- this.push(this.digest());
51
- callback();
52
- }
53
-
54
- /**
55
- * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
56
- * If `encoding` is provided a string will be returned; otherwise
57
- * a `Buffer` is returned.
58
- *
59
- * The `Hash` object can not be used again after `hash.digest()` method has been
60
- * called. Multiple calls will cause an error to be thrown.
61
- * @since v0.1.92
62
- * @param encoding The `encoding` of the return value.
63
- */
64
-
65
- digest(encoding) {
66
- const result = this.internalHash.digest();
67
- if (encoding && encoding !== 'buffer') {
68
- return Buffer.from(result).toString(encoding);
69
- }
70
- return Buffer.from(result);
71
- }
72
- }
73
-
74
- // Implementation for WebCrypto subtle.digest()
75
-
76
- export const asyncDigest = async (algorithm, data) => {
77
- validateMaxBufferLength(data, 'data');
78
- switch (algorithm.name) {
79
- case 'SHA-1':
80
- // Fall through
81
- case 'SHA-256':
82
- // Fall through
83
- case 'SHA-384':
84
- // Fall through
85
- case 'SHA-512':
86
- const normalizedHashName = normalizeHashName(algorithm.name);
87
- const hash = new Hash(normalizedHashName);
88
- hash.update(bufferLikeToArrayBuffer(data));
89
- return hash.digest();
90
- }
91
- throw lazyDOMException(`Unrecognized algorithm name: ${algorithm.name}`, 'NotSupportedError');
92
- };
93
- //# sourceMappingURL=Hash.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["NativeQuickCrypto","toArrayBuffer","validateMaxBufferLength","normalizeHashName","bufferLikeToArrayBuffer","Stream","Buffer","lazyDOMException","global","process","nextTick","setImmediate","createInternalHash","createHash","algorithm","options","Hash","Transform","constructor","arg","undefined","internalHash","copy","outputLength","update","data","inputEncoding","ArrayBuffer","buffer","from","_transform","chunk","encoding","callback","_flush","push","digest","result","toString","asy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