@floatingpixels/supabase-nuxt 0.2.4 → 0.2.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/README.md CHANGED
@@ -91,18 +91,6 @@ Default:
91
91
  - `login`: User will be redirected to this route if not authenticated or after logout.
92
92
  - `exclude`: Routes to exclude from the re-direct. `['/foo', '/bar/*']` will exclude the `foo` page and all pages in your `bar` folder.
93
93
 
94
- ### cookieOptions
95
-
96
- ```ts
97
- cookieOptions: {
98
- maxAge: 60 * 60 * 8,
99
- sameSite: 'lax',
100
- secure: true
101
- }
102
- ```
103
-
104
- Options for cookies used for authentication and session management, refer to [cookieOptions](https://nuxt.com/docs/api/composables/use-cookie#options) for available settings. Please note that the lifetime set here does not determine the Supabase session lifetime.
105
-
106
94
  ### `clientOptions`
107
95
 
108
96
  Default:
package/dist/module.d.mts CHANGED
@@ -1,7 +1,18 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { SupabaseClientOptions } from '@supabase/supabase-js';
3
- import { CookieOptions } from 'nuxt/app';
4
3
 
4
+ declare module '@nuxt/schema' {
5
+ interface PublicRuntimeConfig {
6
+ supabase: {
7
+ url: string;
8
+ key: string;
9
+ serviceKey: string;
10
+ redirect: boolean;
11
+ redirectOptions: RedirectOptions;
12
+ clientOptions: SupabaseClientOptions<string>;
13
+ };
14
+ }
15
+ }
5
16
  interface RedirectOptions {
6
17
  /**
7
18
  * Login route
@@ -57,17 +68,6 @@ interface ModuleOptions {
57
68
  * @type RedirectOptions
58
69
  */
59
70
  redirectOptions?: RedirectOptions;
60
- /**
61
- * Cookie options
62
- * @default {
63
- maxAge: 60 * 60 * 8,
64
- sameSite: 'lax',
65
- secure: false,
66
- }
67
- * @type CookieOptions
68
- * @docs https://nuxt.com/docs/api/composables/use-cookie#options
69
- */
70
- cookieOptions?: CookieOptions;
71
71
  /**
72
72
  * Supabase Client options
73
73
  * @default {
@@ -83,21 +83,6 @@ interface ModuleOptions {
83
83
  clientOptions?: SupabaseClientOptions<string>;
84
84
  }
85
85
 
86
- declare module '@nuxt/schema' {
87
- interface PublicRuntimeConfig {
88
- supabase: {
89
- url: string;
90
- key: string;
91
- redirect: boolean;
92
- redirectOptions: RedirectOptions;
93
- cookieName: string;
94
- cookieOptions: CookieOptions;
95
- types: string | false;
96
- clientOptions: SupabaseClientOptions<string>;
97
- };
98
- }
99
- }
100
-
101
86
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
102
87
 
103
- export { _default as default };
88
+ export { type ModuleOptions, type RedirectOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -1,7 +1,18 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { SupabaseClientOptions } from '@supabase/supabase-js';
3
- import { CookieOptions } from 'nuxt/app';
4
3
 
4
+ declare module '@nuxt/schema' {
5
+ interface PublicRuntimeConfig {
6
+ supabase: {
7
+ url: string;
8
+ key: string;
9
+ serviceKey: string;
10
+ redirect: boolean;
11
+ redirectOptions: RedirectOptions;
12
+ clientOptions: SupabaseClientOptions<string>;
13
+ };
14
+ }
15
+ }
5
16
  interface RedirectOptions {
6
17
  /**
7
18
  * Login route
@@ -57,17 +68,6 @@ interface ModuleOptions {
57
68
  * @type RedirectOptions
58
69
  */
59
70
  redirectOptions?: RedirectOptions;
60
- /**
61
- * Cookie options
62
- * @default {
63
- maxAge: 60 * 60 * 8,
64
- sameSite: 'lax',
65
- secure: false,
66
- }
67
- * @type CookieOptions
68
- * @docs https://nuxt.com/docs/api/composables/use-cookie#options
69
- */
70
- cookieOptions?: CookieOptions;
71
71
  /**
72
72
  * Supabase Client options
73
73
  * @default {
@@ -83,21 +83,6 @@ interface ModuleOptions {
83
83
  clientOptions?: SupabaseClientOptions<string>;
84
84
  }
85
85
 
86
- declare module '@nuxt/schema' {
87
- interface PublicRuntimeConfig {
88
- supabase: {
89
- url: string;
90
- key: string;
91
- redirect: boolean;
92
- redirectOptions: RedirectOptions;
93
- cookieName: string;
94
- cookieOptions: CookieOptions;
95
- types: string | false;
96
- clientOptions: SupabaseClientOptions<string>;
97
- };
98
- }
99
- }
100
-
101
86
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
102
87
 
103
- export { _default as default };
88
+ export { type ModuleOptions, type RedirectOptions, _default as default };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">3.0.0"
6
6
  },
7
- "version": "0.2.4",
7
+ "version": "0.2.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -19,11 +19,6 @@ const module = defineNuxtModule({
19
19
  login: "/login",
20
20
  exclude: []
21
21
  },
22
- cookieOptions: {
23
- maxAge: 60 * 60 * 8,
24
- sameSite: "lax",
25
- secure: false
26
- },
27
22
  clientOptions: {
28
23
  auth: {
29
24
  flowType: "pkce",
@@ -46,8 +41,7 @@ const module = defineNuxtModule({
46
41
  key: options.key,
47
42
  redirect: options.redirect,
48
43
  redirectOptions: options.redirectOptions,
49
- clientOptions: options.clientOptions,
50
- cookieOptions: options.cookieOptions
44
+ clientOptions: options.clientOptions
51
45
  });
52
46
  nuxt.options.runtimeConfig.supabase = defu(nuxt.options.runtimeConfig.supabase, {
53
47
  serviceKey: options.serviceKey
@@ -5,10 +5,8 @@ export default defineNuxtPlugin({
5
5
  enforce: "pre",
6
6
  async setup() {
7
7
  const config = useRuntimeConfig().public.supabase;
8
- const { url, key, cookieOptions } = config;
9
- const supabaseBrowserClient = createBrowserClient(url, key, {
10
- cookieOptions
11
- });
8
+ const { url, key } = config;
9
+ const supabaseBrowserClient = createBrowserClient(url, key);
12
10
  return {
13
11
  provide: {
14
12
  supabase: {
@@ -1,25 +1,26 @@
1
1
  import { defineNuxtPlugin, useRuntimeConfig, useRequestEvent } from "nuxt/app";
2
- import { createServerClient } from "@supabase/ssr";
3
- import { setCookie, parseCookies } from "h3";
2
+ import { createServerClient, parseCookieHeader } from "@supabase/ssr";
3
+ import { setCookie, getHeader } from "h3";
4
4
  export default defineNuxtPlugin({
5
5
  name: "supabase",
6
6
  enforce: "pre",
7
7
  async setup() {
8
- const { url, key, cookieOptions } = useRuntimeConfig().public.supabase;
8
+ const { url, key } = useRuntimeConfig().public.supabase;
9
9
  const event = useRequestEvent();
10
+ if (!event) {
11
+ throw new Error("No request event found");
12
+ }
10
13
  const supabaseServerClient = createServerClient(url, key, {
11
14
  cookies: {
12
15
  getAll: async () => {
13
- const cookies = parseCookies(event);
14
- return Object.entries(cookies).map(([name, value]) => ({ name, value }));
16
+ return parseCookieHeader(getHeader(event, "Cookie") ?? "");
15
17
  },
16
18
  setAll: async (cookiesToSet) => {
17
19
  cookiesToSet.forEach(({ name, value, options }) => {
18
- setCookie(event, name, value, { ...cookieOptions, ...options });
20
+ setCookie(event, name, value, options);
19
21
  });
20
22
  }
21
- },
22
- cookieOptions
23
+ }
23
24
  });
24
25
  return {
25
26
  provide: {
@@ -1,25 +1,23 @@
1
- import { createServerClient } from "@supabase/ssr";
2
- import { parseCookies, setCookie } from "h3";
1
+ import { createServerClient, parseCookieHeader } from "@supabase/ssr";
2
+ import { setCookie, getHeader } from "h3";
3
3
  import { useRuntimeConfig } from "#imports";
4
4
  export const supabaseServerClient = async (event) => {
5
5
  const {
6
- supabase: { url, key, cookieOptions }
6
+ supabase: { url, key }
7
7
  } = useRuntimeConfig().public;
8
8
  let supabaseClient = event.context._supabaseClient;
9
9
  if (!supabaseClient) {
10
10
  supabaseClient = createServerClient(url, key, {
11
11
  cookies: {
12
12
  getAll: async () => {
13
- const cookies = parseCookies(event);
14
- return Object.entries(cookies).map(([name, value]) => ({ name, value }));
13
+ return parseCookieHeader(getHeader(event, "Cookie") ?? "");
15
14
  },
16
15
  setAll: async (cookiesToSet) => {
17
16
  cookiesToSet.forEach(({ name, value, options }) => {
18
- setCookie(event, name, value, { ...cookieOptions, ...options });
17
+ setCookie(event, name, value, options);
19
18
  });
20
19
  }
21
- },
22
- cookieOptions
20
+ }
23
21
  });
24
22
  event.context._supabaseClient = supabaseClient;
25
23
  }
@@ -1,11 +1,11 @@
1
- import { createServerClient } from "@supabase/ssr";
2
- import { parseCookies, setCookie } from "h3";
1
+ import { createServerClient, parseCookieHeader } from "@supabase/ssr";
2
+ import { setCookie, getHeader } from "h3";
3
3
  import { useRuntimeConfig } from "#imports";
4
4
  export const supabaseServiceRole = async (event) => {
5
5
  const {
6
6
  supabase: { serviceKey },
7
7
  public: {
8
- supabase: { url, cookieOptions }
8
+ supabase: { url }
9
9
  }
10
10
  } = useRuntimeConfig();
11
11
  if (!serviceKey) {
@@ -16,16 +16,14 @@ export const supabaseServiceRole = async (event) => {
16
16
  supabaseClient = createServerClient(url, serviceKey, {
17
17
  cookies: {
18
18
  getAll: async () => {
19
- const cookies = parseCookies(event);
20
- return Object.entries(cookies).map(([name, value]) => ({ name, value }));
19
+ return parseCookieHeader(getHeader(event, "Cookie") ?? "");
21
20
  },
22
21
  setAll: async (cookiesToSet) => {
23
22
  cookiesToSet.forEach(({ name, value, options }) => {
24
- setCookie(event, name, value, { ...cookieOptions, ...options });
23
+ setCookie(event, name, value, options);
25
24
  });
26
25
  }
27
- },
28
- cookieOptions
26
+ }
29
27
  });
30
28
  event.context._supabaseServiceRole = supabaseClient;
31
29
  }
package/dist/types.d.mts CHANGED
@@ -1,7 +1 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module.js'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module.js'
1
+ export { type ModuleOptions, type RedirectOptions, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,7 +1 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module'
1
+ export { type ModuleOptions, type RedirectOptions, default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floatingpixels/supabase-nuxt",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Supabase module for Nuxt",
5
5
  "repository": "floatingpixels/supabase-nuxt",
6
6
  "license": "MIT",
@@ -43,6 +43,7 @@
43
43
  "test": "nuxi prepare playground && pnpm vitest",
44
44
  "test:watch": "vitest watch",
45
45
  "test:pw": "playwright test test/playwright/",
46
+ "test:e2e": "pnpm run --silent db:start && pnpm run --silent db:fullreset && pnpm run --silent test:pw && pnpm run --silent db:stop",
46
47
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
47
48
  "supa": "./node_modules/supabase/bin/supabase",
48
49
  "db:fullreset": "pnpm run --silent db:reset && pnpm run --silent db:types && pnpm run --silent db:sync && pnpm run --silent db:seed",
@@ -64,7 +65,7 @@
64
65
  },
65
66
  "devDependencies": {
66
67
  "@nuxt/devtools": "^1.6.1",
67
- "@nuxt/eslint-config": "^0.7.1",
68
+ "@nuxt/eslint-config": "^0.7.2",
68
69
  "@nuxt/module-builder": "^0.8.4",
69
70
  "@nuxt/schema": "^3.14.1592",
70
71
  "@nuxt/test-utils": "^3.14.4",
@@ -72,7 +73,7 @@
72
73
  "@snaplet/copycat": "^5.1.0",
73
74
  "@snaplet/seed": "^0.98.0",
74
75
  "@types/eslint-config-prettier": "^6.11.3",
75
- "@types/node": "^22.9.1",
76
+ "@types/node": "^22.10.0",
76
77
  "@vitest/coverage-v8": "2.1.5",
77
78
  "@vue/test-utils": "^2.4.6",
78
79
  "changelogen": "^0.5.7",
@@ -82,10 +83,10 @@
82
83
  "nuxt": "^3.14.1592",
83
84
  "playwright-core": "^1.49.0",
84
85
  "postgres": "^3.4.5",
85
- "prettier": "^3.3.3",
86
+ "prettier": "^3.4.0",
86
87
  "release-it": "^17.10.0",
87
88
  "supabase": "^1.223.10",
88
- "typescript": "^5.6.3",
89
+ "typescript": "5.6.3",
89
90
  "vitest": "^2.1.5",
90
91
  "vue-tsc": "^2.1.10"
91
92
  }