@ebay-dt/bonfire-next 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/lifecycle-provider.d.ts +12 -0
- package/dist/client/lifecycle-provider.d.ts.map +1 -0
- package/dist/client/lifecycle-provider.js +58 -0
- package/dist/client/lifecycle-provider.js.map +1 -0
- package/dist/server/auth-boundary.d.ts +9 -0
- package/dist/server/auth-boundary.d.ts.map +1 -0
- package/dist/server/auth-boundary.js +25 -0
- package/dist/server/auth-boundary.js.map +1 -0
- package/dist/server/auth-routes.d.ts +17 -0
- package/dist/server/auth-routes.d.ts.map +1 -0
- package/dist/server/auth-routes.js +103 -0
- package/dist/server/auth-routes.js.map +1 -0
- package/dist/server/create-bonfire-next.d.ts +69 -0
- package/dist/server/create-bonfire-next.d.ts.map +1 -0
- package/dist/server/create-bonfire-next.js +137 -0
- package/dist/server/create-bonfire-next.js.map +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/login-page-model.d.ts +16 -0
- package/dist/server/login-page-model.d.ts.map +1 -0
- package/dist/server/login-page-model.js +28 -0
- package/dist/server/login-page-model.js.map +1 -0
- package/dist/server/prototype-actions.d.ts +15 -0
- package/dist/server/prototype-actions.d.ts.map +1 -0
- package/dist/server/prototype-actions.js +80 -0
- package/dist/server/prototype-actions.js.map +1 -0
- package/dist/server/prototype-dashboard.d.ts +13 -0
- package/dist/server/prototype-dashboard.d.ts.map +1 -0
- package/dist/server/prototype-dashboard.js +65 -0
- package/dist/server/prototype-dashboard.js.map +1 -0
- package/dist/server/prototype-routes.d.ts +16 -0
- package/dist/server/prototype-routes.d.ts.map +1 -0
- package/dist/server/prototype-routes.js +127 -0
- package/dist/server/prototype-routes.js.map +1 -0
- package/dist/server/session.d.ts +47 -0
- package/dist/server/session.d.ts.map +1 -0
- package/dist/server/session.js +105 -0
- package/dist/server/session.js.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bonfire contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# `@ebay-dt/bonfire-next`
|
|
2
|
+
|
|
3
|
+
Next.js integration for Bonfire. Server APIs are exposed from
|
|
4
|
+
`@ebay-dt/bonfire-next/server`, and the Next-specific lifecycle client adapter is
|
|
5
|
+
exposed from `@ebay-dt/bonfire-next/client`.
|
|
6
|
+
|
|
7
|
+
It provides HS256 development sessions, the development authentication proxy,
|
|
8
|
+
login/status/logout handlers, and server-side login-page model composition.
|
|
9
|
+
Production remains public and does not require GitHub CLI or
|
|
10
|
+
`BF_SESSION_SECRET`.
|
|
11
|
+
|
|
12
|
+
## Installation and instance setup
|
|
13
|
+
|
|
14
|
+
Install `@ebay-dt/bonfire-next`, `@ebay-dt/bonfire-core`, and `@ebay-dt/bonfire-react` in the
|
|
15
|
+
application. Install `@ebay-dt/bonfire-cli` as a development dependency.
|
|
16
|
+
|
|
17
|
+
Create `bonfire.config.ts`:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import type { BonfireConfigInput } from "@ebay-dt/bonfire-core";
|
|
21
|
+
|
|
22
|
+
const config = {
|
|
23
|
+
appId: "my-app",
|
|
24
|
+
name: "My App",
|
|
25
|
+
auth: {
|
|
26
|
+
github: {
|
|
27
|
+
hostname: "github.com",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} satisfies BonfireConfigInput;
|
|
31
|
+
|
|
32
|
+
export default config;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Create `src/bonfire.ts`:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { createBonfireNext } from "@ebay-dt/bonfire-next/server";
|
|
39
|
+
import config from "../bonfire.config";
|
|
40
|
+
|
|
41
|
+
export const bonfire = createBonfireNext({
|
|
42
|
+
config,
|
|
43
|
+
repositoryRoot: process.cwd(),
|
|
44
|
+
primaryBranch: process.env.BF_PROTOTYPE_BASE_BRANCH,
|
|
45
|
+
sessionSecret: process.env.BF_SESSION_SECRET,
|
|
46
|
+
disableAutoBranchSwitch: process.env.BF_DISABLE_AUTO_BRANCH_SWITCH,
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Run `bonfire prepare` before development so the secret exists in
|
|
51
|
+
`.env.local`. An externally supplied `BF_SESSION_SECRET` takes precedence.
|
|
52
|
+
The explicit repository root enables request-time discovery under
|
|
53
|
+
`src/app/(prototypes)` without relying on package-internal `process.cwd()`.
|
|
54
|
+
`BF_PROTOTYPE_BASE_BRANCH` can override the default `main` branch used as the
|
|
55
|
+
base for identity branches. The configured branch must exist; a missing base
|
|
56
|
+
branch fails preparation rather than silently using the current branch.
|
|
57
|
+
|
|
58
|
+
A development instance can also receive a trusted server-only
|
|
59
|
+
`preparePrototypeFiles` callback. It runs after Bonfire scaffolds or
|
|
60
|
+
duplicates the destination and before the initial commit, allowing the host to
|
|
61
|
+
write prototype-local files. Callback failures clean the newly owned
|
|
62
|
+
destination; commit or push failures preserve completed output. Do not supply
|
|
63
|
+
this callback together with a `prototypeLifecycle` override.
|
|
64
|
+
|
|
65
|
+
## Next host contract
|
|
66
|
+
|
|
67
|
+
Next.js cannot install filesystem routes for a package, so each application
|
|
68
|
+
adds these small bindings. Keep authentication logic in the package.
|
|
69
|
+
|
|
70
|
+
`src/app/layout.tsx`:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import type { Metadata } from "next";
|
|
74
|
+
import { AppHeader } from "@ebay-dt/bonfire-react";
|
|
75
|
+
import { bonfire } from "@/bonfire";
|
|
76
|
+
import "@ebay-dt/bonfire-react/styles/defaults.css";
|
|
77
|
+
|
|
78
|
+
export default async function RootLayout({ children }: LayoutProps<"/">) {
|
|
79
|
+
const { htmlProps, headerProps } = await bonfire.auth.getAppLayoutModel();
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<html lang="en" {...htmlProps}>
|
|
83
|
+
<body>
|
|
84
|
+
<AppHeader {...headerProps} />
|
|
85
|
+
{children}
|
|
86
|
+
</body>
|
|
87
|
+
</html>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`getAppLayoutModel()` returns opaque document props for the packaged header
|
|
93
|
+
layout contract and serializable header props. It bypasses session access in
|
|
94
|
+
production. `AppHeader` receives `user: null` and renders nothing when the
|
|
95
|
+
header is absent, so the host does not implement environment or identity
|
|
96
|
+
branching. For a lifecycle-enabled development header, use
|
|
97
|
+
`LifecycleAppHeader` from `@ebay-dt/bonfire-react/lifecycle` inside the provider; it
|
|
98
|
+
composes the prototype indicator and save/discard popover without duplicating
|
|
99
|
+
that UI in the host.
|
|
100
|
+
|
|
101
|
+
## Prototype lifecycle composition
|
|
102
|
+
|
|
103
|
+
The lifecycle-aware dashboard uses the framework-neutral controller and React
|
|
104
|
+
components from `@ebay-dt/bonfire-react/lifecycle`. The Next-specific provider owns
|
|
105
|
+
router integration, dirty-state observation, and controller lifetime, so the
|
|
106
|
+
host supplies its Server Action references and the current layout user. Add the
|
|
107
|
+
thin dirty route binding as well:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
// src/app/api/prototype-dirty/route.ts
|
|
111
|
+
import { bonfire } from "@/bonfire";
|
|
112
|
+
|
|
113
|
+
export const runtime = "nodejs";
|
|
114
|
+
export const GET = bonfire.prototypes.routes.dirty;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then mount the provider and lifecycle-aware header from the root layout:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { NextLifecycleProvider } from "@ebay-dt/bonfire-next/client";
|
|
121
|
+
import { LifecycleAppHeader } from "@ebay-dt/bonfire-react/lifecycle";
|
|
122
|
+
import {
|
|
123
|
+
createPrototype,
|
|
124
|
+
discardPrototype,
|
|
125
|
+
duplicatePrototype,
|
|
126
|
+
savePrototype,
|
|
127
|
+
} from "@/actions/prototypes";
|
|
128
|
+
import { bonfire } from "@/bonfire";
|
|
129
|
+
|
|
130
|
+
const { headerProps } = await bonfire.auth.getAppLayoutModel();
|
|
131
|
+
|
|
132
|
+
<NextLifecycleProvider
|
|
133
|
+
enabled={process.env.NODE_ENV !== "production"}
|
|
134
|
+
user={headerProps.user}
|
|
135
|
+
dirtyEndpoint="/api/prototype-dirty"
|
|
136
|
+
actions={{
|
|
137
|
+
create: createPrototype,
|
|
138
|
+
duplicate: duplicatePrototype,
|
|
139
|
+
save: savePrototype,
|
|
140
|
+
discard: discardPrototype,
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
<LifecycleAppHeader {...headerProps} />
|
|
144
|
+
{children}
|
|
145
|
+
</NextLifecycleProvider>;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Mount it from the root layout so the controller survives dashboard/prototype
|
|
149
|
+
navigation. Production can leave the provider disabled; the lifecycle-aware
|
|
150
|
+
dashboard then renders its public read-only view.
|
|
151
|
+
|
|
152
|
+
`src/app/login/page.tsx`:
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import { GitHubCliLoginPage } from "@ebay-dt/bonfire-react";
|
|
156
|
+
import { bonfire } from "@/bonfire";
|
|
157
|
+
|
|
158
|
+
type LoginPageProps = {
|
|
159
|
+
searchParams?: Promise<{
|
|
160
|
+
auth?: string;
|
|
161
|
+
code?: string;
|
|
162
|
+
error?: string;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default async function LoginPage({ searchParams }: LoginPageProps) {
|
|
167
|
+
const model = await bonfire.auth.getLoginPageModel(searchParams);
|
|
168
|
+
return <GitHubCliLoginPage {...model} />;
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`src/app/auth/login/route.ts`:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { bonfire } from "@/bonfire";
|
|
176
|
+
|
|
177
|
+
export const runtime = "nodejs";
|
|
178
|
+
export const GET = bonfire.auth.routes.login;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`src/app/auth/status/route.ts`:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { bonfire } from "@/bonfire";
|
|
185
|
+
|
|
186
|
+
export const runtime = "nodejs";
|
|
187
|
+
export const GET = bonfire.auth.routes.status;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`src/app/auth/logout/route.ts`:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { bonfire } from "@/bonfire";
|
|
194
|
+
|
|
195
|
+
export const POST = bonfire.auth.routes.logout;
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`src/proxy.ts`:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { bonfire } from "./bonfire";
|
|
202
|
+
|
|
203
|
+
export const proxy = bonfire.auth.proxy;
|
|
204
|
+
|
|
205
|
+
export const config = {
|
|
206
|
+
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Behavior and security
|
|
211
|
+
|
|
212
|
+
In development, the proxy requires a valid app-specific, HTTP-only session
|
|
213
|
+
cookie. Login reads the local GitHub CLI identity, and status refreshes the
|
|
214
|
+
session while device authentication is in progress. Logout clears the cookie
|
|
215
|
+
and redirects to `/login`. In production, the proxy passes requests through,
|
|
216
|
+
login and status return 404, and logout clears stale state before redirecting to
|
|
217
|
+
`/`.
|
|
218
|
+
|
|
219
|
+
The session secret must contain at least 32 UTF-8 bytes. Tokens use HS256 and
|
|
220
|
+
contain only the validated identity and expiration. Invalid or tampered tokens
|
|
221
|
+
are treated as unauthenticated. Secrets are not included in login models,
|
|
222
|
+
errors, logs, or redirects.
|
|
223
|
+
|
|
224
|
+
The configured GitHub hostname controls both CLI commands and the device
|
|
225
|
+
activation URL. For GitHub Enterprise, set the hostname in configuration rather
|
|
226
|
+
than changing the host bindings.
|
|
227
|
+
|
|
228
|
+
## Prototype dashboard
|
|
229
|
+
|
|
230
|
+
The configured instance exposes read-only catalog methods:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import { PrototypeDashboard } from "@ebay-dt/bonfire-react";
|
|
234
|
+
import { bonfire } from "@/bonfire";
|
|
235
|
+
|
|
236
|
+
type HomeProps = {
|
|
237
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export default async function Home({ searchParams }: HomeProps) {
|
|
241
|
+
const model = await bonfire.prototypes.getDashboardModel(searchParams);
|
|
242
|
+
return <PrototypeDashboard {...model} />;
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The catalog is discovered at request time from
|
|
247
|
+
`src/app/(prototypes)/<author>/<slug>`. Production is public and does not
|
|
248
|
+
include the development-only `mine` option. Catalog reads are read-only and do
|
|
249
|
+
not invoke GitHub CLI, Git, or the network.
|
|
250
|
+
|
|
251
|
+
## Prototype mutation actions
|
|
252
|
+
|
|
253
|
+
Create, duplicate, save, and discard actions are returned as typed results and
|
|
254
|
+
do not perform redirects. Bind them from a small host Server Action module. Save
|
|
255
|
+
and discard accept only a validated target reference and never push changes:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
// src/actions/prototypes.ts
|
|
259
|
+
"use server";
|
|
260
|
+
|
|
261
|
+
import type {
|
|
262
|
+
CreatePrototypeInput,
|
|
263
|
+
DiscardPrototypeInput,
|
|
264
|
+
DuplicatePrototypeInput,
|
|
265
|
+
SavePrototypeInput,
|
|
266
|
+
} from "@ebay-dt/bonfire-core";
|
|
267
|
+
import { bonfire } from "@/bonfire";
|
|
268
|
+
|
|
269
|
+
export async function createPrototype(input: CreatePrototypeInput) {
|
|
270
|
+
return bonfire.prototypes.actions.create(input);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export async function duplicatePrototype(input: DuplicatePrototypeInput) {
|
|
274
|
+
return bonfire.prototypes.actions.duplicate(input);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export async function savePrototype(input: SavePrototypeInput) {
|
|
278
|
+
return bonfire.prototypes.actions.save(input);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export async function discardPrototype(input: DiscardPrototypeInput) {
|
|
282
|
+
return bonfire.prototypes.actions.discard(input);
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Keep these wrappers thin: form validation, session lookup, lifecycle errors,
|
|
287
|
+
and filesystem/Git operations remain in Bonfire. Save creates a local,
|
|
288
|
+
path-scoped commit and discard restores/removes content only inside that path;
|
|
289
|
+
neither operation pushes. The host should pass the Server Action references to
|
|
290
|
+
`NextLifecycleProvider` from `@ebay-dt/bonfire-next/client`. In development, the
|
|
291
|
+
provider protects dirty internal navigation and reload/close attempts; in
|
|
292
|
+
production it is disabled and the application remains public/read-only.
|
|
293
|
+
|
|
294
|
+
## Supported versions
|
|
295
|
+
|
|
296
|
+
- Node.js 24 or newer
|
|
297
|
+
- Next.js 16.2 through 16.x
|
|
298
|
+
- React 19.2 through 19.x
|
|
299
|
+
- ESM-only package output
|
|
300
|
+
|
|
301
|
+
If `gh` is missing or unauthenticated, install GitHub CLI and run
|
|
302
|
+
`gh auth login --hostname <hostname>`. If device login does not open a browser,
|
|
303
|
+
use the link and code shown on the login page. The eventual migration of an
|
|
304
|
+
existing application changes the cookie name and secret contract, so existing
|
|
305
|
+
sessions will need to authenticate again.
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LifecycleActionBindings } from "@ebay-dt/bonfire-react/lifecycle";
|
|
2
|
+
import type { BonfireIdentity } from "@ebay-dt/bonfire-core";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
export type NextLifecycleProviderProps = {
|
|
5
|
+
actions: LifecycleActionBindings;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
user?: BonfireIdentity | null;
|
|
9
|
+
dirtyEndpoint?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function NextLifecycleProvider({ actions, children, enabled, user, dirtyEndpoint, }: NextLifecycleProviderProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
12
|
+
//# sourceMappingURL=lifecycle-provider.d.ts.map
|
|
@@ -0,0 +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;CACxB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,GACd,EAAE,0BAA0B,+TAW5B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createDirtyObservationAdapter, createLifecycleController, LifecycleProvider, } from "@ebay-dt/bonfire-react/lifecycle";
|
|
4
|
+
import { usePathname, useRouter } from "next/navigation.js";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
export function NextLifecycleProvider({ actions, children, enabled = true, user = null, dirtyEndpoint, }) {
|
|
7
|
+
if (!enabled)
|
|
8
|
+
return children;
|
|
9
|
+
return (_jsx(EnabledNextLifecycleProvider, { actions: actions, dirtyEndpoint: dirtyEndpoint, user: user, children: children }));
|
|
10
|
+
}
|
|
11
|
+
function EnabledNextLifecycleProvider({ actions, children, user, dirtyEndpoint, }) {
|
|
12
|
+
const pathname = usePathname() ?? "/";
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
const [route] = useState(() => {
|
|
15
|
+
let currentPathname = pathname;
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
const adapter = {
|
|
18
|
+
getPathname: () => currentPathname,
|
|
19
|
+
subscribe: (listener) => {
|
|
20
|
+
listeners.add(listener);
|
|
21
|
+
return () => listeners.delete(listener);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
adapter,
|
|
26
|
+
setPathname(nextPathname) {
|
|
27
|
+
if (nextPathname === currentPathname)
|
|
28
|
+
return;
|
|
29
|
+
currentPathname = nextPathname;
|
|
30
|
+
for (const listener of listeners)
|
|
31
|
+
listener();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const [navigation] = useState(() => ({
|
|
36
|
+
pathname,
|
|
37
|
+
push: (href) => router.push(href),
|
|
38
|
+
replace: (href) => router.replace(href),
|
|
39
|
+
back: () => router.back(),
|
|
40
|
+
}));
|
|
41
|
+
const [dirtyObservation] = useState(() => createDirtyObservationAdapter({ endpoint: dirtyEndpoint }));
|
|
42
|
+
const [controller] = useState(() => createLifecycleController({
|
|
43
|
+
actions,
|
|
44
|
+
navigation,
|
|
45
|
+
route: route.adapter,
|
|
46
|
+
user,
|
|
47
|
+
dirtyObservation,
|
|
48
|
+
}));
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
route.setPathname(pathname);
|
|
51
|
+
}, [pathname, route]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
controller.start();
|
|
54
|
+
return () => controller.stop();
|
|
55
|
+
}, [controller]);
|
|
56
|
+
return (_jsx(LifecycleProvider, { controller: controller, children: children }));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=lifecycle-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-provider.js","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GAIlB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAU5D,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,IAAI,GAAG,IAAI,EACX,aAAa,GACc;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,CACL,KAAC,4BAA4B,IAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,YAET,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,aAAa,GAId;IACC,MAAM,QAAQ,GAAG,WAAW,EAAE,IAAI,GAAG,CAAC;IACtC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC5B,IAAI,eAAe,GAAG,QAAQ,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;QACxC,MAAM,OAAO,GAA0B;YACrC,WAAW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Q,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtB,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,KAAC,iBAAiB,IAAC,UAAU,EAAE,UAAU,YAAG,QAAQ,GAAqB,CAC1E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextResponse } from "next/server.js";
|
|
2
|
+
import type { NextRequest } from "next/server.js";
|
|
3
|
+
export type AuthProxyOptions = {
|
|
4
|
+
appId: string;
|
|
5
|
+
sessionSecret: string | undefined;
|
|
6
|
+
production: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function createAuthProxy(options: AuthProxyOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
9
|
+
//# sourceMappingURL=auth-boundary.d.ts.map
|
|
@@ -0,0 +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,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,aAGd,WAAW,oCAarD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getSessionCookieName } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import { NextResponse } from "next/server.js";
|
|
3
|
+
import { verifySession } from "./session.js";
|
|
4
|
+
function isAuthPath(pathname) {
|
|
5
|
+
return (pathname === "/login" ||
|
|
6
|
+
pathname === "/auth" ||
|
|
7
|
+
pathname.startsWith("/auth/"));
|
|
8
|
+
}
|
|
9
|
+
export function createAuthProxy(options) {
|
|
10
|
+
const cookieName = getSessionCookieName(options.appId);
|
|
11
|
+
return async function authProxy(request) {
|
|
12
|
+
if (options.production)
|
|
13
|
+
return NextResponse.next();
|
|
14
|
+
if (isAuthPath(request.nextUrl.pathname))
|
|
15
|
+
return NextResponse.next();
|
|
16
|
+
const token = request.cookies.get(cookieName)?.value;
|
|
17
|
+
const identity = token && options.sessionSecret
|
|
18
|
+
? await verifySession(token, options.sessionSecret)
|
|
19
|
+
: null;
|
|
20
|
+
if (identity)
|
|
21
|
+
return NextResponse.next();
|
|
22
|
+
return NextResponse.redirect(new URL("/login", request.url));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=auth-boundary.js.map
|
|
@@ -0,0 +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,UAAU,eAAe,CAAC,OAAyB;IACvD,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEvD,OAAO,KAAK,UAAU,SAAS,CAAC,OAAoB;QAClD,IAAI,OAAO,CAAC,UAAU;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC;QACnD,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC;QAErE,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,YAAY,CAAC,IAAI,EAAE,CAAC;QAEzC,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type BranchPreparationValue, type LifecycleResult, type BonfireIdentity } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import { type GitHubCliClientLike } from "@ebay-dt/bonfire-node";
|
|
3
|
+
import { NextResponse } from "next/server.js";
|
|
4
|
+
import type { NextRequest } from "next/server.js";
|
|
5
|
+
export type AuthRouteOptions = {
|
|
6
|
+
production: boolean;
|
|
7
|
+
githubCli: GitHubCliClientLike;
|
|
8
|
+
createSession: (identity: BonfireIdentity) => Promise<void>;
|
|
9
|
+
clearSession: () => Promise<void>;
|
|
10
|
+
prepareIdentity?: (identity: BonfireIdentity) => Promise<LifecycleResult<BranchPreparationValue>>;
|
|
11
|
+
};
|
|
12
|
+
export declare function createAuthRoutes(options: AuthRouteOptions): {
|
|
13
|
+
login: (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
14
|
+
status: () => Promise<NextResponse<unknown>>;
|
|
15
|
+
logout: (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=auth-routes.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { lifecycleFailure, lifecycleSuccess, } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import { GitHubCliError, } from "@ebay-dt/bonfire-node";
|
|
3
|
+
import { NextResponse } from "next/server.js";
|
|
4
|
+
function notFound() {
|
|
5
|
+
return new NextResponse(null, { status: 404 });
|
|
6
|
+
}
|
|
7
|
+
function redirect(request, path, status = 307) {
|
|
8
|
+
return NextResponse.redirect(new URL(path, request.url), status);
|
|
9
|
+
}
|
|
10
|
+
function logLoginFailure(message) {
|
|
11
|
+
console.error(`Bonfire GitHub CLI login failed: ${message}`);
|
|
12
|
+
}
|
|
13
|
+
function logBranchPreparationFailure() {
|
|
14
|
+
console.error("Bonfire branch preparation failed.");
|
|
15
|
+
}
|
|
16
|
+
async function prepareIdentity(options, identity) {
|
|
17
|
+
try {
|
|
18
|
+
return ((await options.prepareIdentity?.(identity)) ??
|
|
19
|
+
lifecycleSuccess({ status: "disabled" }));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return lifecycleFailure("unexpected-failure");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function branchPreparationFailed(request) {
|
|
26
|
+
logBranchPreparationFailure();
|
|
27
|
+
return redirect(request, "/login?error=branch_prepare_failed");
|
|
28
|
+
}
|
|
29
|
+
export function createAuthRoutes(options) {
|
|
30
|
+
async function login(request) {
|
|
31
|
+
if (options.production)
|
|
32
|
+
return notFound();
|
|
33
|
+
let user;
|
|
34
|
+
try {
|
|
35
|
+
user = await options.githubCli.getUser();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof GitHubCliError &&
|
|
39
|
+
error.reason === "unauthenticated") {
|
|
40
|
+
try {
|
|
41
|
+
const webLogin = await options.githubCli.startWebLogin();
|
|
42
|
+
const loginUrl = new URL("/login", request.url);
|
|
43
|
+
loginUrl.searchParams.set("auth", "started");
|
|
44
|
+
if (webLogin.code)
|
|
45
|
+
loginUrl.searchParams.set("code", webLogin.code);
|
|
46
|
+
return NextResponse.redirect(loginUrl);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
logLoginFailure("device login could not be started");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
logLoginFailure("the configured GitHub CLI request failed");
|
|
53
|
+
return redirect(request, "/login?error=gh_cli_failed");
|
|
54
|
+
}
|
|
55
|
+
const preparation = await prepareIdentity(options, user);
|
|
56
|
+
if (!preparation.ok)
|
|
57
|
+
return branchPreparationFailed(request);
|
|
58
|
+
try {
|
|
59
|
+
await options.createSession(user);
|
|
60
|
+
return redirect(request, "/");
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
logLoginFailure("the configured GitHub CLI request failed");
|
|
64
|
+
return redirect(request, "/login?error=gh_cli_failed");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function status() {
|
|
68
|
+
const response = options.production
|
|
69
|
+
? notFound()
|
|
70
|
+
: await (async () => {
|
|
71
|
+
let user;
|
|
72
|
+
try {
|
|
73
|
+
user = await options.githubCli.getUser();
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return NextResponse.json({ authenticated: false });
|
|
77
|
+
}
|
|
78
|
+
const preparation = await prepareIdentity(options, user);
|
|
79
|
+
if (!preparation.ok) {
|
|
80
|
+
logBranchPreparationFailure();
|
|
81
|
+
return NextResponse.json({
|
|
82
|
+
authenticated: false,
|
|
83
|
+
error: "branch_prepare_failed",
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await options.createSession(user);
|
|
88
|
+
return NextResponse.json({ authenticated: true });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return NextResponse.json({ authenticated: false });
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
response.headers.set("Cache-Control", "no-store");
|
|
95
|
+
return response;
|
|
96
|
+
}
|
|
97
|
+
async function logout(request) {
|
|
98
|
+
await options.clearSession();
|
|
99
|
+
return redirect(request, options.production ? "/" : "/login", 303);
|
|
100
|
+
}
|
|
101
|
+
return { login, status, logout };
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=auth-routes.js.map
|
|
@@ -0,0 +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,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