@mcp-consultant-tools/powerplatform 32.0.0-beta.4 → 33.0.0
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/cli/commands/metadata-commands.js +2 -2
- package/build/cli/commands/metadata-commands.js.map +1 -1
- package/build/cli.js +0 -0
- package/build/http-server.js +0 -0
- package/build/index.js +0 -0
- package/package.json +3 -3
- package/build/PowerPlatformService.d.ts +0 -201
- package/build/PowerPlatformService.js +0 -305
- package/build/PowerPlatformService.js.map +0 -1
- package/build/auth/index.d.ts +0 -64
- package/build/auth/index.d.ts.map +0 -1
- package/build/auth/index.js +0 -39
- package/build/auth/index.js.map +0 -1
- package/build/auth/interactive-auth.d.ts +0 -60
- package/build/auth/interactive-auth.d.ts.map +0 -1
- package/build/auth/interactive-auth.js +0 -429
- package/build/auth/interactive-auth.js.map +0 -1
- package/build/auth/service-principal-auth.d.ts +0 -26
- package/build/auth/service-principal-auth.d.ts.map +0 -1
- package/build/auth/service-principal-auth.js +0 -60
- package/build/auth/service-principal-auth.js.map +0 -1
- package/build/auth/token-cache.d.ts +0 -40
- package/build/auth/token-cache.d.ts.map +0 -1
- package/build/auth/token-cache.js +0 -108
- package/build/auth/token-cache.js.map +0 -1
- package/build/cli/commands/app-commands.d.ts +0 -7
- package/build/cli/commands/field-security-commands.d.ts +0 -8
- package/build/cli/commands/flow-commands.d.ts +0 -7
- package/build/cli/commands/form-commands.d.ts +0 -7
- package/build/cli/commands/index.d.ts +0 -16
- package/build/cli/commands/index.js +0 -33
- package/build/cli/commands/index.js.map +0 -1
- package/build/cli/commands/integration-commands.d.ts +0 -7
- package/build/cli/commands/metadata-commands.d.ts +0 -7
- package/build/cli/commands/plugin-commands.d.ts +0 -7
- package/build/cli/commands/security-commands.d.ts +0 -7
- package/build/cli/commands/solution-commands.d.ts +0 -7
- package/build/cli/output.d.ts +0 -11
- package/build/cli.d.ts +0 -9
- package/build/context-factory.d.ts +0 -11
- package/build/context-factory.js +0 -39
- package/build/context-factory.js.map +0 -1
- package/build/http-server.d.ts +0 -3
- package/build/index.d.ts +0 -18
- package/build/prompts/analysis-prompts.d.ts +0 -3
- package/build/prompts/analysis-prompts.js +0 -286
- package/build/prompts/analysis-prompts.js.map +0 -1
- package/build/prompts/entity-prompts.d.ts +0 -3
- package/build/prompts/entity-prompts.js +0 -304
- package/build/prompts/entity-prompts.js.map +0 -1
- package/build/prompts/index.d.ts +0 -8
- package/build/prompts/index.js +0 -11
- package/build/prompts/index.js.map +0 -1
- package/build/services/index.d.ts +0 -5
- package/build/services/index.js +0 -5
- package/build/services/index.js.map +0 -1
- package/build/tool-examples.d.ts +0 -48
- package/build/tools/app-tools.d.ts +0 -3
- package/build/tools/app-tools.js +0 -127
- package/build/tools/app-tools.js.map +0 -1
- package/build/tools/field-security-tools.d.ts +0 -3
- package/build/tools/field-security-tools.js +0 -84
- package/build/tools/field-security-tools.js.map +0 -1
- package/build/tools/flow-tools.d.ts +0 -3
- package/build/tools/flow-tools.js +0 -374
- package/build/tools/flow-tools.js.map +0 -1
- package/build/tools/form-view-tools.d.ts +0 -3
- package/build/tools/form-view-tools.js +0 -162
- package/build/tools/form-view-tools.js.map +0 -1
- package/build/tools/index.d.ts +0 -14
- package/build/tools/index.js +0 -31
- package/build/tools/index.js.map +0 -1
- package/build/tools/integration-tools.d.ts +0 -3
- package/build/tools/integration-tools.js +0 -325
- package/build/tools/integration-tools.js.map +0 -1
- package/build/tools/metadata-tools.d.ts +0 -3
- package/build/tools/metadata-tools.js +0 -166
- package/build/tools/metadata-tools.js.map +0 -1
- package/build/tools/plugin-tools.d.ts +0 -3
- package/build/tools/plugin-tools.js +0 -138
- package/build/tools/plugin-tools.js.map +0 -1
- package/build/tools/security-tools.d.ts +0 -3
- package/build/tools/security-tools.js +0 -188
- package/build/tools/security-tools.js.map +0 -1
- package/build/tools/solution-tools.d.ts +0 -3
- package/build/tools/solution-tools.js +0 -318
- package/build/tools/solution-tools.js.map +0 -1
- package/build/types.d.ts +0 -9
- package/build/types.js +0 -2
- package/build/types.js.map +0 -1
- package/build/utils/best-practices-formatters.d.ts +0 -26
- package/build/utils/best-practices-formatters.d.ts.map +0 -1
- package/build/utils/best-practices-formatters.js +0 -238
- package/build/utils/best-practices-formatters.js.map +0 -1
- package/build/utils/bestPractices.d.ts +0 -152
- package/build/utils/bestPractices.d.ts.map +0 -1
- package/build/utils/bestPractices.js +0 -338
- package/build/utils/bestPractices.js.map +0 -1
- package/build/utils/iconManager.d.ts +0 -84
- package/build/utils/iconManager.d.ts.map +0 -1
- package/build/utils/iconManager.js +0 -342
- package/build/utils/iconManager.js.map +0 -1
- package/build/utils/prompt-templates.d.ts +0 -9
- package/build/utils/prompt-templates.d.ts.map +0 -1
- package/build/utils/prompt-templates.js +0 -31
- package/build/utils/prompt-templates.js.map +0 -1
- package/build/utils/rate-limiter.d.ts +0 -108
- package/build/utils/rate-limiter.d.ts.map +0 -1
- package/build/utils/rate-limiter.js +0 -241
- package/build/utils/rate-limiter.js.map +0 -1
package/build/auth/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
package/build/auth/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,429 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-auth.js","sourceRoot":"","sources":["../../src/auth/interactive-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,uBAAuB,EACvB,4BAA4B,GAG7B,MAAM,kBAAkB,CAAC;AAC1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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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,60 +0,0 @@
|
|
|
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 { ConfidentialClientApplication } from '@azure/msal-node';
|
|
10
|
-
export class ServicePrincipalAuth {
|
|
11
|
-
config;
|
|
12
|
-
msalClient;
|
|
13
|
-
accessToken = null;
|
|
14
|
-
tokenExpirationTime = 0;
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.msalClient = new ConfidentialClientApplication({
|
|
18
|
-
auth: {
|
|
19
|
-
clientId: this.config.clientId,
|
|
20
|
-
clientSecret: this.config.clientSecret,
|
|
21
|
-
authority: `https://login.microsoftonline.com/${this.config.tenantId}`,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
getAuthMode() {
|
|
26
|
-
return 'service-principal';
|
|
27
|
-
}
|
|
28
|
-
async getAccessToken(resource) {
|
|
29
|
-
const currentTime = Date.now();
|
|
30
|
-
// If we have a token that isn't expired, return it
|
|
31
|
-
if (this.accessToken && this.tokenExpirationTime > currentTime) {
|
|
32
|
-
return this.accessToken;
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
// Get a new token using client credentials flow
|
|
36
|
-
const result = await this.msalClient.acquireTokenByClientCredential({
|
|
37
|
-
scopes: [`${resource}/.default`],
|
|
38
|
-
});
|
|
39
|
-
if (!result || !result.accessToken) {
|
|
40
|
-
throw new Error('Failed to acquire access token');
|
|
41
|
-
}
|
|
42
|
-
this.accessToken = result.accessToken;
|
|
43
|
-
// Set expiration time (subtract 5 minutes to refresh early)
|
|
44
|
-
if (result.expiresOn) {
|
|
45
|
-
this.tokenExpirationTime = result.expiresOn.getTime() - 5 * 60 * 1000;
|
|
46
|
-
}
|
|
47
|
-
return this.accessToken;
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
const errorMessage = error.message || 'Unknown error';
|
|
51
|
-
console.error('Service Principal authentication failed:', errorMessage);
|
|
52
|
-
throw new Error(`Service Principal authentication failed: ${errorMessage}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async getUserInfo() {
|
|
56
|
-
// Service principal doesn't have user info
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=service-principal-auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-principal-auth.js","sourceRoot":"","sources":["../../src/auth/service-principal-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH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