react-native-quick-crypto 1.0.0-beta.10 → 1.0.0-beta.12

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 (35) hide show
  1. package/QuickCrypto.podspec +7 -6
  2. package/android/CMakeLists.txt +2 -0
  3. package/cpp/hash/HybridHash.cpp +181 -0
  4. package/cpp/hash/HybridHash.hpp +57 -0
  5. package/lib/commonjs/hash.js +145 -0
  6. package/lib/commonjs/hash.js.map +1 -0
  7. package/lib/commonjs/index.js +13 -0
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/specs/hash.nitro.js +6 -0
  10. package/lib/commonjs/specs/hash.nitro.js.map +1 -0
  11. package/lib/module/hash.js +139 -0
  12. package/lib/module/hash.js.map +1 -0
  13. package/lib/module/index.js +3 -0
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/module/specs/hash.nitro.js +4 -0
  16. package/lib/module/specs/hash.nitro.js.map +1 -0
  17. package/lib/tsconfig.tsbuildinfo +1 -1
  18. package/lib/typescript/hash.d.ts +87 -0
  19. package/lib/typescript/hash.d.ts.map +1 -0
  20. package/lib/typescript/index.d.ts +3 -0
  21. package/lib/typescript/index.d.ts.map +1 -1
  22. package/lib/typescript/specs/hash.nitro.d.ts +12 -0
  23. package/lib/typescript/specs/hash.nitro.d.ts.map +1 -0
  24. package/lib/typescript/utils/types.d.ts +4 -0
  25. package/lib/typescript/utils/types.d.ts.map +1 -1
  26. package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +1 -0
  27. package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +10 -0
  28. package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +10 -0
  29. package/nitrogen/generated/shared/c++/HybridHashSpec.cpp +25 -0
  30. package/nitrogen/generated/shared/c++/HybridHashSpec.hpp +74 -0
  31. package/package.json +1 -1
  32. package/src/hash.ts +172 -0
  33. package/src/index.ts +3 -0
  34. package/src/specs/hash.nitro.ts +9 -0
  35. package/src/utils/types.ts +9 -0
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.license = package["license"]
13
13
  s.authors = package["authors"]
14
14
 
15
- s.ios.deployment_target = 16.0 # min_ios_version_supported (see https://github.com/Expensify/App/pull/53149#issuecomment-2562786065)
15
+ s.ios.deployment_target = min_ios_version_supported
16
16
  s.visionos.deployment_target = 1.0
17
17
  s.macos.deployment_target = 10.13
18
18
  s.tvos.deployment_target = 13.4
@@ -32,16 +32,17 @@ Pod::Spec.new do |s|
32
32
  "deps/**/*.{h,c}",
33
33
  ]
34
34
 
35
- if ENV["USE_FRAMEWORKS"]
36
- s.dependency "React-Core"
37
- add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern")
38
- add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency")
39
- end
35
+ s.pod_target_xcconfig = {
36
+ # C++ compiler flags, mainly for folly.
37
+ "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES"
38
+ }
40
39
 
41
40
  # Add all files generated by Nitrogen
42
41
  load 'nitrogen/generated/ios/QuickCrypto+autolinking.rb'
43
42
  add_nitrogen_files(s)
44
43
 
44
+ s.dependency 'React-jsi'
45
+ s.dependency 'React-callinvoker'
45
46
  s.dependency "OpenSSL-Universal"
46
47
  install_modules_dependencies(s)
47
48
  end
@@ -9,6 +9,7 @@ set(CMAKE_CXX_STANDARD 20)
9
9
  add_library(
10
10
  ${PACKAGE_NAME} SHARED
11
11
  src/main/cpp/cpp-adapter.cpp
12
+ ../cpp/hash/HybridHash.cpp
12
13
  ../cpp/ed25519/HybridEdKeyPair.cpp
13
14
  ../cpp/pbkdf2/HybridPbkdf2.cpp
14
15
  ../cpp/random/HybridRandom.cpp
@@ -21,6 +22,7 @@ include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/QuickCrypto+autolinkin
21
22
  # local includes
22
23
  include_directories(
23
24
  "src/main/cpp"
25
+ "../cpp/hash"
24
26
  "../cpp/ed25519"
25
27
  "../cpp/pbkdf2"
26
28
  "../cpp/random"
@@ -0,0 +1,181 @@
1
+ #include <NitroModules/ArrayBuffer.hpp>
2
+ #include <memory>
3
+ #include <openssl/err.h>
4
+ #include <openssl/evp.h>
5
+ #include <optional>
6
+ #include <string>
7
+ #include <vector>
8
+
9
+ #include "HybridHash.hpp"
10
+
11
+ namespace margelo::nitro::crypto {
12
+
13
+ HybridHash::~HybridHash()
14
+ {
15
+ if (ctx) {
16
+ EVP_MD_CTX_free(ctx);
17
+ ctx = nullptr;
18
+ }
19
+ }
20
+
21
+ void
22
+ HybridHash::createHash(const std::string& hashAlgorithmArg,
23
+ const std::optional<double> outputLengthArg)
24
+ {
25
+ algorithm = hashAlgorithmArg;
26
+ outputLength = outputLengthArg;
27
+
28
+ // Create hash context
29
+ ctx = EVP_MD_CTX_new();
30
+ if (!ctx) {
31
+ throw std::runtime_error("Failed to create hash context: " +
32
+ std::to_string(ERR_get_error()));
33
+ }
34
+
35
+ // Get the message digest by name
36
+ md = EVP_get_digestbyname(algorithm.c_str());
37
+ if (!md) {
38
+ EVP_MD_CTX_free(ctx);
39
+ ctx = nullptr;
40
+ throw std::runtime_error("Unknown hash algorithm: " + algorithm);
41
+ }
42
+
43
+ // Initialize the digest
44
+ if (EVP_DigestInit_ex(ctx, md, nullptr) != 1) {
45
+ EVP_MD_CTX_free(ctx);
46
+ ctx = nullptr;
47
+ throw std::runtime_error("Failed to initialize hash digest: " +
48
+ std::to_string(ERR_get_error()));
49
+ }
50
+ }
51
+
52
+ void
53
+ HybridHash::update(const std::shared_ptr<ArrayBuffer>& data)
54
+ {
55
+ if (!ctx) {
56
+ throw std::runtime_error("Hash context not initialized");
57
+ }
58
+
59
+ // Update the digest with the data
60
+ if (EVP_DigestUpdate(ctx,
61
+ reinterpret_cast<const uint8_t*>(data->data()),
62
+ data->size()) != 1) {
63
+ throw std::runtime_error("Failed to update hash digest: " +
64
+ std::to_string(ERR_get_error()));
65
+ }
66
+ }
67
+
68
+ std::shared_ptr<ArrayBuffer>
69
+ HybridHash::digest(const std::optional<std::string>& encoding)
70
+ {
71
+ if (!ctx) {
72
+ throw std::runtime_error("Hash context not initialized");
73
+ }
74
+
75
+ setParams();
76
+
77
+ // Get the default digest size
78
+ const size_t defaultLen = EVP_MD_CTX_size(ctx);
79
+ const size_t digestSize =
80
+ (outputLength.has_value()) ? static_cast<int>(*outputLength) : defaultLen;
81
+
82
+ if (digestSize < 0) {
83
+ throw std::runtime_error("Invalid digest size: " +
84
+ std::to_string(digestSize));
85
+ }
86
+
87
+ // Create a buffer for the hash output
88
+ uint8_t* hashBuffer = new uint8_t[digestSize];
89
+ size_t hashLength = digestSize;
90
+
91
+ // Finalize the digest
92
+ int ret;
93
+ if (digestSize == defaultLen) {
94
+ ret = EVP_DigestFinal_ex(
95
+ ctx, hashBuffer, reinterpret_cast<unsigned int*>(&hashLength));
96
+ } else {
97
+ ret = EVP_DigestFinalXOF(ctx, hashBuffer, hashLength);
98
+ }
99
+
100
+ if (ret != 1) {
101
+ delete[] hashBuffer;
102
+ throw std::runtime_error("Failed to finalize hash digest: " +
103
+ std::to_string(ERR_get_error()));
104
+ }
105
+
106
+ return std::make_shared<NativeArrayBuffer>(
107
+ hashBuffer, hashLength, [=]() { delete[] hashBuffer; });
108
+ }
109
+
110
+ std::shared_ptr<margelo::nitro::crypto::HybridHashSpec>
111
+ HybridHash::copy(const std::optional<double> outputLengthArg)
112
+ {
113
+ if (!ctx) {
114
+ throw std::runtime_error("Hash context not initialized");
115
+ }
116
+
117
+ // Create a new context
118
+ EVP_MD_CTX* newCtx = EVP_MD_CTX_new();
119
+ if (!newCtx) {
120
+ throw std::runtime_error("Failed to create new hash context: " +
121
+ std::to_string(ERR_get_error()));
122
+ }
123
+
124
+ // Copy the existing context to the new one
125
+ if (EVP_MD_CTX_copy(newCtx, ctx) != 1) {
126
+ EVP_MD_CTX_free(newCtx);
127
+ throw std::runtime_error("Failed to copy hash context: " +
128
+ std::to_string(ERR_get_error()));
129
+ }
130
+
131
+ return std::make_shared<HybridHash>(newCtx, md, algorithm, outputLengthArg);
132
+ }
133
+
134
+ std::vector<std::string>
135
+ HybridHash::getSupportedHashAlgorithms()
136
+ {
137
+ std::vector<std::string> hashAlgorithms;
138
+
139
+ EVP_MD_do_all_provided(
140
+ nullptr,
141
+ [](EVP_MD* md, void* arg) {
142
+ auto* algorithms = static_cast<std::vector<std::string>*>(arg);
143
+ const char* name = EVP_MD_get0_name(md);
144
+ if (name) {
145
+ algorithms->push_back(name);
146
+ }
147
+ },
148
+ &hashAlgorithms);
149
+
150
+ return hashAlgorithms;
151
+ }
152
+
153
+ void
154
+ HybridHash::setParams()
155
+ {
156
+ // Handle algorithm parameters (like XOF length for SHAKE)
157
+ if (outputLength.has_value()) {
158
+ uint32_t xoflen = outputLength.value();
159
+
160
+ // Add a reasonable maximum output length
161
+ const int MAX_OUTPUT_LENGTH = 16 * 1024 * 1024; // 16MB
162
+ if (xoflen > MAX_OUTPUT_LENGTH) {
163
+ throw std::runtime_error("Output length " + std::to_string(xoflen) +
164
+ " exceeds maximum allowed size of " +
165
+ std::to_string(MAX_OUTPUT_LENGTH));
166
+ }
167
+
168
+ OSSL_PARAM params[] = { OSSL_PARAM_construct_uint("xoflen", &xoflen),
169
+ OSSL_PARAM_END };
170
+
171
+ if (EVP_MD_CTX_set_params(ctx, params) != 1) {
172
+ EVP_MD_CTX_free(ctx);
173
+ ctx = nullptr;
174
+ throw std::runtime_error(
175
+ "Failed to set XOF length (outputLength) parameter: " +
176
+ std::to_string(ERR_get_error()));
177
+ }
178
+ }
179
+ }
180
+
181
+ } // namespace margelo::nitro::crypto
@@ -0,0 +1,57 @@
1
+ #include <NitroModules/ArrayBuffer.hpp>
2
+ #include <memory>
3
+ #include <openssl/evp.h>
4
+ #include <optional>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ #include "HybridHashSpec.hpp"
9
+
10
+ namespace margelo::nitro::crypto {
11
+
12
+ using namespace facebook;
13
+
14
+ class HybridHash : public HybridHashSpec
15
+ {
16
+ public:
17
+ HybridHash()
18
+ : HybridObject(TAG)
19
+ {
20
+ }
21
+ HybridHash(EVP_MD_CTX* ctx,
22
+ const EVP_MD* md,
23
+ const std::string& algorithm,
24
+ const std::optional<double> outputLength)
25
+ : HybridObject(TAG)
26
+ , ctx(ctx)
27
+ , md(md)
28
+ , algorithm(algorithm)
29
+ , outputLength(outputLength)
30
+ {
31
+ }
32
+ ~HybridHash();
33
+
34
+ public:
35
+ // Methods
36
+ void createHash(const std::string& algorithm,
37
+ const std::optional<double> outputLength) override;
38
+ void update(const std::shared_ptr<ArrayBuffer>& data) override;
39
+ std::shared_ptr<ArrayBuffer> digest(
40
+ const std::optional<std::string>& encoding = std::nullopt) override;
41
+ std::shared_ptr<margelo::nitro::crypto::HybridHashSpec> copy(
42
+ const std::optional<double> outputLength) override;
43
+ std::vector<std::string> getSupportedHashAlgorithms() override;
44
+
45
+ private:
46
+ // Methods
47
+ void setParams();
48
+
49
+ private:
50
+ // Properties
51
+ EVP_MD_CTX* ctx = nullptr;
52
+ const EVP_MD* md = nullptr;
53
+ std::string algorithm = "";
54
+ std::optional<double> outputLength = std::nullopt;
55
+ };
56
+
57
+ } // namespace margelo::nitro::crypto
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createHash = createHash;
7
+ exports.getHashes = getHashes;
8
+ exports.hashExports = void 0;
9
+ var _readableStream = require("readable-stream");
10
+ var _reactNativeNitroModules = require("react-native-nitro-modules");
11
+ var _utils = require("./utils");
12
+ class HashUtils {
13
+ static native = _reactNativeNitroModules.NitroModules.createHybridObject('Hash');
14
+ static getSupportedHashAlgorithms() {
15
+ return this.native.getSupportedHashAlgorithms();
16
+ }
17
+ }
18
+ function getHashes() {
19
+ return HashUtils.getSupportedHashAlgorithms();
20
+ }
21
+ class Hash extends _readableStream.Stream.Transform {
22
+ /**
23
+ * @internal use `createHash()` instead
24
+ */
25
+ constructor({
26
+ algorithm,
27
+ options,
28
+ native
29
+ }) {
30
+ super(options);
31
+ this.algorithm = algorithm;
32
+ this.options = options ?? {};
33
+ if (native) {
34
+ this.native = native;
35
+ } else {
36
+ this.native = _reactNativeNitroModules.NitroModules.createHybridObject('Hash');
37
+ this.native.createHash(algorithm, this.options.outputLength);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Updates the hash content with the given `data`, the encoding of which
43
+ * is given in `inputEncoding`.
44
+ * If `encoding` is not provided, and the `data` is a string, an
45
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
46
+ *
47
+ * This can be called many times with new data as it is streamed.
48
+ * @since v1.0.0
49
+ * @param inputEncoding The `encoding` of the `data` string.
50
+ */
51
+
52
+ update(data, inputEncoding) {
53
+ const defaultEncoding = 'utf8';
54
+ inputEncoding = inputEncoding ?? defaultEncoding;
55
+ this.native.update((0, _utils.binaryLikeToArrayBuffer)(data, inputEncoding));
56
+ if (typeof data === 'string' && inputEncoding !== 'buffer') {
57
+ return this; // to support chaining syntax createHash().update().digest()
58
+ }
59
+ return Buffer.from([]); // returning empty buffer as _flush calls digest
60
+ }
61
+
62
+ /**
63
+ * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
64
+ * If `encoding` is provided a string will be returned; otherwise
65
+ * a `Buffer` is returned.
66
+ *
67
+ * The `Hash` object can not be used again after `hash.digest()` method has been
68
+ * called. Multiple calls will cause an error to be thrown.
69
+ * @since v1.0.0
70
+ * @param encoding The `encoding` of the return value.
71
+ */
72
+
73
+ digest(encoding) {
74
+ const nativeDigest = this.native.digest(encoding);
75
+ if (encoding && encoding !== 'buffer') {
76
+ return (0, _utils.ab2str)(nativeDigest, encoding);
77
+ }
78
+ return Buffer.from(nativeDigest);
79
+ }
80
+
81
+ /**
82
+ * Creates a new `Hash` object that contains a deep copy of the internal state
83
+ * of the current `Hash` object.
84
+ *
85
+ * The optional `options` argument controls stream behavior. For XOF hash
86
+ * functions such as `'shake256'`, the `outputLength` option can be used to
87
+ * specify the desired output length in bytes.
88
+ *
89
+ * An error is thrown when an attempt is made to copy the `Hash` object after
90
+ * its `hash.digest()` method has been called.
91
+ *
92
+ * ```js
93
+ * // Calculate a rolling hash.
94
+ * import { createHash } from 'react-native-quick-crypto';
95
+ *
96
+ * const hash = createHash('sha256');
97
+ *
98
+ * hash.update('one');
99
+ * console.log(hash.copy().digest('hex'));
100
+ *
101
+ * hash.update('two');
102
+ * console.log(hash.copy().digest('hex'));
103
+ *
104
+ * hash.update('three');
105
+ * console.log(hash.copy().digest('hex'));
106
+ *
107
+ * // Etc.
108
+ * ```
109
+ * @since v1.0.0
110
+ * @param options `stream.transform` options
111
+ */
112
+
113
+ copy(options) {
114
+ const newOptions = options ?? this.options;
115
+ const newNativeHash = this.native.copy(newOptions.outputLength);
116
+ const hash = new Hash({
117
+ algorithm: this.algorithm,
118
+ options: newOptions,
119
+ native: newNativeHash
120
+ });
121
+ return hash;
122
+ }
123
+
124
+ // stream interface
125
+ _transform(chunk, encoding, callback) {
126
+ this.push(this.update(chunk, encoding));
127
+ callback();
128
+ }
129
+ _flush(callback) {
130
+ this.push(this.digest());
131
+ callback();
132
+ }
133
+ }
134
+ function createHash(algorithm, options) {
135
+ // @ts-expect-error private constructor
136
+ return new Hash({
137
+ algorithm,
138
+ options
139
+ });
140
+ }
141
+ const hashExports = exports.hashExports = {
142
+ createHash,
143
+ getHashes
144
+ };
145
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_readableStream","require","_reactNativeNitroModules","_utils","HashUtils","native","NitroModules","createHybridObject","getSupportedHashAlgorithms","getHashes","Hash","Stream","Transform","constructor","algorithm","options","createHash","outputLength","update","data","inputEncoding","defaultEncoding","binaryLikeToArrayBuffer","Buffer","from","digest","encoding","nativeDigest","ab2str","copy","newOptions","newNativeHash","hash","_transform","chunk","callback","push","_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;IAC3B,IAAI,CAACC,IAAI,CAAC,IAAI,CAACX,MAAM,CAAC,CAAC,CAAC;IACxBU,QAAQ,CAAC,CAAC;EACZ;AACF;AAEO,SAASnB,UAAUA,CAACF,SAAiB,EAAEC,OAAqB,EAAQ;EACzE;EACA,OAAO,IAAIL,IAAI,CAAC;IACdI,SAAS;IACTC;EACF,CAAC,CAAC;AACJ;AAEO,MAAMuB,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBtB,UAAU;EACVP;AACF,CAAC","ignoreList":[]}
@@ -9,6 +9,18 @@ var _exportNames = {
9
9
  exports.install = exports.default = void 0;
10
10
  var _reactNativeBuffer = require("@craftzdog/react-native-buffer");
11
11
  var keys = _interopRequireWildcard(require("./keys"));
12
+ var _hash = require("./hash");
13
+ Object.keys(_hash).forEach(function (key) {
14
+ if (key === "default" || key === "__esModule") return;
15
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16
+ if (key in exports && exports[key] === _hash[key]) return;
17
+ Object.defineProperty(exports, key, {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _hash[key];
21
+ }
22
+ });
23
+ });
12
24
  var ed = _interopRequireWildcard(require("./ed"));
13
25
  Object.keys(ed).forEach(function (key) {
14
26
  if (key === "default" || key === "__esModule") return;
@@ -88,6 +100,7 @@ const QuickCrypto = {
88
100
  // subtle,
89
101
  // constants,
90
102
  ...keys,
103
+ ..._hash.hashExports,
91
104
  ...ed,
92
105
  ...pbkdf2,
93
106
  ...random,
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeBuffer","require","keys","_interopRequireWildcard","ed","Object","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","pbkdf2","random","utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","QuickCrypto","install","global","Buffer","crypto","process","nextTick","setImmediate","_default","module"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;A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ACa,OAAO,GAAGS,WAAW;AACpCS,MAAM,CAAC/B,OAAO,CAACuB,OAAO,GAAGA,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeBuffer","require","keys","_interopRequireWildcard","_hash","Object","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","ed","pbkdf2","random","utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","QuickCrypto","hash","install","global","Buffer","crypto","process","nextTick","setImmediate","_default","module"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AA0DAI,MAAA,CAAAH,IAAA,CAAAE,KAAA,EAAAE,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAF,MAAA,CAAAG,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAH,KAAA,CAAAG,GAAA;EAAAF,MAAA,CAAAQ,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAX,KAAA,CAAAG,GAAA;IAAA;EAAA;AAAA;AAzDA,IAAAS,EAAA,GAAAb,uBAAA,CAAAF,OAAA;AA0DAI,MAAA,CAAAH,IAAA,CAAAc,EAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAF,MAAA,CAAAG,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,EAAA,CAAAT,G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,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAnExB;;AAGA;;AAOA;;AAGA;AACA;AACA;AACA;AACA,MAAMO,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAGjC,IAAI;EACP,GAAGkC,iBAAI;EACP,GAAGpB,EAAE;EACL,GAAGC,MAAM;EACT,GAAGC,MAAM;EACT;EACA;EACA;EACA,GAAGC;AACL,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMkB,OAAO,GAAGA,CAAA,KAAM;EAC3B;EACAC,MAAM,CAACC,MAAM,GAAGA,yBAAM;;EAEtB;EACAD,MAAM,CAACE,MAAM,GAAGL,WAAW;AAC7B,CAAC;;AAED;AAAAvB,OAAA,CAAAyB,OAAA,GAAAA,OAAA;AACAC,MAAM,CAACG,OAAO,CAACC,QAAQ,GAAGC,YAAY;;AAEtC;AAAA,IAAAC,QAAA,GAAAhC,OAAA,CAAAc,OAAA,GACeS,WAAW;AAO1B;AACAU,MAAM,CAACjC,OAAO,GAAGuB,WAAW;AAC5BU,MAAM,CAACjC,OAAO,CAACc,OAAO,GAAGS,WAAW;AACpCU,MAAM,CAACjC,OAAO,CAACyB,OAAO,GAAGA,OAAO","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=hash.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/hash.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ import { Stream } from 'readable-stream';
4
+ import { NitroModules } from 'react-native-nitro-modules';
5
+ import { ab2str, binaryLikeToArrayBuffer } from './utils';
6
+ class HashUtils {
7
+ static native = NitroModules.createHybridObject('Hash');
8
+ static getSupportedHashAlgorithms() {
9
+ return this.native.getSupportedHashAlgorithms();
10
+ }
11
+ }
12
+ export function getHashes() {
13
+ return HashUtils.getSupportedHashAlgorithms();
14
+ }
15
+ class Hash extends Stream.Transform {
16
+ /**
17
+ * @internal use `createHash()` instead
18
+ */
19
+ constructor({
20
+ algorithm,
21
+ options,
22
+ native
23
+ }) {
24
+ super(options);
25
+ this.algorithm = algorithm;
26
+ this.options = options ?? {};
27
+ if (native) {
28
+ this.native = native;
29
+ } else {
30
+ this.native = NitroModules.createHybridObject('Hash');
31
+ this.native.createHash(algorithm, this.options.outputLength);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Updates the hash content with the given `data`, the encoding of which
37
+ * is given in `inputEncoding`.
38
+ * If `encoding` is not provided, and the `data` is a string, an
39
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
40
+ *
41
+ * This can be called many times with new data as it is streamed.
42
+ * @since v1.0.0
43
+ * @param inputEncoding The `encoding` of the `data` string.
44
+ */
45
+
46
+ update(data, inputEncoding) {
47
+ const defaultEncoding = 'utf8';
48
+ inputEncoding = inputEncoding ?? defaultEncoding;
49
+ this.native.update(binaryLikeToArrayBuffer(data, inputEncoding));
50
+ if (typeof data === 'string' && inputEncoding !== 'buffer') {
51
+ return this; // to support chaining syntax createHash().update().digest()
52
+ }
53
+ return Buffer.from([]); // returning empty buffer as _flush calls digest
54
+ }
55
+
56
+ /**
57
+ * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
58
+ * If `encoding` is provided a string will be returned; otherwise
59
+ * a `Buffer` is returned.
60
+ *
61
+ * The `Hash` object can not be used again after `hash.digest()` method has been
62
+ * called. Multiple calls will cause an error to be thrown.
63
+ * @since v1.0.0
64
+ * @param encoding The `encoding` of the return value.
65
+ */
66
+
67
+ digest(encoding) {
68
+ const nativeDigest = this.native.digest(encoding);
69
+ if (encoding && encoding !== 'buffer') {
70
+ return ab2str(nativeDigest, encoding);
71
+ }
72
+ return Buffer.from(nativeDigest);
73
+ }
74
+
75
+ /**
76
+ * Creates a new `Hash` object that contains a deep copy of the internal state
77
+ * of the current `Hash` object.
78
+ *
79
+ * The optional `options` argument controls stream behavior. For XOF hash
80
+ * functions such as `'shake256'`, the `outputLength` option can be used to
81
+ * specify the desired output length in bytes.
82
+ *
83
+ * An error is thrown when an attempt is made to copy the `Hash` object after
84
+ * its `hash.digest()` method has been called.
85
+ *
86
+ * ```js
87
+ * // Calculate a rolling hash.
88
+ * import { createHash } from 'react-native-quick-crypto';
89
+ *
90
+ * const hash = createHash('sha256');
91
+ *
92
+ * hash.update('one');
93
+ * console.log(hash.copy().digest('hex'));
94
+ *
95
+ * hash.update('two');
96
+ * console.log(hash.copy().digest('hex'));
97
+ *
98
+ * hash.update('three');
99
+ * console.log(hash.copy().digest('hex'));
100
+ *
101
+ * // Etc.
102
+ * ```
103
+ * @since v1.0.0
104
+ * @param options `stream.transform` options
105
+ */
106
+
107
+ copy(options) {
108
+ const newOptions = options ?? this.options;
109
+ const newNativeHash = this.native.copy(newOptions.outputLength);
110
+ const hash = new Hash({
111
+ algorithm: this.algorithm,
112
+ options: newOptions,
113
+ native: newNativeHash
114
+ });
115
+ return hash;
116
+ }
117
+
118
+ // stream interface
119
+ _transform(chunk, encoding, callback) {
120
+ this.push(this.update(chunk, encoding));
121
+ callback();
122
+ }
123
+ _flush(callback) {
124
+ this.push(this.digest());
125
+ callback();
126
+ }
127
+ }
128
+ export function createHash(algorithm, options) {
129
+ // @ts-expect-error private constructor
130
+ return new Hash({
131
+ algorithm,
132
+ options
133
+ });
134
+ }
135
+ export const hashExports = {
136
+ createHash,
137
+ getHashes
138
+ };
139
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Stream","NitroModules","ab2str","binaryLikeToArrayBuffer","HashUtils","native","createHybridObject","getSupportedHashAlgorithms","getHashes","Hash","Transform","constructor","algorithm","options","createHash","outputLength","update","data","inputEncoding","defaultEncoding","Buffer","from","digest","encoding","nativeDigest","copy","newOptions","newNativeHash","hash","_transform","chunk","callback","push","_flush","hashExports"],"sourceRoot":"../../src","sources":["hash.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,SAASC,YAAY,QAAQ,4BAA4B;AAIzD,SAASC,MAAM,EAAEC,uBAAuB,QAAQ,SAAS;AAEzD,MAAMC,SAAS,CAAC;EACd,OAAeC,MAAM,GAAGJ,YAAY,CAACK,kBAAkB,CAAa,MAAM,CAAC;EAC3E,OAAcC,0BAA0BA,CAAA,EAAa;IACnD,OAAO,IAAI,CAACF,MAAM,CAACE,0BAA0B,CAAC,CAAC;EACjD;AACF;AAEA,OAAO,SAASC,SAASA,CAAA,EAAG;EAC1B,OAAOJ,SAAS,CAACG,0BAA0B,CAAC,CAAC;AAC/C;AAgBA,MAAME,IAAI,SAAST,MAAM,CAACU,SAAS,CAAC;EAKlC;AACF;AACA;EACUC,WAAWA,CAAC;IAAEC,SAAS;IAAEC,OAAO;IAAER;EAAiB,CAAC,EAAE;IAC5D,KAAK,CAACQ,OAAO,CAAC;IAEd,IAAI,CAACD,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;IAE5B,IAAIR,MAAM,EAAE;MACV,IAAI,CAACA,MAAM,GAAGA,MAAM;IACtB,CAAC,MAAM;MACL,IAAI,CAACA,MAAM,GAAGJ,YAAY,CAACK,kBAAkB,CAAa,MAAM,CAAC;MACjE,IAAI,CAACD,MAAM,CAACS,UAAU,CAACF,SAAS,EAAE,IAAI,CAACC,OAAO,CAACE,YAAY,CAAC;IAC9D;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAGEC,MAAMA,CAACC,IAAgB,E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,EACjBP,QAAwB,EACxBQ,QAAoB,EACpB;IACA,IAAI,CAACC,IAAI,CAAC,IAAI,CAAChB,MAAM,CAACc,KAAK,EAAEP,QAAoB,CAAC,CAAC;IACnDQ,QAAQ,CAAC,CAAC;EACZ;EACAE,MAAMA,CAACF,QAAoB,EAAE;IAC3B,IAAI,CAACC,IAAI,CAAC,IAAI,CAACV,MAAM,CAAC,CAAC,CAAC;IACxBS,QAAQ,CAAC,CAAC;EACZ;AACF;AAEA,OAAO,SAASjB,UAAUA,CAACF,SAAiB,EAAEC,OAAqB,EAAQ;EACzE;EACA,OAAO,IAAIJ,IAAI,CAAC;IACdG,SAAS;IACTC;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,MAAMqB,WAAW,GAAG;EACzBpB,UAAU;EACVN;AACF,CAAC","ignoreList":[]}
@@ -5,6 +5,7 @@ import { Buffer } from '@craftzdog/react-native-buffer';
5
5
 
6
6
  // API imports
7
7
  import * as keys from './keys';
8
+ import { hashExports as hash } from './hash';
8
9
  import * as ed from './ed';
9
10
  import * as pbkdf2 from './pbkdf2';
10
11
  import * as random from './random';
@@ -35,6 +36,7 @@ const QuickCrypto = {
35
36
  // subtle,
36
37
  // constants,
37
38
  ...keys,
39
+ ...hash,
38
40
  ...ed,
39
41
  ...pbkdf2,
40
42
  ...random,
@@ -61,6 +63,7 @@ global.process.nextTick = setImmediate;
61
63
 
62
64
  // exports
63
65
  export default QuickCrypto;
66
+ export * from './hash';
64
67
  export * from './ed';
65
68
  export * from './pbkdf2';
66
69
  export * from './random';