@synonymdev/react-native-pubky 0.7.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +75 -3
- package/android/src/main/java/com/pubky/PubkyModule.kt +369 -252
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +557 -127
- 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 +38 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libpubkymobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +38 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a +0 -0
- package/ios/Pubky-Bridging-Header.h +1 -0
- package/ios/Pubky.mm +26 -1
- package/ios/Pubky.swift +84 -1
- package/ios/pubkymobile.swift +310 -0
- package/lib/commonjs/index.js +69 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +64 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +10 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +10 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +84 -1
@@ -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;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EA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AAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAUtC;AAED,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUjE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUvE;AAED,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAUzE;AAED,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,UAAU,kBAAmB,SAAQ,cAAc;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAU7E;AAED,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAUjC;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAUzB;AAED,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAUzB"}
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { type Result } from '@synonymdev/result';
|
2
|
+
export declare function setEventListener(callback: (eventData: string) => void): Promise<Result<void>>;
|
3
|
+
export declare function removeEventListener(): Promise<Result<void>>;
|
2
4
|
export declare function auth(url: string, secretKey: string): Promise<Result<string[]>>;
|
3
5
|
type Capability = {
|
4
6
|
path: string;
|
@@ -52,6 +54,12 @@ interface IHttpsResolveResult {
|
|
52
54
|
}
|
53
55
|
export declare function resolveHttps(publicKey: string): Promise<Result<IHttpsResolveResult>>;
|
54
56
|
export declare function list(url: string): Promise<Result<string[]>>;
|
57
|
+
export declare function deleteFile(url: string): Promise<Result<string[]>>;
|
58
|
+
interface SessionInfo {
|
59
|
+
pubky: string;
|
60
|
+
capabilities: string[];
|
61
|
+
}
|
62
|
+
export declare function session(pubky: string): Promise<Result<SessionInfo>>;
|
55
63
|
interface IPublicKeyInfo {
|
56
64
|
public_key: string;
|
57
65
|
uri: string;
|
@@ -61,5 +69,7 @@ interface IGenerateSecretKey extends IPublicKeyInfo {
|
|
61
69
|
}
|
62
70
|
export declare function generateSecretKey(): Promise<Result<IGenerateSecretKey>>;
|
63
71
|
export declare function getPublicKeyFromSecretKey(secretKey: string): Promise<Result<IPublicKeyInfo>>;
|
72
|
+
export declare function createRecoveryFile(secretKey: string, passphrase: string): Promise<Result<string>>;
|
73
|
+
export declare function decryptRecoveryFile(recoveryFile: string, passphrase: string): Promise<Result<string>>;
|
64
74
|
export {};
|
65
75
|
//# 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;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAqB1D,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACpC,OAAO,CAAC,MAAM,CAAC,IAAI,CA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,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUjE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUvE;AAED,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAUzE;AAED,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,UAAU,kBAAmB,SAAQ,cAAc;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAU7E;AAED,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAUjC;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAUzB;AAED,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAUzB"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
1
|
+
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
2
2
|
import { ok, err, type Result } from '@synonymdev/result';
|
3
3
|
|
4
4
|
const LINKING_ERROR =
|
@@ -18,6 +18,30 @@ const Pubky = NativeModules.Pubky
|
|
18
18
|
}
|
19
19
|
);
|
20
20
|
|
21
|
+
const eventEmitter = new NativeEventEmitter(Pubky);
|
22
|
+
|
23
|
+
export async function setEventListener(
|
24
|
+
callback: (eventData: string) => void
|
25
|
+
): Promise<Result<void>> {
|
26
|
+
try {
|
27
|
+
await Pubky.setEventListener();
|
28
|
+
eventEmitter.addListener('PubkyEvent', callback);
|
29
|
+
return ok(undefined);
|
30
|
+
} catch (e) {
|
31
|
+
return err(JSON.stringify(e));
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
export async function removeEventListener(): Promise<Result<void>> {
|
36
|
+
try {
|
37
|
+
//await Pubky.removeEventListener();
|
38
|
+
eventEmitter.removeAllListeners('PubkyEvent');
|
39
|
+
return ok(undefined);
|
40
|
+
} catch (e) {
|
41
|
+
return err(JSON.stringify(e));
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
21
45
|
export async function auth(
|
22
46
|
url: string,
|
23
47
|
secretKey: string
|
@@ -225,6 +249,35 @@ export async function list(url: string): Promise<Result<string[]>> {
|
|
225
249
|
}
|
226
250
|
}
|
227
251
|
|
252
|
+
export async function deleteFile(url: string): Promise<Result<string[]>> {
|
253
|
+
try {
|
254
|
+
const res = await Pubky.deleteFile(url);
|
255
|
+
if (res[0] === 'error') {
|
256
|
+
return err(res[1]);
|
257
|
+
}
|
258
|
+
return ok(res[1]);
|
259
|
+
} catch (e) {
|
260
|
+
return err(JSON.stringify(e));
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
interface SessionInfo {
|
265
|
+
pubky: string;
|
266
|
+
capabilities: string[];
|
267
|
+
}
|
268
|
+
|
269
|
+
export async function session(pubky: string): Promise<Result<SessionInfo>> {
|
270
|
+
try {
|
271
|
+
const res = await Pubky.session(pubky);
|
272
|
+
if (res[0] === 'error') {
|
273
|
+
return err(res[1]);
|
274
|
+
}
|
275
|
+
return ok(JSON.parse(res[1]));
|
276
|
+
} catch (e) {
|
277
|
+
return err(JSON.stringify(e));
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
228
281
|
interface IPublicKeyInfo {
|
229
282
|
public_key: string;
|
230
283
|
uri: string;
|
@@ -257,3 +310,33 @@ export async function getPublicKeyFromSecretKey(
|
|
257
310
|
return err(JSON.stringify(e));
|
258
311
|
}
|
259
312
|
}
|
313
|
+
|
314
|
+
export async function createRecoveryFile(
|
315
|
+
secretKey: string,
|
316
|
+
passphrase: string
|
317
|
+
): Promise<Result<string>> {
|
318
|
+
try {
|
319
|
+
const res = await Pubky.createRecoveryFile(secretKey, passphrase);
|
320
|
+
if (res[0] === 'error') {
|
321
|
+
return err(res[1]);
|
322
|
+
}
|
323
|
+
return ok(res[1]);
|
324
|
+
} catch (e) {
|
325
|
+
return err(JSON.stringify(e));
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
export async function decryptRecoveryFile(
|
330
|
+
recoveryFile: string,
|
331
|
+
passphrase: string
|
332
|
+
): Promise<Result<string>> {
|
333
|
+
try {
|
334
|
+
const res = await Pubky.decryptRecoveryFile(recoveryFile, passphrase);
|
335
|
+
if (res[0] === 'error') {
|
336
|
+
return err(res[1]);
|
337
|
+
}
|
338
|
+
return ok(res[1]);
|
339
|
+
} catch (e) {
|
340
|
+
return err(JSON.stringify(e));
|
341
|
+
}
|
342
|
+
}
|