ref0-git 0.3.0 → 0.6.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/app/apps/github/.dev.vars.example +2 -1
- package/app/apps/github/generated/git-rest.ts +191 -25
- package/app/apps/github/generated/routeTree.gen.ts +21 -0
- package/app/apps/github/package.json +1 -1
- package/app/apps/github/src/branches/branch-list.tsx +8 -4
- package/app/apps/github/src/branches/branches.ts +10 -5
- package/app/apps/github/src/camo/addresses.ts +120 -0
- package/app/apps/github/src/camo/client.ts +125 -0
- package/app/apps/github/src/camo/fetch.ts +201 -0
- package/app/apps/github/src/camo/lookup.ts +23 -0
- package/app/apps/github/src/camo/node.ts +50 -0
- package/app/apps/github/src/camo/proxy.ts +116 -0
- package/app/apps/github/src/camo/sign-images.ts +307 -0
- package/app/apps/github/src/camo/signing.ts +80 -0
- package/app/apps/github/src/clients/allowed.ts +111 -18
- package/app/apps/github/src/clients/clients.ts +76 -61
- package/app/apps/github/src/clients/transport.ts +13 -0
- package/app/apps/github/src/code/code-tree.tsx +3 -1
- package/app/apps/github/src/code/file-view.tsx +15 -6
- package/app/apps/github/src/code/files.ts +26 -19
- package/app/apps/github/src/code/go-to-file.tsx +2 -1
- package/app/apps/github/src/code/load.ts +41 -23
- package/app/apps/github/src/code/markdown-files.ts +13 -2
- package/app/apps/github/src/code/ref-pages.ts +14 -5
- package/app/apps/github/src/code/ref-switcher.tsx +4 -3
- package/app/apps/github/src/code/refs.ts +42 -8
- package/app/apps/github/src/code/repo-home.tsx +6 -2
- package/app/apps/github/src/code/repo.ts +12 -6
- package/app/apps/github/src/code/saved.ts +5 -3
- package/app/apps/github/src/code/trees.ts +11 -9
- package/app/apps/github/src/components/markdown/markdown.css +6 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
- package/app/apps/github/src/components/owner-card.tsx +3 -1
- package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
- package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
- package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
- package/app/apps/github/src/components/signin/device-card.tsx +9 -2
- package/app/apps/github/src/components/user-avatar.tsx +2 -1
- package/app/apps/github/src/context/context.ts +13 -0
- package/app/apps/github/src/diffs/blobs.ts +37 -14
- package/app/apps/github/src/diffs/diff-job.ts +53 -0
- package/app/apps/github/src/diffs/diff-worker.ts +6 -0
- package/app/apps/github/src/diffs/diffing.ts +136 -0
- package/app/apps/github/src/diffs/files.ts +4 -3
- package/app/apps/github/src/diffs/hunks.tsx +101 -53
- package/app/apps/github/src/diffs/patch.ts +20 -11
- package/app/apps/github/src/history/commit-diff.ts +10 -5
- package/app/apps/github/src/history/commit-list.tsx +3 -1
- package/app/apps/github/src/history/commit-page.tsx +4 -2
- package/app/apps/github/src/history/history.ts +12 -10
- package/app/apps/github/src/hooks/allowed.ts +9 -9
- package/app/apps/github/src/hooks/avatars.ts +3 -3
- package/app/apps/github/src/hooks/open-counts.ts +5 -4
- package/app/apps/github/src/hooks/profiles.ts +26 -12
- package/app/apps/github/src/hooks/repos.ts +78 -25
- package/app/apps/github/src/inbox/count.ts +30 -29
- package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
- package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
- package/app/apps/github/src/inbox/marks.ts +26 -15
- package/app/apps/github/src/inbox/release-tags.ts +7 -6
- package/app/apps/github/src/inbox/subjects.ts +5 -4
- package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
- package/app/apps/github/src/inbox/subscriptions.ts +95 -35
- package/app/apps/github/src/inbox/threads.ts +6 -6
- package/app/apps/github/src/issues/changes.ts +40 -16
- package/app/apps/github/src/issues/counts.ts +8 -5
- package/app/apps/github/src/issues/issue-list.tsx +20 -6
- package/app/apps/github/src/issues/issue-page.tsx +30 -14
- package/app/apps/github/src/issues/issues.ts +195 -46
- package/app/apps/github/src/issues/label-dialog.tsx +8 -11
- package/app/apps/github/src/issues/labels-page.tsx +35 -3
- package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
- package/app/apps/github/src/issues/milestones-page.tsx +269 -0
- package/app/apps/github/src/issues/new-issue.tsx +3 -1
- package/app/apps/github/src/issues/sidebar.tsx +8 -6
- package/app/apps/github/src/markdown/README.md +22 -17
- package/app/apps/github/src/markdown/context.ts +83 -10
- package/app/apps/github/src/markdown/images.ts +3 -2
- package/app/apps/github/src/markdown/lookup.ts +9 -8
- package/app/apps/github/src/markdown/page-budget.ts +50 -0
- package/app/apps/github/src/markdown/patches.ts +74 -32
- package/app/apps/github/src/markdown/query.ts +7 -2
- package/app/apps/github/src/markdown/remote.ts +106 -0
- package/app/apps/github/src/markdown/render.ts +101 -24
- package/app/apps/github/src/markdown/texts.ts +43 -0
- package/app/apps/github/src/markdown/words-module.d.ts +5 -0
- package/app/apps/github/src/markdown/words-plugin.ts +135 -0
- package/app/apps/github/src/names/repos.ts +1 -1
- package/app/apps/github/src/palette/palette.tsx +7 -4
- package/app/apps/github/src/palette/rows.tsx +54 -33
- package/app/apps/github/src/palette/server.ts +5 -5
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +165 -66
- package/app/apps/github/src/private-repos.ts +2 -2
- package/app/apps/github/src/pulls/compare-page.tsx +6 -3
- package/app/apps/github/src/pulls/files-tab.tsx +480 -214
- package/app/apps/github/src/pulls/held-summary.ts +178 -0
- package/app/apps/github/src/pulls/live.ts +6 -4
- package/app/apps/github/src/pulls/merge-box.tsx +17 -10
- package/app/apps/github/src/pulls/pull-list.tsx +6 -3
- package/app/apps/github/src/pulls/pull-page.tsx +19 -10
- package/app/apps/github/src/pulls/pull.ts +68 -40
- package/app/apps/github/src/pulls/pulls.ts +39 -22
- package/app/apps/github/src/pulls/review-drafts.ts +131 -0
- package/app/apps/github/src/pulls/review.ts +374 -99
- package/app/apps/github/src/pulls/threads.tsx +152 -0
- package/app/apps/github/src/queue/queue-page.tsx +15 -8
- package/app/apps/github/src/queue/queue.ts +35 -20
- package/app/apps/github/src/releases/latest-release.tsx +3 -1
- package/app/apps/github/src/releases/overview.tsx +4 -2
- package/app/apps/github/src/releases/release-form.tsx +8 -5
- package/app/apps/github/src/releases/release-list.tsx +8 -5
- package/app/apps/github/src/releases/release-view.tsx +1 -0
- package/app/apps/github/src/releases/releases.ts +33 -23
- package/app/apps/github/src/releases/tag-list.tsx +3 -1
- package/app/apps/github/src/router.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
- package/app/apps/github/src/routes/-nav.tsx +10 -2
- package/app/apps/github/src/routes/-root-testing.ts +29 -6
- package/app/apps/github/src/routes/__root.tsx +9 -4
- package/app/apps/github/src/routes/index.tsx +3 -1
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
- package/app/apps/github/src/seed/acme.ts +1 -1
- package/app/apps/github/src/seed/seed.ts +199 -110
- package/app/apps/github/src/server.ts +24 -15
- package/app/apps/github/src/settings/account-avatar.tsx +4 -1
- package/app/apps/github/src/settings/general-settings.tsx +3 -1
- package/app/apps/github/src/settings/general.ts +4 -4
- package/app/apps/github/src/settings/hook-form.tsx +3 -1
- package/app/apps/github/src/settings/hook-list.tsx +5 -2
- package/app/apps/github/src/settings/hooks.ts +7 -7
- package/app/apps/github/src/settings/org-settings.tsx +3 -1
- package/app/apps/github/src/settings/orgs.ts +21 -11
- package/app/apps/github/src/settings/settings-layout.tsx +3 -1
- package/app/apps/github/src/signin/approval.ts +4 -3
- package/app/apps/github/src/signin/auth.ts +9 -2
- package/app/apps/github/src/signin/device-code.ts +8 -3
- package/app/apps/github/src/signin/device-prompt.ts +28 -3
- package/app/apps/github/src/signin/revoke.ts +36 -0
- package/app/apps/github/tsconfig.json +4 -1
- package/app/apps/github/vite.config.ts +8 -0
- package/app/pnpm-workspace.yaml +12 -5
- package/app/tsconfig.base.json +1 -0
- package/dist/cli/child.mjs +1 -1
- package/dist/cli/credentials.mjs +4 -4
- package/dist/cli/documents.mjs +32 -22
- package/dist/cli/events.mjs +1 -1
- package/dist/cli/failure.mjs +20 -7
- package/dist/cli/folders.mjs +2 -2
- package/dist/cli/git-remote-ref0.mjs +47 -22
- package/dist/cli/git.mjs +1 -1
- package/dist/cli/helpers.mjs +2 -2
- package/dist/cli/hosts.mjs +3 -3
- package/dist/cli/output.mjs +2 -2
- package/dist/cli/prompt.mjs +1 -1
- package/dist/cli/queue.mjs +7 -7
- package/dist/cli/ref0-git.mjs +2 -2
- package/dist/cli/repos.mjs +35 -18
- package/dist/cli/resources.mjs +5 -5
- package/dist/cli/retry-after.mjs +8 -0
- package/dist/cli/setup.mjs +172 -66
- package/dist/cli/sign-in.mjs +65 -23
- package/dist/cli/sign-ins.mjs +4 -4
- package/dist/cli/sqlite.mjs +2 -2
- package/dist/cli/tokens.mjs +3 -3
- package/dist/cli/vendor.mjs +1 -1
- package/dist/init/app.mjs +20 -21
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +3 -2
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +120 -13
- package/dist/init/frameworks.mjs +16 -0
- package/dist/init/git-module.mjs +22 -7
- package/dist/init/jsonc.mjs +9 -7
- package/dist/init/metadata.mjs +9 -3
- package/dist/init/mounts.mjs +13 -10
- package/dist/init/next.mjs +2 -2
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +42 -45
- package/dist/init/nuxt.mjs +153 -27
- package/dist/init/stores.mjs +14 -9
- package/dist/init/sveltekit.mjs +4 -2
- package/dist/init/template.mjs +9 -6
- package/dist/init/templates.mjs +63 -47
- package/dist/init/vercel.mjs +37 -37
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -4,6 +4,7 @@ import { LockIcon } from 'lucide-react';
|
|
|
4
4
|
import { useState, type FormEvent } from 'react';
|
|
5
5
|
import { toast } from 'sonner';
|
|
6
6
|
|
|
7
|
+
import { useClients } from '../clients/clients.ts';
|
|
7
8
|
import type { RepoPlace } from '../code/places.ts';
|
|
8
9
|
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
9
10
|
import { Button } from '../components/ui/button.tsx';
|
|
@@ -74,6 +75,7 @@ function Choice<Value extends string>({
|
|
|
74
75
|
* whether it's active. The secret is sent once and never shown again.
|
|
75
76
|
*/
|
|
76
77
|
export function HookForm({ place }: { readonly place: RepoPlace }) {
|
|
78
|
+
const clients = useClients();
|
|
77
79
|
const allowed = useAllowed(place);
|
|
78
80
|
const client = useQueryClient();
|
|
79
81
|
const navigate = useNavigate();
|
|
@@ -86,7 +88,7 @@ export function HookForm({ place }: { readonly place: RepoPlace }) {
|
|
|
86
88
|
const [events, setEvents] = useState<EventChoice>('push');
|
|
87
89
|
const [tried, setTried] = useState(false);
|
|
88
90
|
const made = useMutation({
|
|
89
|
-
mutationFn: () => createHook(place, { ...hook, events: eventChoices[events] }),
|
|
91
|
+
mutationFn: () => createHook(clients, place, { ...hook, events: eventChoices[events] }),
|
|
90
92
|
onSuccess: async () => {
|
|
91
93
|
await client.invalidateQueries({ queryKey: ['hooks', place.owner, place.repo] });
|
|
92
94
|
toast.success(`Added the webhook to ${hook.url}`);
|
|
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
import { WebhookIcon } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import { Go } from '../code/controls.tsx';
|
|
5
|
+
import { useClients } from '../clients/clients.ts';
|
|
5
6
|
import type { RepoPlace } from '../code/places.ts';
|
|
6
7
|
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
7
8
|
import { LoadFailed } from '../components/states/states.tsx';
|
|
@@ -43,9 +44,10 @@ function HookRow({
|
|
|
43
44
|
readonly hook: Hook;
|
|
44
45
|
readonly deletes: boolean;
|
|
45
46
|
}) {
|
|
47
|
+
const clients = useClients();
|
|
46
48
|
const client = useQueryClient();
|
|
47
49
|
const deleted = useMutation({
|
|
48
|
-
mutationFn: () => deleteHook(place, hook.id),
|
|
50
|
+
mutationFn: () => deleteHook(clients, place, hook.id),
|
|
49
51
|
onSuccess: () => client.invalidateQueries({ queryKey: ['hooks', place.owner, place.repo] }),
|
|
50
52
|
});
|
|
51
53
|
|
|
@@ -102,7 +104,8 @@ function HookRow({
|
|
|
102
104
|
|
|
103
105
|
/** The repo's webhooks, with Add webhook for whoever may add one. */
|
|
104
106
|
export function HookList({ place }: { readonly place: RepoPlace }) {
|
|
105
|
-
const
|
|
107
|
+
const clients = useClients();
|
|
108
|
+
const hooks = useQuery(hookList(clients, place));
|
|
106
109
|
const allowed = useAllowed(place);
|
|
107
110
|
|
|
108
111
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { components, operations } from '@octokit/openapi-types';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { Clients } from '../clients/clients.ts';
|
|
5
5
|
import type { RepoPlace } from '../code/places.ts';
|
|
6
6
|
import { everyPage, failure } from '../hooks/answers.ts';
|
|
7
7
|
|
|
@@ -42,13 +42,13 @@ const hookOf = (hook: RestHook): Hook => ({
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
/** The repo's webhooks, every page of them. */
|
|
45
|
-
export const hookList = (place: RepoPlace) =>
|
|
45
|
+
export const hookList = (clients: Clients, place: RepoPlace) =>
|
|
46
46
|
queryOptions({
|
|
47
47
|
queryKey: ['hooks', place.owner, place.repo],
|
|
48
48
|
queryFn: async () => {
|
|
49
49
|
const hooks = await everyPage(async (after) => {
|
|
50
50
|
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
51
|
-
const answer = await github.GET('/repos/{owner}/{repo}/hooks', {
|
|
51
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/hooks', {
|
|
52
52
|
params: { path: place, query: { ...{ per_page: 100, after } } },
|
|
53
53
|
});
|
|
54
54
|
if (answer.data === undefined) throw failure("The webhooks didn't load", answer);
|
|
@@ -61,7 +61,7 @@ export const hookList = (place: RepoPlace) =>
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
/** Adds a webhook to the repo; an empty secret sends none. */
|
|
64
|
-
export const createHook = async (place: RepoPlace, hook: NewHook) => {
|
|
64
|
+
export const createHook = async (clients: Clients, place: RepoPlace, hook: NewHook) => {
|
|
65
65
|
const config: HookConfig = {
|
|
66
66
|
url: hook.url,
|
|
67
67
|
content_type: hook.contentType,
|
|
@@ -69,7 +69,7 @@ export const createHook = async (place: RepoPlace, hook: NewHook) => {
|
|
|
69
69
|
insecure_ssl: '0',
|
|
70
70
|
};
|
|
71
71
|
if (hook.secret !== '') config.secret = hook.secret;
|
|
72
|
-
const answer = await github.POST('/repos/{owner}/{repo}/hooks', {
|
|
72
|
+
const answer = await clients.github.POST('/repos/{owner}/{repo}/hooks', {
|
|
73
73
|
params: { path: place },
|
|
74
74
|
body: { name: 'web', config, events: [...hook.events], active: hook.active },
|
|
75
75
|
});
|
|
@@ -79,8 +79,8 @@ export const createHook = async (place: RepoPlace, hook: NewHook) => {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
/** Deletes the repo's webhook `id`. */
|
|
82
|
-
export const deleteHook = async (place: RepoPlace, id: number) => {
|
|
83
|
-
const answer = await github.DELETE('/repos/{owner}/{repo}/hooks/{hook_id}', {
|
|
82
|
+
export const deleteHook = async (clients: Clients, place: RepoPlace, id: number) => {
|
|
83
|
+
const answer = await clients.github.DELETE('/repos/{owner}/{repo}/hooks/{hook_id}', {
|
|
84
84
|
params: { path: { ...place, hook_id: id } },
|
|
85
85
|
});
|
|
86
86
|
if (!answer.response.ok) throw failure("The webhook wasn't deleted", answer);
|
|
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
2
2
|
import { UsersIcon } from 'lucide-react';
|
|
3
3
|
import type { ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
+
import { useClients } from '../clients/clients.ts';
|
|
5
6
|
import { LoadFailed, LoadingSkeleton, NotFound } from '../components/states/states.tsx';
|
|
6
7
|
import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/card.tsx';
|
|
7
8
|
import {
|
|
@@ -148,7 +149,8 @@ const among = (logins: readonly string[], login: string) =>
|
|
|
148
149
|
* changes it.
|
|
149
150
|
*/
|
|
150
151
|
export function OrgSettings({ org, viewer }: { readonly org: string; readonly viewer: string }) {
|
|
151
|
-
const
|
|
152
|
+
const clients = useClients();
|
|
153
|
+
const directory = useQuery(orgDirectory(clients, org));
|
|
152
154
|
if (directory.error !== null) return <LoadFailed message={directory.error.message} />;
|
|
153
155
|
|
|
154
156
|
if (directory.data === undefined) return <OrgSettingsSkeleton />;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { Clients } from '../clients/clients.ts';
|
|
4
4
|
import { everyPage, failure, type EveryPage } from '../hooks/answers.ts';
|
|
5
5
|
import { type Pictures, picturesOf } from '../hooks/avatars.ts';
|
|
6
6
|
|
|
@@ -38,9 +38,14 @@ const loginsOf = (
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/** Every login of team `slug` in `org`, to the pages `everyPage` reads, into `pictures`. */
|
|
41
|
-
const teamMembers = (
|
|
41
|
+
const teamMembers = (
|
|
42
|
+
clients: Clients,
|
|
43
|
+
org: string,
|
|
44
|
+
slug: string,
|
|
45
|
+
pictures: Map<string, string | null>,
|
|
46
|
+
) =>
|
|
42
47
|
everyPage(async (after) => {
|
|
43
|
-
const answer = await github.GET('/orgs/{org}/teams/{team_slug}/members', {
|
|
48
|
+
const answer = await clients.github.GET('/orgs/{org}/teams/{team_slug}/members', {
|
|
44
49
|
params: { path: { org, team_slug: slug }, query: paging(after) },
|
|
45
50
|
});
|
|
46
51
|
if (answer.data === undefined) throw failure(`${slug}'s members didn't load`, answer);
|
|
@@ -55,9 +60,14 @@ const teamMembers = (org: string, slug: string, pictures: Map<string, string | n
|
|
|
55
60
|
* Every login in `org` with `role`, GitHub's `all` or `admin`, which holds its owners too, into
|
|
56
61
|
* `pictures`.
|
|
57
62
|
*/
|
|
58
|
-
const orgMembers = (
|
|
63
|
+
const orgMembers = (
|
|
64
|
+
clients: Clients,
|
|
65
|
+
org: string,
|
|
66
|
+
role: 'all' | 'admin',
|
|
67
|
+
pictures: Map<string, string | null>,
|
|
68
|
+
) =>
|
|
59
69
|
everyPage(async (after) => {
|
|
60
|
-
const answer = await github.GET('/orgs/{org}/members', {
|
|
70
|
+
const answer = await clients.github.GET('/orgs/{org}/members', {
|
|
61
71
|
params: { path: { org }, query: { ...paging(after), role } },
|
|
62
72
|
});
|
|
63
73
|
if (answer.data === undefined) throw failure("The members didn't load", answer);
|
|
@@ -72,20 +82,20 @@ const orgMembers = (org: string, role: 'all' | 'admin', pictures: Map<string, st
|
|
|
72
82
|
* `org`, its members and its teams with theirs, as the drop-in's org routes read them from the
|
|
73
83
|
* host's `people`: `null` when there's no such org.
|
|
74
84
|
*/
|
|
75
|
-
export const orgDirectory = (org: string) =>
|
|
85
|
+
export const orgDirectory = (clients: Clients, org: string) =>
|
|
76
86
|
queryOptions({
|
|
77
87
|
queryKey: ['org-directory', org],
|
|
78
88
|
queryFn: async (): Promise<OrgDirectory | null> => {
|
|
79
|
-
const found = await github.GET('/orgs/{org}', { params: { path: { org } } });
|
|
89
|
+
const found = await clients.github.GET('/orgs/{org}', { params: { path: { org } } });
|
|
80
90
|
if (found.response.status === 404) return null;
|
|
81
91
|
|
|
82
92
|
if (found.data === undefined) throw failure(`${org} didn't load`, found);
|
|
83
93
|
|
|
84
94
|
const pictures = new Map<string, string | null>();
|
|
85
|
-
const members = orgMembers(org, 'all', pictures);
|
|
86
|
-
const admins = orgMembers(org, 'admin', pictures);
|
|
95
|
+
const members = orgMembers(clients, org, 'all', pictures);
|
|
96
|
+
const admins = orgMembers(clients, org, 'admin', pictures);
|
|
87
97
|
const teams = everyPage(async (after) => {
|
|
88
|
-
const answer = await github.GET('/orgs/{org}/teams', {
|
|
98
|
+
const answer = await clients.github.GET('/orgs/{org}/teams', {
|
|
89
99
|
params: { path: { org }, query: paging(after) },
|
|
90
100
|
});
|
|
91
101
|
if (answer.data === undefined) throw failure("The teams didn't load", answer);
|
|
@@ -95,7 +105,7 @@ export const orgDirectory = (org: string) =>
|
|
|
95
105
|
slug: team.slug,
|
|
96
106
|
name: team.name,
|
|
97
107
|
description: team.description,
|
|
98
|
-
members: await teamMembers(org, team.slug, pictures),
|
|
108
|
+
members: await teamMembers(clients, org, team.slug, pictures),
|
|
99
109
|
})),
|
|
100
110
|
);
|
|
101
111
|
|
|
@@ -4,6 +4,7 @@ import type { ReactNode } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import type { PageOperation } from '../clients/allowed.ts';
|
|
6
6
|
import { Go } from '../code/controls.tsx';
|
|
7
|
+
import { useClients } from '../clients/clients.ts';
|
|
7
8
|
import type { RepoPlace } from '../code/places.ts';
|
|
8
9
|
import { LoadFailed } from '../components/states/states.tsx';
|
|
9
10
|
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
@@ -48,7 +49,8 @@ export function SettingsLayout({
|
|
|
48
49
|
readonly current: string;
|
|
49
50
|
readonly children: ReactNode;
|
|
50
51
|
}) {
|
|
51
|
-
const
|
|
52
|
+
const clients = useClients();
|
|
53
|
+
const asked = useQuery(allowedHere(clients, place));
|
|
52
54
|
const allowed = asked.data;
|
|
53
55
|
|
|
54
56
|
if (allowed === undefined) {
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import { ownerProblem } from '../names/owners.ts';
|
|
11
11
|
import { type StarterAuth, sessionFrom } from './auth.ts';
|
|
12
|
-
import { openPrompt, sealPrompt, sealRetry } from './device-prompt.ts';
|
|
12
|
+
import { openPrompt, sealPrompt, sealRetry, tokenScopeOf } from './device-prompt.ts';
|
|
13
13
|
|
|
14
14
|
/** What the starter's approval page decides with: the person's session, and where it's served. */
|
|
15
15
|
export interface StarterApprovalOptions {
|
|
@@ -124,7 +124,8 @@ const shown = async (
|
|
|
124
124
|
/**
|
|
125
125
|
* A decision posted from the Card: from the app's own page, by a live session, with the sealed
|
|
126
126
|
* prompt it showed, for that person, unexpired and for the code Git found. It decides on Git's
|
|
127
|
-
* prompt, never the sealed one, and Git checks the code is still
|
|
127
|
+
* prompt, never the sealed one, granting `tokenScopeOf` its scopes, and Git checks the code is still
|
|
128
|
+
* pending as it settles.
|
|
128
129
|
*/
|
|
129
130
|
const decided = async (
|
|
130
131
|
input: ConfirmApprovalPage,
|
|
@@ -157,7 +158,7 @@ const decided = async (
|
|
|
157
158
|
kind: 'approve',
|
|
158
159
|
actor: { id: login },
|
|
159
160
|
target: { prefix: '' },
|
|
160
|
-
scope:
|
|
161
|
+
scope: tokenScopeOf(prompt.scopes),
|
|
161
162
|
expiresAt: Date.now() + options.tokenDays * day,
|
|
162
163
|
});
|
|
163
164
|
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
isTaken,
|
|
29
29
|
ownerNames,
|
|
30
30
|
} from './owner-names.ts';
|
|
31
|
+
import { revokeRetrying } from './revoke.ts';
|
|
31
32
|
import { open, seal } from './seal.ts';
|
|
32
33
|
import { avatarTable, avatars } from './avatars.ts';
|
|
33
34
|
import { type Unborn, forgetUnborn } from './unborn.ts';
|
|
@@ -599,7 +600,11 @@ export const starterAuth = (options: StarterAuthOptions): Auth => {
|
|
|
599
600
|
update: { gitTokenId: made.value.id, gitToken },
|
|
600
601
|
});
|
|
601
602
|
// Only a row with no token takes it; `returning` answers nothing for one it skipped.
|
|
602
|
-
if (held
|
|
603
|
+
if (held !== null && held !== undefined) return;
|
|
604
|
+
|
|
605
|
+
const revoked = await revokeRetrying(() => options.tokens.revoke(made.value.id));
|
|
606
|
+
if (revoked.kind !== 'success')
|
|
607
|
+
console.error(`Git didn't revoke token ${made.value.id}`);
|
|
603
608
|
},
|
|
604
609
|
},
|
|
605
610
|
delete: {
|
|
@@ -608,7 +613,9 @@ export const starterAuth = (options: StarterAuthOptions): Auth => {
|
|
|
608
613
|
// on it, and one still to come is refused until the session would end.
|
|
609
614
|
const key = sessionKeyOf(session.id);
|
|
610
615
|
const until = session.expiresAt;
|
|
611
|
-
const revoked = await
|
|
616
|
+
const revoked = await revokeRetrying(() =>
|
|
617
|
+
options.tokens.revokeKey({ prefix: '' }, key, { until }),
|
|
618
|
+
);
|
|
612
619
|
if (revoked.kind !== 'success') console.error(`Git didn't revoke session token ${key}`);
|
|
613
620
|
},
|
|
614
621
|
},
|
|
@@ -4,7 +4,9 @@ import { flow } from 'effect/Function';
|
|
|
4
4
|
import * as Option from 'effect/Option';
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import type { TokenScope } from '@ref0/git';
|
|
8
|
+
|
|
9
|
+
import { clientLabel, openPrompt, openRetry, tokenScopeOf } from './device-prompt.ts';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* What `/login/code`'s Card shows: the Code field, with any error under it; the confirm, with a
|
|
@@ -24,9 +26,11 @@ export type DeviceCardState =
|
|
|
24
26
|
readonly client: string;
|
|
25
27
|
readonly login: string;
|
|
26
28
|
readonly userCode: string;
|
|
27
|
-
/** What Approve grants
|
|
29
|
+
/** What Approve grants over every repo `login` may reach: `tokenScopeOf` the device's scopes. */
|
|
30
|
+
readonly tokenScope: TokenScope;
|
|
31
|
+
/** How many days the token Approve mints lasts. */
|
|
28
32
|
readonly days: number;
|
|
29
|
-
/** The scopes the device asked for, which
|
|
33
|
+
/** The scopes the device asked for, which `tokenScope` reaches past `read` only if one names it. */
|
|
30
34
|
readonly scopes: readonly string[];
|
|
31
35
|
/** The sealed prompt, posted back in a hidden field beside `user_code` and `decision`. */
|
|
32
36
|
readonly prompt: string;
|
|
@@ -88,6 +92,7 @@ export const deviceCard = createServerFn({ method: 'GET' })
|
|
|
88
92
|
client: clientLabel(opened.clientId),
|
|
89
93
|
login: session.login,
|
|
90
94
|
userCode: opened.userCode,
|
|
95
|
+
tokenScope: tokenScopeOf(opened.scopes),
|
|
91
96
|
days: opened.days,
|
|
92
97
|
scopes: opened.scopes,
|
|
93
98
|
prompt: data.prompt,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { DeviceApproval } from '@ref0/git';
|
|
2
|
-
import { ghClientId } from '@ref0/git/auth';
|
|
1
|
+
import type { DeviceApproval, TokenScope } from '@ref0/git';
|
|
2
|
+
import { ghClientId, ghWriteScope } from '@ref0/git/auth';
|
|
3
|
+
import { tokenScopes } from '@ref0/git/rest';
|
|
3
4
|
import * as Option from 'effect/Option';
|
|
4
5
|
import * as Schema from 'effect/Schema';
|
|
5
6
|
|
|
@@ -33,7 +34,31 @@ const purpose = 'device-prompt';
|
|
|
33
34
|
/** How long a sealed prompt holds. */
|
|
34
35
|
const promptLife = 10 * 60 * 1000;
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The GitHub scopes a device may ask for that reach past `read`: `ghWriteScope`, `repo`, writes,
|
|
39
|
+
* as gh's and `ref0-git login`'s pushes need, and `repo:status` and `repo_deployment` report, as
|
|
40
|
+
* the drop-in's statuses, checks and deployments take. Every other scope, known or not, and none
|
|
41
|
+
* at all, gets `read`, Git's narrowest token scope, so nothing a device asks for reaches past it
|
|
42
|
+
* unless it names one of these. `public_repo` reads, where GitHub would let it write public repos:
|
|
43
|
+
* a deliberate narrowing, since a Git token has no write over public repos alone.
|
|
44
|
+
*/
|
|
45
|
+
const pastRead: ReadonlyMap<string, TokenScope> = new Map([
|
|
46
|
+
[ghWriteScope, 'write'],
|
|
47
|
+
['repo:status', 'report'],
|
|
48
|
+
['repo_deployment', 'report'],
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
/** Approve's token scope: each scope a device asks for maps as GitHub reads it; the widest wins. */
|
|
52
|
+
export const tokenScopeOf = (scopes: readonly string[]): TokenScope => {
|
|
53
|
+
const reached = scopes.map((scope) => tokenScopes.indexOf(pastRead.get(scope) ?? 'read'));
|
|
54
|
+
|
|
55
|
+
return tokenScopes[Math.max(0, ...reached)] ?? 'read';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* What Approve would grant: a token as `login`, over every repo they may reach, for `days`, at
|
|
60
|
+
* `tokenScopeOf` the prompt's scopes.
|
|
61
|
+
*/
|
|
37
62
|
export interface Grant {
|
|
38
63
|
readonly login: string;
|
|
39
64
|
readonly days: number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GitError, Result } from '@ref0/git';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The most times a session's token revoke is sent again after other writes to the same tokens won
|
|
5
|
+
* every try. It matches the CLI's `tooManyWritesTriesMost` today, and the two are apart on purpose:
|
|
6
|
+
* a person at a terminal waits on the CLI's, while nobody waits on a sign-out's hook.
|
|
7
|
+
*/
|
|
8
|
+
export const revokeTriesMost = 3;
|
|
9
|
+
|
|
10
|
+
/** How long a revoke waits before it's sent again the first time, in ms, doubling after each. */
|
|
11
|
+
export const revokePauseFirst = 250;
|
|
12
|
+
|
|
13
|
+
/** Whether `error` says nothing was written, so sending the same revoke again is safe. */
|
|
14
|
+
const tooManyWrites = (error: GitError) =>
|
|
15
|
+
error.code === 'UNAVAILABLE' && error.context?.reason === 'too-many-writes';
|
|
16
|
+
|
|
17
|
+
const paused = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `revoke`, sent again while Git answers that other writes won every try, `revokeTriesMost` times
|
|
21
|
+
* at most. Any other failure answers at once, as does the last try's.
|
|
22
|
+
*/
|
|
23
|
+
export const revokeRetrying = async (
|
|
24
|
+
revoke: () => Promise<Result<void>>,
|
|
25
|
+
): Promise<Result<void>> => {
|
|
26
|
+
let revoked = await revoke();
|
|
27
|
+
|
|
28
|
+
for (let tried = 0; tried < revokeTriesMost; tried += 1) {
|
|
29
|
+
if (revoked.kind === 'success' || !tooManyWrites(revoked.error)) return revoked;
|
|
30
|
+
|
|
31
|
+
await paused(revokePauseFirst * 2 ** tried);
|
|
32
|
+
revoked = await revoke();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return revoked;
|
|
36
|
+
};
|
|
@@ -4,13 +4,21 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
|
4
4
|
import viteReact from '@vitejs/plugin-react';
|
|
5
5
|
import { defineConfig } from 'vite-plus';
|
|
6
6
|
|
|
7
|
+
import { wordsMemoryMax } from './src/markdown/words-plugin.ts';
|
|
8
|
+
|
|
7
9
|
// Start's server build runs in the Worker: Cloudflare's plugin takes its `ssr` environment.
|
|
8
10
|
export default defineConfig(({ command }) => ({
|
|
9
11
|
// The dev seed is on only under the dev server, `vp dev`: every build drops it and its imports,
|
|
10
12
|
// whatever its mode or `NODE_ENV`.
|
|
11
13
|
define: { __DEV_SEED__: JSON.stringify(command === 'serve') },
|
|
14
|
+
// The diff and highlight Workers are modules: `@pierre/diffs`' loads its highlighter lazily.
|
|
15
|
+
worker: { format: 'es' },
|
|
12
16
|
plugins: [
|
|
13
17
|
cloudflare({ viteEnvironment: { name: 'ssr' } }),
|
|
18
|
+
// Words' WebAssembly under the drop-in's most on its memory (#1098): after Cloudflare's
|
|
19
|
+
// plugin, whose resolve of a `.wasm` import asks this one for the file and makes it the
|
|
20
|
+
// Worker's module.
|
|
21
|
+
wordsMemoryMax(),
|
|
14
22
|
tanstackStart({
|
|
15
23
|
// NodeNext, as the repo types it, resolves only imports that name their extension.
|
|
16
24
|
router: { generatedRouteTree: '../generated/routeTree.gen.ts', addExtensions: true },
|
package/app/pnpm-workspace.yaml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# The workspace's
|
|
2
|
-
# `apps/github`, the examples that host them, the benchmarks, and the root's tooling. The catalog
|
|
1
|
+
# The workspace's packages, `@ref0/infra`, `@ref0/xdiff-wasm`, `@ref0/git` and `@ref0/github`, the
|
|
2
|
+
# app over them, `apps/github`, the examples that host them, the benchmarks, and the root's tooling. The catalog
|
|
3
3
|
# pins every shared version once, at home's versions.
|
|
4
4
|
packages:
|
|
5
5
|
- packages/*
|
|
@@ -45,6 +45,11 @@ catalog:
|
|
|
45
45
|
# Octokit's GitHub App auth, which @ref0/github's App tests sign JWTs and mint installation
|
|
46
46
|
# tokens with, as a CI job would. MIT.
|
|
47
47
|
'@octokit/auth-app': 8.3.1
|
|
48
|
+
# Octokit's core client and its retry plugin, which the `octokit` package turns on by default:
|
|
49
|
+
# @ref0/github's tests send the drop-in's refusals through them, as such a client would, to see
|
|
50
|
+
# which it sends again. MIT.
|
|
51
|
+
'@octokit/core': 7.0.8
|
|
52
|
+
'@octokit/plugin-retry': 8.1.1
|
|
48
53
|
# Octokit's request, which the App tests point at the handler's fetch for auth-app. MIT.
|
|
49
54
|
'@octokit/request': 10.0.16
|
|
50
55
|
# Octokit's webhook signature check, which @ref0/github's webhook tests verify deliveries with.
|
|
@@ -62,7 +67,7 @@ catalog:
|
|
|
62
67
|
# The app's Markdown renderer: words, a WebAssembly parser, with hooks for GitHub's alerts,
|
|
63
68
|
# anchors, references and URLs (Q213). Apache-2.0.
|
|
64
69
|
'@pierre/words': 0.3.0
|
|
65
|
-
'@ref0/workspace': 0.
|
|
70
|
+
'@ref0/workspace': 0.8.0
|
|
66
71
|
'@tailwindcss/vite': 4.3.5
|
|
67
72
|
# The app's stack: TanStack Start, its router and Query, and React, as spike F ran them, at the
|
|
68
73
|
# newest releases past pnpm's minimum release age.
|
|
@@ -157,7 +162,6 @@ catalog:
|
|
|
157
162
|
# The app's REST clients, typed by OpenAPI: GitHub's by @octokit/openapi-types, and Git's by
|
|
158
163
|
# types `openapi-typescript` writes from its OpenAPI document. MIT.
|
|
159
164
|
openapi-fetch: 0.17.0
|
|
160
|
-
openapi-react-query: 0.5.4
|
|
161
165
|
openapi-typescript: 7.13.0
|
|
162
166
|
# Mermaid drawn as SVG on the server, with no DOM: the app's diagrams, in its Markdown. MIT.
|
|
163
167
|
pele: 1.13.0
|
|
@@ -168,7 +172,7 @@ catalog:
|
|
|
168
172
|
react-day-picker: 10.0.2
|
|
169
173
|
react-dom: 19.3.1
|
|
170
174
|
# Rolldown, the bundler Alchemy's Workers build with: for examples/git-alchemy's test that
|
|
171
|
-
# @ref0/
|
|
175
|
+
# @ref0/xdiff-wasm resolves as Alchemy's Worker bundle does, at Alchemy's own version. MIT.
|
|
172
176
|
rolldown: 1.2.16
|
|
173
177
|
# npm's version ranges, for ref0-git's property that `init` reads a framework's major from its
|
|
174
178
|
# package.json spec as npm does. ISC. At the release already in the lockfile.
|
|
@@ -214,3 +218,6 @@ allowBuilds:
|
|
|
214
218
|
better-sqlite3: true
|
|
215
219
|
esbuild: true
|
|
216
220
|
workerd: true
|
|
221
|
+
|
|
222
|
+
minimumReleaseAgeExclude:
|
|
223
|
+
- '@ref0/workspace@0.8.0'
|
package/app/tsconfig.base.json
CHANGED
package/dist/cli/child.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const signalled = (error) => /receipt of signal: '([A-Z0-9]+)'/.exec(error.messa
|
|
|
13
13
|
* can't prompt, and its output on stderr, so stdout holds only the answer. A cancel sends it
|
|
14
14
|
* SIGINT, and SIGKILL if it hasn't stopped within `stopMs`.
|
|
15
15
|
*/
|
|
16
|
-
const runChild = Effect.fnUntraced(function* (argv, cwd) {
|
|
16
|
+
const runChild = /* @__PURE__ */ Effect.fnUntraced(function* (argv, cwd) {
|
|
17
17
|
const [command, ...args] = argv;
|
|
18
18
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
19
19
|
const stdio = yield* Stdio.Stdio;
|
package/dist/cli/credentials.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gitRun } from "./git.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Redacted from "effect/Redacted";
|
|
4
3
|
import * as Data from "effect/Data";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
5
|
// src/cli/credentials.ts
|
|
6
6
|
/**
|
|
7
7
|
* Git's credential protocol, as `git-remote-ref0` and `ref0-git` speak it: `git credential fill`,
|
|
@@ -44,7 +44,7 @@ const fieldsOf = (text) => new Map(text.split("\n").flatMap((line) => {
|
|
|
44
44
|
* The credential Git's helpers keep for `url`, or `undefined` when none does. With `ask`, Git may
|
|
45
45
|
* ask at the terminal, as it does for a push; without, it never does.
|
|
46
46
|
*/
|
|
47
|
-
const fillCredential = Effect.fnUntraced(function* (url, options = {}) {
|
|
47
|
+
const fillCredential = /* @__PURE__ */ Effect.fnUntraced(function* (url, options = {}) {
|
|
48
48
|
const input = yield* credentialInput(url);
|
|
49
49
|
const ran = yield* gitRun(options.ask === true ? ["credential", "fill"] : [
|
|
50
50
|
"-c",
|
|
@@ -71,14 +71,14 @@ const fillCredential = Effect.fnUntraced(function* (url, options = {}) {
|
|
|
71
71
|
};
|
|
72
72
|
});
|
|
73
73
|
/** Stores `credential` for `url` in each of Git's helpers. */
|
|
74
|
-
const approveCredential = Effect.fnUntraced(function* (url, credential) {
|
|
74
|
+
const approveCredential = /* @__PURE__ */ Effect.fnUntraced(function* (url, credential) {
|
|
75
75
|
yield* gitRun(["credential", "approve"], {
|
|
76
76
|
input: yield* credentialInput(url, credential),
|
|
77
77
|
keepStarted: true
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
/** Removes `credential`, or whatever is kept for `url` with none, from each of Git's helpers. */
|
|
81
|
-
const rejectCredential = Effect.fnUntraced(function* (url, credential) {
|
|
81
|
+
const rejectCredential = /* @__PURE__ */ Effect.fnUntraced(function* (url, credential) {
|
|
82
82
|
yield* gitRun(["credential", "reject"], { input: yield* credentialInput(url, credential) });
|
|
83
83
|
});
|
|
84
84
|
export { BrokenField, approveCredential, breaksField, fillCredential, rejectCredential, signals };
|