@jskit-ai/auth-provider-supabase-core 0.2.33 → 0.2.35

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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - **Breaking:** the resolved configuration names whether the app runs in staging or production `isStagingOrProduction`, in place of `isDeployed`.
6
+ - The email change operations (`requestEmailChange`, `requestEmailChangeForUser`, `confirmEmailChange`) answer `AUTH_OPERATION_UNSUPPORTED`, and `features.emailChange` is false: the email is the identity provider's.
5
7
  - **Breaking:** staging and production (`APP_ENV`), not `NODE_ENV=production`, use secure `__Host-` session cookies and refuse development shortcuts; the config's `isProduction` is now `isDeployed`.
6
8
  - The second-factor operations (`getSecondFactorStatus`, `startSecondFactorSetup`, `confirmSecondFactorSetup`, `verifySecondFactor`, `replaceSecondFactorRecoveryCodes`, `removeSecondFactor`, `listSecondFactors`, `resetSecondFactor`) answer `AUTH_OPERATION_UNSUPPORTED`, and `features.secondFactor` is false.
7
9
  - 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-provider-supabase-core",
3
- "version": "0.2.33",
3
+ "version": "0.2.35",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -60,7 +60,7 @@
60
60
  }
61
61
  },
62
62
  "peerDependencies": {
63
- "@jskit-ai/auth-core": "0.2.30",
64
- "@jskit-ai/kernel": "0.2.27"
63
+ "@jskit-ai/auth-core": "0.2.32",
64
+ "@jskit-ai/kernel": "0.2.28"
65
65
  }
66
66
  }
@@ -2,6 +2,6 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@jskit-ai/auth-provider-supabase-core": "0.2.33"
5
+ "@jskit-ai/auth-provider-supabase-core": "0.2.35"
6
6
  }
7
7
  }
@@ -6,11 +6,11 @@ function safeRequestCookies(request) {
6
6
  return {};
7
7
  }
8
8
 
9
- function cookieOptions(isDeployed, maxAge) {
9
+ function cookieOptions(isStagingOrProduction, maxAge) {
10
10
  const options = {
11
11
  httpOnly: true,
12
12
  sameSite: "lax",
13
- secure: isDeployed,
13
+ secure: isStagingOrProduction,
14
14
  path: "/"
15
15
  };
16
16
 
@@ -21,11 +21,11 @@ function cookieOptions(isDeployed, maxAge) {
21
21
  return options;
22
22
  }
23
23
 
24
- function cookieClearOptions(isDeployed) {
24
+ function cookieClearOptions(isStagingOrProduction) {
25
25
  return [
26
- cookieOptions(isDeployed, 0),
26
+ cookieOptions(isStagingOrProduction, 0),
27
27
  {
28
- ...cookieOptions(isDeployed, 0),
28
+ ...cookieOptions(isStagingOrProduction, 0),
29
29
  path: "/api"
30
30
  }
31
31
  ];
@@ -49,7 +49,7 @@ function assertSelectedProvider(env) {
49
49
  /**
50
50
  * Supabase auth's settings, read once from the app's config and Env: the
51
51
  * project, where profiles live, the app's addresses, its OAuth providers and
52
- * dev auth. Whether it is deployed is worked out once, by auth-core's dev auth policy.
52
+ * dev auth. Whether it runs in staging or production is worked out once, by auth-core's dev auth policy.
53
53
  * @param {object} sources
54
54
  * @param {import("@jskit-ai/kernel/server/types").RuntimeConfig} sources.config
55
55
  * @param {import("@jskit-ai/kernel/server/types").RuntimeEnv} sources.env
@@ -74,7 +74,7 @@ function resolveSupabaseConfig({ config, env }) {
74
74
  supabasePublishableKey,
75
75
  configured: Boolean(supabaseUrl && supabasePublishableKey),
76
76
  jwtAudience,
77
- isDeployed: devAuth.isDeployed,
77
+ isStagingOrProduction: devAuth.isStagingOrProduction,
78
78
  appPublicUrl,
79
79
  allowedReturnToOrigins: resolveAllowedOriginsFromSurfaceDefinitions(config.surfaceDefinitions || {}, {
80
80
  seedOrigins: [appPublicUrl]
@@ -147,7 +147,10 @@ function createSupabaseAuthService({ config, profiles }) {
147
147
  replaceSecondFactorRecoveryCodes: unsupported("replaceSecondFactorRecoveryCodes"),
148
148
  removeSecondFactor: unsupported("removeSecondFactor"),
149
149
  listSecondFactors: unsupported("listSecondFactors"),
150
- resetSecondFactor: unsupported("resetSecondFactor")
150
+ resetSecondFactor: unsupported("resetSecondFactor"),
151
+ requestEmailChange: unsupported("requestEmailChange"),
152
+ requestEmailChangeForUser: unsupported("requestEmailChangeForUser"),
153
+ confirmEmailChange: unsupported("confirmEmailChange")
151
154
  });
152
155
  }
153
156
 
@@ -22,12 +22,12 @@ const PERSISTENT_SESSION_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 400;
22
22
  * @param {import("../types.js").SupabaseProfiles} dependencies.profiles
23
23
  */
24
24
  function createSupabaseSessions({ config, clients, profileMirror, profiles }) {
25
- const { isDeployed, jwtAudience, supabaseUrl } = config;
25
+ const { isStagingOrProduction, jwtAudience, supabaseUrl } = config;
26
26
  // Staging and production cookies are Secure, so they are also host-only __Host- cookies.
27
- const ACCESS_TOKEN_COOKIE = hostOnlyCookieName(ACCESS_TOKEN_COOKIE_NAME, isDeployed);
28
- const REFRESH_TOKEN_COOKIE = hostOnlyCookieName(REFRESH_TOKEN_COOKIE_NAME, isDeployed);
29
- const RECOVERY_ACCESS_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_ACCESS_TOKEN_COOKIE_NAME, isDeployed);
30
- const RECOVERY_REFRESH_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_REFRESH_TOKEN_COOKIE_NAME, isDeployed);
27
+ const ACCESS_TOKEN_COOKIE = hostOnlyCookieName(ACCESS_TOKEN_COOKIE_NAME, isStagingOrProduction);
28
+ const REFRESH_TOKEN_COOKIE = hostOnlyCookieName(REFRESH_TOKEN_COOKIE_NAME, isStagingOrProduction);
29
+ const RECOVERY_ACCESS_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_ACCESS_TOKEN_COOKIE_NAME, isStagingOrProduction);
30
+ const RECOVERY_REFRESH_TOKEN_COOKIE = hostOnlyCookieName(RECOVERY_REFRESH_TOKEN_COOKIE_NAME, isStagingOrProduction);
31
31
  const issuerUrl = supabaseUrl ? new URL("/auth/v1", supabaseUrl).toString().replace(/\/$/, "") : "";
32
32
  const jwksUrl = issuerUrl ? `${issuerUrl}/.well-known/jwks.json` : "";
33
33
 
@@ -255,14 +255,14 @@ function createSupabaseSessions({ config, clients, profileMirror, profiles }) {
255
255
  ? Math.floor(sessionAccessMaxAge)
256
256
  : Math.max(Math.floor(sessionAccessMaxAge), PERSISTENT_SESSION_COOKIE_MAX_AGE_SECONDS);
257
257
 
258
- reply.setCookie(accessCookieName, accessToken, cookieOptions(isDeployed, cookieMaxAge));
259
- reply.setCookie(refreshCookieName, refreshToken, cookieOptions(isDeployed, cookieMaxAge));
258
+ reply.setCookie(accessCookieName, accessToken, cookieOptions(isStagingOrProduction, cookieMaxAge));
259
+ reply.setCookie(refreshCookieName, refreshToken, cookieOptions(isStagingOrProduction, cookieMaxAge));
260
260
  }
261
261
 
262
262
  function clearSessionCookies(reply) {
263
- for (const clearOptions of cookieClearOptions(isDeployed)) {
263
+ for (const clearOptions of cookieClearOptions(isStagingOrProduction)) {
264
264
  // A __Host- cookie only exists at Path=/.
265
- if (clearOptions.path === "/" || !isDeployed) {
265
+ if (clearOptions.path === "/" || !isStagingOrProduction) {
266
266
  reply.clearCookie(ACCESS_TOKEN_COOKIE, clearOptions);
267
267
  reply.clearCookie(REFRESH_TOKEN_COOKIE, clearOptions);
268
268
  reply.clearCookie(RECOVERY_ACCESS_TOKEN_COOKIE, clearOptions);
@@ -67,6 +67,11 @@ test("AuthSupabaseProvider exposes a configured provider-owned auth service", as
67
67
  status: 501,
68
68
  code: "AUTH_OPERATION_UNSUPPORTED"
69
69
  });
70
+ assert.equal(authService.getCapabilities().features.emailChange, false);
71
+ assert.throws(() => authService.requestEmailChangeForUser({ userId: "usr_1", email: "new@example.com" }), {
72
+ status: 501,
73
+ code: "AUTH_OPERATION_UNSUPPORTED"
74
+ });
70
75
  await runtime.shutdown();
71
76
  });
72
77