@synonymdev/react-native-pubky 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/android/src/main/java/com/pubky/PubkyModule.kt +40 -0
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +30 -0
- 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/Info.plist +4 -4
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/pubkymobileFFI.h +10 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libpubkymobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +10 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a +0 -0
- package/ios/Pubky.mm +10 -0
- package/ios/Pubky.swift +25 -0
- package/ios/pubkymobile.swift +26 -0
- package/lib/commonjs/index.js +24 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +22 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +19 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +19 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +45 -0
@@ -11,6 +11,8 @@ import kotlinx.coroutines.launch
|
|
11
11
|
import kotlinx.coroutines.withContext
|
12
12
|
import uniffi.pubkymobile.auth
|
13
13
|
import uniffi.pubkymobile.parseAuthUrl
|
14
|
+
import uniffi.pubkymobile.publish
|
15
|
+
import uniffi.pubkymobile.resolve
|
14
16
|
|
15
17
|
class PubkyModule(reactContext: ReactApplicationContext) :
|
16
18
|
ReactContextBaseJavaModule(reactContext) {
|
@@ -51,6 +53,44 @@ class PubkyModule(reactContext: ReactApplicationContext) :
|
|
51
53
|
}
|
52
54
|
}
|
53
55
|
|
56
|
+
@ReactMethod
|
57
|
+
fun publish(recordName: String, recordContent: String, secretKey: String, promise: Promise) {
|
58
|
+
CoroutineScope(Dispatchers.IO).launch {
|
59
|
+
try {
|
60
|
+
val result = publish(recordName, recordContent, secretKey)
|
61
|
+
val array = Arguments.createArray().apply {
|
62
|
+
result.forEach { pushString(it) }
|
63
|
+
}
|
64
|
+
withContext(Dispatchers.Main) {
|
65
|
+
promise.resolve(array)
|
66
|
+
}
|
67
|
+
} catch (e: Exception) {
|
68
|
+
withContext(Dispatchers.Main) {
|
69
|
+
promise.reject("Error", e.message)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
@ReactMethod
|
76
|
+
fun resolve(publicKey: String, promise: Promise) {
|
77
|
+
CoroutineScope(Dispatchers.IO).launch {
|
78
|
+
try {
|
79
|
+
val result = resolve(publicKey)
|
80
|
+
val array = Arguments.createArray().apply {
|
81
|
+
result.forEach { pushString(it) }
|
82
|
+
}
|
83
|
+
withContext(Dispatchers.Main) {
|
84
|
+
promise.resolve(array)
|
85
|
+
}
|
86
|
+
} catch (e: Exception) {
|
87
|
+
withContext(Dispatchers.Main) {
|
88
|
+
promise.reject("Error", e.message)
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
54
94
|
companion object {
|
55
95
|
const val NAME = "Pubky"
|
56
96
|
}
|
@@ -385,6 +385,10 @@ internal interface _UniFFILib : Library {
|
|
385
385
|
): RustBuffer.ByValue
|
386
386
|
fun uniffi_pubkymobile_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
387
387
|
): RustBuffer.ByValue
|
388
|
+
fun uniffi_pubkymobile_fn_func_publish(`recordName`: RustBuffer.ByValue,`recordContent`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
389
|
+
): RustBuffer.ByValue
|
390
|
+
fun uniffi_pubkymobile_fn_func_resolve(`publicKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
391
|
+
): RustBuffer.ByValue
|
388
392
|
fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
|
389
393
|
): RustBuffer.ByValue
|
390
394
|
fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
|
@@ -503,6 +507,10 @@ internal interface _UniFFILib : Library {
|
|
503
507
|
): Short
|
504
508
|
fun uniffi_pubkymobile_checksum_func_parse_auth_url(
|
505
509
|
): Short
|
510
|
+
fun uniffi_pubkymobile_checksum_func_publish(
|
511
|
+
): Short
|
512
|
+
fun uniffi_pubkymobile_checksum_func_resolve(
|
513
|
+
): Short
|
506
514
|
fun ffi_pubkymobile_uniffi_contract_version(
|
507
515
|
): Int
|
508
516
|
|
@@ -526,6 +534,12 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
|
|
526
534
|
if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
|
527
535
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
528
536
|
}
|
537
|
+
if (lib.uniffi_pubkymobile_checksum_func_publish() != 20156.toShort()) {
|
538
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
539
|
+
}
|
540
|
+
if (lib.uniffi_pubkymobile_checksum_func_resolve() != 18303.toShort()) {
|
541
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
542
|
+
}
|
529
543
|
}
|
530
544
|
|
531
545
|
// Async support
|
@@ -628,3 +642,19 @@ fun `parseAuthUrl`(`url`: String): List<String> {
|
|
628
642
|
}
|
629
643
|
|
630
644
|
|
645
|
+
fun `publish`(`recordName`: String, `recordContent`: String, `secretKey`: String): List<String> {
|
646
|
+
return FfiConverterSequenceString.lift(
|
647
|
+
rustCall() { _status ->
|
648
|
+
_UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_publish(FfiConverterString.lower(`recordName`),FfiConverterString.lower(`recordContent`),FfiConverterString.lower(`secretKey`),_status)
|
649
|
+
})
|
650
|
+
}
|
651
|
+
|
652
|
+
|
653
|
+
fun `resolve`(`publicKey`: String): List<String> {
|
654
|
+
return FfiConverterSequenceString.lift(
|
655
|
+
rustCall() { _status ->
|
656
|
+
_UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_resolve(FfiConverterString.lower(`publicKey`),_status)
|
657
|
+
})
|
658
|
+
}
|
659
|
+
|
660
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<key>HeadersPath</key>
|
11
11
|
<string>Headers</string>
|
12
12
|
<key>LibraryIdentifier</key>
|
13
|
-
<string>ios-arm64</string>
|
13
|
+
<string>ios-arm64-simulator</string>
|
14
14
|
<key>LibraryPath</key>
|
15
15
|
<string>libpubkymobile.a</string>
|
16
16
|
<key>SupportedArchitectures</key>
|
@@ -19,6 +19,8 @@
|
|
19
19
|
</array>
|
20
20
|
<key>SupportedPlatform</key>
|
21
21
|
<string>ios</string>
|
22
|
+
<key>SupportedPlatformVariant</key>
|
23
|
+
<string>simulator</string>
|
22
24
|
</dict>
|
23
25
|
<dict>
|
24
26
|
<key>BinaryPath</key>
|
@@ -26,7 +28,7 @@
|
|
26
28
|
<key>HeadersPath</key>
|
27
29
|
<string>Headers</string>
|
28
30
|
<key>LibraryIdentifier</key>
|
29
|
-
<string>ios-arm64
|
31
|
+
<string>ios-arm64</string>
|
30
32
|
<key>LibraryPath</key>
|
31
33
|
<string>libpubkymobile.a</string>
|
32
34
|
<key>SupportedArchitectures</key>
|
@@ -35,8 +37,6 @@
|
|
35
37
|
</array>
|
36
38
|
<key>SupportedPlatform</key>
|
37
39
|
<string>ios</string>
|
38
|
-
<key>SupportedPlatformVariant</key>
|
39
|
-
<string>simulator</string>
|
40
40
|
</dict>
|
41
41
|
</array>
|
42
42
|
<key>CFBundlePackageType</key>
|
@@ -67,6 +67,10 @@ RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
|
|
67
67
|
);
|
68
68
|
RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
|
69
69
|
);
|
70
|
+
RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
|
71
|
+
);
|
72
|
+
RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
|
73
|
+
);
|
70
74
|
RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
71
75
|
);
|
72
76
|
RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
@@ -186,6 +190,12 @@ uint16_t uniffi_pubkymobile_checksum_func_auth(void
|
|
186
190
|
);
|
187
191
|
uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
|
188
192
|
|
193
|
+
);
|
194
|
+
uint16_t uniffi_pubkymobile_checksum_func_publish(void
|
195
|
+
|
196
|
+
);
|
197
|
+
uint16_t uniffi_pubkymobile_checksum_func_resolve(void
|
198
|
+
|
189
199
|
);
|
190
200
|
uint32_t ffi_pubkymobile_uniffi_contract_version(void
|
191
201
|
|
Binary file
|
@@ -67,6 +67,10 @@ RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
|
|
67
67
|
);
|
68
68
|
RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
|
69
69
|
);
|
70
|
+
RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
|
71
|
+
);
|
72
|
+
RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
|
73
|
+
);
|
70
74
|
RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
71
75
|
);
|
72
76
|
RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
@@ -186,6 +190,12 @@ uint16_t uniffi_pubkymobile_checksum_func_auth(void
|
|
186
190
|
);
|
187
191
|
uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
|
188
192
|
|
193
|
+
);
|
194
|
+
uint16_t uniffi_pubkymobile_checksum_func_publish(void
|
195
|
+
|
196
|
+
);
|
197
|
+
uint16_t uniffi_pubkymobile_checksum_func_resolve(void
|
198
|
+
|
189
199
|
);
|
190
200
|
uint32_t ffi_pubkymobile_uniffi_contract_version(void
|
191
201
|
|
Binary file
|
package/ios/Pubky.mm
CHANGED
@@ -11,6 +11,16 @@ RCT_EXTERN_METHOD(parseAuthUrl:(NSString *)url
|
|
11
11
|
withResolver:(RCTPromiseResolveBlock)resolve
|
12
12
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
13
13
|
|
14
|
+
RCT_EXTERN_METHOD(publish:(NSString *)recordName
|
15
|
+
recordContent:(NSString *)recordContent
|
16
|
+
secretKey:(NSString *)secretKey
|
17
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
18
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
19
|
+
|
20
|
+
RCT_EXTERN_METHOD(resolve:(NSString *)publicKey
|
21
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
22
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
23
|
+
|
14
24
|
+ (BOOL)requiresMainQueueSetup
|
15
25
|
{
|
16
26
|
return NO;
|
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,28 @@ 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
|
+
}
|
27
52
|
}
|
package/ios/pubkymobile.swift
CHANGED
@@ -376,6 +376,26 @@ public func parseAuthUrl(url: String) -> [String] {
|
|
376
376
|
)
|
377
377
|
}
|
378
378
|
|
379
|
+
public func publish(recordName: String, recordContent: String, secretKey: String) -> [String] {
|
380
|
+
return try! FfiConverterSequenceString.lift(
|
381
|
+
try! rustCall() {
|
382
|
+
uniffi_pubkymobile_fn_func_publish(
|
383
|
+
FfiConverterString.lower(recordName),
|
384
|
+
FfiConverterString.lower(recordContent),
|
385
|
+
FfiConverterString.lower(secretKey),$0)
|
386
|
+
}
|
387
|
+
)
|
388
|
+
}
|
389
|
+
|
390
|
+
public func resolve(publicKey: String) -> [String] {
|
391
|
+
return try! FfiConverterSequenceString.lift(
|
392
|
+
try! rustCall() {
|
393
|
+
uniffi_pubkymobile_fn_func_resolve(
|
394
|
+
FfiConverterString.lower(publicKey),$0)
|
395
|
+
}
|
396
|
+
)
|
397
|
+
}
|
398
|
+
|
379
399
|
private enum InitializationResult {
|
380
400
|
case ok
|
381
401
|
case contractVersionMismatch
|
@@ -397,6 +417,12 @@ private var initializationResult: InitializationResult {
|
|
397
417
|
if (uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088) {
|
398
418
|
return InitializationResult.apiChecksumMismatch
|
399
419
|
}
|
420
|
+
if (uniffi_pubkymobile_checksum_func_publish() != 20156) {
|
421
|
+
return InitializationResult.apiChecksumMismatch
|
422
|
+
}
|
423
|
+
if (uniffi_pubkymobile_checksum_func_resolve() != 18303) {
|
424
|
+
return InitializationResult.apiChecksumMismatch
|
425
|
+
}
|
400
426
|
|
401
427
|
return InitializationResult.ok
|
402
428
|
}
|
package/lib/commonjs/index.js
CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.auth = auth;
|
7
7
|
exports.parseAuthUrl = parseAuthUrl;
|
8
|
+
exports.publish = publish;
|
9
|
+
exports.resolve = resolve;
|
8
10
|
var _reactNative = require("react-native");
|
9
11
|
var _result = require("@synonymdev/result");
|
10
12
|
const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
@@ -35,4 +37,26 @@ async function parseAuthUrl(url) {
|
|
35
37
|
return (0, _result.err)(JSON.stringify(e));
|
36
38
|
}
|
37
39
|
}
|
40
|
+
async function publish(recordName, recordContent, secretKey) {
|
41
|
+
try {
|
42
|
+
const res = await Pubky.publish(recordName, recordContent, secretKey);
|
43
|
+
if (res[0] === 'error') {
|
44
|
+
return (0, _result.err)(res[1]);
|
45
|
+
}
|
46
|
+
return (0, _result.ok)(res[1]);
|
47
|
+
} catch (e) {
|
48
|
+
return (0, _result.err)(JSON.stringify(e));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
async function resolve(publicKey) {
|
52
|
+
try {
|
53
|
+
const res = await Pubky.resolve(publicKey);
|
54
|
+
if (res[0] === 'error') {
|
55
|
+
return (0, _result.err)(res[1]);
|
56
|
+
}
|
57
|
+
return (0, _result.ok)(JSON.parse(res[1]));
|
58
|
+
} catch (e) {
|
59
|
+
return (0, _result.err)(JSON.stringify(e));
|
60
|
+
}
|
61
|
+
}
|
38
62
|
//# 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":"
|
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,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AAC,OAAOO,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF;AAmBO,eAAeK,OAAOA,CAACC,SAAiB,EAA+B;EAC5E,IAAI;IACF,MAAMb,GAAG,GAAG,MAAMR,KAAK,CAACoB,OAAO,CAACC,SAAS,CAAC;IAC1C,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":[]}
|
package/lib/module/index.js
CHANGED
@@ -30,4 +30,26 @@ 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
|
+
}
|
33
55
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -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"],"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,IAA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/B,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
@@ -10,5 +10,24 @@ 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>>;
|
13
32
|
export {};
|
14
33
|
//# 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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C;CACnB;AACD,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAU5E"}
|
@@ -10,5 +10,24 @@ 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>>;
|
13
32
|
export {};
|
14
33
|
//# 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,EAA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AsB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAU5E"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@synonymdev/react-native-pubky",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"description": "React Native Implementation of Pubky",
|
5
5
|
"source": "./src/index.tsx",
|
6
6
|
"main": "./lib/commonjs/index.js",
|
@@ -40,8 +40,8 @@
|
|
40
40
|
"test": "jest",
|
41
41
|
"typecheck": "tsc",
|
42
42
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
43
|
-
"clean": "
|
44
|
-
"prepare": "bob build",
|
43
|
+
"clean": "rm -rf android/build example/android/build example/android/app/build example/ios/build lib",
|
44
|
+
"prepare": "corepack enable && npm install -g react-native-builder-bob && bob build",
|
45
45
|
"release": "release-it",
|
46
46
|
"example:ios": "cd example && cd ios && rm -rf Pods && cd ../ && npm i && bundle install && npm run build:ios && npm run ios",
|
47
47
|
"example:android": "cd example && npm i && npm run build:android && npm run android",
|
package/src/index.tsx
CHANGED
@@ -54,3 +54,48 @@ export async function parseAuthUrl(
|
|
54
54
|
return err(JSON.stringify(e));
|
55
55
|
}
|
56
56
|
}
|
57
|
+
|
58
|
+
export async function publish(
|
59
|
+
recordName: string,
|
60
|
+
recordContent: string,
|
61
|
+
secretKey: string
|
62
|
+
): Promise<Result<string[]>> {
|
63
|
+
try {
|
64
|
+
const res = await Pubky.publish(recordName, recordContent, secretKey);
|
65
|
+
if (res[0] === 'error') {
|
66
|
+
return err(res[1]);
|
67
|
+
}
|
68
|
+
return ok(res[1]);
|
69
|
+
} catch (e) {
|
70
|
+
return err(JSON.stringify(e));
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
interface ITxt {
|
75
|
+
cache_flush: boolean;
|
76
|
+
class: string;
|
77
|
+
name: string;
|
78
|
+
rdata: {
|
79
|
+
strings: string[];
|
80
|
+
type: string;
|
81
|
+
};
|
82
|
+
ttl: number;
|
83
|
+
}
|
84
|
+
interface IDNSPacket {
|
85
|
+
dns_packet: string;
|
86
|
+
public_key: string;
|
87
|
+
records: ITxt[];
|
88
|
+
signature: string;
|
89
|
+
timestamp: number;
|
90
|
+
}
|
91
|
+
export async function resolve(publicKey: string): Promise<Result<IDNSPacket>> {
|
92
|
+
try {
|
93
|
+
const res = await Pubky.resolve(publicKey);
|
94
|
+
if (res[0] === 'error') {
|
95
|
+
return err(res[1]);
|
96
|
+
}
|
97
|
+
return ok(JSON.parse(res[1]));
|
98
|
+
} catch (e) {
|
99
|
+
return err(JSON.stringify(e));
|
100
|
+
}
|
101
|
+
}
|