@absolutejs/auth 0.9.5 → 0.10.0
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/index.js +34 -51
- package/dist/index.js.map +11 -11
- package/dist/src/authorize.d.ts +6 -9
- package/dist/src/callback.d.ts +5 -8
- package/dist/src/index.d.ts +22 -32
- package/dist/src/profile.d.ts +4 -7
- package/dist/src/protectRoute.d.ts +7 -10
- package/dist/src/refresh.d.ts +5 -8
- package/dist/src/revoke.d.ts +5 -8
- package/dist/src/sessionStore.d.ts +1 -4
- package/dist/src/signout.d.ts +3 -6
- package/dist/src/status.d.ts +1 -4
- package/dist/src/types.d.ts +33 -12
- package/drizzle.config.ts +2 -0
- package/eslint.config.mjs +7 -1
- package/package.json +6 -4
package/dist/src/callback.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders,
|
|
2
|
+
import { ClientProviders, OnCallbackSuccess, RouteString } from './types';
|
|
3
3
|
type CallbackProps<UserType> = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
callbackRoute?: RouteString;
|
|
6
|
-
|
|
6
|
+
onCallbackSuccess?: OnCallbackSuccess<UserType>;
|
|
7
7
|
};
|
|
8
|
-
export declare const callback: <UserType>({ clientProviders, callbackRoute,
|
|
8
|
+
export declare const callback: <UserType>({ clientProviders, callbackRoute, onCallbackSuccess }: CallbackProps<UserType>) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
|
10
10
|
store: {
|
|
11
11
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -13,11 +13,10 @@ export declare const callback: <UserType>({ clientProviders, callbackRoute, onCa
|
|
|
13
13
|
derive: {};
|
|
14
14
|
resolve: {};
|
|
15
15
|
}, {
|
|
16
|
-
typebox: {};
|
|
17
16
|
error: {};
|
|
17
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
18
18
|
}, {
|
|
19
19
|
schema: {};
|
|
20
|
-
standaloneSchema: {};
|
|
21
20
|
macro: {};
|
|
22
21
|
macroFn: {};
|
|
23
22
|
parser: {};
|
|
@@ -29,7 +28,7 @@ export declare const callback: <UserType>({ clientProviders, callbackRoute, onCa
|
|
|
29
28
|
query: unknown;
|
|
30
29
|
headers: unknown;
|
|
31
30
|
response: {
|
|
32
|
-
200: Response;
|
|
31
|
+
200: import("undici-types").Response;
|
|
33
32
|
400: "Cookies are missing" | "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
|
|
34
33
|
401: "Invalid provider" | "Client provider not found" | "No auth provider found";
|
|
35
34
|
500: `${string} - ${string}` | `Failed to validate authorization code: Unknown error: ${string}`;
|
|
@@ -40,11 +39,9 @@ export declare const callback: <UserType>({ clientProviders, callbackRoute, onCa
|
|
|
40
39
|
derive: {};
|
|
41
40
|
resolve: {};
|
|
42
41
|
schema: {};
|
|
43
|
-
standaloneSchema: {};
|
|
44
42
|
}, {
|
|
45
43
|
derive: {};
|
|
46
44
|
resolve: {};
|
|
47
45
|
schema: {};
|
|
48
|
-
standaloneSchema: {};
|
|
49
46
|
}>;
|
|
50
47
|
export {};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { AbsoluteAuthProps } from './types';
|
|
3
|
-
export declare const absoluteAuth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute,
|
|
3
|
+
export declare const absoluteAuth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, onAuthorizeSuccess, onProfileSuccess, onCallbackSuccess, onStatus, onRefreshSuccess, onSignOut, onRevocationSuccess }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
|
|
4
4
|
decorator: {};
|
|
5
5
|
store: {
|
|
6
6
|
session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
|
|
7
7
|
};
|
|
8
|
-
derive: {
|
|
8
|
+
derive: {
|
|
9
|
+
readonly protectRoute: (handleAuth: () => Promise<Response>, handleAuthFail?: () => Promise<Response>) => Promise<Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session ID found", 401> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session found", 401>>;
|
|
10
|
+
};
|
|
9
11
|
resolve: {};
|
|
10
12
|
}, {
|
|
11
|
-
typebox: {};
|
|
12
13
|
error: {};
|
|
14
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
13
15
|
}, {
|
|
14
|
-
schema: {
|
|
15
|
-
|
|
16
|
+
schema: {
|
|
17
|
+
body: unknown;
|
|
18
|
+
headers: unknown;
|
|
19
|
+
query: unknown;
|
|
20
|
+
params: {};
|
|
21
|
+
cookie: unknown;
|
|
22
|
+
response: {};
|
|
23
|
+
};
|
|
16
24
|
macro: {};
|
|
17
25
|
macroFn: {};
|
|
18
26
|
parser: {};
|
|
@@ -26,8 +34,8 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
26
34
|
response: {
|
|
27
35
|
200: Response;
|
|
28
36
|
400: "Cookies are missing";
|
|
29
|
-
401: "No auth provider found" | "No user session found";
|
|
30
|
-
500: string
|
|
37
|
+
401: "No auth provider found" | "No user session found" | "User session not found";
|
|
38
|
+
500: `Error: ${string} - ${string}` | `Unknown Error: ${string}`;
|
|
31
39
|
};
|
|
32
40
|
};
|
|
33
41
|
};
|
|
@@ -43,7 +51,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
43
51
|
400: "Cookies are missing" | "Invalid provider";
|
|
44
52
|
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
45
53
|
501: "Provider does not support revocation";
|
|
46
|
-
500: `Failed to revoke token: ${string}
|
|
54
|
+
500: `Failed to revoke token: ${string}`;
|
|
47
55
|
};
|
|
48
56
|
};
|
|
49
57
|
};
|
|
@@ -73,7 +81,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
73
81
|
400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
|
|
74
82
|
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
75
83
|
501: "Provider is not refreshable";
|
|
76
|
-
500: `Failed to refresh token: ${string}
|
|
84
|
+
500: `Failed to refresh token: ${string}`;
|
|
77
85
|
};
|
|
78
86
|
};
|
|
79
87
|
};
|
|
@@ -88,7 +96,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
88
96
|
query: unknown;
|
|
89
97
|
headers: unknown;
|
|
90
98
|
response: {
|
|
91
|
-
200: Response;
|
|
99
|
+
200: import("undici-types").Response;
|
|
92
100
|
400: "Cookies are missing" | "Provider is required" | "Invalid provider";
|
|
93
101
|
401: "Client provider not found";
|
|
94
102
|
500: `${string} - ${string}` | `Unknown error: ${string}`;
|
|
@@ -117,7 +125,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
117
125
|
query: unknown;
|
|
118
126
|
headers: unknown;
|
|
119
127
|
response: {
|
|
120
|
-
200: Response;
|
|
128
|
+
200: import("undici-types").Response;
|
|
121
129
|
400: "Cookies are missing" | "Provider is required" | "Invalid provider";
|
|
122
130
|
401: "Client provider not found";
|
|
123
131
|
500: `${string} - ${string}` | `Unknown error: ${string}`;
|
|
@@ -143,7 +151,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
143
151
|
query: unknown;
|
|
144
152
|
headers: unknown;
|
|
145
153
|
response: {
|
|
146
|
-
200: Response;
|
|
154
|
+
200: import("undici-types").Response;
|
|
147
155
|
400: "Cookies are missing" | "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
|
|
148
156
|
401: "Invalid provider" | "Client provider not found" | "No auth provider found";
|
|
149
157
|
500: `${string} - ${string}` | `Failed to validate authorization code: Unknown error: ${string}`;
|
|
@@ -166,31 +174,13 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
|
|
|
166
174
|
};
|
|
167
175
|
};
|
|
168
176
|
}) & {}, {
|
|
169
|
-
derive: {
|
|
170
|
-
readonly protectRoute: (handleAuth: () => Promise<Response>, handleAuthFail?: () => Promise<Response>) => Promise<Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session ID found", 401> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session found", 401>>;
|
|
171
|
-
};
|
|
177
|
+
derive: {};
|
|
172
178
|
resolve: {};
|
|
173
|
-
schema:
|
|
174
|
-
body: unknown;
|
|
175
|
-
headers: unknown;
|
|
176
|
-
query: unknown;
|
|
177
|
-
params: {};
|
|
178
|
-
cookie: unknown;
|
|
179
|
-
response: {};
|
|
180
|
-
}, {}, "">;
|
|
181
|
-
standaloneSchema: import("elysia/types").PrettifySchema<{
|
|
182
|
-
body: unknown;
|
|
183
|
-
headers: unknown;
|
|
184
|
-
query: unknown;
|
|
185
|
-
params: unknown;
|
|
186
|
-
cookie: unknown;
|
|
187
|
-
response: unknown;
|
|
188
|
-
}>;
|
|
179
|
+
schema: {};
|
|
189
180
|
}, {
|
|
190
181
|
derive: {};
|
|
191
182
|
resolve: {};
|
|
192
183
|
schema: {};
|
|
193
|
-
standaloneSchema: {};
|
|
194
184
|
}>>;
|
|
195
185
|
export * from './types';
|
|
196
186
|
export { isValidUser } from './typeGuards';
|
package/dist/src/profile.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders,
|
|
2
|
+
import { ClientProviders, OnProfileSuccess, RouteString } from './types';
|
|
3
3
|
type ProfileProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
profileRoute?: RouteString;
|
|
6
|
-
|
|
6
|
+
onProfileSuccess?: OnProfileSuccess;
|
|
7
7
|
};
|
|
8
|
-
export declare const profile: <UserType>({ clientProviders, profileRoute,
|
|
8
|
+
export declare const profile: <UserType>({ clientProviders, profileRoute, onProfileSuccess }: ProfileProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
|
10
10
|
store: {
|
|
11
11
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -13,11 +13,10 @@ export declare const profile: <UserType>({ clientProviders, profileRoute, onProf
|
|
|
13
13
|
derive: {};
|
|
14
14
|
resolve: {};
|
|
15
15
|
}, {
|
|
16
|
-
typebox: {};
|
|
17
16
|
error: {};
|
|
17
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
18
18
|
}, {
|
|
19
19
|
schema: {};
|
|
20
|
-
standaloneSchema: {};
|
|
21
20
|
macro: {};
|
|
22
21
|
macroFn: {};
|
|
23
22
|
parser: {};
|
|
@@ -40,11 +39,9 @@ export declare const profile: <UserType>({ clientProviders, profileRoute, onProf
|
|
|
40
39
|
derive: {};
|
|
41
40
|
resolve: {};
|
|
42
41
|
schema: {};
|
|
43
|
-
standaloneSchema: {};
|
|
44
42
|
}, {
|
|
45
43
|
derive: {};
|
|
46
44
|
resolve: {};
|
|
47
45
|
schema: {};
|
|
48
|
-
standaloneSchema: {};
|
|
49
46
|
}>;
|
|
50
47
|
export {};
|
|
@@ -4,27 +4,24 @@ export declare const protectRoute: <UserType>() => Elysia<"", {
|
|
|
4
4
|
store: {
|
|
5
5
|
session: import("./types").SessionRecord<UserType>;
|
|
6
6
|
};
|
|
7
|
-
derive: {
|
|
7
|
+
derive: {
|
|
8
|
+
readonly protectRoute: (handleAuth: () => Promise<Response>, handleAuthFail?: () => Promise<Response>) => Promise<Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session ID found", 401> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session found", 401>>;
|
|
9
|
+
};
|
|
8
10
|
resolve: {};
|
|
9
11
|
}, {
|
|
10
|
-
typebox: {};
|
|
11
12
|
error: {};
|
|
13
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
12
14
|
}, {
|
|
13
|
-
schema: {}
|
|
14
|
-
standaloneSchema: {};
|
|
15
|
+
schema: import("elysia").MergeSchema<import("elysia").MergeSchema<{}, {}, "">, {}, "">;
|
|
15
16
|
macro: {};
|
|
16
17
|
macroFn: {};
|
|
17
18
|
parser: {};
|
|
18
19
|
}, {}, {
|
|
19
|
-
derive: {
|
|
20
|
-
readonly protectRoute: (handleAuth: () => Promise<Response>, handleAuthFail?: () => Promise<Response>) => Promise<Response | import("elysia/error").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session ID found", 401> | import("elysia/error").ElysiaCustomStatusResponse<"Unauthorized", "No session found", 401>>;
|
|
21
|
-
};
|
|
20
|
+
derive: {};
|
|
22
21
|
resolve: {};
|
|
23
|
-
schema:
|
|
24
|
-
standaloneSchema: import("elysia/types").PrettifySchema<{}>;
|
|
22
|
+
schema: {};
|
|
25
23
|
}, {
|
|
26
24
|
derive: {};
|
|
27
25
|
resolve: {};
|
|
28
26
|
schema: {};
|
|
29
|
-
standaloneSchema: {};
|
|
30
27
|
}>;
|
package/dist/src/refresh.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders,
|
|
2
|
+
import { ClientProviders, OnRefreshSuccess, RouteString } from './types';
|
|
3
3
|
type RefreshProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
refreshRoute?: RouteString;
|
|
6
|
-
|
|
6
|
+
onRefreshSuccess?: OnRefreshSuccess;
|
|
7
7
|
};
|
|
8
|
-
export declare const refresh: <UserType>({ clientProviders, refreshRoute,
|
|
8
|
+
export declare const refresh: <UserType>({ clientProviders, refreshRoute, onRefreshSuccess }: RefreshProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
|
10
10
|
store: {
|
|
11
11
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -13,11 +13,10 @@ export declare const refresh: <UserType>({ clientProviders, refreshRoute, onRefr
|
|
|
13
13
|
derive: {};
|
|
14
14
|
resolve: {};
|
|
15
15
|
}, {
|
|
16
|
-
typebox: {};
|
|
17
16
|
error: {};
|
|
17
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
18
18
|
}, {
|
|
19
19
|
schema: {};
|
|
20
|
-
standaloneSchema: {};
|
|
21
20
|
macro: {};
|
|
22
21
|
macroFn: {};
|
|
23
22
|
parser: {};
|
|
@@ -33,7 +32,7 @@ export declare const refresh: <UserType>({ clientProviders, refreshRoute, onRefr
|
|
|
33
32
|
400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
|
|
34
33
|
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
35
34
|
501: "Provider is not refreshable";
|
|
36
|
-
500: `Failed to refresh token: ${string}
|
|
35
|
+
500: `Failed to refresh token: ${string}`;
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
};
|
|
@@ -41,11 +40,9 @@ export declare const refresh: <UserType>({ clientProviders, refreshRoute, onRefr
|
|
|
41
40
|
derive: {};
|
|
42
41
|
resolve: {};
|
|
43
42
|
schema: {};
|
|
44
|
-
standaloneSchema: {};
|
|
45
43
|
}, {
|
|
46
44
|
derive: {};
|
|
47
45
|
resolve: {};
|
|
48
46
|
schema: {};
|
|
49
|
-
standaloneSchema: {};
|
|
50
47
|
}>;
|
|
51
48
|
export {};
|
package/dist/src/revoke.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders,
|
|
2
|
+
import { ClientProviders, OnRevocationSuccess, RouteString } from './types';
|
|
3
3
|
type RevokeProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
revokeRoute?: RouteString;
|
|
6
|
-
|
|
6
|
+
onRevocationSuccess?: OnRevocationSuccess;
|
|
7
7
|
};
|
|
8
|
-
export declare const revoke: <UserType>({ clientProviders, revokeRoute,
|
|
8
|
+
export declare const revoke: <UserType>({ clientProviders, revokeRoute, onRevocationSuccess }: RevokeProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
|
10
10
|
store: {
|
|
11
11
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -13,11 +13,10 @@ export declare const revoke: <UserType>({ clientProviders, revokeRoute, onRevoca
|
|
|
13
13
|
derive: {};
|
|
14
14
|
resolve: {};
|
|
15
15
|
}, {
|
|
16
|
-
typebox: {};
|
|
17
16
|
error: {};
|
|
17
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
18
18
|
}, {
|
|
19
19
|
schema: {};
|
|
20
|
-
standaloneSchema: {};
|
|
21
20
|
macro: {};
|
|
22
21
|
macroFn: {};
|
|
23
22
|
parser: {};
|
|
@@ -33,7 +32,7 @@ export declare const revoke: <UserType>({ clientProviders, revokeRoute, onRevoca
|
|
|
33
32
|
400: "Cookies are missing" | "Invalid provider";
|
|
34
33
|
401: "Client provider not found" | "No auth provider found" | "No user session found";
|
|
35
34
|
501: "Provider does not support revocation";
|
|
36
|
-
500: `Failed to revoke token: ${string}
|
|
35
|
+
500: `Failed to revoke token: ${string}`;
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
};
|
|
@@ -41,11 +40,9 @@ export declare const revoke: <UserType>({ clientProviders, revokeRoute, onRevoca
|
|
|
41
40
|
derive: {};
|
|
42
41
|
resolve: {};
|
|
43
42
|
schema: {};
|
|
44
|
-
standaloneSchema: {};
|
|
45
43
|
}, {
|
|
46
44
|
derive: {};
|
|
47
45
|
resolve: {};
|
|
48
46
|
schema: {};
|
|
49
|
-
standaloneSchema: {};
|
|
50
47
|
}>;
|
|
51
48
|
export {};
|
|
@@ -8,11 +8,10 @@ export declare const sessionStore: <UserType>() => Elysia<"", {
|
|
|
8
8
|
derive: {};
|
|
9
9
|
resolve: {};
|
|
10
10
|
}, {
|
|
11
|
-
typebox: {}
|
|
11
|
+
typebox: import("@sinclair/typebox").TModule<{}>;
|
|
12
12
|
error: {};
|
|
13
13
|
}, {
|
|
14
14
|
schema: {};
|
|
15
|
-
standaloneSchema: {};
|
|
16
15
|
macro: {};
|
|
17
16
|
macroFn: {};
|
|
18
17
|
parser: {};
|
|
@@ -20,10 +19,8 @@ export declare const sessionStore: <UserType>() => Elysia<"", {
|
|
|
20
19
|
derive: {};
|
|
21
20
|
resolve: {};
|
|
22
21
|
schema: {};
|
|
23
|
-
standaloneSchema: {};
|
|
24
22
|
}, {
|
|
25
23
|
derive: {};
|
|
26
24
|
resolve: {};
|
|
27
25
|
schema: {};
|
|
28
|
-
standaloneSchema: {};
|
|
29
26
|
}>;
|
package/dist/src/signout.d.ts
CHANGED
|
@@ -12,11 +12,10 @@ export declare const signout: <UserType>({ signoutRoute, onSignOut }: SignOutPro
|
|
|
12
12
|
derive: {};
|
|
13
13
|
resolve: {};
|
|
14
14
|
}, {
|
|
15
|
-
typebox: {};
|
|
16
15
|
error: {};
|
|
16
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
17
17
|
}, {
|
|
18
18
|
schema: {};
|
|
19
|
-
standaloneSchema: {};
|
|
20
19
|
macro: {};
|
|
21
20
|
macroFn: {};
|
|
22
21
|
parser: {};
|
|
@@ -30,8 +29,8 @@ export declare const signout: <UserType>({ signoutRoute, onSignOut }: SignOutPro
|
|
|
30
29
|
response: {
|
|
31
30
|
200: Response;
|
|
32
31
|
400: "Cookies are missing";
|
|
33
|
-
401: "No auth provider found" | "No user session found";
|
|
34
|
-
500: string
|
|
32
|
+
401: "No auth provider found" | "No user session found" | "User session not found";
|
|
33
|
+
500: `Error: ${string} - ${string}` | `Unknown Error: ${string}`;
|
|
35
34
|
};
|
|
36
35
|
};
|
|
37
36
|
};
|
|
@@ -39,11 +38,9 @@ export declare const signout: <UserType>({ signoutRoute, onSignOut }: SignOutPro
|
|
|
39
38
|
derive: {};
|
|
40
39
|
resolve: {};
|
|
41
40
|
schema: {};
|
|
42
|
-
standaloneSchema: {};
|
|
43
41
|
}, {
|
|
44
42
|
derive: {};
|
|
45
43
|
resolve: {};
|
|
46
44
|
schema: {};
|
|
47
|
-
standaloneSchema: {};
|
|
48
45
|
}>;
|
|
49
46
|
export {};
|
package/dist/src/status.d.ts
CHANGED
|
@@ -12,11 +12,10 @@ export declare const status: <UserType>({ statusRoute, onStatus }: StatusProps<U
|
|
|
12
12
|
derive: {};
|
|
13
13
|
resolve: {};
|
|
14
14
|
}, {
|
|
15
|
-
typebox: {};
|
|
16
15
|
error: {};
|
|
16
|
+
typebox: import("@sinclair/typebox").TModule<{}, {}>;
|
|
17
17
|
}, {
|
|
18
18
|
schema: {};
|
|
19
|
-
standaloneSchema: {};
|
|
20
19
|
macro: {};
|
|
21
20
|
macroFn: {};
|
|
22
21
|
parser: {};
|
|
@@ -38,11 +37,9 @@ export declare const status: <UserType>({ statusRoute, onStatus }: StatusProps<U
|
|
|
38
37
|
derive: {};
|
|
39
38
|
resolve: {};
|
|
40
39
|
schema: {};
|
|
41
|
-
standaloneSchema: {};
|
|
42
40
|
}, {
|
|
43
41
|
derive: {};
|
|
44
42
|
resolve: {};
|
|
45
43
|
schema: {};
|
|
46
|
-
standaloneSchema: {};
|
|
47
44
|
}>;
|
|
48
45
|
export {};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type UserFunctionProps = {
|
|
|
20
20
|
};
|
|
21
21
|
export type CreateUser<UserType> = ({ userProfile, authProvider }: UserFunctionProps) => Promise<UserType>;
|
|
22
22
|
export type GetUser<UserType> = ({ userProfile, authProvider }: UserFunctionProps) => Promise<UserType | null>;
|
|
23
|
-
export type
|
|
23
|
+
export type OnCallbackSuccess<UserType> = ({ authProvider, tokenResponse, providerInstance, session, user_session_id, originUrl }: {
|
|
24
24
|
providerInstance: OAuth2Client<ProviderOption>;
|
|
25
25
|
authProvider: string;
|
|
26
26
|
tokenResponse: OAuth2TokenResponse;
|
|
@@ -28,28 +28,44 @@ export type OnCallback<UserType> = ({ authProvider, tokenResponse, providerInsta
|
|
|
28
28
|
user_session_id: Cookie<string | undefined>;
|
|
29
29
|
originUrl: string;
|
|
30
30
|
}) => void | Promise<void>;
|
|
31
|
-
export type
|
|
31
|
+
export type OnAuthorizeSuccess = ({ authProvider, authorizationUrl }: {
|
|
32
32
|
authProvider: string;
|
|
33
33
|
authorizationUrl: URL;
|
|
34
34
|
}) => void | Promise<void>;
|
|
35
|
-
export type
|
|
35
|
+
export type OnAuthorizeError = ({ error, authProvider }: {
|
|
36
|
+
authProvider: string;
|
|
37
|
+
error: unknown;
|
|
38
|
+
}) => void | Promise<void>;
|
|
39
|
+
export type OnRefreshSuccess = ({ tokenResponse, authProvider }: {
|
|
36
40
|
tokenResponse: OAuth2TokenResponse;
|
|
37
41
|
authProvider: string;
|
|
38
42
|
}) => void | Promise<void>;
|
|
39
|
-
export type
|
|
43
|
+
export type OnRefreshError = ({ error, authProvider }: {
|
|
44
|
+
authProvider: string;
|
|
45
|
+
error: unknown;
|
|
46
|
+
}) => void | Promise<void>;
|
|
47
|
+
export type OnProfileSuccess = ({ userProfile, authProvider }: {
|
|
40
48
|
userProfile: Record<string, unknown>;
|
|
41
49
|
authProvider: string;
|
|
42
50
|
}) => void | Promise<void>;
|
|
43
|
-
export type
|
|
51
|
+
export type OnProfileError = ({ error, authProvider }: {
|
|
52
|
+
authProvider: string;
|
|
53
|
+
error: unknown;
|
|
54
|
+
}) => void | Promise<void>;
|
|
55
|
+
export type OnRevocationSuccess = ({ tokenToRevoke, authProvider }: {
|
|
44
56
|
tokenToRevoke: string;
|
|
45
57
|
authProvider: string;
|
|
46
58
|
}) => void | Promise<void>;
|
|
59
|
+
export type OnRevocationError = ({ error, authProvider }: {
|
|
60
|
+
authProvider: string;
|
|
61
|
+
error: unknown;
|
|
62
|
+
}) => void | Promise<void>;
|
|
47
63
|
export type OnStatus<UserType> = ({ user }: {
|
|
48
64
|
user: UserType | null;
|
|
49
65
|
}) => void | Promise<void>;
|
|
50
|
-
export type OnSignOut<UserType> = ({ authProvider,
|
|
66
|
+
export type OnSignOut<UserType> = ({ authProvider, userSession }: {
|
|
51
67
|
authProvider: string;
|
|
52
|
-
|
|
68
|
+
userSession: SessionData<UserType>;
|
|
53
69
|
}) => void | Promise<void>;
|
|
54
70
|
export type RouteString = `/${string}`;
|
|
55
71
|
export type AuthorizeRoute = `${string}/:provider${'' | `/${string}`}`;
|
|
@@ -62,13 +78,18 @@ export type AbsoluteAuthProps<UserType> = {
|
|
|
62
78
|
revokeRoute?: RouteString;
|
|
63
79
|
signoutRoute?: RouteString;
|
|
64
80
|
statusRoute?: RouteString;
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
onAuthorizeSuccess?: OnAuthorizeSuccess;
|
|
82
|
+
onAuthorizeError?: OnAuthorizeError;
|
|
83
|
+
onCallbackSuccess?: OnCallbackSuccess<UserType>;
|
|
84
|
+
onCallbackError?: (error: unknown) => void | Promise<void>;
|
|
67
85
|
onStatus?: OnStatus<UserType>;
|
|
68
|
-
|
|
86
|
+
onRefreshSuccess?: OnRefreshSuccess;
|
|
87
|
+
onRefreshError?: OnRefreshError;
|
|
69
88
|
onSignOut?: OnSignOut<UserType>;
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
onRevocationSuccess?: OnRevocationSuccess;
|
|
90
|
+
onRevocationError?: OnRevocationError;
|
|
91
|
+
onProfileSuccess?: OnProfileSuccess;
|
|
92
|
+
onProfileError?: OnProfileError;
|
|
72
93
|
};
|
|
73
94
|
export type ClientProviders = Record<string, {
|
|
74
95
|
providerInstance: OAuth2Client<ProviderOption>;
|
package/drizzle.config.ts
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -127,7 +127,7 @@ export default [
|
|
|
127
127
|
'no-loop-func': 'error',
|
|
128
128
|
'no-magic-numbers': [
|
|
129
129
|
'warn',
|
|
130
|
-
{ detectObjects: false, enforceConst: true, ignore: [0, 1] }
|
|
130
|
+
{ detectObjects: false, enforceConst: true, ignore: [0, 1, -1, 2] }
|
|
131
131
|
],
|
|
132
132
|
'no-misleading-character-class': 'error',
|
|
133
133
|
'no-nested-ternary': 'error',
|
|
@@ -236,6 +236,12 @@ export default [
|
|
|
236
236
|
'import/no-default-export': 'off'
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
|
+
{
|
|
240
|
+
files: ['example/server.ts'],
|
|
241
|
+
rules: {
|
|
242
|
+
'@typescript-eslint/no-unused-vars': 'off'
|
|
243
|
+
}
|
|
244
|
+
},
|
|
239
245
|
{
|
|
240
246
|
files: ['example/db/schema.ts'],
|
|
241
247
|
rules: {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.10.0",
|
|
3
3
|
"name": "@absolutejs/auth",
|
|
4
4
|
"description": "An authorization library for absolutejs",
|
|
5
5
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
15
|
"format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css,json}\"",
|
|
16
16
|
"dev": "bun run --watch example/server.ts",
|
|
17
|
-
"db:
|
|
17
|
+
"db:push": "drizzle-kit push",
|
|
18
18
|
"db:migrate": "bun run ./example/db/migrate.ts",
|
|
19
19
|
"db:studio": "drizzle-kit studio",
|
|
20
20
|
"lint": "eslint ./src ./example ./eslint.config.mjs",
|
|
@@ -30,13 +30,15 @@
|
|
|
30
30
|
],
|
|
31
31
|
"types": "dist/src/index.d.ts",
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"elysia": ">= 1.
|
|
33
|
+
"elysia": ">= 1.2.25"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"citra": "0.21.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@absolutejs/absolute": "0.4.0",
|
|
40
|
+
"@tanstack/react-query": "5.79.0",
|
|
41
|
+
"@elysiajs/eden": "1.2.0",
|
|
40
42
|
"@elysiajs/static": "1.2.0",
|
|
41
43
|
"@neondatabase/serverless": "1.0.0",
|
|
42
44
|
"@react-spring/web": "10.0.0-beta.0",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"@types/react-dom": "19.1.2",
|
|
47
49
|
"drizzle-kit": "0.30.6",
|
|
48
50
|
"drizzle-orm": "0.41.0",
|
|
49
|
-
"elysia": "1.
|
|
51
|
+
"elysia": "1.2.25",
|
|
50
52
|
"eslint": "9.26.0",
|
|
51
53
|
"eslint-plugin-absolute": "0.0.3",
|
|
52
54
|
"eslint-plugin-import": "2.31.0",
|