@jbctechsolutions/mcp-office365 2.5.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/LICENSE +21 -0
- package/README.md +667 -0
- package/dist/applescript/account-repository.d.ts +30 -0
- package/dist/applescript/account-repository.d.ts.map +1 -0
- package/dist/applescript/account-repository.js +38 -0
- package/dist/applescript/account-repository.js.map +1 -0
- package/dist/applescript/account-scripts.d.ts +21 -0
- package/dist/applescript/account-scripts.d.ts.map +1 -0
- package/dist/applescript/account-scripts.js +180 -0
- package/dist/applescript/account-scripts.js.map +1 -0
- package/dist/applescript/calendar-manager.d.ts +44 -0
- package/dist/applescript/calendar-manager.d.ts.map +1 -0
- package/dist/applescript/calendar-manager.js +92 -0
- package/dist/applescript/calendar-manager.js.map +1 -0
- package/dist/applescript/calendar-writer.d.ts +36 -0
- package/dist/applescript/calendar-writer.d.ts.map +1 -0
- package/dist/applescript/calendar-writer.js +94 -0
- package/dist/applescript/calendar-writer.js.map +1 -0
- package/dist/applescript/content-readers.d.ts +114 -0
- package/dist/applescript/content-readers.d.ts.map +1 -0
- package/dist/applescript/content-readers.js +328 -0
- package/dist/applescript/content-readers.js.map +1 -0
- package/dist/applescript/executor.d.ts +60 -0
- package/dist/applescript/executor.d.ts.map +1 -0
- package/dist/applescript/executor.js +173 -0
- package/dist/applescript/executor.js.map +1 -0
- package/dist/applescript/index.d.ts +20 -0
- package/dist/applescript/index.d.ts.map +1 -0
- package/dist/applescript/index.js +29 -0
- package/dist/applescript/index.js.map +1 -0
- package/dist/applescript/mail-sender.d.ts +38 -0
- package/dist/applescript/mail-sender.d.ts.map +1 -0
- package/dist/applescript/mail-sender.js +67 -0
- package/dist/applescript/mail-sender.js.map +1 -0
- package/dist/applescript/parser.d.ts +235 -0
- package/dist/applescript/parser.d.ts.map +1 -0
- package/dist/applescript/parser.js +496 -0
- package/dist/applescript/parser.js.map +1 -0
- package/dist/applescript/repository.d.ts +64 -0
- package/dist/applescript/repository.d.ts.map +1 -0
- package/dist/applescript/repository.js +444 -0
- package/dist/applescript/repository.js.map +1 -0
- package/dist/applescript/scripts.d.ts +265 -0
- package/dist/applescript/scripts.d.ts.map +1 -0
- package/dist/applescript/scripts.js +1483 -0
- package/dist/applescript/scripts.js.map +1 -0
- package/dist/approval/hash.d.ts +87 -0
- package/dist/approval/hash.d.ts.map +1 -0
- package/dist/approval/hash.js +102 -0
- package/dist/approval/hash.js.map +1 -0
- package/dist/approval/index.d.ts +13 -0
- package/dist/approval/index.d.ts.map +1 -0
- package/dist/approval/index.js +7 -0
- package/dist/approval/index.js.map +1 -0
- package/dist/approval/token-manager.d.ts +51 -0
- package/dist/approval/token-manager.d.ts.map +1 -0
- package/dist/approval/token-manager.js +111 -0
- package/dist/approval/token-manager.js.map +1 -0
- package/dist/approval/types.d.ts +44 -0
- package/dist/approval/types.d.ts.map +1 -0
- package/dist/approval/types.js +6 -0
- package/dist/approval/types.js.map +1 -0
- package/dist/cli.d.ts +30 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +143 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/database/connection.d.ts +77 -0
- package/dist/database/connection.d.ts.map +1 -0
- package/dist/database/connection.js +130 -0
- package/dist/database/connection.js.map +1 -0
- package/dist/database/index.d.ts +11 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +11 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/queries.d.ts +93 -0
- package/dist/database/queries.d.ts.map +1 -0
- package/dist/database/queries.js +430 -0
- package/dist/database/queries.js.map +1 -0
- package/dist/database/repository.d.ts +198 -0
- package/dist/database/repository.d.ts.map +1 -0
- package/dist/database/repository.js +199 -0
- package/dist/database/repository.js.map +1 -0
- package/dist/graph/attachments.d.ts +72 -0
- package/dist/graph/attachments.d.ts.map +1 -0
- package/dist/graph/attachments.js +207 -0
- package/dist/graph/attachments.js.map +1 -0
- package/dist/graph/auth/config.d.ts +34 -0
- package/dist/graph/auth/config.d.ts.map +1 -0
- package/dist/graph/auth/config.js +78 -0
- package/dist/graph/auth/config.js.map +1 -0
- package/dist/graph/auth/device-code-flow.d.ts +55 -0
- package/dist/graph/auth/device-code-flow.d.ts.map +1 -0
- package/dist/graph/auth/device-code-flow.js +180 -0
- package/dist/graph/auth/device-code-flow.js.map +1 -0
- package/dist/graph/auth/index.d.ts +13 -0
- package/dist/graph/auth/index.d.ts.map +1 -0
- package/dist/graph/auth/index.js +13 -0
- package/dist/graph/auth/index.js.map +1 -0
- package/dist/graph/auth/token-cache.d.ts +41 -0
- package/dist/graph/auth/token-cache.d.ts.map +1 -0
- package/dist/graph/auth/token-cache.js +105 -0
- package/dist/graph/auth/token-cache.js.map +1 -0
- package/dist/graph/client/batch.d.ts +38 -0
- package/dist/graph/client/batch.d.ts.map +1 -0
- package/dist/graph/client/batch.js +33 -0
- package/dist/graph/client/batch.js.map +1 -0
- package/dist/graph/client/cache.d.ts +64 -0
- package/dist/graph/client/cache.d.ts.map +1 -0
- package/dist/graph/client/cache.js +108 -0
- package/dist/graph/client/cache.js.map +1 -0
- package/dist/graph/client/graph-client.d.ts +630 -0
- package/dist/graph/client/graph-client.d.ts.map +1 -0
- package/dist/graph/client/graph-client.js +1771 -0
- package/dist/graph/client/graph-client.js.map +1 -0
- package/dist/graph/client/index.d.ts +12 -0
- package/dist/graph/client/index.d.ts.map +1 -0
- package/dist/graph/client/index.js +12 -0
- package/dist/graph/client/index.js.map +1 -0
- package/dist/graph/content-readers.d.ts +106 -0
- package/dist/graph/content-readers.d.ts.map +1 -0
- package/dist/graph/content-readers.js +321 -0
- package/dist/graph/content-readers.js.map +1 -0
- package/dist/graph/index.d.ts +18 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +23 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/mailbox-adapter.d.ts +30 -0
- package/dist/graph/mailbox-adapter.d.ts.map +1 -0
- package/dist/graph/mailbox-adapter.js +59 -0
- package/dist/graph/mailbox-adapter.js.map +1 -0
- package/dist/graph/mappers/contact-mapper.d.ts +14 -0
- package/dist/graph/mappers/contact-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/contact-mapper.js +20 -0
- package/dist/graph/mappers/contact-mapper.js.map +1 -0
- package/dist/graph/mappers/email-mapper.d.ts +14 -0
- package/dist/graph/mappers/email-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/email-mapper.js +44 -0
- package/dist/graph/mappers/email-mapper.js.map +1 -0
- package/dist/graph/mappers/event-mapper.d.ts +14 -0
- package/dist/graph/mappers/event-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/event-mapper.js +31 -0
- package/dist/graph/mappers/event-mapper.js.map +1 -0
- package/dist/graph/mappers/folder-mapper.d.ts +22 -0
- package/dist/graph/mappers/folder-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/folder-mapper.js +51 -0
- package/dist/graph/mappers/folder-mapper.js.map +1 -0
- package/dist/graph/mappers/index.d.ts +16 -0
- package/dist/graph/mappers/index.d.ts.map +1 -0
- package/dist/graph/mappers/index.js +16 -0
- package/dist/graph/mappers/index.js.map +1 -0
- package/dist/graph/mappers/task-mapper.d.ts +20 -0
- package/dist/graph/mappers/task-mapper.d.ts.map +1 -0
- package/dist/graph/mappers/task-mapper.js +27 -0
- package/dist/graph/mappers/task-mapper.js.map +1 -0
- package/dist/graph/mappers/utils.d.ts +97 -0
- package/dist/graph/mappers/utils.d.ts.map +1 -0
- package/dist/graph/mappers/utils.js +186 -0
- package/dist/graph/mappers/utils.js.map +1 -0
- package/dist/graph/repository.d.ts +1104 -0
- package/dist/graph/repository.d.ts.map +1 -0
- package/dist/graph/repository.js +2999 -0
- package/dist/graph/repository.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6052 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/html-stripper.d.ts +41 -0
- package/dist/parsers/html-stripper.d.ts.map +1 -0
- package/dist/parsers/html-stripper.js +179 -0
- package/dist/parsers/html-stripper.js.map +1 -0
- package/dist/parsers/index.d.ts +12 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +12 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/olk15.d.ts +87 -0
- package/dist/parsers/olk15.d.ts.map +1 -0
- package/dist/parsers/olk15.js +368 -0
- package/dist/parsers/olk15.js.map +1 -0
- package/dist/signature.d.ts +22 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/signature.js +89 -0
- package/dist/signature.js.map +1 -0
- package/dist/tools/calendar-permissions.d.ts +79 -0
- package/dist/tools/calendar-permissions.d.ts.map +1 -0
- package/dist/tools/calendar-permissions.js +121 -0
- package/dist/tools/calendar-permissions.js.map +1 -0
- package/dist/tools/calendar.d.ts +208 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +247 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/categories.d.ts +94 -0
- package/dist/tools/categories.d.ts.map +1 -0
- package/dist/tools/categories.js +117 -0
- package/dist/tools/categories.js.map +1 -0
- package/dist/tools/checklist-items.d.ts +89 -0
- package/dist/tools/checklist-items.d.ts.map +1 -0
- package/dist/tools/checklist-items.js +140 -0
- package/dist/tools/checklist-items.js.map +1 -0
- package/dist/tools/contacts.d.ts +94 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +134 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/excel.d.ts +96 -0
- package/dist/tools/excel.d.ts.map +1 -0
- package/dist/tools/excel.js +165 -0
- package/dist/tools/excel.js.map +1 -0
- package/dist/tools/focused-overrides.d.ts +70 -0
- package/dist/tools/focused-overrides.d.ts.map +1 -0
- package/dist/tools/focused-overrides.js +117 -0
- package/dist/tools/focused-overrides.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +34 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/linked-resources.d.ts +74 -0
- package/dist/tools/linked-resources.d.ts.map +1 -0
- package/dist/tools/linked-resources.js +122 -0
- package/dist/tools/linked-resources.js.map +1 -0
- package/dist/tools/mail-rules.d.ts +98 -0
- package/dist/tools/mail-rules.d.ts.map +1 -0
- package/dist/tools/mail-rules.js +169 -0
- package/dist/tools/mail-rules.js.map +1 -0
- package/dist/tools/mail-send.d.ts +314 -0
- package/dist/tools/mail-send.d.ts.map +1 -0
- package/dist/tools/mail-send.js +555 -0
- package/dist/tools/mail-send.js.map +1 -0
- package/dist/tools/mail.d.ts +127 -0
- package/dist/tools/mail.d.ts.map +1 -0
- package/dist/tools/mail.js +311 -0
- package/dist/tools/mail.js.map +1 -0
- package/dist/tools/mailbox-organization.d.ts +301 -0
- package/dist/tools/mailbox-organization.d.ts.map +1 -0
- package/dist/tools/mailbox-organization.js +541 -0
- package/dist/tools/mailbox-organization.js.map +1 -0
- package/dist/tools/meetings.d.ts +114 -0
- package/dist/tools/meetings.d.ts.map +1 -0
- package/dist/tools/meetings.js +110 -0
- package/dist/tools/meetings.js.map +1 -0
- package/dist/tools/notes.d.ts +74 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +136 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/onedrive.d.ts +194 -0
- package/dist/tools/onedrive.d.ts.map +1 -0
- package/dist/tools/onedrive.js +257 -0
- package/dist/tools/onedrive.js.map +1 -0
- package/dist/tools/people.d.ts +129 -0
- package/dist/tools/people.d.ts.map +1 -0
- package/dist/tools/people.js +195 -0
- package/dist/tools/people.js.map +1 -0
- package/dist/tools/planner-visualization.d.ts +91 -0
- package/dist/tools/planner-visualization.d.ts.map +1 -0
- package/dist/tools/planner-visualization.js +192 -0
- package/dist/tools/planner-visualization.js.map +1 -0
- package/dist/tools/planner.d.ts +288 -0
- package/dist/tools/planner.d.ts.map +1 -0
- package/dist/tools/planner.js +368 -0
- package/dist/tools/planner.js.map +1 -0
- package/dist/tools/scheduling.d.ts +49 -0
- package/dist/tools/scheduling.d.ts.map +1 -0
- package/dist/tools/scheduling.js +115 -0
- package/dist/tools/scheduling.js.map +1 -0
- package/dist/tools/sharepoint.d.ts +115 -0
- package/dist/tools/sharepoint.d.ts.map +1 -0
- package/dist/tools/sharepoint.js +99 -0
- package/dist/tools/sharepoint.js.map +1 -0
- package/dist/tools/task-attachments.d.ts +74 -0
- package/dist/tools/task-attachments.d.ts.map +1 -0
- package/dist/tools/task-attachments.js +122 -0
- package/dist/tools/task-attachments.js.map +1 -0
- package/dist/tools/tasks.d.ts +74 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +126 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/teams.d.ts +389 -0
- package/dist/tools/teams.d.ts.map +1 -0
- package/dist/tools/teams.js +546 -0
- package/dist/tools/teams.js.map +1 -0
- package/dist/types/calendar.d.ts +60 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +15 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/contacts.d.ts +96 -0
- package/dist/types/contacts.d.ts.map +1 -0
- package/dist/types/contacts.js +41 -0
- package/dist/types/contacts.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mail.d.ts +108 -0
- package/dist/types/mail.d.ts.map +1 -0
- package/dist/types/mail.js +40 -0
- package/dist/types/mail.js.map +1 -0
- package/dist/types/notes.d.ts +26 -0
- package/dist/types/notes.d.ts.map +1 -0
- package/dist/types/notes.js +6 -0
- package/dist/types/notes.js.map +1 -0
- package/dist/types/tasks.d.ts +31 -0
- package/dist/types/tasks.d.ts.map +1 -0
- package/dist/types/tasks.js +6 -0
- package/dist/types/tasks.js.map +1 -0
- package/dist/utils/dates.d.ts +66 -0
- package/dist/utils/dates.d.ts.map +1 -0
- package/dist/utils/dates.js +94 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/errors.d.ts +218 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +306 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/visualization/html.d.ts +26 -0
- package/dist/visualization/html.d.ts.map +1 -0
- package/dist/visualization/html.js +306 -0
- package/dist/visualization/html.js.map +1 -0
- package/dist/visualization/markdown.d.ts +25 -0
- package/dist/visualization/markdown.d.ts.map +1 -0
- package/dist/visualization/markdown.js +186 -0
- package/dist/visualization/markdown.js.map +1 -0
- package/dist/visualization/mermaid.d.ts +25 -0
- package/dist/visualization/mermaid.d.ts.map +1 -0
- package/dist/visualization/mermaid.js +158 -0
- package/dist/visualization/mermaid.js.map +1 -0
- package/dist/visualization/svg.d.ts +25 -0
- package/dist/visualization/svg.d.ts.map +1 -0
- package/dist/visualization/svg.js +282 -0
- package/dist/visualization/svg.js.map +1 -0
- package/dist/visualization/types.d.ts +43 -0
- package/dist/visualization/types.d.ts.map +1 -0
- package/dist/visualization/types.js +34 -0
- package/dist/visualization/types.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Microsoft Authentication Library (MSAL) device code flow implementation.
|
|
7
|
+
*
|
|
8
|
+
* Uses the device code flow for authentication, which is ideal for CLI tools:
|
|
9
|
+
* 1. User is shown a code and URL
|
|
10
|
+
* 2. User visits URL in browser and enters code
|
|
11
|
+
* 3. User authenticates with Microsoft
|
|
12
|
+
* 4. Application receives tokens
|
|
13
|
+
*/
|
|
14
|
+
import { type AuthenticationResult, type AccountInfo } from '@azure/msal-node';
|
|
15
|
+
/**
|
|
16
|
+
* Callback type for device code messages.
|
|
17
|
+
*/
|
|
18
|
+
export type DeviceCodeCallback = (userCode: string, verificationUri: string, message: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Acquires a token using the device code flow.
|
|
21
|
+
*
|
|
22
|
+
* This will prompt the user to authenticate if needed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function acquireTokenInteractive(deviceCodeCallback?: DeviceCodeCallback): Promise<AuthenticationResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Acquires a token silently using cached credentials.
|
|
27
|
+
*
|
|
28
|
+
* Returns null if no cached token is available or if refresh fails.
|
|
29
|
+
*/
|
|
30
|
+
export declare function acquireTokenSilent(): Promise<AuthenticationResult | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets an access token, prompting for login if needed.
|
|
33
|
+
*
|
|
34
|
+
* This is the main entry point for getting a token:
|
|
35
|
+
* 1. First tries to get a cached/refreshed token silently
|
|
36
|
+
* 2. If that fails, prompts for device code authentication
|
|
37
|
+
*/
|
|
38
|
+
export declare function getAccessToken(deviceCodeCallback?: DeviceCodeCallback): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the user is authenticated (has cached tokens).
|
|
41
|
+
*/
|
|
42
|
+
export declare function isAuthenticated(): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the currently authenticated account info.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAccount(): Promise<AccountInfo | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Signs out by clearing the token cache.
|
|
49
|
+
*/
|
|
50
|
+
export declare function signOut(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Resets the MSAL instance (mainly for testing).
|
|
53
|
+
*/
|
|
54
|
+
export declare function resetMsalInstance(): void;
|
|
55
|
+
//# sourceMappingURL=device-code-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-code-flow.d.ts","sourceRoot":"","sources":["../../../src/graph/auth/device-code-flow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AA8C1B;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAiBtG;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,kBAAkB,GAAE,kBAA8C,GACjE,OAAO,CAAC,oBAAoB,CAAC,CAgB/B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAsB/E;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,kBAAkB,GAAE,kBAA8C,GACjE,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAYxD;AAED;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAS9D;AAED;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAW7C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Microsoft Authentication Library (MSAL) device code flow implementation.
|
|
7
|
+
*
|
|
8
|
+
* Uses the device code flow for authentication, which is ideal for CLI tools:
|
|
9
|
+
* 1. User is shown a code and URL
|
|
10
|
+
* 2. User visits URL in browser and enters code
|
|
11
|
+
* 3. User authenticates with Microsoft
|
|
12
|
+
* 4. Application receives tokens
|
|
13
|
+
*/
|
|
14
|
+
import { PublicClientApplication, } from '@azure/msal-node';
|
|
15
|
+
import { loadGraphConfig, getAuthorityUrl } from './config.js';
|
|
16
|
+
import { createTokenCachePlugin, hasTokenCache } from './token-cache.js';
|
|
17
|
+
/**
|
|
18
|
+
* Singleton MSAL application instance.
|
|
19
|
+
*/
|
|
20
|
+
let msalInstance = null;
|
|
21
|
+
/**
|
|
22
|
+
* Cached configuration.
|
|
23
|
+
*/
|
|
24
|
+
let cachedConfig = null;
|
|
25
|
+
/**
|
|
26
|
+
* Gets or creates the MSAL PublicClientApplication instance.
|
|
27
|
+
*/
|
|
28
|
+
function getMsalInstance() {
|
|
29
|
+
if (msalInstance == null) {
|
|
30
|
+
cachedConfig = loadGraphConfig();
|
|
31
|
+
msalInstance = new PublicClientApplication({
|
|
32
|
+
auth: {
|
|
33
|
+
clientId: cachedConfig.clientId,
|
|
34
|
+
authority: getAuthorityUrl(cachedConfig),
|
|
35
|
+
},
|
|
36
|
+
cache: {
|
|
37
|
+
cachePlugin: createTokenCachePlugin(),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return msalInstance;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the cached configuration.
|
|
45
|
+
*/
|
|
46
|
+
function getConfig() {
|
|
47
|
+
if (cachedConfig == null) {
|
|
48
|
+
getMsalInstance(); // This will initialize cachedConfig
|
|
49
|
+
}
|
|
50
|
+
return cachedConfig;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Default callback that outputs to stderr.
|
|
54
|
+
* stderr is used because stdout is reserved for MCP JSON-RPC communication.
|
|
55
|
+
*/
|
|
56
|
+
const defaultDeviceCodeCallback = (userCode, verificationUri, _message) => {
|
|
57
|
+
console.error('\n' + '='.repeat(60));
|
|
58
|
+
console.error('Microsoft Graph API Authentication Required');
|
|
59
|
+
console.error('='.repeat(60));
|
|
60
|
+
console.error(`\nTo sign in, use a web browser to open the page:`);
|
|
61
|
+
console.error(` ${verificationUri}`);
|
|
62
|
+
console.error(`\nAnd enter the code:`);
|
|
63
|
+
console.error(` ${userCode}`);
|
|
64
|
+
console.error('\n' + '='.repeat(60) + '\n');
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Acquires a token using the device code flow.
|
|
68
|
+
*
|
|
69
|
+
* This will prompt the user to authenticate if needed.
|
|
70
|
+
*/
|
|
71
|
+
export async function acquireTokenInteractive(deviceCodeCallback = defaultDeviceCodeCallback) {
|
|
72
|
+
const msal = getMsalInstance();
|
|
73
|
+
const config = getConfig();
|
|
74
|
+
const request = {
|
|
75
|
+
scopes: [...config.scopes],
|
|
76
|
+
deviceCodeCallback: (response) => {
|
|
77
|
+
deviceCodeCallback(response.userCode, response.verificationUri, response.message);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
const result = await msal.acquireTokenByDeviceCode(request);
|
|
81
|
+
if (result == null) {
|
|
82
|
+
throw new Error('Device code authentication failed');
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Acquires a token silently using cached credentials.
|
|
88
|
+
*
|
|
89
|
+
* Returns null if no cached token is available or if refresh fails.
|
|
90
|
+
*/
|
|
91
|
+
export async function acquireTokenSilent() {
|
|
92
|
+
const msal = getMsalInstance();
|
|
93
|
+
const config = getConfig();
|
|
94
|
+
// Get accounts from cache
|
|
95
|
+
const accounts = await msal.getTokenCache().getAllAccounts();
|
|
96
|
+
// Use the first account (most common case)
|
|
97
|
+
const account = accounts[0];
|
|
98
|
+
if (account == null) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return await msal.acquireTokenSilent({
|
|
103
|
+
account,
|
|
104
|
+
scopes: [...config.scopes],
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Token refresh failed, will need interactive auth
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gets an access token, prompting for login if needed.
|
|
114
|
+
*
|
|
115
|
+
* This is the main entry point for getting a token:
|
|
116
|
+
* 1. First tries to get a cached/refreshed token silently
|
|
117
|
+
* 2. If that fails, prompts for device code authentication
|
|
118
|
+
*/
|
|
119
|
+
export async function getAccessToken(deviceCodeCallback = defaultDeviceCodeCallback) {
|
|
120
|
+
// Try silent first
|
|
121
|
+
let result = await acquireTokenSilent();
|
|
122
|
+
// If silent fails, do interactive
|
|
123
|
+
if (result == null) {
|
|
124
|
+
result = await acquireTokenInteractive(deviceCodeCallback);
|
|
125
|
+
}
|
|
126
|
+
return result.accessToken;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks if the user is authenticated (has cached tokens).
|
|
130
|
+
*/
|
|
131
|
+
export async function isAuthenticated() {
|
|
132
|
+
if (!hasTokenCache()) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const msal = getMsalInstance();
|
|
137
|
+
const accounts = await msal.getTokenCache().getAllAccounts();
|
|
138
|
+
return accounts.length > 0;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Gets the currently authenticated account info.
|
|
146
|
+
*/
|
|
147
|
+
export async function getAccount() {
|
|
148
|
+
try {
|
|
149
|
+
const msal = getMsalInstance();
|
|
150
|
+
const accounts = await msal.getTokenCache().getAllAccounts();
|
|
151
|
+
const account = accounts[0];
|
|
152
|
+
return account != null ? account : null;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Signs out by clearing the token cache.
|
|
160
|
+
*/
|
|
161
|
+
export async function signOut() {
|
|
162
|
+
try {
|
|
163
|
+
const msal = getMsalInstance();
|
|
164
|
+
const accounts = await msal.getTokenCache().getAllAccounts();
|
|
165
|
+
for (const account of accounts) {
|
|
166
|
+
await msal.getTokenCache().removeAccount(account);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Ignore errors during sign out
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Resets the MSAL instance (mainly for testing).
|
|
175
|
+
*/
|
|
176
|
+
export function resetMsalInstance() {
|
|
177
|
+
msalInstance = null;
|
|
178
|
+
cachedConfig = null;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=device-code-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-code-flow.js","sourceRoot":"","sources":["../../../src/graph/auth/device-code-flow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EACL,uBAAuB,GAIxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAwB,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;GAEG;AACH,IAAI,YAAY,GAAmC,IAAI,CAAC;AAExD;;GAEG;AACH,IAAI,YAAY,GAA2B,IAAI,CAAC;AAEhD;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,YAAY,GAAG,eAAe,EAAE,CAAC;QAEjC,YAAY,GAAG,IAAI,uBAAuB,CAAC;YACzC,IAAI,EAAE;gBACJ,QAAQ,EAAE,YAAY,CAAC,QAAQ;gBAC/B,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC;aACzC;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,sBAAsB,EAAE;aACtC;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ACpB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Microsoft Graph authentication module.
|
|
7
|
+
*
|
|
8
|
+
* Exports authentication utilities for the device code flow.
|
|
9
|
+
*/
|
|
10
|
+
export { loadGraphConfig, getAuthorityUrl, GRAPH_SCOPES, type GraphAuthConfig } from './config.js';
|
|
11
|
+
export { createTokenCachePlugin, hasTokenCache, clearTokenCache, getTokenCacheDir, getTokenCacheFile, } from './token-cache.js';
|
|
12
|
+
export { acquireTokenInteractive, acquireTokenSilent, getAccessToken, isAuthenticated, getAccount, signOut, resetMsalInstance, type DeviceCodeCallback, } from './device-code-flow.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graph/auth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnG,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,KAAK,kBAAkB,GACxB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Microsoft Graph authentication module.
|
|
7
|
+
*
|
|
8
|
+
* Exports authentication utilities for the device code flow.
|
|
9
|
+
*/
|
|
10
|
+
export { loadGraphConfig, getAuthorityUrl, GRAPH_SCOPES } from './config.js';
|
|
11
|
+
export { createTokenCachePlugin, hasTokenCache, clearTokenCache, getTokenCacheDir, getTokenCacheFile, } from './token-cache.js';
|
|
12
|
+
export { acquireTokenInteractive, acquireTokenSilent, getAccessToken, isAuthenticated, getAccount, signOut, resetMsalInstance, } from './device-code-flow.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graph/auth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAEnG,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,UAAU,EACV,OAAO,EACP,iBAAiB,GAElB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
import type { ICachePlugin, TokenCacheContext } from '@azure/msal-node';
|
|
6
|
+
/**
|
|
7
|
+
* MSAL cache plugin implementation that persists tokens to disk.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FileTokenCachePlugin implements ICachePlugin {
|
|
10
|
+
/**
|
|
11
|
+
* Called by MSAL before accessing the cache.
|
|
12
|
+
* Loads the cache from disk into MSAL's in-memory cache.
|
|
13
|
+
*/
|
|
14
|
+
beforeCacheAccess(context: TokenCacheContext): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Called by MSAL after modifying the cache.
|
|
17
|
+
* Persists the cache to disk.
|
|
18
|
+
*/
|
|
19
|
+
afterCacheAccess(context: TokenCacheContext): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new file-based token cache plugin.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTokenCachePlugin(): ICachePlugin;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a token cache file exists.
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasTokenCache(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Clears the token cache file.
|
|
31
|
+
*/
|
|
32
|
+
export declare function clearTokenCache(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the token cache directory path.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTokenCacheDir(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the token cache file path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getTokenCacheFile(): string;
|
|
41
|
+
//# sourceMappingURL=token-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-cache.d.ts","sourceRoot":"","sources":["../../../src/graph/auth/token-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAqBxE;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD;;;OAGG;IAEG,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlE;;;OAGG;IAEG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAWlE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAErD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAQtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* MSAL token cache plugin for persistent token storage.
|
|
7
|
+
*
|
|
8
|
+
* Stores tokens in ~/.outlook-mcp/tokens.json for persistence
|
|
9
|
+
* across application restarts.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
/**
|
|
15
|
+
* Directory where tokens are stored.
|
|
16
|
+
*/
|
|
17
|
+
const TOKEN_CACHE_DIR = join(homedir(), '.outlook-mcp');
|
|
18
|
+
/**
|
|
19
|
+
* Path to the token cache file.
|
|
20
|
+
*/
|
|
21
|
+
const TOKEN_CACHE_FILE = join(TOKEN_CACHE_DIR, 'tokens.json');
|
|
22
|
+
/**
|
|
23
|
+
* Ensures the token cache directory exists.
|
|
24
|
+
*/
|
|
25
|
+
function ensureCacheDir() {
|
|
26
|
+
if (!existsSync(TOKEN_CACHE_DIR)) {
|
|
27
|
+
mkdirSync(TOKEN_CACHE_DIR, { recursive: true, mode: 0o700 });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* MSAL cache plugin implementation that persists tokens to disk.
|
|
32
|
+
*/
|
|
33
|
+
export class FileTokenCachePlugin {
|
|
34
|
+
/**
|
|
35
|
+
* Called by MSAL before accessing the cache.
|
|
36
|
+
* Loads the cache from disk into MSAL's in-memory cache.
|
|
37
|
+
*/
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
39
|
+
async beforeCacheAccess(context) {
|
|
40
|
+
try {
|
|
41
|
+
if (existsSync(TOKEN_CACHE_FILE)) {
|
|
42
|
+
const data = readFileSync(TOKEN_CACHE_FILE, 'utf-8');
|
|
43
|
+
context.tokenCache.deserialize(data);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// If we can't read the cache, start fresh
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Called by MSAL after modifying the cache.
|
|
52
|
+
* Persists the cache to disk.
|
|
53
|
+
*/
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
55
|
+
async afterCacheAccess(context) {
|
|
56
|
+
if (context.cacheHasChanged) {
|
|
57
|
+
try {
|
|
58
|
+
ensureCacheDir();
|
|
59
|
+
const data = context.tokenCache.serialize();
|
|
60
|
+
writeFileSync(TOKEN_CACHE_FILE, data, { mode: 0o600 });
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// If we can't write, tokens won't persist (user will need to re-auth)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new file-based token cache plugin.
|
|
70
|
+
*/
|
|
71
|
+
export function createTokenCachePlugin() {
|
|
72
|
+
return new FileTokenCachePlugin();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a token cache file exists.
|
|
76
|
+
*/
|
|
77
|
+
export function hasTokenCache() {
|
|
78
|
+
return existsSync(TOKEN_CACHE_FILE);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Clears the token cache file.
|
|
82
|
+
*/
|
|
83
|
+
export function clearTokenCache() {
|
|
84
|
+
try {
|
|
85
|
+
if (existsSync(TOKEN_CACHE_FILE)) {
|
|
86
|
+
writeFileSync(TOKEN_CACHE_FILE, '{}', { mode: 0o600 });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Ignore errors
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gets the token cache directory path.
|
|
95
|
+
*/
|
|
96
|
+
export function getTokenCacheDir() {
|
|
97
|
+
return TOKEN_CACHE_DIR;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the token cache file path.
|
|
101
|
+
*/
|
|
102
|
+
export function getTokenCacheFile() {
|
|
103
|
+
return TOKEN_CACHE_FILE;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=token-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-cache.js","sourceRoot":"","sources":["../../../src/graph/auth/token-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,cAAc,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AAE9D;;GAEG;AACH,SAAS,cAAc;IACrB,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;OAGG;IACH,4DAA4D;IAC5D,KAAK,CAAC,iBAAiB,CAAC,OAA0B;QAChD,IAAI,CAAC;YACH,IAAI,UAAU,CAA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}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Microsoft Graph $batch request utilities.
|
|
7
|
+
* Supports batching up to 20 requests per batch (Graph API limit).
|
|
8
|
+
*/
|
|
9
|
+
export interface BatchRequest {
|
|
10
|
+
id: string;
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
body?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface BatchResponseItem {
|
|
17
|
+
id: string;
|
|
18
|
+
status: number;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
body: unknown;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds a $batch request payload from an array of individual requests.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildBatchPayload(requests: BatchRequest[]): {
|
|
26
|
+
requests: BatchRequest[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Splits requests into batches of the given size (default 20, the Graph API limit).
|
|
30
|
+
*/
|
|
31
|
+
export declare function splitIntoBatches(requests: BatchRequest[], maxPerBatch?: number): BatchRequest[][];
|
|
32
|
+
/**
|
|
33
|
+
* Parses a $batch response into a Map keyed by request ID.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseBatchResponse(response: {
|
|
36
|
+
responses: BatchResponseItem[];
|
|
37
|
+
}): Map<string, BatchResponseItem>;
|
|
38
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/graph/client/batch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,CAExF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,WAAW,GAAE,MAAW,GAAG,YAAY,EAAE,EAAE,CAOrG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAM/G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Builds a $batch request payload from an array of individual requests.
|
|
7
|
+
*/
|
|
8
|
+
export function buildBatchPayload(requests) {
|
|
9
|
+
return { requests };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Splits requests into batches of the given size (default 20, the Graph API limit).
|
|
13
|
+
*/
|
|
14
|
+
export function splitIntoBatches(requests, maxPerBatch = 20) {
|
|
15
|
+
if (requests.length === 0)
|
|
16
|
+
return [];
|
|
17
|
+
const batches = [];
|
|
18
|
+
for (let i = 0; i < requests.length; i += maxPerBatch) {
|
|
19
|
+
batches.push(requests.slice(i, i + maxPerBatch));
|
|
20
|
+
}
|
|
21
|
+
return batches;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses a $batch response into a Map keyed by request ID.
|
|
25
|
+
*/
|
|
26
|
+
export function parseBatchResponse(response) {
|
|
27
|
+
const map = new Map();
|
|
28
|
+
for (const item of response.responses) {
|
|
29
|
+
map.set(item.id, item);
|
|
30
|
+
}
|
|
31
|
+
return map;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../../src/graph/client/batch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAwB;IACxD,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAwB,EAAE,cAAsB,EAAE;IACjF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA4C;IAC7E,MAAM,GAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACtC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
|
+
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default TTL values in milliseconds.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CacheTTL: {
|
|
9
|
+
/** Folders are relatively static */
|
|
10
|
+
readonly FOLDERS: 60000;
|
|
11
|
+
/** Emails change more frequently */
|
|
12
|
+
readonly EMAILS: 30000;
|
|
13
|
+
/** Events are fairly static */
|
|
14
|
+
readonly EVENTS: 30000;
|
|
15
|
+
/** Contacts rarely change */
|
|
16
|
+
readonly CONTACTS: 120000;
|
|
17
|
+
/** Tasks change frequently */
|
|
18
|
+
readonly TASKS: 30000;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Simple in-memory cache with TTL support.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ResponseCache {
|
|
24
|
+
private readonly cache;
|
|
25
|
+
private readonly defaultTtl;
|
|
26
|
+
constructor(defaultTtl?: number);
|
|
27
|
+
/**
|
|
28
|
+
* Gets a cached value if it exists and hasn't expired.
|
|
29
|
+
*/
|
|
30
|
+
get<T>(key: string): T | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Sets a cached value with optional TTL.
|
|
33
|
+
*/
|
|
34
|
+
set<T>(key: string, value: T, ttl?: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a key exists and hasn't expired.
|
|
37
|
+
*/
|
|
38
|
+
has(key: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Removes a specific key from the cache.
|
|
41
|
+
*/
|
|
42
|
+
delete(key: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Clears all entries from the cache.
|
|
45
|
+
*/
|
|
46
|
+
clear(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Removes all expired entries from the cache.
|
|
49
|
+
*/
|
|
50
|
+
prune(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the current number of entries in the cache.
|
|
53
|
+
*/
|
|
54
|
+
get size(): number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a cache key from a method and parameters.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createCacheKey(method: string, ...params: unknown[]): string;
|
|
60
|
+
/**
|
|
61
|
+
* Invalidates cache entries matching a prefix.
|
|
62
|
+
*/
|
|
63
|
+
export declare function invalidateByPrefix(cache: ResponseCache, _prefix: string): void;
|
|
64
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/graph/client/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB,oCAAoC;;IAEpC,oCAAoC;;IAEpC,+BAA+B;;IAE/B,6BAA6B;;IAE7B,8BAA8B;;CAEtB,CAAC;AAEX;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0C;IAChE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,GAAE,MAAwB;IAIhD;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAelC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,GAAE,MAAwB,GAAG,IAAI;IAOlE;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,KAAK,IAAI,MAAM;IAcf;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAK3E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI9E"}
|