@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.
@@ -7,10 +7,16 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", "
7
7
  decorator: {};
8
8
  store: {};
9
9
  derive: {
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>>>;
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: {};
@@ -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 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";
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
- 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>;
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: <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>>;
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: <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>>>;
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 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";
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
- 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>;
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 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>>;
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 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>>;
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: <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>>>;
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 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>;
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: <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>>;
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: <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>>;
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: <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>>>;
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: <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>>;
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: <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>>;
42
+ readonly protectPermission: ProtectPermission<UserType>;
38
43
  }>;
39
44
  }, {}, import("elysia/types").DefaultEphemeral, import("elysia/types").DefaultEphemeral>;
40
45
  export {};
@@ -3174,7 +3174,12 @@ var renderChunk = (chunk) => {
3174
3174
  return "";
3175
3175
  };
3176
3176
  var formatSqlTemplate = (value) => value.queryChunks.map(renderChunk).join("");
3177
- var formatDefault = (value) => {
3177
+ var columnSqlType = (column) => {
3178
+ const dimensions = Reflect.get(column, "dimensions");
3179
+ const elementType = column.getSQLType();
3180
+ return typeof dimensions === "number" && dimensions > 0 ? `${elementType}${"[]".repeat(dimensions)}` : elementType;
3181
+ };
3182
+ var formatScalarDefault = (value) => {
3178
3183
  if (value === null || value === undefined)
3179
3184
  return "NULL";
3180
3185
  if (is(value, SQL))
@@ -3185,15 +3190,17 @@ var formatDefault = (value) => {
3185
3190
  return value ? "true" : "false";
3186
3191
  if (typeof value === "number")
3187
3192
  return String(value);
3188
- if (Array.isArray(value) || typeof value === "object") {
3193
+ if (typeof value === "object") {
3189
3194
  return `'${JSON.stringify(value)}'::jsonb`;
3190
3195
  }
3191
3196
  return String(value);
3192
3197
  };
3193
- var columnSqlType = (column) => {
3198
+ var formatArrayDefault = (values) => `ARRAY[${values.map((value) => Array.isArray(value) ? formatArrayDefault(value) : formatScalarDefault(value)).join(", ")}]`;
3199
+ var formatDefault = (column, value) => {
3194
3200
  const dimensions = Reflect.get(column, "dimensions");
3195
- const elementType = column.getSQLType();
3196
- return typeof dimensions === "number" && dimensions > 0 ? `${elementType}${"[]".repeat(dimensions)}` : elementType;
3201
+ if (Array.isArray(value) && typeof dimensions === "number" && dimensions > 0)
3202
+ return `${formatArrayDefault(value)}::${columnSqlType(column)}`;
3203
+ return formatScalarDefault(value);
3197
3204
  };
3198
3205
  var columnSql = (column) => {
3199
3206
  const parts = [`"${column.name}"`, columnSqlType(column)];
@@ -3202,7 +3209,7 @@ var columnSql = (column) => {
3202
3209
  if (column.notNull && !column.primary)
3203
3210
  parts.push("NOT NULL");
3204
3211
  if (column.hasDefault && column.default !== undefined) {
3205
- parts.push(`DEFAULT ${formatDefault(column.default)}`);
3212
+ parts.push(`DEFAULT ${formatDefault(column, column.default)}`);
3206
3213
  }
3207
3214
  if (column.isUnique)
3208
3215
  parts.push("UNIQUE");
@@ -3652,5 +3659,5 @@ var main = async () => {
3652
3659
  };
3653
3660
  await main();
3654
3661
 
3655
- //# debugId=56E24220E33BD93664756E2164756E21
3662
+ //# debugId=4F26DF822A88399A64756E2164756E21
3656
3663
  //# sourceMappingURL=migrate.js.map