@microsoft/agents-hosting 1.0.7-g73d3d58001 → 1.0.13
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 +3 -3
- package/dist/src/baseAdapter.d.ts +11 -0
- package/dist/src/baseAdapter.js +14 -0
- package/dist/src/baseAdapter.js.map +1 -1
- package/package.json +3 -3
- package/src/baseAdapter.ts +14 -0
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.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.0",
|
|
23
|
-
"@azure/msal-node": "^3.
|
|
24
|
-
"@microsoft/agents-activity": "1.0.
|
|
23
|
+
"@azure/msal-node": "^3.7.0",
|
|
24
|
+
"@microsoft/agents-activity": "1.0.13",
|
|
25
25
|
"axios": "^1.11.0",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0"
|
|
@@ -120,6 +120,17 @@ export declare abstract class BaseAdapter {
|
|
|
120
120
|
* @returns The adapter instance.
|
|
121
121
|
*/
|
|
122
122
|
use(...middlewares: Array<MiddlewareHandler | Middleware>): this;
|
|
123
|
+
/**
|
|
124
|
+
* This method creates a revocable proxy for the given target object.
|
|
125
|
+
* If the environment does not support Proxy.revocable, it returns the original object.
|
|
126
|
+
* @remarks
|
|
127
|
+
* This is used to enhance security by allowing the proxy to be revoked after use,
|
|
128
|
+
* preventing further access to the underlying object.
|
|
129
|
+
*
|
|
130
|
+
* @param target The target object to be proxied.
|
|
131
|
+
* @param handler Optional proxy handler to customize behavior.
|
|
132
|
+
* @returns An object containing the proxy and a revoke function.
|
|
133
|
+
*/
|
|
123
134
|
private makeRevocable;
|
|
124
135
|
/**
|
|
125
136
|
* Runs the middleware pipeline in sequence.
|
package/dist/src/baseAdapter.js
CHANGED
|
@@ -82,6 +82,17 @@ class BaseAdapter {
|
|
|
82
82
|
this.middleware.use(...middlewares);
|
|
83
83
|
return this;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* This method creates a revocable proxy for the given target object.
|
|
87
|
+
* If the environment does not support Proxy.revocable, it returns the original object.
|
|
88
|
+
* @remarks
|
|
89
|
+
* This is used to enhance security by allowing the proxy to be revoked after use,
|
|
90
|
+
* preventing further access to the underlying object.
|
|
91
|
+
*
|
|
92
|
+
* @param target The target object to be proxied.
|
|
93
|
+
* @param handler Optional proxy handler to customize behavior.
|
|
94
|
+
* @returns An object containing the proxy and a revoke function.
|
|
95
|
+
*/
|
|
85
96
|
makeRevocable(target, handler) {
|
|
86
97
|
// Ensure proxy supported (some browsers don't)
|
|
87
98
|
if (typeof Proxy !== 'undefined' && Proxy.revocable) {
|
|
@@ -106,6 +117,7 @@ class BaseAdapter {
|
|
|
106
117
|
if (context && context.activity && context.activity.locale) {
|
|
107
118
|
context.locale = context.activity.locale;
|
|
108
119
|
}
|
|
120
|
+
// Create a revocable proxy for the context which will automatically be revoked upon completion of the turn.
|
|
109
121
|
const pContext = this.makeRevocable(context);
|
|
110
122
|
try {
|
|
111
123
|
await this.middleware.run(pContext.proxy, async () => await next(pContext.proxy));
|
|
@@ -125,6 +137,8 @@ class BaseAdapter {
|
|
|
125
137
|
}
|
|
126
138
|
finally {
|
|
127
139
|
pContext.revoke();
|
|
140
|
+
// Accessing the context after this point, will throw a TypeError.
|
|
141
|
+
// e.g.: "TypeError: Cannot perform 'get' on a proxy that has been revoked"
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseAdapter.js","sourceRoot":"","sources":["../../src/baseAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,gEAA4D;AAC5D,mDAA8E;AAE9E,8DAAyD;AAOzD,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,qBAAqB,CAAC,CAAA;AAE3C;;;;;;;;;;;;;;GAcG;AACH,MAAsB,WAAW;IAAjC;QACE;;WAEG;QACO,eAAU,GAAkB,IAAI,6BAAa,EAAE,CAAA;QAEjD,cAAS,GAA0D,KAAK,EAAE,OAAoB,EAAE,KAAY,EAAE,EAAE;YACtH,MAAM,CAAC,KAAK,CAAC,qCAAqC,KAAK,EAAE,CAAC,CAAA;YAE1D,2EAA2E;YAC3E,MAAM,OAAO,CAAC,iBAAiB,CAC7B,mBAAmB,EACnB,GAAG,KAAK,EAAE,EACV,4CAA4C,EAC5C,WAAW,CACZ,CAAA;YAED,6BAA6B;YAC7B,MAAM,OAAO,CAAC,YAAY,CAAC,wCAAwC,CAAC,CAAA;YACpE,MAAM,OAAO,CAAC,YAAY,CAAC,4DAA4D,CAAC,CAAA;QAC1F,CAAC,CAAA;QAED;;WAEG;QACM,qBAAgB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;QAEnD;;WAEG;QACM,uBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;QAEvD;;WAEG;QACM,kBAAa,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QAE7C;;WAEG;QACH,iBAAY,GAAiB,IAAI,qCAAiB,EAAE,CAAA;QAEpD;;WAEG;QACH,oBAAe,GAA2B,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"baseAdapter.js","sourceRoot":"","sources":["../../src/baseAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,gEAA4D;AAC5D,mDAA8E;AAE9E,8DAAyD;AAOzD,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,qBAAqB,CAAC,CAAA;AAE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BAAS,CAAC;YACT,QAAQ,CAAC,MAAM,EAAE,CAAA;YACjB,kEAAkE;YAClE,2EAA2E;QAC7E,CAAC;IACH,CAAC;CACF;AAxMD,kCAwMC"}
|
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.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.0",
|
|
23
|
-
"@azure/msal-node": "^3.
|
|
24
|
-
"@microsoft/agents-activity": "1.0.
|
|
23
|
+
"@azure/msal-node": "^3.7.0",
|
|
24
|
+
"@microsoft/agents-activity": "1.0.13",
|
|
25
25
|
"axios": "^1.11.0",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0"
|
package/src/baseAdapter.ts
CHANGED
|
@@ -169,6 +169,17 @@ export abstract class BaseAdapter {
|
|
|
169
169
|
return this
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* This method creates a revocable proxy for the given target object.
|
|
174
|
+
* If the environment does not support Proxy.revocable, it returns the original object.
|
|
175
|
+
* @remarks
|
|
176
|
+
* This is used to enhance security by allowing the proxy to be revoked after use,
|
|
177
|
+
* preventing further access to the underlying object.
|
|
178
|
+
*
|
|
179
|
+
* @param target The target object to be proxied.
|
|
180
|
+
* @param handler Optional proxy handler to customize behavior.
|
|
181
|
+
* @returns An object containing the proxy and a revoke function.
|
|
182
|
+
*/
|
|
172
183
|
private makeRevocable<T extends Record<string, any>>(
|
|
173
184
|
target: T,
|
|
174
185
|
handler?: ProxyHandler<T>
|
|
@@ -200,6 +211,7 @@ export abstract class BaseAdapter {
|
|
|
200
211
|
context.locale = context.activity.locale
|
|
201
212
|
}
|
|
202
213
|
|
|
214
|
+
// Create a revocable proxy for the context which will automatically be revoked upon completion of the turn.
|
|
203
215
|
const pContext = this.makeRevocable(context)
|
|
204
216
|
|
|
205
217
|
try {
|
|
@@ -216,6 +228,8 @@ export abstract class BaseAdapter {
|
|
|
216
228
|
}
|
|
217
229
|
} finally {
|
|
218
230
|
pContext.revoke()
|
|
231
|
+
// Accessing the context after this point, will throw a TypeError.
|
|
232
|
+
// e.g.: "TypeError: Cannot perform 'get' on a proxy that has been revoked"
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
}
|