@app-vitals/agent-admin 1.95.0 → 1.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.95.0",
3
+ "version": "1.96.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@anthropic-ai/sdk": "0.137.0",
47
- "@app-vitals/agent-lib": "1.95.0",
47
+ "@app-vitals/agent-lib": "1.96.0",
48
48
  "@hono/zod-openapi": "^1.0.0",
49
49
  "@prisma/adapter-pg": "^7.10.0",
50
50
  "@prisma/client": "^7.10.0",
@@ -1378,6 +1378,122 @@ describe("admin UI — new local agent create flow", () => {
1378
1378
  );
1379
1379
  });
1380
1380
 
1381
+ // ── SWI-17.2: Slack + GitHub App no longer skips the App branch ──
1382
+
1383
+ const slackCookiePayload = (res: Response) => {
1384
+ const m = (res.headers.get("Set-Cookie") ?? "").match(
1385
+ /slack_provision_state=([^;]+)/,
1386
+ );
1387
+ expect(m).toBeTruthy();
1388
+ return JSON.parse(
1389
+ Buffer.from(
1390
+ decodeURIComponent(m?.[1] ?? "").split(".")[1] ?? "",
1391
+ "base64url",
1392
+ ).toString("utf-8"),
1393
+ );
1394
+ };
1395
+
1396
+ const manualAppForm = (extra: Record<string, string>, withId = true) => {
1397
+ const form = new FormData();
1398
+ form.append("name", "slack-gh-manual");
1399
+ form.append("type", TYPE);
1400
+ form.append("runtime", "in-cluster");
1401
+ form.append("connectSlack", "true");
1402
+ form.append("xoxpToken", "xoxe.xoxp-test-token");
1403
+ form.append("ghAuthMode", "app");
1404
+ form.append("ghAppMode", "manual");
1405
+ if (withId) form.append("ghAppId", "12345");
1406
+ form.append("ghAppInstallationId", "67890");
1407
+ form.append(
1408
+ "ghAppPrivateKeyFile",
1409
+ new File(
1410
+ ["-----BEGIN RSA PRIVATE KEY-----\nk\n-----END RSA PRIVATE KEY-----"],
1411
+ "k.pem",
1412
+ ),
1413
+ );
1414
+ for (const [k, v] of Object.entries(extra)) form.append(k, v);
1415
+ return form;
1416
+ };
1417
+
1418
+ it("Slack + manual GitHub App stores the App env before redirecting to Slack", async () => {
1419
+ const { deps, calls } = makeProvisioningDeps();
1420
+ const res = await createAdminUIApp(deps).request("/admin/agents", {
1421
+ method: "POST",
1422
+ body: manualAppForm({}),
1423
+ headers: { Cookie: `admin_session=${adminCookie}` },
1424
+ });
1425
+ expect(res.status).toBe(302);
1426
+ expect(res.headers.get("Location") ?? "").toContain(
1427
+ "slack.com/oauth/authorize",
1428
+ );
1429
+ expect(calls.envPatches.find((p) => p.env.GH_APP_ID)?.env.GH_APP_ID).toBe(
1430
+ "12345",
1431
+ );
1432
+ expect(
1433
+ calls.envPatches.find((p) => p.env.GH_APP_INSTALLATION_ID),
1434
+ ).toBeDefined();
1435
+ expect(
1436
+ calls.envPatches.find((p) => p.env.GH_APP_PRIVATE_KEY),
1437
+ ).toBeDefined();
1438
+ expect(slackCookiePayload(res).ghConnectError).toBeUndefined();
1439
+ });
1440
+
1441
+ it("Slack + manual GitHub App failure does not block Slack and is carried as a warning", async () => {
1442
+ const { deps, calls } = makeProvisioningDeps();
1443
+ const res = await createAdminUIApp(deps).request("/admin/agents", {
1444
+ method: "POST",
1445
+ body: manualAppForm({}, false),
1446
+ headers: { Cookie: `admin_session=${adminCookie}` },
1447
+ });
1448
+ expect(res.status).toBe(302);
1449
+ expect(res.headers.get("Location") ?? "").toContain(
1450
+ "slack.com/oauth/authorize",
1451
+ );
1452
+ expect(calls.envPatches.find((p) => p.env.GH_APP_ID)).toBeUndefined();
1453
+ expect(typeof slackCookiePayload(res).ghConnectError).toBe("string");
1454
+ expect(slackCookiePayload(res).ghConnectSource).toBe("app");
1455
+ });
1456
+
1457
+ it("Slack + auto GitHub App redirects to Slack and carries non-secret deferred inputs in the cookie", async () => {
1458
+ const { deps } = makeProvisioningDeps();
1459
+ const res = await postAgent(deps, {
1460
+ name: "slack-gh-auto",
1461
+ type: TYPE,
1462
+ runtime: "in-cluster",
1463
+ connectSlack: "true",
1464
+ xoxpToken: "xoxe.xoxp-test-token",
1465
+ ghAuthMode: "app",
1466
+ ghAppMode: "auto",
1467
+ githubOrg: "my-org",
1468
+ ghAppPublic: "true",
1469
+ });
1470
+ expect(res.status).toBe(302);
1471
+ expect(res.headers.get("Location") ?? "").toContain(
1472
+ "slack.com/oauth/authorize",
1473
+ );
1474
+ const payload = slackCookiePayload(res);
1475
+ expect(payload.githubOrg).toBe("my-org");
1476
+ expect(payload.ghAppPublic).toBe(true);
1477
+ expect(payload.resumeGithub).toBe(true);
1478
+ expect(JSON.stringify(payload)).not.toContain("xoxe.xoxp-test-token");
1479
+ });
1480
+
1481
+ it("Slack + PAT does not add deferred GitHub fields to the cookie", async () => {
1482
+ const { deps } = makeProvisioningDeps();
1483
+ const res = await postAgent(deps, {
1484
+ name: "slack-pat-nodefer",
1485
+ type: TYPE,
1486
+ runtime: "in-cluster",
1487
+ connectSlack: "true",
1488
+ xoxpToken: "xoxe.xoxp-test-token",
1489
+ ghAuthMode: "pat",
1490
+ ghPat: "ghp_x",
1491
+ });
1492
+ const payload = slackCookiePayload(res);
1493
+ expect(payload.resumeGithub).toBeUndefined();
1494
+ expect(payload.githubOrg).toBeUndefined();
1495
+ });
1496
+
1381
1497
  // ── UAP-5.1: runtime=self-hosted must never trigger Slack/GitHub provisioning ──
1382
1498
 
1383
1499
  it("runtime=self-hosted with connectSlack=true performs no Slack provisioning — plain redirect, no OAuth redirect, no env writes", async () => {
package/src/admin-ui.ts CHANGED
@@ -178,6 +178,7 @@ import {
178
178
  buildAgentManifest,
179
179
  } from "./slack-provisioning-client.ts";
180
180
  import {
181
+ type DeferredGithubState,
181
182
  PROVISION_STATE_COOKIE,
182
183
  PROVISION_STATE_TTL_SECONDS,
183
184
  SlackProvisioningService,
@@ -1716,6 +1717,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1716
1717
  let ghAppId: string | undefined;
1717
1718
  let ghAppInstallationId: string | undefined;
1718
1719
  let ghAppPrivateKey: string | undefined;
1720
+ let ghAppPublic = false;
1719
1721
  let templateDetachedRaw: string | undefined;
1720
1722
  let envRaw: string | undefined;
1721
1723
  try {
@@ -1748,6 +1750,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1748
1750
  ghAppMode = formData.get("ghAppMode")?.toString()?.trim();
1749
1751
  ghAppId = formData.get("ghAppId")?.toString();
1750
1752
  ghAppInstallationId = formData.get("ghAppInstallationId")?.toString();
1753
+ ghAppPublic = formData.get("ghAppPublic")?.toString() === "true";
1751
1754
  // UAP-5.3: the "Use existing GitHub App" option submits the private
1752
1755
  // key as a file upload rather than pasted text — read its contents
1753
1756
  // server-side, mirroring the per-agent connect-github route.
@@ -1859,9 +1862,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1859
1862
  // Slack/GitHub can produce the final HTTP response. When both are
1860
1863
  // requested, GitHub's storage/redirect-prep runs first (PAT storage is
1861
1864
  // synchronous; the App-manifest flow can't run before Slack's redirect
1862
- // either, so it's skipped when Slack is also requested) so GH_TOKEN is
1863
- // already in place by the time the user lands back from Slack's OAuth
1864
- // callback — then Slack's redirect is returned last.
1865
+ // either, so with Slack its non-secret inputs are carried in the signed
1866
+ // provision-state cookie (SWI-17.2) and resumed after the callback). The
1867
+ // manual-App branch is synchronous and runs inline before Slack's redirect
1868
+ // like PAT, so GH_APP_* is in place by the time the user lands back — then
1869
+ // Slack's redirect is returned last.
1865
1870
  //
1866
1871
  // UAP-5.1: this whole block only applies to in-cluster agents. Self-hosted
1867
1872
  // agents use local git config for GitHub auth, not admin-managed
@@ -1892,20 +1897,60 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1892
1897
  }
1893
1898
  }
1894
1899
 
1900
+ // UAP-5.3 / SWI-17.2: "Use existing GitHub App" — validates and persists
1901
+ // GH_APP_ID/GH_APP_INSTALLATION_ID/GH_APP_PRIVATE_KEY directly, no GitHub
1902
+ // API call. Runs inline BEFORE Slack's redirect so it is never skipped
1903
+ // when Slack is selected. Without Slack a failure redirects as before;
1904
+ // with Slack it is carried as a non-blocking warning like the PAT failure.
1905
+ let ghManualError: string | undefined;
1906
+ if (ghAuthMode === "app" && ghAppMode === "manual") {
1907
+ const manualResult =
1908
+ await githubProvisioningService.startAppManualConnect(agent.id, {
1909
+ ghAppId,
1910
+ ghAppInstallationId,
1911
+ ghAppPrivateKey,
1912
+ });
1913
+ if (!manualResult.ok) {
1914
+ if (!connectSlack) {
1915
+ return c.redirect(
1916
+ `/admin/agents/${agent.id}?error=${encodeURIComponent(manualResult.error)}`,
1917
+ 302,
1918
+ );
1919
+ }
1920
+ console.error(
1921
+ "[admin-ui] GitHub App manual storage failed during combined Slack+GitHub connect:",
1922
+ manualResult.error,
1923
+ );
1924
+ ghManualError = manualResult.error;
1925
+ }
1926
+ }
1927
+
1895
1928
  if (connectSlack) {
1896
1929
  const redirectUri = `${appBaseUrl}/admin/agents/${agent.id}/connect-slack/callback`;
1897
- // Carry a failed-PAT-storage warning (UAP-2.1) through Slack's OAuth
1898
- // round trip via the signed provision-state cookie so it resurfaces on
1899
- // the post-callback landing page. Without this, a GitHub PAT that failed
1900
- // to store above would be silently swallowed and the operator misled
1901
- // into believing GH_TOKEN was connected.
1930
+ // Carry a failed-PAT/manual-App storage warning (UAP-2.1) through
1931
+ // Slack's OAuth round trip via the signed provision-state cookie so it
1932
+ // resurfaces on the post-callback landing page.
1902
1933
  const ghConnectError =
1903
- ghPatResult && !ghPatResult.ok ? ghPatResult.error : undefined;
1934
+ (ghPatResult && !ghPatResult.ok ? ghPatResult.error : undefined) ??
1935
+ ghManualError;
1936
+ // SWI-17.2: auto App can't run before Slack's redirect; carry its
1937
+ // non-secret inputs (never tokens) so the callback can resume it.
1938
+ const deferredGithub: DeferredGithubState | undefined =
1939
+ ghAuthMode === "app" && ghAppMode !== "manual"
1940
+ ? {
1941
+ githubOrg,
1942
+ ghAppPublic,
1943
+ resumeGithub: true,
1944
+ }
1945
+ : ghManualError
1946
+ ? { ghConnectSource: "app" }
1947
+ : undefined;
1904
1948
  const slackResult = await slackProvisioningService.startConnect(
1905
1949
  agent.id,
1906
1950
  xoxpToken,
1907
1951
  redirectUri,
1908
1952
  ghConnectError,
1953
+ deferredGithub,
1909
1954
  );
1910
1955
  if (!slackResult.ok) {
1911
1956
  return c.redirect(
@@ -1923,25 +1968,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
1923
1968
  return c.redirect(slackResult.oauthRedirectUrl, 302);
1924
1969
  }
1925
1970
 
1926
- if (ghAuthMode === "app" && ghAppMode === "manual") {
1927
- // UAP-5.3: "Use existing GitHub App" — validates and persists
1928
- // GH_APP_ID/GH_APP_INSTALLATION_ID/GH_APP_PRIVATE_KEY directly, no
1929
- // GitHub API call. On success falls through to the shared
1930
- // redirectWithMembersWarning below, matching the ghAuthMode=pat
1931
- // branch's success path.
1932
- const manualResult =
1933
- await githubProvisioningService.startAppManualConnect(agent.id, {
1934
- ghAppId,
1935
- ghAppInstallationId,
1936
- ghAppPrivateKey,
1937
- });
1938
- if (!manualResult.ok) {
1939
- return c.redirect(
1940
- `/admin/agents/${agent.id}?error=${encodeURIComponent(manualResult.error)}`,
1941
- 302,
1942
- );
1943
- }
1944
- } else if (ghAuthMode === "app") {
1971
+ // Manual App was handled above; success falls through to the shared
1972
+ // redirectWithMembersWarning below.
1973
+ if (ghAuthMode === "app" && ghAppMode !== "manual") {
1945
1974
  const appResult = await githubProvisioningService.startAppAutoConnect(
1946
1975
  agent.id,
1947
1976
  githubOrg,
@@ -3886,7 +3915,9 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
3886
3915
  // cookie — surface it now so the operator isn't misled into believing
3887
3916
  // GH_TOKEN was stored.
3888
3917
  const ghConnectWarning = result.ghConnectError
3889
- ? `GitHub was not connected — storing the PAT failed: ${result.ghConnectError}`
3918
+ ? result.ghConnectSource === "app"
3919
+ ? `GitHub was not connected — storing the GitHub App credentials failed: ${result.ghConnectError}`
3920
+ : `GitHub was not connected — storing the PAT failed: ${result.ghConnectError}`
3890
3921
  : undefined;
3891
3922
 
3892
3923
  if (result.outcome === "reinstalled") {
@@ -53,6 +53,18 @@ interface ProvisionStatePayload {
53
53
  redirectUri?: string;
54
54
  }
55
55
 
56
+ /**
57
+ * SWI-17.2: non-secret GitHub inputs deferred across Slack's OAuth round trip
58
+ * (auto GitHub App selected together with Slack). Never carries secrets.
59
+ */
60
+ export interface DeferredGithubState {
61
+ githubOrg?: string;
62
+ ghAppPublic?: boolean;
63
+ resumeGithub?: boolean;
64
+ /** Which GitHub step produced `ghConnectError`; absent means the PAT. */
65
+ ghConnectSource?: "app";
66
+ }
67
+
56
68
  type StartConnectResult =
57
69
  | {
58
70
  ok: true;
@@ -90,6 +102,11 @@ export type CompleteConnectResult =
90
102
  * isn't misled into believing GH_TOKEN was stored.
91
103
  */
92
104
  ghConnectError?: string;
105
+ /** SWI-17.2 deferred GitHub inputs (absent on older cookies). */
106
+ githubOrg?: string;
107
+ ghAppPublic?: boolean;
108
+ resumeGithub?: boolean;
109
+ ghConnectSource?: "app";
93
110
  }
94
111
  | {
95
112
  /** Success, fresh provisioning — show the xapp-token page next. */
@@ -97,6 +114,10 @@ export type CompleteConnectResult =
97
114
  agentId: string;
98
115
  /** See `reinstalled.ghConnectError` — same non-fatal combined-flow warning. */
99
116
  ghConnectError?: string;
117
+ githubOrg?: string;
118
+ ghAppPublic?: boolean;
119
+ resumeGithub?: boolean;
120
+ ghConnectSource?: "app";
100
121
  };
101
122
 
102
123
  type SaveAppTokenResult =
@@ -235,6 +256,7 @@ export class SlackProvisioningService {
235
256
  xoxpToken: string | undefined,
236
257
  redirectUri: string,
237
258
  ghConnectError?: string,
259
+ deferredGithub?: DeferredGithubState,
238
260
  ): Promise<StartConnectResult> {
239
261
  const prefixError = {
240
262
  ok: false,
@@ -286,7 +308,17 @@ export class SlackProvisioningService {
286
308
  appId,
287
309
  redirectUri,
288
310
  },
289
- ghConnectError ? { ghConnectError } : undefined,
311
+ {
312
+ ...(ghConnectError ? { ghConnectError } : {}),
313
+ ...(deferredGithub?.githubOrg
314
+ ? { githubOrg: deferredGithub.githubOrg }
315
+ : {}),
316
+ ...(deferredGithub?.ghAppPublic !== undefined
317
+ ? { ghAppPublic: deferredGithub.ghAppPublic }
318
+ : {}),
319
+ ...(deferredGithub?.resumeGithub ? { resumeGithub: true } : {}),
320
+ ...(deferredGithub?.ghConnectSource ? { ghConnectSource: "app" } : {}),
321
+ },
290
322
  );
291
323
 
292
324
  return { ok: true, provisionStateToken, oauthRedirectUrl };
@@ -328,6 +360,7 @@ export class SlackProvisioningService {
328
360
  // escapes the verify() try block; kept separate from the
329
361
  // ProvisionStatePayload shape since it's flow-specific, not Slack state.
330
362
  let ghConnectError: string | undefined;
363
+ let deferred: DeferredGithubState = {};
331
364
  try {
332
365
  const payload = (await verify(
333
366
  rawStateCookie,
@@ -358,6 +391,19 @@ export class SlackProvisioningService {
358
391
  typeof payload.ghConnectError === "string"
359
392
  ? payload.ghConnectError
360
393
  : undefined;
394
+ deferred = {
395
+ githubOrg:
396
+ typeof payload.githubOrg === "string" ? payload.githubOrg : undefined,
397
+ ghAppPublic:
398
+ typeof payload.ghAppPublic === "boolean"
399
+ ? payload.ghAppPublic
400
+ : undefined,
401
+ resumeGithub:
402
+ typeof payload.resumeGithub === "boolean"
403
+ ? payload.resumeGithub
404
+ : undefined,
405
+ ghConnectSource: payload.ghConnectSource === "app" ? "app" : undefined,
406
+ };
361
407
  } catch {
362
408
  return {
363
409
  outcome: "invalid_state",
@@ -425,6 +471,7 @@ export class SlackProvisioningService {
425
471
  outcome: "reinstalled",
426
472
  agentId: provisionState.agentId,
427
473
  ghConnectError,
474
+ ...deferred,
428
475
  };
429
476
  }
430
477
 
@@ -432,6 +479,7 @@ export class SlackProvisioningService {
432
479
  outcome: "needs_app_token",
433
480
  agentId: provisionState.agentId,
434
481
  ghConnectError,
482
+ ...deferred,
435
483
  };
436
484
  }
437
485
 
@@ -0,0 +1,124 @@
1
+ /**
2
+ * SWI-17.2: the signed Slack provision-state cookie carries non-secret
3
+ * deferred GitHub inputs (githubOrg, ghAppPublic, resumeGithub) alongside
4
+ * ghConnectError, and completeConnect() hands them back. Older cookies without
5
+ * the fields must keep verifying.
6
+ */
7
+ import { describe, expect, it } from "bun:test";
8
+ import { sign } from "hono/jwt";
9
+ import { SlackProvisioningService } from "./slack-provisioning-service.ts";
10
+
11
+ const SECRET = "test-admin-session-secret-32-bytes!";
12
+ const AGENT_ID = "agent-1";
13
+ const CALLBACK =
14
+ "https://example.com/admin/agents/agent-1/connect-slack/callback";
15
+
16
+ function makeService() {
17
+ return new SlackProvisioningService({
18
+ slackClient: {
19
+ createAppManifest: async () => ({
20
+ appId: "A1",
21
+ oauthRedirectUrl: "https://slack.com/oauth/v2/authorize?x=1",
22
+ clientId: "cid",
23
+ clientSecret: "csecret",
24
+ signingSecret: "ssecret",
25
+ }),
26
+ updateAppManifest: async () => {},
27
+ exchangeOAuthCode: async () => ({ botToken: "xoxb-bot" }),
28
+ authTest: async () => ({ userId: "U1" }),
29
+ },
30
+ agentService: {
31
+ getDetail: async () => ({ id: AGENT_ID, name: "a", accountId: null }),
32
+ updateFields: async () => ({}),
33
+ },
34
+ agentEnvService: {
35
+ patch: async () => {},
36
+ getConfigBundle: async () => null,
37
+ },
38
+ agentCronJobService: { reconcileSystemCrons: async () => ({}) },
39
+ sessionSecret: SECRET,
40
+ appBaseUrl: "https://example.com",
41
+ secretEnvVars: new Set(),
42
+ } as unknown as ConstructorParameters<typeof SlackProvisioningService>[0]);
43
+ }
44
+
45
+ function decode(token: string): Record<string, unknown> {
46
+ return JSON.parse(
47
+ Buffer.from(token.split(".")[1] ?? "", "base64url").toString("utf-8"),
48
+ );
49
+ }
50
+
51
+ describe("SlackProvisioningService deferred GitHub state", () => {
52
+ it("startConnect folds deferred non-secret GitHub inputs into the signed state", async () => {
53
+ const r = await makeService().startConnect(
54
+ AGENT_ID,
55
+ "xoxe.xoxp-secret-token",
56
+ CALLBACK,
57
+ undefined,
58
+ { githubOrg: "my-org", ghAppPublic: true, resumeGithub: true },
59
+ );
60
+ if (!r.ok) throw new Error("expected ok");
61
+ const payload = decode(r.provisionStateToken);
62
+ expect(payload.githubOrg).toBe("my-org");
63
+ expect(payload.ghAppPublic).toBe(true);
64
+ expect(payload.resumeGithub).toBe(true);
65
+ expect(JSON.stringify(payload)).not.toContain("xoxe.xoxp");
66
+ });
67
+
68
+ it("startConnect without deferred inputs omits the fields", async () => {
69
+ const r = await makeService().startConnect(
70
+ AGENT_ID,
71
+ "xoxe.xoxp-t",
72
+ CALLBACK,
73
+ );
74
+ if (!r.ok) throw new Error("expected ok");
75
+ const payload = decode(r.provisionStateToken);
76
+ expect("githubOrg" in payload).toBe(false);
77
+ expect("ghAppPublic" in payload).toBe(false);
78
+ expect("resumeGithub" in payload).toBe(false);
79
+ });
80
+
81
+ it("completeConnect returns the deferred inputs and ghConnectError", async () => {
82
+ const svc = makeService();
83
+ const r = await svc.startConnect(
84
+ AGENT_ID,
85
+ "xoxe.xoxp-t",
86
+ CALLBACK,
87
+ "pat failed",
88
+ { githubOrg: "my-org", ghAppPublic: false, resumeGithub: true },
89
+ );
90
+ if (!r.ok) throw new Error("expected ok");
91
+ const out = await svc.completeConnect(
92
+ r.provisionStateToken,
93
+ "code",
94
+ CALLBACK,
95
+ );
96
+ if (out.outcome !== "needs_app_token") throw new Error(out.outcome);
97
+ expect(out.ghConnectError).toBe("pat failed");
98
+ expect(out.githubOrg).toBe("my-org");
99
+ expect(out.ghAppPublic).toBe(false);
100
+ expect(out.resumeGithub).toBe(true);
101
+ });
102
+
103
+ it("an older cookie without the new fields still verifies", async () => {
104
+ const now = Math.floor(Date.now() / 1000);
105
+ const token = await sign(
106
+ {
107
+ agentId: AGENT_ID,
108
+ clientId: "c",
109
+ clientSecret: "s",
110
+ signingSecret: "g",
111
+ appId: "A",
112
+ iat: now,
113
+ exp: now + 300,
114
+ },
115
+ SECRET,
116
+ "HS256",
117
+ );
118
+ const out = await makeService().completeConnect(token, "code", CALLBACK);
119
+ if (out.outcome !== "needs_app_token") throw new Error(out.outcome);
120
+ expect(out.githubOrg).toBeUndefined();
121
+ expect(out.ghAppPublic).toBeUndefined();
122
+ expect(out.resumeGithub).toBeUndefined();
123
+ });
124
+ });