@usine/gateway 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +99 -11
  3. package/dist/admin/api.d.ts +6 -66
  4. package/dist/admin/api.d.ts.map +1 -1
  5. package/dist/admin/api.js +4 -4
  6. package/dist/admin/api.js.map +1 -1
  7. package/dist/admin/server.d.ts +1 -1
  8. package/dist/admin/server.d.ts.map +1 -1
  9. package/dist/admin/server.js +1 -1
  10. package/dist/admin/server.js.map +1 -1
  11. package/dist/attachment/attachment.d.ts +8 -1
  12. package/dist/attachment/attachment.d.ts.map +1 -1
  13. package/dist/attachment/attachment.js +14 -4
  14. package/dist/attachment/attachment.js.map +1 -1
  15. package/dist/attachment/store.d.ts +7 -0
  16. package/dist/attachment/store.d.ts.map +1 -1
  17. package/dist/attachment/store.js +46 -14
  18. package/dist/attachment/store.js.map +1 -1
  19. package/dist/caller/caller.d.ts +1 -1
  20. package/dist/caller/caller.d.ts.map +1 -1
  21. package/dist/caller/caller.js +8 -7
  22. package/dist/caller/caller.js.map +1 -1
  23. package/dist/chatgpt/auth-file.d.ts +47 -0
  24. package/dist/chatgpt/auth-file.d.ts.map +1 -0
  25. package/dist/chatgpt/auth-file.js +132 -0
  26. package/dist/chatgpt/auth-file.js.map +1 -0
  27. package/dist/chatgpt/logins.d.ts +50 -0
  28. package/dist/chatgpt/logins.d.ts.map +1 -0
  29. package/dist/chatgpt/logins.js +303 -0
  30. package/dist/chatgpt/logins.js.map +1 -0
  31. package/dist/gateway.d.ts +8 -4
  32. package/dist/gateway.d.ts.map +1 -1
  33. package/dist/gateway.js +8 -4
  34. package/dist/gateway.js.map +1 -1
  35. package/dist/github/github.d.ts +19 -8
  36. package/dist/github/github.d.ts.map +1 -1
  37. package/dist/github/github.js +45 -21
  38. package/dist/github/github.js.map +1 -1
  39. package/dist/github/rename.d.ts +30 -0
  40. package/dist/github/rename.d.ts.map +1 -0
  41. package/dist/github/rename.js +83 -0
  42. package/dist/github/rename.js.map +1 -0
  43. package/dist/llm/llm.d.ts +64 -15
  44. package/dist/llm/llm.d.ts.map +1 -1
  45. package/dist/llm/llm.js +89 -37
  46. package/dist/llm/llm.js.map +1 -1
  47. package/dist/node/egress-proxy.js +1 -1
  48. package/dist/node/egress-proxy.js.map +1 -1
  49. package/dist/node/environment.d.ts +15 -10
  50. package/dist/node/environment.d.ts.map +1 -1
  51. package/dist/node/environment.js +51 -24
  52. package/dist/node/environment.js.map +1 -1
  53. package/dist/node/node.d.ts +7 -8
  54. package/dist/node/node.d.ts.map +1 -1
  55. package/dist/node/node.js +22 -23
  56. package/dist/node/node.js.map +1 -1
  57. package/dist/node/reload.d.ts +2 -1
  58. package/dist/node/reload.d.ts.map +1 -1
  59. package/dist/node/reload.js +41 -13
  60. package/dist/node/reload.js.map +1 -1
  61. package/dist/proxy/forward.d.ts +2 -2
  62. package/dist/proxy/forward.d.ts.map +1 -1
  63. package/dist/proxy/forward.js +1 -1
  64. package/dist/proxy/forward.js.map +1 -1
  65. package/dist/proxy/proxy.d.ts +4 -3
  66. package/dist/proxy/proxy.d.ts.map +1 -1
  67. package/dist/proxy/proxy.js +132 -24
  68. package/dist/proxy/proxy.js.map +1 -1
  69. package/package.json +9 -9
@@ -0,0 +1,303 @@
1
+ import { Context, DateTime, Effect, Fiber, FileSystem, Layer, Option, Redacted, Ref, Schema, Semaphore, SynchronizedRef, } from "effect";
2
+ import { HttpClient, HttpClientRequest } from "effect/http";
3
+ import { ChatGptTokens, idTokenAccount, jwtExpiry, readAuthFile, writeAuthFile, } from "./auth-file.js";
4
+ /** The OAuth token endpoint that Codex refreshes ChatGPT logins at. */
5
+ export const CHATGPT_TOKEN_URL = "https://auth.openai.com/oauth/token";
6
+ /** Codex's public OAuth client ID; a login's refresh token works only with it. */
7
+ const CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
8
+ /** An access token that expires within this window is refreshed first, as Codex does. */
9
+ const REFRESH_WINDOW = "5 minutes";
10
+ /** An access token without an `exp` claim is refreshed when its last refresh is older than this, as Codex does. */
11
+ const REFRESH_INTERVAL = "8 days";
12
+ /** After a failed refresh, requests fail for this long without calling the token endpoint. */
13
+ const FAILURE_BACKOFF = "10 seconds";
14
+ /** A 401 for an access token refreshed this recently doesn't start another refresh. */
15
+ const REFUSAL_GRACE = "1 minute";
16
+ /** The number of rotated refresh tokens remembered, so a reload never goes back to one. */
17
+ const RETIRED_TOKENS = 8;
18
+ /** The token endpoint's error codes for a refresh token that can't be used again (Codex `classify_refresh_token_failure`). */
19
+ const REJECTED_CODES = new Set([
20
+ "refresh_token_expired",
21
+ "refresh_token_reused",
22
+ "refresh_token_invalidated",
23
+ ]);
24
+ /**
25
+ * The error for a request whose ChatGPT login has no usable access token: the auth file can't
26
+ * be read (`unreadable`), a refresh failed and is tried again after a short backoff
27
+ * (`refresh-failed`), or the token endpoint rejected the refresh token, which only a new login
28
+ * fixes (`refresh-rejected`). The message names no token and no text from the token endpoint.
29
+ * The reverse proxy answers 401 for `refresh-rejected`, and otherwise 503, which Codex retries.
30
+ */
31
+ export class ChatGptLoginUnavailable extends Schema.TaggedError()("ChatGptLoginUnavailable", {
32
+ authFile: Schema.String,
33
+ reason: Schema.Literals(["unreadable", "refresh-failed", "refresh-rejected"]),
34
+ message: Schema.String,
35
+ }) {
36
+ }
37
+ /** A string field that Codex reads as absent when it's null or empty. */
38
+ const OptionalText = Schema.optionalKey(Schema.NullOr(Schema.String));
39
+ const RefreshResponse = Schema.fromJsonString(Schema.Struct({
40
+ access_token: OptionalText,
41
+ refresh_token: OptionalText,
42
+ id_token: OptionalText,
43
+ }));
44
+ const decodeRefreshResponse = Schema.decodeUnknownOption(RefreshResponse);
45
+ const present = (value) => Option.fromNullishOr(value).pipe(Option.filter((text) => text !== ""));
46
+ const decodeErrorText = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({ error: Schema.String })));
47
+ const decodeErrorObject = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({ error: Schema.Struct({ code: Schema.String }) })));
48
+ const decodeErrorCode = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({ code: Schema.String })));
49
+ /** An error code as OAuth servers send them; other text could echo a token, so it's dropped. */
50
+ const ERROR_CODE = /^[a-z0-9_.-]{1,64}$/u;
51
+ /**
52
+ * Returns the error code in a token endpoint's error body, in lowercase: `error`, `error.code`,
53
+ * or `code`, as Codex reads it. A value that doesn't look like a code is ignored.
54
+ */
55
+ const tokenErrorCode = (body) => decodeErrorText(body).pipe(Option.map(({ error }) => error), Option.orElse(() => Option.map(decodeErrorObject(body), ({ error }) => error.code)), Option.orElse(() => Option.map(decodeErrorCode(body), ({ code }) => code)), Option.map((code) => code.toLowerCase()), Option.filter((code) => ERROR_CODE.test(code)));
56
+ /** The client error statuses that a later request can get past: a request timeout and a rate limit. */
57
+ const TRANSIENT_CLIENT_ERRORS = new Set([408, 429]);
58
+ /**
59
+ * Whether a refresh failure means the refresh token can't be used again: a client error other
60
+ * than a timeout or rate limit, such as `invalid_grant`, or one of Codex's rejection codes.
61
+ * Server errors and network errors are transient.
62
+ */
63
+ const isRejection = (status, code) => (status >= 400 && status < 500 && !TRANSIENT_CLIENT_ERRORS.has(status)) ||
64
+ Option.exists(code, (value) => REJECTED_CODES.has(value));
65
+ const fresh = (tokens, retired) => ({
66
+ tokens,
67
+ refused: false,
68
+ rejected: Option.none(),
69
+ retired,
70
+ refreshedAt: Option.none(),
71
+ failedAt: Option.none(),
72
+ });
73
+ /** Whether `instant` is less than `duration` before `now`. */
74
+ const within = (instant, duration, now) => Option.exists(instant, (at) => DateTime.isGreaterThan(DateTime.addDuration(at, duration), now));
75
+ /** Whether `tokens` must be refreshed at `now` before the next request. */
76
+ const refreshDue = (tokens, now) => Option.match(tokens.expiresAt, {
77
+ onSome: (expiresAt) => !DateTime.isGreaterThan(DateTime.subtractDuration(expiresAt, REFRESH_WINDOW), now),
78
+ onNone: () => Option.match(tokens.lastRefresh, {
79
+ onNone: () => false,
80
+ onSome: (last) => !DateTime.isGreaterThan(DateTime.addDuration(last, REFRESH_INTERVAL), now),
81
+ }),
82
+ });
83
+ const usable = (state, now) => !state.refused && Option.isNone(state.rejected) && !refreshDue(state.tokens, now);
84
+ /** Whether `refreshToken` is this login's current refresh token or one it replaced. */
85
+ const holds = (state, refreshToken) => Redacted.value(state.tokens.refreshToken) === refreshToken ||
86
+ state.retired.includes(refreshToken);
87
+ const accessOf = ({ accessToken, accountId }) => ({
88
+ accessToken,
89
+ accountId,
90
+ });
91
+ const expiryField = (tokens) => Option.match(tokens.expiresAt, { onNone: () => "unknown", onSome: DateTime.formatIso });
92
+ /**
93
+ * The ChatGPT logins the Gateway holds, keyed by auth file. Each login's tokens stay in memory;
94
+ * an access token is refreshed before it expires, one refresh at a time, and the rotated tokens
95
+ * are written back to the auth file. A request never gets an access token that a failed
96
+ * refresh should have replaced.
97
+ */
98
+ export class ChatGptLogins extends Context.Service()("@usine/gateway/ChatGptLogins") {
99
+ static layer = Layer.effect(ChatGptLogins, Effect.gen(function* () {
100
+ const fs = yield* FileSystem.FileSystem;
101
+ const client = yield* HttpClient.HttpClient;
102
+ const scope = yield* Effect.scope;
103
+ const states = yield* Ref.make(new Map());
104
+ // Refreshes and reloads run one at a time, so a rotated refresh token is used once.
105
+ const lock = yield* Semaphore.make(1);
106
+ const inFlight = yield* SynchronizedRef.make(new Map());
107
+ const stateOf = (authFile) => Effect.map(Ref.get(states), (all) => Option.fromNullishOr(all.get(authFile)));
108
+ const store = (authFile, state) => Ref.update(states, (all) => new Map(all).set(authFile, state));
109
+ const unavailable = (login, reason) => {
110
+ switch (reason) {
111
+ case "unreadable":
112
+ return new ChatGptLoginUnavailable({
113
+ authFile: login.authFile,
114
+ reason,
115
+ message: `The gateway can't read its ChatGPT login at ${login.authFile}. Its log has the reason.`,
116
+ });
117
+ case "refresh-failed":
118
+ return new ChatGptLoginUnavailable({
119
+ authFile: login.authFile,
120
+ reason,
121
+ message: `The gateway could not refresh its ChatGPT login and tries again after ${FAILURE_BACKOFF}. Its log has the reason.`,
122
+ });
123
+ case "refresh-rejected":
124
+ return new ChatGptLoginUnavailable({
125
+ authFile: login.authFile,
126
+ reason,
127
+ message: `The token endpoint rejected the refresh token of the gateway's ChatGPT login. Copy a new auth.json from codex login to ${login.authFile} and reload the gateway.`,
128
+ });
129
+ }
130
+ };
131
+ /** Returns the login's state, reading its auth file if it has none. */
132
+ const loaded = Effect.fn("ChatGptLogins.loaded")(function* (login) {
133
+ const current = yield* stateOf(login.authFile);
134
+ if (Option.isSome(current))
135
+ return current.value;
136
+ const tokens = yield* readAuthFile(login.authFile).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.tapError((error) => Effect.logError("Could not read the ChatGPT login", {
137
+ authFile: login.authFile,
138
+ error: error.message,
139
+ })), Effect.mapError(() => unavailable(login, "unreadable")));
140
+ const state = fresh(tokens, []);
141
+ yield* store(login.authFile, state);
142
+ yield* Effect.logInfo("Loaded the ChatGPT login", {
143
+ authFile: login.authFile,
144
+ expiresAt: expiryField(tokens),
145
+ });
146
+ return state;
147
+ });
148
+ /** Records a refresh the token endpoint rejected, so later requests fail without calling it. */
149
+ const rejectRefresh = Effect.fn("ChatGptLogins.rejectRefresh")(function* (login, state, status, code) {
150
+ const why = Option.getOrElse(code, () => `HTTP ${String(status)}`);
151
+ yield* store(login.authFile, { ...state, rejected: Option.some(why) });
152
+ yield* Effect.logError("The token endpoint rejected the ChatGPT login's refresh token; copy a new auth.json from codex login and reload the gateway", { authFile: login.authFile, status, code: why });
153
+ return unavailable(login, "refresh-rejected");
154
+ });
155
+ /** Records a refresh that failed for another reason, so requests back off before the next one. */
156
+ const failRefresh = Effect.fn("ChatGptLogins.failRefresh")(function* (login, state, error) {
157
+ yield* store(login.authFile, { ...state, failedAt: Option.some(yield* DateTime.now) });
158
+ yield* Effect.logError("Could not refresh the ChatGPT login; a later request tries again", {
159
+ authFile: login.authFile,
160
+ error,
161
+ backoff: FAILURE_BACKOFF,
162
+ });
163
+ return unavailable(login, "refresh-failed");
164
+ });
165
+ /**
166
+ * Exchanges the refresh token for new tokens and writes them back to the auth file. Runs
167
+ * uninterruptibly: once the token endpoint has rotated the refresh token, only storing the
168
+ * new one keeps the login usable.
169
+ */
170
+ const refresh = Effect.fn("ChatGptLogins.refresh")(function* (login, state) {
171
+ yield* Effect.annotateCurrentSpan({ authFile: login.authFile });
172
+ const request = HttpClientRequest.post(login.tokenUrl).pipe(HttpClientRequest.acceptJson, HttpClientRequest.bodyJsonUnsafe({
173
+ client_id: CODEX_CLIENT_ID,
174
+ grant_type: "refresh_token",
175
+ refresh_token: Redacted.value(state.tokens.refreshToken),
176
+ }));
177
+ const answer = yield* client.execute(request).pipe(Effect.flatMap((response) => Effect.map(response.text, (body) => ({ status: response.status, body }))), Effect.provideService(HttpClient.TracerDisabledWhen, () => true), Effect.catchTag("HttpClientError", (error) => Effect.flip(failRefresh(login, state, error.reason._tag))));
178
+ if (answer.status < 200 || answer.status >= 300) {
179
+ const code = tokenErrorCode(answer.body);
180
+ return yield* Effect.flip(isRejection(answer.status, code)
181
+ ? rejectRefresh(login, state, answer.status, code)
182
+ : failRefresh(login, state, `the token endpoint answered ${String(answer.status)} (${Option.getOrElse(code, () => "no error code")})`));
183
+ }
184
+ const body = decodeRefreshResponse(answer.body);
185
+ const accessToken = Option.flatMap(body, ({ access_token }) => present(access_token));
186
+ if (Option.isNone(body) || Option.isNone(accessToken))
187
+ return yield* Effect.flip(failRefresh(login, state, "the token endpoint's answer has no access_token"));
188
+ const refreshToken = present(body.value.refresh_token);
189
+ const idToken = present(body.value.id_token);
190
+ const now = yield* DateTime.now;
191
+ const tokens = new ChatGptTokens({
192
+ accessToken: Redacted.make(accessToken.value),
193
+ refreshToken: Option.match(refreshToken, {
194
+ onNone: () => state.tokens.refreshToken,
195
+ onSome: Redacted.make,
196
+ }),
197
+ accountId: state.tokens.accountId.pipe(Option.orElse(() => Option.flatMap(idToken, idTokenAccount))),
198
+ expiresAt: jwtExpiry(accessToken.value),
199
+ lastRefresh: Option.some(now),
200
+ });
201
+ const retired = Option.isSome(refreshToken)
202
+ ? [Redacted.value(state.tokens.refreshToken), ...state.retired].slice(0, RETIRED_TOKENS)
203
+ : state.retired;
204
+ yield* store(login.authFile, {
205
+ ...fresh(tokens, retired),
206
+ refreshedAt: Option.some(now),
207
+ });
208
+ yield* Effect.logInfo("Refreshed the ChatGPT login", {
209
+ authFile: login.authFile,
210
+ expiresAt: expiryField(tokens),
211
+ rotated: Option.isSome(refreshToken),
212
+ });
213
+ yield* writeAuthFile(login.authFile, tokens, idToken, (inFile) => holds(state, inFile)).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.flatMap((written) => written
214
+ ? Effect.logInfo("Wrote the refreshed ChatGPT login to its auth file", {
215
+ authFile: login.authFile,
216
+ })
217
+ : Effect.logWarning("Left the auth file as it is: it holds another ChatGPT login, which the next reload reads", { authFile: login.authFile })), Effect.catchTag("ChatGptAuthFileError", (error) => Effect.logError("Could not write the refreshed ChatGPT login to its auth file; the gateway keeps it in memory, and after a restart the file's refresh token may no longer work", { authFile: login.authFile, error: error.message })));
218
+ return tokens;
219
+ }, Effect.uninterruptible);
220
+ /** Returns a usable access token, refreshing first if needed. Runs under the lock. */
221
+ const refreshed = Effect.fn("ChatGptLogins.refreshed")(function* (login) {
222
+ const state = yield* loaded(login);
223
+ if (Option.isSome(state.rejected))
224
+ return yield* unavailable(login, "refresh-rejected");
225
+ const now = yield* DateTime.now;
226
+ if (usable(state, now))
227
+ return accessOf(state.tokens);
228
+ if (within(state.failedAt, FAILURE_BACKOFF, now))
229
+ return yield* unavailable(login, "refresh-failed");
230
+ yield* Effect.logInfo("Refreshing the ChatGPT login", {
231
+ authFile: login.authFile,
232
+ reason: state.refused ? "refused-by-upstream" : "expiring",
233
+ expiresAt: expiryField(state.tokens),
234
+ });
235
+ return accessOf(yield* refresh(login, state));
236
+ });
237
+ /** Returns the login's refresh in progress, or starts one in the service's scope. */
238
+ const refreshing = (login) => SynchronizedRef.modifyEffect(inFlight, (all) => {
239
+ const running = all.get(login.authFile);
240
+ if (running !== undefined)
241
+ return Effect.succeed([running, all]);
242
+ return lock
243
+ .withPermits(1)(refreshed(login))
244
+ .pipe(Effect.ensuring(SynchronizedRef.update(inFlight, (now) => {
245
+ const next = new Map(now);
246
+ next.delete(login.authFile);
247
+ return next;
248
+ })), Effect.forkIn(scope), Effect.map((fiber) => [fiber, new Map(all).set(login.authFile, fiber)]));
249
+ });
250
+ const access = Effect.fn("ChatGptLogins.access")(function* (login) {
251
+ yield* Effect.annotateCurrentSpan({ authFile: login.authFile });
252
+ const current = yield* stateOf(login.authFile);
253
+ if (Option.isSome(current) && usable(current.value, yield* DateTime.now))
254
+ return accessOf(current.value.tokens);
255
+ return yield* Fiber.join(yield* refreshing(login));
256
+ });
257
+ const refused = Effect.fn("ChatGptLogins.refused")(function* (login, presented) {
258
+ yield* Effect.annotateCurrentSpan({ authFile: login.authFile });
259
+ const now = yield* DateTime.now;
260
+ // Marks the state in one update, so a refresh that ends meanwhile isn't overwritten.
261
+ const outcome = yield* Ref.modify(states, (all) => {
262
+ const current = all.get(login.authFile);
263
+ if (current === undefined ||
264
+ Redacted.value(current.tokens.accessToken) !== Redacted.value(presented.accessToken))
265
+ return ["replaced", all];
266
+ if (within(current.refreshedAt, REFUSAL_GRACE, now))
267
+ return ["recent", all];
268
+ return ["marked", new Map(all).set(login.authFile, { ...current, refused: true })];
269
+ });
270
+ switch (outcome) {
271
+ case "replaced":
272
+ return yield* Effect.logDebug("The ChatGPT backend refused an access token the gateway already replaced", { authFile: login.authFile });
273
+ case "recent":
274
+ return yield* Effect.logWarning("The ChatGPT backend refused an access token refreshed less than a minute ago; the gateway doesn't refresh it again yet", { authFile: login.authFile });
275
+ case "marked":
276
+ return yield* Effect.logWarning("The ChatGPT backend refused the gateway's access token; the next request refreshes it first", { authFile: login.authFile });
277
+ }
278
+ });
279
+ const reload = Effect.fn("ChatGptLogins.reload")(function* (login) {
280
+ yield* Effect.annotateCurrentSpan({ authFile: login.authFile });
281
+ const tokens = yield* readAuthFile(login.authFile).pipe(Effect.provideService(FileSystem.FileSystem, fs));
282
+ const all = yield* Ref.get(states);
283
+ const read = Redacted.value(tokens.refreshToken);
284
+ // Any login that holds the file's refresh token, also under another path, already used or rotated it.
285
+ const holder = Option.fromNullishOr(all.get(login.authFile)).pipe(Option.filter((state) => holds(state, read)), Option.orElse(() => Option.fromNullishOr([...all.values()].find((state) => holds(state, read)))));
286
+ if (Option.isSome(holder)) {
287
+ yield* store(login.authFile, holder.value);
288
+ return yield* Effect.logInfo("Kept the ChatGPT login: its auth file has the same login", {
289
+ authFile: login.authFile,
290
+ rejected: Option.isSome(holder.value.rejected),
291
+ });
292
+ }
293
+ yield* store(login.authFile, fresh(tokens, []));
294
+ yield* Effect.logInfo("Loaded the ChatGPT login", {
295
+ authFile: login.authFile,
296
+ expiresAt: expiryField(tokens),
297
+ replaced: all.has(login.authFile),
298
+ });
299
+ }, lock.withPermits(1));
300
+ return { access, refused, reload };
301
+ }));
302
+ }
303
+ //# sourceMappingURL=logins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logins.js","sourceRoot":"","sources":["../../src/chatgpt/logins.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EAER,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,QAAQ,EACR,GAAG,EACH,MAAM,EACN,SAAS,EACT,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAEL,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,qCAAqC,CAAC;AAEvE,kFA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,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAC5E,CACF,CAAC;YACF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,0DAA0D,EAAE;oBACvF,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;iBAC/C,CAAC,CAAC;YACL,CAAC;YACD,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;YAChD,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,EAAE;gBAChD,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC;gBAC9B,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;aAClC,CAAC,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAExB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC,CAAC,CACH,CAAC;CACH"}
package/dist/gateway.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Layer } from "effect";
2
2
  import { Attachments } from "./attachment/store.ts";
3
3
  import { CallerTokens } from "./caller/caller.ts";
4
+ import { ChatGptLogins } from "./chatgpt/logins.ts";
4
5
  import { SettingsInForce } from "./settings.ts";
5
6
  export { adminRoutes } from "./admin/server.ts";
6
7
  export { AnonymousCredential, Attachment, AttachmentAlreadyExpired, AttachmentConflict, AttachmentCredential, AttachmentId, type AttachmentLookup, ExpiredAttachment, InstallationCredential, LiveAttachment, MissingAttachment, } from "./attachment/attachment.ts";
@@ -8,7 +9,9 @@ export { Attachments } from "./attachment/store.ts";
8
9
  export { CallerClaims, CallerToken, CallerTokenRejected, CallerTokens, GATEWAY_TOKEN_HEADER, tokenFromAuthorization, } from "./caller/caller.ts";
9
10
  export { type EgressDecision, EgressAllowlist, EgressAllowlistError, EgressPermitted, EgressRefusalReason, EgressRefused, EgressRule, HostName, parseEgressAllowlist, Port, } from "./egress/egress.ts";
10
11
  export { GITHUB_ORIGINS, type GitHubOrigins } from "./github/github.ts";
11
- export { AnthropicApiKey, AnthropicCredential, AnthropicProvider, AnthropicSubscriptionToken, type LlmProviders, OpenAiProvider, } from "./llm/llm.ts";
12
+ export { ChatGptAuthFileError, ChatGptTokens } from "./chatgpt/auth-file.ts";
13
+ export { CHATGPT_TOKEN_URL, ChatGptLoginUnavailable, ChatGptLogins } from "./chatgpt/logins.ts";
14
+ export { AnthropicApiKey, AnthropicCredential, AnthropicProvider, AnthropicSubscriptionToken, type ChatGptAccess, ChatGptLogin, HostFilePath, type LlmProvider, type LlmProviders, OpenAiApiKey, OpenAiCredential, OpenAiProvider, } from "./llm/llm.ts";
12
15
  export { endToEndHeaders } from "./proxy/forward.ts";
13
16
  export { GatewayProxy, REFUSAL_HEADER, RefusalReason } from "./proxy/proxy.ts";
14
17
  export { GatewayDomain } from "@usine/core/worker";
@@ -16,8 +19,9 @@ export { AdminToken, CallerKey, GatewaySettings, gatewayHosts, type ReloadableSe
16
19
  export { UpstreamBase } from "./upstream.ts";
17
20
  /**
18
21
  * The Gateway's shared state for one process: the attachment store, the caller token signer,
19
- * and the current settings. Provide this layer once to the reverse proxy, forward proxy, admin
20
- * API, and reload.
22
+ * the current settings, and the ChatGPT logins. Provide this layer once to the reverse proxy,
23
+ * forward proxy, admin API, and reload. The logins need a `FileSystem` for their auth files and
24
+ * an `HttpClient` for refreshes.
21
25
  */
22
- export declare const gatewayServices: Layer.Layer<Attachments | CallerTokens | SettingsInForce, never, import("./settings.ts").GatewaySettings>;
26
+ export declare const gatewayServices: Layer.Layer<Attachments | CallerTokens | ChatGptLogins | SettingsInForce, never, import("effect/FileSystem").FileSystem | import("./settings.ts").GatewaySettings | import("effect/http/HttpClient").HttpClient>;
23
27
  //# sourceMappingURL=gateway.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,cAAc,EACnB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,oBAAoB,EACpB,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,YAAY,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BAAmB,EACnB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,oBAAoB,EACpB,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,aAAa,EAClB,YAAY,EACZ,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACZ,KAAK,kBAAkB,EACvB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,eAAe,kNAK3B,CAAC"}
package/dist/gateway.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Layer } from "effect";
2
2
  import { Attachments } from "./attachment/store.js";
3
3
  import { CallerTokens } from "./caller/caller.js";
4
+ import { ChatGptLogins } from "./chatgpt/logins.js";
4
5
  import { SettingsInForce } from "./settings.js";
5
6
  export { adminRoutes } from "./admin/server.js";
6
7
  export { AnonymousCredential, Attachment, AttachmentAlreadyExpired, AttachmentConflict, AttachmentCredential, AttachmentId, ExpiredAttachment, InstallationCredential, LiveAttachment, MissingAttachment, } from "./attachment/attachment.js";
@@ -8,7 +9,9 @@ export { Attachments } from "./attachment/store.js";
8
9
  export { CallerClaims, CallerToken, CallerTokenRejected, CallerTokens, GATEWAY_TOKEN_HEADER, tokenFromAuthorization, } from "./caller/caller.js";
9
10
  export { EgressAllowlist, EgressAllowlistError, EgressPermitted, EgressRefusalReason, EgressRefused, EgressRule, HostName, parseEgressAllowlist, Port, } from "./egress/egress.js";
10
11
  export { GITHUB_ORIGINS } from "./github/github.js";
11
- export { AnthropicApiKey, AnthropicCredential, AnthropicProvider, AnthropicSubscriptionToken, OpenAiProvider, } from "./llm/llm.js";
12
+ export { ChatGptAuthFileError, ChatGptTokens } from "./chatgpt/auth-file.js";
13
+ export { CHATGPT_TOKEN_URL, ChatGptLoginUnavailable, ChatGptLogins } from "./chatgpt/logins.js";
14
+ export { AnthropicApiKey, AnthropicCredential, AnthropicProvider, AnthropicSubscriptionToken, ChatGptLogin, HostFilePath, OpenAiApiKey, OpenAiCredential, OpenAiProvider, } from "./llm/llm.js";
12
15
  export { endToEndHeaders } from "./proxy/forward.js";
13
16
  export { GatewayProxy, REFUSAL_HEADER, RefusalReason } from "./proxy/proxy.js";
14
17
  export { GatewayDomain } from "@usine/core/worker";
@@ -16,8 +19,9 @@ export { AdminToken, CallerKey, GatewaySettings, gatewayHosts, SettingsInForce,
16
19
  export { UpstreamBase } from "./upstream.js";
17
20
  /**
18
21
  * The Gateway's shared state for one process: the attachment store, the caller token signer,
19
- * and the current settings. Provide this layer once to the reverse proxy, forward proxy, admin
20
- * API, and reload.
22
+ * the current settings, and the ChatGPT logins. Provide this layer once to the reverse proxy,
23
+ * forward proxy, admin API, and reload. The logins need a `FileSystem` for their auth files and
24
+ * an `HttpClient` for refreshes.
21
25
  */
22
- export const gatewayServices = Layer.mergeAll(Attachments.layer, CallerTokens.layer, SettingsInForce.layer);
26
+ export const gatewayServices = Layer.mergeAll(Attachments.layer, CallerTokens.layer, SettingsInForce.layer, ChatGptLogins.layer);
23
27
  //# sourceMappingURL=gateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EAEZ,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,oBAAoB,EACpB,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAE1B,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,EAE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E,iBAAiB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAE1B,YAAY,EACZ,YAAY,EAGZ,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,EAEZ,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,CAC3C,WAAW,CAAC,KAAK,EACjB,YAAY,CAAC,KAAK,EAClB,eAAe,CAAC,KAAK,EACrB,aAAa,CAAC,KAAK,CACpB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { RepositoryName } from "@usine/core/repository";
2
2
  import { Option } from "effect";
3
- import { Headers } from "effect/unstable/http";
3
+ import { Headers } from "effect/http";
4
4
  import type { AttachmentCredential } from "../attachment/attachment.ts";
5
5
  import { UpstreamBase } from "../upstream.ts";
6
6
  /** The upstream origins for GitHub requests: `web` for git smart HTTP, `api` for REST and GraphQL, `uploads` for release asset uploads. */
@@ -21,23 +21,34 @@ export type GitHubHost = "gateway" | "web" | "api" | "uploads";
21
21
  /** GitHub's host names and what each serves. */
22
22
  export declare const GITHUB_HOSTS: ReadonlyMap<string, GitHubHost>;
23
23
  /**
24
- * A forwarded GitHub request: git smart HTTP for a repository, or an API call. `repository` is
25
- * the repository in the path; GraphQL and calls such as `/user` have none.
24
+ * A forwarded GitHub request: git smart HTTP or a release download for a repository, or an API
25
+ * call. `repository` is the repository in the path; GraphQL and calls such as `/user` have none.
26
26
  */
27
27
  export interface GitHubRoute {
28
- readonly protocol: "git" | "api";
28
+ readonly protocol: "git" | "release" | "api";
29
29
  readonly upstream: string;
30
30
  readonly repository: Option.Option<RepositoryName>;
31
31
  }
32
+ /** Returns `value` as a URL if it is an absolute URL. */
33
+ export declare const absoluteUrl: (value: string) => Option.Option<URL>;
34
+ /** Returns `pathname` after `prefix`, if it is `prefix` or a path under it. */
35
+ export declare const afterPrefix: (pathname: string, prefix: string) => Option.Option<string>;
32
36
  /**
33
37
  * Returns the upstream URL and repository for a GitHub request. Returns `None` for paths
34
- * outside git smart HTTP, Git LFS, and the API, such as web pages.
38
+ * outside git smart HTTP, Git LFS, release downloads, and the API, such as web pages.
35
39
  */
36
40
  export declare const githubRoute: (origins: GitHubOrigins, host: GitHubHost, pathname: string, search: string) => Option.Option<GitHubRoute>;
41
+ /**
42
+ * Returns `location` on `git.<domain>` if it points at github.com or api.github.com, with its
43
+ * path and query, so a Worker follows GitHub's redirects, such as those for a renamed
44
+ * repository, through the gateway. API paths move under `/api/v3`. Returns `None` for other
45
+ * hosts, such as the release asset hosts.
46
+ */
47
+ export declare const gatewayLocation: (origins: GitHubOrigins, gitHost: string, location: URL) => Option.Option<URL>;
37
48
  /**
38
49
  * Adds the attachment's credential to a GitHub request whose caller credential was removed: as
39
- * the `x-access-token` password for git, or as a bearer token for the API. An anonymous
40
- * attachment adds nothing.
50
+ * the `x-access-token` password for github.com, which serves git and release downloads, or as a
51
+ * bearer token for the API. An anonymous attachment adds nothing.
41
52
  */
42
- export declare const withGitHubCredential: (route: GitHubRoute, credential: AttachmentCredential, headers: Headers.Headers) => Headers.Headers;
53
+ export declare const withGitHubCredential: (protocol: GitHubRoute["protocol"], credential: AttachmentCredential, headers: Headers.Headers) => Headers.Headers;
43
54
  //# sourceMappingURL=github.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","s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MAAM,KACb,MAAM,CAAC,MAAM,CAAC,WAAW,CAiB3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,YACjB,aAAa,WACb,MAAM,YACL,GAAG,KACZ,MAAM,CAAC,MAAM,CAAC,GAAG,CAOnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aACrB,WAAW,CAAC,UAAU,CAAC,cACrB,oBAAoB,WACvB,OAAO,CAAC,OAAO,KACvB,OAAO,CAAC,OAeV,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { RepositoryName } from "@usine/core/repository";
2
- import { Encoding, Option, Redacted, Schema } from "effect";
3
- import { Headers } from "effect/unstable/http";
2
+ import { Option, Redacted, Result, Schema } from "effect";
3
+ import { Base64 } from "effect/encoding";
4
+ import { Headers } from "effect/http";
4
5
  import { UpstreamBase } from "../upstream.js";
5
6
  /** The github.com origins. */
6
7
  export const GITHUB_ORIGINS = {
@@ -15,17 +16,26 @@ export const GITHUB_HOSTS = new Map([
15
16
  ["uploads.github.com", "uploads"],
16
17
  ]);
17
18
  const GIT_PATH = /^\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/(?:info\/refs|git-upload-pack|git-receive-pack|info\/lfs(?:\/[^?#]*)?)$/u;
19
+ /** `/OWNER/REPO/releases/download/TAG/FILE`, whose tag can contain `/`, and `/OWNER/REPO/releases/latest/download/FILE`. */
20
+ const RELEASE_DOWNLOAD_PATH = /^\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/releases\/(?:download\/.+|latest\/download)\/[^/]+$/u;
21
+ const WEB_PATHS = [
22
+ ["git", GIT_PATH],
23
+ ["release", RELEASE_DOWNLOAD_PATH],
24
+ ];
18
25
  const REPOSITORY_PATH = /^\/repos\/([^/]+)\/([^/]+)(?:\/|$)/u;
19
26
  const decodeRepository = Schema.decodeUnknownOption(RepositoryName);
20
- const gitRoute = (origins, pathname, search) => {
21
- const match = GIT_PATH.exec(pathname);
22
- if (match === null)
23
- return Option.none();
24
- return Option.map(decodeRepository(`${match[1]}/${match[2]}`), (repository) => ({
25
- protocol: "git",
26
- upstream: `${origins.web}${pathname}${search}`,
27
- repository: Option.some(repository),
28
- }));
27
+ /** Returns the github.com route for a repository's git smart HTTP or release download path. */
28
+ const webRoute = (origins, pathname, search) => {
29
+ for (const [protocol, pattern] of WEB_PATHS) {
30
+ const match = pattern.exec(pathname);
31
+ if (match !== null)
32
+ return Option.map(decodeRepository(`${match[1]}/${match[2]}`), (repository) => ({
33
+ protocol,
34
+ upstream: `${origins.web}${pathname}${search}`,
35
+ repository: Option.some(repository),
36
+ }));
37
+ }
38
+ return Option.none();
29
39
  };
30
40
  /** Returns the route for an API path, or `None` for a `/repos/OWNER/REPO` path whose segments aren't a valid repository name. */
31
41
  const apiRoute = (base, rest, search) => {
@@ -40,17 +50,20 @@ const apiRoute = (base, rest, search) => {
40
50
  repository: named,
41
51
  }));
42
52
  };
43
- const afterPrefix = (pathname, prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
53
+ /** Returns `value` as a URL if it is an absolute URL. */
54
+ export const absoluteUrl = (value) => Result.getSuccess(Result.try(() => new URL(value)));
55
+ /** Returns `pathname` after `prefix`, if it is `prefix` or a path under it. */
56
+ export const afterPrefix = (pathname, prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
44
57
  ? Option.some(pathname.slice(prefix.length))
45
58
  : Option.none();
46
59
  /**
47
60
  * Returns the upstream URL and repository for a GitHub request. Returns `None` for paths
48
- * outside git smart HTTP, Git LFS, and the API, such as web pages.
61
+ * outside git smart HTTP, Git LFS, release downloads, and the API, such as web pages.
49
62
  */
50
63
  export const githubRoute = (origins, host, pathname, search) => {
51
64
  switch (host) {
52
65
  case "web":
53
- return gitRoute(origins, pathname, search);
66
+ return webRoute(origins, pathname, search);
54
67
  case "api":
55
68
  return apiRoute(origins.api, pathname, search);
56
69
  case "uploads":
@@ -64,24 +77,35 @@ export const githubRoute = (origins, host, pathname, search) => {
64
77
  const upload = afterPrefix(pathname, "/api/uploads");
65
78
  if (Option.isSome(upload))
66
79
  return apiRoute(origins.uploads, upload.value, search);
67
- return gitRoute(origins, pathname, search);
80
+ return webRoute(origins, pathname, search);
68
81
  }
69
82
  }
70
83
  };
84
+ /**
85
+ * Returns `location` on `git.<domain>` if it points at github.com or api.github.com, with its
86
+ * path and query, so a Worker follows GitHub's redirects, such as those for a renamed
87
+ * repository, through the gateway. API paths move under `/api/v3`. Returns `None` for other
88
+ * hosts, such as the release asset hosts.
89
+ */
90
+ export const gatewayLocation = (origins, gitHost, location) => {
91
+ const target = `${location.origin}${location.pathname}`;
92
+ const onGateway = (prefix) => (rest) => new URL(`http://${gitHost}${prefix}${rest}${location.search}${location.hash}`);
93
+ return Option.map(afterPrefix(target, origins.web), onGateway("")).pipe(Option.orElse(() => Option.map(afterPrefix(target, origins.api), onGateway("/api/v3"))));
94
+ };
71
95
  /**
72
96
  * Adds the attachment's credential to a GitHub request whose caller credential was removed: as
73
- * the `x-access-token` password for git, or as a bearer token for the API. An anonymous
74
- * attachment adds nothing.
97
+ * the `x-access-token` password for github.com, which serves git and release downloads, or as a
98
+ * bearer token for the API. An anonymous attachment adds nothing.
75
99
  */
76
- export const withGitHubCredential = (route, credential, headers) => {
100
+ export const withGitHubCredential = (protocol, credential, headers) => {
77
101
  switch (credential._tag) {
78
102
  case "AnonymousCredential":
79
103
  return headers;
80
104
  case "InstallationCredential": {
81
105
  const token = Redacted.value(credential.token);
82
- return Headers.set(headers, "authorization", route.protocol === "git"
83
- ? `Basic ${Encoding.encodeBase64(`x-access-token:${token}`)}`
84
- : `Bearer ${token}`);
106
+ return Headers.set(headers, "authorization", protocol === "api"
107
+ ? `Bearer ${token}`
108
+ : `Basic ${Base64.encode(`x-access-token:${token}`)}`);
85
109
  }
86
110
  }
87
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/github/github.ts"],"names":[],"mappings":"AAAA,OA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