@supabase/server 0.1.1-rc.24 → 0.1.1-rc.26

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.
@@ -1,9 +1,35 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_create_supabase_context = require('../../create-supabase-context-DNWor6i_.cjs');
2
+ const require_create_supabase_context = require('../../create-supabase-context-DcVorGKG.cjs');
3
3
  let hono_http_exception = require("hono/http-exception");
4
4
  let hono_factory = require("hono/factory");
5
5
 
6
6
  //#region src/adapters/hono/middleware.ts
7
+ /**
8
+ * Hono middleware that creates a {@link SupabaseContext} and stores it in `c.var.supabaseContext`.
9
+ *
10
+ * Skips if a previous middleware already set the context, enabling route-level overrides.
11
+ * Throws a Hono `HTTPException` on auth failure.
12
+ *
13
+ * @param config - Auth modes and optional environment overrides. CORS is excluded — use Hono's `cors()`.
14
+ * @returns A Hono middleware that sets `c.var.supabaseContext`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { Hono } from 'hono'
19
+ * import { withSupabase } from '@supabase/server/adapters/hono'
20
+ *
21
+ * const app = new Hono()
22
+ * app.use('*', withSupabase({ allow: 'user' }))
23
+ *
24
+ * app.get('/profile', async (c) => {
25
+ * const { supabase } = c.var.supabaseContext
26
+ * const { data } = await supabase.rpc('get_profile')
27
+ * return c.json(data)
28
+ * })
29
+ *
30
+ * export default { fetch: app.fetch }
31
+ * ```
32
+ */
7
33
  function withSupabase(config) {
8
34
  return (0, hono_factory.createMiddleware)(async (c, next) => {
9
35
  if (c.var.supabaseContext) {
@@ -1,7 +1,33 @@
1
- import { l as WithSupabaseConfig, o as SupabaseContext } from "../../types-C9J9JcPD.cjs";
1
+ import { l as WithSupabaseConfig, o as SupabaseContext } from "../../types-CnKoFCMX.cjs";
2
2
  import * as hono_types0 from "hono/types";
3
3
 
4
4
  //#region src/adapters/hono/middleware.d.ts
5
+ /**
6
+ * Hono middleware that creates a {@link SupabaseContext} and stores it in `c.var.supabaseContext`.
7
+ *
8
+ * Skips if a previous middleware already set the context, enabling route-level overrides.
9
+ * Throws a Hono `HTTPException` on auth failure.
10
+ *
11
+ * @param config - Auth modes and optional environment overrides. CORS is excluded — use Hono's `cors()`.
12
+ * @returns A Hono middleware that sets `c.var.supabaseContext`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { Hono } from 'hono'
17
+ * import { withSupabase } from '@supabase/server/adapters/hono'
18
+ *
19
+ * const app = new Hono()
20
+ * app.use('*', withSupabase({ allow: 'user' }))
21
+ *
22
+ * app.get('/profile', async (c) => {
23
+ * const { supabase } = c.var.supabaseContext
24
+ * const { data } = await supabase.rpc('get_profile')
25
+ * return c.json(data)
26
+ * })
27
+ *
28
+ * export default { fetch: app.fetch }
29
+ * ```
30
+ */
5
31
  declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): hono_types0.MiddlewareHandler<{
6
32
  Variables: {
7
33
  supabaseContext: SupabaseContext;
@@ -1,7 +1,33 @@
1
- import { l as WithSupabaseConfig, o as SupabaseContext } from "../../types-Ceetds5F.mjs";
1
+ import { l as WithSupabaseConfig, o as SupabaseContext } from "../../types-ClmJ8pi8.mjs";
2
2
  import * as hono_types0 from "hono/types";
3
3
 
4
4
  //#region src/adapters/hono/middleware.d.ts
5
+ /**
6
+ * Hono middleware that creates a {@link SupabaseContext} and stores it in `c.var.supabaseContext`.
7
+ *
8
+ * Skips if a previous middleware already set the context, enabling route-level overrides.
9
+ * Throws a Hono `HTTPException` on auth failure.
10
+ *
11
+ * @param config - Auth modes and optional environment overrides. CORS is excluded — use Hono's `cors()`.
12
+ * @returns A Hono middleware that sets `c.var.supabaseContext`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { Hono } from 'hono'
17
+ * import { withSupabase } from '@supabase/server/adapters/hono'
18
+ *
19
+ * const app = new Hono()
20
+ * app.use('*', withSupabase({ allow: 'user' }))
21
+ *
22
+ * app.get('/profile', async (c) => {
23
+ * const { supabase } = c.var.supabaseContext
24
+ * const { data } = await supabase.rpc('get_profile')
25
+ * return c.json(data)
26
+ * })
27
+ *
28
+ * export default { fetch: app.fetch }
29
+ * ```
30
+ */
5
31
  declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): hono_types0.MiddlewareHandler<{
6
32
  Variables: {
7
33
  supabaseContext: SupabaseContext;
@@ -1,8 +1,34 @@
1
- import { t as createSupabaseContext } from "../../create-supabase-context-BrSIe29v.mjs";
1
+ import { t as createSupabaseContext } from "../../create-supabase-context-CmWaH3s6.mjs";
2
2
  import { HTTPException } from "hono/http-exception";
3
3
  import { createMiddleware } from "hono/factory";
4
4
 
5
5
  //#region src/adapters/hono/middleware.ts
6
+ /**
7
+ * Hono middleware that creates a {@link SupabaseContext} and stores it in `c.var.supabaseContext`.
8
+ *
9
+ * Skips if a previous middleware already set the context, enabling route-level overrides.
10
+ * Throws a Hono `HTTPException` on auth failure.
11
+ *
12
+ * @param config - Auth modes and optional environment overrides. CORS is excluded — use Hono's `cors()`.
13
+ * @returns A Hono middleware that sets `c.var.supabaseContext`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { Hono } from 'hono'
18
+ * import { withSupabase } from '@supabase/server/adapters/hono'
19
+ *
20
+ * const app = new Hono()
21
+ * app.use('*', withSupabase({ allow: 'user' }))
22
+ *
23
+ * app.get('/profile', async (c) => {
24
+ * const { supabase } = c.var.supabaseContext
25
+ * const { data } = await supabase.rpc('get_profile')
26
+ * return c.json(data)
27
+ * })
28
+ *
29
+ * export default { fetch: app.fetch }
30
+ * ```
31
+ */
6
32
  function withSupabase(config) {
7
33
  return createMiddleware(async (c, next) => {
8
34
  if (c.var.supabaseContext) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_verify_auth = require('../verify-auth-6a1UPrFz.cjs');
2
+ const require_verify_auth = require('../verify-auth-DvRVnjdq.cjs');
3
3
 
4
4
  exports.createAdminClient = require_verify_auth.createAdminClient;
5
5
  exports.createContextClient = require_verify_auth.createContextClient;
@@ -1,3 +1,195 @@
1
- import "../types-C9J9JcPD.cjs";
2
- import { a as extractCredentials, i as verifyCredentials, n as createContextClient, o as resolveEnv, r as verifyAuth, t as createAdminClient } from "../create-admin-client-CnuiHPpV.cjs";
1
+ import { i as Credentials, n as AllowWithKey, r as AuthResult, s as SupabaseEnv } from "../types-CnKoFCMX.cjs";
2
+ import { n as EnvError, t as AuthError } from "../errors-BmSsOAvx.cjs";
3
+ import { SupabaseClient } from "@supabase/supabase-js";
4
+
5
+ //#region src/core/resolve-env.d.ts
6
+ /**
7
+ * Resolves Supabase environment configuration from runtime environment variables.
8
+ *
9
+ * Reads `SUPABASE_URL`, keys (`SUPABASE_PUBLISHABLE_KEYS` / `SUPABASE_SECRET_KEYS`),
10
+ * and `SUPABASE_JWKS`. Works across Deno, Node.js, and Bun. For Cloudflare Workers,
11
+ * use `overrides` or enable node-compat.
12
+ *
13
+ * @param overrides - Partial values that take precedence over env vars.
14
+ * @returns `{ data: SupabaseEnv, error: null }` on success, `{ data: null, error: EnvError }` on failure.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const { data: env, error } = resolveEnv()
19
+ * if (error) throw error
20
+ *
21
+ * // Override for tests
22
+ * const { data: env } = resolveEnv({ url: 'http://localhost:54321' })
23
+ * ```
24
+ */
25
+ declare function resolveEnv(overrides?: Partial<SupabaseEnv>): {
26
+ data: SupabaseEnv;
27
+ error: null;
28
+ } | {
29
+ data: null;
30
+ error: EnvError;
31
+ };
32
+ //#endregion
33
+ //#region src/core/extract-credentials.d.ts
34
+ /**
35
+ * Extracts authentication credentials from an incoming HTTP request.
36
+ *
37
+ * Reads two headers:
38
+ * - `Authorization: Bearer <token>` → extracted as `token`
39
+ * - `apikey: <key>` → extracted as `apikey`
40
+ *
41
+ * This is a pure extraction step — no validation or verification is performed.
42
+ * Pass the result to {@link verifyCredentials} to validate against allowed auth modes.
43
+ *
44
+ * @param request - The incoming HTTP request.
45
+ * @returns The extracted {@link Credentials}. Fields are `null` when the corresponding header is absent.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { extractCredentials } from '@supabase/server/core'
50
+ *
51
+ * const creds = extractCredentials(request)
52
+ * console.log(creds.token) // "eyJhbGci..." or null
53
+ * console.log(creds.apikey) // "sb-abc123-publishable-..." or null
54
+ * ```
55
+ */
56
+ declare function extractCredentials(request: Request): Credentials;
57
+ //#endregion
58
+ //#region src/core/verify-credentials.d.ts
59
+ /**
60
+ * Options for {@link verifyCredentials}.
61
+ */
62
+ interface VerifyCredentialsOptions {
63
+ /**
64
+ * Auth mode(s) to try. Modes are attempted in order — the first match wins.
65
+ *
66
+ * @see {@link AllowWithKey} for the full syntax including named keys.
67
+ */
68
+ allow: AllowWithKey | AllowWithKey[];
69
+ /** Optional environment overrides (passed through to {@link resolveEnv}). */
70
+ env?: Partial<SupabaseEnv>;
71
+ }
72
+ /**
73
+ * Verifies pre-extracted credentials against one or more allowed auth modes.
74
+ *
75
+ * Tries each mode in order — first match wins. Use {@link verifyAuth} to extract
76
+ * and verify in a single call.
77
+ *
78
+ * @param credentials - The credentials to verify (from {@link extractCredentials}).
79
+ * @param options - Allowed auth modes and optional env overrides.
80
+ * @returns `{ data: AuthResult, error: null }` on success, `{ data: null, error: AuthError }` on failure.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const credentials = extractCredentials(request)
85
+ * const { data: auth, error } = await verifyCredentials(credentials, {
86
+ * allow: ['user', 'public'],
87
+ * })
88
+ * if (error) {
89
+ * return Response.json({ error: error.message }, { status: error.status })
90
+ * }
91
+ * ```
92
+ */
93
+ declare function verifyCredentials(credentials: Credentials, options: VerifyCredentialsOptions): Promise<{
94
+ data: AuthResult;
95
+ error: null;
96
+ } | {
97
+ data: null;
98
+ error: AuthError;
99
+ }>;
100
+ //#endregion
101
+ //#region src/core/verify-auth.d.ts
102
+ /**
103
+ * Options for {@link verifyAuth}.
104
+ */
105
+ interface VerifyAuthOptions {
106
+ /**
107
+ * Auth mode(s) to try. Modes are attempted in order — the first match wins.
108
+ *
109
+ * @see {@link AllowWithKey} for the full syntax including named keys.
110
+ */
111
+ allow: AllowWithKey | AllowWithKey[];
112
+ /** Optional environment overrides (passed through to {@link resolveEnv}). */
113
+ env?: Partial<SupabaseEnv>;
114
+ }
115
+ /**
116
+ * Extracts credentials from a request and verifies them in a single step.
117
+ *
118
+ * This is a convenience function that combines {@link extractCredentials} and
119
+ * {@link verifyCredentials}. Use it when you want the full auth flow without
120
+ * needing to inspect the raw credentials.
121
+ *
122
+ * @param request - The incoming HTTP request.
123
+ * @param options - Auth modes to accept and optional environment overrides.
124
+ *
125
+ * @returns A result tuple: `{ data, error }`.
126
+ * - On success: `{ data: AuthResult, error: null }`
127
+ * - On failure: `{ data: null, error: AuthError }`
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * import { verifyAuth } from '@supabase/server/core'
132
+ *
133
+ * const { data: auth, error } = await verifyAuth(request, {
134
+ * allow: 'user',
135
+ * })
136
+ *
137
+ * if (error) {
138
+ * return Response.json({ error: error.message }, { status: error.status })
139
+ * }
140
+ *
141
+ * console.log(auth.userClaims!.id) // "d0f1a2b3-..."
142
+ * ```
143
+ */
144
+ declare function verifyAuth(request: Request, options: VerifyAuthOptions): Promise<{
145
+ data: AuthResult;
146
+ error: null;
147
+ } | {
148
+ data: null;
149
+ error: AuthError;
150
+ }>;
151
+ //#endregion
152
+ //#region src/core/create-context-client.d.ts
153
+ /**
154
+ * Creates a Supabase client scoped to the caller's context.
155
+ *
156
+ * Configured with a publishable key and (optionally) the caller's JWT,
157
+ * so Row-Level Security policies apply. Session persistence is disabled
158
+ * (stateless, one client per request).
159
+ *
160
+ * @param token - The caller's JWT, or `null` for anonymous access.
161
+ * @param env - Optional environment overrides (passed through to {@link resolveEnv}).
162
+ * @param keyName - Name of the publishable key to use. Falls back to `"default"`, then first available.
163
+ * @returns A configured {@link SupabaseClient} with RLS enforced.
164
+ * @throws {@link EnvError} If `SUPABASE_URL` is missing or the specified publishable key is not found.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const { data: auth } = await verifyAuth(request, { allow: 'user' })
169
+ * const supabase = createContextClient(auth.token)
170
+ * const { data } = await supabase.rpc('get_my_items')
171
+ * ```
172
+ */
173
+ declare function createContextClient<Database = unknown>(token?: string | null, env?: Partial<SupabaseEnv>, keyName?: string | null): SupabaseClient<Database>;
174
+ //#endregion
175
+ //#region src/core/create-admin-client.d.ts
176
+ /**
177
+ * Creates an admin Supabase client that bypasses Row-Level Security.
178
+ *
179
+ * Uses a secret key for authentication, giving full access to all data.
180
+ * Session persistence is disabled (stateless, one client per request).
181
+ *
182
+ * @param env - Optional environment overrides (passed through to {@link resolveEnv}).
183
+ * @param keyName - Name of the secret key to use. Falls back to `"default"`, then first available.
184
+ * @returns A configured {@link SupabaseClient} with admin (service-role) privileges.
185
+ * @throws {@link EnvError} If `SUPABASE_URL` is missing or the specified secret key is not found.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const supabaseAdmin = createAdminClient()
190
+ * const { data } = await supabaseAdmin.from('audit_log').insert({ action: 'user_login' })
191
+ * ```
192
+ */
193
+ declare function createAdminClient<Database = unknown>(env?: Partial<SupabaseEnv>, keyName?: string | null): SupabaseClient<Database>;
194
+ //#endregion
3
195
  export { createAdminClient, createContextClient, extractCredentials, resolveEnv, verifyAuth, verifyCredentials };
@@ -1,3 +1,195 @@
1
- import "../types-Ceetds5F.mjs";
2
- import { a as extractCredentials, i as verifyCredentials, n as createContextClient, o as resolveEnv, r as verifyAuth, t as createAdminClient } from "../create-admin-client-BQEHqeFW.mjs";
1
+ import { i as Credentials, n as AllowWithKey, r as AuthResult, s as SupabaseEnv } from "../types-ClmJ8pi8.mjs";
2
+ import { n as EnvError, t as AuthError } from "../errors-5ivL23qo.mjs";
3
+ import { SupabaseClient } from "@supabase/supabase-js";
4
+
5
+ //#region src/core/resolve-env.d.ts
6
+ /**
7
+ * Resolves Supabase environment configuration from runtime environment variables.
8
+ *
9
+ * Reads `SUPABASE_URL`, keys (`SUPABASE_PUBLISHABLE_KEYS` / `SUPABASE_SECRET_KEYS`),
10
+ * and `SUPABASE_JWKS`. Works across Deno, Node.js, and Bun. For Cloudflare Workers,
11
+ * use `overrides` or enable node-compat.
12
+ *
13
+ * @param overrides - Partial values that take precedence over env vars.
14
+ * @returns `{ data: SupabaseEnv, error: null }` on success, `{ data: null, error: EnvError }` on failure.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const { data: env, error } = resolveEnv()
19
+ * if (error) throw error
20
+ *
21
+ * // Override for tests
22
+ * const { data: env } = resolveEnv({ url: 'http://localhost:54321' })
23
+ * ```
24
+ */
25
+ declare function resolveEnv(overrides?: Partial<SupabaseEnv>): {
26
+ data: SupabaseEnv;
27
+ error: null;
28
+ } | {
29
+ data: null;
30
+ error: EnvError;
31
+ };
32
+ //#endregion
33
+ //#region src/core/extract-credentials.d.ts
34
+ /**
35
+ * Extracts authentication credentials from an incoming HTTP request.
36
+ *
37
+ * Reads two headers:
38
+ * - `Authorization: Bearer <token>` → extracted as `token`
39
+ * - `apikey: <key>` → extracted as `apikey`
40
+ *
41
+ * This is a pure extraction step — no validation or verification is performed.
42
+ * Pass the result to {@link verifyCredentials} to validate against allowed auth modes.
43
+ *
44
+ * @param request - The incoming HTTP request.
45
+ * @returns The extracted {@link Credentials}. Fields are `null` when the corresponding header is absent.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { extractCredentials } from '@supabase/server/core'
50
+ *
51
+ * const creds = extractCredentials(request)
52
+ * console.log(creds.token) // "eyJhbGci..." or null
53
+ * console.log(creds.apikey) // "sb-abc123-publishable-..." or null
54
+ * ```
55
+ */
56
+ declare function extractCredentials(request: Request): Credentials;
57
+ //#endregion
58
+ //#region src/core/verify-credentials.d.ts
59
+ /**
60
+ * Options for {@link verifyCredentials}.
61
+ */
62
+ interface VerifyCredentialsOptions {
63
+ /**
64
+ * Auth mode(s) to try. Modes are attempted in order — the first match wins.
65
+ *
66
+ * @see {@link AllowWithKey} for the full syntax including named keys.
67
+ */
68
+ allow: AllowWithKey | AllowWithKey[];
69
+ /** Optional environment overrides (passed through to {@link resolveEnv}). */
70
+ env?: Partial<SupabaseEnv>;
71
+ }
72
+ /**
73
+ * Verifies pre-extracted credentials against one or more allowed auth modes.
74
+ *
75
+ * Tries each mode in order — first match wins. Use {@link verifyAuth} to extract
76
+ * and verify in a single call.
77
+ *
78
+ * @param credentials - The credentials to verify (from {@link extractCredentials}).
79
+ * @param options - Allowed auth modes and optional env overrides.
80
+ * @returns `{ data: AuthResult, error: null }` on success, `{ data: null, error: AuthError }` on failure.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const credentials = extractCredentials(request)
85
+ * const { data: auth, error } = await verifyCredentials(credentials, {
86
+ * allow: ['user', 'public'],
87
+ * })
88
+ * if (error) {
89
+ * return Response.json({ error: error.message }, { status: error.status })
90
+ * }
91
+ * ```
92
+ */
93
+ declare function verifyCredentials(credentials: Credentials, options: VerifyCredentialsOptions): Promise<{
94
+ data: AuthResult;
95
+ error: null;
96
+ } | {
97
+ data: null;
98
+ error: AuthError;
99
+ }>;
100
+ //#endregion
101
+ //#region src/core/verify-auth.d.ts
102
+ /**
103
+ * Options for {@link verifyAuth}.
104
+ */
105
+ interface VerifyAuthOptions {
106
+ /**
107
+ * Auth mode(s) to try. Modes are attempted in order — the first match wins.
108
+ *
109
+ * @see {@link AllowWithKey} for the full syntax including named keys.
110
+ */
111
+ allow: AllowWithKey | AllowWithKey[];
112
+ /** Optional environment overrides (passed through to {@link resolveEnv}). */
113
+ env?: Partial<SupabaseEnv>;
114
+ }
115
+ /**
116
+ * Extracts credentials from a request and verifies them in a single step.
117
+ *
118
+ * This is a convenience function that combines {@link extractCredentials} and
119
+ * {@link verifyCredentials}. Use it when you want the full auth flow without
120
+ * needing to inspect the raw credentials.
121
+ *
122
+ * @param request - The incoming HTTP request.
123
+ * @param options - Auth modes to accept and optional environment overrides.
124
+ *
125
+ * @returns A result tuple: `{ data, error }`.
126
+ * - On success: `{ data: AuthResult, error: null }`
127
+ * - On failure: `{ data: null, error: AuthError }`
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * import { verifyAuth } from '@supabase/server/core'
132
+ *
133
+ * const { data: auth, error } = await verifyAuth(request, {
134
+ * allow: 'user',
135
+ * })
136
+ *
137
+ * if (error) {
138
+ * return Response.json({ error: error.message }, { status: error.status })
139
+ * }
140
+ *
141
+ * console.log(auth.userClaims!.id) // "d0f1a2b3-..."
142
+ * ```
143
+ */
144
+ declare function verifyAuth(request: Request, options: VerifyAuthOptions): Promise<{
145
+ data: AuthResult;
146
+ error: null;
147
+ } | {
148
+ data: null;
149
+ error: AuthError;
150
+ }>;
151
+ //#endregion
152
+ //#region src/core/create-context-client.d.ts
153
+ /**
154
+ * Creates a Supabase client scoped to the caller's context.
155
+ *
156
+ * Configured with a publishable key and (optionally) the caller's JWT,
157
+ * so Row-Level Security policies apply. Session persistence is disabled
158
+ * (stateless, one client per request).
159
+ *
160
+ * @param token - The caller's JWT, or `null` for anonymous access.
161
+ * @param env - Optional environment overrides (passed through to {@link resolveEnv}).
162
+ * @param keyName - Name of the publishable key to use. Falls back to `"default"`, then first available.
163
+ * @returns A configured {@link SupabaseClient} with RLS enforced.
164
+ * @throws {@link EnvError} If `SUPABASE_URL` is missing or the specified publishable key is not found.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const { data: auth } = await verifyAuth(request, { allow: 'user' })
169
+ * const supabase = createContextClient(auth.token)
170
+ * const { data } = await supabase.rpc('get_my_items')
171
+ * ```
172
+ */
173
+ declare function createContextClient<Database = unknown>(token?: string | null, env?: Partial<SupabaseEnv>, keyName?: string | null): SupabaseClient<Database>;
174
+ //#endregion
175
+ //#region src/core/create-admin-client.d.ts
176
+ /**
177
+ * Creates an admin Supabase client that bypasses Row-Level Security.
178
+ *
179
+ * Uses a secret key for authentication, giving full access to all data.
180
+ * Session persistence is disabled (stateless, one client per request).
181
+ *
182
+ * @param env - Optional environment overrides (passed through to {@link resolveEnv}).
183
+ * @param keyName - Name of the secret key to use. Falls back to `"default"`, then first available.
184
+ * @returns A configured {@link SupabaseClient} with admin (service-role) privileges.
185
+ * @throws {@link EnvError} If `SUPABASE_URL` is missing or the specified secret key is not found.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const supabaseAdmin = createAdminClient()
190
+ * const { data } = await supabaseAdmin.from('audit_log').insert({ action: 'user_login' })
191
+ * ```
192
+ */
193
+ declare function createAdminClient<Database = unknown>(env?: Partial<SupabaseEnv>, keyName?: string | null): SupabaseClient<Database>;
194
+ //#endregion
3
195
  export { createAdminClient, createContextClient, extractCredentials, resolveEnv, verifyAuth, verifyCredentials };
@@ -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-DxUT0XoT.mjs";
1
+ import { a as createAdminClient, i as createContextClient, n as verifyCredentials, o as resolveEnv, r as extractCredentials, t as verifyAuth } from "../verify-auth-2S7zFfR-.mjs";
2
2
 
3
3
  export { createAdminClient, createContextClient, extractCredentials, resolveEnv, verifyAuth, verifyCredentials };
@@ -1,6 +1,26 @@
1
- import { a as createAdminClient, c as EnvError, i as createContextClient, s as AuthError, t as verifyAuth } from "./verify-auth-DxUT0XoT.mjs";
1
+ import { a as createAdminClient, c as EnvError, i as createContextClient, s as AuthError, t as verifyAuth } from "./verify-auth-2S7zFfR-.mjs";
2
2
 
3
3
  //#region src/create-supabase-context.ts
4
+ /**
5
+ * Creates a {@link SupabaseContext} directly from a request.
6
+ *
7
+ * Use this when you need the context without the full {@link withSupabase} wrapper —
8
+ * e.g., inside framework route handlers or custom middleware. Returns a result tuple
9
+ * instead of producing a `Response`.
10
+ *
11
+ * @param request - The incoming HTTP request.
12
+ * @param options - Auth modes, environment overrides. The `cors` option is ignored here.
13
+ * @returns `{ data: SupabaseContext, error: null }` on success, `{ data: null, error: AuthError }` on failure.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
18
+ * if (error) {
19
+ * return Response.json({ error: error.message }, { status: error.status })
20
+ * }
21
+ * const { data } = await ctx.supabase.rpc('get_my_items')
22
+ * ```
23
+ */
4
24
  async function createSupabaseContext(request, options) {
5
25
  const { data: auth, error } = await verifyAuth(request, {
6
26
  allow: options?.allow ?? "user",
@@ -1,6 +1,26 @@
1
- const require_verify_auth = require('./verify-auth-6a1UPrFz.cjs');
1
+ const require_verify_auth = require('./verify-auth-DvRVnjdq.cjs');
2
2
 
3
3
  //#region src/create-supabase-context.ts
4
+ /**
5
+ * Creates a {@link SupabaseContext} directly from a request.
6
+ *
7
+ * Use this when you need the context without the full {@link withSupabase} wrapper —
8
+ * e.g., inside framework route handlers or custom middleware. Returns a result tuple
9
+ * instead of producing a `Response`.
10
+ *
11
+ * @param request - The incoming HTTP request.
12
+ * @param options - Auth modes, environment overrides. The `cors` option is ignored here.
13
+ * @returns `{ data: SupabaseContext, error: null }` on success, `{ data: null, error: AuthError }` on failure.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const { data: ctx, error } = await createSupabaseContext(request, { allow: 'user' })
18
+ * if (error) {
19
+ * return Response.json({ error: error.message }, { status: error.status })
20
+ * }
21
+ * const { data } = await ctx.supabase.rpc('get_my_items')
22
+ * ```
23
+ */
4
24
  async function createSupabaseContext(request, options) {
5
25
  const { data: auth, error } = await require_verify_auth.verifyAuth(request, {
6
26
  allow: options?.allow ?? "user",