nuxt-bearer-auth 0.1.2 → 0.1.4
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/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/composables/useBearerAuth.d.ts +12 -12
- package/dist/runtime/composables/useBearerAuth.js +3 -0
- package/dist/runtime/middleware/bearer-auth.global.js +1 -0
- package/dist/runtime/plugins/bearer-auth.server.js +1 -0
- package/dist/runtime/server/middleware/auth.js +1 -0
- package/dist/runtime/server/plugins/redis.d.ts +1 -2
- package/dist/runtime/server/plugins/redis.js +2 -2
- package/dist/runtime/server/utils/config.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,7 +160,7 @@ async function submit() {
|
|
|
160
160
|
</script>
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
`identifier` could be any string that identifies a user in your
|
|
163
|
+
`identifier` could be any string that identifies a user in your backend. it could be email, phone number, username, etc.
|
|
164
164
|
|
|
165
165
|
Available composable state and methods:
|
|
166
166
|
|
package/dist/module.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { BearerAuthUser, FetchUserOptions, LoginCredentials, SocialLoginCredentials } from "../types/auth.js";
|
|
1
|
+
import type { AuthApiResponse, BearerAuthUser, FetchUserOptions, LoginCredentials, SocialLoginCredentials } from "../types/auth.js";
|
|
2
2
|
export declare function useBearerAuth<User extends BearerAuthUser = BearerAuthUser>(): {
|
|
3
3
|
user: any;
|
|
4
4
|
status: any;
|
|
5
5
|
ready: any;
|
|
6
6
|
error: any;
|
|
7
|
-
loading:
|
|
8
|
-
isAuthenticated:
|
|
9
|
-
serverReady:
|
|
10
|
-
login: (credentials: LoginCredentials, redirectPath?: string | null) => Promise<
|
|
11
|
-
socialLogin: (credentials: SocialLoginCredentials, redirectPath?: string | null) => Promise<
|
|
12
|
-
register: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<
|
|
13
|
-
verifyOtp: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<
|
|
7
|
+
loading: import("vue").ComputedRef<boolean>;
|
|
8
|
+
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
9
|
+
serverReady: import("vue").ComputedRef<Promise<void>>;
|
|
10
|
+
login: (credentials: LoginCredentials, redirectPath?: string | null) => Promise<AuthApiResponse<User>>;
|
|
11
|
+
socialLogin: (credentials: SocialLoginCredentials, redirectPath?: string | null) => Promise<AuthApiResponse<User>>;
|
|
12
|
+
register: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<AuthApiResponse<User>>;
|
|
13
|
+
verifyOtp: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<AuthApiResponse<User>>;
|
|
14
14
|
fetchUser: (options?: FetchUserOptions) => Promise<{
|
|
15
15
|
data: User | null;
|
|
16
16
|
error: string | null;
|
|
@@ -21,11 +21,11 @@ export declare function useBearerAuth<User extends BearerAuthUser = BearerAuthUs
|
|
|
21
21
|
data: null;
|
|
22
22
|
error: any;
|
|
23
23
|
}>;
|
|
24
|
-
refresh: () => Promise<
|
|
24
|
+
refresh: () => Promise<AuthApiResponse<User>>;
|
|
25
25
|
logout: (destination?: string) => Promise<void>;
|
|
26
|
-
forgotPassword: (payload: Record<string, unknown>) => Promise<
|
|
27
|
-
resetPassword: (payload: Record<string, unknown>) => Promise<
|
|
28
|
-
resendOtp: (identifier: string, payload?: Record<string, unknown>) => Promise<
|
|
26
|
+
forgotPassword: (payload: Record<string, unknown>) => Promise<unknown>;
|
|
27
|
+
resetPassword: (payload: Record<string, unknown>) => Promise<unknown>;
|
|
28
|
+
resendOtp: (identifier: string, payload?: Record<string, unknown>) => Promise<unknown>;
|
|
29
29
|
setUser: (value: User | null) => void;
|
|
30
30
|
setAuthReady: (value: boolean) => void;
|
|
31
31
|
setServerChecked: () => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getRequestURL } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
3
|
import { getBearerAuthSession } from "../utils/sessions.js";
|
|
3
4
|
const SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getBearerAuthRedisClient
|
|
4
4
|
} from "../utils/sessions.js";
|
|
5
5
|
import { isProductionRuntime } from "../utils/config.js";
|
|
6
|
-
export default
|
|
6
|
+
export default async function bearerAuthRedisPlugin() {
|
|
7
7
|
try {
|
|
8
8
|
await ensureBearerAuthRedisConnection();
|
|
9
9
|
} catch (error) {
|
|
@@ -20,4 +20,4 @@ export default defineNitroPlugin(async () => {
|
|
|
20
20
|
process.once("SIGTERM", cleanup);
|
|
21
21
|
process.once("SIGINT", cleanup);
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|