summaryrefslogtreecommitdiff
path: root/lib/passkey.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-16 10:46:39 +0700
committerpolwex <polwex@sortug.com>2025-07-16 10:46:39 +0700
commit8ae0d2779c26f74e64a1db2b028bd2ac2f599cb4 (patch)
tree8add90087aae10a57817b3ef0bfc9fa884646d00 /lib/passkey.ts
parentdc0ad21f0e857adb87d710dd0f2f9affd0a9cbc9 (diff)
encryption done if heavy
Diffstat (limited to 'lib/passkey.ts')
-rw-r--r--lib/passkey.ts22
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();