@absolutejs/auth 0.55.2 → 0.55.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,9 +46,9 @@ export declare const apiKeysRoutes: ({ accessTokenStore, accessTokenTtlMs, apiCl
46
46
  [x: string]: {
47
47
  post: {
48
48
  body: {
49
- client_id?: string | undefined;
50
- scope?: string | undefined;
51
49
  grant_type?: string | undefined;
50
+ scope?: string | undefined;
51
+ client_id?: string | undefined;
52
52
  client_secret?: string | undefined;
53
53
  };
54
54
  params: {};
@@ -1,12 +1,7 @@
1
- import type { Elysia } from 'elysia';
2
- import type { agentAuthContextPlugin } from './agents/context';
3
1
  import type { protectRoutePlugin } from './routes/protectRoute';
4
- import type { stepUpPlugin } from './routes/stepUp';
5
- /** Merge the stable context contributed by independent Auth plugins without
6
- * exposing the configurable route graph in consumer declarations. */
7
- type MergeAuthContext<Base, Extra> = Base extends Elysia<infer Path, infer Singleton, infer Definitions, infer Metadata, infer Routes, infer Ephemeral, infer Volatile> ? Extra extends Elysia<infer ExtraPath, infer ExtraSingleton, infer ExtraDefinitions, infer ExtraMetadata, infer ExtraRoutes, infer ExtraEphemeral, infer ExtraVolatile> ? Elysia<Path & ExtraPath, Singleton & ExtraSingleton, Definitions & ExtraDefinitions, Metadata & ExtraMetadata, Routes & ExtraRoutes, Ephemeral & ExtraEphemeral, Volatile & ExtraVolatile> : never : never;
8
2
  /** The consumer-facing context contributed by `auth()`. Configurable auth
9
3
  * routes are available at runtime but intentionally omitted from this type:
10
- * their user-defined paths cannot form useful literal route declarations. */
11
- export type AuthInstance<UserType> = MergeAuthContext<MergeAuthContext<ReturnType<typeof protectRoutePlugin<UserType>>, ReturnType<typeof stepUpPlugin<UserType>>>, ReturnType<typeof agentAuthContextPlugin>>;
12
- export {};
4
+ * their user-defined paths cannot form useful literal route declarations.
5
+ * Optional step-up and agent contexts remain available through their explicit
6
+ * plugins without multiplying the default application's Elysia type graph. */
7
+ export type AuthInstance<UserType> = ReturnType<typeof protectRoutePlugin<UserType>>;
@@ -39,6 +39,10 @@ export declare const credentialsLogin: <UserType>({ authSessionStore, checkBreac
39
39
  readonly passwordCompromised: boolean;
40
40
  readonly status: "authenticated";
41
41
  };
42
+ 429: {
43
+ readonly retryAfterMs: number | undefined;
44
+ readonly status: "account_locked";
45
+ };
42
46
  422: {
43
47
  type: "validation";
44
48
  on: string;
@@ -48,10 +52,6 @@ export declare const credentialsLogin: <UserType>({ authSessionStore, checkBreac
48
52
  property?: string;
49
53
  expected?: string;
50
54
  };
51
- 429: {
52
- readonly retryAfterMs: number | undefined;
53
- readonly status: "account_locked";
54
- };
55
55
  };
56
56
  };
57
57
  };
@@ -107,6 +107,10 @@ export declare const credentialRoutes: <UserType>(config: CredentialRouteProps<U
107
107
  readonly passwordCompromised: boolean;
108
108
  readonly status: "authenticated";
109
109
  };
110
+ 429: {
111
+ readonly retryAfterMs: number | undefined;
112
+ readonly status: "account_locked";
113
+ };
110
114
  422: {
111
115
  type: "validation";
112
116
  on: string;
@@ -116,10 +120,6 @@ export declare const credentialRoutes: <UserType>(config: CredentialRouteProps<U
116
120
  property?: string;
117
121
  expected?: string;
118
122
  };
119
- 429: {
120
- readonly retryAfterMs: number | undefined;
121
- readonly status: "account_locked";
122
- };
123
123
  };
124
124
  };
125
125
  };
package/dist/index.d.ts CHANGED
@@ -16,24 +16,6 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
16
16
  }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
17
17
  };
18
18
  resolve: {};
19
- } & {
20
- decorator: {};
21
- store: {
22
- session: import("./types").SessionRecord<UserType>;
23
- unregisteredSession: import("./types").UnregisteredSessionRecord;
24
- };
25
- derive: {
26
- readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
27
- readonly code: "Unauthorized";
28
- readonly message: "Recent authentication required";
29
- }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
30
- };
31
- resolve: {};
32
- } & {
33
- decorator: {};
34
- store: {};
35
- derive: {};
36
- resolve: {};
37
19
  }, {
38
20
  typebox: {};
39
21
  error: {};
@@ -56,63 +38,18 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
56
38
  readonly message: "User is not authenticated";
57
39
  }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
58
40
  }>;
59
- } & {
60
- schema: import("elysia").UnwrapRoute<{
61
- cookie: import("@sinclair/typebox").TObject<{
62
- user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
63
- }>;
64
- }, {}, "">;
65
- standaloneSchema: {};
66
- macro: {};
67
- macroFn: {};
68
- parser: {};
69
- response: import("elysia").ExtractErrorFromHandle<{
70
- readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
71
- readonly code: "Unauthorized";
72
- readonly message: "Recent authentication required";
73
- }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
74
- }>;
75
- } & {
76
- schema: {};
77
- standaloneSchema: {};
78
- macro: {};
79
- macroFn: {};
80
- parser: {};
81
- response: {};
82
41
  }, {}, {
83
42
  derive: {};
84
43
  resolve: {};
85
44
  schema: {};
86
45
  standaloneSchema: {};
87
46
  response: {};
88
- } & {
89
- derive: {};
90
- resolve: {};
91
- schema: {};
92
- standaloneSchema: {};
93
- response: {};
94
47
  }, {
95
48
  derive: {};
96
49
  resolve: {};
97
50
  schema: {};
98
51
  standaloneSchema: {};
99
52
  response: {};
100
- } & {
101
- derive: {
102
- readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
103
- code: "Forbidden" | "Unauthorized";
104
- message: "Agent is not authenticated" | "Insufficient agent scopes";
105
- }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
106
- };
107
- resolve: {};
108
- schema: {};
109
- standaloneSchema: {};
110
- response: import("elysia").ExtractErrorFromHandle<{
111
- readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
112
- code: "Forbidden" | "Unauthorized";
113
- message: "Agent is not authenticated" | "Insufficient agent scopes";
114
- }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
115
- }>;
116
53
  }>>;
117
54
  export * from './actions';
118
55
  export type { AuthInstance } from './authInstance';
@@ -138,10 +138,10 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
138
138
  response: {
139
139
  400: "Phone must be in E.164 format";
140
140
  401: "Authentication required";
141
- 501: "SMS MFA is not configured";
142
141
  200: {
143
142
  readonly phone: string;
144
143
  };
144
+ 501: "SMS MFA is not configured";
145
145
  422: {
146
146
  type: "validation";
147
147
  on: string;
@@ -169,6 +169,7 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
169
169
  200: {
170
170
  readonly status: "enrolled";
171
171
  };
172
+ 429: "Too many attempts";
172
173
  422: {
173
174
  type: "validation";
174
175
  on: string;
@@ -178,7 +179,6 @@ export declare const mfaRoutes: <UserType>(config: MfaRouteProps<UserType>) => E
178
179
  property?: string;
179
180
  expected?: string;
180
181
  };
181
- 429: "Too many attempts";
182
182
  };
183
183
  };
184
184
  };
package/dist/mfa/sms.d.ts CHANGED
@@ -40,10 +40,10 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
40
40
  response: {
41
41
  400: "Phone must be in E.164 format";
42
42
  401: "Authentication required";
43
- 501: "SMS MFA is not configured";
44
43
  200: {
45
44
  readonly phone: string;
46
45
  };
46
+ 501: "SMS MFA is not configured";
47
47
  422: {
48
48
  type: "validation";
49
49
  on: string;
@@ -71,6 +71,7 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
71
71
  200: {
72
72
  readonly status: "enrolled";
73
73
  };
74
+ 429: "Too many attempts";
74
75
  422: {
75
76
  type: "validation";
76
77
  on: string;
@@ -80,7 +81,6 @@ export declare const mfaSmsRoutes: <UserType>({ authSessionStore, getUserId, mfa
80
81
  property?: string;
81
82
  expected?: string;
82
83
  };
83
- 429: "Too many attempts";
84
84
  };
85
85
  };
86
86
  };
@@ -27,8 +27,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
27
27
  body: unknown;
28
28
  params: {};
29
29
  query: {
30
- client_id?: string | undefined;
31
30
  scope?: string | undefined;
31
+ client_id?: string | undefined;
32
32
  nonce?: string | undefined;
33
33
  claims?: string | undefined;
34
34
  request?: string | undefined;
@@ -63,18 +63,18 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
63
63
  [x: string]: {
64
64
  post: {
65
65
  body: {
66
- client_id?: string | undefined;
66
+ grant_type?: string | undefined;
67
+ claim_token?: string | undefined;
67
68
  scope?: string | undefined;
68
- audience?: string | undefined;
69
+ assertion?: string | undefined;
69
70
  resource?: string | undefined;
71
+ client_id?: string | undefined;
72
+ audience?: string | undefined;
70
73
  refresh_token?: string | undefined;
71
74
  device_code?: string | undefined;
72
75
  auth_req_id?: string | undefined;
73
- grant_type?: string | undefined;
74
- claim_token?: string | undefined;
75
- assertion?: string | undefined;
76
- code?: string | undefined;
77
76
  client_secret?: string | undefined;
77
+ code?: string | undefined;
78
78
  redirect_uri?: string | undefined;
79
79
  client_assertion?: string | undefined;
80
80
  client_assertion_type?: string | undefined;
@@ -104,12 +104,12 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
104
104
  [x: string]: {
105
105
  post: {
106
106
  body: {
107
- client_id?: string | undefined;
108
107
  scope?: string | undefined;
108
+ resource?: string | undefined;
109
+ client_id?: string | undefined;
109
110
  nonce?: string | undefined;
110
111
  audience?: string | undefined;
111
112
  claims?: string | undefined;
112
- resource?: string | undefined;
113
113
  client_secret?: string | undefined;
114
114
  redirect_uri?: string | undefined;
115
115
  acr_values?: string | undefined;
@@ -199,8 +199,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
199
199
  [x: string]: {
200
200
  post: {
201
201
  body: {
202
- client_id?: string | undefined;
203
202
  scope?: string | undefined;
203
+ client_id?: string | undefined;
204
204
  client_secret?: string | undefined;
205
205
  login_hint?: string | undefined;
206
206
  binding_message?: string | undefined;
@@ -228,8 +228,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
228
228
  [x: string]: {
229
229
  post: {
230
230
  body: {
231
- client_id?: string | undefined;
232
231
  scope?: string | undefined;
232
+ client_id?: string | undefined;
233
233
  client_secret?: string | undefined;
234
234
  };
235
235
  params: {};
@@ -331,8 +331,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
331
331
  [x: string]: {
332
332
  post: {
333
333
  body: {
334
- jwks?: any;
335
334
  scope?: string | undefined;
335
+ jwks?: any;
336
336
  backchannel_logout_uri?: string | undefined;
337
337
  client_name?: string | undefined;
338
338
  grant_types?: string[] | undefined;
@@ -391,8 +391,8 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
391
391
  ":clientId": {
392
392
  put: {
393
393
  body: {
394
- jwks?: any;
395
394
  scope?: string | undefined;
395
+ jwks?: any;
396
396
  backchannel_logout_uri?: string | undefined;
397
397
  client_name?: string | undefined;
398
398
  grant_types?: string[] | undefined;
@@ -162,10 +162,10 @@ export declare const organizationRoutes: <UserType>({ authSessionStore, canCreat
162
162
  response: {
163
163
  401: "Authentication required";
164
164
  403: "Cannot manage members";
165
- 404: "Invitation not found";
166
165
  200: {
167
166
  readonly revoked: string;
168
167
  };
168
+ 404: "Invitation not found";
169
169
  422: {
170
170
  type: "validation";
171
171
  on: string;
@@ -66,11 +66,11 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
66
66
  response: {
67
67
  401: "Invalid or expired setup link";
68
68
  403: "This setup link cannot configure SAML";
69
- 501: "SSO is not configured";
70
69
  200: {
71
70
  readonly configured: true;
72
71
  readonly type: "saml";
73
72
  };
73
+ 501: "SSO is not configured";
74
74
  422: {
75
75
  type: "validation";
76
76
  on: string;
@@ -103,11 +103,11 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
103
103
  response: {
104
104
  401: "Invalid or expired setup link";
105
105
  403: "This setup link cannot configure OIDC";
106
- 501: "SSO is not configured";
107
106
  200: {
108
107
  readonly configured: true;
109
108
  readonly type: "oidc";
110
109
  };
110
+ 501: "SSO is not configured";
111
111
  422: {
112
112
  type: "validation";
113
113
  on: string;
@@ -134,12 +134,12 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
134
134
  response: {
135
135
  401: "Invalid or expired setup link";
136
136
  403: "This setup link cannot configure SCIM";
137
- 501: "SCIM is not configured";
138
137
  200: {
139
138
  readonly baseUrl: `${string}/${string}`;
140
139
  readonly token: string;
141
140
  readonly tokenId: string;
142
141
  };
142
+ 501: "SCIM is not configured";
143
143
  };
144
144
  };
145
145
  };
@@ -66,10 +66,10 @@ export declare const roleRoutes: <UserType>({ authSessionStore, canManageRoles,
66
66
  response: {
67
67
  401: "Authentication required";
68
68
  403: "Cannot manage roles";
69
- 404: "Membership not found";
70
69
  200: {
71
70
  readonly roles: string[];
72
71
  };
72
+ 404: "Membership not found";
73
73
  422: {
74
74
  type: "validation";
75
75
  on: string;
@@ -37,8 +37,8 @@ export declare const refresh: <UserType>({ authSessionStore, clientProviders, re
37
37
  response: {
38
38
  400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
39
39
  401: "Provider is required" | "Client provider not found" | "Client variant is required" | "Client variant not found" | "No auth provider found" | "No user session found";
40
- 501: "Provider is not refreshable";
41
40
  200: Response;
41
+ 501: "Provider is not refreshable";
42
42
  422: {
43
43
  type: "validation";
44
44
  on: string;
@@ -36,8 +36,8 @@ export declare const revoke: <UserType>({ authSessionStore, clientProviders, rev
36
36
  response: {
37
37
  400: "Cookies are missing" | "Invalid provider" | "Session has no access token to revoke";
38
38
  401: "Provider is required" | "Client provider not found" | "Client variant is required" | "Client variant not found" | "No auth provider found" | "No user session found";
39
- 501: "Provider does not support revocation";
40
39
  200: Response;
40
+ 501: "Provider does not support revocation";
41
41
  422: {
42
42
  type: "validation";
43
43
  on: string;
@@ -34,10 +34,10 @@ export declare const sessionRoutes: <UserType>({ authSessionStore, getUserId, se
34
34
  headers: unknown;
35
35
  response: {
36
36
  401: "Authentication required";
37
- 501: "Session management requires an authSessionStore";
38
37
  200: {
39
38
  readonly sessions: SessionSummary[];
40
39
  };
40
+ 501: "Session management requires an authSessionStore";
41
41
  422: {
42
42
  type: "validation";
43
43
  on: string;
@@ -63,11 +63,11 @@ export declare const sessionRoutes: <UserType>({ authSessionStore, getUserId, se
63
63
  response: {
64
64
  400: "Invalid session id";
65
65
  401: "Authentication required";
66
- 501: "Session management requires an authSessionStore";
67
- 404: "Session not found";
68
66
  200: {
69
67
  readonly revoked: `${string}-${string}-${string}-${string}-${string}`;
70
68
  };
69
+ 501: "Session management requires an authSessionStore";
70
+ 404: "Session not found";
71
71
  422: {
72
72
  type: "validation";
73
73
  on: string;
@@ -33,8 +33,8 @@ export declare const ssoDiscoveryRoute: ({ getOrganizationByEmailDomain, ssoConn
33
33
  headers: unknown;
34
34
  response: {
35
35
  400: "An \"email\" query parameter is required" | "A valid email address is required";
36
- 404: "No SSO organization is configured for this email domain" | "No SSO connection is configured for this organization";
37
36
  200: Response;
37
+ 404: "No SSO organization is configured for this email domain" | "No SSO connection is configured for this organization";
38
38
  422: {
39
39
  type: "validation";
40
40
  on: string;
@@ -33,8 +33,8 @@ export declare const oidcSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
33
33
  query: unknown;
34
34
  headers: unknown;
35
35
  response: {
36
- 404: "No OIDC connection is configured for this organization";
37
36
  200: Response;
37
+ 404: "No OIDC connection is configured for this organization";
38
38
  422: {
39
39
  type: "validation";
40
40
  on: string;
@@ -61,8 +61,8 @@ export declare const oidcSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
61
61
  headers: unknown;
62
62
  response: {
63
63
  400: "SSO session cookies are missing" | "Invalid SSO callback request" | "SSO organization mismatch" | "OIDC token response is missing an id_token";
64
- 404: "No OIDC connection is configured for this organization";
65
64
  200: Response;
65
+ 404: "No OIDC connection is configured for this organization";
66
66
  422: {
67
67
  type: "validation";
68
68
  on: string;
@@ -35,8 +35,8 @@ export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
35
35
  query: unknown;
36
36
  headers: unknown;
37
37
  response: {
38
- 404: "No SAML connection is configured for this organization";
39
38
  200: Response;
39
+ 404: "No SAML connection is configured for this organization";
40
40
  422: {
41
41
  type: "validation";
42
42
  on: string;
@@ -62,8 +62,8 @@ export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
62
62
  query: unknown;
63
63
  headers: unknown;
64
64
  response: {
65
- 404: "No SAML connection is configured for this organization";
66
65
  200: Response;
66
+ 404: "No SAML connection is configured for this organization";
67
67
  422: {
68
68
  type: "validation";
69
69
  on: string;
@@ -87,8 +87,8 @@ export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
87
87
  query: unknown;
88
88
  headers: unknown;
89
89
  response: {
90
- 404: "No SAML connection is configured for this organization";
91
90
  200: Response;
91
+ 404: "No SAML connection is configured for this organization";
92
92
  422: {
93
93
  type: "validation";
94
94
  on: string;
@@ -141,9 +141,9 @@ export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
141
141
  headers: unknown;
142
142
  response: {
143
143
  400: "Missing SAMLRequest or SAMLResponse" | "Invalid SAML LogoutRequest";
144
+ 200: Response;
144
145
  501: "SAML Single Logout is not configured";
145
146
  404: "No SAML connection is configured for this organization";
146
- 200: Response;
147
147
  422: {
148
148
  type: "validation";
149
149
  on: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.55.2",
2
+ "version": "0.55.3",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {