@absolutejs/auth 0.75.3 → 0.75.5
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/htmx/configuredRoutes.d.ts +126 -37
- package/dist/htmx/routes.d.ts +126 -37
- package/dist/index.d.ts +432 -162
- package/dist/index.js +44 -37
- package/dist/index.js.map +6 -6
- package/dist/routes/protectRoute.d.ts +21 -4
- package/dist/routes/stepUp.d.ts +8 -3
- package/dist/server.js +44 -37
- package/dist/server.js.map +6 -6
- package/package.json +1 -1
- package/dist/client/dpop.test.d.ts +0 -1
package/dist/agents/routes.d.ts
CHANGED
|
@@ -7,10 +7,16 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", "
|
|
|
7
7
|
decorator: {};
|
|
8
8
|
store: {};
|
|
9
9
|
derive: {
|
|
10
|
-
readonly protectAgent:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
readonly protectAgent: {
|
|
11
|
+
<AuthReturn, AuthFailReturn = never>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
12
|
+
code: "Forbidden" | "Unauthorized";
|
|
13
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
14
|
+
}) => AuthFailReturn): Promise<Response | AuthReturn | Awaited<AuthFailReturn>>;
|
|
15
|
+
<AuthReturn, AuthFailReturn = never>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn, handleAuthFail?: (error: {
|
|
16
|
+
code: "Forbidden" | "Unauthorized";
|
|
17
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
18
|
+
}) => AuthFailReturn): Promise<Response | AuthReturn | Awaited<AuthFailReturn>>;
|
|
19
|
+
};
|
|
14
20
|
};
|
|
15
21
|
}, {
|
|
16
22
|
typebox: {};
|
package/dist/authContext.d.ts
CHANGED
|
@@ -20,54 +20,134 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
20
20
|
unregisteredSession: import("./types").UnregisteredSessionRecord;
|
|
21
21
|
};
|
|
22
22
|
derive: ({
|
|
23
|
-
readonly
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
readonly absoluteAuthStatus: {
|
|
24
|
+
error: {
|
|
25
|
+
readonly code: "Bad Request";
|
|
26
|
+
readonly message: "Cookies are missing";
|
|
27
|
+
};
|
|
28
|
+
user: null;
|
|
29
|
+
impersonator?: undefined;
|
|
27
30
|
} | {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
error: null;
|
|
32
|
+
impersonator: import("./types").Impersonator | undefined;
|
|
33
|
+
user: NonNullable<UserType> | null;
|
|
34
|
+
};
|
|
35
|
+
readonly authPrincipal: import("./principal").AuthPrincipal<UserType> | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
readonly protectRoute: {
|
|
38
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
39
|
+
readonly code: "Bad Request";
|
|
40
|
+
readonly message: "Cookies are missing";
|
|
41
|
+
} | {
|
|
42
|
+
readonly code: "Unauthorized";
|
|
43
|
+
readonly message: "User is not authenticated";
|
|
44
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
45
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
46
|
+
readonly code: "Bad Request";
|
|
47
|
+
readonly message: "Cookies are missing";
|
|
48
|
+
} | {
|
|
49
|
+
readonly code: "Unauthorized";
|
|
50
|
+
readonly message: "User is not authenticated";
|
|
51
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
52
|
+
};
|
|
31
53
|
} & {
|
|
32
|
-
readonly requireRecentAuth:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
readonly requireRecentAuth: {
|
|
55
|
+
<AuthReturn, AuthFailReturn_2 = never>(maxAgeMs: number, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
56
|
+
readonly code: "Unauthorized";
|
|
57
|
+
readonly message: "Recent authentication required";
|
|
58
|
+
}) => AuthFailReturn_2) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_2>>;
|
|
59
|
+
<AuthReturn, AuthFailReturn_3 = never>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
60
|
+
readonly code: "Unauthorized";
|
|
61
|
+
readonly message: "Recent authentication required";
|
|
62
|
+
}) => AuthFailReturn_3) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_3>>;
|
|
63
|
+
};
|
|
36
64
|
} & {
|
|
37
|
-
readonly protectAgent:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
readonly protectAgent: {
|
|
66
|
+
<AuthReturn, AuthFailReturn_4 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
67
|
+
code: "Forbidden" | "Unauthorized";
|
|
68
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
69
|
+
}) => AuthFailReturn_4): Promise<Response | AuthReturn | Awaited<AuthFailReturn_4>>;
|
|
70
|
+
<AuthReturn, AuthFailReturn_5 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn, handleAuthFail?: (error: {
|
|
71
|
+
code: "Forbidden" | "Unauthorized";
|
|
72
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
73
|
+
}) => AuthFailReturn_5): Promise<Response | AuthReturn | Awaited<AuthFailReturn_5>>;
|
|
74
|
+
};
|
|
41
75
|
}) | ({
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
readonly absoluteAuthStatus: {
|
|
77
|
+
error: {
|
|
78
|
+
readonly code: "Bad Request";
|
|
79
|
+
readonly message: "Cookies are missing";
|
|
80
|
+
};
|
|
81
|
+
user: null;
|
|
82
|
+
impersonator?: undefined;
|
|
46
83
|
} | {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
error: null;
|
|
85
|
+
impersonator: import("./types").Impersonator | undefined;
|
|
86
|
+
user: NonNullable<UserType> | null;
|
|
87
|
+
};
|
|
88
|
+
readonly authPrincipal: import("./principal").AuthPrincipal<UserType> | undefined;
|
|
50
89
|
} & {
|
|
51
|
-
readonly
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
90
|
+
readonly protectRoute: {
|
|
91
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
92
|
+
readonly code: "Bad Request";
|
|
93
|
+
readonly message: "Cookies are missing";
|
|
94
|
+
} | {
|
|
95
|
+
readonly code: "Unauthorized";
|
|
96
|
+
readonly message: "User is not authenticated";
|
|
97
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
98
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
99
|
+
readonly code: "Bad Request";
|
|
100
|
+
readonly message: "Cookies are missing";
|
|
101
|
+
} | {
|
|
102
|
+
readonly code: "Unauthorized";
|
|
103
|
+
readonly message: "User is not authenticated";
|
|
104
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
105
|
+
};
|
|
55
106
|
} & {
|
|
56
|
-
readonly
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
107
|
+
readonly requireRecentAuth: {
|
|
108
|
+
<AuthReturn, AuthFailReturn_2 = never>(maxAgeMs: number, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
109
|
+
readonly code: "Unauthorized";
|
|
110
|
+
readonly message: "Recent authentication required";
|
|
111
|
+
}) => AuthFailReturn_2) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_2>>;
|
|
112
|
+
<AuthReturn, AuthFailReturn_3 = never>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
113
|
+
readonly code: "Unauthorized";
|
|
114
|
+
readonly message: "Recent authentication required";
|
|
115
|
+
}) => AuthFailReturn_3) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_3>>;
|
|
116
|
+
};
|
|
117
|
+
} & {
|
|
118
|
+
readonly protectPermission: {
|
|
119
|
+
<AuthReturn, AuthFailReturn_6 = never>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
120
|
+
readonly code: "Bad Request";
|
|
121
|
+
readonly message: "Cookies are missing";
|
|
122
|
+
} | {
|
|
123
|
+
readonly code: "Forbidden";
|
|
124
|
+
readonly message: "Insufficient permissions";
|
|
125
|
+
} | {
|
|
126
|
+
readonly code: "Unauthorized";
|
|
127
|
+
readonly message: "User is not authenticated";
|
|
128
|
+
}) => AuthFailReturn_6) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_6>>;
|
|
129
|
+
<AuthReturn, AuthFailReturn_7 = never>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
130
|
+
readonly code: "Bad Request";
|
|
131
|
+
readonly message: "Cookies are missing";
|
|
132
|
+
} | {
|
|
133
|
+
readonly code: "Forbidden";
|
|
134
|
+
readonly message: "Insufficient permissions";
|
|
135
|
+
} | {
|
|
136
|
+
readonly code: "Unauthorized";
|
|
137
|
+
readonly message: "User is not authenticated";
|
|
138
|
+
}) => AuthFailReturn_7) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_7>>;
|
|
139
|
+
};
|
|
66
140
|
} & {
|
|
67
|
-
readonly protectAgent:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
141
|
+
readonly protectAgent: {
|
|
142
|
+
<AuthReturn, AuthFailReturn_4 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
143
|
+
code: "Forbidden" | "Unauthorized";
|
|
144
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
145
|
+
}) => AuthFailReturn_4): Promise<Response | AuthReturn | Awaited<AuthFailReturn_4>>;
|
|
146
|
+
<AuthReturn, AuthFailReturn_5 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn, handleAuthFail?: (error: {
|
|
147
|
+
code: "Forbidden" | "Unauthorized";
|
|
148
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
149
|
+
}) => AuthFailReturn_5): Promise<Response | AuthReturn | Awaited<AuthFailReturn_5>>;
|
|
150
|
+
};
|
|
71
151
|
});
|
|
72
152
|
}, {
|
|
73
153
|
typebox: {};
|
|
@@ -91,14 +171,22 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
91
171
|
macroFn: {};
|
|
92
172
|
parser: {};
|
|
93
173
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
94
|
-
readonly
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
174
|
+
readonly protectRoute: {
|
|
175
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
176
|
+
readonly code: "Bad Request";
|
|
177
|
+
readonly message: "Cookies are missing";
|
|
178
|
+
} | {
|
|
179
|
+
readonly code: "Unauthorized";
|
|
180
|
+
readonly message: "User is not authenticated";
|
|
181
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
182
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
183
|
+
readonly code: "Bad Request";
|
|
184
|
+
readonly message: "Cookies are missing";
|
|
185
|
+
} | {
|
|
186
|
+
readonly code: "Unauthorized";
|
|
187
|
+
readonly message: "User is not authenticated";
|
|
188
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
189
|
+
};
|
|
102
190
|
}>;
|
|
103
191
|
} & {
|
|
104
192
|
schema: {};
|
|
@@ -112,10 +200,16 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
112
200
|
macroFn: {};
|
|
113
201
|
parser: {};
|
|
114
202
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
115
|
-
readonly requireRecentAuth:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
203
|
+
readonly requireRecentAuth: {
|
|
204
|
+
<AuthReturn, AuthFailReturn_2 = never>(maxAgeMs: number, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
205
|
+
readonly code: "Unauthorized";
|
|
206
|
+
readonly message: "Recent authentication required";
|
|
207
|
+
}) => AuthFailReturn_2) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_2>>;
|
|
208
|
+
<AuthReturn, AuthFailReturn_3 = never>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
209
|
+
readonly code: "Unauthorized";
|
|
210
|
+
readonly message: "Recent authentication required";
|
|
211
|
+
}) => AuthFailReturn_3) | undefined): Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | Awaited<AuthFailReturn_3>>;
|
|
212
|
+
};
|
|
119
213
|
}>;
|
|
120
214
|
} & (import("elysia/types").DefaultMetadata | {
|
|
121
215
|
schema: {};
|
|
@@ -129,16 +223,28 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
129
223
|
macroFn: {};
|
|
130
224
|
parser: {};
|
|
131
225
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
132
|
-
readonly protectPermission:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
226
|
+
readonly protectPermission: {
|
|
227
|
+
<AuthReturn, AuthFailReturn_6 = never>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
228
|
+
readonly code: "Bad Request";
|
|
229
|
+
readonly message: "Cookies are missing";
|
|
230
|
+
} | {
|
|
231
|
+
readonly code: "Forbidden";
|
|
232
|
+
readonly message: "Insufficient permissions";
|
|
233
|
+
} | {
|
|
234
|
+
readonly code: "Unauthorized";
|
|
235
|
+
readonly message: "User is not authenticated";
|
|
236
|
+
}) => AuthFailReturn_6) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_6>>;
|
|
237
|
+
<AuthReturn, AuthFailReturn_7 = never>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: ((error: {
|
|
238
|
+
readonly code: "Bad Request";
|
|
239
|
+
readonly message: "Cookies are missing";
|
|
240
|
+
} | {
|
|
241
|
+
readonly code: "Forbidden";
|
|
242
|
+
readonly message: "Insufficient permissions";
|
|
243
|
+
} | {
|
|
244
|
+
readonly code: "Unauthorized";
|
|
245
|
+
readonly message: "User is not authenticated";
|
|
246
|
+
}) => AuthFailReturn_7) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_7>>;
|
|
247
|
+
};
|
|
142
248
|
}>;
|
|
143
249
|
})) & {
|
|
144
250
|
schema: {};
|
|
@@ -147,10 +253,16 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
147
253
|
macroFn: {};
|
|
148
254
|
parser: {};
|
|
149
255
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
150
|
-
readonly protectAgent:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
256
|
+
readonly protectAgent: {
|
|
257
|
+
<AuthReturn, AuthFailReturn_4 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
258
|
+
code: "Forbidden" | "Unauthorized";
|
|
259
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
260
|
+
}) => AuthFailReturn_4): Promise<Response | AuthReturn | Awaited<AuthFailReturn_4>>;
|
|
261
|
+
<AuthReturn, AuthFailReturn_5 = never>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn, handleAuthFail?: (error: {
|
|
262
|
+
code: "Forbidden" | "Unauthorized";
|
|
263
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
264
|
+
}) => AuthFailReturn_5): Promise<Response | AuthReturn | Awaited<AuthFailReturn_5>>;
|
|
265
|
+
};
|
|
154
266
|
}>;
|
|
155
267
|
}, {}, import("elysia/types").DefaultEphemeral, {
|
|
156
268
|
derive: {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Elysia } from 'elysia';
|
|
1
|
+
import { Elysia, StatusMap, type ElysiaStatus } from 'elysia';
|
|
2
2
|
import type { AuthorizationPluginProps, PermissionCheck } from './config';
|
|
3
3
|
type PermissionFailError = {
|
|
4
4
|
readonly code: 'Bad Request';
|
|
@@ -10,6 +10,11 @@ type PermissionFailError = {
|
|
|
10
10
|
readonly code: 'Unauthorized';
|
|
11
11
|
readonly message: 'User is not authenticated';
|
|
12
12
|
};
|
|
13
|
+
type PermissionFailureResponse = ElysiaStatus<'Bad Request', 'Cookies are missing', (typeof StatusMap)['Bad Request']> | ElysiaStatus<'Forbidden', 'Insufficient permissions', (typeof StatusMap)['Forbidden']> | ElysiaStatus<'Unauthorized', 'User is not authenticated', (typeof StatusMap)['Unauthorized']>;
|
|
14
|
+
type ProtectPermission<UserType> = {
|
|
15
|
+
<AuthReturn, AuthFailReturn = never>(check: PermissionCheck, handleAuth: (user: UserType) => Promise<AuthReturn>, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn): Promise<PermissionFailureResponse | AuthReturn | Awaited<AuthFailReturn>>;
|
|
16
|
+
<AuthReturn, AuthFailReturn = never>(check: PermissionCheck, handleAuth: (user: UserType) => AuthReturn, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn): Promise<PermissionFailureResponse | AuthReturn | Awaited<AuthFailReturn>>;
|
|
17
|
+
};
|
|
13
18
|
export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emit, hasPermission }: AuthorizationPluginProps<UserType>) => Elysia<"", "local", {
|
|
14
19
|
decorator: {};
|
|
15
20
|
store: {
|
|
@@ -17,7 +22,7 @@ export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emi
|
|
|
17
22
|
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
18
23
|
};
|
|
19
24
|
derive: {
|
|
20
|
-
readonly protectPermission: <
|
|
25
|
+
readonly protectPermission: ProtectPermission<UserType>;
|
|
21
26
|
};
|
|
22
27
|
}, {
|
|
23
28
|
typebox: {};
|
|
@@ -34,7 +39,7 @@ export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emi
|
|
|
34
39
|
macroFn: {};
|
|
35
40
|
parser: {};
|
|
36
41
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
37
|
-
readonly protectPermission: <
|
|
42
|
+
readonly protectPermission: ProtectPermission<UserType>;
|
|
38
43
|
}>;
|
|
39
44
|
}, {}, import("elysia/types").DefaultEphemeral, import("elysia/types").DefaultEphemeral>;
|
|
40
45
|
export {};
|
|
@@ -14,14 +14,36 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
14
14
|
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
15
15
|
};
|
|
16
16
|
derive: {
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
readonly absoluteAuthStatus: {
|
|
18
|
+
error: {
|
|
19
|
+
readonly code: "Bad Request";
|
|
20
|
+
readonly message: "Cookies are missing";
|
|
21
|
+
};
|
|
22
|
+
user: null;
|
|
23
|
+
impersonator?: undefined;
|
|
21
24
|
} | {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
error: null;
|
|
26
|
+
impersonator: import("..").Impersonator | undefined;
|
|
27
|
+
user: AuthHtmxUser | null;
|
|
28
|
+
};
|
|
29
|
+
readonly authPrincipal: import("..").AuthPrincipal<AuthHtmxUser> | undefined;
|
|
30
|
+
} & {
|
|
31
|
+
readonly protectRoute: {
|
|
32
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: AuthHtmxUser) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
33
|
+
readonly code: "Bad Request";
|
|
34
|
+
readonly message: "Cookies are missing";
|
|
35
|
+
} | {
|
|
36
|
+
readonly code: "Unauthorized";
|
|
37
|
+
readonly message: "User is not authenticated";
|
|
38
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
39
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: AuthHtmxUser) => AuthReturn, handleAuthFail?: ((error: {
|
|
40
|
+
readonly code: "Bad Request";
|
|
41
|
+
readonly message: "Cookies are missing";
|
|
42
|
+
} | {
|
|
43
|
+
readonly code: "Unauthorized";
|
|
44
|
+
readonly message: "User is not authenticated";
|
|
45
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
46
|
+
};
|
|
25
47
|
};
|
|
26
48
|
}, {
|
|
27
49
|
typebox: {};
|
|
@@ -38,14 +60,22 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
38
60
|
macroFn: {};
|
|
39
61
|
parser: {};
|
|
40
62
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
41
|
-
readonly
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
readonly protectRoute: {
|
|
64
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: AuthHtmxUser) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
65
|
+
readonly code: "Bad Request";
|
|
66
|
+
readonly message: "Cookies are missing";
|
|
67
|
+
} | {
|
|
68
|
+
readonly code: "Unauthorized";
|
|
69
|
+
readonly message: "User is not authenticated";
|
|
70
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
71
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: AuthHtmxUser) => AuthReturn, handleAuthFail?: ((error: {
|
|
72
|
+
readonly code: "Bad Request";
|
|
73
|
+
readonly message: "Cookies are missing";
|
|
74
|
+
} | {
|
|
75
|
+
readonly code: "Unauthorized";
|
|
76
|
+
readonly message: "User is not authenticated";
|
|
77
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
78
|
+
};
|
|
49
79
|
}>;
|
|
50
80
|
}, {
|
|
51
81
|
htmx: {
|
|
@@ -212,7 +242,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
212
242
|
query: unknown;
|
|
213
243
|
headers: unknown;
|
|
214
244
|
response: {
|
|
215
|
-
|
|
245
|
+
400: "Cookies are missing";
|
|
246
|
+
401: "User is not authenticated";
|
|
247
|
+
200: Response;
|
|
216
248
|
422: {
|
|
217
249
|
type: "validation";
|
|
218
250
|
title: "Validation Error";
|
|
@@ -241,7 +273,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
241
273
|
query: unknown;
|
|
242
274
|
headers: unknown;
|
|
243
275
|
response: {
|
|
244
|
-
|
|
276
|
+
400: "Cookies are missing";
|
|
277
|
+
401: "User is not authenticated";
|
|
278
|
+
200: Response;
|
|
245
279
|
422: {
|
|
246
280
|
type: "validation";
|
|
247
281
|
title: "Validation Error";
|
|
@@ -271,7 +305,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
271
305
|
query: unknown;
|
|
272
306
|
headers: unknown;
|
|
273
307
|
response: {
|
|
274
|
-
|
|
308
|
+
400: "Cookies are missing";
|
|
309
|
+
401: "User is not authenticated";
|
|
310
|
+
200: Response;
|
|
275
311
|
422: {
|
|
276
312
|
type: "validation";
|
|
277
313
|
title: "Validation Error";
|
|
@@ -300,7 +336,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
300
336
|
query: unknown;
|
|
301
337
|
headers: unknown;
|
|
302
338
|
response: {
|
|
303
|
-
|
|
339
|
+
400: "Cookies are missing";
|
|
340
|
+
401: "User is not authenticated";
|
|
341
|
+
200: Response;
|
|
304
342
|
422: {
|
|
305
343
|
type: "validation";
|
|
306
344
|
title: "Validation Error";
|
|
@@ -329,7 +367,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
329
367
|
query: unknown;
|
|
330
368
|
headers: unknown;
|
|
331
369
|
response: {
|
|
332
|
-
|
|
370
|
+
400: "Cookies are missing";
|
|
371
|
+
401: "User is not authenticated";
|
|
372
|
+
200: Response;
|
|
333
373
|
422: {
|
|
334
374
|
type: "validation";
|
|
335
375
|
title: "Validation Error";
|
|
@@ -386,7 +426,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
386
426
|
query: unknown;
|
|
387
427
|
headers: unknown;
|
|
388
428
|
response: {
|
|
389
|
-
|
|
429
|
+
400: "Cookies are missing";
|
|
430
|
+
401: "User is not authenticated";
|
|
431
|
+
200: Response;
|
|
390
432
|
422: {
|
|
391
433
|
type: "validation";
|
|
392
434
|
title: "Validation Error";
|
|
@@ -417,7 +459,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
417
459
|
query: unknown;
|
|
418
460
|
headers: unknown;
|
|
419
461
|
response: {
|
|
420
|
-
|
|
462
|
+
400: "Cookies are missing";
|
|
463
|
+
401: "User is not authenticated";
|
|
464
|
+
200: Response;
|
|
421
465
|
422: {
|
|
422
466
|
type: "validation";
|
|
423
467
|
title: "Validation Error";
|
|
@@ -469,7 +513,9 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
469
513
|
query: unknown;
|
|
470
514
|
headers: unknown;
|
|
471
515
|
response: {
|
|
472
|
-
|
|
516
|
+
400: "Cookies are missing";
|
|
517
|
+
401: "User is not authenticated";
|
|
518
|
+
200: Response;
|
|
473
519
|
422: {
|
|
474
520
|
type: "validation";
|
|
475
521
|
title: "Validation Error";
|
|
@@ -648,14 +694,36 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
648
694
|
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
649
695
|
};
|
|
650
696
|
derive: {
|
|
651
|
-
readonly
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
697
|
+
readonly absoluteAuthStatus: {
|
|
698
|
+
error: {
|
|
699
|
+
readonly code: "Bad Request";
|
|
700
|
+
readonly message: "Cookies are missing";
|
|
701
|
+
};
|
|
702
|
+
user: null;
|
|
703
|
+
impersonator?: undefined;
|
|
655
704
|
} | {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
705
|
+
error: null;
|
|
706
|
+
impersonator: import("..").Impersonator | undefined;
|
|
707
|
+
user: AuthHtmxUser | null;
|
|
708
|
+
};
|
|
709
|
+
readonly authPrincipal: import("..").AuthPrincipal<AuthHtmxUser> | undefined;
|
|
710
|
+
} & {
|
|
711
|
+
readonly protectRoute: {
|
|
712
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: AuthHtmxUser) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
713
|
+
readonly code: "Bad Request";
|
|
714
|
+
readonly message: "Cookies are missing";
|
|
715
|
+
} | {
|
|
716
|
+
readonly code: "Unauthorized";
|
|
717
|
+
readonly message: "User is not authenticated";
|
|
718
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
719
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: AuthHtmxUser) => AuthReturn, handleAuthFail?: ((error: {
|
|
720
|
+
readonly code: "Bad Request";
|
|
721
|
+
readonly message: "Cookies are missing";
|
|
722
|
+
} | {
|
|
723
|
+
readonly code: "Unauthorized";
|
|
724
|
+
readonly message: "User is not authenticated";
|
|
725
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
726
|
+
};
|
|
659
727
|
};
|
|
660
728
|
} & {
|
|
661
729
|
derive: {};
|
|
@@ -668,12 +736,33 @@ export declare const createConfiguredAuthHtmxRoutes: <UserType>({ authSessionSto
|
|
|
668
736
|
session: import("..").SessionRecord<AuthHtmxUser>;
|
|
669
737
|
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
670
738
|
};
|
|
671
|
-
readonly
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
739
|
+
readonly absoluteAuthStatus: {
|
|
740
|
+
error: {
|
|
741
|
+
readonly code: "Bad Request";
|
|
742
|
+
readonly message: "Cookies are missing";
|
|
743
|
+
};
|
|
744
|
+
user: null;
|
|
745
|
+
impersonator?: undefined;
|
|
675
746
|
} | {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
747
|
+
error: null;
|
|
748
|
+
impersonator: import("..").Impersonator | undefined;
|
|
749
|
+
user: AuthHtmxUser | null;
|
|
750
|
+
};
|
|
751
|
+
readonly authPrincipal: import("..").AuthPrincipal<AuthHtmxUser> | undefined;
|
|
752
|
+
readonly protectRoute: {
|
|
753
|
+
<AuthReturn, AuthFailReturn = never>(handleAuth: (user: AuthHtmxUser) => Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
754
|
+
readonly code: "Bad Request";
|
|
755
|
+
readonly message: "Cookies are missing";
|
|
756
|
+
} | {
|
|
757
|
+
readonly code: "Unauthorized";
|
|
758
|
+
readonly message: "User is not authenticated";
|
|
759
|
+
}) => AuthFailReturn) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn>>;
|
|
760
|
+
<AuthReturn, AuthFailReturn_1 = never>(handleAuth: (user: AuthHtmxUser) => AuthReturn, handleAuthFail?: ((error: {
|
|
761
|
+
readonly code: "Bad Request";
|
|
762
|
+
readonly message: "Cookies are missing";
|
|
763
|
+
} | {
|
|
764
|
+
readonly code: "Unauthorized";
|
|
765
|
+
readonly message: "User is not authenticated";
|
|
766
|
+
}) => AuthFailReturn_1) | undefined): Promise<(import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401>) | AuthReturn | Awaited<AuthFailReturn_1>>;
|
|
767
|
+
};
|
|
679
768
|
}) => Promise<Response>>;
|