@synonymdev/react-native-pubky 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/ios/Pubky.swift CHANGED
@@ -13,6 +13,7 @@ class Pubky: NSObject {
13
13
  }
14
14
  }
15
15
  }
16
+
16
17
  @objc(parseAuthUrl:withResolver:withRejecter:)
17
18
  func parseAuthUrl(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
18
19
  Task {
@@ -24,4 +25,88 @@ class Pubky: NSObject {
24
25
  }
25
26
  }
26
27
  }
28
+
29
+ @objc(publish:recordContent:secretKey:withResolver:withRejecter:)
30
+ func publish(recordName: String, recordContent: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
31
+ Task {
32
+ do {
33
+ let result = react_native_pubky.publish(recordName: recordName, recordContent: recordContent, secretKey: secretKey)
34
+ resolve(result)
35
+ } catch {
36
+ reject("publish Error", "Failed to publish", error)
37
+ }
38
+ }
39
+ }
40
+
41
+ @objc(resolve:withResolver:withRejecter:)
42
+ func resolve(publicKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
43
+ Task {
44
+ do {
45
+ let result = react_native_pubky.resolve(publicKey: publicKey)
46
+ resolve(result)
47
+ } catch {
48
+ reject("resolve Error", "Failed to resolve", error)
49
+ }
50
+ }
51
+ }
52
+
53
+ @objc(signUp:homeserver:withResolver:withRejecter:)
54
+ func signUp(_ secretKey: String, homeserver: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
55
+ Task {
56
+ do {
57
+ let result = try await react_native_pubky.signUp(secretKey: secretKey, homeserver: homeserver)
58
+ resolve(result)
59
+ } catch {
60
+ reject("signUp Error", "Failed to sign up", error)
61
+ }
62
+ }
63
+ }
64
+
65
+ @objc(signIn:withResolver:withRejecter:)
66
+ func signIn(_ secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
67
+ Task {
68
+ do {
69
+ let result = try await react_native_pubky.signIn(secretKey: secretKey)
70
+ resolve(result)
71
+ } catch {
72
+ reject("signIn Error", "Failed to sign in", error)
73
+ }
74
+ }
75
+ }
76
+
77
+ @objc(signOut:withResolver:withRejecter:)
78
+ func signOut(_ secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
79
+ Task {
80
+ do {
81
+ let result = try await react_native_pubky.signOut(secretKey: secretKey)
82
+ resolve(result)
83
+ } catch {
84
+ reject("signOut Error", "Failed to sign out", error)
85
+ }
86
+ }
87
+ }
88
+
89
+ @objc(put:content:withResolver:withRejecter:)
90
+ func put(_ url: String, content: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
91
+ Task {
92
+ do {
93
+ let result = try await react_native_pubky.put(url: url, content: content)
94
+ resolve(result)
95
+ } catch {
96
+ reject("put Error", "Failed to put", error)
97
+ }
98
+ }
99
+ }
100
+
101
+ @objc(get:withResolver:withRejecter:)
102
+ func get(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
103
+ Task {
104
+ do {
105
+ let result = try await react_native_pubky.get(url: url)
106
+ resolve(result)
107
+ } catch {
108
+ reject("get Error", "Failed to get", error)
109
+ }
110
+ }
111
+ }
27
112
  }
@@ -356,6 +356,68 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
356
356
  return seq
357
357
  }
358
358
  }
359
+ private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
360
+ private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1
361
+
362
+ fileprivate func uniffiRustCallAsync<F, T>(
363
+ rustFutureFunc: () -> UnsafeMutableRawPointer,
364
+ pollFunc: (UnsafeMutableRawPointer, UnsafeMutableRawPointer) -> (),
365
+ completeFunc: (UnsafeMutableRawPointer, UnsafeMutablePointer<RustCallStatus>) -> F,
366
+ freeFunc: (UnsafeMutableRawPointer) -> (),
367
+ liftFunc: (F) throws -> T,
368
+ errorHandler: ((RustBuffer) throws -> Error)?
369
+ ) async throws -> T {
370
+ // Make sure to call uniffiEnsureInitialized() since future creation doesn't have a
371
+ // RustCallStatus param, so doesn't use makeRustCall()
372
+ uniffiEnsureInitialized()
373
+ let rustFuture = rustFutureFunc()
374
+ defer {
375
+ freeFunc(rustFuture)
376
+ }
377
+ var pollResult: Int8;
378
+ repeat {
379
+ pollResult = await withUnsafeContinuation {
380
+ pollFunc(rustFuture, ContinuationHolder($0).toOpaque())
381
+ }
382
+ } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY
383
+
384
+ return try liftFunc(makeRustCall(
385
+ { completeFunc(rustFuture, $0) },
386
+ errorHandler: errorHandler
387
+ ))
388
+ }
389
+
390
+ // Callback handlers for an async calls. These are invoked by Rust when the future is ready. They
391
+ // lift the return value or error and resume the suspended function.
392
+ fileprivate func uniffiFutureContinuationCallback(ptr: UnsafeMutableRawPointer, pollResult: Int8) {
393
+ ContinuationHolder.fromOpaque(ptr).resume(pollResult)
394
+ }
395
+
396
+ // Wraps UnsafeContinuation in a class so that we can use reference counting when passing it across
397
+ // the FFI
398
+ fileprivate class ContinuationHolder {
399
+ let continuation: UnsafeContinuation<Int8, Never>
400
+
401
+ init(_ continuation: UnsafeContinuation<Int8, Never>) {
402
+ self.continuation = continuation
403
+ }
404
+
405
+ func resume(_ pollResult: Int8) {
406
+ self.continuation.resume(returning: pollResult)
407
+ }
408
+
409
+ func toOpaque() -> UnsafeMutableRawPointer {
410
+ return Unmanaged<ContinuationHolder>.passRetained(self).toOpaque()
411
+ }
412
+
413
+ static func fromOpaque(_ ptr: UnsafeRawPointer) -> ContinuationHolder {
414
+ return Unmanaged<ContinuationHolder>.fromOpaque(ptr).takeRetainedValue()
415
+ }
416
+ }
417
+
418
+ fileprivate func uniffiInitContinuationCallback() {
419
+ ffi_pubkymobile_rust_future_continuation_callback_set(uniffiFutureContinuationCallback)
420
+ }
359
421
 
360
422
  public func auth(url: String, secretKey: String) -> [String] {
361
423
  return try! FfiConverterSequenceString.lift(
@@ -367,6 +429,24 @@ public func auth(url: String, secretKey: String) -> [String] {
367
429
  )
368
430
  }
369
431
 
432
+ public func get(url: String) async -> [String] {
433
+ return try! await uniffiRustCallAsync(
434
+ rustFutureFunc: {
435
+ uniffi_pubkymobile_fn_func_get(
436
+ FfiConverterString.lower(url)
437
+ )
438
+ },
439
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
440
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
441
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
442
+ liftFunc: FfiConverterSequenceString.lift,
443
+ errorHandler: nil
444
+
445
+ )
446
+ }
447
+
448
+
449
+
370
450
  public func parseAuthUrl(url: String) -> [String] {
371
451
  return try! FfiConverterSequenceString.lift(
372
452
  try! rustCall() {
@@ -376,6 +456,100 @@ public func parseAuthUrl(url: String) -> [String] {
376
456
  )
377
457
  }
378
458
 
459
+ public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
460
+ return try! FfiConverterSequenceString.lift(
461
+ try! rustCall() {
462
+ uniffi_pubkymobile_fn_func_publish(
463
+ FfiConverterString.lower(recordName),
464
+ FfiConverterString.lower(recordContent),
465
+ FfiConverterString.lower(secretKey),$0)
466
+ }
467
+ )
468
+ }
469
+
470
+ public func put(url: String, content: String) async -> [String] {
471
+ return try! await uniffiRustCallAsync(
472
+ rustFutureFunc: {
473
+ uniffi_pubkymobile_fn_func_put(
474
+ FfiConverterString.lower(url),
475
+ FfiConverterString.lower(content)
476
+ )
477
+ },
478
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
479
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
480
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
481
+ liftFunc: FfiConverterSequenceString.lift,
482
+ errorHandler: nil
483
+
484
+ )
485
+ }
486
+
487
+
488
+
489
+ public func resolve(publicKey: String) -> [String] {
490
+ return try! FfiConverterSequenceString.lift(
491
+ try! rustCall() {
492
+ uniffi_pubkymobile_fn_func_resolve(
493
+ FfiConverterString.lower(publicKey),$0)
494
+ }
495
+ )
496
+ }
497
+
498
+ public func signIn(secretKey: String) async -> [String] {
499
+ return try! await uniffiRustCallAsync(
500
+ rustFutureFunc: {
501
+ uniffi_pubkymobile_fn_func_sign_in(
502
+ FfiConverterString.lower(secretKey)
503
+ )
504
+ },
505
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
506
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
507
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
508
+ liftFunc: FfiConverterSequenceString.lift,
509
+ errorHandler: nil
510
+
511
+ )
512
+ }
513
+
514
+
515
+
516
+ public func signOut(secretKey: String) async -> [String] {
517
+ return try! await uniffiRustCallAsync(
518
+ rustFutureFunc: {
519
+ uniffi_pubkymobile_fn_func_sign_out(
520
+ FfiConverterString.lower(secretKey)
521
+ )
522
+ },
523
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
524
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
525
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
526
+ liftFunc: FfiConverterSequenceString.lift,
527
+ errorHandler: nil
528
+
529
+ )
530
+ }
531
+
532
+
533
+
534
+ public func signUp(secretKey: String, homeserver: String) async -> [String] {
535
+ return try! await uniffiRustCallAsync(
536
+ rustFutureFunc: {
537
+ uniffi_pubkymobile_fn_func_sign_up(
538
+ FfiConverterString.lower(secretKey),
539
+ FfiConverterString.lower(homeserver)
540
+ )
541
+ },
542
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
543
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
544
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
545
+ liftFunc: FfiConverterSequenceString.lift,
546
+ errorHandler: nil
547
+
548
+ )
549
+ }
550
+
551
+
552
+
379
553
  private enum InitializationResult {
380
554
  case ok
381
555
  case contractVersionMismatch
@@ -394,10 +568,32 @@ private var initializationResult: InitializationResult {
394
568
  if (uniffi_pubkymobile_checksum_func_auth() != 61378) {
395
569
  return InitializationResult.apiChecksumMismatch
396
570
  }
571
+ if (uniffi_pubkymobile_checksum_func_get() != 5395) {
572
+ return InitializationResult.apiChecksumMismatch
573
+ }
397
574
  if (uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088) {
398
575
  return InitializationResult.apiChecksumMismatch
399
576
  }
577
+ if (uniffi_pubkymobile_checksum_func_publish() != 20156) {
578
+ return InitializationResult.apiChecksumMismatch
579
+ }
580
+ if (uniffi_pubkymobile_checksum_func_put() != 47594) {
581
+ return InitializationResult.apiChecksumMismatch
582
+ }
583
+ if (uniffi_pubkymobile_checksum_func_resolve() != 18303) {
584
+ return InitializationResult.apiChecksumMismatch
585
+ }
586
+ if (uniffi_pubkymobile_checksum_func_sign_in() != 53969) {
587
+ return InitializationResult.apiChecksumMismatch
588
+ }
589
+ if (uniffi_pubkymobile_checksum_func_sign_out() != 32961) {
590
+ return InitializationResult.apiChecksumMismatch
591
+ }
592
+ if (uniffi_pubkymobile_checksum_func_sign_up() != 28083) {
593
+ return InitializationResult.apiChecksumMismatch
594
+ }
400
595
 
596
+ uniffiInitContinuationCallback()
401
597
  return InitializationResult.ok
402
598
  }
403
599
 
@@ -4,7 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.auth = auth;
7
+ exports.get = get;
7
8
  exports.parseAuthUrl = parseAuthUrl;
9
+ exports.publish = publish;
10
+ exports.put = put;
11
+ exports.resolve = resolve;
12
+ exports.signIn = signIn;
13
+ exports.signOut = signOut;
14
+ exports.signUp = signUp;
8
15
  var _reactNative = require("react-native");
9
16
  var _result = require("@synonymdev/result");
10
17
  const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
@@ -35,4 +42,81 @@ async function parseAuthUrl(url) {
35
42
  return (0, _result.err)(JSON.stringify(e));
36
43
  }
37
44
  }
45
+ async function publish(recordName, recordContent, secretKey) {
46
+ try {
47
+ const res = await Pubky.publish(recordName, recordContent, secretKey);
48
+ if (res[0] === 'error') {
49
+ return (0, _result.err)(res[1]);
50
+ }
51
+ return (0, _result.ok)(res[1]);
52
+ } catch (e) {
53
+ return (0, _result.err)(JSON.stringify(e));
54
+ }
55
+ }
56
+ async function resolve(publicKey) {
57
+ try {
58
+ const res = await Pubky.resolve(publicKey);
59
+ if (res[0] === 'error') {
60
+ return (0, _result.err)(res[1]);
61
+ }
62
+ return (0, _result.ok)(JSON.parse(res[1]));
63
+ } catch (e) {
64
+ return (0, _result.err)(JSON.stringify(e));
65
+ }
66
+ }
67
+ async function signUp(secretKey, homeserver) {
68
+ try {
69
+ const res = await Pubky.signUp(secretKey, homeserver);
70
+ if (res[0] === 'error') {
71
+ return (0, _result.err)(res[1]);
72
+ }
73
+ return (0, _result.ok)(res[1]);
74
+ } catch (e) {
75
+ return (0, _result.err)(JSON.stringify(e));
76
+ }
77
+ }
78
+ async function signIn(secretKey) {
79
+ try {
80
+ const res = await Pubky.signIn(secretKey);
81
+ if (res[0] === 'error') {
82
+ return (0, _result.err)(res[1]);
83
+ }
84
+ return (0, _result.ok)(res[1]);
85
+ } catch (e) {
86
+ return (0, _result.err)(JSON.stringify(e));
87
+ }
88
+ }
89
+ async function signOut(secretKey) {
90
+ try {
91
+ const res = await Pubky.signOut(secretKey);
92
+ if (res[0] === 'error') {
93
+ return (0, _result.err)(res[1]);
94
+ }
95
+ return (0, _result.ok)(res[1]);
96
+ } catch (e) {
97
+ return (0, _result.err)(JSON.stringify(e));
98
+ }
99
+ }
100
+ async function get(url) {
101
+ try {
102
+ const res = await Pubky.get(url);
103
+ if (res[0] === 'error') {
104
+ return (0, _result.err)(res[1]);
105
+ }
106
+ return (0, _result.ok)(JSON.parse(res[1]));
107
+ } catch (e) {
108
+ return (0, _result.err)(JSON.stringify(e));
109
+ }
110
+ }
111
+ async function put(url, content) {
112
+ try {
113
+ const res = await Pubky.put(url, JSON.stringify(content));
114
+ if (res[0] === 'error') {
115
+ return (0, _result.err)(res[1]);
116
+ }
117
+ return (0, _result.ok)(res[1]);
118
+ } catch (e) {
119
+ return (0, _result.err)(JSON.stringify(e));
120
+ }
121
+ }
38
122
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","auth","url","secretKey","res","err","ok","parseAuthUrl","parsed","JSON","parse","e","stringify"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GACjB,6EAA6E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGC,0BAAa,CAACD,KAAK,GAC7BC,0BAAa,CAACD,KAAK,GACnB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEE,eAAeU,IAAIA,CACxBC,GAAW,EACXC,SAAiB,EACU;EAC3B,MAAMC,GAAG,GAAG,MAAMR,KAAK,CAACK,IAAI,CAACC,GAAG,EAAEC,SAAS,CAAC;EAC5C,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;IACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;EACpB;EACA,OAAO,IAAAE,UAAE,EAACF,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB;AAaO,eAAeG,YAAYA,CAChCL,GAAW,EACwB;EACnC,IAAI;IACF,MAAME,GAAG,GAAG,MAAMR,KAAK,CAACW,YAAY,CAACL,GAAG,CAAC;IACzC,IAAIE,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,MAAMI,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,IAAAE,UAAE,EAACE,MAAM,CAAC;EACnB,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","auth","url","secretKey","res","err","ok","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GACjB,6EAA6E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGC,0BAAa,CAACD,KAAK,GAC7BC,0BAAa,CAACD,KAAK,GACnB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEE,eAAeU,IAAIA,CACxBC,GAAW,EACXC,SAAiB,EACU;EAC3B,MAAMC,GAAG,GAAG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AO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAO,IAAAE,UAAE,EAACF,GAAG,CAAC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOO,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
@@ -30,4 +30,81 @@ export async function parseAuthUrl(url) {
30
30
  return err(JSON.stringify(e));
31
31
  }
32
32
  }
33
+ export async function publish(recordName, recordContent, secretKey) {
34
+ try {
35
+ const res = await Pubky.publish(recordName, recordContent, secretKey);
36
+ if (res[0] === 'error') {
37
+ return err(res[1]);
38
+ }
39
+ return ok(res[1]);
40
+ } catch (e) {
41
+ return err(JSON.stringify(e));
42
+ }
43
+ }
44
+ export async function resolve(publicKey) {
45
+ try {
46
+ const res = await Pubky.resolve(publicKey);
47
+ if (res[0] === 'error') {
48
+ return err(res[1]);
49
+ }
50
+ return ok(JSON.parse(res[1]));
51
+ } catch (e) {
52
+ return err(JSON.stringify(e));
53
+ }
54
+ }
55
+ export async function signUp(secretKey, homeserver) {
56
+ try {
57
+ const res = await Pubky.signUp(secretKey, homeserver);
58
+ if (res[0] === 'error') {
59
+ return err(res[1]);
60
+ }
61
+ return ok(res[1]);
62
+ } catch (e) {
63
+ return err(JSON.stringify(e));
64
+ }
65
+ }
66
+ export async function signIn(secretKey) {
67
+ try {
68
+ const res = await Pubky.signIn(secretKey);
69
+ if (res[0] === 'error') {
70
+ return err(res[1]);
71
+ }
72
+ return ok(res[1]);
73
+ } catch (e) {
74
+ return err(JSON.stringify(e));
75
+ }
76
+ }
77
+ export async function signOut(secretKey) {
78
+ try {
79
+ const res = await Pubky.signOut(secretKey);
80
+ if (res[0] === 'error') {
81
+ return err(res[1]);
82
+ }
83
+ return ok(res[1]);
84
+ } catch (e) {
85
+ return err(JSON.stringify(e));
86
+ }
87
+ }
88
+ export async function get(url) {
89
+ try {
90
+ const res = await Pubky.get(url);
91
+ if (res[0] === 'error') {
92
+ return err(res[1]);
93
+ }
94
+ return ok(JSON.parse(res[1]));
95
+ } catch (e) {
96
+ return err(JSON.stringify(e));
97
+ }
98
+ }
99
+ export async function put(url, content) {
100
+ try {
101
+ const res = await Pubky.put(url, JSON.stringify(content));
102
+ if (res[0] === 'error') {
103
+ return err(res[1]);
104
+ }
105
+ return ok(res[1]);
106
+ } catch (e) {
107
+ return err(JSON.stringify(e));
108
+ }
109
+ }
33
110
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","ok","err","LINKING_ERROR","select","ios","default","Pubky","Proxy","get","Error","auth","url","secretKey","res","parseAuthUrl","parsed","JSON","parse","e","stringify"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,EAAE,EAAEC,GAAG,QAAqB,oBAAoB;AAEzD,MAAMC,aAAa,GACjB,6EAA6E,GAC7EH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGR,aAAa,CAACQ,KAAK,GAC7BR,aAAa,CAACQ,KAAK,GACnB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,eAAeQ,IAAIA,CACxBC,GAAW,EACXC,SAAiB,EACU;EAC3B,MAAMC,GAAG,GAAG,MAAMP,KAAK,CAACI,IAAI,CAACC,GAAG,EAAEC,SAAS,CAAC;EAC5C,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;IACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;EACpB;EACA,OAAOb,EAAE,CAACa,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB;AAaA,OAAO,eAAeC,YAAYA,CAChCH,GAAW,EACwB;EACnC,IAAI;IACF,MAAME,GAAG,GAAG,MAAMP,KAAK,CAACQ,YAAY,CAACH,GAAG,CAAC;IACzC,IAAIE,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,MAAME,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC,CAAC,CAAC,CAAC;IACjC,OAAOb,EAAE,CAACe,MAAM,CAAC;EACnB,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","ok","err","LINKING_ERROR","select","ios","default","Pubky","Proxy","get","Error","auth","url","secretKey","res","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,EAAE,EAAEC,GAAG,QAAqB,oBAAoB;AAEzD,MAAMC,aAAa,GACjB,6EAA6E,GAC7EH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGR,aAAa,CAACQ,KAAK,GAC7BR,aAAa,CAACQ,KAAK,GACnB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO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Z,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACa,GAAG,CAAC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
@@ -10,5 +10,29 @@ type PubkyAuthDetails = {
10
10
  secret: string;
11
11
  };
12
12
  export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
13
+ export declare function publish(recordName: string, recordContent: string, secretKey: string): Promise<Result<string[]>>;
14
+ interface ITxt {
15
+ cache_flush: boolean;
16
+ class: string;
17
+ name: string;
18
+ rdata: {
19
+ strings: string[];
20
+ type: string;
21
+ };
22
+ ttl: number;
23
+ }
24
+ interface IDNSPacket {
25
+ dns_packet: string;
26
+ public_key: string;
27
+ records: ITxt[];
28
+ signature: string;
29
+ timestamp: number;
30
+ }
31
+ export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
32
+ export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
33
+ export declare function signIn(secretKey: string): Promise<Result<string[]>>;
34
+ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
35
+ export declare function get(url: string): Promise<Result<string[]>>;
36
+ export declare function put(url: string, content: Object): Promise<Result<string[]>>;
13
37
  export {};
14
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,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AC;CACb;AACD,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,IAAI,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAU5E;AAED,wBAAsB,MAAM,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B;AAED,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUzE;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU1E;AAED,wBAAsB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUhE;AAED,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B"}
@@ -10,5 +10,29 @@ type PubkyAuthDetails = {
10
10
  secret: string;
11
11
  };
12
12
  export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
13
+ export declare function publish(recordName: string, recordContent: string, secretKey: string): Promise<Result<string[]>>;
14
+ interface ITxt {
15
+ cache_flush: boolean;
16
+ class: string;
17
+ name: string;
18
+ rdata: {
19
+ strings: string[];
20
+ type: string;
21
+ };
22
+ ttl: number;
23
+ }
24
+ interface IDNSPacket {
25
+ dns_packet: string;
26
+ public_key: string;
27
+ records: ITxt[];
28
+ signature: string;
29
+ timestamp: number;
30
+ }
31
+ export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
32
+ export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
33
+ export declare function signIn(secretKey: string): Promise<Result<string[]>>;
34
+ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
35
+ export declare function get(url: string): Promise<Result<string[]>>;
36
+ export declare function put(url: string, content: Object): Promise<Result<string[]>>;
13
37
  export {};
14
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAWnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;C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AAC,CAAC,CAU1E;AAED,wBAAsB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUhE;AAED,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synonymdev/react-native-pubky",
3
- "version": "0.2.3",
3
+ "version": "0.4.0",
4
4
  "description": "React Native Implementation of Pubky",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",