@absolutejs/auth 0.75.7 → 0.76.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 +2 -6
- package/dist/agents/index.js +5 -6
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/routes.d.ts +4 -10
- package/dist/authContext.d.ts +66 -178
- package/dist/authorization/protectPermission.d.ts +3 -8
- package/dist/cli/migrate.js +19 -15
- package/dist/cli/migrate.js.map +5 -5
- package/dist/htmx/configuredRoutes.d.ts +37 -126
- package/dist/htmx/routes.d.ts +37 -126
- package/dist/index.d.ts +237 -431
- package/dist/index.js +332 -113
- package/dist/index.js.map +17 -17
- package/dist/mfa/challenge.d.ts +53 -7
- package/dist/mfa/management.d.ts +49 -6
- package/dist/mfa/postgresMfaStore.d.ts +31 -1
- package/dist/mfa/rotation.d.ts +1 -1
- package/dist/mfa/routes.d.ts +78 -2
- package/dist/mfa/sms.d.ts +7 -2
- package/dist/mfa/totp.d.ts +8 -2
- package/dist/mfa/types.d.ts +47 -0
- package/dist/routes/protectRoute.d.ts +4 -21
- package/dist/routes/stepUp.d.ts +3 -8
- package/dist/server.js +330 -113
- package/dist/server.js.map +17 -17
- package/package.json +1 -1
package/dist/agents/routes.d.ts
CHANGED
|
@@ -7,16 +7,10 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", "
|
|
|
7
7
|
decorator: {};
|
|
8
8
|
store: {};
|
|
9
9
|
derive: {
|
|
10
|
-
readonly protectAgent: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
};
|
|
10
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
11
|
+
code: "Forbidden" | "Unauthorized";
|
|
12
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
13
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
20
14
|
};
|
|
21
15
|
}, {
|
|
22
16
|
typebox: {};
|
package/dist/authContext.d.ts
CHANGED
|
@@ -20,134 +20,54 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
20
20
|
unregisteredSession: import("./types").UnregisteredSessionRecord;
|
|
21
21
|
};
|
|
22
22
|
derive: ({
|
|
23
|
-
readonly absoluteAuthStatus: {
|
|
24
|
-
error: {
|
|
25
|
-
readonly code: "Bad Request";
|
|
26
|
-
readonly message: "Cookies are missing";
|
|
27
|
-
};
|
|
28
|
-
user: null;
|
|
29
|
-
impersonator?: undefined;
|
|
30
|
-
} | {
|
|
31
|
-
error: null;
|
|
32
|
-
impersonator: import("./types").Impersonator | undefined;
|
|
33
|
-
user: NonNullable<UserType> | null;
|
|
34
|
-
};
|
|
35
23
|
readonly authPrincipal: import("./principal").AuthPrincipal<UserType> | undefined;
|
|
24
|
+
readonly protectRoute: <AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
25
|
+
readonly code: "Bad Request";
|
|
26
|
+
readonly message: "Cookies are missing";
|
|
27
|
+
} | {
|
|
28
|
+
readonly code: "Unauthorized";
|
|
29
|
+
readonly message: "User is not authenticated";
|
|
30
|
+
}) => AuthFailReturn) | undefined) => import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | AuthReturn | Promise<AuthReturn> | NonNullable<AuthFailReturn>;
|
|
36
31
|
} & {
|
|
37
|
-
readonly
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
};
|
|
53
|
-
} & {
|
|
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
|
-
};
|
|
32
|
+
readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
33
|
+
readonly code: "Unauthorized";
|
|
34
|
+
readonly message: "Recent authentication required";
|
|
35
|
+
}) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
|
|
64
36
|
} & {
|
|
65
|
-
readonly protectAgent: {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
};
|
|
37
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
38
|
+
code: "Forbidden" | "Unauthorized";
|
|
39
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
40
|
+
}) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
|
|
75
41
|
}) | ({
|
|
76
|
-
readonly absoluteAuthStatus: {
|
|
77
|
-
error: {
|
|
78
|
-
readonly code: "Bad Request";
|
|
79
|
-
readonly message: "Cookies are missing";
|
|
80
|
-
};
|
|
81
|
-
user: null;
|
|
82
|
-
impersonator?: undefined;
|
|
83
|
-
} | {
|
|
84
|
-
error: null;
|
|
85
|
-
impersonator: import("./types").Impersonator | undefined;
|
|
86
|
-
user: NonNullable<UserType> | null;
|
|
87
|
-
};
|
|
88
42
|
readonly authPrincipal: import("./principal").AuthPrincipal<UserType> | undefined;
|
|
43
|
+
readonly protectRoute: <AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
44
|
+
readonly code: "Bad Request";
|
|
45
|
+
readonly message: "Cookies are missing";
|
|
46
|
+
} | {
|
|
47
|
+
readonly code: "Unauthorized";
|
|
48
|
+
readonly message: "User is not authenticated";
|
|
49
|
+
}) => AuthFailReturn) | undefined) => import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | AuthReturn | Promise<AuthReturn> | NonNullable<AuthFailReturn>;
|
|
89
50
|
} & {
|
|
90
|
-
readonly
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
};
|
|
106
|
-
} & {
|
|
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
|
-
};
|
|
51
|
+
readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
52
|
+
readonly code: "Unauthorized";
|
|
53
|
+
readonly message: "Recent authentication required";
|
|
54
|
+
}) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
|
|
117
55
|
} & {
|
|
118
|
-
readonly protectPermission: {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
};
|
|
56
|
+
readonly protectPermission: <AuthReturn, AuthFailReturn_3>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
57
|
+
readonly code: "Bad Request";
|
|
58
|
+
readonly message: "Cookies are missing";
|
|
59
|
+
} | {
|
|
60
|
+
readonly code: "Forbidden";
|
|
61
|
+
readonly message: "Insufficient permissions";
|
|
62
|
+
} | {
|
|
63
|
+
readonly code: "Unauthorized";
|
|
64
|
+
readonly message: "User is not authenticated";
|
|
65
|
+
}) => AuthFailReturn_3) | undefined) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | AuthReturn | NonNullable<AuthFailReturn_3>>;
|
|
140
66
|
} & {
|
|
141
|
-
readonly protectAgent: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
};
|
|
67
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
68
|
+
code: "Forbidden" | "Unauthorized";
|
|
69
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
70
|
+
}) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
|
|
151
71
|
});
|
|
152
72
|
}, {
|
|
153
73
|
typebox: {};
|
|
@@ -171,22 +91,14 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
171
91
|
macroFn: {};
|
|
172
92
|
parser: {};
|
|
173
93
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
174
|
-
readonly
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
};
|
|
94
|
+
readonly authPrincipal: import("./principal").AuthPrincipal<UserType> | undefined;
|
|
95
|
+
readonly protectRoute: <AuthReturn, AuthFailReturn = never>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
96
|
+
readonly code: "Bad Request";
|
|
97
|
+
readonly message: "Cookies are missing";
|
|
98
|
+
} | {
|
|
99
|
+
readonly code: "Unauthorized";
|
|
100
|
+
readonly message: "User is not authenticated";
|
|
101
|
+
}) => AuthFailReturn) | undefined) => import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | AuthReturn | Promise<AuthReturn> | NonNullable<AuthFailReturn>;
|
|
190
102
|
}>;
|
|
191
103
|
} & {
|
|
192
104
|
schema: {};
|
|
@@ -200,16 +112,10 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
200
112
|
macroFn: {};
|
|
201
113
|
parser: {};
|
|
202
114
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
203
|
-
readonly requireRecentAuth: {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
};
|
|
115
|
+
readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
116
|
+
readonly code: "Unauthorized";
|
|
117
|
+
readonly message: "Recent authentication required";
|
|
118
|
+
}) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
|
|
213
119
|
}>;
|
|
214
120
|
} & (import("elysia/types").DefaultMetadata | {
|
|
215
121
|
schema: {};
|
|
@@ -223,28 +129,16 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
223
129
|
macroFn: {};
|
|
224
130
|
parser: {};
|
|
225
131
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
226
|
-
readonly protectPermission: {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
};
|
|
132
|
+
readonly protectPermission: <AuthReturn, AuthFailReturn_3>(check: import(".").PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
|
|
133
|
+
readonly code: "Bad Request";
|
|
134
|
+
readonly message: "Cookies are missing";
|
|
135
|
+
} | {
|
|
136
|
+
readonly code: "Forbidden";
|
|
137
|
+
readonly message: "Insufficient permissions";
|
|
138
|
+
} | {
|
|
139
|
+
readonly code: "Unauthorized";
|
|
140
|
+
readonly message: "User is not authenticated";
|
|
141
|
+
}) => AuthFailReturn_3) | undefined) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403> | AuthReturn | NonNullable<AuthFailReturn_3>>;
|
|
248
142
|
}>;
|
|
249
143
|
})) & {
|
|
250
144
|
schema: {};
|
|
@@ -253,16 +147,10 @@ export declare const createAuthContext: <UserType>({ agentAuth, accessTokens, au
|
|
|
253
147
|
macroFn: {};
|
|
254
148
|
parser: {};
|
|
255
149
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
256
|
-
readonly protectAgent: {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
};
|
|
150
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
151
|
+
code: "Forbidden" | "Unauthorized";
|
|
152
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
153
|
+
}) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
|
|
266
154
|
}>;
|
|
267
155
|
}, {}, import("elysia/types").DefaultEphemeral, {
|
|
268
156
|
derive: {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Elysia
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
2
|
import type { AuthorizationPluginProps, PermissionCheck } from './config';
|
|
3
3
|
type PermissionFailError = {
|
|
4
4
|
readonly code: 'Bad Request';
|
|
@@ -10,11 +10,6 @@ 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
|
-
};
|
|
18
13
|
export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emit, hasPermission }: AuthorizationPluginProps<UserType>) => Elysia<"", "local", {
|
|
19
14
|
decorator: {};
|
|
20
15
|
store: {
|
|
@@ -22,7 +17,7 @@ export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emi
|
|
|
22
17
|
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
23
18
|
};
|
|
24
19
|
derive: {
|
|
25
|
-
readonly protectPermission:
|
|
20
|
+
readonly protectPermission: <AuthReturn, AuthFailReturn>(check: PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | AuthReturn | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | NonNullable<AuthFailReturn> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403>>;
|
|
26
21
|
};
|
|
27
22
|
}, {
|
|
28
23
|
typebox: {};
|
|
@@ -39,7 +34,7 @@ export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emi
|
|
|
39
34
|
macroFn: {};
|
|
40
35
|
parser: {};
|
|
41
36
|
response: import("elysia/types").ExtractErrorFromHandle<{
|
|
42
|
-
readonly protectPermission:
|
|
37
|
+
readonly protectPermission: <AuthReturn, AuthFailReturn>(check: PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn) => Promise<import("elysia").ElysiaStatus<"Unauthorized", "User is not authenticated", 401> | AuthReturn | import("elysia").ElysiaStatus<"Bad Request", "Cookies are missing", 400> | NonNullable<AuthFailReturn> | import("elysia").ElysiaStatus<"Forbidden", "Insufficient permissions", 403>>;
|
|
43
38
|
}>;
|
|
44
39
|
}, {}, import("elysia/types").DefaultEphemeral, import("elysia/types").DefaultEphemeral>;
|
|
45
40
|
export {};
|
package/dist/cli/migrate.js
CHANGED
|
@@ -2729,6 +2729,7 @@ var mfaEnrollmentsTable = pgTable9("auth_mfa_enrollments", {
|
|
|
2729
2729
|
backup_code_hashes: jsonb4("backup_code_hashes").$type().notNull().default([]),
|
|
2730
2730
|
created_at_ms: bigint7("created_at_ms", { mode: "number" }).notNull(),
|
|
2731
2731
|
last_used_at_ms: bigint7("last_used_at_ms", { mode: "number" }),
|
|
2732
|
+
mfa_factors: jsonb4("mfa_factors").$type(),
|
|
2732
2733
|
sms_challenge_id: text4("sms_challenge_id"),
|
|
2733
2734
|
sms_code_sent_at_ms: bigint7("sms_code_sent_at_ms", { mode: "number" }),
|
|
2734
2735
|
sms_failed_attempts: smallint("sms_failed_attempts").notNull().default(0),
|
|
@@ -2736,6 +2737,7 @@ var mfaEnrollmentsTable = pgTable9("auth_mfa_enrollments", {
|
|
|
2736
2737
|
mode: "number"
|
|
2737
2738
|
}),
|
|
2738
2739
|
sms_pending_code_hash: text4("sms_pending_code_hash"),
|
|
2740
|
+
sms_pending_factor_id: text4("sms_pending_factor_id"),
|
|
2739
2741
|
sms_pending_purpose: text4("sms_pending_purpose").$type(),
|
|
2740
2742
|
sms_phone: varchar9("sms_phone", { length: PHONE_LENGTH }),
|
|
2741
2743
|
sms_provider_reference: text4("sms_provider_reference"),
|
|
@@ -3172,12 +3174,7 @@ var renderChunk = (chunk) => {
|
|
|
3172
3174
|
return "";
|
|
3173
3175
|
};
|
|
3174
3176
|
var formatSqlTemplate = (value) => value.queryChunks.map(renderChunk).join("");
|
|
3175
|
-
var
|
|
3176
|
-
const dimensions = Reflect.get(column, "dimensions");
|
|
3177
|
-
const elementType = column.getSQLType();
|
|
3178
|
-
return typeof dimensions === "number" && dimensions > 0 ? `${elementType}${"[]".repeat(dimensions)}` : elementType;
|
|
3179
|
-
};
|
|
3180
|
-
var formatScalarDefault = (value) => {
|
|
3177
|
+
var formatDefault = (value) => {
|
|
3181
3178
|
if (value === null || value === undefined)
|
|
3182
3179
|
return "NULL";
|
|
3183
3180
|
if (is(value, SQL))
|
|
@@ -3188,17 +3185,15 @@ var formatScalarDefault = (value) => {
|
|
|
3188
3185
|
return value ? "true" : "false";
|
|
3189
3186
|
if (typeof value === "number")
|
|
3190
3187
|
return String(value);
|
|
3191
|
-
if (typeof value === "object") {
|
|
3188
|
+
if (Array.isArray(value) || typeof value === "object") {
|
|
3192
3189
|
return `'${JSON.stringify(value)}'::jsonb`;
|
|
3193
3190
|
}
|
|
3194
3191
|
return String(value);
|
|
3195
3192
|
};
|
|
3196
|
-
var
|
|
3197
|
-
var formatDefault = (column, value) => {
|
|
3193
|
+
var columnSqlType = (column) => {
|
|
3198
3194
|
const dimensions = Reflect.get(column, "dimensions");
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
return formatScalarDefault(value);
|
|
3195
|
+
const elementType = column.getSQLType();
|
|
3196
|
+
return typeof dimensions === "number" && dimensions > 0 ? `${elementType}${"[]".repeat(dimensions)}` : elementType;
|
|
3202
3197
|
};
|
|
3203
3198
|
var columnSql = (column) => {
|
|
3204
3199
|
const parts = [`"${column.name}"`, columnSqlType(column)];
|
|
@@ -3207,7 +3202,7 @@ var columnSql = (column) => {
|
|
|
3207
3202
|
if (column.notNull && !column.primary)
|
|
3208
3203
|
parts.push("NOT NULL");
|
|
3209
3204
|
if (column.hasDefault && column.default !== undefined) {
|
|
3210
|
-
parts.push(`DEFAULT ${formatDefault(column
|
|
3205
|
+
parts.push(`DEFAULT ${formatDefault(column.default)}`);
|
|
3211
3206
|
}
|
|
3212
3207
|
if (column.isUnique)
|
|
3213
3208
|
parts.push("UNIQUE");
|
|
@@ -3326,6 +3321,14 @@ var mfaSmsAtomicChallengeMigration = {
|
|
|
3326
3321
|
id: "0005_sms_atomic_challenge",
|
|
3327
3322
|
sql: 'ALTER TABLE "auth_mfa_enrollments" ADD COLUMN IF NOT EXISTS "sms_challenge_id" text;'
|
|
3328
3323
|
};
|
|
3324
|
+
var mfaMultipleFactorsMigration = {
|
|
3325
|
+
id: "0006_multiple_factors",
|
|
3326
|
+
sql: [
|
|
3327
|
+
'ALTER TABLE "auth_mfa_enrollments" ADD COLUMN IF NOT EXISTS "mfa_factors" jsonb;',
|
|
3328
|
+
'ALTER TABLE "auth_mfa_enrollments" ADD COLUMN IF NOT EXISTS "sms_pending_factor_id" text;'
|
|
3329
|
+
].join(`
|
|
3330
|
+
`)
|
|
3331
|
+
};
|
|
3329
3332
|
var oidcResourceAudienceMigration = {
|
|
3330
3333
|
id: "0002_resource_audience",
|
|
3331
3334
|
sql: [
|
|
@@ -3407,7 +3410,8 @@ var blockMigrations = {
|
|
|
3407
3410
|
mfaSmsColumnsMigration,
|
|
3408
3411
|
mfaTotpLockoutMigration,
|
|
3409
3412
|
mfaSmsDeliveryPolicyMigration,
|
|
3410
|
-
mfaSmsAtomicChallengeMigration
|
|
3413
|
+
mfaSmsAtomicChallengeMigration,
|
|
3414
|
+
mfaMultipleFactorsMigration
|
|
3411
3415
|
]
|
|
3412
3416
|
},
|
|
3413
3417
|
oidc: {
|
|
@@ -3648,5 +3652,5 @@ var main = async () => {
|
|
|
3648
3652
|
};
|
|
3649
3653
|
await main();
|
|
3650
3654
|
|
|
3651
|
-
//# debugId=
|
|
3655
|
+
//# debugId=56E24220E33BD93664756E2164756E21
|
|
3652
3656
|
//# sourceMappingURL=migrate.js.map
|