@microsoft/agents-hosting 1.6.1 → 1.7.0-beta.1.g8bcd4f11a7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/package.json +3 -3
  2. package/dist/src/app/streaming/streamingResponse.d.ts +11 -0
  3. package/dist/src/app/streaming/streamingResponse.js +21 -0
  4. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  5. package/dist/src/auth/MemoryCache.d.ts +2 -1
  6. package/dist/src/auth/MemoryCache.js +7 -1
  7. package/dist/src/auth/MemoryCache.js.map +1 -1
  8. package/dist/src/auth/authConfiguration.d.ts +1 -1
  9. package/dist/src/auth/authConfiguration.js +36 -1
  10. package/dist/src/auth/authConfiguration.js.map +1 -1
  11. package/dist/src/auth/authConstants.d.ts +7 -7
  12. package/dist/src/auth/authConstants.js.map +1 -1
  13. package/dist/src/auth/connectionManager.d.ts +92 -0
  14. package/dist/src/auth/{msalConnectionManager.js → connectionManager.js} +50 -48
  15. package/dist/src/auth/connectionManager.js.map +1 -0
  16. package/dist/src/auth/index.d.ts +5 -3
  17. package/dist/src/auth/index.js +5 -3
  18. package/dist/src/auth/index.js.map +1 -1
  19. package/dist/src/auth/jwt-middleware.d.ts +6 -0
  20. package/dist/src/auth/jwt-middleware.js +32 -1
  21. package/dist/src/auth/jwt-middleware.js.map +1 -1
  22. package/dist/src/auth/msal/msalConnectionManager.d.ts +17 -0
  23. package/dist/src/auth/msal/msalConnectionManager.js +50 -0
  24. package/dist/src/auth/msal/msalConnectionManager.js.map +1 -0
  25. package/dist/src/auth/msal/msalConnectionSettings.d.ts +68 -0
  26. package/dist/src/auth/msal/msalConnectionSettings.js +7 -0
  27. package/dist/src/auth/msal/msalConnectionSettings.js.map +1 -0
  28. package/dist/src/auth/{msalTokenCredential.d.ts → msal/msalTokenCredential.d.ts} +1 -1
  29. package/dist/src/auth/{msalTokenCredential.js → msal/msalTokenCredential.js} +2 -2
  30. package/dist/src/auth/msal/msalTokenCredential.js.map +1 -0
  31. package/dist/src/auth/{msalTokenProvider.d.ts → msal/msalTokenProvider.d.ts} +23 -3
  32. package/dist/src/auth/{msalTokenProvider.js → msal/msalTokenProvider.js} +264 -160
  33. package/dist/src/auth/msal/msalTokenProvider.js.map +1 -0
  34. package/dist/src/auth/settings.d.ts +142 -133
  35. package/dist/src/auth/settings.js +49 -5
  36. package/dist/src/auth/settings.js.map +1 -1
  37. package/dist/src/auth/sidecar/sidecarAuthProvider.d.ts +74 -0
  38. package/dist/src/auth/sidecar/sidecarAuthProvider.js +181 -0
  39. package/dist/src/auth/sidecar/sidecarAuthProvider.js.map +1 -0
  40. package/dist/src/auth/sidecar/sidecarConnectionSettings.d.ts +65 -0
  41. package/dist/src/auth/sidecar/sidecarConnectionSettings.js +7 -0
  42. package/dist/src/auth/sidecar/sidecarConnectionSettings.js.map +1 -0
  43. package/dist/src/auth/sidecar/sidecarHttpClient.d.ts +95 -0
  44. package/dist/src/auth/sidecar/sidecarHttpClient.js +406 -0
  45. package/dist/src/auth/sidecar/sidecarHttpClient.js.map +1 -0
  46. package/dist/src/auth/sidecar/sidecarModels.d.ts +110 -0
  47. package/dist/src/auth/sidecar/sidecarModels.js +48 -0
  48. package/dist/src/auth/sidecar/sidecarModels.js.map +1 -0
  49. package/dist/src/auth/sidecar/sidecarTokenExpiry.d.ts +13 -0
  50. package/dist/src/auth/sidecar/sidecarTokenExpiry.js +39 -0
  51. package/dist/src/auth/sidecar/sidecarTokenExpiry.js.map +1 -0
  52. package/dist/src/cloudAdapter.js +1 -1
  53. package/dist/src/cloudAdapter.js.map +1 -1
  54. package/dist/src/errorHelper.js +96 -0
  55. package/dist/src/errorHelper.js.map +1 -1
  56. package/dist/src/index.d.ts +1 -1
  57. package/dist/src/index.js +2 -1
  58. package/dist/src/index.js.map +1 -1
  59. package/dist/src/oauth/userTokenClient.d.ts +12 -0
  60. package/dist/src/oauth/userTokenClient.js +28 -8
  61. package/dist/src/oauth/userTokenClient.js.map +1 -1
  62. package/package.json +3 -3
  63. package/src/app/streaming/streamingResponse.ts +24 -1
  64. package/src/auth/MemoryCache.ts +7 -1
  65. package/src/auth/authConfiguration.ts +36 -3
  66. package/src/auth/authConstants.ts +7 -7
  67. package/src/auth/{msalConnectionManager.ts → connectionManager.ts} +65 -61
  68. package/src/auth/index.ts +5 -3
  69. package/src/auth/jwt-middleware.ts +31 -1
  70. package/src/auth/msal/msalConnectionManager.ts +55 -0
  71. package/src/auth/msal/msalConnectionSettings.ts +79 -0
  72. package/src/auth/{msalTokenCredential.ts → msal/msalTokenCredential.ts} +2 -1
  73. package/src/auth/{msalTokenProvider.ts → msal/msalTokenProvider.ts} +337 -156
  74. package/src/auth/settings.ts +131 -76
  75. package/src/auth/sidecar/sidecarAuthProvider.ts +234 -0
  76. package/src/auth/sidecar/sidecarConnectionSettings.ts +72 -0
  77. package/src/auth/sidecar/sidecarHttpClient.ts +443 -0
  78. package/src/auth/sidecar/sidecarModels.ts +153 -0
  79. package/src/auth/sidecar/sidecarTokenExpiry.ts +35 -0
  80. package/src/cloudAdapter.ts +1 -1
  81. package/src/errorHelper.ts +110 -0
  82. package/src/index.ts +1 -1
  83. package/src/oauth/userTokenClient.ts +43 -9
  84. package/dist/src/auth/msalConnectionManager.d.ts +0 -64
  85. package/dist/src/auth/msalConnectionManager.js.map +0 -1
  86. package/dist/src/auth/msalTokenCredential.js.map +0 -1
  87. package/dist/src/auth/msalTokenProvider.js.map +0 -1
@@ -4,41 +4,58 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.MsalConnectionManager = void 0;
7
+ exports.ConnectionManager = exports.defaultAuthProviderFactory = void 0;
8
8
  const agents_activity_1 = require("@microsoft/agents-activity");
9
9
  const agents_telemetry_1 = require("@microsoft/agents-telemetry");
10
10
  const authConfiguration_1 = require("./authConfiguration");
11
- const msalTokenProvider_1 = require("./msalTokenProvider");
11
+ const msalTokenProvider_1 = require("./msal/msalTokenProvider");
12
+ const sidecarAuthProvider_1 = require("./sidecar/sidecarAuthProvider");
13
+ const errorHelper_1 = require("../errorHelper");
12
14
  const logger = (0, agents_telemetry_1.debug)('agents:authorization:connections');
13
- class MsalConnectionManager {
14
- constructor(connectionsConfigurations = new Map(), connectionsMap = [], configuration = {}) {
15
- var _a, _b, _c, _d;
15
+ /**
16
+ * Default {@link AuthProviderFactory} that dispatches per-connection by `authType`: connections with
17
+ * `authType` set to `EntraAuthSideCar` use {@link SidecarAuthProvider}; all others use
18
+ * {@link MsalTokenProvider}.
19
+ * @param config The connection authentication configuration.
20
+ * @returns The auth provider for the connection.
21
+ */
22
+ const defaultAuthProviderFactory = (config) => (config === null || config === void 0 ? void 0 : config.authType) === authConfiguration_1.AuthType.EntraAuthSideCar
23
+ ? new sidecarAuthProvider_1.SidecarAuthProvider(config)
24
+ : new msalTokenProvider_1.MsalTokenProvider(config);
25
+ exports.defaultAuthProviderFactory = defaultAuthProviderFactory;
26
+ /**
27
+ * Generic, provider-agnostic connection manager. Dispatches connections to any {@link AuthProvider}
28
+ * implementation produced by the supplied {@link AuthProviderFactory}, while owning the
29
+ * provider-independent connection routing logic (audience matching, service URL dispatch,
30
+ * `altBlueprintConnectionName` handling, default connection resolution).
31
+ */
32
+ class ConnectionManager {
33
+ /**
34
+ * Creates a new {@link ConnectionManager}.
35
+ * @param providerFactory Factory used to instantiate an {@link AuthProvider} for each connection.
36
+ * @param connectionsConfigurations Map of connection names to their authentication configurations.
37
+ * @param connectionsMap Map items used to route activities to connections.
38
+ * @param configuration Fallback authentication configuration (used when the above are empty).
39
+ */
40
+ constructor(providerFactory = exports.defaultAuthProviderFactory, connectionsConfigurations = new Map(), connectionsMap = [], configuration = {}) {
41
+ var _a, _b, _c;
16
42
  this._connections = new Map();
17
43
  this._connectionsMap = connectionsMap.length > 0 ? connectionsMap : (configuration.connectionsMap || []);
18
44
  this._serviceConnectionConfiguration = {};
19
45
  const providedConnections = connectionsConfigurations.size > 0 ? connectionsConfigurations : (configuration.connections || new Map());
20
46
  for (const [name, config] of providedConnections) {
21
- // Instantiate MsalTokenProvider for each connection
22
- this._connections.set(name, new msalTokenProvider_1.MsalTokenProvider(config));
23
- if (name === MsalConnectionManager.DEFAULT_CONNECTION) {
47
+ this._connections.set(name, providerFactory(config));
48
+ if (name === ConnectionManager.DEFAULT_CONNECTION) {
24
49
  this._serviceConnectionConfiguration = config;
25
50
  }
26
51
  }
27
52
  for (const [name, provider] of this._connections.entries()) {
28
53
  const cfg = provider.connectionSettings;
29
- const authType = (_a = cfg === null || cfg === void 0 ? void 0 : cfg.authType) !== null && _a !== void 0 ? _a : ((cfg === null || cfg === void 0 ? void 0 : cfg.certPemFile)
30
- ? authConfiguration_1.AuthType.Certificate
31
- : (cfg === null || cfg === void 0 ? void 0 : cfg.clientSecret)
32
- ? authConfiguration_1.AuthType.ClientSecret
33
- : (cfg === null || cfg === void 0 ? void 0 : cfg.WIDAssertionFile)
34
- ? authConfiguration_1.AuthType.WorkloadIdentity
35
- : (cfg === null || cfg === void 0 ? void 0 : cfg.federatedClientId) || (cfg === null || cfg === void 0 ? void 0 : cfg.FICClientId)
36
- ? authConfiguration_1.AuthType.FederatedCredentials
37
- : 'none');
38
- logger.debug('connection "%s" clientId=%s tenantId=%s authType=%s', name, (_b = cfg === null || cfg === void 0 ? void 0 : cfg.clientId) !== null && _b !== void 0 ? _b : '<none>', (_c = cfg === null || cfg === void 0 ? void 0 : cfg.tenantId) !== null && _c !== void 0 ? _c : '<none>', authType);
54
+ const authType = (0, authConfiguration_1.resolveAuthType)(cfg);
55
+ logger.debug('connection "%s" clientId=%s tenantId=%s authType=%s', name, (_a = (0, agents_telemetry_1.redactString)(cfg === null || cfg === void 0 ? void 0 : cfg.clientId, true)) !== null && _a !== void 0 ? _a : '<none>', (_b = (0, agents_telemetry_1.redactString)(cfg === null || cfg === void 0 ? void 0 : cfg.tenantId, true)) !== null && _b !== void 0 ? _b : '<none>', authType);
39
56
  }
40
57
  for (const item of this._connectionsMap) {
41
- logger.debug('connectionsMap: %s -> %s audience=%s', item.serviceUrl, item.connection, (_d = item.audience) !== null && _d !== void 0 ? _d : '');
58
+ logger.debug('connectionsMap: %s -> %s audience=%s', item.serviceUrl, item.connection, (_c = item.audience) !== null && _c !== void 0 ? _c : '');
42
59
  }
43
60
  }
44
61
  /**
@@ -49,7 +66,7 @@ class MsalConnectionManager {
49
66
  getConnection(connectionName) {
50
67
  const conn = this._connections.get(connectionName);
51
68
  if (!conn) {
52
- throw new Error(`Connection not found: ${connectionName}`);
69
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ConnectionNotFound, undefined, { connectionName });
53
70
  }
54
71
  return this.applyConnectionDefaults(conn);
55
72
  }
@@ -59,7 +76,7 @@ class MsalConnectionManager {
59
76
  */
60
77
  getDefaultConnection() {
61
78
  if (this._connections.size === 0) {
62
- throw new Error('No connections found for this Agent in the Connections Configuration.');
79
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.NoConnectionsFoundInConfiguration);
63
80
  }
64
81
  // Return the wildcard map item instance.
65
82
  for (const item of this._connectionsMap) {
@@ -90,7 +107,7 @@ class MsalConnectionManager {
90
107
  */
91
108
  getTokenProvider(identity, serviceUrl) {
92
109
  if (!identity) {
93
- throw new Error('Identity is required to get the token provider.');
110
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.IdentityRequiredForTokenProvider);
94
111
  }
95
112
  let audience;
96
113
  if (Array.isArray(identity === null || identity === void 0 ? void 0 : identity.aud)) {
@@ -100,7 +117,7 @@ class MsalConnectionManager {
100
117
  audience = identity.aud;
101
118
  }
102
119
  if (!audience || !serviceUrl)
103
- throw new Error('Audience and Service URL are required to get the token provider.');
120
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.AudienceAndServiceUrlRequiredForTokenProvider);
104
121
  if (this._connectionsMap.length === 0) {
105
122
  logger.debug('no connectionsMap, using default connection for serviceUrl=%s', serviceUrl);
106
123
  return this.getDefaultConnection();
@@ -123,7 +140,7 @@ class MsalConnectionManager {
123
140
  }
124
141
  }
125
142
  }
126
- throw new Error(`No connection found for audience: ${audience} and serviceUrl: ${serviceUrl}`);
143
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.NoConnectionForAudienceAndServiceUrl, undefined, { audience: String(audience), serviceUrl });
127
144
  }
128
145
  /**
129
146
  * Finds a connection based on an activity's blueprint.
@@ -152,31 +169,16 @@ class MsalConnectionManager {
152
169
  getDefaultConnectionConfiguration() {
153
170
  return this._serviceConnectionConfiguration;
154
171
  }
172
+ /**
173
+ * Applies provider-specific defaults to a resolved connection before returning it. The generic
174
+ * base performs no mutation; provider-specific managers may override this.
175
+ * @param conn The resolved auth provider.
176
+ * @returns The auth provider, possibly with defaults applied.
177
+ */
155
178
  applyConnectionDefaults(conn) {
156
- var _a, _b, _c, _d, _e;
157
- var _f, _g, _h;
158
- if (conn.connectionSettings) {
159
- (_a = (_f = conn.connectionSettings).authorityEndpoint) !== null && _a !== void 0 ? _a : (_f.authorityEndpoint = conn.connectionSettings.authority || 'https://login.microsoftonline.com');
160
- (_b = (_g = conn.connectionSettings).authority) !== null && _b !== void 0 ? _b : (_g.authority = conn.connectionSettings.authorityEndpoint);
161
- (_c = (_h = conn.connectionSettings).issuers) !== null && _c !== void 0 ? _c : (_h.issuers = [
162
- 'https://api.botframework.com',
163
- `${(0, authConfiguration_1.resolveAuthority)('https://sts.windows.net', conn.connectionSettings.tenantId)}/`,
164
- `${(0, authConfiguration_1.resolveAuthority)(conn.connectionSettings.authorityEndpoint, conn.connectionSettings.tenantId)}/v2.0`
165
- ]);
166
- // For backward compatibility
167
- if (conn.connectionSettings.federatedClientId) {
168
- conn.connectionSettings.FICClientId = conn.connectionSettings.federatedClientId;
169
- }
170
- if ((_d = conn.connectionSettings.scopes) === null || _d === void 0 ? void 0 : _d.length) {
171
- conn.connectionSettings.scope = (_e = conn.connectionSettings.scopes) === null || _e === void 0 ? void 0 : _e[0];
172
- }
173
- if (conn.connectionSettings.authorityEndpoint) {
174
- conn.connectionSettings.authority = conn.connectionSettings.authorityEndpoint;
175
- }
176
- }
177
179
  return conn;
178
180
  }
179
181
  }
180
- exports.MsalConnectionManager = MsalConnectionManager;
181
- MsalConnectionManager.DEFAULT_CONNECTION = 'serviceConnection';
182
- //# sourceMappingURL=msalConnectionManager.js.map
182
+ exports.ConnectionManager = ConnectionManager;
183
+ ConnectionManager.DEFAULT_CONNECTION = 'serviceConnection';
184
+ //# sourceMappingURL=connectionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../../../src/auth/connectionManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAiF;AACjF,kEAAiE;AACjE,2DAAkF;AAGlF,gEAA4D;AAC5D,uEAAmE;AAEnE,gDAAuC;AAGvC,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,kCAAkC,CAAC,CAAA;AAQxD;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAwB,CAAC,MAAyB,EAAgB,EAAE,CACzG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,MAAK,4BAAQ,CAAC,gBAAgB;IAC5C,CAAC,CAAC,IAAI,yCAAmB,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC,IAAI,qCAAiB,CAAC,MAAM,CAAC,CAAA;AAHtB,QAAA,0BAA0B,8BAGJ;AAEnC;;;;;GAKG;AACH,MAAa,iBAAiB;IAM5B;;;;;;OAMG;IACH,YACE,kBAAuC,kCAA0B,EACjE,4BAA4D,IAAI,GAAG,EAAE,EACrE,iBAAsC,EAAE,EACxC,gBAAmC,EAAE;;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAA;QAC7B,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,C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AO,IAAI,CAAA;IACb,CAAC;;AA9KH,8CA+KC;AA3K2B,oCAAkB,GAAG,mBAAmB,CAAA"}
@@ -1,7 +1,9 @@
1
1
  export * from './authConfiguration';
2
2
  export * from './authConstants';
3
3
  export * from './authProvider';
4
- export * from './msalTokenProvider';
4
+ export * from './msal/msalTokenProvider';
5
5
  export * from './request';
6
- export * from './msalTokenCredential';
7
- export * from './msalConnectionManager';
6
+ export * from './msal/msalTokenCredential';
7
+ export * from './connectionManager';
8
+ export * from './msal/msalConnectionManager';
9
+ export * from './sidecar/sidecarAuthProvider';
@@ -17,8 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./authConfiguration"), exports);
18
18
  __exportStar(require("./authConstants"), exports);
19
19
  __exportStar(require("./authProvider"), exports);
20
- __exportStar(require("./msalTokenProvider"), exports);
20
+ __exportStar(require("./msal/msalTokenProvider"), exports);
21
21
  __exportStar(require("./request"), exports);
22
- __exportStar(require("./msalTokenCredential"), exports);
23
- __exportStar(require("./msalConnectionManager"), exports);
22
+ __exportStar(require("./msal/msalTokenCredential"), exports);
23
+ __exportStar(require("./connectionManager"), exports);
24
+ __exportStar(require("./msal/msalConnectionManager"), exports);
25
+ __exportStar(require("./sidecar/sidecarAuthProvider"), exports);
24
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,kDAA+B;AAC/B,iDAA8B;AAC9B,sDAAmC;AACnC,4CAAyB;AACzB,wDAAqC;AACrC,0DAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,kDAA+B;AAC/B,iDAA8B;AAC9B,2DAAwC;AACxC,4CAAyB;AACzB,6DAA0C;AAC1C,sDAAmC;AACnC,+DAA4C;AAC5C,gEAA6C"}
@@ -5,6 +5,11 @@
5
5
  import { AuthConfiguration } from './authConfiguration';
6
6
  import { Response, NextFunction } from 'express';
7
7
  import { Request } from './request';
8
+ import { JwksClient } from 'jwks-rsa';
9
+ /**
10
+ * Clears process-wide JWKS clients.
11
+ */
12
+ export declare function clearJwksClients(): void;
8
13
  /**
9
14
  * Builds the JWKS URI for the given token issuer and auth configuration.
10
15
  * @param iss The token issuer claim.
@@ -12,6 +17,7 @@ import { Request } from './request';
12
17
  * @returns The JWKS URI string.
13
18
  */
14
19
  export declare function buildJwksUri(iss: string, authConfig: AuthConfiguration): string;
20
+ export declare function getJwksClient(jwksUri: string): JwksClient;
15
21
  /**
16
22
  * Middleware to authorize JWT tokens.
17
23
  * @param authConfig The authentication configuration.
@@ -8,12 +8,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.authorizeJWT = void 0;
11
+ exports.clearJwksClients = clearJwksClients;
11
12
  exports.buildJwksUri = buildJwksUri;
13
+ exports.getJwksClient = getJwksClient;
12
14
  const authConfiguration_1 = require("./authConfiguration");
13
15
  const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
14
16
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
15
17
  const agents_telemetry_1 = require("@microsoft/agents-telemetry");
16
18
  const logger = (0, agents_telemetry_1.debug)('agents:jwt-middleware');
19
+ const jwksClients = new Map();
20
+ const maxJwksClients = 100;
21
+ /**
22
+ * Clears process-wide JWKS clients.
23
+ */
24
+ function clearJwksClients() {
25
+ jwksClients.clear();
26
+ }
17
27
  /**
18
28
  * Builds the JWKS URI for the given token issuer and auth configuration.
19
29
  * @param iss The token issuer claim.
@@ -26,6 +36,26 @@ function buildJwksUri(iss, authConfig) {
26
36
  ? 'https://login.botframework.com/v1/.well-known/keys'
27
37
  : `${(0, authConfiguration_1.resolveAuthority)((_a = authConfig.authorityEndpoint) !== null && _a !== void 0 ? _a : authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`;
28
38
  }
39
+ function getJwksClient(jwksUri) {
40
+ // Check if a client for this JWKS URI already exists in the cache.
41
+ let client = jwksClients.get(jwksUri);
42
+ if (!client) {
43
+ client = (0, jwks_rsa_1.default)({ jwksUri });
44
+ jwksClients.set(jwksUri, client);
45
+ while (jwksClients.size > maxJwksClients) {
46
+ const oldestKey = jwksClients.keys().next().value;
47
+ if (oldestKey === undefined) {
48
+ break;
49
+ }
50
+ jwksClients.delete(oldestKey);
51
+ }
52
+ }
53
+ else {
54
+ jwksClients.delete(jwksUri);
55
+ jwksClients.set(jwksUri, client);
56
+ }
57
+ return client;
58
+ }
29
59
  /**
30
60
  * Verifies the JWT token.
31
61
  * @param raw The raw JWT token.
@@ -51,8 +81,9 @@ const verifyToken = async (raw, config) => {
51
81
  logger.debug(`Audience found at key: ${key}`);
52
82
  const jwksUri = buildJwksUri(payload.iss, authConfig);
53
83
  logger.debug(`fetching keys from ${jwksUri}`);
54
- const jwksClient = (0, jwks_rsa_1.default)({ jwksUri });
84
+ const jwksClient = getJwksClient(jwksUri);
55
85
  const getKey = (header, callback) => {
86
+ // Retrieve the public, issuer-wide signing key from the JWKS endpoint using the kid from the token header.
56
87
  jwksClient.getSigningKey(header.kid, (err, key) => {
57
88
  if (err) {
58
89
  logger.error('jwksClient.getSigningKey ', JSON.stringify(err));
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-middleware.js","sourceRoot":"","sources":["../../../src/auth/jwt-middleware.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAiBH,oCAIC;AAnBD,2DAAyE;AAGzE,wDAA0D;AAC1D,gEAA6F;AAC7F,kEAAmD;AAEnD,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,uBAAuB,CAAC,CAAA;AAE7C;;;;;GAKG;AACH,SAAgB,YAAY,CAAE,GAAW,EAAE,UAA6B;;IACtE,OAAO,GAAG,KAAK,8BAA8B;QAC3C,CAAC,CAAC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IAAI,CAAA;oBACb,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;oBAC9C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,CAAC,CAAA;gBAC9E,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,EAAE,CAAA;QACR,CAAC;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AApCY,QAAA,YAAY,gBAoCxB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { AuthConfiguration } from '../authConfiguration';
6
+ import type { ConnectionMapItem } from '../settings';
7
+ import { AuthProvider } from '../authProvider';
8
+ import { ConnectionManager } from '../connectionManager';
9
+ /**
10
+ * Connection manager backed by MSAL (and, for `EntraAuthSideCar` connections, the Entra sidecar
11
+ * provider). A thin convenience subclass of {@link ConnectionManager} that supplies the default
12
+ * provider factory and applies MSAL-specific connection defaults.
13
+ */
14
+ export declare class MsalConnectionManager extends ConnectionManager {
15
+ constructor(connectionsConfigurations?: Map<string, AuthConfiguration>, connectionsMap?: ConnectionMapItem[], configuration?: AuthConfiguration);
16
+ protected applyConnectionDefaults(conn: AuthProvider): AuthProvider;
17
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MsalConnectionManager = void 0;
8
+ const authConfiguration_1 = require("../authConfiguration");
9
+ const connectionManager_1 = require("../connectionManager");
10
+ /**
11
+ * Connection manager backed by MSAL (and, for `EntraAuthSideCar` connections, the Entra sidecar
12
+ * provider). A thin convenience subclass of {@link ConnectionManager} that supplies the default
13
+ * provider factory and applies MSAL-specific connection defaults.
14
+ */
15
+ class MsalConnectionManager extends connectionManager_1.ConnectionManager {
16
+ constructor(connectionsConfigurations = new Map(), connectionsMap = [], configuration = {}) {
17
+ super(connectionManager_1.defaultAuthProviderFactory, connectionsConfigurations, connectionsMap, configuration);
18
+ }
19
+ applyConnectionDefaults(conn) {
20
+ var _a, _b, _c, _d, _e, _f;
21
+ var _g, _h, _j, _k;
22
+ if (conn.connectionSettings) {
23
+ (_a = (_g = conn.connectionSettings).authorityEndpoint) !== null && _a !== void 0 ? _a : (_g.authorityEndpoint = conn.connectionSettings.authority || 'https://login.microsoftonline.com');
24
+ (_b = (_h = conn.connectionSettings).authority) !== null && _b !== void 0 ? _b : (_h.authority = conn.connectionSettings.authorityEndpoint);
25
+ (_c = (_j = conn.connectionSettings).issuers) !== null && _c !== void 0 ? _c : (_j.issuers = [
26
+ 'https://api.botframework.com',
27
+ `${(0, authConfiguration_1.resolveAuthority)('https://sts.windows.net', conn.connectionSettings.tenantId)}/`,
28
+ `${(0, authConfiguration_1.resolveAuthority)(conn.connectionSettings.authorityEndpoint, conn.connectionSettings.tenantId)}/v2.0`
29
+ ]);
30
+ // For backward compatibility
31
+ if (conn.connectionSettings.federatedClientId) {
32
+ conn.connectionSettings.FICClientId = conn.connectionSettings.federatedClientId;
33
+ }
34
+ if ((_d = conn.connectionSettings.scopes) === null || _d === void 0 ? void 0 : _d.length) {
35
+ conn.connectionSettings.scope = (_e = conn.connectionSettings.scopes) === null || _e === void 0 ? void 0 : _e[0];
36
+ }
37
+ if (conn.connectionSettings.authorityEndpoint) {
38
+ conn.connectionSettings.authority = conn.connectionSettings.authorityEndpoint;
39
+ }
40
+ // .NET parity alias: keep altBlueprintConnectionName and alternateBlueprintConnectionName in sync.
41
+ (_f = (_k = conn.connectionSettings).altBlueprintConnectionName) !== null && _f !== void 0 ? _f : (_k.altBlueprintConnectionName = conn.connectionSettings.alternateBlueprintConnectionName);
42
+ if (conn.connectionSettings.altBlueprintConnectionName) {
43
+ conn.connectionSettings.alternateBlueprintConnectionName = conn.connectionSettings.altBlueprintConnectionName;
44
+ }
45
+ }
46
+ return conn;
47
+ }
48
+ }
49
+ exports.MsalConnectionManager = MsalConnectionManager;
50
+ //# sourceMappingURL=msalConnectionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msalConnectionManager.js","sourceRoot":"","sources":["../../../../src/auth/msal/msalConnectionManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA0E;AAG1E,4DAAoF;AAEpF;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,qCAAiB;IAC1D,YACE,4BAA4D,IAAI,GAAG,EAAE,EACrE,iBAAsC,EAAE,EACxC,gBAAmC,EAAE;QACrC,KAAK,CAAC,8CAA0B,EAAE,yBAAyB,EAAE,cAAc,EAAE,aAAa,CAAC,CAAA;IAC7F,CAAC;IAES,uBAAuB,CAAE,IAAkB;;;QACnD,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,YAAA,IAAI,CAAC,kBAAkB,EAAC,iBAAiB,uCAAjB,iBAAiB,GAAK,IAAI,CAAC,kBAAkB,CAAC,SAAS,IAAI,mCAAmC,EAAA;YACtH,YAAA,IAAI,CAAC,kBAAkB,EAAC,SAAS,uCAAT,SAAS,GAAK,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EAAA;YAC/E,YAAA,IAAI,CAAC,kBAAkB,EAAC,OAAO,uCAAP,OAAO,GAAK;gBAClC,8BAA8B;gBAC9B,GAAG,IAAA,oCAAgB,EAAC,yBAAyB,EAAE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG;gBACnF,GAAG,IAAA,oCAAgB,EAAC,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO;aACxG,EAAA;YACD,6BAA6B;YAC7B,IAAI,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,CAAC;gBAC9C,IAAI,CAAC,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAA;YACjF,CAAC;YAED,IAAI,MAAA,IAAI,CAAC,kBAAkB,CAAC,MAAM,0CAAE,MAAM,EAAE,CAAC;gBAC3C,IAAI,CAAC,kBAAkB,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,kBAAkB,CAAC,MAAM,0CAAG,CAAC,CAAC,CAAA;YACrE,CAAC;YAED,IAAI,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,CAAC;gBAC9C,IAAI,CAAC,kBAAkB,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAA;YAC/E,CAAC;YAED,mGAAmG;YACnG,YAAA,IAAI,CAAC,kBAAkB,EAAC,0BAA0B,uCAA1B,0BAA0B,GAAK,IAAI,CAAC,kBAAkB,CAAC,gCAAgC,EAAA;YAC/G,IAAI,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,EAAE,CAAC;gBACvD,IAAI,CAAC,kBAAkB,CAAC,gCAAgC,GAAG,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,CAAA;YAC/G,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvCD,sDAuCC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { ConnectionSettingsBase } from '../settings';
6
+ /**
7
+ * Connection settings for the MSAL-backed authentication providers (the default providers used for
8
+ * every {@link AuthType} except `EntraAuthSideCar`).
9
+ *
10
+ * @remarks
11
+ * Mirrors the .NET `Microsoft.Agents.Authentication.Msal.Model.ConnectionSettings` class. Node.js uses
12
+ * PEM certificate files (`certPemFile`/`certKeyFile`) rather than the Windows certificate store, so the
13
+ * .NET `CertThumbprint`/`CertSubjectName`/`CertStoreName`/`ValidCertificateOnly` settings have no JS
14
+ * equivalent; all other MSAL properties map one-to-one.
15
+ */
16
+ export interface MsalConnectionSettings extends ConnectionSettingsBase {
17
+ /**
18
+ * The client secret for the authentication configuration.
19
+ */
20
+ clientSecret?: string;
21
+ /**
22
+ * The path to the certificate PEM file.
23
+ */
24
+ certPemFile?: string;
25
+ /**
26
+ * The path to the certificate key file.
27
+ */
28
+ certKeyFile?: string;
29
+ /**
30
+ * Indicates whether to send the X5C param or not (for SNI authentication).
31
+ */
32
+ sendX5C?: boolean;
33
+ /**
34
+ * @deprecated Use federatedClientId instead.
35
+ *
36
+ * The FIC (First-Party Integration Channel) client ID.
37
+ */
38
+ FICClientId?: string;
39
+ /**
40
+ * @deprecated Use `authType` set to `'WorkloadIdentity'` and `federatedTokenFile` instead.
41
+ *
42
+ * The path to K8s provided token.
43
+ */
44
+ WIDAssertionFile?: string;
45
+ /**
46
+ * The Azure region for ESTS-R regional token acquisition (e.g. 'westus', 'eastus').
47
+ * When set, MSAL routes token requests to the specified regional endpoint.
48
+ * See https://learn.microsoft.com/en-us/entra/msal/javascript/node/regional-authorities for details.
49
+ */
50
+ azureRegion?: string;
51
+ /**
52
+ * The path to the federated token file used for Workload Identity authentication.
53
+ */
54
+ federatedTokenFile?: string;
55
+ /**
56
+ * Sets the resource URL for Identity Proxy Manager (IDPM).
57
+ *
58
+ * @remarks
59
+ * Set this to the appropriate resource identifier when the application is running in an environment,
60
+ * such as a Foundry container, that exposes Managed Identity through a container-specific IMDS endpoint.
61
+ * This setting is only meaningful when using Identity Proxy Manager (AuthType.IdentityProxyManager) for authentication.
62
+ */
63
+ idpmResource?: string;
64
+ /**
65
+ * The federated client ID for the authentication configuration, used for workload identity federation scenarios.
66
+ */
67
+ federatedClientId?: string;
68
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=msalConnectionSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msalConnectionSettings.js","sourceRoot":"","sources":["../../../../src/auth/msal/msalConnectionSettings.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -1,5 +1,5 @@
1
1
  import { GetTokenOptions, TokenCredential } from '@azure/core-auth';
2
- import { AuthConfiguration } from './';
2
+ import { AuthConfiguration } from '../authConfiguration';
3
3
  /**
4
4
  * Token credential implementation that uses MSAL (Microsoft Authentication Library) to acquire access tokens.
5
5
  * Implements the Azure Core Auth TokenCredential interface for authentication scenarios.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MsalTokenCredential = void 0;
4
- const _1 = require("./");
4
+ const msalTokenProvider_1 = require("./msalTokenProvider");
5
5
  const agents_telemetry_1 = require("@microsoft/agents-telemetry");
6
6
  const logger = (0, agents_telemetry_1.debug)('agents:msal');
7
7
  /**
@@ -25,7 +25,7 @@ class MsalTokenCredential {
25
25
  async getToken(scopes, options) {
26
26
  logger.debug('getToken scopes=%o', scopes);
27
27
  const scope = scopes[0].substring(0, scopes[0].lastIndexOf('/'));
28
- const token = await new _1.MsalTokenProvider().getAccessToken(this.authConfig, scope);
28
+ const token = await new msalTokenProvider_1.MsalTokenProvider().getAccessToken(this.authConfig, scope);
29
29
  return {
30
30
  token,
31
31
  expiresOnTimestamp: Date.now() + 10000
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msalTokenCredential.js","sourceRoot":"","sources":["../../../../src/auth/msal/msalTokenCredential.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,kEAAmD;AAEnD,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,aAAa,CAAC,CAAA;AAEnC;;;GAGG;AACH,MAAa,mBAAmB;IAC9B;;;OAGG;IACH,YAAqB,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAEtD;;;;;OAKG;IACI,KAAK,CAAC,QAAQ,CAAE,MAAgB,EAAE,OAAyB;QAChE,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAA;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QAChE,MAAM,KAAK,GAAG,MAAM,IAAI,qCAAiB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAClF,OAAO;YACL,KAAK;YACL,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;SACvC,CAAA;IACH,CAAC;CACF;AAtBD,kDAsBC"}
@@ -2,15 +2,35 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { AuthConfiguration } from './authConfiguration';
6
- import { AuthProvider } from './authProvider';
5
+ import { AuthConfiguration } from '../authConfiguration';
6
+ import { AuthProvider } from '../authProvider';
7
7
  /**
8
8
  * Provides tokens using MSAL.
9
9
  */
10
10
  export declare class MsalTokenProvider implements AuthProvider {
11
- private readonly _agenticTokenCache;
11
+ private static readonly _accessTokenCache;
12
+ private static readonly _agenticTokenCache;
13
+ private static readonly _confidentialClients;
14
+ private static readonly _maxConfidentialClients;
12
15
  readonly connectionSettings?: AuthConfiguration;
13
16
  constructor(connectionSettings?: AuthConfiguration);
17
+ /**
18
+ * Clears process-wide auth caches.
19
+ */
20
+ static clearSharedCaches(): void;
21
+ private static cacheKey;
22
+ private static digest;
23
+ private getOrCreateConfidentialClient;
24
+ private getFileCacheIdentity;
25
+ private getAccessTokenCacheKey;
26
+ private cacheAccessToken;
27
+ private cacheAgenticToken;
28
+ private cacheAgenticAuthenticationResult;
29
+ private getAgenticTokenCacheKey;
30
+ private getTokenCacheTtlSeconds;
31
+ private getJwtExpiresAtMs;
32
+ private getClientSecretClient;
33
+ private getCertificateClient;
14
34
  /**
15
35
  * Gets an access token using the auth configuration from the MsalTokenProvider instance and the provided scope.
16
36
  * @param scope The scope for the token.