@microsoft/agents-hosting 1.6.1 → 1.7.0-beta.5.g67b2005119
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/README.md +16 -0
- package/dist/package.json +3 -3
- package/dist/src/agent-client/agentClient.js +4 -3
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.d.ts +25 -6
- package/dist/src/agent-client/agentResponseHandler.js +16 -55
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/agent-client/createAgentResponseHandler.d.ts +48 -0
- package/dist/src/agent-client/createAgentResponseHandler.js +92 -0
- package/dist/src/agent-client/createAgentResponseHandler.js.map +1 -0
- package/dist/src/agent-client/index.d.ts +1 -0
- package/dist/src/agent-client/index.js +1 -0
- package/dist/src/agent-client/index.js.map +1 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.js +2 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +13 -12
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.js +8 -8
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.d.ts +11 -0
- package/dist/src/app/streaming/streamingResponse.js +23 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/turnState.d.ts +0 -1
- package/dist/src/app/turnState.js +15 -14
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/app/turnStateProperty.js +4 -2
- package/dist/src/app/turnStateProperty.js.map +1 -1
- package/dist/src/auth/MemoryCache.d.ts +2 -1
- package/dist/src/auth/MemoryCache.js +7 -1
- package/dist/src/auth/MemoryCache.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +1 -1
- package/dist/src/auth/authConfiguration.js +41 -4
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/authConstants.d.ts +7 -7
- package/dist/src/auth/authConstants.js.map +1 -1
- package/dist/src/auth/connectionManager.d.ts +92 -0
- package/dist/src/auth/{msalConnectionManager.js → connectionManager.js} +50 -48
- package/dist/src/auth/connectionManager.js.map +1 -0
- package/dist/src/auth/index.d.ts +5 -3
- package/dist/src/auth/index.js +5 -3
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/jwt-middleware.d.ts +8 -2
- package/dist/src/auth/jwt-middleware.js +116 -7
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msal/msalConnectionManager.d.ts +17 -0
- package/dist/src/auth/msal/msalConnectionManager.js +50 -0
- package/dist/src/auth/msal/msalConnectionManager.js.map +1 -0
- package/dist/src/auth/msal/msalConnectionSettings.d.ts +68 -0
- package/dist/src/auth/msal/msalConnectionSettings.js +7 -0
- package/dist/src/auth/msal/msalConnectionSettings.js.map +1 -0
- package/dist/src/auth/{msalTokenCredential.d.ts → msal/msalTokenCredential.d.ts} +1 -1
- package/dist/src/auth/{msalTokenCredential.js → msal/msalTokenCredential.js} +2 -2
- package/dist/src/auth/msal/msalTokenCredential.js.map +1 -0
- package/dist/src/auth/{msalTokenProvider.d.ts → msal/msalTokenProvider.d.ts} +23 -3
- package/dist/src/auth/{msalTokenProvider.js → msal/msalTokenProvider.js} +280 -176
- package/dist/src/auth/msal/msalTokenProvider.js.map +1 -0
- package/dist/src/auth/settings.d.ts +142 -133
- package/dist/src/auth/settings.js +49 -5
- package/dist/src/auth/settings.js.map +1 -1
- package/dist/src/auth/sidecar/sidecarAuthProvider.d.ts +74 -0
- package/dist/src/auth/sidecar/sidecarAuthProvider.js +181 -0
- package/dist/src/auth/sidecar/sidecarAuthProvider.js.map +1 -0
- package/dist/src/auth/sidecar/sidecarConnectionSettings.d.ts +65 -0
- package/dist/src/auth/sidecar/sidecarConnectionSettings.js +7 -0
- package/dist/src/auth/sidecar/sidecarConnectionSettings.js.map +1 -0
- package/dist/src/auth/sidecar/sidecarHttpClient.d.ts +95 -0
- package/dist/src/auth/sidecar/sidecarHttpClient.js +406 -0
- package/dist/src/auth/sidecar/sidecarHttpClient.js.map +1 -0
- package/dist/src/auth/sidecar/sidecarModels.d.ts +110 -0
- package/dist/src/auth/sidecar/sidecarModels.js +48 -0
- package/dist/src/auth/sidecar/sidecarModels.js.map +1 -0
- package/dist/src/auth/sidecar/sidecarTokenExpiry.d.ts +13 -0
- package/dist/src/auth/sidecar/sidecarTokenExpiry.js +39 -0
- package/dist/src/auth/sidecar/sidecarTokenExpiry.js.map +1 -0
- package/dist/src/baseAdapter.js +3 -1
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +2 -2
- package/dist/src/cloudAdapter.js +11 -11
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/createCloudAdapter.d.ts +40 -0
- package/dist/src/createCloudAdapter.js +44 -0
- package/dist/src/createCloudAdapter.js.map +1 -0
- package/dist/src/errorHelper.js +302 -79
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/headerPropagation.js +3 -1
- package/dist/src/headerPropagation.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces/index.d.ts +5 -0
- package/dist/src/interfaces/index.js +22 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/webResponse.d.ts +41 -0
- package/dist/src/interfaces/webResponse.js +7 -0
- package/dist/src/interfaces/webResponse.js.map +1 -0
- package/dist/src/middlewareSet.d.ts +0 -1
- package/dist/src/middlewareSet.js +4 -1
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +12 -0
- package/dist/src/oauth/userTokenClient.js +30 -9
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/state/conversationState.js +4 -2
- package/dist/src/state/conversationState.js.map +1 -1
- package/dist/src/state/userState.js +4 -2
- package/dist/src/state/userState.js.map +1 -1
- package/dist/src/storage/memoryStorage.js +5 -3
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/transcript/consoleTranscriptLogger.js +3 -1
- package/dist/src/transcript/consoleTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/fileTranscriptLogger.js +5 -4
- package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.js +2 -1
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +3 -3
- package/src/agent-client/agentClient.ts +5 -4
- package/src/agent-client/agentResponseHandler.ts +43 -67
- package/src/agent-client/createAgentResponseHandler.ts +133 -0
- package/src/agent-client/index.ts +1 -0
- package/src/app/adaptiveCards/activityValueParsers.ts +3 -2
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +5 -5
- package/src/app/agentApplication.ts +8 -16
- package/src/app/streaming/streamingResponse.ts +26 -3
- package/src/app/turnState.ts +15 -14
- package/src/app/turnStateProperty.ts +4 -2
- package/src/auth/MemoryCache.ts +7 -1
- package/src/auth/authConfiguration.ts +41 -6
- package/src/auth/authConstants.ts +7 -7
- package/src/auth/{msalConnectionManager.ts → connectionManager.ts} +65 -61
- package/src/auth/index.ts +5 -3
- package/src/auth/jwt-middleware.ts +118 -9
- package/src/auth/msal/msalConnectionManager.ts +55 -0
- package/src/auth/msal/msalConnectionSettings.ts +79 -0
- package/src/auth/{msalTokenCredential.ts → msal/msalTokenCredential.ts} +2 -1
- package/src/auth/{msalTokenProvider.ts → msal/msalTokenProvider.ts} +353 -172
- package/src/auth/settings.ts +131 -76
- package/src/auth/sidecar/sidecarAuthProvider.ts +234 -0
- package/src/auth/sidecar/sidecarConnectionSettings.ts +72 -0
- package/src/auth/sidecar/sidecarHttpClient.ts +443 -0
- package/src/auth/sidecar/sidecarModels.ts +153 -0
- package/src/auth/sidecar/sidecarTokenExpiry.ts +35 -0
- package/src/baseAdapter.ts +3 -2
- package/src/cloudAdapter.ts +13 -13
- package/src/createCloudAdapter.ts +56 -0
- package/src/errorHelper.ts +354 -89
- package/src/headerPropagation.ts +4 -1
- package/src/index.ts +3 -1
- package/src/interfaces/index.ts +6 -0
- package/src/interfaces/webResponse.ts +44 -0
- package/src/middlewareSet.ts +3 -1
- package/src/oauth/userTokenClient.ts +46 -11
- package/src/state/conversationState.ts +4 -3
- package/src/state/userState.ts +4 -3
- package/src/storage/memoryStorage.ts +5 -3
- package/src/transcript/consoleTranscriptLogger.ts +3 -2
- package/src/transcript/fileTranscriptLogger.ts +6 -5
- package/src/transcript/transcriptLoggerMiddleware.ts +3 -2
- package/src/turnContext.ts +3 -2
- package/dist/src/auth/msalConnectionManager.d.ts +0 -64
- package/dist/src/auth/msalConnectionManager.js.map +0 -1
- package/dist/src/auth/msalTokenCredential.js.map +0 -1
- package/dist/src/auth/msalTokenProvider.js.map +0 -1
|
@@ -8,12 +8,24 @@ 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");
|
|
15
|
+
const errorHelper_1 = require("../errorHelper");
|
|
16
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
13
17
|
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
14
18
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
15
19
|
const agents_telemetry_1 = require("@microsoft/agents-telemetry");
|
|
16
20
|
const logger = (0, agents_telemetry_1.debug)('agents:jwt-middleware');
|
|
21
|
+
const jwksClients = new Map();
|
|
22
|
+
const maxJwksClients = 100;
|
|
23
|
+
/**
|
|
24
|
+
* Clears process-wide JWKS clients.
|
|
25
|
+
*/
|
|
26
|
+
function clearJwksClients() {
|
|
27
|
+
jwksClients.clear();
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* Builds the JWKS URI for the given token issuer and auth configuration.
|
|
19
31
|
* @param iss The token issuer claim.
|
|
@@ -26,6 +38,26 @@ function buildJwksUri(iss, authConfig) {
|
|
|
26
38
|
? 'https://login.botframework.com/v1/.well-known/keys'
|
|
27
39
|
: `${(0, authConfiguration_1.resolveAuthority)((_a = authConfig.authorityEndpoint) !== null && _a !== void 0 ? _a : authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`;
|
|
28
40
|
}
|
|
41
|
+
function getJwksClient(jwksUri) {
|
|
42
|
+
// Check if a client for this JWKS URI already exists in the cache.
|
|
43
|
+
let client = jwksClients.get(jwksUri);
|
|
44
|
+
if (!client) {
|
|
45
|
+
client = (0, jwks_rsa_1.default)({ jwksUri });
|
|
46
|
+
jwksClients.set(jwksUri, client);
|
|
47
|
+
while (jwksClients.size > maxJwksClients) {
|
|
48
|
+
const oldestKey = jwksClients.keys().next().value;
|
|
49
|
+
if (oldestKey === undefined) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
jwksClients.delete(oldestKey);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
jwksClients.delete(jwksUri);
|
|
57
|
+
jwksClients.set(jwksUri, client);
|
|
58
|
+
}
|
|
59
|
+
return client;
|
|
60
|
+
}
|
|
29
61
|
/**
|
|
30
62
|
* Verifies the JWT token.
|
|
31
63
|
* @param raw The raw JWT token.
|
|
@@ -36,14 +68,14 @@ const verifyToken = async (raw, config) => {
|
|
|
36
68
|
const payload = jsonwebtoken_1.default.decode(raw);
|
|
37
69
|
logger.debug('jwt.decode ', JSON.stringify(payload));
|
|
38
70
|
if (!payload) {
|
|
39
|
-
throw
|
|
71
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.InvalidJwtToken);
|
|
40
72
|
}
|
|
41
73
|
const audience = payload.aud;
|
|
42
74
|
const matchingEntry = config.connections && config.connections.size > 0
|
|
43
75
|
? [...config.connections.entries()].find(([_, configuration]) => configuration.clientId === audience)
|
|
44
76
|
: undefined;
|
|
45
77
|
if (!matchingEntry) {
|
|
46
|
-
const err =
|
|
78
|
+
const err = agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.JwtAudienceMismatch);
|
|
47
79
|
logger.error(err.message, audience);
|
|
48
80
|
throw err;
|
|
49
81
|
}
|
|
@@ -51,8 +83,9 @@ const verifyToken = async (raw, config) => {
|
|
|
51
83
|
logger.debug(`Audience found at key: ${key}`);
|
|
52
84
|
const jwksUri = buildJwksUri(payload.iss, authConfig);
|
|
53
85
|
logger.debug(`fetching keys from ${jwksUri}`);
|
|
54
|
-
const jwksClient = (
|
|
86
|
+
const jwksClient = getJwksClient(jwksUri);
|
|
55
87
|
const getKey = (header, callback) => {
|
|
88
|
+
// Retrieve the public, issuer-wide signing key from the JWKS endpoint using the kid from the token header.
|
|
56
89
|
jwksClient.getSigningKey(header.kid, (err, key) => {
|
|
57
90
|
if (err) {
|
|
58
91
|
logger.error('jwksClient.getSigningKey ', JSON.stringify(err));
|
|
@@ -81,6 +114,68 @@ const verifyToken = async (raw, config) => {
|
|
|
81
114
|
});
|
|
82
115
|
});
|
|
83
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Determines whether an `Authorization` header value is present (non-empty).
|
|
119
|
+
*
|
|
120
|
+
* The {@link Request} contract allows `string | string[] | undefined` because
|
|
121
|
+
* different web frameworks surface headers differently. This treats an empty
|
|
122
|
+
* string or empty array as "absent" so callers can distinguish a missing header
|
|
123
|
+
* (anonymous / 401) from a present-but-malformed one (always 401).
|
|
124
|
+
* @param authorization The raw `Authorization` header value.
|
|
125
|
+
* @returns `true` when a non-empty header value is present.
|
|
126
|
+
*/
|
|
127
|
+
function hasAuthorizationHeader(authorization) {
|
|
128
|
+
if (Array.isArray(authorization)) {
|
|
129
|
+
return authorization.some((value) => typeof value === 'string' && value.trim().length > 0);
|
|
130
|
+
}
|
|
131
|
+
return typeof authorization === 'string' && authorization.trim().length > 0;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Parses a single `Authorization` header value and returns its bearer token.
|
|
135
|
+
*
|
|
136
|
+
* Validates the `Bearer <token>` scheme, returning `undefined` for anything
|
|
137
|
+
* malformed (wrong scheme, missing token, or extra whitespace-delimited parts).
|
|
138
|
+
* @param headerValue A single `Authorization` header value.
|
|
139
|
+
* @returns The bearer token, or `undefined` if the value is absent or malformed.
|
|
140
|
+
*/
|
|
141
|
+
function parseBearerValue(headerValue) {
|
|
142
|
+
if (typeof headerValue !== 'string') {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
const parts = headerValue.trim().split(/\s+/);
|
|
146
|
+
if (parts.length !== 2) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const [scheme, token] = parts;
|
|
150
|
+
if (scheme.toLowerCase() !== 'bearer' || !token) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return token;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Extracts the bearer token from a raw `Authorization` header value.
|
|
157
|
+
*
|
|
158
|
+
* On Node's core HTTP parser (which both Express and Fastify use) `Authorization`
|
|
159
|
+
* is always surfaced as a single string holding the *first* header line —
|
|
160
|
+
* duplicate `Authorization` headers are discarded, not comma-joined. The
|
|
161
|
+
* `string[]` case is handled only because the {@link Request} contract permits
|
|
162
|
+
* it for non-Node frameworks; when an array is supplied, every entry is inspected
|
|
163
|
+
* and the first valid `Bearer <token>` is returned (the bearer value is not
|
|
164
|
+
* assumed to be first). Returns `undefined` for anything malformed so the caller
|
|
165
|
+
* can emit a consistent 401 instead of throwing.
|
|
166
|
+
* @param authorization The raw `Authorization` header value.
|
|
167
|
+
* @returns The bearer token, or `undefined` if the header is absent or malformed.
|
|
168
|
+
*/
|
|
169
|
+
function extractBearerToken(authorization) {
|
|
170
|
+
const values = Array.isArray(authorization) ? authorization : [authorization];
|
|
171
|
+
for (const value of values) {
|
|
172
|
+
const token = parseBearerValue(value);
|
|
173
|
+
if (token) {
|
|
174
|
+
return token;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
84
179
|
/**
|
|
85
180
|
* Middleware to authorize JWT tokens.
|
|
86
181
|
* @param authConfig The authentication configuration.
|
|
@@ -88,6 +183,7 @@ const verifyToken = async (raw, config) => {
|
|
|
88
183
|
*/
|
|
89
184
|
const authorizeJWT = (authConfig) => {
|
|
90
185
|
return async function (req, res, next) {
|
|
186
|
+
var _a, _b;
|
|
91
187
|
let failed = false;
|
|
92
188
|
logger.debug('authorizing jwt');
|
|
93
189
|
if (req.method !== 'POST' && req.method !== 'GET') {
|
|
@@ -96,9 +192,8 @@ const authorizeJWT = (authConfig) => {
|
|
|
96
192
|
res.status(405).send({ 'jwt-auth-error': 'Method not allowed' });
|
|
97
193
|
}
|
|
98
194
|
else {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
const token = authHeader.split(' ')[1]; // Extract the token from the Bearer string
|
|
195
|
+
const token = extractBearerToken(req.headers.authorization);
|
|
196
|
+
if (token) {
|
|
102
197
|
try {
|
|
103
198
|
const user = await verifyToken(token, authConfig);
|
|
104
199
|
logger.debug('token verified for ', user);
|
|
@@ -107,9 +202,23 @@ const authorizeJWT = (authConfig) => {
|
|
|
107
202
|
catch (err) {
|
|
108
203
|
failed = true;
|
|
109
204
|
logger.error(err);
|
|
110
|
-
|
|
205
|
+
// Emit only the human-readable description rather than the
|
|
206
|
+
// ExceptionHelper-formatted "[code] - description - helplink" string,
|
|
207
|
+
// so the wire format does not leak internal error codes or help links.
|
|
208
|
+
// Fall back to a stable string so a thrown non-Error (no description/
|
|
209
|
+
// message) never serializes to an empty `{}` and drops the detail.
|
|
210
|
+
const wireMessage = (_b = (_a = err === null || err === void 0 ? void 0 : err.description) !== null && _a !== void 0 ? _a : err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : 'unauthorized';
|
|
211
|
+
res.status(401).send({ 'jwt-auth-error': wireMessage });
|
|
111
212
|
}
|
|
112
213
|
}
|
|
214
|
+
else if (hasAuthorizationHeader(req.headers.authorization)) {
|
|
215
|
+
// Header is present but not a well-formed `Bearer <token>` (e.g. wrong
|
|
216
|
+
// scheme, missing token, or an array value). Respond with a consistent
|
|
217
|
+
// 401 rather than letting malformed input throw before authorization.
|
|
218
|
+
failed = true;
|
|
219
|
+
logger.warn('malformed authorization header');
|
|
220
|
+
res.status(401).send({ 'jwt-auth-error': 'invalid authorization header' });
|
|
221
|
+
}
|
|
113
222
|
else {
|
|
114
223
|
if (!authConfig.clientId && process.env.NODE_ENV !== 'production') {
|
|
115
224
|
logger.info('using anonymous auth');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-middleware.js","sourceRoot":"","sources":["../../../src/auth/jwt-middleware.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;
|
|
1
|
+
{"version":3,"file":"jwt-middleware.js","sourceRoot":"","sources":["../../../src/auth/jwt-middleware.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAkBH,4CAEC;AAQD,oCAIC;AAED,sCAkBC;AAlDD,2DAAyE;AAGzE,gDAAuC;AACvC,gEAA4D;AAC5D,wDAA0D;AAC1D,gEAA6F;AAC7F,kEAAmD;AAEnD,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,uBAAuB,CAAC,CAAA;AAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAA;AACjD,MAAM,cAAc,GAAG,GAAG,CAAA;AAE1B;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,WAAW,CAAC,KAAK,EAAE,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAE,GAAW,EAAE,UAA6B;;IACtE,OAAO,GAAG,KA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O,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC7D,uEAAuE;gBACvE,uEAAuE;gBACvE,sEAAsE;gBACtE,MAAM,GAAG,IAAI,CAAA;gBACb,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAA;gBAC7C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,CAAC,CAAA;YAC5E,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;oBAClE,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;oBACnC,GAAG,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;gBAClC,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,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;AAhDY,QAAA,YAAY,gBAgDxB"}
|
|
@@ -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
|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C,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 @@
|
|
|
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
|
|
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
|
|
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 '
|
|
6
|
-
import { AuthProvider } from '
|
|
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
|
|
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.
|