Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@bsv/sdk": "^1.1.19",
"@bsv/sdk": "^1.1.21",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@google/model-viewer": "^3.5.0",
Expand All @@ -34,17 +34,19 @@
"@vercel/speed-insights": "^1.0.12",
"ai": "^3.1.15",
"blurhash": "^2.0.5",
"bsv-bap": "0.0.2",
"bun-copy-plugin": "^0.2.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"color-hash": "^2.0.2",
"critters": "^0.0.20",
"crypto-es": "^2.1.0",
"daisyui": "^4.11.1",
"dompurify": "^3.0.9",
"framer-motion": "^11.1.7",
"isomorphic-dompurify": "^2.4.0",
"jdenticon": "^3.2.0",
"js-1sat-ord": "^0.1.73",
"js-1sat-ord": "^0.1.74",
"lodash": "^4.17.21",
"lucide-react": "^0.378.0",
"mime": "^3.0.0",
Expand All @@ -64,18 +66,18 @@
"react-slick": "^0.30.2",
"satoshi-token": "^0.0.4",
"sharp": "^0.33.5",
"sigma-protocol": "^0.1.3",
"sigma-protocol": "^0.1.4",
"slick-carousel": "^1.8.1",
"styled-components": "^6.1.8",
"tailwind-merge": "^2.2.1",
"text-encoder-lite": "^2.0.0",
"three": "^0.163.0",
"upgradeps": "^2.0.6",
"usehooks-ts": "^2.9.4",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/bun": "^1.1.1",
"@types/color-hash": "^2.0.0",
"@types/node": "^20",
"@types/randombytes": "^2.0.3",
"@types/react": "^18.3",
Expand Down
26 changes: 26 additions & 0 deletions src/app/api/identity/get/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextResponse } from "next/server";

export async function POST(req: Request) {
const { idKey } = await req.json();
try {
const response = await fetch(
"https://go-bap-indexer-production.up.railway.app/v1/identity/get",

{
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({ idKey: idKey }),
}
);
const data = await response.json();
return NextResponse.json(data);
} catch (err) {
return new NextResponse(null, {
status: 500,
statusText: "Internal Server Error",
});
}
}
26 changes: 26 additions & 0 deletions src/app/api/identity/validByAddress/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextResponse } from "next/server";

export async function POST(req: Request) {
const { address } = await req.json();
try {
const response = await fetch(
"https://go-bap-indexer-production.up.railway.app/v1/identity/validByAddress",

{
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({ address: address }),
}
);
const data = await response.json();
return NextResponse.json(data);
} catch (err) {
return new NextResponse(null, {
status: 500,
statusText: "Internal Server Error",
});
}
}
10 changes: 1 addition & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TanstackProvider from "@/providers/TanstackProvider";
import type { Metadata } from "next";
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from "@vercel/speed-insights/next"
import { Inter, Ubuntu, Ubuntu_Mono } from "next/font/google";
import { Inter, Ubuntu } from "next/font/google";
import { Toaster } from "react-hot-toast";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
Expand All @@ -17,12 +17,6 @@ const ubuntu = Ubuntu({
subsets: ["latin"],
});

const ubuntuMono = Ubuntu_Mono({
style: "normal",
weight: ["400", "700"],
subsets: ["latin"],
});

const description =
"A open token protocol in the spirit of BTC Ordinals with the cost efficiency and performance of Bitcoin SV.";

Expand All @@ -38,7 +32,6 @@ export const metadata: Metadata = {
};

// get pathname

export default function RootLayout({
children,
}: {
Expand All @@ -57,7 +50,6 @@ export default function RootLayout({
/>
<TanstackProvider>
<Header ubuntu={ubuntu} />
{/* <Tabs className={`absolute md:relative m-0 md:my-8 bottom-0 left-0 w-full md:w-fit mx-auto ${ubuntuMono.className}`} /> */}
{children}
<Analytics />
<SpeedInsights />
Expand Down
29 changes: 29 additions & 0 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

import ProfilePage from "@/components/pages/profile";
import { Suspense } from "react";

const Profile = () => {
return (
<Suspense>
<ProfilePage />
</Suspense>
);
};
export default Profile;

export async function generateMetadata() {
return {
title: "Profile Page - 1SatOrdinals",
description: "View your profile information.",
openGraph: {
title: "Profile Page - 1SatOrdinals",
description: "View your profile information.",
type: "website",
},
twitter: {
card: "ummary_large_image",
title: "Profile Page - 1SatOrdinals",
description: "Profile page on 1SatOrdinals.",
},
};
}
70 changes: 22 additions & 48 deletions src/components/Passphrase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import { encryptionPrefix, toastErrorProps, toastProps } from "@/constants";
import {
ImportWalletFromBackupJsonStep,
changeAddressPath,
encryptionKey,
identityAddressPath,
identityPk,
importWalletFromBackupJsonStep,
migrating,
mnemonic,
ordAddressPath,
ordPk,
passphrase,
payPk,
Expand All @@ -26,13 +21,15 @@ import { backupKeys } from "@/utils/wallet";
import { PrivateKey } from "@bsv/sdk";
import { effect, useSignal } from "@preact/signals-react";
import { useSignals } from "@preact/signals-react/runtime";
import randomBytes from "randombytes";
import { useCallback, useEffect, useRef, useState, type FormEvent } from "react";
import toast from "react-hot-toast";
import { FiCopy } from "react-icons/fi";
import { RiErrorWarningFill } from "react-icons/ri";
import { TbDice } from "react-icons/tb";
import { useCopyToClipboard } from "usehooks-ts";
import { hasIdentityBackup } from "@/signals/bapIdentity/index";
import { loadAvailableIdentitiesFromEncryptedStorage, loadIdentityFromEncryptedStorage } from "@/signals/bapIdentity/client";
import randomBytes from "randombytes";

type Props = {
mode: EncryptDecrypt;
Expand Down Expand Up @@ -111,28 +108,22 @@ const EnterPassphrase: React.FC<Props> = ({
return;
}

const iv = new Uint8Array(randomBytes(16).buffer);
const plainKeys = {
payPk: payPk.value,
ordPk: ordPk.value,
};
debugger;
const encrypted = await encryptData(
Buffer.from(
JSON.stringify({
mnemonic: mnemonic.value,
payPk: payPk.value,
ordPk: ordPk.value,
payDerivationPath: changeAddressPath.value,
ordDerivationPath: ordAddressPath.value,
...(!!identityPk.value && { identityPk: identityPk.value }),
...(!!identityAddressPath.value && { identityDerivationPath: identityAddressPath.value }),
}),
JSON.stringify(plainKeys),
"utf-8"
),
encryptionKey.value,
iv
);

const encryptedBackup =
encryptionPrefix +
Buffer.concat([iv, encrypted]).toString("base64");

console.log({encryptionPrefix, encrypted})
const encryptedBackup = `${encryptionPrefix}${encrypted}`;
debugger;
const keys: EncryptedBackupJson = {
encryptedBackup,
pubKey,
Expand Down Expand Up @@ -163,27 +154,20 @@ const EnterPassphrase: React.FC<Props> = ({
toast.error("Failed to encrypt keys", toastErrorProps);
}
}
}, [
download,
encryptionKey.value,
hasDownloadedKeys,
migrating.value,
ordPk.value,
passphrase.value,
payPk.value,
mnemonic.value,
changeAddressPath.value,
ordAddressPath.value,
identityPk.value,
identityAddressPath.value
]);
}, [download, encryptionKey.value, hasDownloadedKeys, migrating.value, ordPk.value, passphrase.value, payPk.value]);

const handleClickDecrypt = async () => {
if (passphrase.value) {
console.log("decrypt keys w passphrase");

try {
await loadKeysFromEncryptedStorage(passphrase.value);
const succeeded = await loadKeysFromEncryptedStorage(passphrase.value);
if (succeeded && !!hasIdentityBackup.value) {
const decryptedId = await loadIdentityFromEncryptedStorage(passphrase.value);
const decryptedIdentities = await loadAvailableIdentitiesFromEncryptedStorage(passphrase.value);

if (!decryptedId || !decryptedIdentities) {
toast.error("Failed to decrypt identity, please import it again.", toastErrorProps);
}
}
onSubmit();
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -269,16 +253,6 @@ const EnterPassphrase: React.FC<Props> = ({
</div>

<div className="flex gap-2 justify-end">
{!migrating.value && !download && (
<button
type="button"
className="btn btn-error"
onClick={() => onSubmit()}
>
Skip
</button>
)}

<button
disabled={(passphrase.value?.length || 0) < 6}
className="btn btn-primary"
Expand Down
Loading