react-native-quick-crypto 0.2.0
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.
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/android/.DS_Store +0 -0
- package/android/CMakeLists.txt +117 -0
- package/android/build.gradle +367 -0
- package/android/gradle/.DS_Store +0 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +6 -0
- package/android/gradlew +183 -0
- package/android/gradlew.bat +100 -0
- package/android/src/.DS_Store +0 -0
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +60 -0
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/android/src/main/java/com/reactnativequickcrypto/QuickCryptoModule.java +70 -0
- package/android/src/main/java/com/reactnativequickcrypto/QuickCryptoPackage.java +26 -0
- package/cpp/.DS_Store +0 -0
- package/cpp/Cipher/MGLCipherHostObject.cpp +632 -0
- package/cpp/Cipher/MGLCipherHostObject.h +90 -0
- package/cpp/Cipher/MGLCreateCipherInstaller.cpp +74 -0
- package/cpp/Cipher/MGLCreateCipherInstaller.h +17 -0
- package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +74 -0
- package/cpp/Cipher/MGLCreateDecipherInstaller.h +17 -0
- package/cpp/HMAC/MGLHmacHostObject.cpp +95 -0
- package/cpp/HMAC/MGLHmacHostObject.h +39 -0
- package/cpp/HMAC/MGLHmacInstaller.cpp +43 -0
- package/cpp/HMAC/MGLHmacInstaller.h +20 -0
- package/cpp/Hash/MGLHashHostObject.cpp +147 -0
- package/cpp/Hash/MGLHashHostObject.h +53 -0
- package/cpp/Hash/MGLHashInstaller.cpp +46 -0
- package/cpp/Hash/MGLHashInstaller.h +20 -0
- package/cpp/JSIUtils/MGLJSIMacros.h +37 -0
- package/cpp/JSIUtils/MGLSmartHostObject.cpp +43 -0
- package/cpp/JSIUtils/MGLSmartHostObject.h +46 -0
- package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +24 -0
- package/cpp/JSIUtils/MGLThreadAwareHostObject.h +43 -0
- package/cpp/JSIUtils/MGLTypedArray.cpp +325 -0
- package/cpp/JSIUtils/MGLTypedArray.h +160 -0
- package/cpp/MGLQuickCryptoHostObject.cpp +64 -0
- package/cpp/MGLQuickCryptoHostObject.h +30 -0
- package/cpp/Random/MGLRandomHostObject.cpp +89 -0
- package/cpp/Random/MGLRandomHostObject.h +27 -0
- package/cpp/Utils/MGLDispatchQueue.cpp +75 -0
- package/cpp/Utils/MGLDispatchQueue.h +55 -0
- package/cpp/Utils/logs.h +38 -0
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +164 -0
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +29 -0
- package/cpp/fastpbkdf2/fastpbkdf2.c +352 -0
- package/cpp/fastpbkdf2/fastpbkdf2.h +68 -0
- package/ios/.DS_Store +0 -0
- package/ios/QuickCrypto.xcodeproj/project.pbxproj +274 -0
- package/ios/QuickCryptoModule.h +5 -0
- package/ios/QuickCryptoModule.mm +42 -0
- package/lib/.DS_Store +0 -0
- package/lib/commonjs/Cipher.js +293 -0
- package/lib/commonjs/Cipher.js.map +1 -0
- package/lib/commonjs/Hash.js +102 -0
- package/lib/commonjs/Hash.js.map +1 -0
- package/lib/commonjs/Hmac.js +104 -0
- package/lib/commonjs/Hmac.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/Cipher.js +6 -0
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +61 -0
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/hash.js +2 -0
- package/lib/commonjs/NativeQuickCrypto/hash.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/hmac.js +2 -0
- package/lib/commonjs/NativeQuickCrypto/hmac.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +2 -0
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/random.js +2 -0
- package/lib/commonjs/NativeQuickCrypto/random.js.map +1 -0
- package/lib/commonjs/QuickCrypto.js +35 -0
- package/lib/commonjs/QuickCrypto.js.map +1 -0
- package/lib/commonjs/Utils.js +152 -0
- package/lib/commonjs/Utils.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/pbkdf2.js +64 -0
- package/lib/commonjs/pbkdf2.js.map +1 -0
- package/lib/commonjs/random.js +213 -0
- package/lib/commonjs/random.js.map +1 -0
- package/lib/module/Cipher.js +287 -0
- package/lib/module/Cipher.js.map +1 -0
- package/lib/module/Hash.js +87 -0
- package/lib/module/Hash.js.map +1 -0
- package/lib/module/Hmac.js +90 -0
- package/lib/module/Hmac.js.map +1 -0
- package/lib/module/NativeQuickCrypto/Cipher.js +2 -0
- package/lib/module/NativeQuickCrypto/Cipher.js.map +1 -0
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +53 -0
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -0
- package/lib/module/NativeQuickCrypto/hash.js +2 -0
- package/lib/module/NativeQuickCrypto/hash.js.map +1 -0
- package/lib/module/NativeQuickCrypto/hmac.js +2 -0
- package/lib/module/NativeQuickCrypto/hmac.js.map +1 -0
- package/lib/module/NativeQuickCrypto/pbkdf2.js +2 -0
- package/lib/module/NativeQuickCrypto/pbkdf2.js.map +1 -0
- package/lib/module/NativeQuickCrypto/random.js +2 -0
- package/lib/module/NativeQuickCrypto/random.js.map +1 -0
- package/lib/module/QuickCrypto.js +18 -0
- package/lib/module/QuickCrypto.js.map +1 -0
- package/lib/module/Utils.js +131 -0
- package/lib/module/Utils.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/pbkdf2.js +51 -0
- package/lib/module/pbkdf2.js.map +1 -0
- package/lib/module/random.js +190 -0
- package/lib/module/random.js.map +1 -0
- package/lib/typescript/Cipher.d.ts +30 -0
- package/lib/typescript/Hash.d.ts +44 -0
- package/lib/typescript/Hmac.d.ts +37 -0
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +22 -0
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +19 -0
- package/lib/typescript/NativeQuickCrypto/hash.d.ts +6 -0
- package/lib/typescript/NativeQuickCrypto/hmac.d.ts +5 -0
- package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts +4 -0
- package/lib/typescript/NativeQuickCrypto/random.d.ts +4 -0
- package/lib/typescript/QuickCrypto.d.ts +31 -0
- package/lib/typescript/Utils.d.ts +13 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/pbkdf2.d.ts +9 -0
- package/lib/typescript/random.d.ts +20 -0
- package/package.json +168 -0
- package/react-native-quick-crypto.podspec +44 -0
- package/src/Cipher.ts +322 -0
- package/src/Hash.ts +98 -0
- package/src/Hmac.ts +107 -0
- package/src/NativeQuickCrypto/Cipher.ts +25 -0
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +79 -0
- package/src/NativeQuickCrypto/hash.ts +10 -0
- package/src/NativeQuickCrypto/hmac.ts +9 -0
- package/src/NativeQuickCrypto/pbkdf2.ts +16 -0
- package/src/NativeQuickCrypto/random.ts +12 -0
- package/src/QuickCrypto.ts +23 -0
- package/src/Utils.ts +151 -0
- package/src/index.ts +1 -0
- package/src/pbkdf2.ts +96 -0
- package/src/random.ts +277 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
B85F94A127BE4A550046C221 /* QuickCryptoModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = B85F94A027BE4A550046C221 /* QuickCryptoModule.mm */; };
|
|
11
|
+
/* End PBXBuildFile section */
|
|
12
|
+
|
|
13
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
14
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
15
|
+
isa = PBXCopyFilesBuildPhase;
|
|
16
|
+
buildActionMask = 2147483647;
|
|
17
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
18
|
+
dstSubfolderSpec = 16;
|
|
19
|
+
files = (
|
|
20
|
+
);
|
|
21
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
22
|
+
};
|
|
23
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
24
|
+
|
|
25
|
+
/* Begin PBXFileReference section */
|
|
26
|
+
134814201AA4EA6300B7C361 /* libQuickCrypto.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libQuickCrypto.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
B85F949F27BE4A550046C221 /* QuickCryptoModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickCryptoModule.h; sourceTree = "<group>"; };
|
|
28
|
+
B85F94A027BE4A550046C221 /* QuickCryptoModule.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickCryptoModule.mm; sourceTree = "<group>"; };
|
|
29
|
+
B85F94A227BE4A5E0046C221 /* cpp */ = {isa = PBXFileReference; lastKnownFileType = folder; name = cpp; path = ../cpp; sourceTree = "<group>"; };
|
|
30
|
+
/* End PBXFileReference section */
|
|
31
|
+
|
|
32
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
33
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
34
|
+
isa = PBXFrameworksBuildPhase;
|
|
35
|
+
buildActionMask = 2147483647;
|
|
36
|
+
files = (
|
|
37
|
+
);
|
|
38
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
39
|
+
};
|
|
40
|
+
/* End PBXFrameworksBuildPhase section */
|
|
41
|
+
|
|
42
|
+
/* Begin PBXGroup section */
|
|
43
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
44
|
+
isa = PBXGroup;
|
|
45
|
+
children = (
|
|
46
|
+
134814201AA4EA6300B7C361 /* libQuickCrypto.a */,
|
|
47
|
+
);
|
|
48
|
+
name = Products;
|
|
49
|
+
sourceTree = "<group>";
|
|
50
|
+
};
|
|
51
|
+
58B511D21A9E6C8500147676 = {
|
|
52
|
+
isa = PBXGroup;
|
|
53
|
+
children = (
|
|
54
|
+
B85F949F27BE4A550046C221 /* QuickCryptoModule.h */,
|
|
55
|
+
B85F94A027BE4A550046C221 /* QuickCryptoModule.mm */,
|
|
56
|
+
B85F94A227BE4A5E0046C221 /* cpp */,
|
|
57
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
58
|
+
);
|
|
59
|
+
sourceTree = "<group>";
|
|
60
|
+
};
|
|
61
|
+
/* End PBXGroup section */
|
|
62
|
+
|
|
63
|
+
/* Begin PBXNativeTarget section */
|
|
64
|
+
58B511DA1A9E6C8500147676 /* QuickCrypto */ = {
|
|
65
|
+
isa = PBXNativeTarget;
|
|
66
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "QuickCrypto" */;
|
|
67
|
+
buildPhases = (
|
|
68
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
69
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
70
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
71
|
+
);
|
|
72
|
+
buildRules = (
|
|
73
|
+
);
|
|
74
|
+
dependencies = (
|
|
75
|
+
);
|
|
76
|
+
name = QuickCrypto;
|
|
77
|
+
productName = RCTDataManager;
|
|
78
|
+
productReference = 134814201AA4EA6300B7C361 /* libQuickCrypto.a */;
|
|
79
|
+
productType = "com.apple.product-type.library.static";
|
|
80
|
+
};
|
|
81
|
+
/* End PBXNativeTarget section */
|
|
82
|
+
|
|
83
|
+
/* Begin PBXProject section */
|
|
84
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
85
|
+
isa = PBXProject;
|
|
86
|
+
attributes = {
|
|
87
|
+
LastUpgradeCheck = 0920;
|
|
88
|
+
ORGANIZATIONNAME = Facebook;
|
|
89
|
+
TargetAttributes = {
|
|
90
|
+
58B511DA1A9E6C8500147676 = {
|
|
91
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "QuickCrypto" */;
|
|
96
|
+
compatibilityVersion = "Xcode 3.2";
|
|
97
|
+
developmentRegion = English;
|
|
98
|
+
hasScannedForEncodings = 0;
|
|
99
|
+
knownRegions = (
|
|
100
|
+
English,
|
|
101
|
+
en,
|
|
102
|
+
);
|
|
103
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
104
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
105
|
+
projectDirPath = "";
|
|
106
|
+
projectRoot = "";
|
|
107
|
+
targets = (
|
|
108
|
+
58B511DA1A9E6C8500147676 /* QuickCrypto */,
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
/* End PBXProject section */
|
|
112
|
+
|
|
113
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
114
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
115
|
+
isa = PBXSourcesBuildPhase;
|
|
116
|
+
buildActionMask = 2147483647;
|
|
117
|
+
files = (
|
|
118
|
+
B85F94A127BE4A550046C221 /* QuickCryptoModule.mm in Sources */,
|
|
119
|
+
);
|
|
120
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
121
|
+
};
|
|
122
|
+
/* End PBXSourcesBuildPhase section */
|
|
123
|
+
|
|
124
|
+
/* Begin XCBuildConfiguration section */
|
|
125
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
126
|
+
isa = XCBuildConfiguration;
|
|
127
|
+
buildSettings = {
|
|
128
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
129
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
130
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
131
|
+
CLANG_ENABLE_MODULES = YES;
|
|
132
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
133
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
134
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
135
|
+
CLANG_WARN_COMMA = YES;
|
|
136
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
137
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
138
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
139
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
140
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
141
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
142
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
143
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
144
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
145
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
146
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
147
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
148
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
149
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
150
|
+
COPY_PHASE_STRIP = NO;
|
|
151
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
152
|
+
ENABLE_TESTABILITY = YES;
|
|
153
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
154
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
155
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
156
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
157
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
158
|
+
"DEBUG=1",
|
|
159
|
+
"$(inherited)",
|
|
160
|
+
);
|
|
161
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
162
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
163
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
164
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
165
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
166
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
167
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
168
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
169
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
170
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
171
|
+
SDKROOT = iphoneos;
|
|
172
|
+
};
|
|
173
|
+
name = Debug;
|
|
174
|
+
};
|
|
175
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
176
|
+
isa = XCBuildConfiguration;
|
|
177
|
+
buildSettings = {
|
|
178
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
179
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
180
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
181
|
+
CLANG_ENABLE_MODULES = YES;
|
|
182
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
183
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
184
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
185
|
+
CLANG_WARN_COMMA = YES;
|
|
186
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
187
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
188
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
189
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
190
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
191
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
192
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
193
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
194
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
195
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
196
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
197
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
198
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
199
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
200
|
+
COPY_PHASE_STRIP = YES;
|
|
201
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
202
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
203
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
204
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
205
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
206
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
207
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
208
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
209
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
210
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
211
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
212
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
213
|
+
SDKROOT = iphoneos;
|
|
214
|
+
VALIDATE_PRODUCT = YES;
|
|
215
|
+
};
|
|
216
|
+
name = Release;
|
|
217
|
+
};
|
|
218
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
219
|
+
isa = XCBuildConfiguration;
|
|
220
|
+
buildSettings = {
|
|
221
|
+
HEADER_SEARCH_PATHS = (
|
|
222
|
+
"$(inherited)",
|
|
223
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
224
|
+
"$(SRCROOT)/../../../React/**",
|
|
225
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
226
|
+
);
|
|
227
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
228
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
229
|
+
PRODUCT_NAME = QuickCrypto;
|
|
230
|
+
SKIP_INSTALL = YES;
|
|
231
|
+
};
|
|
232
|
+
name = Debug;
|
|
233
|
+
};
|
|
234
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
235
|
+
isa = XCBuildConfiguration;
|
|
236
|
+
buildSettings = {
|
|
237
|
+
HEADER_SEARCH_PATHS = (
|
|
238
|
+
"$(inherited)",
|
|
239
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
240
|
+
"$(SRCROOT)/../../../React/**",
|
|
241
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
242
|
+
);
|
|
243
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
244
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
245
|
+
PRODUCT_NAME = QuickCrypto;
|
|
246
|
+
SKIP_INSTALL = YES;
|
|
247
|
+
};
|
|
248
|
+
name = Release;
|
|
249
|
+
};
|
|
250
|
+
/* End XCBuildConfiguration section */
|
|
251
|
+
|
|
252
|
+
/* Begin XCConfigurationList section */
|
|
253
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "QuickCrypto" */ = {
|
|
254
|
+
isa = XCConfigurationList;
|
|
255
|
+
buildConfigurations = (
|
|
256
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
257
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
258
|
+
);
|
|
259
|
+
defaultConfigurationIsVisible = 0;
|
|
260
|
+
defaultConfigurationName = Release;
|
|
261
|
+
};
|
|
262
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "QuickCrypto" */ = {
|
|
263
|
+
isa = XCConfigurationList;
|
|
264
|
+
buildConfigurations = (
|
|
265
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
266
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
267
|
+
);
|
|
268
|
+
defaultConfigurationIsVisible = 0;
|
|
269
|
+
defaultConfigurationName = Release;
|
|
270
|
+
};
|
|
271
|
+
/* End XCConfigurationList section */
|
|
272
|
+
};
|
|
273
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
274
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#import "QuickCryptoModule.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTBridge+Private.h>
|
|
4
|
+
#import <React/RCTUtils.h>
|
|
5
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
6
|
+
#import <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#import "../cpp/MGLQuickCryptoHostObject.h"
|
|
9
|
+
|
|
10
|
+
@implementation QuickCryptoModule
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE(QuickCrypto)
|
|
13
|
+
|
|
14
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
|
|
15
|
+
NSLog(@"Installing JSI bindings for react-native-quick-crypto...");
|
|
16
|
+
RCTBridge* bridge = [RCTBridge currentBridge];
|
|
17
|
+
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
|
|
18
|
+
if (cxxBridge == nil) {
|
|
19
|
+
return @false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
|
|
25
|
+
if (jsiRuntime == nil) {
|
|
26
|
+
return @false;
|
|
27
|
+
}
|
|
28
|
+
auto& runtime = *jsiRuntime;
|
|
29
|
+
auto callInvoker = bridge.jsCallInvoker;
|
|
30
|
+
|
|
31
|
+
auto workerQueue =
|
|
32
|
+
std::make_shared<margelo::DispatchQueue::dispatch_queue>("margelo crypto thread");
|
|
33
|
+
auto hostObject = std::static_pointer_cast<jsi::HostObject>(
|
|
34
|
+
std::make_shared<margelo::MGLQuickCryptoHostObject>(callInvoker, workerQueue));
|
|
35
|
+
auto object = jsi::Object::createFromHostObject(runtime, hostObject);
|
|
36
|
+
runtime.global().setProperty(runtime, "__QuickCryptoProxy", std::move(object));
|
|
37
|
+
|
|
38
|
+
NSLog(@"Successfully installed JSI bindings for react-native-quick-crypto!");
|
|
39
|
+
return @true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@end
|
package/lib/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCipher = createCipher;
|
|
7
|
+
exports.createCipheriv = createCipheriv;
|
|
8
|
+
exports.createDecipher = createDecipher;
|
|
9
|
+
exports.createDecipheriv = createDecipheriv;
|
|
10
|
+
|
|
11
|
+
var _NativeQuickCrypto = require("./NativeQuickCrypto/NativeQuickCrypto");
|
|
12
|
+
|
|
13
|
+
var _stream = _interopRequireDefault(require("stream"));
|
|
14
|
+
|
|
15
|
+
var _Utils = require("./Utils");
|
|
16
|
+
|
|
17
|
+
var _string_decoder = require("string_decoder");
|
|
18
|
+
|
|
19
|
+
var _safeBuffer = require("safe-buffer");
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
|
|
23
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
|
|
25
|
+
const createInternalCipher = _NativeQuickCrypto.NativeQuickCrypto.createCipher;
|
|
26
|
+
const createInternalDecipher = _NativeQuickCrypto.NativeQuickCrypto.createDecipher;
|
|
27
|
+
|
|
28
|
+
function getUIntOption(options, key) {
|
|
29
|
+
let value;
|
|
30
|
+
|
|
31
|
+
if (options && (value = options[key]) != null) {
|
|
32
|
+
// >>> Turns any type into a positive integer (also sets the sign bit to 0)
|
|
33
|
+
// eslint-disable-next-line no-bitwise
|
|
34
|
+
if (value >>> 0 !== value) throw new Error(`options.${key}: ${value}`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function normalizeEncoding(enc) {
|
|
42
|
+
if (!enc) return 'utf8';
|
|
43
|
+
var retried;
|
|
44
|
+
|
|
45
|
+
while (true) {
|
|
46
|
+
switch (enc) {
|
|
47
|
+
case 'utf8':
|
|
48
|
+
case 'utf-8':
|
|
49
|
+
return 'utf8';
|
|
50
|
+
|
|
51
|
+
case 'ucs2':
|
|
52
|
+
case 'ucs-2':
|
|
53
|
+
case 'utf16le':
|
|
54
|
+
case 'utf-16le':
|
|
55
|
+
return 'utf16le';
|
|
56
|
+
|
|
57
|
+
case 'latin1':
|
|
58
|
+
case 'binary':
|
|
59
|
+
return 'latin1';
|
|
60
|
+
|
|
61
|
+
case 'base64':
|
|
62
|
+
case 'ascii':
|
|
63
|
+
case 'hex':
|
|
64
|
+
return enc;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
if (retried) return; // undefined
|
|
68
|
+
|
|
69
|
+
enc = ('' + enc).toLowerCase();
|
|
70
|
+
retried = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function validateEncoding(data, encoding) {
|
|
76
|
+
const normalizedEncoding = normalizeEncoding(encoding);
|
|
77
|
+
const length = data.length;
|
|
78
|
+
|
|
79
|
+
if (normalizedEncoding === 'hex' && length % 2 !== 0) {
|
|
80
|
+
throw new Error(`Encoding ${encoding} not valid for data length ${length}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getDecoder(decoder, encoding) {
|
|
85
|
+
return decoder !== null && decoder !== void 0 ? decoder : new _string_decoder.StringDecoder(encoding);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
class CipherCommon extends _stream.default.Transform {
|
|
89
|
+
constructor(cipherType, cipherKey, isCipher) {
|
|
90
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
91
|
+
let iv = arguments.length > 4 ? arguments[4] : undefined;
|
|
92
|
+
super(options);
|
|
93
|
+
|
|
94
|
+
_defineProperty(this, "internal", void 0);
|
|
95
|
+
|
|
96
|
+
_defineProperty(this, "decoder", void 0);
|
|
97
|
+
|
|
98
|
+
const cipherKeyBuffer = (0, _Utils.binaryLikeToArrayBuffer)(cipherKey); // TODO(osp) This might not be smart, check again after release
|
|
99
|
+
|
|
100
|
+
const authTagLength = getUIntOption(options, 'authTagLength');
|
|
101
|
+
const args = {
|
|
102
|
+
cipher_type: cipherType,
|
|
103
|
+
cipher_key: cipherKeyBuffer,
|
|
104
|
+
iv,
|
|
105
|
+
...options,
|
|
106
|
+
auth_tag_len: authTagLength
|
|
107
|
+
};
|
|
108
|
+
this.internal = isCipher ? createInternalCipher(args) : createInternalDecipher(args);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
update(data, inputEncoding, outputEncoding) {
|
|
112
|
+
var _inputEncoding, _outputEncoding;
|
|
113
|
+
|
|
114
|
+
const defaultEncoding = (0, _Utils.getDefaultEncoding)();
|
|
115
|
+
inputEncoding = (_inputEncoding = inputEncoding) !== null && _inputEncoding !== void 0 ? _inputEncoding : defaultEncoding;
|
|
116
|
+
outputEncoding = (_outputEncoding = outputEncoding) !== null && _outputEncoding !== void 0 ? _outputEncoding : defaultEncoding;
|
|
117
|
+
|
|
118
|
+
if (typeof data === 'string') {
|
|
119
|
+
validateEncoding(data, inputEncoding);
|
|
120
|
+
} else if (!ArrayBuffer.isView(data)) {
|
|
121
|
+
throw new Error('Invalid data argument');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (typeof data === 'string') {
|
|
125
|
+
// On node this is handled on the native side
|
|
126
|
+
// on our case we need to correctly send the arraybuffer to the jsi side
|
|
127
|
+
inputEncoding = inputEncoding === 'buffer' ? 'utf8' : inputEncoding;
|
|
128
|
+
data = (0, _Utils.binaryLikeToArrayBuffer)(data, inputEncoding);
|
|
129
|
+
} else {
|
|
130
|
+
data = (0, _Utils.binaryLikeToArrayBuffer)(data, inputEncoding);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const ret = this.internal.update(data);
|
|
134
|
+
|
|
135
|
+
if (outputEncoding && outputEncoding !== 'buffer') {
|
|
136
|
+
this.decoder = getDecoder(this.decoder, outputEncoding);
|
|
137
|
+
return this.decoder.write(_safeBuffer.Buffer.from(ret));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return ret;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
final(outputEncoding) {
|
|
144
|
+
const ret = this.internal.final();
|
|
145
|
+
|
|
146
|
+
if (outputEncoding && outputEncoding !== 'buffer') {
|
|
147
|
+
this.decoder = getDecoder(this.decoder, outputEncoding);
|
|
148
|
+
return this.decoder.end(_safeBuffer.Buffer.from(ret));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return ret;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_transform(chunk, encoding, callback) {
|
|
155
|
+
this.push(this.update(chunk, encoding));
|
|
156
|
+
callback();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
_flush(callback) {
|
|
160
|
+
this.push(this.final());
|
|
161
|
+
callback();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
setAutoPadding(autoPadding) {
|
|
165
|
+
this.internal.setAutoPadding(!!autoPadding);
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
setAAD(buffer, options) {
|
|
170
|
+
this.internal.setAAD({
|
|
171
|
+
data: buffer.buffer,
|
|
172
|
+
plaintextLength: options === null || options === void 0 ? void 0 : options.plaintextLength
|
|
173
|
+
});
|
|
174
|
+
return this;
|
|
175
|
+
} // protected getAuthTag(): Buffer {
|
|
176
|
+
// return Buffer.from(this.internal.getAuthTag());
|
|
177
|
+
// }
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
setAuthTag(tag) {
|
|
181
|
+
this.internal.setAuthTag(tag.buffer);
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
class Cipher extends CipherCommon {
|
|
188
|
+
constructor(cipherType, cipherKey) {
|
|
189
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
190
|
+
let iv = arguments.length > 3 ? arguments[3] : undefined;
|
|
191
|
+
|
|
192
|
+
if (iv != null) {
|
|
193
|
+
iv = (0, _Utils.binaryLikeToArrayBuffer)(iv);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
super(cipherType, cipherKey, true, options, iv);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
class Decipher extends CipherCommon {
|
|
202
|
+
constructor(cipherType, cipherKey) {
|
|
203
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
204
|
+
let iv = arguments.length > 3 ? arguments[3] : undefined;
|
|
205
|
+
|
|
206
|
+
if (iv != null) {
|
|
207
|
+
iv = (0, _Utils.binaryLikeToArrayBuffer)(iv);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
super(cipherType, cipherKey, false, options, iv);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
} // TODO(osp) This definitions cause typescript errors when using the API
|
|
214
|
+
// export function createDecipher(
|
|
215
|
+
// algorithm: CipherCCMTypes,
|
|
216
|
+
// password: BinaryLike,
|
|
217
|
+
// options: CipherCCMOptions
|
|
218
|
+
// ): Decipher;
|
|
219
|
+
// export function createDecipher(
|
|
220
|
+
// algorithm: CipherGCMTypes,
|
|
221
|
+
// password: BinaryLike,
|
|
222
|
+
// options?: CipherGCMOptions
|
|
223
|
+
// ): Decipher;
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
function createDecipher(algorithm, password, options) {
|
|
227
|
+
return new Decipher(algorithm, password, options);
|
|
228
|
+
} // TODO(osp) This definitions cause typescript errors when using the API
|
|
229
|
+
// export function createDecipheriv(
|
|
230
|
+
// algorithm: CipherCCMTypes,
|
|
231
|
+
// key: BinaryLike,
|
|
232
|
+
// iv: BinaryLike,
|
|
233
|
+
// options: CipherCCMOptions
|
|
234
|
+
// ): Decipher;
|
|
235
|
+
// export function createDecipheriv(
|
|
236
|
+
// algorithm: CipherOCBTypes,
|
|
237
|
+
// key: BinaryLike,
|
|
238
|
+
// iv: BinaryLike,
|
|
239
|
+
// options: CipherOCBOptions
|
|
240
|
+
// ): DecipherOCB;
|
|
241
|
+
// export function createDecipheriv(
|
|
242
|
+
// algorithm: CipherGCMTypes,
|
|
243
|
+
// key: BinaryLike,
|
|
244
|
+
// iv: BinaryLike,
|
|
245
|
+
// options?: CipherGCMOptions
|
|
246
|
+
// ): Decipher;
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
function createDecipheriv(algorithm, key, iv, options) {
|
|
250
|
+
return new Decipher(algorithm, key, options, iv);
|
|
251
|
+
} // TODO(osp) This definitions cause typescript errors when using the API
|
|
252
|
+
// commenting them out for now
|
|
253
|
+
// export function createCipher(
|
|
254
|
+
// algorithm: CipherCCMTypes,
|
|
255
|
+
// password: BinaryLike,
|
|
256
|
+
// options: CipherCCMOptions
|
|
257
|
+
// ): Cipher;
|
|
258
|
+
// export function createCipher(
|
|
259
|
+
// algorithm: CipherGCMTypes,
|
|
260
|
+
// password: BinaryLike,
|
|
261
|
+
// options?: CipherGCMOptions
|
|
262
|
+
// ): Cipher;
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
function createCipher(algorithm, password, options) {
|
|
266
|
+
return new Cipher(algorithm, password, options);
|
|
267
|
+
} // TODO(osp) on all the createCipheriv methods, node seems to use a "KeyObject" is seems to be a thread safe
|
|
268
|
+
// object that creates keys and what not. Not sure if we should support it.
|
|
269
|
+
// Fow now I replaced all of them to BinaryLike
|
|
270
|
+
// export function createCipheriv(
|
|
271
|
+
// algorithm: CipherCCMTypes,
|
|
272
|
+
// key: BinaryLike,
|
|
273
|
+
// iv: BinaryLike,
|
|
274
|
+
// options: CipherCCMOptions
|
|
275
|
+
// ): Cipher;
|
|
276
|
+
// export function createCipheriv(
|
|
277
|
+
// algorithm: CipherOCBTypes,
|
|
278
|
+
// key: BinaryLike,
|
|
279
|
+
// iv: BinaryLike,
|
|
280
|
+
// options: CipherOCBOptions
|
|
281
|
+
// ): CipherOCB;
|
|
282
|
+
// export function createCipheriv(
|
|
283
|
+
// algorithm: CipherGCMTypes,
|
|
284
|
+
// key: BinaryLike,
|
|
285
|
+
// iv: BinaryLike,
|
|
286
|
+
// options?: CipherGCMOptions
|
|
287
|
+
// ): Cipher;
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
function createCipheriv(algorithm, key, iv, options) {
|
|
291
|
+
return new Cipher(algorithm, key, options, iv);
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=Cipher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Cipher.ts"],"names":["createInternalCipher","NativeQuickCrypto","createCipher","createInternalDecipher","createDecipher","getUIntOption","options","key","value","Error","normalizeEncoding","enc","retried","toLowerCase","validateEncoding","data","encoding","normalizedEncoding","length","getDecoder","decoder","StringDecoder","CipherCommon","Stream","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","SBuffer","from","final","end","_transform","chunk","callback","push","_flush","setAutoPadding","autoPadding","setAAD","buffer","plaintextLength","setAuthTag","tag","Cipher","Decipher","algorithm","password","createDecipheriv","createCipheriv"],"mappings":";;;;;;;;;;AACA;;AACA;;AACA;;AAqBA;;AAEA;;;;;;AAEA,MAAMA,oBAAoB,GAAGC,qCAAkBC,YAA/C;AACA,MAAMC,sBAAsB,GAAGF,qCAAkBG,cAAjD;;AAEA,SAASC,aAAT,CAAuBC,OAAvB,EAAqDC,GAArD,EAAkE;AAChE,MAAIC,KAAJ;;AACA,MAAIF,OAAO,IAAI,CAACE,KAAK,GAAGF,OAAO,CAACC,GAAD,CAAhB,KAA0B,IAAzC,EAA+C;AAC7C;AACA;AACA,QAAIC,KAAK,KAAK,CAAV,KAAgBA,KAApB,EAA2B,MAAM,IAAIC,KAAJ,CAAW,WAAUF,GAAI,KAAIC,KAAM,EAAnC,CAAN;AAC3B,WAAOA,KAAP;AACD;;AACD,SAAO,CAAC,CAAR;AACD;;AAED,SAASE,iBAAT,CAA2BC,GAA3B,EAAwC;AACtC,MAAI,CAACA,GAAL,EAAU,OAAO,MAAP;AACV,MAAIC,OAAJ;;AACA,SAAO,IAAP,EAAa;AACX,YAAQD,GAAR;AACE,WAAK,MAAL;AACA,WAAK,OAAL;AACE,eAAO,MAAP;;AACF,WAAK,MAAL;AACA,WAAK,OAAL;AACA,WAAK,SAAL;AACA,WAAK,UAAL;AACE,eAAO,SAAP;;AACF,WAAK,QAAL;AACA,WAAK,QAAL;AACE,eAAO,QAAP;;A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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS4D,cAAT,CACLH,SADK,EAELxD,GAFK,EAGLsB,EAHK,EAILvB,OAJK,EAKG;AACR,SAAO,IAAIuD,MAAJ,CAAWE,SAAX,EAAsBxD,GAAtB,EAA2BD,OAA3B,EAAoCuB,EAApC,CAAP;AACD","sourcesContent":["/* eslint-disable no-dupe-class-members */\nimport { NativeQuickCrypto } from './NativeQuickCrypto/NativeQuickCrypto';\nimport Stream from 'stream';\nimport {\n BinaryLike,\n binaryLikeToArrayBuffer,\n CipherEncoding,\n Encoding,\n getDefaultEncoding,\n} from './Utils';\nimport type { InternalCipher } from './NativeQuickCrypto/Cipher';\n// TODO(osp) re-enable type specific constructors\n// They are nice to have but not absolutely necessary\n// import type {\n// CipherCCMOptions,\n// CipherCCMTypes,\n// CipherGCMTypes,\n// CipherGCMOptions,\n// // CipherKey,\n// // KeyObject,\n// // TODO @Szymon20000 This types seem to be missing? Where did you get this definitions from?\n// // CipherOCBTypes,\n// // CipherOCBOptions,\n// } from 'crypto'; // Node crypto typings\nimport { StringDecoder } from 'string_decoder';\nimport type { Buffer } from '@craftzdog/react-native-buffer';\nimport { Buffer as SBuffer } from 'safe-buffer';\n\nconst createInternalCipher = NativeQuickCrypto.createCipher;\nconst createInternalDecipher = NativeQuickCrypto.createDecipher;\n\nfunction getUIntOption(options: Record<string, any>, key: string) {\n let value;\n if (options && (value = options[key]) != null) {\n // >>> Turns any type into a positive integer (also sets the sign bit to 0)\n // eslint-disable-next-line no-bitwise\n if (value >>> 0 !== value) throw new Error(`options.${key}: ${value}`);\n return value;\n }\n return -1;\n}\n\nfunction normalizeEncoding(enc: string) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n}\n\nfunction validateEncoding(data: string, encoding: string) {\n const normalizedEncoding = normalizeEncoding(encoding);\n const length = data.length;\n\n if (normalizedEncoding === 'hex' && length % 2 !== 0) {\n throw new Error(`Encoding ${encoding} not valid for data length ${length}`);\n }\n}\n\nfunction getDecoder(decoder?: StringDecoder, encoding?: BufferEncoding) {\n return decoder ?? new StringDecoder(encoding);\n}\n\nclass CipherCommon extends Stream.Transform {\n private internal: InternalCipher;\n private decoder: StringDecoder | undefined;\n\n constructor(\n cipherType: string,\n cipherKey: BinaryLike,\n isCipher: boolean,\n options: Record<string, any> = {},\n iv?: BinaryLike | null\n ) {\n super(options);\n const cipherKeyBuffer = binaryLikeToArrayBuffer(cipherKey);\n // TODO(osp) This might not be smart, check again after release\n const authTagLength = getUIntOption(options, 'authTagLength');\n const args = {\n cipher_type: cipherType,\n cipher_key: cipherKeyBuffer,\n iv,\n ...options,\n auth_tag_len: authTagLength,\n };\n this.internal = isCipher\n ? createInternalCipher(args)\n : createInternalDecipher(args);\n }\n\n update(\n data: BinaryLike,\n inputEncoding?: CipherEncoding,\n outputEncoding?: CipherEncoding\n ): ArrayBuffer | string {\n const defaultEncoding = getDefaultEncoding();\n inputEncoding = inputEncoding ?? defaultEncoding;\n outputEncoding = outputEncoding ?? defaultEncoding;\n\n if (typeof data === 'string') {\n validateEncoding(data, inputEncoding);\n } else if (!ArrayBuffer.isView(data)) {\n throw new Error('Invalid data argument');\n }\n\n if (typeof data === 'string') {\n // On node this is handled on the native side\n // on our case we need to correctly send the arraybuffer to the jsi side\n inputEncoding = inputEncoding === 'buffer' ? 'utf8' : inputEncoding;\n data = binaryLikeToArrayBuffer(data, inputEncoding);\n } else {\n data = binaryLikeToArrayBuffer(data as any, inputEncoding);\n }\n\n const ret = this.internal.update(data);\n\n if (outputEncoding && outputEncoding !== 'buffer') {\n this.decoder = getDecoder(this.decoder, outputEncoding);\n\n return this.decoder!.write(SBuffer.from(ret) as any);\n }\n\n return ret;\n }\n\n final(): ArrayBuffer;\n final(outputEncoding: BufferEncoding | 'buffer'): string;\n final(outputEncoding?: BufferEncoding | 'buffer'): ArrayBuffer | string {\n const ret = this.internal.final();\n\n if (outputEncoding && outputEncoding !== 'buffer') {\n this.decoder = getDecoder(this.decoder, outputEncoding);\n\n return this.decoder!.end(SBuffer.from(ret) as any);\n }\n\n return ret;\n }\n\n _transform(chunk: BinaryLike, encoding: Encoding, callback: () => void) {\n this.push(this.update(chunk, encoding));\n callback();\n }\n\n _flush(callback: () => void) {\n this.push(this.final());\n callback();\n }\n\n public setAutoPadding(autoPadding?: boolean): this {\n this.internal.setAutoPadding(!!autoPadding);\n return this;\n }\n\n public setAAD(\n buffer: Buffer,\n options?: {\n plaintextLength: number;\n }\n ): this {\n this.internal.setAAD({\n data: buffer.buffer,\n plaintextLength: options?.plaintextLength,\n });\n return this;\n }\n\n // protected getAuthTag(): Buffer {\n // return Buffer.from(this.internal.getAuthTag());\n // }\n\n public setAuthTag(tag: Buffer): this {\n this.internal.setAuthTag(tag.buffer);\n return this;\n }\n}\n\nclass Cipher extends CipherCommon {\n constructor(\n cipherType: string,\n cipherKey: BinaryLike,\n options: Record<string, any> = {},\n iv?: BinaryLike | null\n ) {\n if (iv != null) {\n iv = binaryLikeToArrayBuffer(iv);\n }\n super(cipherType, cipherKey, true, options, iv);\n }\n}\n\nclass Decipher extends CipherCommon {\n constructor(\n cipherType: string,\n cipherKey: BinaryLike,\n options: Record<string, any> = {},\n iv?: BinaryLike | null\n ) {\n if (iv != null) {\n iv = binaryLikeToArrayBuffer(iv);\n }\n\n super(cipherType, cipherKey, false, options, iv);\n }\n}\n\n// TODO(osp) This definitions cause typescript errors when using the API\n// export function createDecipher(\n// algorithm: CipherCCMTypes,\n// password: BinaryLike,\n// options: CipherCCMOptions\n// ): Decipher;\n// export function createDecipher(\n// algorithm: CipherGCMTypes,\n// password: BinaryLike,\n// options?: CipherGCMOptions\n// ): Decipher;\nexport function createDecipher(\n algorithm: string,\n password: BinaryLike,\n options?: Stream.TransformOptions\n): Decipher {\n return new Decipher(algorithm, password, options);\n}\n\n// TODO(osp) This definitions cause typescript errors when using the API\n// export function createDecipheriv(\n// algorithm: CipherCCMTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options: CipherCCMOptions\n// ): Decipher;\n// export function createDecipheriv(\n// algorithm: CipherOCBTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options: CipherOCBOptions\n// ): DecipherOCB;\n// export function createDecipheriv(\n// algorithm: CipherGCMTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options?: CipherGCMOptions\n// ): Decipher;\nexport function createDecipheriv(\n algorithm: string,\n key: BinaryLike,\n iv: BinaryLike | null,\n options?: Stream.TransformOptions\n): Decipher {\n return new Decipher(algorithm, key, options, iv);\n}\n\n// TODO(osp) This definitions cause typescript errors when using the API\n// commenting them out for now\n// export function createCipher(\n// algorithm: CipherCCMTypes,\n// password: BinaryLike,\n// options: CipherCCMOptions\n// ): Cipher;\n// export function createCipher(\n// algorithm: CipherGCMTypes,\n// password: BinaryLike,\n// options?: CipherGCMOptions\n// ): Cipher;\nexport function createCipher(\n algorithm: string,\n password: BinaryLike,\n options?: Stream.TransformOptions\n): Cipher {\n return new Cipher(algorithm, password, options);\n}\n\n// TODO(osp) on all the createCipheriv methods, node seems to use a \"KeyObject\" is seems to be a thread safe\n// object that creates keys and what not. Not sure if we should support it.\n// Fow now I replaced all of them to BinaryLike\n// export function createCipheriv(\n// algorithm: CipherCCMTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options: CipherCCMOptions\n// ): Cipher;\n// export function createCipheriv(\n// algorithm: CipherOCBTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options: CipherOCBOptions\n// ): CipherOCB;\n// export function createCipheriv(\n// algorithm: CipherGCMTypes,\n// key: BinaryLike,\n// iv: BinaryLike,\n// options?: CipherGCMOptions\n// ): Cipher;\nexport function createCipheriv(\n algorithm: string,\n key: BinaryLike,\n iv: BinaryLike | null,\n options?: Stream.TransformOptions\n): Cipher {\n return new Cipher(algorithm, key, options, iv);\n}\n"]}
|