@jskit-ai/auth-provider-oidc-core 0.2.47 → 0.2.49

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
+ - The email change operations (`requestEmailChange`, `requestEmailChangeForUser`, `confirmEmailChange`) answer `AUTH_OPERATION_UNSUPPORTED`, and `features.emailChange` is false: the email is the identity provider's.
6
+ - **Breaking:** staging and production (`APP_ENV`), not `NODE_ENV=production`, require `AUTH_OIDC_SESSION_SECRET` and use the `__Host-` session cookie; the config's `isProduction` is now `isDeployed`.
5
7
  - The second-factor operations (`getSecondFactorStatus`, `startSecondFactorSetup`, `confirmSecondFactorSetup`, `verifySecondFactor`, `replaceSecondFactorRecoveryCodes`, `removeSecondFactor`, `listSecondFactors`, `resetSecondFactor`) answer `AUTH_OPERATION_UNSUPPORTED`, and `features.secondFactor` is false: the hub asks for its own second factors.
6
8
  - `./server/lib/index` exports `OIDC_CLIENT_INFRASTRUCTURE_TABLES` (`auth_oidc_clients`, `auth_oidc_sessions`, `auth_oidc_logout_tokens`), the protocol state the relying party keeps outside table resources, for an app test's `expectEveryTableOwned({ infrastructureTables })`.
7
9
  - An ordinary request synchronizes the app profile only when it is missing or no longer matches the identity its session keeps from sign-in (`onlyWhenChanged`); sign-in synchronizes in full. The session is still read on every request. Visible difference: a personal workspace, owner membership or settings row deleted while someone is signed in comes back at their next sign-in instead of their next request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-provider-oidc-core",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -20,8 +20,8 @@
20
20
  "openid-client": "6.8.8"
21
21
  },
22
22
  "devDependencies": {
23
- "@jskit-ai/auth-provider-local-core": "0.2.35",
24
- "@jskit-ai/auth-web": "0.2.43",
23
+ "@jskit-ai/auth-provider-local-core": "0.2.37",
24
+ "@jskit-ai/auth-web": "0.2.45",
25
25
  "oidc-provider": "9.12.2"
26
26
  },
27
27
  "description": "Sign in through any OpenID Connect issuer: self-registration or a static client, app-owned sessions, and back-channel logout.",
@@ -91,7 +91,7 @@
91
91
  }
92
92
  },
93
93
  "peerDependencies": {
94
- "@jskit-ai/auth-core": "0.2.29",
95
- "@jskit-ai/kernel": "0.2.26"
94
+ "@jskit-ai/auth-core": "0.2.31",
95
+ "@jskit-ai/kernel": "0.2.27"
96
96
  }
97
97
  }
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "type": "module",
4
4
  "dependencies": {
5
- "@jskit-ai/auth-provider-oidc-core": "0.2.47",
6
- "@jskit-ai/auth-web": "0.2.43"
5
+ "@jskit-ai/auth-provider-oidc-core": "0.2.49",
6
+ "@jskit-ai/auth-web": "0.2.45"
7
7
  }
8
8
  }
@@ -44,13 +44,13 @@ function resolveAppName(appRoot) {
44
44
  }
45
45
  }
46
46
 
47
- function resolveSessionSecret(env, { appRoot, isProduction }) {
47
+ function resolveSessionSecret(env, { appRoot, isDeployed }) {
48
48
  const explicit = text(env.AUTH_OIDC_SESSION_SECRET);
49
49
  if (explicit) {
50
50
  if (explicit.length < 32) throw new Error("AUTH_OIDC_SESSION_SECRET must be at least 32 characters.");
51
51
  return explicit;
52
52
  }
53
- if (isProduction) throw new Error("AUTH_OIDC_SESSION_SECRET is required in production.");
53
+ if (isDeployed) throw new Error("AUTH_OIDC_SESSION_SECRET is required in staging and production.");
54
54
  const storeDir = path.resolve(appRoot, text(env.AUTH_OIDC_STORE_DIR) || DEFAULT_STORE_DIR);
55
55
  const secretPath = path.join(storeDir, SESSION_SECRET_FILE);
56
56
  try {
@@ -69,12 +69,12 @@ function resolveSessionSecret(env, { appRoot, isProduction }) {
69
69
  * Reads the OIDC sign-in Env. Malformed values stop the app with one sentence.
70
70
  * A missing issuer or client is not fatal: the app runs and sign-in explains
71
71
  * what to set (`setupProblem`), so a project can be prepared before its
72
- * accounts hub exists. Production is worked out once, by auth-core's dev auth
72
+ * accounts hub exists. Whether it is deployed is worked out once, by auth-core's dev auth
73
73
  * policy, so sign-in and dev sign-in agree on it.
74
74
  */
75
75
  function resolveOidcConfig({ env = {}, appRoot = process.cwd() } = {}) {
76
76
  const devAuth = resolveDevAuthPolicyFromEnv(env);
77
- const { isProduction } = devAuth;
77
+ const { isDeployed } = devAuth;
78
78
  const issuerValue = text(env.AUTH_OIDC_ISSUER);
79
79
  const registrationToken = text(env.AUTH_OIDC_REGISTRATION_TOKEN);
80
80
  const clientId = text(env.AUTH_OIDC_CLIENT_ID);
@@ -105,14 +105,14 @@ function resolveOidcConfig({ env = {}, appRoot = process.cwd() } = {}) {
105
105
  }
106
106
 
107
107
  return Object.freeze({
108
- isProduction,
108
+ isDeployed,
109
109
  issuer,
110
110
  registrationToken,
111
111
  staticClient: clientId ? Object.freeze({ clientId, clientSecret }) : null,
112
112
  label: text(env.AUTH_OIDC_LABEL) || AUTH_OIDC_DEFAULT_LABEL,
113
113
  appName: resolveAppName(appRoot),
114
114
  appPublicOrigin,
115
- sessionSecret: resolveSessionSecret(env, { appRoot, isProduction }),
115
+ sessionSecret: resolveSessionSecret(env, { appRoot, isDeployed }),
116
116
  devAuth,
117
117
  setupProblem: setupProblem?.message || "",
118
118
  setupProblemCode: setupProblem?.code || ""
@@ -89,11 +89,11 @@ function buildResult(identity, { session = null, appProfile = null } = {}) {
89
89
  */
90
90
  function createOidcAuthService({ config, store, issuer, profileProjector, logger, now = Date.now }) {
91
91
  const sealer = createTransactionSealer({ secret: config.sessionSecret, now });
92
- const secureCookies = config.isProduction;
93
- // Production sessions use a host-only __Host- cookie, like the other providers.
92
+ const secureCookies = config.isDeployed;
93
+ // Staging and production sessions use a host-only __Host- cookie, like the other providers.
94
94
  const sessionCookie = hostOnlyCookieName(SESSION_COOKIE, secureCookies);
95
95
  const appProfileProjection = profileProjector !== noAppProfiles;
96
- const devLoginEnabled = config.devAuth.enabled === true && config.devAuth.isProduction !== true;
96
+ const devLoginEnabled = config.devAuth.enabled === true && config.devAuth.isDeployed !== true;
97
97
  const capabilities = normalizeAuthCapabilities({
98
98
  provider: { id: AUTH_OIDC_PROVIDER_ID, label: config.label },
99
99
  features: {
@@ -162,7 +162,7 @@ function createOidcAuthService({ config, store, issuer, profileProjector, logger
162
162
  } catch {
163
163
  throw new AppError(400, "This request has no usable address.", { code: "auth.oidc.request.noAddress" });
164
164
  }
165
- if (origin.protocol === "http:" && !isLoopbackHostname(origin.hostname) && config.isProduction) {
165
+ if (origin.protocol === "http:" && !isLoopbackHostname(origin.hostname) && config.isDeployed) {
166
166
  throw new AppError(400, "Set APP_PUBLIC_URL so sign-in returns to this app's https address.", {
167
167
  code: "auth.oidc.request.publicUrlRequired"
168
168
  });
@@ -438,7 +438,10 @@ function createOidcAuthService({ config, store, issuer, profileProjector, logger
438
438
  replaceSecondFactorRecoveryCodes: unsupported("replaceSecondFactorRecoveryCodes"),
439
439
  removeSecondFactor: unsupported("removeSecondFactor"),
440
440
  listSecondFactors: unsupported("listSecondFactors"),
441
- resetSecondFactor: unsupported("resetSecondFactor")
441
+ resetSecondFactor: unsupported("resetSecondFactor"),
442
+ requestEmailChange: unsupported("requestEmailChange"),
443
+ requestEmailChangeForUser: unsupported("requestEmailChangeForUser"),
444
+ confirmEmailChange: unsupported("confirmEmailChange")
442
445
  });
443
446
  }
444
447
 
@@ -44,7 +44,7 @@ async function startApp(t, { env = {}, configureExtensions = () => {} } = {}) {
44
44
  "runtime.app-root": appRoot,
45
45
  "runtime.database": { knex },
46
46
  "runtime.env": {
47
- NODE_ENV: "test",
47
+ APP_ENV: "test",
48
48
  AUTH_OIDC_ISSUER: issuer.issuer,
49
49
  AUTH_OIDC_REGISTRATION_TOKEN: issuer.registrationToken,
50
50
  ...env
@@ -128,6 +128,9 @@ test("capabilities: one OIDC button, no password features, preview identity unch
128
128
  status: 501,
129
129
  code: "AUTH_OPERATION_UNSUPPORTED"
130
130
  });
131
+ // The identity provider owns the email; JSKIT does not change it.
132
+ assert.equal(features.emailChange, false);
133
+ assert.throws(() => authService.confirmEmailChange({ token: "link" }), { status: 501, code: "AUTH_OPERATION_UNSUPPORTED" });
131
134
  });
132
135
 
133
136
  test("auth-web's start and complete routes bind the attempt to the browser and return the page", async (t) => {
@@ -148,7 +148,7 @@ test("production sessions use a host-only __Host- cookie", async (t) => {
148
148
  const issuer = await startMockIssuer();
149
149
  const rp = await createRelyingParty({
150
150
  issuer,
151
- env: { NODE_ENV: "production", AUTH_OIDC_SESSION_SECRET: "fixture-oidc-session-secret-0123456789" }
151
+ env: { APP_ENV: "production", NODE_ENV: "production", AUTH_OIDC_SESSION_SECRET: "fixture-oidc-session-secret-0123456789" }
152
152
  });
153
153
  t.after(async () => {
154
154
  await rp.close();
@@ -82,7 +82,7 @@ async function createRelyingParty({ issuer, env = {}, fetchImpl = globalThis.fet
82
82
  const config = resolveOidcConfig({
83
83
  appRoot,
84
84
  env: {
85
- NODE_ENV: "development",
85
+ APP_ENV: "development",
86
86
  AUTH_OIDC_ISSUER: issuer.issuer,
87
87
  AUTH_OIDC_REGISTRATION_TOKEN: issuer.registrationToken,
88
88
  ...env