@economic/agents 2.11.2 → 2.11.3
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/index.d.mts +1 -0
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -133,6 +133,7 @@ type Authentication<UserContext> = {
|
|
|
133
133
|
success: false;
|
|
134
134
|
status: 401 | 403 | 500;
|
|
135
135
|
message: string;
|
|
136
|
+
closeCode?: number;
|
|
136
137
|
};
|
|
137
138
|
declare abstract class Agent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>, State = unknown> extends Think<Cloudflare.Env & AgentEnv, State> {
|
|
138
139
|
protected agentType: AgentConnectionType;
|
package/dist/index.mjs
CHANGED
|
@@ -936,7 +936,7 @@ var Agent = class extends Think {
|
|
|
936
936
|
this.forwardedFor = ctx.request.headers.get("X-Forwarded-For") ?? void 0;
|
|
937
937
|
const auth = await this.authenticate(ctx.request);
|
|
938
938
|
if (!auth.success) {
|
|
939
|
-
const closeCode = auth.status === 401 ? 4001 : auth.status === 403 ? 4003 : 1011;
|
|
939
|
+
const closeCode = auth.closeCode ?? (auth.status === 401 ? 4001 : auth.status === 403 ? 4003 : 1011);
|
|
940
940
|
sendConnectionStatus(connection, closeCode === 1011 ? "error" : "unauthorized");
|
|
941
941
|
connection.close(closeCode, auth.message);
|
|
942
942
|
return;
|
|
@@ -1346,7 +1346,8 @@ var Agent = class extends Think {
|
|
|
1346
1346
|
return {
|
|
1347
1347
|
success: false,
|
|
1348
1348
|
status: closeCode === 4003 ? 403 : closeCode === 4001 ? 401 : 500,
|
|
1349
|
-
message: "Could not establish user context"
|
|
1349
|
+
message: "Could not establish user context",
|
|
1350
|
+
closeCode
|
|
1350
1351
|
};
|
|
1351
1352
|
}
|
|
1352
1353
|
}
|