@supabase/supabase-js 2.110.6-canary.0 → 2.110.6-canary.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/supabase-js",
3
- "version": "2.110.6-canary.0",
3
+ "version": "2.110.6-canary.2",
4
4
  "description": "Isomorphic Javascript SDK for Supabase",
5
5
  "keywords": [
6
6
  "javascript",
@@ -59,11 +59,11 @@
59
59
  "directory": "packages/core/supabase-js"
60
60
  },
61
61
  "dependencies": {
62
- "@supabase/functions-js": "2.110.6-canary.0",
63
- "@supabase/auth-js": "2.110.6-canary.0",
64
- "@supabase/realtime-js": "2.110.6-canary.0",
65
- "@supabase/storage-js": "2.110.6-canary.0",
66
- "@supabase/postgrest-js": "2.110.6-canary.0"
62
+ "@supabase/auth-js": "2.110.6-canary.2",
63
+ "@supabase/functions-js": "2.110.6-canary.2",
64
+ "@supabase/postgrest-js": "2.110.6-canary.2",
65
+ "@supabase/realtime-js": "2.110.6-canary.2",
66
+ "@supabase/storage-js": "2.110.6-canary.2"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@arethetypeswrong/cli": "^0.18.2",
@@ -20,7 +20,7 @@ import {
20
20
  DEFAULT_REALTIME_OPTIONS,
21
21
  DEFAULT_TRACE_PROPAGATION_OPTIONS,
22
22
  } from './lib/constants'
23
- import { assertSupportedApiKey, fetchWithAuth } from './lib/fetch'
23
+ import { checkApiKeyFormat, fetchWithAuth } from './lib/fetch'
24
24
  import {
25
25
  applySettingDefaults,
26
26
  validateSupabaseUrl,
@@ -315,7 +315,7 @@ export default class SupabaseClient<
315
315
  ) {
316
316
  const baseUrl = validateSupabaseUrl(supabaseUrl)
317
317
  if (!supabaseKey) throw new Error('supabaseKey is required.')
318
- assertSupportedApiKey(supabaseKey)
318
+ checkApiKeyFormat(supabaseKey)
319
319
 
320
320
  this.realtimeUrl = new URL('realtime/v1', baseUrl)
321
321
  this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws')
package/src/lib/fetch.ts CHANGED
@@ -24,27 +24,35 @@ export const resolveHeadersConstructor = () => {
24
24
  /**
25
25
  * New-format Supabase API keys (`sb_publishable_…` / `sb_secret_…`) are not JWTs and
26
26
  * must never be sent as a Bearer token — they belong only in the `apikey` header.
27
- * Legacy (JWT) keys predate this format (they don't start with `sb_`) and keep their
28
- * existing behavior. Any other `sb_`-prefixed key is an unrecognized future subtype;
29
- * see {@link assertSupportedApiKey}.
27
+ * All other keys (legacy JWT keys, `sb_temp_…` temporary keys, unrecognized `sb_`
28
+ * subtypes) keep the Bearer fallback.
30
29
  */
31
30
  const isNewApiKey = (key: string): boolean =>
32
31
  key.startsWith('sb_publishable_') || key.startsWith('sb_secret_')
33
32
 
33
+ const TEMP_KEY_PREFIX = 'sb_temp_'
34
+
35
+ const warnedKeySubtypes = new Set<string>()
36
+
34
37
  /**
35
- * Fail fast on an `sb_`-family key whose subtype this SDK version does not recognize, so a
36
- * future key type can never be silently mistreated as a legacy JWT and sent as a Bearer
37
- * token. Recognized new-format keys and legacy JWT keys (no `sb_` prefix) pass through.
38
- * The key itself is never included in the message to avoid leaking secret keys.
38
+ * Warn (once per subtype) when an `sb_` key isn't a subtype this SDK version recognizes.
39
+ * Never throws the server, not the SDK, decides key validity. The key value is never
40
+ * included in the message.
39
41
  */
40
- export const assertSupportedApiKey = (key: string): void => {
41
- if (key.startsWith('sb_') && !isNewApiKey(key)) {
42
- throw new Error(
43
- '@supabase/supabase-js: Unrecognized Supabase API key format. Expected a legacy JWT key ' +
44
- 'or a new-format key (sb_publishable_… / sb_secret_…). This "sb_" key type is not ' +
45
- 'supported by this version of the SDK — please upgrade @supabase/supabase-js.'
46
- )
42
+ export const checkApiKeyFormat = (key: string): void => {
43
+ if (!key.startsWith('sb_') || isNewApiKey(key) || key.startsWith(TEMP_KEY_PREFIX)) {
44
+ return
45
+ }
46
+ const subtype = key.match(/^sb_[a-zA-Z0-9]+_/)?.[0] ?? 'unknown'
47
+ if (warnedKeySubtypes.has(subtype)) {
48
+ return
47
49
  }
50
+ warnedKeySubtypes.add(subtype)
51
+ console.warn(
52
+ '@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed ' +
53
+ 'and send this key as-is; if you see authentication errors you may need to upgrade ' +
54
+ '@supabase/supabase-js to a version that recognizes this key type.'
55
+ )
48
56
  }
49
57
 
50
58
  export const fetchWithAuth = (
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.110.6-canary.0'
7
+ export const version = '2.110.6-canary.2'