@jskit-ai/auth-provider-supabase-core 0.2.20 → 0.2.21
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Reading the signed-in user for the security screen and account changes asks Supabase for a valid access token's user once instead of twice; it asks again only for the new token a session refresh issued.
|
|
5
6
|
- A request with a valid access token synchronizes the app profile only when it is missing or no longer matches the token's email and display name (`onlyWhenChanged`), after one read instead of two plus a transaction; sign-in, account changes and a session refresh synchronize in full. Visible difference: a personal workspace, owner membership or settings row deleted while someone is signed in comes back at their next session refresh or sign-in instead of their next request.
|
|
6
7
|
- `confirmRegistration` answers `AUTH_OPERATION_UNSUPPORTED`: Supabase confirms an email through its own link.
|
|
7
8
|
- Profile mode `users` takes the optional `users.profiles`, `users.settings` and `auth.profile.projector` capabilities instead of `users.identity`, which users-core no longer provides; without all three it refuses to start, naming them.
|
package/package.json
CHANGED
|
@@ -191,7 +191,8 @@ function createSupabaseSessions({ config, clients, profileMirror, profiles }) {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const currentAccessToken = String(session?.access_token || accessToken || "").trim();
|
|
194
|
-
|
|
194
|
+
// The cookie's token was read above; only a token setSession issued is read again.
|
|
195
|
+
const explicitUser = currentAccessToken === accessToken ? null : await getUserByAccessToken(currentAccessToken);
|
|
195
196
|
if (explicitUser) {
|
|
196
197
|
user = explicitUser;
|
|
197
198
|
}
|
|
@@ -7,6 +7,7 @@ import * as authProviderSupabase from "../src/server/lib/index.js";
|
|
|
7
7
|
import { createSupabaseAccountFlows } from "../src/server/lib/accountFlows.js";
|
|
8
8
|
import { resolveSupabaseConfig } from "../src/server/lib/config.js";
|
|
9
9
|
import { createSupabasePasswordFlows } from "../src/server/lib/passwordFlows.js";
|
|
10
|
+
import { createSupabaseSessions } from "../src/server/lib/sessions.js";
|
|
10
11
|
import { PROVIDER_MODE_PROFILES } from "../src/server/lib/profileModes.js";
|
|
11
12
|
|
|
12
13
|
test("auth.provider.supabase exports required symbols", () => {
|
|
@@ -417,3 +418,63 @@ test("supabase password reset consumes the recovery session reader", async () =>
|
|
|
417
418
|
assert.equal(normalSessionReads, 0);
|
|
418
419
|
assert.equal(signOutCalls, 1);
|
|
419
420
|
});
|
|
421
|
+
|
|
422
|
+
test("supabase sessions read a valid access token's user once", async () => {
|
|
423
|
+
const reads = [];
|
|
424
|
+
const user = { id: "supabase-user-1", email: "ada@example.com" };
|
|
425
|
+
const sessions = createSupabaseSessions({
|
|
426
|
+
config: supabaseConfig(),
|
|
427
|
+
clients: {
|
|
428
|
+
ensureConfigured() {},
|
|
429
|
+
createSupabaseClient() {
|
|
430
|
+
return {
|
|
431
|
+
auth: {
|
|
432
|
+
async getUser(token) {
|
|
433
|
+
reads.push(token);
|
|
434
|
+
return { data: { user }, error: null };
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
profileMirror: {},
|
|
441
|
+
profiles: {}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const current = await sessions.resolveCurrentSupabaseUser({ cookies: { sb_access_token: "access-1", sb_refresh_token: "refresh-1" } });
|
|
445
|
+
assert.deepEqual(current, { session: null, user });
|
|
446
|
+
assert.deepEqual(reads, ["access-1"]);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
test("supabase sessions read the user of a token that setSession issued", async () => {
|
|
450
|
+
const reads = [];
|
|
451
|
+
const refreshedUser = { id: "supabase-user-1", email: "ada@example.com" };
|
|
452
|
+
const sessions = createSupabaseSessions({
|
|
453
|
+
config: supabaseConfig(),
|
|
454
|
+
clients: {
|
|
455
|
+
ensureConfigured() {},
|
|
456
|
+
createSupabaseClient() {
|
|
457
|
+
return {
|
|
458
|
+
auth: {
|
|
459
|
+
async getUser(token) {
|
|
460
|
+
reads.push(token);
|
|
461
|
+
return token === "access-2"
|
|
462
|
+
? { data: { user: { ...refreshedUser, read: true } }, error: null }
|
|
463
|
+
: { data: { user: null }, error: { status: 401, message: "expired" } };
|
|
464
|
+
},
|
|
465
|
+
async setSession() {
|
|
466
|
+
return { data: { session: { access_token: "access-2", refresh_token: "refresh-2" }, user: refreshedUser }, error: null };
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
profileMirror: {},
|
|
473
|
+
profiles: {}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const current = await sessions.resolveCurrentSupabaseUser({ cookies: { sb_access_token: "access-1", sb_refresh_token: "refresh-1" } });
|
|
477
|
+
assert.deepEqual(reads, ["access-1", "access-2"]);
|
|
478
|
+
assert.equal(current.user.read, true);
|
|
479
|
+
assert.equal(current.session.access_token, "access-2");
|
|
480
|
+
});
|