@absolutejs/auth 0.77.0 → 0.77.1
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/agents/context.d.ts +6 -2
- package/dist/agents/index.js +6 -5
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/routes.d.ts +10 -4
- package/dist/authContext.d.ts +178 -66
- package/dist/authorization/protectPermission.d.ts +8 -3
- package/dist/cli/migrate.js +14 -7
- package/dist/cli/migrate.js.map +3 -3
- package/dist/htmx/configuredRoutes.d.ts +126 -37
- package/dist/htmx/routes.d.ts +126 -37
- package/dist/index.d.ts +427 -157
- package/dist/index.js +57 -43
- package/dist/index.js.map +7 -7
- package/dist/routes/protectRoute.d.ts +21 -4
- package/dist/routes/stepUp.d.ts +8 -3
- package/dist/server.js +57 -43
- package/dist/server.js.map +7 -7
- package/package.json +1 -1
package/dist/agents/context.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ type AgentAuthFailure = {
|
|
|
5
5
|
code: 'Forbidden' | 'Unauthorized';
|
|
6
6
|
message: 'Agent is not authenticated' | 'Insufficient agent scopes';
|
|
7
7
|
};
|
|
8
|
+
type ProtectAgent = {
|
|
9
|
+
<AuthReturn, AuthFailReturn = never>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn): Promise<Response | AuthReturn | Awaited<AuthFailReturn>>;
|
|
10
|
+
<AuthReturn, AuthFailReturn = never>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn): Promise<Response | AuthReturn | Awaited<AuthFailReturn>>;
|
|
11
|
+
};
|
|
8
12
|
export declare const agentAuthChallenge: ({ config, error, requiredScopes }: {
|
|
9
13
|
config: AgentAuthConfig;
|
|
10
14
|
error?: "invalid_token" | "insufficient_scope";
|
|
@@ -15,7 +19,7 @@ export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysi
|
|
|
15
19
|
decorator: {};
|
|
16
20
|
store: {};
|
|
17
21
|
derive: {
|
|
18
|
-
readonly protectAgent:
|
|
22
|
+
readonly protectAgent: ProtectAgent;
|
|
19
23
|
};
|
|
20
24
|
}, {
|
|
21
25
|
typebox: {};
|
|
@@ -27,7 +31,7 @@ export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysi
|
|
|
27
31
|
macroFn: {};
|
|
28
32
|
parser: {};
|
|
29
33
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
30
|
-
readonly protectAgent:
|
|
34
|
+
readonly protectAgent: ProtectAgent;
|
|
31
35
|
}>;
|
|
32
36
|
}, {}, import("elysia/types").DefaultEphemeral, import("elysia/types").DefaultEphemeral>;
|
|
33
37
|
export {};
|
package/dist/agents/index.js
CHANGED
|
@@ -1653,8 +1653,8 @@ var failureResponse = (config, failure, requiredScopes) => new Response(JSON.str
|
|
|
1653
1653
|
var agentAuthContextPlugin = (config) => new Elysia({
|
|
1654
1654
|
name: "@absolutejs/auth/agent-context",
|
|
1655
1655
|
seed: pluginDependencySeed(config)
|
|
1656
|
-
}).derive(({ request }) =>
|
|
1657
|
-
protectAgent
|
|
1656
|
+
}).derive(({ request }) => {
|
|
1657
|
+
const protectAgent = async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
1658
1658
|
if (config === undefined) {
|
|
1659
1659
|
const failure = {
|
|
1660
1660
|
code: "Unauthorized",
|
|
@@ -1680,8 +1680,9 @@ var agentAuthContextPlugin = (config) => new Elysia({
|
|
|
1680
1680
|
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
1681
1681
|
}
|
|
1682
1682
|
return handleAuth(principal);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1683
|
+
};
|
|
1684
|
+
return { protectAgent };
|
|
1685
|
+
}).as("global");
|
|
1685
1686
|
// src/agents/routes.ts
|
|
1686
1687
|
import { Elysia as Elysia2 } from "elysia";
|
|
1687
1688
|
var HTTP_BAD_REQUEST = 400;
|
|
@@ -13962,5 +13963,5 @@ export {
|
|
|
13962
13963
|
validateClientIdMetadataDocument
|
|
13963
13964
|
};
|
|
13964
13965
|
|
|
13965
|
-
//# debugId=
|
|
13966
|
+
//# debugId=E67FAC64C26F65BF64756E2164756E21
|
|
13966
13967
|
//# sourceMappingURL=index.js.map
|