diff options
Diffstat (limited to 'lib/passkey.ts')
-rw-r--r-- | lib/passkey.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/passkey.ts b/lib/passkey.ts index 81a21a5..6deb656 100644 --- a/lib/passkey.ts +++ b/lib/passkey.ts @@ -1,5 +1,6 @@ "use client"; +import * as age from "age-encryption"; import { Platform } from "react-native"; import * as SecureStore from "expo-secure-store"; import type { AsyncRes } from "./types"; @@ -8,6 +9,27 @@ const PASSKEY_CREDENTIAL_ID_KEY = "urbit_wallet_passkey_id"; const RELYING_PARTY_ID = "wallet.urbit.org"; // Change this to your domain const RELYING_PARTY_NAME = "Urbit Wallet"; +export async function createFancyPasskey() { + const credential = await age.webauthn.createCredential({ + keyName: "pasukii", + }); + return credential; +} +export async function pkEncrypt(mticket: string) { + const e = new age.Encrypter(); + e.addRecipient(new age.webauthn.WebAuthnRecipient()); + const ciphertext = await e.encrypt(mticket); + const armored = age.armor.encode(ciphertext); + return armored; +} +export async function pkDecrypt(data: string) { + const d = new age.Decrypter(); + d.addIdentity(new age.webauthn.WebAuthnIdentity()); + const decoded = age.armor.decode(data); + const out = await d.decrypt(decoded, "text"); + return out; +} + export async function createPasskey(): AsyncRes<PublicKeyCredential> { const pkok = await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(); |