feat: implement parseAuthUrl

Adds & Implements parseAuthUrl.
Updates README.md.
Bumps version to 0.2.0.
This commit is contained in:
coreyphillips
2024-09-15 21:17:10 -04:00
parent b5185fe7ba
commit c2a699d2d2
19 changed files with 221 additions and 41 deletions

View File

@@ -1,33 +1,9 @@
import { StyleSheet, View, Button } from 'react-native';
import { auth } from '@synonymdev/react-native-pubky';
import { getAddress } from 'react-native-address-generator';
import { auth, parseAuthUrl } from '@synonymdev/react-native-pubky';
export default function App() {
return (
<View style={styles.container}>
<Button
title={'getAddress'}
onPress={async (): Promise<void> => {
const mnemonic =
'lazy rally chat way pet outside flame cup oval absurd innocent balcony';
const passphrase = 'passphrase';
const path = "m/84'/1'/0'/0/0";
const network = 'testnet';
const getAddressRes = await getAddress({
mnemonic,
path,
network,
passphrase,
});
if (getAddressRes.isErr()) {
console.log(getAddressRes.error.message);
return;
}
console.log(getAddressRes.value);
}}
/>
<Button
title={'auth'}
onPress={async (): Promise<void> => {
@@ -46,6 +22,23 @@ export default function App() {
}
}}
/>
<Button
title={'parseAuthUrl'}
onPress={async (): Promise<void> => {
try {
const res = await parseAuthUrl(
'pubkyauth:///?relay=https://demo.httprelay.io/link&capabilities=/pub/pubky.app:rw,/pub/example.com/nested:rw&secret=FyzJ3gJ1W7boyFZC1Do9fYrRmDNgCLNRwEu_gaBgPUA'
);
if (res.isErr()) {
console.log(res.error.message);
return;
}
console.log(res.value);
} catch (e) {
console.log(e);
}
}}
/>
</View>
);
}