nuxt-bearer-auth 0.1.2 → 0.1.3

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 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 bacend. it could email, phone numder, username etc.
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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.12.0 || ^4.0.0"
6
6
  },
7
- "version": "0.1.2",
7
+ "version": "0.1.3",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -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: any;
8
- isAuthenticated: any;
9
- serverReady: any;
10
- login: (credentials: LoginCredentials, redirectPath?: string | null) => Promise<any>;
11
- socialLogin: (credentials: SocialLoginCredentials, redirectPath?: string | null) => Promise<any>;
12
- register: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<any>;
13
- verifyOtp: (payload: Record<string, unknown>, redirectPath?: string | null) => Promise<any>;
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<any>;
24
+ refresh: () => Promise<AuthApiResponse<User>>;
25
25
  logout: (destination?: string) => Promise<void>;
26
- forgotPassword: (payload: Record<string, unknown>) => Promise<any>;
27
- resetPassword: (payload: Record<string, unknown>) => Promise<any>;
28
- resendOtp: (identifier: string, payload?: Record<string, unknown>) => Promise<any>;
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,3 +1,6 @@
1
+ import { navigateTo, useRuntimeConfig, useState } from "#app";
2
+ import { computed, watch } from "vue";
3
+ import { $fetch } from "ofetch";
1
4
  let serverCheckPromise = null;
2
5
  let serverCheckResolve = null;
3
6
  async function authFetch(request, options = {}) {
@@ -1,3 +1,4 @@
1
+ import { defineNuxtRouteMiddleware, navigateTo, useRuntimeConfig } from "#app";
1
2
  import { useBearerAuth } from "../composables/useBearerAuth.js";
2
3
  export default defineNuxtRouteMiddleware(async (to) => {
3
4
  const config = useRuntimeConfig();
@@ -1,3 +1,4 @@
1
+ import { defineNuxtPlugin } from "#app";
1
2
  import { getBearerAuthSession } from "../server/utils/sessions.js";
2
3
  import { useBearerAuth } from "../composables/useBearerAuth.js";
3
4
  export default defineNuxtPlugin(async (nuxtApp) => {
@@ -1,4 +1,5 @@
1
1
  import { createError, defineEventHandler, getRequestURL } from "h3";
2
+ import { useRuntimeConfig } from "nitropack/runtime/config";
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) => {
@@ -1,3 +1,2 @@
1
- declare const _default: any;
2
- export default _default;
1
+ export default function bearerAuthRedisPlugin(): Promise<void>;
3
2
  //# sourceMappingURL=redis.d.ts.map
@@ -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 defineNitroPlugin(async () => {
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
+ }
@@ -1,4 +1,5 @@
1
1
  import { createError } from "h3";
2
+ import { useRuntimeConfig } from "nitropack/runtime/config";
2
3
  export function getBearerAuthConfig() {
3
4
  const config = useRuntimeConfig();
4
5
  return config.bearerAuth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-bearer-auth",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Reusable Nuxt authentication module for bearer-token APIs with Redis sessions and CSRF protection.",
5
5
  "type": "module",
6
6
  "license": "MIT",