@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,258 @@
|
|
|
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 { getProviderScopes, parseIntegrationConfiguration } from "../../connectors-core/src/shared/configuration.js";
|
|
9
|
+
import { microsoftFabricProvider } from "../src/server/microsoft-fabric.js";
|
|
10
|
+
|
|
11
|
+
const tenantId = "11111111-2222-3333-4444-555555555555";
|
|
12
|
+
const clientId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
|
13
|
+
const endpoint = "https://api.fabric.microsoft.com/v1/workspaces/11111111-2222-3333-4444-555555555555/graphqlapis/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/graphql";
|
|
14
|
+
const delegated = "https://analysis.windows.net/powerbi/api/GraphQLApi.Execute.All";
|
|
15
|
+
const serviceScope = "https://api.fabric.microsoft.com/.default";
|
|
16
|
+
const context = { applicationId: "app-one", subjectId: "owner-one" };
|
|
17
|
+
const args = { context, integrationId: "fabric" };
|
|
18
|
+
const callback = "https://app.example.test/oauth/fabric/callback";
|
|
19
|
+
const schema = { __schema: { types: [{ name: "Query", kind: "OBJECT" }], queryType: { name: "Query" }, mutationType: null } };
|
|
20
|
+
|
|
21
|
+
async function fixture(t, grantType = "authorization_code") {
|
|
22
|
+
const directory = await mkdtemp(path.join(tmpdir(), "fabric-connector-"));
|
|
23
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
24
|
+
const machine = grantType === "client_credentials";
|
|
25
|
+
const configuration = { schemaVersion: 1, registrations: { fabric: { source: "own", grantType, clientId,
|
|
26
|
+
clientSecretRef: "env:FABRIC_SECRET", ...(machine ? {} : { callbackUrlRef: "env:FABRIC_CALLBACK" }) } }, integrations: {
|
|
27
|
+
fabric: { provider: "microsoft-fabric", accountMode: machine ? "shared" : "per-user", settings: { tenantId, graphqlEndpoint: endpoint },
|
|
28
|
+
scopes: machine ? [serviceScope] : [delegated, "offline_access"], authentication: { method: "oauth2", registrationRef: "fabric" } }
|
|
29
|
+
} };
|
|
30
|
+
const state = { time: Date.now(), tokenCount: 0, value: undefined, status: 200, tokenPatch: {}, tokenStatus: 200,
|
|
31
|
+
tokenError: machine ? "invalid_client" : "invalid_grant", hang: false, secret: "private-client-secret" };
|
|
32
|
+
const requests = [];
|
|
33
|
+
const options = { configuration, providers: [{ ...microsoftFabricProvider, requestTimeoutMs: 40 }], authorize: async (owner) => owner,
|
|
34
|
+
now: () => state.time, resolveReference: async (reference) => {
|
|
35
|
+
if (reference === "env:FABRIC_SECRET") return state.secret;
|
|
36
|
+
assert.equal(machine, false); assert.equal(reference, "env:FABRIC_CALLBACK"); return callback;
|
|
37
|
+
},
|
|
38
|
+
store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(7) }, activeKeyId: "current" }) }),
|
|
39
|
+
fetchImpl: async (address, init) => {
|
|
40
|
+
const url = new URL(String(address)); requests.push({ url, init });
|
|
41
|
+
assert.equal(init.method, "POST"); const headers = new Headers(init.headers);
|
|
42
|
+
if (url.origin === "https://login.microsoftonline.com") {
|
|
43
|
+
assert.equal(url.pathname, `/${tenantId}/oauth2/v2.0/token`);
|
|
44
|
+
const body = new URLSearchParams(init.body);
|
|
45
|
+
assert.equal(body.get("client_id"), clientId); assert.equal(body.get("client_secret"), state.secret);
|
|
46
|
+
assert.equal(headers.has("authorization"), false);
|
|
47
|
+
if (machine) {
|
|
48
|
+
assert.equal(body.get("grant_type"), "client_credentials"); assert.equal(body.get("scope"), serviceScope);
|
|
49
|
+
for (const key of ["redirect_uri", "code", "code_verifier", "refresh_token"]) assert.equal(body.has(key), false);
|
|
50
|
+
} else if (body.get("grant_type") === "authorization_code") {
|
|
51
|
+
assert.equal(body.get("redirect_uri"), callback); assert.equal(body.get("code"), "private-code"); assert.ok(body.get("code_verifier"));
|
|
52
|
+
} else {
|
|
53
|
+
assert.equal(body.get("grant_type"), "refresh_token"); assert.equal(body.get("refresh_token"), `private-refresh-${state.tokenCount}`);
|
|
54
|
+
}
|
|
55
|
+
state.tokenCount++;
|
|
56
|
+
return Response.json(state.tokenStatus === 200 ? { access_token: `private-access-${state.tokenCount}`, token_type: "Bearer", expires_in: 120,
|
|
57
|
+
...(machine ? {} : { refresh_token: `private-refresh-${state.tokenCount}`, scope: "GraphQLApi.Execute.All offline_access" }), ...state.tokenPatch }
|
|
58
|
+
: { error: state.tokenError, error_description: "private-provider-error" }, { status: state.tokenStatus });
|
|
59
|
+
}
|
|
60
|
+
assert.equal(url.href, endpoint); assert.equal(init.redirect, "error");
|
|
61
|
+
assert.equal(headers.get("authorization"), `Bearer private-access-${state.tokenCount}`);
|
|
62
|
+
const body = JSON.parse(init.body); assert.equal(typeof body.query, "string");
|
|
63
|
+
if (state.hang) return new Promise((_, reject) => {
|
|
64
|
+
const timer = setTimeout(() => reject(new Error("Missing abort")), 1000);
|
|
65
|
+
const abort = () => { clearTimeout(timer); reject(init.signal.reason); };
|
|
66
|
+
if (init.signal.aborted) abort(); else init.signal.addEventListener("abort", abort, { once: true });
|
|
67
|
+
});
|
|
68
|
+
if (state.status === 204) return new Response(null, { status: 204 });
|
|
69
|
+
if (typeof state.value === "string") return new Response(state.value, { status: state.status });
|
|
70
|
+
const data = body.query.includes("ConnectorFabricCheck") ? { __typename: "Query" }
|
|
71
|
+
: body.query.includes("ConnectorFabricTypes") ? schema : { inventory: { items: [], hasNextPage: false, endCursor: null } };
|
|
72
|
+
return Response.json(state.value === undefined ? { data } : state.value, { status: state.status });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const service = createConnectionService(options);
|
|
76
|
+
const start = async () => {
|
|
77
|
+
const { authorizationUrl } = await service.beginAuthorization(args); const url = new URL(authorizationUrl);
|
|
78
|
+
const returned = new URL(callback); returned.searchParams.set("state", url.searchParams.get("state")); returned.searchParams.set("code", "private-code");
|
|
79
|
+
return { url, callbackUrl: returned.href };
|
|
80
|
+
};
|
|
81
|
+
const connect = async () => machine ? service.connectClientCredentials(args)
|
|
82
|
+
: service.completeAuthorization({ ...args, callbackUrl: (await start()).callbackUrl });
|
|
83
|
+
return { directory, service, state, options, requests, start, connect };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
test("Fabric user consent pins the tenant, sends PKCE and maps the actual delegated grant", async (t) => {
|
|
87
|
+
const f = await fixture(t); const start = await f.start();
|
|
88
|
+
assert.equal(start.url.href.split("?")[0], `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/authorize`);
|
|
89
|
+
assert.equal(start.url.searchParams.get("scope"), `${delegated} offline_access`);
|
|
90
|
+
assert.equal(start.url.searchParams.get("response_mode"), "query"); assert.equal(start.url.searchParams.get("code_challenge_method"), "S256");
|
|
91
|
+
assert.equal(start.url.searchParams.has("client_secret"), false);
|
|
92
|
+
const metadata = await f.service.completeAuthorization({ ...args, callbackUrl: start.callbackUrl });
|
|
93
|
+
assert.equal(JSON.stringify(metadata).includes("private"), false);
|
|
94
|
+
assert.deepEqual((await f.service.status(args)).grantedScopes, [delegated, "offline_access"]);
|
|
95
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { query: "query ConnectorFabricCheck { __typename }" });
|
|
96
|
+
for (const file of await readdir(f.directory)) {
|
|
97
|
+
const text = await readFile(path.join(f.directory, file), "utf8");
|
|
98
|
+
for (const secret of ["private-code", "private-client-secret", "private-access-1", "private-refresh-1"]) assert.equal(text.includes(secret), false);
|
|
99
|
+
}
|
|
100
|
+
const restarted = createConnectionService(f.options); assert.equal((await restarted.status(args)).status, "connected");
|
|
101
|
+
assert.deepEqual(await restarted.invoke({ ...args, operation: "schema.types" }), { data: schema });
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("Fabric service principals use their own resource scope, no callback, and locked credential renewal", async (t) => {
|
|
105
|
+
const f = await fixture(t, "client_credentials"); await f.connect();
|
|
106
|
+
assert.deepEqual((await f.service.status(args)).grantedScopes, [serviceScope]);
|
|
107
|
+
await assert.rejects(f.service.beginAuthorization(args), { code: "connector_mode_unavailable" });
|
|
108
|
+
f.state.time += 95_000; f.state.secret = "rotated-private-secret";
|
|
109
|
+
const restarted = createConnectionService(f.options);
|
|
110
|
+
await Promise.all([restarted.invoke({ ...args, operation: "connection.check" }), restarted.invoke({ ...args, operation: "schema.types" })]);
|
|
111
|
+
assert.equal(f.state.tokenCount, 2);
|
|
112
|
+
assert.equal(JSON.stringify(await restarted.status(args)).includes("private"), false);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("Fabric forwards one explicit document with JSON variables and preserves empty, nullable and paged data", async (t) => {
|
|
116
|
+
const f = await fixture(t); await f.connect(); const before = f.requests.length;
|
|
117
|
+
const input = { query: "query Stock($filter: InventoryFilterInput, $after: String) { inventory(filter: $filter, after: $after, first: 10) { items { id } hasNextPage endCursor } }",
|
|
118
|
+
operationName: "Stock", variables: { filter: { or: [{ id: { eq: 4 } }, { name: { eq: "Stock & supplies" } }] }, after: null } };
|
|
119
|
+
const result = await f.service.invoke({ ...args, operation: "graphql.execute", input });
|
|
120
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), input); assert.equal(f.requests.length, before + 1);
|
|
121
|
+
assert.deepEqual(result.data.inventory.items, []);
|
|
122
|
+
for (const data of [{ inventory: null }, { inventory: { items: [{ id: 4 }], hasNextPage: true, endCursor: "page+two=" } }]) {
|
|
123
|
+
f.state.value = { data }; assert.deepEqual(await f.service.invoke({ ...args, operation: "graphql.execute", input }), { data });
|
|
124
|
+
}
|
|
125
|
+
assert.equal(f.requests.length, before + 3, "No automatic page traversal.");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("Fabric execution is explicitly mutation-capable and application policy can deny the exact document", async (t) => {
|
|
129
|
+
const f = await fixture(t); await f.connect();
|
|
130
|
+
const input = { query: "mutation UpdateStock($id: ID!) { updateStock(id: $id) { id } }", variables: { id: "4" } };
|
|
131
|
+
f.state.value = { data: { updateStock: { id: "4" } } };
|
|
132
|
+
await f.service.invoke({ ...args, operation: "graphql.execute", input });
|
|
133
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), input);
|
|
134
|
+
const before = f.requests.length;
|
|
135
|
+
const denied = createConnectionService({ ...f.options, authorize: async (owner, operation) => {
|
|
136
|
+
if (operation.operation === "graphql.execute") { assert.deepEqual(operation.input, input); return null; }
|
|
137
|
+
return owner;
|
|
138
|
+
} });
|
|
139
|
+
await assert.rejects(denied.invoke({ ...args, operation: "graphql.execute", input }), { code: "connector_access_denied" });
|
|
140
|
+
assert.equal(f.requests.length, before);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("Fabric rejects unsupported inputs and non-JSON variables before transport", async (t) => {
|
|
144
|
+
const f = await fixture(t); await f.connect(); const before = f.requests.length;
|
|
145
|
+
const query = "query Stock { inventory { items { id } } }";
|
|
146
|
+
for (const input of [{}, { query: " " }, { query: "x".repeat(65_537) }, { query, variables: [] },
|
|
147
|
+
{ query, variables: { big: "x".repeat(65_537) } }, { query, variables: { count: NaN } },
|
|
148
|
+
{ query, variables: { when: new Date() } }, { query, operationName: "two names" }, { query, operationName: "" },
|
|
149
|
+
{ query, endpoint: "https://other.test" }, { query, extensions: {} }]) {
|
|
150
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "graphql.execute", input }), { code: "connector_input_invalid" });
|
|
151
|
+
}
|
|
152
|
+
for (const operation of ["connection.check", "schema.types"]) await assert.rejects(f.service.invoke({ ...args, operation, input: { query } }), { code: "connector_input_invalid" });
|
|
153
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "graphql.subscribe" }), { code: "connector_operation_unknown" });
|
|
154
|
+
assert.equal(f.requests.length, before);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("Fabric never treats GraphQL errors or malformed payloads as success and never replays mutations", async (t) => {
|
|
158
|
+
const f = await fixture(t); await f.connect();
|
|
159
|
+
const input = { query: "mutation Write { updateStock(id: 4) { id } }" };
|
|
160
|
+
for (const value of [null, [], {}, "not-json", { data: null }, { data: [] }, { data: {}, errors: "wrong" },
|
|
161
|
+
{ errors: [{ message: "private-provider-error" }] }, { data: { updateStock: { id: 4 } }, errors: [{ message: "private-provider-error" }] }]) {
|
|
162
|
+
f.state.value = value; const before = f.requests.length;
|
|
163
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "graphql.execute", input }), (error) =>
|
|
164
|
+
["connector_response_invalid", "connector_provider_failed"].includes(error.code) && !error.message.includes("private"));
|
|
165
|
+
assert.equal(f.requests.length, before + 1);
|
|
166
|
+
}
|
|
167
|
+
f.state.value = { data: {} }; await assert.rejects(f.service.invoke({ ...args, operation: "schema.types" }), { code: "connector_response_invalid" });
|
|
168
|
+
f.state.value = { errors: [{ message: "Introspection disabled" }] };
|
|
169
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "schema.types" }), { code: "connector_provider_failed" });
|
|
170
|
+
assert.equal((await f.service.status(args)).status, "connected");
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("Fabric retains renewal before failed calls and requires reconnect after revoked or interactive grants", async (t) => {
|
|
174
|
+
for (const flow of ["authorization_code", "client_credentials"]) {
|
|
175
|
+
const f = await fixture(t, flow); await f.connect(); f.state.time += 95_000; f.state.status = 429;
|
|
176
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "connection.check" }), { code: "connector_rate_limited" });
|
|
177
|
+
f.state.status = 200; const restarted = createConnectionService(f.options);
|
|
178
|
+
await restarted.invoke({ ...args, operation: "connection.check" }); assert.equal(f.state.tokenCount, 2);
|
|
179
|
+
f.state.time += 95_000; f.state.tokenStatus = 400;
|
|
180
|
+
if (flow === "authorization_code") f.state.tokenError = "interaction_required";
|
|
181
|
+
await assert.rejects(restarted.invoke({ ...args, operation: "connection.check" }), { code: "connector_reconnect_required" });
|
|
182
|
+
assert.equal((await restarted.status(args)).status, "reconnect-required");
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("Fabric rejects token grants that cannot authorize verification or have invalid expiry", async (t) => {
|
|
187
|
+
for (const tokenPatch of [{ expires_in: undefined }, { expires_in: 30 }, { expires_in: 2.5 }, { scope: "" }, { scope: "GraphQLApi.Execute.All\noffline_access" }]) {
|
|
188
|
+
const f = await fixture(t); f.state.tokenPatch = tokenPatch;
|
|
189
|
+
await assert.rejects(f.connect(), { code: "connector_response_invalid" }); assert.equal(f.requests.length, 1);
|
|
190
|
+
}
|
|
191
|
+
const f = await fixture(t); f.state.tokenPatch.scope = "offline_access";
|
|
192
|
+
await assert.rejects(f.connect(), { code: "connector_scope_missing" }); assert.equal(f.requests.length, 1);
|
|
193
|
+
assert.equal((await f.service.status(args)).status, "disconnected");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("Fabric binds saved grants and pending consent to tenant, endpoint, client, flow and application owner", async (t) => {
|
|
197
|
+
const f = await fixture(t); await f.connect(); const pending = await f.start();
|
|
198
|
+
for (const change of [(config) => { config.integrations.fabric.settings.tenantId = clientId; },
|
|
199
|
+
(config) => { config.integrations.fabric.settings.graphqlEndpoint = endpoint.replace("graphqlapis/aaaaaaaa", "graphqlapis/bbbbbbbb"); },
|
|
200
|
+
(config) => { config.registrations.fabric.clientId = tenantId; }]) {
|
|
201
|
+
const configuration = structuredClone(f.options.configuration); change(configuration);
|
|
202
|
+
const service = createConnectionService({ ...f.options, configuration });
|
|
203
|
+
assert.equal((await service.status(args)).status, "reconnect-required");
|
|
204
|
+
await assert.rejects(service.invoke({ ...args, operation: "connection.check" }), { code: "connector_reconnect_required" });
|
|
205
|
+
await assert.rejects(service.completeAuthorization({ ...args, callbackUrl: pending.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
206
|
+
}
|
|
207
|
+
for (const owner of [{ ...context, subjectId: "other" }, { ...context, applicationId: "other" }]) {
|
|
208
|
+
await assert.rejects(f.service.invoke({ ...args, context: owner, operation: "connection.check" }), { code: "connector_reconnect_required" });
|
|
209
|
+
}
|
|
210
|
+
const machine = await fixture(t, "client_credentials"); await machine.connect();
|
|
211
|
+
const config = structuredClone(machine.options.configuration); config.registrations.fabric.grantType = "authorization_code";
|
|
212
|
+
config.registrations.fabric.callbackUrlRef = "env:FABRIC_CALLBACK"; config.integrations.fabric.scopes = [delegated];
|
|
213
|
+
const changed = createConnectionService({ ...machine.options, configuration: config, resolveReference: async (ref) => ref.endsWith("CALLBACK") ? callback : "private-client-secret" });
|
|
214
|
+
assert.equal((await changed.status(args)).status, "reconnect-required");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("Fabric cancelled or denied consent keeps existing access and consumes the attempt", async (t) => {
|
|
218
|
+
const f = await fixture(t); await f.connect();
|
|
219
|
+
const pending = await f.start(); await f.service.cancelAuthorization({ ...args, state: pending.url.searchParams.get("state") });
|
|
220
|
+
await assert.rejects(f.service.completeAuthorization({ ...args, callbackUrl: pending.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
221
|
+
const denied = await f.start(); const returned = new URL(denied.callbackUrl); returned.searchParams.delete("code"); returned.searchParams.set("error", "access_denied");
|
|
222
|
+
await assert.rejects(f.service.completeAuthorization({ ...args, callbackUrl: returned.href }), { code: "connector_consent_denied" });
|
|
223
|
+
await assert.rejects(f.service.completeAuthorization({ ...args, callbackUrl: denied.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
224
|
+
assert.equal((await f.service.status(args)).status, "connected"); assert.equal(f.requests.length, 2);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("Fabric aborts hanging requests without replay and local disconnect removes access", async (t) => {
|
|
228
|
+
const f = await fixture(t); await f.connect(); f.state.hang = true;
|
|
229
|
+
const before = f.requests.length; const controller = new AbortController();
|
|
230
|
+
const pending = f.service.invoke({ ...args, operation: "graphql.execute", input: { query: "mutation Write { updateStock(id: 4) { id } }" }, signal: controller.signal });
|
|
231
|
+
setTimeout(() => controller.abort(), 5);
|
|
232
|
+
await assert.rejects(pending, { code: "connector_cancelled" }); assert.equal(f.requests.length, before + 1);
|
|
233
|
+
await assert.rejects(f.service.invoke({ ...args, operation: "connection.check" }), { code: "connector_provider_timeout" });
|
|
234
|
+
assert.equal(f.requests.length, before + 2);
|
|
235
|
+
await f.service.disconnect(args); assert.equal((await f.service.status(args)).status, "disconnected");
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test("Fabric CLI configuration rejects mixed grants and foreign endpoints and validates both guide examples", async (t) => {
|
|
239
|
+
const f = await fixture(t);
|
|
240
|
+
assert.deepEqual(getProviderScopes(microsoftFabricProvider, {}, "client_credentials").map((scope) => scope.value), [serviceScope]);
|
|
241
|
+
const invalid = (change) => {
|
|
242
|
+
const configuration = structuredClone(f.options.configuration); change(configuration);
|
|
243
|
+
assert.throws(() => parseIntegrationConfiguration(JSON.stringify(configuration), { providers: [microsoftFabricProvider] }),
|
|
244
|
+
(error) => error.code === "integration_configuration_invalid" && !error.fieldErrors.configuration);
|
|
245
|
+
};
|
|
246
|
+
for (const tenant of ["common", "organizations", "consumers", "tenant.example.test", "../token"]) invalid((config) => { config.integrations.fabric.settings.tenantId = tenant; });
|
|
247
|
+
for (const url of [endpoint + "?key=private", endpoint + "#fragment", endpoint + "/", endpoint.replace("https:", "http:"),
|
|
248
|
+
endpoint.replace("api.fabric.microsoft.com", "api.fabric.microsoft.com.other.test"), endpoint.replace("/graphql", "/../graphql"),
|
|
249
|
+
endpoint.replace("api.fabric", "user@api.fabric"), endpoint.replace("/v1/", ":444/v1/")]) invalid((config) => { config.integrations.fabric.settings.graphqlEndpoint = url; });
|
|
250
|
+
invalid((config) => { config.integrations.fabric.scopes = [serviceScope]; });
|
|
251
|
+
invalid((config) => { config.registrations.fabric.clientSecretRef = "raw-secret"; });
|
|
252
|
+
invalid((config) => { config.registrations.fabric.clientId = "not-a-guid"; });
|
|
253
|
+
invalid((config) => { config.registrations.fabric.grantType = "client_credentials"; config.integrations.fabric.scopes = [serviceScope]; });
|
|
254
|
+
invalid((config) => { config.registrations.fabric.tokenEndpointAuthMethod = "none"; });
|
|
255
|
+
const guide = await readFile(new URL("../docs/microsoft-fabric.md", import.meta.url), "utf8");
|
|
256
|
+
const blocks = [...guide.matchAll(/```json\n([\s\S]*?)\n```/gu)]; assert.equal(blocks.length, 2);
|
|
257
|
+
for (const block of blocks) assert.deepEqual(parseIntegrationConfiguration(block[1], { providers: [microsoftFabricProvider] }), JSON.parse(block[1]));
|
|
258
|
+
});
|