mirror of
https://github.com/aljazceru/react-native-pubky.git
synced 2025-12-22 00:54:21 +01:00
feat: implement parseAuthUrl
Adds & Implements parseAuthUrl. Updates README.md. Bumps version to 0.2.0.
This commit is contained in:
@@ -28,3 +28,29 @@ export async function auth(
|
||||
}
|
||||
return ok(res[1]);
|
||||
}
|
||||
|
||||
type Capability = {
|
||||
path: string;
|
||||
permission: string;
|
||||
};
|
||||
|
||||
type PubkyAuthDetails = {
|
||||
relay: string;
|
||||
capabilities: Capability[];
|
||||
secret: string;
|
||||
};
|
||||
|
||||
export async function parseAuthUrl(
|
||||
url: string
|
||||
): Promise<Result<PubkyAuthDetails>> {
|
||||
try {
|
||||
const res = await Pubky.parseAuthUrl(url);
|
||||
if (res[0] === 'error') {
|
||||
return err(res[1]);
|
||||
}
|
||||
const parsed = JSON.parse(res[1]);
|
||||
return ok(parsed);
|
||||
} catch (e) {
|
||||
return err(JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user