@madauth/server 0.4.0-beta.1 → 0.5.0-beta.2

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.
@@ -1,5 +1,5 @@
1
1
  import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2
- import { S as StoreAdapter } from '../schema-DTeiSuQB.js';
2
+ import { S as StoreAdapter } from '../schema-BTgDj1Xn.js';
3
3
 
4
4
  interface DynamoDbAdapterOptions {
5
5
  /** The table, with the partition key `pk` and the sort key `sk` (both strings). */
@@ -1,4 +1,4 @@
1
- import { S as StoreAdapter } from '../schema-DTeiSuQB.js';
1
+ import { S as StoreAdapter } from '../schema-BTgDj1Xn.js';
2
2
 
3
3
  /**
4
4
  * Stores madAuth's records in a SQLite file using Node's built-in `node:sqlite` (Node 22.13 or newer).
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StoreAdapter } from './schema-DTeiSuQB.js';
1
+ import { S as StoreAdapter } from './schema-BTgDj1Xn.js';
2
2
 
3
3
  /** The parts of a test runner the contract needs; Vitest, Jest and node:test with `expect` all fit. */
4
4
  interface ContractRunner {
package/dist/testing.js CHANGED
@@ -13,8 +13,10 @@ function testUser(overrides = {}) {
13
13
  name: null,
14
14
  sessionVersion: 0,
15
15
  lastMailAt: 0,
16
+ lastSmsAt: null,
16
17
  wrongCodes: 0,
17
18
  claims: null,
19
+ signedUpAt: null,
18
20
  createdAt: 17e11,
19
21
  ...overrides
20
22
  };
@@ -31,6 +33,9 @@ function testAccount(overrides = {}) {
31
33
  email: null,
32
34
  lastUsedStep: 0,
33
35
  setupId: null,
36
+ phone: null,
37
+ primaryUserId: null,
38
+ secondFactor: null,
34
39
  createdAt: 17e11,
35
40
  ...overrides
36
41
  };
@@ -117,6 +122,20 @@ function storeAdapterContract(t, createAdapter) {
117
122
  expect(await store.findOne("account", { key: account.key })).toEqual(account);
118
123
  expect(await store.findOne("account", { key: unique("password:missing") })).toBe(null);
119
124
  });
125
+ it("lets many records leave a unique field empty, but refuses a value that is taken", async () => {
126
+ const store = await createAdapter();
127
+ const userId = unique("usr_contract");
128
+ const first = testAccount({ userId, key: unique("totp:contract") });
129
+ const second = testAccount({ userId, key: unique("sms:contract") });
130
+ const primary = testAccount({ userId, primaryUserId: userId });
131
+ const another = testAccount({ userId, primaryUserId: userId });
132
+ expect(await store.create("account", first)).toBe(true);
133
+ expect(await store.create("account", second)).toBe(true);
134
+ expect(await store.create("account", primary)).toBe(true);
135
+ expect(await store.create("account", another)).toBe(false);
136
+ expect(await store.findOne("account", { primaryUserId: userId })).toEqual(primary);
137
+ expect(await store.findOne("account", { id: another.id })).toBe(null);
138
+ });
120
139
  it("sets a field to a value and to null", async () => {
121
140
  const store = await createAdapter();
122
141
  const user = testUser({ name: "Ada" });
@@ -8,8 +8,8 @@ interface MadauthUser {
8
8
  /** What admins attached to the user, e.g. `{ roles: ['admin'] }`. Absent without claims. */
9
9
  claims?: Record<string, unknown>;
10
10
  /**
11
- * How this session was authenticated (RFC 8176): `pwd` (password), `google`, `otp` (the authenticator
12
- * app, on its own or as the second factor), e.g. `['pwd', 'otp']`. Present on a user that comes with a session.
11
+ * How this session was authenticated (RFC 8176): `pwd` (password), `google`, `github`, `otp` (the
12
+ * authenticator app, on its own or as the second factor), e.g. `['pwd', 'otp']`. Present on a user that comes with a session.
13
13
  */
14
14
  amr?: string[];
15
15
  }
package/dist/verify.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JWTVerifyGetKey } from 'jose';
2
- import { M as MadauthUser } from './user-BZs84sui.js';
2
+ import { M as MadauthUser } from './user-yoGjrw4k.js';
3
3
 
4
4
  interface SessionVerifierOptions {
5
5
  /** The madAuth server's public base URL (its MADAUTH_ISSUER). */
@@ -1,5 +1,8 @@
1
- /** Every `type` madAuth sends. */
2
- declare const WEBHOOK_TYPES: readonly ["email.verify", "email.reset", "email.already_registered", "email.no_password", "signup.before", "user.created", "email.verified", "email.password_reset", "user.signed_in", "user.deleted", "user.claims_changed", "totp.enabled", "totp.disabled", "totp.recovery_code_used"];
1
+ /**
2
+ * Every `type` madAuth sends: `email.send_*` and `sms.send_*` hand over a message to send, `user.signing_up`
3
+ * asks whether someone may sign up, and the other `user.*` types tell what happened.
4
+ */
5
+ declare const WEBHOOK_TYPES: readonly ["email.send_verification", "email.send_password_reset", "email.send_signin_link", "email.send_already_registered", "email.send_password_reset_no_password", "sms.send_code", "user.signing_up", "user.signed_up", "user.email_verified", "user.password_reset", "user.signed_in", "user.deleted", "user.claims_changed", "user.second_factor_enabled", "user.second_factor_disabled", "user.recovery_code_used"];
3
6
  type WebhookType = (typeof WEBHOOK_TYPES)[number];
4
7
  /** How old a call may be before receivers reject it, so a captured call can't be replayed. */
5
8
  declare const WEBHOOK_TOLERANCE_SECONDS: number;
package/dist/webhook.d.ts CHANGED
@@ -1 +1 @@
1
- export { a as WEBHOOK_TOLERANCE_SECONDS, b as WEBHOOK_TYPES, c as WebhookType, g as generateWebhookSecret, s as signWebhook, v as verifyWebhook } from './webhook-B6P50ocX.js';
1
+ export { a as WEBHOOK_TOLERANCE_SECONDS, b as WEBHOOK_TYPES, c as WebhookType, g as generateWebhookSecret, s as signWebhook, v as verifyWebhook } from './webhook-DlmfG_kS.js';
package/dist/webhook.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  generateWebhookSecret,
5
5
  signWebhook,
6
6
  verifyWebhook
7
- } from "./chunk-Y7ZSUROX.js";
7
+ } from "./chunk-SISM7YUZ.js";
8
8
  export {
9
9
  WEBHOOK_TOLERANCE_SECONDS,
10
10
  WEBHOOK_TYPES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madauth/server",
3
- "version": "0.4.0-beta.1",
3
+ "version": "0.5.0-beta.2",
4
4
  "description": "madAuth server: Google, e-mail & password and authenticator-app sign-in with madAuth sessions, for Docker, AWS Lambda and Azure Functions.",
5
5
  "license": "MIT",
6
6
  "author": "David Neuy",
@@ -88,6 +88,8 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@hono/node-server": "^2.1.3",
91
+ "@zxcvbn-ts/core": "4.2.0",
92
+ "@zxcvbn-ts/language-common": "4.1.3",
91
93
  "hono": "^4.13.12",
92
94
  "jose": "^6.2.12"
93
95
  },