@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,554 @@
|
|
|
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 path from "node:path";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
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 { microsoftWordProvider } from "../src/server/microsoft-word.js";
|
|
10
|
+
import { microsoftPowerPointProvider } from "../src/server/microsoft-powerpoint.js";
|
|
11
|
+
import { microsoftOutlookProvider } from "../src/server/microsoft-outlook.js";
|
|
12
|
+
import { microsoftOneDriveProvider } from "../src/server/microsoft-onedrive.js";
|
|
13
|
+
import { microsoftExcelProvider } from "../src/server/microsoft-excel.js";
|
|
14
|
+
import { microsoftTeamsProvider } from "../src/server/microsoft-teams.js";
|
|
15
|
+
import { microsoftOneNoteProvider } from "../src/server/microsoft-onenote.js";
|
|
16
|
+
import { microsoftSharePointProvider } from "../src/server/microsoft-sharepoint.js";
|
|
17
|
+
|
|
18
|
+
const owner = { applicationId: "app-one", subjectId: "user-one" };
|
|
19
|
+
const callback = "https://application.example/connectors/callback";
|
|
20
|
+
const cases = [
|
|
21
|
+
{ provider: microsoftOutlookProvider, scope: "Mail.Read", authority: "common", input: {}, pathname: "/v1.0/me/mailFolders", item: { id: "inbox", displayName: "Inbox", unreadItemCount: 2 } },
|
|
22
|
+
{ provider: microsoftOneDriveProvider, scope: "Files.Read", authority: "common", input: {}, pathname: "/v1.0/me/drive/root/children", item: { id: "file-id", name: "Budget.xlsx", file: { mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" } } },
|
|
23
|
+
{ provider: microsoftExcelProvider, scope: "Files.Read", authority: "common", input: {}, pathname: "/v1.0/me/drive/root/children", item: { id: "drive!item-1", name: "Budget.xlsx", file: {} } },
|
|
24
|
+
{ provider: microsoftTeamsProvider, scope: "Team.ReadBasic.All", scopes: ["Team.ReadBasic.All", "Channel.ReadBasic.All", "User.Read"], authority: "organizations", input: {}, pathname: "/v1.0/me/joinedTeams", item: { id: "team-id", displayName: "Engineering" } },
|
|
25
|
+
{ provider: microsoftOneNoteProvider, scope: "Notes.Read", authority: "common", input: {}, pathname: "/v1.0/me/onenote/notebooks", item: { id: "notebook-id", displayName: "Notes" } },
|
|
26
|
+
{ provider: microsoftSharePointProvider, scope: "Sites.Read.All", scopes: ["Sites.Read.All", "User.Read"], authority: "organizations", input: { search: "Team & projects" }, pathname: "/v1.0/sites", item: { id: "site-id", name: "Team", webUrl: "https://example.sharepoint.com/sites/team" } },
|
|
27
|
+
{ provider: microsoftWordProvider, scope: "Files.Read", authority: "common", input: {}, pathname: "/v1.0/me/drive/root/children", item: { id: "document-id", name: "Notes.DOCX", file: {} } },
|
|
28
|
+
{ provider: microsoftPowerPointProvider, scope: "Files.Read", authority: "common", input: {}, pathname: "/v1.0/me/drive/root/children", item: { id: "presentation-id", name: "Review.PPTX", file: {} } }
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
async function fixture(t, entry) {
|
|
32
|
+
const directory = await mkdtemp(path.join(tmpdir(), "microsoft-connector-"));
|
|
33
|
+
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
34
|
+
const requests = [];
|
|
35
|
+
const state = { time: Date.now(), scope: (entry.scopes || [entry.scope]).join(" "), status: 200, tokenStatus: 200, tokenCount: 0, response: { value: [entry.item] } };
|
|
36
|
+
const options = {
|
|
37
|
+
configuration: {
|
|
38
|
+
schemaVersion: 1,
|
|
39
|
+
integrations: { service: { provider: entry.provider.id, accountMode: "per-user", ...(entry.tenantId ? { settings: { tenantId: entry.tenantId } } : {}), scopes: [...(entry.scopes || [entry.scope]), "offline_access"], authentication: { method: "oauth2", registrationRef: "microsoft" } } },
|
|
40
|
+
registrations: { microsoft: { source: "own", clientId: "test-client-id", clientSecretRef: "env:MS_SECRET", callbackUrlRef: "env:MS_CALLBACK" } }
|
|
41
|
+
},
|
|
42
|
+
providers: [entry.provider], authorize: async (context) => context, now: () => state.time,
|
|
43
|
+
resolveReference: async (ref) => ref === "env:MS_CALLBACK" ? callback : "test-client-secret",
|
|
44
|
+
store: createFileConnectionStore({ directory, protection: createCredentialProtection({ keys: { current: new Uint8Array(32).fill(5) }, activeKeyId: "current" }) }),
|
|
45
|
+
fetchImpl: async (address, init) => {
|
|
46
|
+
const url = new URL(String(address));
|
|
47
|
+
requests.push({ url, init });
|
|
48
|
+
if (url.hostname === "login.microsoftonline.com") {
|
|
49
|
+
assert.equal(url.href, `https://login.microsoftonline.com/${entry.authority}/oauth2/v2.0/token`);
|
|
50
|
+
if (state.tokenStatus !== 200) return Response.json({ error: "invalid_grant", error_description: "test-client-secret" }, { status: state.tokenStatus });
|
|
51
|
+
state.tokenCount += 1;
|
|
52
|
+
return Response.json({ access_token: `test-access-${state.tokenCount}`, refresh_token: `test-refresh-${state.tokenCount}`, token_type: "Bearer", expires_in: 60, scope: state.scope });
|
|
53
|
+
}
|
|
54
|
+
assert.equal(url.origin, "https://graph.microsoft.com");
|
|
55
|
+
return [202, 204].includes(state.status) ? new Response(null, { status: state.status }) : typeof state.response === "string" ? new Response(state.response, { status: state.status, headers: { "Content-Type": "text/html" } }) : Response.json(state.response, { status: state.status });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const service = createConnectionService(options);
|
|
59
|
+
const input = { context: owner, integrationId: "service" };
|
|
60
|
+
async function start() {
|
|
61
|
+
const result = await service.beginAuthorization({ ...input, verificationInput: entry.input });
|
|
62
|
+
const url = new URL(result.authorizationUrl);
|
|
63
|
+
return { url, callbackUrl: `${callback}?code=authorization-code&state=${url.searchParams.get("state")}` };
|
|
64
|
+
}
|
|
65
|
+
return { service, options, input, start, requests, state, directory };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const entry of cases) {
|
|
69
|
+
test(`${entry.provider.id}: delegates the correct permission and account audience, verifies access and persists privately`, async (t) => {
|
|
70
|
+
assert.deepEqual(entry.provider.verificationFields.filter((field) => field.required).map((field) => field.name), Object.keys(entry.input));
|
|
71
|
+
const { service, options, input, start, requests, directory } = await fixture(t, entry);
|
|
72
|
+
const { url, callbackUrl } = await start();
|
|
73
|
+
assert.equal(url.origin, "https://login.microsoftonline.com");
|
|
74
|
+
assert.equal(url.pathname, `/${entry.authority}/oauth2/v2.0/authorize`);
|
|
75
|
+
assert.equal(url.searchParams.get("scope"), `${(entry.scopes || [entry.scope]).join(" ")} offline_access`);
|
|
76
|
+
assert.equal(url.searchParams.get("code_challenge_method"), "S256");
|
|
77
|
+
assert.equal(url.searchParams.get("response_mode"), "query");
|
|
78
|
+
assert.equal(url.searchParams.has("client_secret"), false);
|
|
79
|
+
const result = await service.completeAuthorization({ ...input, callbackUrl });
|
|
80
|
+
assert.equal(result.status, "connected");
|
|
81
|
+
assert.deepEqual(result.grantedScopes, entry.scopes || [entry.scope]);
|
|
82
|
+
const grant = new URLSearchParams(requests[0].init.body);
|
|
83
|
+
assert.equal(grant.get("grant_type"), "authorization_code");
|
|
84
|
+
assert.equal(grant.get("client_id"), "test-client-id");
|
|
85
|
+
assert.equal(grant.get("client_secret"), "test-client-secret");
|
|
86
|
+
assert.ok(grant.get("code_verifier"));
|
|
87
|
+
assert.equal(requests[1].url.pathname, entry.pathname);
|
|
88
|
+
assert.equal(requests[1].init.method, "GET");
|
|
89
|
+
assert.equal(requests[1].init.redirect, "error");
|
|
90
|
+
assert.equal(new Headers(requests[1].init.headers).get("authorization"), "Bearer test-access-1");
|
|
91
|
+
for (const filename of await readdir(directory)) {
|
|
92
|
+
const text = await readFile(path.join(directory, filename), "utf8");
|
|
93
|
+
for (const secret of ["test-client-secret", "test-access-1", "test-refresh-1"]) assert.equal(text.includes(secret), false);
|
|
94
|
+
}
|
|
95
|
+
const restarted = createConnectionService(options);
|
|
96
|
+
assert.equal((await restarted.status(input)).status, "connected");
|
|
97
|
+
const invocation = { ...input, operation: entry.provider.checkOperation, input: entry.input };
|
|
98
|
+
assert.deepEqual(await restarted.invoke(invocation), { value: [entry.item] });
|
|
99
|
+
for (const context of [{ ...owner, applicationId: "app-two" }, { ...owner, subjectId: "user-two" }]) {
|
|
100
|
+
await assert.rejects(restarted.invoke({ ...invocation, context }), { code: "connector_reconnect_required" });
|
|
101
|
+
}
|
|
102
|
+
await restarted.disconnect(input);
|
|
103
|
+
await assert.rejects(restarted.invoke(invocation), { code: "connector_reconnect_required" });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test(`${entry.provider.id}: cancellation, missing consent and malformed responses never create a usable connection`, async (t) => {
|
|
107
|
+
const { service, input, start, requests, state } = await fixture(t, entry);
|
|
108
|
+
const cancelled = await start();
|
|
109
|
+
await service.cancelAuthorization({ ...input, state: cancelled.url.searchParams.get("state") });
|
|
110
|
+
await assert.rejects(service.completeAuthorization({ ...input, callbackUrl: cancelled.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
111
|
+
assert.equal(requests.length, 0);
|
|
112
|
+
state.scope = "offline_access";
|
|
113
|
+
const missing = await start();
|
|
114
|
+
await assert.rejects(service.completeAuthorization({ ...input, callbackUrl: missing.callbackUrl }), { code: "connector_scope_missing" });
|
|
115
|
+
assert.equal(requests.length, 1);
|
|
116
|
+
await assert.rejects(service.completeAuthorization({ ...input, callbackUrl: missing.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
117
|
+
state.scope = entry.scope;
|
|
118
|
+
state.response = { error: { message: "test-client-secret" } };
|
|
119
|
+
const malformed = await start();
|
|
120
|
+
await assert.rejects(service.completeAuthorization({ ...input, callbackUrl: malformed.callbackUrl }), { code: "connector_response_invalid" });
|
|
121
|
+
assert.equal((await service.status(input)).status, "disconnected");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test(`${entry.provider.id}: refresh rotation survives restart and permission/rate failures do not expose credentials`, async (t) => {
|
|
125
|
+
const { service, options, input, start, requests, state } = await fixture(t, entry);
|
|
126
|
+
await service.completeAuthorization({ ...input, callbackUrl: (await start()).callbackUrl });
|
|
127
|
+
const invocation = { ...input, operation: entry.provider.checkOperation, input: entry.input };
|
|
128
|
+
state.time += 40_000;
|
|
129
|
+
await service.invoke(invocation);
|
|
130
|
+
assert.equal(new URLSearchParams(requests[2].init.body).get("refresh_token"), "test-refresh-1");
|
|
131
|
+
assert.equal(new Headers(requests[3].init.headers).get("authorization"), "Bearer test-access-2");
|
|
132
|
+
const restarted = createConnectionService(options);
|
|
133
|
+
state.time += 40_000;
|
|
134
|
+
await restarted.invoke(invocation);
|
|
135
|
+
assert.equal(new URLSearchParams(requests[4].init.body).get("refresh_token"), "test-refresh-2");
|
|
136
|
+
const before = requests.length;
|
|
137
|
+
await assert.rejects(restarted.invoke({ ...invocation, input: { ...entry.input, arbitrary: true } }), { code: "connector_input_invalid" });
|
|
138
|
+
assert.equal(requests.length, before);
|
|
139
|
+
for (const [status, code] of [[403, "connector_permission_denied"], [429, "connector_rate_limited"], [401, "connector_reconnect_required"]]) {
|
|
140
|
+
state.status = status;
|
|
141
|
+
state.response = { error: { message: "test-client-secret" } };
|
|
142
|
+
await assert.rejects(restarted.invoke(invocation), (error) => {
|
|
143
|
+
assert.equal(error.code, code);
|
|
144
|
+
assert.equal(JSON.stringify(error).includes("test-client-secret"), false);
|
|
145
|
+
return true;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
assert.equal((await restarted.status(input)).status, "reconnect-required");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test(`${entry.provider.id}: paging keeps the opaque link and blocks another origin, user or resource`, async (t) => {
|
|
152
|
+
const { service, input, start, requests, state } = await fixture(t, entry);
|
|
153
|
+
const nextLink = `https://graph.microsoft.com${entry.pathname}?$skiptoken=opaque%2Btoken%3D&$top=2`;
|
|
154
|
+
state.response = { value: [entry.item], "@odata.nextLink": nextLink };
|
|
155
|
+
await service.completeAuthorization({ ...input, callbackUrl: (await start()).callbackUrl });
|
|
156
|
+
const invocation = { ...input, operation: entry.provider.checkOperation, input: entry.input };
|
|
157
|
+
assert.equal((await service.invoke(invocation))["@odata.nextLink"], nextLink);
|
|
158
|
+
state.response = { value: [] };
|
|
159
|
+
assert.deepEqual(await service.invoke({ ...invocation, input: { ...entry.input, nextLink } }), { value: [] });
|
|
160
|
+
assert.equal(requests.at(-1).url.href, nextLink);
|
|
161
|
+
const before = requests.length;
|
|
162
|
+
for (const malicious of [
|
|
163
|
+
"https://attacker.example/steal", "http://graph.microsoft.com/v1.0/me",
|
|
164
|
+
"https://graph.microsoft.com/v1.0/users/other/mailFolders", "https://graph.microsoft.com/v1.0/me/messages",
|
|
165
|
+
`https://user@graph.microsoft.com${entry.pathname}`, `${nextLink}#fragment`, "not a URL"
|
|
166
|
+
]) {
|
|
167
|
+
await assert.rejects(service.invoke({ ...invocation, input: { ...entry.input, nextLink: malicious } }), { code: "connector_input_invalid" });
|
|
168
|
+
}
|
|
169
|
+
assert.equal(requests.length, before);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
test("resource verification requires site search; worksheet operations validate workbook IDs", async (t) => {
|
|
174
|
+
for (const entry of [cases[5]]) {
|
|
175
|
+
const { service, input, requests } = await fixture(t, entry);
|
|
176
|
+
await assert.rejects(service.beginAuthorization(input), (error) => Boolean(error.fieldErrors));
|
|
177
|
+
assert.equal(requests.length, 0);
|
|
178
|
+
}
|
|
179
|
+
for (const itemId of ["../other", "a/b", "https://example.com/workbook.xlsx", "..", "file?search=oops"]) {
|
|
180
|
+
assert.throws(() => microsoftExcelProvider.operations["worksheets.list"].request({ itemId }), (error) => Boolean(error.fieldErrors));
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("Microsoft fragments use bounded page sizes, basic mail fields and Teams' supported request shape", () => {
|
|
185
|
+
const inbox = new URL(microsoftOutlookProvider.operations["inbox.list"].request({ pageSize: 10 }).url);
|
|
186
|
+
assert.equal(inbox.pathname, "/v1.0/me/mailFolders/inbox/messages");
|
|
187
|
+
assert.equal(inbox.searchParams.get("$top"), "10");
|
|
188
|
+
assert.equal(inbox.searchParams.get("$select"), "id,subject,from,receivedDateTime,isRead");
|
|
189
|
+
assert.equal(new URL(microsoftTeamsProvider.operations["teams.list"].request({}).url).search, "");
|
|
190
|
+
assert.throws(() => microsoftTeamsProvider.operations["teams.list"].request({ pageSize: 10 }), (error) => Boolean(error.fieldErrors));
|
|
191
|
+
assert.equal(new URL(microsoftSharePointProvider.operations["sites.search"].request({ search: "A & B" }).url).searchParams.get("search"), "A & B");
|
|
192
|
+
for (const provider of [microsoftOutlookProvider, microsoftOneDriveProvider]) {
|
|
193
|
+
assert.equal(new URL(provider.operations[provider.checkOperation].request({}).url).searchParams.get("$top"), "25");
|
|
194
|
+
for (const pageSize of [0, 101]) assert.throws(() => provider.operations[provider.checkOperation].request({ pageSize }), (error) => Boolean(error.fieldErrors));
|
|
195
|
+
}
|
|
196
|
+
assert.equal(new URL(microsoftOutlookProvider.operations["folders.list"].request({}).url).searchParams.get("includeHiddenFolders"), "false");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const directoryId = "11111111-2222-3333-4444-555555555555";
|
|
200
|
+
|
|
201
|
+
test("Microsoft tenant configuration validates audiences before constructing any provider URL", async (t) => {
|
|
202
|
+
for (const entry of cases) {
|
|
203
|
+
const { options, requests } = await fixture(t, entry);
|
|
204
|
+
const parse = (tenantId) => {
|
|
205
|
+
const config = structuredClone(options.configuration);
|
|
206
|
+
if (tenantId !== undefined) config.integrations.service.settings = { tenantId };
|
|
207
|
+
return parseIntegrationConfiguration(JSON.stringify(config), { providers: [entry.provider] }).integrations.service;
|
|
208
|
+
};
|
|
209
|
+
assert.equal(parse().settings.tenantId, entry.authority);
|
|
210
|
+
const allowed = entry.authority === "organizations" ? ["organizations", directoryId] : ["common", "organizations", "consumers", directoryId];
|
|
211
|
+
for (const tenantId of allowed) assert.equal(parse(tenantId).settings.tenantId, tenantId);
|
|
212
|
+
const invalid = ["", "../common", "https://attacker.example", "directory.example.com", "common?x=1", "organizations/other", "bad-guid"];
|
|
213
|
+
if (entry.authority === "organizations") invalid.push("common", "consumers");
|
|
214
|
+
for (const tenantId of invalid) assert.throws(() => parse(tenantId));
|
|
215
|
+
assert.equal(requests.length, 0);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
for (const [base, tenantId] of [[cases[6], directoryId], [cases[7], "consumers"]]) {
|
|
220
|
+
test(`${base.provider.id}: selected tenant owns both authorization and refresh endpoints`, async (t) => {
|
|
221
|
+
const entry = { ...base, tenantId, authority: tenantId };
|
|
222
|
+
const { service, options, input, start, requests, state } = await fixture(t, entry);
|
|
223
|
+
const begun = await start();
|
|
224
|
+
assert.equal(begun.url.pathname, `/${tenantId}/oauth2/v2.0/authorize`);
|
|
225
|
+
await service.completeAuthorization({ ...input, callbackUrl: begun.callbackUrl });
|
|
226
|
+
state.time += 40_000;
|
|
227
|
+
await createConnectionService(options).invoke({ ...input, operation: "items.list" });
|
|
228
|
+
const tokenRequests = requests.filter(({ url }) => url.hostname === "login.microsoftonline.com");
|
|
229
|
+
assert.equal(tokenRequests.length, 2);
|
|
230
|
+
assert.equal(new URLSearchParams(tokenRequests[1].init.body).get("refresh_token"), "test-refresh-1");
|
|
231
|
+
assert(tokenRequests.every(({ url }) => url.pathname === `/${tenantId}/oauth2/v2.0/token`));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
test("Microsoft tenant changes invalidate pending consent and stored grants before network access", async (t) => {
|
|
236
|
+
for (const entry of cases) {
|
|
237
|
+
const { service, options, input, start, requests } = await fixture(t, entry);
|
|
238
|
+
await service.completeAuthorization({ ...input, callbackUrl: (await start()).callbackUrl });
|
|
239
|
+
const pending = await start();
|
|
240
|
+
const configuration = structuredClone(options.configuration);
|
|
241
|
+
configuration.integrations.service.settings = { tenantId: directoryId };
|
|
242
|
+
const changed = createConnectionService({ ...options, configuration });
|
|
243
|
+
const before = requests.length;
|
|
244
|
+
assert.equal((await changed.status(input)).status, "reconnect-required");
|
|
245
|
+
await assert.rejects(changed.invoke({ ...input, operation: entry.provider.checkOperation, input: entry.input }), { code: "connector_reconnect_required" });
|
|
246
|
+
await assert.rejects(changed.completeAuthorization({ ...input, callbackUrl: pending.callbackUrl }), { code: "connector_attempt_invalid" });
|
|
247
|
+
assert.equal(requests.length, before);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
for (const entry of cases.slice(6)) {
|
|
252
|
+
test(`${entry.provider.id}: filters file pages, preserves empty-page cursors and browses folders and metadata`, async (t) => {
|
|
253
|
+
const { service, input, start, requests, state } = await fixture(t, entry);
|
|
254
|
+
const folder = { id: "folder-id", name: "Quarterly reports", folder: { childCount: 2 } };
|
|
255
|
+
const unrelated = { id: "image-id", name: "Photo.jpg", file: {} };
|
|
256
|
+
const nextLink = `https://graph.microsoft.com${entry.pathname}?$skiptoken=next%2Bpage`;
|
|
257
|
+
state.response = { value: [unrelated], "@odata.nextLink": nextLink };
|
|
258
|
+
await service.completeAuthorization({ ...input, callbackUrl: (await start()).callbackUrl });
|
|
259
|
+
const list = { ...input, operation: "items.list" };
|
|
260
|
+
assert.deepEqual(await service.invoke(list), { value: [], "@odata.nextLink": nextLink });
|
|
261
|
+
state.response = { value: [entry.item, folder, unrelated] };
|
|
262
|
+
assert.deepEqual(await service.invoke({ ...list, input: { nextLink } }), { value: [entry.item, folder] });
|
|
263
|
+
assert.equal(requests.at(-1).url.href, nextLink);
|
|
264
|
+
await service.invoke({ ...list, input: { folderId: folder.id, pageSize: 5 } });
|
|
265
|
+
assert.equal(requests.at(-1).url.pathname, "/v1.0/me/drive/items/folder-id/children");
|
|
266
|
+
assert.equal(requests.at(-1).url.searchParams.get("$top"), "5");
|
|
267
|
+
const before = requests.length;
|
|
268
|
+
for (const bad of [{ folderId: folder.id, nextLink }, { pageSize: 0 }, { pageSize: 101 }, { folderId: "../other" }]) {
|
|
269
|
+
await assert.rejects(service.invoke({ ...list, input: bad }), { code: "connector_input_invalid" });
|
|
270
|
+
}
|
|
271
|
+
for (const itemId of [undefined, "../other", "file?x=1", "https://example.com/file.docx"]) {
|
|
272
|
+
await assert.rejects(service.invoke({ ...input, operation: "items.get", input: { itemId } }), { code: "connector_input_invalid" });
|
|
273
|
+
}
|
|
274
|
+
assert.equal(requests.length, before);
|
|
275
|
+
state.response = entry.item;
|
|
276
|
+
assert.deepEqual(await service.invoke({ ...input, operation: "items.get", input: { itemId: entry.item.id } }), entry.item);
|
|
277
|
+
assert.equal(requests.at(-1).url.pathname, `/v1.0/me/drive/items/${entry.item.id}`);
|
|
278
|
+
assert.equal(requests.at(-1).url.searchParams.get("$select"), "id,name,size,webUrl,file,folder,parentReference,lastModifiedDateTime,eTag");
|
|
279
|
+
assert.equal(requests.at(-1).init.method, "GET");
|
|
280
|
+
for (const unsupported of [unrelated, folder]) {
|
|
281
|
+
state.response = unsupported;
|
|
282
|
+
await assert.rejects(service.invoke({ ...input, operation: "items.get", input: { itemId: unsupported.id } }), { code: "connector_document_type_invalid" });
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test(`${entry.provider.id}: rejects malformed metadata and file facets without leaking provider fields`, async (t) => {
|
|
287
|
+
const { service, input, start, state } = await fixture(t, entry);
|
|
288
|
+
await service.completeAuthorization({ ...input, callbackUrl: (await start()).callbackUrl });
|
|
289
|
+
for (const malformed of [null, { id: "file" }, { ...entry.item, name: "" }, { ...entry.item, file: true }, { ...entry.item, folder: [] }]) {
|
|
290
|
+
for (const operation of ["items.list", "items.get"]) {
|
|
291
|
+
state.response = operation === "items.list" ? { value: [malformed] } : malformed;
|
|
292
|
+
await assert.rejects(service.invoke({ ...input, operation, input: operation === "items.list" ? {} : { itemId: entry.item.id } }), { code: "connector_response_invalid" });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
state.response = { value: [entry.item], "@odata.nextLink": 123 };
|
|
296
|
+
await assert.rejects(service.invoke({ ...input, operation: "items.list" }), { code: "connector_response_invalid" });
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
test("microsoft-excel: read-only connection browses folders while worksheets require separate consent", async (t) => {
|
|
302
|
+
const entry = cases[2];
|
|
303
|
+
const read = await fixture(t, entry);
|
|
304
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
305
|
+
await read.service.invoke({ ...read.input, operation: "items.list", input: { folderId: "folder-1", pageSize: 5 } });
|
|
306
|
+
assert.equal(read.requests.at(-1).url.pathname, "/v1.0/me/drive/items/folder-1/children");
|
|
307
|
+
assert.equal(read.requests.at(-1).url.searchParams.get("$top"), "5");
|
|
308
|
+
const before = read.requests.length;
|
|
309
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "worksheets.list", input: { itemId: entry.item.id } }), { code: "connector_scope_missing" });
|
|
310
|
+
assert.equal(read.requests.length, before);
|
|
311
|
+
const workbook = await fixture(t, { ...entry, scopes: ["Files.Read", "Files.ReadWrite"] });
|
|
312
|
+
await workbook.service.completeAuthorization({ ...workbook.input, callbackUrl: (await workbook.start()).callbackUrl });
|
|
313
|
+
workbook.state.response = { value: [{ id: "sheet-1", name: "Sheet1", position: 0 }] };
|
|
314
|
+
const invocation = { ...workbook.input, operation: "worksheets.list", input: { itemId: entry.item.id } };
|
|
315
|
+
assert.deepEqual(await workbook.service.invoke(invocation), workbook.state.response);
|
|
316
|
+
const pathname = "/v1.0/me/drive/items/drive!item-1/workbook/worksheets";
|
|
317
|
+
assert.equal(workbook.requests.at(-1).url.pathname, pathname);
|
|
318
|
+
const nextLink = `https://graph.microsoft.com${pathname}?$skiptoken=next%2Bpage`;
|
|
319
|
+
await workbook.service.invoke({ ...invocation, input: { ...invocation.input, nextLink } });
|
|
320
|
+
assert.equal(workbook.requests.at(-1).url.href, nextLink);
|
|
321
|
+
await assert.rejects(workbook.service.invoke({ ...invocation, input: { itemId: "other-workbook", nextLink } }), { code: "connector_input_invalid" });
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test("microsoft-excel: bounded cell reads, values/formulas and explicit persistent sessions", async (t) => {
|
|
325
|
+
const entry = cases[2];
|
|
326
|
+
const workbook = await fixture(t, { ...entry, scopes: ["Files.Read", "Files.ReadWrite"] });
|
|
327
|
+
await workbook.service.completeAuthorization({ ...workbook.input, callbackUrl: (await workbook.start()).callbackUrl });
|
|
328
|
+
const invoke = (operation, input) => workbook.service.invoke({ ...workbook.input, operation, input });
|
|
329
|
+
workbook.state.response = { id: "session-1", persistChanges: true };
|
|
330
|
+
assert.deepEqual(await invoke("sessions.create", { itemId: entry.item.id, persistChanges: true }), workbook.state.response);
|
|
331
|
+
assert.deepEqual(JSON.parse(workbook.requests.at(-1).init.body), { persistChanges: true });
|
|
332
|
+
const range = { itemId: entry.item.id, worksheetId: "Sheet 1", address: "A1:B1", sessionId: "session-1" };
|
|
333
|
+
workbook.state.response = { address: "'Sheet 1'!A1:B1", values: [[2, 3]] };
|
|
334
|
+
assert.deepEqual(await invoke("ranges.get", range), workbook.state.response);
|
|
335
|
+
assert.equal(new Headers(workbook.requests.at(-1).init.headers).get("workbook-session-id"), "session-1");
|
|
336
|
+
assert.match(decodeURIComponent(workbook.requests.at(-1).url.pathname), /worksheets\/Sheet 1\/range\(address='A1:B1'\)$/u);
|
|
337
|
+
await invoke("ranges.update", { ...range, values: [[2, 3]] });
|
|
338
|
+
assert.equal(workbook.requests.at(-1).init.method, "PATCH");
|
|
339
|
+
assert.deepEqual(JSON.parse(workbook.requests.at(-1).init.body), { values: [[2, 3]] });
|
|
340
|
+
await invoke("ranges.update", { ...range, formulas: [["=SUM(C1:C3)", null]] });
|
|
341
|
+
assert.deepEqual(JSON.parse(workbook.requests.at(-1).init.body), { formulas: [["=SUM(C1:C3)", null]] });
|
|
342
|
+
for (const invalid of [{ address: "A:A" }, { address: "A1:XFD1048576" }, { address: "XFE1" }, { address: "B2:A1" },
|
|
343
|
+
{ values: [[1]] }, { formulas: [["=1", "=2"]] }, { sessionId: "bad\r\nheader" }, { worksheetId: "../other" }]) {
|
|
344
|
+
const before = workbook.requests.length;
|
|
345
|
+
await assert.rejects(invoke("ranges.update", { ...range, values: [[2, 3]], ...invalid }), { code: "connector_input_invalid" });
|
|
346
|
+
assert.equal(workbook.requests.length, before);
|
|
347
|
+
}
|
|
348
|
+
workbook.state.status = 429;
|
|
349
|
+
const before = workbook.requests.length;
|
|
350
|
+
await assert.rejects(invoke("ranges.update", { ...range, values: [[2, 3]] }));
|
|
351
|
+
assert.equal(workbook.requests.length, before + 1);
|
|
352
|
+
workbook.state.status = 200;
|
|
353
|
+
workbook.state.response = {};
|
|
354
|
+
await assert.rejects(invoke("ranges.get", range), { code: "connector_response_invalid" });
|
|
355
|
+
workbook.state.status = 204;
|
|
356
|
+
await invoke("sessions.close", { itemId: entry.item.id, sessionId: "session-1" });
|
|
357
|
+
assert.ok(workbook.requests.at(-1).url.pathname.endsWith("/closeSession"));
|
|
358
|
+
const read = await fixture(t, entry);
|
|
359
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
360
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "ranges.update", input: { ...range, values: [[2, 3]] } }), { code: "connector_scope_missing" });
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
test("microsoft-onedrive: nested browsing, private download links and bounded binary uploads", async (t) => {
|
|
365
|
+
const entry = cases[1];
|
|
366
|
+
const f = await fixture(t, { ...entry, scopes: ["Files.Read", "Files.ReadWrite"] });
|
|
367
|
+
await f.service.completeAuthorization({ ...f.input, callbackUrl: (await f.start()).callbackUrl });
|
|
368
|
+
const invoke = (operation, input) => f.service.invoke({ ...f.input, operation, input });
|
|
369
|
+
await invoke("items.list", { folderId: "folder-2" });
|
|
370
|
+
assert.equal(f.requests.at(-1).url.pathname, "/v1.0/me/drive/items/folder-2/children");
|
|
371
|
+
f.state.response = { id: "file-2", name: "Report.txt", file: {}, "@microsoft.graph.downloadUrl": "https://storage.1drv.com/private-short-lived" };
|
|
372
|
+
assert.deepEqual(await invoke("items.get", { itemId: "file-2" }), f.state.response);
|
|
373
|
+
assert.ok(f.requests.at(-1).url.searchParams.get("$select").includes("@microsoft.graph.downloadUrl"));
|
|
374
|
+
const data = Buffer.from([0, 255, 32, 65]);
|
|
375
|
+
await invoke("files.upload", { parentId: "folder-2", name: "Report 1.bin", bodyBase64: data.toString("base64") });
|
|
376
|
+
assert.equal(f.requests.at(-1).init.method, "PUT");
|
|
377
|
+
assert.deepEqual(Buffer.from(f.requests.at(-1).init.body), data);
|
|
378
|
+
assert.equal(f.requests.at(-1).url.searchParams.get("@microsoft.graph.conflictBehavior"), "fail");
|
|
379
|
+
assert.ok(f.requests.at(-1).url.pathname.endsWith(":/Report%201.bin:/content"));
|
|
380
|
+
for (const extra of [{ name: "../other" }, { bodyBase64: "wrong%%%" }, { parentId: "../../other" }, { conflictBehavior: "delete" }]) {
|
|
381
|
+
const before = f.requests.length;
|
|
382
|
+
await assert.rejects(invoke("files.upload", { parentId: "folder-2", name: "report.bin", bodyBase64: data.toString("base64"), ...extra }), { code: "connector_input_invalid" });
|
|
383
|
+
assert.equal(f.requests.length, before);
|
|
384
|
+
}
|
|
385
|
+
f.state.response = { id: "file-2", name: "Report", "@microsoft.graph.downloadUrl": "javascript:alert(1)" };
|
|
386
|
+
await assert.rejects(invoke("items.get", { itemId: "file-2" }), { code: "connector_response_invalid" });
|
|
387
|
+
f.state.status = 409;
|
|
388
|
+
const before = f.requests.length;
|
|
389
|
+
await assert.rejects(invoke("files.upload", { parentId: "folder-2", name: "report.bin", bodyBase64: data.toString("base64") }));
|
|
390
|
+
assert.equal(f.requests.length, before + 1);
|
|
391
|
+
const read = await fixture(t, entry);
|
|
392
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
393
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "files.upload", input: { parentId: "folder-2", name: "report.bin", bodyBase64: "AA==" } }), { code: "connector_scope_missing" });
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
test("microsoft-onenote: traverses pages, reads HTML and creates/appends escaped text", async (t) => {
|
|
398
|
+
const entry = cases[4];
|
|
399
|
+
const f = await fixture(t, { ...entry, scopes: ["Notes.Read", "Notes.Create", "Notes.ReadWrite"] });
|
|
400
|
+
await f.service.completeAuthorization({ ...f.input, callbackUrl: (await f.start()).callbackUrl });
|
|
401
|
+
const invoke = (operation, input) => f.service.invoke({ ...f.input, operation, input });
|
|
402
|
+
f.state.response = { value: [{ id: "section:1", displayName: "Notes" }] };
|
|
403
|
+
await invoke("sections.list", { notebookId: "notebook:1" });
|
|
404
|
+
assert.ok(f.requests.at(-1).url.pathname.endsWith("/notebooks/notebook%3A1/sections"));
|
|
405
|
+
f.state.response = { value: [{ id: "page:1", title: "Note" }] };
|
|
406
|
+
await invoke("pages.list", { sectionId: "section:1", pageSize: 5 });
|
|
407
|
+
assert.equal(f.requests.at(-1).url.searchParams.get("$top"), "5");
|
|
408
|
+
f.state.response = "<html><body><p id='p1'>Existing note</p></body></html>";
|
|
409
|
+
assert.deepEqual(await invoke("pages.content", { pageId: "page:1" }), { html: f.state.response });
|
|
410
|
+
assert.equal(f.requests.at(-1).url.searchParams.get("includeIDs"), "true");
|
|
411
|
+
f.state.response = { id: "new-page" };
|
|
412
|
+
await invoke("pages.create", { sectionId: "section:1", title: "Budget <2026>", text: "A & B <script>" });
|
|
413
|
+
assert.equal(new Headers(f.requests.at(-1).init.headers).get("content-type"), "text/html");
|
|
414
|
+
assert.ok(f.requests.at(-1).init.body.includes("Budget <2026>"));
|
|
415
|
+
assert.ok(f.requests.at(-1).init.body.includes("A & B <script>"));
|
|
416
|
+
f.state.status = 204;
|
|
417
|
+
await invoke("pages.append", { pageId: "page:1", text: "Update <img>" });
|
|
418
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), [{ target: "body", action: "append", content: "<p>Update <img></p>" }]);
|
|
419
|
+
const before = f.requests.length;
|
|
420
|
+
await assert.rejects(invoke("pages.append", { pageId: "../../other", text: "No" }), { code: "connector_input_invalid" });
|
|
421
|
+
assert.equal(f.requests.length, before);
|
|
422
|
+
f.state.status = 200; f.state.response = "x".repeat(1048577);
|
|
423
|
+
await assert.rejects(invoke("pages.content", { pageId: "page:1" }), { code: "connector_response_too_large" });
|
|
424
|
+
f.state.status = 429; f.state.response = {};
|
|
425
|
+
const count = f.requests.length;
|
|
426
|
+
await assert.rejects(invoke("pages.append", { pageId: "page:1", text: "No replay" }));
|
|
427
|
+
assert.equal(f.requests.length, count + 1);
|
|
428
|
+
const read = await fixture(t, entry);
|
|
429
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
430
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "pages.create", input: { sectionId: "section:1", title: "No", text: "No" } }), { code: "connector_scope_missing" });
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
test("microsoft-outlook: body and file reads, approved send/move/read actions and calendar appointments", async (t) => {
|
|
435
|
+
const entry = cases[0];
|
|
436
|
+
const f = await fixture(t, { ...entry, scopes: ["Mail.Read", "Mail.ReadWrite", "Mail.Send", "Calendars.ReadWrite"] });
|
|
437
|
+
await f.service.completeAuthorization({ ...f.input, callbackUrl: (await f.start()).callbackUrl });
|
|
438
|
+
const invoke = (operation, input) => f.service.invoke({ ...f.input, operation, input });
|
|
439
|
+
f.state.response = { id: "msg=1", body: { contentType: "text", content: "Receipt" } };
|
|
440
|
+
await invoke("messages.get", { messageId: "msg=1" });
|
|
441
|
+
assert.equal(new Headers(f.requests.at(-1).init.headers).get("prefer"), 'outlook.body-content-type="text"');
|
|
442
|
+
f.state.response = { value: [{ id: "file=1", name: "receipt.txt" }] };
|
|
443
|
+
await invoke("attachments.list", { messageId: "msg=1" });
|
|
444
|
+
f.state.response = { id: "file=1", "@odata.type": "#microsoft.graph.fileAttachment", contentBytes: "SGk=" };
|
|
445
|
+
assert.equal((await invoke("attachments.get", { messageId: "msg=1", attachmentId: "file=1" })).contentBytes, "SGk=");
|
|
446
|
+
f.state.response = { id: "msg=1", isRead: true };
|
|
447
|
+
await invoke("messages.setRead", { messageId: "msg=1", isRead: true });
|
|
448
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { isRead: true });
|
|
449
|
+
await invoke("messages.move", { messageId: "msg=1", destinationId: "archive" });
|
|
450
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { destinationId: "archive" });
|
|
451
|
+
f.state.status = 202;
|
|
452
|
+
assert.deepEqual(await invoke("messages.send", { subject: "Receipt", text: "Thank you", to: ["customer@example.com"] }), { accepted: true });
|
|
453
|
+
const sent = JSON.parse(f.requests.at(-1).init.body);
|
|
454
|
+
assert.deepEqual(sent.message.toRecipients, [{ emailAddress: { address: "customer@example.com" } }]);
|
|
455
|
+
assert.equal(sent.message.body.contentType, "Text"); assert.equal(sent.saveToSentItems, true); assert.equal(sent.message.from, undefined);
|
|
456
|
+
f.state.status = 200; f.state.response = { value: [{ id: "calendar=1" }] };
|
|
457
|
+
await invoke("calendars.list", {});
|
|
458
|
+
await invoke("events.list", { calendarId: "calendar=1", pageSize: 5 });
|
|
459
|
+
f.state.response = { id: "event=1" };
|
|
460
|
+
const event = { calendarId: "calendar=1", subject: "Grooming", start: "2026-09-20T10:00:00Z", end: "2026-09-20T11:00:00Z" };
|
|
461
|
+
await invoke("events.create", event);
|
|
462
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body).start, { dateTime: "2026-09-20T10:00:00", timeZone: "UTC" });
|
|
463
|
+
assert.equal(JSON.parse(f.requests.at(-1).init.body).attendees, undefined);
|
|
464
|
+
const before = f.requests.length;
|
|
465
|
+
await assert.rejects(invoke("events.create", { ...event, end: event.start }), { code: "connector_input_invalid" });
|
|
466
|
+
await assert.rejects(invoke("messages.send", { subject: "No", text: "No", to: ["bad\r\naddress"] }), { code: "connector_input_invalid" });
|
|
467
|
+
await assert.rejects(invoke("messages.get", { messageId: "../../other" }), { code: "connector_input_invalid" });
|
|
468
|
+
assert.equal(f.requests.length, before);
|
|
469
|
+
f.state.status = 429;
|
|
470
|
+
await assert.rejects(invoke("messages.send", { subject: "No replay", text: "No", to: ["customer@example.com"] }));
|
|
471
|
+
assert.equal(f.requests.length, before + 1);
|
|
472
|
+
const read = await fixture(t, entry);
|
|
473
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
474
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "messages.send", input: { subject: "No", text: "No", to: ["customer@example.com"] } }), { code: "connector_scope_missing" });
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test("microsoft-sharepoint: navigates libraries, transfers files and edits list fields with ETag", async (t) => {
|
|
478
|
+
const entry = cases[5];
|
|
479
|
+
const f = await fixture(t, { ...entry, scopes: ["Sites.Read.All", "User.Read", "Sites.ReadWrite.All"] });
|
|
480
|
+
await f.service.completeAuthorization({ ...f.input, callbackUrl: (await f.start()).callbackUrl });
|
|
481
|
+
const invoke = (operation, input) => f.service.invoke({ ...f.input, operation, input });
|
|
482
|
+
const siteId = "tenant.sharepoint.com,site-guid,web-guid";
|
|
483
|
+
f.state.response = { value: [{ id: "drive-1", name: "Documents" }] };
|
|
484
|
+
await invoke("libraries.list", { siteId });
|
|
485
|
+
assert.ok(decodeURIComponent(f.requests.at(-1).url.pathname).endsWith(`/sites/${siteId}/drives`));
|
|
486
|
+
await invoke("files.list", { driveId: "drive-1", folderId: "folder-1" });
|
|
487
|
+
assert.equal(f.requests.at(-1).url.pathname, "/v1.0/drives/drive-1/items/folder-1/children");
|
|
488
|
+
f.state.response = { id: "file-1", name: "Report.txt", "@microsoft.graph.downloadUrl": "https://tenant.sharepoint.com/private-link" };
|
|
489
|
+
await invoke("files.get", { driveId: "drive-1", itemId: "file-1" });
|
|
490
|
+
assert.equal(f.requests.at(-1).url.pathname, "/v1.0/drives/drive-1/items/file-1");
|
|
491
|
+
await invoke("files.upload", { driveId: "drive-1", parentId: "folder-1", name: "Report.txt", bodyBase64: "SGk=" });
|
|
492
|
+
assert.equal(f.requests.at(-1).init.method, "PUT");
|
|
493
|
+
assert.equal(Buffer.from(f.requests.at(-1).init.body).toString(), "Hi");
|
|
494
|
+
f.state.response = { value: [{ id: "list-1" }] };
|
|
495
|
+
await invoke("lists.list", { siteId });
|
|
496
|
+
await invoke("listItems.list", { siteId, listId: "list-1" });
|
|
497
|
+
assert.equal(f.requests.at(-1).url.searchParams.get("$expand"), "fields");
|
|
498
|
+
f.state.response = { id: "item-1" };
|
|
499
|
+
await invoke("listItems.create", { siteId, listId: "list-1", fields: { Title: "Report", Count: 3 } });
|
|
500
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { fields: { Title: "Report", Count: 3 } });
|
|
501
|
+
f.state.response = { Title: "Updated" };
|
|
502
|
+
const update = { siteId, listId: "list-1", itemId: "item-1", fields: { Title: "Updated" }, eTag: '"version-1"' };
|
|
503
|
+
await invoke("listItems.update", update);
|
|
504
|
+
assert.equal(new Headers(f.requests.at(-1).init.headers).get("if-match"), '"version-1"');
|
|
505
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { Title: "Updated" });
|
|
506
|
+
const before = f.requests.length;
|
|
507
|
+
for (const patch of [{ eTag: "*" }, { siteId: "https://other.test" }, { fields: {} }, { fields: { Nested: { value: 1 } } }]) {
|
|
508
|
+
await assert.rejects(invoke("listItems.update", { ...update, ...patch }), { code: "connector_input_invalid" });
|
|
509
|
+
}
|
|
510
|
+
assert.equal(f.requests.length, before);
|
|
511
|
+
f.state.status = 412;
|
|
512
|
+
await assert.rejects(invoke("listItems.update", update));
|
|
513
|
+
assert.equal(f.requests.length, before + 1);
|
|
514
|
+
const read = await fixture(t, entry);
|
|
515
|
+
await read.service.completeAuthorization({ ...read.input, callbackUrl: (await read.start()).callbackUrl });
|
|
516
|
+
await assert.rejects(read.service.invoke({ ...read.input, operation: "listItems.update", input: update }), { code: "connector_scope_missing" });
|
|
517
|
+
assert.equal(microsoftSharePointProvider.operations["sites.create"], undefined);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
test("microsoft-teams: channels, replies and existing chats use separate read/send grants", async (t) => {
|
|
521
|
+
const entry = cases[3];
|
|
522
|
+
const f = await fixture(t, { ...entry, scopes: [...entry.scopes, "ChannelMessage.Read.All", "ChannelMessage.Send", "Chat.ReadWrite"] });
|
|
523
|
+
await f.service.completeAuthorization({ ...f.input, callbackUrl: (await f.start()).callbackUrl });
|
|
524
|
+
const invoke = (operation, input) => f.service.invoke({ ...f.input, operation, input });
|
|
525
|
+
const channel = { teamId: "team-1", channelId: "19:channel@thread.tacv2" };
|
|
526
|
+
f.state.response = { value: [{ id: channel.channelId }] };
|
|
527
|
+
await invoke("channels.list", { teamId: channel.teamId });
|
|
528
|
+
await invoke("messages.list", { ...channel, pageSize: 10 });
|
|
529
|
+
assert.ok(decodeURIComponent(f.requests.at(-1).url.pathname).endsWith(`/teams/team-1/channels/${channel.channelId}/messages`));
|
|
530
|
+
assert.equal(f.requests.at(-1).url.searchParams.get("$top"), "10");
|
|
531
|
+
await invoke("replies.list", { ...channel, messageId: "12345" });
|
|
532
|
+
assert.ok(f.requests.at(-1).url.pathname.endsWith("/messages/12345/replies"));
|
|
533
|
+
f.state.response = { id: "12346" };
|
|
534
|
+
await invoke("messages.send", { ...channel, text: "Approved update" });
|
|
535
|
+
assert.deepEqual(JSON.parse(f.requests.at(-1).init.body), { body: { contentType: "text", content: "Approved update" } });
|
|
536
|
+
await invoke("replies.send", { ...channel, messageId: "12345", text: "Reply" });
|
|
537
|
+
assert.ok(f.requests.at(-1).url.pathname.endsWith("/messages/12345/replies"));
|
|
538
|
+
f.state.response = { value: [{ id: "19:chat@thread.v2" }] };
|
|
539
|
+
await invoke("chats.list", {});
|
|
540
|
+
await invoke("chatMessages.list", { chatId: "19:chat@thread.v2" });
|
|
541
|
+
f.state.response = { id: "12347" };
|
|
542
|
+
await invoke("chatMessages.send", { chatId: "19:chat@thread.v2", text: "Approved chat" });
|
|
543
|
+
assert.ok(decodeURIComponent(f.requests.at(-1).url.pathname).endsWith("/chats/19:chat@thread.v2/messages"));
|
|
544
|
+
const before = f.requests.length;
|
|
545
|
+
await assert.rejects(invoke("messages.send", { ...channel, channelId: "../../other", text: "No" }), { code: "connector_input_invalid" });
|
|
546
|
+
assert.equal(f.requests.length, before);
|
|
547
|
+
f.state.status = 429;
|
|
548
|
+
await assert.rejects(invoke("messages.send", { ...channel, text: "No replay" }));
|
|
549
|
+
assert.equal(f.requests.length, before + 1);
|
|
550
|
+
const basic = await fixture(t, entry);
|
|
551
|
+
await basic.service.completeAuthorization({ ...basic.input, callbackUrl: (await basic.start()).callbackUrl });
|
|
552
|
+
for (const operation of ["messages.list", "messages.send"]) await assert.rejects(basic.service.invoke({ ...basic.input, operation, input: { ...channel, ...(operation.endsWith("send") ? { text: "No" } : {}) } }), { code: "connector_scope_missing" });
|
|
553
|
+
assert.equal(microsoftTeamsProvider.operations["teams.create"], undefined);
|
|
554
|
+
});
|