@synonymdev/react-native-pubky 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -11,8 +11,8 @@ npm install @synonymdev/react-native-pubky
11
11
  ## Implementation Status
12
12
  ### Implemented Methods
13
13
  - [x] [auth](#auth): Authentication functionality.
14
+ - [x] [parseAuthUrl](#parseAuthUrl): Method to decode an authUrl.
14
15
  ### Methods to be Implemented
15
- - [ ] parseAuthUrl: Method to decode an authUrl.
16
16
  - [ ] publish: Functionality to publish content.
17
17
  - [ ] resolve: Functionality to resolve content.
18
18
  - [ ] signIn: Functionality to sign in.
@@ -31,6 +31,18 @@ if (authRes.isErr()) {
31
31
  }
32
32
  console.log(authRes.value);
33
33
  ```
34
+ ### <a name="parseAuthUrl"></a>parseAuthUrl
35
+ ```js
36
+ import { parseAuthUrl } from '@synonymdev/react-native-pubky';
37
+
38
+ const pubkyAuthUrl = 'pubkyauth:///?relay=https://demo.httprelay.io/link&capabilities=/pub/pubky.app:rw,/pub/example.com/nested:rw&secret=FyzJ3gJ1W7boyFZC1Do9fYrRmDNgCLNRwEu_gaBgPUA';
39
+ const parseRes = await parseAuthUrl(pubkyAuthUrl);
40
+ if (parseRes.isErr()) {
41
+ console.log(parseRes.error.message);
42
+ return;
43
+ }
44
+ console.log(parseRes.value);
45
+ ```
34
46
 
35
47
  ## Local Installation
36
48
 
@@ -10,6 +10,7 @@ import kotlinx.coroutines.Dispatchers
10
10
  import kotlinx.coroutines.launch
11
11
  import kotlinx.coroutines.withContext
12
12
  import uniffi.pubkymobile.auth
13
+ import uniffi.pubkymobile.parseAuthUrl
13
14
 
14
15
  class PubkyModule(reactContext: ReactApplicationContext) :
15
16
  ReactContextBaseJavaModule(reactContext) {
@@ -37,6 +38,19 @@ class PubkyModule(reactContext: ReactApplicationContext) :
37
38
  }
38
39
  }
39
40
 
41
+ @ReactMethod
42
+ fun parseAuthUrl(url: String, promise: Promise) {
43
+ try {
44
+ val result = parseAuthUrl(url)
45
+ val array = Arguments.createArray().apply {
46
+ result.forEach { pushString(it) }
47
+ }
48
+ promise.resolve(array)
49
+ } catch (e: Exception) {
50
+ promise.reject("Error", e.message)
51
+ }
52
+ }
53
+
40
54
  companion object {
41
55
  const val NAME = "Pubky"
42
56
  }
@@ -387,6 +387,8 @@ internal interface _UniFFILib : Library {
387
387
 
388
388
  fun uniffi_pubkymobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,
389
389
  ): Pointer
390
+ fun uniffi_pubkymobile_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
391
+ ): RustBuffer.ByValue
390
392
  fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
391
393
  ): RustBuffer.ByValue
392
394
  fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
@@ -503,6 +505,8 @@ internal interface _UniFFILib : Library {
503
505
  ): Unit
504
506
  fun uniffi_pubkymobile_checksum_func_auth(
505
507
  ): Short
508
+ fun uniffi_pubkymobile_checksum_func_parse_auth_url(
509
+ ): Short
506
510
  fun ffi_pubkymobile_uniffi_contract_version(
507
511
  ): Int
508
512
 
@@ -523,6 +527,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
523
527
  if (lib.uniffi_pubkymobile_checksum_func_auth() != 46918.toShort()) {
524
528
  throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
525
529
  }
530
+ if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
531
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
532
+ }
526
533
  }
527
534
 
528
535
  // Async support
@@ -671,3 +678,11 @@ suspend fun `auth`(`url`: String, `secretKey`: String) : List<String> {
671
678
  )
672
679
  }
673
680
 
681
+ fun `parseAuthUrl`(`url`: String): List<String> {
682
+ return FfiConverterSequenceString.lift(
683
+ rustCall() { _status ->
684
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_parse_auth_url(FfiConverterString.lower(`url`),_status)
685
+ })
686
+ }
687
+
688
+
@@ -65,6 +65,8 @@ typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
65
65
  // Scaffolding functions
66
66
  void* _Nonnull uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
67
67
  );
68
+ RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
69
+ );
68
70
  RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
69
71
  );
70
72
  RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
@@ -181,6 +183,9 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
181
183
  );
182
184
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
183
185
 
186
+ );
187
+ uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
188
+
184
189
  );
185
190
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
186
191
 
@@ -65,6 +65,8 @@ typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
65
65
  // Scaffolding functions
66
66
  void* _Nonnull uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
67
67
  );
68
+ RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
69
+ );
68
70
  RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
69
71
  );
70
72
  RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
@@ -181,6 +183,9 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
181
183
  );
182
184
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
183
185
 
186
+ );
187
+ uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
188
+
184
189
  );
185
190
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
186
191
 
package/ios/Pubky.mm CHANGED
@@ -7,6 +7,10 @@ RCT_EXTERN_METHOD(auth:(NSString *)url
7
7
  withResolver:(RCTPromiseResolveBlock)resolve
8
8
  withRejecter:(RCTPromiseRejectBlock)reject)
9
9
 
10
+ RCT_EXTERN_METHOD(parseAuthUrl:(NSString *)url
11
+ withResolver:(RCTPromiseResolveBlock)resolve
12
+ withRejecter:(RCTPromiseRejectBlock)reject)
13
+
10
14
  + (BOOL)requiresMainQueueSetup
11
15
  {
12
16
  return NO;
package/ios/Pubky.swift CHANGED
@@ -2,15 +2,26 @@ import Foundation
2
2
 
3
3
  @objc(Pubky)
4
4
  class Pubky: NSObject {
5
- @objc(auth:secretKey:withResolver:withRejecter:)
6
- func auth(_ url: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
7
- Task {
8
- do {
9
- let result = try await react_native_pubky.auth(url: url, secretKey: secretKey)
10
- resolve(result)
11
- } catch {
12
- reject("auth Error", "Failed to auth", error)
13
- }
14
- }
15
- }
5
+ @objc(auth:secretKey:withResolver:withRejecter:)
6
+ func auth(_ url: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
7
+ Task {
8
+ do {
9
+ let result = try await react_native_pubky.auth(url: url, secretKey: secretKey)
10
+ resolve(result)
11
+ } catch {
12
+ reject("auth Error", "Failed to auth", error)
13
+ }
14
+ }
15
+ }
16
+ @objc(parseAuthUrl:withResolver:withRejecter:)
17
+ func parseAuthUrl(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
18
+ Task {
19
+ do {
20
+ let result = react_native_pubky.parseAuthUrl(url: url)
21
+ resolve(result)
22
+ } catch {
23
+ reject("parseAuthUrl Error", "Failed to parse auth url", error)
24
+ }
25
+ }
26
+ }
16
27
  }
@@ -438,6 +438,15 @@ public func auth(url: String, secretKey: String) async -> [String] {
438
438
 
439
439
 
440
440
 
441
+ public func parseAuthUrl(url: String) -> [String] {
442
+ return try! FfiConverterSequenceString.lift(
443
+ try! rustCall() {
444
+ uniffi_pubkymobile_fn_func_parse_auth_url(
445
+ FfiConverterString.lower(url),$0)
446
+ }
447
+ )
448
+ }
449
+
441
450
  private enum InitializationResult {
442
451
  case ok
443
452
  case contractVersionMismatch
@@ -456,6 +465,9 @@ private var initializationResult: InitializationResult {
456
465
  if (uniffi_pubkymobile_checksum_func_auth() != 46918) {
457
466
  return InitializationResult.apiChecksumMismatch
458
467
  }
468
+ if (uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088) {
469
+ return InitializationResult.apiChecksumMismatch
470
+ }
459
471
 
460
472
  uniffiInitContinuationCallback()
461
473
  return InitializationResult.ok
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.auth = auth;
7
+ exports.parseAuthUrl = parseAuthUrl;
7
8
  var _reactNative = require("react-native");
8
9
  var _result = require("@synonymdev/result");
9
10
  const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
@@ -22,4 +23,16 @@ async function auth(url, secretKey) {
22
23
  }
23
24
  return (0, _result.ok)(res[1]);
24
25
  }
26
+ async function parseAuthUrl(url) {
27
+ try {
28
+ const res = await Pubky.parseAuthUrl(url);
29
+ if (res[0] === 'error') {
30
+ return (0, _result.err)(res[1]);
31
+ }
32
+ const parsed = JSON.parse(res[1]);
33
+ return (0, _result.ok)(parsed);
34
+ } catch (e) {
35
+ return (0, _result.err)(JSON.stringify(e));
36
+ }
37
+ }
25
38
  //# 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"],"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","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"],"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":[]}
@@ -18,4 +18,16 @@ export async function auth(url, secretKey) {
18
18
  }
19
19
  return ok(res[1]);
20
20
  }
21
+ export async function parseAuthUrl(url) {
22
+ try {
23
+ const res = await Pubky.parseAuthUrl(url);
24
+ if (res[0] === 'error') {
25
+ return err(res[1]);
26
+ }
27
+ const parsed = JSON.parse(res[1]);
28
+ return ok(parsed);
29
+ } catch (e) {
30
+ return err(JSON.stringify(e));
31
+ }
32
+ }
21
33
  //# 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"],"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","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"],"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,3 +1,14 @@
1
1
  import { type Result } from '@synonymdev/result';
2
2
  export declare function auth(url: string, secretKey: string): Promise<Result<string[]>>;
3
+ type Capability = {
4
+ path: string;
5
+ permission: string;
6
+ };
7
+ type PubkyAuthDetails = {
8
+ relay: string;
9
+ capabilities: Capability[];
10
+ secret: string;
11
+ };
12
+ export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
13
+ export {};
3
14
  //# 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"}
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,3 +1,14 @@
1
1
  import { type Result } from '@synonymdev/result';
2
2
  export declare function auth(url: string, secretKey: string): Promise<Result<string[]>>;
3
+ type Capability = {
4
+ path: string;
5
+ permission: string;
6
+ };
7
+ type PubkyAuthDetails = {
8
+ relay: string;
9
+ capabilities: Capability[];
10
+ secret: string;
11
+ };
12
+ export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
13
+ export {};
3
14
  //# 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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synonymdev/react-native-pubky",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "React Native Implementation of Pubky",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -49,7 +49,8 @@
49
49
  "cargo-build": "cd rust && cargo build && cd pubky && cargo build && cd pubky && cargo build && cd ../ && cd pubky-common && cargo build && cd ../ && cd pubky-homeserver && cargo build && cd ../../../",
50
50
  "update-bindings:ios": "npm run cargo-build && node setup-ios-bindings.js && npm run reinstall",
51
51
  "update-bindings:android": "npm run cargo-build && node setup-android-bindings.js && npm run reinstall",
52
- "update-bindings": "npm run reinstall && npm run cargo-build && npm run update-bindings:ios && npm run update-bindings:android"
52
+ "update-bindings": "npm run reinstall && npm run cargo-build && npm run update-bindings:ios && npm run update-bindings:android",
53
+ "rebuild": "rm -rf node_modules && cd example && rm -rf node_modules && cd ios && rm -rf Pods Podfile.lock build && cd ../../ && npm run cargo-build && yarn install && npm run update-bindings && cd example && yarn install && bundle install && cd ios && pod install && cd ../ && yarn build:ios && yarn ios"
53
54
  },
54
55
  "keywords": [
55
56
  "pubky",
package/src/index.tsx CHANGED
@@ -28,3 +28,29 @@ export async function auth(
28
28
  }
29
29
  return ok(res[1]);
30
30
  }
31
+
32
+ type Capability = {
33
+ path: string;
34
+ permission: string;
35
+ };
36
+
37
+ type PubkyAuthDetails = {
38
+ relay: string;
39
+ capabilities: Capability[];
40
+ secret: string;
41
+ };
42
+
43
+ export async function parseAuthUrl(
44
+ url: string
45
+ ): Promise<Result<PubkyAuthDetails>> {
46
+ try {
47
+ const res = await Pubky.parseAuthUrl(url);
48
+ if (res[0] === 'error') {
49
+ return err(res[1]);
50
+ }
51
+ const parsed = JSON.parse(res[1]);
52
+ return ok(parsed);
53
+ } catch (e) {
54
+ return err(JSON.stringify(e));
55
+ }
56
+ }