@mcp-consultant-tools/powerplatform-core 26.0.0-beta.2
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/build/auth/index.d.ts +64 -0
- package/build/auth/index.d.ts.map +1 -0
- package/build/auth/index.js +39 -0
- package/build/auth/index.js.map +1 -0
- package/build/auth/interactive-auth.d.ts +60 -0
- package/build/auth/interactive-auth.d.ts.map +1 -0
- package/build/auth/interactive-auth.js +429 -0
- package/build/auth/interactive-auth.js.map +1 -0
- package/build/auth/service-principal-auth.d.ts +26 -0
- package/build/auth/service-principal-auth.d.ts.map +1 -0
- package/build/auth/service-principal-auth.js +60 -0
- package/build/auth/service-principal-auth.js.map +1 -0
- package/build/auth/token-cache.d.ts +40 -0
- package/build/auth/token-cache.d.ts.map +1 -0
- package/build/auth/token-cache.js +108 -0
- package/build/auth/token-cache.js.map +1 -0
- package/build/client/PowerPlatformClient.d.ts +78 -0
- package/build/client/PowerPlatformClient.d.ts.map +1 -0
- package/build/client/PowerPlatformClient.js +198 -0
- package/build/client/PowerPlatformClient.js.map +1 -0
- package/build/client/index.d.ts +6 -0
- package/build/client/index.d.ts.map +1 -0
- package/build/client/index.js +6 -0
- package/build/client/index.js.map +1 -0
- package/build/client/types.d.ts +300 -0
- package/build/client/types.d.ts.map +1 -0
- package/build/client/types.js +5 -0
- package/build/client/types.js.map +1 -0
- package/build/index.d.ts +36 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +55 -0
- package/build/index.js.map +1 -0
- package/build/services/AppManagementService.d.ts +95 -0
- package/build/services/AppManagementService.d.ts.map +1 -0
- package/build/services/AppManagementService.js +322 -0
- package/build/services/AppManagementService.js.map +1 -0
- package/build/services/AppService.d.ts +39 -0
- package/build/services/AppService.d.ts.map +1 -0
- package/build/services/AppService.js +173 -0
- package/build/services/AppService.js.map +1 -0
- package/build/services/AttributeService.d.ts +28 -0
- package/build/services/AttributeService.d.ts.map +1 -0
- package/build/services/AttributeService.js +86 -0
- package/build/services/AttributeService.js.map +1 -0
- package/build/services/BusinessRuleService.d.ts +22 -0
- package/build/services/BusinessRuleService.d.ts.map +1 -0
- package/build/services/BusinessRuleService.js +85 -0
- package/build/services/BusinessRuleService.js.map +1 -0
- package/build/services/DataService.d.ts +53 -0
- package/build/services/DataService.d.ts.map +1 -0
- package/build/services/DataService.js +204 -0
- package/build/services/DataService.js.map +1 -0
- package/build/services/DependencyService.d.ts +27 -0
- package/build/services/DependencyService.d.ts.map +1 -0
- package/build/services/DependencyService.js +47 -0
- package/build/services/DependencyService.js.map +1 -0
- package/build/services/EntityService.d.ts +42 -0
- package/build/services/EntityService.d.ts.map +1 -0
- package/build/services/EntityService.js +132 -0
- package/build/services/EntityService.js.map +1 -0
- package/build/services/FlowService.d.ts +55 -0
- package/build/services/FlowService.d.ts.map +1 -0
- package/build/services/FlowService.js +608 -0
- package/build/services/FlowService.js.map +1 -0
- package/build/services/FormService.d.ts +36 -0
- package/build/services/FormService.d.ts.map +1 -0
- package/build/services/FormService.js +55 -0
- package/build/services/FormService.js.map +1 -0
- package/build/services/MetadataService.d.ts +63 -0
- package/build/services/MetadataService.d.ts.map +1 -0
- package/build/services/MetadataService.js +176 -0
- package/build/services/MetadataService.js.map +1 -0
- package/build/services/OptionSetService.d.ts +40 -0
- package/build/services/OptionSetService.d.ts.map +1 -0
- package/build/services/OptionSetService.js +91 -0
- package/build/services/OptionSetService.js.map +1 -0
- package/build/services/PluginDeploymentService.d.ts +102 -0
- package/build/services/PluginDeploymentService.d.ts.map +1 -0
- package/build/services/PluginDeploymentService.js +412 -0
- package/build/services/PluginDeploymentService.js.map +1 -0
- package/build/services/PluginService.d.ts +61 -0
- package/build/services/PluginService.d.ts.map +1 -0
- package/build/services/PluginService.js +289 -0
- package/build/services/PluginService.js.map +1 -0
- package/build/services/PublishingService.d.ts +37 -0
- package/build/services/PublishingService.d.ts.map +1 -0
- package/build/services/PublishingService.js +65 -0
- package/build/services/PublishingService.js.map +1 -0
- package/build/services/RelationshipService.d.ts +29 -0
- package/build/services/RelationshipService.d.ts.map +1 -0
- package/build/services/RelationshipService.js +46 -0
- package/build/services/RelationshipService.js.map +1 -0
- package/build/services/SolutionService.d.ts +60 -0
- package/build/services/SolutionService.d.ts.map +1 -0
- package/build/services/SolutionService.js +125 -0
- package/build/services/SolutionService.js.map +1 -0
- package/build/services/ValidationService.d.ts +31 -0
- package/build/services/ValidationService.d.ts.map +1 -0
- package/build/services/ValidationService.js +391 -0
- package/build/services/ValidationService.js.map +1 -0
- package/build/services/ViewService.d.ts +36 -0
- package/build/services/ViewService.d.ts.map +1 -0
- package/build/services/ViewService.js +55 -0
- package/build/services/ViewService.js.map +1 -0
- package/build/services/WebResourceService.d.ts +40 -0
- package/build/services/WebResourceService.d.ts.map +1 -0
- package/build/services/WebResourceService.js +64 -0
- package/build/services/WebResourceService.js.map +1 -0
- package/build/services/WorkflowManagementService.d.ts +157 -0
- package/build/services/WorkflowManagementService.d.ts.map +1 -0
- package/build/services/WorkflowManagementService.js +567 -0
- package/build/services/WorkflowManagementService.js.map +1 -0
- package/build/services/WorkflowService.d.ts +28 -0
- package/build/services/WorkflowService.d.ts.map +1 -0
- package/build/services/WorkflowService.js +285 -0
- package/build/services/WorkflowService.js.map +1 -0
- package/build/services/index.d.ts +29 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +31 -0
- package/build/services/index.js.map +1 -0
- package/build/utils/auditLogger.d.ts +76 -0
- package/build/utils/auditLogger.d.ts.map +1 -0
- package/build/utils/auditLogger.js +110 -0
- package/build/utils/auditLogger.js.map +1 -0
- package/build/utils/best-practices-formatters.d.ts +26 -0
- package/build/utils/best-practices-formatters.d.ts.map +1 -0
- package/build/utils/best-practices-formatters.js +238 -0
- package/build/utils/best-practices-formatters.js.map +1 -0
- package/build/utils/bestPractices.d.ts +150 -0
- package/build/utils/bestPractices.d.ts.map +1 -0
- package/build/utils/bestPractices.js +324 -0
- package/build/utils/bestPractices.js.map +1 -0
- package/build/utils/iconManager.d.ts +84 -0
- package/build/utils/iconManager.d.ts.map +1 -0
- package/build/utils/iconManager.js +338 -0
- package/build/utils/iconManager.js.map +1 -0
- package/build/utils/index.d.ts +11 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +18 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/prompt-templates.d.ts +9 -0
- package/build/utils/prompt-templates.d.ts.map +1 -0
- package/build/utils/prompt-templates.js +31 -0
- package/build/utils/prompt-templates.js.map +1 -0
- package/build/utils/publisherConfig.d.ts +33 -0
- package/build/utils/publisherConfig.d.ts.map +1 -0
- package/build/utils/publisherConfig.js +54 -0
- package/build/utils/publisherConfig.js.map +1 -0
- package/build/utils/rate-limiter.d.ts +108 -0
- package/build/utils/rate-limiter.d.ts.map +1 -0
- package/build/utils/rate-limiter.js +242 -0
- package/build/utils/rate-limiter.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication module for PowerPlatform MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Supports two authentication modes:
|
|
5
|
+
* 1. Service Principal (ConfidentialClientApplication) - when client_secret is provided
|
|
6
|
+
* 2. Interactive User Auth (PublicClientApplication) - when no client_secret is provided
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Authentication provider interface
|
|
10
|
+
* All auth implementations must provide a way to get access tokens
|
|
11
|
+
*/
|
|
12
|
+
export interface AuthProvider {
|
|
13
|
+
/**
|
|
14
|
+
* Get an access token for the specified resource
|
|
15
|
+
* @param resource - The resource URL (e.g., https://org.crm.dynamics.com)
|
|
16
|
+
* @returns Access token string
|
|
17
|
+
*/
|
|
18
|
+
getAccessToken(resource: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get information about the authenticated user (if available)
|
|
21
|
+
* Only available for interactive auth
|
|
22
|
+
*/
|
|
23
|
+
getUserInfo?(): Promise<{
|
|
24
|
+
name: string;
|
|
25
|
+
email: string;
|
|
26
|
+
oid: string;
|
|
27
|
+
} | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the authentication mode being used
|
|
30
|
+
*/
|
|
31
|
+
getAuthMode(): 'service-principal' | 'interactive';
|
|
32
|
+
/**
|
|
33
|
+
* Clear cached tokens (logout)
|
|
34
|
+
* Only applicable for interactive auth
|
|
35
|
+
*/
|
|
36
|
+
clearCache?(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for PowerPlatform authentication
|
|
40
|
+
*/
|
|
41
|
+
export interface PowerPlatformAuthConfig {
|
|
42
|
+
/** PowerPlatform organization URL (e.g., https://org.crm.dynamics.com) */
|
|
43
|
+
organizationUrl: string;
|
|
44
|
+
/** Azure AD application (client) ID */
|
|
45
|
+
clientId: string;
|
|
46
|
+
/** Azure AD tenant ID */
|
|
47
|
+
tenantId: string;
|
|
48
|
+
/** Client secret (optional - if provided, uses service principal auth) */
|
|
49
|
+
clientSecret?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create an appropriate auth provider based on configuration
|
|
53
|
+
*
|
|
54
|
+
* If clientSecret is provided → ServicePrincipalAuth (existing behavior)
|
|
55
|
+
* If no clientSecret → InteractiveAuth (browser-based SSO)
|
|
56
|
+
*
|
|
57
|
+
* @param config - PowerPlatform authentication configuration
|
|
58
|
+
* @returns Auth provider instance
|
|
59
|
+
*/
|
|
60
|
+
export declare function createAuthProvider(config: PowerPlatformAuthConfig): AuthProvider;
|
|
61
|
+
export { ServicePrincipalAuth } from './service-principal-auth.js';
|
|
62
|
+
export { InteractiveAuth } from './interactive-auth.js';
|
|
63
|
+
export { TokenCache } from './token-cache.js';
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAElD;;;OAGG;IACH,WAAW,CAAC,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAE7E;;OAEG;IACH,WAAW,IAAI,mBAAmB,GAAG,aAAa,CAAC;IAEnD;;;OAGG;IACH,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,eAAe,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,uBAAuB,GAAG,YAAY,CAiBhF;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication module for PowerPlatform MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Supports two authentication modes:
|
|
5
|
+
* 1. Service Principal (ConfidentialClientApplication) - when client_secret is provided
|
|
6
|
+
* 2. Interactive User Auth (PublicClientApplication) - when no client_secret is provided
|
|
7
|
+
*/
|
|
8
|
+
import { ServicePrincipalAuth } from './service-principal-auth.js';
|
|
9
|
+
import { InteractiveAuth } from './interactive-auth.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create an appropriate auth provider based on configuration
|
|
12
|
+
*
|
|
13
|
+
* If clientSecret is provided → ServicePrincipalAuth (existing behavior)
|
|
14
|
+
* If no clientSecret → InteractiveAuth (browser-based SSO)
|
|
15
|
+
*
|
|
16
|
+
* @param config - PowerPlatform authentication configuration
|
|
17
|
+
* @returns Auth provider instance
|
|
18
|
+
*/
|
|
19
|
+
export function createAuthProvider(config) {
|
|
20
|
+
if (config.clientSecret) {
|
|
21
|
+
// Service Principal mode (existing behavior)
|
|
22
|
+
return new ServicePrincipalAuth({
|
|
23
|
+
organizationUrl: config.organizationUrl,
|
|
24
|
+
clientId: config.clientId,
|
|
25
|
+
clientSecret: config.clientSecret,
|
|
26
|
+
tenantId: config.tenantId,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Interactive User Auth mode (new behavior)
|
|
30
|
+
return new InteractiveAuth({
|
|
31
|
+
organizationUrl: config.organizationUrl,
|
|
32
|
+
clientId: config.clientId,
|
|
33
|
+
tenantId: config.tenantId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export { ServicePrincipalAuth } from './service-principal-auth.js';
|
|
37
|
+
export { InteractiveAuth } from './interactive-auth.js';
|
|
38
|
+
export { TokenCache } from './token-cache.js';
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA8CxD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA+B;IAChE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,6CAA6C;QAC7C,OAAO,IAAI,oBAAoB,CAAC;YAC9B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,4CAA4C;IAC5C,OAAO,IAAI,eAAe,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Authentication Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses PublicClientApplication (authorization code flow with PKCE)
|
|
5
|
+
* for browser-based SSO authentication.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Try silent auth using cached tokens
|
|
9
|
+
* 2. If no cached token or token expired, open browser for login
|
|
10
|
+
* 3. User authenticates via Microsoft Entra ID (SSO if already signed in)
|
|
11
|
+
* 4. Receive authorization code via localhost redirect
|
|
12
|
+
* 5. Exchange code for tokens
|
|
13
|
+
* 6. Cache tokens for future use
|
|
14
|
+
*/
|
|
15
|
+
import type { AuthProvider } from './index.js';
|
|
16
|
+
export interface InteractiveAuthConfig {
|
|
17
|
+
organizationUrl: string;
|
|
18
|
+
clientId: string;
|
|
19
|
+
tenantId: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class InteractiveAuth implements AuthProvider {
|
|
22
|
+
private config;
|
|
23
|
+
private pca;
|
|
24
|
+
private tokenCache;
|
|
25
|
+
private cachedAccount;
|
|
26
|
+
constructor(config: InteractiveAuthConfig);
|
|
27
|
+
getAuthMode(): 'service-principal' | 'interactive';
|
|
28
|
+
getAccessToken(resource: string): Promise<string>;
|
|
29
|
+
getUserInfo(): Promise<{
|
|
30
|
+
name: string;
|
|
31
|
+
email: string;
|
|
32
|
+
oid: string;
|
|
33
|
+
} | null>;
|
|
34
|
+
clearCache(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Acquire token via browser-based interactive flow
|
|
37
|
+
*/
|
|
38
|
+
private acquireTokenInteractive;
|
|
39
|
+
/**
|
|
40
|
+
* Find an available port for the callback server
|
|
41
|
+
*/
|
|
42
|
+
private findFreePort;
|
|
43
|
+
/**
|
|
44
|
+
* HTML page shown after successful authentication
|
|
45
|
+
*/
|
|
46
|
+
private getSuccessHtml;
|
|
47
|
+
/**
|
|
48
|
+
* HTML page shown when authentication fails
|
|
49
|
+
*/
|
|
50
|
+
private getErrorHtml;
|
|
51
|
+
/**
|
|
52
|
+
* HTML page shown while waiting for callback
|
|
53
|
+
*/
|
|
54
|
+
private getWaitingHtml;
|
|
55
|
+
/**
|
|
56
|
+
* Escape HTML to prevent XSS
|
|
57
|
+
*/
|
|
58
|
+
private escapeHtml;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=interactive-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive-auth.d.ts","sourceRoot":"","sources":["../../src/auth/interactive-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,eAAgB,YAAW,YAAY;IAClD,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,aAAa,CAA4B;gBAErC,MAAM,EAAE,qBAAqB;IAezC,WAAW,IAAI,mBAAmB,GAAG,aAAa;IAI5C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBjD,WAAW,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAiB3E,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;OAEG;YACW,uBAAuB;IA2GrC;;OAEG;YACW,YAAY;IAgB1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAiFtB;;OAEG;IACH,OAAO,CAAC,YAAY;IA0EpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAyDtB;;OAEG;IACH,OAAO,CAAC,UAAU;CAUnB"}
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Authentication Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses PublicClientApplication (authorization code flow with PKCE)
|
|
5
|
+
* for browser-based SSO authentication.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Try silent auth using cached tokens
|
|
9
|
+
* 2. If no cached token or token expired, open browser for login
|
|
10
|
+
* 3. User authenticates via Microsoft Entra ID (SSO if already signed in)
|
|
11
|
+
* 4. Receive authorization code via localhost redirect
|
|
12
|
+
* 5. Exchange code for tokens
|
|
13
|
+
* 6. Cache tokens for future use
|
|
14
|
+
*/
|
|
15
|
+
import { PublicClientApplication, InteractionRequiredAuthError, } from '@azure/msal-node';
|
|
16
|
+
import http from 'node:http';
|
|
17
|
+
import open from 'open';
|
|
18
|
+
import { TokenCache } from './token-cache.js';
|
|
19
|
+
export class InteractiveAuth {
|
|
20
|
+
config;
|
|
21
|
+
pca;
|
|
22
|
+
tokenCache;
|
|
23
|
+
cachedAccount = null;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.tokenCache = new TokenCache(config.clientId);
|
|
27
|
+
this.pca = new PublicClientApplication({
|
|
28
|
+
auth: {
|
|
29
|
+
clientId: config.clientId,
|
|
30
|
+
authority: `https://login.microsoftonline.com/${config.tenantId}`,
|
|
31
|
+
},
|
|
32
|
+
cache: {
|
|
33
|
+
cachePlugin: this.tokenCache.createPlugin(),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getAuthMode() {
|
|
38
|
+
return 'interactive';
|
|
39
|
+
}
|
|
40
|
+
async getAccessToken(resource) {
|
|
41
|
+
// Try silent auth first (uses cached tokens)
|
|
42
|
+
const accounts = await this.pca.getTokenCache().getAllAccounts();
|
|
43
|
+
if (accounts.length > 0) {
|
|
44
|
+
try {
|
|
45
|
+
const result = await this.pca.acquireTokenSilent({
|
|
46
|
+
account: accounts[0],
|
|
47
|
+
scopes: [`${resource}/.default`],
|
|
48
|
+
});
|
|
49
|
+
this.cachedAccount = accounts[0];
|
|
50
|
+
return result.accessToken;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (!(error instanceof InteractionRequiredAuthError)) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
// Token expired or revoked, need interactive auth
|
|
57
|
+
console.error('Cached token expired, re-authenticating...');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Interactive auth required
|
|
61
|
+
return this.acquireTokenInteractive(resource);
|
|
62
|
+
}
|
|
63
|
+
async getUserInfo() {
|
|
64
|
+
if (!this.cachedAccount) {
|
|
65
|
+
const accounts = await this.pca.getTokenCache().getAllAccounts();
|
|
66
|
+
this.cachedAccount = accounts[0] || null;
|
|
67
|
+
}
|
|
68
|
+
if (!this.cachedAccount) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name: this.cachedAccount.name || 'Unknown',
|
|
73
|
+
email: this.cachedAccount.username || 'Unknown',
|
|
74
|
+
oid: this.cachedAccount.localAccountId || '',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async clearCache() {
|
|
78
|
+
this.tokenCache.clear();
|
|
79
|
+
this.cachedAccount = null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Acquire token via browser-based interactive flow
|
|
83
|
+
*/
|
|
84
|
+
async acquireTokenInteractive(resource) {
|
|
85
|
+
const port = await this.findFreePort();
|
|
86
|
+
const redirectUri = `http://localhost:${port}`;
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
let serverClosed = false;
|
|
89
|
+
const server = http.createServer(async (req, res) => {
|
|
90
|
+
if (serverClosed)
|
|
91
|
+
return;
|
|
92
|
+
try {
|
|
93
|
+
const url = new URL(req.url, `http://localhost:${port}`);
|
|
94
|
+
if (url.pathname === '/') {
|
|
95
|
+
const code = url.searchParams.get('code');
|
|
96
|
+
const error = url.searchParams.get('error');
|
|
97
|
+
const errorDescription = url.searchParams.get('error_description');
|
|
98
|
+
if (error) {
|
|
99
|
+
res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
100
|
+
res.end(this.getErrorHtml(error, errorDescription || 'Unknown error'));
|
|
101
|
+
serverClosed = true;
|
|
102
|
+
server.close();
|
|
103
|
+
reject(new Error(`Authentication failed: ${error} - ${errorDescription}`));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (code) {
|
|
107
|
+
try {
|
|
108
|
+
const result = await this.pca.acquireTokenByCode({
|
|
109
|
+
code,
|
|
110
|
+
scopes: [`${resource}/.default`, 'offline_access'],
|
|
111
|
+
redirectUri,
|
|
112
|
+
});
|
|
113
|
+
this.cachedAccount = result.account;
|
|
114
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
115
|
+
res.end(this.getSuccessHtml(result));
|
|
116
|
+
serverClosed = true;
|
|
117
|
+
server.close();
|
|
118
|
+
resolve(result.accessToken);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
122
|
+
res.end(this.getErrorHtml('token_exchange_failed', err.message));
|
|
123
|
+
serverClosed = true;
|
|
124
|
+
server.close();
|
|
125
|
+
reject(err);
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// No code or error, show waiting page
|
|
130
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
131
|
+
res.end(this.getWaitingHtml());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
console.error('Error handling callback:', err);
|
|
136
|
+
if (!serverClosed) {
|
|
137
|
+
serverClosed = true;
|
|
138
|
+
server.close();
|
|
139
|
+
reject(err);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
server.on('error', (err) => {
|
|
144
|
+
reject(new Error(`Failed to start callback server: ${err.message}`));
|
|
145
|
+
});
|
|
146
|
+
server.listen(port, async () => {
|
|
147
|
+
try {
|
|
148
|
+
const authUrl = await this.pca.getAuthCodeUrl({
|
|
149
|
+
scopes: [`${resource}/.default`, 'offline_access', 'openid'],
|
|
150
|
+
redirectUri,
|
|
151
|
+
});
|
|
152
|
+
console.error('');
|
|
153
|
+
console.error('Authentication required');
|
|
154
|
+
console.error(' Opening browser for sign-in...');
|
|
155
|
+
console.error(` If browser doesn't open, visit: ${authUrl.substring(0, 80)}...`);
|
|
156
|
+
console.error('');
|
|
157
|
+
await open(authUrl);
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
serverClosed = true;
|
|
161
|
+
server.close();
|
|
162
|
+
reject(err);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
// Timeout after 5 minutes
|
|
166
|
+
const timeout = setTimeout(() => {
|
|
167
|
+
if (!serverClosed) {
|
|
168
|
+
serverClosed = true;
|
|
169
|
+
server.close();
|
|
170
|
+
reject(new Error('Authentication timed out after 5 minutes'));
|
|
171
|
+
}
|
|
172
|
+
}, 5 * 60 * 1000);
|
|
173
|
+
server.on('close', () => {
|
|
174
|
+
clearTimeout(timeout);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Find an available port for the callback server
|
|
180
|
+
*/
|
|
181
|
+
async findFreePort() {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
const server = http.createServer();
|
|
184
|
+
server.on('error', reject);
|
|
185
|
+
server.listen(0, () => {
|
|
186
|
+
const address = server.address();
|
|
187
|
+
if (address && typeof address === 'object') {
|
|
188
|
+
const port = address.port;
|
|
189
|
+
server.close(() => resolve(port));
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
reject(new Error('Failed to get port'));
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* HTML page shown after successful authentication
|
|
199
|
+
*/
|
|
200
|
+
getSuccessHtml(result) {
|
|
201
|
+
const userName = result.account?.name || 'User';
|
|
202
|
+
return `<!DOCTYPE html>
|
|
203
|
+
<html>
|
|
204
|
+
<head>
|
|
205
|
+
<meta charset="utf-8">
|
|
206
|
+
<title>Authentication Successful</title>
|
|
207
|
+
<style>
|
|
208
|
+
body {
|
|
209
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
210
|
+
display: flex;
|
|
211
|
+
justify-content: center;
|
|
212
|
+
align-items: center;
|
|
213
|
+
min-height: 100vh;
|
|
214
|
+
margin: 0;
|
|
215
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
216
|
+
}
|
|
217
|
+
.container {
|
|
218
|
+
background: white;
|
|
219
|
+
padding: 3rem;
|
|
220
|
+
border-radius: 16px;
|
|
221
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
222
|
+
text-align: center;
|
|
223
|
+
max-width: 400px;
|
|
224
|
+
}
|
|
225
|
+
.checkmark {
|
|
226
|
+
width: 80px;
|
|
227
|
+
height: 80px;
|
|
228
|
+
border-radius: 50%;
|
|
229
|
+
background: #10b981;
|
|
230
|
+
display: flex;
|
|
231
|
+
justify-content: center;
|
|
232
|
+
align-items: center;
|
|
233
|
+
margin: 0 auto 1.5rem;
|
|
234
|
+
}
|
|
235
|
+
.checkmark svg {
|
|
236
|
+
width: 40px;
|
|
237
|
+
height: 40px;
|
|
238
|
+
fill: white;
|
|
239
|
+
}
|
|
240
|
+
h1 {
|
|
241
|
+
color: #1f2937;
|
|
242
|
+
margin: 0 0 0.5rem;
|
|
243
|
+
font-size: 1.5rem;
|
|
244
|
+
}
|
|
245
|
+
p {
|
|
246
|
+
color: #6b7280;
|
|
247
|
+
margin: 0.5rem 0;
|
|
248
|
+
}
|
|
249
|
+
.user {
|
|
250
|
+
color: #374151;
|
|
251
|
+
font-weight: 600;
|
|
252
|
+
}
|
|
253
|
+
.close-note {
|
|
254
|
+
margin-top: 1.5rem;
|
|
255
|
+
padding: 1rem;
|
|
256
|
+
background: #f3f4f6;
|
|
257
|
+
border-radius: 8px;
|
|
258
|
+
font-size: 0.875rem;
|
|
259
|
+
}
|
|
260
|
+
</style>
|
|
261
|
+
</head>
|
|
262
|
+
<body>
|
|
263
|
+
<div class="container">
|
|
264
|
+
<div class="checkmark">
|
|
265
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
266
|
+
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
|
|
267
|
+
</svg>
|
|
268
|
+
</div>
|
|
269
|
+
<h1>Authentication Successful</h1>
|
|
270
|
+
<p>Welcome, <span class="user">${this.escapeHtml(userName)}</span>!</p>
|
|
271
|
+
<p>You are now connected to PowerPlatform.</p>
|
|
272
|
+
<div class="close-note">
|
|
273
|
+
You can close this window and return to your application.
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
<script>setTimeout(() => window.close(), 3000);</script>
|
|
277
|
+
</body>
|
|
278
|
+
</html>`;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* HTML page shown when authentication fails
|
|
282
|
+
*/
|
|
283
|
+
getErrorHtml(error, description) {
|
|
284
|
+
return `<!DOCTYPE html>
|
|
285
|
+
<html>
|
|
286
|
+
<head>
|
|
287
|
+
<meta charset="utf-8">
|
|
288
|
+
<title>Authentication Failed</title>
|
|
289
|
+
<style>
|
|
290
|
+
body {
|
|
291
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
292
|
+
display: flex;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
align-items: center;
|
|
295
|
+
min-height: 100vh;
|
|
296
|
+
margin: 0;
|
|
297
|
+
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
|
|
298
|
+
}
|
|
299
|
+
.container {
|
|
300
|
+
background: white;
|
|
301
|
+
padding: 3rem;
|
|
302
|
+
border-radius: 16px;
|
|
303
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
304
|
+
text-align: center;
|
|
305
|
+
max-width: 500px;
|
|
306
|
+
}
|
|
307
|
+
.error-icon {
|
|
308
|
+
width: 80px;
|
|
309
|
+
height: 80px;
|
|
310
|
+
border-radius: 50%;
|
|
311
|
+
background: #ef4444;
|
|
312
|
+
display: flex;
|
|
313
|
+
justify-content: center;
|
|
314
|
+
align-items: center;
|
|
315
|
+
margin: 0 auto 1.5rem;
|
|
316
|
+
}
|
|
317
|
+
.error-icon svg {
|
|
318
|
+
width: 40px;
|
|
319
|
+
height: 40px;
|
|
320
|
+
fill: white;
|
|
321
|
+
}
|
|
322
|
+
h1 {
|
|
323
|
+
color: #1f2937;
|
|
324
|
+
margin: 0 0 1rem;
|
|
325
|
+
font-size: 1.5rem;
|
|
326
|
+
}
|
|
327
|
+
.error-code {
|
|
328
|
+
background: #fef2f2;
|
|
329
|
+
color: #991b1b;
|
|
330
|
+
padding: 0.5rem 1rem;
|
|
331
|
+
border-radius: 8px;
|
|
332
|
+
font-family: monospace;
|
|
333
|
+
margin-bottom: 1rem;
|
|
334
|
+
}
|
|
335
|
+
p {
|
|
336
|
+
color: #6b7280;
|
|
337
|
+
margin: 0.5rem 0;
|
|
338
|
+
}
|
|
339
|
+
</style>
|
|
340
|
+
</head>
|
|
341
|
+
<body>
|
|
342
|
+
<div class="container">
|
|
343
|
+
<div class="error-icon">
|
|
344
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
345
|
+
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
|
|
346
|
+
</svg>
|
|
347
|
+
</div>
|
|
348
|
+
<h1>Authentication Failed</h1>
|
|
349
|
+
<div class="error-code">${this.escapeHtml(error)}</div>
|
|
350
|
+
<p>${this.escapeHtml(description)}</p>
|
|
351
|
+
<p style="margin-top: 1.5rem;">Please close this window and try again.</p>
|
|
352
|
+
</div>
|
|
353
|
+
</body>
|
|
354
|
+
</html>`;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* HTML page shown while waiting for callback
|
|
358
|
+
*/
|
|
359
|
+
getWaitingHtml() {
|
|
360
|
+
return `<!DOCTYPE html>
|
|
361
|
+
<html>
|
|
362
|
+
<head>
|
|
363
|
+
<meta charset="utf-8">
|
|
364
|
+
<title>Authenticating...</title>
|
|
365
|
+
<style>
|
|
366
|
+
body {
|
|
367
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
368
|
+
display: flex;
|
|
369
|
+
justify-content: center;
|
|
370
|
+
align-items: center;
|
|
371
|
+
min-height: 100vh;
|
|
372
|
+
margin: 0;
|
|
373
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
374
|
+
}
|
|
375
|
+
.container {
|
|
376
|
+
background: white;
|
|
377
|
+
padding: 3rem;
|
|
378
|
+
border-radius: 16px;
|
|
379
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
380
|
+
text-align: center;
|
|
381
|
+
}
|
|
382
|
+
.spinner {
|
|
383
|
+
width: 60px;
|
|
384
|
+
height: 60px;
|
|
385
|
+
border: 4px solid #e5e7eb;
|
|
386
|
+
border-top: 4px solid #667eea;
|
|
387
|
+
border-radius: 50%;
|
|
388
|
+
animation: spin 1s linear infinite;
|
|
389
|
+
margin: 0 auto 1.5rem;
|
|
390
|
+
}
|
|
391
|
+
@keyframes spin {
|
|
392
|
+
0% { transform: rotate(0deg); }
|
|
393
|
+
100% { transform: rotate(360deg); }
|
|
394
|
+
}
|
|
395
|
+
h1 {
|
|
396
|
+
color: #1f2937;
|
|
397
|
+
margin: 0 0 0.5rem;
|
|
398
|
+
font-size: 1.5rem;
|
|
399
|
+
}
|
|
400
|
+
p {
|
|
401
|
+
color: #6b7280;
|
|
402
|
+
margin: 0;
|
|
403
|
+
}
|
|
404
|
+
</style>
|
|
405
|
+
</head>
|
|
406
|
+
<body>
|
|
407
|
+
<div class="container">
|
|
408
|
+
<div class="spinner"></div>
|
|
409
|
+
<h1>Authenticating...</h1>
|
|
410
|
+
<p>Please complete sign-in in the browser window.</p>
|
|
411
|
+
</div>
|
|
412
|
+
</body>
|
|
413
|
+
</html>`;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Escape HTML to prevent XSS
|
|
417
|
+
*/
|
|
418
|
+
escapeHtml(text) {
|
|
419
|
+
const map = {
|
|
420
|
+
'&': '&',
|
|
421
|
+
'<': '<',
|
|
422
|
+
'>': '>',
|
|
423
|
+
'"': '"',
|
|
424
|
+
"'": ''',
|
|
425
|
+
};
|
|
426
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=interactive-auth.js.map
|
|
@@ -0,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AC;;;;;;;;QAQtD,CAAC;IACP,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,KAAa,EAAE,WAAmB;QACrD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAiEmB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;SAC3C,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;;;;QAI7B,CAAC;IACP,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqDH,CAAC;IACP,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAY;QAC7B,MAAM,GAAG,GAA2B;YAClC,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,QAAQ;SACd,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Principal Authentication Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses ConfidentialClientApplication (client credentials flow)
|
|
5
|
+
* for app-to-app authentication with client_id + client_secret.
|
|
6
|
+
*
|
|
7
|
+
* This is the existing authentication mechanism, refactored into the auth module.
|
|
8
|
+
*/
|
|
9
|
+
import type { AuthProvider } from './index.js';
|
|
10
|
+
export interface ServicePrincipalConfig {
|
|
11
|
+
organizationUrl: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
tenantId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class ServicePrincipalAuth implements AuthProvider {
|
|
17
|
+
private config;
|
|
18
|
+
private msalClient;
|
|
19
|
+
private accessToken;
|
|
20
|
+
private tokenExpirationTime;
|
|
21
|
+
constructor(config: ServicePrincipalConfig);
|
|
22
|
+
getAuthMode(): 'service-principal' | 'interactive';
|
|
23
|
+
getAccessToken(resource: string): Promise<string>;
|
|
24
|
+
getUserInfo(): Promise<null>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=service-principal-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-principal-auth.d.ts","sourceRoot":"","sources":["../../src/auth/service-principal-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,mBAAmB,CAAa;gBAE5B,MAAM,EAAE,sBAAsB;IAY1C,WAAW,IAAI,mBAAmB,GAAG,aAAa;IAI5C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCjD,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAInC"}
|