@synonymdev/react-native-pubky 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -9
- package/android/src/main/java/com/pubky/PubkyModule.kt +364 -273
- package/android/src/main/java/uniffi/pubkycore/pubkycore.kt +1327 -0
- package/android/src/main/jniLibs/arm64-v8a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkycore.so +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/Info.plist +8 -8
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64/libpubkymobile.a → PubkyCore.xcframework/ios-arm64/libpubkycore.a} +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64-simulator/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a → PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a} +0 -0
- package/ios/Pubky-Bridging-Header.h +1 -0
- package/ios/Pubky.mm +16 -1
- package/ios/Pubky.swift +64 -1
- package/ios/{pubkymobile.swift → pubkycore.swift} +354 -37
- package/lib/commonjs/index.js +45 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +42 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +16 -9
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +16 -9
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +12 -7
- package/react-native-pubky.podspec +1 -1
- package/src/index.tsx +62 -9
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +0 -862
- 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/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libmobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libmobile.a +0 -0
package/lib/commonjs/index.js
CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.auth = auth;
|
7
7
|
exports.createRecoveryFile = createRecoveryFile;
|
8
8
|
exports.decryptRecoveryFile = decryptRecoveryFile;
|
9
|
+
exports.deleteFile = deleteFile;
|
9
10
|
exports.generateSecretKey = generateSecretKey;
|
10
11
|
exports.get = get;
|
11
12
|
exports.getPublicKeyFromSecretKey = getPublicKeyFromSecretKey;
|
@@ -14,8 +15,11 @@ exports.parseAuthUrl = parseAuthUrl;
|
|
14
15
|
exports.publish = publish;
|
15
16
|
exports.publishHttps = publishHttps;
|
16
17
|
exports.put = put;
|
18
|
+
exports.removeEventListener = removeEventListener;
|
17
19
|
exports.resolve = resolve;
|
18
20
|
exports.resolveHttps = resolveHttps;
|
21
|
+
exports.session = session;
|
22
|
+
exports.setEventListener = setEventListener;
|
19
23
|
exports.signIn = signIn;
|
20
24
|
exports.signOut = signOut;
|
21
25
|
exports.signUp = signUp;
|
@@ -30,6 +34,25 @@ const Pubky = _reactNative.NativeModules.Pubky ? _reactNative.NativeModules.Pubk
|
|
30
34
|
throw new Error(LINKING_ERROR);
|
31
35
|
}
|
32
36
|
});
|
37
|
+
const eventEmitter = new _reactNative.NativeEventEmitter(Pubky);
|
38
|
+
async function setEventListener(callback) {
|
39
|
+
try {
|
40
|
+
await Pubky.setEventListener();
|
41
|
+
eventEmitter.addListener('PubkyEvent', callback);
|
42
|
+
return (0, _result.ok)(undefined);
|
43
|
+
} catch (e) {
|
44
|
+
return (0, _result.err)(JSON.stringify(e));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
async function removeEventListener() {
|
48
|
+
try {
|
49
|
+
//await Pubky.removeEventListener();
|
50
|
+
eventEmitter.removeAllListeners('PubkyEvent');
|
51
|
+
return (0, _result.ok)(undefined);
|
52
|
+
} catch (e) {
|
53
|
+
return (0, _result.err)(JSON.stringify(e));
|
54
|
+
}
|
55
|
+
}
|
33
56
|
async function auth(url, secretKey) {
|
34
57
|
const res = await Pubky.auth(url, secretKey);
|
35
58
|
if (res[0] === 'error') {
|
@@ -159,6 +182,28 @@ async function list(url) {
|
|
159
182
|
return (0, _result.err)(JSON.stringify(e));
|
160
183
|
}
|
161
184
|
}
|
185
|
+
async function deleteFile(url) {
|
186
|
+
try {
|
187
|
+
const res = await Pubky.deleteFile(url);
|
188
|
+
if (res[0] === 'error') {
|
189
|
+
return (0, _result.err)(res[1]);
|
190
|
+
}
|
191
|
+
return (0, _result.ok)(res[1]);
|
192
|
+
} catch (e) {
|
193
|
+
return (0, _result.err)(JSON.stringify(e));
|
194
|
+
}
|
195
|
+
}
|
196
|
+
async function session(pubky) {
|
197
|
+
try {
|
198
|
+
const res = await Pubky.session(pubky);
|
199
|
+
if (res[0] === 'error') {
|
200
|
+
return (0, _result.err)(res[1]);
|
201
|
+
}
|
202
|
+
return (0, _result.ok)(JSON.parse(res[1]));
|
203
|
+
} catch (e) {
|
204
|
+
return (0, _result.err)(JSON.stringify(e));
|
205
|
+
}
|
206
|
+
}
|
162
207
|
async function generateSecretKey() {
|
163
208
|
try {
|
164
209
|
const res = await Pubky.generateSecretKey();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","
|
1
|
+
{"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","eventEmitter","NativeEventEmitter","setEventListener","callback","addListener","ok","undefined","e","err","JSON","stringify","removeEventListener","removeAllListeners","auth","url","secretKey","res","parseAuthUrl","parsed","parse","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content","publishHttps","target","resolveHttps","list","deleteFile","session","pubky","generateSecretKey","getPublicKeyFromSecretKey","createRecoveryFile","passphrase","decryptRecoveryFile","recoveryFile"],"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;AAEL,MAAMU,YAAY,GAAG,IAAIC,+BAAkB,CAACN,KAAK,CAAC;AAE3C,eAAeO,gBAAgBA,CACpCC,QAAqC,EACd;EACvB,IAAI;IACF,MAAMR,KAAK,CAACO,gBAAgB,CAAC,CAAC;I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AACC,SAAS,CAACH,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import { NativeModules, Platform } from 'react-native';
|
3
|
+
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
4
4
|
import { ok, err } from '@synonymdev/result';
|
5
5
|
const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
6
6
|
ios: "- You have run 'pod install'\n",
|
@@ -11,6 +11,25 @@ const Pubky = NativeModules.Pubky ? NativeModules.Pubky : new Proxy({}, {
|
|
11
11
|
throw new Error(LINKING_ERROR);
|
12
12
|
}
|
13
13
|
});
|
14
|
+
const eventEmitter = new NativeEventEmitter(Pubky);
|
15
|
+
export async function setEventListener(callback) {
|
16
|
+
try {
|
17
|
+
await Pubky.setEventListener();
|
18
|
+
eventEmitter.addListener('PubkyEvent', callback);
|
19
|
+
return ok(undefined);
|
20
|
+
} catch (e) {
|
21
|
+
return err(JSON.stringify(e));
|
22
|
+
}
|
23
|
+
}
|
24
|
+
export async function removeEventListener() {
|
25
|
+
try {
|
26
|
+
//await Pubky.removeEventListener();
|
27
|
+
eventEmitter.removeAllListeners('PubkyEvent');
|
28
|
+
return ok(undefined);
|
29
|
+
} catch (e) {
|
30
|
+
return err(JSON.stringify(e));
|
31
|
+
}
|
32
|
+
}
|
14
33
|
export async function auth(url, secretKey) {
|
15
34
|
const res = await Pubky.auth(url, secretKey);
|
16
35
|
if (res[0] === 'error') {
|
@@ -140,6 +159,28 @@ export async function list(url) {
|
|
140
159
|
return err(JSON.stringify(e));
|
141
160
|
}
|
142
161
|
}
|
162
|
+
export async function deleteFile(url) {
|
163
|
+
try {
|
164
|
+
const res = await Pubky.deleteFile(url);
|
165
|
+
if (res[0] === 'error') {
|
166
|
+
return err(res[1]);
|
167
|
+
}
|
168
|
+
return ok(res[1]);
|
169
|
+
} catch (e) {
|
170
|
+
return err(JSON.stringify(e));
|
171
|
+
}
|
172
|
+
}
|
173
|
+
export async function session(pubky) {
|
174
|
+
try {
|
175
|
+
const res = await Pubky.session(pubky);
|
176
|
+
if (res[0] === 'error') {
|
177
|
+
return err(res[1]);
|
178
|
+
}
|
179
|
+
return ok(JSON.parse(res[1]));
|
180
|
+
} catch (e) {
|
181
|
+
return err(JSON.stringify(e));
|
182
|
+
}
|
183
|
+
}
|
143
184
|
export async function generateSecretKey() {
|
144
185
|
try {
|
145
186
|
const res = await Pubky.generateSecretKey();
|
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","
|
1
|
+
{"version":3,"names":["NativeModules","Platform","NativeEventEmitter","ok","err","LINKING_ERROR","select","ios","default","Pubky","Proxy","get","Error","eventEmitter","setEventListener","callback","addListener","undefined","e","JSON","stringify","removeEventListener","removeAllListeners","auth","url","secretKey","res","parseAuthUrl","parsed","parse","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content","publishHttps","target","resolveHttps","list","deleteFile","session","pubky","generateSecretKey","getPublicKeyFromSecretKey","createRecoveryFile","passphrase","decryptRecoveryFile","recoveryFile"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;AAC1E,SAASC,EAAE,EAAEC,GAAG,QAAqB,oBAAoB;AAEzD,MAAMC,aAAa,GACjB,6EAA6E,GAC7EJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGT,aAAa,CAACS,KAAK,GAC7BT,aAAa,CAACS,KAAK,GACnB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EAC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AC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOR,CAAC,EAAE;IACV,OAAOd,GAAG,CAACe,IAAI,CAACC,SAAS,CAACF,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
@@ -1,17 +1,19 @@
|
|
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
|
-
type Capability = {
|
5
|
+
export type Capability = {
|
4
6
|
path: string;
|
5
7
|
permission: string;
|
6
8
|
};
|
7
|
-
type PubkyAuthDetails = {
|
9
|
+
export type PubkyAuthDetails = {
|
8
10
|
relay: string;
|
9
11
|
capabilities: Capability[];
|
10
12
|
secret: string;
|
11
13
|
};
|
12
14
|
export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
|
13
15
|
export declare function publish(recordName: string, recordContent: string, secretKey: string): Promise<Result<string[]>>;
|
14
|
-
interface ITxt {
|
16
|
+
export interface ITxt {
|
15
17
|
cache_flush: boolean;
|
16
18
|
class: string;
|
17
19
|
name: string;
|
@@ -21,7 +23,7 @@ interface ITxt {
|
|
21
23
|
};
|
22
24
|
ttl: number;
|
23
25
|
}
|
24
|
-
interface IDNSPacket {
|
26
|
+
export interface IDNSPacket {
|
25
27
|
signed_packet: string;
|
26
28
|
public_key: string;
|
27
29
|
signature: string;
|
@@ -37,7 +39,7 @@ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
|
|
37
39
|
export declare function get(url: string): Promise<Result<string[]>>;
|
38
40
|
export declare function put(url: string, content: Object): Promise<Result<string[]>>;
|
39
41
|
export declare function publishHttps(recordName: string, target: string, secretKey: string): Promise<Result<string[]>>;
|
40
|
-
interface IHttpsRecord {
|
42
|
+
export interface IHttpsRecord {
|
41
43
|
name: string;
|
42
44
|
class: string;
|
43
45
|
ttl: number;
|
@@ -46,22 +48,27 @@ interface IHttpsRecord {
|
|
46
48
|
port?: number;
|
47
49
|
alpn?: string[];
|
48
50
|
}
|
49
|
-
interface IHttpsResolveResult {
|
51
|
+
export interface IHttpsResolveResult {
|
50
52
|
public_key: string;
|
51
53
|
https_records: IHttpsRecord[];
|
52
54
|
}
|
53
55
|
export declare function resolveHttps(publicKey: string): Promise<Result<IHttpsResolveResult>>;
|
54
56
|
export declare function list(url: string): Promise<Result<string[]>>;
|
55
|
-
|
57
|
+
export declare function deleteFile(url: string): Promise<Result<string[]>>;
|
58
|
+
export interface SessionInfo {
|
59
|
+
pubky: string;
|
60
|
+
capabilities: string[];
|
61
|
+
}
|
62
|
+
export declare function session(pubky: string): Promise<Result<SessionInfo>>;
|
63
|
+
export interface IPublicKeyInfo {
|
56
64
|
public_key: string;
|
57
65
|
uri: string;
|
58
66
|
}
|
59
|
-
interface IGenerateSecretKey extends IPublicKeyInfo {
|
67
|
+
export interface IGenerateSecretKey extends IPublicKeyInfo {
|
60
68
|
secret_key: string;
|
61
69
|
}
|
62
70
|
export declare function generateSecretKey(): Promise<Result<IGenerateSecretKey>>;
|
63
71
|
export declare function getPublicKeyFromSecretKey(secretKey: string): Promise<Result<IPublicKeyInfo>>;
|
64
72
|
export declare function createRecoveryFile(secretKey: string, passphrase: string): Promise<Result<string>>;
|
65
73
|
export declare function decryptRecoveryFile(recoveryFile: string, passphrase: string): Promise<Result<string>>;
|
66
|
-
export {};
|
67
74
|
//# 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,wBAA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AAE,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,MAAM,WAAW,WAAW;IAC1B,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,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,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,17 +1,19 @@
|
|
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
|
-
type Capability = {
|
5
|
+
export type Capability = {
|
4
6
|
path: string;
|
5
7
|
permission: string;
|
6
8
|
};
|
7
|
-
type PubkyAuthDetails = {
|
9
|
+
export type PubkyAuthDetails = {
|
8
10
|
relay: string;
|
9
11
|
capabilities: Capability[];
|
10
12
|
secret: string;
|
11
13
|
};
|
12
14
|
export declare function parseAuthUrl(url: string): Promise<Result<PubkyAuthDetails>>;
|
13
15
|
export declare function publish(recordName: string, recordContent: string, secretKey: string): Promise<Result<string[]>>;
|
14
|
-
interface ITxt {
|
16
|
+
export interface ITxt {
|
15
17
|
cache_flush: boolean;
|
16
18
|
class: string;
|
17
19
|
name: string;
|
@@ -21,7 +23,7 @@ interface ITxt {
|
|
21
23
|
};
|
22
24
|
ttl: number;
|
23
25
|
}
|
24
|
-
interface IDNSPacket {
|
26
|
+
export interface IDNSPacket {
|
25
27
|
signed_packet: string;
|
26
28
|
public_key: string;
|
27
29
|
signature: string;
|
@@ -37,7 +39,7 @@ export declare function signOut(secretKey: string): Promise<Result<string[]>>;
|
|
37
39
|
export declare function get(url: string): Promise<Result<string[]>>;
|
38
40
|
export declare function put(url: string, content: Object): Promise<Result<string[]>>;
|
39
41
|
export declare function publishHttps(recordName: string, target: string, secretKey: string): Promise<Result<string[]>>;
|
40
|
-
interface IHttpsRecord {
|
42
|
+
export interface IHttpsRecord {
|
41
43
|
name: string;
|
42
44
|
class: string;
|
43
45
|
ttl: number;
|
@@ -46,22 +48,27 @@ interface IHttpsRecord {
|
|
46
48
|
port?: number;
|
47
49
|
alpn?: string[];
|
48
50
|
}
|
49
|
-
interface IHttpsResolveResult {
|
51
|
+
export interface IHttpsResolveResult {
|
50
52
|
public_key: string;
|
51
53
|
https_records: IHttpsRecord[];
|
52
54
|
}
|
53
55
|
export declare function resolveHttps(publicKey: string): Promise<Result<IHttpsResolveResult>>;
|
54
56
|
export declare function list(url: string): Promise<Result<string[]>>;
|
55
|
-
|
57
|
+
export declare function deleteFile(url: string): Promise<Result<string[]>>;
|
58
|
+
export interface SessionInfo {
|
59
|
+
pubky: string;
|
60
|
+
capabilities: string[];
|
61
|
+
}
|
62
|
+
export declare function session(pubky: string): Promise<Result<SessionInfo>>;
|
63
|
+
export interface IPublicKeyInfo {
|
56
64
|
public_key: string;
|
57
65
|
uri: string;
|
58
66
|
}
|
59
|
-
interface IGenerateSecretKey extends IPublicKeyInfo {
|
67
|
+
export interface IGenerateSecretKey extends IPublicKeyInfo {
|
60
68
|
secret_key: string;
|
61
69
|
}
|
62
70
|
export declare function generateSecretKey(): Promise<Result<IGenerateSecretKey>>;
|
63
71
|
export declare function getPublicKeyFromSecretKey(secretKey: string): Promise<Result<IPublicKeyInfo>>;
|
64
72
|
export declare function createRecoveryFile(secretKey: string, passphrase: string): Promise<Result<string>>;
|
65
73
|
export declare function decryptRecoveryFile(recoveryFile: string, passphrase: string): Promise<Result<string>>;
|
66
|
-
export {};
|
67
74
|
//# 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,CAAC,CAAC,CAQvB;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAQjE;AAED,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,M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MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUvE;AAED,MAAM,WAAW,WAAW;IAC1B,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,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@synonymdev/react-native-pubky",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.9.1",
|
4
4
|
"description": "React Native Implementation of Pubky",
|
5
5
|
"source": "./src/index.tsx",
|
6
6
|
"main": "./lib/commonjs/index.js",
|
@@ -46,11 +46,15 @@
|
|
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",
|
48
48
|
"reinstall": "yarn install && npm run clean && npm run prepare",
|
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
|
-
"update-bindings:ios": "npm run cargo-build && node setup-ios-bindings.js && npm run reinstall",
|
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",
|
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"
|
49
|
+
"cargo-build": "yarn install && node setup-rust.js && 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
|
+
"update-local-bindings:ios": "npm run cargo-build && cd rust && ./build.sh ios && cd ../ && node setup-local-ios-bindings.js && npm run reinstall",
|
51
|
+
"update-local-bindings:android": "npm run cargo-build && cd rust && ./build.sh android && cd ../ && node setup-local-android-bindings.js && npm run reinstall",
|
52
|
+
"update-local-bindings": "npm run reinstall && npm run cargo-build && npm run update-local-bindings:ios && npm run update-local-bindings:android",
|
53
|
+
"rebuild-local": "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-local-bindings && cd example && yarn install && bundle install && cd ios && pod install && cd ../ && yarn build:ios && yarn ios",
|
54
|
+
"update-remote-bindings:ios": "npm run reinstall && node setup-remote-ios-bindings.js && npm run reinstall",
|
55
|
+
"update-remote-bindings:android": "npm run reinstall && node setup-remote-android-bindings.js && npm run reinstall",
|
56
|
+
"update-remote-bindings": "npm run reinstall && npm run update-remote-bindings:ios && npm run update-remote-bindings:android",
|
57
|
+
"rebuild-remote": "rm -rf node_modules && cd example && rm -rf node_modules && cd ios && rm -rf Pods Podfile.lock build && cd ../../ && yarn install && npm run update-remote-bindings && cd example && yarn install && bundle install && cd ios && pod install && cd ../ && yarn build:ios && yarn ios"
|
54
58
|
},
|
55
59
|
"keywords": [
|
56
60
|
"pubky",
|
@@ -69,7 +73,7 @@
|
|
69
73
|
},
|
70
74
|
"homepage": "https://github.com/pubky/react-native-pubky#readme",
|
71
75
|
"publishConfig": {
|
72
|
-
"access": "
|
76
|
+
"access": "public",
|
73
77
|
"registry": "https://registry.npmjs.org/"
|
74
78
|
},
|
75
79
|
"dependencies": {
|
@@ -93,6 +97,7 @@
|
|
93
97
|
"react-native": "0.75.3",
|
94
98
|
"react-native-builder-bob": "^0.30.2",
|
95
99
|
"release-it": "^15.0.0",
|
100
|
+
"simple-git": "^3.27.0",
|
96
101
|
"turbo": "^1.10.7",
|
97
102
|
"typescript": "^5.2.2"
|
98
103
|
},
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
19
19
|
|
20
20
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
21
21
|
s.ios.source_files = "ios/**/*.{h,m,mm,swift}"
|
22
|
-
s.ios.vendored_frameworks = "ios/Frameworks/
|
22
|
+
s.ios.vendored_frameworks = "ios/Frameworks/PubkyCore.xcframework"
|
23
23
|
|
24
24
|
s.pod_target_xcconfig = {
|
25
25
|
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" => "x86_64"
|
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
|
@@ -29,12 +53,12 @@ export async function auth(
|
|
29
53
|
return ok(res[1]);
|
30
54
|
}
|
31
55
|
|
32
|
-
type Capability = {
|
56
|
+
export type Capability = {
|
33
57
|
path: string;
|
34
58
|
permission: string;
|
35
59
|
};
|
36
60
|
|
37
|
-
type PubkyAuthDetails = {
|
61
|
+
export type PubkyAuthDetails = {
|
38
62
|
relay: string;
|
39
63
|
capabilities: Capability[];
|
40
64
|
secret: string;
|
@@ -71,7 +95,7 @@ export async function publish(
|
|
71
95
|
}
|
72
96
|
}
|
73
97
|
|
74
|
-
interface ITxt {
|
98
|
+
export interface ITxt {
|
75
99
|
cache_flush: boolean;
|
76
100
|
class: string;
|
77
101
|
name: string;
|
@@ -81,7 +105,7 @@ interface ITxt {
|
|
81
105
|
};
|
82
106
|
ttl: number;
|
83
107
|
}
|
84
|
-
interface IDNSPacket {
|
108
|
+
export interface IDNSPacket {
|
85
109
|
signed_packet: string;
|
86
110
|
public_key: string;
|
87
111
|
signature: string;
|
@@ -184,7 +208,7 @@ export async function publishHttps(
|
|
184
208
|
}
|
185
209
|
}
|
186
210
|
|
187
|
-
interface IHttpsRecord {
|
211
|
+
export interface IHttpsRecord {
|
188
212
|
name: string;
|
189
213
|
class: string;
|
190
214
|
ttl: number;
|
@@ -194,7 +218,7 @@ interface IHttpsRecord {
|
|
194
218
|
alpn?: string[];
|
195
219
|
}
|
196
220
|
|
197
|
-
interface IHttpsResolveResult {
|
221
|
+
export interface IHttpsResolveResult {
|
198
222
|
public_key: string;
|
199
223
|
https_records: IHttpsRecord[];
|
200
224
|
}
|
@@ -225,11 +249,40 @@ export async function list(url: string): Promise<Result<string[]>> {
|
|
225
249
|
}
|
226
250
|
}
|
227
251
|
|
228
|
-
|
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
|
+
export 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
|
+
|
281
|
+
export interface IPublicKeyInfo {
|
229
282
|
public_key: string;
|
230
283
|
uri: string;
|
231
284
|
}
|
232
|
-
interface IGenerateSecretKey extends IPublicKeyInfo {
|
285
|
+
export interface IGenerateSecretKey extends IPublicKeyInfo {
|
233
286
|
secret_key: string;
|
234
287
|
}
|
235
288
|
export async function generateSecretKey(): Promise<Result<IGenerateSecretKey>> {
|