@floatingpixels/supabase-nuxt 0.2.10 → 0.3.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/README.md CHANGED
@@ -31,14 +31,16 @@ export default defineNuxtConfig({
31
31
  })
32
32
  ```
33
33
 
34
- Add `SUPABASE_URL` and `SUPABASE_KEY` to the `.env`:
34
+ Add `SUPABASE_URL` and `SUPABASE_ANON_KEY` to `.env`:
35
35
 
36
36
  ```zsh
37
- SUPABASE_URL="https://example.supabase.co"
38
- SUPABASE_KEY="<your_key>"
37
+ NUXT_PUBLIC_SUPABASE_URL="https://example.supabase.co"
38
+ NUXT_PUBLIC_SUPABASE_ANON_KEY=""
39
39
  ```
40
40
 
41
- Alternatively, you can prefix the environment variables with `NUXT_PUBLIC_` in order to use `runtimeConfig`.
41
+ When dynamically setting the variables during in an environment, make sure to prefix the environment variables with `NUXT_PUBLIC_` in order to use `runtimeConfig`.
42
+
43
+ The public keys are required to be set in the environment for the module to work. If the service role is needed, you should also set `NUXT_SUPABASE_SERVICE_ROLE_KEY` in the environment, which will be only available on the server side as a private runtime variable.
42
44
 
43
45
  ## Options
44
46
 
@@ -55,19 +57,19 @@ export default defineNuxtConfig({
55
57
 
56
58
  ### `url`
57
59
 
58
- Default: `process.env.SUPABASE_URL` (ex: `https://example.supabase.co`)
60
+ Default: `process.env.NUXT_PUBLIC_SUPABASE_URL` (e.g.: `https://example.supabase.co`)
59
61
 
60
62
  The unique Supabase URL which is supplied when you create a new project in your project dashboard.
61
63
 
62
64
  ### `key`
63
65
 
64
- Default: `process.env.SUPABASE_KEY`
66
+ Default: `process.env.NUXT_PUBLIC_SUPABASE_ANON_KEY`
65
67
 
66
68
  Supabase 'anon key', used to bypass the Supabase API gateway and interact with your Supabase database making use of user JWT to apply RLS Policies.
67
69
 
68
70
  ### `serviceKey`
69
71
 
70
- Default: `process.env.SUPABASE_SERVICE_KEY`
72
+ Default: `process.env.NUXT_SUPABASE_SERVICE_ROLE_KEY`
71
73
 
72
74
  Supabase 'service role key', has super admin rights and can bypass your Row Level Security.
73
75
 
@@ -387,7 +389,7 @@ Make requests with super admin rights to the Supabase API with the `supabaseServ
387
389
 
388
390
  It provides similar functionality as the `supabaseServerClient` but it provides a client with super admin rights that can bypass your [Row Level Security](https://supabase.com/docs/guides/auth/row-level-security).
389
391
 
390
- The client is initialized with the `SUPABASE_SERVICE_KEY` you must have in your `.env` file. Checkout the doc if you want to know more about [Supabase keys](https://supabase.com/docs/learn/auth-deep-dive/auth-deep-dive-jwts#jwts-in-supabase).
392
+ The client is initialized with the `SUPABASE_SERVICE_ROLE_KEY` you must have in your environment. Checkout the doc if you want to know more about [Supabase keys](https://supabase.com/docs/learn/auth-deep-dive/auth-deep-dive-jwts#jwts-in-supabase).
391
393
 
392
394
  > ⚠️ The service key gives admin access to your database, be careful to not expose it in your client side code or in your git repository.
393
395
 
package/dist/module.d.mts CHANGED
@@ -5,8 +5,8 @@ declare module '@nuxt/schema' {
5
5
  interface PublicRuntimeConfig {
6
6
  supabase: {
7
7
  url: string;
8
- key: string;
9
- serviceKey: string;
8
+ anonKey: string;
9
+ serviceRoleKey: string;
10
10
  redirect: boolean;
11
11
  redirectOptions: RedirectOptions;
12
12
  clientOptions: SupabaseClientOptions<string>;
@@ -43,7 +43,7 @@ interface ModuleOptions {
43
43
  * @type string
44
44
  * @docs https://supabase.com/docs/reference/javascript/initializing#parameters
45
45
  */
46
- key: string;
46
+ anonKey: string;
47
47
  /**
48
48
  * Supabase Service key
49
49
  * @default process.env.SUPABASE_SERVICE_KEY
@@ -51,7 +51,7 @@ interface ModuleOptions {
51
51
  * @type string
52
52
  * @docs https://supabase.com/docs/reference/javascript/initializing#parameters
53
53
  */
54
- serviceKey?: string;
54
+ serviceRoleKey?: string;
55
55
  /**
56
56
  * Redirect automatically to login page if user is not authenticated
57
57
  * @default `false`
package/dist/module.d.ts CHANGED
@@ -5,8 +5,8 @@ declare module '@nuxt/schema' {
5
5
  interface PublicRuntimeConfig {
6
6
  supabase: {
7
7
  url: string;
8
- key: string;
9
- serviceKey: string;
8
+ anonKey: string;
9
+ serviceRoleKey: string;
10
10
  redirect: boolean;
11
11
  redirectOptions: RedirectOptions;
12
12
  clientOptions: SupabaseClientOptions<string>;
@@ -43,7 +43,7 @@ interface ModuleOptions {
43
43
  * @type string
44
44
  * @docs https://supabase.com/docs/reference/javascript/initializing#parameters
45
45
  */
46
- key: string;
46
+ anonKey: string;
47
47
  /**
48
48
  * Supabase Service key
49
49
  * @default process.env.SUPABASE_SERVICE_KEY
@@ -51,7 +51,7 @@ interface ModuleOptions {
51
51
  * @type string
52
52
  * @docs https://supabase.com/docs/reference/javascript/initializing#parameters
53
53
  */
54
- serviceKey?: string;
54
+ serviceRoleKey?: string;
55
55
  /**
56
56
  * Redirect automatically to login page if user is not authenticated
57
57
  * @default `false`
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">3.0.0"
6
6
  },
7
- "version": "0.2.10",
7
+ "version": "0.3.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -11,9 +11,9 @@ const module = defineNuxtModule({
11
11
  },
12
12
  // Default configuration options of the Nuxt module
13
13
  defaults: {
14
- url: process.env.SUPABASE_URL,
15
- key: process.env.SUPABASE_KEY,
16
- serviceKey: process.env.SUPABASE_SERVICE_KEY,
14
+ url: process.env.NUXT_PUBLIC_SUPABASE_URL,
15
+ anonKey: process.env.NUXT_PUBLIC_SUPABASE_ANON_KEY,
16
+ serviceRoleKey: process.env.NUXT_SUPABASE_SERVICE_ROLE,
17
17
  redirect: false,
18
18
  redirectOptions: {
19
19
  login: "/login",
@@ -31,20 +31,20 @@ const module = defineNuxtModule({
31
31
  setup(options, nuxt) {
32
32
  const { resolve } = createResolver(import.meta.url);
33
33
  if (!options.url) {
34
- console.warn("Missing `SUPABASE_URL` in environmewnt");
34
+ console.warn("Missing `SUPABASE_URL` in environment");
35
35
  }
36
- if (!options.key) {
37
- console.warn("Missing `SUPABASE_KEY` in environment");
36
+ if (!options.anonKey) {
37
+ console.warn("Missing `SUPABASE_ANON_KEY` in environment");
38
38
  }
39
39
  nuxt.options.runtimeConfig.public.supabase = defu(nuxt.options.runtimeConfig.public.supabase, {
40
40
  url: options.url,
41
- key: options.key,
41
+ anonKey: options.anonKey,
42
42
  redirect: options.redirect,
43
43
  redirectOptions: options.redirectOptions,
44
44
  clientOptions: options.clientOptions
45
45
  });
46
46
  nuxt.options.runtimeConfig.supabase = defu(nuxt.options.runtimeConfig.supabase, {
47
- serviceKey: options.serviceKey
47
+ serviceRoleKey: options.serviceRoleKey
48
48
  });
49
49
  addServerHandler({
50
50
  route: "/supabase/auth/confirm",
@@ -5,8 +5,8 @@ export default defineNuxtPlugin({
5
5
  enforce: "pre",
6
6
  async setup() {
7
7
  const config = useRuntimeConfig().public.supabase;
8
- const { url, key } = config;
9
- const supabaseBrowserClient = createBrowserClient(url, key);
8
+ const { url, anonKey } = config;
9
+ const supabaseBrowserClient = createBrowserClient(url, anonKey);
10
10
  return {
11
11
  provide: {
12
12
  supabase: {
@@ -5,12 +5,12 @@ export default defineNuxtPlugin({
5
5
  name: "supabase",
6
6
  enforce: "pre",
7
7
  async setup() {
8
- const { url, key } = useRuntimeConfig().public.supabase;
8
+ const { url, anonKey } = useRuntimeConfig().public.supabase;
9
9
  const event = useRequestEvent();
10
10
  if (!event) {
11
11
  throw new Error("No request event found");
12
12
  }
13
- const supabaseServerClient = createServerClient(url, key, {
13
+ const supabaseServerClient = createServerClient(url, anonKey, {
14
14
  cookies: {
15
15
  getAll: async () => {
16
16
  return parseCookieHeader(getHeader(event, "Cookie") ?? "");
@@ -3,11 +3,11 @@ 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, anonKey }
7
7
  } = useRuntimeConfig().public;
8
8
  let supabaseClient = event.context._supabaseClient;
9
9
  if (!supabaseClient) {
10
- supabaseClient = createServerClient(url, key, {
10
+ supabaseClient = createServerClient(url, anonKey, {
11
11
  cookies: {
12
12
  getAll: async () => {
13
13
  return parseCookieHeader(getHeader(event, "Cookie") ?? "");
@@ -3,17 +3,17 @@ import { setCookie, getHeader } from "h3";
3
3
  import { useRuntimeConfig } from "#imports";
4
4
  export const supabaseServiceRole = async (event) => {
5
5
  const {
6
- supabase: { serviceKey },
6
+ supabase: { serviceRoleKey },
7
7
  public: {
8
8
  supabase: { url }
9
9
  }
10
10
  } = useRuntimeConfig();
11
- if (!serviceKey) {
11
+ if (!serviceRoleKey) {
12
12
  throw new Error("Missing `SUPABASE_SERVICE_KEY` in `.env`");
13
13
  }
14
14
  let supabaseClient = event.context._supabaseServiceRole;
15
15
  if (!supabaseClient) {
16
- supabaseClient = createServerClient(url, serviceKey, {
16
+ supabaseClient = createServerClient(url, serviceRoleKey, {
17
17
  cookies: {
18
18
  getAll: async () => {
19
19
  return parseCookieHeader(getHeader(event, "Cookie") ?? "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floatingpixels/supabase-nuxt",
3
- "version": "0.2.10",
3
+ "version": "0.3.1",
4
4
  "description": "Supabase module for Nuxt",
5
5
  "repository": "floatingpixels/supabase-nuxt",
6
6
  "license": "MIT",
@@ -59,35 +59,35 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@supabase/ssr": "^0.5.2",
62
- "@supabase/supabase-js": "^2.47.8",
62
+ "@supabase/supabase-js": "^2.47.12",
63
63
  "defu": "^6.1.4"
64
64
  },
65
65
  "devDependencies": {
66
- "@nuxt/devtools": "^1.6.4",
67
- "@nuxt/eslint-config": "^0.7.3",
68
- "@nuxt/kit": "^3.15.0",
66
+ "@nuxt/devtools": "^1.7.0",
67
+ "@nuxt/eslint-config": "^0.7.5",
68
+ "@nuxt/kit": "^3.15.1",
69
69
  "@nuxt/module-builder": "^0.8.4",
70
- "@nuxt/schema": "^3.15.0",
71
- "@nuxt/test-utils": "^3.15.1",
70
+ "@nuxt/schema": "^3.15.1",
71
+ "@nuxt/test-utils": "3.15.1",
72
72
  "@playwright/test": "^1.49.1",
73
- "@snaplet/copycat": "^5.1.0",
73
+ "@snaplet/copycat": "^5.1.1",
74
74
  "@snaplet/seed": "^0.98.0",
75
75
  "@types/eslint-config-prettier": "^6.11.3",
76
- "@types/node": "^22.10.2",
76
+ "@types/node": "^22.10.5",
77
77
  "@vitest/coverage-v8": "2.1.8",
78
78
  "@vue/test-utils": "^2.4.6",
79
79
  "changelogen": "^0.5.7",
80
80
  "eslint": "^9.17.0",
81
81
  "eslint-config-prettier": "^9.1.0",
82
- "happy-dom": "^15.11.7",
83
- "nuxt": "^3.15.0",
82
+ "happy-dom": "^16.5.3",
83
+ "nuxt": "^3.15.1",
84
84
  "playwright-core": "^1.49.1",
85
85
  "postgres": "^3.4.5",
86
86
  "prettier": "^3.4.2",
87
- "release-it": "^17.10.0",
88
- "supabase": "^2.1.1",
89
- "typescript": "5.6.2",
87
+ "release-it": "^18.1.1",
88
+ "supabase": "^2.2.1",
89
+ "typescript": "5.7.3",
90
90
  "vitest": "^2.1.8",
91
- "vue-tsc": "^2.1.10"
91
+ "vue-tsc": "^2.2.0"
92
92
  }
93
93
  }