@synonymdev/react-native-pubky 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/ios/Pubky.mm CHANGED
@@ -21,6 +21,38 @@ RCT_EXTERN_METHOD(resolve:(NSString *)publicKey
21
21
  withResolver:(RCTPromiseResolveBlock)resolve
22
22
  withRejecter:(RCTPromiseRejectBlock)reject)
23
23
 
24
+ RCT_EXTERN_METHOD(signUp:(NSString *)secretKey
25
+ homeserver:(NSString *)homeserver
26
+ withResolver:(RCTPromiseResolveBlock)resolve
27
+ withRejecter:(RCTPromiseRejectBlock)reject)
28
+
29
+ RCT_EXTERN_METHOD(signIn:(NSString *)secretKey
30
+ withResolver:(RCTPromiseResolveBlock)resolve
31
+ withRejecter:(RCTPromiseRejectBlock)reject)
32
+
33
+ RCT_EXTERN_METHOD(signOut:(NSString *)secretKey
34
+ withResolver:(RCTPromiseResolveBlock)resolve
35
+ withRejecter:(RCTPromiseRejectBlock)reject)
36
+
37
+ RCT_EXTERN_METHOD(put:(NSString *)url
38
+ content:(NSString *)content
39
+ withResolver:(RCTPromiseResolveBlock)resolve
40
+ withRejecter:(RCTPromiseRejectBlock)reject)
41
+
42
+ RCT_EXTERN_METHOD(get:(NSString *)url
43
+ withResolver:(RCTPromiseResolveBlock)resolve
44
+ withRejecter:(RCTPromiseRejectBlock)reject)
45
+
46
+ RCT_EXTERN_METHOD(publishHttps:(NSString *)recordName
47
+ target:(NSString *)target
48
+ secretKey:(NSString *)secretKey
49
+ withResolver:(RCTPromiseResolveBlock)resolve
50
+ withRejecter:(RCTPromiseRejectBlock)reject)
51
+
52
+ RCT_EXTERN_METHOD(resolveHttps:(NSString *)publicKey
53
+ withResolver:(RCTPromiseResolveBlock)resolve
54
+ withRejecter:(RCTPromiseRejectBlock)reject)
55
+
24
56
  + (BOOL)requiresMainQueueSetup
25
57
  {
26
58
  return NO;
package/ios/Pubky.swift CHANGED
@@ -49,4 +49,88 @@ class Pubky: NSObject {
49
49
  }
50
50
  }
51
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
+ }
112
+
113
+ @objc(publishHttps:target:secretKey:withResolver:withRejecter:)
114
+ func publishHttps(_ recordName: String, target: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
115
+ Task {
116
+ do {
117
+ let result = try await react_native_pubky.publishHttps(recordName: recordName, target: target, secretKey: secretKey)
118
+ resolve(result)
119
+ } catch {
120
+ reject("publishHttps Error", "Failed to publish HTTPS record", error)
121
+ }
122
+ }
123
+ }
124
+
125
+ @objc(resolveHttps:withResolver:withRejecter:)
126
+ func resolveHttps(_ publicKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
127
+ Task {
128
+ do {
129
+ let result = try await react_native_pubky.resolveHttps(publicKey: publicKey)
130
+ resolve(result)
131
+ } catch {
132
+ reject("resolveHttps Error", "Failed to resolve HTTPS record", error)
133
+ }
134
+ }
135
+ }
52
136
  }
@@ -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() {
@@ -387,6 +467,36 @@ public func publish(recordName: String, recordContent: String, secretKey: String
387
467
  )
388
468
  }
389
469
 
470
+ public func publishHttps(recordName: String, target: String, secretKey: String) -> [String] {
471
+ return try! FfiConverterSequenceString.lift(
472
+ try! rustCall() {
473
+ uniffi_pubkymobile_fn_func_publish_https(
474
+ FfiConverterString.lower(recordName),
475
+ FfiConverterString.lower(target),
476
+ FfiConverterString.lower(secretKey),$0)
477
+ }
478
+ )
479
+ }
480
+
481
+ public func put(url: String, content: String) async -> [String] {
482
+ return try! await uniffiRustCallAsync(
483
+ rustFutureFunc: {
484
+ uniffi_pubkymobile_fn_func_put(
485
+ FfiConverterString.lower(url),
486
+ FfiConverterString.lower(content)
487
+ )
488
+ },
489
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
490
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
491
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
492
+ liftFunc: FfiConverterSequenceString.lift,
493
+ errorHandler: nil
494
+
495
+ )
496
+ }
497
+
498
+
499
+
390
500
  public func resolve(publicKey: String) -> [String] {
391
501
  return try! FfiConverterSequenceString.lift(
392
502
  try! rustCall() {
@@ -396,6 +506,70 @@ public func resolve(publicKey: String) -> [String] {
396
506
  )
397
507
  }
398
508
 
509
+ public func resolveHttps(publicKey: String) -> [String] {
510
+ return try! FfiConverterSequenceString.lift(
511
+ try! rustCall() {
512
+ uniffi_pubkymobile_fn_func_resolve_https(
513
+ FfiConverterString.lower(publicKey),$0)
514
+ }
515
+ )
516
+ }
517
+
518
+ public func signIn(secretKey: String) async -> [String] {
519
+ return try! await uniffiRustCallAsync(
520
+ rustFutureFunc: {
521
+ uniffi_pubkymobile_fn_func_sign_in(
522
+ FfiConverterString.lower(secretKey)
523
+ )
524
+ },
525
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
526
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
527
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
528
+ liftFunc: FfiConverterSequenceString.lift,
529
+ errorHandler: nil
530
+
531
+ )
532
+ }
533
+
534
+
535
+
536
+ public func signOut(secretKey: String) async -> [String] {
537
+ return try! await uniffiRustCallAsync(
538
+ rustFutureFunc: {
539
+ uniffi_pubkymobile_fn_func_sign_out(
540
+ FfiConverterString.lower(secretKey)
541
+ )
542
+ },
543
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
544
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
545
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
546
+ liftFunc: FfiConverterSequenceString.lift,
547
+ errorHandler: nil
548
+
549
+ )
550
+ }
551
+
552
+
553
+
554
+ public func signUp(secretKey: String, homeserver: String) async -> [String] {
555
+ return try! await uniffiRustCallAsync(
556
+ rustFutureFunc: {
557
+ uniffi_pubkymobile_fn_func_sign_up(
558
+ FfiConverterString.lower(secretKey),
559
+ FfiConverterString.lower(homeserver)
560
+ )
561
+ },
562
+ pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
563
+ completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
564
+ freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
565
+ liftFunc: FfiConverterSequenceString.lift,
566
+ errorHandler: nil
567
+
568
+ )
569
+ }
570
+
571
+
572
+
399
573
  private enum InitializationResult {
400
574
  case ok
401
575
  case contractVersionMismatch
@@ -414,16 +588,38 @@ private var initializationResult: InitializationResult {
414
588
  if (uniffi_pubkymobile_checksum_func_auth() != 61378) {
415
589
  return InitializationResult.apiChecksumMismatch
416
590
  }
591
+ if (uniffi_pubkymobile_checksum_func_get() != 5395) {
592
+ return InitializationResult.apiChecksumMismatch
593
+ }
417
594
  if (uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088) {
418
595
  return InitializationResult.apiChecksumMismatch
419
596
  }
420
597
  if (uniffi_pubkymobile_checksum_func_publish() != 20156) {
421
598
  return InitializationResult.apiChecksumMismatch
422
599
  }
600
+ if (uniffi_pubkymobile_checksum_func_publish_https() != 14705) {
601
+ return InitializationResult.apiChecksumMismatch
602
+ }
603
+ if (uniffi_pubkymobile_checksum_func_put() != 47594) {
604
+ return InitializationResult.apiChecksumMismatch
605
+ }
423
606
  if (uniffi_pubkymobile_checksum_func_resolve() != 18303) {
424
607
  return InitializationResult.apiChecksumMismatch
425
608
  }
609
+ if (uniffi_pubkymobile_checksum_func_resolve_https() != 34593) {
610
+ return InitializationResult.apiChecksumMismatch
611
+ }
612
+ if (uniffi_pubkymobile_checksum_func_sign_in() != 53969) {
613
+ return InitializationResult.apiChecksumMismatch
614
+ }
615
+ if (uniffi_pubkymobile_checksum_func_sign_out() != 32961) {
616
+ return InitializationResult.apiChecksumMismatch
617
+ }
618
+ if (uniffi_pubkymobile_checksum_func_sign_up() != 28083) {
619
+ return InitializationResult.apiChecksumMismatch
620
+ }
426
621
 
622
+ uniffiInitContinuationCallback()
427
623
  return InitializationResult.ok
428
624
  }
429
625
 
@@ -4,9 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.auth = auth;
7
+ exports.get = get;
7
8
  exports.parseAuthUrl = parseAuthUrl;
8
9
  exports.publish = publish;
10
+ exports.publishHttps = publishHttps;
11
+ exports.put = put;
9
12
  exports.resolve = resolve;
13
+ exports.resolveHttps = resolveHttps;
14
+ exports.signIn = signIn;
15
+ exports.signOut = signOut;
16
+ exports.signUp = signUp;
10
17
  var _reactNative = require("react-native");
11
18
  var _result = require("@synonymdev/result");
12
19
  const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
@@ -59,4 +66,81 @@ async function resolve(publicKey) {
59
66
  return (0, _result.err)(JSON.stringify(e));
60
67
  }
61
68
  }
69
+ async function signUp(secretKey, homeserver) {
70
+ try {
71
+ const res = await Pubky.signUp(secretKey, homeserver);
72
+ if (res[0] === 'error') {
73
+ return (0, _result.err)(res[1]);
74
+ }
75
+ return (0, _result.ok)(res[1]);
76
+ } catch (e) {
77
+ return (0, _result.err)(JSON.stringify(e));
78
+ }
79
+ }
80
+ async function signIn(secretKey) {
81
+ try {
82
+ const res = await Pubky.signIn(secretKey);
83
+ if (res[0] === 'error') {
84
+ return (0, _result.err)(res[1]);
85
+ }
86
+ return (0, _result.ok)(res[1]);
87
+ } catch (e) {
88
+ return (0, _result.err)(JSON.stringify(e));
89
+ }
90
+ }
91
+ async function signOut(secretKey) {
92
+ try {
93
+ const res = await Pubky.signOut(secretKey);
94
+ if (res[0] === 'error') {
95
+ return (0, _result.err)(res[1]);
96
+ }
97
+ return (0, _result.ok)(res[1]);
98
+ } catch (e) {
99
+ return (0, _result.err)(JSON.stringify(e));
100
+ }
101
+ }
102
+ async function get(url) {
103
+ try {
104
+ const res = await Pubky.get(url);
105
+ if (res[0] === 'error') {
106
+ return (0, _result.err)(res[1]);
107
+ }
108
+ return (0, _result.ok)(JSON.parse(res[1]));
109
+ } catch (e) {
110
+ return (0, _result.err)(JSON.stringify(e));
111
+ }
112
+ }
113
+ async function put(url, content) {
114
+ try {
115
+ const res = await Pubky.put(url, JSON.stringify(content));
116
+ if (res[0] === 'error') {
117
+ return (0, _result.err)(res[1]);
118
+ }
119
+ return (0, _result.ok)(res[1]);
120
+ } catch (e) {
121
+ return (0, _result.err)(JSON.stringify(e));
122
+ }
123
+ }
124
+ async function publishHttps(recordName, target, secretKey) {
125
+ try {
126
+ const res = await Pubky.publishHttps(recordName, target, secretKey);
127
+ if (res[0] === 'error') {
128
+ return (0, _result.err)(res[1]);
129
+ }
130
+ return (0, _result.ok)(res[1]);
131
+ } catch (e) {
132
+ return (0, _result.err)(JSON.stringify(e));
133
+ }
134
+ }
135
+ async function resolveHttps(publicKey) {
136
+ try {
137
+ const res = await Pubky.resolveHttps(publicKey);
138
+ if (res[0] === 'error') {
139
+ return (0, _result.err)(res[1]);
140
+ }
141
+ return (0, _result.ok)(JSON.parse(res[1]));
142
+ } catch (e) {
143
+ return (0, _result.err)(JSON.stringify(e));
144
+ }
145
+ }
62
146
  //# 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","publish","recordName","recordContent","resolve","publicKey"],"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,CA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EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAO,IAAAE,UAAE,EAACG,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOO,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","publishHttps","target","resolveHttps"],"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,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AAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF;AAEO,eAAea,YAAYA,CAChCV,UAAkB,EAClBW,MAAc,EACdtB,SAAiB,EACU;EAC3B,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMR,KAAK,CAAC4B,YAAY,CAACV,UAAU,EAAEW,MAAM,EAAEtB,SAAS,CAAC;IACnE,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,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;AAiBO,eAAee,YAAYA,CAChCT,SAAiB,EACqB;EACtC,IAAI;IACF,MAAMb,GAAG,GAAG,MAAMR,KAAK,CAAC8B,YAAY,CAACT,SAAS,CAAC;IAC/C,IAAIb,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAO,IAAAE,UAAE,EAACG,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOO,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
@@ -52,4 +52,81 @@ export async function resolve(publicKey) {
52
52
  return err(JSON.stringify(e));
53
53
  }
54
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
+ }
110
+ export async function publishHttps(recordName, target, secretKey) {
111
+ try {
112
+ const res = await Pubky.publishHttps(recordName, target, secretKey);
113
+ if (res[0] === 'error') {
114
+ return err(res[1]);
115
+ }
116
+ return ok(res[1]);
117
+ } catch (e) {
118
+ return err(JSON.stringify(e));
119
+ }
120
+ }
121
+ export async function resolveHttps(publicKey) {
122
+ try {
123
+ const res = await Pubky.resolveHttps(publicKey);
124
+ if (res[0] === 'error') {
125
+ return err(res[1]);
126
+ }
127
+ return ok(JSON.parse(res[1]));
128
+ } catch (e) {
129
+ return err(JSON.stringify(e));
130
+ }
131
+ }
55
132
  //# 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","publish","recordName","recordContent","resolve","publicKey"],"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;AAEA,OAAO,eAAeE,OAAOA,CAC3BC,UAAkB,EAClBC,aAAqB,EACrBV,SAAiB,EACU;EAC3B,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMP,KAAK,CAACc,OAAO,CAACC,UAAU,EAAEC,aAAa,EAAEV,SAAS,CAAC;IACrE,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,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;AAmBA,OAAO,eAAeK,OAAOA,CAACC,SAAiB,EAA+B;EAC5E,IAAI;IACF,MAAMX,GAAG,GAAG,MAAMP,KAAK,CAACiB,OAAO,CAACC,SAAS,CAAC;IAC1C,IAAIX,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACgB,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOK,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","publishHttps","target","resolveHtt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CAChCT,SAAiB,EACqB;EACtC,IAAI;IACF,MAAMX,GAAG,GAAG,MAAMP,KAAK,CAAC2B,YAAY,CAACT,SAAS,CAAC;IAC/C,IAAIX,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACgB,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
@@ -22,12 +22,34 @@ interface ITxt {
22
22
  ttl: number;
23
23
  }
24
24
  interface IDNSPacket {
25
- dns_packet: string;
25
+ signed_packet: string;
26
26
  public_key: string;
27
- records: ITxt[];
28
27
  signature: string;
29
28
  timestamp: number;
29
+ last_seen: number;
30
+ dns_packet: string;
31
+ records: ITxt[];
30
32
  }
31
33
  export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
34
+ export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
35
+ export declare function signIn(secretKey: string): Promise<Result<string[]>>;
36
+ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
37
+ export declare function get(url: string): Promise<Result<string[]>>;
38
+ export declare function put(url: string, content: Object): Promise<Result<string[]>>;
39
+ export declare function publishHttps(recordName: string, target: string, secretKey: string): Promise<Result<string[]>>;
40
+ interface IHttpsRecord {
41
+ name: string;
42
+ class: string;
43
+ ttl: number;
44
+ priority: number;
45
+ target: string;
46
+ port?: number;
47
+ alpn?: string[];
48
+ }
49
+ interface IHttpsResolveResult {
50
+ public_key: string;
51
+ https_records: IHttpsRecord[];
52
+ }
53
+ export declare function resolveHttps(publicKey: string): Promise<Result<IHttpsResolveResult>>;
32
54
  export {};
33
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 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CAAC,mBAAmB,CAAC,CAAC,CAUtC"}
@@ -22,12 +22,34 @@ interface ITxt {
22
22
  ttl: number;
23
23
  }
24
24
  interface IDNSPacket {
25
- dns_packet: string;
25
+ signed_packet: string;
26
26
  public_key: string;
27
- records: ITxt[];
28
27
  signature: string;
29
28
  timestamp: number;
29
+ last_seen: number;
30
+ dns_packet: string;
31
+ records: ITxt[];
30
32
  }
31
33
  export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
34
+ export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
35
+ export declare function signIn(secretKey: string): Promise<Result<string[]>>;
36
+ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
37
+ export declare function get(url: string): Promise<Result<string[]>>;
38
+ export declare function put(url: string, content: Object): Promise<Result<string[]>>;
39
+ export declare function publishHttps(recordName: string, target: string, secretKey: string): Promise<Result<string[]>>;
40
+ interface IHttpsRecord {
41
+ name: string;
42
+ class: string;
43
+ ttl: number;
44
+ priority: number;
45
+ target: string;
46
+ port?: number;
47
+ alpn?: string[];
48
+ }
49
+ interface IHttpsResolveResult {
50
+ public_key: string;
51
+ https_records: IHttpsRecord[];
52
+ }
53
+ export declare function resolveHttps(publicKey: string): Promise<Result<IHttpsResolveResult>>;
32
54
  export {};
33
55
  //# sourceMappingURL=index.d.ts.map