@remit/auth-service 0.0.15 → 0.0.16
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/package.json +7 -3
- package/src/auth.ts +3 -3
- package/src/config.ts +6 -3
- package/src/rate-limit-log.test.ts +5 -7
- package/src/rate-limit-log.ts +1 -1
- package/src/rate-limit.test.ts +1 -1
- package/src/schema/auth-schema-sqlite.ts +3 -1
- package/src/signup.test.ts +0 -20
- package/src/schema/meta-schema-sqlite.ts +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/auth-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "better-auth identity service for the self-host stack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"./verifier": {
|
|
18
18
|
"types": "./src/verifier.ts",
|
|
19
19
|
"default": "./src/verifier.ts"
|
|
20
|
+
},
|
|
21
|
+
"./schema": {
|
|
22
|
+
"types": "./src/schema/auth-schema-sqlite.ts",
|
|
23
|
+
"default": "./src/schema/auth-schema-sqlite.ts"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"scripts": {
|
|
@@ -29,8 +33,8 @@
|
|
|
29
33
|
"tsx": "*"
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@remit/logger
|
|
33
|
-
"better-auth": "^1.
|
|
36
|
+
"@remit/logger": "*",
|
|
37
|
+
"better-auth": "^1.7.12",
|
|
34
38
|
"better-sqlite3": "^12.11.1",
|
|
35
39
|
"drizzle-orm": "^0.45.2",
|
|
36
40
|
"jose": "^6.2.3",
|
package/src/auth.ts
CHANGED
|
@@ -6,9 +6,9 @@ import * as authSchemaSqlite from "./schema/auth-schema-sqlite.js";
|
|
|
6
6
|
|
|
7
7
|
export interface AuthConfig {
|
|
8
8
|
/**
|
|
9
|
-
* Path to the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Path to the app database file (#1420). The identity tables live beside
|
|
10
|
+
* the app tables and are driven through the drizzle adapter's `sqlite`
|
|
11
|
+
* provider.
|
|
12
12
|
*/
|
|
13
13
|
connectionString: string;
|
|
14
14
|
secret: string;
|
package/src/config.ts
CHANGED
|
@@ -34,11 +34,14 @@ export interface DataConnectionConfig {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Resolve where identity data lives, from the same env vars the rest of the
|
|
37
|
-
* self-host stack reads (RFC 036 D5). The identity tables
|
|
38
|
-
* database
|
|
37
|
+
* self-host stack reads (RFC 036 D5). The identity tables live in the app
|
|
38
|
+
* database, so the locator is `SQLITE_APP_DB_PATH`.
|
|
39
39
|
*/
|
|
40
40
|
export const resolveDataConnectionConfig = (): DataConnectionConfig => ({
|
|
41
|
-
connectionString: required(
|
|
41
|
+
connectionString: required(
|
|
42
|
+
"SQLITE_APP_DB_PATH",
|
|
43
|
+
process.env.SQLITE_APP_DB_PATH,
|
|
44
|
+
),
|
|
42
45
|
});
|
|
43
46
|
|
|
44
47
|
/**
|
|
@@ -15,16 +15,14 @@ import { CLIENT_IP_HEADER, createAuth } from "./auth.js";
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
process.env.LOG_LEVEL = "info";
|
|
18
|
-
process.env.REMIT_SERVICE_NAME = "auth-service-test";
|
|
19
18
|
|
|
20
19
|
const originalWrite = process.stdout.write.bind(process.stdout);
|
|
21
20
|
const written: string[] = [];
|
|
22
21
|
let capturing = false;
|
|
23
22
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// capturing, so the test runner's own output still reaches the terminal.
|
|
23
|
+
// The logger writes its lines through `process.stdout`. Writes pass through
|
|
24
|
+
// while nothing is capturing, so the test runner's own output still reaches
|
|
25
|
+
// the terminal.
|
|
28
26
|
process.stdout.write = ((
|
|
29
27
|
chunk: string | Uint8Array,
|
|
30
28
|
...rest: unknown[]
|
|
@@ -41,13 +39,13 @@ const { withRateLimitLogging } = await import("./rate-limit-log.js");
|
|
|
41
39
|
const SIGN_IN_MAX = 2;
|
|
42
40
|
const MIGRATIONS = resolve(
|
|
43
41
|
import.meta.dirname,
|
|
44
|
-
"../../../deploy/vps/migrations-sqlite/
|
|
42
|
+
"../../../deploy/vps/migrations-sqlite/app",
|
|
45
43
|
);
|
|
46
44
|
|
|
47
45
|
type Line = Record<string, unknown>;
|
|
48
46
|
|
|
49
47
|
// better-auth writes its own advisories through console, so the captured
|
|
50
|
-
// stream is not all
|
|
48
|
+
// stream is not all JSON; only the structured lines are of interest here.
|
|
51
49
|
const asJsonObject = (line: string): Line | null => {
|
|
52
50
|
try {
|
|
53
51
|
const parsed: unknown = JSON.parse(line);
|
package/src/rate-limit-log.ts
CHANGED
package/src/rate-limit.test.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { CLIENT_IP_HEADER, createAuth } from "./auth.js";
|
|
|
9
9
|
const SIGN_IN_MAX = 2;
|
|
10
10
|
const MIGRATIONS = resolve(
|
|
11
11
|
import.meta.dirname,
|
|
12
|
-
"../../../deploy/vps/migrations-sqlite/
|
|
12
|
+
"../../../deploy/vps/migrations-sqlite/app",
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
const createDatabase = async (dir: string, name: string): Promise<string> => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The five better-auth identity tables, in the shape better-auth's drizzle
|
|
2
2
|
// adapter emits with `provider: "sqlite"`. Used to generate the committed
|
|
3
|
-
// sqlite migrations (deploy/vps/migrations-sqlite/
|
|
3
|
+
// sqlite migrations (deploy/vps/migrations-sqlite/app).
|
|
4
4
|
//
|
|
5
5
|
// Hand-maintained, deliberately. The `@better-auth/cli generate` command no
|
|
6
6
|
// longer emits this shape: it writes `mode: "timestamp_ms"` where these columns
|
|
@@ -104,4 +104,6 @@ export const auth_jwks = sqliteTable("auth_jwks", {
|
|
|
104
104
|
privateKey: text("private_key").notNull(),
|
|
105
105
|
createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
|
|
106
106
|
expiresAt: integer("expires_at", { mode: "timestamp" }),
|
|
107
|
+
alg: text("alg"),
|
|
108
|
+
crv: text("crv"),
|
|
107
109
|
});
|
package/src/signup.test.ts
CHANGED
|
@@ -35,26 +35,6 @@ const baseConfig = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
describe("createAuth self-signup gate", () => {
|
|
38
|
-
it("flips better-auth disableSignUp from the selfSignUpEnabled flag", async () => {
|
|
39
|
-
const open = await createAuth({ ...baseConfig, selfSignUpEnabled: true });
|
|
40
|
-
const closed = await createAuth({
|
|
41
|
-
...baseConfig,
|
|
42
|
-
selfSignUpEnabled: false,
|
|
43
|
-
});
|
|
44
|
-
assert.equal(open.options.emailAndPassword?.disableSignUp, false);
|
|
45
|
-
assert.equal(closed.options.emailAndPassword?.disableSignUp, true);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("drives the sqlite drizzle provider", async () => {
|
|
49
|
-
const auth = await createAuth({
|
|
50
|
-
connectionString: ":memory:",
|
|
51
|
-
secret: baseConfig.secret,
|
|
52
|
-
baseURL: baseConfig.baseURL,
|
|
53
|
-
selfSignUpEnabled: true,
|
|
54
|
-
});
|
|
55
|
-
assert.equal(auth.options.emailAndPassword?.disableSignUp, false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
38
|
it("rejects a signup request server-side when disabled, before any DB access", async () => {
|
|
59
39
|
const auth = await createAuth({ ...baseConfig, selfSignUpEnabled: false });
|
|
60
40
|
const request = new Request(
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// The instance-owner singleton, used to generate the committed SQLite
|
|
2
|
-
// migrations (deploy/vps/migrations-sqlite/meta).
|
|
3
|
-
import { sql } from "drizzle-orm";
|
|
4
|
-
import { check, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
5
|
-
|
|
6
|
-
export const instance_owner = sqliteTable(
|
|
7
|
-
"instance_owner",
|
|
8
|
-
{
|
|
9
|
-
id: integer("id").primaryKey().default(1),
|
|
10
|
-
userId: text("user_id").notNull(),
|
|
11
|
-
claimedAt: integer("claimed_at", { mode: "timestamp" })
|
|
12
|
-
.$defaultFn(() => /* @__PURE__ */ new Date())
|
|
13
|
-
.notNull(),
|
|
14
|
-
},
|
|
15
|
-
(table) => [check("instance_owner_singleton", sql`${table.id} = 1`)],
|
|
16
|
-
);
|