@floatingpixels/supabase-nuxt 0.2.3 → 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 +0 -12
- package/dist/module.d.mts +12 -12
- package/dist/module.d.ts +12 -12
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -8
- package/dist/runtime/plugins/middleware-auth-redirect.d.ts +1 -1
- package/dist/runtime/plugins/supabase.client.js +2 -4
- package/dist/runtime/plugins/supabase.server.js +9 -8
- package/dist/runtime/server/services/supabaseServerClient.js +6 -8
- package/dist/runtime/server/services/supabaseServiceRole.js +6 -8
- package/package.json +18 -17
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: true,
|
|
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 {
|
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: true,
|
|
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 {
|
package/dist/module.json
CHANGED
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: true
|
|
26
|
-
},
|
|
27
22
|
clientOptions: {
|
|
28
23
|
auth: {
|
|
29
24
|
flowType: "pkce",
|
|
@@ -36,10 +31,10 @@ const module = defineNuxtModule({
|
|
|
36
31
|
setup(options, nuxt) {
|
|
37
32
|
const { resolve } = createResolver(import.meta.url);
|
|
38
33
|
if (!options.url) {
|
|
39
|
-
console.warn("Missing `SUPABASE_URL` in
|
|
34
|
+
console.warn("Missing `SUPABASE_URL` in environmewnt");
|
|
40
35
|
}
|
|
41
36
|
if (!options.key) {
|
|
42
|
-
console.warn("Missing `SUPABASE_KEY` in
|
|
37
|
+
console.warn("Missing `SUPABASE_KEY` in environment");
|
|
43
38
|
}
|
|
44
39
|
nuxt.options.runtimeConfig.public.supabase = defu(nuxt.options.runtimeConfig.public.supabase, {
|
|
45
40
|
url: options.url,
|
|
@@ -48,7 +43,6 @@ const module = defineNuxtModule({
|
|
|
48
43
|
redirectOptions: options.redirectOptions,
|
|
49
44
|
clientOptions: options.clientOptions
|
|
50
45
|
});
|
|
51
|
-
nuxt.options.runtimeConfig.public.supabase.cookieOptions = nuxt.options.runtimeConfig.public.supabase.cookieOptions || options.cookieOptions;
|
|
52
46
|
nuxt.options.runtimeConfig.supabase = defu(nuxt.options.runtimeConfig.supabase, {
|
|
53
47
|
serviceKey: options.serviceKey
|
|
54
48
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -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
|
|
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,
|
|
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
|
|
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
|
-
|
|
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,
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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,
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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,
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floatingpixels/supabase-nuxt",
|
|
3
|
-
"version": "0.2.
|
|
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",
|
|
@@ -57,36 +58,36 @@
|
|
|
57
58
|
"db:fullseed": "(npx @snaplet/seed sync) -and (npx tsx seed.ts)"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@nuxt/kit": "^3.14.
|
|
61
|
-
"@supabase/ssr": "^0.5.
|
|
61
|
+
"@nuxt/kit": "^3.14.1592",
|
|
62
|
+
"@supabase/ssr": "^0.5.2",
|
|
62
63
|
"@supabase/supabase-js": "^2.46.1",
|
|
63
64
|
"defu": "^6.1.4"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@nuxt/devtools": "^1.6.
|
|
67
|
-
"@nuxt/eslint-config": "^0.
|
|
67
|
+
"@nuxt/devtools": "^1.6.1",
|
|
68
|
+
"@nuxt/eslint-config": "^0.7.2",
|
|
68
69
|
"@nuxt/module-builder": "^0.8.4",
|
|
69
|
-
"@nuxt/schema": "^3.14.
|
|
70
|
+
"@nuxt/schema": "^3.14.1592",
|
|
70
71
|
"@nuxt/test-utils": "^3.14.4",
|
|
71
|
-
"@playwright/test": "^1.
|
|
72
|
+
"@playwright/test": "^1.49.0",
|
|
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.
|
|
76
|
-
"@vitest/coverage-v8": "2.1.
|
|
76
|
+
"@types/node": "^22.10.0",
|
|
77
|
+
"@vitest/coverage-v8": "2.1.5",
|
|
77
78
|
"@vue/test-utils": "^2.4.6",
|
|
78
79
|
"changelogen": "^0.5.7",
|
|
79
|
-
"eslint": "^9.
|
|
80
|
+
"eslint": "^9.15.0",
|
|
80
81
|
"eslint-config-prettier": "^9.1.0",
|
|
81
|
-
"happy-dom": "^15.11.
|
|
82
|
-
"nuxt": "^3.14.
|
|
83
|
-
"playwright-core": "^1.
|
|
82
|
+
"happy-dom": "^15.11.6",
|
|
83
|
+
"nuxt": "^3.14.1592",
|
|
84
|
+
"playwright-core": "^1.49.0",
|
|
84
85
|
"postgres": "^3.4.5",
|
|
85
|
-
"prettier": "^3.
|
|
86
|
+
"prettier": "^3.4.0",
|
|
86
87
|
"release-it": "^17.10.0",
|
|
87
|
-
"supabase": "^1.
|
|
88
|
-
"typescript": "
|
|
89
|
-
"vitest": "^2.1.
|
|
88
|
+
"supabase": "^1.223.10",
|
|
89
|
+
"typescript": "5.6.3",
|
|
90
|
+
"vitest": "^2.1.5",
|
|
90
91
|
"vue-tsc": "^2.1.10"
|
|
91
92
|
}
|
|
92
93
|
}
|