@jskit-ai/auth-provider-local-db-core 0.1.200 → 0.1.202

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
+ - The users repository answers `findAllByEmail(email)`, every account with the email: one or none, since the users table's email is unique. Local auth's service keys act as a user by email through it.
5
6
  - The migration `auth_local_db_sign_in_facts` adds nullable `sign_in_ip` and `sign_in_user_agent` columns to `auth_local_sessions` (where a session was signed in from, written once at its creation) and nullable `password_changed_at` and `email_changed_at` timestamps to `auth_local_users` (set by `updatePassword`, a reset or a change, and by a used email-change link). Run `npm run db:migrate`. Rows from before it keep null: their sessions answer no sign-in address or browser, so an action that asks for them makes their people sign in again. The owner APIs carry them: `auth.local.sessions.create` takes `signInIp` and `signInUserAgent`, sessions answer them, accounts answer `passwordChangedAt` and `emailChangedAt`, and `auth.local.accounts.updatePassword` sets `passwordChangedAt`.
6
7
  - The migration `auth_local_db_oauth_invitation` adds a nullable `invitation_token` text column to `auth_local_oauth_attempts`, where a provider sign-in started from an invitation keeps its token until the sign-in ends. Run `npm run db:migrate`.
7
8
  - Each table migration has a companion that Knex runs just before it, `auth_local_db_initial-collation`, `auth_local_db_oauth-collation`, `auth_local_db_protection-collation`, `auth_local_db_used_passes-collation` and `auth_local_db_users_second_factors-collation` (run `npm run db:migrate`): on MySQL and MariaDB each creates its migration's tables in the collation of `auth_local_users` (or `users`), not the database's default. On a database whose default differs from its tables', `auth_local_db_users_second_factors` failed (errno 150) and left an empty, unrecorded `auth_local_second_factors`, after recording `auth_local_used_passes` in the database's default; the next migrate creates the first again with its key to `auth_local_users`, converts the second keeping its rows, and adds the key a second try recorded without. A database whose tables match its default changes nothing. No released migration changed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-provider-local-db-core",
3
- "version": "0.1.200",
3
+ "version": "0.1.202",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -11,14 +11,14 @@
11
11
  "./server/types": "./src/server/types.js"
12
12
  },
13
13
  "dependencies": {
14
- "@jskit-ai/auth-provider-local-core": "0.2.44",
15
- "@jskit-ai/resource-core": "0.1.224"
14
+ "@jskit-ai/auth-provider-local-core": "0.2.45",
15
+ "@jskit-ai/resource-core": "0.1.225"
16
16
  },
17
17
  "peerDependencies": {
18
- "@jskit-ai/auth-core": "0.2.38",
19
- "@jskit-ai/database-runtime": "0.1.283",
20
- "@jskit-ai/kernel": "0.2.33",
21
- "@jskit-ai/resource-runtime": "0.2.47"
18
+ "@jskit-ai/auth-core": "0.2.39",
19
+ "@jskit-ai/database-runtime": "0.1.285",
20
+ "@jskit-ai/kernel": "0.2.34",
21
+ "@jskit-ai/resource-runtime": "0.2.49"
22
22
  },
23
23
  "description": "Database-backed local auth storage backend for JSKIT local auth.",
24
24
  "jskit": {
@@ -292,6 +292,11 @@ function userRecords(users, options) {
292
292
  async findByEmail(email) {
293
293
  return mapUser(await findOne(users, "email", email, options));
294
294
  },
295
+ // The table's unique email keeps one account per email.
296
+ async findAllByEmail(email) {
297
+ const user = mapUser(await findOne(users, "email", email, options));
298
+ return user ? [user] : [];
299
+ },
295
300
  async hasAny() {
296
301
  return (await users.query({ page: { size: 1 } }, options)).records.length > 0;
297
302
  },
@@ -93,6 +93,8 @@ test("accounts: create answers the account it wrote, reads find it by id and ema
93
93
  assert.equal(await tx.users.findById(null), null);
94
94
  assert.equal(await tx.users.findByEmail("nobody@example.com"), null);
95
95
  assert.equal(await tx.users.findByEmail(""), null);
96
+ assert.deepEqual(await tx.users.findAllByEmail("ADA@Example.com"), [read], "the unique email answers one account");
97
+ assert.deepEqual(await tx.users.findAllByEmail("nobody@example.com"), []);
96
98
  });
97
99
 
98
100
  const taken = (error) => {