@jskit-ai/connectors-catalog 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -0
- package/docs/ai-upstream-notices.md +51 -0
- package/docs/ai.md +191 -0
- package/docs/airtable.md +130 -0
- package/docs/algolia.md +190 -0
- package/docs/amazon-redshift.md +229 -0
- package/docs/amplitude.md +210 -0
- package/docs/apify.md +162 -0
- package/docs/apollo-io.md +200 -0
- package/docs/asana.md +126 -0
- package/docs/ashby.md +188 -0
- package/docs/atlassian.md +224 -0
- package/docs/attention.md +162 -0
- package/docs/aws-athena.md +150 -0
- package/docs/aws-credentials.md +75 -0
- package/docs/aws-s3.md +193 -0
- package/docs/bigquery.md +146 -0
- package/docs/brevo.md +122 -0
- package/docs/calendly.md +158 -0
- package/docs/canva.md +191 -0
- package/docs/chargebee.md +192 -0
- package/docs/clay.md +194 -0
- package/docs/clickhouse.md +242 -0
- package/docs/confidence-exp.md +74 -0
- package/docs/confidence-flags.md +75 -0
- package/docs/confidence-oauth.md +137 -0
- package/docs/contentful.md +123 -0
- package/docs/databricks.md +180 -0
- package/docs/dbt-semantic-layer.md +175 -0
- package/docs/elevenlabs.md +102 -0
- package/docs/figma.md +132 -0
- package/docs/firebase-cloud-messaging.md +262 -0
- package/docs/firecrawl.md +137 -0
- package/docs/fireflies.md +95 -0
- package/docs/fireworks-ai.md +53 -0
- package/docs/gatewayapi.md +113 -0
- package/docs/gemini-enterprise.md +224 -0
- package/docs/github-api.md +133 -0
- package/docs/gitlab-api.md +138 -0
- package/docs/gmail.md +133 -0
- package/docs/gong.md +205 -0
- package/docs/google-ads.md +156 -0
- package/docs/google-analytics.md +202 -0
- package/docs/google-docs.md +105 -0
- package/docs/google-drive.md +108 -0
- package/docs/google-maps-platform.md +208 -0
- package/docs/google-oauth.md +123 -0
- package/docs/google-search-console.md +124 -0
- package/docs/google-sheets.md +94 -0
- package/docs/google-slides.md +95 -0
- package/docs/granola.md +178 -0
- package/docs/hex.md +161 -0
- package/docs/heygen.md +124 -0
- package/docs/hubspot.md +142 -0
- package/docs/incident-io.md +118 -0
- package/docs/inngest.md +178 -0
- package/docs/klipy.md +149 -0
- package/docs/lexware.md +144 -0
- package/docs/lightspeed.md +193 -0
- package/docs/linear.md +137 -0
- package/docs/linkedin.md +196 -0
- package/docs/logo-dev.md +152 -0
- package/docs/mailgun.md +153 -0
- package/docs/mapbox.md +174 -0
- package/docs/microsoft-excel.md +97 -0
- package/docs/microsoft-fabric.md +249 -0
- package/docs/microsoft-oauth.md +143 -0
- package/docs/microsoft-onedrive.md +76 -0
- package/docs/microsoft-onenote.md +75 -0
- package/docs/microsoft-outlook.md +90 -0
- package/docs/microsoft-powerpoint.md +119 -0
- package/docs/microsoft-sharepoint.md +75 -0
- package/docs/microsoft-teams.md +72 -0
- package/docs/microsoft-word.md +119 -0
- package/docs/miro.md +117 -0
- package/docs/n8n.md +169 -0
- package/docs/notion.md +137 -0
- package/docs/oura.md +161 -0
- package/docs/paddle.md +168 -0
- package/docs/perplexity.md +85 -0
- package/docs/pipedrive.md +120 -0
- package/docs/polar.md +63 -0
- package/docs/posthog.md +227 -0
- package/docs/prestashop.md +151 -0
- package/docs/replicate.md +60 -0
- package/docs/resend.md +153 -0
- package/docs/salesforce.md +234 -0
- package/docs/sanity.md +122 -0
- package/docs/semrush.md +276 -0
- package/docs/sentry.md +112 -0
- package/docs/sevdesk.md +107 -0
- package/docs/shopify.md +206 -0
- package/docs/slack.md +257 -0
- package/docs/snowflake.md +271 -0
- package/docs/storyblok.md +130 -0
- package/docs/stripe.md +77 -0
- package/docs/supabase.md +51 -0
- package/docs/tally.md +105 -0
- package/docs/telegram.md +165 -0
- package/docs/tiktok.md +201 -0
- package/docs/twilio.md +284 -0
- package/docs/twitch.md +428 -0
- package/docs/wave.md +440 -0
- package/docs/wix.md +1249 -0
- package/docs/wiz.md +177 -0
- package/docs/woocommerce.md +400 -0
- package/docs/wordpress-com.md +358 -0
- package/docs/wordpress-self-hosted.md +252 -0
- package/docs/workday.md +292 -0
- package/docs/x-twitter.md +188 -0
- package/docs/xero.md +429 -0
- package/docs/zoho-books.md +214 -0
- package/docs/zoho-crm.md +192 -0
- package/package.json +153 -0
- package/patterns/ai-connections/PATTERN.md +84 -0
- package/patterns/ai-connections/example/ai-model.js +11 -0
- package/patterns/ai-connections/example/perplexity-answer.js +29 -0
- package/patterns/api-key-connection/PATTERN.md +368 -0
- package/patterns/api-key-connection/example/connections.js +18 -0
- package/patterns/api-key-connection/example/integrations.json +19 -0
- package/patterns/assistant-mcp/PATTERN.md +110 -0
- package/patterns/assistant-mcp/example/integrations.json +13 -0
- package/patterns/assistant-mcp-oauth/PATTERN.md +235 -0
- package/patterns/assistant-mcp-oauth/example/integrations.json +102 -0
- package/patterns/aws-storage-queries/PATTERN.md +169 -0
- package/patterns/aws-storage-queries/example/formats/data-formats.js +35 -0
- package/patterns/aws-storage-queries/example/formats/package-lock.json +49 -0
- package/patterns/aws-storage-queries/example/formats/package.json +12 -0
- package/patterns/aws-storage-queries/example/formats/verify-formats.mjs +37 -0
- package/patterns/aws-storage-queries/example/integrations.json +38 -0
- package/patterns/aws-storage-queries/example/s3-transfer.js +34 -0
- package/patterns/event-delivery/PATTERN.md +151 -0
- package/patterns/event-delivery/example/integrations.json +17 -0
- package/patterns/firebase-messaging/PATTERN.md +156 -0
- package/patterns/firebase-messaging/example/server/notifications.js +23 -0
- package/patterns/google-ads-search/PATTERN.md +92 -0
- package/patterns/google-ads-search/example/ads-setup.js +25 -0
- package/patterns/oauth-connection/PATTERN.md +724 -0
- package/patterns/oauth-connection/example/integrations.json +20 -0
- package/patterns/paddle-catalogue/PATTERN.md +78 -0
- package/patterns/paddle-catalogue/example/create-products.js +38 -0
- package/patterns/public-image/PATTERN.md +84 -0
- package/patterns/public-image/example/integrations.json +13 -0
- package/patterns/public-image/example/logo-url.js +16 -0
- package/patterns/redshift-queries/PATTERN.md +150 -0
- package/patterns/redshift-queries/example/integrations.json +33 -0
- package/patterns/source-scanning/PATTERN.md +83 -0
- package/patterns/source-scanning/example/source-scanner.js +13 -0
- package/src/client/firebase-cloud-messaging.js +10 -0
- package/src/client/google-analytics.js +72 -0
- package/src/client/google-maps-platform.js +39 -0
- package/src/client/logo-dev.js +36 -0
- package/src/server/ai.js +46 -0
- package/src/server/airtable.js +67 -0
- package/src/server/algolia.js +63 -0
- package/src/server/amazon-redshift.js +96 -0
- package/src/server/amplitude.js +31 -0
- package/src/server/apify.js +68 -0
- package/src/server/apollo-io.js +85 -0
- package/src/server/asana.js +64 -0
- package/src/server/ashby.js +61 -0
- package/src/server/atlassian.js +32 -0
- package/src/server/attention.js +93 -0
- package/src/server/aws-athena.js +82 -0
- package/src/server/aws-s3.js +49 -0
- package/src/server/awsTransport.js +75 -0
- package/src/server/bigquery.js +97 -0
- package/src/server/brevo.js +97 -0
- package/src/server/calendly.js +77 -0
- package/src/server/canva.js +13 -0
- package/src/server/chargebee.js +88 -0
- package/src/server/clay.js +78 -0
- package/src/server/clickhouse.js +66 -0
- package/src/server/confidence.js +29 -0
- package/src/server/contentful.js +40 -0
- package/src/server/databricks.js +55 -0
- package/src/server/dbt-semantic-layer.js +95 -0
- package/src/server/elevenlabs.js +81 -0
- package/src/server/figma.js +24 -0
- package/src/server/firebase-cloud-messaging.js +111 -0
- package/src/server/firecrawl.js +70 -0
- package/src/server/fireflies.js +31 -0
- package/src/server/fireworks-ai.js +16 -0
- package/src/server/gatewayapi.js +48 -0
- package/src/server/gemini-enterprise.js +47 -0
- package/src/server/github-api.js +90 -0
- package/src/server/gitlab-api.js +67 -0
- package/src/server/gmail.js +60 -0
- package/src/server/gong.js +52 -0
- package/src/server/google-ads-search.js +134 -0
- package/src/server/google-ads.js +80 -0
- package/src/server/google-docs.js +36 -0
- package/src/server/google-drive.js +71 -0
- package/src/server/google-maps-platform.js +90 -0
- package/src/server/google-search-console.js +31 -0
- package/src/server/google-sheets.js +60 -0
- package/src/server/google-slides.js +36 -0
- package/src/server/google.js +61 -0
- package/src/server/granola.js +115 -0
- package/src/server/graphqlOperation.js +15 -0
- package/src/server/hex.js +29 -0
- package/src/server/heygen.js +54 -0
- package/src/server/hubspot.js +85 -0
- package/src/server/incident-io.js +68 -0
- package/src/server/inngest.js +86 -0
- package/src/server/jsonOperation.js +34 -0
- package/src/server/klipy.js +34 -0
- package/src/server/lexware.js +59 -0
- package/src/server/lightspeed.js +82 -0
- package/src/server/linear.js +52 -0
- package/src/server/linkedin.js +74 -0
- package/src/server/mailgun.js +76 -0
- package/src/server/mapbox.js +46 -0
- package/src/server/mcpRegistration.js +41 -0
- package/src/server/mcpTransport.js +60 -0
- package/src/server/microsoft-excel.js +67 -0
- package/src/server/microsoft-fabric.js +81 -0
- package/src/server/microsoft-onedrive.js +58 -0
- package/src/server/microsoft-onenote.js +52 -0
- package/src/server/microsoft-outlook.js +58 -0
- package/src/server/microsoft-powerpoint.js +5 -0
- package/src/server/microsoft-sharepoint.js +46 -0
- package/src/server/microsoft-teams.js +29 -0
- package/src/server/microsoft-word.js +5 -0
- package/src/server/microsoft.js +88 -0
- package/src/server/miro.js +29 -0
- package/src/server/n8n.js +78 -0
- package/src/server/notion.js +76 -0
- package/src/server/oura.js +48 -0
- package/src/server/paddle.js +83 -0
- package/src/server/perplexity.js +15 -0
- package/src/server/pipedrive.js +95 -0
- package/src/server/polar.js +20 -0
- package/src/server/posthog.js +44 -0
- package/src/server/prestashop.js +42 -0
- package/src/server/replicate.js +42 -0
- package/src/server/resend.js +93 -0
- package/src/server/salesforce.js +84 -0
- package/src/server/sanity.js +31 -0
- package/src/server/semrush.js +359 -0
- package/src/server/sentry.js +30 -0
- package/src/server/sevdesk.js +20 -0
- package/src/server/shopify.js +99 -0
- package/src/server/slack.js +143 -0
- package/src/server/snowflake.js +139 -0
- package/src/server/storyblok.js +49 -0
- package/src/server/stripe.js +13 -0
- package/src/server/supabase.js +13 -0
- package/src/server/tally.js +78 -0
- package/src/server/telegram.js +55 -0
- package/src/server/tiktok.js +86 -0
- package/src/server/twilio.js +90 -0
- package/src/server/twitch.js +409 -0
- package/src/server/wave.js +520 -0
- package/src/server/wix.js +1048 -0
- package/src/server/wiz.js +117 -0
- package/src/server/woocommerce.js +412 -0
- package/src/server/wordpress-com.js +236 -0
- package/src/server/wordpress-self-hosted.js +134 -0
- package/src/server/workday.js +136 -0
- package/src/server/x-twitter.js +110 -0
- package/src/server/xero.js +397 -0
- package/src/server/zoho-books.js +90 -0
- package/src/server/zoho-crm.js +89 -0
- package/src/server/zohoOAuth.js +21 -0
- package/src/shared/ai-models.json +8049 -0
- package/src/shared/ai.js +63 -0
- package/src/shared/algolia.js +29 -0
- package/src/shared/amazon-redshift.js +51 -0
- package/src/shared/amplitude.js +28 -0
- package/src/shared/atlassian.js +43 -0
- package/src/shared/aws.js +72 -0
- package/src/shared/canva.js +66 -0
- package/src/shared/chargebee.js +26 -0
- package/src/shared/clickhouse.js +38 -0
- package/src/shared/confidence.js +28 -0
- package/src/shared/databricks.js +33 -0
- package/src/shared/dbt-semantic-layer.js +32 -0
- package/src/shared/definitions.js +140 -0
- package/src/shared/figma.js +21 -0
- package/src/shared/firebase-cloud-messaging.js +45 -0
- package/src/shared/gemini-enterprise.js +33 -0
- package/src/shared/gong.js +33 -0
- package/src/shared/google-ads-search.js +31 -0
- package/src/shared/google-ads.js +28 -0
- package/src/shared/google-maps-platform.js +28 -0
- package/src/shared/google.js +133 -0
- package/src/shared/granola.js +25 -0
- package/src/shared/hex.js +28 -0
- package/src/shared/inngest.js +35 -0
- package/src/shared/lightspeed.js +75 -0
- package/src/shared/linkedin.js +27 -0
- package/src/shared/logo-dev.js +21 -0
- package/src/shared/mapbox.js +38 -0
- package/src/shared/mcp.js +92 -0
- package/src/shared/microsoft-fabric.js +47 -0
- package/src/shared/microsoft.js +231 -0
- package/src/shared/miro.js +27 -0
- package/src/shared/oura.js +23 -0
- package/src/shared/posthog.js +33 -0
- package/src/shared/prestashop.js +23 -0
- package/src/shared/salesforce.js +36 -0
- package/src/shared/semrush.js +24 -0
- package/src/shared/shopify.js +51 -0
- package/src/shared/siteUrl.js +12 -0
- package/src/shared/slack.js +88 -0
- package/src/shared/snowflake.js +55 -0
- package/src/shared/tiktok.js +22 -0
- package/src/shared/tokens.js +747 -0
- package/src/shared/twilio.js +41 -0
- package/src/shared/twitch.js +49 -0
- package/src/shared/wave.js +52 -0
- package/src/shared/wix.js +40 -0
- package/src/shared/wiz.js +41 -0
- package/src/shared/wordpress-com.js +30 -0
- package/src/shared/wordpress.js +69 -0
- package/src/shared/workday.js +50 -0
- package/src/shared/x-twitter.js +19 -0
- package/src/shared/xero.js +46 -0
- package/src/shared/zoho-books.js +39 -0
- package/src/shared/zoho-crm.js +43 -0
- package/src/shared/zoho-regions.js +12 -0
- package/test/ai.test.js +136 -0
- package/test/airtable.test.js +125 -0
- package/test/algolia.test.js +207 -0
- package/test/amazon-redshift.test.js +272 -0
- package/test/amplitude.test.js +239 -0
- package/test/apify.test.js +93 -0
- package/test/apollo-io.test.js +125 -0
- package/test/asana.test.js +99 -0
- package/test/ashby.test.js +97 -0
- package/test/atlassian.test.js +249 -0
- package/test/attention.test.js +79 -0
- package/test/aws.test.js +405 -0
- package/test/brevo.test.js +71 -0
- package/test/calendly.test.js +136 -0
- package/test/canva.test.js +258 -0
- package/test/chargebee.test.js +195 -0
- package/test/clickhouse.test.js +278 -0
- package/test/confidence.test.js +205 -0
- package/test/databricks.test.js +253 -0
- package/test/dbt-semantic-layer.test.js +221 -0
- package/test/designMcp.test.js +336 -0
- package/test/elevenlabs.test.js +52 -0
- package/test/firebase-cloud-messaging.test.js +242 -0
- package/test/firecrawl.test.js +66 -0
- package/test/gemini-enterprise.test.js +218 -0
- package/test/github-api.test.js +167 -0
- package/test/gitlab-api.test.js +160 -0
- package/test/gong.test.js +192 -0
- package/test/google-ads.test.js +350 -0
- package/test/google-maps-platform.test.js +191 -0
- package/test/google.test.js +710 -0
- package/test/granola.test.js +240 -0
- package/test/hex.test.js +253 -0
- package/test/heygen.test.js +121 -0
- package/test/hubspot.test.js +103 -0
- package/test/inngest.test.js +219 -0
- package/test/lightspeed.test.js +250 -0
- package/test/linear.test.js +146 -0
- package/test/linkedin.test.js +243 -0
- package/test/logo-dev.test.js +79 -0
- package/test/mailgun.test.js +107 -0
- package/test/mapbox.test.js +181 -0
- package/test/mcp.test.js +227 -0
- package/test/microsoft-fabric.test.js +258 -0
- package/test/microsoft.test.js +554 -0
- package/test/n8nOAuth.test.js +188 -0
- package/test/notionOAuth.test.js +183 -0
- package/test/oura.test.js +211 -0
- package/test/paddleCatalogue.test.js +51 -0
- package/test/paddlePermissions.test.js +101 -0
- package/test/perplexityComposition.test.js +39 -0
- package/test/pipedriveOAuth.test.js +140 -0
- package/test/posthog.test.js +200 -0
- package/test/prestashop.test.js +207 -0
- package/test/resend.test.js +163 -0
- package/test/salesforce.test.js +276 -0
- package/test/semrush.test.js +479 -0
- package/test/sentry.test.js +35 -0
- package/test/shopify.test.js +247 -0
- package/test/slack.test.js +320 -0
- package/test/snowflake.test.js +391 -0
- package/test/tally.test.js +75 -0
- package/test/telegram.test.js +58 -0
- package/test/tiktok.test.js +243 -0
- package/test/tokens.test.js +1079 -0
- package/test/twilio.test.js +221 -0
- package/test/twitch.test.js +573 -0
- package/test/wave.test.js +678 -0
- package/test/wix.test.js +1099 -0
- package/test/wiz.test.js +185 -0
- package/test/wordpress-com.test.js +469 -0
- package/test/wordpress.test.js +660 -0
- package/test/workday.test.js +314 -0
- package/test/x-twitter.test.js +256 -0
- package/test/xero.test.js +700 -0
- package/test/zoho-books.test.js +253 -0
- package/test/zoho-crm.test.js +223 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createConnectionService } from "../../connectors-core/src/server/index.js";
|
|
7
|
+
import { createFileConnectionStore, createCredentialProtection } from "../../connectors-core/src/server/fileStorage.js";
|
|
8
|
+
import { apolloIoProvider } from "../src/server/apollo-io.js";
|
|
9
|
+
|
|
10
|
+
test("Apollo prospects, explicit enrichment and CRM changes run through the application-owned connection", async t => {
|
|
11
|
+
const directory = await mkdtemp(path.join(tmpdir(), "apollo-repair-"));
|
|
12
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
13
|
+
const requests = [];
|
|
14
|
+
const state = { response: { accounts: [] }, status: 200, fail: false, deny: false, key: "fixture-apollo-key" };
|
|
15
|
+
const context = { applicationId: "sales-app", subjectId: "workspace" };
|
|
16
|
+
const service = createConnectionService({
|
|
17
|
+
configuration: { schemaVersion: 1, registrations: {}, integrations: { sales: {
|
|
18
|
+
provider: "apollo-io", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:APOLLO_API_KEY" }
|
|
19
|
+
} } }, providers: [apolloIoProvider], authorize: async owner => { if (state.deny) throw new Error("forbidden"); return owner; },
|
|
20
|
+
resolveReference: async () => state.key,
|
|
21
|
+
store: createFileConnectionStore({ directory, protection: createCredentialProtection({
|
|
22
|
+
keys: { current: new Uint8Array(32).fill(8) }, activeKeyId: "current"
|
|
23
|
+
}) }), fetchImpl: async (url, init) => {
|
|
24
|
+
requests.push({ url: new URL(url), init });
|
|
25
|
+
if (state.fail) throw new Error("uncertain outcome");
|
|
26
|
+
return Response.json(state.response, { status: state.status });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const identity = { context, integrationId: "sales" };
|
|
30
|
+
const invoke = (operation, input) => service.invoke({ ...identity, operation, input });
|
|
31
|
+
await service.connectApiKey(identity);
|
|
32
|
+
assert.equal(requests.length, 1);
|
|
33
|
+
assert.equal(requests[0].url.pathname, "/api/v1/accounts/search");
|
|
34
|
+
state.response = { people: [{ id: "person-1", first_name: "Fixture" }], total_entries: 1 };
|
|
35
|
+
assert.equal((await invoke("people.search", { person_titles: ["Designer", "Founder"], page: 2 })).people[0].id, "person-1");
|
|
36
|
+
assert.deepEqual(requests.at(-1).url.searchParams.getAll("person_titles[]"), ["Designer", "Founder"]);
|
|
37
|
+
assert.equal(requests.at(-1).url.searchParams.get("page"), "2");
|
|
38
|
+
assert.equal(requests.at(-1).init.body, undefined);
|
|
39
|
+
const beforeCharge = requests.length;
|
|
40
|
+
for (const [operation, input] of [
|
|
41
|
+
["organizations.search", { q_organization_name: "Fixture" }],
|
|
42
|
+
["organizations.enrich", { domain: "fixture.example", allowCreditConsumption: false }],
|
|
43
|
+
["people.enrich", { id: "person-1" }]
|
|
44
|
+
]) await assert.rejects(invoke(operation, input));
|
|
45
|
+
assert.equal(requests.length, beforeCharge);
|
|
46
|
+
state.response = { organizations: [{ id: "org-1" }], pagination: { page: 1 } };
|
|
47
|
+
await invoke("organizations.search", { q_organization_name: "Fixture & Co", allowCreditConsumption: true });
|
|
48
|
+
assert.equal(requests.at(-1).url.pathname, "/api/v1/mixed_companies/search");
|
|
49
|
+
assert.equal(requests.at(-1).url.searchParams.get("q_organization_name"), "Fixture & Co");
|
|
50
|
+
assert.equal(requests.at(-1).url.searchParams.has("allowCreditConsumption"), false);
|
|
51
|
+
state.response = { person: { id: "person-1", email: "fixture@example.test" }, match_confidence: "high" };
|
|
52
|
+
await invoke("people.enrich", { id: "person-1", allowCreditConsumption: true });
|
|
53
|
+
for (const field of ["reveal_personal_emails", "reveal_phone_number", "run_waterfall_email", "run_waterfall_phone"])
|
|
54
|
+
assert.equal(requests.at(-1).url.searchParams.get(field), "false");
|
|
55
|
+
state.response = { person: null, match_confidence: "none" };
|
|
56
|
+
assert.equal((await invoke("people.enrich", { id: "missing", allowCreditConsumption: true })).person, null);
|
|
57
|
+
state.response = { organization: { id: "org-1", domain: "fixture.example" } };
|
|
58
|
+
await invoke("organizations.enrich", { domain: "fixture.example", allowCreditConsumption: true });
|
|
59
|
+
assert.equal(requests.at(-1).init.method, "GET");
|
|
60
|
+
|
|
61
|
+
for (const [operation, input, method, endpoint, response] of [
|
|
62
|
+
["contacts.search", { q_keywords: "Fixture" }, "POST", "contacts/search", { contacts: [] }],
|
|
63
|
+
["contacts.create", { first_name: "Fixture", email: "fixture@example.test", run_dedupe: false }, "POST", "contacts", { contact: { id: "contact-1" } }],
|
|
64
|
+
["contacts.update", { id: "contact-1", title: "Founder", label_names: ["Customers"] }, "PATCH", "contacts/contact-1", { contact: { id: "contact-1" } }],
|
|
65
|
+
["accounts.create", { name: "Fixture", domain: "fixture.example" }, "POST", "accounts", { account: { id: "account-1" } }],
|
|
66
|
+
["accounts.update", { id: "account-1", phone: "+61 800 000 000" }, "PATCH", "accounts/account-1", { account: { id: "account-1" } }],
|
|
67
|
+
["deals.create", { name: "Renewal", account_id: "account-1", amount: "1200.50", closed_date: "2026-12-31" }, "POST", "opportunities", { opportunity: { id: "deal-1" } }],
|
|
68
|
+
["deals.update", { id: "deal-1", opportunity_stage_id: "stage-1" }, "PATCH", "opportunities/deal-1", { opportunity: { id: "deal-1" } }],
|
|
69
|
+
["deals.list", { page: 2 }, "GET", "opportunities/search", { opportunities: [{ id: "deal-1" }] }],
|
|
70
|
+
["dealStages.list", {}, "GET", "opportunity_stages", { opportunity_stages: [{ id: "stage-1" }] }],
|
|
71
|
+
["users.list", { page: 2 }, "GET", "users/search", { users: [{ id: "user-1" }] }]
|
|
72
|
+
]) {
|
|
73
|
+
state.response = response;
|
|
74
|
+
assert.deepEqual(await invoke(operation, input), response);
|
|
75
|
+
const request = requests.at(-1);
|
|
76
|
+
assert.equal(request.url.pathname, `/api/v1/${endpoint}`);
|
|
77
|
+
assert.equal(request.init.method, method);
|
|
78
|
+
assert.equal(new Headers(request.init.headers).get("x-api-key"), state.key);
|
|
79
|
+
assert.equal(request.init.redirect, "error");
|
|
80
|
+
if (method === "PATCH") { const { id, ...body } = input; assert.deepEqual(JSON.parse(request.init.body), body); }
|
|
81
|
+
}
|
|
82
|
+
state.response = { contact: { id: "existing-contact" } };
|
|
83
|
+
await invoke("contacts.create", { first_name: "Fixture", run_dedupe: true });
|
|
84
|
+
assert.equal(JSON.parse(requests.at(-1).init.body).run_dedupe, true);
|
|
85
|
+
const beforeInvalid = requests.length;
|
|
86
|
+
for (const [operation, input] of [
|
|
87
|
+
["people.search", { person_titles: Array(101).fill("Designer") }],
|
|
88
|
+
["contacts.create", { first_name: "Fixture" }], ["contacts.update", { id: "contact-1" }],
|
|
89
|
+
["accounts.update", { id: "../secrets", name: "Fixture" }], ["accounts.create", {}],
|
|
90
|
+
["deals.create", { name: "Renewal", amount: "$1,200" }],
|
|
91
|
+
["deals.update", { id: "deal-1", closed_date: "2026-02-30" }],
|
|
92
|
+
["organizations.enrich", { domain: "https://fixture.example", allowCreditConsumption: true }],
|
|
93
|
+
["people.enrich", { id: "person-1", allowCreditConsumption: true, reveal_phone_number: true }]
|
|
94
|
+
]) await assert.rejects(invoke(operation, input));
|
|
95
|
+
state.deny = true;
|
|
96
|
+
await assert.rejects(invoke("contacts.create", { first_name: "Fixture", run_dedupe: false }));
|
|
97
|
+
state.deny = false;
|
|
98
|
+
await assert.rejects(service.invoke({ ...identity, context: { ...context, applicationId: "other" }, operation: "people.search" }));
|
|
99
|
+
assert.equal(requests.length, beforeInvalid);
|
|
100
|
+
state.response = { person: {} };
|
|
101
|
+
await assert.rejects(invoke("people.enrich", { id: "person-1", allowCreditConsumption: true }), { code: "connector_response_invalid" });
|
|
102
|
+
state.response = { error: { message: state.key } };
|
|
103
|
+
for (const status of [403, 422, 429]) {
|
|
104
|
+
state.status = status;
|
|
105
|
+
await assert.rejects(invoke("people.search", {}), error => !JSON.stringify(error).includes(state.key));
|
|
106
|
+
}
|
|
107
|
+
state.status = 200;
|
|
108
|
+
state.fail = true;
|
|
109
|
+
const beforeUncertain = requests.length;
|
|
110
|
+
await assert.rejects(invoke("contacts.create", { first_name: "Fixture", run_dedupe: false }));
|
|
111
|
+
assert.equal(requests.length, beforeUncertain + 1);
|
|
112
|
+
state.fail = false;
|
|
113
|
+
state.response = { accounts: [] };
|
|
114
|
+
state.key = "rotated-key";
|
|
115
|
+
await invoke("accounts.search", {});
|
|
116
|
+
assert.equal(new Headers(requests.at(-1).init.headers).get("x-api-key"), "rotated-key");
|
|
117
|
+
state.status = 401;
|
|
118
|
+
await assert.rejects(invoke("accounts.search", {}), { code: "connector_reconnect_required" });
|
|
119
|
+
state.status = 200;
|
|
120
|
+
await service.connectApiKey(identity);
|
|
121
|
+
await service.disconnect(identity);
|
|
122
|
+
const disconnectedRequests = requests.length;
|
|
123
|
+
await assert.rejects(invoke("people.search", {}));
|
|
124
|
+
assert.equal(requests.length, disconnectedRequests);
|
|
125
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createConnectionService } from "../../connectors-core/src/server/index.js";
|
|
7
|
+
import { createFileConnectionStore, createCredentialProtection } from "../../connectors-core/src/server/fileStorage.js";
|
|
8
|
+
import { asanaProvider } from "../src/server/asana.js";
|
|
9
|
+
|
|
10
|
+
test("Asana creates a private project, explicitly shares it, tracks tasks and preserves sparse changes", async t => {
|
|
11
|
+
const directory = await mkdtemp(path.join(tmpdir(), "asana-repair-"));
|
|
12
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
13
|
+
const requests = [];
|
|
14
|
+
const state = { status: 200, response: { data: [{ gid: "123" }] }, fail: false, deny: false, key: "asana-fixture" };
|
|
15
|
+
const identity = { context: { applicationId: "work-app", subjectId: "workspace" }, integrationId: "work" };
|
|
16
|
+
const service = createConnectionService({ configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
17
|
+
work: { provider: "asana", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:ASANA_API_KEY" } }
|
|
18
|
+
} }, providers: [asanaProvider], authorize: async context => { if (state.deny) throw new Error("forbidden"); return context; },
|
|
19
|
+
resolveReference: async () => state.key,
|
|
20
|
+
store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(4) }, activeKeyId: "current" }) }),
|
|
21
|
+
fetchImpl: async (url, init) => { requests.push({ url: new URL(url), init });
|
|
22
|
+
if (state.fail) throw new Error("uncertain provider result");
|
|
23
|
+
return Response.json(state.response, { status: state.status }); }
|
|
24
|
+
});
|
|
25
|
+
const invoke = (operation, input) => service.invoke({ ...identity, operation, input });
|
|
26
|
+
await service.connectApiKey(identity);
|
|
27
|
+
assert.equal(requests[0].url.pathname, "/api/1.0/workspaces");
|
|
28
|
+
for (const [operation, input, endpoint] of [
|
|
29
|
+
["projects.list", { workspace: "123", archived: false }, "projects"],
|
|
30
|
+
["users.list", { workspace: "123" }, "workspaces/123/users"],
|
|
31
|
+
["teams.list", { workspace: "123" }, "workspaces/123/teams"],
|
|
32
|
+
["tasks.list", { project: "456", completed_since: "now" }, "projects/456/tasks"]
|
|
33
|
+
]) {
|
|
34
|
+
state.response = { data: [{ gid: "456" }], next_page: { offset: "next & page", uri: "https://untrusted.invalid/page" } };
|
|
35
|
+
assert.deepEqual(await invoke(operation, input), state.response);
|
|
36
|
+
assert.equal(requests.at(-1).url.pathname, `/api/1.0/${endpoint}`);
|
|
37
|
+
await invoke(operation, { ...input, offset: "next & page" });
|
|
38
|
+
assert.equal(requests.at(-1).url.origin, "https://app.asana.com");
|
|
39
|
+
assert.equal(requests.at(-1).url.searchParams.get("offset"), "next & page");
|
|
40
|
+
if (operation === "tasks.list") assert.ok(requests.at(-1).url.searchParams.get("opt_fields").includes("completed"));
|
|
41
|
+
}
|
|
42
|
+
for (const [operation, input, method, endpoint, data] of [
|
|
43
|
+
["projects.create", { name: "Launch", workspace: "123", privacy_setting: "private" }, "POST", "projects", { name: "Launch", workspace: "123", privacy_setting: "private" }],
|
|
44
|
+
["projectMembers.add", { project: "456", member: "789", access_level: "editor" }, "POST", "memberships", { parent: "456", member: "789", access_level: "editor" }],
|
|
45
|
+
["projects.update", { gid: "456", archived: false, notes: "" }, "PUT", "projects/456", { archived: false, notes: "" }],
|
|
46
|
+
["tasks.create", { name: "Publish", workspace: "123", projects: ["456"], assignee: "789", due_on: "2026-12-31" }, "POST", "tasks", { name: "Publish", workspace: "123", projects: ["456"], assignee: "789", due_on: "2026-12-31" }],
|
|
47
|
+
["tasks.update", { gid: "900", completed: true }, "PUT", "tasks/900", { completed: true }],
|
|
48
|
+
["tasks.update", { gid: "900", completed: false, assignee: null, start_on: null, due_on: null }, "PUT", "tasks/900", { completed: false, assignee: null, start_on: null, due_on: null }]
|
|
49
|
+
]) {
|
|
50
|
+
state.response = { data: { gid: "900", ...data } };
|
|
51
|
+
assert.deepEqual(await invoke(operation, input), state.response);
|
|
52
|
+
const request = requests.at(-1);
|
|
53
|
+
assert.equal(request.url.pathname, `/api/1.0/${endpoint}`);
|
|
54
|
+
assert.equal(request.init.method, method);
|
|
55
|
+
assert.deepEqual(JSON.parse(request.init.body), { data });
|
|
56
|
+
assert.equal(new Headers(request.init.headers).get("authorization"), "Bearer asana-fixture");
|
|
57
|
+
assert.equal(request.init.redirect, "error");
|
|
58
|
+
}
|
|
59
|
+
for (const operation of ["tasks.get", "projects.get"]) {
|
|
60
|
+
state.response = { data: { gid: "900", name: "Fixture" } };
|
|
61
|
+
assert.deepEqual(await invoke(operation, { gid: "900" }), state.response);
|
|
62
|
+
}
|
|
63
|
+
const beforeInvalid = requests.length;
|
|
64
|
+
for (const [operation, input] of [
|
|
65
|
+
["projects.create", { name: "Launch", workspace: "123" }],
|
|
66
|
+
["projects.update", { gid: "456" }], ["tasks.get", { gid: "../secrets" }],
|
|
67
|
+
["tasks.update", { gid: "900", start_on: "2026-09-12" }],
|
|
68
|
+
["tasks.update", { gid: "900", due_on: "2026-02-30" }],
|
|
69
|
+
["projects.update", { gid: "456", start_on: "2026-12-31", due_on: "2026-12-31" }],
|
|
70
|
+
["tasks.update", { gid: "900", projects: ["456"] }],
|
|
71
|
+
["projectMembers.add", { project: "456", member: "789", access_level: "owner" }]
|
|
72
|
+
]) await assert.rejects(invoke(operation, input));
|
|
73
|
+
state.deny = true;
|
|
74
|
+
await assert.rejects(invoke("tasks.update", { gid: "900", completed: true }));
|
|
75
|
+
state.deny = false;
|
|
76
|
+
await assert.rejects(service.invoke({ ...identity, context: { ...identity.context, applicationId: "other" }, operation: "workspaces.list" }));
|
|
77
|
+
assert.equal(requests.length, beforeInvalid);
|
|
78
|
+
state.response = { data: {} };
|
|
79
|
+
await assert.rejects(invoke("tasks.get", { gid: "900" }), { code: "connector_response_invalid" });
|
|
80
|
+
for (const status of [400, 403, 404, 429]) {
|
|
81
|
+
state.status = status; state.response = { errors: [{ message: state.key }] };
|
|
82
|
+
await assert.rejects(invoke("tasks.get", { gid: "900" }), e => !JSON.stringify(e).includes(state.key));
|
|
83
|
+
}
|
|
84
|
+
state.status = 200; state.fail = true;
|
|
85
|
+
const beforeUncertain = requests.length;
|
|
86
|
+
await assert.rejects(invoke("tasks.create", { name: "Publish", workspace: "123" }));
|
|
87
|
+
assert.equal(requests.length, beforeUncertain + 1);
|
|
88
|
+
state.fail = false; state.response = { data: [] }; state.key = "rotated-fixture";
|
|
89
|
+
await invoke("workspaces.list", {});
|
|
90
|
+
assert.equal(new Headers(requests.at(-1).init.headers).get("authorization"), "Bearer rotated-fixture");
|
|
91
|
+
state.status = 401;
|
|
92
|
+
await assert.rejects(invoke("workspaces.list", {}), { code: "connector_reconnect_required" });
|
|
93
|
+
state.status = 200;
|
|
94
|
+
await service.connectApiKey(identity);
|
|
95
|
+
await service.disconnect(identity);
|
|
96
|
+
const afterDisconnect = requests.length;
|
|
97
|
+
await assert.rejects(invoke("tasks.list", { project: "456" }));
|
|
98
|
+
assert.equal(requests.length, afterDisconnect);
|
|
99
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createConnectionService } from "../../connectors-core/src/server/index.js";
|
|
7
|
+
import { createFileConnectionStore, createCredentialProtection } from "../../connectors-core/src/server/fileStorage.js";
|
|
8
|
+
import { ashbyProvider } from "../src/server/ashby.js";
|
|
9
|
+
|
|
10
|
+
const id = "11111111-1111-4111-8111-111111111111";
|
|
11
|
+
const stage = "22222222-2222-4222-8222-222222222222";
|
|
12
|
+
test("Ashby syncs candidates/applications, updates a profile and explicitly advances a sourced application", async t => {
|
|
13
|
+
const directory = await mkdtemp(path.join(tmpdir(), "ashby-repair-"));
|
|
14
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
15
|
+
const requests = [];
|
|
16
|
+
const state = { status: 200, response: { success: true, results: [], moreDataAvailable: false }, fail: false, deny: false };
|
|
17
|
+
const identity = { context: { applicationId: "hiring-app", subjectId: "workspace" }, integrationId: "hiring" };
|
|
18
|
+
const service = createConnectionService({ configuration: { schemaVersion: 1, registrations: {}, integrations: {
|
|
19
|
+
hiring: { provider: "ashby", accountMode: "shared", scopes: [], authentication: { method: "api-key", secretRef: "env:ASHBY_API_KEY" } }
|
|
20
|
+
} }, providers: [ashbyProvider], authorize: async context => { if (state.deny) throw new Error("forbidden"); return context; },
|
|
21
|
+
resolveReference: async () => "ashby-fixture-key",
|
|
22
|
+
store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(3) }, activeKeyId: "current" }) }),
|
|
23
|
+
fetchImpl: async (url, init) => { requests.push({ url: new URL(url), init });
|
|
24
|
+
if (state.fail) throw new Error("uncertain result");
|
|
25
|
+
return Response.json(state.response, { status: state.status }); }
|
|
26
|
+
});
|
|
27
|
+
const invoke = (operation, input) => service.invoke({ ...identity, operation, input });
|
|
28
|
+
await service.connectApiKey(identity);
|
|
29
|
+
assert.equal(requests[0].url.pathname, "/job.list");
|
|
30
|
+
for (const [operation, endpoint, input] of [
|
|
31
|
+
["candidates.list", "candidate.list", {}],
|
|
32
|
+
["applications.list", "application.list", { jobId: id, status: "Active" }],
|
|
33
|
+
["interviewPlans.list", "interviewPlan.list", {}]
|
|
34
|
+
]) {
|
|
35
|
+
state.response = { success: true, results: [{ id }], moreDataAvailable: true, nextCursor: "next & page" };
|
|
36
|
+
assert.deepEqual(await invoke(operation, { ...input, syncToken: "old-checkpoint" }), state.response);
|
|
37
|
+
assert.equal(requests.at(-1).url.pathname, `/${endpoint}`);
|
|
38
|
+
state.response = { success: true, results: [], moreDataAvailable: false, syncToken: "new-checkpoint" };
|
|
39
|
+
assert.equal((await invoke(operation, { ...input, syncToken: "old-checkpoint", cursor: "next & page" })).syncToken, "new-checkpoint");
|
|
40
|
+
const sent = JSON.parse(requests.at(-1).init.body);
|
|
41
|
+
assert.equal(sent.syncToken, "old-checkpoint");
|
|
42
|
+
assert.equal(sent.cursor, "next & page");
|
|
43
|
+
}
|
|
44
|
+
for (const [operation, input, endpoint, body] of [
|
|
45
|
+
["jobs.get", { id }, "job.info", { id }],
|
|
46
|
+
["candidates.get", { id }, "candidate.info", { id }],
|
|
47
|
+
["candidates.create", { name: "Fixture Candidate", email: "candidate@example.test" }, "candidate.create", { name: "Fixture Candidate", email: "candidate@example.test" }],
|
|
48
|
+
["candidates.update", { candidateId: id, phoneNumber: "+61 400 000 000" }, "candidate.update", { candidateId: id, phoneNumber: "+61 400 000 000", sendNotifications: false }],
|
|
49
|
+
["applications.get", { applicationId: id }, "application.info", { applicationId: id }],
|
|
50
|
+
["applications.create", { candidateId: id, jobId: id, interviewPlanId: stage }, "application.create", { candidateId: id, jobId: id, interviewPlanId: stage }],
|
|
51
|
+
["applications.changeStage", { applicationId: id, interviewStageId: stage }, "application.changeStage", { applicationId: id, interviewStageId: stage }],
|
|
52
|
+
["applications.changeStage", { applicationId: id, interviewStageId: stage, archiveReasonId: id }, "application.changeStage", { applicationId: id, interviewStageId: stage, archiveReasonId: id }]
|
|
53
|
+
]) {
|
|
54
|
+
state.response = { success: true, results: { id, ...body } };
|
|
55
|
+
assert.deepEqual(await invoke(operation, input), state.response);
|
|
56
|
+
const request = requests.at(-1);
|
|
57
|
+
assert.equal(request.url.pathname, `/${endpoint}`);
|
|
58
|
+
assert.equal(request.init.method, "POST");
|
|
59
|
+
assert.deepEqual(JSON.parse(request.init.body), body);
|
|
60
|
+
assert.equal(new Headers(request.init.headers).get("authorization"), `Basic ${Buffer.from("ashby-fixture-key:").toString("base64")}`);
|
|
61
|
+
assert.equal(new Headers(request.init.headers).get("accept"), "application/json; version=1");
|
|
62
|
+
assert.equal(request.init.redirect, "error");
|
|
63
|
+
}
|
|
64
|
+
state.response = { success: true, results: [{ id: stage, type: "Interview", title: "Screen" }] };
|
|
65
|
+
assert.equal((await invoke("interviewStages.list", { interviewPlanId: id })).results[0].id, stage);
|
|
66
|
+
state.response = { success: true, results: [{ id: stage, text: "Position closed" }] };
|
|
67
|
+
await invoke("archiveReasons.list", {});
|
|
68
|
+
assert.equal(requests.at(-1).url.pathname, "/archiveReason.list");
|
|
69
|
+
assert.deepEqual(JSON.parse(requests.at(-1).init.body), { includeArchived: false });
|
|
70
|
+
const beforeInvalid = requests.length;
|
|
71
|
+
for (const [operation, input] of [
|
|
72
|
+
["candidates.create", { name: "" }], ["candidates.update", { candidateId: id }],
|
|
73
|
+
["applications.create", { candidateId: id, jobId: "wrong" }],
|
|
74
|
+
["applications.changeStage", { applicationId: id }],
|
|
75
|
+
["applications.changeStage", { applicationId: id, interviewStageId: stage, archiveEmail: {} }],
|
|
76
|
+
["applications.list", { limit: 101 }], ["interviewStages.list", {}]
|
|
77
|
+
]) await assert.rejects(invoke(operation, input));
|
|
78
|
+
state.deny = true;
|
|
79
|
+
await assert.rejects(invoke("applications.changeStage", { applicationId: id, interviewStageId: stage }));
|
|
80
|
+
state.deny = false;
|
|
81
|
+
await assert.rejects(service.invoke({ ...identity, context: { ...identity.context, applicationId: "other" }, operation: "jobs.list" }));
|
|
82
|
+
assert.equal(requests.length, beforeInvalid);
|
|
83
|
+
for (const response of [{ success: false, errors: [{ message: "ashby-fixture-key" }] }, { success: true, results: {} }]) {
|
|
84
|
+
state.response = response;
|
|
85
|
+
await assert.rejects(invoke("candidates.get", { id }), e => !JSON.stringify(e).includes("ashby-fixture-key"));
|
|
86
|
+
}
|
|
87
|
+
state.response = { success: true, results: [], moreDataAvailable: true };
|
|
88
|
+
await assert.rejects(invoke("candidates.list", {}), { code: "connector_response_invalid" });
|
|
89
|
+
for (const status of [403, 429]) {
|
|
90
|
+
state.status = status;
|
|
91
|
+
await assert.rejects(invoke("applications.list", {}));
|
|
92
|
+
}
|
|
93
|
+
state.status = 200; state.fail = true;
|
|
94
|
+
const beforeUncertain = requests.length;
|
|
95
|
+
await assert.rejects(invoke("candidates.create", { name: "Fixture Candidate" }));
|
|
96
|
+
assert.equal(requests.length, beforeUncertain + 1);
|
|
97
|
+
});
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createConnectionService } from "../../connectors-core/src/server/index.js";
|
|
7
|
+
import { createFileConnectionStore, createCredentialProtection } from "../../connectors-core/src/server/fileStorage.js";
|
|
8
|
+
import { parseIntegrationConfiguration } from "../../connectors-core/src/shared/configuration.js";
|
|
9
|
+
import { atlassianProvider, registerAtlassianClient } from "../src/server/atlassian.js";
|
|
10
|
+
|
|
11
|
+
const context = { applicationId: "assistant-host", subjectId: "account-owner" };
|
|
12
|
+
const input = { context, integrationId: "work" };
|
|
13
|
+
const callback = "http://127.0.0.1:4919/atlassian/callback";
|
|
14
|
+
const resource = "https://mcp.atlassian.com/v2/mcp";
|
|
15
|
+
const endpoint = `${resource}?tools=all`;
|
|
16
|
+
const tokenEndpoint = "https://auth.atlassian.com/oauth/token";
|
|
17
|
+
const registrationEndpoint = "https://auth.atlassian.com/VCeDsk8ZHncYF1g234fKtc4lNipbBhu3/dcr/register";
|
|
18
|
+
const scopes = ["read:me", "read:jira:agent-interface", "offline_access"];
|
|
19
|
+
const discovery = { tools: [{ name: "getJiraIssue", inputSchema: { type: "object", properties: { cloudId: { type: "string" } } } }] };
|
|
20
|
+
|
|
21
|
+
async function fixture(t) {
|
|
22
|
+
const directory = await mkdtemp(path.join(tmpdir(), "atlassian-connector-"));
|
|
23
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
24
|
+
const protection = createCredentialProtection({ keys: { current: new Uint8Array(32).fill(3) }, activeKeyId: "current" });
|
|
25
|
+
const state = { time: Date.now(), scopes, status: 200, list: discovery, call: { content: [{ type: "text", text: "Project work" }] } };
|
|
26
|
+
const requests = [];
|
|
27
|
+
const options = {
|
|
28
|
+
configuration: { schemaVersion: 1, registrations: { atlassian: { source: "own", clientId: "fixture-client",
|
|
29
|
+
clientSecretRef: "env:ATLASSIAN_CLIENT_SECRET", callbackUrlRef: "env:ATLASSIAN_CALLBACK" } }, integrations: {
|
|
30
|
+
work: { provider: "atlassian", accountMode: "assistant", scopes,
|
|
31
|
+
authentication: { method: "oauth2", registrationRef: "atlassian" } }
|
|
32
|
+
} },
|
|
33
|
+
providers: [atlassianProvider], store: createFileConnectionStore({ directory, protection }), now: () => state.time,
|
|
34
|
+
authorize: async (owner, request) => request.operation === "tools.call" &&
|
|
35
|
+
(!["getJiraIssue", "getConfluencePage"].includes(request.input.name) || request.input.arguments.cloudId !== "allowed-site") ? null : owner,
|
|
36
|
+
resolveReference: async (reference) => reference === "env:ATLASSIAN_CLIENT_SECRET" ? "fixture-client-secret" : callback,
|
|
37
|
+
fetchImpl: async (address, init) => {
|
|
38
|
+
init.signal.throwIfAborted();
|
|
39
|
+
const url = String(address);
|
|
40
|
+
requests.push({ url, init, headers: new Headers(init.headers) });
|
|
41
|
+
if (url === tokenEndpoint) {
|
|
42
|
+
if (state.tokenError) return Response.json({ error: state.tokenError, error_description: "fixture-client-secret" }, { status: 400 });
|
|
43
|
+
const refresh = new URLSearchParams(init.body).get("grant_type") === "refresh_token";
|
|
44
|
+
return Response.json({ token_type: "Bearer", access_token: refresh ? "refreshed-access" : "initial-access",
|
|
45
|
+
refresh_token: refresh ? "rotated-refresh" : "initial-refresh", expires_in: 60, scope: state.scopes.join(" ") });
|
|
46
|
+
}
|
|
47
|
+
assert.equal(url, endpoint);
|
|
48
|
+
if (init.method === "DELETE") return new Response(null, { status: 204 });
|
|
49
|
+
if (init.method === "GET") return new Response(null, { status: 405 });
|
|
50
|
+
if (state.status !== 200) return new Response("initial-access fixture-client-secret", { status: state.status,
|
|
51
|
+
headers: { "WWW-Authenticate": 'Bearer resource_metadata="https://unexpected.invalid/auth"' } });
|
|
52
|
+
const message = JSON.parse(init.body);
|
|
53
|
+
requests.at(-1).message = message;
|
|
54
|
+
if (message.id === undefined) return new Response(null, { status: 202 });
|
|
55
|
+
const result = message.method === "initialize" ? { protocolVersion: message.params.protocolVersion,
|
|
56
|
+
capabilities: { tools: {} }, serverInfo: { name: "atlassian-fixture", version: "1" } }
|
|
57
|
+
: message.method === "tools/list" ? state.list : state.call;
|
|
58
|
+
if (state.pause && message.method === "tools/call") {
|
|
59
|
+
state.started();
|
|
60
|
+
return new Promise((resolve, reject) => init.signal.addEventListener("abort", () => reject(init.signal.reason), { once: true }));
|
|
61
|
+
}
|
|
62
|
+
return Response.json({ jsonrpc: "2.0", id: message.id, result }, { headers: { "Mcp-Session-Id": "atlassian-session" } });
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const service = createConnectionService(options);
|
|
66
|
+
const complete = async (start, extra = "code=fixture-code") => service.completeAuthorization({ ...input,
|
|
67
|
+
callbackUrl: `${callback}?state=${new URL(start.authorizationUrl).searchParams.get("state")}&${extra}` });
|
|
68
|
+
return { service, options, state, requests, directory, protection, complete };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
test("Atlassian v2 binds PKCE and resource grants to its authorization server, then refreshes after file restart", async (t) => {
|
|
73
|
+
const { service, options, requests, state, complete, directory, protection } = await fixture(t);
|
|
74
|
+
const start = await service.beginAuthorization(input);
|
|
75
|
+
const url = new URL(start.authorizationUrl);
|
|
76
|
+
assert.equal(url.origin + url.pathname, "https://auth.atlassian.com/authorize");
|
|
77
|
+
assert.equal(url.searchParams.get("resource"), resource);
|
|
78
|
+
assert.equal(url.searchParams.get("scope"), scopes.join(" "));
|
|
79
|
+
assert.equal(url.searchParams.get("code_challenge_method"), "S256");
|
|
80
|
+
assert.equal(requests.length, 0);
|
|
81
|
+
assert.equal((await complete(start)).status, "connected");
|
|
82
|
+
const grant = new URLSearchParams(requests.find(({ url }) => url === tokenEndpoint).init.body);
|
|
83
|
+
assert.equal(grant.get("resource"), resource);
|
|
84
|
+
assert.equal(grant.get("client_secret"), "fixture-client-secret");
|
|
85
|
+
assert.equal(grant.get("redirect_uri"), callback);
|
|
86
|
+
assert(grant.get("code_verifier"));
|
|
87
|
+
assert.equal(requests.filter(({ message }) => message?.method === "tools/call").length, 0);
|
|
88
|
+
const initialized = requests.find(({ message }) => message?.method === "initialize");
|
|
89
|
+
assert.deepEqual(initialized.message.params.capabilities, {});
|
|
90
|
+
for (const request of requests.filter(({ url }) => url === endpoint)) {
|
|
91
|
+
assert.equal(request.headers.get("authorization"), "Bearer initial-access");
|
|
92
|
+
assert.equal(request.init.redirect, "error");
|
|
93
|
+
assert.equal(request.init.credentials, "omit");
|
|
94
|
+
}
|
|
95
|
+
const restarted = createConnectionService({ ...options, store: createFileConnectionStore({ directory, protection }) });
|
|
96
|
+
state.time += 61_000;
|
|
97
|
+
assert.deepEqual(await restarted.invoke({ ...input, operation: "tools.list", input: { cursor: "next-page" } }), discovery);
|
|
98
|
+
assert.deepEqual(requests.findLast(({ message }) => message?.method === "tools/list").message.params, { cursor: "next-page" });
|
|
99
|
+
const refresh = new URLSearchParams(requests.findLast(({ url }) => url === tokenEndpoint).init.body);
|
|
100
|
+
assert.equal(refresh.get("resource"), resource);
|
|
101
|
+
assert.equal(refresh.get("refresh_token"), "initial-refresh");
|
|
102
|
+
assert.equal(requests.at(-1).headers.get("authorization"), "Bearer refreshed-access");
|
|
103
|
+
assert.equal(requests.at(-1).init.method, "DELETE");
|
|
104
|
+
for (const name of await readdir(directory)) {
|
|
105
|
+
const stored = await readFile(path.join(directory, name), "utf8");
|
|
106
|
+
for (const secret of ["initial-access", "refreshed-access", "initial-refresh", "rotated-refresh", "fixture-client-secret", grant.get("code_verifier")]) assert(!stored.includes(secret));
|
|
107
|
+
}
|
|
108
|
+
const count = requests.length;
|
|
109
|
+
await assert.rejects(complete(start), { code: "connector_attempt_invalid" });
|
|
110
|
+
for (const owner of [{ ...context, applicationId: "another-host" }, { ...context, subjectId: "another-owner" }]) {
|
|
111
|
+
await assert.rejects(restarted.invoke({ ...input, context: owner, operation: "tools.list" }), { code: "connector_reconnect_required" });
|
|
112
|
+
}
|
|
113
|
+
assert.equal(requests.length, count);
|
|
114
|
+
await restarted.disconnect(input);
|
|
115
|
+
assert.equal((await service.status(input)).status, "disconnected");
|
|
116
|
+
assert.equal(requests.length, count);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("Atlassian validates assistant ownership and permissions, and cannot reuse attempts after scope edits", async (t) => {
|
|
120
|
+
const { options, service, requests } = await fixture(t);
|
|
121
|
+
const parse = (config) => parseIntegrationConfiguration(JSON.stringify(config), { providers: [atlassianProvider] });
|
|
122
|
+
for (const [field, value] of [["accountMode", "shared"], ["accountMode", "per-user"], ["scopes", ["admin"]], ["scopes", []]]) {
|
|
123
|
+
const config = structuredClone(options.configuration);
|
|
124
|
+
config.integrations.work[field] = value;
|
|
125
|
+
assert.throws(() => parse(config));
|
|
126
|
+
}
|
|
127
|
+
const config = structuredClone(options.configuration);
|
|
128
|
+
config.integrations.work.scopes = atlassianProvider.scopes.map(({ value }) => value);
|
|
129
|
+
assert.deepEqual(parse(config).integrations.work.scopes, config.integrations.work.scopes);
|
|
130
|
+
assert(atlassianProvider.scopes.filter(({ value }) => /^(write:|delete:|manage:)/.test(value)).every(({ recommended }) => !recommended));
|
|
131
|
+
const start = await service.beginAuthorization(input);
|
|
132
|
+
const changed = createConnectionService({ ...options, configuration: config });
|
|
133
|
+
await assert.rejects(changed.completeAuthorization({ ...input, callbackUrl: `${callback}?code=x&state=${new URL(start.authorizationUrl).searchParams.get("state")}` }), { code: "connector_attempt_invalid" });
|
|
134
|
+
assert.equal(requests.length, 0);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("Atlassian authorizes the exact tool and destination site, preserves tool errors and cancels without replay", async (t) => {
|
|
138
|
+
const { service, complete, requests, state } = await fixture(t);
|
|
139
|
+
await complete(await service.beginAuthorization(input));
|
|
140
|
+
const count = requests.length;
|
|
141
|
+
for (const payload of [{ name: "deleteJiraIssue", arguments: {} }, { name: "getJiraIssue", arguments: { cloudId: "another-site" } }]) {
|
|
142
|
+
await assert.rejects(service.invoke({ ...input, operation: "tools.call", input: payload }), { code: "connector_access_denied" });
|
|
143
|
+
}
|
|
144
|
+
await assert.rejects(service.invoke({ ...input, operation: "tools.list", input: { url: "https://unexpected.invalid" } }), { code: "connector_input_invalid" });
|
|
145
|
+
assert.equal(requests.length, count);
|
|
146
|
+
const payload = { name: "getJiraIssue", arguments: { cloudId: "allowed-site" } };
|
|
147
|
+
for (const [name, text] of [["getJiraIssue", "DOG-42: Grooming booking fails. Status: In Progress. Assignee: Sam."],
|
|
148
|
+
["getConfluencePage", "Booking runbook: restart the worker, then verify the pending appointment queue."]]) {
|
|
149
|
+
state.call = { content: [{ type: "text", text }] };
|
|
150
|
+
const request = { name, arguments: { cloudId: "allowed-site" } };
|
|
151
|
+
assert.deepEqual(await service.invoke({ ...input, operation: "tools.call", input: request }), state.call);
|
|
152
|
+
assert.deepEqual(requests.findLast(({ message }) => message?.method === "tools/call").message.params, request);
|
|
153
|
+
}
|
|
154
|
+
state.call = { content: [{ type: "text", text: "This issue is not accessible" }], isError: true };
|
|
155
|
+
assert.deepEqual(await service.invoke({ ...input, operation: "tools.call", input: payload }), state.call);
|
|
156
|
+
assert.deepEqual(requests.findLast(({ message }) => message?.method === "tools/call").message.params, payload);
|
|
157
|
+
state.pause = true;
|
|
158
|
+
const started = new Promise((resolve) => { state.started = resolve; });
|
|
159
|
+
const controller = new AbortController();
|
|
160
|
+
const pending = assert.rejects(service.invoke({ ...input, operation: "tools.call", input: payload, signal: controller.signal }), { code: "connector_cancelled" });
|
|
161
|
+
await started;
|
|
162
|
+
controller.abort();
|
|
163
|
+
await pending;
|
|
164
|
+
assert.equal(requests.filter(({ message }) => message?.method === "tools/call").length, 4);
|
|
165
|
+
assert.equal(requests.at(-1).init.method, "DELETE");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("Atlassian declined consent and malformed discovery do not persist a connection", async (t) => {
|
|
169
|
+
const { service, complete, requests, state } = await fixture(t);
|
|
170
|
+
await assert.rejects(complete(await service.beginAuthorization(input), "error=access_denied"), { code: "connector_consent_denied" });
|
|
171
|
+
assert.equal(requests.length, 0);
|
|
172
|
+
state.list = { wrong: [] };
|
|
173
|
+
await assert.rejects(complete(await service.beginAuthorization(input)), { code: "connector_provider_failed" });
|
|
174
|
+
assert.equal((await service.status(input)).status, "disconnected");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("Atlassian preserves the provider's reduced grant and permits empty discovery without claiming product access", async (t) => {
|
|
178
|
+
const { service, complete, state, requests } = await fixture(t);
|
|
179
|
+
state.scopes = ["read:me"];
|
|
180
|
+
state.list = { tools: [] };
|
|
181
|
+
const connected = await complete(await service.beginAuthorization(input));
|
|
182
|
+
assert.deepEqual(connected.grantedScopes, ["read:me"]);
|
|
183
|
+
assert.deepEqual(await service.invoke({ ...input, operation: "tools.list" }), { tools: [] });
|
|
184
|
+
assert(!requests.some(({ message }) => message?.method === "tools/call"));
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("Atlassian sanitizes HTTP/refresh failures, persists reconnect status and never follows injected auth metadata", async (t) => {
|
|
188
|
+
const { service, complete, requests, state } = await fixture(t);
|
|
189
|
+
for (const [status, code] of [[401, "connector_reconnect_required"], [403, "connector_permission_denied"], [429, "connector_rate_limited"], [500, "connector_provider_failed"]]) {
|
|
190
|
+
state.status = status;
|
|
191
|
+
await assert.rejects(complete(await service.beginAuthorization(input)), (error) => {
|
|
192
|
+
assert.equal(error.code, code);
|
|
193
|
+
assert(!error.message.includes("fixture-client-secret"));
|
|
194
|
+
assert.equal(error.cause, undefined);
|
|
195
|
+
return true;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
assert(requests.every(({ url }) => url === endpoint || url === tokenEndpoint));
|
|
199
|
+
state.status = 200;
|
|
200
|
+
await complete(await service.beginAuthorization(input));
|
|
201
|
+
state.time += 61_000;
|
|
202
|
+
state.tokenError = "invalid_grant";
|
|
203
|
+
await assert.rejects(service.invoke({ ...input, operation: "tools.list" }), { code: "connector_reconnect_required" });
|
|
204
|
+
assert.equal((await service.status(input)).status, "reconnect-required");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("Atlassian explicit registration uses its v2 issuer's DCR endpoint and preserves requested product permissions", async () => {
|
|
208
|
+
const requests = [];
|
|
209
|
+
const result = await registerAtlassianClient({ clientName: "My assistant", callbackUrl: callback, scopes }, {
|
|
210
|
+
fetchImpl: async (url, init) => {
|
|
211
|
+
requests.push({ url: String(url), init });
|
|
212
|
+
return Response.json({ ...JSON.parse(init.body), client_id: "created-client", client_secret: "created-secret", client_secret_expires_at: 0 });
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
assert.deepEqual(result, { clientId: "created-client", clientSecret: "created-secret", clientSecretExpiresAt: 0 });
|
|
216
|
+
assert.equal(requests.length, 1);
|
|
217
|
+
assert.equal(requests[0].url, registrationEndpoint);
|
|
218
|
+
assert.equal(requests[0].init.redirect, "error");
|
|
219
|
+
assert.equal(requests[0].init.credentials, "omit");
|
|
220
|
+
assert.deepEqual(JSON.parse(requests[0].init.body), { client_name: "My assistant", redirect_uris: [callback], token_endpoint_auth_method: "client_secret_post",
|
|
221
|
+
grant_types: ["authorization_code", "refresh_token"], response_types: ["code"], scope: scopes.join(" ") });
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("Atlassian registration rejects invalid inputs and ambiguous responses without automatic replay", async () => {
|
|
225
|
+
const valid = { clientName: "CLI client", callbackUrl: callback, scopes };
|
|
226
|
+
let requests = 0;
|
|
227
|
+
const options = { fetchImpl: async () => { requests++; throw new Error("secret-provider-response"); } };
|
|
228
|
+
for (const fields of [{ callbackUrl: "http://remote.example/callback" }, { callbackUrl: "https://user:secret@example.test/callback" },
|
|
229
|
+
{ callbackUrl: "https://example.test/callback?other=1" }, { scopes: [] }, { scopes: ["admin"] }, { scopes: ["read:me", "read:me"] }, { clientName: "" }]) {
|
|
230
|
+
await assert.rejects(registerAtlassianClient({ ...valid, ...fields }, options));
|
|
231
|
+
assert.equal(requests, 0, `Unexpected registration request for ${JSON.stringify(fields)}`);
|
|
232
|
+
}
|
|
233
|
+
assert.equal(requests, 0);
|
|
234
|
+
await assert.rejects(registerAtlassianClient(valid, options), (error) => {
|
|
235
|
+
assert.equal(error.code, "connector_registration_failed");
|
|
236
|
+
assert.equal(error.cause, undefined);
|
|
237
|
+
assert(!error.message.includes("secret-provider-response"));
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
240
|
+
assert.equal(requests, 1);
|
|
241
|
+
for (const changes of [{ client_secret: undefined }, { token_endpoint_auth_method: "none" }, { redirect_uris: ["https://unexpected.invalid"] }]) {
|
|
242
|
+
await assert.rejects(registerAtlassianClient(valid, { fetchImpl: async (url, init) => Response.json({ ...JSON.parse(init.body),
|
|
243
|
+
client_id: "client", client_secret: "secret", ...changes }) }), { code: "connector_registration_failed" });
|
|
244
|
+
}
|
|
245
|
+
const controller = new AbortController();
|
|
246
|
+
controller.abort();
|
|
247
|
+
await assert.rejects(registerAtlassianClient(valid, { ...options, signal: controller.signal }), { code: "connector_registration_interrupted" });
|
|
248
|
+
assert.equal(requests, 1);
|
|
249
|
+
});
|