@open-mercato/channel-ms365 0.0.0-stage → 0.11.1-develop.8910.1.d07a49d70a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/AGENTS.md +55 -0
  3. package/build.mjs +7 -0
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +7 -0
  6. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-001.spec.js +22 -0
  7. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-001.spec.js.map +7 -0
  8. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-002.spec.js +33 -0
  9. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-002.spec.js.map +7 -0
  10. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-003.spec.js +57 -0
  11. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-003.spec.js.map +7 -0
  12. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-004.spec.js +36 -0
  13. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-004.spec.js.map +7 -0
  14. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-005.spec.js +38 -0
  15. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-005.spec.js.map +7 -0
  16. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-006.spec.js +25 -0
  17. package/dist/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-006.spec.js.map +7 -0
  18. package/dist/modules/channel_ms365/__integration__/fixtures.js +77 -0
  19. package/dist/modules/channel_ms365/__integration__/fixtures.js.map +7 -0
  20. package/dist/modules/channel_ms365/acl.js +10 -0
  21. package/dist/modules/channel_ms365/acl.js.map +7 -0
  22. package/dist/modules/channel_ms365/di.js +23 -0
  23. package/dist/modules/channel_ms365/di.js.map +7 -0
  24. package/dist/modules/channel_ms365/index.js +10 -0
  25. package/dist/modules/channel_ms365/index.js.map +7 -0
  26. package/dist/modules/channel_ms365/integration.js +77 -0
  27. package/dist/modules/channel_ms365/integration.js.map +7 -0
  28. package/dist/modules/channel_ms365/lib/adapter.js +694 -0
  29. package/dist/modules/channel_ms365/lib/adapter.js.map +7 -0
  30. package/dist/modules/channel_ms365/lib/capabilities.js +10 -0
  31. package/dist/modules/channel_ms365/lib/capabilities.js.map +7 -0
  32. package/dist/modules/channel_ms365/lib/convert-outbound.js +70 -0
  33. package/dist/modules/channel_ms365/lib/convert-outbound.js.map +7 -0
  34. package/dist/modules/channel_ms365/lib/credentials.js +86 -0
  35. package/dist/modules/channel_ms365/lib/credentials.js.map +7 -0
  36. package/dist/modules/channel_ms365/lib/graph-client.js +388 -0
  37. package/dist/modules/channel_ms365/lib/graph-client.js.map +7 -0
  38. package/dist/modules/channel_ms365/lib/health.js +11 -0
  39. package/dist/modules/channel_ms365/lib/health.js.map +7 -0
  40. package/dist/modules/channel_ms365/lib/normalize-inbound.js +25 -0
  41. package/dist/modules/channel_ms365/lib/normalize-inbound.js.map +7 -0
  42. package/dist/modules/channel_ms365/lib/oauth.js +127 -0
  43. package/dist/modules/channel_ms365/lib/oauth.js.map +7 -0
  44. package/dist/modules/channel_ms365/setup.js +25 -0
  45. package/dist/modules/channel_ms365/setup.js.map +7 -0
  46. package/dist/modules/channel_ms365/widgets/injection/connect/widget.client.js +38 -0
  47. package/dist/modules/channel_ms365/widgets/injection/connect/widget.client.js.map +7 -0
  48. package/dist/modules/channel_ms365/widgets/injection/connect/widget.js +17 -0
  49. package/dist/modules/channel_ms365/widgets/injection/connect/widget.js.map +7 -0
  50. package/dist/modules/channel_ms365/widgets/injection-table.js +14 -0
  51. package/dist/modules/channel_ms365/widgets/injection-table.js.map +7 -0
  52. package/jest.config.cjs +34 -0
  53. package/jest.setup.ts +20 -0
  54. package/package.json +95 -3
  55. package/src/index.ts +1 -0
  56. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-001.spec.ts +31 -0
  57. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-002.spec.ts +46 -0
  58. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-003.spec.ts +77 -0
  59. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-004.spec.ts +49 -0
  60. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-005.spec.ts +60 -0
  61. package/src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-006.spec.ts +36 -0
  62. package/src/modules/channel_ms365/__integration__/fixtures.ts +97 -0
  63. package/src/modules/channel_ms365/acl.ts +6 -0
  64. package/src/modules/channel_ms365/di.ts +21 -0
  65. package/src/modules/channel_ms365/index.ts +7 -0
  66. package/src/modules/channel_ms365/integration.ts +76 -0
  67. package/src/modules/channel_ms365/lib/__tests__/adapter.test.ts +1416 -0
  68. package/src/modules/channel_ms365/lib/__tests__/convert-outbound.test.ts +70 -0
  69. package/src/modules/channel_ms365/lib/__tests__/credentials.test.ts +98 -0
  70. package/src/modules/channel_ms365/lib/__tests__/graph-client.test.ts +437 -0
  71. package/src/modules/channel_ms365/lib/__tests__/health.test.ts +24 -0
  72. package/src/modules/channel_ms365/lib/__tests__/mailparser-warmup.test.ts +23 -0
  73. package/src/modules/channel_ms365/lib/__tests__/normalize-inbound.test.ts +62 -0
  74. package/src/modules/channel_ms365/lib/__tests__/oauth.test.ts +184 -0
  75. package/src/modules/channel_ms365/lib/adapter.ts +1015 -0
  76. package/src/modules/channel_ms365/lib/capabilities.ts +20 -0
  77. package/src/modules/channel_ms365/lib/convert-outbound.ts +109 -0
  78. package/src/modules/channel_ms365/lib/credentials.ts +166 -0
  79. package/src/modules/channel_ms365/lib/graph-client.ts +596 -0
  80. package/src/modules/channel_ms365/lib/health.ts +16 -0
  81. package/src/modules/channel_ms365/lib/normalize-inbound.ts +55 -0
  82. package/src/modules/channel_ms365/lib/oauth.ts +230 -0
  83. package/src/modules/channel_ms365/setup.ts +36 -0
  84. package/src/modules/channel_ms365/widgets/injection/connect/__tests__/widget.test.tsx +80 -0
  85. package/src/modules/channel_ms365/widgets/injection/connect/widget.client.tsx +64 -0
  86. package/src/modules/channel_ms365/widgets/injection/connect/widget.ts +16 -0
  87. package/src/modules/channel_ms365/widgets/injection-table.ts +12 -0
  88. package/tsconfig.json +9 -0
  89. package/watch.mjs +7 -0
  90. package/README.md +0 -3
@@ -0,0 +1,2 @@
1
+ [build:channel-ms365] found 24 entry points
2
+ [build:channel-ms365] built successfully
package/AGENTS.md ADDED
@@ -0,0 +1,55 @@
1
+ # `@open-mercato/channel-ms365` — Agent Guidelines
2
+
3
+ Microsoft 365 / Exchange Online email channel provider for the Communications Hub (`communication_channels`). Connects per-user mailboxes via Entra ID OAuth2 (v2.0 endpoints, PKCE). Outbound and inbound both go through Microsoft Graph; inbound uses the Inbox delta query (polling — Graph change notifications are a phase-2 follow-up).
4
+
5
+ - **Package**: `@open-mercato/channel-ms365` ⇒ **module id**: `channel_ms365`
6
+ - **Provider key**: `ms365` (registered in the hub's channel adapter registry)
7
+ - **Spec**: `.ai/specs/2026-09-04-ms365-graph-email-channel.md`
8
+ - This is an integration provider package — keep all Microsoft-specific logic here. Do NOT add it to `packages/core`.
9
+
10
+ ## Key Files (`src/modules/channel_ms365/`)
11
+
12
+ | File | Purpose |
13
+ |------|---------|
14
+ | `integration.ts` | `IntegrationDefinition` (tenant credential fields: client id / secret / tenant id / scopes, `healthCheck.service`, detail widget spot) |
15
+ | `di.ts` | `register(container)` — registers the adapter AND `channelMs365HealthCheck` under the exact `healthCheck.service` name |
16
+ | `setup.ts` | Registers the adapter at import time; declares `defaultRoleFeatures` |
17
+ | `acl.ts` | `channel_ms365.view`, `channel_ms365.configure` |
18
+ | `lib/adapter.ts` | `Ms365ChannelAdapter` — implements the `ChannelAdapter` contract |
19
+ | `lib/credentials.ts` | Zod schemas: OAuth client config + per-user tokens + channel sync state; default scopes |
20
+ | `lib/oauth.ts` | `MicrosoftOAuthClient` (authorize URL with PKCE, code exchange, refresh, Graph `/me` profile), authority/Graph base-URL helpers |
21
+ | `lib/graph-client.ts` | `GraphMailClient` (Inbox delta, list, `$value` MIME, draft-from-MIME, send, move, delete) + `GraphApiError` |
22
+ | `lib/convert-outbound.ts` / `lib/normalize-inbound.ts` | RFC2822 outbound build / inbound MIME normalization via the shared `email-mime` helpers |
23
+ | `lib/capabilities.ts` | `ChannelCapabilities` (`realtimePush: false`, `deleteMessage: true`) |
24
+ | `lib/health.ts` | `channelMs365HealthCheck` (validates the tenant client config) |
25
+ | `widgets/injection/connect/` | *Connect Microsoft 365* button on the profile channels page (`useConnectChannel`) |
26
+
27
+ ## Adapter Contract
28
+
29
+ `lib/adapter.ts` implements `ChannelAdapter` from `@open-mercato/core/modules/communication_channels/lib/adapter`. Key methods: `sendMessage`, `normalizeInbound`, `convertOutbound`, `buildOAuthAuthorizeUrl`, `exchangeOAuthCode`, `refreshCredentials`, `fetchHistory`, `importHistory`, `deleteMessage`, `resolveContact`.
30
+
31
+ - Tenant OAuth client config (`{ clientId, clientSecret, tenantId?, scopes? }`) lives on `IntegrationCredentials` for provider `ms365` at tenant scope; per-user tokens live on the per-user row. `tenantId` defaults to `organizations` (no personal accounts).
32
+ - `fetchHistory` is cursor-driven via `channelState.deltaLink` / `nextLink` plus a `receivedWatermark`. The stored link MUST only advance after every message of a page was normalized; a transient `$value` failure pins the incoming state (`hardFailed`) and the next tick re-reads the same page. `410 Gone` re-bootstraps from the watermark.
33
+ - `sendMessage` creates a draft from raw MIME (`POST /me/messages`) and sends it (`/send`) so the authoritative `internetMessageId` is known; a permanent send failure deletes the orphan draft.
34
+ - Every Graph call sends `Prefer: IdType="ImmutableId"`; delta/next links are only followed on the configured Graph origin.
35
+ - A 401 anywhere surfaces the `requires_reauth` sentinel (never prefix or translate it). Entra rotates refresh tokens — `refreshCredentials` always persists the new one.
36
+ - The clients are swappable via `setGraphMailClient` / `setMicrosoftOAuthClient` (test-only hooks).
37
+
38
+ ## Health Check
39
+
40
+ `lib/health.ts` exports `channelMs365HealthCheck`, registered in `di.ts` under the name declared in `integration.ts` (`healthCheck.service`). The hub passes the tenant-scoped OAuth client config (no access token at this layer), so the probe validates the config against `ms365ClientCredentialsSchema` rather than calling Graph. Missing/invalid config ⇒ `unhealthy`.
41
+
42
+ ## Env Vars (all optional)
43
+
44
+ | Var | Purpose |
45
+ |-----|---------|
46
+ | `OM_CHANNEL_MS365_LOGIN_BASE_URL` | Entra authority host override for sovereign clouds (default `https://login.microsoftonline.com`) |
47
+ | `OM_CHANNEL_MS365_GRAPH_BASE_URL` | Graph base URL override (default `https://graph.microsoft.com/v1.0`) |
48
+ | `OM_CHANNEL_MS365_DELTA_PAGE_SIZE` | Delta/list page size, 1..200 (default 50) |
49
+ | `OM_CHANNEL_MS365_REQUEST_TIMEOUT_MS` | Per-request Graph timeout (default 30000) |
50
+
51
+ ## After Changes
52
+
53
+ - Run `yarn generate` after adding/modifying module files (DI, setup, acl, integration, widgets).
54
+ - Run unit tests: `yarn test` (jest specs live under `lib/__tests__/`).
55
+ - If you change the `healthCheck.service` name, update both `integration.ts` AND `di.ts` so the hub can resolve it.
package/build.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { buildPackage } from '../../scripts/build-package.mjs'
4
+
5
+ const packageDir = dirname(fileURLToPath(import.meta.url))
6
+
7
+ await buildPackage(packageDir, { name: 'channel-ms365' })
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { metadata } from "./modules/channel_ms365/index.js";
2
+ export {
3
+ metadata
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export { metadata } from './modules/channel_ms365/index'\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,22 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { getAuthToken } from "@open-mercato/core/helpers/integration/authFixtures";
3
+ import { apiRequest } from "@open-mercato/core/helpers/integration/api";
4
+ test.describe("TC-CHANNEL-MS365-001: Microsoft 365 OAuth router wiring", () => {
5
+ test("POST /oauth/ms365/initiate resolves the ms365 adapter", async ({ request }) => {
6
+ const token = await getAuthToken(request);
7
+ const response = await apiRequest(
8
+ request,
9
+ "POST",
10
+ "/api/communication_channels/oauth/ms365/initiate",
11
+ { token, data: { returnUrl: "/backend/profile/communication-channels" } }
12
+ );
13
+ expect(response.status(), "route should not 5xx").toBeLessThan(500);
14
+ expect(response.status(), "ms365 provider should be registered").not.toBe(404);
15
+ expect(response.status(), "ms365 adapter must implement buildOAuthAuthorizeUrl").not.toBe(400);
16
+ if (response.status() === 409) {
17
+ const body = await response.json();
18
+ expect(body.code).toBe("oauth_client_not_configured");
19
+ }
20
+ });
21
+ });
22
+ //# sourceMappingURL=TC-CHANNEL-MS365-001.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-001.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { getAuthToken } from '@open-mercato/core/helpers/integration/authFixtures'\nimport { apiRequest } from '@open-mercato/core/helpers/integration/api'\n\n/**\n * TC-CHANNEL-MS365-001 \u2014 Microsoft 365 provider is registered with the hub's OAuth router.\n *\n * `POST /api/communication_channels/oauth/ms365/initiate` must resolve the\n * `ms365` adapter. Without tenant client credentials the hub answers 409 with\n * the actionable `oauth_client_not_configured` code; with credentials it\n * answers 200 (covered by TC-CHANNEL-MS365-003). A 404 would mean the adapter\n * is not registered; a 5xx would mean the adapter threw while building the URL.\n */\ntest.describe('TC-CHANNEL-MS365-001: Microsoft 365 OAuth router wiring', () => {\n test('POST /oauth/ms365/initiate resolves the ms365 adapter', async ({ request }) => {\n const token = await getAuthToken(request)\n const response = await apiRequest(\n request,\n 'POST',\n '/api/communication_channels/oauth/ms365/initiate',\n { token, data: { returnUrl: '/backend/profile/communication-channels' } },\n )\n expect(response.status(), 'route should not 5xx').toBeLessThan(500)\n expect(response.status(), 'ms365 provider should be registered').not.toBe(404)\n expect(response.status(), 'ms365 adapter must implement buildOAuthAuthorizeUrl').not.toBe(400)\n if (response.status() === 409) {\n const body = (await response.json()) as { code?: string }\n expect(body.code).toBe('oauth_client_not_configured')\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAW3B,KAAK,SAAS,2DAA2D,MAAM;AAC7E,OAAK,yDAAyD,OAAO,EAAE,QAAQ,MAAM;AACnF,UAAM,QAAQ,MAAM,aAAa,OAAO;AACxC,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,EAAE,OAAO,MAAM,EAAE,WAAW,0CAA0C,EAAE;AAAA,IAC1E;AACA,WAAO,SAAS,OAAO,GAAG,sBAAsB,EAAE,aAAa,GAAG;AAClE,WAAO,SAAS,OAAO,GAAG,qCAAqC,EAAE,IAAI,KAAK,GAAG;AAC7E,WAAO,SAAS,OAAO,GAAG,qDAAqD,EAAE,IAAI,KAAK,GAAG;AAC7F,QAAI,SAAS,OAAO,MAAM,KAAK;AAC7B,YAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,aAAO,KAAK,IAAI,EAAE,KAAK,6BAA6B;AAAA,IACtD;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,33 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { apiRequest } from "@open-mercato/core/helpers/integration/api";
3
+ import { readJsonSafe } from "@open-mercato/core/helpers/integration/generalFixtures";
4
+ import { createMs365Sandbox, MS365_INTEGRATION_ID } from "./fixtures.js";
5
+ test.describe("TC-CHANNEL-MS365-002: Microsoft 365 tenant credentials + health check", () => {
6
+ test("saving the client config flips the health check between healthy and unhealthy", async ({ request }) => {
7
+ const sandbox = await createMs365Sandbox(request, "TC-MS365-002");
8
+ try {
9
+ const detail = await apiRequest(request, "GET", `/api/integrations/${MS365_INTEGRATION_ID}`, { token: sandbox.token });
10
+ expect(detail.status(), "channel_ms365 integration should be registered").toBe(200);
11
+ await sandbox.saveClientCredentials({
12
+ clientId: "tc-ms365-002-client-id",
13
+ clientSecret: "tc-ms365-002-client-secret",
14
+ tenantId: "contoso.onmicrosoft.com",
15
+ scopes: ""
16
+ });
17
+ const healthy = await apiRequest(request, "POST", `/api/integrations/${MS365_INTEGRATION_ID}/health`, { token: sandbox.token });
18
+ expect(healthy.status()).toBe(200);
19
+ const healthyBody = await readJsonSafe(healthy);
20
+ expect(healthyBody.status).toBe("healthy");
21
+ expect(healthyBody.details?.tenantId).toBe("contoso.onmicrosoft.com");
22
+ await sandbox.saveClientCredentials({ clientId: "", clientSecret: "", tenantId: "", scopes: "" });
23
+ const unhealthy = await apiRequest(request, "POST", `/api/integrations/${MS365_INTEGRATION_ID}/health`, { token: sandbox.token });
24
+ expect(unhealthy.status()).toBe(200);
25
+ const unhealthyBody = await readJsonSafe(unhealthy);
26
+ expect(unhealthyBody.status).toBe("unhealthy");
27
+ expect(unhealthyBody.details?.reason).toBe("invalid_oauth_client");
28
+ } finally {
29
+ await sandbox.dispose();
30
+ }
31
+ });
32
+ });
33
+ //# sourceMappingURL=TC-CHANNEL-MS365-002.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-002.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { apiRequest } from '@open-mercato/core/helpers/integration/api'\nimport { readJsonSafe } from '@open-mercato/core/helpers/integration/generalFixtures'\nimport { createMs365Sandbox, MS365_INTEGRATION_ID } from './fixtures'\n\ntype JsonRecord = Record<string, unknown>\n\n/**\n * TC-CHANNEL-MS365-002 \u2014 Tenant OAuth client config + health check.\n *\n * Runs inside a dedicated organization/user sandbox (see `fixtures.ts`) so the\n * shared default organization's credentials are never overwritten. The\n * provider health check validates the client config without a network call:\n * a complete config is `healthy` and echoes the effective tenant; a config\n * without a client id is `unhealthy` with the `invalid_oauth_client` reason.\n */\ntest.describe('TC-CHANNEL-MS365-002: Microsoft 365 tenant credentials + health check', () => {\n test('saving the client config flips the health check between healthy and unhealthy', async ({ request }) => {\n const sandbox = await createMs365Sandbox(request, 'TC-MS365-002')\n try {\n const detail = await apiRequest(request, 'GET', `/api/integrations/${MS365_INTEGRATION_ID}`, { token: sandbox.token })\n expect(detail.status(), 'channel_ms365 integration should be registered').toBe(200)\n\n await sandbox.saveClientCredentials({\n clientId: 'tc-ms365-002-client-id',\n clientSecret: 'tc-ms365-002-client-secret',\n tenantId: 'contoso.onmicrosoft.com',\n scopes: '',\n })\n const healthy = await apiRequest(request, 'POST', `/api/integrations/${MS365_INTEGRATION_ID}/health`, { token: sandbox.token })\n expect(healthy.status()).toBe(200)\n const healthyBody = (await readJsonSafe(healthy)) as JsonRecord\n expect(healthyBody.status).toBe('healthy')\n expect((healthyBody.details as JsonRecord | null)?.tenantId).toBe('contoso.onmicrosoft.com')\n\n await sandbox.saveClientCredentials({ clientId: '', clientSecret: '', tenantId: '', scopes: '' })\n const unhealthy = await apiRequest(request, 'POST', `/api/integrations/${MS365_INTEGRATION_ID}/health`, { token: sandbox.token })\n expect(unhealthy.status()).toBe(200)\n const unhealthyBody = (await readJsonSafe(unhealthy)) as JsonRecord\n expect(unhealthyBody.status).toBe('unhealthy')\n expect((unhealthyBody.details as JsonRecord | null)?.reason).toBe('invalid_oauth_client')\n } finally {\n await sandbox.dispose()\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB,4BAA4B;AAazD,KAAK,SAAS,yEAAyE,MAAM;AAC3F,OAAK,iFAAiF,OAAO,EAAE,QAAQ,MAAM;AAC3G,UAAM,UAAU,MAAM,mBAAmB,SAAS,cAAc;AAChE,QAAI;AACF,YAAM,SAAS,MAAM,WAAW,SAAS,OAAO,qBAAqB,oBAAoB,IAAI,EAAE,OAAO,QAAQ,MAAM,CAAC;AACrH,aAAO,OAAO,OAAO,GAAG,gDAAgD,EAAE,KAAK,GAAG;AAElF,YAAM,QAAQ,sBAAsB;AAAA,QAClC,UAAU;AAAA,QACV,cAAc;AAAA,QACd,UAAU;AAAA,QACV,QAAQ;AAAA,MACV,CAAC;AACD,YAAM,UAAU,MAAM,WAAW,SAAS,QAAQ,qBAAqB,oBAAoB,WAAW,EAAE,OAAO,QAAQ,MAAM,CAAC;AAC9H,aAAO,QAAQ,OAAO,CAAC,EAAE,KAAK,GAAG;AACjC,YAAM,cAAe,MAAM,aAAa,OAAO;AAC/C,aAAO,YAAY,MAAM,EAAE,KAAK,SAAS;AACzC,aAAQ,YAAY,SAA+B,QAAQ,EAAE,KAAK,yBAAyB;AAE3F,YAAM,QAAQ,sBAAsB,EAAE,UAAU,IAAI,cAAc,IAAI,UAAU,IAAI,QAAQ,GAAG,CAAC;AAChG,YAAM,YAAY,MAAM,WAAW,SAAS,QAAQ,qBAAqB,oBAAoB,WAAW,EAAE,OAAO,QAAQ,MAAM,CAAC;AAChI,aAAO,UAAU,OAAO,CAAC,EAAE,KAAK,GAAG;AACnC,YAAM,gBAAiB,MAAM,aAAa,SAAS;AACnD,aAAO,cAAc,MAAM,EAAE,KAAK,WAAW;AAC7C,aAAQ,cAAc,SAA+B,MAAM,EAAE,KAAK,sBAAsB;AAAA,IAC1F,UAAE;AACA,YAAM,QAAQ,QAAQ;AAAA,IACxB;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,57 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { readJsonSafe } from "@open-mercato/core/helpers/integration/generalFixtures";
3
+ import { createMs365Sandbox } from "./fixtures.js";
4
+ const BASE_URL = process.env.BASE_URL?.trim() || "";
5
+ test.describe("TC-CHANNEL-MS365-003: OAuth initiate with tenant config", () => {
6
+ test("returns an Entra v2.0 authorize URL with PKCE and the default scopes", async ({ request }) => {
7
+ const sandbox = await createMs365Sandbox(request, "TC-MS365-003");
8
+ const statusUrl = `${BASE_URL}/api/communication_channels/oauth/ms365/status`;
9
+ const initiateUrl = `${BASE_URL}/api/communication_channels/oauth/ms365/initiate`;
10
+ const headers = { Authorization: `Bearer ${sandbox.token}`, "Content-Type": "application/json" };
11
+ try {
12
+ await sandbox.saveClientCredentials({ clientId: "tc-ms365-003-client-id" });
13
+ const partialStatus = await request.get(statusUrl, { headers });
14
+ expect(partialStatus.status()).toBe(200);
15
+ expect(await partialStatus.json()).toEqual({ configured: false });
16
+ const partialInitiate = await request.post(initiateUrl, { headers, data: {} });
17
+ expect(partialInitiate.status()).toBe(409);
18
+ expect(await readJsonSafe(partialInitiate)).toMatchObject({ code: "oauth_client_not_configured" });
19
+ await sandbox.saveClientCredentials({
20
+ clientId: "tc-ms365-003-client-id",
21
+ clientSecret: "tc-ms365-003-client-secret",
22
+ tenantId: "",
23
+ scopes: ""
24
+ });
25
+ const readyStatus = await request.get(statusUrl, { headers });
26
+ expect(readyStatus.status()).toBe(200);
27
+ expect(await readyStatus.json()).toEqual({ configured: true });
28
+ const response = await request.post(initiateUrl, {
29
+ headers,
30
+ data: { returnUrl: "/backend/profile/communication-channels", loginHint: "alice@contoso.com" }
31
+ });
32
+ expect(response.status()).toBe(200);
33
+ const body = await readJsonSafe(response);
34
+ expect(typeof body.authorizeUrl).toBe("string");
35
+ const url = new URL(body.authorizeUrl);
36
+ expect(url.origin).toBe("https://login.microsoftonline.com");
37
+ expect(url.pathname).toBe("/organizations/oauth2/v2.0/authorize");
38
+ expect(url.searchParams.get("client_id")).toBe("tc-ms365-003-client-id");
39
+ expect(url.searchParams.get("response_type")).toBe("code");
40
+ expect(url.searchParams.get("code_challenge_method")).toBe("S256");
41
+ expect(url.searchParams.get("code_challenge") ?? "").toMatch(/^[A-Za-z0-9_-]{43}$/);
42
+ expect(url.searchParams.get("prompt")).toBe("select_account");
43
+ expect(url.searchParams.get("login_hint")).toBe("alice@contoso.com");
44
+ expect(url.searchParams.get("state") ?? "").not.toBe("");
45
+ expect(url.searchParams.get("redirect_uri") ?? "").toContain("/api/communication_channels/oauth/ms365/callback");
46
+ const scope = url.searchParams.get("scope") ?? "";
47
+ for (const expected of ["offline_access", "openid", "https://graph.microsoft.com/Mail.ReadWrite", "https://graph.microsoft.com/Mail.Send", "https://graph.microsoft.com/User.Read"]) {
48
+ expect(scope).toContain(expected);
49
+ }
50
+ const setCookie = response.headers()["set-cookie"] ?? "";
51
+ expect(setCookie).toContain("HttpOnly");
52
+ } finally {
53
+ await sandbox.dispose();
54
+ }
55
+ });
56
+ });
57
+ //# sourceMappingURL=TC-CHANNEL-MS365-003.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-003.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { readJsonSafe } from '@open-mercato/core/helpers/integration/generalFixtures'\nimport { createMs365Sandbox } from './fixtures'\n\nconst BASE_URL = process.env.BASE_URL?.trim() || ''\n\n/**\n * TC-CHANNEL-MS365-003 \u2014 OAuth initiate builds an Entra authorize URL with PKCE.\n *\n * Runs inside a dedicated organization/user sandbox (see `fixtures.ts`). With\n * the sandbox's tenant client config saved, `POST /oauth/ms365/initiate` must\n * answer 200 with an `authorizeUrl` on the configured Entra authority, carry\n * the hub-minted `state`, the S256 PKCE challenge, `select_account`, and every\n * default scope, and set the HttpOnly state cookie. No live Microsoft call is\n * made \u2014 the URL is only built, never followed.\n *\n * Before that, the workspace setup check (#10365): with only a client ID saved\n * the Microsoft 365 setup is incomplete (the client secret is required), so the\n * status route reports `configured: false` and initiate answers 409; once the\n * secret is saved the status flips to `configured: true`.\n */\ntest.describe('TC-CHANNEL-MS365-003: OAuth initiate with tenant config', () => {\n test('returns an Entra v2.0 authorize URL with PKCE and the default scopes', async ({ request }) => {\n const sandbox = await createMs365Sandbox(request, 'TC-MS365-003')\n const statusUrl = `${BASE_URL}/api/communication_channels/oauth/ms365/status`\n const initiateUrl = `${BASE_URL}/api/communication_channels/oauth/ms365/initiate`\n const headers = { Authorization: `Bearer ${sandbox.token}`, 'Content-Type': 'application/json' }\n try {\n await sandbox.saveClientCredentials({ clientId: 'tc-ms365-003-client-id' })\n const partialStatus = await request.get(statusUrl, { headers })\n expect(partialStatus.status()).toBe(200)\n expect(await partialStatus.json()).toEqual({ configured: false })\n const partialInitiate = await request.post(initiateUrl, { headers, data: {} })\n expect(partialInitiate.status()).toBe(409)\n expect(await readJsonSafe(partialInitiate)).toMatchObject({ code: 'oauth_client_not_configured' })\n\n await sandbox.saveClientCredentials({\n clientId: 'tc-ms365-003-client-id',\n clientSecret: 'tc-ms365-003-client-secret',\n tenantId: '',\n scopes: '',\n })\n const readyStatus = await request.get(statusUrl, { headers })\n expect(readyStatus.status()).toBe(200)\n expect(await readyStatus.json()).toEqual({ configured: true })\n\n const response = await request.post(initiateUrl, {\n headers,\n data: { returnUrl: '/backend/profile/communication-channels', loginHint: 'alice@contoso.com' },\n })\n expect(response.status()).toBe(200)\n const body = (await readJsonSafe(response)) as { authorizeUrl?: string }\n expect(typeof body.authorizeUrl).toBe('string')\n\n const url = new URL(body.authorizeUrl as string)\n expect(url.origin).toBe('https://login.microsoftonline.com')\n expect(url.pathname).toBe('/organizations/oauth2/v2.0/authorize')\n expect(url.searchParams.get('client_id')).toBe('tc-ms365-003-client-id')\n expect(url.searchParams.get('response_type')).toBe('code')\n expect(url.searchParams.get('code_challenge_method')).toBe('S256')\n expect(url.searchParams.get('code_challenge') ?? '').toMatch(/^[A-Za-z0-9_-]{43}$/)\n expect(url.searchParams.get('prompt')).toBe('select_account')\n expect(url.searchParams.get('login_hint')).toBe('alice@contoso.com')\n expect(url.searchParams.get('state') ?? '').not.toBe('')\n expect(url.searchParams.get('redirect_uri') ?? '').toContain('/api/communication_channels/oauth/ms365/callback')\n const scope = url.searchParams.get('scope') ?? ''\n for (const expected of ['offline_access', 'openid', 'https://graph.microsoft.com/Mail.ReadWrite', 'https://graph.microsoft.com/Mail.Send', 'https://graph.microsoft.com/User.Read']) {\n expect(scope).toContain(expected)\n }\n\n const setCookie = response.headers()['set-cookie'] ?? ''\n expect(setCookie).toContain('HttpOnly')\n } finally {\n await sandbox.dispose()\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAEnC,MAAM,WAAW,QAAQ,IAAI,UAAU,KAAK,KAAK;AAiBjD,KAAK,SAAS,2DAA2D,MAAM;AAC7E,OAAK,wEAAwE,OAAO,EAAE,QAAQ,MAAM;AAClG,UAAM,UAAU,MAAM,mBAAmB,SAAS,cAAc;AAChE,UAAM,YAAY,GAAG,QAAQ;AAC7B,UAAM,cAAc,GAAG,QAAQ;AAC/B,UAAM,UAAU,EAAE,eAAe,UAAU,QAAQ,KAAK,IAAI,gBAAgB,mBAAmB;AAC/F,QAAI;AACF,YAAM,QAAQ,sBAAsB,EAAE,UAAU,yBAAyB,CAAC;AAC1E,YAAM,gBAAgB,MAAM,QAAQ,IAAI,WAAW,EAAE,QAAQ,CAAC;AAC9D,aAAO,cAAc,OAAO,CAAC,EAAE,KAAK,GAAG;AACvC,aAAO,MAAM,cAAc,KAAK,CAAC,EAAE,QAAQ,EAAE,YAAY,MAAM,CAAC;AAChE,YAAM,kBAAkB,MAAM,QAAQ,KAAK,aAAa,EAAE,SAAS,MAAM,CAAC,EAAE,CAAC;AAC7E,aAAO,gBAAgB,OAAO,CAAC,EAAE,KAAK,GAAG;AACzC,aAAO,MAAM,aAAa,eAAe,CAAC,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEjG,YAAM,QAAQ,sBAAsB;AAAA,QAClC,UAAU;AAAA,QACV,cAAc;AAAA,QACd,UAAU;AAAA,QACV,QAAQ;AAAA,MACV,CAAC;AACD,YAAM,cAAc,MAAM,QAAQ,IAAI,WAAW,EAAE,QAAQ,CAAC;AAC5D,aAAO,YAAY,OAAO,CAAC,EAAE,KAAK,GAAG;AACrC,aAAO,MAAM,YAAY,KAAK,CAAC,EAAE,QAAQ,EAAE,YAAY,KAAK,CAAC;AAE7D,YAAM,WAAW,MAAM,QAAQ,KAAK,aAAa;AAAA,QAC/C;AAAA,QACA,MAAM,EAAE,WAAW,2CAA2C,WAAW,oBAAoB;AAAA,MAC/F,CAAC;AACD,aAAO,SAAS,OAAO,CAAC,EAAE,KAAK,GAAG;AAClC,YAAM,OAAQ,MAAM,aAAa,QAAQ;AACzC,aAAO,OAAO,KAAK,YAAY,EAAE,KAAK,QAAQ;AAE9C,YAAM,MAAM,IAAI,IAAI,KAAK,YAAsB;AAC/C,aAAO,IAAI,MAAM,EAAE,KAAK,mCAAmC;AAC3D,aAAO,IAAI,QAAQ,EAAE,KAAK,sCAAsC;AAChE,aAAO,IAAI,aAAa,IAAI,WAAW,CAAC,EAAE,KAAK,wBAAwB;AACvE,aAAO,IAAI,aAAa,IAAI,eAAe,CAAC,EAAE,KAAK,MAAM;AACzD,aAAO,IAAI,aAAa,IAAI,uBAAuB,CAAC,EAAE,KAAK,MAAM;AACjE,aAAO,IAAI,aAAa,IAAI,gBAAgB,KAAK,EAAE,EAAE,QAAQ,qBAAqB;AAClF,aAAO,IAAI,aAAa,IAAI,QAAQ,CAAC,EAAE,KAAK,gBAAgB;AAC5D,aAAO,IAAI,aAAa,IAAI,YAAY,CAAC,EAAE,KAAK,mBAAmB;AACnE,aAAO,IAAI,aAAa,IAAI,OAAO,KAAK,EAAE,EAAE,IAAI,KAAK,EAAE;AACvD,aAAO,IAAI,aAAa,IAAI,cAAc,KAAK,EAAE,EAAE,UAAU,kDAAkD;AAC/G,YAAM,QAAQ,IAAI,aAAa,IAAI,OAAO,KAAK;AAC/C,iBAAW,YAAY,CAAC,kBAAkB,UAAU,8CAA8C,yCAAyC,uCAAuC,GAAG;AACnL,eAAO,KAAK,EAAE,UAAU,QAAQ;AAAA,MAClC;AAEA,YAAM,YAAY,SAAS,QAAQ,EAAE,YAAY,KAAK;AACtD,aAAO,SAAS,EAAE,UAAU,UAAU;AAAA,IACxC,UAAE;AACA,YAAM,QAAQ,QAAQ;AAAA,IACxB;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,36 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { getAuthToken } from "@open-mercato/core/helpers/integration/authFixtures";
3
+ import { apiRequest } from "@open-mercato/core/helpers/integration/api";
4
+ const BASE_URL = process.env.BASE_URL?.trim() || "";
5
+ test.describe("TC-CHANNEL-MS365-004: OAuth callback state verification", () => {
6
+ test("GET /oauth/ms365/callback with a forged state redirects with oauth=error and creates no channel", async ({ request }) => {
7
+ const token = await getAuthToken(request);
8
+ const before = await apiRequest(request, "GET", "/api/communication_channels/me/channels", { token });
9
+ expect(before.status()).toBe(200);
10
+ const beforeBody = await before.json();
11
+ const countBefore = (beforeBody.items ?? beforeBody.channels ?? []).length;
12
+ const response = await request.get(
13
+ `${BASE_URL}/api/communication_channels/oauth/ms365/callback?code=forged-code&state=forged-state`,
14
+ { headers: { Authorization: `Bearer ${token}` }, maxRedirects: 0 }
15
+ );
16
+ expect(response.status()).toBe(302);
17
+ const location = response.headers()["location"] ?? "";
18
+ expect(location).toContain("/backend/profile/communication-channels");
19
+ expect(location).toContain("oauth=error");
20
+ expect(location).toContain("provider=ms365");
21
+ expect(location).not.toContain("oauth=connected");
22
+ const after = await apiRequest(request, "GET", "/api/communication_channels/me/channels", { token });
23
+ const afterBody = await after.json();
24
+ expect((afterBody.items ?? afterBody.channels ?? []).length).toBe(countBefore);
25
+ });
26
+ test("GET /oauth/ms365/callback without code or state redirects with missing_code_or_state", async ({ request }) => {
27
+ const token = await getAuthToken(request);
28
+ const response = await request.get(`${BASE_URL}/api/communication_channels/oauth/ms365/callback`, {
29
+ headers: { Authorization: `Bearer ${token}` },
30
+ maxRedirects: 0
31
+ });
32
+ expect(response.status()).toBe(302);
33
+ expect(response.headers()["location"] ?? "").toContain("code=missing_code_or_state");
34
+ });
35
+ });
36
+ //# sourceMappingURL=TC-CHANNEL-MS365-004.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-004.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { getAuthToken } from '@open-mercato/core/helpers/integration/authFixtures'\nimport { apiRequest } from '@open-mercato/core/helpers/integration/api'\n\nconst BASE_URL = process.env.BASE_URL?.trim() || ''\n\n/**\n * TC-CHANNEL-MS365-004 \u2014 OAuth callback rejects a tampered / missing state.\n *\n * The hub binds the callback to the signed state cookie minted at initiate\n * time. A callback that arrives without that cookie (or with a `state` that\n * does not match it) MUST bounce back to the profile page with an error flash\n * and MUST NOT create a channel \u2014 the code is never exchanged.\n */\ntest.describe('TC-CHANNEL-MS365-004: OAuth callback state verification', () => {\n test('GET /oauth/ms365/callback with a forged state redirects with oauth=error and creates no channel', async ({ request }) => {\n const token = await getAuthToken(request)\n\n const before = await apiRequest(request, 'GET', '/api/communication_channels/me/channels', { token })\n expect(before.status()).toBe(200)\n const beforeBody = (await before.json()) as { items?: unknown[]; channels?: unknown[] }\n const countBefore = (beforeBody.items ?? beforeBody.channels ?? []).length\n\n const response = await request.get(\n `${BASE_URL}/api/communication_channels/oauth/ms365/callback?code=forged-code&state=forged-state`,\n { headers: { Authorization: `Bearer ${token}` }, maxRedirects: 0 },\n )\n expect(response.status()).toBe(302)\n const location = response.headers()['location'] ?? ''\n expect(location).toContain('/backend/profile/communication-channels')\n expect(location).toContain('oauth=error')\n expect(location).toContain('provider=ms365')\n expect(location).not.toContain('oauth=connected')\n\n const after = await apiRequest(request, 'GET', '/api/communication_channels/me/channels', { token })\n const afterBody = (await after.json()) as { items?: unknown[]; channels?: unknown[] }\n expect((afterBody.items ?? afterBody.channels ?? []).length).toBe(countBefore)\n })\n\n test('GET /oauth/ms365/callback without code or state redirects with missing_code_or_state', async ({ request }) => {\n const token = await getAuthToken(request)\n const response = await request.get(`${BASE_URL}/api/communication_channels/oauth/ms365/callback`, {\n headers: { Authorization: `Bearer ${token}` },\n maxRedirects: 0,\n })\n expect(response.status()).toBe(302)\n expect(response.headers()['location'] ?? '').toContain('code=missing_code_or_state')\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAE3B,MAAM,WAAW,QAAQ,IAAI,UAAU,KAAK,KAAK;AAUjD,KAAK,SAAS,2DAA2D,MAAM;AAC7E,OAAK,mGAAmG,OAAO,EAAE,QAAQ,MAAM;AAC7H,UAAM,QAAQ,MAAM,aAAa,OAAO;AAExC,UAAM,SAAS,MAAM,WAAW,SAAS,OAAO,2CAA2C,EAAE,MAAM,CAAC;AACpG,WAAO,OAAO,OAAO,CAAC,EAAE,KAAK,GAAG;AAChC,UAAM,aAAc,MAAM,OAAO,KAAK;AACtC,UAAM,eAAe,WAAW,SAAS,WAAW,YAAY,CAAC,GAAG;AAEpE,UAAM,WAAW,MAAM,QAAQ;AAAA,MAC7B,GAAG,QAAQ;AAAA,MACX,EAAE,SAAS,EAAE,eAAe,UAAU,KAAK,GAAG,GAAG,cAAc,EAAE;AAAA,IACnE;AACA,WAAO,SAAS,OAAO,CAAC,EAAE,KAAK,GAAG;AAClC,UAAM,WAAW,SAAS,QAAQ,EAAE,UAAU,KAAK;AACnD,WAAO,QAAQ,EAAE,UAAU,yCAAyC;AACpE,WAAO,QAAQ,EAAE,UAAU,aAAa;AACxC,WAAO,QAAQ,EAAE,UAAU,gBAAgB;AAC3C,WAAO,QAAQ,EAAE,IAAI,UAAU,iBAAiB;AAEhD,UAAM,QAAQ,MAAM,WAAW,SAAS,OAAO,2CAA2C,EAAE,MAAM,CAAC;AACnG,UAAM,YAAa,MAAM,MAAM,KAAK;AACpC,YAAQ,UAAU,SAAS,UAAU,YAAY,CAAC,GAAG,MAAM,EAAE,KAAK,WAAW;AAAA,EAC/E,CAAC;AAED,OAAK,wFAAwF,OAAO,EAAE,QAAQ,MAAM;AAClH,UAAM,QAAQ,MAAM,aAAa,OAAO;AACxC,UAAM,WAAW,MAAM,QAAQ,IAAI,GAAG,QAAQ,oDAAoD;AAAA,MAChG,SAAS,EAAE,eAAe,UAAU,KAAK,GAAG;AAAA,MAC5C,cAAc;AAAA,IAChB,CAAC;AACD,WAAO,SAAS,OAAO,CAAC,EAAE,KAAK,GAAG;AAClC,WAAO,SAAS,QAAQ,EAAE,UAAU,KAAK,EAAE,EAAE,UAAU,4BAA4B;AAAA,EACrF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { login } from "@open-mercato/core/helpers/integration/auth";
3
+ const CONNECT_MENU_TRIGGER = /Connect channel|Połącz kanał|Kanal verbinden|Conectar canal|채널 연결/;
4
+ const CONNECT_MS365_BUTTON = /Connect Microsoft 365|Połącz Microsoft 365|Microsoft 365 verbinden|Conectar Microsoft 365|Microsoft 365 연결/;
5
+ const PERSONAL_CHANNELS = "/backend/profile/communication-channels";
6
+ const STATUS_ROUTE = "**/api/communication_channels/oauth/ms365/status";
7
+ const SETUP_DETAIL = "/backend/integrations/channel_ms365";
8
+ test.describe("TC-CHANNEL-MS365-005: Connect Microsoft 365 button on the profile page", () => {
9
+ for (const role of ["admin", "employee"]) {
10
+ test(`${role} sees the Connect Microsoft 365 button, enabled once the workspace is set up`, async ({ page }) => {
11
+ let configured = false;
12
+ await page.route(STATUS_ROUTE, (route) => route.fulfill({ json: { configured } }));
13
+ await login(page, role);
14
+ const openConnectMenu = async () => {
15
+ await page.goto(PERSONAL_CHANNELS);
16
+ const trigger = page.getByRole("button", { name: CONNECT_MENU_TRIGGER });
17
+ await expect(trigger).toBeVisible({ timeout: 3e4 });
18
+ await trigger.click();
19
+ };
20
+ await openConnectMenu();
21
+ const button = page.getByRole("button", { name: CONNECT_MS365_BUTTON });
22
+ await expect(button).toBeVisible({ timeout: 3e4 });
23
+ await expect(button).toBeDisabled();
24
+ const hint = page.locator(`[id="${await button.getAttribute("aria-describedby")}"]`);
25
+ await expect(hint.getByRole("status")).toHaveCount(0);
26
+ if (role === "admin") {
27
+ await expect(hint.getByRole("link")).toHaveAttribute("href", SETUP_DETAIL);
28
+ } else {
29
+ await expect(hint).toBeVisible();
30
+ await expect(hint.getByRole("link")).toHaveCount(0);
31
+ }
32
+ configured = true;
33
+ await openConnectMenu();
34
+ await expect(button).toBeEnabled();
35
+ });
36
+ }
37
+ });
38
+ //# sourceMappingURL=TC-CHANNEL-MS365-005.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-005.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { login } from '@open-mercato/core/helpers/integration/auth'\n\n/**\n * TC-CHANNEL-MS365-005 \u2014 \"Connect Microsoft 365\" is injected into the profile channels page.\n *\n * The provider package injects its connect button into the\n * `profile:communication-channels:connect` widget spot, gated by\n * `communication_channels.connect_user_channel`. Both default roles that carry\n * that feature (admin, employee) must find the button next to the Gmail / IMAP ones.\n *\n * Since #5735 the spot renders inside the page's \"Connect channel\" disclosure:\n * the panel stays mounted but hidden until the trigger is clicked, so the test\n * opens it first and then asserts on the provider button.\n *\n * Since #10365 the button checks the workspace OAuth setup first: it stays\n * disabled with a setup hint until Microsoft 365 credentials are saved. The\n * status route is stubbed so both states are covered without real credentials;\n * the hint is located through the button's `aria-describedby`, because the\n * Gmail button renders the same hint text.\n */\nconst CONNECT_MENU_TRIGGER = /Connect channel|Po\u0142\u0105cz kana\u0142|Kanal verbinden|Conectar canal|\uCC44\uB110 \uC5F0\uACB0/\nconst CONNECT_MS365_BUTTON = /Connect Microsoft 365|Po\u0142\u0105cz Microsoft 365|Microsoft 365 verbinden|Conectar Microsoft 365|Microsoft 365 \uC5F0\uACB0/\nconst PERSONAL_CHANNELS = '/backend/profile/communication-channels'\nconst STATUS_ROUTE = '**/api/communication_channels/oauth/ms365/status'\nconst SETUP_DETAIL = '/backend/integrations/channel_ms365'\n\ntest.describe('TC-CHANNEL-MS365-005: Connect Microsoft 365 button on the profile page', () => {\n for (const role of ['admin', 'employee'] as const) {\n test(`${role} sees the Connect Microsoft 365 button, enabled once the workspace is set up`, async ({ page }) => {\n let configured = false\n await page.route(STATUS_ROUTE, (route) => route.fulfill({ json: { configured } }))\n await login(page, role)\n\n const openConnectMenu = async () => {\n await page.goto(PERSONAL_CHANNELS)\n const trigger = page.getByRole('button', { name: CONNECT_MENU_TRIGGER })\n await expect(trigger).toBeVisible({ timeout: 30_000 })\n await trigger.click()\n }\n\n await openConnectMenu()\n const button = page.getByRole('button', { name: CONNECT_MS365_BUTTON })\n await expect(button).toBeVisible({ timeout: 30_000 })\n await expect(button).toBeDisabled()\n const hint = page.locator(`[id=\"${await button.getAttribute('aria-describedby')}\"]`)\n await expect(hint.getByRole('status')).toHaveCount(0)\n if (role === 'admin') {\n await expect(hint.getByRole('link')).toHaveAttribute('href', SETUP_DETAIL)\n } else {\n await expect(hint).toBeVisible()\n await expect(hint.getByRole('link')).toHaveCount(0)\n }\n\n configured = true\n await openConnectMenu()\n await expect(button).toBeEnabled()\n })\n }\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,aAAa;AAoBtB,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAe;AAErB,KAAK,SAAS,0EAA0E,MAAM;AAC5F,aAAW,QAAQ,CAAC,SAAS,UAAU,GAAY;AACjD,SAAK,GAAG,IAAI,gFAAgF,OAAO,EAAE,KAAK,MAAM;AAC9G,UAAI,aAAa;AACjB,YAAM,KAAK,MAAM,cAAc,CAAC,UAAU,MAAM,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AACjF,YAAM,MAAM,MAAM,IAAI;AAEtB,YAAM,kBAAkB,YAAY;AAClC,cAAM,KAAK,KAAK,iBAAiB;AACjC,cAAM,UAAU,KAAK,UAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvE,cAAM,OAAO,OAAO,EAAE,YAAY,EAAE,SAAS,IAAO,CAAC;AACrD,cAAM,QAAQ,MAAM;AAAA,MACtB;AAEA,YAAM,gBAAgB;AACtB,YAAM,SAAS,KAAK,UAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,YAAM,OAAO,MAAM,EAAE,YAAY,EAAE,SAAS,IAAO,CAAC;AACpD,YAAM,OAAO,MAAM,EAAE,aAAa;AAClC,YAAM,OAAO,KAAK,QAAQ,QAAQ,MAAM,OAAO,aAAa,kBAAkB,CAAC,IAAI;AACnF,YAAM,OAAO,KAAK,UAAU,QAAQ,CAAC,EAAE,YAAY,CAAC;AACpD,UAAI,SAAS,SAAS;AACpB,cAAM,OAAO,KAAK,UAAU,MAAM,CAAC,EAAE,gBAAgB,QAAQ,YAAY;AAAA,MAC3E,OAAO;AACL,cAAM,OAAO,IAAI,EAAE,YAAY;AAC/B,cAAM,OAAO,KAAK,UAAU,MAAM,CAAC,EAAE,YAAY,CAAC;AAAA,MACpD;AAEA,mBAAa;AACb,YAAM,gBAAgB;AACtB,YAAM,OAAO,MAAM,EAAE,YAAY;AAAA,IACnC,CAAC;AAAA,EACH;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ import { expect, test } from "@playwright/test";
2
+ import { login } from "@open-mercato/core/helpers/integration/auth";
3
+ import { getAuthToken } from "@open-mercato/core/helpers/integration/authFixtures";
4
+ import { apiRequest } from "@open-mercato/core/helpers/integration/api";
5
+ import { readJsonSafe } from "@open-mercato/core/helpers/integration/generalFixtures";
6
+ test.describe("TC-CHANNEL-MS365-006: Microsoft 365 integration card", () => {
7
+ test("GET /api/integrations/channel_ms365 exposes the tenant credential fields", async ({ request }) => {
8
+ const token = await getAuthToken(request);
9
+ const response = await apiRequest(request, "GET", "/api/integrations/channel_ms365", { token });
10
+ expect(response.status()).toBe(200);
11
+ const body = await readJsonSafe(response);
12
+ const serialized = JSON.stringify(body);
13
+ for (const key of ["clientId", "clientSecret", "tenantId", "scopes"]) {
14
+ expect(serialized, `credential field ${key} should be declared`).toContain(`"${key}"`);
15
+ }
16
+ expect(serialized).toContain('"ms365"');
17
+ expect(serialized).toContain("communication_channels");
18
+ });
19
+ test("the Integrations page lists Microsoft 365", async ({ page }) => {
20
+ await login(page, "admin");
21
+ await page.goto("/backend/integrations");
22
+ await expect(page.getByText("Microsoft 365", { exact: false }).first()).toBeVisible({ timeout: 3e4 });
23
+ });
24
+ });
25
+ //# sourceMappingURL=TC-CHANNEL-MS365-006.spec.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/TC-CHANNEL-MS365-006.spec.ts"],
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { login } from '@open-mercato/core/helpers/integration/auth'\nimport { getAuthToken } from '@open-mercato/core/helpers/integration/authFixtures'\nimport { apiRequest } from '@open-mercato/core/helpers/integration/api'\nimport { readJsonSafe } from '@open-mercato/core/helpers/integration/generalFixtures'\n\ntype JsonRecord = Record<string, unknown>\n\n/**\n * TC-CHANNEL-MS365-006 \u2014 Microsoft 365 appears in Integrations with its credential fields.\n *\n * The provider registers an `IntegrationDefinition` (`channel_ms365`) in the\n * communication category. The detail API must expose the four tenant credential\n * fields (client id, client secret, tenant id, scopes) and the Integrations\n * page must list the provider so an admin can find it.\n */\ntest.describe('TC-CHANNEL-MS365-006: Microsoft 365 integration card', () => {\n test('GET /api/integrations/channel_ms365 exposes the tenant credential fields', async ({ request }) => {\n const token = await getAuthToken(request)\n const response = await apiRequest(request, 'GET', '/api/integrations/channel_ms365', { token })\n expect(response.status()).toBe(200)\n const body = (await readJsonSafe(response)) as JsonRecord\n const serialized = JSON.stringify(body)\n for (const key of ['clientId', 'clientSecret', 'tenantId', 'scopes']) {\n expect(serialized, `credential field ${key} should be declared`).toContain(`\"${key}\"`)\n }\n expect(serialized).toContain('\"ms365\"')\n expect(serialized).toContain('communication_channels')\n })\n\n test('the Integrations page lists Microsoft 365', async ({ page }) => {\n await login(page, 'admin')\n await page.goto('/backend/integrations')\n await expect(page.getByText('Microsoft 365', { exact: false }).first()).toBeVisible({ timeout: 30_000 })\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAY7B,KAAK,SAAS,wDAAwD,MAAM;AAC1E,OAAK,4EAA4E,OAAO,EAAE,QAAQ,MAAM;AACtG,UAAM,QAAQ,MAAM,aAAa,OAAO;AACxC,UAAM,WAAW,MAAM,WAAW,SAAS,OAAO,mCAAmC,EAAE,MAAM,CAAC;AAC9F,WAAO,SAAS,OAAO,CAAC,EAAE,KAAK,GAAG;AAClC,UAAM,OAAQ,MAAM,aAAa,QAAQ;AACzC,UAAM,aAAa,KAAK,UAAU,IAAI;AACtC,eAAW,OAAO,CAAC,YAAY,gBAAgB,YAAY,QAAQ,GAAG;AACpE,aAAO,YAAY,oBAAoB,GAAG,qBAAqB,EAAE,UAAU,IAAI,GAAG,GAAG;AAAA,IACvF;AACA,WAAO,UAAU,EAAE,UAAU,SAAS;AACtC,WAAO,UAAU,EAAE,UAAU,wBAAwB;AAAA,EACvD,CAAC;AAED,OAAK,6CAA6C,OAAO,EAAE,KAAK,MAAM;AACpE,UAAM,MAAM,MAAM,OAAO;AACzB,UAAM,KAAK,KAAK,uBAAuB;AACvC,UAAM,OAAO,KAAK,UAAU,iBAAiB,EAAE,OAAO,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,SAAS,IAAO,CAAC;AAAA,EACzG,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,77 @@
1
+ import { randomInt } from "node:crypto";
2
+ import { expect } from "@playwright/test";
3
+ import { apiRequest } from "@open-mercato/core/helpers/integration/api";
4
+ import {
5
+ createOrganizationFixture,
6
+ createRoleFixture,
7
+ createUserFixture,
8
+ deleteOrganizationIfExists,
9
+ deleteRoleIfExists,
10
+ deleteUserIfExists,
11
+ getAuthToken,
12
+ setRoleAclFeatures
13
+ } from "@open-mercato/core/helpers/integration/authFixtures";
14
+ import { getTokenContext } from "@open-mercato/core/helpers/integration/generalFixtures";
15
+ const MS365_INTEGRATION_ID = "channel_ms365";
16
+ const PASSWORD = "Tc-Ms365-Fixture-1!";
17
+ async function createMs365Sandbox(request, label) {
18
+ const stamp = `${Date.now()}-${randomInt(1e4)}`;
19
+ const adminToken = await getAuthToken(request, "admin");
20
+ const { tenantId } = getTokenContext(adminToken);
21
+ let organizationId = null;
22
+ let roleId = null;
23
+ let userId = null;
24
+ const dispose = async () => {
25
+ await deleteUserIfExists(request, adminToken, userId);
26
+ await deleteRoleIfExists(request, adminToken, roleId);
27
+ await deleteOrganizationIfExists(request, adminToken, organizationId);
28
+ };
29
+ try {
30
+ organizationId = await createOrganizationFixture(request, adminToken, { name: `${label} ${stamp}`, tenantId });
31
+ roleId = await createRoleFixture(request, adminToken, { name: `${label} role ${stamp}`, tenantId });
32
+ await setRoleAclFeatures(request, adminToken, {
33
+ roleId,
34
+ features: [
35
+ "integrations.view",
36
+ "integrations.manage",
37
+ "integrations.credentials.manage",
38
+ "communication_channels.view",
39
+ "communication_channels.connect_user_channel"
40
+ ]
41
+ });
42
+ const email = `${label.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${stamp}@example.com`;
43
+ userId = await createUserFixture(request, adminToken, {
44
+ email,
45
+ password: PASSWORD,
46
+ organizationId,
47
+ roles: [roleId],
48
+ name: `${label} user`
49
+ });
50
+ const token = await getAuthToken(request, email, PASSWORD);
51
+ expect(getTokenContext(token).organizationId, "sandbox user is scoped to the sandbox organization").toBe(organizationId);
52
+ const saveClientCredentials = async (credentials) => {
53
+ const response = await apiRequest(request, "PUT", `/api/integrations/${MS365_INTEGRATION_ID}/credentials`, {
54
+ token,
55
+ data: { credentials }
56
+ });
57
+ expect(response.status(), "PUT sandbox credentials should succeed").toBe(200);
58
+ };
59
+ return {
60
+ token,
61
+ organizationId,
62
+ saveClientCredentials,
63
+ dispose: async () => {
64
+ await saveClientCredentials({ clientId: "", clientSecret: "", tenantId: "", scopes: "" }).catch(() => void 0);
65
+ await dispose();
66
+ }
67
+ };
68
+ } catch (error) {
69
+ await dispose();
70
+ throw error;
71
+ }
72
+ }
73
+ export {
74
+ MS365_INTEGRATION_ID,
75
+ createMs365Sandbox
76
+ };
77
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/channel_ms365/__integration__/fixtures.ts"],
4
+ "sourcesContent": ["import { randomInt } from 'node:crypto'\nimport type { APIRequestContext } from '@playwright/test'\nimport { expect } from '@playwright/test'\nimport { apiRequest } from '@open-mercato/core/helpers/integration/api'\nimport {\n createOrganizationFixture,\n createRoleFixture,\n createUserFixture,\n deleteOrganizationIfExists,\n deleteRoleIfExists,\n deleteUserIfExists,\n getAuthToken,\n setRoleAclFeatures,\n} from '@open-mercato/core/helpers/integration/authFixtures'\nimport { getTokenContext } from '@open-mercato/core/helpers/integration/generalFixtures'\n\nexport const MS365_INTEGRATION_ID = 'channel_ms365'\n/** Meets the default password policy (length, upper/lower case, digit, symbol). */\nconst PASSWORD = 'Tc-Ms365-Fixture-1!'\n\n/**\n * Isolated tenant-config sandbox for the Microsoft 365 provider specs.\n *\n * Tenant OAuth client credentials are stored per organization, so every spec\n * that needs them gets its own organization plus a user (with the integration\n * and connect features) scoped to it. Nothing in the shared default\n * organization is touched, and the sandbox is torn down in `dispose()`.\n */\nexport interface Ms365Sandbox {\n token: string\n organizationId: string\n saveClientCredentials: (credentials: Record<string, string>) => Promise<void>\n dispose: () => Promise<void>\n}\n\nexport async function createMs365Sandbox(request: APIRequestContext, label: string): Promise<Ms365Sandbox> {\n const stamp = `${Date.now()}-${randomInt(10_000)}`\n const adminToken = await getAuthToken(request, 'admin')\n const { tenantId } = getTokenContext(adminToken)\n\n let organizationId: string | null = null\n let roleId: string | null = null\n let userId: string | null = null\n const dispose = async () => {\n await deleteUserIfExists(request, adminToken, userId)\n await deleteRoleIfExists(request, adminToken, roleId)\n await deleteOrganizationIfExists(request, adminToken, organizationId)\n }\n\n try {\n organizationId = await createOrganizationFixture(request, adminToken, { name: `${label} ${stamp}`, tenantId })\n roleId = await createRoleFixture(request, adminToken, { name: `${label} role ${stamp}`, tenantId })\n await setRoleAclFeatures(request, adminToken, {\n roleId,\n features: [\n 'integrations.view',\n 'integrations.manage',\n 'integrations.credentials.manage',\n 'communication_channels.view',\n 'communication_channels.connect_user_channel',\n ],\n })\n const email = `${label.toLowerCase().replace(/[^a-z0-9]+/g, '-')}-${stamp}@example.com`\n userId = await createUserFixture(request, adminToken, {\n email,\n password: PASSWORD,\n organizationId,\n roles: [roleId],\n name: `${label} user`,\n })\n const token = await getAuthToken(request, email, PASSWORD)\n expect(getTokenContext(token).organizationId, 'sandbox user is scoped to the sandbox organization').toBe(organizationId)\n\n const saveClientCredentials = async (credentials: Record<string, string>) => {\n const response = await apiRequest(request, 'PUT', `/api/integrations/${MS365_INTEGRATION_ID}/credentials`, {\n token,\n data: { credentials },\n })\n expect(response.status(), 'PUT sandbox credentials should succeed').toBe(200)\n }\n\n return {\n token,\n organizationId,\n saveClientCredentials,\n dispose: async () => {\n // Clear the sandbox row before removing the organization so no\n // credential material outlives the fixture.\n await saveClientCredentials({ clientId: '', clientSecret: '', tenantId: '', scopes: '' }).catch(() => undefined)\n await dispose()\n },\n }\n } catch (error) {\n await dispose()\n throw error\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEzB,MAAM,uBAAuB;AAEpC,MAAM,WAAW;AAiBjB,eAAsB,mBAAmB,SAA4B,OAAsC;AACzG,QAAM,QAAQ,GAAG,KAAK,IAAI,CAAC,IAAI,UAAU,GAAM,CAAC;AAChD,QAAM,aAAa,MAAM,aAAa,SAAS,OAAO;AACtD,QAAM,EAAE,SAAS,IAAI,gBAAgB,UAAU;AAE/C,MAAI,iBAAgC;AACpC,MAAI,SAAwB;AAC5B,MAAI,SAAwB;AAC5B,QAAM,UAAU,YAAY;AAC1B,UAAM,mBAAmB,SAAS,YAAY,MAAM;AACpD,UAAM,mBAAmB,SAAS,YAAY,MAAM;AACpD,UAAM,2BAA2B,SAAS,YAAY,cAAc;AAAA,EACtE;AAEA,MAAI;AACF,qBAAiB,MAAM,0BAA0B,SAAS,YAAY,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,IAAI,SAAS,CAAC;AAC7G,aAAS,MAAM,kBAAkB,SAAS,YAAY,EAAE,MAAM,GAAG,KAAK,SAAS,KAAK,IAAI,SAAS,CAAC;AAClG,UAAM,mBAAmB,SAAS,YAAY;AAAA,MAC5C;AAAA,MACA,UAAU;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AACD,UAAM,QAAQ,GAAG,MAAM,YAAY,EAAE,QAAQ,eAAe,GAAG,CAAC,IAAI,KAAK;AACzE,aAAS,MAAM,kBAAkB,SAAS,YAAY;AAAA,MACpD;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,OAAO,CAAC,MAAM;AAAA,MACd,MAAM,GAAG,KAAK;AAAA,IAChB,CAAC;AACD,UAAM,QAAQ,MAAM,aAAa,SAAS,OAAO,QAAQ;AACzD,WAAO,gBAAgB,KAAK,EAAE,gBAAgB,oDAAoD,EAAE,KAAK,cAAc;AAEvH,UAAM,wBAAwB,OAAO,gBAAwC;AAC3E,YAAM,WAAW,MAAM,WAAW,SAAS,OAAO,qBAAqB,oBAAoB,gBAAgB;AAAA,QACzG;AAAA,QACA,MAAM,EAAE,YAAY;AAAA,MACtB,CAAC;AACD,aAAO,SAAS,OAAO,GAAG,wCAAwC,EAAE,KAAK,GAAG;AAAA,IAC9E;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,YAAY;AAGnB,cAAM,sBAAsB,EAAE,UAAU,IAAI,cAAc,IAAI,UAAU,IAAI,QAAQ,GAAG,CAAC,EAAE,MAAM,MAAM,MAAS;AAC/G,cAAM,QAAQ;AAAA,MAChB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ const features = [
2
+ { id: "channel_ms365.view", title: "View Microsoft 365 channel configuration", module: "channel_ms365" },
3
+ { id: "channel_ms365.configure", title: "Configure Microsoft 365 OAuth defaults", module: "channel_ms365" }
4
+ ];
5
+ var acl_default = features;
6
+ export {
7
+ acl_default as default,
8
+ features
9
+ };
10
+ //# sourceMappingURL=acl.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/modules/channel_ms365/acl.ts"],
4
+ "sourcesContent": ["export const features = [\n { id: 'channel_ms365.view', title: 'View Microsoft 365 channel configuration', module: 'channel_ms365' },\n { id: 'channel_ms365.configure', title: 'Configure Microsoft 365 OAuth defaults', module: 'channel_ms365' },\n]\n\nexport default features\n"],
5
+ "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,EAAE,IAAI,sBAAsB,OAAO,4CAA4C,QAAQ,gBAAgB;AAAA,EACvG,EAAE,IAAI,2BAA2B,OAAO,0CAA0C,QAAQ,gBAAgB;AAC5G;AAEA,IAAO,cAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,23 @@
1
+ import { asValue } from "awilix";
2
+ import {
3
+ hasChannelAdapter,
4
+ registerChannelAdapter
5
+ } from "@open-mercato/core/modules/communication_channels/lib/adapter-registry-singleton";
6
+ import { getMs365ChannelAdapter } from "./lib/adapter.js";
7
+ import { channelMs365HealthCheck } from "./lib/health.js";
8
+ function register(container) {
9
+ if (!hasChannelAdapter("ms365")) {
10
+ registerChannelAdapter(getMs365ChannelAdapter());
11
+ }
12
+ container.register({
13
+ channelMs365Adapter: asValue(getMs365ChannelAdapter()),
14
+ // Registered under the exact service name declared in `integration.ts`
15
+ // (`healthCheck.service`). Without this, the hub's `container.resolve(...)`
16
+ // throws and the integration reports permanently 'unhealthy'.
17
+ channelMs365HealthCheck: asValue(channelMs365HealthCheck)
18
+ });
19
+ }
20
+ export {
21
+ register
22
+ };
23
+ //# sourceMappingURL=di.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/modules/channel_ms365/di.ts"],
4
+ "sourcesContent": ["import { asValue } from 'awilix'\nimport type { AppContainer } from '@open-mercato/shared/lib/di/container'\nimport {\n hasChannelAdapter,\n registerChannelAdapter,\n} from '@open-mercato/core/modules/communication_channels/lib/adapter-registry-singleton'\nimport { getMs365ChannelAdapter } from './lib/adapter'\nimport { channelMs365HealthCheck } from './lib/health'\n\nexport function register(container: AppContainer): void {\n if (!hasChannelAdapter('ms365')) {\n registerChannelAdapter(getMs365ChannelAdapter())\n }\n container.register({\n channelMs365Adapter: asValue(getMs365ChannelAdapter()),\n // Registered under the exact service name declared in `integration.ts`\n // (`healthCheck.service`). Without this, the hub's `container.resolve(...)`\n // throws and the integration reports permanently 'unhealthy'.\n channelMs365HealthCheck: asValue(channelMs365HealthCheck),\n })\n}\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AAExB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AAEjC,SAAS,SAAS,WAA+B;AACtD,MAAI,CAAC,kBAAkB,OAAO,GAAG;AAC/B,2BAAuB,uBAAuB,CAAC;AAAA,EACjD;AACA,YAAU,SAAS;AAAA,IACjB,qBAAqB,QAAQ,uBAAuB,CAAC;AAAA;AAAA;AAAA;AAAA,IAIrD,yBAAyB,QAAQ,uBAAuB;AAAA,EAC1D,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ const metadata = {
2
+ id: "channel_ms365",
3
+ requires: ["communication_channels", "integrations"],
4
+ title: "Microsoft 365 Email Channel",
5
+ description: "Connect per-user Microsoft 365 / Exchange Online mailboxes via Entra ID OAuth2. Outbound and inbound go through Microsoft Graph (Inbox delta polling). Pairs with the Communications Hub."
6
+ };
7
+ export {
8
+ metadata
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/modules/channel_ms365/index.ts"],
4
+ "sourcesContent": ["export const metadata = {\n id: 'channel_ms365',\n requires: ['communication_channels', 'integrations'],\n title: 'Microsoft 365 Email Channel',\n description:\n 'Connect per-user Microsoft 365 / Exchange Online mailboxes via Entra ID OAuth2. Outbound and inbound go through Microsoft Graph (Inbox delta polling). Pairs with the Communications Hub.',\n}\n"],
5
+ "mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,IAAI;AAAA,EACJ,UAAU,CAAC,0BAA0B,cAAc;AAAA,EACnD,OAAO;AAAA,EACP,aACE;AACJ;",
6
+ "names": []
7
+ }