@jskit-ai/auth-provider-supabase-core 0.1.57 → 0.1.59

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,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  "packageVersion": 1,
3
3
  "packageId": "@jskit-ai/auth-provider-supabase-core",
4
- "version": "0.1.57",
4
+ "version": "0.1.59",
5
5
  "kind": "runtime",
6
6
  "options": {
7
7
  "auth-supabase-url": {
@@ -83,8 +83,8 @@ export default Object.freeze({
83
83
  "mutations": {
84
84
  "dependencies": {
85
85
  "runtime": {
86
- "@jskit-ai/auth-core": "0.1.57",
87
- "@jskit-ai/kernel": "0.1.58",
86
+ "@jskit-ai/auth-core": "0.1.59",
87
+ "@jskit-ai/kernel": "0.1.60",
88
88
  "dotenv": "^16.4.5",
89
89
  "@supabase/supabase-js": "^2.57.4",
90
90
  "jose": "^6.1.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-provider-supabase-core",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -12,10 +12,11 @@
12
12
  "./client": "./src/client/index.js"
13
13
  },
14
14
  "dependencies": {
15
- "@jskit-ai/auth-core": "0.1.57",
16
- "@jskit-ai/kernel": "0.1.58",
15
+ "@jskit-ai/auth-core": "0.1.59",
16
+ "@jskit-ai/kernel": "0.1.60",
17
17
  "json-rest-schema": "1.x.x",
18
18
  "jose": "^6.1.0",
19
- "@supabase/supabase-js": "^2.57.4"
19
+ "@supabase/supabase-js": "^2.57.4",
20
+ "ws": "^8.18.3"
20
21
  }
21
22
  }
@@ -48,6 +48,7 @@ import { buildDisabledPasswordSecret } from "./authSecrets.js";
48
48
  import { createAccountFlows } from "./accountFlows.js";
49
49
  import { createOauthFlows } from "./oauthFlows.js";
50
50
  import { createPasswordSecurityFlows } from "./passwordSecurityFlows.js";
51
+ import { buildSupabaseServerClientOptions } from "./supabaseClientOptions.js";
51
52
  import { USER_PROFILE_EMAIL_CONFLICT_CODE } from "./standaloneProfileSyncService.js";
52
53
  import {
53
54
  assertDevAuthBootstrapConfig,
@@ -202,12 +203,7 @@ function createService(options) {
202
203
 
203
204
  function createSupabaseClient() {
204
205
  ensureConfigured();
205
- return createClient(supabaseUrl, supabasePublishableKey, {
206
- auth: {
207
- autoRefreshToken: false,
208
- persistSession: false
209
- }
210
- });
206
+ return createClient(supabaseUrl, supabasePublishableKey, buildSupabaseServerClientOptions());
211
207
  }
212
208
 
213
209
  function getSupabaseClient() {
@@ -0,0 +1,34 @@
1
+ import WebSocket from "ws";
2
+
3
+ function resolveRealtimeTransport({
4
+ nativeWebSocket = globalThis.WebSocket,
5
+ fallbackTransport = WebSocket
6
+ } = {}) {
7
+ if (typeof nativeWebSocket === "function") {
8
+ return null;
9
+ }
10
+
11
+ if (typeof fallbackTransport === "function") {
12
+ return fallbackTransport;
13
+ }
14
+
15
+ return null;
16
+ }
17
+
18
+ export function buildSupabaseServerClientOptions(options = {}) {
19
+ const realtimeTransport = resolveRealtimeTransport(options);
20
+ const clientOptions = {
21
+ auth: {
22
+ autoRefreshToken: false,
23
+ persistSession: false
24
+ }
25
+ };
26
+
27
+ if (realtimeTransport) {
28
+ clientOptions.realtime = {
29
+ transport: realtimeTransport
30
+ };
31
+ }
32
+
33
+ return clientOptions;
34
+ }
@@ -0,0 +1,36 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { buildSupabaseServerClientOptions } from "../src/server/lib/supabaseClientOptions.js";
4
+
5
+ test("buildSupabaseServerClientOptions omits realtime transport when native WebSocket exists", () => {
6
+ const NativeWebSocket = function NativeWebSocket() {};
7
+ const options = buildSupabaseServerClientOptions({
8
+ nativeWebSocket: NativeWebSocket,
9
+ fallbackTransport: function FallbackTransport() {}
10
+ });
11
+
12
+ assert.deepEqual(options, {
13
+ auth: {
14
+ autoRefreshToken: false,
15
+ persistSession: false
16
+ }
17
+ });
18
+ });
19
+
20
+ test("buildSupabaseServerClientOptions injects fallback transport when native WebSocket is unavailable", () => {
21
+ const fallbackTransport = function FallbackTransport() {};
22
+ const options = buildSupabaseServerClientOptions({
23
+ nativeWebSocket: undefined,
24
+ fallbackTransport
25
+ });
26
+
27
+ assert.deepEqual(options, {
28
+ auth: {
29
+ autoRefreshToken: false,
30
+ persistSession: false
31
+ },
32
+ realtime: {
33
+ transport: fallbackTransport
34
+ }
35
+ });
36
+ });