@sanoma-ai/connector-github 0.4.3 → 0.4.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sanoma-ai/connector-github
2
2
 
3
- GitHub resources for [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows): repositories, branch protection rules and team memberships, read through the [`integrations/github`](https://github.com/integrations/terraform-provider-github) OpenTofu provider (6.13.0) on [provider-bridge](https://github.com/Sanoma-AI/provider-bridge). It reads only: there is no create, update or delete yet.
3
+ GitHub resources for [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows): repositories, branch protection rules and team memberships, read through the [`integrations/github`](https://github.com/integrations/terraform-provider-github) OpenTofu provider (6.13.0) on [provider-bridge](https://github.com/Sanoma-AI/provider-bridge), and the company repository's pull requests, through its [remote half](#remote-half).
4
4
 
5
5
  ## Usage
6
6
 
@@ -35,6 +35,29 @@ The fields are the provider's attributes, by their names. A list block of at mos
35
35
 
36
36
  The logo is GitHub's mark from [Octicons](https://primer.style/octicons/) (`mark-github`, MIT), there only to identify the service an operation calls.
37
37
 
38
+ ## Remote half
39
+
40
+ The `github` connector carries GitHub's remote half (`githubRemote`, `withSetup(..., { remote })`): what a change is reviewed and merged through when the company's repository is on GitHub. `ResolvedConfig.remotes` holds it under `github`, and `remoteFor(remotes, url)` from `@sanoma-ai/workflows` finds it for a clone URL, `https://github.com/<owner>/<repo>(.git)`, `git@github.com:<owner>/<repo>(.git)` or `ssh://git@github.com/<owner>/<repo>(.git)`. `open(repo, { secrets })` gives the repository's `SourceHost` (the type is in `@sanoma-ai/workflows`):
41
+
42
+ | Method | GitHub's REST API |
43
+ | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | `pullRequestFor(branch)`, `pullRequest(number)` | `GET /repos/{owner}/{repo}/pulls?state=all&head={owner}:{branch}` (the open one, else the latest), `GET …/pulls/{number}` |
45
+ | `openPullRequest({ branch, base, title, body })` | `POST …/pulls`; the branch's open one into `base` when it has one already |
46
+ | `mergePullRequest(number, { sha, method: "squash", title })` | `PUT …/pulls/{number}/merge` at `sha`; a `DriverError` with `vendorCode` `head_moved` on 409 (the branch moved on), `not_mergeable` on 405, unless the pull request is merged already (a retry whose first answer was lost), when it answers the merge commit |
47
+ | `closePullRequest(number)`, `deleteBranch(branch)` | `PATCH …/pulls/{number}`, `DELETE …/git/refs/heads/{branch}` (nothing when it is gone) |
48
+ | `setStatus({ sha, state, description, targetUrl })` | `POST …/statuses/{sha}` with context `sanoma`, the description cut to GitHub's 140 characters |
49
+ | `enforcement(base)` | `GET …/rules/branches/{base}`: `pullRequest` when a ruleset requires a pull request, `check` when one requires the `sanoma` status check (rulesets only, not classic branch protection); GitHub's 403 for a plan without rules (a private repository on Free) is neither, with the reason |
50
+
51
+ Every call is plain `fetch` with GitHub's media type and `X-GitHub-Api-Version: 2022-11-28`. A failure is a `DriverError` with GitHub's status and message, retryable on a server error or a rate limit. A commit status works with a person's token and with the App; check runs would need an App, so the half sets statuses only.
52
+
53
+ **Tokens**, read through `secrets` on every call (the app's are the environment's, then the stored credentials), never logged: `githubToken(secrets, owner, prefer)` mints an installation token of the company's GitHub App when its keys are stored (`SANOMA_GITHUB_APP_ID`, `SANOMA_GITHUB_APP_PEM`, which the app's **Create GitHub App** stores; `GITHUB_APP_SECRETS` names them) and the App is installed on the owner (among its first 100 installations), signed with `appJwt`, and otherwise takes `GITHUB_TOKEN`, also when the App's keys do not work; `prefer: "token"` tries `GITHUB_TOKEN` first, as going live's push does. An opened repository mints its installation token for that repository alone (GITHUB_TOKEN when the installation does not cover it) and keeps its token for the calls made together and after them: an installation token until five minutes before its hour is out, a person's for five minutes, either until GitHub answers 401. With neither, a call fails, not retryable, `vendorCode` `no_token`. A `GITHUB_TOKEN` for the company's repository needs, as a fine-grained token on it: Contents, Pull requests and Commit statuses: write (Metadata: read comes with them), and the App the same.
54
+
55
+ **Webhooks:** `webhook(request, { secrets })` verifies `X-Hub-Signature-256` (HMAC SHA-256 of the body's bytes under `SANOMA_GITHUB_WEBHOOK_SECRET`, compared in constant time) and throws a `DriverError` (`bad_signature`, status 401) for a missing or wrong one, or `no_webhook_secret` when the secret is not stored. A `push` to a branch is `{ kind: "pushed", repo, branch, head }`; a `pull_request` `closed` is `{ kind: "closed", repo, branch, number, merged, sha }`, `sha` the merge commit when merged; any other event or action, a tag's push, a deleted branch and a fork's pull request are `[]`. A JSON body and a form-encoded `payload` are both read.
56
+
57
+ `owners({ secrets })` lists the accounts the App is installed on (`GET /app/installations`, signed as the App), what going live offers besides the token's own.
58
+
59
+ `@sanoma-ai/connector-github/remote` exports `githubRemote`, `githubToken`, `appJwt` and `GITHUB_APP_SECRETS`.
60
+
38
61
  ## Resource types
39
62
 
40
63
  `src/resources.gen.ts` is generated from the provider's schema by `pnpm generate`, which runs [`@sanoma-ai/bridge/tfschema`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/bridge/src/tfschema/AGENTS.md) with `src/resources.config.ts`: the provider (its release, sha256 and recorded schema are `@sanoma-ai/bridge`'s pin and fixture), the types to generate, and the attributes whose change replaces the object (ForceNew in the provider's source, which the schema does not carry). It is checked in and never edited by hand; `pnpm generate` on a clean tree changes nothing. `src/connector.ts` is the rest, one `tfConnector` record from [`@sanoma-ai/bridge/connector`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/bridge/README.md#connectors-for-opentofu-providers): each type's title, identity, `find` and `bindingId`, the field that names another resource (`branch_protection.repository_id`), and GitHub's title, logo and package. The connector, the constructors, the driver and the fake all derive from it.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * GitHub resources, read through the `integrations/github` OpenTofu provider: each type has a
3
3
  * `read` and an `import` operation (`github.repository.read`), both effect `read`. It carries its
4
- * live driver (`githubDriver`, on the default bridge) and its fake (`fakeGithub`), of which each
5
- * sandbox run makes its own.
4
+ * live driver (`githubDriver`, on the default bridge), its fake (`fakeGithub`), of which each
5
+ * sandbox run makes its own, and its remote half (`githubRemote`): a repository's pull requests,
6
+ * the `sanoma` status, the rules on a branch and the App's webhooks.
6
7
  */
7
8
  export declare const github: import("@sanoma-ai/workflows").Connector<"github", import("@sanoma-ai/bridge/connector").TfResources<"github", {
8
9
  repository: import("zod").ZodObject<{
package/dist/index.js CHANGED
@@ -2,11 +2,17 @@ import { withSetup } from "@sanoma-ai/workflows";
2
2
  import { githubTf } from "./connector.js";
3
3
  import { githubDriver } from "./driver.js";
4
4
  import { fakeGithub } from "./fake.js";
5
+ import { githubRemote } from "./remote.js";
5
6
  /**
6
7
  * GitHub resources, read through the `integrations/github` OpenTofu provider: each type has a
7
8
  * `read` and an `import` operation (`github.repository.read`), both effect `read`. It carries its
8
- * live driver (`githubDriver`, on the default bridge) and its fake (`fakeGithub`), of which each
9
- * sandbox run makes its own.
9
+ * live driver (`githubDriver`, on the default bridge), its fake (`fakeGithub`), of which each
10
+ * sandbox run makes its own, and its remote half (`githubRemote`): a repository's pull requests,
11
+ * the `sanoma` status, the rules on a branch and the App's webhooks.
10
12
  */
11
- export const github = withSetup(githubTf.connector, { driver: githubDriver, fake: fakeGithub });
13
+ export const github = withSetup(githubTf.connector, {
14
+ driver: githubDriver,
15
+ fake: fakeGithub,
16
+ remote: () => githubRemote,
17
+ });
12
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE;IAClD,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY;CAC3B,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type RemoteContext, type RemoteHalf } from "@sanoma-ai/workflows";
2
+ /** The secrets of the company's GitHub App the half reads, as the app's manifest flow stores them. */
3
+ export declare const GITHUB_APP_SECRETS: {
4
+ readonly id: "SANOMA_GITHUB_APP_ID";
5
+ readonly pem: "SANOMA_GITHUB_APP_PEM";
6
+ readonly webhook_secret: "SANOMA_GITHUB_WEBHOOK_SECRET";
7
+ };
8
+ /** A JWT the GitHub App signs for itself, good for 9 minutes: what its installations are listed and its tokens minted with. */
9
+ export declare function appJwt(appId: string, pem: string): string;
10
+ /**
11
+ * A token that writes to `owner`'s repositories: an installation token of the company's GitHub
12
+ * App (minted from `appJwt`) when its keys are stored and it is installed on `owner`, else the
13
+ * stored `GITHUB_TOKEN`; `prefer: "token"` tries `GITHUB_TOKEN` first. A `DriverError` with
14
+ * `vendorCode` `no_token` when there is neither.
15
+ */
16
+ export declare function githubToken(secrets: RemoteContext["secrets"], owner: string, prefer?: "app" | "token"): Promise<string>;
17
+ /**
18
+ * GitHub's remote half: `matches` a GitHub clone URL, `open`s a repository (its pull requests,
19
+ * the `sanoma` status, the rules on a branch), verifies and reads the App's webhooks, and lists
20
+ * the accounts the App is installed on.
21
+ */
22
+ export declare const githubRemote: RemoteHalf;
package/dist/remote.js ADDED
@@ -0,0 +1,389 @@
1
+ import { createHmac, createSign, timingSafeEqual } from "node:crypto";
2
+ import { DriverError, retryableStatus, } from "@sanoma-ai/workflows";
3
+ import { z } from "zod";
4
+ // GitHub's remote half: a repository's pull requests, the `sanoma` commit status, the rules on a
5
+ // branch and the App's webhooks, over GitHub's REST API with plain `fetch`. It signs in as the
6
+ // company's GitHub App when the App is installed on the owner, else with `GITHUB_TOKEN`.
7
+ /** The secrets of the company's GitHub App the half reads, as the app's manifest flow stores them. */
8
+ export const GITHUB_APP_SECRETS = {
9
+ id: "SANOMA_GITHUB_APP_ID",
10
+ pem: "SANOMA_GITHUB_APP_PEM",
11
+ webhook_secret: "SANOMA_GITHUB_WEBHOOK_SECRET",
12
+ };
13
+ /** A person's token, the one the resources' driver reads too. */
14
+ const TOKEN = "GITHUB_TOKEN";
15
+ /** The commit status's name, which a ruleset's required check names. */
16
+ const CONTEXT = "sanoma";
17
+ /** What `enforcement` says when GitHub refuses to read a branch's rules (a private repository on Free). */
18
+ const NO_RULES = "On a private repository this needs GitHub Team or Pro, or a public repository.";
19
+ const API = "https://api.github.com";
20
+ const jwtPart = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
21
+ /** A JWT the GitHub App signs for itself, good for 9 minutes: what its installations are listed and its tokens minted with. */
22
+ export function appJwt(appId, pem) {
23
+ const now = Math.floor(Date.now() / 1000);
24
+ const body = `${jwtPart({ alg: "RS256", typ: "JWT" })}.${jwtPart({ iat: now - 60, exp: now + 540, iss: appId })}`;
25
+ return `${body}.${createSign("RSA-SHA256").update(body).sign(pem, "base64url")}`;
26
+ }
27
+ /** One call to GitHub's REST API, signed in with `token`; a failure to reach it is a retryable `DriverError`. */
28
+ async function send(token, method, path, body) {
29
+ try {
30
+ const res = await fetch(`${API}${path}`, {
31
+ method,
32
+ headers: {
33
+ authorization: `Bearer ${token}`,
34
+ accept: "application/vnd.github+json",
35
+ "x-github-api-version": "2022-11-28",
36
+ "user-agent": "sanoma",
37
+ ...(body !== undefined && { "content-type": "application/json" }),
38
+ },
39
+ ...(body !== undefined && { body: JSON.stringify(body) }),
40
+ signal: AbortSignal.timeout(30_000),
41
+ });
42
+ // The body too: the timeout may fire while it streams.
43
+ const text = await res.text();
44
+ return { status: res.status, headers: res.headers, body: parseJson(text) };
45
+ }
46
+ catch (cause) {
47
+ throw new DriverError(`github: ${method} ${path}: the request failed`, { retryable: true, cause });
48
+ }
49
+ }
50
+ /** `text` as JSON, else the text itself (undefined when empty). */
51
+ function parseJson(text) {
52
+ try {
53
+ return text ? JSON.parse(text) : undefined;
54
+ }
55
+ catch {
56
+ return text;
57
+ }
58
+ }
59
+ /** A rate limit: a 429, or a 403 with no requests left or a `retry-after` (GitHub's secondary limits). */
60
+ const limited = ({ status, headers }) => status === 429 || (status === 403 && (headers.get("x-ratelimit-remaining") === "0" || headers.has("retry-after")));
61
+ /** GitHub's answer as a `DriverError`, its message GitHub's own; retryable on a rate limit or a server error. */
62
+ function failed(method, path, reply, vendorCode) {
63
+ const message = typeof reply.body?.message === "string" ? reply.body.message : `status ${reply.status}`;
64
+ return new DriverError(`github: ${method} ${path} answered ${reply.status}: ${message}`, {
65
+ retryable: retryableStatus(reply.status) || limited(reply),
66
+ status: reply.status,
67
+ ...(vendorCode && { vendorCode }),
68
+ });
69
+ }
70
+ /** The body of a 2xx answer, read with `schema`; anything else a `DriverError`. */
71
+ async function ok(token, method, path, schema, body) {
72
+ const reply = await send(token, method, path, body);
73
+ if (reply.status >= 300)
74
+ throw failed(method, path, reply);
75
+ return read(schema, reply.body, `${method} ${path}`);
76
+ }
77
+ function read(schema, body, what) {
78
+ const parsed = schema.safeParse(body);
79
+ if (!parsed.success) {
80
+ throw new DriverError(`github: ${what} answered what Sanoma cannot read: ${z.prettifyError(parsed.error)}`, {
81
+ retryable: false,
82
+ });
83
+ }
84
+ return parsed.data;
85
+ }
86
+ const Installation = z.object({ id: z.number(), account: z.object({ login: z.string(), type: z.string() }) });
87
+ const AccessToken = z.object({ token: z.string(), expires_at: z.string() });
88
+ /** A JWT of the App, when its keys are among `found`. */
89
+ function jwtOf(found) {
90
+ const id = found.get(GITHUB_APP_SECRETS.id);
91
+ const pem = found.get(GITHUB_APP_SECRETS.pem);
92
+ return id && pem ? appJwt(id, pem) : undefined;
93
+ }
94
+ const installations = (jwt) => ok(jwt, "GET", "/app/installations?per_page=100", z.array(Installation));
95
+ /**
96
+ * An installation token of the App, when its keys are among `found` and it is installed on
97
+ * `owner`; for the repository `name` alone when given, which GitHub refuses (422) when the
98
+ * installation does not cover it.
99
+ */
100
+ async function appToken(found, owner, name) {
101
+ const jwt = jwtOf(found);
102
+ if (!jwt)
103
+ return undefined;
104
+ const installation = (await installations(jwt)).find((i) => i.account.login.toLowerCase() === owner.toLowerCase());
105
+ if (!installation)
106
+ return undefined;
107
+ const scope = name === undefined ? undefined : { repositories: [name] };
108
+ const made = await ok(jwt, "POST", `/app/installations/${installation.id}/access_tokens`, AccessToken, scope);
109
+ return { token: made.token, expiresAt: Date.parse(made.expires_at) };
110
+ }
111
+ /** The token `githubToken` chooses (an installation token for the repository `name` alone, when given), with its expiry. */
112
+ async function mint(secrets, owner, prefer, name) {
113
+ const found = await secrets([TOKEN, GITHUB_APP_SECRETS.id, GITHUB_APP_SECRETS.pem]);
114
+ const token = found.get(TOKEN);
115
+ if (prefer === "token" && token)
116
+ return { token };
117
+ const app = await appToken(found, owner, name).catch((err) => {
118
+ // The App's keys stored but not working (a deleted App, a bad key, GitHub down): the person's token, when there is one.
119
+ if (token)
120
+ return undefined;
121
+ throw err instanceof DriverError
122
+ ? err
123
+ : new DriverError("github: signing as the GitHub App failed", { retryable: false, cause: err });
124
+ });
125
+ if (app)
126
+ return app;
127
+ if (token)
128
+ return { token };
129
+ throw new DriverError(`github: no ${TOKEN}, and the GitHub App is not installed on ${owner}`, {
130
+ retryable: false,
131
+ vendorCode: "no_token",
132
+ });
133
+ }
134
+ /**
135
+ * A token that writes to `owner`'s repositories: an installation token of the company's GitHub
136
+ * App (minted from `appJwt`) when its keys are stored and it is installed on `owner`, else the
137
+ * stored `GITHUB_TOKEN`; `prefer: "token"` tries `GITHUB_TOKEN` first. A `DriverError` with
138
+ * `vendorCode` `no_token` when there is neither.
139
+ */
140
+ export async function githubToken(secrets, owner, prefer = "app") {
141
+ return (await mint(secrets, owner, prefer)).token;
142
+ }
143
+ const Pull = z.object({
144
+ number: z.number(),
145
+ html_url: z.string(),
146
+ state: z.enum(["open", "closed"]),
147
+ merged_at: z.string().nullish(),
148
+ merge_commit_sha: z.string().nullish(),
149
+ head: z.object({ ref: z.string(), sha: z.string() }),
150
+ });
151
+ /** A pull request as GitHub answers it, as a change follows it: merged once `merged_at` is set. */
152
+ const pullOf = (pull) => ({
153
+ number: pull.number,
154
+ url: pull.html_url,
155
+ branch: pull.head.ref,
156
+ head: pull.head.sha,
157
+ state: pull.merged_at ? "merged" : pull.state,
158
+ ...(pull.merged_at && pull.merge_commit_sha && { mergeSha: pull.merge_commit_sha }),
159
+ });
160
+ const Rule = z.object({
161
+ type: z.string(),
162
+ parameters: z
163
+ .object({ required_status_checks: z.array(z.object({ context: z.string() })).optional() })
164
+ .loose()
165
+ .optional(),
166
+ });
167
+ /** A branch name in a path, each `/`-separated part encoded. */
168
+ const branchPath = (branch) => branch.split("/").map(encodeURIComponent).join("/");
169
+ /**
170
+ * The repository `repo` on GitHub, signed in as `githubToken` says. The token is kept for the calls
171
+ * made together and after them, an installation token until five minutes before its hour is out and
172
+ * a person's for five minutes, so a token or an installation set later is used soon after.
173
+ */
174
+ function openRepo(repo, { secrets }) {
175
+ const base = `/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
176
+ let kept;
177
+ let until = 0;
178
+ const token = async (prefer) => {
179
+ if (prefer !== undefined)
180
+ return (await mint(secrets, repo.owner, prefer, repo.name)).token;
181
+ if (kept && Date.now() >= until)
182
+ kept = undefined;
183
+ if (!kept) {
184
+ kept = mint(secrets, repo.owner, "app", repo.name);
185
+ until = Infinity;
186
+ }
187
+ const minted = await kept.catch((err) => {
188
+ kept = undefined;
189
+ throw err;
190
+ });
191
+ // An installation token until five minutes before its hour is out; a person's for five minutes.
192
+ until = Math.min(until, (minted.expiresAt ?? Date.now() + 600_000) - 300_000);
193
+ return minted.token;
194
+ };
195
+ const call = async (method, path, body) => {
196
+ const reply = await send(await token(), method, `${base}${path}`, body);
197
+ // A token revoked or rotated since it was kept: the next call takes a fresh one.
198
+ if (reply.status === 401)
199
+ kept = undefined;
200
+ return reply;
201
+ };
202
+ const okCall = async (method, path, schema, body, codes = {}) => {
203
+ const reply = await call(method, path, body);
204
+ if (reply.status >= 300)
205
+ throw failed(method, `${base}${path}`, reply, codes[reply.status]);
206
+ return read(schema, reply.body, `${method} ${base}${path}`);
207
+ };
208
+ const host = {
209
+ token,
210
+ async pullRequestFor(branch) {
211
+ const query = new URLSearchParams({ state: "all", head: `${repo.owner}:${branch}` });
212
+ const pulls = await okCall("GET", `/pulls?${query}`, z.array(Pull));
213
+ const pull = pulls.find((p) => p.state === "open") ?? pulls[0];
214
+ return pull && pullOf(pull);
215
+ },
216
+ async pullRequest(number) {
217
+ return pullOf(await okCall("GET", `/pulls/${number}`, Pull));
218
+ },
219
+ async openPullRequest({ branch, base: into, title, body }) {
220
+ const path = "/pulls";
221
+ const reply = await call("POST", path, { title, head: branch, base: into, body });
222
+ if (reply.status < 300)
223
+ return pullOf(read(Pull, reply.body, `POST ${base}${path}`));
224
+ // Opened already (by an earlier try of the same step): that one, when it is into the same base.
225
+ const exists = JSON.stringify(reply.body?.errors ?? "").includes("A pull request already exists");
226
+ if (reply.status === 422 && exists) {
227
+ const query = new URLSearchParams({ state: "open", head: `${repo.owner}:${branch}`, base: into });
228
+ const [open] = await okCall("GET", `/pulls?${query}`, z.array(Pull));
229
+ if (open)
230
+ return pullOf(open);
231
+ }
232
+ throw failed("POST", `${base}${path}`, reply);
233
+ },
234
+ async mergePullRequest(number, { sha, method, title }) {
235
+ const body = { sha, merge_method: method, ...(title && { commit_title: title }) };
236
+ // 409: the branch moved on from `sha`; 405: GitHub will not merge it (a conflict, a rule).
237
+ const codes = { 409: "head_moved", 405: "not_mergeable" };
238
+ try {
239
+ return { sha: (await okCall("PUT", `/pulls/${number}/merge`, z.object({ sha: z.string() }), body, codes)).sha };
240
+ }
241
+ catch (err) {
242
+ // A retry after a merge whose answer was lost: GitHub refuses it, but the pull request is merged.
243
+ if (!(err instanceof DriverError) || err.vendorCode === undefined)
244
+ throw err;
245
+ const pull = await host.pullRequest(number);
246
+ if (pull.state === "merged" && pull.mergeSha)
247
+ return { sha: pull.mergeSha };
248
+ throw err;
249
+ }
250
+ },
251
+ async closePullRequest(number) {
252
+ await okCall("PATCH", `/pulls/${number}`, Pull, { state: "closed" });
253
+ },
254
+ async deleteBranch(branch) {
255
+ const path = `/git/refs/heads/${branchPath(branch)}`;
256
+ const reply = await call("DELETE", path);
257
+ // GitHub answers a branch that is gone with 422, "Reference does not exist".
258
+ if (reply.status < 300 || (reply.status === 422 && /does not exist/i.test(reply.body?.message ?? "")))
259
+ return;
260
+ throw failed("DELETE", `${base}${path}`, reply);
261
+ },
262
+ async setStatus({ sha, state, description, targetUrl }) {
263
+ await okCall("POST", `/statuses/${sha}`, z.object({ id: z.number() }), {
264
+ state,
265
+ context: CONTEXT,
266
+ // GitHub refuses a description longer than 140 characters.
267
+ description: [...description].length > 140 ? `${[...description].slice(0, 139).join("")}…` : description,
268
+ ...(targetUrl && { target_url: targetUrl }),
269
+ });
270
+ },
271
+ async enforcement(branch) {
272
+ const path = `/rules/branches/${branchPath(branch)}`;
273
+ const reply = await call("GET", path);
274
+ // GitHub refuses to read rules where the plan has none: "Upgrade to GitHub Pro or make this repository public".
275
+ const unplanned = reply.status === 403 && !limited(reply) && /upgrade|public/i.test(reply.body?.message ?? "");
276
+ if (unplanned)
277
+ return { pullRequest: false, check: false, reason: NO_RULES };
278
+ if (reply.status >= 300)
279
+ throw failed("GET", `${base}${path}`, reply);
280
+ const rules = read(z.array(Rule), reply.body, `GET ${base}${path}`);
281
+ return {
282
+ pullRequest: rules.some((rule) => rule.type === "pull_request"),
283
+ check: rules.some((rule) => rule.type === "required_status_checks" &&
284
+ !!rule.parameters?.required_status_checks?.some((c) => c.context === CONTEXT)),
285
+ };
286
+ },
287
+ };
288
+ return host;
289
+ }
290
+ const Repository = z.object({ name: z.string(), owner: z.object({ login: z.string() }) });
291
+ const Push = z.object({ ref: z.string(), after: z.string(), deleted: z.boolean().optional(), repository: Repository });
292
+ const PullEvent = z.object({
293
+ action: z.string(),
294
+ number: z.number(),
295
+ pull_request: z.object({
296
+ merged: z.boolean().nullish(),
297
+ merge_commit_sha: z.string().nullish(),
298
+ head: z.object({ ref: z.string(), repo: z.object({ full_name: z.string() }).nullish() }),
299
+ }),
300
+ repository: Repository.extend({ full_name: z.string() }),
301
+ });
302
+ const repoOf = ({ name, owner }) => ({ owner: owner.login, name });
303
+ /** What a delivery of `event` says, for the events a change follows: a branch pushed, a pull request closed. */
304
+ function eventsOf(event, payload) {
305
+ if (event === "push") {
306
+ const push = read(Push, payload, "a push webhook");
307
+ if (push.deleted || !push.ref.startsWith("refs/heads/"))
308
+ return [];
309
+ return [
310
+ { kind: "pushed", repo: repoOf(push.repository), branch: push.ref.slice("refs/heads/".length), head: push.after },
311
+ ];
312
+ }
313
+ if (event === "pull_request") {
314
+ const pull = read(PullEvent, payload, "a pull_request webhook");
315
+ // A fork's branch is not the repository's own, though it may share a name.
316
+ if (pull.action !== "closed" || pull.pull_request.head.repo?.full_name !== pull.repository.full_name)
317
+ return [];
318
+ const merged = pull.pull_request.merged === true;
319
+ const sha = merged ? pull.pull_request.merge_commit_sha : undefined;
320
+ return [
321
+ {
322
+ kind: "closed",
323
+ repo: repoOf(pull.repository),
324
+ branch: pull.pull_request.head.ref,
325
+ number: pull.number,
326
+ merged,
327
+ ...(sha && { sha }),
328
+ },
329
+ ];
330
+ }
331
+ return [];
332
+ }
333
+ /** Whether `signature` (`X-Hub-Signature-256`) is `body`'s HMAC SHA-256 under `secret`, compared in constant time. */
334
+ function signedBy(secret, body, signature) {
335
+ const expected = Buffer.from(`sha256=${createHmac("sha256", secret).update(body).digest("hex")}`);
336
+ const given = Buffer.from(signature ?? "");
337
+ return given.length === expected.length && timingSafeEqual(given, expected);
338
+ }
339
+ /** A clone URL of a repository on GitHub: `https://github.com/o/r(.git)`, `git@github.com:o/r(.git)` or `ssh://git@github.com/o/r(.git)`. */
340
+ const GITHUB_URL = /^(?:https:\/\/(?:www\.)?github\.com\/|(?:ssh:\/\/)?git@github\.com[:/])([\w-]+)\/([\w.-]+?)(?:\.git)?\/?$/i;
341
+ /**
342
+ * GitHub's remote half: `matches` a GitHub clone URL, `open`s a repository (its pull requests,
343
+ * the `sanoma` status, the rules on a branch), verifies and reads the App's webhooks, and lists
344
+ * the accounts the App is installed on.
345
+ */
346
+ export const githubRemote = {
347
+ matches(url) {
348
+ const match = GITHUB_URL.exec(url.trim());
349
+ return match ? { owner: match[1], name: match[2] } : undefined;
350
+ },
351
+ open: openRepo,
352
+ async webhook(request, { secrets }) {
353
+ const secret = (await secrets([GITHUB_APP_SECRETS.webhook_secret])).get(GITHUB_APP_SECRETS.webhook_secret);
354
+ if (!secret) {
355
+ throw new DriverError(`github: ${GITHUB_APP_SECRETS.webhook_secret} is not stored, so no webhook can be verified`, {
356
+ retryable: false,
357
+ vendorCode: "no_webhook_secret",
358
+ });
359
+ }
360
+ const raw = Buffer.from(await request.arrayBuffer());
361
+ if (!signedBy(secret, raw, request.headers.get("x-hub-signature-256"))) {
362
+ throw new DriverError("github: the webhook's signature is missing or wrong", {
363
+ retryable: false,
364
+ status: 401,
365
+ vendorCode: "bad_signature",
366
+ });
367
+ }
368
+ // An App delivers JSON; a repository's own webhook may send it form-encoded, as `payload`.
369
+ const body = raw.toString("utf8");
370
+ const form = request.headers.get("content-type")?.startsWith("application/x-www-form-urlencoded");
371
+ const json = form ? new URLSearchParams(body).get("payload") : body;
372
+ let payload;
373
+ try {
374
+ payload = JSON.parse(json ?? "");
375
+ }
376
+ catch {
377
+ throw new DriverError("github: the webhook's body is not JSON", { retryable: false, vendorCode: "bad_payload" });
378
+ }
379
+ return eventsOf(request.headers.get("x-github-event"), payload);
380
+ },
381
+ async owners({ secrets }) {
382
+ const jwt = jwtOf(await secrets([GITHUB_APP_SECRETS.id, GITHUB_APP_SECRETS.pem]));
383
+ return (jwt ? await installations(jwt) : []).map(({ account }) => ({
384
+ login: account.login,
385
+ kind: account.type === "Organization" ? "organization" : "user",
386
+ }));
387
+ },
388
+ };
389
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,WAAW,EAOX,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iGAAiG;AACjG,+FAA+F;AAC/F,yFAAyF;AAEzF,sGAAsG;AACtG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,EAAE,EAAE,sBAAsB;IAC1B,GAAG,EAAE,uBAAuB;IAC5B,cAAc,EAAE,8BAA8B;CACtC,CAAC;AAEX,iEAAiE;AACjE,MAAM,KAAK,GAAG,cAAc,CAAC;AAE7B,wEAAwE;AACxE,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEzB,2GAA2G;AAC3G,MAAM,QAAQ,GAAG,gFAAgF,CAAC;AAElG,MAAM,GAAG,GAAG,wBAAwB,CAAC;AAErC,MAA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AG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,IAAI,OAAgB,CAAC;QACrB,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,WAAW,CAAC,wCAAwC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC;QACnH,CAAC;QACD,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;YACjE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAE,cAAwB,CAAC,CAAC,CAAE,MAAgB;SACtF,CAAC,CAAC,CAAC;IACN,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanoma-ai/connector-github",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "GitHub resources (repositories, branch protection, team membership) for Sanoma, read through the OpenTofu provider",
5
5
  "keywords": [
6
6
  "connector",
@@ -45,23 +45,27 @@
45
45
  "./fake": {
46
46
  "types": "./dist/fake.d.ts",
47
47
  "default": "./dist/fake.js"
48
+ },
49
+ "./remote": {
50
+ "types": "./dist/remote.d.ts",
51
+ "default": "./dist/remote.js"
48
52
  }
49
53
  },
50
54
  "publishConfig": {
51
55
  "access": "public"
52
56
  },
53
57
  "devDependencies": {
54
- "@sanoma-ai/bridge": "0.4.3",
55
- "@sanoma-ai/workflows": "0.5.0",
58
+ "@sanoma-ai/bridge": "0.4.5",
59
+ "@sanoma-ai/workflows": "0.7.0",
56
60
  "zod": "^4.6.5"
57
61
  },
58
62
  "peerDependencies": {
59
- "@sanoma-ai/bridge": "^0.4.3",
60
- "@sanoma-ai/workflows": "^0.5.0",
63
+ "@sanoma-ai/bridge": "^0.4.5",
64
+ "@sanoma-ai/workflows": "^0.7.0",
61
65
  "zod": "^4"
62
66
  },
63
67
  "engines": {
64
- "node": ">=24"
68
+ "node": ">=26"
65
69
  },
66
70
  "sanoma": {
67
71
  "title": "GitHub",