@functionland/react-native-fula 1.14.6 → 1.14.8
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/android/build.gradle
CHANGED
|
@@ -94,8 +94,8 @@ dependencies {
|
|
|
94
94
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
95
95
|
//noinspection GradleDynamicVersion
|
|
96
96
|
implementation "com.facebook.react:react-native:+"
|
|
97
|
-
implementation 'com.github.functionland:fula-build-aar:v1.
|
|
98
|
-
implementation 'com.github.functionland:wnfs-android:v1.8.
|
|
97
|
+
implementation 'com.github.functionland:fula-build-aar:v1.14.3' // From jitpack.io
|
|
98
|
+
implementation 'com.github.functionland:wnfs-android:v1.8.1' // From jitpack.io
|
|
99
99
|
implementation 'commons-io:commons-io:20030203.000550'
|
|
100
100
|
implementation 'commons-codec:commons-codec:1.15'
|
|
101
101
|
// implementation files('mobile.aar')
|
package/ios/Cryptography.swift
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import CommonCrypto
|
|
3
3
|
import CryptoSwift
|
|
4
|
+
import os.log
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
public class Cryptography: NSObject {
|
|
6
9
|
public static func encryptMsg(_ message: Array<UInt8>, _ secretKey: Array<UInt8>)
|
|
7
10
|
throws -> String {
|
|
11
|
+
OSLog.viewCycle.info("ReactNative encryptMsg started for \(message)")
|
|
8
12
|
let aes = try! AES(key: secretKey, blockMode: ECB(), padding: .pkcs5)
|
|
13
|
+
OSLog.viewCycle.info("ReactNative encryptMsg aes")
|
|
9
14
|
let encrypted = try! aes.encrypt(message)
|
|
10
|
-
|
|
15
|
+
OSLog.viewCycle.info("ReactNative encryptMsg encrypted")
|
|
16
|
+
do{
|
|
17
|
+
let data = Data(encrypted).base64EncodedString()
|
|
18
|
+
OSLog.viewCycle.info("ReactNative encryptMsg: \(data)")
|
|
19
|
+
return data
|
|
20
|
+
} catch let error {
|
|
21
|
+
OSLog.viewCycle.info("ReactNative encryptMsg error: \(error.localizedDescription)")
|
|
22
|
+
throw error
|
|
23
|
+
}
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
public static func decryptMsg(_ cipherText: String, _ secretKey: Array<UInt8>)
|
package/ios/Fula.mm
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(FulaModule, NSObject)
|
|
4
4
|
|
|
5
|
-
RCT_EXTERN_METHOD(checkConnection: (NSNumber *) timeout
|
|
5
|
+
RCT_EXTERN_METHOD(checkConnection: (nonnull NSNumber *) timeout
|
|
6
6
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
7
7
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
8
8
|
|
package/ios/Fula.swift
CHANGED
|
@@ -3,6 +3,32 @@ import Foundation.NSDate // for TimeInterval
|
|
|
3
3
|
import CommonCrypto
|
|
4
4
|
import Wnfs
|
|
5
5
|
import Fula
|
|
6
|
+
import os.log
|
|
7
|
+
|
|
8
|
+
extension OSLog {
|
|
9
|
+
|
|
10
|
+
private static var subsystem = Bundle.main.bundleIdentifier!
|
|
11
|
+
|
|
12
|
+
/// Logs the view cycles like a view that appeared.
|
|
13
|
+
static let viewCycle = OSLog(subsystem: subsystem, category: "viewcycle")
|
|
14
|
+
|
|
15
|
+
/// All logs related to tracking and analytics.
|
|
16
|
+
static let statistics = OSLog(subsystem: subsystem, category: "statistics")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
extension OSLog {
|
|
20
|
+
|
|
21
|
+
func info(_ msg: String, _ args: CVarArg...) {
|
|
22
|
+
os_log("%{public}@", log: self, type: .info, msg)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func error(_ msg: String, _ args: CVarArg...) {
|
|
26
|
+
os_log("%{public}@", log: self, type: .error, msg)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ... (more methods for different log levels, if needed)
|
|
30
|
+
}
|
|
31
|
+
|
|
6
32
|
|
|
7
33
|
@objc(FulaModule)
|
|
8
34
|
class FulaModule: NSObject {
|
|
@@ -110,28 +136,33 @@ class FulaModule: NSObject {
|
|
|
110
136
|
}
|
|
111
137
|
|
|
112
138
|
@objc(checkConnection:withResolver:withRejecter:)
|
|
113
|
-
func checkConnection(timeout:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
print("ReactNative", "checkConnection failed with Error: ", error.localizedDescription)
|
|
129
|
-
// callback(BOOL(false))
|
|
130
|
-
resolve(false)
|
|
139
|
+
func checkConnection(timeout: NSNumber, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
140
|
+
OSLog.viewCycle.info("ReactNative checkConnection started with timeout=\(timeout)")
|
|
141
|
+
|
|
142
|
+
if let timeoutInt = timeout as? Int {
|
|
143
|
+
if fula != nil {
|
|
144
|
+
DispatchQueue.global(qos: .default).async {
|
|
145
|
+
do {
|
|
146
|
+
let connectionStatus = try self.checkConnectionInternal(timeout: timeoutInt)
|
|
147
|
+
OSLog.viewCycle.info("ReactNative checkConnection ended \(connectionStatus)")
|
|
148
|
+
resolve(connectionStatus)
|
|
149
|
+
}
|
|
150
|
+
catch let error {
|
|
151
|
+
OSLog.viewCycle.info("ReactNative checkConnection failed with Error: \(error.localizedDescription)")
|
|
152
|
+
resolve(false)
|
|
153
|
+
}
|
|
131
154
|
}
|
|
155
|
+
} else {
|
|
156
|
+
OSLog.viewCycle.info("ReactNative checkConnection fula is null")
|
|
157
|
+
resolve(false)
|
|
132
158
|
}
|
|
159
|
+
} else {
|
|
160
|
+
OSLog.viewCycle.error("ReactNative checkConnection - invalid timeout value")
|
|
161
|
+
reject("ERR_INVALID_TIMEOUT", "Invalid timeout value", nil)
|
|
162
|
+
}
|
|
133
163
|
}
|
|
134
164
|
|
|
165
|
+
|
|
135
166
|
@objc(newClient:withStorePath:withBloxAddr:withExchange:withAutoFlush:withUseRelay:withRefresh:withResolver:withRejecter:)
|
|
136
167
|
func newClient(identityString: String, storePath: String, bloxAddr: String, exchange: String, autoFlush: Bool, useRelay: Bool, refresh: Bool, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
137
168
|
print("ReactNative", "newClient storePath= " , storePath , " bloxAddr= " , bloxAddr , " exchange= " , exchange , " autoFlush= " , autoFlush , " useRelay= " , useRelay , " refresh= " , refresh);
|
|
@@ -174,22 +205,24 @@ class FulaModule: NSObject {
|
|
|
174
205
|
// function to be compatible with the android version.
|
|
175
206
|
@objc(initFula:withStorePath:withBloxAddr:withExchange:withAutoFlush:withRootConfig:withUseRelay:withRefresh:withResolver:withRejecter:)
|
|
176
207
|
func initFula(identityString: String, storePath: String, bloxAddr: String, exchange: String, autoFlush: Bool, rootConfig: String, useRelay: Bool, refresh: Bool, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
177
|
-
|
|
208
|
+
|
|
209
|
+
OSLog.viewCycle.info("ReactNative - init started")
|
|
210
|
+
|
|
178
211
|
do {
|
|
179
212
|
|
|
180
213
|
var resultData = Dictionary<String, String>()
|
|
181
|
-
|
|
214
|
+
OSLog.viewCycle.info("ReactNative init storePath= \(storePath)")
|
|
182
215
|
let identity = self.toByte(identityString)
|
|
183
|
-
|
|
216
|
+
OSLog.viewCycle.info("ReactNative init identity= \(identityString)")
|
|
184
217
|
let obj = try initInternal(identity: identity, storePath: storePath, bloxAddr: bloxAddr, exchange: exchange, autoFlush: autoFlush, _rootCid: rootConfig, useRelay: useRelay, refresh: refresh)
|
|
185
|
-
|
|
218
|
+
OSLog.viewCycle.info("ReactNative init object created: [ \(obj[0]), \(obj[1]), \(obj[2]) ]")
|
|
186
219
|
resultData["peerId"] = obj[0]
|
|
187
220
|
resultData["rootCid"] = obj[1]
|
|
188
221
|
resultData["wnfs_key"] = obj[2]
|
|
189
222
|
resolve(resultData as NSDictionary)
|
|
190
223
|
|
|
191
224
|
} catch let error {
|
|
192
|
-
|
|
225
|
+
OSLog.viewCycle.info("ReactNative init failed with Error: \(error.localizedDescription)")
|
|
193
226
|
reject("ERR_FULA", "init failed", error)
|
|
194
227
|
}
|
|
195
228
|
|
|
@@ -212,85 +245,108 @@ class FulaModule: NSObject {
|
|
|
212
245
|
|
|
213
246
|
}
|
|
214
247
|
|
|
215
|
-
func checkConnectionInternal() throws
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
248
|
+
func checkConnectionInternal(timeout: Int) throws -> Bool {
|
|
249
|
+
OSLog.viewCycle.info("ReactNative checkConnectionInternal started with timeout: \(timeout)")
|
|
250
|
+
var connectionStatus = false
|
|
251
|
+
|
|
252
|
+
if let fula = self.fula {
|
|
253
|
+
let semaphore = DispatchSemaphore(value: 0)
|
|
254
|
+
let queue = DispatchQueue(label: "com.yourapp.checkConnection", attributes: .concurrent)
|
|
255
|
+
|
|
256
|
+
queue.async {
|
|
257
|
+
do {
|
|
258
|
+
OSLog.viewCycle.info("ReactNative connectToBlox started")
|
|
259
|
+
try fula.connectToBlox()
|
|
260
|
+
connectionStatus = true
|
|
261
|
+
OSLog.viewCycle.info("ReactNative checkConnectionInternal succeeded")
|
|
262
|
+
semaphore.signal()
|
|
263
|
+
} catch let error {
|
|
264
|
+
OSLog.viewCycle.info("ReactNative checkConnectionInternal failed with Error: \(error.localizedDescription)")
|
|
265
|
+
semaphore.signal()
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let timeoutResult = semaphore.wait(timeout: .now() + .seconds(timeout))
|
|
270
|
+
switch timeoutResult {
|
|
271
|
+
case .timedOut:
|
|
272
|
+
OSLog.viewCycle.info("ReactNative checkConnectionInternal timed out")
|
|
273
|
+
return false
|
|
274
|
+
case .success:
|
|
275
|
+
return connectionStatus
|
|
224
276
|
}
|
|
225
277
|
} else {
|
|
226
|
-
|
|
278
|
+
OSLog.viewCycle.info("ReactNative checkConnectionInternal failed because fula is not initialized")
|
|
279
|
+
return false
|
|
227
280
|
}
|
|
228
281
|
}
|
|
229
282
|
|
|
230
|
-
@objc(checkFailedActions:withResolver:withRejecter:)
|
|
231
|
-
func checkFailedActions(retry: Bool, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
283
|
+
@objc(checkFailedActions:withTimeout:withResolver:withRejecter:)
|
|
284
|
+
func checkFailedActions(retry: Bool, timeout: Int, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
|
|
285
|
+
do {
|
|
286
|
+
guard let fula = fula else {
|
|
287
|
+
throw NSError(domain: "ERR_FULA", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula is not initialized"])
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if !retry {
|
|
291
|
+
OSLog.viewCycle.info("ReactNative checkFailedActions without retry")
|
|
292
|
+
let failedLinks = try fula.listFailedPushes()
|
|
293
|
+
|
|
294
|
+
let nextFailedLink = try failedLinks.next()
|
|
295
|
+
if nextFailedLink != nil {
|
|
296
|
+
// Assuming nextFailedLink is of type Data; replace `toHex()` with an appropriate method to convert Data to a hex string
|
|
297
|
+
OSLog.viewCycle.info("ReactNative checkFailedActions found")
|
|
239
298
|
resolve(true)
|
|
240
299
|
} else {
|
|
241
300
|
resolve(false)
|
|
242
301
|
}
|
|
243
302
|
} else {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
resolve(!retryResults)
|
|
248
|
-
|
|
303
|
+
OSLog.viewCycle.info("ReactNative checkFailedActions with retry")
|
|
304
|
+
let retryResults = try retryFailedActionsInternal(timeout: timeout) // Ensure retryFailedActionsInternal accepts a timeout parameter
|
|
305
|
+
resolve(!retryResults)
|
|
249
306
|
}
|
|
250
|
-
}
|
|
251
|
-
|
|
307
|
+
} catch let error {
|
|
308
|
+
OSLog.viewCycle.info("ReactNative checkFailedActions failed with Error: \(error.localizedDescription)")
|
|
309
|
+
reject("ERR_FULA", "CheckFailedActions failed", error)
|
|
252
310
|
}
|
|
253
|
-
} catch let error {
|
|
254
|
-
print("ReactNative", "checkFailedActions failed with Error: ", error.localizedDescription)
|
|
255
|
-
reject("ERR_FULA", "CheckFailedActions failed", error)
|
|
256
|
-
}
|
|
257
311
|
}
|
|
258
312
|
|
|
259
|
-
func retryFailedActionsInternal() throws -> Bool {
|
|
260
|
-
print("ReactNative", "retryFailedActionsInternal started")
|
|
261
|
-
if (fula != nil) {
|
|
262
|
-
//Fula is initialized
|
|
263
|
-
do {
|
|
264
|
-
try checkConnectionInternal()
|
|
265
313
|
|
|
314
|
+
|
|
315
|
+
func retryFailedActionsInternal(timeout: Int) throws -> Bool {
|
|
316
|
+
OSLog.viewCycle.info("ReactNative retryFailedActionsInternal started")
|
|
317
|
+
|
|
318
|
+
guard let fula = fula else {
|
|
319
|
+
OSLog.viewCycle.info("ReactNative retryFailedActionsInternal failed because fula is not initialized")
|
|
320
|
+
return false
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
do {
|
|
324
|
+
let connectionCheck = try checkConnectionInternal(timeout: timeout)
|
|
325
|
+
|
|
326
|
+
if connectionCheck {
|
|
266
327
|
do {
|
|
267
|
-
|
|
268
|
-
try fula
|
|
269
|
-
|
|
270
|
-
try fula
|
|
328
|
+
OSLog.viewCycle.info("ReactNative retryFailedPushes started")
|
|
329
|
+
try fula.retryFailedPushes()
|
|
330
|
+
OSLog.viewCycle.info("ReactNative flush started")
|
|
331
|
+
try fula.flush()
|
|
271
332
|
return true
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
print("ReactNative", "retryFailedActionsInternal failed with Error: ", error.localizedDescription)
|
|
333
|
+
} catch let error {
|
|
334
|
+
try fula.flush()
|
|
335
|
+
OSLog.viewCycle.info("ReactNative retryFailedActionsInternal failed with Error: \(error.localizedDescription)")
|
|
276
336
|
return false
|
|
277
337
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
catch let error {
|
|
282
|
-
print("ReactNative", "retryFailedActions failed with Error: ", error.localizedDescription)
|
|
338
|
+
} else {
|
|
339
|
+
OSLog.viewCycle.info("ReactNative retryFailedActionsInternal failed because blox is offline")
|
|
283
340
|
return false
|
|
284
341
|
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
//Fula is not initialized
|
|
342
|
+
} catch let error {
|
|
343
|
+
OSLog.viewCycle.info("ReactNative retryFailedActionsInternal failed with Error: \(error.localizedDescription)")
|
|
288
344
|
return false
|
|
289
345
|
}
|
|
290
|
-
|
|
291
346
|
}
|
|
292
347
|
|
|
293
348
|
|
|
349
|
+
|
|
294
350
|
func createPeerIdentity(privateKey: Data) throws -> Data {
|
|
295
351
|
do {
|
|
296
352
|
// 1: First: create public key from provided private key
|
|
@@ -331,31 +387,44 @@ class FulaModule: NSObject {
|
|
|
331
387
|
try encryptAndStoreConfig()
|
|
332
388
|
}
|
|
333
389
|
|
|
334
|
-
func loadWnfs(_
|
|
335
|
-
|
|
336
|
-
let hash32 =
|
|
337
|
-
|
|
390
|
+
func loadWnfs(_ _wnfsKey: Data , _ _rootCid: String) throws {
|
|
391
|
+
OSLog.viewCycle.info("ReactNative loadWnfs called: rootCid=\(_rootCid)")
|
|
392
|
+
let hash32 = _wnfsKey.sha256()
|
|
393
|
+
OSLog.viewCycle.info("ReactNative wnfsKey= \(_wnfsKey.toHex()) ; hash32 = \(hash32.toHex())");
|
|
338
394
|
try wnfs?.LoadWithWNFSKey(wnfsKey: hash32, cid: _rootCid)
|
|
339
395
|
rootCid = _rootCid
|
|
396
|
+
wnfsKey = _wnfsKey
|
|
340
397
|
if (fula != nil) {
|
|
341
398
|
try fula?.flush()
|
|
342
399
|
}
|
|
343
|
-
|
|
400
|
+
OSLog.viewCycle.info("ReactNative loadWnfs completed")
|
|
344
401
|
try encryptAndStoreConfig()
|
|
345
402
|
}
|
|
346
403
|
|
|
347
404
|
|
|
348
405
|
func encryptAndStoreConfig() throws {
|
|
349
406
|
do {
|
|
350
|
-
if
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
407
|
+
if let identityEncryptedGlobalUnwrapped = identityEncryptedGlobal {
|
|
408
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig started")
|
|
409
|
+
|
|
410
|
+
if let rootCidUnwrapped = rootCid, let wnfsKeyUnwrapped = wnfsKey, let secretKeyGlobalUnwrapped = secretKeyGlobal {
|
|
411
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig started with rootCid: \(rootCidUnwrapped.toUint8Array()) and wnfsKey:\(wnfsKeyUnwrapped)")
|
|
412
|
+
|
|
413
|
+
let cid_encrypted = try Cryptography.encryptMsg(rootCidUnwrapped.toUint8Array(), secretKeyGlobalUnwrapped)
|
|
414
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig cid_encrypted: \(cid_encrypted)")
|
|
415
|
+
|
|
416
|
+
let wnfs_key_encrypted = try Cryptography.encryptMsg(wnfsKeyUnwrapped.toUint8Array(), secretKeyGlobalUnwrapped)
|
|
417
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig wnfs_key_encrypted: \(wnfs_key_encrypted)")
|
|
418
|
+
|
|
419
|
+
userDataHelper.add("cid_encrypted_" + identityEncryptedGlobalUnwrapped, cid_encrypted)
|
|
420
|
+
userDataHelper.add("wnfs_key_encrypted_" + identityEncryptedGlobalUnwrapped, wnfs_key_encrypted)
|
|
421
|
+
} else {
|
|
422
|
+
// Handle the case where rootCid, wnfsKey, or secretKeyGlobal is nil
|
|
423
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig failed because one of the values is nil")
|
|
424
|
+
}
|
|
356
425
|
}
|
|
357
426
|
} catch let error {
|
|
358
|
-
|
|
427
|
+
OSLog.viewCycle.info("ReactNative encryptAndStoreConfig failed with Error: \(error.localizedDescription)")
|
|
359
428
|
throw error
|
|
360
429
|
}
|
|
361
430
|
}
|
|
@@ -443,7 +512,7 @@ class FulaModule: NSObject {
|
|
|
443
512
|
do {
|
|
444
513
|
if (fula == nil || refresh) {
|
|
445
514
|
try newClientInternal(identity: identity, storePath: storePath, bloxAddr: bloxAddr, exchange: exchange, autoFlush: autoFlush, useRelay: useRelay, refresh: refresh)
|
|
446
|
-
|
|
515
|
+
OSLog.viewCycle.info("ReactNative fula initialized: \(self.fula!.id_())")
|
|
447
516
|
}
|
|
448
517
|
if(client == nil || refresh) {
|
|
449
518
|
client = Client(clientInput: fula!)
|
|
@@ -458,7 +527,7 @@ class FulaModule: NSObject {
|
|
|
458
527
|
}
|
|
459
528
|
return try c.get(cid)
|
|
460
529
|
})
|
|
461
|
-
|
|
530
|
+
OSLog.viewCycle.info("ReactNative wnfs initialized")
|
|
462
531
|
}
|
|
463
532
|
|
|
464
533
|
let secretKey = try Cryptography.generateKey(identity)
|
|
@@ -467,35 +536,35 @@ class FulaModule: NSObject {
|
|
|
467
536
|
secretKeyGlobal = secretKey
|
|
468
537
|
|
|
469
538
|
if (rootCid == nil || rootCid!.isEmpty) {
|
|
470
|
-
|
|
539
|
+
OSLog.viewCycle.info("ReactNative rootCid is empty.")
|
|
471
540
|
//Load from keystore
|
|
472
541
|
|
|
473
542
|
let cid_encrypted_fetched = userDataHelper.getValue("cid_encrypted_"+identity_encrypted)
|
|
474
|
-
|
|
543
|
+
OSLog.viewCycle.info("ReactNative Here1")
|
|
475
544
|
var cid: Array<UInt8>? = nil
|
|
476
545
|
if(cid_encrypted_fetched != nil && !cid_encrypted_fetched!.isEmpty) {
|
|
477
|
-
|
|
546
|
+
OSLog.viewCycle.info("ReactNative decrypting cid= \(cid_encrypted_fetched!) with secret \(secretKey.toHex())")
|
|
478
547
|
cid = try Cryptography.decryptMsg(cid_encrypted_fetched!, secretKey)
|
|
479
548
|
}
|
|
480
549
|
print("ReactNative", "Here2")
|
|
481
550
|
//print("ReactNative", "Attempted to fetch cid from keystore cid="+cid+" & wnfs_key="+wnfs_key)
|
|
482
551
|
if(cid == nil || cid!.isEmpty){
|
|
483
|
-
|
|
552
|
+
OSLog.viewCycle.info("ReactNative cid or wnfs key was not found")
|
|
484
553
|
if(!_rootCid.isEmpty){
|
|
485
|
-
|
|
554
|
+
OSLog.viewCycle.info("ReactNative Re-setting cid from input: \(_rootCid)")
|
|
486
555
|
cid = _rootCid.toUint8Array()
|
|
487
556
|
}
|
|
488
557
|
|
|
489
558
|
}
|
|
490
559
|
if(cid == nil || cid!.isEmpty){
|
|
491
|
-
|
|
560
|
+
OSLog.viewCycle.info("ReactNative Tried to recover cid but was not successful. Creating ones")
|
|
492
561
|
try createNewrootCid(identity: identity)
|
|
493
562
|
} else {
|
|
494
|
-
|
|
495
|
-
|
|
563
|
+
OSLog.viewCycle.info("ReactNative Found cid and wnfs key in keychain store")
|
|
564
|
+
OSLog.viewCycle.info("ReactNative Recovered cid and private ref from keychain store. cid=\(cid!) & wnfs_key=\(identity)")
|
|
496
565
|
try loadWnfs(identity, cid!.toData().toUTF8String()!)
|
|
497
566
|
}
|
|
498
|
-
|
|
567
|
+
OSLog.viewCycle.info("ReactNative creating/reloading rootCid completed")
|
|
499
568
|
|
|
500
569
|
/*
|
|
501
570
|
byte[] testbyte = convertStringToByte("-104,40,24,-93,24,100,24,114,24,111,24,111,24,116,24,-126,24,-126,0,0,24,-128,24,103,24,118,24,101,24,114,24,115,24,105,24,111,24,110,24,101,24,48,24,46,24,49,24,46,24,48,24,105,24,115,24,116,24,114,24,117,24,99,24,116,24,117,24,114,24,101,24,100,24,104,24,97,24,109,24,116")
|
|
@@ -508,22 +577,22 @@ class FulaModule: NSObject {
|
|
|
508
577
|
*/
|
|
509
578
|
|
|
510
579
|
|
|
511
|
-
|
|
580
|
+
OSLog.viewCycle.info("ReactNative rootCid is created: cid=\(self.rootCid!) & wnfs_key=\(self.wnfsKey!.toHex())")
|
|
512
581
|
} else {
|
|
513
|
-
|
|
582
|
+
OSLog.viewCycle.info("ReactNative rootCid existed: cid=\(self.rootCid!) & wnfs_key=\(self.wnfsKey!.toHex())")
|
|
514
583
|
}
|
|
515
584
|
let peerId = fula!.id_()
|
|
516
585
|
var obj = [String]()
|
|
517
586
|
obj.append(peerId)
|
|
518
587
|
obj.append(rootCid!)
|
|
519
588
|
obj.append(wnfsKey!.toHex())
|
|
520
|
-
|
|
589
|
+
OSLog.viewCycle.info("ReactNative initInternal is completed successfully")
|
|
521
590
|
if (fula != nil) {
|
|
522
591
|
try fula?.flush()
|
|
523
592
|
}
|
|
524
593
|
return obj
|
|
525
594
|
} catch let error {
|
|
526
|
-
|
|
595
|
+
OSLog.viewCycle.info("ReactNative init internal failed with Error: \(error.localizedDescription)")
|
|
527
596
|
throw error
|
|
528
597
|
}
|
|
529
598
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.8",
|
|
4
4
|
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|