@jskit-ai/auth-provider-supabase-core 0.1.241 → 0.1.242
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": "@jskit-ai/auth-provider-supabase-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.242",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@jskit-ai/auth-core": "0.1.
|
|
63
|
-
"@jskit-ai/kernel": "0.1.
|
|
62
|
+
"@jskit-ai/auth-core": "0.1.243",
|
|
63
|
+
"@jskit-ai/kernel": "0.1.245"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
AUTH_METHOD_PASSWORD_PROVIDER,
|
|
9
9
|
buildOAuthMethodId
|
|
10
10
|
} from "@jskit-ai/auth-core/shared/authMethods";
|
|
11
|
-
import { normalizeEmail } from "@jskit-ai/auth-core/server/utils";
|
|
11
|
+
import { hostOnlyCookieName, normalizeEmail } from "@jskit-ai/auth-core/server/utils";
|
|
12
12
|
import {
|
|
13
13
|
isTransientAuthMessage,
|
|
14
14
|
isTransientSupabaseError,
|
|
@@ -68,10 +68,10 @@ import {
|
|
|
68
68
|
resolveSupabaseOAuthProviderCatalog
|
|
69
69
|
} from "./oauthProviderCatalog.js";
|
|
70
70
|
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
71
|
+
const ACCESS_TOKEN_COOKIE_NAME = "sb_access_token";
|
|
72
|
+
const REFRESH_TOKEN_COOKIE_NAME = "sb_refresh_token";
|
|
73
|
+
const RECOVERY_ACCESS_TOKEN_COOKIE_NAME = "sb_recovery_access_token";
|
|
74
|
+
const RECOVERY_REFRESH_TOKEN_COOKIE_NAME = "sb_recovery_refresh_token";
|
|
75
75
|
const DEFAULT_AUDIENCE = "authenticated";
|
|
76
76
|
const DEFAULT_AUTH_PROVIDER_ID = "supabase";
|
|
77
77
|
const AUTH_PROVIDER_ID_PATTERN = /^[a-z][a-z0-9_-]{1,63}$/;
|
|
@@ -128,6 +128,11 @@ function createService(options) {
|
|
|
128
128
|
throw new Error("userProfileSyncService with syncIdentityProfile() and findByIdentity() is required.");
|
|
129
129
|
}
|
|
130
130
|
const isProduction = options.nodeEnv === "production";
|
|
131
|
+
// Production cookies are Secure, so they are also host-only __Host- cookies.
|
|
132
|
+
const ACCESS_TOKEN_COOKIE = hostOnlyCookieName(ACCESS_TOKEN_COOKIE_NAME, isProduction);
|
|
133
|
+
const REFRESH_TOKEN_COOKIE = hostOnlyCookieName(REFRESH_TOKEN_COOKIE_NAME, isProduction);
|
|
134
|
+
const RECOVERY_ACCESS_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_ACCESS_TOKEN_COOKIE_NAME, isProduction);
|
|
135
|
+
const RECOVERY_REFRESH_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_REFRESH_TOKEN_COOKIE_NAME, isProduction);
|
|
131
136
|
const jwtAudience = String(authProvider.jwtAudience || DEFAULT_AUDIENCE).trim();
|
|
132
137
|
const devAuthConfig = resolveDevAuthConfig({
|
|
133
138
|
enabled: options.devAuthBypassEnabled,
|
|
@@ -501,10 +506,13 @@ function createService(options) {
|
|
|
501
506
|
|
|
502
507
|
function clearSessionCookies(reply) {
|
|
503
508
|
for (const clearOptions of cookieClearOptions(isProduction)) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
509
|
+
// A __Host- cookie only exists at Path=/.
|
|
510
|
+
if (clearOptions.path === "/" || !isProduction) {
|
|
511
|
+
reply.clearCookie(ACCESS_TOKEN_COOKIE, clearOptions);
|
|
512
|
+
reply.clearCookie(REFRESH_TOKEN_COOKIE, clearOptions);
|
|
513
|
+
reply.clearCookie(RECOVERY_ACCESS_TOKEN_COOKIE, clearOptions);
|
|
514
|
+
reply.clearCookie(RECOVERY_REFRESH_TOKEN_COOKIE, clearOptions);
|
|
515
|
+
}
|
|
508
516
|
}
|
|
509
517
|
}
|
|
510
518
|
|
|
@@ -80,8 +80,17 @@ test("clearSessionCookies preserves secure cookie clearing in production", () =>
|
|
|
80
80
|
|
|
81
81
|
authService.clearSessionCookies(reply);
|
|
82
82
|
|
|
83
|
-
assert.equal(clearCalls.length, 8);
|
|
84
83
|
assert.equal(clearCalls.every((call) => call.options.secure === true), true);
|
|
84
|
+
// Production names are host-only __Host- cookies, which only exist at Path=/.
|
|
85
|
+
assert.deepEqual(
|
|
86
|
+
clearCalls.map((call) => `${call.name} ${call.options.path}`),
|
|
87
|
+
[
|
|
88
|
+
"__Host-sb_access_token /",
|
|
89
|
+
"__Host-sb_refresh_token /",
|
|
90
|
+
"__Host-sb_recovery_access_token /",
|
|
91
|
+
"__Host-sb_recovery_refresh_token /"
|
|
92
|
+
]
|
|
93
|
+
);
|
|
85
94
|
});
|
|
86
95
|
|
|
87
96
|
test("supabase account flow updateDisplayName accepts the core command payload shape", async () => {
|