diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/login/ShipCredsForm.tsx | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/components/login/ShipCredsForm.tsx b/components/login/ShipCredsForm.tsx index ac58e86..d84a474 100644 --- a/components/login/ShipCredsForm.tsx +++ b/components/login/ShipCredsForm.tsx @@ -9,8 +9,15 @@ import { } from "react-native"; import PrimaryButton from "../PrimaryButton"; import { useState } from "react"; -import { createFancyPasskey, pkDecrypt, pkEncrypt } from "@/lib/passkey"; +import { + createFancyPasskey, + createPasskey, + pkDecrypt, + pkEncrypt, +} from "@/lib/passkey"; import toast, { Toaster } from "react-hot-toast"; +import { makeWalletFromP } from "@/lib/urbit/wallet"; +import { hex2buf } from "@/lib/utils/bit"; export function ShipForm() { const colors = lightColors; @@ -20,11 +27,35 @@ export function ShipForm() { const [encryptedTicket, setenc] = useState(""); const [isLoading, setIsLoading] = useState(false); async function onSubmit() { + const wallet = await makeWalletFromP(patp, ticket); + console.log("seed", wallet.ownership.seed); + const privkey = wallet.ownership.keys.private; + const clean = privkey.replace(/^0x/i, ""); + const byteLength = clean.length / 2; + toast(`bytes: ${byteLength}`); + const bufer = hex2buf(privkey); + toast(`buffer size: ${bufer.byteLength}`); + const ba = Uint8Array.fromHex(clean); + toast(`uintarray byte length: ${ba.byteLength}`); + console.log({ + bufl: bufer.length, + bufbl: bufer.byteLength, + ul: ba.length, + ubl: ba.byteLength, + }); + } + async function makeFPk() { console.log("running", { patp, ticket }); const passkey = await createFancyPasskey(); console.log({ passkey }); toast(passkey); } + async function makePk() { + console.log("running", { patp, ticket }); + const passkey = await createPasskey(); + if ("error" in passkey) return toast.error(passkey.error); + console.log({ passkey }); + } async function enc() { const done = await pkEncrypt(ticket); console.log({ encryptedTicket }); @@ -65,6 +96,12 @@ export function ShipForm() { isLoading={isLoading} /> <PrimaryButton + label="Make Passkey" + onPress={makePk} + style={{ marginTop: 0 }} + isLoading={isLoading} + /> + <PrimaryButton label="Encrypt" onPress={enc} style={{ marginTop: 0 }} |