@madauth/server 0.3.0-beta.2 → 0.5.0-beta.1
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/README.md +3 -2
- package/dist/bin.js +202 -50
- package/dist/chunk-7DHKDRGY.js +1706 -0
- package/dist/{chunk-DCDTO5LG.js → chunk-A7UYZRBL.js} +1 -0
- package/dist/chunk-NP75Y3IV.js +107 -0
- package/dist/chunk-NYIEFI4B.js +1040 -0
- package/dist/{chunk-56MOVFO4.js → chunk-O2URPWA6.js} +37 -4
- package/dist/{chunk-3QRKWLR7.js → chunk-SISM7YUZ.js} +15 -10
- package/dist/{config-Dg2fZuWR.d.ts → config-CcGlHVAN.d.ts} +19 -8
- package/dist/dynamodb.js +1 -1
- package/dist/entry/azure.d.ts +3 -3
- package/dist/entry/azure.js +4 -4
- package/dist/entry/lambda.d.ts +3 -3
- package/dist/entry/lambda.js +4 -4
- package/dist/entry/node.d.ts +3 -3
- package/dist/entry/node.js +4 -4
- package/dist/index.d.ts +37 -15
- package/dist/index.js +12 -6
- package/dist/{schema-3yhCc2jH.d.ts → schema-BTgDj1Xn.d.ts} +79 -3
- package/dist/sqlite.js +2 -2
- package/dist/standalone/azure.mjs +5511 -922
- package/dist/standalone/lambda.mjs +5461 -872
- package/dist/standalone/main.mjs +5487 -898
- package/dist/store/dynamodb.d.ts +1 -1
- package/dist/store/sqlite.d.ts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +21 -0
- package/dist/{user-BMWEWREH.d.ts → user-yoGjrw4k.d.ts} +5 -0
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +1 -1
- package/dist/{webhook-j5u9Kv9l.d.ts → webhook-DlmfG_kS.d.ts} +5 -2
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +1 -1
- package/package.json +4 -2
- package/dist/chunk-CD7Y4T66.js +0 -62
- package/dist/chunk-DVVBIFIV.js +0 -718
- package/dist/chunk-TI35AZ2U.js +0 -660
package/dist/store/dynamodb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
2
|
-
import { S as StoreAdapter } from '../schema-
|
|
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). */
|
package/dist/store/sqlite.d.ts
CHANGED
package/dist/testing.d.ts
CHANGED
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
|
};
|
|
@@ -29,6 +31,11 @@ function testAccount(overrides = {}) {
|
|
|
29
31
|
failedAttempts: 0,
|
|
30
32
|
lockedUntil: 0,
|
|
31
33
|
email: null,
|
|
34
|
+
lastUsedStep: 0,
|
|
35
|
+
setupId: null,
|
|
36
|
+
phone: null,
|
|
37
|
+
primaryUserId: null,
|
|
38
|
+
secondFactor: null,
|
|
32
39
|
createdAt: 17e11,
|
|
33
40
|
...overrides
|
|
34
41
|
};
|
|
@@ -115,6 +122,20 @@ function storeAdapterContract(t, createAdapter) {
|
|
|
115
122
|
expect(await store.findOne("account", { key: account.key })).toEqual(account);
|
|
116
123
|
expect(await store.findOne("account", { key: unique("password:missing") })).toBe(null);
|
|
117
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
|
+
});
|
|
118
139
|
it("sets a field to a value and to null", async () => {
|
|
119
140
|
const store = await createAdapter();
|
|
120
141
|
const user = testUser({ name: "Ada" });
|
|
@@ -7,6 +7,11 @@ interface MadauthUser {
|
|
|
7
7
|
picture?: string;
|
|
8
8
|
/** What admins attached to the user, e.g. `{ roles: ['admin'] }`. Absent without claims. */
|
|
9
9
|
claims?: Record<string, unknown>;
|
|
10
|
+
/**
|
|
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
|
+
*/
|
|
14
|
+
amr?: string[];
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
export type { MadauthUser as M };
|
package/dist/verify.d.ts
CHANGED
package/dist/verify.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
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-
|
|
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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madauth/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "madAuth server: Google
|
|
3
|
+
"version": "0.5.0-beta.1",
|
|
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",
|
|
7
7
|
"homepage": "https://github.com/inouiw/madAuth#readme",
|
|
@@ -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
|
},
|
package/dist/chunk-CD7Y4T66.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// src/store/schema.ts
|
|
2
|
-
var madauthSchema = {
|
|
3
|
-
version: 4,
|
|
4
|
-
models: {
|
|
5
|
-
/** Someone who signed in, whichever way: the e-mail address is the identity shared by the sign-in methods. */
|
|
6
|
-
user: {
|
|
7
|
-
fields: {
|
|
8
|
-
id: { type: "string", primaryKey: true },
|
|
9
|
-
email: { type: "string" },
|
|
10
|
-
emailNormalized: { type: "string", unique: true },
|
|
11
|
-
emailVerified: { type: "boolean" },
|
|
12
|
-
name: { type: "string", nullable: true },
|
|
13
|
-
sessionVersion: { type: "number" },
|
|
14
|
-
lastMailAt: { type: "number" },
|
|
15
|
-
/** Wrong e-mail codes in a row, counted across e-mails (since version 2). */
|
|
16
|
-
wrongCodes: { type: "number" },
|
|
17
|
-
/** What admins attached to the user, as JSON, e.g. `{"roles":["admin"]}` (since version 4). */
|
|
18
|
-
claims: { type: "string", nullable: true },
|
|
19
|
-
createdAt: { type: "number" }
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
/** How a user signs in. `key` is `password:<userId>` or `google:<sub>`; later e.g. `totp:<userId>`. */
|
|
23
|
-
account: {
|
|
24
|
-
fields: {
|
|
25
|
-
id: { type: "string", primaryKey: true },
|
|
26
|
-
userId: { type: "string", index: true },
|
|
27
|
-
key: { type: "string", unique: true },
|
|
28
|
-
secret: { type: "string", nullable: true },
|
|
29
|
-
failedAttempts: { type: "number" },
|
|
30
|
-
lockedUntil: { type: "number" },
|
|
31
|
-
/** The address the provider reported at the last sign-in, e.g. Google's current primary address (since version 4). */
|
|
32
|
-
email: { type: "string", nullable: true },
|
|
33
|
-
createdAt: { type: "number" }
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
/** A pending e-mail verification or password reset. `id` is the SHA-256 of the link token. */
|
|
37
|
-
verification: {
|
|
38
|
-
fields: {
|
|
39
|
-
id: { type: "string", primaryKey: true },
|
|
40
|
-
userId: { type: "string", index: true },
|
|
41
|
-
purpose: { type: "string" },
|
|
42
|
-
codeHash: { type: "string" },
|
|
43
|
-
attempts: { type: "number" },
|
|
44
|
-
expiresAt: { type: "number" }
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
/** A setting admins change at runtime, as JSON (since version 4), e.g. `methods`: which sign-in methods are on. */
|
|
48
|
-
setting: {
|
|
49
|
-
fields: {
|
|
50
|
-
id: { type: "string", primaryKey: true },
|
|
51
|
-
value: { type: "string" },
|
|
52
|
-
updatedAt: { type: "number" },
|
|
53
|
-
/** The address of the admin who set it; empty when set from the command line. */
|
|
54
|
-
updatedBy: { type: "string", nullable: true }
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
madauthSchema
|
|
62
|
-
};
|