Add base project

Implement auth method
This commit is contained in:
coreyphillips
2024-09-11 22:03:27 -04:00
parent 66649117dc
commit b03d04ccc4
192 changed files with 54913 additions and 3 deletions

30
src/index.tsx Normal file
View File

@@ -0,0 +1,30 @@
import { NativeModules, Platform } from 'react-native';
import { ok, err, type Result } from '@synonymdev/result';
const LINKING_ERROR =
`The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';
const Pubky = NativeModules.Pubky
? NativeModules.Pubky
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
export async function auth(
url: string,
secretKey: string
): Promise<Result<string[]>> {
const res = await Pubky.auth(url, secretKey);
if (res[0] === 'error') {
return err(res[1]);
}
return ok(res[1]);
}