@jant/core 1.0.1 → 1.2.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/bin/lib/site-snapshot.js +10 -0
- package/dist/{app-Gt7_skt6.js → app-CbOZ2Irh.js} +8704 -5180
- package/dist/client/.vite/manifest.json +125 -85
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-hWapNE40.js} +26 -26
- package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js} +1 -1
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +2 -0
- package/dist/client/_assets/chunks/preload-helper-Czpn1I53.js +1 -0
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +1 -0
- package/dist/client/_assets/chunks/{settings-paths-h6RjIe3C.js → settings-paths-BBVT8zKj.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-BuCPjSrB.js +1 -0
- package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
- package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
- package/dist/client/_assets/client-BO8GOFfT.js +354 -0
- package/dist/client/_assets/client-D8Rrsd73.css +2 -0
- package/dist/client/_assets/client-auth-CsUGM718.js +859 -0
- package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
- package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-CI9-eh-8.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-BnGPuqwc.js} +166 -166
- package/dist/client/_assets/client-share-0DICJjAc.css +1 -0
- package/dist/client/_assets/client-share-C59mOLJ1.js +149 -0
- package/dist/index.js +1 -1
- package/dist/node.js +3 -2
- package/package.json +2 -1
- package/src/app.tsx +9 -0
- package/src/client/components/compose-types.ts +1 -0
- package/src/client/components/jant-compose-dialog.ts +1 -0
- package/src/client/components/jant-compose-editor.ts +30 -0
- package/src/client/components/jant-compose-fullscreen.ts +1 -0
- package/src/client/components/jant-post-menu.ts +80 -13
- package/src/client/components/jant-share-dialog.ts +422 -0
- package/src/client/components/jant-share-menu.ts +188 -0
- package/src/client/compose-bridge.ts +61 -1
- package/src/client/feed-video-player.ts +6 -0
- package/src/client/lazy-entries.ts +21 -1
- package/src/client/post-menu-shared.ts +100 -0
- package/src/client/share-capture.ts +443 -0
- package/src/client/share-launch.ts +133 -0
- package/src/client/tiptap/bubble-menu.ts +25 -2
- package/src/client/tiptap/create-editor.ts +2 -0
- package/src/client/tiptap/extensions.ts +4 -0
- package/src/client/video-processor.ts +106 -52
- package/src/client/view-confirm.ts +108 -0
- package/src/client-share.ts +8 -0
- package/src/client.ts +2 -0
- package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
- package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
- package/src/db/migrations/meta/0035_snapshot.json +2877 -0
- package/src/db/migrations/meta/0036_snapshot.json +2924 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
- package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
- package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
- package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/_journal.json +14 -0
- package/src/db/pg/schema.ts +40 -0
- package/src/db/schema.ts +61 -0
- package/src/i18n/locales/public/en.po +5 -0
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +5 -0
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +5 -0
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +149 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +149 -0
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +149 -0
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/discover.ts +31 -0
- package/src/lib/env.ts +20 -0
- package/src/lib/github-app-state.ts +1 -1
- package/src/lib/github-app.ts +183 -1
- package/src/lib/markdown-manager.ts +129 -1
- package/src/lib/post-meta.ts +13 -3
- package/src/lib/referrer-aliases.ts +311 -0
- package/src/lib/render.tsx +10 -0
- package/src/lib/resolve-config.ts +14 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/summary.ts +152 -54
- package/src/lib/tiptap-render.ts +1 -0
- package/src/lib/upload.ts +21 -1
- package/src/lib/version.ts +2 -0
- package/src/lib/video-playback.ts +55 -0
- package/src/lib/view-buffer.ts +201 -0
- package/src/lib/view-counting.ts +539 -0
- package/src/lib/view-token.ts +177 -0
- package/src/lib/view.ts +13 -1
- package/src/middleware/view-counter.ts +140 -0
- package/src/node/runtime.ts +4 -0
- package/src/preset.css +31 -14
- package/src/routes/api/media.ts +21 -3
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/dash/settings.tsx +433 -168
- package/src/routes/pages/archive.tsx +1 -0
- package/src/routes/pages/collection.tsx +6 -0
- package/src/routes/pages/collections.tsx +1 -0
- package/src/routes/pages/featured.tsx +1 -0
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/page.tsx +3 -0
- package/src/routes/pages/partials.tsx +23 -0
- package/src/routes/pages/smart-collection.tsx +2 -0
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/view-confirm.ts +63 -0
- package/src/services/export-theme/assets/client-site.js +1 -1
- package/src/services/export-theme/styles/main.css +39 -21
- package/src/services/export.ts +2 -0
- package/src/services/index.ts +17 -0
- package/src/services/mcp.ts +31 -1
- package/src/services/media.ts +63 -0
- package/src/services/stats.ts +1130 -0
- package/src/style-share.css +16 -0
- package/src/styles/components-author.css +177 -0
- package/src/styles/components.css +25 -3
- package/src/styles/share.css +1103 -0
- package/src/styles/tokens.css +65 -30
- package/src/styles/ui.css +62 -13
- package/src/types/app-context.ts +9 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/config.ts +54 -0
- package/src/types/views.ts +6 -0
- package/src/ui/compose/ComposeDialog.tsx +6 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
- package/src/ui/dash/settings/StatsContent.tsx +855 -0
- package/src/ui/font-themes.ts +39 -6
- package/src/ui/layouts/BaseLayout.tsx +11 -2
- package/src/ui/layouts/SiteLayout.tsx +9 -3
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +31 -4
- package/src/ui/shared/PostFooter.tsx +20 -4
- package/src/ui/shared/icon-collector.ts +28 -0
- package/src/ui/shared/post-article-attributes.ts +3 -0
- package/dist/client/_assets/chunks/footnote-rail-BJwswtVQ.js +0 -1
- package/dist/client/_assets/chunks/lit-DW8VmJAT.js +0 -2
- package/dist/client/_assets/chunks/slug-format-Dsi0e9Xn.js +0 -1
- package/dist/client/_assets/chunks/sortable-list-DWNKv782.js +0 -2
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-DTZZEvLU.js +0 -2
- package/dist/client/_assets/client-BaqmpPQ-.css +0 -2
- package/dist/client/_assets/client-C6melOtG.js +0 -296
- package/dist/client/_assets/client-auth-Ccq8kSqq.js +0 -828
- package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
- package/dist/client/_assets/client-compose-oxzPb3SS.js +0 -2004
|
@@ -68,6 +68,18 @@ import {
|
|
|
68
68
|
getTelegramStatusStreamUrl,
|
|
69
69
|
} from "../../lib/telegram-settings-status.js";
|
|
70
70
|
import { TelegramContent } from "../../ui/dash/settings/TelegramContent.js";
|
|
71
|
+
import {
|
|
72
|
+
StatsContent,
|
|
73
|
+
statsPageName,
|
|
74
|
+
statsReferrerName,
|
|
75
|
+
} from "../../ui/dash/settings/StatsContent.js";
|
|
76
|
+
import {
|
|
77
|
+
DEFAULT_STATS_WINDOW,
|
|
78
|
+
STATS_WINDOWS,
|
|
79
|
+
type StatsWindow,
|
|
80
|
+
} from "../../services/stats.js";
|
|
81
|
+
import { formatDayKey, formatHourKey } from "../../lib/view-counting.js";
|
|
82
|
+
import { now } from "../../lib/time.js";
|
|
71
83
|
import { toAbsoluteSiteUrl, toPublicPath } from "../../lib/url.js";
|
|
72
84
|
import {
|
|
73
85
|
ContentLanguageSchema,
|
|
@@ -89,14 +101,21 @@ import {
|
|
|
89
101
|
getDiscoverPingUrl,
|
|
90
102
|
getGitHubAppConfig,
|
|
91
103
|
getHostedControlPlaneSsoSecret,
|
|
104
|
+
getSiteResolutionMode,
|
|
92
105
|
getTelegramBotPool,
|
|
106
|
+
type GitHubAppEnvConfig,
|
|
107
|
+
type GitHubAppOAuthConfig,
|
|
93
108
|
} from "../../lib/env.js";
|
|
94
109
|
import {
|
|
110
|
+
buildAuthorizeUrl,
|
|
95
111
|
buildInstallUrl,
|
|
112
|
+
createPkcePair,
|
|
96
113
|
getInstallation,
|
|
97
114
|
listInstallationReposPage,
|
|
115
|
+
listOwnedInstallations,
|
|
98
116
|
searchInstallationRepos,
|
|
99
117
|
type InstallationAccount,
|
|
118
|
+
type OwnedInstallation,
|
|
100
119
|
} from "../../lib/github-app.js";
|
|
101
120
|
import {
|
|
102
121
|
isSyncPending,
|
|
@@ -161,6 +180,18 @@ const UpdateDiscoverSettingsSchema = z.object({
|
|
|
161
180
|
discover: z.enum(["latest", "off"]),
|
|
162
181
|
});
|
|
163
182
|
|
|
183
|
+
const UpdateStatsSettingsSchema = z.object({
|
|
184
|
+
enabled: z.boolean(),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/** The stats window a `?days=` asks for, or the default for anything else. */
|
|
188
|
+
function parseStatsWindow(value: string | undefined): StatsWindow {
|
|
189
|
+
const days = Number(value);
|
|
190
|
+
return (STATS_WINDOWS as readonly number[]).includes(days)
|
|
191
|
+
? (days as StatsWindow)
|
|
192
|
+
: DEFAULT_STATS_WINDOW;
|
|
193
|
+
}
|
|
194
|
+
|
|
164
195
|
function publicPath(c: Context<Env>, path: string): string {
|
|
165
196
|
return toPublicPath(path, c.var.appConfig.sitePathPrefix);
|
|
166
197
|
}
|
|
@@ -230,7 +261,8 @@ function breadcrumbLabel(
|
|
|
230
261
|
| "deleteAccount"
|
|
231
262
|
| "apiTokens"
|
|
232
263
|
| "githubSync"
|
|
233
|
-
| "telegram"
|
|
264
|
+
| "telegram"
|
|
265
|
+
| "stats",
|
|
234
266
|
): string {
|
|
235
267
|
const i18n = getI18n(c);
|
|
236
268
|
switch (key) {
|
|
@@ -314,11 +346,20 @@ function breadcrumbLabel(
|
|
|
314
346
|
return i18n._(
|
|
315
347
|
msg({ message: "Telegram", comment: "@context: Breadcrumb label" }),
|
|
316
348
|
);
|
|
349
|
+
case "stats":
|
|
350
|
+
return i18n._(
|
|
351
|
+
msg({ message: "Stats", comment: "@context: Breadcrumb label" }),
|
|
352
|
+
);
|
|
317
353
|
}
|
|
318
354
|
}
|
|
319
355
|
|
|
320
356
|
type DemoRestriction =
|
|
321
|
-
|
|
357
|
+
| "sessions"
|
|
358
|
+
| "password"
|
|
359
|
+
| "accountDeletion"
|
|
360
|
+
| "customCss"
|
|
361
|
+
| "codeInjection"
|
|
362
|
+
| "stats";
|
|
322
363
|
|
|
323
364
|
function getDemoRestrictionMessage(
|
|
324
365
|
c: Context<Env>,
|
|
@@ -372,6 +413,15 @@ function getDemoRestrictionMessage(
|
|
|
372
413
|
"@context: Error shown when saving code injection is blocked in demo mode",
|
|
373
414
|
}),
|
|
374
415
|
);
|
|
416
|
+
case "stats":
|
|
417
|
+
return i18n._(
|
|
418
|
+
msg({
|
|
419
|
+
message:
|
|
420
|
+
"Stats settings are locked in demo mode. Every visitor shares the demo site.",
|
|
421
|
+
comment:
|
|
422
|
+
"@context: Error shown when changing the stats setting is blocked in demo mode",
|
|
423
|
+
}),
|
|
424
|
+
);
|
|
375
425
|
}
|
|
376
426
|
}
|
|
377
427
|
|
|
@@ -421,6 +471,112 @@ settingsRoutes.get("/", async (c) => {
|
|
|
421
471
|
});
|
|
422
472
|
});
|
|
423
473
|
|
|
474
|
+
// ===========================================================================
|
|
475
|
+
// Stats
|
|
476
|
+
// ===========================================================================
|
|
477
|
+
|
|
478
|
+
settingsRoutes.get("/stats", async (c) => {
|
|
479
|
+
const { appConfig, services } = c.var;
|
|
480
|
+
const enabled = appConfig.stats.enabled;
|
|
481
|
+
const days = parseStatsWindow(c.req.query("days"));
|
|
482
|
+
// One page, or else one referrer. The referrer key is the stored one, so
|
|
483
|
+
// an empty value is Direct and `/` Internal: present or absent is what
|
|
484
|
+
// matters, not truthy.
|
|
485
|
+
const pageKey = c.req.query("page") || undefined;
|
|
486
|
+
const referrerKey =
|
|
487
|
+
pageKey === undefined ? c.req.query("referrer") : undefined;
|
|
488
|
+
const at = now();
|
|
489
|
+
const window = {
|
|
490
|
+
days,
|
|
491
|
+
today: formatDayKey(at, appConfig.timeZone),
|
|
492
|
+
hour: formatHourKey(at, appConfig.timeZone),
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// The chrome needs nothing from the counts, so the reads go out together.
|
|
496
|
+
const [navData, page, referrer, overview] = await Promise.all([
|
|
497
|
+
getNavigationData(c),
|
|
498
|
+
enabled && pageKey !== undefined
|
|
499
|
+
? services.stats.getPage(pageKey, window)
|
|
500
|
+
: null,
|
|
501
|
+
enabled && referrerKey !== undefined
|
|
502
|
+
? services.stats.getReferrer(referrerKey, window)
|
|
503
|
+
: null,
|
|
504
|
+
enabled && pageKey === undefined && referrerKey === undefined
|
|
505
|
+
? services.stats.getOverview(window)
|
|
506
|
+
: null,
|
|
507
|
+
]);
|
|
508
|
+
if (pageKey !== undefined && !page) return c.notFound();
|
|
509
|
+
if (referrerKey !== undefined && !referrer) return c.notFound();
|
|
510
|
+
|
|
511
|
+
const statsLabel = breadcrumbLabel(c, "stats");
|
|
512
|
+
const content = (
|
|
513
|
+
<StatsContent
|
|
514
|
+
enabled={enabled}
|
|
515
|
+
days={days}
|
|
516
|
+
overview={overview}
|
|
517
|
+
page={page}
|
|
518
|
+
referrer={referrer}
|
|
519
|
+
sitePathPrefix={appConfig.sitePathPrefix}
|
|
520
|
+
demoMode={appConfig.demoMode}
|
|
521
|
+
/>
|
|
522
|
+
);
|
|
523
|
+
const detailName = page
|
|
524
|
+
? statsPageName(page.page, getI18n(c))
|
|
525
|
+
: referrer
|
|
526
|
+
? statsReferrerName(referrer.referrer, getI18n(c))
|
|
527
|
+
: null;
|
|
528
|
+
|
|
529
|
+
return renderPublicPage(c, {
|
|
530
|
+
page: "settings",
|
|
531
|
+
title: buildPageTitle(statsLabel, navData.siteName),
|
|
532
|
+
navData,
|
|
533
|
+
content:
|
|
534
|
+
detailName !== null ? (
|
|
535
|
+
<>
|
|
536
|
+
<AdminBreadcrumb
|
|
537
|
+
ancestors={[
|
|
538
|
+
{
|
|
539
|
+
label: breadcrumbLabel(c, "settings"),
|
|
540
|
+
href: publicPath(c, "/settings"),
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
label: statsLabel,
|
|
544
|
+
href: `${publicPath(c, "/settings/stats")}?days=${days}`,
|
|
545
|
+
},
|
|
546
|
+
]}
|
|
547
|
+
current={detailName}
|
|
548
|
+
/>
|
|
549
|
+
{content}
|
|
550
|
+
</>
|
|
551
|
+
) : (
|
|
552
|
+
<>
|
|
553
|
+
<AdminBreadcrumb
|
|
554
|
+
parent={breadcrumbLabel(c, "settings")}
|
|
555
|
+
parentHref={publicPath(c, "/settings")}
|
|
556
|
+
current={statsLabel}
|
|
557
|
+
/>
|
|
558
|
+
{content}
|
|
559
|
+
</>
|
|
560
|
+
),
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
settingsRoutes.post("/stats", async (c) => {
|
|
565
|
+
if (c.var.appConfig.demoMode) refuseInDemo(c, "stats");
|
|
566
|
+
const body = parseValidated(UpdateStatsSettingsSchema, await c.req.json());
|
|
567
|
+
await c.var.services.stats.setEnabled(body.enabled, {
|
|
568
|
+
today: formatDayKey(now(), c.var.appConfig.timeZone),
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// Either way the page changes shape — the chart appears, or it goes with
|
|
572
|
+
// the counts — so it is shown again rather than toasted at.
|
|
573
|
+
const wantsJson = c.req.header("accept")?.includes("application/json");
|
|
574
|
+
if (wantsJson) {
|
|
575
|
+
return c.json({ status: "ok" as const });
|
|
576
|
+
}
|
|
577
|
+
return dsRedirect(publicPath(c, "/settings/stats"));
|
|
578
|
+
});
|
|
579
|
+
|
|
424
580
|
// ===========================================================================
|
|
425
581
|
// General settings
|
|
426
582
|
// ===========================================================================
|
|
@@ -2146,15 +2302,18 @@ settingsRoutes.post("/github-sync/disconnect", async (c) => {
|
|
|
2146
2302
|
* Recreate installation bindings for sites that sync through the App
|
|
2147
2303
|
* but have no row to prove it.
|
|
2148
2304
|
*
|
|
2149
|
-
*
|
|
2150
|
-
*
|
|
2151
|
-
*
|
|
2152
|
-
*
|
|
2153
|
-
*
|
|
2305
|
+
* The ids come from the author's own sites' sync settings, which only
|
|
2306
|
+
* the connect route writes, and only for an installation the author
|
|
2307
|
+
* could already see — so trusting them proves nothing new. GitHub is the
|
|
2308
|
+
* only source for the account behind an id, so the repair costs one call
|
|
2309
|
+
* per distinct id, bounded by how many sites the author has, and only
|
|
2310
|
+
* runs when they would otherwise be sent round GitHub. Ids GitHub no
|
|
2311
|
+
* longer recognizes are skipped: an uninstalled App has nothing to
|
|
2312
|
+
* rebuild.
|
|
2154
2313
|
*/
|
|
2155
2314
|
async function rebuildInstallationBindings(
|
|
2156
2315
|
c: Context<Env>,
|
|
2157
|
-
app:
|
|
2316
|
+
app: GitHubAppEnvConfig,
|
|
2158
2317
|
userId: string,
|
|
2159
2318
|
): Promise<void> {
|
|
2160
2319
|
const syncing =
|
|
@@ -2185,11 +2344,123 @@ async function rebuildInstallationBindings(
|
|
|
2185
2344
|
}
|
|
2186
2345
|
}
|
|
2187
2346
|
|
|
2347
|
+
const GITHUB_STATE_COOKIE = "jant_gh_app_state";
|
|
2348
|
+
const GITHUB_PKCE_COOKIE = "jant_gh_app_verifier";
|
|
2349
|
+
/** Long enough for an install click-through, short enough to stop mattering. */
|
|
2350
|
+
const GITHUB_ROUND_TRIP_SECONDS = 600;
|
|
2351
|
+
const GITHUB_OAUTH_NOT_CONFIGURED =
|
|
2352
|
+
"Connecting a GitHub account needs the App's client credentials. Set GITHUB_APP_CLIENT_ID and GITHUB_APP_CLIENT_SECRET on this deployment.";
|
|
2353
|
+
|
|
2188
2354
|
/**
|
|
2189
|
-
*
|
|
2355
|
+
* Start one round trip to GitHub: mint the `state` it carries and pin it to
|
|
2356
|
+
* this browser in a cookie, which the callback compares byte-for-byte.
|
|
2190
2357
|
*
|
|
2191
|
-
*
|
|
2192
|
-
*
|
|
2358
|
+
* Behind a hosted control plane the state is signed with the shared SSO
|
|
2359
|
+
* secret, because the control plane receives GitHub's redirect and reads
|
|
2360
|
+
* the site to send the browser back to from it. Self-hosted, the App's
|
|
2361
|
+
* URLs point straight at this site and a plain nonce does.
|
|
2362
|
+
*
|
|
2363
|
+
* @param c - Request context; the cookie is set on its response.
|
|
2364
|
+
* @returns The state to hand to GitHub.
|
|
2365
|
+
*/
|
|
2366
|
+
async function startGitHubRoundTrip(c: Context<Env>): Promise<string> {
|
|
2367
|
+
const nonce = generateInstallNonce();
|
|
2368
|
+
const ssoSecret = getHostedControlPlaneSsoSecret(c.env);
|
|
2369
|
+
const host = new URL(c.var.appConfig.siteUrl).host;
|
|
2370
|
+
const state = ssoSecret
|
|
2371
|
+
? await signInstallState(host, nonce, ssoSecret)
|
|
2372
|
+
: nonce;
|
|
2373
|
+
setCookie(c, GITHUB_STATE_COOKIE, state, {
|
|
2374
|
+
httpOnly: true,
|
|
2375
|
+
sameSite: "Lax",
|
|
2376
|
+
path: "/",
|
|
2377
|
+
maxAge: GITHUB_ROUND_TRIP_SECONDS,
|
|
2378
|
+
});
|
|
2379
|
+
return state;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
/** Send the browser to GitHub to install the App on an account. */
|
|
2383
|
+
async function redirectToAppInstall(c: Context<Env>, app: GitHubAppEnvConfig) {
|
|
2384
|
+
const state = await startGitHubRoundTrip(c);
|
|
2385
|
+
return c.redirect(buildInstallUrl(app.slug, state));
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* Send the browser to GitHub to sign the author in, so the callback can
|
|
2390
|
+
* ask GitHub which installations they own. An author who has authorized
|
|
2391
|
+
* the App before passes straight through.
|
|
2392
|
+
*/
|
|
2393
|
+
async function redirectToGitHubSignIn(
|
|
2394
|
+
c: Context<Env>,
|
|
2395
|
+
oauth: GitHubAppOAuthConfig,
|
|
2396
|
+
) {
|
|
2397
|
+
const state = await startGitHubRoundTrip(c);
|
|
2398
|
+
const { verifier, challenge } = await createPkcePair();
|
|
2399
|
+
setCookie(c, GITHUB_PKCE_COOKIE, verifier, {
|
|
2400
|
+
httpOnly: true,
|
|
2401
|
+
sameSite: "Lax",
|
|
2402
|
+
path: "/",
|
|
2403
|
+
maxAge: GITHUB_ROUND_TRIP_SECONDS,
|
|
2404
|
+
});
|
|
2405
|
+
return c.redirect(buildAuthorizeUrl(oauth.clientId, state, challenge));
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
function endGitHubRoundTrip(c: Context<Env>): void {
|
|
2409
|
+
for (const name of [GITHUB_STATE_COOKIE, GITHUB_PKCE_COOKIE]) {
|
|
2410
|
+
setCookie(c, name, "", {
|
|
2411
|
+
httpOnly: true,
|
|
2412
|
+
sameSite: "Lax",
|
|
2413
|
+
path: "/",
|
|
2414
|
+
maxAge: 0,
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* Render the repository picker, which loads the accounts the author can
|
|
2421
|
+
* see and the repositories behind each.
|
|
2422
|
+
*/
|
|
2423
|
+
async function renderRepoPickerPage(c: Context<Env>) {
|
|
2424
|
+
const navData = await getNavigationData(c);
|
|
2425
|
+
const base = publicPath(c, "/settings/github-sync");
|
|
2426
|
+
const suggestedRepoName = suggestSyncRepoName(c.var.appConfig.siteUrl);
|
|
2427
|
+
const labels = buildRepoPickerLabels(c, suggestedRepoName);
|
|
2428
|
+
return renderPublicPage(c, {
|
|
2429
|
+
page: "settings",
|
|
2430
|
+
title: buildPageTitle("GitHub Sync — Pick Repository", navData.siteName),
|
|
2431
|
+
navData,
|
|
2432
|
+
content: (
|
|
2433
|
+
<>
|
|
2434
|
+
<AdminBreadcrumb
|
|
2435
|
+
parent={breadcrumbLabel(c, "settings")}
|
|
2436
|
+
parentHref={publicPath(c, "/settings")}
|
|
2437
|
+
current={breadcrumbLabel(c, "githubSync")}
|
|
2438
|
+
/>
|
|
2439
|
+
<jant-repo-picker
|
|
2440
|
+
labels={labels}
|
|
2441
|
+
api-base={`${base}/app`}
|
|
2442
|
+
connect-url={`${base}/app/connect`}
|
|
2443
|
+
install-url={`${base}/app/install?force=new`}
|
|
2444
|
+
cancel-url={publicPath(c, "/settings")}
|
|
2445
|
+
create-repo-name-hint={suggestedRepoName}
|
|
2446
|
+
>
|
|
2447
|
+
{/* SSR fallback while the Lit component upgrades. */}
|
|
2448
|
+
<div class="flex flex-col gap-6 max-w-lg">
|
|
2449
|
+
<div>
|
|
2450
|
+
<h2 class="text-lg font-medium mb-1">Pick a repository</h2>
|
|
2451
|
+
<p class="text-sm text-muted-foreground">Loading repositories…</p>
|
|
2452
|
+
</div>
|
|
2453
|
+
</div>
|
|
2454
|
+
</jant-repo-picker>
|
|
2455
|
+
</>
|
|
2456
|
+
),
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
/**
|
|
2461
|
+
* Start connecting GitHub Sync through the App.
|
|
2462
|
+
*
|
|
2463
|
+
* Only available when GitHub App env vars are configured.
|
|
2193
2464
|
*/
|
|
2194
2465
|
settingsRoutes.get("/github-sync/app/install", async (c) => {
|
|
2195
2466
|
const app = getGitHubAppConfig(c.env);
|
|
@@ -2197,22 +2468,14 @@ settingsRoutes.get("/github-sync/app/install", async (c) => {
|
|
|
2197
2468
|
return c.text("GitHub App is not configured on this deployment.", 404);
|
|
2198
2469
|
}
|
|
2199
2470
|
|
|
2200
|
-
//
|
|
2201
|
-
//
|
|
2202
|
-
//
|
|
2203
|
-
//
|
|
2204
|
-
//
|
|
2205
|
-
// and never comes back with installation_id.
|
|
2471
|
+
// An author who already authorized an account — on this site or on any
|
|
2472
|
+
// other site they belong to — goes straight to the picker. A GitHub App
|
|
2473
|
+
// installs once per GitHub account, so their second blog has no binding
|
|
2474
|
+
// of its own and GitHub will not create one: its install page shows the
|
|
2475
|
+
// existing installation's Configure page and never comes back.
|
|
2206
2476
|
//
|
|
2207
|
-
//
|
|
2208
|
-
//
|
|
2209
|
-
// second blog to the same account has no binding here yet and cannot
|
|
2210
|
-
// create one through GitHub, so site-scoping this check would leave
|
|
2211
|
-
// them with no way in at all.
|
|
2212
|
-
//
|
|
2213
|
-
// `?force=new` bypasses the predicate so the picker's "Install on
|
|
2214
|
-
// another account" action can still reach GitHub to add a fresh
|
|
2215
|
-
// install.
|
|
2477
|
+
// `?force=new` bypasses this so the picker's "Install on another
|
|
2478
|
+
// account" action can still reach GitHub to add a fresh install.
|
|
2216
2479
|
const forceNew = c.req.query("force") === "new";
|
|
2217
2480
|
if (!forceNew) {
|
|
2218
2481
|
const userId = requireSessionUserId(c);
|
|
@@ -2221,10 +2484,8 @@ settingsRoutes.get("/github-sync/app/install", async (c) => {
|
|
|
2221
2484
|
userId,
|
|
2222
2485
|
);
|
|
2223
2486
|
// An author with nothing to show but a site already syncing through
|
|
2224
|
-
// the App
|
|
2225
|
-
//
|
|
2226
|
-
// the binding from the sync settings instead of sending them into
|
|
2227
|
-
// the dead end.
|
|
2487
|
+
// the App lost a binding along the way. Rebuild it from the sync
|
|
2488
|
+
// settings rather than sending them round GitHub for it.
|
|
2228
2489
|
if (existing.length === 0) {
|
|
2229
2490
|
await rebuildInstallationBindings(c, app, userId);
|
|
2230
2491
|
existing =
|
|
@@ -2232,100 +2493,61 @@ settingsRoutes.get("/github-sync/app/install", async (c) => {
|
|
|
2232
2493
|
userId,
|
|
2233
2494
|
);
|
|
2234
2495
|
}
|
|
2235
|
-
if (existing.length > 0)
|
|
2236
|
-
const navData = await getNavigationData(c);
|
|
2237
|
-
const base = publicPath(c, "/settings/github-sync");
|
|
2238
|
-
const suggestedRepoName = suggestSyncRepoName(c.var.appConfig.siteUrl);
|
|
2239
|
-
const labels = buildRepoPickerLabels(c, suggestedRepoName);
|
|
2240
|
-
return renderPublicPage(c, {
|
|
2241
|
-
page: "settings",
|
|
2242
|
-
title: buildPageTitle(
|
|
2243
|
-
"GitHub Sync — Pick Repository",
|
|
2244
|
-
navData.siteName,
|
|
2245
|
-
),
|
|
2246
|
-
navData,
|
|
2247
|
-
content: (
|
|
2248
|
-
<>
|
|
2249
|
-
<AdminBreadcrumb
|
|
2250
|
-
parent={breadcrumbLabel(c, "settings")}
|
|
2251
|
-
parentHref={publicPath(c, "/settings")}
|
|
2252
|
-
current={breadcrumbLabel(c, "githubSync")}
|
|
2253
|
-
/>
|
|
2254
|
-
<jant-repo-picker
|
|
2255
|
-
labels={labels}
|
|
2256
|
-
api-base={`${base}/app`}
|
|
2257
|
-
connect-url={`${base}/app/connect`}
|
|
2258
|
-
install-url={`${base}/app/install?force=new`}
|
|
2259
|
-
cancel-url={publicPath(c, "/settings")}
|
|
2260
|
-
create-repo-name-hint={suggestedRepoName}
|
|
2261
|
-
>
|
|
2262
|
-
<div class="flex flex-col gap-6 max-w-lg">
|
|
2263
|
-
<div>
|
|
2264
|
-
<h2 class="text-lg font-medium mb-1">Pick a repository</h2>
|
|
2265
|
-
<p class="text-sm text-muted-foreground">
|
|
2266
|
-
Loading repositories…
|
|
2267
|
-
</p>
|
|
2268
|
-
</div>
|
|
2269
|
-
</div>
|
|
2270
|
-
</jant-repo-picker>
|
|
2271
|
-
</>
|
|
2272
|
-
),
|
|
2273
|
-
});
|
|
2274
|
-
}
|
|
2496
|
+
if (existing.length > 0) return renderRepoPickerPage(c);
|
|
2275
2497
|
}
|
|
2276
2498
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
setCookie(c, "jant_gh_app_state", state, {
|
|
2292
|
-
httpOnly: true,
|
|
2293
|
-
sameSite: "Lax",
|
|
2294
|
-
path: "/",
|
|
2295
|
-
maxAge: 600,
|
|
2296
|
-
});
|
|
2297
|
-
|
|
2298
|
-
return c.redirect(buildInstallUrl(app.slug, state));
|
|
2499
|
+
if (app.oauth) {
|
|
2500
|
+
// With nothing to show yet, ask GitHub what the author owns before
|
|
2501
|
+
// offering to install: the App may already be on their account, put
|
|
2502
|
+
// there through another Jant account, and the install page is a dead
|
|
2503
|
+
// end for that account. The callback moves on to the install page when
|
|
2504
|
+
// GitHub lists nothing.
|
|
2505
|
+
return forceNew
|
|
2506
|
+
? redirectToAppInstall(c, app)
|
|
2507
|
+
: redirectToGitHubSignIn(c, app.oauth);
|
|
2508
|
+
}
|
|
2509
|
+
if (!mayBindWithoutSignIn(c.env)) {
|
|
2510
|
+
return c.text(GITHUB_OAUTH_NOT_CONFIGURED, 500);
|
|
2511
|
+
}
|
|
2512
|
+
return redirectToAppInstall(c, app);
|
|
2299
2513
|
});
|
|
2300
2514
|
|
|
2301
2515
|
/**
|
|
2302
|
-
*
|
|
2516
|
+
* Whether the callback may bind the installation the install page names
|
|
2517
|
+
* without asking GitHub who installed it. Only an App without client
|
|
2518
|
+
* credentials needs this.
|
|
2303
2519
|
*
|
|
2304
|
-
* GitHub
|
|
2305
|
-
*
|
|
2306
|
-
*
|
|
2520
|
+
* GitHub warns that the id can be forged: it rides in a URL anyone can
|
|
2521
|
+
* type. On a single-site deployment that buys nothing. Its one account
|
|
2522
|
+
* belongs to whoever runs the deployment, who holds the App's private key
|
|
2523
|
+
* and can already act on every installation of the App. A host-based
|
|
2524
|
+
* deployment serves many authors, and a forged id would let one of them
|
|
2525
|
+
* take over another's installation.
|
|
2307
2526
|
*/
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
return c.text("GitHub App is not configured on this deployment.", 404);
|
|
2312
|
-
}
|
|
2527
|
+
function mayBindWithoutSignIn(env: Bindings): boolean {
|
|
2528
|
+
return getSiteResolutionMode(env) === "single-site";
|
|
2529
|
+
}
|
|
2313
2530
|
|
|
2314
|
-
|
|
2531
|
+
/**
|
|
2532
|
+
* Check that the callback carries the `state` this browser's round trip
|
|
2533
|
+
* started with.
|
|
2534
|
+
*
|
|
2535
|
+
* The cookie stops a forged callback from binding the attacker's GitHub
|
|
2536
|
+
* account to this author's site, where their posts would then be pushed.
|
|
2537
|
+
* Behind a control plane the state must also verify and name this host,
|
|
2538
|
+
* which stops a rogue control plane from sending a replayed token to
|
|
2539
|
+
* another site.
|
|
2540
|
+
*
|
|
2541
|
+
* @param c - Request context carrying the callback query and cookies.
|
|
2542
|
+
* @returns The response to stop with, or `null` when the state is good.
|
|
2543
|
+
*/
|
|
2544
|
+
async function rejectRoundTripState(c: Context<Env>): Promise<Response | null> {
|
|
2315
2545
|
const state = c.req.query("state");
|
|
2316
|
-
|
|
2317
|
-
return c.text("Missing installation_id.", 400);
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
const expected = getCookie(c, "jant_gh_app_state");
|
|
2546
|
+
const expected = getCookie(c, GITHUB_STATE_COOKIE);
|
|
2321
2547
|
if (!state || !expected || expected !== state) {
|
|
2322
2548
|
return c.text("Invalid or expired state.", 400);
|
|
2323
2549
|
}
|
|
2324
2550
|
|
|
2325
|
-
// Defense in depth: when an SSO secret is present the state should also
|
|
2326
|
-
// HMAC-verify and its embedded host must match the host serving this
|
|
2327
|
-
// request. This blocks a rogue control plane from redirecting a victim
|
|
2328
|
-
// to the wrong site with a replayed token.
|
|
2329
2551
|
const ssoSecret = getHostedControlPlaneSsoSecret(c.env);
|
|
2330
2552
|
if (ssoSecret) {
|
|
2331
2553
|
const payload = await verifyInstallState(state, ssoSecret);
|
|
@@ -2334,18 +2556,102 @@ settingsRoutes.get("/github-sync/app/callback", async (c) => {
|
|
|
2334
2556
|
return c.text("State signature invalid for this host.", 400);
|
|
2335
2557
|
}
|
|
2336
2558
|
}
|
|
2559
|
+
return null;
|
|
2560
|
+
}
|
|
2337
2561
|
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2562
|
+
/**
|
|
2563
|
+
* Where GitHub sends the browser back, from either kind of trip.
|
|
2564
|
+
*
|
|
2565
|
+
* With the App's client credentials set, the installation id the install
|
|
2566
|
+
* page (the App's Setup URL) sends back is never read, since anyone can
|
|
2567
|
+
* type it into this URL. The author signs in with GitHub instead, and only
|
|
2568
|
+
* the installations GitHub says they own are bound. Without credentials, a
|
|
2569
|
+
* single-site deployment binds the id the install page sent, after GitHub
|
|
2570
|
+
* confirms the App has that installation.
|
|
2571
|
+
*/
|
|
2572
|
+
settingsRoutes.get("/github-sync/app/callback", async (c) => {
|
|
2573
|
+
const app = getGitHubAppConfig(c.env);
|
|
2574
|
+
if (!app) {
|
|
2575
|
+
return c.text("GitHub App is not configured on this deployment.", 404);
|
|
2576
|
+
}
|
|
2577
|
+
if (app.oauth) return completeGitHubSignIn(c, app, app.oauth);
|
|
2578
|
+
if (mayBindWithoutSignIn(c.env)) return completeAppInstall(c, app);
|
|
2579
|
+
return c.text(GITHUB_OAUTH_NOT_CONFIGURED, 500);
|
|
2580
|
+
});
|
|
2581
|
+
|
|
2582
|
+
/**
|
|
2583
|
+
* Finish a round trip through GitHub sign-in.
|
|
2584
|
+
*
|
|
2585
|
+
* From the install page it arrives with `installation_id` and no `code`,
|
|
2586
|
+
* and the author is sent on to sign in. From sign-in (the App's redirect
|
|
2587
|
+
* URI) it arrives with `code` and our `state`. The code buys a user token,
|
|
2588
|
+
* the token answers which installations this person owns, and those alone
|
|
2589
|
+
* are bound to this site.
|
|
2590
|
+
*/
|
|
2591
|
+
async function completeGitHubSignIn(
|
|
2592
|
+
c: Context<Env>,
|
|
2593
|
+
app: GitHubAppEnvConfig,
|
|
2594
|
+
oauth: GitHubAppOAuthConfig,
|
|
2595
|
+
) {
|
|
2596
|
+
// Sign-in turned down on GitHub's side. Sending the browser back to
|
|
2597
|
+
// sign-in would only show the same prompt again.
|
|
2598
|
+
if (c.req.query("error")) {
|
|
2599
|
+
endGitHubRoundTrip(c);
|
|
2600
|
+
return c.text(
|
|
2601
|
+
"GitHub sign-in was declined, so no account was connected. Start again from GitHub Sync settings to connect one.",
|
|
2602
|
+
400,
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
const code = c.req.query("code");
|
|
2607
|
+
if (!code) return redirectToGitHubSignIn(c, oauth);
|
|
2608
|
+
|
|
2609
|
+
const rejected = await rejectRoundTripState(c);
|
|
2610
|
+
if (rejected) return rejected;
|
|
2611
|
+
const verifier = getCookie(c, GITHUB_PKCE_COOKIE);
|
|
2612
|
+
if (!verifier) return c.text("Invalid or expired state.", 400);
|
|
2613
|
+
|
|
2614
|
+
let owned: OwnedInstallation[];
|
|
2615
|
+
try {
|
|
2616
|
+
owned = await listOwnedInstallations(oauth, code, verifier);
|
|
2617
|
+
} catch {
|
|
2618
|
+
return c.text(
|
|
2619
|
+
"GitHub did not confirm which accounts you own. Start again from GitHub Sync settings.",
|
|
2620
|
+
502,
|
|
2621
|
+
);
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// Nothing installed on an account this person owns: the install page is
|
|
2625
|
+
// the way on, and it comes back here once the App is installed. This
|
|
2626
|
+
// replaces the state cookie with the install trip's own.
|
|
2627
|
+
if (owned.length === 0) return redirectToAppInstall(c, app);
|
|
2628
|
+
|
|
2629
|
+
endGitHubRoundTrip(c);
|
|
2630
|
+
for (const { installationId, account } of owned) {
|
|
2631
|
+
await c.var.services.githubAppInstallations.upsertInstallation(
|
|
2632
|
+
installationId,
|
|
2633
|
+
c.var.currentSite.id,
|
|
2634
|
+
account,
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
return renderRepoPickerPage(c);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
/**
|
|
2641
|
+
* Finish an install trip on a deployment that may bind the installation
|
|
2642
|
+
* GitHub names (see `mayBindWithoutSignIn`).
|
|
2643
|
+
*/
|
|
2644
|
+
async function completeAppInstall(c: Context<Env>, app: GitHubAppEnvConfig) {
|
|
2645
|
+
const installationId = c.req.query("installation_id");
|
|
2646
|
+
if (!installationId) return c.text("Missing installation_id.", 400);
|
|
2647
|
+
|
|
2648
|
+
const rejected = await rejectRoundTripState(c);
|
|
2649
|
+
if (rejected) return rejected;
|
|
2650
|
+
|
|
2651
|
+
// The binding is what every later step reads, so the round trip ends
|
|
2652
|
+
// only once it is written: GitHub won't send a second callback for an
|
|
2653
|
+
// App that is now installed, and until then reloading this URL is the
|
|
2654
|
+
// retry.
|
|
2349
2655
|
try {
|
|
2350
2656
|
const installation = await getInstallation(app, installationId);
|
|
2351
2657
|
await c.var.services.githubAppInstallations.upsertInstallation(
|
|
@@ -2360,50 +2666,9 @@ settingsRoutes.get("/github-sync/app/callback", async (c) => {
|
|
|
2360
2666
|
);
|
|
2361
2667
|
}
|
|
2362
2668
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
sameSite: "Lax",
|
|
2367
|
-
path: "/",
|
|
2368
|
-
maxAge: 0,
|
|
2369
|
-
});
|
|
2370
|
-
|
|
2371
|
-
const navData = await getNavigationData(c);
|
|
2372
|
-
const base = publicPath(c, "/settings/github-sync");
|
|
2373
|
-
const suggestedRepoName = suggestSyncRepoName(c.var.appConfig.siteUrl);
|
|
2374
|
-
const labels = buildRepoPickerLabels(c, suggestedRepoName);
|
|
2375
|
-
|
|
2376
|
-
return renderPublicPage(c, {
|
|
2377
|
-
page: "settings",
|
|
2378
|
-
title: buildPageTitle("GitHub Sync — Pick Repository", navData.siteName),
|
|
2379
|
-
navData,
|
|
2380
|
-
content: (
|
|
2381
|
-
<>
|
|
2382
|
-
<AdminBreadcrumb
|
|
2383
|
-
parent={breadcrumbLabel(c, "settings")}
|
|
2384
|
-
parentHref={publicPath(c, "/settings")}
|
|
2385
|
-
current={breadcrumbLabel(c, "githubSync")}
|
|
2386
|
-
/>
|
|
2387
|
-
<jant-repo-picker
|
|
2388
|
-
labels={labels}
|
|
2389
|
-
api-base={`${base}/app`}
|
|
2390
|
-
connect-url={`${base}/app/connect`}
|
|
2391
|
-
install-url={`${base}/app/install?force=new`}
|
|
2392
|
-
cancel-url={publicPath(c, "/settings")}
|
|
2393
|
-
create-repo-name-hint={suggestedRepoName}
|
|
2394
|
-
>
|
|
2395
|
-
{/* SSR fallback while the Lit component upgrades. */}
|
|
2396
|
-
<div class="flex flex-col gap-6 max-w-lg">
|
|
2397
|
-
<div>
|
|
2398
|
-
<h2 class="text-lg font-medium mb-1">Pick a repository</h2>
|
|
2399
|
-
<p class="text-sm text-muted-foreground">Loading repositories…</p>
|
|
2400
|
-
</div>
|
|
2401
|
-
</div>
|
|
2402
|
-
</jant-repo-picker>
|
|
2403
|
-
</>
|
|
2404
|
-
),
|
|
2405
|
-
});
|
|
2406
|
-
});
|
|
2669
|
+
endGitHubRoundTrip(c);
|
|
2670
|
+
return renderRepoPickerPage(c);
|
|
2671
|
+
}
|
|
2407
2672
|
|
|
2408
2673
|
/**
|
|
2409
2674
|
* Values that keep a placeholder literal for the client to fill in.
|
|
@@ -2828,7 +3093,7 @@ settingsRoutes.post("/github-sync/app/connect", async (c) => {
|
|
|
2828
3093
|
* Helper: load the GitHub App config or short-circuit with a 404 JSON error.
|
|
2829
3094
|
*/
|
|
2830
3095
|
type RequireAppResult =
|
|
2831
|
-
| { app:
|
|
3096
|
+
| { app: GitHubAppEnvConfig; response: null }
|
|
2832
3097
|
| { app: null; response: Response };
|
|
2833
3098
|
|
|
2834
3099
|
function requireGitHubApp(c: Context<Env>): RequireAppResult {
|
|
@@ -2851,7 +3116,7 @@ function requireGitHubApp(c: Context<Env>): RequireAppResult {
|
|
|
2851
3116
|
* top-level imports (the module already lazy-imports github-api).
|
|
2852
3117
|
*/
|
|
2853
3118
|
async function getInstallationTokenFromApp(
|
|
2854
|
-
app:
|
|
3119
|
+
app: GitHubAppEnvConfig,
|
|
2855
3120
|
installationId: string,
|
|
2856
3121
|
): Promise<string> {
|
|
2857
3122
|
const { getInstallationToken } = await import("../../lib/github-app.js");
|