@madauth/server 0.3.0-beta.1 → 0.4.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 +104 -42
- package/dist/chunk-3PACOYTG.js +1185 -0
- package/dist/{chunk-DCDTO5LG.js → chunk-A7UYZRBL.js} +1 -0
- package/dist/{chunk-CD7Y4T66.js → chunk-GA4TF7EI.js} +24 -2
- package/dist/{chunk-ODITZLMM.js → chunk-ISJGOCF3.js} +258 -84
- package/dist/{chunk-56MOVFO4.js → chunk-OMIX3ERC.js} +11 -2
- package/dist/{chunk-NPNM26J3.js → chunk-Y7ZSUROX.js} +5 -1
- package/dist/{config-DEBYi8hb.d.ts → config-DkE_2D3-.d.ts} +5 -2
- 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 +29 -14
- package/dist/index.js +10 -6
- package/dist/{schema-3yhCc2jH.d.ts → schema-DTeiSuQB.d.ts} +39 -2
- package/dist/sqlite.js +2 -2
- package/dist/standalone/azure.mjs +1331 -676
- package/dist/standalone/lambda.mjs +1319 -664
- package/dist/standalone/main.mjs +1191 -536
- 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 +2 -0
- package/dist/{user-BMWEWREH.d.ts → user-BZs84sui.d.ts} +5 -0
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +1 -1
- package/dist/{webhook-DCDP6SaE.d.ts → webhook-B6P50ocX.d.ts} +1 -1
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-ZSBKNV5W.js +0 -713
package/dist/entry/node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as EntryOptions } from '../config-
|
|
1
|
+
import { E as EntryOptions } from '../config-DkE_2D3-.js';
|
|
2
2
|
import 'jose';
|
|
3
|
-
import '../schema-
|
|
4
|
-
import '../webhook-
|
|
3
|
+
import '../schema-DTeiSuQB.js';
|
|
4
|
+
import '../webhook-B6P50ocX.js';
|
|
5
5
|
|
|
6
6
|
type StartOptions = EntryOptions;
|
|
7
7
|
/**
|
package/dist/entry/node.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createApp
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-3PACOYTG.js";
|
|
4
|
+
import "../chunk-A7UYZRBL.js";
|
|
5
5
|
import {
|
|
6
6
|
loadConfig,
|
|
7
7
|
resolveEnv
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-ISJGOCF3.js";
|
|
9
9
|
import "../chunk-JDQLSL36.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-Y7ZSUROX.js";
|
|
11
11
|
|
|
12
12
|
// src/entry/node.ts
|
|
13
13
|
import { serve } from "@hono/node-server";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { M as MadauthConfig } from './config-
|
|
3
|
-
export { C as ConfigError, a as ConfigOverrides, E as EntryOptions, e as envVars, l as loadConfig } from './config-
|
|
2
|
+
import { M as MadauthConfig } from './config-DkE_2D3-.js';
|
|
3
|
+
export { C as ConfigError, a as ConfigOverrides, E as EntryOptions, e as envVars, l as loadConfig } from './config-DkE_2D3-.js';
|
|
4
4
|
import { JWK } from 'jose';
|
|
5
|
-
import { a as Schema } from './schema-
|
|
6
|
-
export { F as FieldDef, b as FieldType, R as Row, S as StoreAdapter, V as Value, W as Where, m as madauthSchema } from './schema-
|
|
7
|
-
export { M as MadauthUser } from './user-
|
|
8
|
-
import './webhook-
|
|
5
|
+
import { a as Schema } from './schema-DTeiSuQB.js';
|
|
6
|
+
export { F as FieldDef, b as FieldType, R as Row, S as StoreAdapter, V as Value, W as Where, m as madauthSchema } from './schema-DTeiSuQB.js';
|
|
7
|
+
export { M as MadauthUser } from './user-BZs84sui.js';
|
|
8
|
+
import './webhook-B6P50ocX.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The primary sign-in methods madAuth has: Google, e-mail & password, and the authenticator app on its own
|
|
12
|
+
* (the e-mail address and a code from the app).
|
|
13
|
+
*/
|
|
14
|
+
declare const SIGN_IN_METHODS: readonly ["google", "password", "totp"];
|
|
15
|
+
type SignInMethod = (typeof SIGN_IN_METHODS)[number];
|
|
16
|
+
/** The methods that can ask for a code from the authenticator app after they succeeded. */
|
|
17
|
+
declare const METHODS_WITH_SECOND_FACTOR: readonly ["google", "password"];
|
|
18
|
+
/**
|
|
19
|
+
* Whether a method asks for the authenticator app as a second factor: never, when the user has set one up
|
|
20
|
+
* (`optional`), or always, so that a user without one sets it up at the next sign-in (`required`).
|
|
21
|
+
*/
|
|
22
|
+
declare const SECOND_FACTOR_POLICIES: readonly ["none", "optional", "required"];
|
|
23
|
+
type SecondFactorPolicy = (typeof SECOND_FACTOR_POLICIES)[number];
|
|
24
|
+
/** The settings of a method that is on. `secondFactor` is for Google and password; it defaults to `none`. */
|
|
25
|
+
interface MethodSetting {
|
|
26
|
+
secondFactor?: SecondFactorPolicy;
|
|
27
|
+
}
|
|
28
|
+
/** The sign-in methods that are on, each with its settings. A method that is not listed is off. */
|
|
29
|
+
type MethodSettings = Partial<Record<SignInMethod, MethodSetting>>;
|
|
9
30
|
|
|
10
31
|
/** Creates a new private ES256 JWK for MADAUTH_SIGNING_KEY. */
|
|
11
32
|
declare function generateSigningKey(): Promise<JWK>;
|
|
12
33
|
|
|
13
|
-
/** The sign-in methods madAuth has. */
|
|
14
|
-
declare const SIGN_IN_METHODS: readonly ["google", "password"];
|
|
15
|
-
type SignInMethod = (typeof SIGN_IN_METHODS)[number];
|
|
16
|
-
/** Which sign-in methods are on. A method that is not mentioned is on. */
|
|
17
|
-
type MethodSettings = Partial<Record<SignInMethod, boolean>>;
|
|
18
|
-
|
|
19
34
|
/** Hash parameter that carries a sign-in error back to the app after the code flow. */
|
|
20
35
|
declare const REDIRECT_ERROR_PARAM = "madauth_error";
|
|
21
36
|
|
|
@@ -25,7 +40,7 @@ declare const REDIRECT_ERROR_PARAM = "madauth_error";
|
|
|
25
40
|
*/
|
|
26
41
|
declare function createApp(config: MadauthConfig): Hono;
|
|
27
42
|
|
|
28
|
-
/** The SQL table that holds a model, e.g. `madauth_user`. */
|
|
43
|
+
/** The SQL table that holds a model, e.g. `madauth_user`, or `madauth_recovery_code` for `recoveryCode`. */
|
|
29
44
|
declare function tableName(model: string): string;
|
|
30
45
|
/** The SQL column that holds a field, e.g. `email_normalized` for `emailNormalized`. */
|
|
31
46
|
declare function columnName(field: string): string;
|
|
@@ -55,4 +70,4 @@ declare function parseRoles(input: unknown): string[] | null;
|
|
|
55
70
|
*/
|
|
56
71
|
declare function parseClaims(input: unknown): Claims | null;
|
|
57
72
|
|
|
58
|
-
export { ADMIN_ROLE, type Claims, MadauthConfig, type MethodSettings, REDIRECT_ERROR_PARAM, SIGN_IN_METHODS, Schema, type SignInMethod, type SqlDialect, columnName, createApp, createTablesSql, generateSigningKey, parseClaims, parseRoles, tableName, upgradeTablesSql };
|
|
73
|
+
export { ADMIN_ROLE, type Claims, METHODS_WITH_SECOND_FACTOR, MadauthConfig, type MethodSetting, type MethodSettings, REDIRECT_ERROR_PARAM, SECOND_FACTOR_POLICIES, SIGN_IN_METHODS, Schema, type SecondFactorPolicy, type SignInMethod, type SqlDialect, columnName, createApp, createTablesSql, generateSigningKey, parseClaims, parseRoles, tableName, upgradeTablesSql };
|
package/dist/index.js
CHANGED
|
@@ -3,32 +3,36 @@ import {
|
|
|
3
3
|
createTablesSql,
|
|
4
4
|
tableName,
|
|
5
5
|
upgradeTablesSql
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMIX3ERC.js";
|
|
7
7
|
import {
|
|
8
8
|
madauthSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GA4TF7EI.js";
|
|
10
10
|
import {
|
|
11
11
|
REDIRECT_ERROR_PARAM,
|
|
12
12
|
createApp
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-3PACOYTG.js";
|
|
14
|
+
import "./chunk-A7UYZRBL.js";
|
|
15
15
|
import {
|
|
16
16
|
ADMIN_ROLE,
|
|
17
17
|
ConfigError,
|
|
18
|
+
METHODS_WITH_SECOND_FACTOR,
|
|
19
|
+
SECOND_FACTOR_POLICIES,
|
|
18
20
|
SIGN_IN_METHODS,
|
|
19
21
|
envVars,
|
|
20
22
|
loadConfig,
|
|
21
23
|
parseClaims,
|
|
22
24
|
parseRoles
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ISJGOCF3.js";
|
|
24
26
|
import {
|
|
25
27
|
generateSigningKey
|
|
26
28
|
} from "./chunk-JDQLSL36.js";
|
|
27
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-Y7ZSUROX.js";
|
|
28
30
|
export {
|
|
29
31
|
ADMIN_ROLE,
|
|
30
32
|
ConfigError,
|
|
33
|
+
METHODS_WITH_SECOND_FACTOR,
|
|
31
34
|
REDIRECT_ERROR_PARAM,
|
|
35
|
+
SECOND_FACTOR_POLICIES,
|
|
32
36
|
SIGN_IN_METHODS,
|
|
33
37
|
columnName,
|
|
34
38
|
createApp,
|
|
@@ -43,7 +43,7 @@ interface Schema {
|
|
|
43
43
|
}
|
|
44
44
|
/** The records madAuth stores. Timestamps are milliseconds since 1970. */
|
|
45
45
|
declare const madauthSchema: {
|
|
46
|
-
readonly version:
|
|
46
|
+
readonly version: 5;
|
|
47
47
|
readonly models: {
|
|
48
48
|
/** Someone who signed in, whichever way: the e-mail address is the identity shared by the sign-in methods. */
|
|
49
49
|
readonly user: {
|
|
@@ -86,7 +86,10 @@ declare const madauthSchema: {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* How a user signs in. `key` is `password:<userId>`, `google:<sub>` or `totp:<userId>` (the authenticator
|
|
91
|
+
* app, whose `secret` is encrypted).
|
|
92
|
+
*/
|
|
90
93
|
readonly account: {
|
|
91
94
|
readonly fields: {
|
|
92
95
|
readonly id: {
|
|
@@ -116,6 +119,40 @@ declare const madauthSchema: {
|
|
|
116
119
|
readonly type: "string";
|
|
117
120
|
readonly nullable: true;
|
|
118
121
|
};
|
|
122
|
+
/** The time step of the last authenticator code that was accepted, so a code works once; 0 before (since version 5). */
|
|
123
|
+
readonly lastUsedStep: {
|
|
124
|
+
readonly type: "number";
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The setup an authenticator secret came from; its recovery codes carry the same id, so the app and
|
|
128
|
+
* its codes always belong together. Empty for other accounts (since version 5).
|
|
129
|
+
*/
|
|
130
|
+
readonly setupId: {
|
|
131
|
+
readonly type: "string";
|
|
132
|
+
readonly nullable: true;
|
|
133
|
+
};
|
|
134
|
+
readonly createdAt: {
|
|
135
|
+
readonly type: "number";
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* A recovery code of a user's authenticator app (since version 5). `id` is the code's keyed hash; the
|
|
141
|
+
* record goes when the code is used. It works only while the account's `setupId` is its own.
|
|
142
|
+
*/
|
|
143
|
+
readonly recoveryCode: {
|
|
144
|
+
readonly fields: {
|
|
145
|
+
readonly id: {
|
|
146
|
+
readonly type: "string";
|
|
147
|
+
readonly primaryKey: true;
|
|
148
|
+
};
|
|
149
|
+
readonly userId: {
|
|
150
|
+
readonly type: "string";
|
|
151
|
+
readonly index: true;
|
|
152
|
+
};
|
|
153
|
+
readonly setupId: {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
};
|
|
119
156
|
readonly createdAt: {
|
|
120
157
|
readonly type: "number";
|
|
121
158
|
};
|
package/dist/sqlite.js
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
createTablesSql,
|
|
4
4
|
tableName,
|
|
5
5
|
upgradeTablesSql
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMIX3ERC.js";
|
|
7
7
|
import {
|
|
8
8
|
madauthSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GA4TF7EI.js";
|
|
10
10
|
|
|
11
11
|
// src/store/sqlite.ts
|
|
12
12
|
function createSqliteAdapter(path) {
|