@jskit-ai/auth-provider-supabase-core 0.1.51 → 0.1.53

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.51",
4
+ "version": "0.1.53",
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.51",
87
- "@jskit-ai/kernel": "0.1.52",
86
+ "@jskit-ai/auth-core": "0.1.53",
87
+ "@jskit-ai/kernel": "0.1.54",
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.51",
3
+ "version": "0.1.53",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -12,8 +12,8 @@
12
12
  "./client": "./src/client/index.js"
13
13
  },
14
14
  "dependencies": {
15
- "@jskit-ai/auth-core": "0.1.51",
16
- "@jskit-ai/kernel": "0.1.52",
15
+ "@jskit-ai/auth-core": "0.1.53",
16
+ "@jskit-ai/kernel": "0.1.54",
17
17
  "jose": "^6.1.0",
18
18
  "@supabase/supabase-js": "^2.57.4"
19
19
  }
@@ -1,6 +1,7 @@
1
1
  import { resolveAllowedOriginsFromSurfaceDefinitions } from "@jskit-ai/kernel/shared/support/returnToPath";
2
2
  import { withActionDefaults } from "@jskit-ai/kernel/shared/actions";
3
3
  import { normalizeRecordId } from "@jskit-ai/kernel/shared/support/normalize";
4
+ import { resolveAuthServiceDecorators } from "@jskit-ai/auth-core/server/authServiceDecoratorRegistry";
4
5
  import { createService } from "../lib/service.js";
5
6
  import { createStandaloneProfileSyncService } from "../lib/standaloneProfileSyncService.js";
6
7
  import { createAuthSessionEventsService } from "../lib/authSessionEventsService.js";
@@ -185,6 +186,19 @@ function resolveOptionalRepositories(scope) {
185
186
  return repositories;
186
187
  }
187
188
 
189
+ function applyAuthServiceDecorators(scope, authService) {
190
+ let decoratedAuthService = authService;
191
+
192
+ for (const decorator of resolveAuthServiceDecorators(scope)) {
193
+ decoratedAuthService = decorator.decorateAuthService(decoratedAuthService);
194
+ if (!decoratedAuthService || typeof decoratedAuthService !== "object") {
195
+ throw new Error(`Auth service decorator "${decorator.decoratorId}" must return an auth service object.`);
196
+ }
197
+ }
198
+
199
+ return decoratedAuthService;
200
+ }
201
+
188
202
  class AuthSupabaseServiceProvider {
189
203
  static id = "auth.provider.supabase";
190
204
 
@@ -225,7 +239,7 @@ class AuthSupabaseServiceProvider {
225
239
  userProfileSyncService = scope.make("users.profile.sync.service");
226
240
  }
227
241
 
228
- return createService({
242
+ const authService = createService({
229
243
  authProvider,
230
244
  appPublicUrl: String(env.APP_PUBLIC_URL || "").trim(),
231
245
  authAllowedReturnToOrigins: resolveAllowedReturnToOrigins({
@@ -241,6 +255,8 @@ class AuthSupabaseServiceProvider {
241
255
  devAuthAccessTtlSeconds: env.AUTH_DEV_ACCESS_TTL_SECONDS,
242
256
  devAuthRefreshTtlSeconds: env.AUTH_DEV_REFRESH_TTL_SECONDS
243
257
  });
258
+
259
+ return applyAuthServiceDecorators(scope, authService);
244
260
  });
245
261
  }
246
262
 
@@ -1,6 +1,7 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
3
  import { createApplication } from "@jskit-ai/kernel/_testable";
4
+ import { registerAuthServiceDecorator } from "@jskit-ai/auth-core/server/authServiceDecoratorRegistry";
4
5
  import { ActionRuntimeServiceProvider } from "@jskit-ai/kernel/server/actions";
5
6
  import { AuthSupabaseServiceProvider } from "../src/server/providers/AuthSupabaseServiceProvider.js";
6
7
 
@@ -220,6 +221,46 @@ test("auth supabase provider can boot dev auth without Supabase credentials", as
220
221
  assert.equal(definitions.some((definition) => definition.id === "auth.dev.loginAs"), true);
221
222
  });
222
223
 
224
+ test("auth supabase provider applies registered auth service decorators", async () => {
225
+ const app = createApplication();
226
+ app.instance("appConfig", createAppConfigFixture());
227
+ app.instance("jskit.env", {
228
+ AUTH_SUPABASE_URL: "https://example.supabase.co",
229
+ AUTH_SUPABASE_PUBLISHABLE_KEY: "sb_publishable_test_key",
230
+ AUTH_PROFILE_MODE: "standalone",
231
+ APP_PUBLIC_URL: "http://localhost:5173",
232
+ NODE_ENV: "test"
233
+ });
234
+ app.instance("jskit.logger", {
235
+ info() {},
236
+ warn() {},
237
+ error() {},
238
+ debug() {}
239
+ });
240
+ app.instance("domainEvents", {
241
+ async publish() {}
242
+ });
243
+
244
+ registerAuthServiceDecorator(app, "test.auth.decorator.marker", () => ({
245
+ decoratorId: "marker",
246
+ order: 10,
247
+ decorateAuthService(authService) {
248
+ return {
249
+ ...authService,
250
+ marker: "decorated"
251
+ };
252
+ }
253
+ }));
254
+
255
+ await app.start({
256
+ providers: [ActionRuntimeServiceProvider, AuthSupabaseServiceProvider]
257
+ });
258
+
259
+ const authService = app.make("authService");
260
+ assert.equal(authService.marker, "decorated");
261
+ assert.equal(typeof authService.login, "function");
262
+ });
263
+
223
264
  test("auth supabase provider rejects dev auth bypass in production", async () => {
224
265
  const app = createApplication();
225
266
  app.instance("appConfig", createAppConfigFixture());