@ebay-dt/bonfire-next 0.1.0-alpha.1 → 0.1.0-alpha.2
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.
- package/README.md +33 -15
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/lifecycle-provider.d.ts.map +1 -1
- package/dist/client/lifecycle-provider.js.map +1 -1
- package/dist/server/agent-actions.d.ts.map +1 -1
- package/dist/server/agent-actions.js.map +1 -1
- package/dist/server/auth-boundary.d.ts.map +1 -1
- package/dist/server/auth-boundary.js.map +1 -1
- package/dist/server/auth-routes.d.ts.map +1 -1
- package/dist/server/auth-routes.js.map +1 -1
- package/dist/server/create-bonfire-next.d.ts.map +1 -1
- package/dist/server/create-bonfire-next.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/login-page-model.d.ts.map +1 -1
- package/dist/server/login-page-model.js.map +1 -1
- package/dist/server/prototype-actions.d.ts.map +1 -1
- package/dist/server/prototype-actions.js.map +1 -1
- package/dist/server/prototype-dashboard.d.ts.map +1 -1
- package/dist/server/prototype-dashboard.js.map +1 -1
- package/dist/server/prototype-environment.d.ts.map +1 -1
- package/dist/server/prototype-environment.js.map +1 -1
- package/dist/server/prototype-routes.d.ts.map +1 -1
- package/dist/server/prototype-routes.js.map +1 -1
- package/dist/server/session.d.ts.map +1 -1
- package/dist/server/session.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -85,7 +85,9 @@ const config = {
|
|
|
85
85
|
Prototype metadata can provide a validated `theme` policy. If it is omitted,
|
|
86
86
|
Bonfire applies the instance defaults and registered capabilities. The server
|
|
87
87
|
integration passes the normalized policy and registry to the host; it does not
|
|
88
|
-
scan metadata or construct a theme map in the application.
|
|
88
|
+
scan metadata or construct a theme map in the application. The preferred host
|
|
89
|
+
composition passes `prototype.themeRegistry` directly to
|
|
90
|
+
`PrototypeEnvironment` alongside `prototype.theme`.
|
|
89
91
|
|
|
90
92
|
The host owns theme CSS. Use the provider's `data-theme` and
|
|
91
93
|
`data-color-scheme` attributes in an instance stylesheet. Keep a `system`
|
|
@@ -96,11 +98,19 @@ or Dark value separately through React.
|
|
|
96
98
|
The deployment endpoint is complete, has no embedded default, and must remain in
|
|
97
99
|
server-only configuration. When configured, the provider sends only
|
|
98
100
|
`{ applicationId, login }`; it does not send owner or branch values. The
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
`applicationId` (normally `config.appId`) must exactly match the application's
|
|
102
|
+
DT deployment-service registration. The service resolves the repository,
|
|
103
|
+
project, deployment target, and credentials from the application ID and login.
|
|
104
|
+
HTTP 201 confirms deployment creation, while `readyState` reports the
|
|
105
|
+
provider's current state; Bonfire preserves the `deploymentId` but does not
|
|
106
|
+
poll it. `deploymentAvailable` exposes configured development capability to the
|
|
107
|
+
lifecycle provider, not authorization.
|
|
108
|
+
|
|
109
|
+
A registration mismatch is intentionally surfaced as a safe deployment failure;
|
|
110
|
+
Bonfire does not send the provider's response details to the browser. Diagnose
|
|
111
|
+
it server-side by comparing the configured application ID with the registered
|
|
112
|
+
value. Any host-facing message should remain generic, such as “Deployment is
|
|
113
|
+
not configured for this application.”
|
|
104
114
|
|
|
105
115
|
Run `bonfire prepare` before development so the secret exists in
|
|
106
116
|
`.env.local`. An externally supplied `BF_SESSION_SECRET` takes precedence.
|
|
@@ -123,24 +133,31 @@ Next.js cannot install filesystem routes for a package, so each application
|
|
|
123
133
|
adds these small bindings. Keep authentication logic in the package.
|
|
124
134
|
|
|
125
135
|
`src/app/layout.tsx` should own the document and long-lived providers, but not
|
|
126
|
-
route-specific application chrome
|
|
136
|
+
route-specific application chrome. Apply `htmlProps` to the root `<html>`
|
|
137
|
+
element:
|
|
127
138
|
|
|
128
139
|
```tsx
|
|
129
140
|
import "@ebay-dt/bonfire-react/styles/defaults.css";
|
|
141
|
+
import { bonfire } from "@/bonfire";
|
|
142
|
+
|
|
143
|
+
export default async function RootLayout({ children }: LayoutProps<"/">) {
|
|
144
|
+
const { htmlProps } = await bonfire.auth.getAppLayoutModel();
|
|
130
145
|
|
|
131
|
-
export default function RootLayout({ children }: LayoutProps<"/">) {
|
|
132
146
|
return (
|
|
133
|
-
<html lang="en">
|
|
147
|
+
<html lang="en" {...htmlProps}>
|
|
134
148
|
<body>{children}</body>
|
|
135
149
|
</html>
|
|
136
150
|
);
|
|
137
151
|
}
|
|
138
152
|
```
|
|
139
153
|
|
|
140
|
-
`getAppLayoutModel()` returns opaque document props and
|
|
141
|
-
props.
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
`getAppLayoutModel()` returns a paired set of opaque document props and
|
|
155
|
+
serializable header props. Spread `htmlProps` on `<html>` and `headerProps` on
|
|
156
|
+
`<AppHeader>`; do not omit the document props when rendering the header. Both
|
|
157
|
+
values come from the same `getAppLayoutModel()` result. Render `AppHeader` in
|
|
158
|
+
the route layout that owns it. Keep the dashboard header in a system layout and
|
|
159
|
+
the prototype header inside the prototype environment, so the header can
|
|
160
|
+
consume the environment context:
|
|
144
161
|
|
|
145
162
|
```tsx
|
|
146
163
|
// src/app/(system)/layout.tsx
|
|
@@ -210,8 +227,9 @@ within one prototype to preserve state while navigation to another remounts it.
|
|
|
210
227
|
The lifecycle-aware dashboard uses the framework-neutral controller and React
|
|
211
228
|
components from `@ebay-dt/bonfire-react/lifecycle`. The Next-specific provider
|
|
212
229
|
supplies router integration, dirty-state observation, and Server Action
|
|
213
|
-
bindings, while `LifecycleProvider` owns the React controller lifecycle.
|
|
214
|
-
|
|
230
|
+
bindings, while `LifecycleProvider` owns the React controller lifecycle. The
|
|
231
|
+
dirty endpoint is a long-lived SSE route and must run on the Node runtime. Bind
|
|
232
|
+
it directly; do not wrap it in another handler:
|
|
215
233
|
|
|
216
234
|
```ts
|
|
217
235
|
// src/app/api/prototype-dirty/route.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n type NextLifecycleProviderProps,\n} from \"./lifecycle-provider.js\";\n"]}
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n type NextLifecycleProviderProps,\n} from \"./lifecycle-provider.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,uBAAuB,EAG7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAY5B"}
|
|
1
|
+
{"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,uBAAuB,EAG7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAY5B","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-provider.js","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,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ecycleController,\n LifecycleProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC1C,CAAC;AAkCF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CA8CvB"}
|
|
1
|
+
{"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC1C,CAAC;AAkCF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CA8CvB","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult;\n}\n\nfunction unauthenticated() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult;\n}\n\nfunction invalidInput() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n return { openInCursor, openInClaudeCode };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-actions.js","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,0BAA0B,GAK3B,MAAM,uBAAuB,CAAC;AAc/B,SAAS,SAAS;IAChB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;KACD,CAAC;AAChC,CAAC;AAED,SAAS,eAAe;IACtB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KACP,CAAC;AAChC,CAAC;AAED,SAAS,YAAY;IACnB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,E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AK,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,eAAe;gBAAE,OAAO,YAAY,EAAE,CAAC;YAC5D,oBAAoB,CAAC,aAAa,CAAC,CAAC;YACpC,OAAO,iBAAiB,EAAE,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YAChD,IAAI,QAAQ,KAAK,IAAI;gBAAE,OAAO,eAAe,EAAE,CAAC;YAChD,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB,CAAC,aAAa,CAAC,CAAC;YACpC,OAAO,iBAAiB,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult;\n}\n\nfunction unauthenticated() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult;\n}\n\nfunction invalidInput() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n return { openInCursor, openInClaudeCode };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-boundary.d.ts","sourceRoot":"","sources":["../../src/server/auth-boundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAUF,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,aAGd,WAAW,oCAqBrD"}
|
|
1
|
+
{"version":3,"file":"auth-boundary.d.ts","sourceRoot":"","sources":["../../src/server/auth-boundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAUF,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,aAGd,WAAW,oCAqBrD","sourcesContent":["import { getSessionCookieName } from \"@ebay-dt/bonfire-core\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\nimport { verifySession } from \"./session.js\";\n\nexport type AuthProxyOptions = {\n appId: string;\n sessionSecret: string | undefined;\n production: boolean;\n};\n\nfunction isAuthPath(pathname: string): boolean {\n return (\n pathname === \"/login\" ||\n pathname === \"/auth\" ||\n pathname.startsWith(\"/auth/\")\n );\n}\n\nexport const BONFIRE_PATHNAME_HEADER = \"x-bonfire-pathname\";\n\nexport function createAuthProxy(options: AuthProxyOptions) {\n const cookieName = getSessionCookieName(options.appId);\n\n return async function authProxy(request: NextRequest) {\n // Forwarded so the shared prototype route-group layout can resolve the\n // active prototype's theme policy server-side without duplicating catalog\n // lookup in the host.\n const forwardedHeaders = new Headers(request.headers);\n forwardedHeaders.set(BONFIRE_PATHNAME_HEADER, request.nextUrl.pathname);\n const next = () =>\n NextResponse.next({ request: { headers: forwardedHeaders } });\n\n if (options.production) return next();\n if (isAuthPath(request.nextUrl.pathname)) return next();\n\n const token = request.cookies.get(cookieName)?.value;\n const identity =\n token && options.sessionSecret\n ? await verifySession(token, options.sessionSecret)\n : null;\n if (identity) return next();\n\n return NextResponse.redirect(new URL(\"/login\", request.url));\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-boundary.js","sourceRoot":"","sources":["../../src/server/auth-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,CACL,QAAQ,KAAK,QAAQ;QACrB,QAAQ,KAAK,OAAO;QACpB,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAE5D,MAAM,UAAU,eAAe,CAAC,OAAyB;IACvD,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEvD,OAAO,KAAK,UAAU,SAAS,CAAC,OAAoB;QAClD,uEAAuE;QACvE,0EAA0E;QAC1E,sBAAsB;QACtB,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtD,gBAAgB,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAEhE,IAAI,OAAO,CAAC,UAAU;YAAE,OAAO,IAAI,EAAE,CAAC;QACtC,IAAI,UAAU,CA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C;QACtD,gBAAgB,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAEhE,IAAI,OAAO,CAAC,UAAU;YAAE,OAAO,IAAI,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QAExD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;QACrD,MAAM,QAAQ,GACZ,KAAK,IAAI,OAAO,CAAC,aAAa;YAC5B,CAAC,CAAC,MAAM,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC;YACnD,CAAC,CAAC,IAAI,CAAC;QACX,IAAI,QAAQ;YAAE,OAAO,IAAI,EAAE,CAAC;QAE5B,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { getSessionCookieName } from \"@ebay-dt/bonfire-core\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\nimport { verifySession } from \"./session.js\";\n\nexport type AuthProxyOptions = {\n appId: string;\n sessionSecret: string | undefined;\n production: boolean;\n};\n\nfunction isAuthPath(pathname: string): boolean {\n return (\n pathname === \"/login\" ||\n pathname === \"/auth\" ||\n pathname.startsWith(\"/auth/\")\n );\n}\n\nexport const BONFIRE_PATHNAME_HEADER = \"x-bonfire-pathname\";\n\nexport function createAuthProxy(options: AuthProxyOptions) {\n const cookieName = getSessionCookieName(options.appId);\n\n return async function authProxy(request: NextRequest) {\n // Forwarded so the shared prototype route-group layout can resolve the\n // active prototype's theme policy server-side without duplicating catalog\n // lookup in the host.\n const forwardedHeaders = new Headers(request.headers);\n forwardedHeaders.set(BONFIRE_PATHNAME_HEADER, request.nextUrl.pathname);\n const next = () =>\n NextResponse.next({ request: { headers: forwardedHeaders } });\n\n if (options.production) return next();\n if (isAuthPath(request.nextUrl.pathname)) return next();\n\n const token = request.cookies.get(cookieName)?.value;\n const identity =\n token && options.sessionSecret\n ? await verifySession(token, options.sessionSecret)\n : null;\n if (identity) return next();\n\n return NextResponse.redirect(new URL(\"/login\", request.url));\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvD,CAAC;AAqCF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAqEV,WAAW;EAM3C"}
|
|
1
|
+
{"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvD,CAAC;AAqCF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAqEV,WAAW;EAM3C","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-routes.js","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAa9C,SAAS,QAAQ;IACf,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,OAAoB,EAAE,IAAY,EAAE,MAAM,GAAG,GAAG;IAChE,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,CAAC,KAAK,CAAC,oCAAoC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,2BAA2B;IAClC,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACtD,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,OAAyB,EACzB,QAAyB;IAEzB,IAAI,CAAC;QACH,OAAO,CACL,CAAC,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC3C,gBAAgB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAmC,CAAC,CAC1E,CAA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E,CAAC;oBACpB,2BAA2B,EAAE,CAAC;oBAC9B,OAAO,YAAY,CAAC,IAAI,CAAC;wBACvB,aAAa,EAAE,KAAK;wBACpB,KAAK,EAAE,uBAAgC;qBACxC,CAAC,CAAC;gBACL,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oBAClC,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBACpD,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;QACT,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,UAAU,MAAM,CAAC,OAAoB;QACxC,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-bonfire-next.d.ts","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,kBAAkB,CAA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AC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE;QACT,KAAK,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACX,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;KAC9B,CAAC;CACH,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;iCAoHvB,OAAO,CAAC,cAAc,CAAC;2CAgBhD,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA8ChE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n lifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n type BranchPreparationValue,\n type BonfireConfigInput,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\n\nexport type CreateBonfireNextOptions = {\n config: BonfireConfigInput;\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig(options.config);\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prepareIdentity = production\n ? undefined\n : automaticBranchSwitch === \"enabled\" && lifecycle\n ? lifecycle.prepareBranch.bind(lifecycle)\n : async () =>\n lifecycleSuccess({\n status: \"disabled\",\n } satisfies BranchPreparationValue);\n const prototypeActions = createPrototypeActions({\n production,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n prepareIdentity,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n agents: prototypeAgentActions,\n routes: prototypeRoutes,\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-bonfire-next.js","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iCAAiC,GAIlC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,GAO7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAmC9D,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AACjE,M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;YAC9D,YAAY,EAAE;gBACZ,UAAU,EAAE,mBAAmB;aACA;YACjC,SAAS;YACT,OAAO,EAAE,gBAAgB;YACzB,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,eAAe;SACxB;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"create-bonfire-next.js","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iCAAiC,GAIlC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,GAO7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAmC9D,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AACjE,MAAM,6BAA6B,GAAG,QAAQ,CAAC;AAE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AE,mBAAmB;aACA;YACjC,SAAS;YACT,OAAO,EAAE,gBAAgB;YACzB,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,eAAe;SACxB;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n lifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n type BranchPreparationValue,\n type BonfireConfigInput,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\n\nexport type CreateBonfireNextOptions = {\n config: BonfireConfigInput;\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig(options.config);\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prepareIdentity = production\n ? undefined\n : automaticBranchSwitch === \"enabled\" && lifecycle\n ? lifecycle.prepareBranch.bind(lifecycle)\n : async () =>\n lifecycleSuccess({\n status: \"disabled\",\n } satisfies BranchPreparationValue);\n const prototypeActions = createPrototypeActions({\n production,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n prepareIdentity,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n agents: prototypeAgentActions,\n routes: prototypeRoutes,\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export {\n createBonfireNext,\n type CreateBonfireNextOptions,\n type PrototypeCapabilities,\n} from \"./create-bonfire-next.js\";\nexport {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"@ebay-dt/bonfire-node\";\nexport type { PrototypeActions } from \"./prototype-actions.js\";\nexport type { PrototypeAgentActions } from \"./agent-actions.js\";\nexport type { PrototypeRoutes } from \"./prototype-routes.js\";\nexport type { PrototypeRouteModel } from \"./prototype-environment.js\";\n"]}
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAKxB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAKxB,MAAM,uBAAuB,CAAC","sourcesContent":["export {\n createBonfireNext,\n type CreateBonfireNextOptions,\n type PrototypeCapabilities,\n} from \"./create-bonfire-next.js\";\nexport {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"@ebay-dt/bonfire-node\";\nexport type { PrototypeActions } from \"./prototype-actions.js\";\nexport type { PrototypeAgentActions } from \"./agent-actions.js\";\nexport type { PrototypeRoutes } from \"./prototype-routes.js\";\nexport type { PrototypeRouteModel } from \"./prototype-environment.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-page-model.d.ts","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAQ9E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,YAAY,CAAC,EAAE,iBAAiB;;;;;;;;;;;EAuBjC;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,8BAG9D"}
|
|
1
|
+
{"version":3,"file":"login-page-model.d.ts","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAQ9E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,YAAY,CAAC,EAAE,iBAAiB;;;;;;;;;;;EAuBjC;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,8BAG9D","sourcesContent":["import type {\n GitHubCliLoginPageModel,\n BonfireConfig,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type LoginSearchParams = Record<string, string | string[] | undefined>;\n\nconst DEVICE_CODE_PATTERN = /^[A-Za-z0-9-]{1,64}$/;\n\nfunction singleValue(value: string | string[] | undefined) {\n return typeof value === \"string\" ? value : null;\n}\n\nexport function createLoginPageModel(\n config: BonfireConfig,\n searchParams?: LoginSearchParams,\n) {\n const auth = singleValue(searchParams?.auth);\n const error = singleValue(searchParams?.error);\n const code = singleValue(searchParams?.code);\n const pollingActive = auth === \"started\";\n\n return {\n applicationName: config.name,\n githubHostname: config.auth.github.hostname,\n loginUrl: \"/auth/login\",\n statusUrl: \"/auth/status\",\n returnUrl: \"/\",\n deviceUrl: `https://${config.auth.github.hostname}/login/device`,\n fallbackCommand: `gh auth login --hostname ${config.auth.github.hostname}`,\n deviceCode:\n pollingActive && code && DEVICE_CODE_PATTERN.test(code) ? code : null,\n pollingActive,\n error:\n error === \"gh_cli_failed\" || error === \"branch_prepare_failed\"\n ? error\n : null,\n } satisfies GitHubCliLoginPageModel;\n}\n\nexport async function getLoginPageSearchParams(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n) {\n return (await searchParams) ?? {};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-page-model.js","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEnD,SAAS,WAAW,C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el,\n BonfireConfig,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type LoginSearchParams = Record<string, string | string[] | undefined>;\n\nconst DEVICE_CODE_PATTERN = /^[A-Za-z0-9-]{1,64}$/;\n\nfunction singleValue(value: string | string[] | undefined) {\n return typeof value === \"string\" ? value : null;\n}\n\nexport function createLoginPageModel(\n config: BonfireConfig,\n searchParams?: LoginSearchParams,\n) {\n const auth = singleValue(searchParams?.auth);\n const error = singleValue(searchParams?.error);\n const code = singleValue(searchParams?.code);\n const pollingActive = auth === \"started\";\n\n return {\n applicationName: config.name,\n githubHostname: config.auth.github.hostname,\n loginUrl: \"/auth/login\",\n statusUrl: \"/auth/status\",\n returnUrl: \"/\",\n deviceUrl: `https://${config.auth.github.hostname}/login/device`,\n fallbackCommand: `gh auth login --hostname ${config.auth.github.hostname}`,\n deviceCode:\n pollingActive && code && DEVICE_CODE_PATTERN.test(code) ? code : null,\n pollingActive,\n error:\n error === \"gh_cli_failed\" || error === \"branch_prepare_failed\"\n ? error\n : null,\n } satisfies GitHubCliLoginPageModel;\n}\n\nexport async function getLoginPageSearchParams(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n) {\n return (await searchParams) ?? {};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-actions.d.ts","sourceRoot":"","sources":["../../src/server/prototype-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,u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O,EAAE,uBAAuB,GAC/B,gBAAgB,CAwLlB","sourcesContent":["import {\n lifecycleFailure,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n LifecycleInputError,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleResult,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeActions = {\n create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>>;\n duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>>;\n edit(input: EditPrototypeInput): Promise<LifecycleResult<EditPrototypeValue>>;\n delete(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>>;\n save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>>;\n discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>>;\n deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>>;\n};\n\nexport type PrototypeActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction logUnexpectedFailure(\n operation:\n \"create\" | \"duplicate\" | \"edit\" | \"delete\" | \"save\" | \"discard\" | \"deploy\",\n) {\n console.error(`Bonfire prototype ${operation} failed unexpectedly.`);\n}\n\nexport function createPrototypeActions(\n options: PrototypeActionsOptions,\n): PrototypeActions {\n async function create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.create(\n identity,\n parseCreatePrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"create\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.duplicate(\n identity,\n parseDuplicatePrototypeInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"duplicate\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function edit(\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.edit(\n identity,\n parseEditPrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"edit\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deletePrototype(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.delete(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"delete\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.save(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"save\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.discard(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"discard\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n if (options.production) return lifecycleFailure(\"forbidden\");\n\n let parsedInput: PrototypeCommandInput;\n try {\n parsedInput = parsePrototypeCommandInput(input);\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n if (options.lifecycle === null) {\n return lifecycleFailure(\"deployment-unavailable\");\n }\n\n let identity: BonfireIdentity | null;\n try {\n identity = await options.getCurrentUser();\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n\n try {\n return await options.lifecycle.deploy(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n }\n\n return {\n create,\n duplicate,\n edit,\n delete: deletePrototype,\n save,\n discard,\n deploy,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-actions.js","sourceRoot":"","sources":["../../src/server/prototype-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,GAepB,MAAM,uBAAuB,CAAC;AAgC/B,SAAS,oBAAoB,CAC3B,SAC4E;IAE5E,OAAO,CAAC,KAAK,CAAC,qBAAqB,SAAS,uBAAuB,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAgC;IAEhC,KAAK,UAAU,MAAM,CACnB,KAA2B;QAE3B,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YACrD,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YAChD,IAAI,QAAQ,KAAK,IAAI;gBAAE,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;YAClE,OAAO,MAAM,OAAO,CAAC,SAAS,CAAC,MAAM,CACnC,QAAQ,EACR,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CACxD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;gBACzC,OAAO,gBAAgB,CAAC,eAAe,CAAC,CAAC;YAC3C,CAAC;YACD,oBAAoB,CAA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CAAC;QACpD,CAAC;QAED,IAAI,QAAgC,CAAC;QACrC,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QAElE,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,SAAS;QACT,IAAI;QACJ,MAAM,EAAE,eAAe;QACvB,IAAI;QACJ,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n lifecycleFailure,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n LifecycleInputError,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleResult,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeActions = {\n create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>>;\n duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>>;\n edit(input: EditPrototypeInput): Promise<LifecycleResult<EditPrototypeValue>>;\n delete(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>>;\n save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>>;\n discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>>;\n deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>>;\n};\n\nexport type PrototypeActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction logUnexpectedFailure(\n operation:\n \"create\" | \"duplicate\" | \"edit\" | \"delete\" | \"save\" | \"discard\" | \"deploy\",\n) {\n console.error(`Bonfire prototype ${operation} failed unexpectedly.`);\n}\n\nexport function createPrototypeActions(\n options: PrototypeActionsOptions,\n): PrototypeActions {\n async function create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.create(\n identity,\n parseCreatePrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"create\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.duplicate(\n identity,\n parseDuplicatePrototypeInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"duplicate\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function edit(\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.edit(\n identity,\n parseEditPrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"edit\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deletePrototype(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.delete(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"delete\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.save(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"save\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.discard(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"discard\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n if (options.production) return lifecycleFailure(\"forbidden\");\n\n let parsedInput: PrototypeCommandInput;\n try {\n parsedInput = parsePrototypeCommandInput(input);\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n if (options.lifecycle === null) {\n return lifecycleFailure(\"deployment-unavailable\");\n }\n\n let identity: BonfireIdentity | null;\n try {\n identity = await options.getCurrentUser();\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n\n try {\n return await options.lifecycle.deploy(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n }\n\n return {\n create,\n duplicate,\n edit,\n delete: deletePrototype,\n save,\n discard,\n deploy,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-dashboard.d.ts","sourceRoot":"","sources":["../../src/server/prototype-dashboard.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,MAAM,8BAA8B,GAAG,MAAM,CACjD,MAAM,EACN,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS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sourcesContent":["import { connection } from \"next/server.js\";\nimport {\n definePrototypeRef,\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeDashboardSearchParams = Record<\n string,\n string | string[] | undefined\n>;\n\ntype DashboardSearchParamsInput =\n | PrototypeDashboardSearchParams\n | Promise<PrototypeDashboardSearchParams>\n | undefined;\n\ntype PrototypeDashboardLoaderOptions = {\n applicationName: string;\n production: boolean;\n catalog: PrototypeCatalogLike;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n themeRegistry?: ThemeRegistry;\n};\n\nconst MAX_QUERY_VALUE_LENGTH = 128;\nconst VALID_SORTS = new Set<PrototypeCatalogQuery[\"sort\"]>([\n \"recent\",\n \"alphabetical\",\n \"deployed\",\n]);\n\nfunction singleQueryValue(value: unknown) {\n if (typeof value !== \"string\") return null;\n if (value.length > MAX_QUERY_VALUE_LENGTH) return null;\n return value;\n}\n\nfunction normalizeSort(value: unknown): PrototypeCatalogQuery[\"sort\"] {\n const scalar = singleQueryValue(value);\n return scalar !== null &&\n VALID_SORTS.has(scalar as PrototypeCatalogQuery[\"sort\"])\n ? (scalar as PrototypeCatalogQuery[\"sort\"])\n : \"recent\";\n}\n\nfunction normalizeAuthor(\n value: unknown,\n currentLogin: string | null,\n): PrototypeCatalogQuery[\"author\"] {\n const scalar = singleQueryValue(value);\n if (scalar === \"all\") return \"all\";\n if (scalar === \"mine\") return currentLogin === null ? \"all\" : \"mine\";\n if (scalar === null) return \"all\";\n\n try {\n return definePrototypeRef({ login: scalar, slug: \"prototype\" }).login;\n } catch {\n return \"all\";\n }\n}\n\nasync function normalizeSearchParams(\n searchParams: DashboardSearchParamsInput,\n currentLogin: string | null,\n): Promise<PrototypeCatalogQuery> {\n const params = (await searchParams) ?? {};\n return {\n author: normalizeAuthor(params.author, currentLogin),\n sort: normalizeSort(params.sort),\n };\n}\n\nexport function createPrototypeDashboardModelLoader(\n options: PrototypeDashboardLoaderOptions,\n) {\n return async function getDashboardModel(\n searchParams?: DashboardSearchParamsInput,\n ): Promise<PrototypeDashboardModel> {\n await connection();\n\n const [summaries, currentUser] = await Promise.all([\n options.catalog.scan(),\n options.production ? Promise.resolve(null) : options.getCurrentUser(),\n ]);\n const currentLogin = currentUser?.login ?? null;\n const query = await normalizeSearchParams(searchParams, currentLogin);\n const filtered = filterPrototypes(summaries, query.author, currentLogin);\n const visibleSummaries = sortPrototypes(filtered, query.sort);\n\n return {\n applicationName: options.applicationName,\n query,\n authorOptions: getPrototypeAuthorOptions(summaries, currentLogin),\n showMine: currentUser !== null,\n summaries: visibleSummaries,\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-dashboard.js","sourceRoot":"","sources":["../../src/server/prototype-dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,GAKf,MAAM,uBAAuB,CAAC;AAqB/B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAgC;IACzD,QAAQ;IACR,cAAc;IACd,UAAU;CACX,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,KAAK,CAAC,MAAM,GAAG,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,MAAM,MAAM,GAAG,gBAAgB,CAAC,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,EAAE,CAAC;QAEnB,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;YACtB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE;SACtE,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,WAAW,EAAE,KAAK,IAAI,IAAI,CAAC;QAChD,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACzE,MAAM,gBAAgB,GAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAE9D,OAAO;YACL,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,KAAK;YACL,aAAa,EAAE,yBAAyB,CAAC,SAAS,EAAE,YAAY,CAAC;YACjE,QAAQ,EAAE,WAAW,KAAK,IAAI;YAC9B,SAAS,EAAE,gBAAgB;YAC3B,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS;gBACrC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;SAC9C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { connection } from \"next/server.js\";\nimport {\n definePrototypeRef,\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeDashboardSearchParams = Record<\n string,\n string | string[] | undefined\n>;\n\ntype DashboardSearchParamsInput =\n | PrototypeDashboardSearchParams\n | Promise<PrototypeDashboardSearchParams>\n | undefined;\n\ntype PrototypeDashboardLoaderOptions = {\n applicationName: string;\n production: boolean;\n catalog: PrototypeCatalogLike;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n themeRegistry?: ThemeRegistry;\n};\n\nconst MAX_QUERY_VALUE_LENGTH = 128;\nconst VALID_SORTS = new Set<PrototypeCatalogQuery[\"sort\"]>([\n \"recent\",\n \"alphabetical\",\n \"deployed\",\n]);\n\nfunction singleQueryValue(value: unknown) {\n if (typeof value !== \"string\") return null;\n if (value.length > MAX_QUERY_VALUE_LENGTH) return null;\n return value;\n}\n\nfunction normalizeSort(value: unknown): PrototypeCatalogQuery[\"sort\"] {\n const scalar = singleQueryValue(value);\n return scalar !== null &&\n VALID_SORTS.has(scalar as PrototypeCatalogQuery[\"sort\"])\n ? (scalar as PrototypeCatalogQuery[\"sort\"])\n : \"recent\";\n}\n\nfunction normalizeAuthor(\n value: unknown,\n currentLogin: string | null,\n): PrototypeCatalogQuery[\"author\"] {\n const scalar = singleQueryValue(value);\n if (scalar === \"all\") return \"all\";\n if (scalar === \"mine\") return currentLogin === null ? \"all\" : \"mine\";\n if (scalar === null) return \"all\";\n\n try {\n return definePrototypeRef({ login: scalar, slug: \"prototype\" }).login;\n } catch {\n return \"all\";\n }\n}\n\nasync function normalizeSearchParams(\n searchParams: DashboardSearchParamsInput,\n currentLogin: string | null,\n): Promise<PrototypeCatalogQuery> {\n const params = (await searchParams) ?? {};\n return {\n author: normalizeAuthor(params.author, currentLogin),\n sort: normalizeSort(params.sort),\n };\n}\n\nexport function createPrototypeDashboardModelLoader(\n options: PrototypeDashboardLoaderOptions,\n) {\n return async function getDashboardModel(\n searchParams?: DashboardSearchParamsInput,\n ): Promise<PrototypeDashboardModel> {\n await connection();\n\n const [summaries, currentUser] = await Promise.all([\n options.catalog.scan(),\n options.production ? Promise.resolve(null) : options.getCurrentUser(),\n ]);\n const currentLogin = currentUser?.login ?? null;\n const query = await normalizeSearchParams(searchParams, currentLogin);\n const filtered = filterPrototypes(summaries, query.author, currentLogin);\n const visibleSummaries = sortPrototypes(filtered, query.sort);\n\n return {\n applicationName: options.applicationName,\n query,\n authorOptions: getPrototypeAuthorOptions(summaries, currentLogin),\n showMine: currentUser !== null,\n summaries: visibleSummaries,\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-environment.d.ts","sourceRoot":"","sources":["../../src/server/prototype-environment.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,KAAK,sCAAsC,GAAG;IAC5C,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAeF,iBAAS,qCAAqC,CAC5C,OAAO,EAAE,sCAAsC;2BAGtC,YAAY,KAClB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;gCAyCC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;EAU3E;AAED,OAAO,EAAE,qCAAqC,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"prototype-environment.d.ts","sourceRoot":"","sources":["../../src/server/prototype-environment.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,KAAK,sCAAsC,GAAG;IAC5C,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAeF,iBAAS,qCAAqC,CAC5C,OAAO,EAAE,sCAAsC;2BAGtC,YAAY,KAClB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;gCAyCC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;EAU3E;AAED,OAAO,EAAE,qCAAqC,EAAE,CAAC","sourcesContent":["import { headers } from \"next/headers.js\";\nimport {\n createDefaultPrototypeTheme,\n definePrototypeRef,\n parsePrototypeTheme,\n parsePrototypePath,\n type PrototypeRef,\n type PrototypeTheme,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\nimport { BONFIRE_PATHNAME_HEADER } from \"./auth-boundary.js\";\n\nexport type PrototypeRouteModel = {\n ref: PrototypeRef;\n url: string;\n theme?: PrototypeTheme;\n themeRegistry?: ThemeRegistry;\n};\n\ntype PrototypeEnvironmentModelLoaderOptions = {\n catalog: PrototypeCatalogLike;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction normalizeRouteTheme(\n theme: PrototypeTheme | undefined,\n themeRegistry: ThemeRegistry | undefined,\n) {\n if (theme !== undefined) {\n return parsePrototypeTheme(theme, \"theme\", themeRegistry);\n }\n if (themeRegistry !== undefined) {\n return createDefaultPrototypeTheme(themeRegistry);\n }\n return undefined;\n}\n\nfunction createPrototypeEnvironmentModelLoader(\n options: PrototypeEnvironmentModelLoaderOptions,\n) {\n async function getRouteModel(\n input: PrototypeRef,\n ): Promise<PrototypeRouteModel | null> {\n let ref: PrototypeRef;\n try {\n ref = definePrototypeRef(input);\n } catch {\n return null;\n }\n\n const summary = await options.catalog.getSummary(ref);\n if (summary === null) return null;\n\n let theme: PrototypeTheme | undefined;\n try {\n theme = normalizeRouteTheme(summary.theme, options.themeRegistry);\n } catch {\n return null;\n }\n\n return {\n ref: summary.ref,\n url: summary.url,\n ...(theme === undefined ? {} : { theme }),\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n }\n\n /**\n * Resolves the route model for the request currently being rendered,\n * using the pathname forwarded by `createAuthProxy` (see\n * `BONFIRE_PATHNAME_HEADER`). Intended for a shared prototype route-group\n * layout that mounts `PrototypeEnvironment` around both `AppHeader` and\n * `{children}`. The layout is entered from the dashboard and intentionally\n * remains stable while navigating within the prototype route group.\n *\n * Returns `null` when the current request is not a prototype route, or\n * when the pathname header is unavailable (for example, a request that\n * bypassed the proxy). Hosts that support soft navigation between\n * prototypes should resolve by prototype-specific route params instead.\n */\n async function getCurrentRouteModel(): Promise<PrototypeRouteModel | null> {\n const requestHeaders = await headers();\n const pathname = requestHeaders.get(BONFIRE_PATHNAME_HEADER);\n if (pathname === null) return null;\n const ref = parsePrototypePath(pathname);\n if (ref === null) return null;\n return getRouteModel(ref);\n }\n\n return { getRouteModel, getCurrentRouteModel };\n}\n\nexport { createPrototypeEnvironmentModelLoader };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-environment.js","sourceRoot":"","sources":["../../src/server/prototype-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GAInB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAc7D,SAAS,mBAAm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headers } from \"next/headers.js\";\nimport {\n createDefaultPrototypeTheme,\n definePrototypeRef,\n parsePrototypeTheme,\n parsePrototypePath,\n type PrototypeRef,\n type PrototypeTheme,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\nimport { BONFIRE_PATHNAME_HEADER } from \"./auth-boundary.js\";\n\nexport type PrototypeRouteModel = {\n ref: PrototypeRef;\n url: string;\n theme?: PrototypeTheme;\n themeRegistry?: ThemeRegistry;\n};\n\ntype PrototypeEnvironmentModelLoaderOptions = {\n catalog: PrototypeCatalogLike;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction normalizeRouteTheme(\n theme: PrototypeTheme | undefined,\n themeRegistry: ThemeRegistry | undefined,\n) {\n if (theme !== undefined) {\n return parsePrototypeTheme(theme, \"theme\", themeRegistry);\n }\n if (themeRegistry !== undefined) {\n return createDefaultPrototypeTheme(themeRegistry);\n }\n return undefined;\n}\n\nfunction createPrototypeEnvironmentModelLoader(\n options: PrototypeEnvironmentModelLoaderOptions,\n) {\n async function getRouteModel(\n input: PrototypeRef,\n ): Promise<PrototypeRouteModel | null> {\n let ref: PrototypeRef;\n try {\n ref = definePrototypeRef(input);\n } catch {\n return null;\n }\n\n const summary = await options.catalog.getSummary(ref);\n if (summary === null) return null;\n\n let theme: PrototypeTheme | undefined;\n try {\n theme = normalizeRouteTheme(summary.theme, options.themeRegistry);\n } catch {\n return null;\n }\n\n return {\n ref: summary.ref,\n url: summary.url,\n ...(theme === undefined ? {} : { theme }),\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n }\n\n /**\n * Resolves the route model for the request currently being rendered,\n * using the pathname forwarded by `createAuthProxy` (see\n * `BONFIRE_PATHNAME_HEADER`). Intended for a shared prototype route-group\n * layout that mounts `PrototypeEnvironment` around both `AppHeader` and\n * `{children}`. The layout is entered from the dashboard and intentionally\n * remains stable while navigating within the prototype route group.\n *\n * Returns `null` when the current request is not a prototype route, or\n * when the pathname header is unavailable (for example, a request that\n * bypassed the proxy). Hosts that support soft navigation between\n * prototypes should resolve by prototype-specific route params instead.\n */\n async function getCurrentRouteModel(): Promise<PrototypeRouteModel | null> {\n const requestHeaders = await headers();\n const pathname = requestHeaders.get(BONFIRE_PATHNAME_HEADER);\n if (pathname === null) return null;\n const ref = parsePrototypePath(pathname);\n if (ref === null) return null;\n return getRouteModel(ref);\n }\n\n return { getRouteModel, getCurrentRouteModel };\n}\n\nexport { createPrototypeEnvironmentModelLoader };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-routes.d.ts","sourceRoot":"","sources":["../../src/server/prototype-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAItE,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAyBF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,GAC7B,eAAe,CA2GjB"}
|
|
1
|
+
{"version":3,"file":"prototype-routes.d.ts","sourceRoot":"","sources":["../../src/server/prototype-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAItE,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAyBF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,GAC7B,eAAe,CA2GjB","sourcesContent":["import type { NextRequest } from \"next/server.js\";\nimport {\n definePrototypeRef,\n type BonfireIdentity,\n type DirtyObservationValue,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\n\nconst encoder = new TextEncoder();\n\ntype PrototypeRouteOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n getWatcher: () => Promise<PrototypeWatcher | null>;\n};\n\nexport type PrototypeRoutes = {\n dirty(request: NextRequest): Promise<Response>;\n};\n\nfunction errorResponse(status: number) {\n return new Response(null, {\n status,\n headers: { \"Cache-Control\": \"no-store\" },\n });\n}\n\nfunction dirtyMessage(value: DirtyObservationValue) {\n return encoder.encode(\n `data: ${JSON.stringify({\n dirty: value.status === \"dirty\",\n ...(value.previewUrl !== undefined\n ? { previewUrl: value.previewUrl }\n : {}),\n })}\\n\\n`,\n );\n}\n\nfunction queryValue(request: NextRequest, name: string) {\n const values = request.nextUrl.searchParams.getAll(name);\n return values.length === 1 ? values[0] : null;\n}\n\nexport function createPrototypeRoutes(\n options: PrototypeRouteOptions,\n): PrototypeRoutes {\n async function dirty(request: NextRequest) {\n if (options.production) return errorResponse(404);\n\n const identity = await options.getCurrentUser();\n if (identity === null) return errorResponse(401);\n\n const login = queryValue(request, \"login\");\n const slug = queryValue(request, \"slug\");\n if (login === null || slug === null) return errorResponse(400);\n\n let ref;\n try {\n ref = definePrototypeRef({ login, slug });\n } catch {\n return errorResponse(400);\n }\n if (ref.login !== identity.login) return errorResponse(403);\n if (options.lifecycle === null) return errorResponse(404);\n\n let initial: Awaited<ReturnType<PrototypeLifecycle[\"getDirtyState\"]>>;\n try {\n initial = await options.lifecycle.getDirtyState(identity, { ref });\n } catch {\n return errorResponse(500);\n }\n if (!initial.ok) {\n switch (initial.error.code) {\n case \"unauthenticated\":\n return errorResponse(401);\n case \"forbidden\":\n return errorResponse(403);\n case \"invalid-input\":\n return errorResponse(400);\n case \"not-found\":\n return errorResponse(404);\n default:\n return errorResponse(500);\n }\n }\n\n let watcher: PrototypeWatcher | null;\n try {\n watcher = await options.getWatcher();\n } catch {\n return errorResponse(500);\n }\n if (watcher === null) return errorResponse(404);\n\n let closeStream: () => void = () => undefined;\n const stream = new ReadableStream({\n start(controller) {\n let closed = false;\n let unsubscribe: () => void = () => undefined;\n\n const close = () => {\n if (closed) return;\n closed = true;\n unsubscribe();\n request.signal.removeEventListener(\"abort\", close);\n try {\n controller.close();\n } catch {\n // The stream may already have been closed by the client.\n }\n };\n\n closeStream = close;\n request.signal.addEventListener(\"abort\", close, { once: true });\n if (request.signal.aborted) {\n close();\n return;\n }\n\n try {\n controller.enqueue(dirtyMessage(initial.value));\n unsubscribe = watcher.subscribe({\n ref,\n initial: initial.value,\n onChange(value) {\n if (closed) return;\n try {\n controller.enqueue(dirtyMessage(value));\n } catch {\n close();\n }\n },\n });\n } catch {\n close();\n }\n },\n cancel() {\n closeStream();\n },\n });\n\n return new Response(stream, {\n headers: {\n \"Cache-Control\": \"no-cache, no-store\",\n Connection: \"keep-alive\",\n \"Content-Type\": \"text/event-stream\",\n },\n });\n }\n\n return { dirty };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-routes.js","sourceRoot":"","sources":["../../src/server/prototype-routes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,GAGnB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAalC,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM;QACN,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE;KACzC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,KAA4B;IAChD,OAAO,OAAO,CAAC,MAAM,CACnB,SAAS,IAAI,CAAC,SAAS,CAAC;QACtB,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,OAAO;QAC/B,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;YAChC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE;YAClC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,MAAM,CACT,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,OAAoB,EAAE,IAAY;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAA8B;IAE9B,KAAK,UAAU,KAAK,CAAC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M,CAAC,OAAO,EAAE,CAAC;oBAC3B,KAAK,EAAE,CAAC;oBACR,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC;oBACH,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;oBAChD,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;wBAC9B,GAAG;wBACH,OAAO,EAAE,OAAO,CAAC,KAAK;wBACtB,QAAQ,CAAC,KAAK;4BACZ,IAAI,MAAM;gCAAE,OAAO;4BACnB,IAAI,CAAC;gCACH,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;4BAC1C,CAAC;4BAAC,MAAM,CAAC;gCACP,KAAK,EAAE,CAAC;4BACV,CAAC;wBACH,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,KAAK,EAAE,CAAC;gBACV,CAAC;YACH,CAAC;YACD,MAAM;gBACJ,WAAW,EAAE,CAAC;YAChB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE;YAC1B,OAAO,EAAE;gBACP,eAAe,EAAE,oBAAoB;gBACrC,UAAU,EAAE,YAAY;gBACxB,cAAc,EAAE,mBAAmB;aACpC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"prototype-routes.js","sourceRoot":"","sources":["../../src/server/prototype-routes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,GAGnB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAalC,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM;QACN,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE;KACzC,CAAC,CAAC;AACL,CAAC;AAED,S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C;YACD,MAAM;gBACJ,WAAW,EAAE,CAAC;YAChB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE;YAC1B,OAAO,EAAE;gBACP,eAAe,EAAE,oBAAoB;gBACrC,UAAU,EAAE,YAAY;gBACxB,cAAc,EAAE,mBAAmB;aACpC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC","sourcesContent":["import type { NextRequest } from \"next/server.js\";\nimport {\n definePrototypeRef,\n type BonfireIdentity,\n type DirtyObservationValue,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\n\nconst encoder = new TextEncoder();\n\ntype PrototypeRouteOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n getWatcher: () => Promise<PrototypeWatcher | null>;\n};\n\nexport type PrototypeRoutes = {\n dirty(request: NextRequest): Promise<Response>;\n};\n\nfunction errorResponse(status: number) {\n return new Response(null, {\n status,\n headers: { \"Cache-Control\": \"no-store\" },\n });\n}\n\nfunction dirtyMessage(value: DirtyObservationValue) {\n return encoder.encode(\n `data: ${JSON.stringify({\n dirty: value.status === \"dirty\",\n ...(value.previewUrl !== undefined\n ? { previewUrl: value.previewUrl }\n : {}),\n })}\\n\\n`,\n );\n}\n\nfunction queryValue(request: NextRequest, name: string) {\n const values = request.nextUrl.searchParams.getAll(name);\n return values.length === 1 ? values[0] : null;\n}\n\nexport function createPrototypeRoutes(\n options: PrototypeRouteOptions,\n): PrototypeRoutes {\n async function dirty(request: NextRequest) {\n if (options.production) return errorResponse(404);\n\n const identity = await options.getCurrentUser();\n if (identity === null) return errorResponse(401);\n\n const login = queryValue(request, \"login\");\n const slug = queryValue(request, \"slug\");\n if (login === null || slug === null) return errorResponse(400);\n\n let ref;\n try {\n ref = definePrototypeRef({ login, slug });\n } catch {\n return errorResponse(400);\n }\n if (ref.login !== identity.login) return errorResponse(403);\n if (options.lifecycle === null) return errorResponse(404);\n\n let initial: Awaited<ReturnType<PrototypeLifecycle[\"getDirtyState\"]>>;\n try {\n initial = await options.lifecycle.getDirtyState(identity, { ref });\n } catch {\n return errorResponse(500);\n }\n if (!initial.ok) {\n switch (initial.error.code) {\n case \"unauthenticated\":\n return errorResponse(401);\n case \"forbidden\":\n return errorResponse(403);\n case \"invalid-input\":\n return errorResponse(400);\n case \"not-found\":\n return errorResponse(404);\n default:\n return errorResponse(500);\n }\n }\n\n let watcher: PrototypeWatcher | null;\n try {\n watcher = await options.getWatcher();\n } catch {\n return errorResponse(500);\n }\n if (watcher === null) return errorResponse(404);\n\n let closeStream: () => void = () => undefined;\n const stream = new ReadableStream({\n start(controller) {\n let closed = false;\n let unsubscribe: () => void = () => undefined;\n\n const close = () => {\n if (closed) return;\n closed = true;\n unsubscribe();\n request.signal.removeEventListener(\"abort\", close);\n try {\n controller.close();\n } catch {\n // The stream may already have been closed by the client.\n }\n };\n\n closeStream = close;\n request.signal.addEventListener(\"abort\", close, { once: true });\n if (request.signal.aborted) {\n close();\n return;\n }\n\n try {\n controller.enqueue(dirtyMessage(initial.value));\n unsubscribe = watcher.subscribe({\n ref,\n initial: initial.value,\n onChange(value) {\n if (closed) return;\n try {\n controller.enqueue(dirtyMessage(value));\n } catch {\n close();\n }\n },\n });\n } catch {\n close();\n }\n },\n cancel() {\n closeStream();\n },\n });\n\n return new Response(stream, {\n headers: {\n \"Cache-Control\": \"no-cache, no-store\",\n Connection: \"keep-alive\",\n \"Content-Type\": \"text/event-stream\",\n },\n });\n }\n\n return { dirty };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/server/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AA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C;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,0BAA0B,CAAC;CAC7C,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB;;;;;;;8BAuB1B,eAAe;;EAyBvD","sourcesContent":["import { cookies as nextCookies } from \"next/headers.js\";\nimport { jwtVerify, SignJWT } from \"jose\";\nimport {\n getSessionCookieName,\n parseBonfireIdentity,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\n\nexport const SESSION_DURATION_SECONDS = 30 * 24 * 60 * 60;\nexport const SESSION_MAX_AGE = SESSION_DURATION_SECONDS;\nexport const SESSION_ALGORITHM = \"HS256\";\nconst MINIMUM_SECRET_BYTES = 32;\n\ntype SessionCookieStore = {\n get(name: string): { value: string } | undefined;\n set(name: string, value: string, options: SessionCookieOptions): void;\n delete(name: string): void;\n};\n\ntype SessionCookieOptions = {\n httpOnly: boolean;\n secure: boolean;\n sameSite: \"lax\";\n path: string;\n maxAge: number;\n};\n\ntype SessionCookieStoreProvider = () => Promise<SessionCookieStore>;\n\nexport class SessionSecretError extends Error {\n constructor(\n message = \"BF_SESSION_SECRET must contain at least 32 UTF-8 bytes\",\n ) {\n super(message);\n this.name = \"SessionSecretError\";\n }\n}\n\nexport function getSessionKey(secret: unknown) {\n if (\n typeof secret !== \"string\" ||\n Buffer.byteLength(secret, \"utf8\") < MINIMUM_SECRET_BYTES\n ) {\n throw new SessionSecretError();\n }\n return new TextEncoder().encode(secret);\n}\n\nfunction identityPayload(payload: Record<string, unknown>) {\n const allowedClaims = new Set([\"login\", \"name\", \"avatar_url\", \"exp\"]);\n const unexpectedClaim = Object.keys(payload).find(\n (claim) => !allowedClaims.has(claim),\n );\n if (unexpectedClaim) throw new Error(\"unexpected session claim\");\n if (typeof payload.exp !== \"number\" || !Number.isInteger(payload.exp)) {\n throw new Error(\"invalid session expiration\");\n }\n\n const identity = parseBonfireIdentity({\n login: payload.login,\n ...(Object.hasOwn(payload, \"name\") ? { name: payload.name } : {}),\n avatar_url: payload.avatar_url,\n });\n return { ...identity, exp: payload.exp } satisfies BonfireIdentity & {\n exp: number;\n };\n}\n\nexport async function signSession(\n identity: BonfireIdentity,\n secret: unknown,\n now = Date.now(),\n) {\n const key = getSessionKey(secret);\n const parsedIdentity = parseBonfireIdentity(identity);\n const expiration = Math.floor(now / 1000) + SESSION_DURATION_SECONDS;\n\n return new SignJWT(parsedIdentity)\n .setProtectedHeader({ alg: SESSION_ALGORITHM })\n .setExpirationTime(expiration)\n .sign(key);\n}\n\nexport async function verifySession(\n token: string,\n secret: unknown,\n now = Date.now(),\n) {\n const key = getSessionKey(secret);\n try {\n const result = await jwtVerify(token, key, {\n algorithms: [SESSION_ALGORITHM],\n currentDate: new Date(now),\n });\n const payload = identityPayload(result.payload);\n return {\n login: payload.login,\n name: payload.name,\n avatar_url: payload.avatar_url,\n };\n } catch {\n return null;\n }\n}\n\ntype SessionAdapterOptions = {\n appId: string;\n sessionSecret: string | undefined;\n production: boolean;\n getCookieStore?: SessionCookieStoreProvider;\n};\n\nexport function createSessionAdapter(options: SessionAdapterOptions) {\n const cookieName = getSessionCookieName(options.appId);\n if (!options.production && options.sessionSecret === undefined) {\n throw new SessionSecretError(\n \"BF_SESSION_SECRET is required for development sessions\",\n );\n }\n if (options.sessionSecret !== undefined) getSessionKey(options.sessionSecret);\n\n const getCookieStore =\n options.getCookieStore ??\n (() => nextCookies() as Promise<SessionCookieStore>);\n\n async function getSession() {\n if (options.production && options.sessionSecret === undefined) return null;\n if (options.sessionSecret === undefined) return null;\n\n const cookieStore = await getCookieStore();\n const token = cookieStore.get(cookieName)?.value;\n if (!token) return null;\n return verifySession(token, options.sessionSecret);\n }\n\n async function createSession(identity: BonfireIdentity) {\n if (options.production && options.sessionSecret === undefined) return;\n if (options.sessionSecret === undefined) {\n throw new SessionSecretError(\n \"BF_SESSION_SECRET is required for development sessions\",\n );\n }\n\n const token = await signSession(identity, options.sessionSecret);\n const cookieStore = await getCookieStore();\n cookieStore.set(cookieName, token, {\n httpOnly: true,\n secure: options.production,\n sameSite: \"lax\",\n path: \"/\",\n maxAge: SESSION_MAX_AGE,\n });\n }\n\n async function clearSession() {\n const cookieStore = await getCookieStore();\n cookieStore.delete(cookieName);\n }\n\n return { cookieName, getSession, createSession, clearSession };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAkBhC,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YACE,OAAO,GAAG,wDAAwD;QAElE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,IACE,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB,EACxD,CAAC;QACD,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,eAAe,CAAC,OAAgC;IACvD,MAAM,aAAa,GAAG,IAAI,GA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CAAC;QACjD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,UAAU,aAAa,CAAC,QAAyB;QACpD,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS;YAAE,OAAO;QACtE,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,kBAAkB,CAC1B,wDAAwD,CACzD,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE;YACjC,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,GAAG;YACT,MAAM,EAAE,eAAe;SACxB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,UAAU,YAAY;QACzB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACjE,CAAC","sourcesContent":["import { cookies as nextCookies } from \"next/headers.js\";\nimport { jwtVerify, SignJWT } from \"jose\";\nimport {\n getSessionCookieName,\n parseBonfireIdentity,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\n\nexport const SESSION_DURATION_SECONDS = 30 * 24 * 60 * 60;\nexport const SESSION_MAX_AGE = SESSION_DURATION_SECONDS;\nexport const SESSION_ALGORITHM = \"HS256\";\nconst MINIMUM_SECRET_BYTES = 32;\n\ntype SessionCookieStore = {\n get(name: string): { value: string } | undefined;\n set(name: string, value: string, options: SessionCookieOptions): void;\n delete(name: string): void;\n};\n\ntype SessionCookieOptions = {\n httpOnly: boolean;\n secure: boolean;\n sameSite: \"lax\";\n path: string;\n maxAge: number;\n};\n\ntype SessionCookieStoreProvider = () => Promise<SessionCookieStore>;\n\nexport class SessionSecretError extends Error {\n constructor(\n message = \"BF_SESSION_SECRET must contain at least 32 UTF-8 bytes\",\n ) {\n super(message);\n this.name = \"SessionSecretError\";\n }\n}\n\nexport function getSessionKey(secret: unknown) {\n if (\n typeof secret !== \"string\" ||\n Buffer.byteLength(secret, \"utf8\") < MINIMUM_SECRET_BYTES\n ) {\n throw new SessionSecretError();\n }\n return new TextEncoder().encode(secret);\n}\n\nfunction identityPayload(payload: Record<string, unknown>) {\n const allowedClaims = new Set([\"login\", \"name\", \"avatar_url\", \"exp\"]);\n const unexpectedClaim = Object.keys(payload).find(\n (claim) => !allowedClaims.has(claim),\n );\n if (unexpectedClaim) throw new Error(\"unexpected session claim\");\n if (typeof payload.exp !== \"number\" || !Number.isInteger(payload.exp)) {\n throw new Error(\"invalid session expiration\");\n }\n\n const identity = parseBonfireIdentity({\n login: payload.login,\n ...(Object.hasOwn(payload, \"name\") ? { name: payload.name } : {}),\n avatar_url: payload.avatar_url,\n });\n return { ...identity, exp: payload.exp } satisfies BonfireIdentity & {\n exp: number;\n };\n}\n\nexport async function signSession(\n identity: BonfireIdentity,\n secret: unknown,\n now = Date.now(),\n) {\n const key = getSessionKey(secret);\n const parsedIdentity = parseBonfireIdentity(identity);\n const expiration = Math.floor(now / 1000) + SESSION_DURATION_SECONDS;\n\n return new SignJWT(parsedIdentity)\n .setProtectedHeader({ alg: SESSION_ALGORITHM })\n .setExpirationTime(expiration)\n .sign(key);\n}\n\nexport async function verifySession(\n token: string,\n secret: unknown,\n now = Date.now(),\n) {\n const key = getSessionKey(secret);\n try {\n const result = await jwtVerify(token, key, {\n algorithms: [SESSION_ALGORITHM],\n currentDate: new Date(now),\n });\n const payload = identityPayload(result.payload);\n return {\n login: payload.login,\n name: payload.name,\n avatar_url: payload.avatar_url,\n };\n } catch {\n return null;\n }\n}\n\ntype SessionAdapterOptions = {\n appId: string;\n sessionSecret: string | undefined;\n production: boolean;\n getCookieStore?: SessionCookieStoreProvider;\n};\n\nexport function createSessionAdapter(options: SessionAdapterOptions) {\n const cookieName = getSessionCookieName(options.appId);\n if (!options.production && options.sessionSecret === undefined) {\n throw new SessionSecretError(\n \"BF_SESSION_SECRET is required for development sessions\",\n );\n }\n if (options.sessionSecret !== undefined) getSessionKey(options.sessionSecret);\n\n const getCookieStore =\n options.getCookieStore ??\n (() => nextCookies() as Promise<SessionCookieStore>);\n\n async function getSession() {\n if (options.production && options.sessionSecret === undefined) return null;\n if (options.sessionSecret === undefined) return null;\n\n const cookieStore = await getCookieStore();\n const token = cookieStore.get(cookieName)?.value;\n if (!token) return null;\n return verifySession(token, options.sessionSecret);\n }\n\n async function createSession(identity: BonfireIdentity) {\n if (options.production && options.sessionSecret === undefined) return;\n if (options.sessionSecret === undefined) {\n throw new SessionSecretError(\n \"BF_SESSION_SECRET is required for development sessions\",\n );\n }\n\n const token = await signSession(identity, options.sessionSecret);\n const cookieStore = await getCookieStore();\n cookieStore.set(cookieName, token, {\n httpOnly: true,\n secure: options.production,\n sameSite: \"lax\",\n path: \"/\",\n maxAge: SESSION_MAX_AGE,\n });\n }\n\n async function clearSession() {\n const cookieStore = await getCookieStore();\n cookieStore.delete(cookieName);\n }\n\n return { cookieName, getSession, createSession, clearSession };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebay-dt/bonfire-next",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Next.js server integration for Bonfire.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ebay-dt/bonfire-core": "0.1.0-alpha.
|
|
35
|
-
"@ebay-dt/bonfire-node": "0.1.0-alpha.
|
|
34
|
+
"@ebay-dt/bonfire-core": "0.1.0-alpha.2",
|
|
35
|
+
"@ebay-dt/bonfire-node": "0.1.0-alpha.2",
|
|
36
36
|
"jose": "^6.1.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@ebay-dt/bonfire-react": "0.1.0-alpha.
|
|
39
|
+
"@ebay-dt/bonfire-react": "0.1.0-alpha.2",
|
|
40
40
|
"next": ">=16.2 <17",
|
|
41
41
|
"react": ">=19.2 <20",
|
|
42
42
|
"react-dom": ">=19.2 <20"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@ebay-dt/bonfire-react": "0.1.0-alpha.
|
|
45
|
+
"@ebay-dt/bonfire-react": "0.1.0-alpha.2",
|
|
46
46
|
"@repo/eslint-config": "0.0.0",
|
|
47
47
|
"@repo/typescript-config": "0.0.0",
|
|
48
48
|
"@types/node": "20.19.43",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vitest": "^5.0.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"build": "tsc -p tsconfig.build.json",
|
|
59
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/embed-source-map-sources.mjs dist",
|
|
60
60
|
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
61
61
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
62
62
|
"lint": "eslint .",
|