@absolutejs/auth 0.1.0 → 0.2.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.
- package/dist/example/utils/userUtils.d.ts +17 -0
- package/dist/index.js +128 -128
- package/dist/src/authorize.d.ts +2 -2
- package/dist/src/callback.d.ts +4 -6
- package/dist/src/index.d.ts +3 -2
- package/dist/src/logout.d.ts +1 -2
- package/dist/src/refresh.d.ts +2 -2
- package/dist/src/revoke.d.ts +2 -2
- package/dist/src/status.d.ts +2 -2
- package/dist/src/types.d.ts +16 -14
- package/dist/src/utils.d.ts +15 -0
- package/package.json +9 -5
package/dist/src/authorize.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders
|
|
2
|
+
import { ClientProviders } from './types';
|
|
3
3
|
type AuthorizeProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
authorizeRoute?: string;
|
|
6
|
-
onAuthorize?:
|
|
6
|
+
onAuthorize?: () => void;
|
|
7
7
|
};
|
|
8
8
|
export declare const authorize: ({ clientProviders, authorizeRoute, onAuthorize }: AuthorizeProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
package/dist/src/callback.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders,
|
|
2
|
+
import { ClientProviders, OnCallback } from './types';
|
|
3
3
|
type CallbackProps<UserType> = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
callbackRoute?: string;
|
|
6
|
-
onCallback?:
|
|
7
|
-
getUser?: GetUser<UserType>;
|
|
8
|
-
createUser?: CreateUser<UserType>;
|
|
6
|
+
onCallback?: OnCallback<UserType>;
|
|
9
7
|
};
|
|
10
|
-
export declare const callback: <UserType>({ clientProviders, callbackRoute, onCallback
|
|
8
|
+
export declare const callback: <UserType>({ clientProviders, callbackRoute, onCallback }: CallbackProps<UserType>) => Elysia<"", {
|
|
11
9
|
decorator: {};
|
|
12
10
|
store: {
|
|
13
11
|
session: import("./types").SessionRecord<UserType>;
|
|
@@ -33,7 +31,7 @@ export declare const callback: <UserType>({ clientProviders, callbackRoute, onCa
|
|
|
33
31
|
200: import("undici-types").Response;
|
|
34
32
|
400: "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
|
|
35
33
|
401: "Invalid provider" | "No auth provider found";
|
|
36
|
-
500:
|
|
34
|
+
500: `${string} - ${string}` | `Failed to validate authorization code: Unknown error: ${string}`;
|
|
37
35
|
};
|
|
38
36
|
};
|
|
39
37
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OAuth2RequestError, ArcticFetchError } from 'arctic';
|
|
2
2
|
import { Elysia } from 'elysia';
|
|
3
3
|
import { AbsoluteAuthProps } from './types';
|
|
4
|
-
export declare const absoluteAuth: <UserType>({ config, authorizeRoute, callbackRoute, logoutRoute, statusRoute, refreshRoute, revokeRoute, onAuthorize, onCallback, onStatus, onRefresh, onLogout, onRevoke
|
|
4
|
+
export declare const absoluteAuth: <UserType>({ config, authorizeRoute, callbackRoute, logoutRoute, statusRoute, refreshRoute, revokeRoute, onAuthorize, onCallback, onStatus, onRefresh, onLogout, onRevoke }: AbsoluteAuthProps<UserType>) => Elysia<"", {
|
|
5
5
|
decorator: {};
|
|
6
6
|
store: {
|
|
7
7
|
session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
|
|
@@ -117,7 +117,7 @@ export declare const absoluteAuth: <UserType>({ config, authorizeRoute, callback
|
|
|
117
117
|
200: import("undici-types").Response;
|
|
118
118
|
400: "Invalid callback request" | "Invalid state mismatch" | "Code verifier not found and is required";
|
|
119
119
|
401: "Invalid provider" | "No auth provider found";
|
|
120
|
-
500:
|
|
120
|
+
500: `${string} - ${string}` | `Failed to validate authorization code: Unknown error: ${string}`;
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
123
|
};
|
|
@@ -139,3 +139,4 @@ export declare const absoluteAuth: <UserType>({ config, authorizeRoute, callback
|
|
|
139
139
|
resolve: {};
|
|
140
140
|
schema: {};
|
|
141
141
|
}>;
|
|
142
|
+
export * from './utils';
|
package/dist/src/logout.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { OAuthEventHandler } from './types';
|
|
3
2
|
type LogoutProps = {
|
|
4
3
|
logoutRoute?: string;
|
|
5
|
-
onLogout?:
|
|
4
|
+
onLogout?: () => void;
|
|
6
5
|
};
|
|
7
6
|
export declare const logout: ({ logoutRoute, onLogout }: LogoutProps) => Elysia<"", {
|
|
8
7
|
decorator: {};
|
package/dist/src/refresh.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders
|
|
2
|
+
import { ClientProviders } from './types';
|
|
3
3
|
type RefreshProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
refreshRoute?: string;
|
|
6
|
-
onRefresh?:
|
|
6
|
+
onRefresh?: () => void;
|
|
7
7
|
};
|
|
8
8
|
export declare const refresh: ({ clientProviders, refreshRoute, onRefresh }: RefreshProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
package/dist/src/revoke.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders
|
|
2
|
+
import { ClientProviders } from './types';
|
|
3
3
|
type RevokeProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
revokeRoute?: string;
|
|
6
|
-
onRevoke?:
|
|
6
|
+
onRevoke?: () => void;
|
|
7
7
|
};
|
|
8
8
|
export declare const revoke: ({ clientProviders, revokeRoute, onRevoke }: RevokeProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
package/dist/src/status.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import { ClientProviders
|
|
2
|
+
import { ClientProviders } from './types';
|
|
3
3
|
type StatusProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
statusRoute?: string;
|
|
6
|
-
onStatus?:
|
|
6
|
+
onStatus?: () => void;
|
|
7
7
|
};
|
|
8
8
|
export declare const status: <UserType>({ clientProviders, statusRoute, onStatus }: StatusProps) => Elysia<"", {
|
|
9
9
|
decorator: {};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Cookie } from 'elysia';
|
|
1
2
|
import { providers } from './providers';
|
|
2
3
|
type SessionData<UserType> = {
|
|
3
4
|
user: UserType;
|
|
@@ -12,19 +13,22 @@ type Oauth2ConfigOptions = {
|
|
|
12
13
|
};
|
|
13
14
|
export type Providers = keyof typeof providers;
|
|
14
15
|
export type SessionRecord<UserType> = Record<string, SessionData<UserType> | undefined>;
|
|
15
|
-
export type
|
|
16
|
-
|
|
16
|
+
export type UserFunctionProps = {
|
|
17
|
+
authProvider: string;
|
|
17
18
|
decodedIdToken: {
|
|
18
19
|
[key: string]: string | undefined;
|
|
19
20
|
};
|
|
21
|
+
};
|
|
22
|
+
export type CreateUser<UserType> = ({ decodedIdToken, authProvider }: UserFunctionProps) => Promise<UserType>;
|
|
23
|
+
export type GetUser<UserType> = ({ decodedIdToken, authProvider }: UserFunctionProps) => Promise<UserType | null>;
|
|
24
|
+
export type OnCallback<UserType> = ({ authProvider, decodedIdToken, session, user_session_id }: {
|
|
20
25
|
authProvider: string;
|
|
21
|
-
}) => Promise<UserType>;
|
|
22
|
-
export type GetUser<UserType> = ({ decodedIdToken, authProvider }: {
|
|
23
26
|
decodedIdToken: {
|
|
24
27
|
[key: string]: string | undefined;
|
|
25
28
|
};
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
session: SessionRecord<UserType>;
|
|
30
|
+
user_session_id: Cookie<string | undefined>;
|
|
31
|
+
}) => void;
|
|
28
32
|
export type AbsoluteAuthProps<UserType> = {
|
|
29
33
|
config: Oauth2ConfigOptions;
|
|
30
34
|
authorizeRoute?: string;
|
|
@@ -33,14 +37,12 @@ export type AbsoluteAuthProps<UserType> = {
|
|
|
33
37
|
revokeRoute?: string;
|
|
34
38
|
logoutRoute?: string;
|
|
35
39
|
statusRoute?: string;
|
|
36
|
-
onAuthorize?:
|
|
37
|
-
onCallback?:
|
|
38
|
-
onStatus?:
|
|
39
|
-
onRefresh?:
|
|
40
|
-
onLogout?:
|
|
41
|
-
onRevoke?:
|
|
42
|
-
createUser?: CreateUser<UserType>;
|
|
43
|
-
getUser?: GetUser<UserType>;
|
|
40
|
+
onAuthorize?: () => void;
|
|
41
|
+
onCallback?: OnCallback<UserType>;
|
|
42
|
+
onStatus?: () => void;
|
|
43
|
+
onRefresh?: () => void;
|
|
44
|
+
onLogout?: () => void;
|
|
45
|
+
onRevoke?: () => void;
|
|
44
46
|
};
|
|
45
47
|
export type ClientProviders = Record<string, {
|
|
46
48
|
providerInstance: InstanceType<(typeof providers)[Providers]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Cookie } from 'elysia';
|
|
2
|
+
import { AbsoluteAuthProps, CreateUser, GetUser, SessionRecord } from './types';
|
|
3
|
+
type InsantiateUserSessionProps<UserType> = {
|
|
4
|
+
authProvider: string;
|
|
5
|
+
decodedIdToken: {
|
|
6
|
+
[key: string]: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
session: SessionRecord<UserType>;
|
|
9
|
+
user_session_id: Cookie<string | undefined>;
|
|
10
|
+
createUser?: CreateUser<UserType>;
|
|
11
|
+
getUser?: GetUser<UserType>;
|
|
12
|
+
};
|
|
13
|
+
export declare const instantiateUserSession: <UserType>({ authProvider, decodedIdToken, user_session_id, session, getUser, createUser }: InsantiateUserSessionProps<UserType>) => Promise<void>;
|
|
14
|
+
export declare const createAuthConfig: <UserType>(props: AbsoluteAuthProps<UserType>) => AbsoluteAuthProps<UserType>;
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1
|
|
2
|
+
"version": "0.2.1",
|
|
3
3
|
"name": "@absolutejs/auth",
|
|
4
4
|
"description": "An authorization library for absolutejs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/absolutejs/absolute-auth.git"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"license": "CC BY-NC 4.0",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"dev": "bun run --watch example/server.ts",
|
|
17
17
|
"db:generate": "drizzle-kit generate --schema ./example/db/schema.ts --dialect postgresql",
|
|
18
18
|
"db:migrate": "bun run ./example/db/migrate.ts",
|
|
19
|
-
"db:studio": "drizzle-kit studio"
|
|
19
|
+
"db:studio": "drizzle-kit studio",
|
|
20
|
+
"release": "bun run format && bun run build && bun publish"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"authorization",
|
|
@@ -27,8 +28,10 @@
|
|
|
27
28
|
],
|
|
28
29
|
"types": "dist/src/index.d.ts",
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"arctic": "3.6.0"
|
|
31
|
-
|
|
31
|
+
"arctic": "3.6.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"elysia": ">= 1.2.0"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@elysiajs/static": "1.2.0",
|
|
@@ -41,6 +44,7 @@
|
|
|
41
44
|
"prettier": "3.5.3",
|
|
42
45
|
"react": "19.1.0",
|
|
43
46
|
"react-dom": "19.1.0",
|
|
47
|
+
"elysia": "1.2.25",
|
|
44
48
|
"typescript": "5.8.3"
|
|
45
49
|
},
|
|
46
50
|
"module": "dist/index.js",
|