@absolutejs/auth 0.17.5 → 0.17.7

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.
@@ -31,8 +31,8 @@ export declare const callback: <UserType>({ clientProviders, callbackRoute, onCa
31
31
  query: unknown;
32
32
  headers: unknown;
33
33
  response: {
34
- [x: number]: unknown;
35
- 200: Response;
34
+ [x: string]: any;
35
+ 200: any;
36
36
  400: "Cookies are missing" | "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
37
37
  401: "Invalid provider" | "Client provider not found" | "No auth provider found";
38
38
  500: `${string} - ${string}` | `Failed to validate authorization code: Unknown status: ${string}`;
@@ -19,7 +19,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
19
19
  } | {
20
20
  readonly code: "Unauthorized";
21
21
  readonly message: "User is not authenticated";
22
- }) => Promise<Response | import("./types").StatusReturn>) => Promise<Response | import("./types").StatusReturn | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request" | "Internal Server Error", "Cookies are missing" | `Error: ${string} - ${string}` | `Unknown Error: ${string}`, 400 | 500> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401>>;
22
+ }) => Promise<Response | import("./types").StatusReturn>) => Promise<import("./types").StatusReturn | Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request" | "Internal Server Error", "Cookies are missing" | `Error: ${string} - ${string}` | `Unknown Error: ${string}`, 400 | 500> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401>>;
23
23
  };
24
24
  resolve: {};
25
25
  }, {
@@ -174,8 +174,8 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
174
174
  query: unknown;
175
175
  headers: unknown;
176
176
  response: {
177
- [x: number]: unknown;
178
- 200: Response;
177
+ [x: string]: any;
178
+ 200: any;
179
179
  400: "Cookies are missing" | "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
180
180
  401: "Invalid provider" | "Client provider not found" | "No auth provider found";
181
181
  500: `${string} - ${string}` | `Failed to validate authorization code: Unknown status: ${string}`;
@@ -12,7 +12,7 @@ export declare const protectRoute: <UserType>() => Elysia<"", {
12
12
  unregisteredSession: import("./types").UnregisteredSessionRecord;
13
13
  };
14
14
  derive: {
15
- readonly protectRoute: (handleAuth: (user: UserType) => Promise<Response | StatusReturn>, handleAuthFail?: (error: AuthFailError) => Promise<Response | StatusReturn>) => Promise<Response | StatusReturn | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request" | "Internal Server Error", "Cookies are missing" | `Error: ${string} - ${string}` | `Unknown Error: ${string}`, 400 | 500> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401>>;
15
+ readonly protectRoute: (handleAuth: (user: UserType) => Promise<Response | StatusReturn>, handleAuthFail?: (error: AuthFailError) => Promise<Response | StatusReturn>) => Promise<StatusReturn | Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request" | "Internal Server Error", "Cookies are missing" | `Error: ${string} - ${string}` | `Unknown Error: ${string}`, 400 | 500> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401>>;
16
16
  };
17
17
  resolve: {};
18
18
  }, {
@@ -22,7 +22,8 @@ export type UnregisteredSessionRecord = Record<string, {
22
22
  userIdentity: Record<string, unknown>;
23
23
  expiresAt: number;
24
24
  }>;
25
- export type OnNewUser<UserType> = (userIdentity: Record<string, unknown>) => UserType | Response | StatusReturn | Promise<UserType | Response | StatusReturn>;
25
+ export type StatusReturn = ElysiaCustomStatusResponse<any, any, any>;
26
+ export type OnNewUser<UserType> = (userIdentity: Record<string, unknown>) => UserType | StatusReturn | Promise<UserType | StatusReturn>;
26
27
  export type GetUser<UserType> = (userIdentity: Record<string, unknown>) => UserType | null | undefined | Promise<UserType | null | undefined>;
27
28
  export type CallbackCookie = Record<string, Cookie<string | undefined>> & {
28
29
  user_session_id: Cookie<`${string}-${string}-${string}-${string}-${string}` | undefined>;
@@ -91,10 +92,6 @@ export type GetStatusProps<UserType> = {
91
92
  session: SessionRecord<UserType>;
92
93
  onStatus?: OnStatus<UserType>;
93
94
  };
94
- type AllowedStatusText = Parameters<typeof statusType>[0];
95
- type AllowedBody = Parameters<typeof statusType>[1];
96
- type StatusCodeFor<Text extends AllowedStatusText> = ReturnType<typeof statusType> extends ElysiaCustomStatusResponse<Text, infer InferredBody, infer InferredCode> ? [InferredBody] extends [unknown] ? InferredCode : never : never;
97
- export type StatusReturn<Text extends AllowedStatusText = AllowedStatusText, Body extends AllowedBody = AllowedBody> = ElysiaCustomStatusResponse<Text, Body, StatusCodeFor<Text>>;
98
95
  export type AbsoluteAuthProps<UserType> = {
99
96
  providersConfiguration: OAuth2ConfigurationOptions;
100
97
  authorizeRoute?: AuthorizeRoute;
@@ -1,5 +1,5 @@
1
1
  import { AbsoluteAuthProps, GetStatusProps, InsantiateUserSessionProps, OAuth2ConfigurationOptions } from './types';
2
- export declare const instantiateUserSession: <UserType>({ userSessionId, authProvider, session, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser }: InsantiateUserSessionProps<UserType>) => Promise<Response | import("./types").StatusReturn<number | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required", unknown> | undefined>;
2
+ export declare const instantiateUserSession: <UserType>({ userSessionId, authProvider, session, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser }: InsantiateUserSessionProps<UserType>) => Promise<import("./types").StatusReturn | (Awaited<UserType> & Response) | undefined>;
3
3
  export declare const createAuthConfiguration: <UserType>(configuration: AbsoluteAuthProps<UserType>) => AbsoluteAuthProps<UserType>;
4
4
  export declare const createProvidersConfiguration: (providersConfiguration: OAuth2ConfigurationOptions) => OAuth2ConfigurationOptions;
5
5
  export declare const getStatus: <UserType>({ user_session_id, session, onStatus }: GetStatusProps<UserType>) => Promise<{
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.17.5",
2
+ "version": "0.17.7",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {