@jskit-ai/auth-provider-local-core 0.2.33 → 0.2.34

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 pass comes from `@jskit-ai/auth-pass/server`, a new dependency, instead of auth-core's removed `./server/passSignIn`; `AuthLocalPassIdentity` takes auth-pass's `AuthPass`. Pass sign-in behaves as before, with the same refusals and texts.
6
+
5
7
  - One-time pass sign-in: with `AUTH_PASS_PUBLIC_KEY`, `AUTH_PASS_AUDIENCE` and `AUTH_PASS_RESOURCE` set, `signInWithPass({ pass })` checks a pass from `@jskit-ai/auth-core/server/passSignIn`, records it as used, and signs in the account the new `auth.local.pass-identity` capability names for it (`AuthLocalPassIdentity`, also `createLocalAuthService({ passIdentity })`); startup stops when the key is set and no mapping is installed. Each pass signs in once: the backend contract gains `passes.use({ id, expiresAt })` and `passes.deleteExpired(now)`, keyed by the hash of the pass's id and kept until 30 seconds after it expires, and the file backend keeps them in `passes.passwd`. Without the key, `signInWithPass` is refused as unsupported and nothing else changes.
6
8
  - A dev sign-in (`devLoginAs`), a password sign-in, a recovery link's sign-in and a display-name change hold one database connection at a time. Each read or synchronized the application's profile inside local auth's transaction, and the profile projector (users-core's) reads and writes on a connection of its own, so one request held two pool connections, and as many such requests at once as the pool has connections each held one and waited for ever for another. The profile is now read or synchronized after local auth's transaction, as registration, OAuth sign-in and email confirmation already did; a dev sign-in finds its user in one transaction, reads the profile, and only then creates its session in another, so a user without a profile still gets none. Should synchronizing the profile fail after a sign-in's transaction committed, the sign-in still fails and its session is never handed out (it expires), as for a registration; a recovery link is then used up, and a changed display name stays changed until the next request's profile check synchronizes it.
7
9
  - `AUTH_COOKIE_SAME_SITE=strict` makes every local auth cookie SameSite=Strict, and its clearing: the access, refresh, recovery and OAuth attempt cookies. Unset, blank or `lax` keeps them Lax, as before; any other value stops startup, naming the setting. OAuth sign-in works under `strict`: the provider's cross-site return only loads the login page, and the attempt cookie is read by that page's same-origin `POST /api/oauth/complete`. `resolveLocalAuthConfig()` returns `cookieSameSite`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-provider-local-core",
3
- "version": "0.2.33",
3
+ "version": "0.2.34",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -12,6 +12,7 @@
12
12
  "./locales/en.json": "./locales/en.json"
13
13
  },
14
14
  "dependencies": {
15
+ "@jskit-ai/auth-pass": "0.1.0",
15
16
  "openid-client": "6.8.8"
16
17
  },
17
18
  "description": "Local auth provider with a file backend default, no database requirement, and optional Google, Microsoft and GitHub sign-in.",
@@ -70,7 +71,7 @@
70
71
  }
71
72
  },
72
73
  "peerDependencies": {
73
- "@jskit-ai/auth-core": "0.2.28",
74
+ "@jskit-ai/auth-core": "0.2.29",
74
75
  "@jskit-ai/kernel": "0.2.26"
75
76
  }
76
77
  }
@@ -1,6 +1,6 @@
1
1
  import { parseBooleanFlag } from "@jskit-ai/auth-core/server/booleanFlag";
2
2
  import { assertDevAuthPolicy, resolveDevAuthPolicyFromEnv } from "@jskit-ai/auth-core/server/devAuth";
3
- import { resolvePassSignInFromEnv } from "@jskit-ai/auth-core/server/passSignIn";
3
+ import { resolvePassSignInFromEnv } from "@jskit-ai/auth-pass/server";
4
4
  import { randomBytes } from "node:crypto";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
@@ -1,5 +1,4 @@
1
- import { AUTH_TEXTS, createAuthError } from "@jskit-ai/auth-core/server/authTexts";
2
- import { verifyPass } from "@jskit-ai/auth-core/server/passSignIn";
1
+ import { PASS_TEXTS, createPassError, verifyPass } from "@jskit-ai/auth-pass/server";
3
2
  import { buildAuthPayload } from "./authPayloads.js";
4
3
  import { sha256Base64url } from "./tokens.js";
5
4
 
@@ -13,7 +12,7 @@ async function noPassIdentities() {
13
12
  }
14
13
 
15
14
  /**
16
- * Sign-in with a one-time signed pass (`@jskit-ai/auth-core/server/passSignIn`), for a configuration whose passSignIn
15
+ * Sign-in with a one-time signed pass (`@jskit-ai/auth-pass/server`), for a configuration whose passSignIn
17
16
  * holds the issuer's key, audience and resource. A pass is checked, then recorded as used in the backend, so it signs
18
17
  * in once however many servers share the backend's database, and then the application's pass identity names the
19
18
  * account it signs in: one that is missing or disabled is refused as unmapped. The session is an ordinary one, as a
@@ -39,12 +38,12 @@ function createLocalPassSignIn({ backend, config, passIdentity, profileProjector
39
38
  const firstUse = await backend.withTransaction((tx) =>
40
39
  tx.passes.use({ id: sha256Base64url(pass.id), expiresAt: pass.usableUntil }));
41
40
  if (!firstUse) {
42
- throw createAuthError(AUTH_TEXTS.passReplayed);
41
+ throw createPassError(PASS_TEXTS.passReplayed);
43
42
  }
44
43
  const userId = await passIdentity(pass);
45
44
  const user = userId ? await backend.withTransaction((tx) => tx.users.findById(userId)) : null;
46
45
  if (!user || user.disabled) {
47
- throw createAuthError(AUTH_TEXTS.passUnmapped);
46
+ throw createPassError(PASS_TEXTS.passUnmapped);
48
47
  }
49
48
  const session = await backend.withTransaction((tx) => sessions.createSessionForUser(tx, user));
50
49
  // After the transaction, as a password sign-in does: the profile projector works in transactions of its own.
@@ -78,9 +78,9 @@
78
78
 
79
79
  /**
80
80
  * The `auth.local.pass-identity` capability: the application's mapping from a verified one-time pass
81
- * (`@jskit-ai/auth-core/server/passSignIn`) to the local account it signs in, by the account's id, or null when the
81
+ * (`@jskit-ai/auth-pass/server`) to the local account it signs in, by the account's id, or null when the
82
82
  * pass's subject has none, which refuses the pass as unmapped. Required while AUTH_PASS_PUBLIC_KEY is set.
83
- * @typedef {(pass: import("@jskit-ai/auth-core/server/passSignIn").AuthPass) => Promise<string | null>} AuthLocalPassIdentity
83
+ * @typedef {(pass: import("@jskit-ai/auth-pass/server").AuthPass) => Promise<string | null>} AuthLocalPassIdentity
84
84
  */
85
85
 
86
86
  /**
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { generateKeyPairSync } from "node:crypto";
3
- import { signPass } from "@jskit-ai/auth-core/server/passSignIn";
3
+ import { signPass } from "@jskit-ai/auth-pass/server";
4
4
  import { NO_PASSWORD } from "../src/server/lib/accounts.js";
5
5
 
6
6
  /**