add ratatoskr
diff --git a/package-lock.json b/package-lock.json
index de87eea..b22d509 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7,6 +7,7 @@
"name": "burya",
"license": "UNLICENSED",
"dependencies": {
+ "@jottocraft/rtsk-middleware": "^0.1.0",
"@remix-run/cloudflare": "^1.7.6",
"@remix-run/cloudflare-workers": "^1.7.6",
"@remix-run/react": "^1.7.6",
@@ -15,7 +16,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
- "shamrock-ux": "^0.0.70-beta",
+ "shamrock-ux": "^0.0.71-beta",
"styled-components": "^5.3.6",
"ua-parser-js": "^1.0.32"
},
@@ -2203,6 +2204,11 @@
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==",
"dev": true
},
+ "node_modules/@jottocraft/rtsk-middleware": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@jottocraft/rtsk-middleware/-/rtsk-middleware-0.1.0.tgz",
+ "integrity": "sha512-tcj5OfIQNy0pOdtZRZhFfQYYReCd6ZpIVFL4TcOK4jGEAkOEt/7IxUzD7uh5wprc3b0lOcTmnsNTTf5yLvNd4A=="
+ },
"node_modules/@jridgewell/gen-mapping": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
@@ -12645,9 +12651,9 @@
"integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ=="
},
"node_modules/shamrock-ux": {
- "version": "0.0.70-beta",
- "resolved": "https://registry.npmjs.org/shamrock-ux/-/shamrock-ux-0.0.70-beta.tgz",
- "integrity": "sha512-Om0ROeb+weR3DxyXiRZcuMujdXEhbmo5246BPGvF7kc1Zmts8kjdM6h6M5ZqLtlUScaUPriR4wQlpjGo+AElAQ==",
+ "version": "0.0.71-beta",
+ "resolved": "https://registry.npmjs.org/shamrock-ux/-/shamrock-ux-0.0.71-beta.tgz",
+ "integrity": "sha512-b7+tWsZWIlerNRGG8Nrp2ZZ54wBm+F6/avBF2zno6dYpEz4/dMO4vIvKXUpMAe+EpW1FUw8o7XmV+H1Fbz0fzg==",
"dependencies": {
"chroma-js": "^2.1.2",
"lodash": "^4.17.21",
@@ -16852,6 +16858,11 @@
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==",
"dev": true
},
+ "@jottocraft/rtsk-middleware": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@jottocraft/rtsk-middleware/-/rtsk-middleware-0.1.0.tgz",
+ "integrity": "sha512-tcj5OfIQNy0pOdtZRZhFfQYYReCd6ZpIVFL4TcOK4jGEAkOEt/7IxUzD7uh5wprc3b0lOcTmnsNTTf5yLvNd4A=="
+ },
"@jridgewell/gen-mapping": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
@@ -24567,9 +24578,9 @@
"integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ=="
},
"shamrock-ux": {
- "version": "0.0.70-beta",
- "resolved": "https://registry.npmjs.org/shamrock-ux/-/shamrock-ux-0.0.70-beta.tgz",
- "integrity": "sha512-Om0ROeb+weR3DxyXiRZcuMujdXEhbmo5246BPGvF7kc1Zmts8kjdM6h6M5ZqLtlUScaUPriR4wQlpjGo+AElAQ==",
+ "version": "0.0.71-beta",
+ "resolved": "https://registry.npmjs.org/shamrock-ux/-/shamrock-ux-0.0.71-beta.tgz",
+ "integrity": "sha512-b7+tWsZWIlerNRGG8Nrp2ZZ54wBm+F6/avBF2zno6dYpEz4/dMO4vIvKXUpMAe+EpW1FUw8o7XmV+H1Fbz0fzg==",
"requires": {
"chroma-js": "^2.1.2",
"lodash": "^4.17.21",
diff --git a/package.json b/package.json
index f7cc475..e2dc74a 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"generate:css": "tailwindcss -i ./src/styles/tailwind.css -o src/intermediates/tailwind.css"
},
"dependencies": {
+ "@jottocraft/rtsk-middleware": "^0.1.0",
"@remix-run/cloudflare": "^1.7.6",
"@remix-run/cloudflare-workers": "^1.7.6",
"@remix-run/react": "^1.7.6",
@@ -23,7 +24,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
- "shamrock-ux": "^0.0.70-beta",
+ "shamrock-ux": "^0.0.71-beta",
"styled-components": "^5.3.6",
"ua-parser-js": "^1.0.32"
},
diff --git a/remix.config.js b/remix.config.js
index c2df613..148a89f 100644
--- a/remix.config.js
+++ b/remix.config.js
@@ -2,7 +2,7 @@
module.exports = {
serverBuildTarget: "cloudflare-workers",
server: "./src/worker/index.ts",
- //devServerBroadcastDelay: 1000,
+ devServerBroadcastDelay: 1000,
ignoredRouteFiles: ["**/.*"],
appDirectory: "src/app",
assetsBuildDirectory: "public/dist",
diff --git a/src/app/components/NavRoot.tsx b/src/app/components/NavRoot.tsx
index 214025d..f20c946 100644
--- a/src/app/components/NavRoot.tsx
+++ b/src/app/components/NavRoot.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Navbar, Sidebar, Container, Clickable, SidebarItem, SidebarGroup, Icon } from "shamrock-ux";
-import { useLoaderData, useLocation, useNavigate } from "@remix-run/react";
+import { useLoaderData, useLocation } from "@remix-run/react";
import tools from "../tools";
import IPDetailsPage from "./ip/IPDetailsPage";
import { Helmet } from "react-helmet-async";
@@ -8,7 +8,6 @@
export default function NavRoot({ children }: { children: React.ReactNode }) {
const loaderData = useLoaderData();
const location = useLocation();
- const navigate = useNavigate();
if (loaderData?.dedicatedPanel) return (
<>
@@ -56,7 +55,7 @@
group.items.forEach((tool: SidebarItem & { id: string; }) => {
const pathname = `/${tool.id}`;
tool.active = location.pathname === pathname;
- tool.onClick = () => navigate(pathname);
+ tool.href = pathname;
return tool;
});
diff --git a/src/app/components/StatusBox.tsx b/src/app/components/StatusBox.tsx
index cac44ee..f82aea7 100644
--- a/src/app/components/StatusBox.tsx
+++ b/src/app/components/StatusBox.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { Icon } from "shamrock-ux";
-export default function StatusBox({ type, children }: { type?: string; children: React.ReactNode; }) {
+export default function StatusBox({ type, children }: { type?: "info" | "error" | "warning" | "success"; children: React.ReactNode; }) {
let color = "bg-blue-500", icon = "info";
if (type === "error") { color = "bg-red-500"; icon = "priority_high"; }
if (type === "warning") { color = "bg-amber-500"; icon = "warning"; }
diff --git a/src/app/routes/connection.tsx b/src/app/routes/connection.tsx
new file mode 100644
index 0000000..e8f7f63
--- /dev/null
+++ b/src/app/routes/connection.tsx
@@ -0,0 +1,35 @@
+import { HeadersFunction, LoaderFunction } from "@remix-run/cloudflare";
+import { useLoaderData } from "@remix-run/react";
+import React from "react";
+import { Helmet } from "react-helmet-async";
+import Widget from "../components/Widget";
+import getConnectionProps, { ConnectionProps } from "../util/connection/connectionStats";
+
+export const loader: LoaderFunction = async ({ request, context }) => {
+ return getConnectionProps(request, context.cf as IncomingRequestCfProperties);
+};
+
+export default function Connection() {
+ const data = useLoaderData() as ConnectionProps;
+
+ return (
+ <>
+ <Helmet>
+ <title>Connection</title>
+ </Helmet>
+ <table>
+ <tbody>
+ <tr>
+ <td className="p-4" colSpan={2}>
+ <Widget name="Legacy User-Agent header" icon="code">
+ <p>
+ <code className="font-medium text-type-0">{data.colo}</code>
+ </p>
+ </Widget>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </>
+ );
+}
\ No newline at end of file
diff --git a/src/app/routes/dns.tsx b/src/app/routes/dns.tsx
new file mode 100644
index 0000000..f604f8a
--- /dev/null
+++ b/src/app/routes/dns.tsx
@@ -0,0 +1,43 @@
+import { LoaderFunction } from "@remix-run/cloudflare";
+import { Clickable, Icon } from "shamrock-ux";
+import tools from "../tools";
+
+export default function DNS() {
+
+ return (
+ <div className="w-full max-w-md mx-auto my-24 space-y-8">
+ <div className="space-y-4 text-center">
+ <div className="text-4xl font-semibold text-type-0 flex flex-row items-center justify-center space-x-2">
+ <Icon>🧰</Icon>
+ <h1>WebDiag</h1>
+ </div>
+ <h2 className="text-type-20">Select a tool below to get started</h2>
+ </div>
+ <div className="space-y-4">
+ {tools.map(group => (
+ <div key={group.title} className="space-y-2">
+ <div className="flex flex-row items-center space-x-2 mx-1 text-lg text-type-10 font-medium">
+ <Icon>{group.icon}</Icon>
+ <h3>{group.title}</h3>
+ </div>
+ <div className="space-y-1">
+ {group.items.map(tool => (
+ <div key={tool.id}>
+ <Clickable href={`/${tool.id}`} className="w-full">
+ <div className="hover:bg-ui-10 rounded-lg p-2 text-left">
+ <div className="flex flex-row items-center font-medium text-type-20 space-x-1">
+ <Icon>{tool.icon}</Icon>
+ <h5>{tool.name}</h5>
+ </div>
+ <p className="text-type-30 text-sm">{tool.desc}</p>
+ </div>
+ </Clickable>
+ </div>
+ ))}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/src/app/routes/http.tsx b/src/app/routes/http.tsx
index d2178c4..2aa5364 100644
--- a/src/app/routes/http.tsx
+++ b/src/app/routes/http.tsx
@@ -58,7 +58,7 @@
<KVGroup data={data.headers.secCH} cat="Client hints" icon="devices" desc="These headers were specifically requested for WebDiag's User Agent tool and may not be present in a typical HTTP request" />
<KVGroup data={data.headers.cf} cat="Cloudflare proxy headers" icon="multiple_stop" desc="These headers were added by the Cloudflare reverse proxy used by WebDiag and may not be present in your original request" />
<StatusBox type="info">
- <p>This tool only accepts GET requests, as it's intended to be used in a browser. If you'd like to troubleshoot more complicated HTTP requests, try using <Link href="https://echo.jottocraft.com">echo.jottocraft.com</Link>.</p>
+ <p>This tool only accepts body-less GET requests, since it's intended to be loaded from a browser. If you'd like to check requests from other contexts, try using <Link href="https://echo.jottocraft.com">echo.jottocraft.com</Link>.</p>
</StatusBox>
</div>
</>
diff --git a/src/app/routes/index.tsx b/src/app/routes/index.tsx
index 03714ee..34f42b5 100644
--- a/src/app/routes/index.tsx
+++ b/src/app/routes/index.tsx
@@ -1,10 +1,8 @@
import { LoaderFunction } from "@remix-run/cloudflare";
-import { useNavigate } from "@remix-run/react";
import { Clickable, Icon } from "shamrock-ux";
import tools from "../tools";
export default function Index() {
- const navigate = useNavigate();
return (
<div className="w-full max-w-md mx-auto my-24 space-y-8">
@@ -25,7 +23,7 @@
<div className="space-y-1">
{group.items.map(tool => (
<div key={tool.id}>
- <Clickable href={`/${tool.id}`} onClick={(e) => { e.preventDefault(); navigate(`/${tool.id}`) }} className="w-full">
+ <Clickable href={`/${tool.id}`} className="w-full">
<div className="hover:bg-ui-10 rounded-lg p-2 text-left">
<div className="flex flex-row items-center font-medium text-type-20 space-x-1">
<Icon>{tool.icon}</Icon>
diff --git a/src/app/routes/ratatoskr.tsx b/src/app/routes/ratatoskr.tsx
new file mode 100644
index 0000000..9eb5213
--- /dev/null
+++ b/src/app/routes/ratatoskr.tsx
@@ -0,0 +1,136 @@
+import { withRatatoskr } from "@jottocraft/rtsk-middleware";
+import { HeadersFunction, LoaderFunction } from "@remix-run/cloudflare";
+import { useLoaderData } from "@remix-run/react";
+import React from "react";
+import { Helmet } from "react-helmet-async";
+import { Button, Icon, Link } from "shamrock-ux";
+import StatusBox from "../components/StatusBox";
+import Widget from "../components/Widget";
+import getConnectionProps, { ConnectionProps } from "../util/connection/connectionStats";
+
+type RatatoskrLoaderData = {
+ user: null | {
+ id: string;
+ email: string;
+ emailVerified?: boolean;
+ username?: string;
+ displayName?: string;
+ sessionExp: string;
+ }
+};
+
+export const loader: LoaderFunction = async ({ request, context }) => {
+ const resPromise: Promise<Response> = withRatatoskr(async (req) => {
+ return new Response(JSON.stringify({
+ user: req.ratatoskr.user && {
+ id: req.ratatoskr.user.id,
+ email: req.ratatoskr.user.email,
+ emailVerified: req.ratatoskr.user.emailVerified,
+ username: req.ratatoskr.user.username,
+ displayName: req.ratatoskr.user.displayName,
+ sessionExp: req.ratatoskr.user.sessionExp
+ }
+ }), {
+ status: 200,
+ headers: {
+ "Content-Type": "application/json"
+ }
+ });
+ }, { ratatoskr: RATATOSKR_CORE }, ["id", "email", "emailVerified", "username", "displayName", "sessionExp"])(request);
+
+ return resPromise;
+};
+
+//Forward loader headers to the page
+export const headers: HeadersFunction = ({ loaderHeaders }) => {
+ return loaderHeaders;
+};
+
+export default function Ratatoskr() {
+ const data = useLoaderData() as RatatoskrLoaderData;
+
+ return (
+ <>
+ <Helmet>
+ <title>jottocraft ID</title>
+ </Helmet>
+ <table>
+ <tbody>
+ <tr>
+ <td className="p-4" colSpan={2}>
+ <StatusBox type="warning">
+ <p>
+ {/*jottocraft ID is in private alpha and subject to change*/}
+ jottocraft ID is in internal preview and subject to change and/or data loss
+ </p>
+ </StatusBox>
+ </td>
+ </tr>
+ {data.user === null ? (
+ <tr>
+ <td className="p-4 space-y-2">
+ <p>You're not signed into jottocraft ID</p>
+ <Button href="https://id.jottocraft.com/sid?rp=https://webdiag.jottocraft.com/ratatoskr" icon="login" align="right">Sign in</Button>
+ </td>
+ </tr>
+ ) : (
+ <>
+ <tr>
+ <td className="p-4" colSpan={2}>
+ <Widget name="User ID" icon="badge">
+ <p>
+ <code className="font-medium text-type-0">{data.user.id}</code>
+ </p>
+ </Widget>
+ </td>
+ </tr>
+ <tr>
+ <td className="p-4">
+ <Widget name="Email address" icon="email">
+ <p>
+ {data.user.email}
+ </p>
+ </Widget>
+ </td>
+ <td className="p-4">
+ <Widget name="Verification status" icon="done">
+ {data.user.emailVerified ? (
+ <p><Icon>✅</Icon> Email verified</p>
+ ) : (
+ <p><Icon>❌</Icon> Email not verified</p>
+ )}
+ </Widget>
+ </td>
+ </tr>
+ <tr>
+ <td className="p-4">
+ <Widget name="Username" icon="badge">
+ <p>
+ {data.user.username ? "@" + data.user.username : <i>Not set</i>}
+ </p>
+ </Widget>
+ </td>
+ <td className="p-4">
+ <Widget name="Display name" icon="face">
+ <p>
+ {data.user.displayName ? data.user.displayName : <i>Not set</i>}
+ </p>
+ </Widget>
+ </td>
+ </tr>
+ <tr>
+ <td className="p-4">
+ <Widget name="Session expiration" icon="alarm">
+ <p>
+ {data.user.sessionExp ? new Date(data.user.sessionExp).toLocaleString() : <i>Unavailable</i>}
+ </p>
+ </Widget>
+ </td>
+ </tr>
+ </>
+ )}
+ </tbody>
+ </table>
+ </>
+ );
+}
\ No newline at end of file
diff --git a/src/app/tools.ts b/src/app/tools.ts
index 17fcd52..f3ef587 100644
--- a/src/app/tools.ts
+++ b/src/app/tools.ts
@@ -4,7 +4,7 @@
{ name: "IP address", desc: "Get information about your public network", icon: "travel_explore", id: "ip" },
{ name: "User agent", desc: "Get information about your device and browser", icon: "devices", id: "ua" },
{ name: "Browser HTTP request", desc: "Show all the data your browser sends to load websites", icon: "swap_vert", id: "http" },
- // { name: "Connection info", desc: "Get information about how your browser establishes connections with web servers", icon: "cable", id: "con" },
+ // { name: "Connection info", desc: "Get information about how your browser establishes connections with web servers", icon: "cable", id: "connection" },
// { name: "Query DNS", desc: "Resolve DNS names with public resolvers", icon: "dns", id: "dns" }
]
},
@@ -14,7 +14,9 @@
// { name: "Mouse tracer", desc: "Monitor for mouse, touch, and pen presses and movement", icon: "mouse", id: "mouse" }
// ]
// },
- //{ type: "group", title: "jottocraft cookies", icon: "🍪", items: [
- // { name: "jottocraft ID", icon: "badge", active: location.pathname === "/ratatoskr" }
- //] }
+ {
+ type: "group", title: "Cookies", icon: "🍪", items: [
+ { name: "jottocraft ID", desc: "Troubleshoot your jottocraft ID session", icon: "badge", id: "ratatoskr" }
+ ]
+ }
];
\ No newline at end of file
diff --git a/src/app/util/connection/connectionStats.ts b/src/app/util/connection/connectionStats.ts
new file mode 100644
index 0000000..f14fb9f
--- /dev/null
+++ b/src/app/util/connection/connectionStats.ts
@@ -0,0 +1,29 @@
+export type ConnectionProps = {
+ lat?: string;
+ lon?: string;
+} & Pick<
+ IncomingRequestCfProperties,
+ "colo"
+ | "clientTcpRtt"
+ | "tlsCipher"
+ | "tlsVersion"
+ | "requestPriority"
+>;
+
+export default async function getConnectionProps(request: Request, cf: IncomingRequestCfProperties): Promise<ConnectionProps> {
+ let lat, lon;
+ if ("latitude" in cf) {
+ lat = cf.latitude;
+ lon = cf.longitude;
+ }
+
+ return {
+ lat,
+ lon,
+ colo: cf.colo,
+ clientTcpRtt: cf.clientTcpRtt,
+ tlsCipher: cf.tlsCipher,
+ tlsVersion: cf.tlsVersion,
+ requestPriority: cf.requestPriority
+ };
+}
\ No newline at end of file
diff --git a/src/bindings.d.ts b/src/bindings.d.ts
index e69de29..98cf370 100644
--- a/src/bindings.d.ts
+++ b/src/bindings.d.ts
@@ -0,0 +1,5 @@
+export { };
+
+declare global {
+ const RATATOSKR_CORE: Fetcher;
+}
\ No newline at end of file
diff --git a/wrangler.toml b/wrangler.toml
index 1c2b699..9917103 100644
--- a/wrangler.toml
+++ b/wrangler.toml
@@ -6,6 +6,10 @@
# https://developers.cloudflare.com/workers/platform/compatibility-dates
compatibility_date = "2022-11-24"
+services = [
+ { binding = "RATATOSKR_CORE", service = "ratatoskr-core" }
+]
+
[site]
bucket = "./public"