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