@absolutejs/auth 0.17.4 → 0.17.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/src/index.d.ts +1 -1
- package/dist/src/protectRoute.d.ts +1 -1
- package/dist/src/types.d.ts +5 -1
- package/dist/src/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -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("
|
|
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>>;
|
|
23
23
|
};
|
|
24
24
|
resolve: {};
|
|
25
25
|
}, {
|
|
@@ -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 |
|
|
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>>;
|
|
16
16
|
};
|
|
17
17
|
resolve: {};
|
|
18
18
|
}, {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CredentialsFor, NonEmptyArray, OAuth2Client, OAuth2TokenResponse, ProviderOption, ProvidersMap } from 'citra';
|
|
2
2
|
import { Cookie, status as statusType, redirect as redirectType } from 'elysia';
|
|
3
|
+
import { ElysiaCustomStatusResponse } from 'elysia/error';
|
|
3
4
|
type SessionData<UserType> = {
|
|
4
5
|
user: UserType;
|
|
5
6
|
accessToken: string;
|
|
@@ -90,7 +91,10 @@ export type GetStatusProps<UserType> = {
|
|
|
90
91
|
session: SessionRecord<UserType>;
|
|
91
92
|
onStatus?: OnStatus<UserType>;
|
|
92
93
|
};
|
|
93
|
-
|
|
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>>;
|
|
94
98
|
export type AbsoluteAuthProps<UserType> = {
|
|
95
99
|
providersConfiguration: OAuth2ConfigurationOptions;
|
|
96
100
|
authorizeRoute?: AuthorizeRoute;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -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("
|
|
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>;
|
|
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