@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/README.md +39 -5
- package/android/src/main/java/com/pubky/PubkyModule.kt +140 -0
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +187 -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/ios-arm64/Headers/pubkymobileFFI.h +35 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libpubkymobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +35 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a +0 -0
- package/ios/Pubky.mm +32 -0
- package/ios/Pubky.swift +85 -0
- package/ios/pubkymobile.swift +196 -0
- package/lib/commonjs/index.js +84 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +77 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +24 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +24 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +111 -0
package/src/index.tsx
CHANGED
@@ -54,3 +54,114 @@ 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
|
+
}
|
102
|
+
|
103
|
+
export async function signUp(
|
104
|
+
secretKey: string,
|
105
|
+
homeserver: string
|
106
|
+
): Promise<Result<string[]>> {
|
107
|
+
try {
|
108
|
+
const res = await Pubky.signUp(secretKey, homeserver);
|
109
|
+
if (res[0] === 'error') {
|
110
|
+
return err(res[1]);
|
111
|
+
}
|
112
|
+
return ok(res[1]);
|
113
|
+
} catch (e) {
|
114
|
+
return err(JSON.stringify(e));
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
export async function signIn(secretKey: string): Promise<Result<string[]>> {
|
119
|
+
try {
|
120
|
+
const res = await Pubky.signIn(secretKey);
|
121
|
+
if (res[0] === 'error') {
|
122
|
+
return err(res[1]);
|
123
|
+
}
|
124
|
+
return ok(res[1]);
|
125
|
+
} catch (e) {
|
126
|
+
return err(JSON.stringify(e));
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
export async function signOut(secretKey: string): Promise<Result<string[]>> {
|
131
|
+
try {
|
132
|
+
const res = await Pubky.signOut(secretKey);
|
133
|
+
if (res[0] === 'error') {
|
134
|
+
return err(res[1]);
|
135
|
+
}
|
136
|
+
return ok(res[1]);
|
137
|
+
} catch (e) {
|
138
|
+
return err(JSON.stringify(e));
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
export async function get(url: string): Promise<Result<string[]>> {
|
143
|
+
try {
|
144
|
+
const res = await Pubky.get(url);
|
145
|
+
if (res[0] === 'error') {
|
146
|
+
return err(res[1]);
|
147
|
+
}
|
148
|
+
return ok(JSON.parse(res[1]));
|
149
|
+
} catch (e) {
|
150
|
+
return err(JSON.stringify(e));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
export async function put(
|
155
|
+
url: string,
|
156
|
+
content: Object
|
157
|
+
): Promise<Result<string[]>> {
|
158
|
+
try {
|
159
|
+
const res = await Pubky.put(url, JSON.stringify(content));
|
160
|
+
if (res[0] === 'error') {
|
161
|
+
return err(res[1]);
|
162
|
+
}
|
163
|
+
return ok(res[1]);
|
164
|
+
} catch (e) {
|
165
|
+
return err(JSON.stringify(e));
|
166
|
+
}
|
167
|
+
}
|