react-native-security-suite 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +20 -1
  3. package/android/build.gradle +86 -43
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +1 -3
  6. package/android/src/main/AndroidManifestDeprecated.xml +3 -0
  7. package/android/src/main/java/com/{reactnativesecuritysuite → securitysuite}/SecuritySuiteModule.java +8 -1
  8. package/android/src/main/java/com/{reactnativesecuritysuite → securitysuite}/SecuritySuitePackage.java +1 -1
  9. package/android/src/main/java/com/securitysuite/Sslpinning.java +302 -0
  10. package/android/src/main/java/com/{reactnativesecuritysuite → securitysuite}/StorageEncryption.java +1 -2
  11. package/ios/ReactNativeSslPinning-Bridging-Header.h +2 -0
  12. package/ios/{SecuritySuite.m → SecuritySuite.mm} +2 -0
  13. package/ios/SecuritySuite.swift +55 -1
  14. package/ios/SecuritySuite.xcodeproj/project.pbxproj +20 -10
  15. package/ios/SecuritySuite.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -3
  16. package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcuserdata/mohammadnavabi.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  17. package/ios/SecuritySuite.xcodeproj/xcuserdata/mohammadnavabi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  18. package/ios/SslPinning.swift +195 -0
  19. package/lib/commonjs/helpers.js +0 -3
  20. package/lib/commonjs/helpers.js.map +1 -1
  21. package/lib/commonjs/index.js +46 -38
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/module/helpers.js +0 -1
  24. package/lib/module/helpers.js.map +1 -1
  25. package/lib/module/index.js +43 -14
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/typescript/helpers.d.ts +1 -0
  28. package/lib/typescript/helpers.d.ts.map +1 -0
  29. package/lib/typescript/index.d.ts +4 -1
  30. package/lib/typescript/index.d.ts.map +1 -0
  31. package/package.json +45 -35
  32. package/react-native-security-suite.podspec +18 -2
  33. package/src/index.tsx +66 -16
  34. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  35. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  36. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  37. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  38. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  39. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  40. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  41. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  42. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  43. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  44. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  45. package/android/.gradle/7.4/gc.properties +0 -0
  46. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  47. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  48. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  49. package/android/.gradle/file-system.probe +0 -0
  50. package/android/.gradle/vcs-1/gc.properties +0 -0
  51. package/android/.idea/compiler.xml +0 -6
  52. package/android/.idea/gradle.xml +0 -17
  53. package/android/.idea/jarRepositories.xml +0 -40
  54. package/android/.idea/misc.xml +0 -10
  55. package/android/.idea/vcs.xml +0 -6
  56. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  57. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  58. package/android/gradlew +0 -234
  59. package/android/gradlew.bat +0 -89
  60. package/android/local.properties +0 -8
  61. package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcuserdata/Navabi.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  62. /package/ios/SecuritySuite.xcodeproj/xcuserdata/{Navabi.xcuserdatad → mohammadnavabi.xcuserdatad}/xcschemes/xcschememanagement.plist +0 -0
@@ -7,8 +7,10 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- 59F427012A67C7B90072365D /* StorageEncryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59F426FF2A67C7B90072365D /* StorageEncryption.swift */; };
11
- 59F427022A67C7B90072365D /* DataHashingMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59F427002A67C7B90072365D /* DataHashingMethods.swift */; };
10
+ 4895B17B2A7545930068E02B /* SslPinning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4895B1782A7545930068E02B /* SslPinning.swift */; };
11
+ 4895B17C2A7545930068E02B /* DataHashingMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4895B17A2A7545930068E02B /* DataHashingMethods.swift */; };
12
+ 48C650222A751374001FA3B0 /* StorageEncryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48C650202A751374001FA3B0 /* StorageEncryption.swift */; };
13
+ 48C650232A751374001FA3B0 /* DataHashingMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48C650212A751374001FA3B0 /* DataHashingMethods.swift */; };
12
14
  F4FF95D7245B92E800C19C63 /* SecuritySuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* SecuritySuite.swift */; };
13
15
  /* End PBXBuildFile section */
14
16
 
@@ -26,9 +28,11 @@
26
28
 
27
29
  /* Begin PBXFileReference section */
28
30
  134814201AA4EA6300B7C361 /* libSecuritySuite.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSecuritySuite.a; sourceTree = BUILT_PRODUCTS_DIR; };
29
- 59F426FF2A67C7B90072365D /* StorageEncryption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageEncryption.swift; sourceTree = "<group>"; };
30
- 59F427002A67C7B90072365D /* DataHashingMethods.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataHashingMethods.swift; sourceTree = "<group>"; };
31
- B3E7B5891CC2AC0600A0062D /* SecuritySuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecuritySuite.m; sourceTree = "<group>"; };
31
+ 4895B1782A7545930068E02B /* SslPinning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SslPinning.swift; sourceTree = "<group>"; };
32
+ 4895B17A2A7545930068E02B /* DataHashingMethods.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DataHashingMethods.swift; path = "../../../../Desktop/@navabi/react-native-ssl-pinning/ios/DataHashingMethods.swift"; sourceTree = "<group>"; };
33
+ 48C650202A751374001FA3B0 /* StorageEncryption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageEncryption.swift; sourceTree = "<group>"; };
34
+ 48C650212A751374001FA3B0 /* DataHashingMethods.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataHashingMethods.swift; sourceTree = "<group>"; };
35
+ B3E7B5891CC2AC0600A0062D /* SecuritySuite.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecuritySuite.mm; sourceTree = "<group>"; };
32
36
  F4FF95D5245B92E700C19C63 /* SecuritySuite-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SecuritySuite-Bridging-Header.h"; sourceTree = "<group>"; };
33
37
  F4FF95D6245B92E800C19C63 /* SecuritySuite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecuritySuite.swift; sourceTree = "<group>"; };
34
38
  /* End PBXFileReference section */
@@ -56,10 +60,12 @@
56
60
  isa = PBXGroup;
57
61
  children = (
58
62
  F4FF95D6245B92E800C19C63 /* SecuritySuite.swift */,
59
- B3E7B5891CC2AC0600A0062D /* SecuritySuite.m */,
63
+ B3E7B5891CC2AC0600A0062D /* SecuritySuite.mm */,
60
64
  F4FF95D5245B92E700C19C63 /* SecuritySuite-Bridging-Header.h */,
61
- 59F427002A67C7B90072365D /* DataHashingMethods.swift */,
62
- 59F426FF2A67C7B90072365D /* StorageEncryption.swift */,
65
+ 48C650212A751374001FA3B0 /* DataHashingMethods.swift */,
66
+ 48C650202A751374001FA3B0 /* StorageEncryption.swift */,
67
+ 4895B17A2A7545930068E02B /* DataHashingMethods.swift */,
68
+ 4895B1782A7545930068E02B /* SslPinning.swift */,
63
69
  134814211AA4EA7D00B7C361 /* Products */,
64
70
  );
65
71
  sourceTree = "<group>";
@@ -121,8 +127,10 @@
121
127
  isa = PBXSourcesBuildPhase;
122
128
  buildActionMask = 2147483647;
123
129
  files = (
124
- 59F427022A67C7B90072365D /* DataHashingMethods.swift in Sources */,
125
- 59F427012A67C7B90072365D /* StorageEncryption.swift in Sources */,
130
+ 48C650232A751374001FA3B0 /* DataHashingMethods.swift in Sources */,
131
+ 4895B17C2A7545930068E02B /* DataHashingMethods.swift in Sources */,
132
+ 4895B17B2A7545930068E02B /* SslPinning.swift in Sources */,
133
+ 48C650222A751374001FA3B0 /* StorageEncryption.swift in Sources */,
126
134
  F4FF95D7245B92E800C19C63 /* SecuritySuite.swift in Sources */,
127
135
  );
128
136
  runOnlyForDeploymentPostprocessing = 0;
@@ -158,6 +166,7 @@
158
166
  COPY_PHASE_STRIP = NO;
159
167
  ENABLE_STRICT_OBJC_MSGSEND = YES;
160
168
  ENABLE_TESTABILITY = YES;
169
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
161
170
  GCC_C_LANGUAGE_STANDARD = gnu99;
162
171
  GCC_DYNAMIC_NO_PIC = NO;
163
172
  GCC_NO_COMMON_BLOCKS = YES;
@@ -208,6 +217,7 @@
208
217
  COPY_PHASE_STRIP = YES;
209
218
  ENABLE_NS_ASSERTIONS = NO;
210
219
  ENABLE_STRICT_OBJC_MSGSEND = YES;
220
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
211
221
  GCC_C_LANGUAGE_STANDARD = gnu99;
212
222
  GCC_NO_COMMON_BLOCKS = YES;
213
223
  GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -1,7 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <Workspace
3
3
  version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
4
  </Workspace>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "A64F3F4E-A635-49DB-ABEE-307D79B2D34E"
4
+ type = "1"
5
+ version = "2.0">
6
+ </Bucket>
@@ -0,0 +1,195 @@
1
+ @available(iOS 13.0, *)
2
+ class SSLPinning: NSObject, URLSessionDelegate {
3
+ var validDomains: [String] = []
4
+ var intermediateKeyHashes: [Data] = []
5
+ var leafKeyHashes: [Data] = []
6
+
7
+ init(data: NSDictionary) {
8
+ if let certs = data["certificates"] as? [String] {
9
+ for cert in certs {
10
+ intermediateKeyHashes.append(Data(base64Encoded: cert)!)
11
+ }
12
+ }
13
+
14
+ if let domains = data["validDomains"] as? [String] {
15
+ for domain in domains {
16
+ validDomains.append(domain)
17
+ }
18
+ }
19
+ }
20
+
21
+ func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
22
+ guard let trust = challenge.protectionSpace.serverTrust else {
23
+ return completionHandler(.cancelAuthenticationChallenge, nil)
24
+ }
25
+
26
+ let host = challenge.protectionSpace.host
27
+ let port = challenge.protectionSpace.port
28
+ guard port == 443, (3...4).contains(trust.certificates.count),
29
+ let leafCertificate = trust.certificates.first,
30
+ let commonName = leafCertificate.commonName,
31
+ validDomains.contains(where: { commonName == $0 || commonName.hasSuffix("." + $0) }) else {
32
+ completionHandler(.cancelAuthenticationChallenge, nil)
33
+ return
34
+ }
35
+ let intermediateCertificatesValid = trust.certificates.dropFirst().prefix(2).allSatisfy {
36
+ ($0.pin.map(intermediateKeyHashes.contains) ?? false)
37
+ }
38
+ let leafCertificateValid = leafKeyHashes.contains(leafCertificate.pin ?? .init())
39
+
40
+ let pattern = commonName
41
+ .replacingOccurrences(of: ".", with: "\\.")
42
+ .replacingOccurrences(of: "*", with: ".+", options: [.anchored])
43
+ guard intermediateCertificatesValid && (leafKeyHashes.isEmpty || leafCertificateValid),
44
+ let commonNameRegex = try? NSRegularExpression(pattern: pattern) else {
45
+ completionHandler(.cancelAuthenticationChallenge, nil)
46
+ return
47
+ }
48
+
49
+ guard commonNameRegex.textMatches(in: host) == [host] else {
50
+ completionHandler(.cancelAuthenticationChallenge, nil)
51
+ return
52
+ }
53
+
54
+ trust.policies = [.ssl(server: true, hostname: host)]
55
+ do {
56
+ if try !trust.evaluate() {
57
+ completionHandler(.cancelAuthenticationChallenge, nil)
58
+ }
59
+ } catch {
60
+ completionHandler(.cancelAuthenticationChallenge, nil)
61
+ return
62
+ }
63
+
64
+ let credential = URLCredential(trust: trust)
65
+ completionHandler(.useCredential, credential)
66
+ }
67
+ }
68
+
69
+ @available(iOS 13.0, *)
70
+ extension Data {
71
+ /**
72
+ Calculates hash digest of data.
73
+
74
+ - Parameter digest: digest type. Currently only SHA is supported.
75
+ - Returns: A data object with length equal to digest length.
76
+ */
77
+ public func _hash() -> Data {
78
+ guard !isEmpty else { return Data() }
79
+ var result = [UInt8](repeating: 0, count: 256/8)
80
+ self.withUnsafeBytes { (buf: UnsafeRawBufferPointer) -> Void in
81
+ let ptr = buf.baseAddress!
82
+ let dataLen = CC_LONG(buf.count)
83
+ CC_SHA256(ptr, dataLen, &result)
84
+ }
85
+
86
+ return Data(result)
87
+ }
88
+ }
89
+
90
+ extension Dictionary {
91
+ func toString() -> String? {
92
+ return (self.compactMap({ (key, value) -> String in
93
+ return "\(key)=\(value)"
94
+ }) as Array).joined(separator: "&")
95
+ }
96
+ }
97
+
98
+ @available(iOS 13.0, *)
99
+ extension SecTrust {
100
+ // Returns certificates of the certificate chain used to evaluate trust.
101
+ fileprivate var certificates: [SecCertificate] {
102
+ (0..<SecTrustGetCertificateCount(self))
103
+ .map { SecTrustGetCertificateAtIndex(self, $0 as CFIndex)! }
104
+ }
105
+
106
+ // Retrieves the policies used by a given trust management object.
107
+ fileprivate var policies: [SecPolicy]? {
108
+ get {
109
+ var result: CFArray?
110
+ SecTrustCopyPolicies(self, &result)
111
+ return result as? [SecPolicy]
112
+ }
113
+ set {
114
+ if let newValue = newValue {
115
+ SecTrustSetPolicies(self, newValue as CFArray)
116
+ } else {
117
+ SecTrustSetPolicies(self, [] as CFArray)
118
+ }
119
+ }
120
+ }
121
+
122
+ fileprivate func evaluate() throws -> Bool {
123
+ var error: CFError?
124
+ let success = SecTrustEvaluateWithError(self, &error)
125
+ if let error = error {
126
+ throw error
127
+ }
128
+ return success
129
+ }
130
+ }
131
+
132
+ @available(iOS 13.0, *)
133
+ extension SecCertificate {
134
+ fileprivate var key: SecKey? {
135
+ SecCertificateCopyKey(self)
136
+ }
137
+
138
+ fileprivate var commonName: String? {
139
+ var result: CFString?
140
+ SecCertificateCopyCommonName(self, &result)
141
+ return result as String?
142
+ }
143
+
144
+ fileprivate var pin: Data? {
145
+ try? key?.bytes().hash(digest: .sha256)
146
+ }
147
+ }
148
+
149
+ extension SecPolicy {
150
+ static func ssl(server: Bool, hostname: String) -> SecPolicy {
151
+ SecPolicyCreateSSL(server, hostname as CFString)
152
+ }
153
+
154
+ static func basicX509() -> SecPolicy {
155
+ SecPolicyCreateBasicX509()
156
+ }
157
+ }
158
+
159
+ extension NSRegularExpression {
160
+ public func matches(
161
+ in string: String,
162
+ options: NSRegularExpression.MatchingOptions = []
163
+ ) -> [NSTextCheckingResult] {
164
+ matches(in: string, options: options, range: NSRange(string.startIndex..., in: string))
165
+ }
166
+
167
+ public func textMatches(
168
+ in string: String,
169
+ options: NSRegularExpression.MatchingOptions = []
170
+ ) -> [String] {
171
+ textMatches(in: string, options: options, range: string.startIndex...)
172
+ }
173
+
174
+ public func matches<R: RangeExpression>(
175
+ in string: String,
176
+ options: NSRegularExpression.MatchingOptions = [],
177
+ range: R
178
+ ) -> [NSTextCheckingResult] where R.Bound == String.Index {
179
+ matches(in: string, options: options, range: NSRange(range, in: string))
180
+ }
181
+
182
+ public func textMatches<R: RangeExpression>(
183
+ in string: String,
184
+ options: NSRegularExpression.MatchingOptions = [],
185
+ range: R
186
+ ) -> [String] where R.Bound == String.Index {
187
+ matches(in: string, options: options, range: NSRange(range, in: string))
188
+ .map {
189
+ guard let range = Range($0.range, in: string) else {
190
+ return ""
191
+ }
192
+ return String(string[range])
193
+ }
194
+ }
195
+ }
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isJsonString = void 0;
7
-
8
7
  const isJsonString = value => {
9
8
  try {
10
9
  JSON.parse(value);
11
10
  } catch (e) {
12
11
  return false;
13
12
  }
14
-
15
13
  return true;
16
14
  };
17
-
18
15
  exports.isJsonString = isJsonString;
19
16
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isJsonString","value","JSON","parse","e"],"sources":["helpers.ts"],"sourcesContent":["export const isJsonString = (value: string): boolean => {\n try {\n JSON.parse(value);\n } catch (e) {\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;AAAO,MAAMA,YAAY,GAAIC,KAAD,IAA4B;EACtD,IAAI;IACFC,IAAI,CAACC,KAAL,CAAWF,KAAX;EACD,CAFD,CAEE,OAAOG,CAAP,EAAU;IACV,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD,CAPM"}
1
+ {"version":3,"names":["isJsonString","value","JSON","parse","e","exports"],"sourceRoot":"../../src","sources":["helpers.ts"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAIC,KAAa,IAAc;EACtD,IAAI;IACFC,IAAI,CAACC,KAAK,CAACF,KAAK,CAAC;EACnB,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC;AAACC,OAAA,CAAAL,YAAA,GAAAA,YAAA"}
@@ -5,18 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.decryptBySharedKey = exports.decrypt = exports.SecureStorage = void 0;
7
7
  exports.deviceHasSecurityRisk = deviceHasSecurityRisk;
8
- exports.getSharedKey = exports.getPublicKey = exports.getDeviceId = exports.encryptBySharedKey = exports.encrypt = void 0;
9
-
8
+ exports.encryptBySharedKey = exports.encrypt = void 0;
9
+ exports.fetch = fetch;
10
+ exports.getSharedKey = exports.getPublicKey = exports.getDeviceId = void 0;
10
11
  var _reactNative = require("react-native");
11
-
12
12
  var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
13
-
14
13
  var _lodash = _interopRequireDefault(require("lodash"));
15
-
16
14
  var _helpers = require("./helpers");
17
-
18
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
16
  const LINKING_ERROR = `The package 'react-native-security-suite' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
21
17
  ios: "- You have run 'pod install'\n",
22
18
  default: ''
@@ -25,33 +21,21 @@ const SecuritySuite = _reactNative.NativeModules.SecuritySuite ? _reactNative.Na
25
21
  get() {
26
22
  throw new Error(LINKING_ERROR);
27
23
  }
28
-
29
24
  });
30
-
31
25
  const getPublicKey = () => SecuritySuite.getPublicKey();
32
-
33
26
  exports.getPublicKey = getPublicKey;
34
-
35
27
  const getSharedKey = serverPublicKey => SecuritySuite.getSharedKey(serverPublicKey);
36
-
37
28
  exports.getSharedKey = getSharedKey;
38
-
39
29
  const encryptBySharedKey = input => input && typeof input === 'string' ? SecuritySuite.encrypt(input) : '';
40
-
41
30
  exports.encryptBySharedKey = encryptBySharedKey;
42
-
43
31
  const decryptBySharedKey = input => input && typeof input === 'string' ? SecuritySuite.decrypt(input) : '';
44
-
45
32
  exports.decryptBySharedKey = decryptBySharedKey;
46
-
47
33
  const getDeviceId = () => new Promise((resolve, reject) => {
48
34
  SecuritySuite.getDeviceId((result, error) => {
49
35
  if (error !== null) reject(error);else resolve(result);
50
36
  });
51
37
  });
52
-
53
38
  exports.getDeviceId = getDeviceId;
54
-
55
39
  const encrypt = function (input) {
56
40
  let hardEncryption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
57
41
  let secretKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -62,9 +46,7 @@ const encrypt = function (input) {
62
46
  });
63
47
  });
64
48
  };
65
-
66
49
  exports.encrypt = encrypt;
67
-
68
50
  const decrypt = function (input) {
69
51
  let hardEncryption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
70
52
  let secretKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -75,7 +57,6 @@ const decrypt = function (input) {
75
57
  });
76
58
  });
77
59
  };
78
-
79
60
  exports.decrypt = decrypt;
80
61
  const SecureStorage = {
81
62
  setItem: async (key, value) => {
@@ -131,15 +112,16 @@ const SecureStorage = {
131
112
  multiSet: async keyValuePairs => {
132
113
  try {
133
114
  const encryptedKeyValuePairs = await Promise.all(keyValuePairs.map(async item => {
134
- if (item.length !== 2) return [];
135
- const encryptedKey = await encrypt(item[0], false);
136
- const encryptedValue = await encrypt(item[1]);
137
- return [encryptedKey, encryptedValue];
115
+ if (item.length === 2 && item[0] && item[1]) {
116
+ const encryptedKey = await encrypt(item[0], false);
117
+ const encryptedValue = await encrypt(item[1]);
118
+ return [encryptedKey, encryptedValue];
119
+ }
120
+ return null;
138
121
  }));
139
-
140
122
  _asyncStorage.default.multiSet(encryptedKeyValuePairs);
141
123
  } catch (e) {
142
- return e;
124
+ console.error('multiSet error: ', e);
143
125
  }
144
126
  },
145
127
  multiGet: async keys => {
@@ -159,14 +141,16 @@ const SecureStorage = {
159
141
  multiMerge: async keyValuePairs => {
160
142
  try {
161
143
  return keyValuePairs.map(async item => {
162
- if (item.length !== 2) return;
163
- const encryptedKey = await encrypt(item[0], false);
164
- const encryptedData = await _asyncStorage.default.getItem(item[0]);
165
- const data = await decrypt(encryptedData ?? '');
166
- if (!(0, _helpers.isJsonString)(data) || !(0, _helpers.isJsonString)(item[1])) return null;
167
- const mergedData = await JSON.stringify(_lodash.default.merge(JSON.parse(data), JSON.parse(item[1])));
168
- const encryptedValue = await encrypt(mergedData, false);
169
- return _asyncStorage.default.setItem(encryptedKey, encryptedValue);
144
+ if (item.length === 2 && item[0] && item[1]) {
145
+ const encryptedKey = await encrypt(item[0], false);
146
+ const encryptedData = await _asyncStorage.default.getItem(item[0]);
147
+ const data = await decrypt(encryptedData ?? '');
148
+ if (!(0, _helpers.isJsonString)(data) || !(0, _helpers.isJsonString)(item[1])) return null;
149
+ const mergedData = await JSON.stringify(_lodash.default.merge(JSON.parse(data), JSON.parse(item[1])));
150
+ const encryptedValue = await encrypt(mergedData, false);
151
+ return _asyncStorage.default.setItem(encryptedKey, encryptedValue);
152
+ }
153
+ return null;
170
154
  });
171
155
  } catch (e) {
172
156
  return e;
@@ -190,11 +174,35 @@ const SecureStorage = {
190
174
  }
191
175
  };
192
176
  exports.SecureStorage = SecureStorage;
193
-
177
+ function fetch(url, options) {
178
+ return new Promise((resolve, reject) => {
179
+ SecuritySuite.fetch(url, options, (result, error) => {
180
+ try {
181
+ if (error === null) {
182
+ result.json = () => JSON.parse(result.response);
183
+ resolve(result);
184
+ } else {
185
+ let errorJson = JSON.parse(error.error);
186
+ const objectError = {
187
+ json: () => errorJson,
188
+ error: error.error,
189
+ path: errorJson === null || errorJson === void 0 ? void 0 : errorJson.path,
190
+ message: errorJson === null || errorJson === void 0 ? void 0 : errorJson.message,
191
+ code: errorJson === null || errorJson === void 0 ? void 0 : errorJson.code,
192
+ status: error === null || error === void 0 ? void 0 : error.status,
193
+ url: error === null || error === void 0 ? void 0 : error.url
194
+ };
195
+ reject(objectError);
196
+ }
197
+ } catch (e) {
198
+ console.error('SSL Pinnning fetch error: ', e);
199
+ }
200
+ });
201
+ });
202
+ }
194
203
  function deviceHasSecurityRisk() {
195
204
  return SecuritySuite.deviceHasSecurityRisk();
196
205
  }
197
-
198
206
  var _default = SecuritySuite;
199
207
  exports.default = _default;
200
208
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","SecuritySuite","NativeModules","Proxy","get","Error","getPublicKey","getSharedKey","serverPublicKey","encryptBySharedKey","input","encrypt","decryptBySharedKey","decrypt","getDeviceId","Promise","resolve","reject","result","error","hardEncryption","secretKey","storageEncrypt","storageDecrypt","SecureStorage","setItem","key","value","encryptedKey","encryptedValue","AsyncStorage","e","getItem","encryptedData","mergeItem","data","isJsonString","mergedData","JSON","stringify","_","merge","parse","removeItem","getAllKeys","encryptedKeys","all","map","item","decryptedKey","multiSet","keyValuePairs","encryptedKeyValuePairs","length","multiGet","keys","Array","isArray","encryptedItems","decryptedalue","multiMerge","multiRemove","clear","deviceHasSecurityRisk"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport AsyncStorage from '@react-native-async-storage/async-storage';\nimport _ from 'lodash';\nimport { isJsonString } from './helpers';\n\nconst LINKING_ERROR =\n `The package 'react-native-security-suite' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst SecuritySuite = NativeModules.SecuritySuite\n ? NativeModules.SecuritySuite\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const getPublicKey = (): Promise<string> => SecuritySuite.getPublicKey();\n\nexport const getSharedKey = (serverPublicKey: string): Promise<string> =>\n SecuritySuite.getSharedKey(serverPublicKey);\n\nexport const encryptBySharedKey = (input: string): Promise<string> =>\n input && typeof input === 'string' ? SecuritySuite.encrypt(input) : '';\n\nexport const decryptBySharedKey = (input: string) =>\n input && typeof input === 'string' ? SecuritySuite.decrypt(input) : '';\n\nexport const getDeviceId = (): Promise<string> =>\n new Promise((resolve: any, reject: any) => {\n SecuritySuite.getDeviceId((result: string | null, error: string | null) => {\n if (error !== null) reject(error);\n else resolve(result);\n });\n });\n\nexport const encrypt = (\n input: string,\n hardEncryption = true,\n secretKey = null\n): Promise<string> =>\n new Promise((resolve: any, reject: any) => {\n if (!input) resolve(input);\n\n SecuritySuite.storageEncrypt(\n input,\n secretKey,\n hardEncryption,\n (result: string | null, error: string | null) => {\n if (error !== null) reject(error);\n else resolve(result);\n }\n );\n });\n\nexport const decrypt = (\n input: string,\n hardEncryption = true,\n secretKey = null\n): Promise<string> =>\n new Promise((resolve: any, reject: any) => {\n if (!input) resolve(input);\n\n SecuritySuite.storageDecrypt(\n input,\n secretKey,\n hardEncryption,\n (result: string | null, error: string | null) => {\n if (error !== null) reject(error);\n else resolve(result);\n }\n );\n });\n\nexport const SecureStorage = {\n setItem: async (key: string, value: string) => {\n try {\n const encryptedKey = await encrypt(key, false);\n const encryptedValue = await encrypt(value);\n return AsyncStorage.setItem(encryptedKey, encryptedValue);\n } catch (e) {\n return e;\n }\n },\n getItem: async (key: string) => {\n try {\n const encryptedKey = await encrypt(key, false);\n const encryptedData = await AsyncStorage.getItem(encryptedKey);\n return decrypt(encryptedData ?? '');\n } catch (e) {\n return e;\n }\n },\n mergeItem: async (key: string, value: string) => {\n try {\n const encryptedKey = await encrypt(key, false);\n const encryptedData = await AsyncStorage.getItem(encryptedKey);\n const data = await decrypt(encryptedData ?? '');\n if (!isJsonString(data) || !isJsonString(value)) return null;\n const mergedData = await JSON.stringify(\n _.merge(JSON.parse(data), JSON.parse(value))\n );\n const encryptedValue = await encrypt(mergedData);\n return AsyncStorage.setItem(encryptedKey, encryptedValue);\n } catch (e) {\n return e;\n }\n },\n removeItem: async (key: string) => {\n try {\n const encryptedKey = await encrypt(key, false);\n return AsyncStorage.removeItem(encryptedKey);\n } catch (e) {\n return e;\n }\n },\n getAllKeys: async () => {\n try {\n const encryptedKeys = await AsyncStorage.getAllKeys();\n return await Promise.all(\n encryptedKeys.map(async (item: string): Promise<string> => {\n const decryptedKey = await decrypt(item, false);\n return decryptedKey ? decryptedKey : item;\n })\n );\n } catch (e) {\n return e;\n }\n },\n multiSet: async (keyValuePairs: Array<Array<string>>) => {\n try {\n const encryptedKeyValuePairs: any = await Promise.all(\n keyValuePairs.map(async (item: Array<string>) => {\n if (item.length !== 2) return [];\n const encryptedKey = await encrypt(item[0], false);\n const encryptedValue = await encrypt(item[1]);\n return [encryptedKey, encryptedValue];\n })\n );\n AsyncStorage.multiSet(encryptedKeyValuePairs);\n } catch (e) {\n return e;\n }\n },\n multiGet: async (keys: Array<string>) => {\n try {\n if (!Array.isArray(keys)) return null;\n const encryptedKeys = await Promise.all(\n keys.map(\n async (item: string): Promise<string> => await encrypt(item, false)\n )\n );\n const encryptedItems = await AsyncStorage.multiGet(encryptedKeys);\n return await Promise.all(\n encryptedItems && encryptedItems.length\n ? encryptedItems.map(async (item: any): Promise<string[]> => {\n const decryptedKey = await decrypt(item[0], false);\n const decryptedalue = await decrypt(item[1]);\n return [decryptedKey, decryptedalue];\n })\n : []\n );\n } catch (e) {\n return e;\n }\n },\n multiMerge: async (keyValuePairs: Array<Array<string>>) => {\n try {\n return keyValuePairs.map(async (item: Array<string>) => {\n if (item.length !== 2) return;\n const encryptedKey = await encrypt(item[0], false);\n const encryptedData = await AsyncStorage.getItem(item[0]);\n const data = await decrypt(encryptedData ?? '');\n if (!isJsonString(data) || !isJsonString(item[1])) return null;\n const mergedData = await JSON.stringify(\n _.merge(JSON.parse(data), JSON.parse(item[1]))\n );\n const encryptedValue = await encrypt(mergedData, false);\n return AsyncStorage.setItem(encryptedKey, encryptedValue);\n });\n } catch (e) {\n return e;\n }\n },\n multiRemove: async (keys: Array<string>) => {\n try {\n if (!Array.isArray(keys)) return keys;\n const encryptedKeys = await Promise.all(\n keys.map(\n async (item: string): Promise<string> => await encrypt(item, false)\n )\n );\n return AsyncStorage.multiRemove(encryptedKeys);\n } catch (e) {\n return e;\n }\n },\n clear: async () => {\n try {\n return AsyncStorage.clear();\n } catch (e) {\n return e;\n }\n },\n};\n\nexport function deviceHasSecurityRisk(): Promise<boolean> {\n return SecuritySuite.deviceHasSecurityRisk();\n}\n\nexport default SecuritySuite;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAChB,sFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGC,0BAAA,CAAcD,aAAd,GAClBC,0BAAA,CAAcD,aADI,GAElB,IAAIE,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;;AAWO,MAAMU,YAAY,GAAG,MAAuBL,aAAa,CAACK,YAAd,EAA5C;;;;AAEA,MAAMC,YAAY,GAAIC,eAAD,IAC1BP,aAAa,CAACM,YAAd,CAA2BC,eAA3B,CADK;;;;AAGA,MAAMC,kBAAkB,GAAIC,KAAD,IAChCA,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA1B,GAAqCT,aAAa,CAACU,OAAd,CAAsBD,KAAtB,CAArC,GAAoE,EAD/D;;;;AAGA,MAAME,kBAAkB,GAAIF,KAAD,IAChCA,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA1B,GAAqCT,aAAa,CAACY,OAAd,CAAsBH,KAAtB,CAArC,GAAoE,EAD/D;;;;AAGA,MAAMI,WAAW,GAAG,MACzB,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAeC,MAAf,KAA+B;EACzChB,aAAa,CAACa,WAAd,CAA0B,CAAC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EE,OAAO/B,CAAP,EAAU;MACV,OAAOA,CAAP;IACD;EACF;AAjI0B,CAAtB;;;AAoIA,SAASgC,qBAAT,GAAmD;EACxD,OAAO9D,aAAa,CAAC8D,qBAAd,EAAP;AACD;;eAEc9D,a"}
1
+ {"version":3,"names":["_reactNative","require","_asyncStorage","_interopRequireDefault","_lodash","_helpers","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","SecuritySuite","NativeModules","Proxy","get","Error","getPublicKey","exports","getSharedKey","serverPublicKey","encryptBySharedKey","input","encrypt","decryptBySharedKey","decrypt","getDeviceId","Promise","resolve","reject","result","error","hardEncryption","arguments","length","undefined","secretKey","storageEncrypt","storageDecrypt","SecureStorage","setItem","key","value","encryptedKey","encryptedValue","AsyncStorage","e","getItem","encryptedData","mergeItem","data","isJsonString","mergedData","JSON","stringify","_","merge","parse","removeItem","getAllKeys","encryptedKeys","all","map","item","decryptedKey","multiSet","keyValuePairs","encryptedKeyValuePairs","console","multiGet","keys","Array","isArray","encryptedItems","decryptedalue","multiMerge","multiRemove","clear","fetch","url","options","json","response","errorJson","objectError","path","message","code","status","deviceHasSecurityRisk","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAyC,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAOzC,MAAMG,aAAa,GAChB,sFAAqF,GACtFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEJ,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMK,aAAa,GAAGC,0BAAa,CAACD,aAAa,GA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B;MACF,CAAC,CAAC,OAAOtC,CAAC,EAAE;QACVsB,OAAO,CAACrC,KAAK,CAAC,4BAA4B,EAAEe,CAAC,CAAC;MAChD;IACF,CACF,CAAC;EACH,CAAC,CAAC;AACJ;AAEO,SAAS2C,qBAAqBA,CAAA,EAAqB;EACxD,OAAO7E,aAAa,CAAC6E,qBAAqB,CAAC,CAAC;AAC9C;AAAC,IAAAC,QAAA,GAEc9E,aAAa;AAAAM,OAAA,CAAAX,OAAA,GAAAmF,QAAA"}
@@ -4,7 +4,6 @@ export const isJsonString = value => {
4
4
  } catch (e) {
5
5
  return false;
6
6
  }
7
-
8
7
  return true;
9
8
  };
10
9
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isJsonString","value","JSON","parse","e"],"sources":["helpers.ts"],"sourcesContent":["export const isJsonString = (value: string): boolean => {\n try {\n JSON.parse(value);\n } catch (e) {\n return false;\n }\n return true;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,KAAD,IAA4B;EACtD,IAAI;IACFC,IAAI,CAACC,KAAL,CAAWF,KAAX;EACD,CAFD,CAEE,OAAOG,CAAP,EAAU;IACV,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD,CAPM"}
1
+ {"version":3,"names":["isJsonString","value","JSON","parse","e"],"sourceRoot":"../../src","sources":["helpers.ts"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,KAAa,IAAc;EACtD,IAAI;IACFC,IAAI,CAACC,KAAK,CAACF,KAAK,CAAC;EACnB,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC"}
@@ -10,7 +10,6 @@ const SecuritySuite = NativeModules.SecuritySuite ? NativeModules.SecuritySuite
10
10
  get() {
11
11
  throw new Error(LINKING_ERROR);
12
12
  }
13
-
14
13
  });
15
14
  export const getPublicKey = () => SecuritySuite.getPublicKey();
16
15
  export const getSharedKey = serverPublicKey => SecuritySuite.getSharedKey(serverPublicKey);
@@ -95,14 +94,16 @@ export const SecureStorage = {
95
94
  multiSet: async keyValuePairs => {
96
95
  try {
97
96
  const encryptedKeyValuePairs = await Promise.all(keyValuePairs.map(async item => {
98
- if (item.length !== 2) return [];
99
- const encryptedKey = await encrypt(item[0], false);
100
- const encryptedValue = await encrypt(item[1]);
101
- return [encryptedKey, encryptedValue];
97
+ if (item.length === 2 && item[0] && item[1]) {
98
+ const encryptedKey = await encrypt(item[0], false);
99
+ const encryptedValue = await encrypt(item[1]);
100
+ return [encryptedKey, encryptedValue];
101
+ }
102
+ return null;
102
103
  }));
103
104
  AsyncStorage.multiSet(encryptedKeyValuePairs);
104
105
  } catch (e) {
105
- return e;
106
+ console.error('multiSet error: ', e);
106
107
  }
107
108
  },
108
109
  multiGet: async keys => {
@@ -122,14 +123,16 @@ export const SecureStorage = {
122
123
  multiMerge: async keyValuePairs => {
123
124
  try {
124
125
  return keyValuePairs.map(async item => {
125
- if (item.length !== 2) return;
126
- const encryptedKey = await encrypt(item[0], false);
127
- const encryptedData = await AsyncStorage.getItem(item[0]);
128
- const data = await decrypt(encryptedData ?? '');
129
- if (!isJsonString(data) || !isJsonString(item[1])) return null;
130
- const mergedData = await JSON.stringify(_.merge(JSON.parse(data), JSON.parse(item[1])));
131
- const encryptedValue = await encrypt(mergedData, false);
132
- return AsyncStorage.setItem(encryptedKey, encryptedValue);
126
+ if (item.length === 2 && item[0] && item[1]) {
127
+ const encryptedKey = await encrypt(item[0], false);
128
+ const encryptedData = await AsyncStorage.getItem(item[0]);
129
+ const data = await decrypt(encryptedData ?? '');
130
+ if (!isJsonString(data) || !isJsonString(item[1])) return null;
131
+ const mergedData = await JSON.stringify(_.merge(JSON.parse(data), JSON.parse(item[1])));
132
+ const encryptedValue = await encrypt(mergedData, false);
133
+ return AsyncStorage.setItem(encryptedKey, encryptedValue);
134
+ }
135
+ return null;
133
136
  });
134
137
  } catch (e) {
135
138
  return e;
@@ -152,6 +155,32 @@ export const SecureStorage = {
152
155
  }
153
156
  }
154
157
  };
158
+ export function fetch(url, options) {
159
+ return new Promise((resolve, reject) => {
160
+ SecuritySuite.fetch(url, options, (result, error) => {
161
+ try {
162
+ if (error === null) {
163
+ result.json = () => JSON.parse(result.response);
164
+ resolve(result);
165
+ } else {
166
+ let errorJson = JSON.parse(error.error);
167
+ const objectError = {
168
+ json: () => errorJson,
169
+ error: error.error,
170
+ path: errorJson === null || errorJson === void 0 ? void 0 : errorJson.path,
171
+ message: errorJson === null || errorJson === void 0 ? void 0 : errorJson.message,
172
+ code: errorJson === null || errorJson === void 0 ? void 0 : errorJson.code,
173
+ status: error === null || error === void 0 ? void 0 : error.status,
174
+ url: error === null || error === void 0 ? void 0 : error.url
175
+ };
176
+ reject(objectError);
177
+ }
178
+ } catch (e) {
179
+ console.error('SSL Pinnning fetch error: ', e);
180
+ }
181
+ });
182
+ });
183
+ }
155
184
  export function deviceHasSecurityRisk() {
156
185
  return SecuritySuite.deviceHasSecurityRisk();
157
186
  }