@microsoft/agents-hosting 1.1.1 → 1.1.4-geb1c05c291
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/dist/package.json +2 -2
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +4 -0
- package/dist/src/app/auth/handlers/agenticAuthorization.js +12 -7
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
- package/package.json +2 -2
- package/src/app/auth/handlers/agenticAuthorization.ts +13 -7
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4-geb1c05c291",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.1",
|
|
23
23
|
"@azure/msal-node": "^3.8.2",
|
|
24
|
-
"@microsoft/agents-activity": "1.1.
|
|
24
|
+
"@microsoft/agents-activity": "1.1.4-geb1c05c291",
|
|
25
25
|
"axios": "^1.13.2",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0",
|
|
@@ -80,10 +80,14 @@ export declare class AgenticAuthorization implements AuthorizationHandler {
|
|
|
80
80
|
private _key;
|
|
81
81
|
/**
|
|
82
82
|
* Sets the authorization context in the turn state.
|
|
83
|
+
* @param context The turn context in which to set the authorization data.
|
|
84
|
+
* @param scopes The OAuth scopes associated with the authorization context.
|
|
85
|
+
* @param data The token response to store in the turn state.
|
|
83
86
|
*/
|
|
84
87
|
private setContext;
|
|
85
88
|
/**
|
|
86
89
|
* Gets the authorization context from the turn state.
|
|
90
|
+
* @param scopes The OAuth scopes for which the context is being retrieved.
|
|
87
91
|
*/
|
|
88
92
|
private getContext;
|
|
89
93
|
/**
|
|
@@ -60,7 +60,8 @@ class AgenticAuthorization {
|
|
|
60
60
|
async token(context, options) {
|
|
61
61
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
62
62
|
try {
|
|
63
|
-
const
|
|
63
|
+
const scopes = (options === null || options === void 0 ? void 0 : options.scopes) || this._options.scopes;
|
|
64
|
+
const tokenResponse = this.getContext(context, scopes);
|
|
64
65
|
if (tokenResponse.token) {
|
|
65
66
|
logger.debug(this.prefix('Using cached Agentic user token'));
|
|
66
67
|
return tokenResponse;
|
|
@@ -72,8 +73,8 @@ class AgenticAuthorization {
|
|
|
72
73
|
else {
|
|
73
74
|
connection = this.settings.connections.getTokenProvider(context.identity, (_b = context.activity.serviceUrl) !== null && _b !== void 0 ? _b : '');
|
|
74
75
|
}
|
|
75
|
-
const token = await connection.getAgenticUserToken((_c = context.activity.getAgenticTenantId()) !== null && _c !== void 0 ? _c : '', (_d = context.activity.getAgenticInstanceId()) !== null && _d !== void 0 ? _d : '', (_e = context.activity.getAgenticUser()) !== null && _e !== void 0 ? _e : '',
|
|
76
|
-
this.setContext(context, { token });
|
|
76
|
+
const token = await connection.getAgenticUserToken((_c = context.activity.getAgenticTenantId()) !== null && _c !== void 0 ? _c : '', (_d = context.activity.getAgenticInstanceId()) !== null && _d !== void 0 ? _d : '', (_e = context.activity.getAgenticUser()) !== null && _e !== void 0 ? _e : '', scopes);
|
|
77
|
+
this.setContext(context, scopes, { token });
|
|
77
78
|
(_f = this._onSuccess) === null || _f === void 0 ? void 0 : _f.call(this, context);
|
|
78
79
|
return { token };
|
|
79
80
|
}
|
|
@@ -104,16 +105,20 @@ class AgenticAuthorization {
|
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
107
|
* Sets the authorization context in the turn state.
|
|
108
|
+
* @param context The turn context in which to set the authorization data.
|
|
109
|
+
* @param scopes The OAuth scopes associated with the authorization context.
|
|
110
|
+
* @param data The token response to store in the turn state.
|
|
107
111
|
*/
|
|
108
|
-
setContext(context, data) {
|
|
109
|
-
return context.turnState.set(this._key
|
|
112
|
+
setContext(context, scopes, data) {
|
|
113
|
+
return context.turnState.set(`${this._key}:${scopes.join(';')}`, () => data);
|
|
110
114
|
}
|
|
111
115
|
/**
|
|
112
116
|
* Gets the authorization context from the turn state.
|
|
117
|
+
* @param scopes The OAuth scopes for which the context is being retrieved.
|
|
113
118
|
*/
|
|
114
|
-
getContext(context) {
|
|
119
|
+
getContext(context, scopes) {
|
|
115
120
|
var _a;
|
|
116
|
-
const result = context.turnState.get(this._key);
|
|
121
|
+
const result = context.turnState.get(`${this._key}:${scopes.join(';')}`);
|
|
117
122
|
return (_a = result === null || result === void 0 ? void 0 : result()) !== null && _a !== void 0 ? _a : { token: undefined };
|
|
118
123
|
}
|
|
119
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agenticAuthorization.js","sourceRoot":"","sources":["../../../../../src/app/auth/handlers/agenticAuthorization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAkD;AAElD,oCAA2I;AAI3I,MAAM,MAAM,GAAG,IAAA,uBAAK,EAAC,8BAA8B,CAAC,CAAA;AA+BpD;;GAEG;AACH,MAAa,oBAAoB;IAK/B;;;;;OAKG;IACH,YAA6B,EAAU,EAAE,OAAoC,EAAU,QAAsC;QAAhG,OAAE,GAAF,EAAE,CAAQ;QAAgD,aAAQ,GAAR,QAAQ,CAA8B;
|
|
1
|
+
{"version":3,"file":"agenticAuthorization.js","sourceRoot":"","sources":["../../../../../src/app/auth/handlers/agenticAuthorization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAkD;AAElD,oCAA2I;AAI3I,MAAM,MAAM,GAAG,IAAA,uBAAK,EAAC,8BAA8B,CAAC,CAAA;AA+BpD;;GAEG;AACH,MAAa,oBAAoB;IAK/B;;;;;OAKG;IACH,YAA6B,EAAU,EAAE,OAAoC,EAAU,Q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,UAAU,CAAE,KAAwB;;QAC1C,OAAO,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAW,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACvD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACnB,CAAC;YACD,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,mCAAI,EAAE,CAAA;IACd,CAAC;CACF;AA/ID,oDA+IC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4-geb1c05c291",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.1",
|
|
23
23
|
"@azure/msal-node": "^3.8.2",
|
|
24
|
-
"@microsoft/agents-activity": "1.1.
|
|
24
|
+
"@microsoft/agents-activity": "1.1.4-geb1c05c291",
|
|
25
25
|
"axios": "^1.13.2",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0",
|
|
@@ -98,7 +98,9 @@ export class AgenticAuthorization implements AuthorizationHandler {
|
|
|
98
98
|
*/
|
|
99
99
|
async token (context: TurnContext, options?: AuthorizationHandlerTokenOptions): Promise<TokenResponse> {
|
|
100
100
|
try {
|
|
101
|
-
const
|
|
101
|
+
const scopes = options?.scopes || this._options.scopes!
|
|
102
|
+
|
|
103
|
+
const tokenResponse = this.getContext(context, scopes)
|
|
102
104
|
if (tokenResponse.token) {
|
|
103
105
|
logger.debug(this.prefix('Using cached Agentic user token'))
|
|
104
106
|
return tokenResponse
|
|
@@ -116,10 +118,10 @@ export class AgenticAuthorization implements AuthorizationHandler {
|
|
|
116
118
|
context.activity.getAgenticTenantId() ?? '',
|
|
117
119
|
context.activity.getAgenticInstanceId() ?? '',
|
|
118
120
|
context.activity.getAgenticUser() ?? '',
|
|
119
|
-
|
|
121
|
+
scopes
|
|
120
122
|
)
|
|
121
123
|
|
|
122
|
-
this.setContext(context, { token })
|
|
124
|
+
this.setContext(context, scopes, { token })
|
|
123
125
|
this._onSuccess?.(context)
|
|
124
126
|
return { token }
|
|
125
127
|
} catch (error) {
|
|
@@ -155,16 +157,20 @@ export class AgenticAuthorization implements AuthorizationHandler {
|
|
|
155
157
|
|
|
156
158
|
/**
|
|
157
159
|
* Sets the authorization context in the turn state.
|
|
160
|
+
* @param context The turn context in which to set the authorization data.
|
|
161
|
+
* @param scopes The OAuth scopes associated with the authorization context.
|
|
162
|
+
* @param data The token response to store in the turn state.
|
|
158
163
|
*/
|
|
159
|
-
private setContext (context: TurnContext, data: TokenResponse) {
|
|
160
|
-
return context.turnState.set(this._key
|
|
164
|
+
private setContext (context: TurnContext, scopes: string[], data: TokenResponse) {
|
|
165
|
+
return context.turnState.set(`${this._key}:${scopes.join(';')}`, () => data)
|
|
161
166
|
}
|
|
162
167
|
|
|
163
168
|
/**
|
|
164
169
|
* Gets the authorization context from the turn state.
|
|
170
|
+
* @param scopes The OAuth scopes for which the context is being retrieved.
|
|
165
171
|
*/
|
|
166
|
-
private getContext (context: TurnContext): TokenResponse {
|
|
167
|
-
const result = context.turnState.get(this._key)
|
|
172
|
+
private getContext (context: TurnContext, scopes: string[]): TokenResponse {
|
|
173
|
+
const result = context.turnState.get(`${this._key}:${scopes.join(';')}`)
|
|
168
174
|
return result?.() ?? { token: undefined }
|
|
169
175
|
}
|
|
170
176
|
|