ref0-git 0.9.0 → 0.11.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.
@@ -5968,6 +5968,10 @@ export interface operations {
5968
5968
  query: {
5969
5969
  ref: string;
5970
5970
  path?: string;
5971
+ authors?: string[];
5972
+ committers?: string[];
5973
+ since?: string | ("Infinity" | "-Infinity" | "NaN");
5974
+ until?: string | ("Infinity" | "-Infinity" | "NaN");
5971
5975
  after?: string;
5972
5976
  limit?: string;
5973
5977
  objects?: string;
@@ -337,7 +337,14 @@ const mayChange = async (
337
337
  return allowed.includes('repo.update');
338
338
  };
339
339
 
340
- /** Whose avatar `change` is for, once `mayChange` lets its changer make it. Else the refusal. */
340
+ /** The account or repo at `place` as `changer` reads it, or `undefined`. */
341
+ const targetFor = (context: AvatarContext, changer: Changer, place: AvatarPlace) =>
342
+ readTarget(context, changer.origin, changer.admin ? undefined : changer.token, place);
343
+
344
+ /**
345
+ * Whose avatar `change` is for, and who makes it, once `mayChange` lets its changer make it. Else
346
+ * the refusal.
347
+ */
341
348
  const changeable = async (
342
349
  context: AvatarContext,
343
350
  request: Request,
@@ -347,14 +354,13 @@ const changeable = async (
347
354
  const changer = await changerOf(context, request);
348
355
  if (changer instanceof Response) return changer;
349
356
 
350
- const token = changer.admin ? undefined : changer.token;
351
- const target = await readTarget(context, changer.origin, token, place);
357
+ const target = await targetFor(context, changer, place);
352
358
  if (target === undefined) return notFound();
353
359
 
354
360
  if (!(await mayChange(context, request, changer, change, place, target)))
355
361
  return refused(403, changer.admin ? adminRefusal : changers[target.kind]);
356
362
 
357
- return target;
363
+ return { changer, target };
358
364
  };
359
365
 
360
366
  /** Why the instance admin's upload is refused: their token only removes. */
@@ -365,7 +371,8 @@ export const adminRefusal = "The instance admin removes a picture but doesn't up
365
371
  * A body that names more than 1 MB is refused before it's read, and one that sends more is refused
366
372
  * once the count passes it (413). Bytes that aren't PNG, JPEG or WebP by their signature, or whose
367
373
  * header can't be read, are refused whatever their Content-Type says (415), and a picture over 1024
368
- * pixels a side is refused by its header (422).
374
+ * pixels a side is refused by its header (422). A repo its uploader no longer reads once the icon
375
+ * is written, deleted while its body came in, has the icon removed again and answers 404.
369
376
  */
370
377
  export const uploadAvatar = async (
371
378
  context: AvatarContext,
@@ -375,9 +382,10 @@ export const uploadAvatar = async (
375
382
  const length = Number(request.headers.get('content-length') ?? 0);
376
383
  if (!(length <= iconBytesMost)) return refused(413, iconTypeRefusal);
377
384
 
378
- const target = await changeable(context, request, place, 'upload');
379
- if (target instanceof Response) return target;
385
+ const allowed = await changeable(context, request, place, 'upload');
386
+ if (allowed instanceof Response) return allowed;
380
387
 
388
+ const { changer, target } = allowed;
381
389
  const bytes = await bytesUpTo(request.body, iconBytesMost);
382
390
  if (bytes === undefined) return refused(413, iconTypeRefusal);
383
391
 
@@ -391,6 +399,15 @@ export const uploadAvatar = async (
391
399
  const hash = await hashOf(bytes);
392
400
  await context.avatars.put(target.kind, target.id, { type: sniffed.type, bytes, hash });
393
401
 
402
+ // A repo deleted while its body came in may have had its icon removed by `repo.deleted` before
403
+ // this write landed. Read after the write: a delete that committed first is seen here, and one
404
+ // that commits later removes this row on its own event (#2223).
405
+ if (target.kind === 'repo' && (await targetFor(context, changer, place))?.id !== target.id) {
406
+ await context.avatars.remove(target.kind, target.id);
407
+
408
+ return notFound();
409
+ }
410
+
394
411
  return Response.json({ hash }, { headers: { 'cache-control': 'no-store' } });
395
412
  };
396
413
 
@@ -403,10 +420,10 @@ export const removeAvatar = async (
403
420
  request: Request,
404
421
  place: AvatarPlace,
405
422
  ): Promise<Response> => {
406
- const target = await changeable(context, request, place, 'remove');
407
- if (target instanceof Response) return target;
423
+ const allowed = await changeable(context, request, place, 'remove');
424
+ if (allowed instanceof Response) return allowed;
408
425
 
409
- await context.avatars.remove(target.kind, target.id);
426
+ await context.avatars.remove(allowed.target.kind, allowed.target.id);
410
427
 
411
428
  return new Response(null, { status: 204 });
412
429
  };
@@ -1,7 +1,6 @@
1
1
  import { createServerFn } from '@tanstack/react-start';
2
2
  import { getRequest } from '@tanstack/react-start/server';
3
3
  import * as Effect from 'effect/Effect';
4
- import * as Option from 'effect/Option';
5
4
  import * as Schema from 'effect/Schema';
6
5
 
7
6
  import type { TokenRecord as GitTokenRecord, TokenTarget } from '@ref0/git';
@@ -70,13 +69,12 @@ export type HostAsk = typeof HostAsk.Type;
70
69
  export type HostOperation = HostAsk['operation'];
71
70
 
72
71
  /**
73
- * What `hostCallFor` asks with: the Worker's APIs, the session key, Git's `identify`, the repo
74
- * icons a repo's delete deletes, the person's orgs, and Git's direct lists an org's tokens are read
75
- * through.
72
+ * What `hostCallFor` asks with: the Worker's APIs, the session key, Git's `identify`, the
73
+ * person's orgs, and Git's direct lists an org's tokens are read through.
76
74
  */
77
75
  export type HostContext = Pick<
78
76
  AppContext,
79
- 'api' | 'sealKey' | 'identify' | 'session' | 'avatars' | 'accounts' | 'git'
77
+ 'api' | 'sealKey' | 'identify' | 'session' | 'accounts' | 'git'
80
78
  >;
81
79
 
82
80
  /** A token of the person's, as Git's REST lists it. */
@@ -182,8 +180,6 @@ const segment = encodeURIComponent;
182
180
  const repoPath = (owner: string, repo: string) =>
183
181
  `/api/v3/repos/${segment(owner)}/${segment(repo)}`;
184
182
 
185
- const repoId = Schema.decodeUnknownOption(Schema.Struct({ id: Schema.Number }));
186
-
187
183
  /** A token place's list as host code reads it, `rows` at most, and whether more followed. */
188
184
  const listed = async (tokens: TokenLists, target: TokenTarget, rows: number) => {
189
185
  const items: GitTokenRecord[] = [];
@@ -283,32 +279,15 @@ const repoWrite = (ask: HostAsk, login: string) => {
283
279
  path: repoPath(ask.owner, ask.repo),
284
280
  json: encodeRepoSettings(ask.settings),
285
281
  };
282
+
283
+ // Its icon goes on Git's `repo.deleted`, as one deleted through the API does (`repo-icons.ts`).
284
+ case 'repo.delete':
285
+ return { method: 'DELETE', path: repoPath(ask.owner, ask.repo) };
286
286
  default:
287
287
  return undefined;
288
288
  }
289
289
  };
290
290
 
291
- /**
292
- * The repo deleted as `login`, and its icon with it, by the repo's REST `id`, read first, since the
293
- * delete answers none. A repo deleted around the app, straight through the API, keeps its icon's row.
294
- */
295
- const deleteRepo = async (
296
- context: HostContext,
297
- origin: string,
298
- login: string,
299
- place: { readonly owner: string; readonly repo: string },
300
- ) => {
301
- const path = repoPath(place.owner, place.repo);
302
- const found = await callAs(context, origin, login, { method: 'GET', path });
303
- const repo = found.ok ? Option.getOrUndefined(repoId(await found.json())) : undefined;
304
- if (!found.ok) await found.body?.cancel();
305
-
306
- const deleted = await callAs(context, origin, login, { method: 'DELETE', path });
307
- if (deleted.ok && repo !== undefined) await context.avatars.remove('repo', String(repo.id));
308
-
309
- return deleted;
310
- };
311
-
312
291
  /**
313
292
  * `ask`, made as the session's person through the host's sign-in, or refused (Q520): only a POST
314
293
  * from the app's own origin, only for a session whose token Git still takes, so sign-out ends it.
@@ -340,8 +319,6 @@ export const hostCallFor = async (
340
319
  }
341
320
 
342
321
  const login = session.login;
343
- if (ask.operation === 'repo.delete') return deleteRepo(context, origin, login, ask);
344
-
345
322
  const write = repoWrite(ask, login);
346
323
  if (write !== undefined) return callAs(context, origin, login, write);
347
324
 
@@ -0,0 +1,39 @@
1
+ import { Git, GitEvents } from '@ref0/git';
2
+ import { repoNumber } from '@ref0/github';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Schema from 'effect/Schema';
5
+
6
+ import type { Avatars } from './context.ts';
7
+
8
+ /** A deleted repo's icon the store didn't remove, by the repo's REST `id`: the run is sent again. */
9
+ class RepoIconUnremoved extends Schema.TaggedError<RepoIconUnremoved>()('RepoIconUnremoved', {
10
+ repo: Schema.Number,
11
+ cause: Schema.Unknown,
12
+ }) {}
13
+
14
+ /**
15
+ * A deleted repo's icon removed from `avatars`, however the repo was deleted: through the app, the
16
+ * API or `gh`. Git's `repo.deleted` names the repo by its internal ID, and its icon is kept under
17
+ * the REST `id` that `repoNumber` gives it. A remove that fails fails the run, which Git tries
18
+ * again as its delivery's retry says; once those tries are spent, the job stays failed, and its
19
+ * cursor holds, until the host retries or discards it (#2223).
20
+ */
21
+ export const repoIcons = (avatars: Avatars) =>
22
+ Git.addDelivery(
23
+ 'repo-icons',
24
+ GitEvents.group((on) =>
25
+ on.handle('repo.deleted', ({ events }) =>
26
+ Effect.forEach(
27
+ events,
28
+ ({ internalId }) =>
29
+ Effect.flatMap(repoNumber(internalId), (id) =>
30
+ Effect.tryPromise({
31
+ try: () => avatars.remove('repo', String(id)),
32
+ catch: (cause) => new RepoIconUnremoved({ repo: id, cause }),
33
+ }),
34
+ ),
35
+ { discard: true },
36
+ ),
37
+ ),
38
+ ),
39
+ );
@@ -25,6 +25,7 @@ import type {
25
25
  PeopleFor,
26
26
  PeopleInput,
27
27
  PeopleMembers,
28
+ PeopleEmails,
28
29
  PeopleMembership,
29
30
  PeopleOrg,
30
31
  PeopleSearch,
@@ -82,6 +83,7 @@ const refusedLookup = (input: PeopleInput): PeopleAnswer => {
82
83
  case 'teams':
83
84
  case 'team-members':
84
85
  return { items: [] };
86
+ case 'emails':
85
87
  case 'membership':
86
88
  return [];
87
89
  case 'search':
@@ -599,6 +601,15 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
599
601
  return { ...found, name: person.name, ...picture } satisfies GitHubUser;
600
602
  });
601
603
 
604
+ // A login's commit addresses, the default's, for a person the app holds: none for a login
605
+ // with no account, as its user lookup answers none.
606
+ const emails = Effect.fnUntraced(function* (input: PeopleEmails) {
607
+ const person = yield* read(() => orgs.person(input.login));
608
+ if (person === undefined) return [];
609
+
610
+ return yield* base(input);
611
+ });
612
+
602
613
  const org = Effect.fnUntraced(function* (input: PeopleOrg) {
603
614
  return (yield* read(() => orgs.org(input.org))) ? yield* orgOf(input.org) : undefined;
604
615
  });
@@ -660,6 +671,8 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
660
671
  return search(input);
661
672
  case 'members':
662
673
  return members(input);
674
+ case 'emails':
675
+ return emails(input);
663
676
  case 'membership':
664
677
  return read(() => orgs.among(input.org, input.logins));
665
678
  case 'team-members':
@@ -680,6 +693,7 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
680
693
  input: PeopleMembers | PeopleTeamMembers,
681
694
  ): Effect.Effect<Listed<GitHubUser>, GitError>;
682
695
  function lookup(input: PeopleTeams): Effect.Effect<Listed<GitHubTeam>, GitError>;
696
+ function lookup(input: PeopleEmails): Effect.Effect<readonly string[], GitError>;
683
697
  function lookup(input: PeopleMembership): Effect.Effect<readonly string[], GitError>;
684
698
  function lookup(input: PeopleTeam): Effect.Effect<GitHubTeam | undefined, GitError>;
685
699
  function lookup(input: PeopleSearch): Effect.Effect<PeopleSearchAnswer, GitError>;
@@ -1,7 +1,7 @@
1
1
  import { choices, movesOf, platformOf, recovered, saysOf, settle, withDefaults } from "../init/choices.mjs";
2
2
  import { appOutput, checkedManifest, copied, entered } from "../init/app.mjs";
3
3
  import { nodeAppOutput, startOrigin } from "../init/node-app.mjs";
4
- import { configParts, gitClasses, gitSecrets } from "../init/cloudflare.mjs";
4
+ import { adminsVar, configParts, gitClasses, gitSecrets } from "../init/cloudflare.mjs";
5
5
  import { platforms } from "../init/template.mjs";
6
6
  import { pnpmManual, withPnpmOverrides, wroteOf } from "../init/files.mjs";
7
7
  import { keepsData, mainOrigin, nodeNeeds, routed, routedFindings } from "../init/node.mjs";
@@ -1486,8 +1486,29 @@ const setupCommands = [init, Command.make("doctor", {
1486
1486
  const served = platformOf(project.detected) === "node" && starter === void 0 && !routed(project.framework) && project.layout.kind !== "mount" ? project.held?.app === "ref0" ? startOrigin : mainOrigin : void 0;
1487
1487
  const signIn = served === void 0 ? "sign in to it with its admin token, <host> being where it's served" : "sign in to it with its admin token";
1488
1488
  const tokenFiles = secretFilesOf(withDefaults(project.held ?? {}, project.project));
1489
- const next = {
1490
- says: platformOf(project.detected) === "node" ? starter !== void 0 ? `Build it with \`${project.packageManager.value} run build\`, start it with ${starter.start(project.packageManager.value)}, ${signIn}, then push a scratch repo through it` : routed(project.framework) ? `Build it with \`${project.packageManager.value} run build\`, start it with ${routedStart(project.framework, project.packageManager.value)}, ${signIn}, then push a scratch repo through it` : project.layout.kind === "mount" ? `Start your server with \`node --env-file-if-exists=.env\`, which loads what src/git.ts reads, ${signIn}, then push a scratch repo through it` : `Start it with \`${project.packageManager.value} start\`, ${project.held?.app === "ref0" ? "sign up on it, setting APP_ORIGIN to where it's served first" : signIn}, then push a scratch repo through it` : vercel ? `Check Production has each variable with \`vercel env ls production\`, deploy it with Vercel's CLI or a Git import, ${signIn}, then push a scratch repo through it` : `${project.held?.app === "ref0" ? "Set APP_ORIGIN to where it's served, make AUTH_DB and its tables with `wrangler d1`, deploy" : "Deploy"} it with \`wrangler deploy\`, set ${secretsOf(withDefaults(project.held ?? {}, project.project)).join(" and ")} with \`wrangler secret put\`, ${signIn}, then push a scratch repo through it`,
1489
+ const bootstrapped = platformOf(project.detected) !== "node" && !vercel && project.held?.app !== "ref0";
1490
+ const next = bootstrapped ? {
1491
+ says: `Set ${adminsVar} in the Worker's vars to your login, deploy it with \`wrangler deploy\`, set ${secretsOf(withDefaults(project.held ?? {}, project.project)).join(" and ")} with \`wrangler secret put\`, sign in to it with that bootstrap secret, <host> being where it's served, and mint your admin token. Then sign in with yours, run \`doctor --verify\`, and delete ${gitSecrets.join(" and ")}`,
1492
+ run: [[
1493
+ "login",
1494
+ `<host>${base}`,
1495
+ "--with-token"
1496
+ ], [
1497
+ "tokens",
1498
+ "create",
1499
+ "--host",
1500
+ `<host>${base}`,
1501
+ "--prefix",
1502
+ "",
1503
+ "--scope",
1504
+ "admin",
1505
+ "--subject",
1506
+ "<your login>",
1507
+ "--show-token"
1508
+ ]],
1509
+ stdinFrom: "ADMIN_TOKEN"
1510
+ } : {
1511
+ says: platformOf(project.detected) === "node" ? starter !== void 0 ? `Build it with \`${project.packageManager.value} run build\`, start it with ${starter.start(project.packageManager.value)}, ${signIn}, then push a scratch repo through it` : routed(project.framework) ? `Build it with \`${project.packageManager.value} run build\`, start it with ${routedStart(project.framework, project.packageManager.value)}, ${signIn}, then push a scratch repo through it` : project.layout.kind === "mount" ? `Start your server with \`node --env-file-if-exists=.env\`, which loads what src/git.ts reads, ${signIn}, then push a scratch repo through it` : `Start it with \`${project.packageManager.value} start\`, ${project.held?.app === "ref0" ? "sign up on it, setting APP_ORIGIN to where it's served first" : signIn}, then push a scratch repo through it` : vercel ? `Check Production has each variable with \`vercel env ls production\`, deploy it with Vercel's CLI or a Git import, ${signIn}, then push a scratch repo through it` : `Set APP_ORIGIN to where it's served, make AUTH_DB and its tables with \`wrangler d1\`, deploy it with \`wrangler deploy\`, set ${secretsOf(withDefaults(project.held ?? {}, project.project)).join(" and ")} with \`wrangler secret put\`, ${signIn}, then push a scratch repo through it`,
1491
1512
  run: [[
1492
1513
  "login",
1493
1514
  `${served ?? "<host>"}${base}`,
@@ -1502,7 +1523,7 @@ const setupCommands = [init, Command.make("doctor", {
1502
1523
  });
1503
1524
  yield* receipt({
1504
1525
  done: "Ready to deploy",
1505
- fields: [["Admin token", `ADMIN_TOKEN, in ${tokenFiles.join(" or ")} locally, or the host's secret`]],
1526
+ fields: [bootstrapped ? ["Bootstrap", `ADMIN_TOKEN, in ${tokenFiles.join(" or ")} locally, or the host's secret, until an admin in ${adminsVar} signs in`] : ["Admin token", `ADMIN_TOKEN, in ${tokenFiles.join(" or ")} locally, or the host's secret`]],
1506
1527
  next
1507
1528
  });
1508
1529
  })).pipe(Command.withDescription("Check a folder's Git setup, or with --verify a host end to end (experimental)"))];
package/dist/init/app.mjs CHANGED
@@ -156,7 +156,7 @@ const dialectOn = {
156
156
  const nodeHead = (choices) => {
157
157
  const queue = choices.queue === "on";
158
158
  const dialect = dialectOn[choices.records];
159
- return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", "", "import { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';", "import { privateReposOf } from './private-repos.ts';", "import { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';", "import { avatars } from './signin/avatars.ts';", "import { clientIpHeader } from './signin/client-ip.ts';", "import { appAuth } from './signin/host-session.ts';", "import { orgsOver } from './signin/orgs.ts';", "import { sealKey } from './signin/seal.ts';", "", "/** What the app reads from `.env`, as the server's entry reads it here. */", "export { env };", "", storeLines(choices), bucketLines(choices), "", peopleOn[choices.records], "");
159
+ return lines(firstImports(choices, false), dialect !== false && `${dialect}\n`, gitImport(choices), queue && "import type { MergeInput, MergePlan } from '@ref0/git';", githubImport(choices), "import * as Languages from '@ref0/github/languages';", infraImports(choices), "import { xdiff } from '@ref0/xdiff-wasm/node';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", "", "import { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';", "import { repoIcons } from './context/repo-icons.ts';", `import { env${partsOf(choices).length > 0 ? ", need" : ""} } from './env.ts';`, "import { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';", "import { privateReposOf } from './private-repos.ts';", "import { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';", "import { avatars } from './signin/avatars.ts';", "import { clientIpHeader } from './signin/client-ip.ts';", "import { appAuth } from './signin/host-session.ts';", "import { orgsOver } from './signin/orgs.ts';", "import { sealKey } from './signin/seal.ts';", "", "/** What the app reads from `.env`, as the server's entry reads it here. */", "export { env };", "", storeLines(choices), bucketLines(choices), "", peopleOn[choices.records], "");
160
160
  };
161
161
  /** The app's `src/git.ts` on Node: `apps/github`'s own past its head, Node's head and parts in Cloudflare's place. */
162
162
  const nodeGit = (choices) => filled(templates.appGitNode, {
@@ -13,8 +13,10 @@ import * as Redacted from "effect/Redacted";
13
13
  */
14
14
  /** The files that hold secrets on Cloudflare: `.gitignore` ends with them, and `init` refuses one Git tracks. */
15
15
  const secretFiles = [".dev.vars"];
16
- /** The secrets Git's Worker takes: the admin's, which signs in to make repos and tokens. */
16
+ /** The secrets Git's Worker takes: the bootstrap's, which mints the first admin's token. */
17
17
  const gitSecrets = ["ADMIN_TOKEN"];
18
+ /** The var that names the Worker's admins, logins between commas: the person's to fill in. */
19
+ const adminsVar = "ADMINS";
18
20
  /** What an entry that falls through to its host's own `fetch` imports, to route Git's URLs first. */
19
21
  const fallThroughImports = lines("import { Git } from '@ref0/git';", "import * as Option from 'effect/Option';");
20
22
  /** Git's answer to `request` on the module's runtime, `undefined` for a URL no route of Git's owns. */
@@ -38,20 +40,22 @@ const gitModule = (choices, envFile, cpu) => {
38
40
  const packs = choices.objects === "packs";
39
41
  return filled(templates.workerGit, {
40
42
  header: `${header(choices, "Cloudflare")}\n`,
41
- gitImports: `${gitImports(choices)}\n`,
43
+ gitImports: `${gitImports(choices, true)}\n`,
42
44
  infraImport: unless(packs, looseInfraImport),
43
- effectImports: `${effectImports(choices)}\n`,
45
+ effectImports: `${effectImports(choices, true)}\n`,
44
46
  envFile: `'${envFile}'`,
45
47
  safety: unless(packs, "binds the objects"),
46
48
  bucket: unless(packs, looseAdapter),
47
49
  merge: unless(choices.queue === "on", ""),
48
50
  features: `${featuresLines(choices, {
51
+ admins: true,
49
52
  cpu,
50
53
  merges: "{ xdiff }",
51
54
  uploads: packs && uploads
52
55
  })}\n`,
53
56
  runtime: `${runtimeLines(choices, {
54
57
  token: "env.ADMIN_TOKEN",
58
+ bootstrap: true,
55
59
  adapter: "adapter"
56
60
  })}\n`
57
61
  });
@@ -102,7 +106,7 @@ const wranglerConfig = (choices, name) => {
102
106
  name: ` "name": ${jsonString(name)},`,
103
107
  limits: limitsLine,
104
108
  bucket: bucketLine(choices, name),
105
- vars: packs ? ` "vars": { "PACKS_BUCKET": "${bucketName(name)}" },\n` : ""
109
+ vars: packs ? ` "vars": { "PACKS_BUCKET": "${bucketName(name)}", "${adminsVar}": "" },\n` : ` "vars": { "${adminsVar}": "" },\n`
106
110
  });
107
111
  };
108
112
  /** The classes a config's migrations make, and how many migrations it has. */
@@ -186,6 +190,7 @@ const mergeWrangler = (text, choices, name, main) => {
186
190
  bucket_name: packsBucket
187
191
  }]), (from) => withEntries(from, ["vars"], { PACKS_BUCKET: packsBucket }));
188
192
  }
193
+ steps.push((from) => withEntries(from, ["vars"], { [adminsVar]: "" }));
189
194
  if (main !== void 0) steps.push((from) => withValue(from, ["main"], main));
190
195
  return steps.reduce((from, step) => step(from), text);
191
196
  };
@@ -241,6 +246,7 @@ const alchemyLines = (choices, _name) => [
241
246
  ...abortUploads,
242
247
  " }),"
243
248
  ] : [],
249
+ ` ${adminsVar}: "",`,
244
250
  " ADMIN_TOKEN: Config.Redacted(\"ADMIN_TOKEN\"),"
245
251
  ];
246
252
  /** The lines a `wrangler.toml` needs, since `init` writes no TOML. */
@@ -255,8 +261,9 @@ const tomlLines = (choices, name) => [
255
261
  "binding = \"PACKS\"",
256
262
  `bucket_name = "${bucketName(name)}"`,
257
263
  "[vars]",
258
- `PACKS_BUCKET = "${bucketName(name)}"`
259
- ] : [],
264
+ `PACKS_BUCKET = "${bucketName(name)}"`,
265
+ `${adminsVar} = ""`
266
+ ] : ["[vars]", `${adminsVar} = ""`],
260
267
  "[[migrations]]",
261
268
  "tag = \"git-v1\"",
262
269
  "new_sqlite_classes = [\"Records\", \"Jobs\"]"
@@ -361,9 +368,9 @@ const cloudflareOutput = (choices, project, secret, vendor) => {
361
368
  lines: entryLines(choices)
362
369
  }] : []],
363
370
  packages: gitPackages(choices),
364
- needs: [],
371
+ needs: [adminsVar],
365
372
  secret: "ADMIN_TOKEN, made for wrangler dev, in .dev.vars",
366
373
  next: "Check it, then deploy it"
367
374
  };
368
375
  };
369
- export { bucketLine, bucketName, cloudflareOutput, configCpu, configParts, devVars, gitClasses, gitModule, gitSecrets, limitsLine, looseAdapter, looseInfraImport, mergePackage, mergeWrangler, secretFiles };
376
+ export { adminsVar, bucketLine, bucketName, cloudflareOutput, configCpu, configParts, devVars, gitClasses, gitModule, gitSecrets, limitsLine, looseAdapter, looseInfraImport, mergePackage, mergeWrangler, secretFiles };
@@ -24,8 +24,11 @@ const gitDependencies = (choices, vendor) => [...gitPackages(choices).map((each)
24
24
  const repoHint = lines("// Nothing here makes a repo over HTTP: make one from code, as", "// `runtime.runPromise(Repos.create({ name: 'acme/app' }))`.");
25
25
  /** `src/git.ts`'s first lines: what it serves, on `on`, and whose file it is. */
26
26
  const header = (choices, on) => lines(`// Git on ${on}, ${served[choices.serve]}${choices.queue === "on" ? ", with a merge queue on `main`" : ""}. Written by`, "// `ref0-git init`, and yours to change: `init` rewrites it only while it reads as written, and", "// `ref0-git doctor` checks it.", choices.serve === "git" && repoHint);
27
- /** The `@ref0/git` names the composition uses, as chosen. */
28
- const gitNames = (choices) => [
27
+ /**
28
+ * The `@ref0/git` names the composition uses, as chosen, and with `admins` the bound on a login
29
+ * that a Worker checks its `ADMINS` against.
30
+ */
31
+ const gitNames = (choices, admins) => [
29
32
  choices.serve === "github" && "accept",
30
33
  "Auth",
31
34
  "Git",
@@ -35,7 +38,9 @@ const gitNames = (choices) => [
35
38
  "Objects",
36
39
  "Policy",
37
40
  choices.serve !== "git" && "Rest",
38
- "Tokens"
41
+ "Tokens",
42
+ admins && "maxActorIdLength",
43
+ choices.serve === "github" && admins && "reject"
39
44
  ].filter(Predicate.isString);
40
45
  /** The drop-in's names, under `--serve github`: Releases only beside a bucket. */
41
46
  const githubNames = (choices) => [
@@ -45,26 +50,27 @@ const githubNames = (choices) => [
45
50
  "GitHubPolicy",
46
51
  "Imports",
47
52
  "Inbox",
48
- "People",
49
53
  choices.objects === "packs" && "Releases",
50
54
  "Search",
51
55
  "Streams",
52
- "Webhooks",
53
- "defaultPeople"
56
+ "Webhooks"
54
57
  ].filter(Predicate.isString);
55
58
  /** An import of `names` from `from`, as the formatter writes it: on one line where it fits. */
56
59
  const namedImport = (names, from) => {
57
60
  const line = `import { ${names.join(", ")} } from '${from}';`;
58
61
  return line.length <= 100 ? line : `import {\n${names.map((name) => ` ${name},`).join("\n")}\n} from '${from}';`;
59
62
  };
60
- /** Git's imports, from `@ref0/git` to the drop-in. */
61
- const gitImports = (choices) => lines(namedImport(gitNames(choices), "@ref0/git"), choices.queue === "on" && "import type { MergeInput, MergePlan } from '@ref0/git';", choices.serve === "github" && lines("import { JoinedCalls } from '@ref0/git/extend';", namedImport(githubNames(choices), "@ref0/github"), "import * as Languages from '@ref0/github/languages';"));
62
- /** Effect's imports, which the composition is written in. */
63
- const effectImports = (choices) => lines(choices.serve === "github" && lines("import * as Effect from 'effect/Effect';", "import * as FetchHttpClient from 'effect/http/FetchHttpClient';"), "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", "import * as Redacted from 'effect/Redacted';");
63
+ /** Git's imports, from `@ref0/git` to the drop-in, with `admins` for a Worker's `ADMINS`. */
64
+ const gitImports = (choices, admins = false) => lines(namedImport(gitNames(choices, admins), "@ref0/git"), choices.queue === "on" && "import type { MergeInput, MergePlan } from '@ref0/git';", choices.serve === "github" && lines(namedImport(githubNames(choices), "@ref0/github"), "import * as Languages from '@ref0/github/languages';"));
65
+ /**
66
+ * Effect's imports, which the composition is written in, and with `admins` what a Worker's policy
67
+ * over its `ADMINS` reads the host's tokens with.
68
+ */
69
+ const effectImports = (choices, admins = false) => lines(admins && "import * as Context from 'effect/Context';", (admins || choices.serve === "github") && "import * as Effect from 'effect/Effect';", choices.serve === "github" && "import * as FetchHttpClient from 'effect/http/FetchHttpClient';", "import * as Layer from 'effect/Layer';", "import * as ManagedRuntime from 'effect/ManagedRuntime';", admins && "import * as Option from 'effect/Option';", "import * as Redacted from 'effect/Redacted';");
64
70
  /** Who `ADMIN_TOKEN` signs in as. */
65
71
  const adminLines = lines("/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */", "const admin = { id: '_admin' };", "");
66
72
  /** How the queue writes an entry onto `main`, when there's a queue. */
67
- const mergeLines = (choices) => choices.queue === "on" && lines("/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */", "const merge = ({ entry }: MergeInput): MergePlan => ({", " method: 'merge',", " message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,", " author: {", " name: entry.actor.id,", " email: `${entry.actor.id}@users.noreply.git`,", " at: Date.now(),", " offset: 0,", " },", "});", "");
73
+ const mergeLines = (choices) => choices.queue === "on" && lines("/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */", "const merge = ({ entry, at }: MergeInput): MergePlan => ({", " method: 'merge',", " message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,", " author: {", " name: entry.actor.id,", " email: `${entry.actor.id}@users.noreply.git`,", " at,", " offset: 0,", " },", "});", "");
68
74
  /** Who may do what: the admin's and a visitor's limits, as `Policy` decides them. */
69
75
  const policyLines = lines("/**", " * Who may do what: a visitor signs in first, and the admin makes repos and tokens but never", " * pushes.", " */", "const policy = Policy.make(({ caller: { actor }, operation }) => {", " if (actor.anonymous === true) return Policy.reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return Policy.reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return Policy.accept();", "});", "");
70
76
  /** What one push may carry into `Objects.layerRecords()`, as `@ref0/git` holds it. */
@@ -102,9 +108,9 @@ const gitFeatures = (choices, parts) => {
102
108
  */
103
109
  const unstableNextLine = ["// @effect", "diagnostics-next-line unstableApiUsage:off"].join("-");
104
110
  /** The drop-in over Git's features, under `--serve github`: each of its features a line too. */
105
- const githubFeatures = (choices) => lines("/**", " * GitHub's REST, GraphQL, webhooks and Event Streams over Git's, so `gh` and Octokit work, and", " * the drop-in's features, each a line: delete one to turn it off.", " */", "const github = Layer.mergeAll(", " Inbox.layer(),", " Deployments.layer(),", " // Without it, a repo's `language` and `license` answer null.", " Languages.layer(),", " // Repo and user search, and `org:` and `user:` search over an owner's public repos.", " Search.layer(),", " // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.", " Layer.provideMerge(Apps.layer(), Webhooks.layer()),", " // GitHub's Event Streams over Git's event feeds.", " Streams.layer(),", " // A repo's import from GitHub, its releases among it.", " Imports.layer(),", ").pipe(", choices.objects === "packs" && " // A release's assets, in the bucket beside the packs.\n Layer.provideMerge(Releases.layer()),", " Layer.provideMerge(GitHub.layer()),", " // The drop-in's own permissions narrow nothing past `policy`'s.", " Layer.provideMerge(GitHubPolicy.layer(GitHubPolicy.make(() => Effect.succeed(accept())))),", " // Who's who, by login, from Git's own records.", " Layer.provideMerge(", " People.layer(", " Effect.map(Effect.service(JoinedCalls), (joined) =>", " defaultPeople({ git: joined.effectHostCalls }),", " ),", " ),", " ),", " Layer.provideMerge(features),", " // A webhook's deliveries and an import's calls to GitHub, each the platform's `fetch`.", ` ${unstableNextLine}`, " Layer.provide(FetchHttpClient.layer),", ");", "");
111
+ const githubFeatures = (choices, admins) => lines("/**", " * GitHub's REST, GraphQL, webhooks and Event Streams over Git's, so `gh` and Octokit work, and", " * the drop-in's features, each a line: delete one to turn it off.", " */", "const github = Layer.mergeAll(", " Inbox.layer(),", " Deployments.layer(),", " // Without it, a repo's `language` and `license` answer null.", " Languages.layer(),", " // Repo and user search, and `org:` and `user:` search over an owner's public repos.", " Search.layer(),", " // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.", " Layer.provideMerge(Apps.layer(), Webhooks.layer()),", " // GitHub's Event Streams over Git's event feeds.", " Streams.layer(),", " // A repo's import from GitHub, its releases among it.", " Imports.layer(),", ").pipe(", choices.objects === "packs" && " // A release's assets, in the bucket beside the packs.\n Layer.provideMerge(Releases.layer()),", " Layer.provideMerge(GitHub.layer()),", admins ? lines(" // The drop-in narrows nothing past `policy`'s, but its org and account routes ask it alone:", " // it refuses a visitor, the bootstrap and an `admin` token outside ADMINS, as `policy` does.", " Layer.provideMerge(", " GitHubPolicy.layer(", " GitHubPolicy.make((asker) =>", " Effect.succeed(", " asker.actor.anonymous === true || isBootstrap(asker) || adminOutside(asker)", " ? reject({ message: 'Only an admin in ADMINS reaches this, with their admin token' })", " : accept(),", " ),", " ),", " ),", " ),") : lines(" // The drop-in's own permissions narrow nothing past `policy`'s.", " Layer.provideMerge(GitHubPolicy.layer(GitHubPolicy.make(() => Effect.succeed(accept())))),"), " Layer.provideMerge(features),", " // A webhook's deliveries and an import's calls to GitHub, each the platform's `fetch`.", ` ${unstableNextLine}`, " Layer.provide(FetchHttpClient.layer),", ");", "");
106
112
  /** Git's features, and the drop-in's over them under `--serve github`. */
107
- const featuresLines = (choices, parts) => lines(gitFeatures(choices, parts), choices.serve === "github" && githubFeatures(choices));
113
+ const featuresLines = (choices, parts) => lines(gitFeatures(choices, parts), choices.serve === "github" && githubFeatures(choices, parts.admins === true));
108
114
  /**
109
115
  * `Git.layer`'s options: Git's URLs under the base path, when there's one, and the platform's
110
116
  * `maxDuration`, when it sets one.
@@ -117,5 +123,5 @@ const gitOptions = (choices, maxDuration) => {
117
123
  * The admin's sign-in, then `export const runtime`: the whole host, Git with its features over the
118
124
  * adapter, one runtime that every entry, object and job runner takes.
119
125
  */
120
- const runtimeLines = (choices, parts) => lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`, "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", " * adapter, deciding with `policy`, and the admin signing in with `auth`.", parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime = ManagedRuntime.make(", parts.maxDuration !== void 0 && lines(" // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first,", " // with Git's own message."), ` Git.layer(${gitOptions(choices, parts.maxDuration)}, ${choices.serve === "github" ? "github" : "features"}).pipe(`, " Layer.provide(Policy.layer(policy)),", " Layer.provide(Auth.layer(auth)),", choices.objects === "packs" ? " Layer.provide(Objects.layer())," : ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n Layer.provide(Objects.layerRecords()),`, ` Layer.provideMerge(${parts.adapter}),`, " ),", ");", "");
126
+ const runtimeLines = (choices, parts) => lines(parts.bootstrap === true ? lines("/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */", "const auth =", ` ${parts.token} === undefined || ${parts.token} === ''`, " ? Layer.empty", ` : Auth.layer(Auth.bearer({ token: Redacted.make(${parts.token}), actor: bootstrap }));`) : lines("/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */", `const auth = Auth.bearer({ token: Redacted.make(${parts.token}), actor: admin });`), "", "/**", " * The whole host, one runtime that every request and job shares: Git and its features over the", ` * adapter, deciding with \`policy\`, and the ${parts.bootstrap === true ? "bootstrap" : "admin"} signing in with \`auth\`.`, parts.jobs !== void 0 && ` * ${parts.jobs}`, " */", "export const runtime = ManagedRuntime.make(", parts.maxDuration !== void 0 && lines(" // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first,", " // with Git's own message."), ` Git.layer(${gitOptions(choices, parts.maxDuration)}, ${choices.serve === "github" ? "github" : "features"}).pipe(`, " Layer.provide(Policy.layer(policy)),", parts.bootstrap === true ? " Layer.provide(auth)," : " Layer.provide(Auth.layer(auth)),", choices.objects === "packs" ? " Layer.provide(Objects.layer())," : ` // Each object a row in its push's commit: no bucket, ${looseSays}.\n Layer.provide(Objects.layerRecords()),`, ` Layer.provideMerge(${parts.adapter}),`, " ),", ");", "");
121
127
  export { adminLines, effectImports, featuresLines, gitDependencies, gitImports, gitPackages, header, lfsLines, looseSays, mergeLines, policyLines, queueLine, repoHint, runtimeLines, writtenCpu };
@@ -1,6 +1,6 @@
1
1
  // src/init/metadata.ts
2
2
  /** The version `ref0-git`, `create-ref0-git` and Git's packages release at, all at once (Q738). */
3
- const release = "0.9.0";
3
+ const release = "0.11.0";
4
4
  /** The packages the app depends on, by their folder in a checkout's `packages/`. */
5
5
  const appPackages = [
6
6
  "infra",
@@ -19,7 +19,7 @@ var templates_default = {
19
19
  "slot": "infraImport",
20
20
  "text": "import {\n layer,\n layerR2,\n layerR2Signed,\n toJobObject,\n toRecordsObject,\n} from '@ref0/infra/cloudflare';"
21
21
  },
22
- "\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` ",
22
+ "\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';\nimport { repoIcons } from './context/repo-icons.ts';\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` ",
23
23
  {
24
24
  "slot": "safety",
25
25
  "text": "binds the objects, the bucket and D1"
@@ -31,7 +31,7 @@ var templates_default = {
31
31
  },
32
32
  {
33
33
  "slot": "queueMerge",
34
- "text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at: Date.now(), offset: 0 },\n };\n};\n\n"
34
+ "text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry, at }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at, offset: 0 },\n };\n};\n\n"
35
35
  },
36
36
  "/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\nexport const policy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: async (prefix, most, host) => privateReposOf(repoListOn(run))(prefix, most, host),\n repoName: async (internalId, signal) =>\n (await runtime.runPromise(RepoRecords.record(internalId), { signal }))?.name,\n});\n\n",
37
37
  {
@@ -48,7 +48,7 @@ var templates_default = {
48
48
  "slot": "releases",
49
49
  "text": " // A release's assets, in the bucket beside the packs.\n Releases.layer(),\n"
50
50
  },
51
- " // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
51
+ " // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
52
52
  {
53
53
  "slot": "lfs",
54
54
  "text": " // Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use\n // `limits.cpu_ms` from wrangler.jsonc: raise both together.\n Lfs.layer({ cpuMs: 300_000 }),\n"
@@ -66,11 +66,11 @@ var templates_default = {
66
66
  appGitNode: [
67
67
  {
68
68
  "slot": "head",
69
- "text": "import {\n Git,\n Lfs,\n Merges,\n MergeQueue,\n Objects,\n RepoRecords,\n Rest,\n SignIn,\n Tokens,\n} from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport {\n Apps,\n Deployments,\n GitHub,\n Inbox,\n Releases,\n Search,\n Streams,\n Webhooks,\n} from '@ref0/github';\nimport * as Languages from '@ref0/github/languages';\nimport {\n layer,\n layerR2,\n layerR2Signed,\n toJobObject,\n toRecordsObject,\n} from '@ref0/infra/cloudflare';\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` binds the objects, the bucket and D1 and sets `APP_ORIGIN`; the\n// secrets come from `wrangler secret put`, or `.dev.vars` locally.\nexport const env = bindings as Env;\n\nconst {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, the bucket signs parts, and a push's pack past 64 MiB may upload to\n// it in parts, past Workers' 100 MB body.\nconst signed =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? undefined\n : layerR2Signed(env.PACKS, {\n accountId,\n bucket: env.PACKS_BUCKET,\n accessKeyId,\n secretAccessKey,\n });\n\nconst bucket = signed ?? layerR2(env.PACKS);\n\nconst uploads =\n signed === undefined\n ? Layer.empty\n : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed);\n\n"
69
+ "text": "import {\n Git,\n Lfs,\n Merges,\n MergeQueue,\n Objects,\n RepoRecords,\n Rest,\n SignIn,\n Tokens,\n} from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport {\n Apps,\n Deployments,\n GitHub,\n Inbox,\n Releases,\n Search,\n Streams,\n Webhooks,\n} from '@ref0/github';\nimport * as Languages from '@ref0/github/languages';\nimport {\n layer,\n layerR2,\n layerR2Signed,\n toJobObject,\n toRecordsObject,\n} from '@ref0/infra/cloudflare';\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { hostLayer, peopleOver, repoListOn, runOn, tokenCallsOn } from './context/host.ts';\nimport { repoIcons } from './context/repo-icons.ts';\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules, type Identify } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` binds the objects, the bucket and D1 and sets `APP_ORIGIN`; the\n// secrets come from `wrangler secret put`, or `.dev.vars` locally.\nexport const env = bindings as Env;\n\nconst {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, the bucket signs parts, and a push's pack past 64 MiB may upload to\n// it in parts, past Workers' 100 MB body.\nconst signed =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? undefined\n : layerR2Signed(env.PACKS, {\n accountId,\n bucket: env.PACKS_BUCKET,\n accessKeyId,\n secretAccessKey,\n });\n\nconst bucket = signed ?? layerR2(env.PACKS);\n\nconst uploads =\n signed === undefined\n ? Layer.empty\n : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed);\n\n"
70
70
  },
71
71
  {
72
72
  "slot": "queueMerge",
73
- "text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at: Date.now(), offset: 0 },\n };\n};\n\n"
73
+ "text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry, at }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at, offset: 0 },\n };\n};\n\n"
74
74
  },
75
75
  "/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\nexport const policy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: async (prefix, most, host) => privateReposOf(repoListOn(run))(prefix, most, host),\n repoName: async (internalId, signal) =>\n (await runtime.runPromise(RepoRecords.record(internalId), { signal }))?.name,\n});\n\n",
76
76
  {
@@ -87,7 +87,7 @@ var templates_default = {
87
87
  "slot": "releases",
88
88
  "text": " // A release's assets, in the bucket beside the packs.\n Releases.layer(),\n"
89
89
  },
90
- " // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
90
+ " // `org:` and `user:` search an owner's repos, its private ones by the policy's hook.\n Search.layer({ readableRepos: policy.readableRepos }),\n // Without it, a repo's `language` and `license` answer null.\n Languages.layer(),\n // A repo's and an org's hooks, each delivery a `fetch`, and GitHub Apps, whose hooks they send.\n // @effect-diagnostics-next-line unstableApiUsage:off\n Layer.provideMerge(Apps.layer(), Webhooks.layer().pipe(Layer.provide(FetchHttpClient.layer))),\n // GitHub's Event Streams over Git's event feeds, which a pull request's page follows.\n Streams.layer(),\n // A deleted repo's icon, removed however the repo was deleted.\n repoIcons(pictures),\n).pipe(\n Layer.provideMerge(GitHub.layer()),\n Layer.provideMerge(peopleOver(policy.people)),\n Layer.provideMerge(\n Layer.mergeAll(\n Rest.layer(),\n",
91
91
  {
92
92
  "slot": "lfs",
93
93
  "text": " // Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use\n // `limits.cpu_ms` from wrangler.jsonc: raise both together.\n Lfs.layer({ cpuMs: 300_000 }),\n"
@@ -191,7 +191,7 @@ var templates_default = {
191
191
  },
192
192
  {
193
193
  "slot": "gitImports",
194
- "text": "import { Auth, Git, Lfs, MergeQueue, Merges, Objects, Policy, Rest, Tokens } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\n"
194
+ "text": "import {\n Auth,\n Git,\n Lfs,\n MergeQueue,\n Merges,\n Objects,\n Policy,\n Rest,\n Tokens,\n maxActorIdLength,\n} from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\n"
195
195
  },
196
196
  {
197
197
  "slot": "infraImport",
@@ -200,7 +200,7 @@ var templates_default = {
200
200
  "\nimport xdiff from '@ref0/xdiff-wasm/xdiff.wasm';\nimport { env as bindings } from 'cloudflare:workers';\n",
201
201
  {
202
202
  "slot": "effectImports",
203
- "text": "import * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Redacted from 'effect/Redacted';\n"
203
+ "text": "import * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Option from 'effect/Option';\nimport * as Redacted from 'effect/Redacted';\n"
204
204
  },
205
205
  "\nimport type { Env } from ",
206
206
  {
@@ -212,23 +212,23 @@ var templates_default = {
212
212
  "slot": "safety",
213
213
  "text": "binds the objects and the bucket"
214
214
  },
215
- ", and `ADMIN_TOKEN` is its secret.\nconst env = bindings as Env;\n\n/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */\nconst admin = { id: '_admin' };\n\n",
215
+ ", and sets `ADMINS`.\nconst env = bindings as Env;\n\n/**\n * Who `ADMIN_TOKEN` signs in as, while it's set: it mints a listed admin's first `admin` token, and\n * nothing else. No login can be it.\n */\nconst bootstrap = { id: '_admin' };\n\n/**\n * The host's admins: `ADMINS`, from `wrangler.jsonc`'s vars, logins between commas. Each signs in\n * as themselves with an `admin` token, and makes repos, mints tokens and pushes. Adding one is a\n * vars edit and a deploy. A login that can't be one stops the Worker's start, so a deploy that\n * names it fails.\n */\nconst admins = new Set(\n (env.ADMINS ?? '')\n .split(',')\n .map((login) => login.trim())\n .filter((login) => login !== ''),\n);\n\nfor (const login of admins) {\n if (login === bootstrap.id || new TextEncoder().encode(login).length > maxActorIdLength) {\n throw new Error(`ADMINS names '${login}', which can't be a login`);\n }\n}\n\n",
216
216
  {
217
217
  "slot": "bucket",
218
218
  "text": "const {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, the bucket signs parts, and a push's pack past 64 MiB may upload to\n// it in parts, past Workers' 100 MB body.\nconst signed =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? undefined\n : layerR2Signed(env.PACKS, {\n accountId,\n bucket: env.PACKS_BUCKET,\n accessKeyId,\n secretAccessKey,\n });\n\n/** The records and job objects, and the packs' bucket. */\nconst adapter = Layer.merge(\n layer({ records: env.RECORDS, jobs: env.JOBS }),\n signed ?? layerR2(env.PACKS),\n);\n\n"
219
219
  },
220
220
  {
221
221
  "slot": "merge",
222
- "text": "/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */\nconst merge = ({ entry }: MergeInput): MergePlan => ({\n method: 'merge',\n message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,\n author: {\n name: entry.actor.id,\n email: `${entry.actor.id}@users.noreply.git`,\n at: Date.now(),\n offset: 0,\n },\n});\n\n"
222
+ "text": "/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */\nconst merge = ({ entry, at }: MergeInput): MergePlan => ({\n method: 'merge',\n message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,\n author: {\n name: entry.actor.id,\n email: `${entry.actor.id}@users.noreply.git`,\n at,\n offset: 0,\n },\n});\n\n"
223
223
  },
224
- "/**\n * Who may do what: a visitor signs in first, and the admin makes repos and tokens but never\n * pushes.\n */\nconst policy = Policy.make(({ caller: { actor }, operation }) => {\n if (actor.anonymous === true) return Policy.reject({ message: 'Sign in first' });\n\n if (actor.id === admin.id && operation.kind === 'push') {\n return Policy.reject({\n message: \"The admin token can't push\",\n hint: 'Make a write token for yourself: npx ref0-git tokens create --help',\n });\n }\n\n return Policy.accept();\n});\n\n",
224
+ "/** How much of the whole host's tokens the bootstrap reads to find an admin's: pages of 200. */\nconst bootstrapReads = { pages: 10, limit: 200 };\n\n/**\n * Whether an admin in `admins` holds an active `admin` token, which retires the bootstrap. It\n * reads the whole host's tokens from `runtime`, which `policy` is part of. Past `bootstrapReads`,\n * or with no `Tokens` to read, it can't tell, and answers yes.\n */\nconst adminSignedIn = Effect.gen(function* () {\n const tokens = Context.getOption(yield* runtime.contextEffect, Tokens.Tokens);\n if (Option.isNone(tokens)) return true;\n\n let after: string | undefined;\n\n for (let read = 0; read < bootstrapReads.pages; read += 1) {\n const page =\n after === undefined\n ? { limit: bootstrapReads.limit }\n : { limit: bootstrapReads.limit, after };\n const listed = yield* tokens.value.list({ prefix: '' }, { page });\n const held = listed.items.some(\n (token) => token.scope === 'admin' && admins.has(token.subject.id),\n );\n if (held) return true;\n\n if (listed.next === undefined) return false;\n\n after = listed.next;\n }\n\n return true;\n});\n\n/**\n * What the bootstrap may do: say who it is, as `ref0-git login` asks, and mint an `admin` token for\n * a login in `admins`, until one of them holds one. Then it's retired, and `ADMIN_TOKEN` is deleted.\n */\nconst bootstrapped = (operation: Policy.Input['operation']) =>\n Effect.gen(function* () {\n if (admins.size === 0) {\n return yield* Policy.reject({\n message: 'ADMINS names no one',\n hint: \"Add your login to ADMINS in wrangler.jsonc's vars, then deploy\",\n });\n }\n\n if (yield* adminSignedIn) {\n return yield* Policy.reject({\n message: 'The bootstrap secret is retired: an admin in ADMINS signs in. Delete ADMIN_TOKEN',\n hint: 'wrangler secret delete ADMIN_TOKEN',\n });\n }\n\n if (operation.kind === 'me') return yield* Policy.accept();\n\n const minted =\n operation.kind === 'token.create' &&\n operation.scope === 'admin' &&\n 'prefix' in operation &&\n operation.prefix === '' &&\n admins.has(operation.subject.id);\n if (minted) return yield* Policy.accept();\n\n return yield* Policy.reject({\n message: \"The bootstrap secret mints only an admin's first token\",\n hint: \"npx ref0-git tokens create --prefix '' --scope admin --subject <a login in ADMINS> --show-token\",\n });\n });\n\n/** Whether `caller` is the bootstrap: `ADMIN_TOKEN` signed in, not a token. */\nconst isBootstrap = ({ actor, token }: Policy.Input['caller']) =>\n actor.anonymous !== true && actor.id === bootstrap.id && token === undefined;\n\n/** Whether `caller` holds an `admin` token that isn't an admin's in `admins`. */\nconst adminOutside = ({ actor, subject, token }: Policy.Input['caller']) =>\n token?.scope === 'admin' &&\n !admins.has(subject?.id ?? (actor.anonymous === true ? '' : actor.id));\n\n/**\n * Who may do what: a visitor signs in first, the bootstrap only mints an admin's first token, and\n * an `admin` token is only ever an admin's. Every other caller does what its token reaches.\n */\nconst policy = Policy.make(({ caller, operation }) =>\n Effect.gen(function* () {\n if (caller.actor.anonymous === true) return yield* Policy.reject({ message: 'Sign in first' });\n\n if (isBootstrap(caller)) return yield* bootstrapped(operation);\n\n if (adminOutside(caller)) {\n return yield* Policy.reject({ message: 'An admin token works only for an admin in ADMINS' });\n }\n\n const mintsAdmin = operation.kind === 'token.create' && operation.scope === 'admin';\n\n if (mintsAdmin && !admins.has(operation.subject.id)) {\n return yield* Policy.reject({ message: 'An admin token is only for an admin in ADMINS' });\n }\n\n return yield* Policy.accept();\n }),\n);\n\n",
225
225
  {
226
226
  "slot": "features",
227
227
  "text": "/** Git's features, each a line: delete one to turn it off. */\nconst features = Layer.mergeAll(\n // Git's REST, beside Git's protocol and sign-in.\n Rest.layer(),\n // Git LFS, its objects in the bucket beside the packs. An upload through the Worker may use\n // `limits.cpu_ms` from wrangler.jsonc: raise both together.\n Lfs.layer({ cpuMs: 300_000 }),\n // A push past 64 MiB may upload its pack, once the bucket signs parts.\n signed === undefined\n ? Layer.empty\n : Layer.provide(Git.layerUploads({ above: 64 * 1024 * 1024 }), signed),\n MergeQueue.layer({ target: 'refs/heads/main', keys: 'reusable', merge }),\n).pipe(Layer.provideMerge(Tokens.layer()), Layer.provideMerge(Merges.layer({ xdiff })));\n\n"
228
228
  },
229
229
  {
230
230
  "slot": "runtime",
231
- "text": "/** The admin's sign-in: `ADMIN_TOKEN`, as a Bearer token or as Basic's password. */\nconst auth = Auth.bearer({ token: Redacted.make(env.ADMIN_TOKEN), actor: admin });\n\n/**\n * The whole host, one runtime that every request and job shares: Git and its features over the\n * adapter, deciding with `policy`, and the admin signing in with `auth`.\n */\nexport const runtime = ManagedRuntime.make(\n Git.layer({}, features).pipe(\n Layer.provide(Policy.layer(policy)),\n Layer.provide(Auth.layer(auth)),\n Layer.provide(Objects.layer()),\n Layer.provideMerge(adapter),\n ),\n);\n\n"
231
+ "text": "/** The bootstrap's sign-in, while `ADMIN_TOKEN` holds one: a Bearer token, or Basic's password. */\nconst auth =\n env.ADMIN_TOKEN === undefined || env.ADMIN_TOKEN === ''\n ? Layer.empty\n : Auth.layer(Auth.bearer({ token: Redacted.make(env.ADMIN_TOKEN), actor: bootstrap }));\n\n/**\n * The whole host, one runtime that every request and job shares: Git and its features over the\n * adapter, deciding with `policy`, and the bootstrap signing in with `auth`.\n */\nexport const runtime = ManagedRuntime.make(\n Git.layer({}, features).pipe(\n Layer.provide(Policy.layer(policy)),\n Layer.provide(auth),\n Layer.provide(Objects.layer()),\n Layer.provideMerge(adapter),\n ),\n);\n\n"
232
232
  },
233
233
  "/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = toRecordsObject(runtime);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = toJobObject(runtime);\n"
234
234
  ],
@@ -254,7 +254,7 @@ var templates_default = {
254
254
  "slot": "bucket",
255
255
  "text": " /** The packs' bucket, and its name, which a signed link names. */\n readonly PACKS: R2Bucket;\n readonly PACKS_BUCKET: string;\n"
256
256
  },
257
- " /** Signs in as the admin, who makes repos and tokens and never pushes. */\n readonly ADMIN_TOKEN: string;\n",
257
+ " /** The host's admins, logins between commas: each signs in as themselves with an `admin` token. */\n readonly ADMINS?: string;\n /** The bootstrap secret: it mints a listed admin's first `admin` token, then is deleted. */\n readonly ADMIN_TOKEN?: string;\n",
258
258
  {
259
259
  "slot": "signing",
260
260
  "text": " /** R2's S3 credentials for the packs' bucket: with all three, a large push uploads its pack. */\n readonly R2_ACCOUNT_ID?: string;\n readonly R2_ACCESS_KEY_ID?: string;\n readonly R2_SECRET_ACCESS_KEY?: string;\n"
@@ -267,7 +267,7 @@ var templates_default = {
267
267
  "slot": "about",
268
268
  "text": "Durable Object classes, and an R2 bucket"
269
269
  },
270
- ". Written by\n// `ref0-git init`. `ADMIN_TOKEN` is its one secret: `wrangler secret put ADMIN_TOKEN`.\n",
270
+ ". Written by\n// `ref0-git init`. `ADMINS` names its admins, logins between commas. `ADMIN_TOKEN`, its one\n// secret, mints the first one's token: `wrangler secret put ADMIN_TOKEN`, deleted once they have it.\n",
271
271
  {
272
272
  "slot": "signing",
273
273
  "text": "// With R2's S3 credentials too, as the secrets `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID` and\n// `R2_SECRET_ACCESS_KEY`, a large push uploads its pack to the bucket in parts.\n"
@@ -289,7 +289,7 @@ var templates_default = {
289
289
  },
290
290
  {
291
291
  "slot": "vars",
292
- "text": " \"vars\": { \"PACKS_BUCKET\": \"git-packs\" },\n"
292
+ "text": " \"vars\": { \"PACKS_BUCKET\": \"git-packs\", \"ADMINS\": \"\" },\n"
293
293
  },
294
294
  " \"migrations\": [{ \"tag\": \"v1\", \"new_sqlite_classes\": [\"Records\", \"Jobs\"] }],\n}\n"
295
295
  ],
@@ -56,5 +56,5 @@ const initPacked = (name, at) => {
56
56
  * the release, or the tarball `--from-checkout` names for that package. One it wrote moves to this
57
57
  * run's spec; any other is the person's, a tarball of their own in `vendor/` too, and stays.
58
58
  */
59
- const initWrote = (name, spec) => spec === "0.9.0" || spec !== void 0 && packedPath(name).test(spec);
59
+ const initWrote = (name, spec) => spec === "0.11.0" || spec !== void 0 && packedPath(name).test(spec);
60
60
  export { catalog, contentNamed, frameworkPackages, initPacked, initWrote, nodeAppPackages, nodePackages, peerPackages, published, release, specOf, storePackages, unpacked, vercelPackages };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ref0-git",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "private": false,
5
5
  "description": "ref0-git, the CLI for a Git host built on @ref0/git, and git-remote-ref0, its remote helper",
6
6
  "license": "Apache-2.0",
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@effect/platform-node-shared": "4.1.7",
27
- "@ref0/git": "0.9.0",
28
- "@ref0/infra": "0.9.0",
27
+ "@ref0/git": "0.11.0",
28
+ "@ref0/infra": "0.11.0",
29
29
  "diff": "9.0.0",
30
30
  "effect": "^4.1.7"
31
31
  },
@@ -34,8 +34,8 @@
34
34
  "@effect/vitest": "4.1.7",
35
35
  "@libsql/client": "0.18.0",
36
36
  "@libsql/kysely-libsql": "0.4.1",
37
- "@ref0/github": "0.9.0",
38
- "@ref0/xdiff-wasm": "0.9.0",
37
+ "@ref0/github": "0.11.0",
38
+ "@ref0/xdiff-wasm": "0.11.0",
39
39
  "@tanstack/react-start": "1.169.7",
40
40
  "@types/node": "24.19.4",
41
41
  "@types/pg": "8.23.1",