@synonymdev/react-native-pubky 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -9
- package/android/src/main/java/com/pubky/PubkyModule.kt +364 -273
- package/android/src/main/java/uniffi/pubkycore/pubkycore.kt +1327 -0
- package/android/src/main/jniLibs/arm64-v8a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkycore.so +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/Info.plist +8 -8
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64/libpubkymobile.a → PubkyCore.xcframework/ios-arm64/libpubkycore.a} +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64-simulator/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a → PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a} +0 -0
- package/ios/Pubky-Bridging-Header.h +1 -0
- package/ios/Pubky.mm +16 -1
- package/ios/Pubky.swift +64 -1
- package/ios/{pubkymobile.swift → pubkycore.swift} +354 -37
- package/lib/commonjs/index.js +45 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +42 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +16 -9
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +16 -9
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +12 -7
- package/react-native-pubky.podspec +1 -1
- package/src/index.tsx +62 -9
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +0 -862
- package/android/src/main/jniLibs/arm64-v8a/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkymobile.so +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libmobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libmobile.a +0 -0
package/ios/Pubky.mm
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
2
|
+
#import <React/RCTEventEmitter.h>
|
2
3
|
|
3
|
-
@interface RCT_EXTERN_MODULE(Pubky,
|
4
|
+
@interface RCT_EXTERN_MODULE(Pubky, RCTEventEmitter)
|
5
|
+
|
6
|
+
RCT_EXTERN_METHOD(setEventListener:(RCTPromiseResolveBlock)resolve
|
7
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
8
|
+
|
9
|
+
RCT_EXTERN_METHOD(removeEventListener:(RCTPromiseResolveBlock)resolve
|
10
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
11
|
+
|
12
|
+
RCT_EXTERN_METHOD(deleteFile:(NSString *)url
|
13
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
14
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
15
|
+
|
16
|
+
RCT_EXTERN_METHOD(session:(NSString *)pubky
|
17
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
18
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
4
19
|
|
5
20
|
RCT_EXTERN_METHOD(auth:(NSString *)url
|
6
21
|
secretKey:(NSString *)secretKey
|
package/ios/Pubky.swift
CHANGED
@@ -1,7 +1,46 @@
|
|
1
1
|
import Foundation
|
2
|
+
import React
|
2
3
|
|
3
4
|
@objc(Pubky)
|
4
|
-
class Pubky:
|
5
|
+
class Pubky: RCTEventEmitter {
|
6
|
+
|
7
|
+
override init() {
|
8
|
+
super.init()
|
9
|
+
}
|
10
|
+
|
11
|
+
@objc override static func requiresMainQueueSetup() -> Bool {
|
12
|
+
return false
|
13
|
+
}
|
14
|
+
|
15
|
+
override func supportedEvents() -> [String]! {
|
16
|
+
return ["PubkyEvent"]
|
17
|
+
}
|
18
|
+
|
19
|
+
class EventListenerImpl: EventListener {
|
20
|
+
weak var pubky: Pubky?
|
21
|
+
|
22
|
+
init(pubky: Pubky) {
|
23
|
+
self.pubky = pubky
|
24
|
+
}
|
25
|
+
|
26
|
+
func onEventOccurred(eventData: String) {
|
27
|
+
pubky?.sendEvent(withName: "PubkyEvent", body: eventData)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
@objc(setEventListener:withRejecter:)
|
32
|
+
func setEventListener(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
33
|
+
let listener = EventListenerImpl(pubky: self)
|
34
|
+
react_native_pubky.setEventListener(listener: listener)
|
35
|
+
resolve(nil)
|
36
|
+
}
|
37
|
+
|
38
|
+
@objc(removeEventListener:withRejecter:)
|
39
|
+
func removeEventListener(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
40
|
+
react_native_pubky.removeEventListener()
|
41
|
+
resolve(nil)
|
42
|
+
}
|
43
|
+
|
5
44
|
@objc(auth:secretKey:withResolver:withRejecter:)
|
6
45
|
func auth(_ url: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
7
46
|
Task {
|
@@ -144,6 +183,30 @@ class Pubky: NSObject {
|
|
144
183
|
}
|
145
184
|
}
|
146
185
|
|
186
|
+
@objc(deleteFile:withResolver:withRejecter:)
|
187
|
+
func deleteFile(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
188
|
+
Task {
|
189
|
+
do {
|
190
|
+
let result = try await react_native_pubky.deleteFile(url: url)
|
191
|
+
resolve(result)
|
192
|
+
} catch {
|
193
|
+
reject("list Error", "Failed to deleteFile", error)
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
@objc(session:withResolver:withRejecter:)
|
199
|
+
func session(_ pubky: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
200
|
+
Task {
|
201
|
+
do {
|
202
|
+
let result = react_native_pubky.session(pubky: pubky)
|
203
|
+
resolve(result)
|
204
|
+
} catch {
|
205
|
+
reject("session Error", "Failed to get session", error)
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
147
210
|
@objc(generateSecretKey:withRejecter:)
|
148
211
|
func generateSecretKey(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
149
212
|
Task {
|
@@ -5,8 +5,8 @@ import Foundation
|
|
5
5
|
// Depending on the consumer's build setup, the low-level FFI code
|
6
6
|
// might be in a separate module, or it might be compiled inline into
|
7
7
|
// this module. This is a bit of light hackery to work with both.
|
8
|
-
#if canImport(
|
9
|
-
import
|
8
|
+
#if canImport(pubkycoreFFI)
|
9
|
+
import pubkycoreFFI
|
10
10
|
#endif
|
11
11
|
|
12
12
|
fileprivate extension RustBuffer {
|
@@ -19,13 +19,13 @@ fileprivate extension RustBuffer {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
|
22
|
-
try! rustCall {
|
22
|
+
try! rustCall { ffi_pubkycore_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
|
23
23
|
}
|
24
24
|
|
25
25
|
// Frees the buffer in place.
|
26
26
|
// The buffer must not be used after this is called.
|
27
27
|
func deallocate() {
|
28
|
-
try! rustCall {
|
28
|
+
try! rustCall { ffi_pubkycore_rustbuffer_free(self, $0) }
|
29
29
|
}
|
30
30
|
}
|
31
31
|
|
@@ -297,6 +297,27 @@ private func uniffiCheckCallStatus(
|
|
297
297
|
// Public interface members begin here.
|
298
298
|
|
299
299
|
|
300
|
+
fileprivate struct FfiConverterBool : FfiConverter {
|
301
|
+
typealias FfiType = Int8
|
302
|
+
typealias SwiftType = Bool
|
303
|
+
|
304
|
+
public static func lift(_ value: Int8) throws -> Bool {
|
305
|
+
return value != 0
|
306
|
+
}
|
307
|
+
|
308
|
+
public static func lower(_ value: Bool) -> Int8 {
|
309
|
+
return value ? 1 : 0
|
310
|
+
}
|
311
|
+
|
312
|
+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
313
|
+
return try lift(readInt(&buf))
|
314
|
+
}
|
315
|
+
|
316
|
+
public static func write(_ value: Bool, into buf: inout [UInt8]) {
|
317
|
+
writeInt(&buf, lower(value))
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
300
321
|
fileprivate struct FfiConverterString: FfiConverter {
|
301
322
|
typealias SwiftType = String
|
302
323
|
typealias FfiType = RustBuffer
|
@@ -335,6 +356,240 @@ fileprivate struct FfiConverterString: FfiConverter {
|
|
335
356
|
}
|
336
357
|
}
|
337
358
|
|
359
|
+
|
360
|
+
public protocol EventNotifierProtocol {
|
361
|
+
|
362
|
+
}
|
363
|
+
|
364
|
+
public class EventNotifier: EventNotifierProtocol {
|
365
|
+
fileprivate let pointer: UnsafeMutableRawPointer
|
366
|
+
|
367
|
+
// TODO: We'd like this to be `private` but for Swifty reasons,
|
368
|
+
// we can't implement `FfiConverter` without making this `required` and we can't
|
369
|
+
// make it `required` without making it `public`.
|
370
|
+
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
|
371
|
+
self.pointer = pointer
|
372
|
+
}
|
373
|
+
|
374
|
+
deinit {
|
375
|
+
try! rustCall { uniffi_pubkycore_fn_free_eventnotifier(pointer, $0) }
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
}
|
383
|
+
|
384
|
+
public struct FfiConverterTypeEventNotifier: FfiConverter {
|
385
|
+
typealias FfiType = UnsafeMutableRawPointer
|
386
|
+
typealias SwiftType = EventNotifier
|
387
|
+
|
388
|
+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EventNotifier {
|
389
|
+
let v: UInt64 = try readInt(&buf)
|
390
|
+
// The Rust code won't compile if a pointer won't fit in a UInt64.
|
391
|
+
// We have to go via `UInt` because that's the thing that's the size of a pointer.
|
392
|
+
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
|
393
|
+
if (ptr == nil) {
|
394
|
+
throw UniffiInternalError.unexpectedNullPointer
|
395
|
+
}
|
396
|
+
return try lift(ptr!)
|
397
|
+
}
|
398
|
+
|
399
|
+
public static func write(_ value: EventNotifier, into buf: inout [UInt8]) {
|
400
|
+
// This fiddling is because `Int` is the thing that's the same size as a pointer.
|
401
|
+
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
|
402
|
+
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
|
403
|
+
}
|
404
|
+
|
405
|
+
public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
406
|
+
return EventNotifier(unsafeFromRawPointer: pointer)
|
407
|
+
}
|
408
|
+
|
409
|
+
public static func lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
|
410
|
+
return value.pointer
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
414
|
+
|
415
|
+
public func FfiConverterTypeEventNotifier_lift(_ pointer: UnsafeMutableRawPointer) throws -> EventNotifier {
|
416
|
+
return try FfiConverterTypeEventNotifier.lift(pointer)
|
417
|
+
}
|
418
|
+
|
419
|
+
public func FfiConverterTypeEventNotifier_lower(_ value: EventNotifier) -> UnsafeMutableRawPointer {
|
420
|
+
return FfiConverterTypeEventNotifier.lower(value)
|
421
|
+
}
|
422
|
+
|
423
|
+
fileprivate extension NSLock {
|
424
|
+
func withLock<T>(f: () throws -> T) rethrows -> T {
|
425
|
+
self.lock()
|
426
|
+
defer { self.unlock() }
|
427
|
+
return try f()
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
fileprivate typealias UniFFICallbackHandle = UInt64
|
432
|
+
fileprivate class UniFFICallbackHandleMap<T> {
|
433
|
+
private var leftMap: [UniFFICallbackHandle: T] = [:]
|
434
|
+
private var counter: [UniFFICallbackHandle: UInt64] = [:]
|
435
|
+
private var rightMap: [ObjectIdentifier: UniFFICallbackHandle] = [:]
|
436
|
+
|
437
|
+
private let lock = NSLock()
|
438
|
+
private var currentHandle: UniFFICallbackHandle = 0
|
439
|
+
private let stride: UniFFICallbackHandle = 1
|
440
|
+
|
441
|
+
func insert(obj: T) -> UniFFICallbackHandle {
|
442
|
+
lock.withLock {
|
443
|
+
let id = ObjectIdentifier(obj as AnyObject)
|
444
|
+
let handle = rightMap[id] ?? {
|
445
|
+
currentHandle += stride
|
446
|
+
let handle = currentHandle
|
447
|
+
leftMap[handle] = obj
|
448
|
+
rightMap[id] = handle
|
449
|
+
return handle
|
450
|
+
}()
|
451
|
+
counter[handle] = (counter[handle] ?? 0) + 1
|
452
|
+
return handle
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
func get(handle: UniFFICallbackHandle) -> T? {
|
457
|
+
lock.withLock {
|
458
|
+
leftMap[handle]
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
func delete(handle: UniFFICallbackHandle) {
|
463
|
+
remove(handle: handle)
|
464
|
+
}
|
465
|
+
|
466
|
+
@discardableResult
|
467
|
+
func remove(handle: UniFFICallbackHandle) -> T? {
|
468
|
+
lock.withLock {
|
469
|
+
defer { counter[handle] = (counter[handle] ?? 1) - 1 }
|
470
|
+
guard counter[handle] == 1 else { return leftMap[handle] }
|
471
|
+
let obj = leftMap.removeValue(forKey: handle)
|
472
|
+
if let obj = obj {
|
473
|
+
rightMap.removeValue(forKey: ObjectIdentifier(obj as AnyObject))
|
474
|
+
}
|
475
|
+
return obj
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
// Magic number for the Rust proxy to call using the same mechanism as every other method,
|
481
|
+
// to free the callback once it's dropped by Rust.
|
482
|
+
private let IDX_CALLBACK_FREE: Int32 = 0
|
483
|
+
// Callback return codes
|
484
|
+
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
|
485
|
+
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
|
486
|
+
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
|
487
|
+
|
488
|
+
// Declaration and FfiConverters for EventListener Callback Interface
|
489
|
+
|
490
|
+
public protocol EventListener : AnyObject {
|
491
|
+
func onEventOccurred(eventData: String)
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
// The ForeignCallback that is passed to Rust.
|
496
|
+
fileprivate let foreignCallbackCallbackInterfaceEventListener : ForeignCallback =
|
497
|
+
{ (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer<UInt8>, argsLen: Int32, out_buf: UnsafeMutablePointer<RustBuffer>) -> Int32 in
|
498
|
+
|
499
|
+
|
500
|
+
func invokeOnEventOccurred(_ swiftCallbackInterface: EventListener, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
|
501
|
+
var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
|
502
|
+
func makeCall() throws -> Int32 {
|
503
|
+
try swiftCallbackInterface.onEventOccurred(
|
504
|
+
eventData: try FfiConverterString.read(from: &reader)
|
505
|
+
)
|
506
|
+
return UNIFFI_CALLBACK_SUCCESS
|
507
|
+
}
|
508
|
+
return try makeCall()
|
509
|
+
}
|
510
|
+
|
511
|
+
|
512
|
+
switch method {
|
513
|
+
case IDX_CALLBACK_FREE:
|
514
|
+
FfiConverterCallbackInterfaceEventListener.drop(handle: handle)
|
515
|
+
// Sucessful return
|
516
|
+
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
517
|
+
return UNIFFI_CALLBACK_SUCCESS
|
518
|
+
case 1:
|
519
|
+
let cb: EventListener
|
520
|
+
do {
|
521
|
+
cb = try FfiConverterCallbackInterfaceEventListener.lift(handle)
|
522
|
+
} catch {
|
523
|
+
out_buf.pointee = FfiConverterString.lower("EventListener: Invalid handle")
|
524
|
+
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
525
|
+
}
|
526
|
+
do {
|
527
|
+
return try invokeOnEventOccurred(cb, argsData, argsLen, out_buf)
|
528
|
+
} catch let error {
|
529
|
+
out_buf.pointee = FfiConverterString.lower(String(describing: error))
|
530
|
+
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
531
|
+
}
|
532
|
+
|
533
|
+
// This should never happen, because an out of bounds method index won't
|
534
|
+
// ever be used. Once we can catch errors, we should return an InternalError.
|
535
|
+
// https://github.com/mozilla/uniffi-rs/issues/351
|
536
|
+
default:
|
537
|
+
// An unexpected error happened.
|
538
|
+
// See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
|
539
|
+
return UNIFFI_CALLBACK_UNEXPECTED_ERROR
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
// FfiConverter protocol for callback interfaces
|
544
|
+
fileprivate struct FfiConverterCallbackInterfaceEventListener {
|
545
|
+
private static let initCallbackOnce: () = {
|
546
|
+
// Swift ensures this initializer code will once run once, even when accessed by multiple threads.
|
547
|
+
try! rustCall { (err: UnsafeMutablePointer<RustCallStatus>) in
|
548
|
+
uniffi_pubkycore_fn_init_callback_eventlistener(foreignCallbackCallbackInterfaceEventListener, err)
|
549
|
+
}
|
550
|
+
}()
|
551
|
+
|
552
|
+
private static func ensureCallbackinitialized() {
|
553
|
+
_ = initCallbackOnce
|
554
|
+
}
|
555
|
+
|
556
|
+
static func drop(handle: UniFFICallbackHandle) {
|
557
|
+
handleMap.remove(handle: handle)
|
558
|
+
}
|
559
|
+
|
560
|
+
private static var handleMap = UniFFICallbackHandleMap<EventListener>()
|
561
|
+
}
|
562
|
+
|
563
|
+
extension FfiConverterCallbackInterfaceEventListener : FfiConverter {
|
564
|
+
typealias SwiftType = EventListener
|
565
|
+
// We can use Handle as the FfiType because it's a typealias to UInt64
|
566
|
+
typealias FfiType = UniFFICallbackHandle
|
567
|
+
|
568
|
+
public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType {
|
569
|
+
ensureCallbackinitialized();
|
570
|
+
guard let callback = handleMap.get(handle: handle) else {
|
571
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
572
|
+
}
|
573
|
+
return callback
|
574
|
+
}
|
575
|
+
|
576
|
+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
577
|
+
ensureCallbackinitialized();
|
578
|
+
let handle: UniFFICallbackHandle = try readInt(&buf)
|
579
|
+
return try lift(handle)
|
580
|
+
}
|
581
|
+
|
582
|
+
public static func lower(_ v: SwiftType) -> UniFFICallbackHandle {
|
583
|
+
ensureCallbackinitialized();
|
584
|
+
return handleMap.insert(obj: v)
|
585
|
+
}
|
586
|
+
|
587
|
+
public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
|
588
|
+
ensureCallbackinitialized();
|
589
|
+
writeInt(&buf, lower(v))
|
590
|
+
}
|
591
|
+
}
|
592
|
+
|
338
593
|
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
339
594
|
typealias SwiftType = [String]
|
340
595
|
|
@@ -360,7 +615,7 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
360
615
|
public func auth(url: String, secretKey: String) -> [String] {
|
361
616
|
return try! FfiConverterSequenceString.lift(
|
362
617
|
try! rustCall() {
|
363
|
-
|
618
|
+
uniffi_pubkycore_fn_func_auth(
|
364
619
|
FfiConverterString.lower(url),
|
365
620
|
FfiConverterString.lower(secretKey),$0)
|
366
621
|
}
|
@@ -370,7 +625,7 @@ public func auth(url: String, secretKey: String) -> [String] {
|
|
370
625
|
public func createRecoveryFile(secretKey: String, passphrase: String) -> [String] {
|
371
626
|
return try! FfiConverterSequenceString.lift(
|
372
627
|
try! rustCall() {
|
373
|
-
|
628
|
+
uniffi_pubkycore_fn_func_create_recovery_file(
|
374
629
|
FfiConverterString.lower(secretKey),
|
375
630
|
FfiConverterString.lower(passphrase),$0)
|
376
631
|
}
|
@@ -380,17 +635,26 @@ public func createRecoveryFile(secretKey: String, passphrase: String) -> [Strin
|
|
380
635
|
public func decryptRecoveryFile(recoveryFile: String, passphrase: String) -> [String] {
|
381
636
|
return try! FfiConverterSequenceString.lift(
|
382
637
|
try! rustCall() {
|
383
|
-
|
638
|
+
uniffi_pubkycore_fn_func_decrypt_recovery_file(
|
384
639
|
FfiConverterString.lower(recoveryFile),
|
385
640
|
FfiConverterString.lower(passphrase),$0)
|
386
641
|
}
|
387
642
|
)
|
388
643
|
}
|
389
644
|
|
645
|
+
public func deleteFile(url: String) -> [String] {
|
646
|
+
return try! FfiConverterSequenceString.lift(
|
647
|
+
try! rustCall() {
|
648
|
+
uniffi_pubkycore_fn_func_delete_file(
|
649
|
+
FfiConverterString.lower(url),$0)
|
650
|
+
}
|
651
|
+
)
|
652
|
+
}
|
653
|
+
|
390
654
|
public func generateSecretKey() -> [String] {
|
391
655
|
return try! FfiConverterSequenceString.lift(
|
392
656
|
try! rustCall() {
|
393
|
-
|
657
|
+
uniffi_pubkycore_fn_func_generate_secret_key($0)
|
394
658
|
}
|
395
659
|
)
|
396
660
|
}
|
@@ -398,7 +662,7 @@ public func generateSecretKey() -> [String] {
|
|
398
662
|
public func get(url: String) -> [String] {
|
399
663
|
return try! FfiConverterSequenceString.lift(
|
400
664
|
try! rustCall() {
|
401
|
-
|
665
|
+
uniffi_pubkycore_fn_func_get(
|
402
666
|
FfiConverterString.lower(url),$0)
|
403
667
|
}
|
404
668
|
)
|
@@ -407,7 +671,7 @@ public func get(url: String) -> [String] {
|
|
407
671
|
public func getPublicKeyFromSecretKey(secretKey: String) -> [String] {
|
408
672
|
return try! FfiConverterSequenceString.lift(
|
409
673
|
try! rustCall() {
|
410
|
-
|
674
|
+
uniffi_pubkycore_fn_func_get_public_key_from_secret_key(
|
411
675
|
FfiConverterString.lower(secretKey),$0)
|
412
676
|
}
|
413
677
|
)
|
@@ -416,7 +680,7 @@ public func getPublicKeyFromSecretKey(secretKey: String) -> [String] {
|
|
416
680
|
public func list(url: String) -> [String] {
|
417
681
|
return try! FfiConverterSequenceString.lift(
|
418
682
|
try! rustCall() {
|
419
|
-
|
683
|
+
uniffi_pubkycore_fn_func_list(
|
420
684
|
FfiConverterString.lower(url),$0)
|
421
685
|
}
|
422
686
|
)
|
@@ -425,7 +689,7 @@ public func list(url: String) -> [String] {
|
|
425
689
|
public func parseAuthUrl(url: String) -> [String] {
|
426
690
|
return try! FfiConverterSequenceString.lift(
|
427
691
|
try! rustCall() {
|
428
|
-
|
692
|
+
uniffi_pubkycore_fn_func_parse_auth_url(
|
429
693
|
FfiConverterString.lower(url),$0)
|
430
694
|
}
|
431
695
|
)
|
@@ -434,7 +698,7 @@ public func parseAuthUrl(url: String) -> [String] {
|
|
434
698
|
public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
|
435
699
|
return try! FfiConverterSequenceString.lift(
|
436
700
|
try! rustCall() {
|
437
|
-
|
701
|
+
uniffi_pubkycore_fn_func_publish(
|
438
702
|
FfiConverterString.lower(recordName),
|
439
703
|
FfiConverterString.lower(recordContent),
|
440
704
|
FfiConverterString.lower(secretKey),$0)
|
@@ -445,7 +709,7 @@ public func publish(recordName: String, recordContent: String, secretKey: String
|
|
445
709
|
public func publishHttps(recordName: String, target: String, secretKey: String) -> [String] {
|
446
710
|
return try! FfiConverterSequenceString.lift(
|
447
711
|
try! rustCall() {
|
448
|
-
|
712
|
+
uniffi_pubkycore_fn_func_publish_https(
|
449
713
|
FfiConverterString.lower(recordName),
|
450
714
|
FfiConverterString.lower(target),
|
451
715
|
FfiConverterString.lower(secretKey),$0)
|
@@ -456,17 +720,25 @@ public func publishHttps(recordName: String, target: String, secretKey: String)
|
|
456
720
|
public func put(url: String, content: String) -> [String] {
|
457
721
|
return try! FfiConverterSequenceString.lift(
|
458
722
|
try! rustCall() {
|
459
|
-
|
723
|
+
uniffi_pubkycore_fn_func_put(
|
460
724
|
FfiConverterString.lower(url),
|
461
725
|
FfiConverterString.lower(content),$0)
|
462
726
|
}
|
463
727
|
)
|
464
728
|
}
|
465
729
|
|
730
|
+
public func removeEventListener() {
|
731
|
+
try! rustCall() {
|
732
|
+
uniffi_pubkycore_fn_func_remove_event_listener($0)
|
733
|
+
}
|
734
|
+
}
|
735
|
+
|
736
|
+
|
737
|
+
|
466
738
|
public func resolve(publicKey: String) -> [String] {
|
467
739
|
return try! FfiConverterSequenceString.lift(
|
468
740
|
try! rustCall() {
|
469
|
-
|
741
|
+
uniffi_pubkycore_fn_func_resolve(
|
470
742
|
FfiConverterString.lower(publicKey),$0)
|
471
743
|
}
|
472
744
|
)
|
@@ -475,16 +747,34 @@ public func resolve(publicKey: String) -> [String] {
|
|
475
747
|
public func resolveHttps(publicKey: String) -> [String] {
|
476
748
|
return try! FfiConverterSequenceString.lift(
|
477
749
|
try! rustCall() {
|
478
|
-
|
750
|
+
uniffi_pubkycore_fn_func_resolve_https(
|
479
751
|
FfiConverterString.lower(publicKey),$0)
|
480
752
|
}
|
481
753
|
)
|
482
754
|
}
|
483
755
|
|
756
|
+
public func session(pubky: String) -> [String] {
|
757
|
+
return try! FfiConverterSequenceString.lift(
|
758
|
+
try! rustCall() {
|
759
|
+
uniffi_pubkycore_fn_func_session(
|
760
|
+
FfiConverterString.lower(pubky),$0)
|
761
|
+
}
|
762
|
+
)
|
763
|
+
}
|
764
|
+
|
765
|
+
public func setEventListener(listener: EventListener) {
|
766
|
+
try! rustCall() {
|
767
|
+
uniffi_pubkycore_fn_func_set_event_listener(
|
768
|
+
FfiConverterCallbackInterfaceEventListener.lower(listener),$0)
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
|
773
|
+
|
484
774
|
public func signIn(secretKey: String) -> [String] {
|
485
775
|
return try! FfiConverterSequenceString.lift(
|
486
776
|
try! rustCall() {
|
487
|
-
|
777
|
+
uniffi_pubkycore_fn_func_sign_in(
|
488
778
|
FfiConverterString.lower(secretKey),$0)
|
489
779
|
}
|
490
780
|
)
|
@@ -493,7 +783,7 @@ public func signIn(secretKey: String) -> [String] {
|
|
493
783
|
public func signOut(secretKey: String) -> [String] {
|
494
784
|
return try! FfiConverterSequenceString.lift(
|
495
785
|
try! rustCall() {
|
496
|
-
|
786
|
+
uniffi_pubkycore_fn_func_sign_out(
|
497
787
|
FfiConverterString.lower(secretKey),$0)
|
498
788
|
}
|
499
789
|
)
|
@@ -502,13 +792,22 @@ public func signOut(secretKey: String) -> [String] {
|
|
502
792
|
public func signUp(secretKey: String, homeserver: String) -> [String] {
|
503
793
|
return try! FfiConverterSequenceString.lift(
|
504
794
|
try! rustCall() {
|
505
|
-
|
795
|
+
uniffi_pubkycore_fn_func_sign_up(
|
506
796
|
FfiConverterString.lower(secretKey),
|
507
797
|
FfiConverterString.lower(homeserver),$0)
|
508
798
|
}
|
509
799
|
)
|
510
800
|
}
|
511
801
|
|
802
|
+
public func switchNetwork(useTestnet: Bool) -> [String] {
|
803
|
+
return try! FfiConverterSequenceString.lift(
|
804
|
+
try! rustCall() {
|
805
|
+
uniffi_pubkycore_fn_func_switch_network(
|
806
|
+
FfiConverterBool.lower(useTestnet),$0)
|
807
|
+
}
|
808
|
+
)
|
809
|
+
}
|
810
|
+
|
512
811
|
private enum InitializationResult {
|
513
812
|
case ok
|
514
813
|
case contractVersionMismatch
|
@@ -520,56 +819,74 @@ private var initializationResult: InitializationResult {
|
|
520
819
|
// Get the bindings contract version from our ComponentInterface
|
521
820
|
let bindings_contract_version = 24
|
522
821
|
// Get the scaffolding contract version by calling the into the dylib
|
523
|
-
let scaffolding_contract_version =
|
822
|
+
let scaffolding_contract_version = ffi_pubkycore_uniffi_contract_version()
|
524
823
|
if bindings_contract_version != scaffolding_contract_version {
|
525
824
|
return InitializationResult.contractVersionMismatch
|
526
825
|
}
|
527
|
-
if (
|
826
|
+
if (uniffi_pubkycore_checksum_func_auth() != 51826) {
|
827
|
+
return InitializationResult.apiChecksumMismatch
|
828
|
+
}
|
829
|
+
if (uniffi_pubkycore_checksum_func_create_recovery_file() != 48846) {
|
830
|
+
return InitializationResult.apiChecksumMismatch
|
831
|
+
}
|
832
|
+
if (uniffi_pubkycore_checksum_func_decrypt_recovery_file() != 26407) {
|
833
|
+
return InitializationResult.apiChecksumMismatch
|
834
|
+
}
|
835
|
+
if (uniffi_pubkycore_checksum_func_delete_file() != 9063) {
|
836
|
+
return InitializationResult.apiChecksumMismatch
|
837
|
+
}
|
838
|
+
if (uniffi_pubkycore_checksum_func_generate_secret_key() != 12800) {
|
839
|
+
return InitializationResult.apiChecksumMismatch
|
840
|
+
}
|
841
|
+
if (uniffi_pubkycore_checksum_func_get() != 6591) {
|
842
|
+
return InitializationResult.apiChecksumMismatch
|
843
|
+
}
|
844
|
+
if (uniffi_pubkycore_checksum_func_get_public_key_from_secret_key() != 40316) {
|
528
845
|
return InitializationResult.apiChecksumMismatch
|
529
846
|
}
|
530
|
-
if (
|
847
|
+
if (uniffi_pubkycore_checksum_func_list() != 43198) {
|
531
848
|
return InitializationResult.apiChecksumMismatch
|
532
849
|
}
|
533
|
-
if (
|
850
|
+
if (uniffi_pubkycore_checksum_func_parse_auth_url() != 27379) {
|
534
851
|
return InitializationResult.apiChecksumMismatch
|
535
852
|
}
|
536
|
-
if (
|
853
|
+
if (uniffi_pubkycore_checksum_func_publish() != 48989) {
|
537
854
|
return InitializationResult.apiChecksumMismatch
|
538
855
|
}
|
539
|
-
if (
|
856
|
+
if (uniffi_pubkycore_checksum_func_publish_https() != 5614) {
|
540
857
|
return InitializationResult.apiChecksumMismatch
|
541
858
|
}
|
542
|
-
if (
|
859
|
+
if (uniffi_pubkycore_checksum_func_put() != 48150) {
|
543
860
|
return InitializationResult.apiChecksumMismatch
|
544
861
|
}
|
545
|
-
if (
|
862
|
+
if (uniffi_pubkycore_checksum_func_remove_event_listener() != 23534) {
|
546
863
|
return InitializationResult.apiChecksumMismatch
|
547
864
|
}
|
548
|
-
if (
|
865
|
+
if (uniffi_pubkycore_checksum_func_resolve() != 34317) {
|
549
866
|
return InitializationResult.apiChecksumMismatch
|
550
867
|
}
|
551
|
-
if (
|
868
|
+
if (uniffi_pubkycore_checksum_func_resolve_https() != 17266) {
|
552
869
|
return InitializationResult.apiChecksumMismatch
|
553
870
|
}
|
554
|
-
if (
|
871
|
+
if (uniffi_pubkycore_checksum_func_session() != 59795) {
|
555
872
|
return InitializationResult.apiChecksumMismatch
|
556
873
|
}
|
557
|
-
if (
|
874
|
+
if (uniffi_pubkycore_checksum_func_set_event_listener() != 60071) {
|
558
875
|
return InitializationResult.apiChecksumMismatch
|
559
876
|
}
|
560
|
-
if (
|
877
|
+
if (uniffi_pubkycore_checksum_func_sign_in() != 21584) {
|
561
878
|
return InitializationResult.apiChecksumMismatch
|
562
879
|
}
|
563
|
-
if (
|
880
|
+
if (uniffi_pubkycore_checksum_func_sign_out() != 34903) {
|
564
881
|
return InitializationResult.apiChecksumMismatch
|
565
882
|
}
|
566
|
-
if (
|
883
|
+
if (uniffi_pubkycore_checksum_func_sign_up() != 37999) {
|
567
884
|
return InitializationResult.apiChecksumMismatch
|
568
885
|
}
|
569
|
-
if (
|
886
|
+
if (uniffi_pubkycore_checksum_func_switch_network() != 64215) {
|
570
887
|
return InitializationResult.apiChecksumMismatch
|
571
888
|
}
|
572
|
-
if (
|
889
|
+
if (uniffi_pubkycore_checksum_method_eventlistener_on_event_occurred() != 11531) {
|
573
890
|
return InitializationResult.apiChecksumMismatch
|
574
891
|
}
|
575
892
|
|