Merge pull request #21 from pubky/session-info

refactor: return session info
This commit is contained in:
Corey
2024-11-23 22:45:22 -05:00
committed by GitHub
10 changed files with 8 additions and 7 deletions

View File

@@ -1237,7 +1237,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-pubky (0.9.2):
- react-native-pubky (0.9.3):
- DoubleConversion
- glog
- hermes-engine
@@ -1757,7 +1757,7 @@ SPEC CHECKSUMS:
React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404
React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4
React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e
react-native-pubky: b33ab8648b1ae4084ab1969f13b87baa51aa7a8e
react-native-pubky: e88bb8d49d795e78a269a32b790068fbd5824b8f
React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9
React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27
React-perflogger: 3bbb82f18e9ac29a1a6931568e99d6305ef4403b

View File

@@ -24,6 +24,7 @@ import {
} from '@synonymdev/react-native-pubky';
const HOMESERVER = '8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo';
//const HOMESERVER = 'ufibwbmed6jeq9k4p583go95wofakh9fwpp4k734trq79pd9u1uy';
const SECRET_KEY =
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
const PUBLIC_KEY = 'z4e8s17cou9qmuwen8p1556jzhf1wktmzo6ijsfnri9c4hnrdfty';

View File

@@ -1,6 +1,6 @@
{
"name": "@synonymdev/react-native-pubky",
"version": "0.9.2",
"version": "0.9.3",
"description": "React Native Implementation of Pubky",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",

View File

@@ -129,25 +129,25 @@ export async function resolve(publicKey: string): Promise<Result<IDNSPacket>> {
export async function signUp(
secretKey: string,
homeserver: string
): Promise<Result<string[]>> {
): Promise<Result<SessionInfo>> {
try {
const res = await Pubky.signUp(secretKey, homeserver);
if (res[0] === 'error') {
return err(res[1]);
}
return ok(res[1]);
return ok(JSON.parse(res[1]));
} catch (e) {
return err(JSON.stringify(e));
}
}
export async function signIn(secretKey: string): Promise<Result<string[]>> {
export async function signIn(secretKey: string): Promise<Result<SessionInfo>> {
try {
const res = await Pubky.signIn(secretKey);
if (res[0] === 'error') {
return err(res[1]);
}
return ok(res[1]);
return ok(JSON.parse(res[1]));
} catch (e) {
return err(JSON.stringify(e));
}