@jskit-ai/connectors-catalog 0.2.27 → 0.2.29
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/CHANGELOG.md +1 -0
- package/package.json +3 -3
- package/patterns/api-key-connection/example/connections.js +4 -1
- package/patterns/firebase-messaging/example/server/notifications.js +4 -1
- package/src/server/brevo.js +9 -8
- package/src/server/calendly.js +5 -4
- package/src/server/chargebee.js +6 -5
- package/src/server/firebase-cloud-messaging.js +2 -1
- package/src/server/gatewayapi.js +4 -3
- package/src/server/gmail.js +3 -2
- package/src/server/google-ads-search.js +3 -2
- package/src/server/incident-io.js +3 -2
- package/src/server/inngest.js +3 -2
- package/src/server/linkedin.js +2 -1
- package/src/server/mailgun.js +3 -2
- package/src/server/microsoft-outlook.js +5 -4
- package/src/server/microsoft-teams.js +4 -3
- package/src/server/resend.js +4 -3
- package/src/server/sideEffect.js +17 -0
- package/src/server/slack.js +3 -2
- package/src/server/telegram.js +3 -2
- package/src/server/twilio.js +5 -4
- package/src/server/twitch.js +3 -2
- package/src/server/wave.js +4 -3
- package/src/server/wixBookings.js +10 -9
- package/src/server/woocommerce.js +2 -1
- package/test/brevo.test.js +1 -1
- package/test/calendly.test.js +3 -3
- package/test/chargebee.test.js +4 -4
- package/test/firebase-cloud-messaging.test.js +4 -4
- package/test/google-ads.test.js +9 -9
- package/test/google.test.js +5 -5
- package/test/inngest.test.js +4 -4
- package/test/linkedin.test.js +6 -6
- package/test/mailgun.test.js +1 -1
- package/test/microsoft.test.js +5 -5
- package/test/resend.test.js +1 -1
- package/test/slack.test.js +5 -5
- package/test/telegram.test.js +1 -1
- package/test/tokens.test.js +18 -18
- package/test/twilio.test.js +5 -5
- package/test/twitch.test.js +4 -4
- package/test/wave.test.js +5 -5
- package/test/wix.test.js +4 -4
- package/test/wordpress.test.js +1 -1
package/src/server/wave.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createSchema } from "json-rest-schema";
|
|
|
2
2
|
import { ConnectorError } from "@jskit-ai/connectors-core/server";
|
|
3
3
|
import { waveDefinition } from "../shared/wave.js";
|
|
4
4
|
import { graphqlOperation } from "./graphqlOperation.js";
|
|
5
|
+
import { sideEffect } from "./sideEffect.js";
|
|
5
6
|
|
|
6
7
|
const endpoint = "https://gql.waveapps.com/graphql/public";
|
|
7
8
|
const identifier = (value) => typeof value === "string" && value.length > 0 && value.length <= 2048 && !/[\s\p{Cc}]/u.test(value);
|
|
@@ -272,10 +273,10 @@ const waveProvider = Object.freeze({
|
|
|
272
273
|
"invoices.update": documentMutation("Invoice", "Patch", { ...invoiceFields, customerId: { ...businessId, required: false },
|
|
273
274
|
items: { ...invoiceFields.items, required: false }, id: businessId }, "invoice:write"),
|
|
274
275
|
"invoices.approve": documentMutation("Invoice", "Approve", { invoiceId: businessId }, "invoice:write"),
|
|
275
|
-
"invoices.send": documentMutation("Invoice", "Send", {
|
|
276
|
+
"invoices.send": sideEffect(documentMutation("Invoice", "Send", {
|
|
276
277
|
invoiceId: businessId,
|
|
277
278
|
...sendFields
|
|
278
|
-
}, "invoice:send"),
|
|
279
|
+
}, "invoice:send")),
|
|
279
280
|
"estimates.create": documentMutation("Estimate", "Create", estimateFields, "estimate:write"),
|
|
280
281
|
"estimates.update": documentMutation("Estimate", "Patch", {
|
|
281
282
|
...estimateFields, id: businessId,
|
|
@@ -285,7 +286,7 @@ const waveProvider = Object.freeze({
|
|
|
285
286
|
exchangeRate: { ...decimalInput, required: true }, items: { ...estimateFields.items, required: false }
|
|
286
287
|
}, "estimate:write"),
|
|
287
288
|
"estimates.approve": documentMutation("Estimate", "Approve", { estimateId: businessId }, "estimate:write"),
|
|
288
|
-
"estimates.send": documentMutation("Estimate", "Send", { estimateId: businessId, ...sendFields }, "estimate:send"),
|
|
289
|
+
"estimates.send": sideEffect(documentMutation("Estimate", "Send", { estimateId: businessId, ...sendFields }, "estimate:send")),
|
|
289
290
|
"estimates.list": businessPage("estimates", estimateSelection, ["estimate:read", "estimate:*"], validEstimate, ", sort: CREATED_AT_DESC"),
|
|
290
291
|
"estimates.get": {
|
|
291
292
|
...graphqlOperation(endpoint,
|
|
@@ -4,6 +4,7 @@ import { validateSchemaPayload } from "@jskit-ai/kernel/shared/validators";
|
|
|
4
4
|
import { serializeNativeJson, requestPath, sameRecord, cursor, querySchema, contactIdField, nativeJsonObjectField } from "./wixValues.js";
|
|
5
5
|
import { isUuid } from "../shared/uuid.js";
|
|
6
6
|
import { isRecord } from "@jskit-ai/kernel/shared/support/normalize";
|
|
7
|
+
import { sideEffect } from "./sideEffect.js";
|
|
7
8
|
|
|
8
9
|
// Wix Bookings operations: bookings, services, availability, staff, categories and service forms.
|
|
9
10
|
|
|
@@ -228,7 +229,7 @@ function bookingConfirmationOperation(action) {
|
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
231
|
const wixBookingOperations = {
|
|
231
|
-
"bookings.reschedule": {
|
|
232
|
+
"bookings.reschedule": sideEffect({
|
|
232
233
|
scopes: [],
|
|
233
234
|
request(input) {
|
|
234
235
|
const { bookingId, revision, slot, notifyParticipants, message } = validateSchemaPayload({ schema: bookingRescheduleSchema, mode: "replace" }, input, { statusCode: 422 });
|
|
@@ -249,10 +250,10 @@ const wixBookingOperations = {
|
|
|
249
250
|
},
|
|
250
251
|
validateResult: (value, request) => isUuid(value?.booking?.id) && sameRecord(value.booking.id === requestPath(request, -2), "Wix returned a different booking. Check the operation outcome before retrying.", { messageCode: "connectors.wix.returnedDifferentBookingCheckOperation" }) && typeof value.booking.revision === "string" && /^\d{1,19}$/u.test(value.booking.revision) &&
|
|
251
252
|
BigInt(value.booking.revision) <= 9223372036854775807n && typeof value.booking.status === "string" && value.booking.status.length > 0
|
|
252
|
-
},
|
|
253
|
-
"bookings.confirm": bookingConfirmationOperation("confirm"),
|
|
254
|
-
"bookings.decline": bookingConfirmationOperation("decline"),
|
|
255
|
-
"bookings.confirmOrDecline": bookingConfirmationOperation("confirmOrDecline"),
|
|
253
|
+
}),
|
|
254
|
+
"bookings.confirm": sideEffect(bookingConfirmationOperation("confirm")),
|
|
255
|
+
"bookings.decline": sideEffect(bookingConfirmationOperation("decline")),
|
|
256
|
+
"bookings.confirmOrDecline": sideEffect(bookingConfirmationOperation("confirmOrDecline")),
|
|
256
257
|
"bookingServices.listAddOnGroups": {
|
|
257
258
|
scopes: [],
|
|
258
259
|
request(input) {
|
|
@@ -355,7 +356,7 @@ const wixBookingOperations = {
|
|
|
355
356
|
typeof field.type === "string" && field.type.length > 0 && (field.label === undefined || typeof field.label === "string" && field.label.length <= 350) &&
|
|
356
357
|
(field.deleted === undefined || typeof field.deleted === "boolean") && (field.options === undefined || Array.isArray(field.options) && field.options.length <= 400))
|
|
357
358
|
},
|
|
358
|
-
"bookings.create": {
|
|
359
|
+
"bookings.create": sideEffect({
|
|
359
360
|
scopes: [],
|
|
360
361
|
request(input) {
|
|
361
362
|
const value = validateSchemaPayload({ schema: bookingCreateSchema, mode: "replace" }, input, { statusCode: 422 });
|
|
@@ -381,7 +382,7 @@ const wixBookingOperations = {
|
|
|
381
382
|
},
|
|
382
383
|
validateResult: value => isUuid(value?.booking?.id) && typeof value.booking.revision === "string" && /^\d{1,19}$/u.test(value.booking.revision) &&
|
|
383
384
|
BigInt(value.booking.revision) <= 9223372036854775807n && typeof value.booking.status === "string" && value.booking.status.length > 0
|
|
384
|
-
},
|
|
385
|
+
}),
|
|
385
386
|
"availability.list": availabilityOperation("list"),
|
|
386
387
|
"availability.get": availabilityOperation("get"),
|
|
387
388
|
"bookings.list": {
|
|
@@ -402,7 +403,7 @@ const wixBookingOperations = {
|
|
|
402
403
|
(!request.body.query.filter?.id || sameRecord(value.extendedBookings.length <= 1 && value.extendedBookings.every(record => record.booking.id === request.body.query.filter.id),
|
|
403
404
|
"Wix returned an unexpected booking for the requested ID.", { messageCode: "connectors.wix.returnedUnexpectedBookingRequestedId" }))
|
|
404
405
|
},
|
|
405
|
-
"bookings.cancel": {
|
|
406
|
+
"bookings.cancel": sideEffect({
|
|
406
407
|
scopes: [],
|
|
407
408
|
request(input) {
|
|
408
409
|
const { bookingId, revision, notifyParticipants, message, waiveCharges } = validateSchemaPayload({ schema: bookingCancelSchema, mode: "replace" }, input, { statusCode: 422 });
|
|
@@ -413,7 +414,7 @@ const wixBookingOperations = {
|
|
|
413
414
|
},
|
|
414
415
|
validateResult: (value, request) => isUuid(value?.booking?.id) && sameRecord(value.booking.id === requestPath(request, -2), "Wix returned a different booking. Check the operation outcome before retrying.", { messageCode: "connectors.wix.returnedDifferentBookingCheckOperation" }) && value.booking.status === "CANCELED" &&
|
|
415
416
|
typeof value.booking.revision === "string" && /^\d{1,19}$/u.test(value.booking.revision) && BigInt(value.booking.revision) <= 9223372036854775807n
|
|
416
|
-
},
|
|
417
|
+
}),
|
|
417
418
|
"bookingServices.list": {
|
|
418
419
|
scopes: [],
|
|
419
420
|
request(input) {
|
|
@@ -4,6 +4,7 @@ import { createSchema } from "json-rest-schema";
|
|
|
4
4
|
import { validateSchemaPayload } from "@jskit-ai/kernel/shared/validators";
|
|
5
5
|
import { woocommerceDefinition } from "../shared/wordpress.js";
|
|
6
6
|
import { jsonOperation } from "./jsonOperation.js";
|
|
7
|
+
import { sideEffect } from "./sideEffect.js";
|
|
7
8
|
|
|
8
9
|
const baseUrl = (settings) => `${settings.siteUrl.replace(/\/+$/u, "")}/wp-json/wc/v3`;
|
|
9
10
|
const pagination = {
|
|
@@ -328,7 +329,7 @@ const woocommerceProvider = Object.freeze({
|
|
|
328
329
|
operations: {
|
|
329
330
|
"refunds.list": refundOperation("list"),
|
|
330
331
|
"refunds.get": refundOperation("get"),
|
|
331
|
-
"refunds.create": refundOperation("create"),
|
|
332
|
+
"refunds.create": sideEffect(refundOperation("create")),
|
|
332
333
|
"reports.sales": reportOperation("sales"),
|
|
333
334
|
"reports.topSellers": reportOperation("top_sellers"),
|
|
334
335
|
"reports.orders": reportOperation("orders/totals"),
|
package/test/brevo.test.js
CHANGED
|
@@ -10,7 +10,7 @@ test("Brevo explicitly sends messages and campaigns, manages contacts and retain
|
|
|
10
10
|
const directory = await makeTestDirectory("brevo-repair-"); t.after(() => rm(directory, { recursive: true, force: true }));
|
|
11
11
|
const requests = []; const state = { response: { contacts: [], count: 0 }, status: 200, deny: false, fail: false };
|
|
12
12
|
const identity = { context: { applicationId: "booking-app", subjectId: "owner" }, integrationId: "messaging" };
|
|
13
|
-
const service = createConnectionService({ configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
13
|
+
const service = createConnectionService({ sideEffects: "live", configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
14
14
|
messaging: { provider: "brevo", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:BREVO_API_KEY" } }
|
|
15
15
|
} }, providers: [brevoProvider], authorize: async context => { if (state.deny) throw new Error("denied"); return context; },
|
|
16
16
|
resolveReference: async () => "brevo-fixture-key",
|
package/test/calendly.test.js
CHANGED
|
@@ -42,7 +42,7 @@ test("Calendly web OAuth uses Basic and PKCE, persists rotating refresh tokens a
|
|
|
42
42
|
return Response.json({ resource: { uri: "https://api.calendly.com/users/one", name: "Fixture" } });
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
const service = createConnectionService(options);
|
|
45
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
46
46
|
for (const outcome of ["cancel", "denied"]) {
|
|
47
47
|
const attempt = new URL((await service.beginAuthorization(input)).authorizationUrl);
|
|
48
48
|
const denied = new URL(callback);
|
|
@@ -68,7 +68,7 @@ test("Calendly web OAuth uses Basic and PKCE, persists rotating refresh tokens a
|
|
|
68
68
|
time += 40_000;
|
|
69
69
|
await Promise.all([service.invoke({ ...input, operation: "profile.read" }), service.invoke({ ...input, operation: "profile.read" })]);
|
|
70
70
|
assert.equal(exchanges, 2);
|
|
71
|
-
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
71
|
+
const restarted = createConnectionService({ sideEffects: "live", ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
72
72
|
time += 40_000;
|
|
73
73
|
await restarted.invoke({ ...input, operation: "profile.read" });
|
|
74
74
|
assert.equal(exchanges, 3);
|
|
@@ -90,7 +90,7 @@ test("Calendly scheduling retains booking details, scopes, pagination and explic
|
|
|
90
90
|
const directory = await makeTestDirectory("calendly-scheduling-"); t.after(() => rm(directory, { recursive: true, force: true }));
|
|
91
91
|
const requests = []; const state = { response: { resource: { uri: "https://api.calendly.com/users/u", name: "Owner" } }, status: 200, fail: false, deny: false };
|
|
92
92
|
const identity = { context: { applicationId: "booking", subjectId: "owner" }, integrationId: "calendar" };
|
|
93
|
-
const service = createConnectionService({ configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
93
|
+
const service = createConnectionService({ sideEffects: "live", configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
94
94
|
calendar: { provider: "calendly", accountMode: "shared", scopes: ["users:read", "event_types:read", "availability:read", "scheduled_events:read", "scheduled_events:write", "scheduling_links:write"], authentication: { method: "api-key", secretRef: "env:CALENDLY_API_KEY" } }
|
|
95
95
|
} }, providers: [calendlyProvider], authorize: async context => { if (state.deny) throw new Error("denied"); return context; }, resolveReference: async () => "fixture-token",
|
|
96
96
|
store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(6) }, activeKeyId: "current" }) }),
|
package/test/chargebee.test.js
CHANGED
|
@@ -33,7 +33,7 @@ async function fixture(t) {
|
|
|
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({ ...options, sideEffects: "live" }), options, requests, directory, protection, state };
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
test("Chargebee verifies a site with Basic API-key authentication and retains file ownership across restart", async (t) => {
|
|
@@ -52,7 +52,7 @@ test("Chargebee verifies a site with Basic API-key authentication and retains fi
|
|
|
52
52
|
assert.equal(stored.includes(state.key), false);
|
|
53
53
|
assert.equal(stored.includes(first.headers.get("authorization")), false);
|
|
54
54
|
}
|
|
55
|
-
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
55
|
+
const restarted = createConnectionService({ sideEffects: "live", ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
56
56
|
assert.deepEqual(await restarted.status(input), connected);
|
|
57
57
|
state.key = "test_rotated_key";
|
|
58
58
|
assert.deepEqual(await restarted.invoke({ ...input, operation: "customers.list" }), customers);
|
|
@@ -88,10 +88,10 @@ test("Chargebee site changes require verification and never fall back across sit
|
|
|
88
88
|
await service.connectApiKey(input);
|
|
89
89
|
const configuration = structuredClone(options.configuration);
|
|
90
90
|
configuration.integrations.billing.settings.siteName = "acme-live";
|
|
91
|
-
const changed = createConnectionService({ ...options, configuration });
|
|
91
|
+
const changed = createConnectionService({ sideEffects: "live", ...options, configuration });
|
|
92
92
|
assert.equal((await changed.status(input)).status, "reconnect-required");
|
|
93
93
|
await assert.rejects(changed.invoke({ ...input, operation: "customers.list" }), { code: "connector_reconnect_required" });
|
|
94
|
-
const wrongHost = createConnectionService({ ...options, providers: [{ ...chargebeeProvider, operations: {
|
|
94
|
+
const wrongHost = createConnectionService({ sideEffects: "live", ...options, providers: [{ ...chargebeeProvider, operations: {
|
|
95
95
|
"customers.list": { scopes: [], request: () => ({ method: "GET", url: "https://acme-live.chargebee.com/api/v2/customers" }) }
|
|
96
96
|
} }] });
|
|
97
97
|
await assert.rejects(wrongHost.invoke({ ...input, operation: "customers.list" }), { code: "connector_destination_invalid" });
|
|
@@ -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) };
|
|
49
|
+
return { state, options, directory, service: createConnectionService({ ...options, sideEffects: "live" }) };
|
|
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); await restarted.invoke({ ...input, operation: "messages.validate", input: { message } });
|
|
171
|
+
const restarted = createConnectionService({ ...f.options, sideEffects: "live" }); 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({ ...f.options, configuration }); assert.equal((await changed.status(input)).status, "reconnect-required");
|
|
180
|
+
const changed = createConnectionService({ sideEffects: "live", ...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({ ...f.options, authorize: async (owner, operation) => {
|
|
189
|
+
const service = createConnectionService({ sideEffects: "live", ...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;
|
package/test/google-ads.test.js
CHANGED
|
@@ -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);
|
|
74
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
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({ ...f.options, store: createFileConnectionStore({ directory: f.directory, protection: f.protection }) });
|
|
149
|
+
const restarted = createConnectionService({ sideEffects: "live", ...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))]);
|
|
154
|
+
await Promise.all([f.invoke(undefined, restarted), f.invoke(undefined, createConnectionService({ ...f.options, sideEffects: "live" }))]);
|
|
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({ ...f.options, configuration }); const calls = f.state.calls.length;
|
|
172
|
+
const changed = createConnectionService({ sideEffects: "live", ...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({ ...f.options, configuration });
|
|
179
|
+
const missing = createConnectionService({ sideEffects: "live", ...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({ ...f.options, authorize: async (owner, operation) => {
|
|
221
|
+
const authorized = createConnectionService({ sideEffects: "live", ...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({ ...f.options, configuration }), { code: "integration_configuration_invalid" });
|
|
240
|
+
assert.throws(() => createConnectionService({ sideEffects: "live", ...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({ ...f.options, providers: [{ ...provider, requestTimeoutMs: 20 }] });
|
|
248
|
+
const timed = createConnectionService({ sideEffects: "live", ...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({ ...f.options, configuration: f.configuration });
|
|
325
|
+
const restarted = createConnectionService({ sideEffects: "live", ...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
|
});
|
package/test/google.test.js
CHANGED
|
@@ -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);
|
|
54
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
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);
|
|
80
|
+
const restarted = createConnectionService({ ...options, sideEffects: "live" });
|
|
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);
|
|
193
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
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({ ...options, authorize: async () => null });
|
|
349
|
+
const denied = createConnectionService({ sideEffects: "live", ...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({ ...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({ 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 }); } });
|
|
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 });
|
package/test/inngest.test.js
CHANGED
|
@@ -49,7 +49,7 @@ async function fixture(t) {
|
|
|
49
49
|
{ status: state.httpStatus, headers: { Location: "https://unexpected.example", Link: '<https://unexpected.example/next>; rel="next"' } });
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
return { service: createConnectionService(options), options, directory, protection, state, requests, resolved };
|
|
52
|
+
return { service: createConnectionService({ ...options, sideEffects: "live" }), options, directory, protection, state, requests, resolved };
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
test("Inngest verifies only signing-key metadata and keeps both credential values out of file state", async (t) => {
|
|
@@ -67,7 +67,7 @@ test("Inngest verifies only signing-key metadata and keeps both credential value
|
|
|
67
67
|
assert.equal(text.includes(state.eventKey), false);
|
|
68
68
|
assert.equal(text.includes(state.signing), false);
|
|
69
69
|
}
|
|
70
|
-
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
70
|
+
const restarted = createConnectionService({ sideEffects: "live", ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
71
71
|
assert.deepEqual(await restarted.status(input), connection);
|
|
72
72
|
for (const owner of [{ ...context, applicationId: "different-app" }, { ...context, subjectId: "different-owner" }]) {
|
|
73
73
|
await assert.rejects(restarted.invoke({ ...input, context: owner, operation: "events.send", input: event }), { code: "connector_reconnect_required" });
|
|
@@ -189,7 +189,7 @@ test("Inngest reference and branch changes require reverification, including bra
|
|
|
189
189
|
const config = structuredClone(options.configuration);
|
|
190
190
|
Object.assign(config.integrations.jobs.settings, changes);
|
|
191
191
|
for (const [name, value] of Object.entries(changes)) if (value === undefined) delete config.integrations.jobs.settings[name];
|
|
192
|
-
const changed = createConnectionService({ ...options, configuration: config });
|
|
192
|
+
const changed = createConnectionService({ sideEffects: "live", ...options, configuration: config });
|
|
193
193
|
const count = requests.length;
|
|
194
194
|
assert.equal((await changed.status(input)).status, "reconnect-required");
|
|
195
195
|
await assert.rejects(changed.invoke({ ...input, operation: "events.send", input: event }), { code: "connector_reconnect_required" });
|
|
@@ -197,7 +197,7 @@ test("Inngest reference and branch changes require reverification, including bra
|
|
|
197
197
|
}
|
|
198
198
|
const config = structuredClone(options.configuration);
|
|
199
199
|
delete config.integrations.jobs.settings.branchEnvironment;
|
|
200
|
-
const changed = createConnectionService({ ...options, configuration: config });
|
|
200
|
+
const changed = createConnectionService({ sideEffects: "live", ...options, configuration: config });
|
|
201
201
|
await changed.connectApiKey(input);
|
|
202
202
|
await changed.invoke({ ...input, operation: "events.send", input: event });
|
|
203
203
|
assert.equal(requests.at(-1).headers.get("x-inngest-env"), null);
|
package/test/linkedin.test.js
CHANGED
|
@@ -55,7 +55,7 @@ async function fixture(t) {
|
|
|
55
55
|
return Response.json(state.response, { status: state.status });
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
const service = createConnectionService(options);
|
|
58
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
59
59
|
async function start() {
|
|
60
60
|
const { authorizationUrl } = await service.beginAuthorization(input);
|
|
61
61
|
const url = new URL(authorizationUrl); const redirect = new URL(callback);
|
|
@@ -100,7 +100,7 @@ test("LinkedIn uses confidential Web OAuth, validates userinfo and persists only
|
|
|
100
100
|
const text = await readFile(path.join(directory, name), "utf8");
|
|
101
101
|
for (const secret of ["fixture-client-secret", "fixture-access-1", "unused-identity-token"]) assert.equal(text.includes(secret), false);
|
|
102
102
|
}
|
|
103
|
-
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
103
|
+
const restarted = createConnectionService({ sideEffects: "live", ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
104
104
|
assert.deepEqual(await restarted.invoke({ ...input, operation: "profile.read" }), state.response);
|
|
105
105
|
state.response = { sub: "member-1", email: "member@example.test", email_verified: false };
|
|
106
106
|
assert.deepEqual(await restarted.invoke({ ...input, operation: "profile.read" }), state.response);
|
|
@@ -185,7 +185,7 @@ test("LinkedIn sanitizes API failures and handles provider cancellation and time
|
|
|
185
185
|
state.stall = true;
|
|
186
186
|
const controller = new AbortController(); controller.abort();
|
|
187
187
|
await assert.rejects(service.invoke({ ...input, operation: "profile.read", signal: controller.signal }), { code: "connector_cancelled" });
|
|
188
|
-
const timeoutService = createConnectionService({ ...options, providers: [{ ...provider, requestTimeoutMs: 20 }] });
|
|
188
|
+
const timeoutService = createConnectionService({ sideEffects: "live", ...options, providers: [{ ...provider, requestTimeoutMs: 20 }] });
|
|
189
189
|
const keepAlive = setTimeout(() => {}, 1000);
|
|
190
190
|
try { await assert.rejects(timeoutService.invoke({ ...input, operation: "profile.read" }), { code: "connector_provider_timeout" }); }
|
|
191
191
|
finally { clearTimeout(keepAlive); }
|
|
@@ -200,9 +200,9 @@ test("LinkedIn respects host policy, registration identity and unavailable manag
|
|
|
200
200
|
const count = state.calls.length; state.deny = true;
|
|
201
201
|
await assert.rejects(service.invoke({ ...input, operation: "profile.read" })); assert.equal(state.calls.length, count); state.deny = false;
|
|
202
202
|
const changed = structuredClone(configuration); changed.registrations.linkedin.clientId = "other-client";
|
|
203
|
-
await assert.rejects(createConnectionService({ ...options, configuration: changed }).invoke({ ...input, operation: "profile.read" }), { code: "connector_reconnect_required" });
|
|
203
|
+
await assert.rejects(createConnectionService({ sideEffects: "live", ...options, configuration: changed }).invoke({ ...input, operation: "profile.read" }), { code: "connector_reconnect_required" });
|
|
204
204
|
changed.registrations.linkedin = { source: "managed", serviceUrlRef: "env:GATEWAY", serviceCredentialRef: "env:GATEWAY_KEY", assignmentRef: "shared" };
|
|
205
|
-
assert.throws(() => createConnectionService({ ...options, configuration: changed }), { code: "integration_configuration_invalid" });
|
|
205
|
+
assert.throws(() => createConnectionService({ sideEffects: "live", ...options, configuration: changed }), { code: "integration_configuration_invalid" });
|
|
206
206
|
assert.equal(state.calls.length, count);
|
|
207
207
|
});
|
|
208
208
|
|
|
@@ -215,7 +215,7 @@ test("LinkedIn's documented portable JSON validates unchanged", async () => {
|
|
|
215
215
|
test("LinkedIn publishes text as the connected member and respects host policy without retries", async (t) => {
|
|
216
216
|
const f = await fixture(t); f.configuration.integrations.linkedin.scopes.push("w_member_social");
|
|
217
217
|
f.state.scope += " w_member_social";
|
|
218
|
-
const service = createConnectionService(f.options);
|
|
218
|
+
const service = createConnectionService({ ...f.options, sideEffects: "live" });
|
|
219
219
|
const auth = new URL((await service.beginAuthorization(input)).authorizationUrl);
|
|
220
220
|
const returned = new URL(callback); returned.searchParams.set("code", "code"); returned.searchParams.set("state", auth.searchParams.get("state"));
|
|
221
221
|
await service.completeAuthorization({ ...input, callbackUrl: returned.href });
|
package/test/mailgun.test.js
CHANGED
|
@@ -17,7 +17,7 @@ async function fixture(t, region = "us") {
|
|
|
17
17
|
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
18
18
|
const requests = [];
|
|
19
19
|
const state = { fail: false, status: 200, malformed: false, deny: false };
|
|
20
|
-
const service = createConnectionService({
|
|
20
|
+
const service = createConnectionService({ sideEffects: "live",
|
|
21
21
|
configuration: { schemaVersion: 1, registrations: {}, integrations: { mail: {
|
|
22
22
|
provider: "mailgun", accountMode: "shared", scopes: [], settings: { region },
|
|
23
23
|
authentication: { method: "api-key", secretRef: "env:MAILGUN_KEY" }
|
package/test/microsoft.test.js
CHANGED
|
@@ -55,7 +55,7 @@ async function fixture(t, entry) {
|
|
|
55
55
|
return [202, 204].includes(state.status) ? new Response(null, { status: state.status }) : typeof state.response === "string" ? new Response(state.response, { status: state.status, headers: { "Content-Type": "text/html" } }) : Response.json(state.response, { status: state.status });
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
const service = createConnectionService(options);
|
|
58
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
59
59
|
const input = { context: owner, integrationId: "service" };
|
|
60
60
|
async function start() {
|
|
61
61
|
const result = await service.beginAuthorization({ ...input, verificationInput: entry.input });
|
|
@@ -92,7 +92,7 @@ for (const entry of cases) {
|
|
|
92
92
|
const text = await readFile(path.join(directory, filename), "utf8");
|
|
93
93
|
for (const secret of ["test-client-secret", "test-access-1", "test-refresh-1"]) assert.equal(text.includes(secret), false);
|
|
94
94
|
}
|
|
95
|
-
const restarted = createConnectionService(options);
|
|
95
|
+
const restarted = createConnectionService({ ...options, sideEffects: "live" });
|
|
96
96
|
assert.equal((await restarted.status(input)).status, "connected");
|
|
97
97
|
const invocation = { ...input, operation: entry.provider.checkOperation, input: entry.input };
|
|
98
98
|
assert.deepEqual(await restarted.invoke(invocation), { value: [entry.item] });
|
|
@@ -129,7 +129,7 @@ for (const entry of cases) {
|
|
|
129
129
|
await service.invoke(invocation);
|
|
130
130
|
assert.equal(new URLSearchParams(requests[2].init.body).get("refresh_token"), "test-refresh-1");
|
|
131
131
|
assert.equal(new Headers(requests[3].init.headers).get("authorization"), "Bearer test-access-2");
|
|
132
|
-
const restarted = createConnectionService(options);
|
|
132
|
+
const restarted = createConnectionService({ ...options, sideEffects: "live" });
|
|
133
133
|
state.time += 40_000;
|
|
134
134
|
await restarted.invoke(invocation);
|
|
135
135
|
assert.equal(new URLSearchParams(requests[4].init.body).get("refresh_token"), "test-refresh-2");
|
|
@@ -224,7 +224,7 @@ for (const [base, tenantId] of [[cases[6], directoryId], [cases[7], "consumers"]
|
|
|
224
224
|
assert.equal(begun.url.pathname, `/${tenantId}/oauth2/v2.0/authorize`);
|
|
225
225
|
await service.completeAuthorization({ ...input, callbackUrl: begun.callbackUrl });
|
|
226
226
|
state.time += 40_000;
|
|
227
|
-
await createConnectionService(options).invoke({ ...input, operation: "items.list" });
|
|
227
|
+
await createConnectionService({ ...options, sideEffects: "live" }).invoke({ ...input, operation: "items.list" });
|
|
228
228
|
const tokenRequests = requests.filter(({ url }) => url.hostname === "login.microsoftonline.com");
|
|
229
229
|
assert.equal(tokenRequests.length, 2);
|
|
230
230
|
assert.equal(new URLSearchParams(tokenRequests[1].init.body).get("refresh_token"), "test-refresh-1");
|
|
@@ -239,7 +239,7 @@ test("Microsoft tenant changes invalidate pending consent and stored grants befo
|
|
|
239
239
|
const pending = await start();
|
|
240
240
|
const configuration = structuredClone(options.configuration);
|
|
241
241
|
configuration.integrations.service.settings = { tenantId: directoryId };
|
|
242
|
-
const changed = createConnectionService({ ...options, configuration });
|
|
242
|
+
const changed = createConnectionService({ sideEffects: "live", ...options, configuration });
|
|
243
243
|
const before = requests.length;
|
|
244
244
|
assert.equal((await changed.status(input)).status, "reconnect-required");
|
|
245
245
|
await assert.rejects(changed.invoke({ ...input, operation: entry.provider.checkOperation, input: entry.input }), { code: "connector_reconnect_required" });
|
package/test/resend.test.js
CHANGED
|
@@ -20,7 +20,7 @@ async function fixture(t) {
|
|
|
20
20
|
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
21
21
|
const requests = [];
|
|
22
22
|
const state = { fail: false };
|
|
23
|
-
const service = createConnectionService({
|
|
23
|
+
const service = createConnectionService({ sideEffects: "live",
|
|
24
24
|
configuration: { schemaVersion: 1, registrations: {}, integrations: { mail: {
|
|
25
25
|
provider: "resend", accountMode: "shared", scopes: [],
|
|
26
26
|
authentication: { method: "api-key", secretRef: "env:RESEND_KEY" }
|
package/test/slack.test.js
CHANGED
|
@@ -59,7 +59,7 @@ async function fixture(t, actor = "user", granted = scopes) {
|
|
|
59
59
|
return Response.json(url.pathname === "/api/auth.test" ? { ok: true, team_id: "T123", user_id: "U123" } : state.page, { status: state.apiStatus });
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
const service = createConnectionService(options);
|
|
62
|
+
const service = createConnectionService({ ...options, sideEffects: "live" });
|
|
63
63
|
async function start() {
|
|
64
64
|
const { authorizationUrl } = await service.beginAuthorization(input);
|
|
65
65
|
const url = new URL(authorizationUrl);
|
|
@@ -91,7 +91,7 @@ for (const actor of ["user", "bot"]) {
|
|
|
91
91
|
assert(body.get("code_verifier"));
|
|
92
92
|
assert.equal(requests[1].url.searchParams.get("types"), "public_channel");
|
|
93
93
|
for (const filename of await readdir(directory)) assert(!(await readFile(path.join(directory, filename), "utf8")).includes("secret-"));
|
|
94
|
-
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
94
|
+
const restarted = createConnectionService({ sideEffects: "live", ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
95
95
|
assert.deepEqual(await restarted.status(input), { ...connected, callbackUrl: callback });
|
|
96
96
|
for (const [operation, type] of [["channels.list", "public_channel"], ["groups.list", "private_channel"], ["directMessages.list", "im"], ["groupMessages.list", "mpim"]]) {
|
|
97
97
|
assert.deepEqual(await restarted.invoke({ ...input, operation, input: { limit: 5, cursor: "next +&/=", exclude_archived: true } }), page);
|
|
@@ -111,7 +111,7 @@ for (const actor of ["user", "bot"]) {
|
|
|
111
111
|
const { service, options, state, connect, requests } = await fixture(t, actor);
|
|
112
112
|
await connect();
|
|
113
113
|
state.time += 40_000;
|
|
114
|
-
const restarted = createConnectionService(options);
|
|
114
|
+
const restarted = createConnectionService({ ...options, sideEffects: "live" });
|
|
115
115
|
await Promise.all([service.invoke({ ...input, operation: "channels.list" }), restarted.invoke({ ...input, operation: "groups.list" })]);
|
|
116
116
|
assert.equal(state.tokenCount, 2);
|
|
117
117
|
state.time += 40_000;
|
|
@@ -177,7 +177,7 @@ test("Slack changing actor invalidates pending attempts and connections, and can
|
|
|
177
177
|
const next = await start();
|
|
178
178
|
const configuration = structuredClone(options.configuration);
|
|
179
179
|
configuration.integrations.slack.settings.actor = "bot";
|
|
180
|
-
const changed = createConnectionService({ ...options, configuration });
|
|
180
|
+
const changed = createConnectionService({ sideEffects: "live", ...options, configuration });
|
|
181
181
|
const before = requests.length;
|
|
182
182
|
await assert.rejects(changed.completeAuthorization({ ...input, callbackUrl: next.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
183
183
|
await assert.rejects(changed.invoke({ ...input, operation: "channels.list" }), { code: "connector_reconnect_required" });
|
|
@@ -247,7 +247,7 @@ test("Slack API throttling does not replay and revocation persists reconnect sta
|
|
|
247
247
|
state.apiStatus = 200;
|
|
248
248
|
state.page = { ok: false, error: "token_revoked", detail: "secret-client" };
|
|
249
249
|
await assert.rejects(service.invoke({ ...input, operation: "channels.list" }), { code: "connector_reconnect_required" });
|
|
250
|
-
const restarted = createConnectionService(options);
|
|
250
|
+
const restarted = createConnectionService({ ...options, sideEffects: "live" });
|
|
251
251
|
assert.equal((await restarted.status(input)).status, "reconnect-required");
|
|
252
252
|
before = requests.length;
|
|
253
253
|
await assert.rejects(restarted.invoke({ ...input, operation: "channels.list" }), { code: "connector_reconnect_required" });
|
package/test/telegram.test.js
CHANGED
|
@@ -11,7 +11,7 @@ test("Telegram sends plain messages and polls without hidden acknowledgement or
|
|
|
11
11
|
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
12
12
|
const requests = [];
|
|
13
13
|
let response = { ok: true, result: { id: 123, is_bot: true, first_name: "Fixture" } }, status = 200;
|
|
14
|
-
const service = createConnectionService({
|
|
14
|
+
const service = createConnectionService({ sideEffects: "live",
|
|
15
15
|
configuration: { schemaVersion: 1, registrations: {}, integrations: { forms: {
|
|
16
16
|
provider: "telegram", accountMode: "shared", displayName: "Forms", scopes: [],
|
|
17
17
|
authentication: { method: "api-key", secretRef: "env:TELEGRAM_BOT_TOKEN" }
|