@orbclub/create-app 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -2
  3. package/bin/create-orb-app.js +410 -0
  4. package/bin/node-version.js +6 -0
  5. package/bin/package-manager.js +87 -0
  6. package/bin/sdk-version.js +3 -0
  7. package/package.json +33 -4
  8. package/template/.env.local.example +10 -0
  9. package/template/AGENTS.md +105 -0
  10. package/template/README.md +56 -0
  11. package/template/eslint.config.mjs +11 -0
  12. package/template/gitignore +26 -0
  13. package/template/next.config.ts +25 -0
  14. package/template/package.json +29 -0
  15. package/template/pnpm-workspace.yaml +15 -0
  16. package/template/src/app/.well-known/orb-siwo.json/route.ts +23 -0
  17. package/template/src/app/api/local-sign-in/init/route.ts +12 -0
  18. package/template/src/app/api/local-sign-in/local-sign-in.ts +50 -0
  19. package/template/src/app/api/local-sign-in/status/route.ts +12 -0
  20. package/template/src/app/api/orb/route-validation.ts +123 -0
  21. package/template/src/app/api/orb/user/route.ts +44 -0
  22. package/template/src/app/api/route-security.ts +105 -0
  23. package/template/src/app/api/site-session/bind/route.ts +82 -0
  24. package/template/src/app/api/site-session/binding/route.ts +35 -0
  25. package/template/src/app/api/site-session/end/route.ts +30 -0
  26. package/template/src/app/api/site-session/renew/route.ts +71 -0
  27. package/template/src/app/api/site-session/site-session.ts +152 -0
  28. package/template/src/app/globals.css +196 -0
  29. package/template/src/app/home.tsx +115 -0
  30. package/template/src/app/layout.tsx +24 -0
  31. package/template/src/app/page.tsx +12 -0
  32. package/template/src/lib/orb-session.ts +703 -0
  33. package/template/src/lib/sign-in.ts +61 -0
  34. package/template/src/lib/site-origin.ts +35 -0
  35. package/template/src/lib/use-orb-session.ts +26 -0
  36. package/template/tsconfig.json +30 -0
@@ -0,0 +1,82 @@
1
+ import {
2
+ OrbSiteSessionError,
3
+ bindSiteSession,
4
+ isCompactJwt,
5
+ } from "@orbclub/apps-sdk";
6
+ import type { OrbBoundSiteSession } from "@orbclub/apps-sdk";
7
+
8
+ import {
9
+ BIND_COOKIE,
10
+ RENEW_COOKIE,
11
+ accountOf,
12
+ clearSessionCookies,
13
+ endAfterResponse,
14
+ jsonNoStore,
15
+ readAccessCookie,
16
+ readCookie,
17
+ readSiteSessionRequest,
18
+ setSessionCookies,
19
+ siteSessionErrorResponse,
20
+ } from "../site-session";
21
+ import { RouteError } from "../../route-security";
22
+
23
+ export const runtime = "nodejs";
24
+
25
+ /** Binds the sign-in, or null when it is access-only. */
26
+ async function bind(
27
+ bindSecret: string | null,
28
+ accessToken: string,
29
+ domain: string,
30
+ ): Promise<OrbBoundSiteSession | null> {
31
+ if (!bindSecret) return null;
32
+ let bound: OrbBoundSiteSession;
33
+ try {
34
+ // Orb verifies the access token and that it is this binding's sign-in.
35
+ bound = await bindSiteSession({ bindSecret, accessToken });
36
+ } catch (reason) {
37
+ if (reason instanceof OrbSiteSessionError) return null;
38
+ throw reason;
39
+ }
40
+ return bound.requestorDomain === domain &&
41
+ bound.accountAddress.toLowerCase() === accountOf(accessToken)
42
+ ? bound
43
+ : null;
44
+ }
45
+
46
+ /**
47
+ * After a browser sign-in: ties it to a renew handle. `renewable: false`
48
+ * means the sign-in is access-only (renewal is off for this site, or the
49
+ * viewer did not choose to stay logged in) and ends with its access token.
50
+ *
51
+ * The new sign-in replaces any earlier session in this browser: its cookies
52
+ * are replaced or cleared, and it is ended with Orb, so a reload never
53
+ * restores the earlier account.
54
+ */
55
+ export async function POST(request: Request): Promise<Response> {
56
+ try {
57
+ const { body, domain } = await readSiteSessionRequest(request, [
58
+ "accessToken",
59
+ ]);
60
+ const { accessToken } = body;
61
+ if (!isCompactJwt(accessToken)) {
62
+ throw new RouteError(400, "accessToken must be a JWT.");
63
+ }
64
+
65
+ const bound = await bind(
66
+ readCookie(request, BIND_COOKIE),
67
+ accessToken,
68
+ domain,
69
+ );
70
+ const previous = readCookie(request, RENEW_COOKIE);
71
+ if (previous && previous !== bound?.handle) {
72
+ endAfterResponse(previous, readAccessCookie(request));
73
+ }
74
+
75
+ const response = jsonNoStore({ renewable: bound !== null });
76
+ if (bound) setSessionCookies(response, { ...bound, accessToken });
77
+ else clearSessionCookies(response);
78
+ return response;
79
+ } catch (reason) {
80
+ return siteSessionErrorResponse(reason);
81
+ }
82
+ }
@@ -0,0 +1,35 @@
1
+ import { createBindSecret, renewBindingFor } from "@orbclub/apps-sdk";
2
+
3
+ import {
4
+ BIND_COOKIE,
5
+ jsonNoStore,
6
+ readCookie,
7
+ readSiteSessionRequest,
8
+ setBindCookie,
9
+ siteSessionErrorResponse,
10
+ } from "../site-session";
11
+
12
+ export const runtime = "nodejs";
13
+
14
+ const BIND_SECRET = /^[0-9a-f]{64}$/;
15
+
16
+ /**
17
+ * Before a browser sign-in: reuses or creates the bind secret cookie and
18
+ * returns only its hash, which the page sends as `renewBinding`.
19
+ */
20
+ export async function POST(request: Request): Promise<Response> {
21
+ try {
22
+ await readSiteSessionRequest(request);
23
+ const stored = readCookie(request, BIND_COOKIE);
24
+ const bindSecret =
25
+ stored && BIND_SECRET.test(stored) ? stored : createBindSecret();
26
+
27
+ const response = jsonNoStore({
28
+ renewBinding: await renewBindingFor(bindSecret),
29
+ });
30
+ setBindCookie(response, bindSecret);
31
+ return response;
32
+ } catch (reason) {
33
+ return siteSessionErrorResponse(reason);
34
+ }
35
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ RENEW_COOKIE,
3
+ clearSessionCookies,
4
+ endAfterResponse,
5
+ jsonNoStore,
6
+ readAccessCookie,
7
+ readCookie,
8
+ readSiteSessionRequest,
9
+ siteSessionErrorResponse,
10
+ } from "../site-session";
11
+
12
+ export const runtime = "nodejs";
13
+
14
+ /**
15
+ * Log Out: clears the session cookies at once, then ends the session with
16
+ * Orb after the response.
17
+ */
18
+ export async function POST(request: Request): Promise<Response> {
19
+ try {
20
+ await readSiteSessionRequest(request);
21
+ const handle = readCookie(request, RENEW_COOKIE);
22
+ if (handle) endAfterResponse(handle, readAccessCookie(request));
23
+
24
+ const response = jsonNoStore({ ended: true });
25
+ clearSessionCookies(response);
26
+ return response;
27
+ } catch (reason) {
28
+ return siteSessionErrorResponse(reason);
29
+ }
30
+ }
@@ -0,0 +1,71 @@
1
+ import {
2
+ ORB_SITE_SESSION_RENEW_BEFORE_MS,
3
+ OrbSiteSessionError,
4
+ getTokenExpiresAt,
5
+ renewSiteSession,
6
+ } from "@orbclub/apps-sdk";
7
+ import type { OrbRenewedSiteSession } from "@orbclub/apps-sdk";
8
+
9
+ import {
10
+ RENEW_COOKIE,
11
+ clearSessionCookies,
12
+ jsonNoStore,
13
+ readAccessCookie,
14
+ readCookie,
15
+ readSiteSessionRequest,
16
+ setSessionCookies,
17
+ siteSessionErrorResponse,
18
+ } from "../site-session";
19
+
20
+ export const runtime = "nodejs";
21
+
22
+ function ended(): Response {
23
+ const response = jsonNoStore({ message: "Sign in again." }, 401);
24
+ clearSessionCookies(response);
25
+ return response;
26
+ }
27
+
28
+ /**
29
+ * Returns the browser session's access token: the stored one while it has
30
+ * time left (a reload restores the session this way), otherwise a renewed
31
+ * one. 401 means the session cannot be renewed; 503 is temporary.
32
+ */
33
+ export async function POST(request: Request): Promise<Response> {
34
+ try {
35
+ const { domain } = await readSiteSessionRequest(request);
36
+ const handle = readCookie(request, RENEW_COOKIE);
37
+ if (!handle) return ended();
38
+
39
+ const stored = readAccessCookie(request);
40
+ const storedExpiresAt = stored ? getTokenExpiresAt(stored) : null;
41
+ if (
42
+ stored &&
43
+ storedExpiresAt !== null &&
44
+ storedExpiresAt - Date.now() > ORB_SITE_SESSION_RENEW_BEFORE_MS
45
+ ) {
46
+ return jsonNoStore({ accessToken: stored });
47
+ }
48
+
49
+ let renewed: OrbRenewedSiteSession;
50
+ try {
51
+ renewed = await renewSiteSession({ handle });
52
+ } catch (reason) {
53
+ if (!(reason instanceof OrbSiteSessionError)) throw reason;
54
+ if (reason.final) return ended();
55
+ return jsonNoStore(
56
+ {
57
+ message: "Session renewal is temporarily unavailable.",
58
+ retryAfterMs: reason.retryAfterMs,
59
+ },
60
+ 503,
61
+ );
62
+ }
63
+ if (renewed.requestorDomain !== domain) return ended();
64
+
65
+ const response = jsonNoStore({ accessToken: renewed.accessToken });
66
+ setSessionCookies(response, renewed);
67
+ return response;
68
+ } catch (reason) {
69
+ return siteSessionErrorResponse(reason);
70
+ }
71
+ }
@@ -0,0 +1,152 @@
1
+ import { after } from "next/server";
2
+ import {
3
+ OrbAppsSDK,
4
+ endSiteSession,
5
+ getTokenExpiresAt,
6
+ } from "@orbclub/apps-sdk";
7
+
8
+ import { getSignInSetup } from "../../../lib/sign-in";
9
+ import {
10
+ jsonNoStore,
11
+ readBoundedJsonObject,
12
+ RouteError,
13
+ } from "../route-security";
14
+
15
+ /**
16
+ * Staying signed in after browser-site Sign in with Orb. The refresh token
17
+ * stays with Orb; this server keeps three HttpOnly cookies:
18
+ *
19
+ * - the bind secret, whose hash the page sends with the sign-in;
20
+ * - the renew handle Orb returns at bind and rotates on every renewal;
21
+ * - the current access token, so a reload can restore the session without a
22
+ * renewal.
23
+ *
24
+ * The `__Host-` prefix makes browsers refuse these names unless this exact
25
+ * host set them over https with `Path=/`, so a sibling subdomain cannot plant
26
+ * its own session here.
27
+ *
28
+ * Enabled only for the browser-site flow (an https ORB_APP_ORIGIN). Orb
29
+ * switches renewal on per site; until then bind answers `renewable: false`
30
+ * and sessions end when the access token expires.
31
+ */
32
+
33
+ export const BIND_COOKIE = "__Host-orb-site-bind";
34
+ export const RENEW_COOKIE = "__Host-orb-site-renew";
35
+ export const ACCESS_COOKIE = "__Host-orb-site-access";
36
+ const BIND_COOKIE_MAX_AGE_S = 30 * 24 * 60 * 60;
37
+ const MAX_ACCESS_TOKEN_LENGTH = 16_384;
38
+
39
+ export { jsonNoStore };
40
+
41
+ /** Route errors keep their status; anything else is a generic 502. */
42
+ export function siteSessionErrorResponse(reason: unknown): Response {
43
+ return reason instanceof RouteError
44
+ ? jsonNoStore({ message: reason.message }, reason.status)
45
+ : jsonNoStore({ message: "Session renewal is unavailable." }, 502);
46
+ }
47
+
48
+ /**
49
+ * Accepts only JSON sent by this app's own page on the configured origin and
50
+ * returns the body and the site's hostname (Orb's `requestorDomain`).
51
+ */
52
+ export async function readSiteSessionRequest(
53
+ request: Request,
54
+ fields: readonly string[] = [],
55
+ ): Promise<{ body: Record<string, unknown>; domain: string }> {
56
+ const setup = getSignInSetup();
57
+ if (setup.flow !== "site") {
58
+ throw new RouteError(404, "Browser sign-in is not enabled.");
59
+ }
60
+ const origin = new URL(setup.origin);
61
+ if (
62
+ request.headers.get("host") !== origin.host ||
63
+ request.headers.get("origin") !== setup.origin ||
64
+ request.headers.get("sec-fetch-site") !== "same-origin"
65
+ ) {
66
+ throw new RouteError(403, "Request must come from this app.");
67
+ }
68
+
69
+ const body = await readBoundedJsonObject(request, 20 * 1024);
70
+ if (Object.keys(body).some((key) => !fields.includes(key))) {
71
+ throw new RouteError(400, "Request body has unexpected fields.");
72
+ }
73
+ return { body, domain: origin.hostname };
74
+ }
75
+
76
+ export function readCookie(request: Request, name: string): string | null {
77
+ for (const part of request.headers.get("cookie")?.split(";") ?? []) {
78
+ const separator = part.indexOf("=");
79
+ if (separator > 0 && part.slice(0, separator).trim() === name) {
80
+ return part.slice(separator + 1).trim() || null;
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+
86
+ /** A usable access token from the cookie, or null. */
87
+ export function readAccessCookie(request: Request): string | null {
88
+ const token = readCookie(request, ACCESS_COOKIE);
89
+ return token && token.length <= MAX_ACCESS_TOKEN_LENGTH ? token : null;
90
+ }
91
+
92
+ export function accountOf(token: string): string | undefined {
93
+ return OrbAppsSDK.getAccountAddressFromToken(token)?.toLowerCase();
94
+ }
95
+
96
+ function setCookie(
97
+ response: Response,
98
+ name: string,
99
+ value: string,
100
+ maxAgeSeconds: number,
101
+ ): void {
102
+ response.headers.append(
103
+ "set-cookie",
104
+ `${name}=${value}; Path=/; Max-Age=${Math.max(0, Math.floor(maxAgeSeconds))}; HttpOnly; Secure; SameSite=Strict`,
105
+ );
106
+ }
107
+
108
+ export function setBindCookie(response: Response, bindSecret: string): void {
109
+ setCookie(response, BIND_COOKIE, bindSecret, BIND_COOKIE_MAX_AGE_S);
110
+ }
111
+
112
+ /** Stores the renew handle and the access token it currently goes with. */
113
+ export function setSessionCookies(
114
+ response: Response,
115
+ session: { handle: string; refreshExpiresInMs: number; accessToken: string },
116
+ ): void {
117
+ setCookie(
118
+ response,
119
+ RENEW_COOKIE,
120
+ session.handle,
121
+ session.refreshExpiresInMs / 1000,
122
+ );
123
+ const expiresAt = getTokenExpiresAt(session.accessToken) ?? Date.now();
124
+ setCookie(
125
+ response,
126
+ ACCESS_COOKIE,
127
+ session.accessToken,
128
+ (expiresAt - Date.now()) / 1000,
129
+ );
130
+ }
131
+
132
+ /**
133
+ * Ends a logged-out or replaced session with Orb after the response, so the
134
+ * cookies are cleared at once even when Orb is slow (it retries for seconds).
135
+ */
136
+ export function endAfterResponse(
137
+ handle: string,
138
+ accessToken: string | null,
139
+ ): void {
140
+ after(async () => {
141
+ try {
142
+ await endSiteSession({ handle, accessToken });
143
+ } catch {
144
+ // A disconnect in Orb > Connected Apps also ends the session.
145
+ }
146
+ });
147
+ }
148
+
149
+ export function clearSessionCookies(response: Response): void {
150
+ setCookie(response, RENEW_COOKIE, "", 0);
151
+ setCookie(response, ACCESS_COOKIE, "", 0);
152
+ }
@@ -0,0 +1,196 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ :root {
6
+ --background: #141414;
7
+ --foreground: #ededed;
8
+ --panel: #1c1c1c;
9
+ --panel-border: #2c2c2c;
10
+ --muted: #9ca3af;
11
+ --accent: #4f46e5;
12
+ --accent-active: #4338ca;
13
+ --secondary-bg: #27272a;
14
+ --secondary-hover: #323238;
15
+ --error-bg: #3f0f12;
16
+ --error-border: #7f1d1d;
17
+ --error-text: #fca5a5;
18
+ --font-sans:
19
+ ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
20
+ sans-serif;
21
+ --font-mono:
22
+ ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
23
+ }
24
+
25
+ html,
26
+ body {
27
+ margin: 0;
28
+ padding: 0;
29
+ touch-action: pan-x pan-y;
30
+ background: var(--background);
31
+ color: var(--foreground);
32
+ font-family: var(--font-sans);
33
+ }
34
+
35
+ body {
36
+ min-height: 100dvh;
37
+ }
38
+
39
+ h1,
40
+ h2,
41
+ p {
42
+ margin: 0;
43
+ }
44
+
45
+ main {
46
+ min-height: 100dvh;
47
+ width: 100%;
48
+ max-width: 34rem;
49
+ margin: 0 auto;
50
+ padding-top: calc(16px + var(--orb-safe-top, env(safe-area-inset-top)));
51
+ padding-right: calc(16px + var(--orb-safe-right, env(safe-area-inset-right)));
52
+ padding-bottom: calc(
53
+ 24px + var(--orb-safe-bottom, env(safe-area-inset-bottom))
54
+ );
55
+ padding-left: calc(16px + var(--orb-safe-left, env(safe-area-inset-left)));
56
+ }
57
+
58
+ .page-title {
59
+ font-size: 1.3rem;
60
+ font-weight: 700;
61
+ letter-spacing: -0.02em;
62
+ }
63
+
64
+ .stack {
65
+ display: flex;
66
+ flex-direction: column;
67
+ gap: 0.75rem;
68
+ }
69
+
70
+ .meta {
71
+ color: var(--muted);
72
+ font-size: 0.78rem;
73
+ line-height: 1.45;
74
+ }
75
+
76
+ .card {
77
+ border: 1px solid var(--panel-border);
78
+ border-radius: 14px;
79
+ background: color-mix(in srgb, var(--panel) 94%, #000 6%);
80
+ padding: 0.9rem;
81
+ }
82
+
83
+ .card h2 {
84
+ font-size: 0.95rem;
85
+ color: #d4d4d8;
86
+ }
87
+
88
+ .row {
89
+ display: flex;
90
+ align-items: center;
91
+ justify-content: space-between;
92
+ gap: 0.75rem;
93
+ font-size: 0.85rem;
94
+ }
95
+
96
+ .row strong {
97
+ color: var(--muted);
98
+ font-weight: 600;
99
+ }
100
+
101
+ button,
102
+ .link-button {
103
+ display: inline-flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ width: 100%;
107
+ min-height: 2.5rem;
108
+ border: none;
109
+ border-radius: 10px;
110
+ padding: 0.65rem 0.9rem;
111
+ font-size: 0.85rem;
112
+ font-weight: 600;
113
+ text-decoration: none;
114
+ cursor: pointer;
115
+ }
116
+
117
+ button.primary {
118
+ color: #fff;
119
+ background: var(--accent);
120
+ }
121
+
122
+ button.primary:active {
123
+ background: var(--accent-active);
124
+ }
125
+
126
+ button.secondary,
127
+ .link-button.secondary {
128
+ color: #f4f4f5;
129
+ background: var(--secondary-bg);
130
+ }
131
+
132
+ button.secondary:hover,
133
+ .link-button.secondary:hover {
134
+ background: var(--secondary-hover);
135
+ }
136
+
137
+ button:disabled {
138
+ cursor: not-allowed;
139
+ opacity: 0.45;
140
+ }
141
+
142
+ .qr {
143
+ width: min(72vw, 224px);
144
+ height: min(72vw, 224px);
145
+ object-fit: contain;
146
+ border-radius: 10px;
147
+ border: 1px solid var(--panel-border);
148
+ background: #fff;
149
+ padding: 0.5rem;
150
+ }
151
+
152
+ .profile {
153
+ display: grid;
154
+ gap: 0.5rem;
155
+ }
156
+
157
+ .profile img {
158
+ width: 72px;
159
+ height: 72px;
160
+ border-radius: 999px;
161
+ object-fit: cover;
162
+ border: 1px solid var(--panel-border);
163
+ }
164
+
165
+ code {
166
+ max-width: 210px;
167
+ overflow-x: auto;
168
+ white-space: nowrap;
169
+ color: #c4b5fd;
170
+ background: #1a1230;
171
+ border-radius: 7px;
172
+ padding: 0.1rem 0.4rem;
173
+ font-family: var(--font-mono);
174
+ font-size: 0.75rem;
175
+ }
176
+
177
+ .error {
178
+ border: 1px solid var(--error-border);
179
+ background: var(--error-bg);
180
+ color: var(--error-text);
181
+ border-radius: 10px;
182
+ padding: 0.7rem 0.8rem;
183
+ font-size: 0.85rem;
184
+ }
185
+
186
+ @media (max-width: 640px) {
187
+ .row {
188
+ align-items: flex-start;
189
+ flex-direction: column;
190
+ gap: 0.25rem;
191
+ }
192
+
193
+ code {
194
+ max-width: 100%;
195
+ }
196
+ }
@@ -0,0 +1,115 @@
1
+ "use client";
2
+
3
+ import { useOrbSession } from "@/lib/use-orb-session";
4
+ import type { SignInSetup } from "@/lib/sign-in";
5
+
6
+ type HomeProps = {
7
+ appName: string;
8
+ signInSetup: SignInSetup;
9
+ };
10
+
11
+ export function Home({ appName, signInSetup }: HomeProps) {
12
+ const session = useOrbSession(signInSetup);
13
+ const insideOrb = Boolean(session.context);
14
+
15
+ return (
16
+ <main className="stack">
17
+ <header className="stack">
18
+ <h1 className="page-title">{appName}</h1>
19
+ {session.started && (
20
+ <p className="meta">
21
+ {insideOrb ? "Running inside Orb" : "Running in a browser"}
22
+ </p>
23
+ )}
24
+ </header>
25
+
26
+ <section className="card stack">{renderSession()}</section>
27
+
28
+ {session.error && (
29
+ <p className="error" role="alert">
30
+ {session.error}
31
+ </p>
32
+ )}
33
+ </main>
34
+ );
35
+
36
+ function renderSession() {
37
+ if (!session.started || session.status === "restoring") {
38
+ return <p className="meta">Checking your Orb session...</p>;
39
+ }
40
+
41
+ if (session.status === "signed-in") {
42
+ const metadata = session.user?.metadata;
43
+ return (
44
+ <>
45
+ {session.loadingUser && <p className="meta">Loading profile...</p>}
46
+ {metadata && (
47
+ <div className="profile">
48
+ {metadata.rawPicture && (
49
+ // eslint-disable-next-line @next/next/no-img-element
50
+ <img src={metadata.rawPicture} alt="" />
51
+ )}
52
+ <div className="row">
53
+ <strong>Name</strong>
54
+ <span>{metadata.name ?? "Not set"}</span>
55
+ </div>
56
+ <div className="row">
57
+ <strong>Handle</strong>
58
+ <span>{metadata.handle ?? "Not set"}</span>
59
+ </div>
60
+ <div className="row">
61
+ <strong>Address</strong>
62
+ <code>{metadata.address ?? "Unknown"}</code>
63
+ </div>
64
+ </div>
65
+ )}
66
+ <button className="secondary" onClick={() => void session.signOut()}>
67
+ Sign out
68
+ </button>
69
+ </>
70
+ );
71
+ }
72
+
73
+ if (session.status === "connecting") {
74
+ const { qr } = session;
75
+ return (
76
+ <>
77
+ {qr?.image && (
78
+ // eslint-disable-next-line @next/next/no-img-element
79
+ <img src={qr.image} alt="Sign-in QR code" className="qr" />
80
+ )}
81
+ <p className="meta">
82
+ {qr?.message ?? "Approve the sign-in in the Orb app."}
83
+ </p>
84
+ {qr?.showAppLink && qr.deepLink && (
85
+ <a className="link-button secondary" href={qr.deepLink}>
86
+ Open in Orb App
87
+ </a>
88
+ )}
89
+ {qr && (
90
+ <button className="secondary" onClick={session.cancel}>
91
+ Cancel
92
+ </button>
93
+ )}
94
+ </>
95
+ );
96
+ }
97
+
98
+ if (!insideOrb && session.browserSignIn.flow === "none") {
99
+ return <p className="meta">{session.browserSignIn.message}</p>;
100
+ }
101
+
102
+ return (
103
+ <>
104
+ <p className="meta">
105
+ {insideOrb
106
+ ? "Sign in with your Orb profile."
107
+ : "Scan a QR code with the Orb app to sign in."}
108
+ </p>
109
+ <button className="primary" onClick={() => void session.signIn()}>
110
+ Sign in with Orb
111
+ </button>
112
+ </>
113
+ );
114
+ }
115
+ }
@@ -0,0 +1,24 @@
1
+ import type { Metadata, Viewport } from "next";
2
+ import "./globals.css";
3
+
4
+ export const metadata: Metadata = {
5
+ title: __DISPLAY_NAME_JSON__,
6
+ description: "An Orb app",
7
+ };
8
+
9
+ export const viewport: Viewport = {
10
+ width: "device-width",
11
+ initialScale: 1,
12
+ maximumScale: 1,
13
+ userScalable: false,
14
+ };
15
+
16
+ export default function RootLayout({
17
+ children,
18
+ }: Readonly<{ children: React.ReactNode }>) {
19
+ return (
20
+ <html lang="en">
21
+ <body>{children}</body>
22
+ </html>
23
+ );
24
+ }