@preventive/triage 1.0.0-alpha.72 → 1.0.0-alpha.74

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 (138) hide show
  1. package/common/bundle-compare-diff.d.ts +4 -1
  2. package/common/bundle-compare-diff.js +4 -3
  3. package/common/bundle-sources.d.ts +2 -0
  4. package/common/bundle-sources.js +22 -3
  5. package/common/finding-duplicates.js +5 -0
  6. package/common/finding-filters.js +45 -4
  7. package/common/line-diff.d.ts +2 -2
  8. package/common/line-diff.js +20 -8
  9. package/common/managed/finding-detail.js +1 -1
  10. package/common/managed/review-view-routes.js +23 -0
  11. package/common/managed/risk-routes.js +30 -0
  12. package/common/managed/routes.js +11 -6
  13. package/common/managed/team-app.d.ts +8 -6
  14. package/common/managed/team-app.js +15 -3
  15. package/common/stasis-files.d.ts +5 -0
  16. package/common/stasis-files.js +20 -0
  17. package/common/stasis-tgz.d.ts +6 -0
  18. package/common/stasis-tgz.js +27 -0
  19. package/common/workspace-app.js +20 -0
  20. package/out/activity.js +2 -4
  21. package/out/{chunk-2F3CYNPZ.js → chunk-2IHCVA3Y.js} +1 -1
  22. package/out/{chunk-HAZKDK4M.js → chunk-2V6Q4ZOZ.js} +1 -1
  23. package/out/{chunk-RRBIJL2B.js → chunk-4IW3VD3H.js} +1 -1
  24. package/out/chunk-4YZOXAXR.js +2 -0
  25. package/out/chunk-5YP7P5KA.js +1 -0
  26. package/out/chunk-62QT2RXR.js +6 -0
  27. package/out/chunk-6VOB5WXX.js +2 -0
  28. package/out/chunk-A4BBBHQU.js +1 -0
  29. package/out/{chunk-4ISO5F7Y.js → chunk-ADMVRLNP.js} +1 -1
  30. package/out/{chunk-HETCVNO4.js → chunk-BLPHP4U3.js} +1 -1
  31. package/out/{chunk-Y5ZHFNBD.js → chunk-BXQCCW7F.js} +1 -1
  32. package/out/chunk-C6OPCPCA.js +1 -0
  33. package/out/{chunk-JFL7WLRV.js → chunk-CU3FPB3P.js} +1 -1
  34. package/out/chunk-DQJEVHRE.js +52 -0
  35. package/out/chunk-ESJZZF2Y.js +255 -0
  36. package/out/{chunk-M37X4LCF.js → chunk-EXQQ5VQJ.js} +1 -1
  37. package/out/{chunk-NXATZJQ2.js → chunk-GSNSP3EF.js} +1 -1
  38. package/out/chunk-GV5U7OLP.js +40 -0
  39. package/out/{chunk-JOXLZXMI.js → chunk-GX5UXWT4.js} +1 -1
  40. package/out/chunk-HLMQ7QYS.js +1 -0
  41. package/out/{chunk-YF4M5OCI.js → chunk-I6UQQKAH.js} +1 -1
  42. package/out/{chunk-UCP3JRE2.js → chunk-LVW7WWV4.js} +1 -1
  43. package/out/chunk-NEFCZAIY.js +11 -0
  44. package/out/{chunk-TOXMUOIW.js → chunk-OQS2USZM.js} +1 -1
  45. package/out/chunk-PLF4LBLE.js +1 -0
  46. package/out/chunk-QBFT2DDR.js +1 -0
  47. package/out/{chunk-QMVOEBWC.js → chunk-S2ZIKK45.js} +1 -1
  48. package/out/chunk-S5HSDGTP.js +8 -0
  49. package/out/chunk-SSPDMA6D.js +1 -0
  50. package/out/{chunk-4XIH7YTX.js → chunk-UH6NZBSU.js} +1 -1
  51. package/out/{chunk-M3Y6SLC4.js → chunk-UJP4PQJA.js} +1 -1
  52. package/out/{chunk-PAD2JHZT.js → chunk-UJSJMXEG.js} +1 -1
  53. package/out/chunk-VRAJCPV5.js +3 -0
  54. package/out/chunk-VS7RV24Z.js +4 -0
  55. package/out/{chunk-E3LFSUDJ.js → chunk-VYYUMYVW.js} +1 -1
  56. package/out/chunk-W5PRH5D7.js +2 -0
  57. package/out/{chunk-VRX2APNA.js → chunk-XVKDPU4D.js} +1 -1
  58. package/out/{chunk-WKFBZYJX.js → chunk-YI4D6XVX.js} +1 -1
  59. package/out/client-managed-import.js +3 -3
  60. package/out/client-managed.js +30 -28
  61. package/out/compare.js +16 -23
  62. package/out/dialogs.js +38 -38
  63. package/out/graph.js +14 -14
  64. package/out/index.html +31 -51
  65. package/out/scan.js +2 -2
  66. package/out/terminal.js +239 -240
  67. package/out/view.css +1 -1
  68. package/out/view.js +15 -15
  69. package/package.json +21 -13
  70. package/risk/actions/resolve.js +47 -16
  71. package/risk/actions/uses.js +27 -9
  72. package/risk/actions/workflow.js +75 -2
  73. package/risk/files/hosts.js +4 -4
  74. package/risk/files/readability.js +5 -2
  75. package/risk/files/runs-code.js +12 -25
  76. package/risk/files/script.js +141 -19
  77. package/risk/index.d.ts +24 -7
  78. package/risk/index.js +1 -0
  79. package/risk/npm/assess.js +1 -1
  80. package/risk/npm/compare.js +5 -4
  81. package/risk/npm/diff.js +1 -1
  82. package/risk/npm/held.js +6 -2
  83. package/risk/npm/registry.js +5 -2
  84. package/risk/npm/tarball.js +79 -22
  85. package/server-managed/bundle-advisories.ts +12 -36
  86. package/server-managed/bundle-build-worker.js +29 -11
  87. package/server-managed/bundle-build.ts +4 -3
  88. package/server-managed/bundle-cache.ts +53 -13
  89. package/server-managed/bundle.ts +45 -13
  90. package/server-managed/comparison.ts +7 -6
  91. package/server-managed/db-methods.ts +54 -17
  92. package/server-managed/db-neon.ts +9 -2
  93. package/server-managed/db-schema.ts +12 -2
  94. package/server-managed/db.ts +4 -1
  95. package/server-managed/dependency-reviews.ts +8 -5
  96. package/server-managed/github-errors.ts +22 -0
  97. package/server-managed/github-requests.ts +4 -2
  98. package/server-managed/http.ts +238 -27
  99. package/server-managed/management.ts +10 -4
  100. package/server-managed/npm-delta.ts +1 -1
  101. package/server-managed/npm-loads.ts +2 -2
  102. package/server-managed/npm-packages.ts +34 -29
  103. package/server-managed/npm-patch-paths.ts +57 -0
  104. package/server-managed/npm-patch.ts +77 -82
  105. package/server-managed/package-entry-points.ts +54 -6
  106. package/server-managed/rename-diff-worker.js +11 -7
  107. package/server-managed/rename-diff.ts +5 -4
  108. package/server-managed/report-opening.ts +77 -0
  109. package/server-managed/report-sources.ts +2 -1
  110. package/server-managed/repository-aliases.ts +34 -0
  111. package/server-managed/repository-browser.ts +87 -32
  112. package/server-managed/repository-code.ts +14 -8
  113. package/server-managed/repository-dependency-reviews.ts +21 -0
  114. package/server-managed/repository-risk-read.ts +71 -4
  115. package/server-managed/repository-risk.ts +9 -2
  116. package/server-managed/stasis-config.ts +97 -5
  117. package/server-managed/team-reports.ts +5 -3
  118. package/server-managed/type-only-proof.js +26 -4
  119. package/server-managed/upstream-cache.ts +18 -12
  120. package/server-managed/workspace-shares.ts +4 -4
  121. package/out/chunk-27Y75UQR.js +0 -4
  122. package/out/chunk-4RS3NDOG.js +0 -1
  123. package/out/chunk-4XSH6ZLT.js +0 -1
  124. package/out/chunk-7CHIFYQW.js +0 -42
  125. package/out/chunk-CZ3U2LI4.js +0 -2
  126. package/out/chunk-ETL5ZPPR.js +0 -259
  127. package/out/chunk-L6VIWL2Y.js +0 -1
  128. package/out/chunk-OSHR3N4S.js +0 -3
  129. package/out/chunk-UD33S2MG.js +0 -52
  130. package/out/chunk-VG5RH6KN.js +0 -2
  131. package/out/chunk-WFDXHPT2.js +0 -12
  132. package/out/chunk-WMFDQS2L.js +0 -11
  133. package/out/chunk-WREU7JAG.js +0 -1
  134. /package/out/{chunk-4LZK6C6N.js → chunk-74JZTGTO.js} +0 -0
  135. /package/out/{chunk-JMG5DXII.js → chunk-7HP2VYIC.js} +0 -0
  136. /package/out/{chunk-HOB3YPS5.js → chunk-K4XJHM2T.js} +0 -0
  137. /package/out/{chunk-4EMM6UCD.js → chunk-QI66YA4F.js} +0 -0
  138. /package/out/{chunk-G3LY2FV4.js → chunk-WCDYSIKG.js} +0 -0
@@ -8,7 +8,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'
8
8
  import { WebSocket } from 'ws'
9
9
  import { type ManagedDb, type ManagedDbOptions, createManagedMethods } from './db-methods.ts'
10
10
  import { revisionSchema } from './revisions.ts'
11
- import { MANAGED_SCHEMA, REPO_UPLOAD_INDEXES, VIEW_SESSION_INDEX } from './db-schema.ts'
11
+ import { MANAGED_SCHEMA, REPORT_OPENING_COLUMNS, REPO_UPLOAD_INDEXES, VIEW_SESSION_INDEX } from './db-schema.ts'
12
12
  import { STORAGE_SCHEMA } from './storage-db.ts'
13
13
  import { GITHUB_COMMIT_SCHEMA, GITHUB_METADATA_SCHEMA, GITHUB_STATE_REASON_COLUMN } from './github-metadata.ts'
14
14
  import { MANAGED_ISSUE_SCHEMA } from './managed-issues.ts'
@@ -40,7 +40,7 @@ const LOCK = 'SELECT pg_advisory_xact_lock(1937006964, 1835101793)'
40
40
  // Whether every version up to the latest is recorded, in one round trip at
41
41
  // a cold start: a database with no versions table yet (undefined_table) has
42
42
  // none. Outside a transaction, so the failed read aborts nothing.
43
- const SCHEMA_VERSIONS = 36
43
+ const SCHEMA_VERSIONS = 38
44
44
  async function currentSchema(db: PgConnection): Promise<boolean> {
45
45
  try {
46
46
  const { rows } = await db.query(`SELECT count(*) AS n FROM managed_schema_version WHERE version BETWEEN 1 AND ${SCHEMA_VERSIONS}`)
@@ -139,6 +139,13 @@ async function migrateFrom12(db: PgConnection): Promise<void> {
139
139
  // The patch a dependency review's base is of, none of those written
140
140
  // before; each author's one draft of a comparison held to it too.
141
141
  await migration(db, 36, `ALTER TABLE managed_dependency_review ${addColumns(DEPENDENCY_REVIEW_COLUMNS)}`, DEPENDENCY_REVIEW_INDEXES)
142
+ // Whether a report may open on Confirmed, existing ones read for it as the
143
+ // reports page lists them (report-opening.ts), and none switched yet.
144
+ await migration(db, 37, `ALTER TABLE managed_report ${addColumns(REPORT_OPENING_COLUMNS)}`)
145
+ // When a dependency review was last published to a team, none of those
146
+ // published before: a time in milliseconds, so BIGINT, as postgresSchema
147
+ // makes SQLite's INTEGER.
148
+ await migration(db, 38, postgresSchema(`ALTER TABLE managed_dependency_review ${addColumns(DEPENDENCY_REVIEW_COLUMNS)}`))
142
149
  }
143
150
 
144
151
  async function initialize(db: PgConnection): Promise<void> {
@@ -27,6 +27,9 @@ export const inUserTeamScope = (user: string, row: string) => `EXISTS (SELECT 1
27
27
  JOIN managed_team t ON t.id = tu.team_id AND t.hidden = 0
28
28
  WHERE tu.user_id = ${user} AND tr.repo_id = ${row}.repo_id AND ${withinTeamPath(`${row}.repo_directory`)})`
29
29
 
30
+ // A report's opening (report-opening.ts), added to databases created before it.
31
+ export const REPORT_OPENING_COLUMNS = [['confirmed_offered', 'INTEGER'], ['confirmed_default', 'INTEGER NOT NULL DEFAULT 0']] as const
32
+
30
33
  export const MANAGED_SCHEMA = `
31
34
  CREATE TABLE IF NOT EXISTS managed_user (
32
35
  id TEXT PRIMARY KEY,
@@ -133,7 +136,12 @@ CREATE INDEX IF NOT EXISTS managed_bundle_uploaded_at_idx ON managed_bundle(uplo
133
136
  -- links, nulled (not cascaded) when the user / selected repo goes away. bundle_id
134
137
  -- is the (nullable) auto-resolved link to a stored bundle; bundle_integrity is
135
138
  -- the report's declared primary bundle (from its bundleHashes), kept so a later
136
- -- bundle upload of that integrity can re-link.
139
+ -- bundle upload of that integrity can re-link. confirmed_offered is whether
140
+ -- the report, alone, may be switched to open on Confirmed (Manage → Reports,
141
+ -- report-opening.ts): 1 where its pass leaves Confirmed rows but it is no App
142
+ -- view on its own, 0 where the switch would change nothing, NULL where it is
143
+ -- yet to be read (one uploaded before the column).
144
+ -- confirmed_default is that switch, as a manager set it.
137
145
  CREATE TABLE IF NOT EXISTS managed_report (
138
146
  id TEXT PRIMARY KEY,
139
147
  slug TEXT NOT NULL,
@@ -151,7 +159,9 @@ CREATE TABLE IF NOT EXISTS managed_report (
151
159
  visible INTEGER NOT NULL DEFAULT 0,
152
160
  bundle_id TEXT REFERENCES managed_bundle(id) ON DELETE SET NULL,
153
161
  bundle_integrity TEXT,
154
- uploaded_at INTEGER NOT NULL
162
+ uploaded_at INTEGER NOT NULL,
163
+ confirmed_offered INTEGER,
164
+ confirmed_default INTEGER NOT NULL DEFAULT 0
155
165
  ) STRICT;
156
166
 
157
167
  CREATE INDEX IF NOT EXISTS managed_report_uploaded_at_idx ON managed_report(uploaded_at);
@@ -7,7 +7,7 @@ import { migrateReportLocations } from './report-migration.ts'
7
7
  import { initCommentMethods } from './comments.ts'
8
8
  import { initActivityMethods } from './activity.ts'
9
9
  import { revisionSchema } from './revisions.ts'
10
- import { MANAGED_SCHEMA, REPO_UPLOAD_INDEXES, VIEW_SESSION_INDEX } from './db-schema.ts'
10
+ import { MANAGED_SCHEMA, REPORT_OPENING_COLUMNS, REPO_UPLOAD_INDEXES, VIEW_SESSION_INDEX } from './db-schema.ts'
11
11
  import { GITHUB_LINK_USER_COLUMNS } from './github-links.ts'
12
12
  import { REPOSITORY_DEPENDENCY_REVIEW_COLUMNS } from './repository-dependency-reviews.ts'
13
13
  import { DEPENDENCY_REVIEW_COLUMNS, DEPENDENCY_REVIEW_INDEXES } from './dependency-reviews.ts'
@@ -108,6 +108,9 @@ export function openSqliteManagedDb(path: string, options: ManagedDbOptions = {}
108
108
  ensureColumn(db, 'managed_report', 'repo_embedded', 'INTEGER NOT NULL DEFAULT 0')
109
109
  migrateReportLocations(db, join(dirname(path), 'reports'))
110
110
  ensureColumn(db, 'managed_report', 'analyzer', 'TEXT')
111
+ // Existing reports are read for it as the reports page lists them
112
+ // (report-opening.ts), and none was switched yet.
113
+ for (const [column, type] of REPORT_OPENING_COLUMNS) ensureColumn(db, 'managed_report', column, type)
111
114
  // Existing rows predate publication controls and were already visible.
112
115
  // Backfill only when adding the column; newly inserted rows still use the
113
116
  // hidden default and must be explicitly published.
@@ -69,7 +69,7 @@ CREATE TABLE IF NOT EXISTS managed_dependency_review (
69
69
  time INTEGER NOT NULL, revision INTEGER NOT NULL, published_at INTEGER, revoked_at INTEGER, files TEXT,
70
70
  status TEXT CHECK (status IN ('accept', 'accept-with-nits', 'request-changes', 'reject')), comment TEXT NOT NULL DEFAULT '',
71
71
  shasum TEXT NOT NULL DEFAULT '', base_shasum TEXT NOT NULL DEFAULT '', patch_hash TEXT NOT NULL DEFAULT '', patch_source TEXT,
72
- base_patch_hash TEXT NOT NULL DEFAULT ''
72
+ base_patch_hash TEXT NOT NULL DEFAULT '', shared_at INTEGER
73
73
  ) STRICT;
74
74
  CREATE INDEX IF NOT EXISTS managed_dependency_review_context_idx
75
75
  ON managed_dependency_review(ecosystem, package, version, integrity, base_package, base_version, base_integrity, time);
@@ -88,8 +88,11 @@ CREATE TABLE IF NOT EXISTS managed_dependency_review_team (
88
88
  CREATE INDEX IF NOT EXISTS managed_dependency_review_team_idx ON managed_dependency_review_team(team_id, review_id);
89
89
  `
90
90
  // The columns added since the table was, for a database that has it already.
91
+ // `shared_at`: when it was last published to a team, its first or one more,
92
+ // as a team's Dependencies tab asks what changed since (repository-dependency-reviews.ts
93
+ // changedReviewVersions); none of one published before it was kept.
91
94
  export const DEPENDENCY_REVIEW_COLUMNS = [['shasum', "TEXT NOT NULL DEFAULT ''"], ['base_shasum', "TEXT NOT NULL DEFAULT ''"],
92
- ['patch_hash', "TEXT NOT NULL DEFAULT ''"], ['patch_source', 'TEXT'], ['base_patch_hash', "TEXT NOT NULL DEFAULT ''"]] as const
95
+ ['patch_hash', "TEXT NOT NULL DEFAULT ''"], ['patch_source', 'TEXT'], ['base_patch_hash', "TEXT NOT NULL DEFAULT ''"], ['shared_at', 'INTEGER']] as const
93
96
  // Each author's one draft of a comparison, its patches' too, made once those
94
97
  // columns are: those held to it before patches, then its base's, were reviewed gone.
95
98
  export const DEPENDENCY_REVIEW_INDEXES = `
@@ -202,12 +205,12 @@ async function publish(db: ManagedSql, current: DependencyReview | undefined, us
202
205
  if (!summarizeReview(entries, change.files, change.nonTextFiles).checkedFiles) throw new ManagedMutationError(400, 'no-reviewed-files')
203
206
  if (!change.final || !allowedReviewVerdicts(entries.filter(entry => !change.nonTextFiles.includes(entry.file))).includes(change.final.status)) throw new ManagedMutationError(400, 'bad-final-verdict')
204
207
  if (needsPackageJsonReview(entries, change.files, change.nonTextFiles)) throw new ManagedMutationError(400, 'package-json-not-reviewed')
205
- await db.prepare(`UPDATE managed_dependency_review SET published_at = ?, files = ?, status = ?, comment = ?, shasum = ?, base_shasum = ?, patch_source = ?, revision = revision + 1
206
- WHERE id = ?`).run(now, JSON.stringify({ paths: [...new Set(change.files)].toSorted(), nonTextFiles: [...new Set(change.nonTextFiles)].toSorted() }),
208
+ await db.prepare(`UPDATE managed_dependency_review SET published_at = ?, shared_at = ?, files = ?, status = ?, comment = ?, shasum = ?, base_shasum = ?, patch_source = ?,
209
+ revision = revision + 1 WHERE id = ?`).run(now, now, JSON.stringify({ paths: [...new Set(change.files)].toSorted(), nonTextFiles: [...new Set(change.nonTextFiles)].toSorted() }),
207
210
  change.final.status, change.final.comment, ...shasums(tarballs), current.id)
208
211
  } else {
209
212
  if (change.final) return conflict()
210
- await db.prepare('UPDATE managed_dependency_review SET revision = revision + 1 WHERE id = ?').run(current.id)
213
+ await db.prepare('UPDATE managed_dependency_review SET shared_at = ?, revision = revision + 1 WHERE id = ?').run(now, current.id)
211
214
  }
212
215
  for (const team of selected) await db.prepare('INSERT INTO managed_dependency_review_team (review_id, team_id) VALUES (?, ?) ON CONFLICT DO NOTHING').run(current.id, team)
213
216
  }
@@ -7,6 +7,9 @@ export class GithubApiError extends Error {
7
7
  retryAfter: number | null
8
8
  // What failed, where GitHub wasn't reached (githubUnreachable).
9
9
  detail: string | null
10
+ // The repository GitHub's redirect sends one asked of to, by its id, where
11
+ // it moved (githubMoved).
12
+ movedTo: number | null = null
10
13
  constructor(status: number, message: string, retryAfter: number | null = null, detail: string | null = null) {
11
14
  super(message)
12
15
  this.name = 'GithubApiError'
@@ -31,7 +34,25 @@ export function githubUnreachable(error: unknown, started: number): GithubApiErr
31
34
  return new GithubApiError(502, 'github-unreachable', null, `${failed}, after ${((Date.now() - started) / 1000).toFixed(1)}s`)
32
35
  }
33
36
 
37
+ // The statuses of a redirect, and where GitHub's API sends a repository
38
+ // renamed or transferred: to that repository by its id, then the rest of
39
+ // what was asked of it.
40
+ const REDIRECTS = new Set([301, 302, 303, 307, 308])
41
+ const REPOSITORY_BY_ID = /^https:\/\/api\.github\.com\/repositories\/([1-9]\d{0,14})(?:[/?]|$)/u
42
+
43
+ // A redirect GitHub answered, never followed, as it answers of a repository
44
+ // renamed or transferred since it was named so: `github-moved`, with the id of
45
+ // the repository it sends it to (`movedTo`), null where it names none.
46
+ function githubMoved(location: string | null | undefined): GithubApiError {
47
+ const error = new GithubApiError(502, 'github-moved')
48
+ const id = REPOSITORY_BY_ID.exec(location ?? '')?.[1]
49
+ error.movedTo = id === undefined ? null : Number(id)
50
+ return error
51
+ }
52
+ export const isGithubMoved = (error: unknown): error is GithubApiError => error instanceof GithubApiError && error.message === 'github-moved'
53
+
34
54
  export async function throwGithubResponseError(res: Response): Promise<never> {
55
+ if (REDIRECTS.has(res.status)) throw githubMoved(res.headers?.get('location'))
35
56
  if (res.status === 403 || res.status === 429) {
36
57
  const body = await res.json().catch(() => null) as { message?: unknown } | null
37
58
  if (res.status === 429 || res.headers.get('x-ratelimit-remaining') === '0' || res.headers.has('retry-after')
@@ -57,6 +78,7 @@ export async function upstreamGithub<T>(request: () => Promise<T>): Promise<T> {
57
78
  // status handling, including rate limits, without exposing that text.
58
79
  if (error.status === 401) throw new GithubApiError(401, 'github-unauthorized')
59
80
  if (error.status === 404) throw new GithubApiError(404, 'github-not-found')
81
+ if (REDIRECTS.has(error.status)) throw githubMoved((error as { headers?: Headers }).headers?.get('location'))
60
82
  if (error.status === 429 || (error.status === 403 && /rate limit|abuse detection/iu.test(error.message))) {
61
83
  throw new GithubApiError(429, 'github-rate-limited', 60)
62
84
  }
@@ -134,7 +134,9 @@ export const repoApi = (fullName: string) => `${GITHUB_API}/repos/${encodedPath(
134
134
  // share an outstanding read through its body; one GitHub answered with an
135
135
  // ETag is asked again If-None-Match, its body kept answering a 304
136
136
  // (taggedRead). POSTs only opt in for read-only GraphQL
137
- // queries (repository-history.ts), never for mutations or token mints.
137
+ // queries (repository-history.ts), never for mutations or token mints. A
138
+ // redirect is never followed: it fails as `github-moved` (github-errors.ts),
139
+ // as GitHub answers of a repository renamed or transferred.
138
140
  export function githubJson(url: string, token: string | null, fetchImpl: typeof fetch, method: 'GET' | 'POST' = 'GET', body?: unknown,
139
141
  readOnly = method === 'GET'): Promise<unknown> {
140
142
  if (readOnly) return shareGithubRead(fetchImpl, JSON.stringify([url, token, method, body]), () => githubJson(url, token, fetchImpl, method, body, false))
@@ -149,7 +151,7 @@ export function githubJson(url: string, token: string | null, fetchImpl: typeof
149
151
  res = await fetchImpl(url, {
150
152
  method,
151
153
  signal: AbortSignal.timeout(body === undefined ? 10_000 : 20_000),
152
- redirect: 'error',
154
+ redirect: 'manual',
153
155
  headers: {
154
156
  ...githubHeaders(token), ...(body === undefined ? {} : { 'content-type': 'application/json' }),
155
157
  ...(tagged ? { 'if-none-match': tagged.etag } : {}),