react-native-mosquito-transport 0.0.14

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 (86) hide show
  1. package/CODE_OF_CONDUCT.md +133 -0
  2. package/CONTRIBUTING.md +114 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1 -0
  5. package/android/build.gradle +77 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +4 -0
  8. package/android/src/main/java/com/mosquitodb/MosquitodbModule.java +32 -0
  9. package/android/src/main/java/com/mosquitodb/MosquitodbPackage.java +28 -0
  10. package/example/.bundle/config +2 -0
  11. package/example/.node-version +1 -0
  12. package/example/.watchmanconfig +1 -0
  13. package/example/Gemfile +6 -0
  14. package/example/android/app/build.gradle +170 -0
  15. package/example/android/app/debug.keystore +0 -0
  16. package/example/android/app/proguard-rules.pro +10 -0
  17. package/example/android/app/src/debug/AndroidManifest.xml +13 -0
  18. package/example/android/app/src/debug/java/com/mosquitodbexample/ReactNativeFlipper.java +75 -0
  19. package/example/android/app/src/main/AndroidManifest.xml +25 -0
  20. package/example/android/app/src/main/java/com/mosquitodbexample/MainActivity.java +35 -0
  21. package/example/android/app/src/main/java/com/mosquitodbexample/MainApplication.java +62 -0
  22. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  23. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  24. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  25. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  26. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  27. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  28. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  29. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  30. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  31. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  32. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  33. package/example/android/app/src/main/res/values/strings.xml +3 -0
  34. package/example/android/app/src/main/res/values/styles.xml +9 -0
  35. package/example/android/app/src/release/java/com/mosquitodbexample/ReactNativeFlipper.java +20 -0
  36. package/example/android/build.gradle +21 -0
  37. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  38. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  39. package/example/android/gradle.properties +44 -0
  40. package/example/android/gradlew +234 -0
  41. package/example/android/gradlew.bat +89 -0
  42. package/example/android/settings.gradle +4 -0
  43. package/example/app.json +4 -0
  44. package/example/babel.config.js +17 -0
  45. package/example/index.js +5 -0
  46. package/example/ios/.xcode.env +11 -0
  47. package/example/ios/File.swift +6 -0
  48. package/example/ios/MosquitodbExample/AppDelegate.h +6 -0
  49. package/example/ios/MosquitodbExample/AppDelegate.mm +36 -0
  50. package/example/ios/MosquitodbExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  51. package/example/ios/MosquitodbExample/Images.xcassets/Contents.json +6 -0
  52. package/example/ios/MosquitodbExample/Info.plist +55 -0
  53. package/example/ios/MosquitodbExample/LaunchScreen.storyboard +47 -0
  54. package/example/ios/MosquitodbExample/main.m +10 -0
  55. package/example/ios/MosquitodbExample-Bridging-Header.h +3 -0
  56. package/example/ios/MosquitodbExample.xcodeproj/project.pbxproj +702 -0
  57. package/example/ios/MosquitodbExample.xcodeproj/xcshareddata/xcschemes/MosquitodbExample.xcscheme +88 -0
  58. package/example/ios/MosquitodbExampleTests/Info.plist +24 -0
  59. package/example/ios/MosquitodbExampleTests/MosquitodbExampleTests.m +66 -0
  60. package/example/ios/Podfile +60 -0
  61. package/example/metro.config.js +40 -0
  62. package/example/package.json +22 -0
  63. package/example/react-native.config.js +10 -0
  64. package/example/src/App.tsx +31 -0
  65. package/ios/Mosquitodb-Bridging-Header.h +2 -0
  66. package/ios/Mosquitodb.m +22 -0
  67. package/ios/Mosquitodb.swift +305 -0
  68. package/ios/Mosquitodb.xcodeproj/project.pbxproj +283 -0
  69. package/package.json +45 -0
  70. package/react-native-mosquitodb.podspec +35 -0
  71. package/src/helpers/EngineApi.js +34 -0
  72. package/src/helpers/listeners.js +7 -0
  73. package/src/helpers/peripherals.js +195 -0
  74. package/src/helpers/utils.js +113 -0
  75. package/src/helpers/values.js +72 -0
  76. package/src/helpers/variables.js +34 -0
  77. package/src/index.d.ts +373 -0
  78. package/src/index.js +369 -0
  79. package/src/products/auth/accessor.js +151 -0
  80. package/src/products/auth/index.js +279 -0
  81. package/src/products/database/accessor.js +316 -0
  82. package/src/products/database/index.js +603 -0
  83. package/src/products/database/types.js +22 -0
  84. package/src/products/database/validator.js +282 -0
  85. package/src/products/http_callable/index.js +230 -0
  86. package/src/products/storage/index.js +217 -0
@@ -0,0 +1,283 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 5E555C0D2413F4C50049A1A2 /* Mosquitodb.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Mosquitodb.m */; };
11
+ F4FF95D7245B92E800C19C63 /* Mosquitodb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* Mosquitodb.swift */; };
12
+ /* End PBXBuildFile section */
13
+
14
+ /* Begin PBXCopyFilesBuildPhase section */
15
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
16
+ isa = PBXCopyFilesBuildPhase;
17
+ buildActionMask = 2147483647;
18
+ dstPath = "include/$(PRODUCT_NAME)";
19
+ dstSubfolderSpec = 16;
20
+ files = (
21
+ );
22
+ runOnlyForDeploymentPostprocessing = 0;
23
+ };
24
+ /* End PBXCopyFilesBuildPhase section */
25
+
26
+ /* Begin PBXFileReference section */
27
+ 134814201AA4EA6300B7C361 /* libMosquitodb.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMosquitodb.a; sourceTree = BUILT_PRODUCTS_DIR; };
28
+ B3E7B5891CC2AC0600A0062D /* Mosquitodb.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mosquitodb.m; sourceTree = "<group>"; };
29
+ F4FF95D5245B92E700C19C63 /* Mosquitodb-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Mosquitodb-Bridging-Header.h"; sourceTree = "<group>"; };
30
+ F4FF95D6245B92E800C19C63 /* Mosquitodb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mosquitodb.swift; sourceTree = "<group>"; };
31
+ /* End PBXFileReference section */
32
+
33
+ /* Begin PBXFrameworksBuildPhase section */
34
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
35
+ isa = PBXFrameworksBuildPhase;
36
+ buildActionMask = 2147483647;
37
+ files = (
38
+ );
39
+ runOnlyForDeploymentPostprocessing = 0;
40
+ };
41
+ /* End PBXFrameworksBuildPhase section */
42
+
43
+ /* Begin PBXGroup section */
44
+ 134814211AA4EA7D00B7C361 /* Products */ = {
45
+ isa = PBXGroup;
46
+ children = (
47
+ 134814201AA4EA6300B7C361 /* libMosquitodb.a */,
48
+ );
49
+ name = Products;
50
+ sourceTree = "<group>";
51
+ };
52
+ 58B511D21A9E6C8500147676 = {
53
+ isa = PBXGroup;
54
+ children = (
55
+ F4FF95D6245B92E800C19C63 /* Mosquitodb.swift */,
56
+ B3E7B5891CC2AC0600A0062D /* Mosquitodb.m */,
57
+ F4FF95D5245B92E700C19C63 /* Mosquitodb-Bridging-Header.h */,
58
+ 134814211AA4EA7D00B7C361 /* Products */,
59
+ );
60
+ sourceTree = "<group>";
61
+ };
62
+ /* End PBXGroup section */
63
+
64
+ /* Begin PBXNativeTarget section */
65
+ 58B511DA1A9E6C8500147676 /* Mosquitodb */ = {
66
+ isa = PBXNativeTarget;
67
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Mosquitodb" */;
68
+ buildPhases = (
69
+ 58B511D71A9E6C8500147676 /* Sources */,
70
+ 58B511D81A9E6C8500147676 /* Frameworks */,
71
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
72
+ );
73
+ buildRules = (
74
+ );
75
+ dependencies = (
76
+ );
77
+ name = Mosquitodb;
78
+ productName = RCTDataManager;
79
+ productReference = 134814201AA4EA6300B7C361 /* libMosquitodb.a */;
80
+ productType = "com.apple.product-type.library.static";
81
+ };
82
+ /* End PBXNativeTarget section */
83
+
84
+ /* Begin PBXProject section */
85
+ 58B511D31A9E6C8500147676 /* Project object */ = {
86
+ isa = PBXProject;
87
+ attributes = {
88
+ LastUpgradeCheck = 0920;
89
+ ORGANIZATIONNAME = Facebook;
90
+ TargetAttributes = {
91
+ 58B511DA1A9E6C8500147676 = {
92
+ CreatedOnToolsVersion = 6.1.1;
93
+ };
94
+ };
95
+ };
96
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Mosquitodb" */;
97
+ compatibilityVersion = "Xcode 3.2";
98
+ developmentRegion = English;
99
+ hasScannedForEncodings = 0;
100
+ knownRegions = (
101
+ English,
102
+ en,
103
+ );
104
+ mainGroup = 58B511D21A9E6C8500147676;
105
+ productRefGroup = 58B511D21A9E6C8500147676;
106
+ projectDirPath = "";
107
+ projectRoot = "";
108
+ targets = (
109
+ 58B511DA1A9E6C8500147676 /* Mosquitodb */,
110
+ );
111
+ };
112
+ /* End PBXProject section */
113
+
114
+ /* Begin PBXSourcesBuildPhase section */
115
+ 58B511D71A9E6C8500147676 /* Sources */ = {
116
+ isa = PBXSourcesBuildPhase;
117
+ buildActionMask = 2147483647;
118
+ files = (
119
+ F4FF95D7245B92E800C19C63 /* Mosquitodb.swift in Sources */,
120
+ B3E7B58A1CC2AC0600A0062D /* Mosquitodb.m in Sources */,
121
+ );
122
+ runOnlyForDeploymentPostprocessing = 0;
123
+ };
124
+ /* End PBXSourcesBuildPhase section */
125
+
126
+ /* Begin XCBuildConfiguration section */
127
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
128
+ isa = XCBuildConfiguration;
129
+ buildSettings = {
130
+ ALWAYS_SEARCH_USER_PATHS = NO;
131
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
132
+ CLANG_CXX_LIBRARY = "libc++";
133
+ CLANG_ENABLE_MODULES = YES;
134
+ CLANG_ENABLE_OBJC_ARC = YES;
135
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
136
+ CLANG_WARN_BOOL_CONVERSION = YES;
137
+ CLANG_WARN_COMMA = YES;
138
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
139
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
140
+ CLANG_WARN_EMPTY_BODY = YES;
141
+ CLANG_WARN_ENUM_CONVERSION = YES;
142
+ CLANG_WARN_INFINITE_RECURSION = YES;
143
+ CLANG_WARN_INT_CONVERSION = YES;
144
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
145
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
146
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
147
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
148
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
149
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
150
+ CLANG_WARN_UNREACHABLE_CODE = YES;
151
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
152
+ COPY_PHASE_STRIP = NO;
153
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
154
+ ENABLE_TESTABILITY = YES;
155
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
156
+ GCC_C_LANGUAGE_STANDARD = gnu99;
157
+ GCC_DYNAMIC_NO_PIC = NO;
158
+ GCC_NO_COMMON_BLOCKS = YES;
159
+ GCC_OPTIMIZATION_LEVEL = 0;
160
+ GCC_PREPROCESSOR_DEFINITIONS = (
161
+ "DEBUG=1",
162
+ "$(inherited)",
163
+ );
164
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
165
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
166
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
167
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
168
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
169
+ GCC_WARN_UNUSED_FUNCTION = YES;
170
+ GCC_WARN_UNUSED_VARIABLE = YES;
171
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
172
+ MTL_ENABLE_DEBUG_INFO = YES;
173
+ ONLY_ACTIVE_ARCH = YES;
174
+ SDKROOT = iphoneos;
175
+ };
176
+ name = Debug;
177
+ };
178
+ 58B511EE1A9E6C8500147676 /* Release */ = {
179
+ isa = XCBuildConfiguration;
180
+ buildSettings = {
181
+ ALWAYS_SEARCH_USER_PATHS = NO;
182
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
183
+ CLANG_CXX_LIBRARY = "libc++";
184
+ CLANG_ENABLE_MODULES = YES;
185
+ CLANG_ENABLE_OBJC_ARC = YES;
186
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
187
+ CLANG_WARN_BOOL_CONVERSION = YES;
188
+ CLANG_WARN_COMMA = YES;
189
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
190
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
191
+ CLANG_WARN_EMPTY_BODY = YES;
192
+ CLANG_WARN_ENUM_CONVERSION = YES;
193
+ CLANG_WARN_INFINITE_RECURSION = YES;
194
+ CLANG_WARN_INT_CONVERSION = YES;
195
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
196
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
197
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
198
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
199
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
200
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
201
+ CLANG_WARN_UNREACHABLE_CODE = YES;
202
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
203
+ COPY_PHASE_STRIP = YES;
204
+ ENABLE_NS_ASSERTIONS = NO;
205
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
206
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
207
+ GCC_C_LANGUAGE_STANDARD = gnu99;
208
+ GCC_NO_COMMON_BLOCKS = YES;
209
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
210
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
211
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
212
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
213
+ GCC_WARN_UNUSED_FUNCTION = YES;
214
+ GCC_WARN_UNUSED_VARIABLE = YES;
215
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
216
+ MTL_ENABLE_DEBUG_INFO = NO;
217
+ SDKROOT = iphoneos;
218
+ VALIDATE_PRODUCT = YES;
219
+ };
220
+ name = Release;
221
+ };
222
+ 58B511F01A9E6C8500147676 /* Debug */ = {
223
+ isa = XCBuildConfiguration;
224
+ buildSettings = {
225
+ HEADER_SEARCH_PATHS = (
226
+ "$(inherited)",
227
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
228
+ "$(SRCROOT)/../../../React/**",
229
+ "$(SRCROOT)/../../react-native/React/**",
230
+ );
231
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
232
+ OTHER_LDFLAGS = "-ObjC";
233
+ PRODUCT_NAME = Mosquitodb;
234
+ SKIP_INSTALL = YES;
235
+ SWIFT_OBJC_BRIDGING_HEADER = "Mosquitodb-Bridging-Header.h";
236
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
237
+ SWIFT_VERSION = 5.0;
238
+ };
239
+ name = Debug;
240
+ };
241
+ 58B511F11A9E6C8500147676 /* Release */ = {
242
+ isa = XCBuildConfiguration;
243
+ buildSettings = {
244
+ HEADER_SEARCH_PATHS = (
245
+ "$(inherited)",
246
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
247
+ "$(SRCROOT)/../../../React/**",
248
+ "$(SRCROOT)/../../react-native/React/**",
249
+ );
250
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
251
+ OTHER_LDFLAGS = "-ObjC";
252
+ PRODUCT_NAME = Mosquitodb;
253
+ SKIP_INSTALL = YES;
254
+ SWIFT_OBJC_BRIDGING_HEADER = "Mosquitodb-Bridging-Header.h";
255
+ SWIFT_VERSION = 5.0;
256
+ };
257
+ name = Release;
258
+ };
259
+ /* End XCBuildConfiguration section */
260
+
261
+ /* Begin XCConfigurationList section */
262
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Mosquitodb" */ = {
263
+ isa = XCConfigurationList;
264
+ buildConfigurations = (
265
+ 58B511ED1A9E6C8500147676 /* Debug */,
266
+ 58B511EE1A9E6C8500147676 /* Release */,
267
+ );
268
+ defaultConfigurationIsVisible = 0;
269
+ defaultConfigurationName = Release;
270
+ };
271
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Mosquitodb" */ = {
272
+ isa = XCConfigurationList;
273
+ buildConfigurations = (
274
+ 58B511F01A9E6C8500147676 /* Debug */,
275
+ 58B511F11A9E6C8500147676 /* Release */,
276
+ );
277
+ defaultConfigurationIsVisible = 0;
278
+ defaultConfigurationName = Release;
279
+ };
280
+ /* End XCConfigurationList section */
281
+ };
282
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
283
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "react-native-mosquito-transport",
3
+ "version": "0.0.14",
4
+ "description": "React native javascript sdk for mosquito-transport (https://github.com/deflexable/mosquito-transport)",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/deflexable/react-native-mosquito-transport.git"
12
+ },
13
+ "keywords": [
14
+ "mosquito-transport",
15
+ "javascript",
16
+ "selfhosted",
17
+ "serverless",
18
+ "Baas",
19
+ "database",
20
+ "react-native",
21
+ "mongodb"
22
+ ],
23
+ "author": "Anthony Onabanjo <deflexable@gmail.com> (https://github.com/deflexable)",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/deflexable/react-native-mosquito-transport/issues"
27
+ },
28
+ "homepage": "https://github.com/deflexable/react-native-mosquito-transport#readme",
29
+ "dependencies": {
30
+ "@types/crypto-js": "^4.2.1",
31
+ "@types/lodash": "^4.14.194",
32
+ "buffer": "^6.0.3",
33
+ "crypto-js": "^4.2.0",
34
+ "json-buffer": "^3.0.1",
35
+ "lodash": "^4.17.21",
36
+ "react-native-get-random-values": "^1.9.0",
37
+ "set-large-timeout": "^1.0.1",
38
+ "socket.io-client": "^4.6.2",
39
+ "subscription-listener": "^1.0.9",
40
+ "tweetnacl": "^1.0.3"
41
+ },
42
+ "engines": {
43
+ "node": ">= 16.0.0"
44
+ }
45
+ }
@@ -0,0 +1,35 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-mosquitodb"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/deflexable/react-native-mosquitodb.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ # Don't install the dependencies when we run `pod install` in the old architecture.
22
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
+ s.pod_target_xcconfig = {
25
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
+ }
29
+ s.dependency "React-Codegen"
30
+ s.dependency "RCT-Folly"
31
+ s.dependency "RCTRequired"
32
+ s.dependency "RCTTypeSafety"
33
+ s.dependency "ReactCommon/turbomodule/core"
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ import { encodeBinary } from './peripherals';
2
+
3
+ const apis = {
4
+ _readDocument: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._readDocument(baseApi)) : '_readDocument'}`,
5
+ _writeDocument: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._writeDocument(baseApi)) : '_writeDocument'}`,
6
+ _deleteCollection: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._deleteCollection(baseApi)) : '_deleteCollection'}`,
7
+ _queryCollection: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._queryCollection(baseApi)) : '_queryCollection'}`,
8
+ _writeMapDocument: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._writeMapDocument(baseApi)) : '_writeMapDocument'}`,
9
+ _customSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._customSignin(baseApi)) : '_customSignin'}`,
10
+ _customSignup: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._customSignup(baseApi)) : '_customSignup'}`,
11
+ _googleSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._googleSignin(baseApi)) : '_googleSignin'}`,
12
+ _appleSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._appleSignin(baseApi)) : '_appleSignin'}`,
13
+ _facebookSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._facebookSignin(baseApi)) : '_facebookSignin'}`,
14
+ _twitterSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._twitterSignin(baseApi)) : '_twitterSignin'}`,
15
+ _githubSignin: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._githubSignin(baseApi)) : '_githubSignin'}`,
16
+ _signOut: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._signOut(baseApi)) : '_signOut'}`,
17
+ _invalidateToken: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._invalidateToken(baseApi)) : '_invalidateToken'}`,
18
+ _refreshAuthToken: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._refreshAuthToken(baseApi)) : '_refreshAuthToken'}`,
19
+ _downloadFile: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._downloadFile(baseApi)) : '_downloadFile'}`,
20
+ _uploadFile: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._uploadFile(baseApi)) : '_uploadFile'}`,
21
+ _deleteFile: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._deleteFile(baseApi)) : '_deleteFile'}`,
22
+ _deleteFolder: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._deleteFolder(baseApi)) : '_deleteFolder'}`,
23
+ staticStorage: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis.staticStorage(baseApi)) : 'storage'}`,
24
+ _documentCount: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._documentCount(baseApi)) : '_documentCount'}`,
25
+ _areYouOk: (baseApi, ugly) => `${baseApi}/${ugly ? encodeBinary(apis._areYouOk(baseApi)) : '_areYouOk'}`,
26
+ // static path
27
+ _listenCollection: (ugly) => `${ugly ? encodeBinary(apis._listenCollection()) : '_listenCollection'}`,
28
+ _listenDocument: (ugly) => `${ugly ? encodeBinary(apis._listenDocument()) : '_listenDocument'}`,
29
+ _startDisconnectWriteTask: (ugly) => `${ugly ? encodeBinary(apis._startDisconnectWriteTask()) : '_startDisconnectWriteTask'}`,
30
+ _cancelDisconnectWriteTask: (ugly) => `${ugly ? encodeBinary(apis._cancelDisconnectWriteTask()) : '_cancelDisconnectWriteTask'}`,
31
+ _listenUserVerification: (ugly) => `${ugly ? encodeBinary(apis._listenUserVerification()) : '_listenUserVerification'}`
32
+ };
33
+
34
+ export default { ...apis };
@@ -0,0 +1,7 @@
1
+ import SubscriptionListener from "subscription-listener";
2
+
3
+ export const AuthTokenListener = new SubscriptionListener();
4
+ export const TokenRefreshListener = new SubscriptionListener();
5
+ export const StoreReadyListener = new SubscriptionListener();
6
+ export const ServerReachableListener = new SubscriptionListener();
7
+ export const DatabaseRecordsListener = new SubscriptionListener();
@@ -0,0 +1,195 @@
1
+ import { Buffer } from "buffer";
2
+ import { ServerReachableListener } from "./listeners";
3
+ import aes_pkg from 'crypto-js/aes.js';
4
+ import Utf8Encoder from 'crypto-js/enc-utf8.js';
5
+ import naclPkg from 'tweetnacl';
6
+
7
+ const { encrypt, decrypt } = aes_pkg;
8
+ const { box, randomBytes } = naclPkg;
9
+
10
+ export const simplifyError = (error, message) => ({
11
+ simpleError: { error, message }
12
+ });
13
+
14
+ export const simplifyCaughtError = (e) => e?.simpleError ? e : simplifyError('unexpected_error', `${e}`);
15
+
16
+ export const everyEntrie = (obj, callback) => {
17
+ if (typeof obj !== 'object' || Array.isArray(obj)) return;
18
+ oEntries(obj).forEach(e => {
19
+ callback?.(e);
20
+ });
21
+ }
22
+
23
+ export const flatEntries = (obj) => oEntries(obj);
24
+
25
+ export const flatRawEntries = () => oEntries(obj, false);
26
+
27
+ export const oEntries = (obj, includeObj = true) => {
28
+ let o = [];
29
+
30
+ Object.entries(obj).forEach(e => {
31
+ o.push(e);
32
+ if (e[1] && typeof e[1] === 'object' && !Array.isArray(e[1])) {
33
+ o = [...o, ...oEntries(e[1])];
34
+ }
35
+ });
36
+
37
+ return o.filter(v => includeObj || typeof v[1] !== 'object' || Array.isArray(v[1]));
38
+ }
39
+
40
+ export const IS_RAW_OBJECT = (e) => e && typeof e === 'object' && !Array.isArray(e) && !(e instanceof Date);
41
+
42
+ export const IS_WHOLE_NUMBER = (v) => typeof v === 'number' && !`${v}`.includes('.');
43
+
44
+ export const IS_DECIMAL_NUMBER = (v) => typeof v === 'number' && `${v}`.includes('.');
45
+
46
+ export const queryEntries = (obj, lastPath = '', exceptions = [], seperator = '.') => {
47
+ let o = [];
48
+ const isArraySeperator = Array.isArray(lastPath);
49
+
50
+ Object.entries(obj).forEach(([key, value]) => {
51
+ if (IS_RAW_OBJECT(value) && !exceptions.includes(key)) {
52
+ o = [
53
+ ...o,
54
+ ...queryEntries(
55
+ value,
56
+ isArraySeperator ? [...lastPath, key] : `${lastPath}${key}${seperator}`,
57
+ exceptions,
58
+ seperator
59
+ )
60
+ ];
61
+ } else o.push(isArraySeperator ? [[...lastPath, key], value] : [`${lastPath}${key}`, value]);
62
+ });
63
+
64
+ return o;
65
+ }
66
+
67
+ export const objToUniqueString = (obj) => {
68
+ const keys = [],
69
+ values = [];
70
+
71
+ if (Array.isArray(obj)) {
72
+ obj.forEach(e => {
73
+ if (IS_RAW_OBJECT(e)) {
74
+ queryEntries(e).map(([k, v]) => {
75
+ keys.push(k);
76
+ values.push(v);
77
+ });
78
+ } else keys.push(Array.isArray(e) ? JSON.stringify(e) : `${e}`);
79
+ });
80
+ } else if (!IS_RAW_OBJECT(obj))
81
+ return `${obj}`;
82
+ else
83
+ queryEntries(obj).map(([k, v]) => {
84
+ keys.push(k);
85
+ values.push(v);
86
+ });
87
+
88
+ return [
89
+ ...keys.sort(),
90
+ ...values.map(v => `${Array.isArray(v) ? JSON.stringify(v) : v}`).sort()
91
+ ].join(',');
92
+ }
93
+
94
+ export const cloneInstance = (v) => {
95
+ if (v && typeof v === 'object') {
96
+ return Array.isArray(v) ? [...v] : { ...v };
97
+ }
98
+ return v;
99
+ }
100
+
101
+ export const listenReachableServer = (callback, projectUrl) => ServerReachableListener.listenTo(projectUrl, t => {
102
+ if (typeof t === 'boolean') callback?.(t);
103
+ }, true);
104
+
105
+ export const prefixStoragePath = (path, prefix = 'file:///') => {
106
+ if (!path) return path;
107
+
108
+ if (!path.startsWith('/') && !path.includes(':')) return prefix + path;
109
+
110
+ return prefix + path.split('/').filter((v, i) => i && v).join('/');
111
+ }
112
+
113
+ export const getUrlExtension = (url) => {
114
+ const r = url.split(/[#?]/)[0].split(".").pop().trim();
115
+ return r === url ? '' : r;
116
+ }
117
+
118
+ export const niceTry = (promise) => new Promise(async resolve => {
119
+
120
+ try {
121
+ const r = await promise();
122
+ resolve(r);
123
+ } catch (e) { resolve(); }
124
+ });
125
+
126
+ export const shuffleArray = (n) => {
127
+ const array = [...n];
128
+ let currentIndex = array.length, randomIndex;
129
+
130
+ while (currentIndex != 0) {
131
+ randomIndex = Math.floor(Math.random() * currentIndex);
132
+ currentIndex--;
133
+
134
+ [array[currentIndex], array[randomIndex]] = [
135
+ array[randomIndex], array[currentIndex]
136
+ ];
137
+ }
138
+
139
+ return array;
140
+ }
141
+
142
+ export function sortArrayByObjectKey(arr = [], key) {
143
+ return arr.slice(0).sort(function (a, b) {
144
+ const left = getLodash(a, key),
145
+ right = getLodash(b, key);
146
+
147
+ return (left > right) ? 1 : (left < right) ? -1 : 0;
148
+ });
149
+ }
150
+
151
+ export const encryptString = (txt, password, iv) => {
152
+ return encrypt(txt, `${password || ''}${iv || ''}`).toString();
153
+ }
154
+
155
+ export const decryptString = (txt, password, iv) => {
156
+ return decrypt(txt, `${password || ''}${iv || ''}`).toString(Utf8Encoder);
157
+ }
158
+
159
+ export const serializeE2E = (data, auth_token, serverPublicKey) => {
160
+ const pair = box.keyPair(),
161
+ nonce = randomBytes(box.nonceLength),
162
+ pubBase64 = Buffer.from(pair.publicKey).toString('base64'),
163
+ nonceBase64 = Buffer.from(nonce).toString('base64');
164
+
165
+ return [
166
+ `${pubBase64}.${nonceBase64}.${Buffer.from(
167
+ box(
168
+ Buffer.from(JSON.stringify([
169
+ data,
170
+ auth_token
171
+ ]), 'utf8'),
172
+ nonce,
173
+ Buffer.from(serverPublicKey, 'base64'),
174
+ pair.secretKey
175
+ )
176
+ ).toString('base64')}`,
177
+ [pair.secretKey, pair.publicKey]
178
+ ];
179
+ }
180
+
181
+ export const deserializeE2E = (data, serverPublicKey, clientPrivateKey) => {
182
+ const [binaryNonce, binaryData] = data.split('.'),
183
+ baseArray = box.open(
184
+ Buffer.from(binaryData, 'base64'),
185
+ Buffer.from(binaryNonce, 'base64'),
186
+ Buffer.from(serverPublicKey, 'base64'),
187
+ clientPrivateKey
188
+ );
189
+
190
+ if (!baseArray) throw 'Decrypting e2e message failed';
191
+ return JSON.parse(Buffer.from(baseArray).toString('utf8'))[0];
192
+ }
193
+
194
+ export const encodeBinary = (s) => Buffer.from(s, 'utf8').toString('base64');
195
+ export const decodeBinary = (s) => Buffer.from(s, 'base64').toString('utf8');