@supabase/server 0.2.0 → 1.0.0

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.
Files changed (38) hide show
  1. package/README.md +93 -92
  2. package/dist/adapters/h3/index.cjs +3 -3
  3. package/dist/adapters/h3/index.d.cts +3 -3
  4. package/dist/adapters/h3/index.d.mts +3 -3
  5. package/dist/adapters/h3/index.mjs +3 -3
  6. package/dist/adapters/hono/index.cjs +2 -2
  7. package/dist/adapters/hono/index.d.cts +2 -2
  8. package/dist/adapters/hono/index.d.mts +2 -2
  9. package/dist/adapters/hono/index.mjs +2 -2
  10. package/dist/core/index.cjs +1 -1
  11. package/dist/core/index.d.cts +25 -9
  12. package/dist/core/index.d.mts +25 -9
  13. package/dist/core/index.mjs +1 -1
  14. package/dist/{create-supabase-context-C_8SbO5w.cjs → create-supabase-context-B-2NDJhL.cjs} +10 -9
  15. package/dist/{create-supabase-context-DXD5rxi1.mjs → create-supabase-context-BBZtr3D2.mjs} +10 -9
  16. package/dist/{errors-Dyj5Cjt6.d.cts → errors-0dbzn5gA.d.mts} +1 -1
  17. package/dist/{errors-m42mkqhD.d.mts → errors-CZFEYnV_.d.cts} +1 -1
  18. package/dist/index.cjs +3 -3
  19. package/dist/index.d.cts +5 -5
  20. package/dist/index.d.mts +5 -5
  21. package/dist/index.mjs +3 -3
  22. package/dist/{types-DKe8uOwI.d.mts → types-B2yXZjmG.d.mts} +40 -23
  23. package/dist/{types-DqhOaSlC.d.cts → types-u7fYLtzC.d.cts} +40 -23
  24. package/dist/{verify-auth-C4zqDlfj.cjs → verify-auth-BKZK83Y8.cjs} +66 -34
  25. package/dist/{verify-auth-CxFZy9rl.mjs → verify-auth-CZQd36s0.mjs} +66 -34
  26. package/docs/adapters/h3.md +180 -0
  27. package/docs/{hono-adapter.md → adapters/hono.md} +14 -25
  28. package/docs/api-reference.md +28 -15
  29. package/docs/auth-modes.md +38 -34
  30. package/docs/core-primitives.md +13 -13
  31. package/docs/environment-variables.md +17 -17
  32. package/docs/error-handling.md +4 -4
  33. package/docs/getting-started.md +17 -17
  34. package/docs/security.md +15 -15
  35. package/docs/ssr-frameworks.md +148 -172
  36. package/docs/typescript-generics.md +6 -6
  37. package/package.json +5 -3
  38. package/skills/supabase-server/SKILL.md +51 -44
@@ -1,5 +1,5 @@
1
- import { a as CreateAdminClientOptions, i as ClientAuth, n as AllowWithKey, o as CreateContextClientOptions, r as AuthResult, s as Credentials, u as SupabaseEnv } from "../types-DKe8uOwI.mjs";
2
- import { i as EnvError, t as AuthError } from "../errors-m42mkqhD.mjs";
1
+ import { a as AuthResult, c as CreateContextClientOptions, f as SupabaseEnv, i as AuthModeWithKey, l as Credentials, o as ClientAuth, s as CreateAdminClientOptions } from "../types-B2yXZjmG.mjs";
2
+ import { i as EnvError, t as AuthError } from "../errors-0dbzn5gA.mjs";
3
3
  import { SupabaseClient } from "@supabase/supabase-js";
4
4
 
5
5
  //#region src/core/resolve-env.d.ts
@@ -63,9 +63,17 @@ interface VerifyCredentialsOptions {
63
63
  /**
64
64
  * Auth mode(s) to try. Modes are attempted in order — the first match wins.
65
65
  *
66
- * @see {@link AllowWithKey} for the full syntax including named keys.
66
+ * @see {@link AuthModeWithKey} for the full syntax including named keys.
67
+ *
68
+ * @defaultValue `"user"`
69
+ */
70
+ auth?: AuthModeWithKey | AuthModeWithKey[];
71
+ /**
72
+ * @deprecated Use {@link VerifyCredentialsOptions.auth} instead. Kept for
73
+ * backward compatibility; will be removed in a future major release. When
74
+ * both are provided, `auth` wins.
67
75
  */
68
- allow: AllowWithKey | AllowWithKey[];
76
+ allow?: AuthModeWithKey | AuthModeWithKey[];
69
77
  /** Optional environment overrides (passed through to {@link resolveEnv}). */
70
78
  env?: Partial<SupabaseEnv>;
71
79
  }
@@ -86,7 +94,7 @@ interface VerifyCredentialsOptions {
86
94
  * ```ts
87
95
  * const credentials = extractCredentials(request)
88
96
  * const { data: auth, error } = await verifyCredentials(credentials, {
89
- * allow: ['user', 'public'],
97
+ * auth: ['user', 'publishable'],
90
98
  * })
91
99
  * if (error) {
92
100
  * return Response.json({ message: error.message }, { status: error.status })
@@ -109,9 +117,17 @@ interface VerifyAuthOptions {
109
117
  /**
110
118
  * Auth mode(s) to try. Modes are attempted in order — the first match wins.
111
119
  *
112
- * @see {@link AllowWithKey} for the full syntax including named keys.
120
+ * @see {@link AuthModeWithKey} for the full syntax including named keys.
121
+ *
122
+ * @defaultValue `"user"`
123
+ */
124
+ auth?: AuthModeWithKey | AuthModeWithKey[];
125
+ /**
126
+ * @deprecated Use {@link VerifyAuthOptions.auth} instead. Kept for backward
127
+ * compatibility; will be removed in a future major release. When both are
128
+ * provided, `auth` wins.
113
129
  */
114
- allow: AllowWithKey | AllowWithKey[];
130
+ allow?: AuthModeWithKey | AuthModeWithKey[];
115
131
  /** Optional environment overrides (passed through to {@link resolveEnv}). */
116
132
  env?: Partial<SupabaseEnv>;
117
133
  }
@@ -134,7 +150,7 @@ interface VerifyAuthOptions {
134
150
  * import { verifyAuth } from '@supabase/server/core'
135
151
  *
136
152
  * const { data: auth, error } = await verifyAuth(request, {
137
- * allow: 'user',
153
+ * auth: 'user',
138
154
  * })
139
155
  *
140
156
  * if (error) {
@@ -163,7 +179,7 @@ declare function verifyAuth(request: Request, options: VerifyAuthOptions): Promi
163
179
  *
164
180
  * @example
165
181
  * ```ts
166
- * const { data: auth } = await verifyAuth(request, { allow: 'user' })
182
+ * const { data: auth } = await verifyAuth(request, { auth: 'user' })
167
183
  * const supabase = createContextClient({
168
184
  * auth: { token: auth.token, keyName: auth.keyName },
169
185
  * })
@@ -1,3 +1,3 @@
1
- import { a as createAdminClient, i as createContextClient, n as verifyCredentials, o as resolveEnv, r as extractCredentials, t as verifyAuth } from "../verify-auth-CxFZy9rl.mjs";
1
+ import { a as createAdminClient, i as createContextClient, n as verifyCredentials, o as resolveEnv, r as extractCredentials, t as verifyAuth } from "../verify-auth-CZQd36s0.mjs";
2
2
 
3
3
  export { createAdminClient, createContextClient, extractCredentials, resolveEnv, verifyAuth, verifyCredentials };
@@ -1,4 +1,4 @@
1
- const require_verify_auth = require('./verify-auth-C4zqDlfj.cjs');
1
+ const require_verify_auth = require('./verify-auth-BKZK83Y8.cjs');
2
2
 
3
3
  //#region src/create-supabase-context.ts
4
4
  /**
@@ -14,7 +14,7 @@ const require_verify_auth = require('./verify-auth-C4zqDlfj.cjs');
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
17
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
18
18
  * if (error) {
19
19
  * return Response.json({ message: error.message }, { status: error.status })
20
20
  * }
@@ -23,7 +23,8 @@ const require_verify_auth = require('./verify-auth-C4zqDlfj.cjs');
23
23
  */
24
24
  async function createSupabaseContext(request, options) {
25
25
  const { data: auth, error } = await require_verify_auth.verifyAuth(request, {
26
- allow: options?.allow ?? "user",
26
+ auth: options?.auth,
27
+ allow: options?.allow,
27
28
  env: options?.env
28
29
  });
29
30
  if (error) return {
@@ -35,24 +36,24 @@ async function createSupabaseContext(request, options) {
35
36
  env: options?.env,
36
37
  supabaseOptions: options?.supabaseOptions
37
38
  };
38
- const publicKeyName = auth.authType === "public" ? auth.keyName : void 0;
39
+ const publishableKeyName = auth.authMode === "publishable" ? auth.keyName : void 0;
39
40
  return {
40
41
  data: {
41
42
  supabase: require_verify_auth.createContextClient({
42
43
  auth: {
43
44
  token: auth.token,
44
- keyName: publicKeyName
45
+ keyName: publishableKeyName
45
46
  },
46
47
  ...config
47
48
  }),
48
49
  supabaseAdmin: require_verify_auth.createAdminClient({
49
- auth: { keyName: auth.authType === "secret" ? auth.keyName : void 0 },
50
+ auth: { keyName: auth.authMode === "secret" ? auth.keyName : void 0 },
50
51
  ...config
51
52
  }),
52
53
  userClaims: auth.userClaims,
53
- claims: auth.claims,
54
- authType: auth.authType,
55
- authKeyName: auth.keyName
54
+ jwtClaims: auth.jwtClaims,
55
+ authMode: auth.authMode,
56
+ authKeyName: auth.keyName ?? void 0
56
57
  },
57
58
  error: null
58
59
  };
@@ -1,4 +1,4 @@
1
- import { a as createAdminClient, f as Errors, i as createContextClient, l as CreateSupabaseClientError, s as AuthError, t as verifyAuth, u as EnvError } from "./verify-auth-CxFZy9rl.mjs";
1
+ import { a as createAdminClient, f as Errors, i as createContextClient, l as CreateSupabaseClientError, s as AuthError, t as verifyAuth, u as EnvError } from "./verify-auth-CZQd36s0.mjs";
2
2
 
3
3
  //#region src/create-supabase-context.ts
4
4
  /**
@@ -14,7 +14,7 @@ import { a as createAdminClient, f as Errors, i as createContextClient, l as Cre
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
17
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
18
18
  * if (error) {
19
19
  * return Response.json({ message: error.message }, { status: error.status })
20
20
  * }
@@ -23,7 +23,8 @@ import { a as createAdminClient, f as Errors, i as createContextClient, l as Cre
23
23
  */
24
24
  async function createSupabaseContext(request, options) {
25
25
  const { data: auth, error } = await verifyAuth(request, {
26
- allow: options?.allow ?? "user",
26
+ auth: options?.auth,
27
+ allow: options?.allow,
27
28
  env: options?.env
28
29
  });
29
30
  if (error) return {
@@ -35,24 +36,24 @@ async function createSupabaseContext(request, options) {
35
36
  env: options?.env,
36
37
  supabaseOptions: options?.supabaseOptions
37
38
  };
38
- const publicKeyName = auth.authType === "public" ? auth.keyName : void 0;
39
+ const publishableKeyName = auth.authMode === "publishable" ? auth.keyName : void 0;
39
40
  return {
40
41
  data: {
41
42
  supabase: createContextClient({
42
43
  auth: {
43
44
  token: auth.token,
44
- keyName: publicKeyName
45
+ keyName: publishableKeyName
45
46
  },
46
47
  ...config
47
48
  }),
48
49
  supabaseAdmin: createAdminClient({
49
- auth: { keyName: auth.authType === "secret" ? auth.keyName : void 0 },
50
+ auth: { keyName: auth.authMode === "secret" ? auth.keyName : void 0 },
50
51
  ...config
51
52
  }),
52
53
  userClaims: auth.userClaims,
53
- claims: auth.claims,
54
- authType: auth.authType,
55
- authKeyName: auth.keyName
54
+ jwtClaims: auth.jwtClaims,
55
+ authMode: auth.authMode,
56
+ authKeyName: auth.keyName ?? void 0
56
57
  },
57
58
  error: null
58
59
  };
@@ -53,7 +53,7 @@ declare const MissingDefaultSecretKeyError = "MISSING_DEFAULT_SECRET_KEY";
53
53
  * ```ts
54
54
  * import { AuthError, createSupabaseContext } from '@supabase/server'
55
55
  *
56
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
56
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
57
57
  * if (error) {
58
58
  * // error is an AuthError
59
59
  * return Response.json(
@@ -53,7 +53,7 @@ declare const MissingDefaultSecretKeyError = "MISSING_DEFAULT_SECRET_KEY";
53
53
  * ```ts
54
54
  * import { AuthError, createSupabaseContext } from '@supabase/server'
55
55
  *
56
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
56
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
57
57
  * if (error) {
58
58
  * // error is an AuthError
59
59
  * return Response.json(
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_verify_auth = require('./verify-auth-C4zqDlfj.cjs');
3
- const require_create_supabase_context = require('./create-supabase-context-C_8SbO5w.cjs');
2
+ const require_verify_auth = require('./verify-auth-BKZK83Y8.cjs');
3
+ const require_create_supabase_context = require('./create-supabase-context-B-2NDJhL.cjs');
4
4
  let _supabase_supabase_js_cors = require("@supabase/supabase-js/cors");
5
5
 
6
6
  //#region src/cors.ts
@@ -55,7 +55,7 @@ function addCorsHeaders(response, config) {
55
55
  * import { withSupabase } from '@supabase/server'
56
56
  *
57
57
  * export default {
58
- * fetch: withSupabase({ allow: 'user' }, async (req, ctx) => {
58
+ * fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
59
59
  * const { data } = await ctx.supabase.rpc('get_my_profile')
60
60
  * return Response.json(data)
61
61
  * }),
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CreateAdminClientOptions, c as JWTClaims, d as UserClaims, f as WithSupabaseConfig, i as ClientAuth, l as SupabaseContext, n as AllowWithKey, o as CreateContextClientOptions, r as AuthResult, s as Credentials, t as Allow, u as SupabaseEnv } from "./types-DqhOaSlC.cjs";
2
- import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as MissingSecretKeyError, f as MissingSupabaseURLError, i as EnvError, l as MissingDefaultSecretKeyError, n as AuthGenericError, o as Errors, r as CreateSupabaseClientError, s as InvalidCredentialsError, t as AuthError, u as MissingPublishableKeyError } from "./errors-Dyj5Cjt6.cjs";
1
+ import { a as AuthResult, c as CreateContextClientOptions, d as SupabaseContext, f as SupabaseEnv, i as AuthModeWithKey, l as Credentials, m as WithSupabaseConfig, n as AllowWithKey, o as ClientAuth, p as UserClaims, r as AuthMode, s as CreateAdminClientOptions, t as Allow, u as JWTClaims } from "./types-u7fYLtzC.cjs";
2
+ import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as MissingSecretKeyError, f as MissingSupabaseURLError, i as EnvError, l as MissingDefaultSecretKeyError, n as AuthGenericError, o as Errors, r as CreateSupabaseClientError, s as InvalidCredentialsError, t as AuthError, u as MissingPublishableKeyError } from "./errors-CZFEYnV_.cjs";
3
3
 
4
4
  //#region src/with-supabase.d.ts
5
5
  /**
@@ -18,7 +18,7 @@ import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as Miss
18
18
  * import { withSupabase } from '@supabase/server'
19
19
  *
20
20
  * export default {
21
- * fetch: withSupabase({ allow: 'user' }, async (req, ctx) => {
21
+ * fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
22
22
  * const { data } = await ctx.supabase.rpc('get_my_profile')
23
23
  * return Response.json(data)
24
24
  * }),
@@ -41,7 +41,7 @@ declare function withSupabase<Database = unknown>(config: WithSupabaseConfig, ha
41
41
  *
42
42
  * @example
43
43
  * ```ts
44
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
44
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
45
45
  * if (error) {
46
46
  * return Response.json({ message: error.message }, { status: error.status })
47
47
  * }
@@ -56,4 +56,4 @@ declare function createSupabaseContext<Database = unknown>(request: Request, opt
56
56
  error: AuthError;
57
57
  }>;
58
58
  //#endregion
59
- export { type Allow, type AllowWithKey, AuthError, AuthGenericError, type AuthResult, type ClientAuth, type CreateAdminClientOptions, type CreateContextClientOptions, CreateSupabaseClientError, type Credentials, EnvError, EnvGenericError, Errors, InvalidCredentialsError, type JWTClaims, MissingDefaultPublishableKeyError, MissingDefaultSecretKeyError, MissingPublishableKeyError, MissingSecretKeyError, MissingSupabaseURLError, type SupabaseContext, type SupabaseEnv, type UserClaims, type WithSupabaseConfig, createSupabaseContext, withSupabase };
59
+ export { type Allow, type AllowWithKey, AuthError, AuthGenericError, type AuthMode, type AuthModeWithKey, type AuthResult, type ClientAuth, type CreateAdminClientOptions, type CreateContextClientOptions, CreateSupabaseClientError, type Credentials, EnvError, EnvGenericError, Errors, InvalidCredentialsError, type JWTClaims, MissingDefaultPublishableKeyError, MissingDefaultSecretKeyError, MissingPublishableKeyError, MissingSecretKeyError, MissingSupabaseURLError, type SupabaseContext, type SupabaseEnv, type UserClaims, type WithSupabaseConfig, createSupabaseContext, withSupabase };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CreateAdminClientOptions, c as JWTClaims, d as UserClaims, f as WithSupabaseConfig, i as ClientAuth, l as SupabaseContext, n as AllowWithKey, o as CreateContextClientOptions, r as AuthResult, s as Credentials, t as Allow, u as SupabaseEnv } from "./types-DKe8uOwI.mjs";
2
- import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as MissingSecretKeyError, f as MissingSupabaseURLError, i as EnvError, l as MissingDefaultSecretKeyError, n as AuthGenericError, o as Errors, r as CreateSupabaseClientError, s as InvalidCredentialsError, t as AuthError, u as MissingPublishableKeyError } from "./errors-m42mkqhD.mjs";
1
+ import { a as AuthResult, c as CreateContextClientOptions, d as SupabaseContext, f as SupabaseEnv, i as AuthModeWithKey, l as Credentials, m as WithSupabaseConfig, n as AllowWithKey, o as ClientAuth, p as UserClaims, r as AuthMode, s as CreateAdminClientOptions, t as Allow, u as JWTClaims } from "./types-B2yXZjmG.mjs";
2
+ import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as MissingSecretKeyError, f as MissingSupabaseURLError, i as EnvError, l as MissingDefaultSecretKeyError, n as AuthGenericError, o as Errors, r as CreateSupabaseClientError, s as InvalidCredentialsError, t as AuthError, u as MissingPublishableKeyError } from "./errors-0dbzn5gA.mjs";
3
3
 
4
4
  //#region src/with-supabase.d.ts
5
5
  /**
@@ -18,7 +18,7 @@ import { a as EnvGenericError, c as MissingDefaultPublishableKeyError, d as Miss
18
18
  * import { withSupabase } from '@supabase/server'
19
19
  *
20
20
  * export default {
21
- * fetch: withSupabase({ allow: 'user' }, async (req, ctx) => {
21
+ * fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
22
22
  * const { data } = await ctx.supabase.rpc('get_my_profile')
23
23
  * return Response.json(data)
24
24
  * }),
@@ -41,7 +41,7 @@ declare function withSupabase<Database = unknown>(config: WithSupabaseConfig, ha
41
41
  *
42
42
  * @example
43
43
  * ```ts
44
- * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
44
+ * const { data: ctx, error } = await createSupabaseContext(request, { auth: 'user' })
45
45
  * if (error) {
46
46
  * return Response.json({ message: error.message }, { status: error.status })
47
47
  * }
@@ -56,4 +56,4 @@ declare function createSupabaseContext<Database = unknown>(request: Request, opt
56
56
  error: AuthError;
57
57
  }>;
58
58
  //#endregion
59
- export { type Allow, type AllowWithKey, AuthError, AuthGenericError, type AuthResult, type ClientAuth, type CreateAdminClientOptions, type CreateContextClientOptions, CreateSupabaseClientError, type Credentials, EnvError, EnvGenericError, Errors, InvalidCredentialsError, type JWTClaims, MissingDefaultPublishableKeyError, MissingDefaultSecretKeyError, MissingPublishableKeyError, MissingSecretKeyError, MissingSupabaseURLError, type SupabaseContext, type SupabaseEnv, type UserClaims, type WithSupabaseConfig, createSupabaseContext, withSupabase };
59
+ export { type Allow, type AllowWithKey, AuthError, AuthGenericError, type AuthMode, type AuthModeWithKey, type AuthResult, type ClientAuth, type CreateAdminClientOptions, type CreateContextClientOptions, CreateSupabaseClientError, type Credentials, EnvError, EnvGenericError, Errors, InvalidCredentialsError, type JWTClaims, MissingDefaultPublishableKeyError, MissingDefaultSecretKeyError, MissingPublishableKeyError, MissingSecretKeyError, MissingSupabaseURLError, type SupabaseContext, type SupabaseEnv, type UserClaims, type WithSupabaseConfig, createSupabaseContext, withSupabase };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as MissingSecretKeyError, c as AuthGenericError, d as EnvGenericError, f as Errors, g as MissingPublishableKeyError, h as MissingDefaultSecretKeyError, l as CreateSupabaseClientError, m as MissingDefaultPublishableKeyError, p as InvalidCredentialsError, s as AuthError, u as EnvError, v as MissingSupabaseURLError } from "./verify-auth-CxFZy9rl.mjs";
2
- import { t as createSupabaseContext } from "./create-supabase-context-DXD5rxi1.mjs";
1
+ import { _ as MissingSecretKeyError, c as AuthGenericError, d as EnvGenericError, f as Errors, g as MissingPublishableKeyError, h as MissingDefaultSecretKeyError, l as CreateSupabaseClientError, m as MissingDefaultPublishableKeyError, p as InvalidCredentialsError, s as AuthError, u as EnvError, v as MissingSupabaseURLError } from "./verify-auth-CZQd36s0.mjs";
2
+ import { t as createSupabaseContext } from "./create-supabase-context-BBZtr3D2.mjs";
3
3
  import { corsHeaders } from "@supabase/supabase-js/cors";
4
4
 
5
5
  //#region src/cors.ts
@@ -54,7 +54,7 @@ function addCorsHeaders(response, config) {
54
54
  * import { withSupabase } from '@supabase/server'
55
55
  *
56
56
  * export default {
57
- * fetch: withSupabase({ allow: 'user' }, async (req, ctx) => {
57
+ * fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
58
58
  * const { data } = await ctx.supabase.rpc('get_my_profile')
59
59
  * return Response.json(data)
60
60
  * }),
@@ -4,44 +4,52 @@ import { SupabaseClient, SupabaseClientOptions } from "@supabase/supabase-js";
4
4
  /**
5
5
  * Authentication mode that determines what credentials a request must provide.
6
6
  *
7
- * - `"always"` — No credentials required. Every request is accepted.
8
- * - `"public"` — Requires a valid publishable key in the `apikey` header.
7
+ * - `"none"` — No credentials required. Every request is accepted.
8
+ * - `"publishable"` — Requires a valid publishable key in the `apikey` header.
9
9
  * - `"secret"` — Requires a valid secret key in the `apikey` header (timing-safe comparison).
10
10
  * - `"user"` — Requires a valid JWT in the `Authorization: Bearer <token>` header.
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
14
  * // Single mode
15
- * withSupabase({ allow: 'user' }, handler)
15
+ * withSupabase({ auth: 'user' }, handler)
16
16
  *
17
17
  * // Multiple modes — the first match wins.
18
18
  * // A mode is tried only when its credential is present; a JWT that is
19
19
  * // present but fails verification rejects immediately rather than falling
20
20
  * // through to the next mode.
21
- * withSupabase({ allow: ['user', 'public'] }, handler)
21
+ * withSupabase({ auth: ['user', 'publishable'] }, handler)
22
22
  * ```
23
23
  */
24
- type Allow = 'always' | 'public' | 'secret' | 'user';
24
+ type AuthMode = 'none' | 'publishable' | 'secret' | 'user';
25
+ /**
26
+ * @deprecated Use {@link AuthMode} instead. Will be removed in a future major release.
27
+ */
28
+ type Allow = AuthMode;
25
29
  /**
26
30
  * Extended auth mode that supports targeting a specific named key.
27
31
  *
28
- * Use the colon syntax (`"public:web_app"`) to require a specific named key
32
+ * Use the colon syntax (`"publishable:web_app"`) to require a specific named key
29
33
  * from the `SUPABASE_PUBLISHABLE_KEYS` or `SUPABASE_SECRET_KEYS` JSON object.
30
- * Use `"public:*"` or `"secret:*"` to accept any key in the set.
34
+ * Use `"publishable:*"` or `"secret:*"` to accept any key in the set.
31
35
  *
32
36
  * @example
33
37
  * ```ts
34
38
  * // Accept only the "mobile" publishable key
35
- * withSupabase({ allow: 'public:mobile' }, handler)
39
+ * withSupabase({ auth: 'publishable:mobile' }, handler)
36
40
  *
37
41
  * // Accept any secret key
38
- * withSupabase({ allow: 'secret:*' }, handler)
42
+ * withSupabase({ auth: 'secret:*' }, handler)
39
43
  *
40
44
  * // Mix named keys with other modes
41
- * withSupabase({ allow: ['user', 'public:web_app'] }, handler)
45
+ * withSupabase({ auth: ['user', 'publishable:web_app'] }, handler)
42
46
  * ```
43
47
  */
44
- type AllowWithKey = Allow | `public:${string}` | `secret:${string}`;
48
+ type AuthModeWithKey = AuthMode | `publishable:${string}` | `secret:${string}`;
49
+ /**
50
+ * @deprecated Use {@link AuthModeWithKey} instead. Will be removed in a future major release.
51
+ */
52
+ type AllowWithKey = AuthModeWithKey;
45
53
  /**
46
54
  * Resolved Supabase environment configuration.
47
55
  *
@@ -104,13 +112,13 @@ interface Credentials {
104
112
  */
105
113
  interface AuthResult {
106
114
  /** The auth mode that was successfully matched. */
107
- authType: Allow;
115
+ authMode: AuthMode;
108
116
  /** The verified JWT, or `null` for non-user auth modes. */
109
117
  token: string | null;
110
118
  /** Normalized user identity derived from the JWT, or `null` when no JWT is present. */
111
119
  userClaims: UserClaims | null;
112
120
  /** Raw JWT payload, or `null` when no JWT is present. */
113
- claims: JWTClaims | null;
121
+ jwtClaims: JWTClaims | null;
114
122
  /** Name of the matched key (e.g. `"default"`, `"mobile"`), or `null` for `"user"` / `"always"` modes. */
115
123
  keyName?: string | null;
116
124
  }
@@ -170,16 +178,16 @@ interface UserClaims {
170
178
  * @example
171
179
  * ```ts
172
180
  * // Require authenticated users, auto-CORS enabled (default)
173
- * const config: WithSupabaseConfig = { allow: 'user' }
181
+ * const config: WithSupabaseConfig = { auth: 'user' }
174
182
  *
175
183
  * // Accept users or service-to-service calls, custom CORS headers
176
184
  * const config: WithSupabaseConfig = {
177
- * allow: ['user', 'secret'],
185
+ * auth: ['user', 'secret'],
178
186
  * cors: { 'Access-Control-Allow-Origin': 'https://myapp.com' },
179
187
  * }
180
188
  *
181
189
  * // No auth required, CORS disabled
182
- * const config: WithSupabaseConfig = { allow: 'always', cors: false }
190
+ * const config: WithSupabaseConfig = { auth: 'none', cors: false }
183
191
  * ```
184
192
  */
185
193
  interface WithSupabaseConfig {
@@ -190,7 +198,13 @@ interface WithSupabaseConfig {
190
198
  *
191
199
  * @defaultValue `"user"`
192
200
  */
193
- allow?: AllowWithKey | AllowWithKey[];
201
+ auth?: AuthModeWithKey | AuthModeWithKey[];
202
+ /**
203
+ * @deprecated Use {@link WithSupabaseConfig.auth} instead. The `allow` option
204
+ * is kept for backward compatibility and will be removed in a future major release.
205
+ * When both `auth` and `allow` are provided, `auth` takes precedence.
206
+ */
207
+ allow?: AuthModeWithKey | AuthModeWithKey[];
194
208
  /**
195
209
  * Override auto-detected environment variables. Useful for testing
196
210
  * or when running in environments without standard env var support.
@@ -218,7 +232,7 @@ interface WithSupabaseConfig {
218
232
  * @example
219
233
  * ```ts
220
234
  * withSupabase({
221
- * allow: 'user',
235
+ * auth: 'user',
222
236
  * supabaseOptions: { db: { schema: 'api' } },
223
237
  * }, handler)
224
238
  * ```
@@ -268,11 +282,14 @@ interface SupabaseContext<Database = unknown> {
268
282
  /** JWT-derived identity. For the full Supabase User object, call `supabase.auth.getUser()`. */
269
283
  userClaims: UserClaims | null;
270
284
  /** Raw JWT payload. `null` for non-user auth modes. */
271
- claims: JWTClaims | null;
285
+ jwtClaims: JWTClaims | null;
272
286
  /** The auth mode that was used for this request. */
273
- authType: Allow;
274
- /** The auth key name of the API key that was used for this request. */
275
- authKeyName?: string | null;
287
+ authMode: AuthMode;
288
+ /**
289
+ * The auth key name of the API key that was used for this request.
290
+ * Omitted for `'user'` and `'none'` modes, which don't match a named key.
291
+ */
292
+ authKeyName?: string;
276
293
  }
277
294
  //#endregion
278
- export { CreateAdminClientOptions as a, JWTClaims as c, UserClaims as d, WithSupabaseConfig as f, ClientAuth as i, SupabaseContext as l, AllowWithKey as n, CreateContextClientOptions as o, AuthResult as r, Credentials as s, Allow as t, SupabaseEnv as u };
295
+ export { AuthResult as a, CreateContextClientOptions as c, SupabaseContext as d, SupabaseEnv as f, AuthModeWithKey as i, Credentials as l, WithSupabaseConfig as m, AllowWithKey as n, ClientAuth as o, UserClaims as p, AuthMode as r, CreateAdminClientOptions as s, Allow as t, JWTClaims as u };
@@ -4,44 +4,52 @@ import { SupabaseClient, SupabaseClientOptions } from "@supabase/supabase-js";
4
4
  /**
5
5
  * Authentication mode that determines what credentials a request must provide.
6
6
  *
7
- * - `"always"` — No credentials required. Every request is accepted.
8
- * - `"public"` — Requires a valid publishable key in the `apikey` header.
7
+ * - `"none"` — No credentials required. Every request is accepted.
8
+ * - `"publishable"` — Requires a valid publishable key in the `apikey` header.
9
9
  * - `"secret"` — Requires a valid secret key in the `apikey` header (timing-safe comparison).
10
10
  * - `"user"` — Requires a valid JWT in the `Authorization: Bearer <token>` header.
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
14
  * // Single mode
15
- * withSupabase({ allow: 'user' }, handler)
15
+ * withSupabase({ auth: 'user' }, handler)
16
16
  *
17
17
  * // Multiple modes — the first match wins.
18
18
  * // A mode is tried only when its credential is present; a JWT that is
19
19
  * // present but fails verification rejects immediately rather than falling
20
20
  * // through to the next mode.
21
- * withSupabase({ allow: ['user', 'public'] }, handler)
21
+ * withSupabase({ auth: ['user', 'publishable'] }, handler)
22
22
  * ```
23
23
  */
24
- type Allow = 'always' | 'public' | 'secret' | 'user';
24
+ type AuthMode = 'none' | 'publishable' | 'secret' | 'user';
25
+ /**
26
+ * @deprecated Use {@link AuthMode} instead. Will be removed in a future major release.
27
+ */
28
+ type Allow = AuthMode;
25
29
  /**
26
30
  * Extended auth mode that supports targeting a specific named key.
27
31
  *
28
- * Use the colon syntax (`"public:web_app"`) to require a specific named key
32
+ * Use the colon syntax (`"publishable:web_app"`) to require a specific named key
29
33
  * from the `SUPABASE_PUBLISHABLE_KEYS` or `SUPABASE_SECRET_KEYS` JSON object.
30
- * Use `"public:*"` or `"secret:*"` to accept any key in the set.
34
+ * Use `"publishable:*"` or `"secret:*"` to accept any key in the set.
31
35
  *
32
36
  * @example
33
37
  * ```ts
34
38
  * // Accept only the "mobile" publishable key
35
- * withSupabase({ allow: 'public:mobile' }, handler)
39
+ * withSupabase({ auth: 'publishable:mobile' }, handler)
36
40
  *
37
41
  * // Accept any secret key
38
- * withSupabase({ allow: 'secret:*' }, handler)
42
+ * withSupabase({ auth: 'secret:*' }, handler)
39
43
  *
40
44
  * // Mix named keys with other modes
41
- * withSupabase({ allow: ['user', 'public:web_app'] }, handler)
45
+ * withSupabase({ auth: ['user', 'publishable:web_app'] }, handler)
42
46
  * ```
43
47
  */
44
- type AllowWithKey = Allow | `public:${string}` | `secret:${string}`;
48
+ type AuthModeWithKey = AuthMode | `publishable:${string}` | `secret:${string}`;
49
+ /**
50
+ * @deprecated Use {@link AuthModeWithKey} instead. Will be removed in a future major release.
51
+ */
52
+ type AllowWithKey = AuthModeWithKey;
45
53
  /**
46
54
  * Resolved Supabase environment configuration.
47
55
  *
@@ -104,13 +112,13 @@ interface Credentials {
104
112
  */
105
113
  interface AuthResult {
106
114
  /** The auth mode that was successfully matched. */
107
- authType: Allow;
115
+ authMode: AuthMode;
108
116
  /** The verified JWT, or `null` for non-user auth modes. */
109
117
  token: string | null;
110
118
  /** Normalized user identity derived from the JWT, or `null` when no JWT is present. */
111
119
  userClaims: UserClaims | null;
112
120
  /** Raw JWT payload, or `null` when no JWT is present. */
113
- claims: JWTClaims | null;
121
+ jwtClaims: JWTClaims | null;
114
122
  /** Name of the matched key (e.g. `"default"`, `"mobile"`), or `null` for `"user"` / `"always"` modes. */
115
123
  keyName?: string | null;
116
124
  }
@@ -170,16 +178,16 @@ interface UserClaims {
170
178
  * @example
171
179
  * ```ts
172
180
  * // Require authenticated users, auto-CORS enabled (default)
173
- * const config: WithSupabaseConfig = { allow: 'user' }
181
+ * const config: WithSupabaseConfig = { auth: 'user' }
174
182
  *
175
183
  * // Accept users or service-to-service calls, custom CORS headers
176
184
  * const config: WithSupabaseConfig = {
177
- * allow: ['user', 'secret'],
185
+ * auth: ['user', 'secret'],
178
186
  * cors: { 'Access-Control-Allow-Origin': 'https://myapp.com' },
179
187
  * }
180
188
  *
181
189
  * // No auth required, CORS disabled
182
- * const config: WithSupabaseConfig = { allow: 'always', cors: false }
190
+ * const config: WithSupabaseConfig = { auth: 'none', cors: false }
183
191
  * ```
184
192
  */
185
193
  interface WithSupabaseConfig {
@@ -190,7 +198,13 @@ interface WithSupabaseConfig {
190
198
  *
191
199
  * @defaultValue `"user"`
192
200
  */
193
- allow?: AllowWithKey | AllowWithKey[];
201
+ auth?: AuthModeWithKey | AuthModeWithKey[];
202
+ /**
203
+ * @deprecated Use {@link WithSupabaseConfig.auth} instead. The `allow` option
204
+ * is kept for backward compatibility and will be removed in a future major release.
205
+ * When both `auth` and `allow` are provided, `auth` takes precedence.
206
+ */
207
+ allow?: AuthModeWithKey | AuthModeWithKey[];
194
208
  /**
195
209
  * Override auto-detected environment variables. Useful for testing
196
210
  * or when running in environments without standard env var support.
@@ -218,7 +232,7 @@ interface WithSupabaseConfig {
218
232
  * @example
219
233
  * ```ts
220
234
  * withSupabase({
221
- * allow: 'user',
235
+ * auth: 'user',
222
236
  * supabaseOptions: { db: { schema: 'api' } },
223
237
  * }, handler)
224
238
  * ```
@@ -268,11 +282,14 @@ interface SupabaseContext<Database = unknown> {
268
282
  /** JWT-derived identity. For the full Supabase User object, call `supabase.auth.getUser()`. */
269
283
  userClaims: UserClaims | null;
270
284
  /** Raw JWT payload. `null` for non-user auth modes. */
271
- claims: JWTClaims | null;
285
+ jwtClaims: JWTClaims | null;
272
286
  /** The auth mode that was used for this request. */
273
- authType: Allow;
274
- /** The auth key name of the API key that was used for this request. */
275
- authKeyName?: string | null;
287
+ authMode: AuthMode;
288
+ /**
289
+ * The auth key name of the API key that was used for this request.
290
+ * Omitted for `'user'` and `'none'` modes, which don't match a named key.
291
+ */
292
+ authKeyName?: string;
276
293
  }
277
294
  //#endregion
278
- export { CreateAdminClientOptions as a, JWTClaims as c, UserClaims as d, WithSupabaseConfig as f, ClientAuth as i, SupabaseContext as l, AllowWithKey as n, CreateContextClientOptions as o, AuthResult as r, Credentials as s, Allow as t, SupabaseEnv as u };
295
+ export { AuthResult as a, CreateContextClientOptions as c, SupabaseContext as d, SupabaseEnv as f, AuthModeWithKey as i, Credentials as l, WithSupabaseConfig as m, AllowWithKey as n, ClientAuth as o, UserClaims as p, AuthMode as r, CreateAdminClientOptions as s, Allow as t, JWTClaims as u };