Graphical PDS migrator for AT Protocol

Compare changes

Choose any two refs to compare.

.DS_Store

This is a binary file and will not be displayed.

+3
.env.example
···
···
+
# generate with `openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32`
+
COOKIE_SECRET=my_secret
+
MIGRATION_STATE=up
-36
.github/workflows/deploy.yml
···
-
name: Deploy
-
on:
-
push:
-
branches: main
-
pull_request:
-
branches: main
-
-
jobs:
-
deploy:
-
name: Deploy
-
runs-on: ubuntu-latest
-
-
permissions:
-
id-token: write # Needed for auth with Deno Deploy
-
contents: read # Needed to clone the repository
-
-
steps:
-
- name: Clone repository
-
uses: actions/checkout@v4
-
-
- name: Install Deno
-
uses: denoland/setup-deno@v2
-
with:
-
deno-version: v2.x
-
-
- name: Build step
-
run: "deno task build"
-
-
- name: Upload to Deno Deploy
-
uses: denoland/deployctl@v1
-
with:
-
project: "roscoerubin-airport-67"
-
entrypoint: "main.ts"
-
root: "."
-
-
···
+2
.gitignore
···
.env.production.local
.env.local
# Fresh build directory
_fresh/
# npm dependencies
···
.env.production.local
.env.local
+
.DS_Store
+
# Fresh build directory
_fresh/
# npm dependencies
+35 -9
.zed/settings.json
···
{
"languages": {
"TypeScript": {
"language_servers": [
-
"wakatime",
"deno",
"!typescript-language-server",
"!vtsls",
-
"!eslint"
-
],
-
"formatter": "language_server"
},
"TSX": {
"language_servers": [
-
"wakatime",
"deno",
"!typescript-language-server",
"!vtsls",
-
"!eslint"
-
],
-
"formatter": "language_server"
}
-
}
}
···
+
// Folder-specific settings
+
//
+
// For a full list of overridable settings, and general information on folder-specific settings,
+
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
+
"lsp": {
+
"deno": {
+
"settings": {
+
"deno": {
+
"enable": true,
+
"cacheOnSave": true,
+
"suggest": {
+
"imports": {
+
"autoDiscover": true
+
}
+
}
+
}
+
}
+
}
+
},
"languages": {
+
"JavaScript": {
+
"language_servers": [
+
"deno",
+
"!vtsls",
+
"!eslint",
+
"..."
+
]
+
},
"TypeScript": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
+
"!eslint",
+
"..."
+
]
},
"TSX": {
"language_servers": [
"deno",
"!typescript-language-server",
"!vtsls",
+
"!eslint",
+
"..."
+
]
}
+
},
+
"formatter": "language_server"
}
+18 -20
README.md
···
# Airport
-
Your terminal for seamless AT Protocol PDS (Personal Data Server) migration and backup.
-
Airport is a web application built with Fresh and Deno that helps users safely migrate and backup their Bluesky PDS data. It provides a user-friendly interface for managing your AT Protocol data.
-
-
โš ๏ธ **Alpha Status**: Airport is currently in alpha. Please use migration tools at your own risk and avoid using with main accounts during this phase.
## Features
···
- User-friendly interface
- Coming soon: PLC Key retrieval, data backup
-
## Technology Stack
-
- [Fresh](https://fresh.deno.dev/) - The next-gen web framework
-
- [Deno](https://deno.com/) - A modern runtime for JavaScript and TypeScript
-
- [Tailwind CSS](https://tailwindcss.com/) - For styling
-
- AT Protocol Integration
-
-
## Getting Started
-
### Prerequisites
-
Make sure to install Deno:
https://docs.deno.com/runtime/getting_started/installation
-
### Development
-
Start the project in development mode:
-
```
deno task dev
```
-
This will watch the project directory and restart as necessary.
-
## About
-
Airport is developed with โค๏ธ by [Roscoe](https://bsky.app/profile/knotbin.com) for [Spark](https://sprk.so), a new short-video platform for AT Protocol.
## Contributing
-
We welcome contributions! Please feel free to submit a Pull Request. Please only submit pull requests that are relevant to the project. This project targets people with a non-advanced understanding of AT Protocol, so please avoid submitting pull requests that add features that complicate the user experience.
## License
···
# Airport
+
Your terminal for seamless AT Protocol PDS (Personal Data Server) migration and
+
backup.
+
Airport is a web application built with Fresh and Deno that helps users safely
+
migrate and backup their Bluesky PDS data. It provides a user-friendly interface
+
for managing your AT Protocol data.
## Features
···
- User-friendly interface
- Coming soon: PLC Key retrieval, data backup
+
## Tech Stack
+
- [Fresh](https://fresh.deno.dev/) - Web Framework
+
- [Deno](https://deno.com/) - Runtime
+
- [Tailwind](https://tailwindcss.com/) - Styling
+
## Development
+
Make sure you have Deno installed:
https://docs.deno.com/runtime/getting_started/installation
Start the project in development mode:
+
```shell
deno task dev
```
## About
+
Airport is developed with โค๏ธ by [Roscoe](https://bsky.app/profile/knotbin.com)
+
for [Spark](https://sprk.so), a new short-video platform for AT Protocol.
## Contributing
+
We welcome contributions! Please feel free to submit a Pull Request. Please only
+
submit pull requests that are relevant to the project. This project targets
+
people with a non-advanced understanding of AT Protocol, so please avoid
+
submitting pull requests that add features that complicate the user experience.
## License
+33 -11
components/Button.tsx
···
condensed?: boolean;
};
-
type ButtonProps = ButtonBaseProps & Omit<JSX.HTMLAttributes<HTMLButtonElement>, keyof ButtonBaseProps>;
-
type AnchorProps = ButtonBaseProps & Omit<JSX.HTMLAttributes<HTMLAnchorElement>, keyof ButtonBaseProps> & { href: string };
/**
* The button props or anchor props for a button or link.
···
* @component
*/
export function Button(props: Props) {
-
const { color = "blue", icon, iconAlt, label, className = "", condensed = false, ...rest } = props;
-
const isAnchor = 'href' in props;
const baseStyles = "airport-sign flex items-center [transition:none]";
-
const paddingStyles = condensed ? 'px-2 py-1.5' : 'px-3 py-2 sm:px-6 sm:py-3';
-
const transformStyles = "translate-y-0 hover:translate-y-1 hover:transition-transform hover:duration-200 hover:ease-in-out";
const colorStyles = {
-
blue: "bg-gradient-to-r from-blue-400 to-blue-500 text-white hover:from-blue-500 hover:to-blue-600",
-
amber: "bg-gradient-to-r from-amber-400 to-amber-500 text-slate-900 hover:from-amber-500 hover:to-amber-600",
};
const buttonContent = (
···
<img
src={icon}
alt={iconAlt || ""}
-
className={`${condensed ? 'w-4 h-4' : 'w-6 h-6'} mr-2`}
-
style={{ filter: color === 'blue' ? "brightness(0) invert(1)" : "brightness(0)" }}
/>
)}
{label && (
···
</>
);
-
const buttonStyles = `${baseStyles} ${paddingStyles} ${transformStyles} ${colorStyles[color]} ${className}`;
if (isAnchor) {
return (
···
condensed?: boolean;
};
+
type ButtonProps =
+
& ButtonBaseProps
+
& Omit<JSX.HTMLAttributes<HTMLButtonElement>, keyof ButtonBaseProps>;
+
type AnchorProps =
+
& ButtonBaseProps
+
& Omit<JSX.HTMLAttributes<HTMLAnchorElement>, keyof ButtonBaseProps>
+
& { href: string };
/**
* The button props or anchor props for a button or link.
···
* @component
*/
export function Button(props: Props) {
+
const {
+
color = "blue",
+
icon,
+
iconAlt,
+
label,
+
className = "",
+
condensed = false,
+
...rest
+
} = props;
+
const isAnchor = "href" in props;
const baseStyles = "airport-sign flex items-center [transition:none]";
+
const paddingStyles = condensed ? "px-2 py-1.5" : "px-3 py-2 sm:px-6 sm:py-3";
+
const transformStyles =
+
"translate-y-0 hover:translate-y-1 hover:transition-transform hover:duration-200 hover:ease-in-out";
const colorStyles = {
+
blue:
+
"bg-gradient-to-r from-blue-400 to-blue-500 text-white hover:from-blue-500 hover:to-blue-600",
+
amber:
+
"bg-gradient-to-r from-amber-400 to-amber-500 text-slate-900 hover:from-amber-500 hover:to-amber-600",
};
const buttonContent = (
···
<img
src={icon}
alt={iconAlt || ""}
+
className={`${condensed ? "w-4 h-4" : "w-6 h-6"} mr-2`}
+
style={{
+
filter: color === "blue"
+
? "brightness(0) invert(1)"
+
: "brightness(0)",
+
}}
/>
)}
{label && (
···
</>
);
+
const buttonStyles = `${baseStyles} ${paddingStyles} ${transformStyles} ${
+
colorStyles[color]
+
} ${className}`;
if (isAnchor) {
return (
+65
components/Link.tsx
···
···
+
import { JSX } from "preact";
+
+
/**
+
* Props for the Link component
+
*/
+
type Props = Omit<JSX.HTMLAttributes<HTMLAnchorElement>, "href"> & {
+
/** URL for the link */
+
href: string;
+
/** Whether this is an external link that should show an outbound icon */
+
isExternal?: boolean;
+
/** Link text content */
+
children: JSX.Element | string;
+
};
+
+
/**
+
* A link component that handles external links with appropriate styling and accessibility.
+
* Automatically adds external link icon and proper attributes for external links.
+
*/
+
export function Link(props: Props) {
+
const {
+
isExternal = false,
+
class: className = "",
+
children,
+
href,
+
...rest
+
} = props;
+
+
// SVG for external link icon
+
const externalLinkIcon = (
+
<svg
+
xmlns="http://www.w3.org/2000/svg"
+
viewBox="0 0 20 20"
+
fill="currentColor"
+
className="w-4 h-4 inline-block ml-1"
+
aria-hidden="true"
+
>
+
<path
+
fillRule="evenodd"
+
d="M4.25 5.5a.75.75 0 00-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 00.75-.75v-4a.75.75 0 011.5 0v4A2.25 2.25 0 0112.75 17h-8.5A2.25 2.25 0 012 14.75v-8.5A2.25 2.25 0 014.25 4h5a.75.75 0 010 1.5h-5z"
+
/>
+
<path
+
fillRule="evenodd"
+
d="M6.194 12.753a.75.75 0 001.06.053L16.5 4.44v2.81a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.553l-9.056 8.194a.75.75 0 00-.053 1.06z"
+
/>
+
</svg>
+
);
+
+
return (
+
<a
+
href={href}
+
{...rest}
+
className={`inline-flex items-center hover:underline ${className}`}
+
{...(isExternal && {
+
target: "_blank",
+
rel: "noopener noreferrer",
+
"aria-label": `${
+
typeof children === "string" ? children : ""
+
} (opens in new tab)`,
+
})}
+
>
+
{children}
+
{isExternal && externalLinkIcon}
+
</a>
+
);
+
}
+77
components/MigrationCompletion.tsx
···
···
+
export interface MigrationCompletionProps {
+
isVisible: boolean;
+
}
+
+
export default function MigrationCompletion(
+
{ isVisible }: MigrationCompletionProps,
+
) {
+
if (!isVisible) return null;
+
+
const handleLogout = async () => {
+
try {
+
const response = await fetch("/api/logout", {
+
method: "POST",
+
credentials: "include",
+
});
+
if (!response.ok) {
+
throw new Error("Logout failed");
+
}
+
globalThis.location.href = "/";
+
} catch (error) {
+
console.error("Failed to logout:", error);
+
}
+
};
+
+
return (
+
<div class="p-4 bg-green-50 dark:bg-green-900 rounded-lg border-2 border-green-200 dark:border-green-800">
+
<p class="text-sm text-green-800 dark:text-green-200 pb-2">
+
Migration completed successfully! Sign out to finish the process and
+
return home.<br />
+
Please consider donating to Airport to support server and development
+
costs.
+
</p>
+
<div class="flex space-x-4">
+
<button
+
type="button"
+
onClick={handleLogout}
+
class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
+
/>
+
</svg>
+
<span>Sign Out</span>
+
</button>
+
<a
+
href="https://ko-fi.com/knotbin"
+
target="_blank"
+
class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
+
/>
+
</svg>
+
<span>Support Us</span>
+
</a>
+
</div>
+
</div>
+
);
+
}
+208
components/MigrationStep.tsx
···
···
+
import { IS_BROWSER } from "fresh/runtime";
+
import { ComponentChildren } from "preact";
+
+
export type StepStatus =
+
| "pending"
+
| "in-progress"
+
| "verifying"
+
| "completed"
+
| "error";
+
+
export interface MigrationStepProps {
+
name: string;
+
status: StepStatus;
+
error?: string;
+
isVerificationError?: boolean;
+
index: number;
+
onRetryVerification?: (index: number) => void;
+
children?: ComponentChildren;
+
}
+
+
export function MigrationStep({
+
name,
+
status,
+
error,
+
isVerificationError,
+
index,
+
onRetryVerification,
+
children,
+
}: MigrationStepProps) {
+
return (
+
<div key={name} class={getStepClasses(status)}>
+
{getStepIcon(status)}
+
<div class="flex-1">
+
<p
+
class={`font-medium ${
+
status === "error"
+
? "text-red-900 dark:text-red-200"
+
: status === "completed"
+
? "text-green-900 dark:text-green-200"
+
: status === "in-progress"
+
? "text-blue-900 dark:text-blue-200"
+
: "text-gray-900 dark:text-gray-200"
+
}`}
+
>
+
{getStepDisplayName(
+
{ name, status, error, isVerificationError },
+
index,
+
)}
+
</p>
+
{error && (
+
<div class="mt-1">
+
<p class="text-sm text-red-600 dark:text-red-400">
+
{(() => {
+
try {
+
const err = JSON.parse(error);
+
return err.message || error;
+
} catch {
+
return error;
+
}
+
})()}
+
</p>
+
{isVerificationError && onRetryVerification && (
+
<div class="flex space-x-2 mt-2">
+
<button
+
type="button"
+
onClick={() => onRetryVerification(index)}
+
class="px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors duration-200 dark:bg-blue-500 dark:hover:bg-blue-400"
+
disabled={!IS_BROWSER}
+
>
+
Retry Verification
+
</button>
+
</div>
+
)}
+
</div>
+
)}
+
{children}
+
</div>
+
</div>
+
);
+
}
+
+
function getStepDisplayName(
+
step: Pick<
+
MigrationStepProps,
+
"name" | "status" | "error" | "isVerificationError"
+
>,
+
index: number,
+
) {
+
if (step.status === "completed") {
+
switch (index) {
+
case 0:
+
return "Account Created";
+
case 1:
+
return "Data Migrated";
+
case 2:
+
return "Identity Migrated";
+
case 3:
+
return "Migration Finalized";
+
}
+
}
+
+
if (step.status === "in-progress") {
+
switch (index) {
+
case 0:
+
return "Creating your new account...";
+
case 1:
+
return "Migrating your data...";
+
case 2:
+
return step.name ===
+
"Enter the token sent to your email to complete identity migration"
+
? step.name
+
: "Migrating your identity...";
+
case 3:
+
return "Finalizing migration...";
+
}
+
}
+
+
if (step.status === "verifying") {
+
switch (index) {
+
case 0:
+
return "Verifying account creation...";
+
case 1:
+
return "Verifying data migration...";
+
case 2:
+
return "Verifying identity migration...";
+
case 3:
+
return "Verifying migration completion...";
+
}
+
}
+
+
return step.name;
+
}
+
+
function getStepIcon(status: StepStatus) {
+
switch (status) {
+
case "pending":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-gray-300 dark:border-gray-600 flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600" />
+
</div>
+
);
+
case "in-progress":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-blue-500 border-t-transparent animate-spin flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-blue-500" />
+
</div>
+
);
+
case "verifying":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-yellow-500 border-t-transparent animate-spin flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-yellow-500" />
+
</div>
+
);
+
case "completed":
+
return (
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center">
+
<svg
+
class="w-5 h-5 text-white"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M5 13l4 4L19 7"
+
/>
+
</svg>
+
</div>
+
);
+
case "error":
+
return (
+
<div class="w-8 h-8 rounded-full bg-red-500 flex items-center justify-center">
+
<svg
+
class="w-5 h-5 text-white"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M6 18L18 6M6 6l12 12"
+
/>
+
</svg>
+
</div>
+
);
+
}
+
}
+
+
function getStepClasses(status: StepStatus) {
+
const baseClasses =
+
"flex items-center space-x-3 p-4 rounded-lg transition-colors duration-200";
+
switch (status) {
+
case "pending":
+
return `${baseClasses} bg-gray-50 dark:bg-gray-800`;
+
case "in-progress":
+
return `${baseClasses} bg-blue-50 dark:bg-blue-900`;
+
case "verifying":
+
return `${baseClasses} bg-yellow-50 dark:bg-yellow-900`;
+
case "completed":
+
return `${baseClasses} bg-green-50 dark:bg-green-900`;
+
case "error":
+
return `${baseClasses} bg-red-50 dark:bg-red-900`;
+
}
+
}
+33 -9
deno.json
···
"tasks": {
"check": "deno fmt --check . && deno lint . && deno check **/*.ts && deno check **/*.tsx",
"dev": "deno run -A --env --watch=static/,routes/ dev.ts",
-
"build": "deno run -A --unstable-otel dev.ts build",
-
"start": "deno run -A --unstable-otel main.ts",
"update": "deno run -A -r jsr:@fresh/update ."
},
"lint": {
"rules": {
-
"tags": ["fresh", "recommended"]
}
},
-
"exclude": ["**/_fresh/*"],
"imports": {
"@atproto/api": "npm:@atproto/api@^0.15.6",
"@bigmoves/atproto-oauth-client": "jsr:@bigmoves/atproto-oauth-client@^0.2.0",
···
"posthog-js": "npm:posthog-js@1.120.0",
"preact": "npm:preact@^10.26.6",
"@preact/signals": "npm:@preact/signals@^2.0.4",
-
"tailwindcss": "npm:tailwindcss@^3.4.3"
},
"compilerOptions": {
-
"lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns"],
"jsx": "precompile",
"jsxImportSource": "preact",
-
"jsxPrecompileSkipElements": ["a", "img", "source", "body", "html", "head"],
-
"types": ["node"]
},
-
"unstable": ["kv", "otel"]
}
···
"tasks": {
"check": "deno fmt --check . && deno lint . && deno check **/*.ts && deno check **/*.tsx",
"dev": "deno run -A --env --watch=static/,routes/ dev.ts",
+
"build": "deno run -A dev.ts build",
+
"start": "deno run -A main.ts",
"update": "deno run -A -r jsr:@fresh/update ."
},
"lint": {
"rules": {
+
"tags": [
+
"fresh",
+
"recommended"
+
]
}
},
+
"exclude": [
+
"**/_fresh/*"
+
],
"imports": {
"@atproto/api": "npm:@atproto/api@^0.15.6",
"@bigmoves/atproto-oauth-client": "jsr:@bigmoves/atproto-oauth-client@^0.2.0",
···
"posthog-js": "npm:posthog-js@1.120.0",
"preact": "npm:preact@^10.26.6",
"@preact/signals": "npm:@preact/signals@^2.0.4",
+
"tailwindcss": "npm:tailwindcss@^3.4.3",
+
"@atproto/crypto": "npm:@atproto/crypto@^0.4.4",
+
"@did-plc/lib": "npm:@did-plc/lib@^0.0.4"
},
"compilerOptions": {
+
"lib": [
+
"dom",
+
"dom.asynciterable",
+
"dom.iterable",
+
"deno.ns"
+
],
"jsx": "precompile",
"jsxImportSource": "preact",
+
"jsxPrecompileSkipElements": [
+
"a",
+
"img",
+
"source",
+
"body",
+
"html",
+
"head"
+
],
+
"types": [
+
"node"
+
]
},
+
"unstable": [
+
"kv",
+
"otel"
+
]
}
+284 -1
deno.lock
···
"npm:@atproto/api@*": "0.15.6",
"npm:@atproto/api@~0.15.6": "0.15.6",
"npm:@atproto/crypto@*": "0.4.4",
"npm:@atproto/identity@*": "0.4.8",
"npm:@atproto/jwk@0.1.4": "0.1.4",
"npm:@atproto/oauth-client@~0.3.13": "0.3.16",
"npm:@atproto/oauth-types@~0.2.4": "0.2.7",
"npm:@atproto/syntax@*": "0.4.0",
"npm:@atproto/xrpc@*": "0.7.0",
"npm:@lucide/lab@*": "0.1.2",
"npm:@opentelemetry/api@^1.9.0": "1.9.0",
"npm:@preact/signals@^1.2.3": "1.3.2_preact@10.26.6",
···
"zod"
]
},
"@atproto/crypto@0.4.4": {
"integrity": "sha512-Yq9+crJ7WQl7sxStVpHgie5Z51R05etaK9DLWYG/7bR5T4bhdcIgF6IfklLShtZwLYdVVj+K15s0BqW9a8PSDA==",
"dependencies": [
···
"integrity": "sha512-Z0sLnJ87SeNdAifT+rqpgE1Rc3layMMW25gfWNo4u40RGuRODbdfAZlTwBSU2r+Vk45hU+iE+xeQspfednCEnA==",
"dependencies": [
"@atproto/common-web",
-
"@atproto/crypto"
]
},
"@atproto/jwk@0.1.4": {
···
"integrity": "sha512-SfhP9dGx2qclaScFDb58Jnrmim5nk4geZXCqg6sB0I/KZhZEkr9iIx1hLCp+sxkIfEsmEJjeWO4B0rjUIJW5cw==",
"dependencies": [
"@atproto/lexicon",
"zod"
]
},
···
"os": ["win32"],
"cpu": ["x64"]
},
"@isaacs/cliui@8.0.2": {
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
"dependencies": [
···
},
"@noble/hashes@1.8.0": {
"integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="
},
"@nodelib/fs.scandir@2.1.5": {
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
···
"undici-types"
]
},
"ansi-regex@5.0.1": {
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
},
···
"arg@5.0.2": {
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg=="
},
"autoprefixer@10.4.17_postcss@8.4.35": {
"integrity": "sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==",
"dependencies": [
···
"await-lock@2.2.2": {
"integrity": "sha512-aDczADvlvTGajTDjcjpJMqRkOF6Qdz3YbPZm/PyW6tKPkx2hlYBzxMhEywM/tU72HrVZjgl5VCdRuMlA7pZ8Gw=="
},
"balanced-match@1.0.2": {
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"binary-extensions@2.3.0": {
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw=="
···
],
"bin": true
},
"camelcase-css@2.0.1": {
"integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA=="
},
···
},
"caniuse-lite@1.0.30001717": {
"integrity": "sha512-auPpttCq6BDEG8ZAuHJIplGw6GODhjw+/11e7IjpnYCxZcW/ONgPs0KVBJ0d1bY3e2+7PRe5RCLyP+PfwVgkYw=="
},
"chokidar@3.6.0": {
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
···
"colord@2.9.3": {
"integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw=="
},
"commander@4.1.1": {
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="
},
···
"css-tree@2.2.1"
]
},
"didyoumean@1.2.2": {
"integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw=="
},
···
"domhandler"
]
},
"eastasianwidth@0.2.0": {
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
},
···
"entities@4.5.0": {
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw=="
},
"esbuild-wasm@0.23.1": {
"integrity": "sha512-L3vn7ctvBrtScRfoB0zG1eOCiV4xYvpLYWfe6PDZuV+iDFDm4Mt3xeLIDllG8cDHQ8clUouK3XekulE+cxgkgw==",
"bin": true
···
"escalade@3.2.0": {
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="
},
"fast-glob@3.3.3": {
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
"dependencies": [
···
"micromatch"
]
},
"fastq@1.19.1": {
"integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==",
"dependencies": [
···
"to-regex-range"
]
},
"foreground-child@3.3.1": {
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
"dependencies": [
···
"signal-exit"
]
},
"fraction.js@4.3.7": {
"integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew=="
},
···
"function-bind@1.1.2": {
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="
},
"glob-parent@5.1.2": {
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dependencies": [
···
],
"bin": true
},
"graphemer@1.4.0": {
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag=="
},
"hasown@2.0.2": {
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"dependencies": [
"function-bind"
]
},
"ipaddr.js@2.2.0": {
"integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA=="
···
"preact@10.26.6"
]
},
"mdn-data@2.0.28": {
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g=="
},
···
"picomatch"
]
},
"minimatch@9.0.5": {
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dependencies": [
···
"object-hash@3.0.0": {
"integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="
},
"package-json-from-dist@1.0.1": {
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="
},
···
"pify@2.3.0": {
"integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog=="
},
"pirates@4.0.7": {
"integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA=="
},
···
"preact@10.26.7": {
"integrity": "sha512-43xS+QYc1X1IPbw03faSgY6I6OYWcLrJRv3hU0+qMOfh/XCHcP0MX2CVjNARYR2cC/guu975sta4OcjlczxD7g=="
},
"psl@1.15.0": {
"integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
"dependencies": [
···
"queue-microtask@1.2.3": {
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"read-cache@1.0.0": {
"integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==",
"dependencies": [
"pify"
]
},
"readdirp@3.6.0": {
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dependencies": [
"picomatch"
]
},
"resolve@1.22.10": {
"integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==",
···
"queue-microtask"
]
},
"shebang-command@2.0.0": {
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dependencies": [
···
},
"signal-exit@4.1.0": {
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="
},
"source-map-js@1.2.1": {
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
},
"string-width@4.2.3": {
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dependencies": [
···
"eastasianwidth",
"emoji-regex@9.2.2",
"strip-ansi@7.1.0"
]
},
"strip-ansi@6.0.1": {
···
"any-promise"
]
},
"tlds@1.258.0": {
"integrity": "sha512-XGhStWuOlBA5D8QnyN2xtgB2cUOdJ3ztisne1DYVWMcVH29qh8eQIpRmP3HnuJLdgyzG0HpdGzRMu1lm/Oictw==",
"bin": true
···
"jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",
"jsr:@knotbin/posthog-fresh@~0.1.3",
"npm:@atproto/api@~0.15.6",
"npm:@preact/signals@^2.0.4",
"npm:posthog-js@1.120.0",
"npm:preact@^10.26.6",
···
"npm:@atproto/api@*": "0.15.6",
"npm:@atproto/api@~0.15.6": "0.15.6",
"npm:@atproto/crypto@*": "0.4.4",
+
"npm:@atproto/crypto@~0.4.4": "0.4.4",
"npm:@atproto/identity@*": "0.4.8",
"npm:@atproto/jwk@0.1.4": "0.1.4",
"npm:@atproto/oauth-client@~0.3.13": "0.3.16",
"npm:@atproto/oauth-types@~0.2.4": "0.2.7",
"npm:@atproto/syntax@*": "0.4.0",
"npm:@atproto/xrpc@*": "0.7.0",
+
"npm:@did-plc/lib@^0.0.4": "0.0.4",
"npm:@lucide/lab@*": "0.1.2",
"npm:@opentelemetry/api@^1.9.0": "1.9.0",
"npm:@preact/signals@^1.2.3": "1.3.2_preact@10.26.6",
···
"zod"
]
},
+
"@atproto/common@0.1.1": {
+
"integrity": "sha512-GYwot5wF/z8iYGSPjrLHuratLc0CVgovmwfJss7+BUOB6y2/Vw8+1Vw0n9DDI0gb5vmx3UI8z0uJgC8aa8yuJg==",
+
"dependencies": [
+
"@ipld/dag-cbor",
+
"multiformats@9.9.0",
+
"pino",
+
"zod"
+
]
+
},
+
"@atproto/crypto@0.1.0": {
+
"integrity": "sha512-9xgFEPtsCiJEPt9o3HtJT30IdFTGw5cQRSJVIy5CFhqBA4vDLcdXiRDLCjkzHEVbtNCsHUW6CrlfOgbeLPcmcg==",
+
"dependencies": [
+
"@noble/secp256k1",
+
"big-integer",
+
"multiformats@9.9.0",
+
"one-webcrypto",
+
"uint8arrays@3.0.0"
+
]
+
},
"@atproto/crypto@0.4.4": {
"integrity": "sha512-Yq9+crJ7WQl7sxStVpHgie5Z51R05etaK9DLWYG/7bR5T4bhdcIgF6IfklLShtZwLYdVVj+K15s0BqW9a8PSDA==",
"dependencies": [
···
"integrity": "sha512-Z0sLnJ87SeNdAifT+rqpgE1Rc3layMMW25gfWNo4u40RGuRODbdfAZlTwBSU2r+Vk45hU+iE+xeQspfednCEnA==",
"dependencies": [
"@atproto/common-web",
+
"@atproto/crypto@0.4.4"
]
},
"@atproto/jwk@0.1.4": {
···
"integrity": "sha512-SfhP9dGx2qclaScFDb58Jnrmim5nk4geZXCqg6sB0I/KZhZEkr9iIx1hLCp+sxkIfEsmEJjeWO4B0rjUIJW5cw==",
"dependencies": [
"@atproto/lexicon",
+
"zod"
+
]
+
},
+
"@did-plc/lib@0.0.4": {
+
"integrity": "sha512-Omeawq3b8G/c/5CtkTtzovSOnWuvIuCI4GTJNrt1AmCskwEQV7zbX5d6km1mjJNbE0gHuQPTVqZxLVqetNbfwA==",
+
"dependencies": [
+
"@atproto/common",
+
"@atproto/crypto@0.1.0",
+
"@ipld/dag-cbor",
+
"axios",
+
"multiformats@9.9.0",
+
"uint8arrays@3.0.0",
"zod"
]
},
···
"os": ["win32"],
"cpu": ["x64"]
},
+
"@ipld/dag-cbor@7.0.3": {
+
"integrity": "sha512-1VVh2huHsuohdXC1bGJNE8WR72slZ9XE2T3wbBBq31dm7ZBatmKLLxrB+XAqafxfRFjv08RZmj/W/ZqaM13AuA==",
+
"dependencies": [
+
"cborg",
+
"multiformats@9.9.0"
+
]
+
},
"@isaacs/cliui@8.0.2": {
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
"dependencies": [
···
},
"@noble/hashes@1.8.0": {
"integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="
+
},
+
"@noble/secp256k1@1.7.2": {
+
"integrity": "sha512-/qzwYl5eFLH8OWIecQWM31qld2g1NfjgylK+TNhqtaUKP37Nm+Y+z30Fjhw0Ct8p9yCQEm2N3W/AckdIb3SMcQ=="
},
"@nodelib/fs.scandir@2.1.5": {
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
···
"undici-types"
]
},
+
"abort-controller@3.0.0": {
+
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
+
"dependencies": [
+
"event-target-shim"
+
]
+
},
"ansi-regex@5.0.1": {
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
},
···
"arg@5.0.2": {
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg=="
},
+
"asynckit@0.4.0": {
+
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+
},
+
"atomic-sleep@1.0.0": {
+
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ=="
+
},
"autoprefixer@10.4.17_postcss@8.4.35": {
"integrity": "sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==",
"dependencies": [
···
"await-lock@2.2.2": {
"integrity": "sha512-aDczADvlvTGajTDjcjpJMqRkOF6Qdz3YbPZm/PyW6tKPkx2hlYBzxMhEywM/tU72HrVZjgl5VCdRuMlA7pZ8Gw=="
},
+
"axios@1.10.0": {
+
"integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
+
"dependencies": [
+
"follow-redirects",
+
"form-data",
+
"proxy-from-env"
+
]
+
},
"balanced-match@1.0.2": {
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
+
},
+
"base64-js@1.5.1": {
+
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
+
},
+
"big-integer@1.6.52": {
+
"integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg=="
},
"binary-extensions@2.3.0": {
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw=="
···
],
"bin": true
},
+
"buffer@6.0.3": {
+
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
+
"dependencies": [
+
"base64-js",
+
"ieee754"
+
]
+
},
+
"call-bind-apply-helpers@1.0.2": {
+
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+
"dependencies": [
+
"es-errors",
+
"function-bind"
+
]
+
},
"camelcase-css@2.0.1": {
"integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA=="
},
···
},
"caniuse-lite@1.0.30001717": {
"integrity": "sha512-auPpttCq6BDEG8ZAuHJIplGw6GODhjw+/11e7IjpnYCxZcW/ONgPs0KVBJ0d1bY3e2+7PRe5RCLyP+PfwVgkYw=="
+
},
+
"cborg@1.10.2": {
+
"integrity": "sha512-b3tFPA9pUr2zCUiCfRd2+wok2/LBSNUMKOuRRok+WlvvAgEt/PlbgPTsZUcwCOs53IJvLgTp0eotwtosE6njug==",
+
"bin": true
},
"chokidar@3.6.0": {
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
···
"colord@2.9.3": {
"integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw=="
},
+
"combined-stream@1.0.8": {
+
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+
"dependencies": [
+
"delayed-stream"
+
]
+
},
"commander@4.1.1": {
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="
},
···
"css-tree@2.2.1"
]
},
+
"delayed-stream@1.0.0": {
+
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
+
},
"didyoumean@1.2.2": {
"integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw=="
},
···
"domhandler"
]
},
+
"dunder-proto@1.0.1": {
+
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+
"dependencies": [
+
"call-bind-apply-helpers",
+
"es-errors",
+
"gopd"
+
]
+
},
"eastasianwidth@0.2.0": {
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
},
···
"entities@4.5.0": {
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw=="
},
+
"es-define-property@1.0.1": {
+
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="
+
},
+
"es-errors@1.3.0": {
+
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="
+
},
+
"es-object-atoms@1.1.1": {
+
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
+
"dependencies": [
+
"es-errors"
+
]
+
},
+
"es-set-tostringtag@2.1.0": {
+
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
+
"dependencies": [
+
"es-errors",
+
"get-intrinsic",
+
"has-tostringtag",
+
"hasown"
+
]
+
},
"esbuild-wasm@0.23.1": {
"integrity": "sha512-L3vn7ctvBrtScRfoB0zG1eOCiV4xYvpLYWfe6PDZuV+iDFDm4Mt3xeLIDllG8cDHQ8clUouK3XekulE+cxgkgw==",
"bin": true
···
"escalade@3.2.0": {
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="
},
+
"event-target-shim@5.0.1": {
+
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
+
},
+
"events@3.3.0": {
+
"integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="
+
},
"fast-glob@3.3.3": {
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
"dependencies": [
···
"micromatch"
]
},
+
"fast-redact@3.5.0": {
+
"integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A=="
+
},
"fastq@1.19.1": {
"integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==",
"dependencies": [
···
"to-regex-range"
]
},
+
"follow-redirects@1.15.9": {
+
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="
+
},
"foreground-child@3.3.1": {
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
"dependencies": [
···
"signal-exit"
]
},
+
"form-data@4.0.3": {
+
"integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==",
+
"dependencies": [
+
"asynckit",
+
"combined-stream",
+
"es-set-tostringtag",
+
"hasown",
+
"mime-types"
+
]
+
},
"fraction.js@4.3.7": {
"integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew=="
},
···
"function-bind@1.1.2": {
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="
},
+
"get-intrinsic@1.3.0": {
+
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+
"dependencies": [
+
"call-bind-apply-helpers",
+
"es-define-property",
+
"es-errors",
+
"es-object-atoms",
+
"function-bind",
+
"get-proto",
+
"gopd",
+
"has-symbols",
+
"hasown",
+
"math-intrinsics"
+
]
+
},
+
"get-proto@1.0.1": {
+
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+
"dependencies": [
+
"dunder-proto",
+
"es-object-atoms"
+
]
+
},
"glob-parent@5.1.2": {
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dependencies": [
···
],
"bin": true
},
+
"gopd@1.2.0": {
+
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="
+
},
"graphemer@1.4.0": {
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag=="
},
+
"has-symbols@1.1.0": {
+
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="
+
},
+
"has-tostringtag@1.0.2": {
+
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
+
"dependencies": [
+
"has-symbols"
+
]
+
},
"hasown@2.0.2": {
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"dependencies": [
"function-bind"
]
+
},
+
"ieee754@1.2.1": {
+
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
},
"ipaddr.js@2.2.0": {
"integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA=="
···
"preact@10.26.6"
]
},
+
"math-intrinsics@1.1.0": {
+
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="
+
},
"mdn-data@2.0.28": {
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g=="
},
···
"picomatch"
]
},
+
"mime-db@1.52.0": {
+
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
+
},
+
"mime-types@2.1.35": {
+
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+
"dependencies": [
+
"mime-db"
+
]
+
},
"minimatch@9.0.5": {
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dependencies": [
···
"object-hash@3.0.0": {
"integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="
},
+
"on-exit-leak-free@2.1.2": {
+
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA=="
+
},
+
"one-webcrypto@1.0.3": {
+
"integrity": "sha512-fu9ywBVBPx0gS9K0etIROTiCkvI5S1TDjFsYFb3rC1ewFxeOqsbzq7aIMBHsYfrTHBcGXJaONXXjTl8B01cW1Q=="
+
},
"package-json-from-dist@1.0.1": {
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="
},
···
"pify@2.3.0": {
"integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog=="
},
+
"pino-abstract-transport@1.2.0": {
+
"integrity": "sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==",
+
"dependencies": [
+
"readable-stream",
+
"split2"
+
]
+
},
+
"pino-std-serializers@6.2.2": {
+
"integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA=="
+
},
+
"pino@8.21.0": {
+
"integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==",
+
"dependencies": [
+
"atomic-sleep",
+
"fast-redact",
+
"on-exit-leak-free",
+
"pino-abstract-transport",
+
"pino-std-serializers",
+
"process-warning",
+
"quick-format-unescaped",
+
"real-require",
+
"safe-stable-stringify",
+
"sonic-boom",
+
"thread-stream"
+
],
+
"bin": true
+
},
"pirates@4.0.7": {
"integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA=="
},
···
"preact@10.26.7": {
"integrity": "sha512-43xS+QYc1X1IPbw03faSgY6I6OYWcLrJRv3hU0+qMOfh/XCHcP0MX2CVjNARYR2cC/guu975sta4OcjlczxD7g=="
},
+
"process-warning@3.0.0": {
+
"integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ=="
+
},
+
"process@0.11.10": {
+
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
+
},
+
"proxy-from-env@1.1.0": {
+
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+
},
"psl@1.15.0": {
"integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
"dependencies": [
···
"queue-microtask@1.2.3": {
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
+
"quick-format-unescaped@4.0.4": {
+
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="
+
},
"read-cache@1.0.0": {
"integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==",
"dependencies": [
"pify"
]
},
+
"readable-stream@4.7.0": {
+
"integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==",
+
"dependencies": [
+
"abort-controller",
+
"buffer",
+
"events",
+
"process",
+
"string_decoder"
+
]
+
},
"readdirp@3.6.0": {
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dependencies": [
"picomatch"
]
+
},
+
"real-require@0.2.0": {
+
"integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg=="
},
"resolve@1.22.10": {
"integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==",
···
"queue-microtask"
]
},
+
"safe-buffer@5.2.1": {
+
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
+
},
+
"safe-stable-stringify@2.5.0": {
+
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA=="
+
},
"shebang-command@2.0.0": {
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dependencies": [
···
},
"signal-exit@4.1.0": {
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="
+
},
+
"sonic-boom@3.8.1": {
+
"integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==",
+
"dependencies": [
+
"atomic-sleep"
+
]
},
"source-map-js@1.2.1": {
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
},
+
"split2@4.2.0": {
+
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="
+
},
"string-width@4.2.3": {
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dependencies": [
···
"eastasianwidth",
"emoji-regex@9.2.2",
"strip-ansi@7.1.0"
+
]
+
},
+
"string_decoder@1.3.0": {
+
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
+
"dependencies": [
+
"safe-buffer"
]
},
"strip-ansi@6.0.1": {
···
"any-promise"
]
},
+
"thread-stream@2.7.0": {
+
"integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==",
+
"dependencies": [
+
"real-require"
+
]
+
},
"tlds@1.258.0": {
"integrity": "sha512-XGhStWuOlBA5D8QnyN2xtgB2cUOdJ3ztisne1DYVWMcVH29qh8eQIpRmP3HnuJLdgyzG0HpdGzRMu1lm/Oictw==",
"bin": true
···
"jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",
"jsr:@knotbin/posthog-fresh@~0.1.3",
"npm:@atproto/api@~0.15.6",
+
"npm:@atproto/crypto@~0.4.4",
+
"npm:@did-plc/lib@^0.0.4",
"npm:@preact/signals@^2.0.4",
"npm:posthog-js@1.120.0",
"npm:preact@^10.26.6",
+1134
islands/DidPlcProgress.tsx
···
···
+
import { useState } from "preact/hooks";
+
import { Link } from "../components/Link.tsx";
+
+
interface PlcUpdateStep {
+
name: string;
+
status: "pending" | "in-progress" | "verifying" | "completed" | "error";
+
error?: string;
+
}
+
+
interface KeyJson {
+
publicKeyDid: string;
+
[key: string]: unknown;
+
}
+
+
// Content chunks for the description
+
const contentChunks = [
+
{
+
title: "Welcome to Key Management",
+
subtitle: "BOARDING PASS - SECTION A",
+
content: (
+
<>
+
<div class="passenger-info text-slate-600 dark:text-slate-300 font-mono text-sm mb-4">
+
GATE: KEY-01 โ€ข SEAT: DID-1A
+
</div>
+
<p class="text-slate-700 dark:text-slate-300 mb-4">
+
This tool helps you add a new rotation key to your{" "}
+
<Link
+
href="https://web.plc.directory/"
+
isExternal
+
class="text-blue-600 dark:text-blue-400"
+
>
+
PLC (Public Ledger of Credentials)
+
</Link>
+
. Having control of a rotation key gives you sovereignty over your DID
+
(Decentralized Identifier).
+
</p>
+
</>
+
),
+
},
+
{
+
title: "Key Benefits",
+
subtitle: "BOARDING PASS - SECTION B",
+
content: (
+
<>
+
<div class="passenger-info text-slate-600 dark:text-slate-300 font-mono text-sm mb-4">
+
GATE: KEY-02 โ€ข SEAT: DID-1B
+
</div>
+
<div class="space-y-4">
+
<div class="p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700">
+
<h4 class="font-mono font-bold text-amber-500 dark:text-amber-400 mb-2">
+
PROVIDER MOBILITY โœˆ๏ธ
+
</h4>
+
<p class="text-slate-700 dark:text-slate-300">
+
Change your PDS without losing your identity, protecting you if
+
your provider becomes hostile.
+
</p>
+
</div>
+
<div class="p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700">
+
<h4 class="font-mono font-bold text-amber-500 dark:text-amber-400 mb-2">
+
IDENTITY CONTROL โœจ
+
</h4>
+
<p class="text-slate-700 dark:text-slate-300">
+
Modify your DID document independently of your provider.
+
</p>
+
</div>
+
<div class="p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700">
+
<p class="text-slate-700 dark:text-slate-300">
+
๐Ÿ’ก It's good practice to have a rotation key so you can move to a
+
different provider if you need to.
+
</p>
+
</div>
+
</div>
+
</>
+
),
+
},
+
{
+
title: "โš ๏ธ CRITICAL SECURITY WARNING",
+
subtitle: "BOARDING PASS - SECTION C",
+
content: (
+
<>
+
<div class="passenger-info text-slate-600 dark:text-slate-300 font-mono text-sm mb-4">
+
GATE: KEY-03 โ€ข SEAT: DID-1C
+
</div>
+
<div class="p-4 bg-red-50 dark:bg-red-900 rounded-lg border-2 border-red-500 dark:border-red-700 mb-4">
+
<div class="flex items-center mb-3">
+
<span class="text-2xl mr-2">โš ๏ธ</span>
+
<h4 class="font-mono font-bold text-red-700 dark:text-red-400 text-lg">
+
NON-REVOCABLE KEY WARNING
+
</h4>
+
</div>
+
<div class="space-y-3 text-red-700 dark:text-red-300">
+
<p class="font-bold">
+
This rotation key CANNOT BE DISABLED OR DELETED once added:
+
</p>
+
<ul class="list-disc pl-5 space-y-2">
+
<li>
+
If compromised, the attacker can take complete control of your
+
account and identity
+
</li>
+
<li>
+
Malicious actors with this key have COMPLETE CONTROL of your
+
account and identity
+
</li>
+
<li>
+
Store securely, like a password (e.g. <strong>DO NOT</strong>
+
{" "}
+
keep it in Notes or any easily accessible app on an unlocked
+
device).
+
</li>
+
</ul>
+
</div>
+
</div>
+
<div class="p-3 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700">
+
<p class="text-slate-700 dark:text-slate-300">
+
๐Ÿ’ก We recommend adding a custom rotation key but recommend{" "}
+
<strong class="italic">against</strong>{" "}
+
having more than one custom rotation key, as more than one increases
+
risk.
+
</p>
+
</div>
+
</>
+
),
+
},
+
{
+
title: "Technical Overview",
+
subtitle: "BOARDING PASS - SECTION C",
+
content: (
+
<>
+
<div class="passenger-info text-slate-600 dark:text-slate-300 font-mono text-sm mb-4">
+
GATE: KEY-03 โ€ข SEAT: DID-1C
+
</div>
+
<div class="p-4 bg-white dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700">
+
<div class="flex items-center mb-3">
+
<span class="text-lg mr-2">๐Ÿ“</span>
+
<h4 class="font-mono font-bold text-amber-500 dark:text-amber-400">
+
TECHNICAL DETAILS
+
</h4>
+
</div>
+
<p class="text-slate-700 dark:text-slate-300">
+
The rotation key is a did:key that will be added to your PLC
+
document's rotationKeys array. This process uses the AT Protocol's
+
PLC operations to update your DID document.
+
<Link
+
href="https://web.plc.directory/"
+
class="block ml-1 text-blue-600 dark:text-blue-400"
+
isExternal
+
>
+
Learn more about did:plc
+
</Link>
+
</p>
+
</div>
+
</>
+
),
+
},
+
];
+
+
export default function PlcUpdateProgress() {
+
const [hasStarted, setHasStarted] = useState(false);
+
const [currentChunkIndex, setCurrentChunkIndex] = useState(0);
+
const [steps, setSteps] = useState<PlcUpdateStep[]>([
+
{ name: "Generate Rotation Key", status: "pending" },
+
{ name: "Start PLC update", status: "pending" },
+
{ name: "Complete PLC update", status: "pending" },
+
]);
+
const [generatedKey, setGeneratedKey] = useState<string>("");
+
const [keyJson, setKeyJson] = useState<KeyJson | null>(null);
+
const [emailToken, setEmailToken] = useState<string>("");
+
const [hasDownloadedKey, setHasDownloadedKey] = useState(false);
+
const [downloadedKeyId, setDownloadedKeyId] = useState<string | null>(null);
+
+
const updateStepStatus = (
+
index: number,
+
status: PlcUpdateStep["status"],
+
error?: string,
+
) => {
+
console.log(
+
`Updating step ${index} to ${status}${
+
error ? ` with error: ${error}` : ""
+
}`,
+
);
+
setSteps((prevSteps) =>
+
prevSteps.map((step, i) =>
+
i === index
+
? { ...step, status, error }
+
: i > index
+
? { ...step, status: "pending", error: undefined }
+
: step
+
)
+
);
+
};
+
+
const handleStart = () => {
+
setHasStarted(true);
+
// Automatically start the first step
+
setTimeout(() => {
+
handleGenerateKey();
+
}, 100);
+
};
+
+
const getStepDisplayName = (step: PlcUpdateStep, index: number) => {
+
if (step.status === "completed") {
+
switch (index) {
+
case 0:
+
return "Rotation Key Generated";
+
case 1:
+
return "PLC Operation Requested";
+
case 2:
+
return "PLC Update Completed";
+
}
+
}
+
+
if (step.status === "in-progress") {
+
switch (index) {
+
case 0:
+
return "Generating Rotation Key...";
+
case 1:
+
return "Requesting PLC Operation Token...";
+
case 2:
+
return step.name ===
+
"Enter the code sent to your email to complete PLC update"
+
? step.name
+
: "Completing PLC Update...";
+
}
+
}
+
+
if (step.status === "verifying") {
+
switch (index) {
+
case 0:
+
return "Verifying Rotation Key Generation...";
+
case 1:
+
return "Verifying PLC Operation Token Request...";
+
case 2:
+
return "Verifying PLC Update Completion...";
+
}
+
}
+
+
return step.name;
+
};
+
+
const handleStartPlcUpdate = async (keyToUse?: string) => {
+
const key = keyToUse || generatedKey;
+
+
// Debug logging
+
console.log("=== PLC Update Debug ===");
+
console.log("Current state:", {
+
keyToUse,
+
generatedKey,
+
key,
+
hasKeyJson: !!keyJson,
+
keyJsonId: keyJson?.publicKeyDid,
+
hasDownloadedKey,
+
downloadedKeyId,
+
steps: steps.map((s) => ({ name: s.name, status: s.status })),
+
});
+
+
if (!key) {
+
console.log("No key generated yet");
+
updateStepStatus(1, "error", "No key generated yet");
+
return;
+
}
+
+
if (!keyJson || keyJson.publicKeyDid !== key) {
+
console.log("Key mismatch or missing:", {
+
hasKeyJson: !!keyJson,
+
keyJsonId: keyJson?.publicKeyDid,
+
expectedKey: key,
+
});
+
updateStepStatus(
+
1,
+
"error",
+
"Please ensure you have the correct key loaded",
+
);
+
return;
+
}
+
+
updateStepStatus(1, "in-progress");
+
try {
+
// First request the token
+
console.log("Requesting PLC token...");
+
const tokenRes = await fetch("/api/plc/token", {
+
method: "GET",
+
});
+
const tokenText = await tokenRes.text();
+
console.log("Token response:", tokenText);
+
+
if (!tokenRes.ok) {
+
try {
+
const json = JSON.parse(tokenText);
+
throw new Error(json.message || "Failed to request PLC token");
+
} catch {
+
throw new Error(tokenText || "Failed to request PLC token");
+
}
+
}
+
+
let data;
+
try {
+
data = JSON.parse(tokenText);
+
if (!data.success) {
+
throw new Error(data.message || "Failed to request token");
+
}
+
} catch {
+
throw new Error("Invalid response from server");
+
}
+
+
console.log("Token request successful, updating UI...");
+
// Update step name to prompt for token
+
setSteps((prevSteps) =>
+
prevSteps.map((step, i) =>
+
i === 1
+
? {
+
...step,
+
name: "Enter the code sent to your email to complete PLC update",
+
status: "in-progress",
+
}
+
: step
+
)
+
);
+
} catch (error) {
+
console.error("Token request failed:", error);
+
updateStepStatus(
+
1,
+
"error",
+
error instanceof Error ? error.message : String(error),
+
);
+
}
+
};
+
+
const handleTokenSubmit = async () => {
+
console.log("=== Token Submit Debug ===");
+
console.log("Current state:", {
+
emailToken,
+
generatedKey,
+
keyJsonId: keyJson?.publicKeyDid,
+
steps: steps.map((s) => ({ name: s.name, status: s.status })),
+
});
+
+
if (!emailToken) {
+
console.log("No token provided");
+
updateStepStatus(1, "error", "Please enter the email token");
+
return;
+
}
+
+
if (!keyJson || !keyJson.publicKeyDid) {
+
console.log("Missing key data");
+
updateStepStatus(1, "error", "Key data is missing, please try again");
+
return;
+
}
+
+
// Prevent duplicate submissions
+
if (steps[1].status === "completed" || steps[2].status === "completed") {
+
console.log("Update already completed, preventing duplicate submission");
+
return;
+
}
+
+
updateStepStatus(1, "completed");
+
try {
+
updateStepStatus(2, "in-progress");
+
console.log("Submitting update request with token...");
+
// Send the update request with both key and token
+
const res = await fetch("/api/plc/update", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
body: JSON.stringify({
+
key: keyJson.publicKeyDid,
+
token: emailToken,
+
}),
+
});
+
const text = await res.text();
+
console.log("Update response:", text);
+
+
let data;
+
try {
+
data = JSON.parse(text);
+
} catch {
+
throw new Error("Invalid response from server");
+
}
+
+
// Check for error responses
+
if (!res.ok || !data.success) {
+
const errorMessage = data.message || "Failed to complete PLC update";
+
console.error("Update failed:", errorMessage);
+
throw new Error(errorMessage);
+
}
+
+
// Only proceed if we have a successful response
+
console.log("Update completed successfully!");
+
+
// Add a delay before marking steps as completed for better UX
+
updateStepStatus(2, "verifying");
+
+
const verifyRes = await fetch("/api/plc/verify", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
body: JSON.stringify({
+
key: keyJson.publicKeyDid,
+
}),
+
});
+
+
const verifyText = await verifyRes.text();
+
console.log("Verification response:", verifyText);
+
+
let verifyData;
+
try {
+
verifyData = JSON.parse(verifyText);
+
} catch {
+
throw new Error("Invalid verification response from server");
+
}
+
+
if (!verifyRes.ok || !verifyData.success) {
+
const errorMessage = verifyData.message ||
+
"Failed to verify PLC update";
+
console.error("Verification failed:", errorMessage);
+
throw new Error(errorMessage);
+
}
+
+
console.log("Verification successful, marking steps as completed");
+
updateStepStatus(2, "completed");
+
} catch (error) {
+
console.error("Update failed:", error);
+
// Reset the steps to error state
+
updateStepStatus(
+
1,
+
"error",
+
error instanceof Error ? error.message : String(error),
+
);
+
updateStepStatus(2, "pending"); // Reset the final step
+
+
// If token is invalid, we should clear it so user can try again
+
if (
+
error instanceof Error &&
+
error.message.toLowerCase().includes("token is invalid")
+
) {
+
setEmailToken("");
+
}
+
}
+
};
+
+
const handleDownload = () => {
+
console.log("=== Download Debug ===");
+
console.log("Download started with:", {
+
hasKeyJson: !!keyJson,
+
keyJsonId: keyJson?.publicKeyDid,
+
});
+
+
if (!keyJson) {
+
console.error("No key JSON to download");
+
return;
+
}
+
+
try {
+
const jsonString = JSON.stringify(keyJson, null, 2);
+
const blob = new Blob([jsonString], {
+
type: "application/json",
+
});
+
const url = URL.createObjectURL(blob);
+
const a = document.createElement("a");
+
a.href = url;
+
a.download = `plc-key-${keyJson.publicKeyDid || "unknown"}.json`;
+
a.style.display = "none";
+
document.body.appendChild(a);
+
a.click();
+
document.body.removeChild(a);
+
URL.revokeObjectURL(url);
+
+
console.log("Download completed, proceeding to next step...");
+
setHasDownloadedKey(true);
+
setDownloadedKeyId(keyJson.publicKeyDid);
+
+
// Automatically proceed to the next step after successful download
+
setTimeout(() => {
+
console.log("Auto-proceeding with key:", keyJson.publicKeyDid);
+
handleStartPlcUpdate(keyJson.publicKeyDid);
+
}, 1000);
+
} catch (error) {
+
console.error("Download failed:", error);
+
}
+
};
+
+
const handleGenerateKey = async () => {
+
console.log("=== Generate Key Debug ===");
+
updateStepStatus(0, "in-progress");
+
setKeyJson(null);
+
setGeneratedKey("");
+
setHasDownloadedKey(false);
+
setDownloadedKeyId(null);
+
+
try {
+
console.log("Requesting new key...");
+
const res = await fetch("/api/plc/keys");
+
const text = await res.text();
+
console.log("Key generation response:", text);
+
+
if (!res.ok) {
+
try {
+
const json = JSON.parse(text);
+
throw new Error(json.message || "Failed to generate key");
+
} catch {
+
throw new Error(text || "Failed to generate key");
+
}
+
}
+
+
let data;
+
try {
+
data = JSON.parse(text);
+
} catch {
+
throw new Error("Invalid response from /api/plc/keys");
+
}
+
+
if (!data.publicKeyDid || !data.privateKeyHex) {
+
throw new Error("Key generation failed: missing key data");
+
}
+
+
console.log("Key generated successfully:", {
+
keyId: data.publicKeyDid,
+
});
+
+
setGeneratedKey(data.publicKeyDid);
+
setKeyJson(data);
+
updateStepStatus(0, "completed");
+
} catch (error) {
+
console.error("Key generation failed:", error);
+
updateStepStatus(
+
0,
+
"error",
+
error instanceof Error ? error.message : String(error),
+
);
+
}
+
};
+
+
const getStepIcon = (status: PlcUpdateStep["status"]) => {
+
switch (status) {
+
case "pending":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-gray-300 dark:border-gray-600 flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600" />
+
</div>
+
);
+
case "in-progress":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-blue-500 border-t-transparent animate-spin flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-blue-500" />
+
</div>
+
);
+
case "verifying":
+
return (
+
<div class="w-8 h-8 rounded-full border-2 border-yellow-500 border-t-transparent animate-spin flex items-center justify-center">
+
<div class="w-3 h-3 rounded-full bg-yellow-500" />
+
</div>
+
);
+
case "completed":
+
return (
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center">
+
<svg
+
class="w-5 h-5 text-white"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M5 13l4 4L19 7"
+
/>
+
</svg>
+
</div>
+
);
+
case "error":
+
return (
+
<div class="w-8 h-8 rounded-full bg-red-500 flex items-center justify-center">
+
<svg
+
class="w-5 h-5 text-white"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M6 18L18 6M6 6l12 12"
+
/>
+
</svg>
+
</div>
+
);
+
}
+
};
+
+
const getStepClasses = (status: PlcUpdateStep["status"]) => {
+
const baseClasses =
+
"flex items-center space-x-3 p-4 rounded-lg transition-colors duration-200";
+
switch (status) {
+
case "pending":
+
return `${baseClasses} bg-gray-50 dark:bg-gray-800`;
+
case "in-progress":
+
return `${baseClasses} bg-blue-50 dark:bg-blue-900`;
+
case "verifying":
+
return `${baseClasses} bg-yellow-50 dark:bg-yellow-900`;
+
case "completed":
+
return `${baseClasses} bg-green-50 dark:bg-green-900`;
+
case "error":
+
return `${baseClasses} bg-red-50 dark:bg-red-900`;
+
}
+
};
+
+
const requestNewToken = async () => {
+
try {
+
console.log("Requesting new token...");
+
const res = await fetch("/api/plc/token", {
+
method: "GET",
+
});
+
const text = await res.text();
+
console.log("Token request response:", text);
+
+
if (!res.ok) {
+
throw new Error(text || "Failed to request new token");
+
}
+
+
let data;
+
try {
+
data = JSON.parse(text);
+
if (!data.success) {
+
throw new Error(data.message || "Failed to request token");
+
}
+
} catch {
+
throw new Error("Invalid response from server");
+
}
+
+
// Clear any existing error and token
+
setEmailToken("");
+
updateStepStatus(1, "in-progress");
+
updateStepStatus(2, "pending");
+
} catch (error) {
+
console.error("Failed to request new token:", error);
+
updateStepStatus(
+
1,
+
"error",
+
error instanceof Error ? error.message : String(error),
+
);
+
}
+
};
+
+
if (!hasStarted) {
+
return (
+
<div class="space-y-6">
+
<div class="ticket bg-white dark:bg-slate-800 p-6 relative">
+
<div class="boarding-label text-amber-500 dark:text-amber-400 font-mono font-bold tracking-wider text-sm mb-2">
+
{contentChunks[currentChunkIndex].subtitle}
+
</div>
+
+
<div class="flex justify-between items-start mb-4">
+
<h3 class="text-2xl font-mono text-slate-800 dark:text-slate-200">
+
{contentChunks[currentChunkIndex].title}
+
</h3>
+
</div>
+
+
{/* Main Description */}
+
<div class="mb-6">{contentChunks[currentChunkIndex].content}</div>
+
+
{/* Navigation */}
+
<div class="mt-8 border-t border-dashed border-slate-200 dark:border-slate-700 pt-4">
+
<div class="flex justify-between items-center">
+
<button
+
type="button"
+
onClick={() =>
+
setCurrentChunkIndex((prev) => Math.max(0, prev - 1))}
+
class={`px-4 py-2 font-mono text-slate-600 dark:text-slate-400 hover:text-slate-800 dark:hover:text-slate-200 transition-colors duration-200 flex items-center space-x-2 ${
+
currentChunkIndex === 0 ? "invisible" : ""
+
}`}
+
>
+
<svg
+
class="w-5 h-5 rotate-180"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M9 5l7 7-7 7"
+
/>
+
</svg>
+
<span>Previous Gate</span>
+
</button>
+
+
{currentChunkIndex === contentChunks.length - 1
+
? (
+
<button
+
type="button"
+
onClick={handleStart}
+
class="px-6 py-2 bg-amber-500 hover:bg-amber-600 text-white font-mono rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<span>Begin Key Generation</span>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M9 5l7 7-7 7"
+
/>
+
</svg>
+
</button>
+
)
+
: (
+
<button
+
type="button"
+
onClick={() =>
+
setCurrentChunkIndex((prev) =>
+
Math.min(contentChunks.length - 1, prev + 1)
+
)}
+
class="px-4 py-2 font-mono text-slate-600 dark:text-slate-400 hover:text-slate-800 dark:hover:text-slate-200 transition-colors duration-200 flex items-center space-x-2"
+
>
+
<span>Next Gate</span>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M9 5l7 7-7 7"
+
/>
+
</svg>
+
</button>
+
)}
+
</div>
+
+
{/* Progress Dots */}
+
<div class="flex justify-center space-x-3 mt-4">
+
{contentChunks.map((_, index) => (
+
<div
+
key={index}
+
class={`h-1.5 w-8 rounded-full transition-colors duration-200 ${
+
index === currentChunkIndex
+
? "bg-amber-500"
+
: "bg-slate-200 dark:bg-slate-700"
+
}`}
+
/>
+
))}
+
</div>
+
</div>
+
</div>
+
</div>
+
);
+
}
+
+
return (
+
<div class="space-y-8">
+
{/* Progress Steps */}
+
<div class="space-y-4">
+
<div class="flex items-center justify-between">
+
<h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">
+
Key Generation Progress
+
</h3>
+
{/* Add a help tooltip */}
+
<div class="relative group">
+
<button class="text-gray-400 hover:text-gray-500" type="button">
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+
/>
+
</svg>
+
</button>
+
<div class="absolute right-0 w-64 p-2 mt-2 space-y-1 text-sm bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 hidden group-hover:block z-10">
+
<p class="text-gray-600 dark:text-gray-400">
+
Follow these steps to securely add a new rotation key to your
+
PLC record. Each step requires completion before proceeding.
+
</p>
+
</div>
+
</div>
+
</div>
+
+
{/* Steps with enhanced visual hierarchy */}
+
{steps.map((step, index) => (
+
<div
+
key={step.name}
+
class={`${getStepClasses(step.status)} ${
+
step.status === "in-progress"
+
? "ring-2 ring-blue-500 ring-opacity-50"
+
: ""
+
}`}
+
>
+
<div class="flex-shrink-0">{getStepIcon(step.status)}</div>
+
<div class="flex-1 min-w-0">
+
<div class="flex items-center justify-between">
+
<p
+
class={`font-medium ${
+
step.status === "error"
+
? "text-red-900 dark:text-red-200"
+
: step.status === "completed"
+
? "text-green-900 dark:text-green-200"
+
: step.status === "in-progress"
+
? "text-blue-900 dark:text-blue-200"
+
: "text-gray-900 dark:text-gray-200"
+
}`}
+
>
+
{getStepDisplayName(step, index)}
+
</p>
+
{/* Add step number */}
+
<span class="text-sm text-gray-500 dark:text-gray-400">
+
Step {index + 1} of {steps.length}
+
</span>
+
</div>
+
+
{step.error && (
+
<div class="mt-2 p-2 bg-red-50 dark:bg-red-900/50 rounded-md">
+
<p class="text-sm text-red-600 dark:text-red-400 flex items-center">
+
<svg
+
class="w-4 h-4 mr-1"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+
/>
+
</svg>
+
{(() => {
+
try {
+
const err = JSON.parse(step.error);
+
return err.message || step.error;
+
} catch {
+
return step.error;
+
}
+
})()}
+
</p>
+
</div>
+
)}
+
+
{/* Key Download Warning */}
+
{index === 0 &&
+
step.status === "completed" &&
+
!hasDownloadedKey && (
+
<div class="mt-4 space-y-4">
+
<div class="bg-yellow-50 dark:bg-yellow-900/50 p-4 rounded-lg border border-yellow-200 dark:border-yellow-800">
+
<div class="flex items-start">
+
<div class="flex-shrink-0">
+
<svg
+
class="h-5 w-5 text-yellow-400"
+
viewBox="0 0 20 20"
+
fill="currentColor"
+
>
+
<path
+
fill-rule="evenodd"
+
d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z"
+
clip-rule="evenodd"
+
/>
+
</svg>
+
</div>
+
<div class="ml-3">
+
<h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-200">
+
Critical Security Step
+
</h3>
+
<div class="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
+
<p class="mb-2">
+
Your rotation key grants control over your identity:
+
</p>
+
<ul class="list-disc pl-5 space-y-2">
+
<li>
+
<strong>Store Securely:</strong>{" "}
+
Use a password manager
+
</li>
+
<li>
+
<strong>Keep Private:</strong>{" "}
+
Never share with anyone
+
</li>
+
<li>
+
<strong>Backup:</strong> Keep a secure backup copy
+
</li>
+
<li>
+
<strong>Required:</strong>{" "}
+
Needed for future DID modifications
+
</li>
+
</ul>
+
</div>
+
</div>
+
</div>
+
</div>
+
+
<div class="flex items-center justify-between">
+
<button
+
type="button"
+
onClick={handleDownload}
+
class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
+
/>
+
</svg>
+
<span>Download Key</span>
+
</button>
+
+
<div class="flex items-center text-sm text-red-600 dark:text-red-400">
+
<svg
+
class="w-4 h-4 mr-1"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
+
/>
+
</svg>
+
Download required to proceed
+
</div>
+
</div>
+
</div>
+
)}
+
+
{/* Email Code Input */}
+
{index === 1 &&
+
(step.status === "in-progress" ||
+
step.status === "verifying") &&
+
step.name ===
+
"Enter the code sent to your email to complete PLC update" &&
+
(
+
<div class="mt-4 space-y-4">
+
<div class="bg-blue-50 dark:bg-blue-900/50 p-4 rounded-lg">
+
<p class="text-sm text-blue-800 dark:text-blue-200 mb-3">
+
Check your email for the verification code to complete
+
the PLC update:
+
</p>
+
<div class="flex space-x-2">
+
<div class="flex-1 relative">
+
<input
+
type="text"
+
value={emailToken}
+
onChange={(e) =>
+
setEmailToken(e.currentTarget.value)}
+
placeholder="Enter verification code"
+
class="w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"
+
/>
+
</div>
+
<button
+
type="button"
+
onClick={handleTokenSubmit}
+
disabled={!emailToken || step.status === "verifying"}
+
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2"
+
>
+
<span>
+
{step.status === "verifying"
+
? "Verifying..."
+
: "Verify"}
+
</span>
+
<svg
+
class="w-4 h-4"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
+
/>
+
</svg>
+
</button>
+
</div>
+
{step.error && (
+
<div class="mt-2 p-2 bg-red-50 dark:bg-red-900/50 rounded-md">
+
<p class="text-sm text-red-600 dark:text-red-400 flex items-center">
+
<svg
+
class="w-4 h-4 mr-1"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
+
/>
+
</svg>
+
{step.error}
+
</p>
+
{step.error
+
.toLowerCase()
+
.includes("token is invalid") && (
+
<div class="mt-2">
+
<p class="text-sm text-red-500 dark:text-red-300 mb-2">
+
The verification code may have expired. Request
+
a new code to try again.
+
</p>
+
<button
+
type="button"
+
onClick={requestNewToken}
+
class="text-sm px-3 py-1 bg-red-100 hover:bg-red-200 dark:bg-red-800 dark:hover:bg-red-700 text-red-700 dark:text-red-200 rounded-md transition-colors duration-200 flex items-center space-x-1"
+
>
+
<svg
+
class="w-4 h-4"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
+
/>
+
</svg>
+
<span>Request New Code</span>
+
</button>
+
</div>
+
)}
+
</div>
+
)}
+
</div>
+
</div>
+
)}
+
</div>
+
</div>
+
))}
+
</div>
+
+
{/* Success Message */}
+
{steps[2].status === "completed" && (
+
<div class="p-4 bg-green-50 dark:bg-green-900/50 rounded-lg border-2 border-green-200 dark:border-green-800">
+
<div class="flex items-center space-x-3 mb-4">
+
<svg
+
class="w-6 h-6 text-green-500"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
+
/>
+
</svg>
+
<h4 class="text-lg font-medium text-green-800 dark:text-green-200">
+
PLC Update Successful!
+
</h4>
+
</div>
+
<p class="text-sm text-green-700 dark:text-green-300 mb-4">
+
Your rotation key has been successfully added to your PLC record.
+
You can now use this key for future DID modifications.
+
</p>
+
<div class="flex space-x-4">
+
<button
+
type="button"
+
onClick={async () => {
+
try {
+
const response = await fetch("/api/logout", {
+
method: "POST",
+
credentials: "include",
+
});
+
if (!response.ok) {
+
throw new Error("Logout failed");
+
}
+
globalThis.location.href = "/";
+
} catch (error) {
+
console.error("Failed to logout:", error);
+
}
+
}}
+
class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
+
/>
+
</svg>
+
<span>Sign Out</span>
+
</button>
+
<a
+
href="https://ko-fi.com/knotbin"
+
target="_blank"
+
class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200 flex items-center space-x-2"
+
>
+
<svg
+
class="w-5 h-5"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
+
/>
+
</svg>
+
<span>Support Us</span>
+
</a>
+
</div>
+
</div>
+
)}
+
</div>
+
);
+
}
+45 -34
islands/Header.tsx
···
/>
<div className="flex items-center gap-3">
{/* Departures (Migration) */}
<Button
href="/migrate"
···
{/* Check-in (Login/Profile) */}
<div className="relative">
-
{user?.did ? (
-
<div className="relative">
<Button
color="amber"
-
icon="/icons/ticket_bold.svg"
iconAlt="Check-in"
-
label="CHECKED IN"
-
onClick={() => setShowDropdown(!showDropdown)}
/>
-
{showDropdown && (
-
<div className="absolute right-0 mt-2 w-64 bg-white dark:bg-slate-800 rounded-lg shadow-lg p-4 border border-slate-200 dark:border-slate-700">
-
<div className="text-sm font-mono mb-2 pb-2 border-b border-slate-900/10">
-
<div title={user.handle || "Anonymous"}>
-
{truncateText(user.handle || "Anonymous", 20)}
-
</div>
-
<div className="text-xs opacity-75" title={user.did}>
-
{truncateText(user.did, 25)}
-
</div>
-
</div>
-
<button
-
type="button"
-
onClick={handleLogout}
-
className="text-sm font-mono text-slate-900 hover:text-slate-700 w-full text-left transition-colors"
-
>
-
Sign Out
-
</button>
-
</div>
-
)}
-
</div>
-
) : (
-
<Button
-
href="/login"
-
color="amber"
-
icon="/icons/ticket_bold.svg"
-
iconAlt="Check-in"
-
label="CHECK-IN"
-
/>
-
)}
</div>
</div>
</div>
···
/>
<div className="flex items-center gap-3">
+
{/* Ticket booth (did:plc update) */}
+
<Button
+
href="/ticket-booth"
+
color="amber"
+
icon="/icons/ticket_bold.svg"
+
iconAlt="Ticket"
+
label="TICKET BOOTH"
+
/>
+
{/* Departures (Migration) */}
<Button
href="/migrate"
···
{/* Check-in (Login/Profile) */}
<div className="relative">
+
{user?.did
+
? (
+
<div className="relative">
+
<Button
+
color="amber"
+
icon="/icons/account.svg"
+
iconAlt="Check-in"
+
label="CHECKED IN"
+
onClick={() => setShowDropdown(!showDropdown)}
+
/>
+
{showDropdown && (
+
<div className="absolute right-0 mt-2 w-64 bg-white dark:bg-slate-800 rounded-lg shadow-lg p-4 border border-slate-200 dark:border-slate-700">
+
<div className="text-sm font-mono mb-2 pb-2 border-b border-slate-900/10">
+
<div title={user.handle || "Anonymous"}>
+
{truncateText(user.handle || "Anonymous", 20)}
+
</div>
+
<div className="text-xs opacity-75" title={user.did}>
+
{truncateText(user.did, 25)}
+
</div>
+
</div>
+
<button
+
type="button"
+
onClick={handleLogout}
+
className="text-sm font-mono text-slate-900 hover:text-slate-700 w-full text-left transition-colors"
+
>
+
Sign Out
+
</button>
+
</div>
+
)}
+
</div>
+
)
+
: (
<Button
+
href="/login"
color="amber"
+
icon="/icons/account.svg"
iconAlt="Check-in"
+
label="CHECK-IN"
/>
+
)}
</div>
</div>
</div>
+37
islands/LoginButton.tsx
···
···
+
import { useEffect, useState } from "preact/hooks";
+
import { Button } from "../components/Button.tsx";
+
+
export default function LoginButton() {
+
const [isMobile, setIsMobile] = useState(true); // Default to mobile for SSR
+
+
useEffect(() => {
+
const checkMobile = () => {
+
setIsMobile(globalThis.innerWidth < 640);
+
};
+
+
// Check on mount
+
checkMobile();
+
+
// Listen for resize events
+
globalThis.addEventListener("resize", checkMobile);
+
return () => globalThis.removeEventListener("resize", checkMobile);
+
}, []);
+
+
return (
+
<div class="mt-6 sm:mt-8 text-center w-fit mx-auto">
+
<Button
+
href={isMobile ? undefined : "/login"}
+
color="blue"
+
label={isMobile ? "MOBILE NOT SUPPORTED" : "GET STARTED"}
+
className={isMobile
+
? "opacity-50 cursor-not-allowed"
+
: "opacity-100 cursor-pointer"}
+
onClick={(e: MouseEvent) => {
+
if (isMobile) {
+
e.preventDefault();
+
}
+
}}
+
/>
+
</div>
+
);
+
}
+17 -15
islands/LoginSelector.tsx
···
-
import { useState } from "preact/hooks"
-
import HandleInput from "./HandleInput.tsx"
-
import CredLogin from "./CredLogin.tsx"
/**
* The login method selector for OAuth or Credential.
···
* @component
*/
export default function LoginMethodSelector() {
-
const [loginMethod, setLoginMethod] = useState<'oauth' | 'password'>('password')
return (
<div className="flex flex-col gap-8">
···
<div className="flex gap-4 mb-6">
<button
type="button"
-
onClick={() => setLoginMethod('oauth')}
className={`flex-1 px-4 py-2 rounded-md transition-colors ${
-
loginMethod === 'oauth'
-
? 'bg-blue-500 text-white'
-
: 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
}`}
>
OAuth
</button>
<button
type="button"
-
onClick={() => setLoginMethod('password')}
className={`flex-1 px-4 py-2 rounded-md transition-colors ${
-
loginMethod === 'password'
-
? 'bg-blue-500 text-white'
-
: 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
}`}
>
Credential
</button>
</div>
-
{loginMethod === 'oauth' && (
<div className="mb-4 p-3 bg-amber-50 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-md text-sm">
Note: OAuth login cannot be used for migrations.
</div>
)}
-
{loginMethod === 'oauth' ? <HandleInput /> : <CredLogin />}
<div className="mt-4 text-center">
<a
···
</div>
</div>
</div>
-
)
}
···
+
import { useState } from "preact/hooks";
+
import HandleInput from "./HandleInput.tsx";
+
import CredLogin from "./CredLogin.tsx";
/**
* The login method selector for OAuth or Credential.
···
* @component
*/
export default function LoginMethodSelector() {
+
const [loginMethod, setLoginMethod] = useState<"oauth" | "password">(
+
"password",
+
);
return (
<div className="flex flex-col gap-8">
···
<div className="flex gap-4 mb-6">
<button
type="button"
+
onClick={() => setLoginMethod("oauth")}
className={`flex-1 px-4 py-2 rounded-md transition-colors ${
+
loginMethod === "oauth"
+
? "bg-blue-500 text-white"
+
: "bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300"
}`}
>
OAuth
</button>
<button
type="button"
+
onClick={() => setLoginMethod("password")}
className={`flex-1 px-4 py-2 rounded-md transition-colors ${
+
loginMethod === "password"
+
? "bg-blue-500 text-white"
+
: "bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300"
}`}
>
Credential
</button>
</div>
+
{loginMethod === "oauth" && (
<div className="mb-4 p-3 bg-amber-50 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-md text-sm">
Note: OAuth login cannot be used for migrations.
</div>
)}
+
{loginMethod === "oauth" ? <HandleInput /> : <CredLogin />}
<div className="mt-4 text-center">
<a
···
</div>
</div>
</div>
+
);
}
+122 -545
islands/MigrationProgress.tsx
···
import { useEffect, useState } from "preact/hooks";
/**
* The migration progress props.
···
}
/**
-
* The migration step.
-
* @type {MigrationStep}
-
*/
-
interface MigrationStep {
-
name: string;
-
status: "pending" | "in-progress" | "verifying" | "completed" | "error";
-
error?: string;
-
}
-
-
/**
* The migration progress component.
* @param props - The migration progress props
* @returns The migration progress component
* @component
*/
export default function MigrationProgress(props: MigrationProgressProps) {
-
const [token, setToken] = useState("");
-
-
const [steps, setSteps] = useState<MigrationStep[]>([
-
{ name: "Create Account", status: "pending" },
-
{ name: "Migrate Data", status: "pending" },
-
{ name: "Migrate Identity", status: "pending" },
-
{ name: "Finalize Migration", status: "pending" },
-
]);
-
const updateStepStatus = (
-
index: number,
-
status: MigrationStep["status"],
-
error?: string,
-
) => {
-
console.log(
-
`Updating step ${index} to ${status}${
-
error ? ` with error: ${error}` : ""
-
}`,
-
);
-
setSteps((prevSteps) =>
-
prevSteps.map((step, i) =>
-
i === index
-
? { ...step, status, error }
-
: i > index
-
? { ...step, status: "pending", error: undefined }
-
: step
-
)
-
);
};
const validateParams = () => {
if (!props.service?.trim()) {
-
updateStepStatus(0, "error", "Missing service URL");
return false;
}
if (!props.handle?.trim()) {
-
updateStepStatus(0, "error", "Missing handle");
return false;
}
if (!props.email?.trim()) {
-
updateStepStatus(0, "error", "Missing email");
return false;
}
if (!props.password?.trim()) {
-
updateStepStatus(0, "error", "Missing password");
return false;
}
return true;
···
invite: props.invite,
});
-
if (!validateParams()) {
-
console.log("Parameter validation failed");
-
return;
-
}
-
-
startMigration().catch((error) => {
-
console.error("Unhandled migration error:", error);
-
updateStepStatus(
-
0,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
});
-
}, []);
-
-
const getStepDisplayName = (step: MigrationStep, index: number) => {
-
if (step.status === "completed") {
-
switch (index) {
-
case 0: return "Account Created";
-
case 1: return "Data Migrated";
-
case 2: return "Identity Migrated";
-
case 3: return "Migration Finalized";
-
}
-
}
-
-
if (step.status === "in-progress") {
-
switch (index) {
-
case 0: return "Creating your new account...";
-
case 1: return "Migrating your data...";
-
case 2: return step.name === "Enter the token sent to your email to complete identity migration"
-
? step.name
-
: "Migrating your identity...";
-
case 3: return "Finalizing migration...";
-
}
-
}
-
-
if (step.status === "verifying") {
-
switch (index) {
-
case 0: return "Verifying account creation...";
-
case 1: return "Verifying data migration...";
-
case 2: return "Verifying identity migration...";
-
case 3: return "Verifying migration completion...";
-
}
-
}
-
-
return step.name;
-
};
-
-
const startMigration = async () => {
-
try {
-
// Step 1: Create Account
-
updateStepStatus(0, "in-progress");
-
console.log("Starting account creation...");
-
try {
-
const createRes = await fetch("/api/migrate/create", {
-
method: "POST",
-
headers: { "Content-Type": "application/json" },
-
body: JSON.stringify({
-
service: props.service,
-
handle: props.handle,
-
password: props.password,
-
email: props.email,
-
...(props.invite ? { invite: props.invite } : {}),
-
}),
-
});
-
console.log("Create account response status:", createRes.status);
-
const responseText = await createRes.text();
-
console.log("Create account response:", responseText);
-
-
if (!createRes.ok) {
-
try {
-
const json = JSON.parse(responseText);
-
throw new Error(json.message || "Failed to create account");
-
} catch {
-
throw new Error(responseText || "Failed to create account");
}
}
-
-
try {
-
const jsonData = JSON.parse(responseText);
-
if (!jsonData.success) {
-
throw new Error(jsonData.message || "Account creation failed");
-
}
-
} catch (e) {
-
console.log("Response is not JSON or lacks success field:", e);
-
}
-
-
updateStepStatus(0, "verifying");
-
const verified = await verifyStep(0);
-
if (!verified) {
-
throw new Error("Account creation verification failed");
-
}
} catch (error) {
-
updateStepStatus(
-
0,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
throw error;
}
-
// Step 2: Migrate Data
-
updateStepStatus(1, "in-progress");
-
console.log("Starting data migration...");
-
-
try {
-
console.log("Data migration: Sending request to /api/migrate/data");
-
const dataRes = await fetch("/api/migrate/data", {
-
method: "POST",
-
headers: { "Content-Type": "application/json" },
-
});
-
-
console.log("Data migration: Response status:", dataRes.status);
-
const dataText = await dataRes.text();
-
console.log("Data migration: Raw response:", dataText);
-
-
if (!dataRes.ok) {
-
try {
-
const json = JSON.parse(dataText);
-
console.error("Data migration: Error response:", json);
-
throw new Error(json.message || "Failed to migrate data");
-
} catch {
-
console.error("Data migration: Non-JSON error response:", dataText);
-
throw new Error(dataText || "Failed to migrate data");
-
}
-
}
-
-
try {
-
const jsonData = JSON.parse(dataText);
-
console.log("Data migration: Parsed response:", jsonData);
-
if (!jsonData.success) {
-
console.error("Data migration: Unsuccessful response:", jsonData);
-
throw new Error(jsonData.message || "Data migration failed");
-
}
-
console.log("Data migration: Success response:", jsonData);
-
-
// Display migration logs
-
if (jsonData.logs && Array.isArray(jsonData.logs)) {
-
console.log("Data migration: Logs:", jsonData.logs);
-
jsonData.logs.forEach((log: string) => {
-
if (log.includes("Successfully migrated blob:")) {
-
console.log("Data migration: Blob success:", log);
-
} else if (log.includes("Failed to migrate blob")) {
-
console.error("Data migration: Blob failure:", log);
-
} else {
-
console.log("Data migration:", log);
-
}
-
});
-
}
-
} catch (e) {
-
console.error("Data migration: Failed to parse response:", e);
-
throw new Error("Invalid response from server during data migration");
-
}
-
-
console.log("Data migration: Starting verification");
-
updateStepStatus(1, "verifying");
-
const verified = await verifyStep(1);
-
console.log("Data migration: Verification result:", verified);
-
if (!verified) {
-
throw new Error("Data migration verification failed");
-
}
-
} catch (error) {
-
console.error("Data migration: Error caught:", error);
-
updateStepStatus(
-
1,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
throw error;
}
-
// Step 3: Request Identity Migration
-
updateStepStatus(2, "in-progress");
-
console.log("Requesting identity migration...");
-
try {
-
const requestRes = await fetch("/api/migrate/identity/request", {
-
method: "POST",
-
headers: { "Content-Type": "application/json" },
-
});
-
console.log("Identity request response status:", requestRes.status);
-
const requestText = await requestRes.text();
-
console.log("Identity request response:", requestText);
-
if (!requestRes.ok) {
-
try {
-
const json = JSON.parse(requestText);
-
throw new Error(json.message || "Failed to request identity migration");
-
} catch {
-
throw new Error(requestText || "Failed to request identity migration");
-
}
-
}
-
-
try {
-
const jsonData = JSON.parse(requestText);
-
if (!jsonData.success) {
-
throw new Error(
-
jsonData.message || "Identity migration request failed",
-
);
-
}
-
console.log("Identity migration requested successfully");
-
-
// Update step name to prompt for token
-
setSteps(prevSteps =>
-
prevSteps.map((step, i) =>
-
i === 2
-
? { ...step, name: "Enter the token sent to your email to complete identity migration" }
-
: step
-
)
-
);
-
// Don't continue with migration - wait for token input
-
return;
-
} catch (e) {
-
console.error("Failed to parse identity request response:", e);
-
throw new Error(
-
"Invalid response from server during identity request",
-
);
-
}
-
} catch (error) {
-
updateStepStatus(
-
2,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
throw error;
-
}
-
} catch (error) {
-
console.error("Migration error in try/catch:", error);
}
};
-
const handleIdentityMigration = async () => {
-
if (!token) return;
-
-
try {
-
const identityRes = await fetch(
-
`/api/migrate/identity/sign?token=${encodeURIComponent(token)}`,
-
{
-
method: "POST",
-
headers: { "Content-Type": "application/json" },
-
},
-
);
-
-
const identityData = await identityRes.text();
-
if (!identityRes.ok) {
-
try {
-
const json = JSON.parse(identityData);
-
throw new Error(json.message || "Failed to complete identity migration");
-
} catch {
-
throw new Error(identityData || "Failed to complete identity migration");
-
}
-
}
-
-
let data;
-
try {
-
data = JSON.parse(identityData);
-
if (!data.success) {
-
throw new Error(data.message || "Identity migration failed");
-
}
-
} catch {
-
throw new Error("Invalid response from server");
-
}
-
-
-
updateStepStatus(2, "verifying");
-
const verified = await verifyStep(2);
-
if (!verified) {
-
throw new Error("Identity migration verification failed");
-
}
-
-
// Step 4: Finalize Migration
-
updateStepStatus(3, "in-progress");
-
try {
-
const finalizeRes = await fetch("/api/migrate/finalize", {
-
method: "POST",
-
headers: { "Content-Type": "application/json" },
-
});
-
-
const finalizeData = await finalizeRes.text();
-
if (!finalizeRes.ok) {
-
try {
-
const json = JSON.parse(finalizeData);
-
throw new Error(json.message || "Failed to finalize migration");
-
} catch {
-
throw new Error(finalizeData || "Failed to finalize migration");
-
}
-
}
-
-
try {
-
const jsonData = JSON.parse(finalizeData);
-
if (!jsonData.success) {
-
throw new Error(jsonData.message || "Finalization failed");
-
}
-
} catch {
-
throw new Error("Invalid response from server during finalization");
-
}
-
-
updateStepStatus(3, "verifying");
-
const verified = await verifyStep(3);
-
if (!verified) {
-
throw new Error("Migration finalization verification failed");
-
}
-
} catch (error) {
-
updateStepStatus(
-
3,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
throw error;
-
}
-
} catch (error) {
-
console.error("Identity migration error:", error);
-
updateStepStatus(
-
2,
-
"error",
-
error instanceof Error ? error.message : String(error),
-
);
-
}
};
-
const getStepIcon = (status: MigrationStep["status"]) => {
-
switch (status) {
-
case "pending":
-
return (
-
<div class="w-8 h-8 rounded-full border-2 border-gray-300 dark:border-gray-600 flex items-center justify-center">
-
<div class="w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600" />
-
</div>
-
);
-
case "in-progress":
-
return (
-
<div class="w-8 h-8 rounded-full border-2 border-blue-500 border-t-transparent animate-spin flex items-center justify-center">
-
<div class="w-3 h-3 rounded-full bg-blue-500" />
-
</div>
-
);
-
case "verifying":
-
return (
-
<div class="w-8 h-8 rounded-full border-2 border-yellow-500 border-t-transparent animate-spin flex items-center justify-center">
-
<div class="w-3 h-3 rounded-full bg-yellow-500" />
-
</div>
-
);
-
case "completed":
-
return (
-
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center">
-
<svg
-
class="w-5 h-5 text-white"
-
fill="none"
-
stroke="currentColor"
-
viewBox="0 0 24 24"
-
>
-
<path
-
stroke-linecap="round"
-
stroke-linejoin="round"
-
stroke-width="2"
-
d="M5 13l4 4L19 7"
-
/>
-
</svg>
-
</div>
-
);
-
case "error":
-
return (
-
<div class="w-8 h-8 rounded-full bg-red-500 flex items-center justify-center">
-
<svg
-
class="w-5 h-5 text-white"
-
fill="none"
-
stroke="currentColor"
-
viewBox="0 0 24 24"
-
>
-
<path
-
stroke-linecap="round"
-
stroke-linejoin="round"
-
stroke-width="2"
-
d="M6 18L18 6M6 6l12 12"
-
/>
-
</svg>
-
</div>
-
);
-
}
};
-
const getStepClasses = (status: MigrationStep["status"]) => {
-
const baseClasses =
-
"flex items-center space-x-3 p-4 rounded-lg transition-colors duration-200";
-
switch (status) {
-
case "pending":
-
return `${baseClasses} bg-gray-50 dark:bg-gray-800`;
-
case "in-progress":
-
return `${baseClasses} bg-blue-50 dark:bg-blue-900`;
-
case "verifying":
-
return `${baseClasses} bg-yellow-50 dark:bg-yellow-900`;
-
case "completed":
-
return `${baseClasses} bg-green-50 dark:bg-green-900`;
-
case "error":
-
return `${baseClasses} bg-red-50 dark:bg-red-900`;
-
}
};
-
// Helper to verify a step after completion
-
const verifyStep = async (stepNum: number) => {
-
console.log(`Verification: Starting step ${stepNum + 1}`);
-
updateStepStatus(stepNum, "verifying");
-
try {
-
console.log(`Verification: Fetching status for step ${stepNum + 1}`);
-
const res = await fetch(`/api/migrate/status?step=${stepNum + 1}`);
-
console.log(`Verification: Status response status:`, res.status);
-
const data = await res.json();
-
console.log(`Verification: Status data for step ${stepNum + 1}:`, data);
-
-
if (data.ready) {
-
console.log(`Verification: Step ${stepNum + 1} is ready`);
-
updateStepStatus(stepNum, "completed");
-
return true;
-
} else {
-
console.log(`Verification: Step ${stepNum + 1} is not ready:`, data.reason);
-
const statusDetails = {
-
activated: data.activated,
-
validDid: data.validDid,
-
repoCommit: data.repoCommit,
-
repoRev: data.repoRev,
-
repoBlocks: data.repoBlocks,
-
expectedRecords: data.expectedRecords,
-
indexedRecords: data.indexedRecords,
-
privateStateValues: data.privateStateValues,
-
expectedBlobs: data.expectedBlobs,
-
importedBlobs: data.importedBlobs
-
};
-
console.log(`Verification: Step ${stepNum + 1} status details:`, statusDetails);
-
const errorMessage = `${data.reason || "Verification failed"}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`;
-
updateStepStatus(stepNum, "error", errorMessage);
-
return false;
-
}
-
} catch (e) {
-
console.error(`Verification: Error in step ${stepNum + 1}:`, e);
-
updateStepStatus(stepNum, "error", e instanceof Error ? e.message : String(e));
-
return false;
-
}
-
};
return (
<div class="space-y-8">
-
<div class="space-y-4">
-
{steps.map((step, index) => (
-
<div key={step.name} class={getStepClasses(step.status)}>
-
{getStepIcon(step.status)}
-
<div class="flex-1">
-
<p
-
class={`font-medium ${
-
step.status === "error"
-
? "text-red-900 dark:text-red-200"
-
: step.status === "completed"
-
? "text-green-900 dark:text-green-200"
-
: step.status === "in-progress"
-
? "text-blue-900 dark:text-blue-200"
-
: "text-gray-900 dark:text-gray-200"
-
}`}
-
>
-
{getStepDisplayName(step, index)}
-
</p>
-
{step.error && (
-
<p class="text-sm text-red-600 dark:text-red-400 mt-1">
-
{(() => {
-
try {
-
const err = JSON.parse(step.error);
-
return err.message || step.error;
-
} catch {
-
return step.error;
-
}
-
})()}
-
</p>
-
)}
-
{index === 2 && step.status === "in-progress" &&
-
step.name === "Enter the token sent to your email to complete identity migration" && (
-
<div class="mt-4 space-y-4">
-
<p class="text-sm text-blue-800 dark:text-blue-200">
-
Please check your email for the migration token and enter it below:
-
</p>
-
<div class="flex space-x-2">
-
<input
-
type="text"
-
value={token}
-
onChange={(e) => setToken(e.currentTarget.value)}
-
placeholder="Enter token"
-
class="flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"
-
/>
-
<button
-
type="button"
-
onClick={handleIdentityMigration}
-
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors duration-200"
-
>
-
Submit Token
-
</button>
-
</div>
-
</div>
-
)
-
}
</div>
</div>
-
))}
</div>
-
{steps[3].status === "completed" && (
-
<div class="p-4 bg-green-50 dark:bg-green-900 rounded-lg border-2 border-green-200 dark:border-green-800">
-
<p class="text-sm text-green-800 dark:text-green-200">
-
Migration completed successfully! You can now close this page.
-
</p>
-
<button
-
type="button"
-
onClick={async () => {
-
try {
-
const response = await fetch("/api/logout", {
-
method: "POST",
-
credentials: "include",
-
});
-
if (!response.ok) {
-
throw new Error("Logout failed");
-
}
-
globalThis.location.href = "/";
-
} catch (error) {
-
console.error("Failed to logout:", error);
-
}
-
}}
-
class="mt-4 mr-4 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200"
-
>
-
Sign Out
-
</button>
-
<a href="https://ko-fi.com/knotbin" target="_blank" class="mt-4 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200">
-
Donate
-
</a>
-
</div>
-
)}
</div>
);
}
···
import { useEffect, useState } from "preact/hooks";
+
import { MigrationStateInfo } from "../lib/migration-types.ts";
+
import AccountCreationStep from "./migration-steps/AccountCreationStep.tsx";
+
import DataMigrationStep from "./migration-steps/DataMigrationStep.tsx";
+
import IdentityMigrationStep from "./migration-steps/IdentityMigrationStep.tsx";
+
import FinalizationStep from "./migration-steps/FinalizationStep.tsx";
+
import MigrationCompletion from "../components/MigrationCompletion.tsx";
/**
* The migration progress props.
···
}
/**
* The migration progress component.
* @param props - The migration progress props
* @returns The migration progress component
* @component
*/
export default function MigrationProgress(props: MigrationProgressProps) {
+
const [migrationState, setMigrationState] = useState<
+
MigrationStateInfo | null
+
>(null);
+
const [currentStep, setCurrentStep] = useState(0);
+
const [completedSteps, setCompletedSteps] = useState<Set<number>>(new Set());
+
const [hasError, setHasError] = useState(false);
+
const credentials = {
+
service: props.service,
+
handle: props.handle,
+
email: props.email,
+
password: props.password,
+
invite: props.invite,
};
const validateParams = () => {
if (!props.service?.trim()) {
+
setHasError(true);
return false;
}
if (!props.handle?.trim()) {
+
setHasError(true);
return false;
}
if (!props.email?.trim()) {
+
setHasError(true);
return false;
}
if (!props.password?.trim()) {
+
setHasError(true);
return false;
}
return true;
···
invite: props.invite,
});
+
// Check migration state first
+
const checkMigrationState = async () => {
try {
+
const migrationResponse = await fetch("/api/migration-state");
+
if (migrationResponse.ok) {
+
const migrationData = await migrationResponse.json();
+
setMigrationState(migrationData);
+
if (!migrationData.allowMigration) {
+
setHasError(true);
+
return;
}
}
} catch (error) {
+
console.error("Failed to check migration state:", error);
+
setHasError(true);
+
return;
}
+
if (!validateParams()) {
+
console.log("Parameter validation failed");
+
return;
}
+
// Start with the first step
+
setCurrentStep(0);
+
};
+
checkMigrationState();
+
}, []);
+
const handleStepComplete = (stepIndex: number) => {
+
console.log(`Step ${stepIndex} completed`);
+
setCompletedSteps((prev) => new Set([...prev, stepIndex]));
+
// Move to next step if not the last one
+
if (stepIndex < 3) {
+
setCurrentStep(stepIndex + 1);
}
};
+
const handleStepError = (
+
stepIndex: number,
+
error: string,
+
isVerificationError?: boolean,
+
) => {
+
console.error(`Step ${stepIndex} error:`, error, { isVerificationError });
+
// Errors are handled within each step component
};
+
const isStepActive = (stepIndex: number) => {
+
return currentStep === stepIndex && !hasError;
};
+
const _isStepCompleted = (stepIndex: number) => {
+
return completedSteps.has(stepIndex);
};
+
const allStepsCompleted = completedSteps.size === 4;
return (
<div class="space-y-8">
+
{/* Migration state alert */}
+
{migrationState && !migrationState.allowMigration && (
+
<div
+
class={`p-4 rounded-lg border ${
+
migrationState.state === "maintenance"
+
? "bg-yellow-50 border-yellow-200 text-yellow-800 dark:bg-yellow-900/20 dark:border-yellow-800 dark:text-yellow-200"
+
: "bg-red-50 border-red-200 text-red-800 dark:bg-red-900/20 dark:border-red-800 dark:text-red-200"
+
}`}
+
>
+
<div class="flex items-center">
+
<div
+
class={`mr-3 ${
+
migrationState.state === "maintenance"
+
? "text-yellow-600 dark:text-yellow-400"
+
: "text-red-600 dark:text-red-400"
+
}`}
+
>
+
{migrationState.state === "maintenance" ? "โš ๏ธ" : "๐Ÿšซ"}
+
</div>
+
<div>
+
<h3 class="font-semibold mb-1">
+
{migrationState.state === "maintenance"
+
? "Maintenance Mode"
+
: "Service Unavailable"}
+
</h3>
+
<p class="text-sm">{migrationState.message}</p>
</div>
</div>
+
</div>
+
)}
+
+
<div class="space-y-4">
+
<AccountCreationStep
+
credentials={credentials}
+
onStepComplete={() => handleStepComplete(0)}
+
onStepError={(error, isVerificationError) =>
+
handleStepError(0, error, isVerificationError)}
+
isActive={isStepActive(0)}
+
/>
+
+
<DataMigrationStep
+
credentials={credentials}
+
onStepComplete={() => handleStepComplete(1)}
+
onStepError={(error, isVerificationError) =>
+
handleStepError(1, error, isVerificationError)}
+
isActive={isStepActive(1)}
+
/>
+
+
<IdentityMigrationStep
+
credentials={credentials}
+
onStepComplete={() => handleStepComplete(2)}
+
onStepError={(error, isVerificationError) =>
+
handleStepError(2, error, isVerificationError)}
+
isActive={isStepActive(2)}
+
/>
+
+
<FinalizationStep
+
credentials={credentials}
+
onStepComplete={() => handleStepComplete(3)}
+
onStepError={(error, isVerificationError) =>
+
handleStepError(3, error, isVerificationError)}
+
isActive={isStepActive(3)}
+
/>
</div>
+
<MigrationCompletion isVisible={allStepsCompleted} />
</div>
);
}
+340 -76
islands/MigrationSetup.tsx
···
-
import { useState, useEffect } from "preact/hooks";
import { IS_BROWSER } from "fresh/runtime";
/**
···
}
/**
* The migration setup component.
* @param props - The migration setup props
* @returns The migration setup component
···
const [showConfirmation, setShowConfirmation] = useState(false);
const [confirmationText, setConfirmationText] = useState("");
const [passport, setPassport] = useState<UserPassport | null>(null);
const ensureServiceUrl = (url: string): string => {
if (!url) return url;
···
useEffect(() => {
if (!IS_BROWSER) return;
-
const fetchPassport = async () => {
try {
const response = await fetch("/api/me", {
credentials: "include",
});
···
const userData = await response.json();
if (userData) {
// Get PDS URL from the current service
-
const pdsResponse = await fetch(`/api/resolve-pds?did=${userData.did}`);
const pdsData = await pdsResponse.json();
-
setPassport({
did: userData.did,
handle: userData.handle,
pds: pdsData.pds || "Unknown",
-
createdAt: new Date().toISOString() // TODO: Get actual creation date from API
});
}
} catch (error) {
-
console.error("Failed to fetch passport:", error);
}
};
-
fetchPassport();
}, []);
const checkServerDescription = async (serviceUrl: string) => {
···
const handleSubmit = (e: Event) => {
e.preventDefault();
if (!service || !handlePrefix || !email || !password) {
setError("Please fill in all required fields");
return;
···
};
const handleConfirmation = () => {
if (confirmationText !== "MIGRATE") {
setError("Please type 'MIGRATE' to confirm");
return;
···
<div class="max-w-2xl mx-auto p-6 bg-gradient-to-b from-blue-50 to-white dark:from-gray-800 dark:to-gray-900 rounded-lg shadow-xl relative overflow-hidden">
{/* Decorative airport elements */}
<div class="absolute top-0 left-0 w-full h-1 bg-blue-500"></div>
-
<div class="absolute top-2 left-4 text-blue-500 text-sm font-mono">TERMINAL 1</div>
-
<div class="absolute top-2 right-4 text-blue-500 text-sm font-mono">GATE M1</div>
<div class="text-center mb-8 relative">
-
<p class="text-gray-600 dark:text-gray-400 mt-4">Please complete your migration check-in</p>
-
<div class="mt-2 text-sm text-gray-500 dark:text-gray-400 font-mono">FLIGHT: MIG-2024</div>
</div>
{/* Passport Section */}
{passport && (
<div class="mb-8 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 border border-gray-200 dark:border-gray-700">
<div class="flex items-center justify-between mb-4">
-
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Current Passport</h3>
-
<div class="text-xs text-gray-500 dark:text-gray-400 font-mono">ISSUED: {new Date().toLocaleDateString()}</div>
</div>
<div class="grid grid-cols-2 gap-4 text-sm">
<div>
<div class="text-gray-500 dark:text-gray-400 mb-1">Handle</div>
-
<div class="font-mono text-gray-900 dark:text-white">{passport.handle}</div>
</div>
<div>
<div class="text-gray-500 dark:text-gray-400 mb-1">DID</div>
-
<div class="font-mono text-gray-900 dark:text-white break-all">{passport.did}</div>
</div>
<div>
-
<div class="text-gray-500 dark:text-gray-400 mb-1">Citizen of PDS</div>
-
<div class="font-mono text-gray-900 dark:text-white break-all">{passport.pds}</div>
</div>
<div>
-
<div class="text-gray-500 dark:text-gray-400 mb-1">Account Age</div>
<div class="font-mono text-gray-900 dark:text-white">
-
{passport.createdAt ? new Date(passport.createdAt).toLocaleDateString() : "Unknown"}
</div>
</div>
</div>
···
<form onSubmit={handleSubmit} class="space-y-6">
{error && (
-
<div class="bg-red-50 dark:bg-red-900 rounded-lg">
<p class="text-red-800 dark:text-red-200 flex items-center">
-
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
{error}
</p>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Destination Server
-
<span class="text-xs text-gray-500 ml-1">(Final Destination)</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white disabled:opacity-50 disabled:cursor-not-allowed pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
-
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"></path>
</svg>
</div>
</div>
{isLoading && (
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400 flex items-center">
-
<svg class="animate-spin -ml-1 mr-2 h-4 w-4 text-blue-500" fill="none" viewBox="0 0 24 24">
-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Verifying destination server...
</p>
···
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
New Account Handle
<span class="text-xs text-gray-500 ml-1">(Passport ID)</span>
</label>
<div class="mt-1 relative w-full">
<div class="flex rounded-md shadow-sm w-full">
···
placeholder="username"
required
class="w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10 pr-32"
-
style={{ fontFamily: 'inherit' }}
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
-
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
</svg>
</div>
{/* Suffix for domain ending */}
-
{availableDomains.length > 0 ? (
-
availableDomains.length === 1 ? (
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 select-none pointer-events-none font-mono text-base">
-
{availableDomains[0]}
-
</span>
-
) : (
-
<span class="absolute inset-y-0 right-0 flex items-center pr-1">
-
<select
-
value={selectedDomain}
-
onChange={(e) => setSelectedDomain(e.currentTarget.value)}
-
class="bg-transparent text-gray-400 font-mono text-base focus:outline-none focus:ring-0 border-0 pr-2"
-
style={{ appearance: 'none' }}
-
>
-
{availableDomains.map((domain) => (
-
<option key={domain} value={domain}>{domain}</option>
-
))}
-
</select>
</span>
-
)
-
) : (
-
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 select-none pointer-events-none font-mono text-base">
-
.example.com
-
</span>
-
)}
</div>
</div>
</div>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Email
-
<span class="text-xs text-gray-500 ml-1">(Emergency Contact)</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
-
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
</svg>
</div>
</div>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
New Account Password
-
<span class="text-xs text-gray-500 ml-1">(Security Clearance)</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
-
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path>
</svg>
</div>
</div>
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
-
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
</svg>
</div>
</div>
···
<button
type="submit"
-
disabled={isLoading}
class="w-full flex justify-center items-center py-3 px-4 rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
>
-
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
Proceed to Check-in
</button>
···
<div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50">
<div
class="bg-white dark:bg-gray-800 rounded-xl p-8 max-w-md w-full shadow-2xl border-0 relative animate-popin"
-
style={{ boxShadow: '0 8px 32px 0 rgba(255, 0, 0, 0.15), 0 1.5px 8px 0 rgba(0,0,0,0.10)' }}
>
<div class="absolute -top-8 left-1/2 -translate-x-1/2">
<div class="bg-red-500 rounded-full p-3 shadow-lg animate-bounce-short">
-
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
</div>
<div class="text-center mb-4 mt-6">
-
<h3 class="text-2xl font-bold text-red-600 mb-2 tracking-wide">Final Boarding Call</h3>
<p class="text-gray-700 dark:text-gray-300 mb-2 text-base">
-
<span class="font-semibold text-red-500">Warning:</span> This migration process can be <strong>irreversible</strong>.<br />Airport is in <strong>alpha</strong> currently, and we don't recommend it for main accounts. Migrate at your own risk. We reccomend backing up your data before proceeding.
</p>
<p class="text-gray-700 dark:text-gray-300 mb-4 text-base">
-
Please type <span class="font-mono font-bold text-blue-600">MIGRATE</span> below to confirm and proceed.
</p>
</div>
<div class="relative">
···
class="px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md flex items-center transition"
type="button"
>
-
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
Cancel
</button>
<button
onClick={handleConfirmation}
-
class={`px-4 py-2 rounded-md flex items-center transition font-semibold ${confirmationText.trim().toLowerCase() === 'migrate' ? 'bg-red-600 text-white hover:bg-red-700 cursor-pointer' : 'bg-red-300 text-white cursor-not-allowed'}`}
type="button"
-
disabled={confirmationText.trim().toLowerCase() !== 'migrate'}
>
-
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
Confirm Migration
</button>
···
+
import { useEffect, useState } from "preact/hooks";
import { IS_BROWSER } from "fresh/runtime";
/**
···
}
/**
+
* The migration state info.
+
* @type {MigrationStateInfo}
+
*/
+
interface MigrationStateInfo {
+
state: "up" | "issue" | "maintenance";
+
message: string;
+
allowMigration: boolean;
+
}
+
+
/**
* The migration setup component.
* @param props - The migration setup props
* @returns The migration setup component
···
const [showConfirmation, setShowConfirmation] = useState(false);
const [confirmationText, setConfirmationText] = useState("");
const [passport, setPassport] = useState<UserPassport | null>(null);
+
const [migrationState, setMigrationState] = useState<
+
MigrationStateInfo | null
+
>(null);
const ensureServiceUrl = (url: string): string => {
if (!url) return url;
···
useEffect(() => {
if (!IS_BROWSER) return;
+
const fetchInitialData = async () => {
try {
+
// Check migration state first
+
const migrationResponse = await fetch("/api/migration-state");
+
if (migrationResponse.ok) {
+
const migrationData = await migrationResponse.json();
+
setMigrationState(migrationData);
+
}
+
+
// Fetch user passport
const response = await fetch("/api/me", {
credentials: "include",
});
···
const userData = await response.json();
if (userData) {
// Get PDS URL from the current service
+
const pdsResponse = await fetch(
+
`/api/resolve-pds?did=${userData.did}`,
+
);
const pdsData = await pdsResponse.json();
+
setPassport({
did: userData.did,
handle: userData.handle,
pds: pdsData.pds || "Unknown",
+
createdAt: new Date().toISOString(), // TODO: Get actual creation date from API
});
}
} catch (error) {
+
console.error("Failed to fetch initial data:", error);
}
};
+
fetchInitialData();
}, []);
const checkServerDescription = async (serviceUrl: string) => {
···
const handleSubmit = (e: Event) => {
e.preventDefault();
+
// Check migration state first
+
if (migrationState && !migrationState.allowMigration) {
+
setError(migrationState.message);
+
return;
+
}
+
if (!service || !handlePrefix || !email || !password) {
setError("Please fill in all required fields");
return;
···
};
const handleConfirmation = () => {
+
// Double-check migration state before proceeding
+
if (migrationState && !migrationState.allowMigration) {
+
setError(migrationState.message);
+
return;
+
}
+
if (confirmationText !== "MIGRATE") {
setError("Please type 'MIGRATE' to confirm");
return;
···
<div class="max-w-2xl mx-auto p-6 bg-gradient-to-b from-blue-50 to-white dark:from-gray-800 dark:to-gray-900 rounded-lg shadow-xl relative overflow-hidden">
{/* Decorative airport elements */}
<div class="absolute top-0 left-0 w-full h-1 bg-blue-500"></div>
+
<div class="absolute top-2 left-4 text-blue-500 text-sm font-mono">
+
TERMINAL 1
+
</div>
+
<div class="absolute top-2 right-4 text-blue-500 text-sm font-mono">
+
GATE M1
+
</div>
+
+
{/* Migration state alert */}
+
{migrationState && !migrationState.allowMigration && (
+
<div
+
class={`mb-6 mt-4 p-4 rounded-lg border ${
+
migrationState.state === "maintenance"
+
? "bg-yellow-50 border-yellow-200 text-yellow-800 dark:bg-yellow-900/20 dark:border-yellow-800 dark:text-yellow-200"
+
: "bg-red-50 border-red-200 text-red-800 dark:bg-red-900/20 dark:border-red-800 dark:text-red-200"
+
}`}
+
>
+
<div class="flex items-center">
+
<div
+
class={`mr-3 ${
+
migrationState.state === "maintenance"
+
? "text-yellow-600 dark:text-yellow-400"
+
: "text-red-600 dark:text-red-400"
+
}`}
+
>
+
{migrationState.state === "maintenance" ? "โš ๏ธ" : "๐Ÿšซ"}
+
</div>
+
<div>
+
<h3 class="font-semibold mb-1">
+
{migrationState.state === "maintenance"
+
? "Maintenance Mode"
+
: "Service Unavailable"}
+
</h3>
+
<p class="text-sm">{migrationState.message}</p>
+
</div>
+
</div>
+
</div>
+
)}
<div class="text-center mb-8 relative">
+
<p class="text-gray-600 dark:text-gray-400 mt-4">
+
Please complete your migration check-in
+
</p>
+
<div class="mt-2 text-sm text-gray-500 dark:text-gray-400 font-mono">
+
FLIGHT: MIG-2024
+
</div>
</div>
{/* Passport Section */}
{passport && (
<div class="mb-8 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 border border-gray-200 dark:border-gray-700">
<div class="flex items-center justify-between mb-4">
+
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
+
Current Passport
+
</h3>
+
<div class="text-xs text-gray-500 dark:text-gray-400 font-mono">
+
ISSUED: {new Date().toLocaleDateString()}
+
</div>
</div>
<div class="grid grid-cols-2 gap-4 text-sm">
<div>
<div class="text-gray-500 dark:text-gray-400 mb-1">Handle</div>
+
<div class="font-mono text-gray-900 dark:text-white">
+
{passport.handle}
+
</div>
</div>
<div>
<div class="text-gray-500 dark:text-gray-400 mb-1">DID</div>
+
<div class="font-mono text-gray-900 dark:text-white break-all">
+
{passport.did}
+
</div>
</div>
<div>
+
<div class="text-gray-500 dark:text-gray-400 mb-1">
+
Citizen of PDS
+
</div>
+
<div class="font-mono text-gray-900 dark:text-white break-all">
+
{passport.pds}
+
</div>
</div>
<div>
+
<div class="text-gray-500 dark:text-gray-400 mb-1">
+
Account Age
+
</div>
<div class="font-mono text-gray-900 dark:text-white">
+
{passport.createdAt
+
? new Date(passport.createdAt).toLocaleDateString()
+
: "Unknown"}
</div>
</div>
</div>
···
<form onSubmit={handleSubmit} class="space-y-6">
{error && (
+
<div class="bg-red-50 dark:bg-red-900 rounded-lg ">
<p class="text-red-800 dark:text-red-200 flex items-center">
+
<svg
+
class="w-5 h-5 mr-2"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
+
>
+
</path>
</svg>
{error}
</p>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Destination Server
+
<span class="text-xs text-gray-500 ml-1">
+
(Final Destination)
+
</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white disabled:opacity-50 disabled:cursor-not-allowed pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+
<svg
+
class="h-5 w-5 text-gray-400"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
+
>
+
</path>
</svg>
</div>
</div>
{isLoading && (
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400 flex items-center">
+
<svg
+
class="animate-spin -ml-1 mr-2 h-4 w-4 text-blue-500"
+
fill="none"
+
viewBox="0 0 24 24"
+
>
+
<circle
+
class="opacity-25"
+
cx="12"
+
cy="12"
+
r="10"
+
stroke="currentColor"
+
stroke-width="4"
+
>
+
</circle>
+
<path
+
class="opacity-75"
+
fill="currentColor"
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
+
>
+
</path>
</svg>
Verifying destination server...
</p>
···
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
New Account Handle
<span class="text-xs text-gray-500 ml-1">(Passport ID)</span>
+
<div class="inline-block relative group ml-2">
+
<svg
+
class="w-4 h-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 cursor-help"
+
fill="currentColor"
+
viewBox="0 0 20 20"
+
>
+
<path
+
fill-rule="evenodd"
+
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z"
+
clip-rule="evenodd"
+
/>
+
</svg>
+
<div class="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10">
+
You can change your handle to a custom domain later
+
<div class="absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-gray-900">
+
</div>
+
</div>
+
</div>
</label>
<div class="mt-1 relative w-full">
<div class="flex rounded-md shadow-sm w-full">
···
placeholder="username"
required
class="w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10 pr-32"
+
style={{ fontFamily: "inherit" }}
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+
<svg
+
class="h-5 w-5 text-gray-400"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
+
>
+
</path>
</svg>
</div>
{/* Suffix for domain ending */}
+
{availableDomains.length > 0
+
? (
+
availableDomains.length === 1
+
? (
+
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 select-none pointer-events-none font-mono text-base">
+
{availableDomains[0]}
+
</span>
+
)
+
: (
+
<span class="absolute inset-y-0 right-0 flex items-center pr-1">
+
<select
+
value={selectedDomain}
+
onChange={(e) =>
+
setSelectedDomain(e.currentTarget.value)}
+
class="bg-transparent text-gray-400 font-mono text-base focus:outline-none focus:ring-0 border-0 pr-2"
+
style={{ appearance: "none" }}
+
>
+
{availableDomains.map((domain) => (
+
<option key={domain} value={domain}>
+
{domain}
+
</option>
+
))}
+
</select>
+
</span>
+
)
+
)
+
: (
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 select-none pointer-events-none font-mono text-base">
+
.example.com
</span>
+
)}
</div>
</div>
</div>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Email
+
<span class="text-xs text-gray-500 ml-1">
+
(Emergency Contact)
+
</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+
<svg
+
class="h-5 w-5 text-gray-400"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
+
>
+
</path>
</svg>
</div>
</div>
···
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
New Account Password
+
<span class="text-xs text-gray-500 ml-1">
+
(Security Clearance)
+
</span>
</label>
<div class="relative">
<input
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+
<svg
+
class="h-5 w-5 text-gray-400"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"
+
>
+
</path>
</svg>
</div>
</div>
···
class="mt-1 block w-full rounded-md bg-white dark:bg-gray-700 shadow-sm focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 dark:text-white pl-10"
/>
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+
<svg
+
class="h-5 w-5 text-gray-400"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"
+
>
+
</path>
</svg>
</div>
</div>
···
<button
type="submit"
+
disabled={isLoading ||
+
Boolean(migrationState && !migrationState.allowMigration)}
class="w-full flex justify-center items-center py-3 px-4 rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
>
+
<svg
+
class="w-5 h-5 mr-2"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M5 13l4 4L19 7"
+
>
+
</path>
</svg>
Proceed to Check-in
</button>
···
<div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50">
<div
class="bg-white dark:bg-gray-800 rounded-xl p-8 max-w-md w-full shadow-2xl border-0 relative animate-popin"
+
style={{
+
boxShadow:
+
"0 8px 32px 0 rgba(255, 0, 0, 0.15), 0 1.5px 8px 0 rgba(0,0,0,0.10)",
+
}}
>
<div class="absolute -top-8 left-1/2 -translate-x-1/2">
<div class="bg-red-500 rounded-full p-3 shadow-lg animate-bounce-short">
+
<svg
+
class="w-8 h-8 text-white"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
+
/>
</svg>
</div>
</div>
<div class="text-center mb-4 mt-6">
+
<h3 class="text-2xl font-bold text-red-600 mb-2 tracking-wide">
+
Final Boarding Call
+
</h3>
<p class="text-gray-700 dark:text-gray-300 mb-2 text-base">
+
<span class="font-semibold text-red-500">Warning:</span>{" "}
+
This migration is <strong>irreversible</strong>{" "}
+
if coming from Bluesky servers.<br />Bluesky does not recommend
+
it for main accounts. Migrate at your own risk. We reccomend
+
backing up your data before proceeding.
</p>
<p class="text-gray-700 dark:text-gray-300 mb-4 text-base">
+
Please type{" "}
+
<span class="font-mono font-bold text-blue-600">MIGRATE</span>
+
{" "}
+
below to confirm and proceed.
</p>
</div>
<div class="relative">
···
class="px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md flex items-center transition"
type="button"
>
+
<svg
+
class="w-5 h-5 mr-2"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M6 18L18 6M6 6l12 12"
+
>
+
</path>
</svg>
Cancel
</button>
<button
onClick={handleConfirmation}
+
class={`px-4 py-2 rounded-md flex items-center transition font-semibold ${
+
confirmationText.trim().toLowerCase() === "migrate"
+
? "bg-red-600 text-white hover:bg-red-700 cursor-pointer"
+
: "bg-red-300 text-white cursor-not-allowed"
+
}`}
type="button"
+
disabled={confirmationText.trim().toLowerCase() !== "migrate"}
>
+
<svg
+
class="w-5 h-5 mr-2"
+
fill="none"
+
stroke="currentColor"
+
viewBox="0 0 24 24"
+
>
+
<path
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
stroke-width="2"
+
d="M5 13l4 4L19 7"
+
>
+
</path>
</svg>
Confirm Migration
</button>
+8 -8
islands/SocialLinks.tsx
···
import { useEffect, useState } from "preact/hooks";
-
import * as Icon from 'npm:preact-feather';
/**
* The GitHub repository.
···
const [starCount, setStarCount] = useState<number | null>(null);
useEffect(() => {
-
const CACHE_KEY = 'github_stars';
const CACHE_DURATION = 15 * 60 * 1000; // 15 minutes in milliseconds
const fetchRepoInfo = async () => {
try {
-
const response = await fetch("https://api.github.com/repos/knotbin/airport");
const data: GitHubRepo = await response.json();
const cacheData = {
count: data.stargazers_count,
-
timestamp: Date.now()
};
localStorage.setItem(CACHE_KEY, JSON.stringify(cacheData));
setStarCount(data.stargazers_count);
···
stroke-linejoin="round"
xmlns="http://www.w3.org/2000/svg"
>
-
<path
-
d="M55.491 15.172c29.35 22.035 60.917 66.712 72.509 90.686 11.592-23.974 43.159-68.651 72.509-90.686C221.686-.727 256-13.028 256 26.116c0 7.818-4.482 65.674-7.111 75.068-9.138 32.654-42.436 40.983-72.057 35.942 51.775 8.812 64.946 38 36.501 67.187-54.021 55.433-77.644-13.908-83.696-31.676-1.11-3.257-1.63-4.78-1.637-3.485-.008-1.296-.527.228-1.637 3.485-6.052 17.768-29.675 87.11-83.696 31.676-28.445-29.187-15.274-58.375 36.5-67.187-29.62 5.041-62.918-3.288-72.056-35.942C4.482 91.79 0 33.934 0 26.116 0-13.028 34.314-.727 55.491 15.172Z"
-
/>
</svg>
</a>
<a
···
</a>
</div>
);
-
}
···
import { useEffect, useState } from "preact/hooks";
+
import * as Icon from "npm:preact-feather";
/**
* The GitHub repository.
···
const [starCount, setStarCount] = useState<number | null>(null);
useEffect(() => {
+
const CACHE_KEY = "github_stars";
const CACHE_DURATION = 15 * 60 * 1000; // 15 minutes in milliseconds
const fetchRepoInfo = async () => {
try {
+
const response = await fetch(
+
"https://api.github.com/repos/knotbin/airport",
+
);
const data: GitHubRepo = await response.json();
const cacheData = {
count: data.stargazers_count,
+
timestamp: Date.now(),
};
localStorage.setItem(CACHE_KEY, JSON.stringify(cacheData));
setStarCount(data.stargazers_count);
···
stroke-linejoin="round"
xmlns="http://www.w3.org/2000/svg"
>
+
<path d="M55.491 15.172c29.35 22.035 60.917 66.712 72.509 90.686 11.592-23.974 43.159-68.651 72.509-90.686C221.686-.727 256-13.028 256 26.116c0 7.818-4.482 65.674-7.111 75.068-9.138 32.654-42.436 40.983-72.057 35.942 51.775 8.812 64.946 38 36.501 67.187-54.021 55.433-77.644-13.908-83.696-31.676-1.11-3.257-1.63-4.78-1.637-3.485-.008-1.296-.527.228-1.637 3.485-6.052 17.768-29.675 87.11-83.696 31.676-28.445-29.187-15.274-58.375 36.5-67.187-29.62 5.041-62.918-3.288-72.056-35.942C4.482 91.79 0 33.934 0 26.116 0-13.028 34.314-.727 55.491 15.172Z" />
</svg>
</a>
<a
···
</a>
</div>
);
+
}
+11 -3
islands/Ticket.tsx
···
import { useEffect, useState } from "preact/hooks";
import { IS_BROWSER } from "fresh/runtime";
/**
* The user interface for the ticket component.
···
</p>
<p>
Think you might need to migrate in the future but your PDS might be
-
hostile or offline? No worries! Soon you'll be able to go to the
-
ticket booth and get a PLC key to use for account recovery in the
-
future. You can also go to baggage claim (take the air shuttle to
terminal four) and get a downloadable backup of all your current PDS
data in case that were to happen.
</p>
···
import { useEffect, useState } from "preact/hooks";
import { IS_BROWSER } from "fresh/runtime";
+
import { Link } from "../components/Link.tsx";
/**
* The user interface for the ticket component.
···
</p>
<p>
Think you might need to migrate in the future but your PDS might be
+
hostile or offline? No worries! You can go to the{" "}
+
<Link
+
href="/ticket-booth"
+
isExternal
+
class="text-blue-600 dark:text-blue-400"
+
>
+
ticket booth
+
</Link>{" "}
+
and get a PLC key to use for account recovery in the future. Soon
+
you'll also be able to go to baggage claim (take the air shuttle to
terminal four) and get a downloadable backup of all your current PDS
data in case that were to happen.
</p>
+151
islands/migration-steps/AccountCreationStep.tsx
···
···
+
import { useEffect, useState } from "preact/hooks";
+
import { MigrationStep } from "../../components/MigrationStep.tsx";
+
import {
+
parseApiResponse,
+
StepCommonProps,
+
verifyMigrationStep,
+
} from "../../lib/migration-types.ts";
+
+
interface AccountCreationStepProps extends StepCommonProps {
+
isActive: boolean;
+
}
+
+
export default function AccountCreationStep({
+
credentials,
+
onStepComplete,
+
onStepError,
+
isActive,
+
}: AccountCreationStepProps) {
+
const [status, setStatus] = useState<
+
"pending" | "in-progress" | "verifying" | "completed" | "error"
+
>("pending");
+
const [error, setError] = useState<string>();
+
const [retryCount, setRetryCount] = useState(0);
+
const [showContinueAnyway, setShowContinueAnyway] = useState(false);
+
+
useEffect(() => {
+
if (isActive && status === "pending") {
+
startAccountCreation();
+
}
+
}, [isActive]);
+
+
const startAccountCreation = async () => {
+
setStatus("in-progress");
+
setError(undefined);
+
+
try {
+
const createRes = await fetch("/api/migrate/create", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
body: JSON.stringify({
+
service: credentials.service,
+
handle: credentials.handle,
+
password: credentials.password,
+
email: credentials.email,
+
...(credentials.invite ? { invite: credentials.invite } : {}),
+
}),
+
});
+
+
const responseText = await createRes.text();
+
+
if (!createRes.ok) {
+
const parsed = parseApiResponse(responseText);
+
throw new Error(parsed.message || "Failed to create account");
+
}
+
+
const parsed = parseApiResponse(responseText);
+
if (!parsed.success) {
+
throw new Error(parsed.message || "Account creation failed");
+
}
+
+
// Verify the account creation
+
await verifyAccountCreation();
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage);
+
}
+
};
+
+
const verifyAccountCreation = async () => {
+
setStatus("verifying");
+
+
try {
+
const result = await verifyMigrationStep(1);
+
+
if (result.ready) {
+
setStatus("completed");
+
setRetryCount(0);
+
setShowContinueAnyway(false);
+
onStepComplete();
+
} else {
+
const statusDetails = {
+
activated: result.activated,
+
validDid: result.validDid,
+
};
+
const errorMessage = `${
+
result.reason || "Verification failed"
+
}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`;
+
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
};
+
+
const retryVerification = async () => {
+
await verifyAccountCreation();
+
};
+
+
const continueAnyway = () => {
+
setStatus("completed");
+
setShowContinueAnyway(false);
+
onStepComplete();
+
};
+
+
return (
+
<MigrationStep
+
name="Create Account"
+
status={status}
+
error={error}
+
isVerificationError={status === "error" &&
+
error?.includes("Verification failed")}
+
index={0}
+
onRetryVerification={retryVerification}
+
>
+
{status === "error" && showContinueAnyway && (
+
<div class="flex space-x-2 mt-2">
+
<button
+
type="button"
+
onClick={continueAnyway}
+
class="px-3 py-1 text-xs bg-white border border-gray-300 text-gray-700 hover:bg-gray-100 rounded transition-colors duration-200
+
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700"
+
>
+
Continue Anyway
+
</button>
+
</div>
+
)}
+
</MigrationStep>
+
);
+
}
+172
islands/migration-steps/DataMigrationStep.tsx
···
···
+
import { useEffect, useState } from "preact/hooks";
+
import { MigrationStep } from "../../components/MigrationStep.tsx";
+
import {
+
parseApiResponse,
+
StepCommonProps,
+
verifyMigrationStep,
+
} from "../../lib/migration-types.ts";
+
+
interface DataMigrationStepProps extends StepCommonProps {
+
isActive: boolean;
+
}
+
+
export default function DataMigrationStep({
+
credentials: _credentials,
+
onStepComplete,
+
onStepError,
+
isActive,
+
}: DataMigrationStepProps) {
+
const [status, setStatus] = useState<
+
"pending" | "in-progress" | "verifying" | "completed" | "error"
+
>("pending");
+
const [error, setError] = useState<string>();
+
const [retryCount, setRetryCount] = useState(0);
+
const [showContinueAnyway, setShowContinueAnyway] = useState(false);
+
+
useEffect(() => {
+
if (isActive && status === "pending") {
+
startDataMigration();
+
}
+
}, [isActive]);
+
+
const startDataMigration = async () => {
+
setStatus("in-progress");
+
setError(undefined);
+
+
try {
+
// Step 1: Migrate Repo
+
const repoRes = await fetch("/api/migrate/data/repo", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
});
+
+
const repoText = await repoRes.text();
+
+
if (!repoRes.ok) {
+
const parsed = parseApiResponse(repoText);
+
throw new Error(parsed.message || "Failed to migrate repo");
+
}
+
+
// Step 2: Migrate Blobs
+
const blobsRes = await fetch("/api/migrate/data/blobs", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
});
+
+
const blobsText = await blobsRes.text();
+
+
if (!blobsRes.ok) {
+
const parsed = parseApiResponse(blobsText);
+
throw new Error(parsed.message || "Failed to migrate blobs");
+
}
+
+
// Step 3: Migrate Preferences
+
const prefsRes = await fetch("/api/migrate/data/prefs", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
});
+
+
const prefsText = await prefsRes.text();
+
+
if (!prefsRes.ok) {
+
const parsed = parseApiResponse(prefsText);
+
throw new Error(parsed.message || "Failed to migrate preferences");
+
}
+
+
// Verify the data migration
+
await verifyDataMigration();
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage);
+
}
+
};
+
+
const verifyDataMigration = async () => {
+
setStatus("verifying");
+
+
try {
+
const result = await verifyMigrationStep(2);
+
+
if (result.ready) {
+
setStatus("completed");
+
setRetryCount(0);
+
setShowContinueAnyway(false);
+
onStepComplete();
+
} else {
+
const statusDetails = {
+
repoCommit: result.repoCommit,
+
repoRev: result.repoRev,
+
repoBlocks: result.repoBlocks,
+
expectedRecords: result.expectedRecords,
+
indexedRecords: result.indexedRecords,
+
privateStateValues: result.privateStateValues,
+
expectedBlobs: result.expectedBlobs,
+
importedBlobs: result.importedBlobs,
+
};
+
const errorMessage = `${
+
result.reason || "Verification failed"
+
}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`;
+
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
};
+
+
const retryVerification = async () => {
+
await verifyDataMigration();
+
};
+
+
const continueAnyway = () => {
+
setStatus("completed");
+
setShowContinueAnyway(false);
+
onStepComplete();
+
};
+
+
return (
+
<MigrationStep
+
name="Migrate Data"
+
status={status}
+
error={error}
+
isVerificationError={status === "error" &&
+
error?.includes("Verification failed")}
+
index={1}
+
onRetryVerification={retryVerification}
+
>
+
{status === "error" && showContinueAnyway && (
+
<div class="flex space-x-2 mt-2">
+
<button
+
type="button"
+
onClick={continueAnyway}
+
class="px-3 py-1 text-xs bg-white border border-gray-300 text-gray-700 hover:bg-gray-100 rounded transition-colors duration-200
+
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700"
+
>
+
Continue Anyway
+
</button>
+
</div>
+
)}
+
</MigrationStep>
+
);
+
}
+143
islands/migration-steps/FinalizationStep.tsx
···
···
+
import { useEffect, useState } from "preact/hooks";
+
import { MigrationStep } from "../../components/MigrationStep.tsx";
+
import {
+
parseApiResponse,
+
StepCommonProps,
+
verifyMigrationStep,
+
} from "../../lib/migration-types.ts";
+
+
interface FinalizationStepProps extends StepCommonProps {
+
isActive: boolean;
+
}
+
+
export default function FinalizationStep({
+
credentials: _credentials,
+
onStepComplete,
+
onStepError,
+
isActive,
+
}: FinalizationStepProps) {
+
const [status, setStatus] = useState<
+
"pending" | "in-progress" | "verifying" | "completed" | "error"
+
>("pending");
+
const [error, setError] = useState<string>();
+
const [retryCount, setRetryCount] = useState(0);
+
const [showContinueAnyway, setShowContinueAnyway] = useState(false);
+
+
useEffect(() => {
+
if (isActive && status === "pending") {
+
startFinalization();
+
}
+
}, [isActive]);
+
+
const startFinalization = async () => {
+
setStatus("in-progress");
+
setError(undefined);
+
+
try {
+
const finalizeRes = await fetch("/api/migrate/finalize", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
});
+
+
const finalizeData = await finalizeRes.text();
+
if (!finalizeRes.ok) {
+
const parsed = parseApiResponse(finalizeData);
+
throw new Error(parsed.message || "Failed to finalize migration");
+
}
+
+
const parsed = parseApiResponse(finalizeData);
+
if (!parsed.success) {
+
throw new Error(parsed.message || "Finalization failed");
+
}
+
+
// Verify the finalization
+
await verifyFinalization();
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage);
+
}
+
};
+
+
const verifyFinalization = async () => {
+
setStatus("verifying");
+
+
try {
+
const result = await verifyMigrationStep(4);
+
+
if (result.ready) {
+
setStatus("completed");
+
setRetryCount(0);
+
setShowContinueAnyway(false);
+
onStepComplete();
+
} else {
+
const statusDetails = {
+
activated: result.activated,
+
validDid: result.validDid,
+
};
+
const errorMessage = `${
+
result.reason || "Verification failed"
+
}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`;
+
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
};
+
+
const retryVerification = async () => {
+
await verifyFinalization();
+
};
+
+
const continueAnyway = () => {
+
setStatus("completed");
+
setShowContinueAnyway(false);
+
onStepComplete();
+
};
+
+
return (
+
<MigrationStep
+
name="Finalize Migration"
+
status={status}
+
error={error}
+
isVerificationError={status === "error" &&
+
error?.includes("Verification failed")}
+
index={3}
+
onRetryVerification={retryVerification}
+
>
+
{status === "error" && showContinueAnyway && (
+
<div class="flex space-x-2 mt-2">
+
<button
+
type="button"
+
onClick={continueAnyway}
+
class="px-3 py-1 text-xs bg-white border border-gray-300 text-gray-700 hover:bg-gray-100 rounded transition-colors duration-200
+
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700"
+
>
+
Continue Anyway
+
</button>
+
</div>
+
)}
+
</MigrationStep>
+
);
+
}
+294
islands/migration-steps/IdentityMigrationStep.tsx
···
···
+
import { useEffect, useRef, useState } from "preact/hooks";
+
import { MigrationStep } from "../../components/MigrationStep.tsx";
+
import {
+
parseApiResponse,
+
StepCommonProps,
+
verifyMigrationStep,
+
} from "../../lib/migration-types.ts";
+
+
interface IdentityMigrationStepProps extends StepCommonProps {
+
isActive: boolean;
+
}
+
+
export default function IdentityMigrationStep({
+
credentials: _credentials,
+
onStepComplete,
+
onStepError,
+
isActive,
+
}: IdentityMigrationStepProps) {
+
const [status, setStatus] = useState<
+
"pending" | "in-progress" | "verifying" | "completed" | "error"
+
>("pending");
+
const [error, setError] = useState<string>();
+
const [retryCount, setRetryCount] = useState(0);
+
const [showContinueAnyway, setShowContinueAnyway] = useState(false);
+
const [token, setToken] = useState("");
+
const [identityRequestSent, setIdentityRequestSent] = useState(false);
+
const [identityRequestCooldown, setIdentityRequestCooldown] = useState(0);
+
const [cooldownInterval, setCooldownInterval] = useState<number | null>(null);
+
const [stepName, setStepName] = useState("Migrate Identity");
+
const identityRequestInProgressRef = useRef(false);
+
+
// Clean up interval on unmount
+
useEffect(() => {
+
return () => {
+
if (cooldownInterval !== null) {
+
clearInterval(cooldownInterval);
+
}
+
};
+
}, [cooldownInterval]);
+
+
useEffect(() => {
+
if (isActive && status === "pending") {
+
startIdentityMigration();
+
}
+
}, [isActive]);
+
+
const startIdentityMigration = async () => {
+
// Prevent multiple concurrent calls
+
if (identityRequestInProgressRef.current) {
+
return;
+
}
+
+
identityRequestInProgressRef.current = true;
+
setStatus("in-progress");
+
setError(undefined);
+
+
// Don't send duplicate requests
+
if (identityRequestSent) {
+
setStepName(
+
"Enter the token sent to your email to complete identity migration",
+
);
+
setTimeout(() => {
+
identityRequestInProgressRef.current = false;
+
}, 1000);
+
return;
+
}
+
+
try {
+
const requestRes = await fetch("/api/migrate/identity/request", {
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
});
+
+
const requestText = await requestRes.text();
+
+
if (!requestRes.ok) {
+
const parsed = parseApiResponse(requestText);
+
throw new Error(
+
parsed.message || "Failed to request identity migration",
+
);
+
}
+
+
const parsed = parseApiResponse(requestText);
+
if (!parsed.success) {
+
throw new Error(parsed.message || "Identity migration request failed");
+
}
+
+
// Mark request as sent
+
setIdentityRequestSent(true);
+
+
// Handle rate limiting
+
const jsonData = JSON.parse(requestText);
+
if (jsonData.rateLimited && jsonData.cooldownRemaining) {
+
setIdentityRequestCooldown(jsonData.cooldownRemaining);
+
+
// Clear any existing interval
+
if (cooldownInterval !== null) {
+
clearInterval(cooldownInterval);
+
}
+
+
// Set up countdown timer
+
const intervalId = setInterval(() => {
+
setIdentityRequestCooldown((prev) => {
+
if (prev <= 1) {
+
clearInterval(intervalId);
+
setCooldownInterval(null);
+
return 0;
+
}
+
return prev - 1;
+
});
+
}, 1000);
+
+
setCooldownInterval(intervalId);
+
}
+
+
// Update step name to prompt for token
+
setStepName(
+
identityRequestCooldown > 0
+
? `Please wait ${identityRequestCooldown}s before requesting another code`
+
: "Enter the token sent to your email to complete identity migration",
+
);
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
// Don't mark as error if it was due to rate limiting
+
if (identityRequestCooldown > 0) {
+
setStatus("in-progress");
+
} else {
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage);
+
}
+
} finally {
+
setTimeout(() => {
+
identityRequestInProgressRef.current = false;
+
}, 1000);
+
}
+
};
+
+
const handleIdentityMigration = async () => {
+
if (!token) return;
+
+
try {
+
const identityRes = await fetch(
+
`/api/migrate/identity/sign?token=${encodeURIComponent(token)}`,
+
{
+
method: "POST",
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
+
const identityData = await identityRes.text();
+
if (!identityRes.ok) {
+
const parsed = parseApiResponse(identityData);
+
throw new Error(
+
parsed.message || "Failed to complete identity migration",
+
);
+
}
+
+
const parsed = parseApiResponse(identityData);
+
if (!parsed.success) {
+
throw new Error(parsed.message || "Identity migration failed");
+
}
+
+
// Verify the identity migration
+
await verifyIdentityMigration();
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage);
+
}
+
};
+
+
const verifyIdentityMigration = async () => {
+
setStatus("verifying");
+
+
try {
+
const result = await verifyMigrationStep(3);
+
+
if (result.ready) {
+
setStatus("completed");
+
setRetryCount(0);
+
setShowContinueAnyway(false);
+
onStepComplete();
+
} else {
+
const statusDetails = {
+
activated: result.activated,
+
validDid: result.validDid,
+
};
+
const errorMessage = `${
+
result.reason || "Verification failed"
+
}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`;
+
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
setRetryCount((prev) => prev + 1);
+
if (retryCount >= 1) {
+
setShowContinueAnyway(true);
+
}
+
+
setError(errorMessage);
+
setStatus("error");
+
onStepError(errorMessage, true);
+
}
+
};
+
+
const retryVerification = async () => {
+
await verifyIdentityMigration();
+
};
+
+
const continueAnyway = () => {
+
setStatus("completed");
+
setShowContinueAnyway(false);
+
onStepComplete();
+
};
+
+
return (
+
<MigrationStep
+
name={stepName}
+
status={status}
+
error={error}
+
isVerificationError={status === "error" &&
+
error?.includes("Verification failed")}
+
index={2}
+
onRetryVerification={retryVerification}
+
>
+
{status === "error" && showContinueAnyway && (
+
<div class="flex space-x-2 mt-2">
+
<button
+
type="button"
+
onClick={continueAnyway}
+
class="px-3 py-1 text-xs bg-white border border-gray-300 text-gray-700 hover:bg-gray-100 rounded transition-colors duration-200
+
dark:bg-gray-800 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700"
+
>
+
Continue Anyway
+
</button>
+
</div>
+
)}
+
+
{(status === "in-progress" || identityRequestSent) &&
+
stepName.includes("Enter the token sent to your email") &&
+
(identityRequestCooldown > 0
+
? (
+
<div class="mt-4">
+
<p class="text-sm text-amber-600 dark:text-amber-400">
+
<span class="font-medium">Rate limit:</span> Please wait{" "}
+
{identityRequestCooldown}{" "}
+
seconds before requesting another code. Check your email inbox
+
and spam folder for a previously sent code.
+
</p>
+
</div>
+
)
+
: (
+
<div class="mt-4 space-y-4">
+
<p class="text-sm text-blue-800 dark:text-blue-200">
+
Please check your email for the migration token and enter it
+
below:
+
</p>
+
<div class="flex space-x-2">
+
<input
+
type="text"
+
value={token}
+
onChange={(e) => setToken(e.currentTarget.value)}
+
placeholder="Enter token"
+
class="flex-1 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"
+
/>
+
<button
+
type="button"
+
onClick={handleIdentityMigration}
+
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors duration-200"
+
>
+
Submit Token
+
</button>
+
</div>
+
</div>
+
))}
+
</MigrationStep>
+
);
+
}
+7
lib/check-dids.ts
···
···
+
import { getSession } from "./sessions.ts";
+
+
export async function checkDidsMatch(req: Request): Promise<boolean> {
+
const oldSession = await getSession(req, undefined, false);
+
const newSession = await getSession(req, undefined, true);
+
return oldSession.did === newSession.did;
+
}
+20 -28
lib/cred/sessions.ts
···
import { Agent } from "npm:@atproto/api";
import { getIronSession, SessionOptions } from "npm:iron-session";
-
import { CredentialSession, createSessionOptions } from "../types.ts";
let migrationSessionOptions: SessionOptions;
let credentialSessionOptions: SessionOptions;
···
}
return migrationSessionOptions;
}
-
if (!credentialSessionOptions) {
credentialSessionOptions = await createSessionOptions("cred_sid");
}
···
export async function getCredentialSession(
req: Request,
res: Response = new Response(),
-
isMigration: boolean = false
) {
const options = await getOptions(isMigration);
-
return getIronSession<CredentialSession>(
-
req,
-
res,
-
options,
-
);
}
/**
···
res: Response = new Response(),
isMigration: boolean = false,
) {
-
const session = await getCredentialSession(
-
req,
-
res,
-
isMigration
-
);
-
if (!session.did || !session.service || !session.handle || !session.password) {
return null;
}
···
data: CredentialSession,
isMigration: boolean = false,
) {
-
const session = await getCredentialSession(
-
req,
-
res,
-
isMigration
-
);
session.did = data.did;
session.handle = data.handle;
session.service = data.service;
···
res: Response = new Response(),
isMigration: boolean = false,
) {
-
const session = await getCredentialSession(
-
req,
-
res,
-
isMigration
-
);
console.log("Session state:", {
hasDid: !!session.did,
···
hasPassword: !!session.password,
hasAccessJwt: !!session.accessJwt,
service: session.service,
-
handle: session.handle
});
if (
-
!session.did || !session.service || !session.handle || !session.password
) {
console.log("Missing required session fields");
return null;
···
const sessionInfo = await agent.com.atproto.server.getSession();
console.log("Stored JWT is valid, session info:", {
did: sessionInfo.data.did,
-
handle: sessionInfo.data.handle
});
return agent;
} catch (err) {
···
console.log("Session created successfully:", {
did: sessionRes.data.did,
handle: sessionRes.data.handle,
-
hasAccessJwt: !!sessionRes.data.accessJwt
});
// Store the new token
···
import { Agent } from "npm:@atproto/api";
import { getIronSession, SessionOptions } from "npm:iron-session";
+
import { createSessionOptions, CredentialSession } from "../types.ts";
let migrationSessionOptions: SessionOptions;
let credentialSessionOptions: SessionOptions;
···
}
return migrationSessionOptions;
}
+
if (!credentialSessionOptions) {
credentialSessionOptions = await createSessionOptions("cred_sid");
}
···
export async function getCredentialSession(
req: Request,
res: Response = new Response(),
+
isMigration: boolean = false,
) {
const options = await getOptions(isMigration);
+
return getIronSession<CredentialSession>(req, res, options);
}
/**
···
res: Response = new Response(),
isMigration: boolean = false,
) {
+
const session = await getCredentialSession(req, res, isMigration);
+
if (
+
!session.did ||
+
!session.service ||
+
!session.handle ||
+
!session.password
+
) {
return null;
}
···
data: CredentialSession,
isMigration: boolean = false,
) {
+
const session = await getCredentialSession(req, res, isMigration);
session.did = data.did;
session.handle = data.handle;
session.service = data.service;
···
res: Response = new Response(),
isMigration: boolean = false,
) {
+
const session = await getCredentialSession(req, res, isMigration);
console.log("Session state:", {
hasDid: !!session.did,
···
hasPassword: !!session.password,
hasAccessJwt: !!session.accessJwt,
service: session.service,
+
handle: session.handle,
});
if (
+
!session.did ||
+
!session.service ||
+
!session.handle ||
+
!session.password
) {
console.log("Missing required session fields");
return null;
···
const sessionInfo = await agent.com.atproto.server.getSession();
console.log("Stored JWT is valid, session info:", {
did: sessionInfo.data.did,
+
handle: sessionInfo.data.handle,
});
return agent;
} catch (err) {
···
console.log("Session created successfully:", {
did: sessionRes.data.did,
handle: sessionRes.data.handle,
+
hasAccessJwt: !!sessionRes.data.accessJwt,
});
// Store the new token
+3 -3
lib/id-resolver.ts
···
},
async resolveHandleToDid(handle: string) {
-
return await resolver.handle.resolve(handle) as Did
},
async resolveDidToPdsUrl(did: string): Promise<string | undefined> {
···
return didDoc.pds;
} else {
const forcedDidDoc = await resolver.did.resolveAtprotoData(
-
did,
true,
-
)
if (forcedDidDoc.pds) {
return forcedDidDoc.pds;
}
···
},
async resolveHandleToDid(handle: string) {
+
return await resolver.handle.resolve(handle) as Did;
},
async resolveDidToPdsUrl(did: string): Promise<string | undefined> {
···
return didDoc.pds;
} else {
const forcedDidDoc = await resolver.did.resolveAtprotoData(
+
did,
true,
+
);
if (forcedDidDoc.pds) {
return forcedDidDoc.pds;
}
+73
lib/migration-state.ts
···
···
+
/**
+
* Migration state types and utilities for controlling migration availability.
+
*/
+
+
export type MigrationState = "up" | "issue" | "maintenance";
+
+
export interface MigrationStateInfo {
+
state: MigrationState;
+
message: string;
+
allowMigration: boolean;
+
}
+
+
/**
+
* Get the current migration state from environment variables.
+
* @returns The migration state information
+
*/
+
export function getMigrationState(): MigrationStateInfo {
+
const state = (Deno.env.get("MIGRATION_STATE") || "up")
+
.toLowerCase() as MigrationState;
+
+
switch (state) {
+
case "issue":
+
return {
+
state: "issue",
+
message:
+
"Migration services are temporarily unavailable as we investigate an issue. Please try again later.",
+
allowMigration: false,
+
};
+
+
case "maintenance":
+
return {
+
state: "maintenance",
+
message:
+
"Migration services are temporarily unavailable for maintenance. Please try again later.",
+
allowMigration: false,
+
};
+
+
case "up":
+
default:
+
return {
+
state: "up",
+
message: "Migration services are operational.",
+
allowMigration: true,
+
};
+
}
+
}
+
+
/**
+
* Check if migrations are currently allowed.
+
* @returns True if migrations are allowed, false otherwise
+
*/
+
export function isMigrationAllowed(): boolean {
+
return getMigrationState().allowMigration;
+
}
+
+
/**
+
* Get a user-friendly message for the current migration state.
+
* @returns The message to display to users
+
*/
+
export function getMigrationStateMessage(): string {
+
return getMigrationState().message;
+
}
+
+
/**
+
* Throw an error if migrations are not allowed.
+
* Used in API endpoints to prevent migration operations when disabled.
+
*/
+
export function assertMigrationAllowed(): void {
+
const stateInfo = getMigrationState();
+
if (!stateInfo.allowMigration) {
+
throw new Error(stateInfo.message);
+
}
+
}
+63
lib/migration-types.ts
···
···
+
/**
+
* Shared types for migration components
+
*/
+
+
export interface MigrationStateInfo {
+
state: "up" | "issue" | "maintenance";
+
message: string;
+
allowMigration: boolean;
+
}
+
+
export interface MigrationCredentials {
+
service: string;
+
handle: string;
+
email: string;
+
password: string;
+
invite?: string;
+
}
+
+
export interface StepCommonProps {
+
credentials: MigrationCredentials;
+
onStepComplete: () => void;
+
onStepError: (error: string, isVerificationError?: boolean) => void;
+
}
+
+
export interface VerificationResult {
+
ready: boolean;
+
reason?: string;
+
activated?: boolean;
+
validDid?: boolean;
+
repoCommit?: boolean;
+
repoRev?: boolean;
+
repoBlocks?: number;
+
expectedRecords?: number;
+
indexedRecords?: number;
+
privateStateValues?: number;
+
expectedBlobs?: number;
+
importedBlobs?: number;
+
}
+
+
/**
+
* Helper function to verify a migration step
+
*/
+
export async function verifyMigrationStep(
+
stepNum: number,
+
): Promise<VerificationResult> {
+
const res = await fetch(`/api/migrate/status?step=${stepNum}`);
+
const data = await res.json();
+
return data;
+
}
+
+
/**
+
* Helper function to handle API responses with proper error parsing
+
*/
+
export function parseApiResponse(
+
responseText: string,
+
): { success: boolean; message?: string } {
+
try {
+
const json = JSON.parse(responseText);
+
return { success: json.success !== false, message: json.message };
+
} catch {
+
return { success: responseText.trim() !== "", message: responseText };
+
}
+
}
+2 -2
lib/oauth/sessions.ts
···
import { Agent } from "npm:@atproto/api";
import { getIronSession, SessionOptions } from "npm:iron-session";
import { oauthClient } from "./client.ts";
-
import { OauthSession, createSessionOptions } from "../types.ts";
let oauthSessionOptions: SessionOptions;
···
* @returns The OAuth session agent
*/
export async function getOauthSessionAgent(
-
req: Request
) {
try {
console.log("Getting OAuth session...");
···
import { Agent } from "npm:@atproto/api";
import { getIronSession, SessionOptions } from "npm:iron-session";
import { oauthClient } from "./client.ts";
+
import { createSessionOptions, OauthSession } from "../types.ts";
let oauthSessionOptions: SessionOptions;
···
* @returns The OAuth session agent
*/
export async function getOauthSessionAgent(
+
req: Request,
) {
try {
console.log("Getting OAuth session...");
+31 -10
lib/sessions.ts
···
import { Agent } from "npm:@atproto/api";
-
import { OauthSession, CredentialSession } from "./types.ts";
-
import { getCredentialSession, getCredentialSessionAgent } from "./cred/sessions.ts";
import { getOauthSession, getOauthSessionAgent } from "./oauth/sessions.ts";
import { IronSession } from "npm:iron-session";
···
export async function getSession(
req: Request,
res: Response = new Response(),
-
isMigration: boolean = false
): Promise<IronSession<OauthSession | CredentialSession>> {
if (isMigration) {
return await getCredentialSession(req, res, true);
···
const credentialSession = await getCredentialSession(req, res);
if (oauthSession.did) {
-
console.log("Oauth session found")
return oauthSession;
}
if (credentialSession.did) {
···
export async function getSessionAgent(
req: Request,
res: Response = new Response(),
-
isMigration: boolean = false
): Promise<Agent | null> {
if (isMigration) {
return await getCredentialSessionAgent(req, res, isMigration);
}
const oauthAgent = await getOauthSessionAgent(req);
-
const credentialAgent = await getCredentialSessionAgent(req, res, isMigration);
if (oauthAgent) {
return oauthAgent;
···
/**
* Destroy all sessions for the given request.
* @param req - The request object
*/
-
export async function destroyAllSessions(req: Request) {
-
const oauthSession = await getOauthSession(req);
-
const credentialSession = await getCredentialSession(req);
-
const migrationSession = await getCredentialSession(req, new Response(), true);
if (oauthSession.did) {
oauthSession.destroy();
···
credentialSession.destroy();
}
if (migrationSession.did) {
migrationSession.destroy();
}
}
···
import { Agent } from "npm:@atproto/api";
+
import { CredentialSession, OauthSession } from "./types.ts";
+
import {
+
getCredentialSession,
+
getCredentialSessionAgent,
+
} from "./cred/sessions.ts";
import { getOauthSession, getOauthSessionAgent } from "./oauth/sessions.ts";
import { IronSession } from "npm:iron-session";
···
export async function getSession(
req: Request,
res: Response = new Response(),
+
isMigration: boolean = false,
): Promise<IronSession<OauthSession | CredentialSession>> {
if (isMigration) {
return await getCredentialSession(req, res, true);
···
const credentialSession = await getCredentialSession(req, res);
if (oauthSession.did) {
+
console.log("Oauth session found");
return oauthSession;
}
if (credentialSession.did) {
···
export async function getSessionAgent(
req: Request,
res: Response = new Response(),
+
isMigration: boolean = false,
): Promise<Agent | null> {
if (isMigration) {
return await getCredentialSessionAgent(req, res, isMigration);
}
const oauthAgent = await getOauthSessionAgent(req);
+
const credentialAgent = await getCredentialSessionAgent(
+
req,
+
res,
+
isMigration,
+
);
if (oauthAgent) {
return oauthAgent;
···
/**
* Destroy all sessions for the given request.
* @param req - The request object
+
* @param res - The response object
*/
+
export async function destroyAllSessions(
+
req: Request,
+
res?: Response,
+
): Promise<Response> {
+
const response = res || new Response();
+
const oauthSession = await getOauthSession(req, response);
+
const credentialSession = await getCredentialSession(req, res);
+
const migrationSession = await getCredentialSession(
+
req,
+
res,
+
true,
+
);
if (oauthSession.did) {
oauthSession.destroy();
···
credentialSession.destroy();
}
if (migrationSession.did) {
+
console.log("DESTROYING MIGRATION SESSION", migrationSession);
migrationSession.destroy();
+
} else {
+
console.log("MIGRATION SESSION NOT FOUND", migrationSession);
}
+
+
return response;
}
+1 -1
lib/storage.ts
···
NodeSavedSessionStore,
NodeSavedState,
NodeSavedStateStore,
-
} from "jsr:@bigmoves/atproto-oauth-client";
/**
* The state store for sessions.
···
NodeSavedSessionStore,
NodeSavedState,
NodeSavedStateStore,
+
} from "@bigmoves/atproto-oauth-client";
/**
* The state store for sessions.
+32 -26
lib/types.ts
···
* @param db - The Deno KV instance for the database
* @returns The unlock function
*/
-
async function createLock(key: string, db: Deno.Kv): Promise<() => Promise<void>> {
const lockKey = ["session_lock", key];
const lockValue = Date.now();
-
// Try to acquire lock
const result = await db.atomic()
-
.check({ key: lockKey, versionstamp: null }) // Only if key doesn't exist
-
.set(lockKey, lockValue, { expireIn: 5000 }) // 5 second TTL
.commit();
if (!result.ok) {
···
* @type {OauthSession}
*/
export interface OauthSession {
-
did: string
}
/**
···
* @param cookieName - The name of the iron session cookie
* @returns The session options for iron session
*/
-
export const createSessionOptions = async (cookieName: string): Promise<SessionOptions> => {
-
const cookieSecret = Deno.env.get("COOKIE_SECRET");
-
if (!cookieSecret) {
-
throw new Error("COOKIE_SECRET is not set");
-
}
-
if (!db) {
-
db = await Deno.openKv();
-
}
-
return {
-
cookieName: cookieName,
-
password: cookieSecret,
-
cookieOptions: {
-
secure: Deno.env.get("NODE_ENV") === "production" || Deno.env.get("NODE_ENV") === "staging",
-
httpOnly: true,
-
sameSite: "lax",
-
path: "/",
-
domain: undefined,
-
},
-
lockFn: (key: string) => createLock(key, db)
-
}
-
};
···
* @param db - The Deno KV instance for the database
* @returns The unlock function
*/
+
async function createLock(
+
key: string,
+
db: Deno.Kv,
+
): Promise<() => Promise<void>> {
const lockKey = ["session_lock", key];
const lockValue = Date.now();
+
// Try to acquire lock
const result = await db.atomic()
+
.check({ key: lockKey, versionstamp: null }) // Only if key doesn't exist
+
.set(lockKey, lockValue, { expireIn: 5000 }) // 5 second TTL
.commit();
if (!result.ok) {
···
* @type {OauthSession}
*/
export interface OauthSession {
+
did: string;
}
/**
···
* @param cookieName - The name of the iron session cookie
* @returns The session options for iron session
*/
+
export const createSessionOptions = async (
+
cookieName: string,
+
): Promise<SessionOptions> => {
+
const cookieSecret = Deno.env.get("COOKIE_SECRET");
+
if (!cookieSecret) {
+
throw new Error("COOKIE_SECRET is not set");
+
}
+
if (!db) {
+
db = await Deno.openKv();
+
}
+
return {
+
cookieName: cookieName,
+
password: cookieSecret,
+
cookieOptions: {
+
secure: Deno.env.get("NODE_ENV") === "production" ||
+
Deno.env.get("NODE_ENV") === "staging",
+
httpOnly: true,
+
sameSite: "lax",
+
path: "/",
+
domain: undefined,
+
},
+
lockFn: (key: string) => createLock(key, db),
+
};
+
};
routes/.DS_Store

This is a binary file and will not be displayed.

+5 -5
routes/_error.tsx
···
-
import { PageProps, HttpError } from "fresh";
import posthog from "posthog-js";
export default function ErrorPage(props: PageProps) {
const error = props.error; // Contains the thrown Error or HTTPError
if (error instanceof HttpError) {
-
posthog.default.capture('error', {
error: error.message,
status: error.status,
});
···
FLIGHT NOT FOUND
</p>
<p class="text-lg sm:text-xl text-slate-600 dark:text-white/70 max-w-2xl">
-
We couldn't locate the destination you're looking for. Please
-
check your flight number and try again.
</p>
<div class="mt-8">
<a
···
</div>
</div>
</>
-
)
}
}
···
+
import { HttpError, PageProps } from "fresh";
import posthog from "posthog-js";
export default function ErrorPage(props: PageProps) {
const error = props.error; // Contains the thrown Error or HTTPError
if (error instanceof HttpError) {
+
posthog.default.capture("error", {
error: error.message,
status: error.status,
});
···
FLIGHT NOT FOUND
</p>
<p class="text-lg sm:text-xl text-slate-600 dark:text-white/70 max-w-2xl">
+
We couldn't locate the destination you're looking for.
+
Please check your flight number and try again.
</p>
<div class="mt-8">
<a
···
</div>
</div>
</>
+
);
}
}
+68 -38
routes/about.tsx
···
<div class="px-2 sm:px-4 py-4 sm:py-8 mx-auto">
<div class="max-w-screen-lg mx-auto flex flex-col items-center justify-center">
<div class="prose dark:prose-invert max-w-none w-full mb-0">
-
<h1 class="text-3xl font-bold text-center mb-8">About AT Protocol</h1>
<div class="space-y-6">
<section>
-
<h2 class="text-2xl font-semibold mb-4">What is AT Protocol?</h2>
<p class="text-gray-600 dark:text-gray-300">
AT Protocol (Authenticated Transfer Protocol) is the
foundation of Bluesky and other social apps like
<a href="https://tangled.sh">Tangled</a>,
-
<a href="https://spark.com">Spark</a>, and more.
-
Unlike traditional social platforms that lock your
-
data and identity to a single service, AT Protocol
-
gives you complete control over your digital presence.
-
Think of it as an open standard for social networking,
-
similar to how email works across different providers.
</p>
</section>
···
<h2 class="text-2xl font-semibold mb-4">Key Features</h2>
<ul class="list-disc pl-6 space-y-4 text-gray-600 dark:text-gray-300">
<li>
-
<strong>PDS Servers:</strong> PDS servers are where your data is stored.
-
They can be run by anyone, and they are very lightweight, allowing you to
-
choose which one to use or run your own. PDS servers just store your data,
-
meaning you don't have to switch PDS servers to use a different app or service.
-
You can have one PDS while using many different apps and services with the
same account.
</li>
<li>
-
<strong>Decentralized Identity:</strong> Your account is tied to a DID
-
(Decentralized Identifier) rather than your handle/username.
-
This means you can move your entire account, including your followers
-
and content, to any PDS by changing where your DID points.
-
It's also the reason you can use any domain as your handle, because
-
your identity is not tied to your handle. Your handle can change,
but your DID will always remain the same.
</li>
<li>
-
<strong>Portable Content:</strong> All your posts, likes, and other social
-
data are stored in your Personal Data Server (PDS).
-
You can switch PDS providers without losing any content or connections.
</li>
<li>
-
<strong>Architecture:</strong> The protocol uses a three-tier architecture:
-
Personal Data Servers (PDS) store your content,
-
relays broadcast a stream of all events on all PDSes,
-
and AppViews process and serve that stream into content for users.
-
This means when you make a post, the content is stored on your PDS,
-
picked up by relays, and AppViews listen to those relays to deliver
-
that post to all users.
</li>
<li>
-
<strong>Algorithmic Choice:</strong> You're not locked into a single algorithm
-
for your feed. Different services can offer different ways of curating content,
-
and you can choose which one you prefer. Bluesky offers a way to make custom
-
feeds, but even if it didn't, different apps could still offer their own
-
algorithms for curating content.
</li>
</ul>
</section>
···
<h2 class="text-2xl font-semibold mb-4">Learn More</h2>
<div class="space-y-4">
<p class="text-gray-600 dark:text-gray-300">
-
Want to dive deeper into AT Protocol? Check out these resources:
</p>
<ul class="list-none space-y-2">
<li>
-
<a href="https://atproto.com" class="text-blue-500 hover:underline">Official AT Protocol Docs</a> - The main source for protocol specs and information
</li>
<li>
-
<a href="https://github.com/bluesky-social/atproto" class="text-blue-500 hover:underline">GitHub Repository</a> - View the protocol implementation
</li>
<li>
-
<a href="https://atproto.wiki" class="text-blue-500 hover:underline">AT Protocol Wiki</a> - Community-driven documentation and resources
</li>
</ul>
</div>
···
<div class="px-2 sm:px-4 py-4 sm:py-8 mx-auto">
<div class="max-w-screen-lg mx-auto flex flex-col items-center justify-center">
<div class="prose dark:prose-invert max-w-none w-full mb-0">
+
<h1 class="text-3xl font-bold text-center mb-8">
+
About AT Protocol
+
</h1>
<div class="space-y-6">
<section>
+
<h2 class="text-2xl font-semibold mb-4">
+
What is AT Protocol?
+
</h2>
<p class="text-gray-600 dark:text-gray-300">
AT Protocol (Authenticated Transfer Protocol) is the
foundation of Bluesky and other social apps like
<a href="https://tangled.sh">Tangled</a>,
+
<a href="https://spark.com">Spark</a>, and more. Unlike
+
traditional social platforms that lock your data and identity
+
to a single service, AT Protocol gives you complete control
+
over your digital presence. Think of it as an open standard
+
for social networking, similar to how email works across
+
different providers.
</p>
</section>
···
<h2 class="text-2xl font-semibold mb-4">Key Features</h2>
<ul class="list-disc pl-6 space-y-4 text-gray-600 dark:text-gray-300">
<li>
+
<strong>PDS Servers:</strong>{" "}
+
PDS servers are where your data is stored. They can be run
+
by anyone, and they are very lightweight, allowing you to
+
choose which one to use or run your own. PDS servers just
+
store your data, meaning you don't have to switch PDS
+
servers to use a different app or service. You can have one
+
PDS while using many different apps and services with the
same account.
</li>
<li>
+
<strong>Decentralized Identity:</strong>{" "}
+
Your account is tied to a DID (Decentralized Identifier)
+
rather than your handle/username. This means you can move
+
your entire account, including your followers and content,
+
to any PDS by changing where your DID points. It's also the
+
reason you can use any domain as your handle, because your
+
identity is not tied to your handle. Your handle can change,
but your DID will always remain the same.
</li>
<li>
+
<strong>Portable Content:</strong>{" "}
+
All your posts, likes, and other social data are stored in
+
your Personal Data Server (PDS). You can switch PDS
+
providers without losing any content or connections.
</li>
<li>
+
<strong>Architecture:</strong>{" "}
+
The protocol uses a three-tier architecture: Personal Data
+
Servers (PDS) store your content, relays broadcast a stream
+
of all events on all PDSes, and AppViews process and serve
+
that stream into content for users. This means when you make
+
a post, the content is stored on your PDS, picked up by
+
relays, and AppViews listen to those relays to deliver that
+
post to all users.
</li>
<li>
+
<strong>Algorithmic Choice:</strong>{" "}
+
You're not locked into a single algorithm for your feed.
+
Different services can offer different ways of curating
+
content, and you can choose which one you prefer. Bluesky
+
offers a way to make custom feeds, but even if it didn't,
+
different apps could still offer their own algorithms for
+
curating content.
</li>
</ul>
</section>
···
<h2 class="text-2xl font-semibold mb-4">Learn More</h2>
<div class="space-y-4">
<p class="text-gray-600 dark:text-gray-300">
+
Want to dive deeper into AT Protocol? Check out these
+
resources:
</p>
<ul class="list-none space-y-2">
<li>
+
<a
+
href="https://atproto.com"
+
class="text-blue-500 hover:underline"
+
>
+
Official AT Protocol Docs
+
</a>{" "}
+
- The main source for protocol specs and information
</li>
<li>
+
<a
+
href="https://github.com/bluesky-social/atproto"
+
class="text-blue-500 hover:underline"
+
>
+
GitHub Repository
+
</a>{" "}
+
- View the protocol implementation
</li>
<li>
+
<a
+
href="https://atproto.wiki"
+
class="text-blue-500 hover:underline"
+
>
+
AT Protocol Wiki
+
</a>{" "}
+
- Community-driven documentation and resources
</li>
</ul>
</div>
routes/api/.DS_Store

This is a binary file and will not be displayed.

+59 -41
routes/api/cred/login.ts
···
const { handle, password } = body;
if (!handle || !password) {
-
return new Response(JSON.stringify({
-
success: false,
-
message: "Handle and password are required"
-
}), {
-
status: 400,
-
headers: { "Content-Type": "application/json" }
-
});
}
console.log("Resolving handle:", handle);
-
const did = await resolver.resolveHandleToDid(handle)
-
const service = await resolver.resolveDidToPdsUrl(did)
console.log("Resolved service:", service);
if (!service) {
-
return new Response(JSON.stringify({
-
success: false,
-
message: "Invalid handle"
-
}), {
-
status: 400,
-
})
}
try {
···
console.log("Created ATProto session:", {
did: sessionRes.data.did,
handle: sessionRes.data.handle,
-
hasAccessJwt: !!sessionRes.data.accessJwt
});
// Create response for setting cookies
-
const response = new Response(JSON.stringify({
-
success: true,
-
did,
-
handle
-
}), {
-
status: 200,
-
headers: { "Content-Type": "application/json" }
-
});
// Create and save our client session with tokens
await setCredentialSession(ctx.req, response, {
···
service,
password,
handle,
-
accessJwt: sessionRes.data.accessJwt
});
// Log the response headers
console.log("Response headers:", {
cookies: response.headers.get("Set-Cookie"),
-
allHeaders: Object.fromEntries(response.headers.entries())
});
return response;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
console.error("Login failed:", message);
-
return new Response(JSON.stringify({
-
success: false,
-
message: "Invalid credentials"
-
}), {
-
status: 401,
-
headers: { "Content-Type": "application/json" }
-
});
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Login error:", message);
-
return new Response(JSON.stringify({
-
success: false,
-
message: error instanceof Error ? error.message : "An error occurred"
-
}), {
-
status: 500,
-
headers: { "Content-Type": "application/json" }
-
});
}
-
}
});
···
const { handle, password } = body;
if (!handle || !password) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Handle and password are required",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
}
+
);
}
console.log("Resolving handle:", handle);
+
const did =
+
typeof handle == "string" && handle.startsWith("did:")
+
? handle
+
: await resolver.resolveHandleToDid(handle);
+
const service = await resolver.resolveDidToPdsUrl(did);
console.log("Resolved service:", service);
if (!service) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid handle",
+
}),
+
{
+
status: 400,
+
}
+
);
}
try {
···
console.log("Created ATProto session:", {
did: sessionRes.data.did,
handle: sessionRes.data.handle,
+
hasAccessJwt: !!sessionRes.data.accessJwt,
});
// Create response for setting cookies
+
const response = new Response(
+
JSON.stringify({
+
success: true,
+
did,
+
handle,
+
}),
+
{
+
status: 200,
+
headers: { "Content-Type": "application/json" },
+
}
+
);
// Create and save our client session with tokens
await setCredentialSession(ctx.req, response, {
···
service,
password,
handle,
+
accessJwt: sessionRes.data.accessJwt,
});
// Log the response headers
console.log("Response headers:", {
cookies: response.headers.get("Set-Cookie"),
+
allHeaders: Object.fromEntries(response.headers.entries()),
});
return response;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
console.error("Login failed:", message);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid credentials",
+
}),
+
{
+
status: 401,
+
headers: { "Content-Type": "application/json" },
+
}
+
);
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Login error:", message);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: error instanceof Error ? error.message : "An error occurred",
+
}),
+
{
+
status: 500,
+
headers: { "Content-Type": "application/json" },
+
}
+
);
}
+
},
});
+4 -4
routes/api/logout.ts
···
-
import { getSession, destroyAllSessions } from "../../lib/sessions.ts";
import { oauthClient } from "../../lib/oauth/client.ts";
import { define } from "../../utils.ts";
···
if (session.did) {
// Try to revoke both types of sessions - the one that doesn't exist will just no-op
await Promise.all([
-
oauthClient.revoke(session.did).catch(console.error)
]);
// Then destroy the iron session
session.destroy();
}
// Destroy all sessions including migration session
-
await destroyAllSessions(req);
-
return response;
} catch (error: unknown) {
const err = error instanceof Error ? error : new Error(String(error));
console.error("Logout failed:", err.message);
···
+
import { destroyAllSessions, getSession } from "../../lib/sessions.ts";
import { oauthClient } from "../../lib/oauth/client.ts";
import { define } from "../../utils.ts";
···
if (session.did) {
// Try to revoke both types of sessions - the one that doesn't exist will just no-op
await Promise.all([
+
oauthClient.revoke(session.did).catch(console.error),
]);
// Then destroy the iron session
session.destroy();
}
// Destroy all sessions including migration session
+
const result = await destroyAllSessions(req, response);
+
return result;
} catch (error: unknown) {
const err = error instanceof Error ? error : new Error(String(error));
console.error("Logout failed:", err.message);
+12 -9
routes/api/me.ts
···
const res = new Response();
try {
-
console.log("[/api/me] Request headers:", Object.fromEntries(req.headers.entries()));
const agent = await getSessionAgent(req, res);
if (!agent) {
···
status: 200,
headers: {
"Content-Type": "application/json",
-
"X-Response-Type": "null"
-
}
});
}
···
const responseData = {
did: session.data.did,
-
handle
};
return new Response(JSON.stringify(responseData), {
status: 200,
headers: {
"Content-Type": "application/json",
-
"X-Response-Type": "user"
-
}
});
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
···
stack: err instanceof Error ? err.stack : undefined,
url: req.url,
method: req.method,
-
headers: Object.fromEntries(req.headers.entries())
});
return new Response(JSON.stringify(null), {
···
headers: {
"Content-Type": "application/json",
"X-Response-Type": "error",
-
"X-Error-Message": encodeURIComponent(message)
-
}
});
}
},
···
const res = new Response();
try {
+
console.log(
+
"[/api/me] Request headers:",
+
Object.fromEntries(req.headers.entries()),
+
);
const agent = await getSessionAgent(req, res);
if (!agent) {
···
status: 200,
headers: {
"Content-Type": "application/json",
+
"X-Response-Type": "null",
+
},
});
}
···
const responseData = {
did: session.data.did,
+
handle,
};
return new Response(JSON.stringify(responseData), {
status: 200,
headers: {
"Content-Type": "application/json",
+
"X-Response-Type": "user",
+
},
});
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
···
stack: err instanceof Error ? err.stack : undefined,
url: req.url,
method: req.method,
+
headers: Object.fromEntries(req.headers.entries()),
});
return new Response(JSON.stringify(null), {
···
headers: {
"Content-Type": "application/json",
"X-Response-Type": "error",
+
"X-Error-Message": encodeURIComponent(message),
+
},
});
}
},
+6 -2
routes/api/migrate/create.ts
···
import { setCredentialSession } from "../../../lib/cred/sessions.ts";
import { Agent } from "@atproto/api";
import { define } from "../../../utils.ts";
/**
* Handle account creation
···
async POST(ctx) {
const res = new Response();
try {
const body = await ctx.req.json();
const serviceUrl = body.service;
const newHandle = body.handle;
···
return new Response("Could not create new agent", { status: 400 });
}
-
console.log("getting did")
const session = await oldAgent.com.atproto.server.getSession();
const accountDid = session.data.did;
-
console.log("got did")
const describeRes = await newAgent.com.atproto.server.describeServer();
const newServerDid = describeRes.data.did;
const inviteRequired = describeRes.data.inviteCodeRequired ?? false;
···
import { setCredentialSession } from "../../../lib/cred/sessions.ts";
import { Agent } from "@atproto/api";
import { define } from "../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../lib/migration-state.ts";
/**
* Handle account creation
···
async POST(ctx) {
const res = new Response();
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
const body = await ctx.req.json();
const serviceUrl = body.service;
const newHandle = body.handle;
···
return new Response("Could not create new agent", { status: 400 });
}
+
console.log("getting did");
const session = await oldAgent.com.atproto.server.getSession();
const accountDid = session.data.did;
+
console.log("got did");
const describeRes = await newAgent.com.atproto.server.describeServer();
const newServerDid = describeRes.data.did;
const inviteRequired = describeRes.data.inviteCodeRequired ?? false;
+359
routes/api/migrate/data/blobs.ts
···
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../../lib/check-dids.ts";
+
import { define } from "../../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../../lib/migration-state.ts";
+
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
+
console.log("Blob migration: Starting session retrieval");
+
const oldAgent = await getSessionAgent(ctx.req);
+
console.log("Blob migration: Got old agent:", !!oldAgent);
+
+
const newAgent = await getSessionAgent(ctx.req, res, true);
+
console.log("Blob migration: Got new agent:", !!newAgent);
+
+
if (!oldAgent) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Unauthorized",
+
}),
+
{
+
status: 401,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
if (!newAgent) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Migration session not found or invalid",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Migrate blobs
+
const migrationLogs: string[] = [];
+
const migratedBlobs: string[] = [];
+
const failedBlobs: string[] = [];
+
let pageCount = 0;
+
let blobCursor: string | undefined = undefined;
+
let totalBlobs = 0;
+
let processedBlobs = 0;
+
+
const startTime = Date.now();
+
console.log(`[${new Date().toISOString()}] Starting blob migration...`);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Starting blob migration...`,
+
);
+
+
// First count total blobs
+
console.log(`[${new Date().toISOString()}] Starting blob count...`);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Starting blob count...`,
+
);
+
+
const session = await oldAgent.com.atproto.server.getSession();
+
const accountDid = session.data.did;
+
+
do {
+
const pageStartTime = Date.now();
+
console.log(
+
`[${new Date().toISOString()}] Counting blobs on page ${
+
pageCount + 1
+
}...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Counting blobs on page ${
+
pageCount + 1
+
}...`,
+
);
+
const listedBlobs = await oldAgent.com.atproto.sync.listBlobs({
+
did: accountDid,
+
cursor: blobCursor,
+
});
+
+
const newBlobs = listedBlobs.data.cids.length;
+
totalBlobs += newBlobs;
+
const pageTime = Date.now() - pageStartTime;
+
+
console.log(
+
`[${new Date().toISOString()}] Found ${newBlobs} blobs on page ${
+
pageCount + 1
+
} in ${pageTime / 1000} seconds, total so far: ${totalBlobs}`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Found ${newBlobs} blobs on page ${
+
pageCount + 1
+
} in ${pageTime / 1000} seconds, total so far: ${totalBlobs}`,
+
);
+
+
pageCount++;
+
blobCursor = listedBlobs.data.cursor;
+
} while (blobCursor);
+
+
console.log(
+
`[${new Date().toISOString()}] Total blobs to migrate: ${totalBlobs}`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Total blobs to migrate: ${totalBlobs}`,
+
);
+
+
// Reset cursor for actual migration
+
blobCursor = undefined;
+
pageCount = 0;
+
processedBlobs = 0;
+
+
do {
+
const pageStartTime = Date.now();
+
console.log(
+
`[${new Date().toISOString()}] Fetching blob list page ${
+
pageCount + 1
+
}...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Fetching blob list page ${
+
pageCount + 1
+
}...`,
+
);
+
+
const listedBlobs = await oldAgent.com.atproto.sync.listBlobs({
+
did: accountDid,
+
cursor: blobCursor,
+
});
+
+
const pageTime = Date.now() - pageStartTime;
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Found ${listedBlobs.data.cids.length} blobs on page ${
+
pageCount + 1
+
} in ${pageTime / 1000} seconds`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Found ${listedBlobs.data.cids.length} blobs on page ${
+
pageCount + 1
+
} in ${pageTime / 1000} seconds`,
+
);
+
+
blobCursor = listedBlobs.data.cursor;
+
+
for (const cid of listedBlobs.data.cids) {
+
try {
+
const blobStartTime = Date.now();
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Starting migration for blob ${cid} (${
+
processedBlobs + 1
+
} of ${totalBlobs})...`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Starting migration for blob ${cid} (${
+
processedBlobs + 1
+
} of ${totalBlobs})...`,
+
);
+
+
const blobRes = await oldAgent.com.atproto.sync.getBlob({
+
did: accountDid,
+
cid,
+
});
+
+
const contentLength = blobRes.headers["content-length"];
+
if (!contentLength) {
+
throw new Error(`Blob ${cid} has no content length`);
+
}
+
+
const size = parseInt(contentLength, 10);
+
if (isNaN(size)) {
+
throw new Error(
+
`Blob ${cid} has invalid content length: ${contentLength}`,
+
);
+
}
+
+
const MAX_SIZE = 200 * 1024 * 1024; // 200MB
+
if (size > MAX_SIZE) {
+
throw new Error(
+
`Blob ${cid} exceeds maximum size limit (${size} bytes)`,
+
);
+
}
+
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Downloading blob ${cid} (${size} bytes)...`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Downloading blob ${cid} (${size} bytes)...`,
+
);
+
+
if (!blobRes.data) {
+
throw new Error(
+
`Failed to download blob ${cid}: No data received`,
+
);
+
}
+
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Uploading blob ${cid} to new account...`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Uploading blob ${cid} to new account...`,
+
);
+
+
try {
+
await newAgent.com.atproto.repo.uploadBlob(blobRes.data);
+
const blobTime = Date.now() - blobStartTime;
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Successfully migrated blob ${cid} in ${
+
blobTime / 1000
+
} seconds`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Successfully migrated blob ${cid} in ${
+
blobTime / 1000
+
} seconds`,
+
);
+
migratedBlobs.push(cid);
+
} catch (uploadError) {
+
console.error(
+
`[${new Date().toISOString()}] Failed to upload blob ${cid}:`,
+
uploadError,
+
);
+
throw new Error(
+
`Upload failed: ${
+
uploadError instanceof Error
+
? uploadError.message
+
: String(uploadError)
+
}`,
+
);
+
}
+
} catch (error) {
+
const errorMessage = error instanceof Error
+
? error.message
+
: String(error);
+
const detailedError = `[${
+
new Date().toISOString()
+
}] Failed to migrate blob ${cid}: ${errorMessage}`;
+
console.error(detailedError);
+
console.error("Full error details:", error);
+
migrationLogs.push(detailedError);
+
failedBlobs.push(cid);
+
}
+
+
processedBlobs++;
+
const progressLog = `[${
+
new Date().toISOString()
+
}] Progress: ${processedBlobs}/${totalBlobs} blobs processed (${
+
Math.round((processedBlobs / totalBlobs) * 100)
+
}%)`;
+
console.log(progressLog);
+
migrationLogs.push(progressLog);
+
}
+
pageCount++;
+
} while (blobCursor);
+
+
const totalTime = Date.now() - startTime;
+
const completionMessage = `[${
+
new Date().toISOString()
+
}] Blob migration completed in ${
+
totalTime / 1000
+
} seconds: ${migratedBlobs.length} blobs migrated${
+
failedBlobs.length > 0 ? `, ${failedBlobs.length} failed` : ""
+
} (${pageCount} pages processed)`;
+
console.log(completionMessage);
+
migrationLogs.push(completionMessage);
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: failedBlobs.length > 0
+
? `Blob migration completed with ${failedBlobs.length} failed blobs`
+
: "Blob migration completed successfully",
+
migratedBlobs,
+
failedBlobs,
+
totalMigrated: migratedBlobs.length,
+
totalFailed: failedBlobs.length,
+
totalProcessed: processedBlobs,
+
totalBlobs,
+
logs: migrationLogs,
+
timing: {
+
totalTime: totalTime / 1000,
+
},
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
} catch (error) {
+
const message = error instanceof Error ? error.message : String(error);
+
console.error(
+
`[${new Date().toISOString()}] Blob migration error:`,
+
message,
+
);
+
console.error("Full error details:", error);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: `Blob migration failed: ${message}`,
+
error: error instanceof Error
+
? {
+
name: error.name,
+
message: error.message,
+
stack: error.stack,
+
}
+
: String(error),
+
}),
+
{
+
status: 500,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
}
+
},
+
});
+163
routes/api/migrate/data/prefs.ts
···
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../../lib/check-dids.ts";
+
import { define } from "../../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../../lib/migration-state.ts";
+
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
+
console.log("Preferences migration: Starting session retrieval");
+
const oldAgent = await getSessionAgent(ctx.req);
+
console.log("Preferences migration: Got old agent:", !!oldAgent);
+
+
const newAgent = await getSessionAgent(ctx.req, res, true);
+
console.log("Preferences migration: Got new agent:", !!newAgent);
+
+
if (!oldAgent || !newAgent) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Not authenticated",
+
}),
+
{
+
status: 401,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Migrate preferences
+
const migrationLogs: string[] = [];
+
const startTime = Date.now();
+
console.log(
+
`[${new Date().toISOString()}] Starting preferences migration...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Starting preferences migration...`,
+
);
+
+
// Fetch preferences
+
console.log(
+
`[${
+
new Date().toISOString()
+
}] Fetching preferences from old account...`,
+
);
+
migrationLogs.push(
+
`[${
+
new Date().toISOString()
+
}] Fetching preferences from old account...`,
+
);
+
+
const fetchStartTime = Date.now();
+
const prefs = await oldAgent.app.bsky.actor.getPreferences();
+
const fetchTime = Date.now() - fetchStartTime;
+
+
console.log(
+
`[${new Date().toISOString()}] Preferences fetched in ${
+
fetchTime / 1000
+
} seconds`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Preferences fetched in ${
+
fetchTime / 1000
+
} seconds`,
+
);
+
+
// Update preferences
+
console.log(
+
`[${new Date().toISOString()}] Updating preferences on new account...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Updating preferences on new account...`,
+
);
+
+
const updateStartTime = Date.now();
+
await newAgent.app.bsky.actor.putPreferences(prefs.data);
+
const updateTime = Date.now() - updateStartTime;
+
+
console.log(
+
`[${new Date().toISOString()}] Preferences updated in ${
+
updateTime / 1000
+
} seconds`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Preferences updated in ${
+
updateTime / 1000
+
} seconds`,
+
);
+
+
const totalTime = Date.now() - startTime;
+
const completionMessage = `[${
+
new Date().toISOString()
+
}] Preferences migration completed in ${totalTime / 1000} seconds total`;
+
console.log(completionMessage);
+
migrationLogs.push(completionMessage);
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: "Preferences migration completed successfully",
+
logs: migrationLogs,
+
timing: {
+
fetchTime: fetchTime / 1000,
+
updateTime: updateTime / 1000,
+
totalTime: totalTime / 1000,
+
},
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
} catch (error) {
+
const message = error instanceof Error ? error.message : String(error);
+
console.error(
+
`[${new Date().toISOString()}] Preferences migration error:`,
+
message,
+
);
+
console.error("Full error details:", error);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: `Preferences migration failed: ${message}`,
+
error: error instanceof Error
+
? {
+
name: error.name,
+
message: error.message,
+
stack: error.stack,
+
}
+
: String(error),
+
}),
+
{
+
status: 500,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
}
+
},
+
});
+163
routes/api/migrate/data/repo.ts
···
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../../lib/check-dids.ts";
+
import { define } from "../../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../../lib/migration-state.ts";
+
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
+
console.log("Repo migration: Starting session retrieval");
+
const oldAgent = await getSessionAgent(ctx.req);
+
console.log("Repo migration: Got old agent:", !!oldAgent);
+
+
const newAgent = await getSessionAgent(ctx.req, res, true);
+
console.log("Repo migration: Got new agent:", !!newAgent);
+
+
if (!oldAgent || !newAgent) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Not authenticated",
+
}),
+
{
+
status: 401,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
const session = await oldAgent.com.atproto.server.getSession();
+
const accountDid = session.data.did;
+
// Migrate repo data
+
const migrationLogs: string[] = [];
+
const startTime = Date.now();
+
console.log(`[${new Date().toISOString()}] Starting repo migration...`);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Starting repo migration...`,
+
);
+
+
// Get repo data from old account
+
console.log(
+
`[${new Date().toISOString()}] Fetching repo data from old account...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Fetching repo data from old account...`,
+
);
+
+
const fetchStartTime = Date.now();
+
const repoData = await oldAgent.com.atproto.sync.getRepo({
+
did: accountDid,
+
});
+
const fetchTime = Date.now() - fetchStartTime;
+
+
console.log(
+
`[${new Date().toISOString()}] Repo data fetched in ${
+
fetchTime / 1000
+
} seconds`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Repo data fetched in ${
+
fetchTime / 1000
+
} seconds`,
+
);
+
+
console.log(
+
`[${new Date().toISOString()}] Importing repo data to new account...`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Importing repo data to new account...`,
+
);
+
+
// Import repo data to new account
+
const importStartTime = Date.now();
+
await newAgent.com.atproto.repo.importRepo(repoData.data, {
+
encoding: "application/vnd.ipld.car",
+
});
+
const importTime = Date.now() - importStartTime;
+
+
console.log(
+
`[${new Date().toISOString()}] Repo data imported in ${
+
importTime / 1000
+
} seconds`,
+
);
+
migrationLogs.push(
+
`[${new Date().toISOString()}] Repo data imported in ${
+
importTime / 1000
+
} seconds`,
+
);
+
+
const totalTime = Date.now() - startTime;
+
const completionMessage = `[${
+
new Date().toISOString()
+
}] Repo migration completed in ${totalTime / 1000} seconds total`;
+
console.log(completionMessage);
+
migrationLogs.push(completionMessage);
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: "Repo migration completed successfully",
+
logs: migrationLogs,
+
timing: {
+
fetchTime: fetchTime / 1000,
+
importTime: importTime / 1000,
+
totalTime: totalTime / 1000,
+
},
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
} catch (error) {
+
const message = error instanceof Error ? error.message : String(error);
+
console.error(
+
`[${new Date().toISOString()}] Repo migration error:`,
+
message,
+
);
+
console.error("Full error details:", error);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: `Repo migration failed: ${message}`,
+
error: error instanceof Error
+
? {
+
name: error.name,
+
message: error.message,
+
stack: error.stack,
+
}
+
: String(error),
+
}),
+
{
+
status: 500,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
}
+
},
+
});
-367
routes/api/migrate/data.ts
···
-
import { define } from "../../../utils.ts";
-
import {
-
getSessionAgent,
-
} from "../../../lib/sessions.ts";
-
import { Agent, ComAtprotoSyncGetBlob } from "npm:@atproto/api";
-
-
// Retry configuration
-
const MAX_RETRIES = 3;
-
const INITIAL_RETRY_DELAY = 1000; // 1 second
-
-
/**
-
* Retry options
-
* @param maxRetries - The maximum number of retries
-
* @param initialDelay - The initial delay between retries
-
* @param onRetry - The function to call on retry
-
*/
-
interface RetryOptions {
-
maxRetries?: number;
-
initialDelay?: number;
-
onRetry?: (attempt: number, error: Error) => void;
-
}
-
-
/**
-
* Retry function with exponential backoff
-
* @param operation - The operation to retry
-
* @param options - The retry options
-
* @returns The result of the operation
-
*/
-
async function withRetry<T>(
-
operation: () => Promise<T>,
-
options: RetryOptions = {},
-
): Promise<T> {
-
const maxRetries = options.maxRetries ?? MAX_RETRIES;
-
const initialDelay = options.initialDelay ?? INITIAL_RETRY_DELAY;
-
-
let lastError: Error | null = null;
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
-
try {
-
return await operation();
-
} catch (error) {
-
lastError = error instanceof Error ? error : new Error(String(error));
-
-
// Don't retry on certain errors
-
if (error instanceof Error) {
-
// Don't retry on permanent errors like authentication
-
if (error.message.includes("Unauthorized") || error.message.includes("Invalid token")) {
-
throw error;
-
}
-
}
-
-
if (attempt < maxRetries - 1) {
-
const delay = initialDelay * Math.pow(2, attempt);
-
console.log(`Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms:`, lastError.message);
-
if (options.onRetry) {
-
options.onRetry(attempt + 1, lastError);
-
}
-
await new Promise(resolve => setTimeout(resolve, delay));
-
}
-
}
-
}
-
throw lastError ?? new Error("Operation failed after retries");
-
}
-
-
/**
-
* Handle blob upload to new PDS
-
* Retries on errors
-
* @param newAgent - The new agent
-
* @param blobRes - The blob response
-
* @param cid - The CID of the blob
-
*/
-
async function handleBlobUpload(
-
newAgent: Agent,
-
blobRes: ComAtprotoSyncGetBlob.Response,
-
cid: string
-
) {
-
try {
-
const contentLength = parseInt(blobRes.headers["content-length"] || "0", 10);
-
const contentType = blobRes.headers["content-type"];
-
-
// Check file size before attempting upload
-
const MAX_SIZE = 95 * 1024 * 1024; // 95MB to be safe
-
if (contentLength > MAX_SIZE) {
-
throw new Error(`Blob ${cid} exceeds maximum size limit (${contentLength} bytes)`);
-
}
-
-
await withRetry(
-
() => newAgent.com.atproto.repo.uploadBlob(blobRes.data, {
-
encoding: contentType,
-
}),
-
{
-
maxRetries: 5,
-
onRetry: (attempt, error) => {
-
console.log(`Retrying blob upload for ${cid} (attempt ${attempt}):`, error.message);
-
},
-
}
-
);
-
} catch (error) {
-
console.error(`Failed to upload blob ${cid}:`, error);
-
throw error;
-
}
-
}
-
-
/**
-
* Handle data migration
-
* @param ctx - The context object containing the request and response
-
* @returns A response object with the migration result
-
*/
-
export const handler = define.handlers({
-
async POST(ctx) {
-
const res = new Response();
-
try {
-
console.log("Data migration: Starting session retrieval");
-
const oldAgent = await getSessionAgent(ctx.req);
-
console.log("Data migration: Got old agent:", !!oldAgent);
-
-
// Log cookie information
-
const cookies = ctx.req.headers.get("cookie");
-
console.log("Data migration: Cookies present:", !!cookies);
-
console.log("Data migration: Cookie header:", cookies);
-
-
const newAgent = await getSessionAgent(ctx.req, res, true);
-
console.log("Data migration: Got new agent:", !!newAgent);
-
-
if (!oldAgent) {
-
return new Response(
-
JSON.stringify({
-
success: false,
-
message: "Unauthorized",
-
}),
-
{
-
status: 401,
-
headers: { "Content-Type": "application/json" },
-
},
-
);
-
}
-
if (!newAgent) {
-
return new Response(
-
JSON.stringify({
-
success: false,
-
message: "Migration session not found or invalid",
-
}),
-
{
-
status: 400,
-
headers: { "Content-Type": "application/json" },
-
},
-
);
-
}
-
-
const session = await oldAgent.com.atproto.server.getSession();
-
const accountDid = session.data.did;
-
-
// Migrate repo data with retries
-
const repoRes = await withRetry(
-
() => oldAgent.com.atproto.sync.getRepo({
-
did: accountDid,
-
}),
-
{
-
maxRetries: 5,
-
onRetry: (attempt, error) => {
-
console.log(`Retrying repo fetch (attempt ${attempt}):`, error.message);
-
},
-
}
-
);
-
-
await withRetry(
-
() => newAgent.com.atproto.repo.importRepo(repoRes.data, {
-
encoding: "application/vnd.ipld.car",
-
}),
-
{
-
maxRetries: 5,
-
onRetry: (attempt, error) => {
-
console.log(`Retrying repo import (attempt ${attempt}):`, error.message);
-
},
-
}
-
);
-
-
// Migrate blobs with enhanced error handling
-
let blobCursor: string | undefined = undefined;
-
const migratedBlobs: string[] = [];
-
const failedBlobs: Array<{ cid: string; error: string }> = [];
-
const migrationLogs: string[] = [];
-
let totalBlobs = 0;
-
let pageCount = 0;
-
-
// First count total blobs
-
console.log("Starting blob count...");
-
do {
-
const listedBlobs = await oldAgent.com.atproto.sync.listBlobs({
-
did: accountDid,
-
cursor: blobCursor,
-
});
-
const newBlobs = listedBlobs.data.cids.length;
-
totalBlobs += newBlobs;
-
pageCount++;
-
console.log(`Blob count page ${pageCount}: found ${newBlobs} blobs, total so far: ${totalBlobs}`);
-
migrationLogs.push(`Blob count page ${pageCount}: found ${newBlobs} blobs, total so far: ${totalBlobs}`);
-
-
if (!listedBlobs.data.cursor) {
-
console.log("No more cursor, finished counting blobs");
-
break;
-
}
-
blobCursor = listedBlobs.data.cursor;
-
} while (blobCursor);
-
-
// Reset cursor for actual migration
-
blobCursor = undefined;
-
let processedBlobs = 0;
-
pageCount = 0;
-
-
do {
-
try {
-
const listedBlobs = await withRetry(
-
() => oldAgent.com.atproto.sync.listBlobs({
-
did: accountDid,
-
cursor: blobCursor,
-
}),
-
{
-
maxRetries: 5,
-
onRetry: (attempt, error) => {
-
const log = `Retrying blob list fetch (attempt ${attempt}): ${error.message}`;
-
console.log(log);
-
migrationLogs.push(log);
-
},
-
}
-
);
-
-
pageCount++;
-
console.log(`Processing blob page ${pageCount}: ${listedBlobs.data.cids.length} blobs`);
-
migrationLogs.push(`Processing blob page ${pageCount}: ${listedBlobs.data.cids.length} blobs`);
-
-
for (const cid of listedBlobs.data.cids) {
-
try {
-
const blobRes = await withRetry(
-
() => oldAgent.com.atproto.sync.getBlob({
-
did: accountDid,
-
cid,
-
}),
-
{
-
maxRetries: 5,
-
onRetry: (attempt, error) => {
-
const log = `Retrying blob download for ${cid} (attempt ${attempt}): ${error.message}`;
-
console.log(log);
-
migrationLogs.push(log);
-
},
-
}
-
);
-
-
await handleBlobUpload(newAgent, blobRes, cid);
-
migratedBlobs.push(cid);
-
processedBlobs++;
-
const progressLog = `Migrating blob ${processedBlobs} of ${totalBlobs}: ${cid}`;
-
console.log(progressLog);
-
migrationLogs.push(progressLog);
-
} catch (error) {
-
const errorMsg = error instanceof Error ? error.message : String(error);
-
console.error(`Failed to migrate blob ${cid}:`, error);
-
failedBlobs.push({
-
cid,
-
error: errorMsg,
-
});
-
migrationLogs.push(`Failed to migrate blob ${cid}: ${errorMsg}`);
-
}
-
}
-
-
if (!listedBlobs.data.cursor) {
-
console.log("No more cursor, finished processing blobs");
-
migrationLogs.push("No more cursor, finished processing blobs");
-
break;
-
}
-
blobCursor = listedBlobs.data.cursor;
-
} catch (error) {
-
const errorMsg = error instanceof Error ? error.message : String(error);
-
console.error("Error during blob migration batch:", error);
-
migrationLogs.push(`Error during blob migration batch: ${errorMsg}`);
-
if (error instanceof Error &&
-
(error.message.includes("Unauthorized") ||
-
error.message.includes("Invalid token"))) {
-
throw error;
-
}
-
break;
-
}
-
} while (blobCursor);
-
-
const completionMessage = `Data migration completed: ${migratedBlobs.length} blobs migrated${failedBlobs.length > 0 ? `, ${failedBlobs.length} failed` : ''} (${pageCount} pages processed)`;
-
console.log(completionMessage);
-
migrationLogs.push(completionMessage);
-
-
// Migrate preferences with retry
-
console.log("Starting preferences migration...");
-
migrationLogs.push("Starting preferences migration...");
-
-
const prefs = await withRetry(
-
() => oldAgent.app.bsky.actor.getPreferences(),
-
{
-
maxRetries: 3,
-
onRetry: (attempt, error) => {
-
const log = `Retrying preferences fetch (attempt ${attempt}): ${error.message}`;
-
console.log(log);
-
migrationLogs.push(log);
-
},
-
}
-
);
-
-
console.log("Preferences fetched, updating on new account...");
-
migrationLogs.push("Preferences fetched, updating on new account...");
-
-
await withRetry(
-
() => newAgent.app.bsky.actor.putPreferences(prefs.data),
-
{
-
maxRetries: 3,
-
onRetry: (attempt, error) => {
-
const log = `Retrying preferences update (attempt ${attempt}): ${error.message}`;
-
console.log(log);
-
migrationLogs.push(log);
-
},
-
}
-
);
-
-
console.log("Preferences migration completed");
-
migrationLogs.push("Preferences migration completed");
-
-
const finalMessage = `Data migration fully completed: ${migratedBlobs.length} blobs migrated${failedBlobs.length > 0 ? `, ${failedBlobs.length} failed` : ''} (${pageCount} pages processed), preferences migrated`;
-
console.log(finalMessage);
-
migrationLogs.push(finalMessage);
-
-
return new Response(
-
JSON.stringify({
-
success: true,
-
message: failedBlobs.length > 0
-
? `Data migration completed with ${failedBlobs.length} failed blobs`
-
: "Data migration completed successfully",
-
migratedBlobs,
-
failedBlobs,
-
totalMigrated: migratedBlobs.length,
-
totalFailed: failedBlobs.length,
-
logs: migrationLogs,
-
}),
-
{
-
status: failedBlobs.length > 0 ? 207 : 200,
-
headers: {
-
"Content-Type": "application/json",
-
...Object.fromEntries(res.headers),
-
},
-
},
-
);
-
} catch (error) {
-
console.error("Data migration error:", error);
-
return new Response(
-
JSON.stringify({
-
success: false,
-
message: error instanceof Error
-
? error.message
-
: "Failed to migrate data",
-
error: error instanceof Error ? {
-
name: error.name,
-
message: error.message,
-
stack: error.stack,
-
} : String(error),
-
}),
-
{
-
status: 400,
-
headers: { "Content-Type": "application/json" },
-
},
-
);
-
}
-
},
-
});
···
+17
routes/api/migrate/finalize.ts
···
import { getSessionAgent } from "../../../lib/sessions.ts";
import { define } from "../../../utils.ts";
export const handler = define.handlers({
async POST(ctx) {
const res = new Response();
try {
const oldAgent = await getSessionAgent(ctx.req);
const newAgent = await getSessionAgent(ctx.req, res, true);
···
return new Response("Migration session not found or invalid", {
status: 400,
});
}
// Activate new account and deactivate old account
···
import { getSessionAgent } from "../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../lib/check-dids.ts";
import { define } from "../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../lib/migration-state.ts";
export const handler = define.handlers({
async POST(ctx) {
const res = new Response();
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
const oldAgent = await getSessionAgent(ctx.req);
const newAgent = await getSessionAgent(ctx.req, res, true);
···
return new Response("Migration session not found or invalid", {
status: 400,
});
+
}
+
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
+
}),
+
{ status: 400, headers: { "Content-Type": "application/json" } },
+
);
}
// Activate new account and deactivate old account
+74 -4
routes/api/migrate/identity/request.ts
···
-
import {
-
getSessionAgent,
-
} from "../../../../lib/sessions.ts";
import { define } from "../../../../utils.ts";
/**
* Handle identity migration request
···
async POST(ctx) {
const res = new Response();
try {
console.log("Starting identity migration request...");
const oldAgent = await getSessionAgent(ctx.req);
console.log("Got old agent:", {
···
);
}
// Request the signature
console.log("Requesting PLC operation signature...");
try {
await oldAgent.com.atproto.identity.requestPlcOperationSignature();
console.log("Successfully requested PLC operation signature");
} catch (error) {
console.error("Error requesting PLC operation signature:", {
name: error instanceof Error ? error.name : "Unknown",
message: error instanceof Error ? error.message : String(error),
-
status: 400
});
throw error;
}
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../../lib/check-dids.ts";
import { define } from "../../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../../lib/migration-state.ts";
+
+
// Simple in-memory cache for rate limiting
+
// In a production environment, you might want to use Redis or another shared cache
+
const requestCache = new Map<string, number>();
+
const COOLDOWN_PERIOD_MS = 60000; // 1 minute cooldown
/**
* Handle identity migration request
···
async POST(ctx) {
const res = new Response();
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
+
console.log("Starting identity migration request...");
const oldAgent = await getSessionAgent(ctx.req);
console.log("Got old agent:", {
···
);
}
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Check if we've recently sent a request for this DID
+
const did = oldAgent.did || "";
+
const now = Date.now();
+
const lastRequestTime = requestCache.get(did);
+
+
if (lastRequestTime && now - lastRequestTime < COOLDOWN_PERIOD_MS) {
+
console.log(
+
`Rate limiting PLC request for ${did}, last request was ${
+
(now - lastRequestTime) / 1000
+
} seconds ago`,
+
);
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message:
+
"A PLC code was already sent to your email. Please check your inbox and spam folder.",
+
rateLimited: true,
+
cooldownRemaining: Math.ceil(
+
(COOLDOWN_PERIOD_MS - (now - lastRequestTime)) / 1000,
+
),
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers),
+
},
+
},
+
);
+
}
+
// Request the signature
console.log("Requesting PLC operation signature...");
try {
await oldAgent.com.atproto.identity.requestPlcOperationSignature();
console.log("Successfully requested PLC operation signature");
+
+
// Store the request time
+
if (did) {
+
requestCache.set(did, now);
+
+
// Optionally, set up cache cleanup for DIDs that haven't been used in a while
+
setTimeout(() => {
+
if (
+
did &&
+
requestCache.has(did) &&
+
Date.now() - requestCache.get(did)! > COOLDOWN_PERIOD_MS * 2
+
) {
+
requestCache.delete(did);
+
}
+
}, COOLDOWN_PERIOD_MS * 2);
+
}
} catch (error) {
console.error("Error requesting PLC operation signature:", {
name: error instanceof Error ? error.name : "Unknown",
message: error instanceof Error ? error.message : String(error),
+
status: 400,
});
throw error;
}
+20 -3
routes/api/migrate/identity/sign.ts
···
-
import {
-
getSessionAgent,
-
} from "../../../../lib/sessions.ts";
import { Secp256k1Keypair } from "npm:@atproto/crypto";
import * as ui8 from "npm:uint8arrays";
import { define } from "../../../../utils.ts";
/**
* Handle identity migration sign
···
async POST(ctx) {
const res = new Response();
try {
const url = new URL(ctx.req.url);
const token = url.searchParams.get("token");
···
JSON.stringify({
success: false,
message: "Migration session not found or invalid",
}),
{
status: 400,
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { checkDidsMatch } from "../../../../lib/check-dids.ts";
import { Secp256k1Keypair } from "npm:@atproto/crypto";
import * as ui8 from "npm:uint8arrays";
import { define } from "../../../../utils.ts";
+
import { assertMigrationAllowed } from "../../../../lib/migration-state.ts";
/**
* Handle identity migration sign
···
async POST(ctx) {
const res = new Response();
try {
+
// Check if migrations are currently allowed
+
assertMigrationAllowed();
const url = new URL(ctx.req.url);
const token = url.searchParams.get("token");
···
JSON.stringify({
success: false,
message: "Migration session not found or invalid",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Verify DIDs match between sessions
+
const didsMatch = await checkDidsMatch(ctx.req);
+
if (!didsMatch) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Invalid state, original and target DIDs do not match",
}),
{
status: 400,
+44 -37
routes/api/migrate/next-step.ts
···
import { define } from "../../../utils.ts";
export const handler = define.handlers({
-
async GET(ctx) {
-
let nextStep = null;
-
const oldAgent = await getSessionAgent(ctx.req);
-
const newAgent = await getSessionAgent(ctx.req, new Response(), true);
-
if (!newAgent) return Response.json({ nextStep: 1, completed: false });
-
if (!oldAgent) return new Response("Unauthorized", { status: 401 });
-
const oldStatus = await oldAgent.com.atproto.server.checkAccountStatus();
-
const newStatus = await newAgent.com.atproto.server.checkAccountStatus();
-
if (!oldStatus.data || !newStatus.data) return new Response("Could not verify status", { status: 500 });
-
// Check conditions in sequence to determine the next step
-
if (!newStatus.data) {
-
nextStep = 1;
-
} else if (!(newStatus.data.repoCommit &&
-
newStatus.data.indexedRecords === oldStatus.data.indexedRecords &&
-
newStatus.data.privateStateValues === oldStatus.data.privateStateValues &&
-
newStatus.data.expectedBlobs === newStatus.data.importedBlobs &&
-
newStatus.data.importedBlobs === oldStatus.data.importedBlobs)) {
-
nextStep = 2;
-
} else if (!newStatus.data.validDid) {
-
nextStep = 3;
-
} else if (!(newStatus.data.activated === true && oldStatus.data.activated === false)) {
-
nextStep = 4;
-
}
-
return Response.json({
-
nextStep,
-
completed: nextStep === null,
-
currentStatus: {
-
activated: newStatus.data.activated,
-
validDid: newStatus.data.validDid,
-
repoCommit: newStatus.data.repoCommit,
-
indexedRecords: newStatus.data.indexedRecords,
-
privateStateValues: newStatus.data.privateStateValues,
-
importedBlobs: newStatus.data.importedBlobs
-
}
-
});
-
}
-
})
···
import { define } from "../../../utils.ts";
export const handler = define.handlers({
+
async GET(ctx) {
+
let nextStep = null;
+
const oldAgent = await getSessionAgent(ctx.req);
+
const newAgent = await getSessionAgent(ctx.req, new Response(), true);
+
if (!newAgent) return Response.json({ nextStep: 1, completed: false });
+
if (!oldAgent) return new Response("Unauthorized", { status: 401 });
+
const oldStatus = await oldAgent.com.atproto.server.checkAccountStatus();
+
const newStatus = await newAgent.com.atproto.server.checkAccountStatus();
+
if (!oldStatus.data || !newStatus.data) {
+
return new Response("Could not verify status", { status: 500 });
+
}
+
// Check conditions in sequence to determine the next step
+
if (!newStatus.data) {
+
nextStep = 1;
+
} else if (
+
!(newStatus.data.repoCommit &&
+
newStatus.data.indexedRecords === oldStatus.data.indexedRecords &&
+
newStatus.data.privateStateValues ===
+
oldStatus.data.privateStateValues &&
+
newStatus.data.expectedBlobs === newStatus.data.importedBlobs &&
+
newStatus.data.importedBlobs === oldStatus.data.importedBlobs)
+
) {
+
nextStep = 2;
+
} else if (!newStatus.data.validDid) {
+
nextStep = 3;
+
} else if (
+
!(newStatus.data.activated === true && oldStatus.data.activated === false)
+
) {
+
nextStep = 4;
+
}
+
return Response.json({
+
nextStep,
+
completed: nextStep === null,
+
currentStatus: {
+
activated: newStatus.data.activated,
+
validDid: newStatus.data.validDid,
+
repoCommit: newStatus.data.repoCommit,
+
indexedRecords: newStatus.data.indexedRecords,
+
privateStateValues: newStatus.data.privateStateValues,
+
importedBlobs: newStatus.data.importedBlobs,
+
},
+
});
+
},
+
});
+130 -104
routes/api/migrate/status.ts
···
import { getSessionAgent } from "../../../lib/sessions.ts";
import { define } from "../../../utils.ts";
export const handler = define.handlers({
-
async GET(ctx) {
-
console.log("Status check: Starting");
-
const url = new URL(ctx.req.url);
-
const params = new URLSearchParams(url.search);
-
const step = params.get("step");
-
console.log("Status check: Step", step);
-
console.log("Status check: Getting agents");
-
const oldAgent = await getSessionAgent(ctx.req);
-
const newAgent = await getSessionAgent(ctx.req, new Response(), true);
-
-
if (!oldAgent || !newAgent) {
-
console.log("Status check: Unauthorized - missing agents", {
-
hasOldAgent: !!oldAgent,
-
hasNewAgent: !!newAgent
-
});
-
return new Response("Unauthorized", { status: 401 });
-
}
-
console.log("Status check: Fetching account statuses");
-
const oldStatus = await oldAgent.com.atproto.server.checkAccountStatus();
-
const newStatus = await newAgent.com.atproto.server.checkAccountStatus();
-
-
if (!oldStatus.data || !newStatus.data) {
-
console.error("Status check: Failed to verify status", {
-
hasOldStatus: !!oldStatus.data,
-
hasNewStatus: !!newStatus.data
-
});
-
return new Response("Could not verify status", { status: 500 });
-
}
-
console.log("Status check: Account statuses", {
-
old: oldStatus.data,
-
new: newStatus.data
-
});
-
const readyToContinue = () => {
-
if (step) {
-
console.log("Status check: Evaluating step", step);
-
switch (step) {
-
case "1": {
-
if (newStatus.data) {
-
console.log("Status check: Step 1 ready");
-
return { ready: true };
-
}
-
console.log("Status check: Step 1 not ready - new account status not available");
-
return { ready: false, reason: "New account status not available" };
-
}
-
case "2": {
-
const isReady = newStatus.data.repoCommit &&
-
newStatus.data.indexedRecords === oldStatus.data.indexedRecords &&
-
newStatus.data.privateStateValues === oldStatus.data.privateStateValues &&
-
newStatus.data.expectedBlobs === newStatus.data.importedBlobs &&
-
newStatus.data.importedBlobs === oldStatus.data.importedBlobs;
-
if (isReady) {
-
console.log("Status check: Step 2 ready");
-
return { ready: true };
-
}
-
const reasons = [];
-
if (!newStatus.data.repoCommit) reasons.push("Repository not imported.");
-
if (newStatus.data.indexedRecords < oldStatus.data.indexedRecords)
-
reasons.push("Not all records imported.");
-
if (newStatus.data.privateStateValues < oldStatus.data.privateStateValues)
-
reasons.push("Not all private state values imported.");
-
if (newStatus.data.expectedBlobs !== newStatus.data.importedBlobs)
-
reasons.push("Expected blobs not fully imported.");
-
if (newStatus.data.importedBlobs < oldStatus.data.importedBlobs)
-
reasons.push("Not all blobs imported.");
-
console.log("Status check: Step 2 not ready", { reasons });
-
return { ready: false, reason: reasons.join(", ") };
-
}
-
case "3": {
-
if (newStatus.data.validDid) {
-
console.log("Status check: Step 3 ready");
-
return { ready: true };
-
}
-
console.log("Status check: Step 3 not ready - DID not valid");
-
return { ready: false, reason: "DID not valid" };
-
}
-
case "4": {
-
if (newStatus.data.activated === true && oldStatus.data.activated === false) {
-
console.log("Status check: Step 4 ready");
-
return { ready: true };
-
}
-
console.log("Status check: Step 4 not ready - Account not activated");
-
return { ready: false, reason: "Account not activated" };
-
}
-
}
-
} else {
-
console.log("Status check: No step specified, returning ready");
-
return { ready: true };
}
}
-
const status = {
-
activated: newStatus.data.activated,
-
validDid: newStatus.data.validDid,
-
repoCommit: newStatus.data.repoCommit,
-
repoRev: newStatus.data.repoRev,
-
repoBlocks: newStatus.data.repoBlocks,
-
expectedRecords: oldStatus.data.indexedRecords,
-
indexedRecords: newStatus.data.indexedRecords,
-
privateStateValues: newStatus.data.privateStateValues,
-
expectedBlobs: newStatus.data.expectedBlobs,
-
importedBlobs: newStatus.data.importedBlobs,
-
...readyToContinue()
-
}
-
console.log("Status check: Complete", status);
-
return Response.json(status);
-
}
-
})
···
+
import { checkDidsMatch } from "../../../lib/check-dids.ts";
import { getSessionAgent } from "../../../lib/sessions.ts";
import { define } from "../../../utils.ts";
export const handler = define.handlers({
+
async GET(ctx) {
+
console.log("Status check: Starting");
+
const url = new URL(ctx.req.url);
+
const params = new URLSearchParams(url.search);
+
const step = params.get("step");
+
console.log("Status check: Step", step);
+
console.log("Status check: Getting agents");
+
const oldAgent = await getSessionAgent(ctx.req);
+
const newAgent = await getSessionAgent(ctx.req, new Response(), true);
+
if (!oldAgent || !newAgent) {
+
console.log("Status check: Unauthorized - missing agents", {
+
hasOldAgent: !!oldAgent,
+
hasNewAgent: !!newAgent,
+
});
+
return new Response("Unauthorized", { status: 401 });
+
}
+
const didsMatch = await checkDidsMatch(ctx.req);
+
console.log("Status check: Fetching account statuses");
+
const oldStatus = await oldAgent.com.atproto.server.checkAccountStatus();
+
const newStatus = await newAgent.com.atproto.server.checkAccountStatus();
+
if (!oldStatus.data || !newStatus.data) {
+
console.error("Status check: Failed to verify status", {
+
hasOldStatus: !!oldStatus.data,
+
hasNewStatus: !!newStatus.data,
+
});
+
return new Response("Could not verify status", { status: 500 });
+
}
+
console.log("Status check: Account statuses", {
+
old: oldStatus.data,
+
new: newStatus.data,
+
});
+
const readyToContinue = () => {
+
if (!didsMatch) {
+
return {
+
ready: false,
+
reason: "Invalid state, original and target DIDs do not match",
+
};
+
}
+
if (step) {
+
console.log("Status check: Evaluating step", step);
+
switch (step) {
+
case "1": {
+
if (newStatus.data) {
+
console.log("Status check: Step 1 ready");
+
return { ready: true };
+
}
+
console.log(
+
"Status check: Step 1 not ready - new account status not available",
+
);
+
return { ready: false, reason: "New account status not available" };
+
}
+
case "2": {
+
const isReady = newStatus.data.repoCommit &&
+
newStatus.data.indexedRecords === oldStatus.data.indexedRecords &&
+
newStatus.data.privateStateValues ===
+
oldStatus.data.privateStateValues &&
+
newStatus.data.expectedBlobs === newStatus.data.importedBlobs &&
+
newStatus.data.importedBlobs === oldStatus.data.importedBlobs;
+
+
if (isReady) {
+
console.log("Status check: Step 2 ready");
+
return { ready: true };
+
}
+
+
const reasons = [];
+
if (!newStatus.data.repoCommit) {
+
reasons.push("Repository not imported.");
+
}
+
if (newStatus.data.indexedRecords < oldStatus.data.indexedRecords) {
+
reasons.push("Not all records imported.");
+
}
+
if (
+
newStatus.data.privateStateValues <
+
oldStatus.data.privateStateValues
+
) {
+
reasons.push("Not all private state values imported.");
+
}
+
if (newStatus.data.expectedBlobs !== newStatus.data.importedBlobs) {
+
reasons.push("Expected blobs not fully imported.");
+
}
+
if (newStatus.data.importedBlobs < oldStatus.data.importedBlobs) {
+
reasons.push("Not all blobs imported.");
+
}
+
+
console.log("Status check: Step 2 not ready", { reasons });
+
return { ready: false, reason: reasons.join(", ") };
+
}
+
case "3": {
+
if (newStatus.data.validDid) {
+
console.log("Status check: Step 3 ready");
+
return { ready: true };
+
}
+
console.log("Status check: Step 3 not ready - DID not valid");
+
return { ready: false, reason: "DID not valid" };
+
}
+
case "4": {
+
if (
+
newStatus.data.activated === true &&
+
oldStatus.data.activated === false
+
) {
+
console.log("Status check: Step 4 ready");
+
return { ready: true };
}
+
console.log(
+
"Status check: Step 4 not ready - Account not activated",
+
);
+
return { ready: false, reason: "Account not activated" };
+
}
}
+
} else {
+
console.log("Status check: No step specified, returning ready");
+
return { ready: true };
+
}
+
};
+
const status = {
+
activated: newStatus.data.activated,
+
validDid: newStatus.data.validDid,
+
repoCommit: newStatus.data.repoCommit,
+
repoRev: newStatus.data.repoRev,
+
repoBlocks: newStatus.data.repoBlocks,
+
expectedRecords: oldStatus.data.indexedRecords,
+
indexedRecords: newStatus.data.indexedRecords,
+
privateStateValues: newStatus.data.privateStateValues,
+
expectedBlobs: newStatus.data.expectedBlobs,
+
importedBlobs: newStatus.data.importedBlobs,
+
...readyToContinue(),
+
};
+
console.log("Status check: Complete", status);
+
return Response.json(status);
+
},
+
});
+45
routes/api/migration-state.ts
···
···
+
import { getMigrationState } from "../../lib/migration-state.ts";
+
import { define } from "../../utils.ts";
+
+
/**
+
* API endpoint to check the current migration state.
+
* Returns the migration state information including whether migrations are allowed.
+
*/
+
export const handler = define.handlers({
+
GET(_ctx) {
+
try {
+
const stateInfo = getMigrationState();
+
+
return new Response(
+
JSON.stringify({
+
state: stateInfo.state,
+
message: stateInfo.message,
+
allowMigration: stateInfo.allowMigration,
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
},
+
},
+
);
+
} catch (error) {
+
console.error("Error checking migration state:", error);
+
+
return new Response(
+
JSON.stringify({
+
state: "issue",
+
message:
+
"Unable to determine migration state. Please try again later.",
+
allowMigration: false,
+
}),
+
{
+
status: 500,
+
headers: {
+
"Content-Type": "application/json",
+
},
+
},
+
);
+
}
+
},
+
});
+13 -13
routes/api/oauth/initiate.ts
···
-
import { isValidHandle } from 'npm:@atproto/syntax'
import { oauthClient } from "../../../lib/oauth/client.ts";
import { define } from "../../../utils.ts";
function isValidUrl(url: string): boolean {
try {
-
const urlp = new URL(url)
// http or https
-
return urlp.protocol === 'http:' || urlp.protocol === 'https:'
} catch {
-
return false
}
}
export const handler = define.handlers({
async POST(ctx) {
-
const data = await ctx.req.json()
-
const handle = data.handle
if (
-
typeof handle !== 'string' ||
!(isValidHandle(handle) || isValidUrl(handle))
) {
-
return new Response("Invalid Handle", {status: 400})
}
// Initiate the OAuth flow
try {
const url = await oauthClient.authorize(handle, {
-
scope: 'atproto transition:generic transition:chat.bsky',
-
})
-
return Response.json({ redirectUrl: url.toString() })
} catch (err) {
-
console.error({ err }, 'oauth authorize failed')
-
return new Response("Couldn't initiate login", {status: 500})
}
},
});
···
+
import { isValidHandle } from "npm:@atproto/syntax";
import { oauthClient } from "../../../lib/oauth/client.ts";
import { define } from "../../../utils.ts";
function isValidUrl(url: string): boolean {
try {
+
const urlp = new URL(url);
// http or https
+
return urlp.protocol === "http:" || urlp.protocol === "https:";
} catch {
+
return false;
}
}
export const handler = define.handlers({
async POST(ctx) {
+
const data = await ctx.req.json();
+
const handle = data.handle;
if (
+
typeof handle !== "string" ||
!(isValidHandle(handle) || isValidUrl(handle))
) {
+
return new Response("Invalid Handle", { status: 400 });
}
// Initiate the OAuth flow
try {
const url = await oauthClient.authorize(handle, {
+
scope: "atproto transition:generic transition:chat.bsky",
+
});
+
return Response.json({ redirectUrl: url.toString() });
} catch (err) {
+
console.error({ err }, "oauth authorize failed");
+
return new Response("Couldn't initiate login", { status: 500 });
}
},
});
+42
routes/api/plc/keys.ts
···
···
+
import { Secp256k1Keypair } from "@atproto/crypto";
+
import { getSessionAgent } from "../../../lib/sessions.ts";
+
import { define } from "../../../utils.ts";
+
import * as ui8 from "npm:uint8arrays";
+
+
/**
+
* Generate and return PLC keys for the authenticated user
+
*/
+
export const handler = define.handlers({
+
async GET(ctx) {
+
const agent = await getSessionAgent(ctx.req);
+
if (!agent) {
+
return new Response("Unauthorized", { status: 401 });
+
}
+
+
// Create a new keypair
+
const keypair = await Secp256k1Keypair.create({ exportable: true });
+
+
// Export private key bytes
+
const privateKeyBytes = await keypair.export();
+
const privateKeyHex = ui8.toString(privateKeyBytes, "hex");
+
+
// Get public key as DID
+
const publicKeyDid = keypair.did();
+
+
// Convert private key to multikey format (base58btc)
+
const privateKeyMultikey = ui8.toString(privateKeyBytes, "base58btc");
+
+
// Return the key information
+
return new Response(
+
JSON.stringify({
+
keyType: "secp256k1",
+
publicKeyDid: publicKeyDid,
+
privateKeyHex: privateKeyHex,
+
privateKeyMultikey: privateKeyMultikey,
+
}),
+
{
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
},
+
});
+61
routes/api/plc/token.ts
···
···
+
import { getSessionAgent } from "../../../lib/sessions.ts";
+
import { define } from "../../../utils.ts";
+
+
/**
+
* Handle account creation
+
* First step of the migration process
+
* Body must contain:
+
* - service: The service URL of the new account
+
* - handle: The handle of the new account
+
* - password: The password of the new account
+
* - email: The email of the new account
+
* - invite: The invite code of the new account (optional depending on the PDS)
+
* @param ctx - The context object containing the request and response
+
* @returns A response object with the creation result
+
*/
+
export const handler = define.handlers({
+
async GET(ctx) {
+
const res = new Response();
+
try {
+
const agent = await getSessionAgent(ctx.req, res);
+
+
if (!agent) return new Response("Unauthorized", { status: 401 });
+
+
// console.log("getting did");
+
// const session = await agent.com.atproto.server.getSession();
+
// const accountDid = session.data.did;
+
// console.log("got did");
+
+
await agent.com.atproto.identity.requestPlcOperationSignature();
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message:
+
"We've requested a token to update your identity, it should be sent to your account's email address.",
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers), // Include session cookie headers
+
},
+
},
+
);
+
} catch (error) {
+
console.error("PLC signature request error:", error);
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: error instanceof Error
+
? error.message
+
: "Failed to get PLC operation signature (sending confirmation email)",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
},
+
});
+92
routes/api/plc/update/complete.ts
···
···
+
import { getSessionAgent } from "../../../../lib/sessions.ts";
+
import { define } from "../../../../utils.ts";
+
+
/**
+
* Complete PLC update using email token
+
*/
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
const url = new URL(ctx.req.url);
+
const token = url.searchParams.get("token");
+
+
if (!token) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Missing token parameter",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
const agent = await getSessionAgent(ctx.req, res, true);
+
if (!agent) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Unauthorized",
+
}),
+
{
+
status: 401,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
const did = agent.did;
+
if (!did) {
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "No DID found in session",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Submit the PLC operation with the token
+
await agent!.com.atproto.identity.submitPlcOperation({
+
operation: { token: token },
+
});
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: "PLC update completed successfully",
+
did,
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers), // Include session cookie headers
+
},
+
},
+
);
+
} catch (error) {
+
console.error("PLC update completion error:", error);
+
const message = error instanceof Error
+
? error.message
+
: "Unknown error occurred";
+
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: `Failed to complete PLC update: ${message}`,
+
}),
+
{
+
status: 500,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
},
+
});
+155
routes/api/plc/update.ts
···
···
+
import { getSessionAgent } from "../../../lib/sessions.ts";
+
import { define } from "../../../utils.ts";
+
import * as plc from "@did-plc/lib";
+
+
/**
+
* Handle PLC update operation
+
* Body must contain:
+
* - key: The new rotation key to add
+
* - token: The email token received from requestPlcOperationSignature
+
* @param ctx - The context object containing the request and response
+
* @returns A response object with the update result
+
*/
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
console.log("=== PLC Update Debug ===");
+
const body = await ctx.req.json();
+
const { key: newKey, token } = body;
+
console.log("Request body:", { newKey, hasToken: !!token });
+
+
if (!newKey) {
+
console.log("Missing key in request");
+
return new Response("Missing param key in request body", {
+
status: 400,
+
});
+
}
+
+
if (!token) {
+
console.log("Missing token in request");
+
return new Response("Missing param token in request body", {
+
status: 400,
+
});
+
}
+
+
const agent = await getSessionAgent(ctx.req, res);
+
if (!agent) {
+
console.log("No agent found");
+
return new Response("Unauthorized", { status: 401 });
+
}
+
+
const session = await agent.com.atproto.server.getSession();
+
const did = session.data.did;
+
if (!did) {
+
console.log("No DID found in session");
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "No DID found in your session",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
console.log("Using agent DID:", did);
+
+
// Get recommended credentials first
+
console.log("Getting did:plc document...");
+
const plcClient = new plc.Client("https://plc.directory");
+
const didDoc = await plcClient.getDocumentData(did);
+
if (!didDoc) {
+
console.log("No DID document found for agent DID");
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "No DID document found for your account",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
console.log("Got DID document:", didDoc);
+
+
const rotationKeys = didDoc.rotationKeys ?? [];
+
if (!rotationKeys.length) {
+
console.log("No existing rotation keys found");
+
throw new Error("No rotation keys provided in recommended credentials");
+
}
+
+
// Check if the key is already in rotation keys
+
if (rotationKeys.includes(newKey)) {
+
console.log("Key already exists in rotation keys");
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "This key is already in your rotation keys",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
+
// Perform the actual PLC update with the provided token
+
console.log("Signing PLC operation...");
+
const plcOp = await agent.com.atproto.identity.signPlcOperation({
+
token,
+
rotationKeys: [newKey, ...rotationKeys],
+
});
+
console.log("PLC operation signed successfully:", plcOp.data);
+
+
console.log("Submitting PLC operation...");
+
const plcSubmit = await agent.com.atproto.identity.submitPlcOperation({
+
operation: plcOp.data.operation,
+
});
+
console.log("PLC operation submitted successfully:", plcSubmit);
+
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: "PLC update completed successfully",
+
did: plcOp.data,
+
newKey,
+
rotationKeys: [newKey, ...rotationKeys],
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers), // Include session cookie headers
+
},
+
},
+
);
+
} catch (error) {
+
console.error("PLC update error:", error);
+
const errorMessage = error instanceof Error
+
? error.message
+
: "Failed to update your PLC";
+
console.log("Sending error response:", errorMessage);
+
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: errorMessage,
+
error: error instanceof Error
+
? {
+
name: error.name,
+
message: error.message,
+
stack: error.stack,
+
}
+
: String(error),
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
},
+
});
+129
routes/api/plc/verify.ts
···
···
+
import { getSessionAgent } from "../../../lib/sessions.ts";
+
import { define } from "../../../utils.ts";
+
import * as plc from "@did-plc/lib";
+
+
/**
+
* Verify if a rotation key exists in the PLC document
+
* Body must contain:
+
* - key: The rotation key to verify
+
* @param ctx - The context object containing the request and response
+
* @returns A response object with the verification result
+
*/
+
export const handler = define.handlers({
+
async POST(ctx) {
+
const res = new Response();
+
try {
+
const body = await ctx.req.json();
+
const { key: newKey } = body;
+
console.log("Request body:", { newKey });
+
+
if (!newKey) {
+
console.log("Missing key in request");
+
return new Response("Missing param key in request body", {
+
status: 400,
+
});
+
}
+
+
const agent = await getSessionAgent(ctx.req, res);
+
if (!agent) {
+
console.log("No agent found");
+
return new Response("Unauthorized", { status: 401 });
+
}
+
+
const session = await agent.com.atproto.server.getSession();
+
const did = session.data.did;
+
if (!did) {
+
console.log("No DID found in session");
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "No DID found in your session",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
console.log("Using agent DID:", did);
+
+
// Fetch the PLC document to check rotation keys
+
console.log("Getting did:plc document...");
+
const plcClient = new plc.Client("https://plc.directory");
+
const didDoc = await plcClient.getDocumentData(did);
+
if (!didDoc) {
+
console.log("No DID document found for agent DID");
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "No DID document found for your account",
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
console.log("Got DID document:", didDoc);
+
+
const rotationKeys = didDoc.rotationKeys ?? [];
+
if (!rotationKeys.length) {
+
console.log("No existing rotation keys found");
+
throw new Error("No rotation keys found in did:plc document");
+
}
+
+
// Check if the key exists in rotation keys
+
if (rotationKeys.includes(newKey)) {
+
return new Response(
+
JSON.stringify({
+
success: true,
+
message: "Rotation key exists in PLC document",
+
}),
+
{
+
status: 200,
+
headers: {
+
"Content-Type": "application/json",
+
...Object.fromEntries(res.headers), // Include session cookie headers
+
},
+
},
+
);
+
}
+
+
// If we get here, the key was not found
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: "Rotation key not found in PLC document",
+
}),
+
{
+
status: 404,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
} catch (error) {
+
console.error("PLC verification error:", error);
+
const errorMessage = error instanceof Error
+
? error.message
+
: "Failed to verify rotation key";
+
console.log("Sending error response:", errorMessage);
+
+
return new Response(
+
JSON.stringify({
+
success: false,
+
message: errorMessage,
+
error: error instanceof Error
+
? {
+
name: error.name,
+
message: error.message,
+
stack: error.stack,
+
}
+
: String(error),
+
}),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
+
}
+
},
+
});
+11 -8
routes/api/resolve-pds.ts
···
const did = url.searchParams.get("did");
if (!did) {
-
return new Response(JSON.stringify({ error: "DID parameter is required" }), {
-
status: 400,
-
headers: { "Content-Type": "application/json" }
-
});
}
try {
const pds = await resolver.resolveDidToPdsUrl(did);
return new Response(JSON.stringify({ pds }), {
status: 200,
-
headers: { "Content-Type": "application/json" }
});
} catch (error) {
console.error("Failed to resolve PDS:", error);
return new Response(JSON.stringify({ error: "Failed to resolve PDS" }), {
status: 500,
-
headers: { "Content-Type": "application/json" }
});
}
-
}
-
});
···
const did = url.searchParams.get("did");
if (!did) {
+
return new Response(
+
JSON.stringify({ error: "DID parameter is required" }),
+
{
+
status: 400,
+
headers: { "Content-Type": "application/json" },
+
},
+
);
}
try {
const pds = await resolver.resolveDidToPdsUrl(did);
return new Response(JSON.stringify({ pds }), {
status: 200,
+
headers: { "Content-Type": "application/json" },
});
} catch (error) {
console.error("Failed to resolve PDS:", error);
return new Response(JSON.stringify({ error: "Failed to resolve PDS" }), {
status: 500,
+
headers: { "Content-Type": "application/json" },
});
}
+
},
+
});
+1 -2
routes/api/server/describe.ts
···
-
import { Agent } from "@atproto/api";
import { getSessionAgent } from "../../../lib/sessions.ts";
import { define } from "../../../utils.ts";
···
}
const result = await agent.com.atproto.server.describeServer();
return Response.json(result);
-
}
});
···
import { Agent } from "@atproto/api";
import { getSessionAgent } from "../../../lib/sessions.ts";
import { define } from "../../../utils.ts";
···
}
const result = await agent.com.atproto.server.describeServer();
return Response.json(result);
+
},
});
+22 -20
routes/index.tsx
···
import Ticket from "../islands/Ticket.tsx";
import AirportSign from "../components/AirportSign.tsx";
import SocialLinks from "../islands/SocialLinks.tsx";
-
import { Button } from "../components/Button.tsx";
export default function Home() {
return (
···
<p class="font-mono text-lg sm:text-xl font-bold mb-4 sm:mb-6 mt-0 text-center text-gray-600 dark:text-gray-300">
Your terminal for seamless AT Protocol PDS migration and backup.
</p>
-
<p class="font-mono mb-4 sm:mb-6 mt-0 text-center text-gray-600 dark:text-gray-300">
-
Airport is in <strong>alpha</strong> currently, and we don't recommend it for main accounts. <br/> Please use its migration tools at your own risk.
-
</p>
<Ticket />
-
<div class="mt-6 sm:mt-8 text-center w-fit mx-auto">
-
<Button
-
href="/login"
-
color="blue"
-
label="MOBILE NOT SUPPORTED"
-
className="opacity-50 cursor-not-allowed sm:opacity-100 sm:cursor-pointer"
-
onClick={(e: MouseEvent) => {
-
if (globalThis.innerWidth < 640) {
-
e.preventDefault();
-
}
-
}}
-
/>
-
</div>
<p class="font-mono text-lg sm:text-xl mb-4 mt-4 sm:mb-6 text-center text-gray-600 dark:text-gray-300">
-
Airport is made with love by <a class="text-blue-500 hover:underline" href="https://bsky.app/profile/knotbin.com">Roscoe</a> for <a class="text-blue-500 hover:underline" href="https://sprk.so">Spark</a>, a new short-video platform for AT Protocol.
</p>
<div class="text-center mb-4">
-
<a href="/about" class="inline-flex items-center text-blue-500 hover:text-blue-600 transition-colors">
-
<img src="/icons/info_bold.svg" alt="Info" class="w-5 h-5 mr-2" />
<span class="font-mono">Learn more about AT Protocol</span>
</a>
</div>
···
import Ticket from "../islands/Ticket.tsx";
import AirportSign from "../components/AirportSign.tsx";
import SocialLinks from "../islands/SocialLinks.tsx";
+
import LoginButton from "../islands/LoginButton.tsx";
export default function Home() {
return (
···
<p class="font-mono text-lg sm:text-xl font-bold mb-4 sm:mb-6 mt-0 text-center text-gray-600 dark:text-gray-300">
Your terminal for seamless AT Protocol PDS migration and backup.
</p>
<Ticket />
+
<LoginButton />
<p class="font-mono text-lg sm:text-xl mb-4 mt-4 sm:mb-6 text-center text-gray-600 dark:text-gray-300">
+
Airport is made with love by{" "}
+
<a
+
class="text-blue-500 hover:underline"
+
href="https://bsky.app/profile/knotbin.com"
+
>
+
Roscoe
+
</a>{" "}
+
for{" "}
+
<a class="text-blue-500 hover:underline" href="https://sprk.so">
+
Spark
+
</a>, a new short-video platform for AT Protocol.
</p>
<div class="text-center mb-4">
+
<a
+
href="/about"
+
class="inline-flex items-center text-blue-500 hover:text-blue-600 transition-colors"
+
>
+
<img
+
src="/icons/info_bold.svg"
+
alt="Info"
+
class="w-5 h-5 mr-2"
+
/>
<span class="font-mono">Learn more about AT Protocol</span>
</a>
</div>
+1 -1
routes/login/index.tsx
···
import { PageProps } from "fresh";
-
import LoginSelector from "../../islands/LoginSelector.tsx"
export async function submitHandle(handle: string) {
const response = await fetch("/api/oauth/initiate", {
···
import { PageProps } from "fresh";
+
import LoginSelector from "../../islands/LoginSelector.tsx";
export async function submitHandle(handle: string) {
const response = await fetch("/api/oauth/initiate", {
+2 -2
routes/migrate/progress.tsx
···
if (!service || !handle || !email || !password) {
return (
-
<div class="min-h-screen bg-gray-50 dark:bg-gray-900 p-4">
<div class="max-w-2xl mx-auto">
<div class="bg-red-50 dark:bg-red-900 p-4 rounded-lg">
<p class="text-red-800 dark:text-red-200">
···
}
return (
-
<div class="min-h-screen bg-gray-50 dark:bg-gray-900 p-4">
<div class="max-w-2xl mx-auto">
<h1 class="font-mono text-3xl font-bold text-gray-900 dark:text-white mb-8">
Migration Progress
···
if (!service || !handle || !email || !password) {
return (
+
<div class="bg-gray-50 dark:bg-gray-900 p-4">
<div class="max-w-2xl mx-auto">
<div class="bg-red-50 dark:bg-red-900 p-4 rounded-lg">
<p class="text-red-800 dark:text-red-200">
···
}
return (
+
<div class="bg-gray-50 dark:bg-gray-900 p-4">
<div class="max-w-2xl mx-auto">
<h1 class="font-mono text-3xl font-bold text-gray-900 dark:text-white mb-8">
Migration Progress
+14
routes/ticket-booth/index.tsx
···
···
+
import DidPlcProgress from "../../islands/DidPlcProgress.tsx";
+
+
export default function TicketBooth() {
+
return (
+
<div class=" bg-gray-50 dark:bg-gray-900 p-4">
+
<div class="max-w-2xl mx-auto">
+
<h1 class="font-mono text-3xl font-bold text-gray-900 dark:text-white mb-8">
+
Ticket Booth Self-Service Kiosk
+
</h1>
+
<DidPlcProgress />
+
</div>
+
</div>
+
);
+
}
+52 -9
static/favicon.svg
···
-
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="768px" height="768px"><svg width="768px" height="768px" viewBox="0 0 768 768" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Artboard</title>
-
<g id="SvgjsG1018" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
-
<path d="M258.744161,673.532662 C220.757598,658.556745 187.761971,637.340862 159.757278,609.885015 C131.731315,582.675001 109.640415,549.95668 94.87512,513.789548 C79.62504,476.904419 72,436.829975 72,393.566215 C72,341.982502 79.9023142,296.222756 95.7069425,256.286977 C111.788845,216.351199 133.97078,182.794052 162.252746,155.615536 C190.638366,128.268343 224.327386,107.031355 261.239629,93.2158823 C298.948918,79.0719608 339.292311,72 382.269809,72 C434.951904,72 481.118055,80.1812879 520.768263,96.5438638 C560.418471,112.90644 593.414098,135.092983 619.755146,163.103494 C645.823967,190.667688 665.804365,223.408333 678.398635,259.198961 C691.153247,294.974763 696.976005,332.414555 695.866908,371.518338 C694.480537,425.320706 674.410807,486.092796 651.875912,513.807986 C627.109489,544.267686 603.766423,555.08515 561.350365,555.08515 C539.879106,555.08515 518.908303,544.647246 498.437956,523.771439 L520.642336,488.757018 L553.379562,469.399451 C566.854015,479.647575 578.145985,482.494276 587.255474,477.939554 C600.919708,471.107472 612.130106,436.413978 615.180122,422.270056 C618.73393,406.280102 620.684502,389.975506 621.002879,373.598326 C621.834702,330.611898 615.457396,294.420099 601.870961,265.022929 C588.284526,235.625759 569.845793,211.91389 546.554762,193.887324 C524.028964,175.836615 498.164782,162.407064 470.442999,154.367543 C442.715581,146.047589 415.1268,141.887612 387.676656,141.887612 C348.85827,141.887612 314.337635,148.127577 284.114749,160.607508 C253.891863,172.810107 228.382638,190.143344 207.587075,212.60722 C187.068785,234.793763 171.541431,261.140284 161.005012,291.646781 C150.745868,321.875947 145.893569,355.155762 146.448118,391.486227 C147.557214,427.53936 154.073158,459.98718 165.995948,488.829687 C177.28032,516.727243 194.28181,541.951359 215.9053,562.877276 C237.610095,583.620856 263.386636,599.628298 291.601152,609.885015 C320.714941,620.700955 352.601472,626.108925 387.260744,626.108925 C406.669937,626.108925 425.940493,623.89027 445.072411,619.452962 C464.481604,615.292985 482.227152,609.330351 498.309054,601.565061 L522.015997,666.460701 C500.665885,676.444645 478.206676,683.793938 454.63837,688.508578 C431.262297,693.509483 407.422332,696.019474 383.517543,696 C338.321851,696 296.730724,688.508578 258.744161,673.532662 Z" id="SvgjsPath1017" fill="#0083FF" fill-rule="nonzero"></path>
-
<g id="SvgjsG1016" transform="translate(115.0733, 79.4049)" fill="#0083FF">
-
<path d="M329.828907,231.383849 L260.699401,110.602459 C251.63529,94.765511 234.795945,84.9961472 216.561535,84.9961472 L202.32856,84.9961472 C197.759942,84.9961472 194.291354,89.1141864 195.064554,93.6217527 L218.683383,231.383849 L146.044594,231.383849 L117.317307,191.126992 C112.543308,184.436292 104.83484,180.465281 96.6208666,180.465281 L77.9170684,180.465281 C74.6441326,180.465281 72.2041032,183.486025 72.8889188,186.689439 L90.5192033,269.169882 C90.542094,269.250079 90.5821529,269.322638 90.6349289,269.382467 C90.634293,269.446115 90.634293,269.509764 90.634293,269.572775 L90.6349289,269.760538 C90.5821529,269.821003 90.542094,269.892926 90.5192033,269.973759 L72.8889188,352.453566 C72.2041032,355.657617 74.6441326,358.677724 77.9170684,358.677724 L96.6208666,358.677724 C104.83484,358.677724 112.543308,354.706712 117.317307,348.016012 L146.042051,307.761702 L218.684019,307.761702 L195.064554,445.52889 C194.291354,450.036456 197.759942,454.154495 202.32856,454.154495 L216.561535,454.154495 C234.795945,454.154495 251.63529,444.385132 260.699401,428.548184 L329.83145,307.761702 L399.512242,307.761702 C415.470292,307.761702 431.243943,304.348885 445.777042,297.751748 L448.41584,296.553888 C458.994558,291.751631 465.788667,281.20003 465.788667,269.572775 C465.788667,257.946157 458.994558,247.394556 448.41584,242.592299 L445.777042,241.39444 C431.243943,234.797303 415.470292,231.383849 399.512242,231.383849 L329.828907,231.383849 Z" id="SvgjsPath1015" transform="translate(269.2809, 269.5753) rotate(-134) translate(-269.2809, -269.5753)"></path>
-
</g>
</g>
-
</svg><style>@media (prefers-color-scheme: light) { :root { filter: none; } }
-
@media (prefers-color-scheme: dark) { :root { filter: none; } }
-
</style></svg>
···
+
<svg
+
xmlns="http://www.w3.org/2000/svg"
+
version="1.1"
+
xmlns:xlink="http://www.w3.org/1999/xlink"
+
width="768px"
+
height="768px"
+
>
+
<svg
+
width="768px"
+
height="768px"
+
viewBox="0 0 768 768"
+
version="1.1"
+
xmlns="http://www.w3.org/2000/svg"
+
xmlns:xlink="http://www.w3.org/1999/xlink"
+
>
<title>Artboard</title>
+
<g
+
id="SvgjsG1018"
+
stroke="none"
+
stroke-width="1"
+
fill="none"
+
fill-rule="evenodd"
+
>
+
<path
+
d="M258.744161,673.532662 C220.757598,658.556745 187.761971,637.340862 159.757278,609.885015 C131.731315,582.675001 109.640415,549.95668 94.87512,513.789548 C79.62504,476.904419 72,436.829975 72,393.566215 C72,341.982502 79.9023142,296.222756 95.7069425,256.286977 C111.788845,216.351199 133.97078,182.794052 162.252746,155.615536 C190.638366,128.268343 224.327386,107.031355 261.239629,93.2158823 C298.948918,79.0719608 339.292311,72 382.269809,72 C434.951904,72 481.118055,80.1812879 520.768263,96.5438638 C560.418471,112.90644 593.414098,135.092983 619.755146,163.103494 C645.823967,190.667688 665.804365,223.408333 678.398635,259.198961 C691.153247,294.974763 696.976005,332.414555 695.866908,371.518338 C694.480537,425.320706 674.410807,486.092796 651.875912,513.807986 C627.109489,544.267686 603.766423,555.08515 561.350365,555.08515 C539.879106,555.08515 518.908303,544.647246 498.437956,523.771439 L520.642336,488.757018 L553.379562,469.399451 C566.854015,479.647575 578.145985,482.494276 587.255474,477.939554 C600.919708,471.107472 612.130106,436.413978 615.180122,422.270056 C618.73393,406.280102 620.684502,389.975506 621.002879,373.598326 C621.834702,330.611898 615.457396,294.420099 601.870961,265.022929 C588.284526,235.625759 569.845793,211.91389 546.554762,193.887324 C524.028964,175.836615 498.164782,162.407064 470.442999,154.367543 C442.715581,146.047589 415.1268,141.887612 387.676656,141.887612 C348.85827,141.887612 314.337635,148.127577 284.114749,160.607508 C253.891863,172.810107 228.382638,190.143344 207.587075,212.60722 C187.068785,234.793763 171.541431,261.140284 161.005012,291.646781 C150.745868,321.875947 145.893569,355.155762 146.448118,391.486227 C147.557214,427.53936 154.073158,459.98718 165.995948,488.829687 C177.28032,516.727243 194.28181,541.951359 215.9053,562.877276 C237.610095,583.620856 263.386636,599.628298 291.601152,609.885015 C320.714941,620.700955 352.601472,626.108925 387.260744,626.108925 C406.669937,626.108925 425.940493,623.89027 445.072411,619.452962 C464.481604,615.292985 482.227152,609.330351 498.309054,601.565061 L522.015997,666.460701 C500.665885,676.444645 478.206676,683.793938 454.63837,688.508578 C431.262297,693.509483 407.422332,696.019474 383.517543,696 C338.321851,696 296.730724,688.508578 258.744161,673.532662 Z"
+
id="SvgjsPath1017"
+
fill="#0083FF"
+
fill-rule="nonzero"
+
></path>
+
<g
+
id="SvgjsG1016"
+
transform="translate(115.0733, 79.4049)"
+
fill="#0083FF"
+
>
+
<path
+
d="M329.828907,231.383849 L260.699401,110.602459 C251.63529,94.765511 234.795945,84.9961472 216.561535,84.9961472 L202.32856,84.9961472 C197.759942,84.9961472 194.291354,89.1141864 195.064554,93.6217527 L218.683383,231.383849 L146.044594,231.383849 L117.317307,191.126992 C112.543308,184.436292 104.83484,180.465281 96.6208666,180.465281 L77.9170684,180.465281 C74.6441326,180.465281 72.2041032,183.486025 72.8889188,186.689439 L90.5192033,269.169882 C90.542094,269.250079 90.5821529,269.322638 90.6349289,269.382467 C90.634293,269.446115 90.634293,269.509764 90.634293,269.572775 L90.6349289,269.760538 C90.5821529,269.821003 90.542094,269.892926 90.5192033,269.973759 L72.8889188,352.453566 C72.2041032,355.657617 74.6441326,358.677724 77.9170684,358.677724 L96.6208666,358.677724 C104.83484,358.677724 112.543308,354.706712 117.317307,348.016012 L146.042051,307.761702 L218.684019,307.761702 L195.064554,445.52889 C194.291354,450.036456 197.759942,454.154495 202.32856,454.154495 L216.561535,454.154495 C234.795945,454.154495 251.63529,444.385132 260.699401,428.548184 L329.83145,307.761702 L399.512242,307.761702 C415.470292,307.761702 431.243943,304.348885 445.777042,297.751748 L448.41584,296.553888 C458.994558,291.751631 465.788667,281.20003 465.788667,269.572775 C465.788667,257.946157 458.994558,247.394556 448.41584,242.592299 L445.777042,241.39444 C431.243943,234.797303 415.470292,231.383849 399.512242,231.383849 L329.828907,231.383849 Z"
+
id="SvgjsPath1015"
+
transform="translate(269.2809, 269.5753) rotate(-134) translate(-269.2809, -269.5753)"
+
></path>
+
</g>
</g>
+
</svg><style>
+
@media (prefers-color-scheme: light) {
+
:root {
+
filter: none;
+
}
+
}
+
@media (prefers-color-scheme: dark) {
+
:root {
+
filter: none;
+
}
+
}
+
</style>
+
</svg>
+12
static/icons/account.svg
···
···
+
<svg
+
xmlns="http://www.w3.org/2000/svg"
+
height="24px"
+
viewBox="0 0 24 24"
+
width="24px"
+
fill="#e3e3e3"
+
>
+
<path d="M0 0h24v24H0z" fill="none" />
+
<path
+
d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
+
/>
+
</svg>
+9 -3
static/icons/bluesky.svg
···
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-20 -20 296 266" fill="none">
-
<path
d="M55.491 15.172c29.35 22.035 60.917 66.712 72.509 90.686 11.592-23.974 43.159-68.651 72.509-90.686C221.686-.727 256-13.028 256 26.116c0 7.818-4.482 65.674-7.111 75.068-9.138 32.654-42.436 40.983-72.057 35.942 51.775 8.812 64.946 38 36.501 67.187-54.021 55.433-77.644-13.908-83.696-31.676-1.11-3.257-1.63-4.78-1.637-3.485-.008-1.296-.527.228-1.637 3.485-6.052 17.768-29.675 87.11-83.696 31.676-28.445-29.187-15.274-58.375 36.5-67.187-29.62 5.041-62.918-3.288-72.056-35.942C4.482 91.79 0 33.934 0 26.116 0-13.028 34.314-.727 55.491 15.172Z"
stroke="currentColor"
stroke-width="25"
fill="none"
stroke-linejoin="round"
/>
-
</svg>
···
+
<svg
+
xmlns="http://www.w3.org/2000/svg"
+
width="24"
+
height="24"
+
viewBox="-20 -20 296 266"
+
fill="none"
+
>
+
<path
d="M55.491 15.172c29.35 22.035 60.917 66.712 72.509 90.686 11.592-23.974 43.159-68.651 72.509-90.686C221.686-.727 256-13.028 256 26.116c0 7.818-4.482 65.674-7.111 75.068-9.138 32.654-42.436 40.983-72.057 35.942 51.775 8.812 64.946 38 36.501 67.187-54.021 55.433-77.644-13.908-83.696-31.676-1.11-3.257-1.63-4.78-1.637-3.485-.008-1.296-.527.228-1.637 3.485-6.052 17.768-29.675 87.11-83.696 31.676-28.445-29.187-15.274-58.375 36.5-67.187-29.62 5.041-62.918-3.288-72.056-35.942C4.482 91.79 0 33.934 0 26.116 0-13.028 34.314-.727 55.491 15.172Z"
stroke="currentColor"
stroke-width="25"
fill="none"
stroke-linejoin="round"
/>
+
</svg>
+29 -5
static/icons/info_bold.svg
···
<?xml version="1.0" encoding="UTF-8"?>
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
-
<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
-
<path d="M12 16V12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
-
<path d="M12 8H12.01" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
-
</svg>
···
<?xml version="1.0" encoding="UTF-8"?>
+
<svg
+
width="24"
+
height="24"
+
viewBox="0 0 24 24"
+
fill="none"
+
xmlns="http://www.w3.org/2000/svg"
+
>
+
<path
+
d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
+
stroke="currentColor"
+
stroke-width="2"
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
/>
+
<path
+
d="M12 16V12"
+
stroke="currentColor"
+
stroke-width="2"
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
/>
+
<path
+
d="M12 8H12.01"
+
stroke="currentColor"
+
stroke-width="2"
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
/>
+
</svg>
+21 -4
static/icons/plane-departure_bold.svg
···
-
<svg width="80" height="80" viewBox="4 20 70 36" fill="none" xmlns="http://www.w3.org/2000/svg">
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.8224 33.2841L31.008 22.743C29.2561 21.8109 27.1909 21.6663 25.3262 22.345L19.7985 24.3569C19.3667 24.5141 19.2513 25.0706 19.5849 25.3865L34.2839 39.3037L18.5107 45.0447L13.6805 42.0448C12.6378 41.3972 11.3555 41.2642 10.202 41.684L5.45108 43.4133C4.99314 43.5799 4.83855 44.15 5.14954 44.5252L13.9345 55.124C13.9589 55.1535 13.9934 55.1711 14.0299 55.1746C14.0582 55.1928 14.0913 55.2035 14.1264 55.2046L22.9607 55.4824C27.707 55.6317 32.4381 54.874 36.9004 53.2498L63.8001 43.4591C66.6965 42.405 69.3245 40.7247 71.4968 38.5381L72.708 37.3189C73.9986 36.0199 74.4226 34.0923 73.7963 32.3716C73.1701 30.6509 71.6062 29.4468 69.7826 29.2812L68.071 29.1259C65.0014 28.8472 61.9082 29.2493 59.0119 30.3034L50.8224 33.2841Z" fill="#FFFFFF" />
-
<path d="M7 64H75" stroke="#C2CCDE" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" />
-
</svg>
···
+
<svg
+
width="80"
+
height="80"
+
viewBox="4 20 70 36"
+
fill="none"
+
xmlns="http://www.w3.org/2000/svg"
+
>
+
<path
+
fill-rule="evenodd"
+
clip-rule="evenodd"
+
d="M50.8224 33.2841L31.008 22.743C29.2561 21.8109 27.1909 21.6663 25.3262 22.345L19.7985 24.3569C19.3667 24.5141 19.2513 25.0706 19.5849 25.3865L34.2839 39.3037L18.5107 45.0447L13.6805 42.0448C12.6378 41.3972 11.3555 41.2642 10.202 41.684L5.45108 43.4133C4.99314 43.5799 4.83855 44.15 5.14954 44.5252L13.9345 55.124C13.9589 55.1535 13.9934 55.1711 14.0299 55.1746C14.0582 55.1928 14.0913 55.2035 14.1264 55.2046L22.9607 55.4824C27.707 55.6317 32.4381 54.874 36.9004 53.2498L63.8001 43.4591C66.6965 42.405 69.3245 40.7247 71.4968 38.5381L72.708 37.3189C73.9986 36.0199 74.4226 34.0923 73.7963 32.3716C73.1701 30.6509 71.6062 29.4468 69.7826 29.2812L68.071 29.1259C65.0014 28.8472 61.9082 29.2493 59.0119 30.3034L50.8224 33.2841Z"
+
fill="#FFFFFF"
+
/>
+
<path
+
d="M7 64H75"
+
stroke="#C2CCDE"
+
stroke-width="6"
+
stroke-linecap="round"
+
stroke-linejoin="round"
+
/>
+
</svg>
+14 -3
static/icons/plane_bold.svg
···
-
<svg width="80" height="80" viewBox="8 10 64 60" fill="none" xmlns="http://www.w3.org/2000/svg">
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M49.4268 34L38.5549 15.0236C37.1294 12.5354 34.4811 11.0005 31.6134 11.0005H29.375C28.6565 11.0005 28.111 11.6475 28.2326 12.3557L31.9471 34H20.5233L16.0054 27.6751C15.2546 26.6239 14.0423 26 12.7505 26H9.80898C9.29425 26 8.91051 26.4746 9.01821 26.9779L11.7909 39.9367C11.7945 39.9493 11.8008 39.9607 11.8091 39.9701C11.809 39.9801 11.809 39.9901 11.809 40L11.8091 40.0295C11.8008 40.039 11.7945 40.0503 11.7909 40.063L9.01821 53.0217C8.91051 53.5251 9.29425 53.9996 9.80898 53.9996H12.7505C14.0423 53.9996 15.2546 53.3757 16.0054 52.3245L20.5229 46H31.9472L28.2326 67.6451C28.111 68.3533 28.6565 69.0003 29.375 69.0003H31.6134C34.4811 69.0003 37.1294 67.4654 38.5549 64.9772L49.4272 46H60.3858C62.8955 46 65.3762 45.4638 67.6618 44.4273L68.0768 44.2391C69.7405 43.4846 70.809 41.8268 70.809 40C70.809 38.1733 69.7405 36.5155 68.0768 35.761L67.6618 35.5728C65.3762 34.5363 62.8955 34 60.3858 34H49.4268Z" fill="#C2CCDE" />
-
</svg>
···
+
<svg
+
width="80"
+
height="80"
+
viewBox="8 10 64 60"
+
fill="none"
+
xmlns="http://www.w3.org/2000/svg"
+
>
+
<path
+
fill-rule="evenodd"
+
clip-rule="evenodd"
+
d="M49.4268 34L38.5549 15.0236C37.1294 12.5354 34.4811 11.0005 31.6134 11.0005H29.375C28.6565 11.0005 28.111 11.6475 28.2326 12.3557L31.9471 34H20.5233L16.0054 27.6751C15.2546 26.6239 14.0423 26 12.7505 26H9.80898C9.29425 26 8.91051 26.4746 9.01821 26.9779L11.7909 39.9367C11.7945 39.9493 11.8008 39.9607 11.8091 39.9701C11.809 39.9801 11.809 39.9901 11.809 40L11.8091 40.0295C11.8008 40.039 11.7945 40.0503 11.7909 40.063L9.01821 53.0217C8.91051 53.5251 9.29425 53.9996 9.80898 53.9996H12.7505C14.0423 53.9996 15.2546 53.3757 16.0054 52.3245L20.5229 46H31.9472L28.2326 67.6451C28.111 68.3533 28.6565 69.0003 29.375 69.0003H31.6134C34.4811 69.0003 37.1294 67.4654 38.5549 64.9772L49.4272 46H60.3858C62.8955 46 65.3762 45.4638 67.6618 44.4273L68.0768 44.2391C69.7405 43.4846 70.809 41.8268 70.809 40C70.809 38.1733 69.7405 36.5155 68.0768 35.761L67.6618 35.5728C65.3762 34.5363 62.8955 34 60.3858 34H49.4268Z"
+
fill="#C2CCDE"
+
/>
+
</svg>
+18 -4
static/icons/ticket_bold.svg
···
-
<svg width="80" height="80" viewBox="6 18 70 44" fill="none" xmlns="http://www.w3.org/2000/svg">
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 24C8 21.7909 9.79086 20 12 20H68C70.2091 20 72 21.7909 72 24V33.6052C71.6647 33.6578 71.3304 33.7373 71 33.8446C68.3333 34.7111 66.5279 37.1961 66.5279 40C66.5279 42.8039 68.3333 45.2889 71 46.1554C71.3304 46.2627 71.6647 46.3422 72 46.3948V56C72 58.2091 70.2091 60 68 60H12C9.79086 60 8 58.2091 8 56V46.4726C8.66685 46.4727 9.3412 46.3694 10 46.1554C12.6667 45.2889 14.4721 42.8039 14.4721 40C14.4721 37.1961 12.6667 34.7111 10 33.8446C9.3412 33.6306 8.66685 33.5273 8 33.5274V24Z" fill="#FFFFFF" />
-
<path d="M72 33.6052L72.3097 35.5811C73.2828 35.4286 74 34.5903 74 33.6052H72ZM71 33.8446L70.382 31.9425L70.382 31.9425L71 33.8446ZM71 46.1554L70.382 48.0575H70.382L71 46.1554ZM72 46.3948H74C74 45.4097 73.2828 44.5714 72.3097 44.4189L72 46.3948ZM8 46.4726L8.00027 44.4726C7.46979 44.4725 6.96101 44.6832 6.58588 45.0583C6.21075 45.4333 6 45.9421 6 46.4726H8ZM10 46.1554L10.618 48.0575H10.618L10 46.1554ZM14.4721 40H12.4721H14.4721ZM10 33.8446L10.618 31.9425H10.618L10 33.8446ZM8 33.5274H6C6 34.0579 6.21075 34.5667 6.58588 34.9417C6.96101 35.3168 7.46979 35.5275 8.00027 35.5274L8 33.5274ZM12 18C8.68629 18 6 20.6863 6 24H10C10 22.8954 10.8954 22 12 22V18ZM68 18H12V22H68V18ZM74 24C74 20.6863 71.3137 18 68 18V22C69.1046 22 70 22.8954 70 24H74ZM74 33.6052V24H70V33.6052H74ZM71.6903 31.6294C71.2511 31.6982 70.8136 31.8023 70.382 31.9425L71.618 35.7467C71.8472 35.6723 72.0783 35.6174 72.3097 35.5811L71.6903 31.6294ZM70.382 31.9425C66.8913 33.0767 64.5279 36.3296 64.5279 40H68.5279C68.5279 38.0626 69.7754 36.3454 71.618 35.7467L70.382 31.9425ZM64.5279 40C64.5279 43.6704 66.8913 46.9233 70.382 48.0575L71.618 44.2533C69.7754 43.6546 68.5279 41.9374 68.5279 40H64.5279ZM70.382 48.0575C70.8136 48.1977 71.2511 48.3018 71.6903 48.3706L72.3097 44.4189C72.0783 44.3826 71.8472 44.3277 71.618 44.2533L70.382 48.0575ZM74 56V46.3948H70V56H74ZM68 62C71.3137 62 74 59.3137 74 56H70C70 57.1046 69.1046 58 68 58V62ZM12 62H68V58H12V62ZM6 56C6 59.3137 8.68629 62 12 62V58C10.8954 58 10 57.1046 10 56H6ZM6 46.4726V56H10V46.4726H6ZM9.38197 44.2533C8.92559 44.4015 8.46006 44.4726 8.00027 44.4726L7.99973 48.4726C8.87364 48.4727 9.7568 48.3373 10.618 48.0575L9.38197 44.2533ZM12.4721 40C12.4721 41.9374 11.2246 43.6545 9.38197 44.2533L10.618 48.0575C14.1087 46.9233 16.4721 43.6704 16.4721 40H12.4721ZM9.38197 35.7467C11.2246 36.3454 12.4721 38.0626 12.4721 40H16.4721C16.4721 36.3296 14.1087 33.0767 10.618 31.9425L9.38197 35.7467ZM8.00027 35.5274C8.46006 35.5274 8.92559 35.5985 9.38197 35.7467L10.618 31.9425C9.7568 31.6627 8.87364 31.5273 7.99973 31.5274L8.00027 35.5274ZM6 24V33.5274H10V24H6Z" fill="#FFFFFF" />
-
</svg>
···
+
<svg
+
width="80"
+
height="80"
+
viewBox="6 18 70 44"
+
fill="none"
+
xmlns="http://www.w3.org/2000/svg"
+
>
+
<path
+
fill-rule="evenodd"
+
clip-rule="evenodd"
+
d="M8 24C8 21.7909 9.79086 20 12 20H68C70.2091 20 72 21.7909 72 24V33.6052C71.6647 33.6578 71.3304 33.7373 71 33.8446C68.3333 34.7111 66.5279 37.1961 66.5279 40C66.5279 42.8039 68.3333 45.2889 71 46.1554C71.3304 46.2627 71.6647 46.3422 72 46.3948V56C72 58.2091 70.2091 60 68 60H12C9.79086 60 8 58.2091 8 56V46.4726C8.66685 46.4727 9.3412 46.3694 10 46.1554C12.6667 45.2889 14.4721 42.8039 14.4721 40C14.4721 37.1961 12.6667 34.7111 10 33.8446C9.3412 33.6306 8.66685 33.5273 8 33.5274V24Z"
+
fill="#FFFFFF"
+
/>
+
<path
+
d="M72 33.6052L72.3097 35.5811C73.2828 35.4286 74 34.5903 74 33.6052H72ZM71 33.8446L70.382 31.9425L70.382 31.9425L71 33.8446ZM71 46.1554L70.382 48.0575H70.382L71 46.1554ZM72 46.3948H74C74 45.4097 73.2828 44.5714 72.3097 44.4189L72 46.3948ZM8 46.4726L8.00027 44.4726C7.46979 44.4725 6.96101 44.6832 6.58588 45.0583C6.21075 45.4333 6 45.9421 6 46.4726H8ZM10 46.1554L10.618 48.0575H10.618L10 46.1554ZM14.4721 40H12.4721H14.4721ZM10 33.8446L10.618 31.9425H10.618L10 33.8446ZM8 33.5274H6C6 34.0579 6.21075 34.5667 6.58588 34.9417C6.96101 35.3168 7.46979 35.5275 8.00027 35.5274L8 33.5274ZM12 18C8.68629 18 6 20.6863 6 24H10C10 22.8954 10.8954 22 12 22V18ZM68 18H12V22H68V18ZM74 24C74 20.6863 71.3137 18 68 18V22C69.1046 22 70 22.8954 70 24H74ZM74 33.6052V24H70V33.6052H74ZM71.6903 31.6294C71.2511 31.6982 70.8136 31.8023 70.382 31.9425L71.618 35.7467C71.8472 35.6723 72.0783 35.6174 72.3097 35.5811L71.6903 31.6294ZM70.382 31.9425C66.8913 33.0767 64.5279 36.3296 64.5279 40H68.5279C68.5279 38.0626 69.7754 36.3454 71.618 35.7467L70.382 31.9425ZM64.5279 40C64.5279 43.6704 66.8913 46.9233 70.382 48.0575L71.618 44.2533C69.7754 43.6546 68.5279 41.9374 68.5279 40H64.5279ZM70.382 48.0575C70.8136 48.1977 71.2511 48.3018 71.6903 48.3706L72.3097 44.4189C72.0783 44.3826 71.8472 44.3277 71.618 44.2533L70.382 48.0575ZM74 56V46.3948H70V56H74ZM68 62C71.3137 62 74 59.3137 74 56H70C70 57.1046 69.1046 58 68 58V62ZM12 62H68V58H12V62ZM6 56C6 59.3137 8.68629 62 12 62V58C10.8954 58 10 57.1046 10 56H6ZM6 46.4726V56H10V46.4726H6ZM9.38197 44.2533C8.92559 44.4015 8.46006 44.4726 8.00027 44.4726L7.99973 48.4726C8.87364 48.4727 9.7568 48.3373 10.618 48.0575L9.38197 44.2533ZM12.4721 40C12.4721 41.9374 11.2246 43.6545 9.38197 44.2533L10.618 48.0575C14.1087 46.9233 16.4721 43.6704 16.4721 40H12.4721ZM9.38197 35.7467C11.2246 36.3454 12.4721 38.0626 12.4721 40H16.4721C16.4721 36.3296 14.1087 33.0767 10.618 31.9425L9.38197 35.7467ZM8.00027 35.5274C8.46006 35.5274 8.92559 35.5985 9.38197 35.7467L10.618 31.9425C9.7568 31.6627 8.87364 31.5273 7.99973 31.5274L8.00027 35.5274ZM6 24V33.5274H10V24H6Z"
+
fill="#FFFFFF"
+
/>
+
</svg>
+125 -116
static/styles.css
···
@import url("https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
@font-face {
-
font-family: "Skyfont";
-
src: url("fonts/skyfont.regular.otf") format("opentype");
-
font-weight: normal;
-
font-style: normal;
}
@font-face {
-
font-family: "F25_Bank_Printer";
-
src: url("fonts/F25_Bank_Printer.ttf") format("truetype");
-
font-weight: normal;
-
font-style: normal;
}
@tailwind base;
···
@tailwind utilities;
@keyframes fadeOut {
-
0% {
-
opacity: 1;
-
}
-
75% {
-
opacity: 1;
-
} /* Hold full opacity for most of the animation */
-
100% {
-
opacity: 0;
-
}
}
.status-message-fade {
-
animation: fadeOut 2s forwards;
}
.font-spectral {
-
font-family: "Spectral", serif;
}
.grow-wrap {
-
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
-
display: grid;
}
.grow-wrap::after {
-
/* Note the weird space! Needed to preventy jumpy behavior */
-
content: attr(data-replicated-value) " ";
-
/* This is how textarea text behaves */
-
white-space: pre-wrap;
-
/* Hidden from view, clicks, and screen readers */
-
visibility: hidden;
}
.grow-wrap > textarea {
-
/* You could leave this, but after a user resizes, then it ruins the auto sizing */
-
resize: none;
-
/* Firefox shows scrollbar on growth, you can hide like this. */
-
overflow: hidden;
}
.grow-wrap > textarea,
.grow-wrap::after {
-
/* Identical styling required!! */
-
font: inherit;
-
/* Place on top of each other */
-
grid-area: 1 / 1 / 2 / 2;
}
/* Base styling */
@layer base {
-
body {
-
@apply bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100;
-
font-family: Space Mono;
-
}
-
button {
-
@apply rounded-xl;
-
}
-
input {
-
@apply px-4 py-2;
-
}
-
h1,
-
h2,
-
h3,
-
h4,
-
h5 {
-
font-family:
-
Share Tech Mono,
-
monospace;
-
}
}
.ticket {
-
font-family: F25_Bank_Printer, monospace;
-
@apply bg-white dark:bg-gray-800 p-8 relative overflow-hidden;
-
position: relative;
-
/* Angled corners */
-
clip-path: polygon(
-
20px 0,
-
/* Top left corner */ calc(100% - 20px) 0,
-
/* Top right corner */ 100% 20px,
-
/* Top right */ 100% calc(100% - 20px),
-
/* Bottom right */ calc(100% - 20px) 100%,
-
/* Bottom right corner */ 20px 100%,
-
/* Bottom left corner */ 0 calc(100% - 20px),
-
/* Bottom left */ 0 20px /* Back to top left */
-
);
}
/* Create side perforations using pseudo-elements */
.ticket::before,
.ticket::after {
-
content: "";
-
position: absolute;
-
top: 30px;
-
bottom: 30px;
-
width: 1px;
-
background-image: linear-gradient(
-
to bottom,
-
transparent 0%,
-
transparent 40%,
-
currentColor 40%,
-
currentColor 60%,
-
transparent 60%,
-
transparent 100%
-
);
-
background-size: 100% 20px;
-
background-repeat: repeat-y;
-
opacity: 0.2;
}
.ticket::before {
-
left: 8px;
}
.ticket::after {
-
right: 8px;
}
.dark .ticket {
-
background-image:
-
radial-gradient(
-
circle at 10px center,
-
rgb(17 24 39) 4px,
-
transparent 4px
-
),
-
radial-gradient(
-
circle at calc(100% - 10px) center,
-
rgb(17 24 39) 4px,
-
transparent 4px
-
);
}
/* Remove the previous background images and corner cuts */
.ticket::before,
.ticket::after {
-
display: none;
}
.boarding-label {
-
@apply absolute top-2 right-2 bg-blue-100 dark:bg-blue-900 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider;
-
transform: rotate(2deg);
}
.flight-info {
-
@apply flex justify-between items-center mt-4 pt-4 border-t border-dashed;
}
.passenger-info {
-
@apply text-sm text-gray-600 dark:text-gray-400 mt-2;
}
/* Modern Airport Sign Styles */
.airport-sign {
-
position: relative;
-
transform-origin: top;
-
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
-
border-radius: 0.5rem;
-
backdrop-filter: blur(8px);
}
/* Dropdown panel styles */
.airport-sign + div {
-
border-radius: 0.5rem;
-
backdrop-filter: blur(8px);
}
/* Remove old texture styles */
.airport-sign,
.airport-sign + div {
-
background-blend-mode: overlay;
}
@keyframes popin {
-
0% { opacity: 0; transform: scale(0.95); }
-
100% { opacity: 1; transform: scale(1); }
}
.animate-popin {
-
animation: popin 0.25s cubic-bezier(0.4,0,0.2,1);
}
@keyframes bounce-short {
-
0%, 100% { transform: translateY(0); }
-
50% { transform: translateY(-8px); }
}
.animate-bounce-short {
animation: bounce-short 0.5s;
···
@import url("https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
@font-face {
+
font-family: "Skyfont";
+
src: url("fonts/skyfont.regular.otf") format("opentype");
+
font-weight: normal;
+
font-style: normal;
}
@font-face {
+
font-family: "F25_Bank_Printer";
+
src: url("fonts/F25_Bank_Printer.ttf") format("truetype");
+
font-weight: normal;
+
font-style: normal;
}
@tailwind base;
···
@tailwind utilities;
@keyframes fadeOut {
+
0% {
+
opacity: 1;
+
}
+
75% {
+
opacity: 1;
+
} /* Hold full opacity for most of the animation */
+
100% {
+
opacity: 0;
+
}
}
.status-message-fade {
+
animation: fadeOut 2s forwards;
}
.font-spectral {
+
font-family: "Spectral", serif;
}
.grow-wrap {
+
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
+
display: grid;
}
.grow-wrap::after {
+
/* Note the weird space! Needed to preventy jumpy behavior */
+
content: attr(data-replicated-value) " ";
+
/* This is how textarea text behaves */
+
white-space: pre-wrap;
+
/* Hidden from view, clicks, and screen readers */
+
visibility: hidden;
}
.grow-wrap > textarea {
+
/* You could leave this, but after a user resizes, then it ruins the auto sizing */
+
resize: none;
+
/* Firefox shows scrollbar on growth, you can hide like this. */
+
overflow: hidden;
}
.grow-wrap > textarea,
.grow-wrap::after {
+
/* Identical styling required!! */
+
font: inherit;
+
/* Place on top of each other */
+
grid-area: 1 / 1 / 2 / 2;
}
/* Base styling */
@layer base {
+
body {
+
@apply bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100;
+
font-family: Space Mono;
+
}
+
button {
+
@apply rounded-xl;
+
}
+
input {
+
@apply px-4 py-2;
+
}
+
h1,
+
h2,
+
h3,
+
h4,
+
h5 {
+
font-family: Share Tech Mono, monospace;
+
}
}
.ticket {
+
font-family: F25_Bank_Printer, monospace;
+
@apply bg-white dark:bg-gray-800 p-8 relative overflow-hidden;
+
position: relative;
+
/* Angled corners */
+
clip-path: polygon(
+
20px 0,
+
/* Top left corner */ calc(100% - 20px) 0,
+
/* Top right corner */ 100% 20px,
+
/* Top right */ 100% calc(100% - 20px),
+
/* Bottom right */ calc(100% - 20px) 100%,
+
/* Bottom right corner */ 20px 100%,
+
/* Bottom left corner */ 0 calc(100% - 20px),
+
/* Bottom left */ 0 20px /* Back to top left */
+
);
}
/* Create side perforations using pseudo-elements */
.ticket::before,
.ticket::after {
+
content: "";
+
position: absolute;
+
top: 30px;
+
bottom: 30px;
+
width: 1px;
+
background-image: linear-gradient(
+
to bottom,
+
transparent 0%,
+
transparent 40%,
+
currentColor 40%,
+
currentColor 60%,
+
transparent 60%,
+
transparent 100%
+
);
+
background-size: 100% 20px;
+
background-repeat: repeat-y;
+
opacity: 0.2;
}
.ticket::before {
+
left: 8px;
}
.ticket::after {
+
right: 8px;
}
.dark .ticket {
+
background-image:
+
radial-gradient(
+
circle at 10px center,
+
rgb(17 24 39) 4px,
+
transparent 4px
+
),
+
radial-gradient(
+
circle at calc(100% - 10px) center,
+
rgb(17 24 39) 4px,
+
transparent 4px
+
);
}
/* Remove the previous background images and corner cuts */
.ticket::before,
.ticket::after {
+
display: none;
}
.boarding-label {
+
@apply absolute top-2 right-2 bg-blue-100 dark:bg-blue-900 px-3 py-1
+
rounded-full text-xs font-bold uppercase tracking-wider;
+
transform: rotate(2deg);
}
.flight-info {
+
@apply flex justify-between items-center mt-4 pt-4 border-t border-dashed;
}
.passenger-info {
+
@apply text-sm text-gray-600 dark:text-gray-400 mt-2;
}
/* Modern Airport Sign Styles */
.airport-sign {
+
position: relative;
+
transform-origin: top;
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
+
border-radius: 0.5rem;
+
backdrop-filter: blur(8px);
}
/* Dropdown panel styles */
.airport-sign + div {
+
border-radius: 0.5rem;
+
backdrop-filter: blur(8px);
}
/* Remove old texture styles */
.airport-sign,
.airport-sign + div {
+
background-blend-mode: overlay;
}
@keyframes popin {
+
0% {
+
opacity: 0;
+
transform: scale(0.95);
+
}
+
100% {
+
opacity: 1;
+
transform: scale(1);
+
}
}
.animate-popin {
+
animation: popin 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes bounce-short {
+
0%, 100% {
+
transform: translateY(0);
+
}
+
50% {
+
transform: translateY(-8px);
+
}
}
.animate-bounce-short {
animation: bounce-short 0.5s;