@jskit-ai/connectors-catalog 0.2.40 → 0.2.42

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 (81) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/docs/linkedin.md +3 -1
  3. package/docs/oura.md +4 -1
  4. package/package.json +3 -3
  5. package/patterns/api-key-connection/PATTERN.md +4 -1
  6. package/patterns/api-key-connection/example/connections.js +3 -3
  7. package/patterns/firebase-messaging/example/server/notifications.js +3 -3
  8. package/patterns/oauth-connection/PATTERN.md +3 -1
  9. package/src/server/sideEffect.js +1 -1
  10. package/test/airtable.test.js +1 -0
  11. package/test/algolia.test.js +4 -4
  12. package/test/amazon-redshift.test.js +7 -7
  13. package/test/amplitude.test.js +3 -3
  14. package/test/apify.test.js +1 -0
  15. package/test/apollo-io.test.js +1 -0
  16. package/test/asana.test.js +1 -1
  17. package/test/ashby.test.js +1 -1
  18. package/test/atlassian.test.js +3 -3
  19. package/test/attention.test.js +1 -1
  20. package/test/aws.test.js +13 -13
  21. package/test/brevo.test.js +1 -1
  22. package/test/calendly.test.js +3 -3
  23. package/test/canva.test.js +3 -3
  24. package/test/chargebee.test.js +4 -4
  25. package/test/clickhouse.test.js +10 -10
  26. package/test/confidence.test.js +5 -5
  27. package/test/databricks.test.js +7 -7
  28. package/test/dbt-semantic-layer.test.js +3 -3
  29. package/test/designMcp.test.js +4 -4
  30. package/test/elevenlabs.test.js +1 -0
  31. package/test/firebase-cloud-messaging.test.js +4 -4
  32. package/test/firecrawl.test.js +1 -0
  33. package/test/gemini-enterprise.test.js +4 -4
  34. package/test/github-api.test.js +3 -2
  35. package/test/gitlab-api.test.js +5 -4
  36. package/test/gong.test.js +4 -4
  37. package/test/google-ads.test.js +9 -9
  38. package/test/google-maps-platform.test.js +3 -3
  39. package/test/google.test.js +5 -5
  40. package/test/granola.test.js +5 -5
  41. package/test/hex.test.js +3 -3
  42. package/test/heygen.test.js +3 -3
  43. package/test/hubspot.test.js +2 -2
  44. package/test/inngest.test.js +4 -4
  45. package/test/lightspeed.test.js +6 -6
  46. package/test/linear.test.js +3 -3
  47. package/test/linkedin.test.js +6 -6
  48. package/test/logo-dev.test.js +1 -1
  49. package/test/mailgun.test.js +1 -1
  50. package/test/mapbox.test.js +3 -3
  51. package/test/mcp.test.js +5 -5
  52. package/test/microsoft-fabric.test.js +7 -7
  53. package/test/microsoft.test.js +5 -5
  54. package/test/n8nOAuth.test.js +4 -4
  55. package/test/notionOAuth.test.js +6 -6
  56. package/test/oura.test.js +5 -5
  57. package/test/paddlePermissions.test.js +2 -1
  58. package/test/pipedriveOAuth.test.js +1 -1
  59. package/test/posthog.test.js +4 -4
  60. package/test/prestashop.test.js +6 -6
  61. package/test/resend.test.js +1 -1
  62. package/test/salesforce.test.js +8 -8
  63. package/test/semrush.test.js +10 -10
  64. package/test/shopify.test.js +10 -10
  65. package/test/slack.test.js +5 -5
  66. package/test/snowflake.test.js +7 -7
  67. package/test/tally.test.js +1 -0
  68. package/test/telegram.test.js +1 -1
  69. package/test/tiktok.test.js +7 -7
  70. package/test/tokens.test.js +18 -18
  71. package/test/twilio.test.js +5 -5
  72. package/test/twitch.test.js +4 -4
  73. package/test/wave.test.js +5 -5
  74. package/test/wix.test.js +4 -4
  75. package/test/wordpress-com.test.js +3 -3
  76. package/test/wordpress.test.js +5 -5
  77. package/test/workday.test.js +4 -4
  78. package/test/x-twitter.test.js +5 -5
  79. package/test/xero.test.js +18 -18
  80. package/test/zoho-books.test.js +5 -5
  81. package/test/zoho-crm.test.js +5 -5
@@ -32,7 +32,7 @@ async function fixture(t, authentication = { method: "api-key", secretRef: "env:
32
32
  return state.text === undefined ? Response.json(state.response, { status: state.status }) : new Response(state.text, { status: state.status });
33
33
  }
34
34
  };
35
- return { service: createConnectionService(options), options, directory, protection, requests, resolutions, state };
35
+ return { service: createConnectionService({ appEnv: "test", ...options }), options, directory, protection, requests, resolutions, state };
36
36
  }
37
37
 
38
38
  test("ClickHouse verifies Basic credentials without putting them in URLs or files, and resolves rotation after restart", async (t) => {
@@ -57,7 +57,7 @@ test("ClickHouse verifies Basic credentials without putting them in URLs or file
57
57
  }
58
58
  assert.equal(JSON.stringify(connected).includes(state.secret), false);
59
59
  assert.deepEqual(resolutions, ["env:CLICKHOUSE_PASSWORD"]);
60
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
60
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
61
61
  assert.deepEqual(await restarted.status(input), connected);
62
62
  assert.equal(requests.length, 1, "status validates the local credential binding without querying the database");
63
63
  assert.deepEqual(resolutions, ["env:CLICKHOUSE_PASSWORD", "env:CLICKHOUSE_PASSWORD"]);
@@ -72,13 +72,13 @@ test("ClickHouse verifies Basic credentials without putting them in URLs or file
72
72
  test("ClickHouse distinguishes an empty password, a missing explicit binding and requests with no credentials", async (t) => {
73
73
  const { options, requests, resolutions, state } = await fixture(t, { method: "api-key" });
74
74
  delete options.configuration.integrations.warehouse.settings.username;
75
- const empty = createConnectionService(options);
75
+ const empty = createConnectionService({ appEnv: "test", ...options });
76
76
  await empty.connectApiKey(input);
77
77
  assert.equal(requests[0].headers.get("authorization"), `Basic ${Buffer.from("default:").toString("base64")}`);
78
78
  assert.equal(resolutions.length, 0);
79
79
  options.configuration.integrations.warehouse.authentication.secretRef = "env:EMPTY_PASSWORD";
80
80
  state.secret = "";
81
- const explicit = createConnectionService(options);
81
+ const explicit = createConnectionService({ appEnv: "test", ...options });
82
82
  await explicit.connectApiKey(input);
83
83
  assert.equal(requests.at(-1).headers.get("authorization"), requests[0].headers.get("authorization"));
84
84
  for (const value of [undefined, null, 12, "password\nheader"]) {
@@ -87,7 +87,7 @@ test("ClickHouse distinguishes an empty password, a missing explicit binding and
87
87
  }
88
88
  assert.equal(requests.length, 2, "An invalid explicit binding must never fall back to an empty password.");
89
89
  options.configuration.integrations.warehouse.authentication = { method: "none" };
90
- const noCredentials = createConnectionService(options);
90
+ const noCredentials = createConnectionService({ appEnv: "test", ...options });
91
91
  await noCredentials.connectWithoutCredentials(input);
92
92
  await noCredentials.invoke({ ...input, operation: "connection.check" });
93
93
  assert.ok(requests.slice(2).every(({ headers, url }) => !headers.has("authorization") && !url.searchParams.has("password") && !url.searchParams.has("user")));
@@ -189,18 +189,18 @@ test("ClickHouse isolates connections and requires verification after changing m
189
189
  for (const changes of [{ username: "other" }, { httpUrl: "https://other.example" }, { httpUrl: "https://warehouse.example:8443/other/" }]) {
190
190
  const configuration = structuredClone(options.configuration);
191
191
  Object.assign(configuration.integrations.warehouse.settings, changes);
192
- const changed = createConnectionService({ ...options, configuration });
192
+ const changed = createConnectionService({ appEnv: "test", ...options, configuration });
193
193
  assert.equal((await changed.status(input)).status, "reconnect-required");
194
194
  await assert.rejects(changed.invoke({ ...input, operation: "connection.check" }), { code: "connector_reconnect_required" });
195
195
  }
196
- const denied = createConnectionService({ ...options, authorize: async () => { throw new Error("Access denied"); } });
196
+ const denied = createConnectionService({ appEnv: "test", ...options, authorize: async () => { throw new Error("Access denied"); } });
197
197
  await assert.rejects(denied.connectApiKey(input), /Access denied/u);
198
198
  assert.equal(requests.length, 1);
199
199
  assert.equal(resolutions.length, 1);
200
200
  const configuration = structuredClone(options.configuration);
201
201
  configuration.integrations.warehouse.authentication = { method: "none" };
202
202
  delete configuration.integrations.warehouse.settings.username;
203
- const changed = createConnectionService({ ...options, configuration });
203
+ const changed = createConnectionService({ appEnv: "test", ...options, configuration });
204
204
  await assert.rejects(changed.invoke({ ...input, operation: "connection.check" }), { code: "connector_reconnect_required" });
205
205
  await changed.connectWithoutCredentials(input);
206
206
  assert.equal((await service.status(input)).status, "reconnect-required");
@@ -238,7 +238,7 @@ test("ClickHouse reports timeout and cancellation without replaying a database q
238
238
  for (const [failure, code] of [["TimeoutError", "connector_provider_timeout"], ["AbortError", "connector_cancelled"]]) {
239
239
  let calls = 0;
240
240
  const controller = new AbortController();
241
- const interrupted = createConnectionService({ ...options, fetchImpl: async () => {
241
+ const interrupted = createConnectionService({ appEnv: "test", ...options, fetchImpl: async () => {
242
242
  calls++;
243
243
  controller.abort(new DOMException("Interrupted", failure));
244
244
  throw new Error("Wrapped transport failure");
@@ -266,7 +266,7 @@ test("ClickHouse analytical queries keep typed values separate, bounded and auth
266
266
  for (const invalid of [{ sql: "DROP TABLE bookings" }, { sql: "SELECT 1; SELECT 2" }, { sql: "SELECT 1", readonly: 0 },
267
267
  { sql: "SELECT {x:Int32}", parameters: { x: 3 } }, { sql: "SELECT 1", parameters: { "a&readonly": "0" } }])
268
268
  await assert.rejects(service.invoke({ ...input, operation: "queries.read", input: invalid }), { code: "connector_input_invalid" });
269
- const denied = createConnectionService({ ...options, authorize: async (owner, request) => request.operation === "queries.read" ? null : owner });
269
+ const denied = createConnectionService({ appEnv: "test", ...options, authorize: async (owner, request) => request.operation === "queries.read" ? null : owner });
270
270
  await assert.rejects(denied.invoke({ ...input, operation: "queries.read", input: values }), { code: "connector_access_denied" });
271
271
  assert.equal(requests.length, count);
272
272
  state.status = 500; state.response = { error: "query setting forbidden" };
@@ -53,7 +53,7 @@ async function fixture(t, spec) {
53
53
  return Response.json({ jsonrpc: "2.0", id: message.id, result }, { headers: { "Mcp-Session-Id": "fixture-session" } });
54
54
  }
55
55
  };
56
- const service = createConnectionService(options);
56
+ const service = createConnectionService({ appEnv: "test", ...options });
57
57
  const complete = (start, extra = "code=fixture-code") => service.completeAuthorization({ ...input, callbackUrl: `${callback}?state=${new URL(start.authorizationUrl).searchParams.get("state")}&${extra}` });
58
58
  return { service, options, state, requests, directory, complete };
59
59
  }
@@ -67,7 +67,7 @@ for (const spec of specs) {
67
67
  const body = new URLSearchParams(f.requests.find((request) => request.url.endsWith("/token")).init.body);
68
68
  assert.equal(body.get("resource"), `${origin}/mcp`); assert.equal(body.get("client_secret"), "private-client-secret"); assert.equal(body.get("redirect_uri"), callback); assert(body.get("code_verifier"));
69
69
  assert.equal(f.requests.some(({ message }) => message?.method === "tools/call"), false);
70
- const restarted = createConnectionService(f.options); f.state.time += 61_000;
70
+ const restarted = createConnectionService({ appEnv: "test", ...f.options }); f.state.time += 61_000;
71
71
  f.state.list = { tools: [], nextCursor: "next-page" };
72
72
  assert.deepEqual(await restarted.invoke({ ...input, operation: "tools.list", input: { cursor: "next-page" } }), f.state.list);
73
73
  assert.deepEqual(f.requests.findLast(({ message }) => message?.method === "tools/list").message.params, { cursor: "next-page" });
@@ -116,7 +116,7 @@ for (const spec of specs) {
116
116
  test("Confidence Flags and Experiments cannot reuse a pending attempt or connected grant by changing provider", async (t) => {
117
117
  const f = await fixture(t, specs[0]); const start = await f.service.beginAuthorization(input);
118
118
  const config = structuredClone(f.options.configuration); config.integrations.research.provider = confidenceExpProvider.id;
119
- const changed = createConnectionService({ ...f.options, configuration: config });
119
+ const changed = createConnectionService({ appEnv: "test", ...f.options, configuration: config });
120
120
  await assert.rejects(changed.completeAuthorization({ ...input, callbackUrl: `${callback}?code=x&state=${new URL(start.authorizationUrl).searchParams.get("state")}` }), { code: "connector_attempt_invalid" });
121
121
  assert.equal(f.requests.length, 0); await f.complete(await f.service.beginAuthorization(input)); const before = f.requests.length;
122
122
  assert.equal((await changed.status(input)).status, "reconnect-required");
@@ -159,7 +159,7 @@ test("Both Confidence guides use the portable assistant-only registration contra
159
159
  test("Confidence Exp retains actual analysis content and limits calls to approved experiment resources", async t => {
160
160
  const spec = specs.find(item => item.provider === confidenceExpProvider);
161
161
  const f = await fixture(t, spec); await f.complete(await f.service.beginAuthorization(input));
162
- const allowed = createConnectionService({ ...f.options, authorize: async (owner, request) =>
162
+ const allowed = createConnectionService({ appEnv: "test", ...f.options, authorize: async (owner, request) =>
163
163
  request.operation !== "tools.call" || ["get_experiment", "get_results"].includes(request.input.name) && request.input.arguments.name === spec.arguments.name ? owner : null });
164
164
  for (const [name, result] of [["get_experiment", { name: spec.arguments.name, state: "live", analysisResults: ["results/primary"] }],
165
165
  ["get_results", { relativeEffect: 0.04, confidenceInterval: [-0.01, 0.09], significant: false, sampleSizes: { control: 200, treatment: 205 }, recommendation: "continue" }]]) {
@@ -185,7 +185,7 @@ test("Confidence Flags permits explicitly approved management calls and preserve
185
185
  { name: "testResolveFlag", arguments: { name: "flags/new-checkout", entity: "test-user" } }
186
186
  ];
187
187
  let approved;
188
- const host = createConnectionService({ ...f.options, authorize: async (owner, request) =>
188
+ const host = createConnectionService({ appEnv: "test", ...f.options, authorize: async (owner, request) =>
189
189
  request.operation !== "tools.call" || JSON.stringify(request.input) === JSON.stringify(approved) ? owner : null });
190
190
  for (const call of calls) {
191
191
  const before = f.requests.length;
@@ -73,7 +73,7 @@ async function fixture(t, grantType = "authorization_code", workspaceUrl = "http
73
73
  return Response.json(state.value === undefined ? url.pathname.endsWith("/get") ? job : { jobs: [job], next_page_token: "page+two=" } : state.value, { status: state.status });
74
74
  }
75
75
  };
76
- const service = createConnectionService(options);
76
+ const service = createConnectionService({ appEnv: "test", ...options });
77
77
  const start = async () => {
78
78
  const { authorizationUrl } = await service.beginAuthorization({ ...args, verificationInput: { limit: 1 } });
79
79
  const url = new URL(authorizationUrl); const returned = new URL(callback);
@@ -96,7 +96,7 @@ test("Databricks user consent pins the workspace, sends PKCE and persists encryp
96
96
  const text = await readFile(path.join(f.directory, file), "utf8");
97
97
  for (const secret of ["private-code", "private-client-secret", "private-access-1", "private-refresh-1"]) assert.equal(text.includes(secret), false);
98
98
  }
99
- const restarted = createConnectionService(f.options);
99
+ const restarted = createConnectionService({ appEnv: "test", ...f.options });
100
100
  assert.equal((await restarted.status(args)).status, "connected");
101
101
  assert.deepEqual(await restarted.invoke({ ...args, operation: "jobs.get", input: { job_id: 123 } }), job);
102
102
  });
@@ -104,7 +104,7 @@ test("Databricks user consent pins the workspace, sends PKCE and persists encryp
104
104
  test("Databricks service principals use confidential grants on AWS, Azure and GCP without callbacks", async (t) => {
105
105
  for (const origin of ["https://dbc-abc123.cloud.databricks.com", "https://adb-123456789.7.azuredatabricks.net", "https://123456789.7.gcp.databricks.com/"]) {
106
106
  const f = await fixture(t, "client_credentials", origin); await f.connect();
107
- const restarted = createConnectionService(f.options);
107
+ const restarted = createConnectionService({ appEnv: "test", ...f.options });
108
108
  assert.equal((await restarted.status(args)).status, "connected");
109
109
  assert.deepEqual((await restarted.status(args)).grantedScopes, ["jobs"]);
110
110
  f.state.time += 85_000; // 35 seconds remain: refresh before Azure's 30-second refusal boundary.
@@ -147,7 +147,7 @@ test("Databricks verifies granted scopes and application ownership before readin
147
147
  for (const owner of [{ ...context, subjectId: "another" }, { ...context, applicationId: "another" }]) {
148
148
  await assert.rejects(f.service.invoke({ ...args, context: owner, operation: "jobs.list" }), { code: "connector_reconnect_required" });
149
149
  }
150
- const denied = createConnectionService({ ...f.options, authorize: async () => null });
150
+ const denied = createConnectionService({ appEnv: "test", ...f.options, authorize: async () => null });
151
151
  await assert.rejects(denied.invoke({ ...args, operation: "jobs.list" }), { code: "connector_access_denied" });
152
152
  assert.equal(f.requests.length, 2);
153
153
  const insufficient = await fixture(t); insufficient.state.tokenPatch.scope = "offline_access";
@@ -161,7 +161,7 @@ test("Databricks persists renewal before failed reads and marks revoked grants f
161
161
  const f = await fixture(t, type); await f.connect(); f.state.time += 85_000; f.state.status = 429;
162
162
  await assert.rejects(f.service.invoke({ ...args, operation: "jobs.list" }), { code: "connector_rate_limited" });
163
163
  f.state.status = 200;
164
- const restarted = createConnectionService(f.options); await restarted.invoke({ ...args, operation: "jobs.list" });
164
+ const restarted = createConnectionService({ appEnv: "test", ...f.options }); await restarted.invoke({ ...args, operation: "jobs.list" });
165
165
  assert.equal(f.state.count, 2);
166
166
  f.state.time += 85_000; f.state.tokenStatus = 400;
167
167
  await assert.rejects(restarted.invoke({ ...args, operation: "jobs.list" }), (error) => error.code === "connector_reconnect_required" && !error.message.includes("private"));
@@ -180,7 +180,7 @@ test("Databricks rejects malformed token lifetimes, scopes and refresh values be
180
180
  test("Databricks pending consent cannot change workspace and cancelled, denied or replayed consent preserves saved access", async (t) => {
181
181
  const f = await fixture(t); await f.connect(); const start = await f.start();
182
182
  const changed = structuredClone(f.options.configuration); changed.integrations.warehouse.settings.workspaceUrl = "https://dbc-other.cloud.databricks.com";
183
- const other = createConnectionService({ ...f.options, configuration: changed });
183
+ const other = createConnectionService({ appEnv: "test", ...f.options, configuration: changed });
184
184
  await assert.rejects(other.completeAuthorization({ ...args, callbackUrl: start.callbackUrl }), { code: "connector_attempt_invalid" });
185
185
  const denied = await f.start(); const returned = new URL(denied.callbackUrl); returned.searchParams.delete("code"); returned.searchParams.set("error", "access_denied");
186
186
  await assert.rejects(f.service.completeAuthorization({ ...args, callbackUrl: returned.href }), { code: "connector_consent_denied" });
@@ -195,7 +195,7 @@ test("Databricks grants cannot move to a different workspace, client or service
195
195
  for (const mutate of [(value) => { value.integrations.warehouse.settings.workspaceUrl = "https://dbc-other.cloud.databricks.com"; },
196
196
  (value) => { value.registrations.databricks.clientId = "other-client"; }, (value) => { value.integrations.warehouse.scopes = ["all-apis"]; }]) {
197
197
  const configuration = structuredClone(f.options.configuration); mutate(configuration);
198
- const changed = createConnectionService({ ...f.options, configuration });
198
+ const changed = createConnectionService({ appEnv: "test", ...f.options, configuration });
199
199
  assert.equal((await changed.status(args)).status, "reconnect-required");
200
200
  await assert.rejects(changed.invoke({ ...args, operation: "jobs.list" }), { code: "connector_reconnect_required" });
201
201
  }
@@ -45,7 +45,7 @@ async function fixture(t, host = "semantic-layer.cloud.getdbt.com") {
45
45
  return Response.json(state.response === undefined ? { data } : state.response, { status: state.status });
46
46
  }
47
47
  };
48
- return { service: createConnectionService(options), options, state, requests, directory };
48
+ return { service: createConnectionService({ appEnv: "test", ...options }), options, state, requests, directory };
49
49
  }
50
50
 
51
51
  test("dbt verifies only environment metadata and preserves file-backed ownership, references and exact large IDs", async (t) => {
@@ -59,7 +59,7 @@ test("dbt verifies only environment metadata and preserves file-backed ownership
59
59
  assert.deepEqual(request.body.variables, { environmentId });
60
60
  assert.match(request.body.query, /\$environmentId: BigInt!/u); assert(!request.body.query.includes("mutation"));
61
61
  for (const name of await readdir(f.directory)) assert(!(await readFile(path.join(f.directory, name), "utf8")).includes(f.state.key));
62
- const restarted = createConnectionService(f.options);
62
+ const restarted = createConnectionService({ appEnv: "test", ...f.options });
63
63
  assert.deepEqual(await restarted.status(input), connected);
64
64
  for (const owner of [{ ...context, applicationId: "other" }, { ...context, subjectId: "other" }]) {
65
65
  await assert.rejects(restarted.invoke({ ...input, context: owner, operation: "metrics.list" }), { code: "connector_reconnect_required" });
@@ -155,7 +155,7 @@ test("dbt changing environment, host or token reference requires verification fo
155
155
  const f = await fixture(t); await f.service.connectApiKey(input); const before = f.requests.length;
156
156
  for (const change of [{ settings: { host: "semantic-layer.au.dbt.com", environmentId } }, { settings: { host: f.options.configuration.integrations.metrics.settings.host, environmentId: "1" } }, { authentication: { method: "api-key", secretRef: "env:OTHER_TOKEN" } }]) {
157
157
  const configuration = structuredClone(f.options.configuration); Object.assign(configuration.integrations.metrics, change);
158
- const changed = createConnectionService({ ...f.options, configuration });
158
+ const changed = createConnectionService({ appEnv: "test", ...f.options, configuration });
159
159
  assert.equal((await changed.status(input)).status, "reconnect-required");
160
160
  await assert.rejects(changed.invoke({ ...input, operation: "metrics.list" }), { code: "connector_reconnect_required" });
161
161
  }
@@ -82,7 +82,7 @@ async function fixture(t, spec) {
82
82
  return Response.json({ jsonrpc: "2.0", id: message.id, result }, { headers: { "Mcp-Session-Id": "fixture-session" } });
83
83
  }
84
84
  };
85
- const service = createConnectionService(options);
85
+ const service = createConnectionService({ appEnv: "test", ...options });
86
86
  const complete = (start, extra = "code=fixture-code", issuer = spec.issuer) => service.completeAuthorization({ ...input,
87
87
  callbackUrl: `${callback}?state=${new URL(start.authorizationUrl).searchParams.get("state")}&${extra}&iss=${encodeURIComponent(issuer)}` });
88
88
  return { service, options, state, requests, directory, protection, complete };
@@ -105,7 +105,7 @@ for (const spec of cases) {
105
105
  assert.equal(grant.get("redirect_uri"), callback);
106
106
  assert(grant.get("code_verifier"));
107
107
  assert(!requests.some(({ message }) => message?.method === "tools/call"));
108
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
108
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
109
109
  state.time += 61_000;
110
110
  assert.deepEqual(await restarted.invoke({ ...input, operation: "tools.list", input: { cursor: "next-page" } }), state.list);
111
111
  const refresh = new URLSearchParams(requests.findLast(({ url }) => url === spec.tokenUrl).init.body);
@@ -142,7 +142,7 @@ for (const spec of cases) {
142
142
  const changed = structuredClone(options.configuration);
143
143
  changed.registrations.client.clientId = "replacement-client";
144
144
  const pending = await service.beginAuthorization(input);
145
- const other = createConnectionService({ ...options, configuration: changed });
145
+ const other = createConnectionService({ appEnv: "test", ...options, configuration: changed });
146
146
  await assert.rejects(other.completeAuthorization({ ...input, callbackUrl: `${callback}?code=x&state=${new URL(pending.authorizationUrl).searchParams.get("state")}` }), { code: "connector_attempt_invalid" });
147
147
  for (const fields of [{ accountMode: "per-user" }, { scopes: [] }, { scopes: ["admin"] }]) {
148
148
  const invalid = structuredClone(options.configuration);
@@ -262,7 +262,7 @@ test("Sentry returns issue context only after exact tool authorization and rejec
262
262
  assert.deepEqual(result, state.result);
263
263
  const changed = structuredClone(options.configuration);
264
264
  changed.integrations.design.settings.projectSlug = "other-project";
265
- const other = createConnectionService({ ...options, configuration: changed });
265
+ const other = createConnectionService({ appEnv: "test", ...options, configuration: changed });
266
266
  const count = requests.length;
267
267
  await assert.rejects(other.invoke({ ...input, operation: "tools.list" }), { code: "connector_reconnect_required" });
268
268
  assert.equal(requests.length, count);
@@ -11,6 +11,7 @@ test("ElevenLabs returns playable audio and creates a consented voice clone with
11
11
  const context = { applicationId: "voice-app", subjectId: "workspace" }; const requests = [];
12
12
  let responseMode = "audio"; let status = 200; let deny = false; let fail = false;
13
13
  const service = createConnectionService({
14
+ appEnv: "test",
14
15
  configuration: { schemaVersion: 1, registrations: {}, integrations: { voice: { provider: "elevenlabs", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:ELEVENLABS_API_KEY" } } } },
15
16
  providers: [elevenlabsProvider], authorize: async owner => { if (deny) throw new Error("denied"); return owner; },
16
17
  resolveReference: async () => "fixture-voice-key",
@@ -46,7 +46,7 @@ async function fixture(t) {
46
46
  : Response.json(state.response ?? { name: "projects/target-project/messages/fixture-receipt" }, { status: state.status });
47
47
  }
48
48
  };
49
- return { state, options, directory, service: createConnectionService({ ...options, sideEffects: "live" }) };
49
+ return { state, options, directory, service: createConnectionService({ ...options, appEnv: "production" }) };
50
50
  }
51
51
 
52
52
  test("Firebase CLI validates both client modes, public fields and indirect credentials without accepting mixed setup", async (t) => {
@@ -168,7 +168,7 @@ test("Firebase cannot claim a connection for denied sends or a malformed or wron
168
168
 
169
169
  test("Firebase grants survive file restart, renew with rotated credentials and retain owner and project boundaries", async (t) => {
170
170
  const f = await fixture(t); await f.service.connectServiceAccount(input);
171
- const restarted = createConnectionService({ ...f.options, sideEffects: "live" }); await restarted.invoke({ ...input, operation: "messages.validate", input: { message } });
171
+ const restarted = createConnectionService({ ...f.options, appEnv: "production" }); await restarted.invoke({ ...input, operation: "messages.validate", input: { message } });
172
172
  assert.equal(f.state.grants.length, 1); f.state.now += 3_600_000;
173
173
  await restarted.invoke({ ...input, operation: "messages.validate", input: { message } }); assert.equal(f.state.grants.length, 2);
174
174
  f.state.credential = JSON.stringify({ ...account, private_key_id: "b".repeat(40) });
@@ -177,7 +177,7 @@ test("Firebase grants survive file restart, renew with rotated credentials and r
177
177
  await assert.rejects(restarted.invoke({ ...input, context: owner, operation: "messages.send", input: { message } }), { code: "connector_reconnect_required" });
178
178
  }
179
179
  const configuration = structuredClone(f.options.configuration); configuration.integrations.push.settings.projectId = "other-project";
180
- const changed = createConnectionService({ sideEffects: "live", ...f.options, configuration }); assert.equal((await changed.status(input)).status, "reconnect-required");
180
+ const changed = createConnectionService({ appEnv: "production", ...f.options, configuration }); assert.equal((await changed.status(input)).status, "reconnect-required");
181
181
  await assert.rejects(changed.invoke({ ...input, operation: "messages.send", input: { message } }), { code: "connector_reconnect_required" });
182
182
  await restarted.disconnect(input); assert.equal((await f.service.status(input)).status, "disconnected");
183
183
  });
@@ -186,7 +186,7 @@ test("sending requires application authorization over the exact audience and pay
186
186
  const f = await fixture(t); await f.service.connectServiceAccount(input);
187
187
  let release; const paused = new Promise((resolve) => { release = resolve; }); let started;
188
188
  const authorizing = new Promise((resolve) => { started = resolve; });
189
- const service = createConnectionService({ sideEffects: "live", ...f.options, authorize: async (owner, operation) => {
189
+ const service = createConnectionService({ appEnv: "production", ...f.options, authorize: async (owner, operation) => {
190
190
  if (operation.operation !== "messages.send") return owner;
191
191
  if (operation.input.message.fid !== message.fid) return null;
192
192
  started(); await paused; operation.input.message.fid = "policy-mutation"; return owner;
@@ -11,6 +11,7 @@ test("Firecrawl searches and imports bounded crawl pages without leaking the key
11
11
  t.after(() => rm(directory, { recursive: true, force: true }));
12
12
  const requests = []; let status = 200; let fail = false; let malformed = false; let deny = false; let key = "fixture-key";
13
13
  const service = createConnectionService({
14
+ appEnv: "test",
14
15
  configuration: { schemaVersion: 1, registrations: {}, integrations: { firecrawl: { provider: "firecrawl", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:FIRECRAWL_API_KEY" } } } },
15
16
  providers: [firecrawlProvider], authorize: async owner => { if (deny) throw new Error("denied"); return owner; },
16
17
  resolveReference: async () => key,
@@ -62,7 +62,7 @@ async function fixture(t, { location = "global", accountMode = "shared" } = {})
62
62
  return Response.json(state.value === undefined ? init.method === "POST" ? searchPage : engine : state.value, { status: state.status });
63
63
  }
64
64
  };
65
- const service = createConnectionService(options);
65
+ const service = createConnectionService({ appEnv: "test", ...options });
66
66
  const start = async () => {
67
67
  const { authorizationUrl } = await service.beginAuthorization(args); const url = new URL(authorizationUrl);
68
68
  const returned = new URL(callback); returned.searchParams.set("state", url.searchParams.get("state")); returned.searchParams.set("code", "private-code");
@@ -80,7 +80,7 @@ test("Gemini Enterprise uses Google PKCE consent and the configured regional eng
80
80
  assert.equal(start.url.searchParams.get("prompt"), "consent"); assert.equal(start.url.searchParams.get("code_challenge_method"), "S256");
81
81
  assert.equal(start.url.searchParams.has("client_secret"), false);
82
82
  await f.service.completeAuthorization({ ...args, callbackUrl: start.callbackUrl });
83
- const restarted = createConnectionService(f.options);
83
+ const restarted = createConnectionService({ appEnv: "test", ...f.options });
84
84
  assert.equal((await restarted.status(args)).status, "connected");
85
85
  assert.deepEqual(await restarted.invoke({ ...args, operation: "engine.get" }), f.engine);
86
86
  for (const file of await readdir(f.directory)) {
@@ -111,7 +111,7 @@ test("Gemini Enterprise rejects caller target and identity overrides, invalid pa
111
111
  await assert.rejects(f.service.invoke({ ...args, operation: "search", input }));
112
112
  }
113
113
  await assert.rejects(f.service.invoke({ ...args, operation: "engine.get", input: { engineId: "other" } }));
114
- const denied = createConnectionService({ ...f.options, authorize: async () => { throw new Error("Denied by host"); } });
114
+ const denied = createConnectionService({ appEnv: "test", ...f.options, authorize: async () => { throw new Error("Denied by host"); } });
115
115
  await assert.rejects(denied.invoke({ ...args, operation: "engine.get" }), /Denied by host/u);
116
116
  assert.equal(f.requests.length, count);
117
117
  const narrowed = await fixture(t); narrowed.state.tokenPatch.scope = "https://www.googleapis.com/auth/other";
@@ -125,7 +125,7 @@ test("Gemini Enterprise binds stored grants and pending consent to their applica
125
125
  }
126
126
  for (const [key, value] of [["projectId", "another-project"], ["location", "eu"], ["engineId", "another-engine"]]) {
127
127
  const configuration = structuredClone(f.options.configuration); configuration.integrations["enterprise-search"].settings[key] = value;
128
- const changed = createConnectionService({ ...f.options, configuration });
128
+ const changed = createConnectionService({ appEnv: "test", ...f.options, configuration });
129
129
  assert.equal((await changed.status(args)).status, "reconnect-required");
130
130
  await assert.rejects(changed.invoke({ ...args, operation: "engine.get" }), { code: "connector_reconnect_required" });
131
131
  const start = await f.start(); await assert.rejects(changed.completeAuthorization({ ...args, callbackUrl: start.callbackUrl }), { code: "connector_attempt_invalid" });
@@ -45,7 +45,7 @@ for (const perUser of [false, true]) test(`GitHub OAuth ${perUser ? "per-user no
45
45
  return Response.json({ id: 123, login: "fixture" });
46
46
  }
47
47
  };
48
- const service = createConnectionService(options);
48
+ const service = createConnectionService({ appEnv: "test", ...options });
49
49
  for (const outcome of ["cancel", "denied"]) {
50
50
  const attempt = new URL((await service.beginAuthorization(input)).authorizationUrl);
51
51
  const denied = new URL(callback);
@@ -71,7 +71,7 @@ for (const perUser of [false, true]) test(`GitHub OAuth ${perUser ? "per-user no
71
71
  time += 40_000;
72
72
  await Promise.all([service.invoke({ ...input, operation: "account.read" }), service.invoke({ ...input, operation: "account.read" })]);
73
73
  assert.equal(exchanges, perUser ? 1 : 2);
74
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
74
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
75
75
  time += 40_000;
76
76
  await restarted.invoke({ ...input, operation: "account.read" });
77
77
  assert.equal(exchanges, perUser ? 1 : 3);
@@ -107,6 +107,7 @@ test("GitHub repository reads and issue/PR writes preserve paths, pagination and
107
107
  t.after(() => rm(directory, { recursive: true, force: true }));
108
108
  const requests = []; let status = 200, malformed = false, fail = false;
109
109
  const service = createConnectionService({
110
+ appEnv: "test",
110
111
  configuration: { schemaVersion: 1, registrations: {}, integrations: { github: { provider: "github-api", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:GITHUB_TOKEN" } } } },
111
112
  providers: [githubApiProvider], authorize: async owner => owner, resolveReference: async () => "private-token",
112
113
  store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(8) }, activeKeyId: "current" }) }),
@@ -47,7 +47,7 @@ for (const perUser of [false, true]) test(`GitLab OAuth ${perUser ? "per-user no
47
47
  return Response.json({ id: 123, username: "fixture" });
48
48
  }
49
49
  };
50
- const service = createConnectionService(options);
50
+ const service = createConnectionService({ appEnv: "test", ...options });
51
51
  for (const outcome of ["cancel", "denied"]) {
52
52
  const attempt = new URL((await service.beginAuthorization(input)).authorizationUrl);
53
53
  const denied = new URL(callback);
@@ -73,7 +73,7 @@ for (const perUser of [false, true]) test(`GitLab OAuth ${perUser ? "per-user no
73
73
  time += 40_000;
74
74
  await Promise.all([service.invoke({ ...input, operation: "profile.read" }), service.invoke({ ...input, operation: "profile.read" })]);
75
75
  assert.equal(exchanges, perUser ? 1 : 2);
76
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
76
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
77
77
  time += 40_000;
78
78
  await restarted.invoke({ ...input, operation: "profile.read" });
79
79
  assert.equal(exchanges, perUser ? 1 : 3);
@@ -88,12 +88,12 @@ for (const perUser of [false, true]) test(`GitLab OAuth ${perUser ? "per-user no
88
88
  }
89
89
  const changedConfiguration = structuredClone(options.configuration);
90
90
  changedConfiguration.integrations.gitlab.settings.instanceUrl = "https://another-gitlab.example.test";
91
- const changed = createConnectionService({ ...options, configuration: changedConfiguration });
91
+ const changed = createConnectionService({ appEnv: "test", ...options, configuration: changedConfiguration });
92
92
  assert.equal((await changed.status(input)).status, "reconnect-required");
93
93
  await assert.rejects(changed.invoke({ ...input, operation: "profile.read" }), { code: "connector_reconnect_required" });
94
94
  for (const instanceUrl of ["http://gitlab.example.test", "https://name:secret@gitlab.example.test", "https://gitlab.example.test/subpath", "https://gitlab.example.test/?token=secret", "not-a-url"]) {
95
95
  changedConfiguration.integrations.gitlab.settings.instanceUrl = instanceUrl;
96
- assert.throws(() => createConnectionService({ ...options, configuration: changedConfiguration }), { code: "integration_configuration_invalid" });
96
+ assert.throws(() => createConnectionService({ appEnv: "test", ...options, configuration: changedConfiguration }), { code: "integration_configuration_invalid" });
97
97
  }
98
98
  await restarted.disconnect(input);
99
99
  assert.equal((await restarted.status(input)).status, "disconnected");
@@ -105,6 +105,7 @@ test("GitLab project paths, content and issue/MR writes use the selected host wi
105
105
  t.after(() => rm(directory, { recursive: true, force: true }));
106
106
  const requests = []; let status = 200, fail = false;
107
107
  const service = createConnectionService({
108
+ appEnv: "test",
108
109
  configuration: { schemaVersion: 1, registrations: {}, integrations: { gitlab: { provider: "gitlab-api", settings: { instanceUrl: "https://code.example.test" }, accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:GITLAB_TOKEN" } } } },
109
110
  providers: [gitlabApiProvider], authorize: async owner => owner, resolveReference: async () => "private-token",
110
111
  store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(8) }, activeKeyId: "current" }) }),
package/test/gong.test.js CHANGED
@@ -33,7 +33,7 @@ async function fixture(t, apiBaseUrl = "https://api.gong.io") {
33
33
  return Response.json(state.response, { status: state.status });
34
34
  }
35
35
  };
36
- return { service: createConnectionService(options), options, requests, directory, protection, state };
36
+ return { service: createConnectionService({ appEnv: "test", ...options }), options, requests, directory, protection, state };
37
37
  }
38
38
 
39
39
  for (const apiBaseUrl of ["https://api.gong.io", "https://company-17.api.gong.io/"]) {
@@ -52,7 +52,7 @@ for (const apiBaseUrl of ["https://api.gong.io", "https://company-17.api.gong.io
52
52
  assert.equal(stored.includes(state.secret), false);
53
53
  assert.equal(stored.includes(header), false);
54
54
  }
55
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
55
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
56
56
  assert.deepEqual(await restarted.status(input), connected);
57
57
  state.secret = "rotated-fixture-secret";
58
58
  assert.deepEqual(await restarted.invoke({ ...input, operation: "users.list" }), users);
@@ -102,12 +102,12 @@ test("Gong requires verification after key identity or host changes and never cr
102
102
  for (const [field, value] of [["accessKey", "OTHER_KEY"], ["apiBaseUrl", "https://company-18.api.gong.io"]]) {
103
103
  const configuration = structuredClone(options.configuration);
104
104
  configuration.integrations.sales.settings[field] = value;
105
- const changed = createConnectionService({ ...options, configuration });
105
+ const changed = createConnectionService({ appEnv: "test", ...options, configuration });
106
106
  assert.equal((await changed.status(input)).status, "reconnect-required");
107
107
  await assert.rejects(changed.invoke({ ...input, operation: "users.list" }), { code: "connector_reconnect_required" });
108
108
  }
109
109
  for (const origin of ["https://company-18.api.gong.io", "https://api.gong.io"]) {
110
- const wrongHost = createConnectionService({ ...options, providers: [{ ...gongProvider, operations: {
110
+ const wrongHost = createConnectionService({ appEnv: "test", ...options, providers: [{ ...gongProvider, operations: {
111
111
  "users.list": { scopes: [], request: () => ({ method: "GET", url: `${origin}/v2/users` }) }
112
112
  } }] });
113
113
  await assert.rejects(wrongHost.invoke({ ...input, operation: "users.list" }), { code: "connector_destination_invalid" });
@@ -71,7 +71,7 @@ async function fixture(t, settings = { loginCustomerId: "9876543210" }) {
71
71
  return Response.json(accounts ? state.accounts : state.respond ? state.respond(url, JSON.parse(init.body)) : state.response);
72
72
  }
73
73
  };
74
- const service = createConnectionService({ ...options, sideEffects: "live" });
74
+ const service = createConnectionService({ ...options, appEnv: "production" });
75
75
  const start = async (target = service) => {
76
76
  const result = await target.beginAuthorization(input); const url = new URL(result.authorizationUrl);
77
77
  const returned = new URL(callback); returned.searchParams.set("code", "fixture-code"); returned.searchParams.set("state", url.searchParams.get("state"));
@@ -146,12 +146,12 @@ test("Google Ads rejects malformed IDs, unbounded queries and caller transport f
146
146
 
147
147
  test("Google Ads encrypted file grants survive restart, isolate owners, renew once and retain refresh tokens", async (t) => {
148
148
  const f = await fixture(t); await f.connect();
149
- const restarted = createConnectionService({ sideEffects: "live", ...f.options, store: createFileConnectionStore({ directory: f.directory, protection: f.protection }) });
149
+ const restarted = createConnectionService({ appEnv: "production", ...f.options, store: createFileConnectionStore({ directory: f.directory, protection: f.protection }) });
150
150
  assert.equal((await restarted.status(input)).status, "connected");
151
151
  await assert.rejects(restarted.invoke({ ...input, context: { ...context, subjectId: "user-two" }, operation: "customers.listAccessible" }), { code: "connector_reconnect_required" });
152
152
  await assert.rejects(restarted.invoke({ ...input, context: { ...context, applicationId: "other-app" }, operation: "customers.listAccessible" }), { code: "connector_reconnect_required" });
153
153
  f.state.time += 3600000; f.state.refresh = false;
154
- await Promise.all([f.invoke(undefined, restarted), f.invoke(undefined, createConnectionService({ ...f.options, sideEffects: "live" }))]);
154
+ await Promise.all([f.invoke(undefined, restarted), f.invoke(undefined, createConnectionService({ ...f.options, appEnv: "production" }))]);
155
155
  assert.equal(f.state.grants, 2); assert.equal(f.state.lastRefresh, "refresh-fixture-1");
156
156
  f.state.time += 3600000; f.state.refresh = true; await f.invoke(undefined, restarted);
157
157
  assert.equal(f.state.grants, 3); assert.equal(f.state.lastRefresh, "refresh-fixture-3");
@@ -169,14 +169,14 @@ test("Google Ads settings and client changes invalidate saved access and in-prog
169
169
  const started = await f.start(); const configuration = structuredClone(f.configuration);
170
170
  if (change === "manager") configuration.integrations.ads.settings.loginCustomerId = "1111111111";
171
171
  if (change === "client") configuration.registrations.google.clientId = "different-client";
172
- const changed = createConnectionService({ sideEffects: "live", ...f.options, configuration }); const calls = f.state.calls.length;
172
+ const changed = createConnectionService({ appEnv: "production", ...f.options, configuration }); const calls = f.state.calls.length;
173
173
  await assert.rejects(changed.invoke({ ...input, operation: "customers.listAccessible" }), { code: "connector_reconnect_required" });
174
174
  await assert.rejects(changed.completeAuthorization({ ...input, callbackUrl: started.callbackUrl }));
175
175
  assert.equal(f.state.calls.length, calls);
176
176
  }
177
177
  const configuration = structuredClone(f.configuration);
178
178
  configuration.registrations.google.clientSecretRef = "env:MISSING";
179
- const missing = createConnectionService({ sideEffects: "live", ...f.options, configuration });
179
+ const missing = createConnectionService({ appEnv: "production", ...f.options, configuration });
180
180
  await assert.rejects(f.invoke(undefined, missing), { code: "connector_binding_missing" });
181
181
  });
182
182
 
@@ -218,7 +218,7 @@ test("Google Ads distinguishes API approval, quota, scope, account and query fai
218
218
 
219
219
  test("Google Ads host policy sees immutable account/query inputs and denies before credentials or HTTP", async (t) => {
220
220
  const f = await fixture(t); await f.connect(); const values = { customerId, query };
221
- const authorized = createConnectionService({ sideEffects: "live", ...f.options, authorize: async (owner, operation) => {
221
+ const authorized = createConnectionService({ appEnv: "production", ...f.options, authorize: async (owner, operation) => {
222
222
  if (operation.operation === "reports.search") {
223
223
  assert.deepEqual(operation.input, { customerId, query }); operation.input.customerId = "1111111111"; values.query = "SELECT customer.id FROM customer";
224
224
  }
@@ -237,7 +237,7 @@ test("Google Ads rejects declined or insufficient consent and keeps managed assi
237
237
  f.state.scope = "openid"; await assert.rejects(f.connect(), { code: "connector_scope_missing" }); assert.equal(f.state.calls.length, 1);
238
238
  const configuration = structuredClone(f.configuration);
239
239
  configuration.registrations.google = { source: "managed", serviceUrlRef: "env:GATEWAY", serviceCredentialRef: "env:IDENTITY", assignmentRef: "public" };
240
- assert.throws(() => createConnectionService({ sideEffects: "live", ...f.options, configuration }), { code: "integration_configuration_invalid" });
240
+ assert.throws(() => createConnectionService({ appEnv: "production", ...f.options, configuration }), { code: "integration_configuration_invalid" });
241
241
  });
242
242
 
243
243
  test("Google Ads refresh scope reduction, API cancellation and timeout do not replay requests", async (t) => {
@@ -245,7 +245,7 @@ test("Google Ads refresh scope reduction, API cancellation and timeout do not re
245
245
  const keepAlive = setTimeout(() => {}, 1000);
246
246
  t.after(() => clearTimeout(keepAlive));
247
247
  const f = await fixture(t); await f.connect(); f.state.stall = "api";
248
- const timed = createConnectionService({ sideEffects: "live", ...f.options, providers: [{ ...provider, requestTimeoutMs: 20 }] });
248
+ const timed = createConnectionService({ appEnv: "production", ...f.options, providers: [{ ...provider, requestTimeoutMs: 20 }] });
249
249
  await assert.rejects(f.invoke(undefined, timed), { code: "connector_provider_timeout" });
250
250
  const controller = new AbortController(); const pending = f.service.invoke({ ...input, operation: "reports.search", input: { customerId, query }, signal: controller.signal });
251
251
  const timer = setTimeout(() => controller.abort(), 20); await assert.rejects(pending, { code: "connector_cancelled" }); clearTimeout(timer);
@@ -322,7 +322,7 @@ test("Search workflow uses existing consent, Google validation, atomic paused cr
322
322
  assert.equal((await f.ads.report()).campaigns[0].campaign.id, "33");
323
323
  const before = f.state.grants;
324
324
  f.configuration.extensions.googleAdsSearch.ads.headlines[0] = "Fresh Booking Copy";
325
- const restarted = createConnectionService({ sideEffects: "live", ...f.options, configuration: f.configuration });
325
+ const restarted = createConnectionService({ appEnv: "production", ...f.options, configuration: f.configuration });
326
326
  assert.equal((await restarted.status(input)).status, "connected");
327
327
  assert.equal(f.state.grants, before, "campaign changes do not require fresh OAuth consent");
328
328
  });
@@ -37,7 +37,7 @@ async function fixture(t) {
37
37
  return Response.json(state.response, { status: state.status });
38
38
  }
39
39
  };
40
- return { service: createConnectionService(options), options, directory, protection, requests, state };
40
+ return { service: createConnectionService({ appEnv: "test", ...options }), options, directory, protection, requests, state };
41
41
  }
42
42
 
43
43
  test("Google Maps verification requires an explicit address and saves only references across restart", async (t) => {
@@ -55,7 +55,7 @@ test("Google Maps verification requires an explicit address and saves only refer
55
55
  assert.equal(requests[0].init.redirect, "error");
56
56
  assert.equal(JSON.stringify(connected).includes(state.key), false);
57
57
  for (const name of await readdir(directory)) assert.equal((await readFile(path.join(directory, name), "utf8")).includes(state.key), false);
58
- const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
58
+ const restarted = createConnectionService({ appEnv: "test", ...options, store: createFileConnectionStore({ directory, protection }) });
59
59
  assert.deepEqual(await restarted.status(input), connected);
60
60
  state.key = "replacement-server-key";
61
61
  assert.deepEqual(await restarted.invoke({ ...input, operation: "geocoding.forward", input: verificationInput }), places);
@@ -78,7 +78,7 @@ test("Google Maps keeps optional browser configuration portable and requires ver
78
78
  delete changed.integrations.maps.settings.browserKeyRef;
79
79
  assert.deepEqual(parse(changed), changed);
80
80
  await service.connectApiKey({ ...input, verificationInput });
81
- const replacement = createConnectionService({ ...options, configuration: changed });
81
+ const replacement = createConnectionService({ appEnv: "test", ...options, configuration: changed });
82
82
  assert.equal((await replacement.status(input)).status, "reconnect-required");
83
83
  await assert.rejects(replacement.invoke({ ...input, operation: "geocoding.forward", input: verificationInput }), { code: "connector_reconnect_required" });
84
84
  assert.equal(requests.length, 1);
@@ -51,7 +51,7 @@ async function fixture(t, entry) {
51
51
  };
52
52
  const requests = [];
53
53
  const state = { scopes, response: entry.response, status: 200 };
54
- const service = createConnectionService({ ...options, sideEffects: "live" });
54
+ const service = createConnectionService({ ...options, appEnv: "production" });
55
55
  const input = { context: owner, integrationId: "provider" };
56
56
  async function start() {
57
57
  const { authorizationUrl } = await service.beginAuthorization({ ...input, verificationInput: entry.verificationInput });
@@ -77,7 +77,7 @@ for (const entry of cases) {
77
77
  assert.equal(requests[1].url.pathname, entry.expectedPath);
78
78
  assert.equal(new Headers(requests[1].init.headers).get("authorization"), "Bearer test-access-token");
79
79
  assert.equal(requests[1].init.redirect, "error");
80
- const restarted = createConnectionService({ ...options, sideEffects: "live" });
80
+ const restarted = createConnectionService({ ...options, appEnv: "production" });
81
81
  assert.equal((await restarted.status(input)).status, "connected");
82
82
  assert.equal((await restarted.status(input)).accountLabel, result.accountLabel);
83
83
  assert.deepEqual(await restarted.invoke({ ...input, operation: entry.provider.checkOperation, input: entry.verificationInput }), entry.response);
@@ -190,7 +190,7 @@ test("captured auxiliary Google scopes round-trip without granting unrelated rea
190
190
  assert.equal(provider.operations[provider.checkOperation].scopes.includes(scope), false);
191
191
  }
192
192
  options.configuration.integrations.provider.scopes = [...new Set([...options.configuration.integrations.provider.scopes, ...auxiliary])];
193
- const service = createConnectionService({ ...options, sideEffects: "live" });
193
+ const service = createConnectionService({ ...options, appEnv: "production" });
194
194
  const result = await service.beginAuthorization({ ...input, verificationInput: entry.verificationInput });
195
195
  const requested = new URL(result.authorizationUrl).searchParams.get("scope").split(" ");
196
196
  for (const scope of auxiliary) assert.ok(requested.includes(scope));
@@ -346,7 +346,7 @@ test("BigQuery discovers datasets and table schemas and inspects/cancels jobs wi
346
346
  const count = requests.length;
347
347
  await assert.rejects(service.invoke({ ...input, operation, input: { ...values, projectId: "other" } }), { code: "connector_input_invalid" });
348
348
  await assert.rejects(service.invoke({ ...input, context: { ...owner, subjectId: "other" }, operation, input: values }), { code: "connector_reconnect_required" });
349
- const denied = createConnectionService({ sideEffects: "live", ...options, authorize: async () => null });
349
+ const denied = createConnectionService({ appEnv: "production", ...options, authorize: async () => null });
350
350
  await assert.rejects(denied.invoke({ ...input, operation, input: values }));
351
351
  assert.equal(requests.length, count);
352
352
  state.response = { datasets: "bad", tables: "bad", jobReference: {}, schema: "bad" };
@@ -438,7 +438,7 @@ test("Gmail reads full MIME bodies, attachments and search and gates explicit ma
438
438
  assert.deepEqual(JSON.parse(requests.at(-1).init.body), { name: "Confirmed" });
439
439
  state.response = { labels: [{ id: "Label_1", name: "Confirmed" }] };
440
440
  assert.equal((await service.invoke({ ...input, operation: "labels.list" })).labels[0].name, "Confirmed");
441
- const noContent = createConnectionService({ sideEffects: "live", ...options, fetchImpl: async (url, init) => { requests.push({ url: new URL(url), init }); assert.equal(init.method, "DELETE"); return new Response(null, { status: 204 }); } });
441
+ const noContent = createConnectionService({ appEnv: "production", ...options, fetchImpl: async (url, init) => { requests.push({ url: new URL(url), init }); assert.equal(init.method, "DELETE"); return new Response(null, { status: 204 }); } });
442
442
  for (const operation of ["drafts.delete", "labels.delete"]) assert.equal(await noContent.invoke({ ...input, operation, input: { id: "draft_or_label" } }), null);
443
443
  const before = requests.length;
444
444
  for (const [operation, values] of [["messages.send", { raw: "not MIME + /" }], ["messages.modify", { id: "msg_1" }], ["attachments.get", { messageId: "../other", id: "attachment_1" }]]) await assert.rejects(service.invoke({ ...input, operation, input: values }), { code: "connector_input_invalid", statusCode: 422 });