@shipfox/api-auth 4.0.0 → 6.0.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +75 -0
- package/README.md +71 -37
- package/dist/config.d.ts +0 -12
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -62
- package/dist/config.js.map +1 -1
- package/dist/core/auth.d.ts +21 -2
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js +109 -77
- package/dist/core/auth.js.map +1 -1
- package/dist/core/email-owner.d.ts +12 -0
- package/dist/core/email-owner.d.ts.map +1 -0
- package/dist/core/email-owner.js +20 -0
- package/dist/core/email-owner.js.map +1 -0
- package/dist/core/job-lease-token.d.ts.map +1 -1
- package/dist/core/job-lease-token.js +3 -2
- package/dist/core/job-lease-token.js.map +1 -1
- package/dist/core/jwt.d.ts +2 -2
- package/dist/core/jwt.d.ts.map +1 -1
- package/dist/core/jwt.js.map +1 -1
- package/dist/core/rate-limit.d.ts.map +1 -1
- package/dist/core/rate-limit.js +2 -7
- package/dist/core/rate-limit.js.map +1 -1
- package/dist/core/runner-session-token.d.ts.map +1 -1
- package/dist/core/runner-session-token.js +3 -2
- package/dist/core/runner-session-token.js.map +1 -1
- package/dist/db/db.d.ts +0 -218
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +0 -2
- package/dist/db/db.js.map +1 -1
- package/dist/db/users.d.ts +3 -0
- package/dist/db/users.d.ts.map +1 -1
- package/dist/db/users.js +28 -10
- package/dist/db/users.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -34
- package/dist/index.js.map +1 -1
- package/dist/presentation/auth/jwt-auth.d.ts.map +1 -1
- package/dist/presentation/auth/jwt-auth.js +2 -2
- package/dist/presentation/auth/jwt-auth.js.map +1 -1
- package/dist/presentation/e2eRoutes/create-session.d.ts +2 -1
- package/dist/presentation/e2eRoutes/create-session.d.ts.map +1 -1
- package/dist/presentation/e2eRoutes/create-session.js +42 -39
- package/dist/presentation/e2eRoutes/create-session.js.map +1 -1
- package/dist/presentation/e2eRoutes/index.d.ts +2 -1
- package/dist/presentation/e2eRoutes/index.d.ts.map +1 -1
- package/dist/presentation/e2eRoutes/index.js +12 -10
- package/dist/presentation/e2eRoutes/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +4 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +16 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/email-verification/verify-email-confirm.d.ts +2 -1
- package/dist/presentation/routes/email-verification/verify-email-confirm.d.ts.map +1 -1
- package/dist/presentation/routes/email-verification/verify-email-confirm.js +36 -25
- package/dist/presentation/routes/email-verification/verify-email-confirm.js.map +1 -1
- package/dist/presentation/routes/email-verification/verify-email-resend.d.ts.map +1 -1
- package/dist/presentation/routes/email-verification/verify-email-resend.js +20 -4
- package/dist/presentation/routes/email-verification/verify-email-resend.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +2 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +11 -13
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/password/password-reset-confirm.d.ts +2 -1
- package/dist/presentation/routes/password/password-reset-confirm.d.ts.map +1 -1
- package/dist/presentation/routes/password/password-reset-confirm.js +29 -26
- package/dist/presentation/routes/password/password-reset-confirm.js.map +1 -1
- package/dist/presentation/routes/registration/signup.d.ts +2 -1
- package/dist/presentation/routes/registration/signup.d.ts.map +1 -1
- package/dist/presentation/routes/registration/signup.js +86 -68
- package/dist/presentation/routes/registration/signup.js.map +1 -1
- package/dist/presentation/routes/session/login.d.ts +2 -1
- package/dist/presentation/routes/session/login.d.ts.map +1 -1
- package/dist/presentation/routes/session/login.js +40 -37
- package/dist/presentation/routes/session/login.js.map +1 -1
- package/dist/presentation/routes/session/refresh.d.ts +2 -1
- package/dist/presentation/routes/session/refresh.d.ts.map +1 -1
- package/dist/presentation/routes/session/refresh.js +42 -39
- package/dist/presentation/routes/session/refresh.js.map +1 -1
- package/dist/presentation/subscribers/index.d.ts +0 -1
- package/dist/presentation/subscribers/index.d.ts.map +1 -1
- package/dist/presentation/subscribers/index.js +0 -1
- package/dist/presentation/subscribers/index.js.map +1 -1
- package/dist/presentation/subscribers/on-password-reset-send-requested.js +1 -1
- package/dist/presentation/subscribers/on-password-reset-send-requested.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0000_initial.sql +1 -13
- package/drizzle/meta/0000_snapshot.json +0 -92
- package/package.json +30 -42
- package/src/config.ts +0 -56
- package/src/core/auth.test.ts +106 -187
- package/src/core/auth.ts +131 -87
- package/src/core/email-owner.test.ts +86 -0
- package/src/core/email-owner.ts +23 -0
- package/src/core/job-lease-token.test.ts +2 -1
- package/src/core/job-lease-token.ts +3 -2
- package/src/core/jwt.ts +2 -2
- package/src/core/rate-limit.test.ts +11 -28
- package/src/core/rate-limit.ts +3 -11
- package/src/core/runner-session-token.test.ts +2 -1
- package/src/core/runner-session-token.ts +3 -2
- package/src/db/db.ts +0 -2
- package/src/db/users.ts +32 -14
- package/src/index.test.ts +15 -11
- package/src/index.ts +23 -20
- package/src/presentation/auth/jwt-auth.test.ts +2 -1
- package/src/presentation/auth/jwt-auth.ts +2 -2
- package/src/presentation/e2eRoutes/create-session.ts +34 -30
- package/src/presentation/e2eRoutes/index.test.ts +9 -6
- package/src/presentation/e2eRoutes/index.ts +8 -5
- package/src/presentation/inter-module.ts +13 -0
- package/src/presentation/routes/email-verification/verify-email-confirm.ts +42 -24
- package/src/presentation/routes/email-verification/verify-email-resend.ts +18 -4
- package/src/presentation/routes/index.test.ts +10 -3
- package/src/presentation/routes/index.ts +22 -12
- package/src/presentation/routes/password/password-reset-confirm.ts +25 -22
- package/src/presentation/routes/password/password-reset-request.test.ts +1 -0
- package/src/presentation/routes/rate-limit.test.ts +2 -2
- package/src/presentation/routes/registration/signup.test.ts +39 -74
- package/src/presentation/routes/registration/signup.ts +89 -70
- package/src/presentation/routes/session/login.ts +38 -35
- package/src/presentation/routes/session/refresh.ts +43 -40
- package/src/presentation/subscribers/email-send-requested.test.ts +2 -30
- package/src/presentation/subscribers/index.ts +0 -1
- package/src/presentation/subscribers/on-password-reset-send-requested.ts +1 -1
- package/test/env.ts +1 -3
- package/test/globalSetup.ts +10 -1
- package/test/routes.ts +51 -84
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/core/entities/email-verification.d.ts +0 -9
- package/dist/core/entities/email-verification.d.ts.map +0 -1
- package/dist/core/entities/email-verification.js +0 -3
- package/dist/core/entities/email-verification.js.map +0 -1
- package/dist/db/email-verifications.d.ts +0 -39
- package/dist/db/email-verifications.d.ts.map +0 -1
- package/dist/db/email-verifications.js +0 -95
- package/dist/db/email-verifications.js.map +0 -1
- package/dist/db/schema/email-verifications.d.ts +0 -114
- package/dist/db/schema/email-verifications.d.ts.map +0 -1
- package/dist/db/schema/email-verifications.js +0 -35
- package/dist/db/schema/email-verifications.js.map +0 -1
- package/dist/presentation/subscribers/on-email-verification-send-requested.d.ts +0 -3
- package/dist/presentation/subscribers/on-email-verification-send-requested.d.ts.map +0 -1
- package/dist/presentation/subscribers/on-email-verification-send-requested.js +0 -13
- package/dist/presentation/subscribers/on-email-verification-send-requested.js.map +0 -1
- package/src/core/entities/email-verification.ts +0 -8
- package/src/db/email-verifications.test.ts +0 -61
- package/src/db/email-verifications.ts +0 -160
- package/src/db/schema/email-verifications.ts +0 -37
- package/src/presentation/routes/email-verification/verify-email-confirm.test.ts +0 -66
- package/src/presentation/routes/email-verification/verify-email-resend.test.ts +0 -100
- package/src/presentation/subscribers/on-email-verification-send-requested.ts +0 -10
package/drizzle/0000_initial.sql
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
CREATE TYPE "public"."auth_user_status" AS ENUM('active', 'suspended', 'deleted');--> statement-breakpoint
|
|
2
|
-
CREATE TABLE "auth_email_verifications" (
|
|
3
|
-
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
4
|
-
"user_id" uuid NOT NULL,
|
|
5
|
-
"hashed_token" text NOT NULL,
|
|
6
|
-
"expires_at" timestamp with time zone NOT NULL,
|
|
7
|
-
"used_at" timestamp with time zone,
|
|
8
|
-
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
9
|
-
);
|
|
10
|
-
--> statement-breakpoint
|
|
11
2
|
CREATE TABLE "auth_outbox" (
|
|
12
3
|
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
13
4
|
"event_type" text NOT NULL,
|
|
@@ -65,11 +56,8 @@ CREATE TABLE "auth_users" (
|
|
|
65
56
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
66
57
|
);
|
|
67
58
|
--> statement-breakpoint
|
|
68
|
-
ALTER TABLE "auth_email_verifications" ADD CONSTRAINT "auth_email_verifications_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
69
59
|
ALTER TABLE "auth_password_resets" ADD CONSTRAINT "auth_password_resets_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
70
60
|
ALTER TABLE "auth_refresh_tokens" ADD CONSTRAINT "auth_refresh_tokens_user_id_auth_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."auth_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
71
|
-
CREATE UNIQUE INDEX "auth_email_verifications_hashed_token_unique" ON "auth_email_verifications" USING btree ("hashed_token");--> statement-breakpoint
|
|
72
|
-
CREATE INDEX "auth_email_verifications_user_id_idx" ON "auth_email_verifications" USING btree ("user_id");--> statement-breakpoint
|
|
73
61
|
CREATE INDEX "auth_outbox_pending_idx" ON "auth_outbox" USING btree ("next_dispatch_at","created_at") WHERE "dispatched_at" IS NULL AND "dead_lettered_at" IS NULL;--> statement-breakpoint
|
|
74
62
|
CREATE INDEX "auth_outbox_dispatched_retention_idx" ON "auth_outbox" USING btree ("dispatched_at","id") WHERE "dispatched_at" IS NOT NULL;--> statement-breakpoint
|
|
75
63
|
CREATE UNIQUE INDEX "auth_password_resets_hashed_token_unique" ON "auth_password_resets" USING btree ("hashed_token");--> statement-breakpoint
|
|
@@ -78,4 +66,4 @@ CREATE UNIQUE INDEX "auth_rate_limits_window_unique" ON "auth_rate_limits" USING
|
|
|
78
66
|
CREATE INDEX "auth_rate_limits_expires_at_idx" ON "auth_rate_limits" USING btree ("expires_at");--> statement-breakpoint
|
|
79
67
|
CREATE UNIQUE INDEX "auth_refresh_tokens_hashed_token_unique" ON "auth_refresh_tokens" USING btree ("hashed_token");--> statement-breakpoint
|
|
80
68
|
CREATE INDEX "auth_refresh_tokens_user_id_idx" ON "auth_refresh_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
81
|
-
CREATE UNIQUE INDEX "auth_users_email_unique" ON "auth_users" USING btree ("email");
|
|
69
|
+
CREATE UNIQUE INDEX "auth_users_email_unique" ON "auth_users" USING btree ("email");
|
|
@@ -4,98 +4,6 @@
|
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
6
6
|
"tables": {
|
|
7
|
-
"public.auth_email_verifications": {
|
|
8
|
-
"name": "auth_email_verifications",
|
|
9
|
-
"schema": "",
|
|
10
|
-
"columns": {
|
|
11
|
-
"id": {
|
|
12
|
-
"name": "id",
|
|
13
|
-
"type": "uuid",
|
|
14
|
-
"primaryKey": true,
|
|
15
|
-
"notNull": true,
|
|
16
|
-
"default": "uuidv7()"
|
|
17
|
-
},
|
|
18
|
-
"user_id": {
|
|
19
|
-
"name": "user_id",
|
|
20
|
-
"type": "uuid",
|
|
21
|
-
"primaryKey": false,
|
|
22
|
-
"notNull": true
|
|
23
|
-
},
|
|
24
|
-
"hashed_token": {
|
|
25
|
-
"name": "hashed_token",
|
|
26
|
-
"type": "text",
|
|
27
|
-
"primaryKey": false,
|
|
28
|
-
"notNull": true
|
|
29
|
-
},
|
|
30
|
-
"expires_at": {
|
|
31
|
-
"name": "expires_at",
|
|
32
|
-
"type": "timestamp with time zone",
|
|
33
|
-
"primaryKey": false,
|
|
34
|
-
"notNull": true
|
|
35
|
-
},
|
|
36
|
-
"used_at": {
|
|
37
|
-
"name": "used_at",
|
|
38
|
-
"type": "timestamp with time zone",
|
|
39
|
-
"primaryKey": false,
|
|
40
|
-
"notNull": false
|
|
41
|
-
},
|
|
42
|
-
"created_at": {
|
|
43
|
-
"name": "created_at",
|
|
44
|
-
"type": "timestamp with time zone",
|
|
45
|
-
"primaryKey": false,
|
|
46
|
-
"notNull": true,
|
|
47
|
-
"default": "now()"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"indexes": {
|
|
51
|
-
"auth_email_verifications_hashed_token_unique": {
|
|
52
|
-
"name": "auth_email_verifications_hashed_token_unique",
|
|
53
|
-
"columns": [
|
|
54
|
-
{
|
|
55
|
-
"expression": "hashed_token",
|
|
56
|
-
"isExpression": false,
|
|
57
|
-
"asc": true,
|
|
58
|
-
"nulls": "last"
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"isUnique": true,
|
|
62
|
-
"concurrently": false,
|
|
63
|
-
"method": "btree",
|
|
64
|
-
"with": {}
|
|
65
|
-
},
|
|
66
|
-
"auth_email_verifications_user_id_idx": {
|
|
67
|
-
"name": "auth_email_verifications_user_id_idx",
|
|
68
|
-
"columns": [
|
|
69
|
-
{
|
|
70
|
-
"expression": "user_id",
|
|
71
|
-
"isExpression": false,
|
|
72
|
-
"asc": true,
|
|
73
|
-
"nulls": "last"
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
"isUnique": false,
|
|
77
|
-
"concurrently": false,
|
|
78
|
-
"method": "btree",
|
|
79
|
-
"with": {}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
"foreignKeys": {
|
|
83
|
-
"auth_email_verifications_user_id_auth_users_id_fk": {
|
|
84
|
-
"name": "auth_email_verifications_user_id_auth_users_id_fk",
|
|
85
|
-
"tableFrom": "auth_email_verifications",
|
|
86
|
-
"tableTo": "auth_users",
|
|
87
|
-
"columnsFrom": ["user_id"],
|
|
88
|
-
"columnsTo": ["id"],
|
|
89
|
-
"onDelete": "cascade",
|
|
90
|
-
"onUpdate": "no action"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"compositePrimaryKeys": {},
|
|
94
|
-
"uniqueConstraints": {},
|
|
95
|
-
"policies": {},
|
|
96
|
-
"checkConstraints": {},
|
|
97
|
-
"isRLSEnabled": false
|
|
98
|
-
},
|
|
99
7
|
"public.auth_outbox": {
|
|
100
8
|
"name": "auth_outbox",
|
|
101
9
|
"schema": "",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-auth",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -13,32 +13,16 @@
|
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"imports": {
|
|
15
15
|
"#test/*": "./test/*",
|
|
16
|
-
"#*":
|
|
17
|
-
"workspace-source": "./src/*",
|
|
18
|
-
"development": "./src/*",
|
|
19
|
-
"default": "./dist/*"
|
|
20
|
-
}
|
|
16
|
+
"#*": "./dist/*"
|
|
21
17
|
},
|
|
22
18
|
"exports": {
|
|
23
19
|
".": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"default": "./src/index.ts"
|
|
27
|
-
},
|
|
28
|
-
"default": {
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"default": "./dist/index.js"
|
|
31
|
-
}
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
32
22
|
},
|
|
33
23
|
"./config": {
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"default": "./src/config.ts"
|
|
37
|
-
},
|
|
38
|
-
"default": {
|
|
39
|
-
"types": "./dist/config.d.ts",
|
|
40
|
-
"default": "./dist/config.js"
|
|
41
|
-
}
|
|
24
|
+
"types": "./dist/config.d.ts",
|
|
25
|
+
"default": "./dist/config.js"
|
|
42
26
|
}
|
|
43
27
|
},
|
|
44
28
|
"dependencies": {
|
|
@@ -46,22 +30,24 @@
|
|
|
46
30
|
"@node-rs/argon2": "^2.0.2",
|
|
47
31
|
"drizzle-orm": "^0.45.2",
|
|
48
32
|
"zod": "^4.4.3",
|
|
49
|
-
"@shipfox/api-auth-context": "
|
|
50
|
-
"@shipfox/api-auth-dto": "
|
|
51
|
-
"@shipfox/api-
|
|
52
|
-
"@shipfox/api-workspaces-dto": "
|
|
53
|
-
"@shipfox/
|
|
54
|
-
"@shipfox/
|
|
55
|
-
"@shipfox/node-
|
|
56
|
-
"@shipfox/node-
|
|
57
|
-
"@shipfox/node-
|
|
58
|
-
"@shipfox/node-
|
|
59
|
-
"@shipfox/node-
|
|
60
|
-
"@shipfox/node-
|
|
61
|
-
"@shipfox/node-
|
|
62
|
-
"@shipfox/node-
|
|
63
|
-
"@shipfox/node-
|
|
64
|
-
"@shipfox/node-
|
|
33
|
+
"@shipfox/api-auth-context": "6.0.0",
|
|
34
|
+
"@shipfox/api-auth-dto": "6.0.0",
|
|
35
|
+
"@shipfox/api-email-challenges": "0.2.0",
|
|
36
|
+
"@shipfox/api-workspaces-dto": "6.0.0",
|
|
37
|
+
"@shipfox/inter-module": "0.2.0",
|
|
38
|
+
"@shipfox/config": "1.2.2",
|
|
39
|
+
"@shipfox/node-drizzle": "0.3.2",
|
|
40
|
+
"@shipfox/node-auth-root-key": "0.2.0",
|
|
41
|
+
"@shipfox/node-fastify": "0.2.4",
|
|
42
|
+
"@shipfox/node-jwt": "0.3.0",
|
|
43
|
+
"@shipfox/node-email": "0.2.2",
|
|
44
|
+
"@shipfox/node-mailer": "0.2.0",
|
|
45
|
+
"@shipfox/node-module": "0.4.0",
|
|
46
|
+
"@shipfox/node-opentelemetry": "0.5.2",
|
|
47
|
+
"@shipfox/node-outbox": "0.2.4",
|
|
48
|
+
"@shipfox/node-postgres": "0.4.2",
|
|
49
|
+
"@shipfox/node-rate-limit": "0.3.0",
|
|
50
|
+
"@shipfox/node-tokens": "0.3.0"
|
|
65
51
|
},
|
|
66
52
|
"devDependencies": {
|
|
67
53
|
"@types/pg": "^8.15.5",
|
|
@@ -70,16 +56,18 @@
|
|
|
70
56
|
"fastify-type-provider-zod": "^6.0.0",
|
|
71
57
|
"fishery": "^2.4.0",
|
|
72
58
|
"jose": "^6.0.0",
|
|
73
|
-
"@shipfox/biome": "1.8.
|
|
74
|
-
"@shipfox/
|
|
59
|
+
"@shipfox/biome": "1.8.2",
|
|
60
|
+
"@shipfox/depcruise": "1.0.2",
|
|
61
|
+
"@shipfox/swc": "1.2.6",
|
|
75
62
|
"@shipfox/ts-config": "1.3.8",
|
|
76
|
-
"@shipfox/typescript": "1.1.
|
|
77
|
-
"@shipfox/vitest": "1.2.
|
|
63
|
+
"@shipfox/typescript": "1.1.7",
|
|
64
|
+
"@shipfox/vitest": "1.2.3"
|
|
78
65
|
},
|
|
79
66
|
"scripts": {
|
|
80
67
|
"build": "shipfox-swc",
|
|
81
68
|
"check": "shipfox-biome-check",
|
|
82
69
|
"check:fix": "shipfox-biome-check --write",
|
|
70
|
+
"depcruise": "shipfox-depcruise",
|
|
83
71
|
"test": "shipfox-vitest-run",
|
|
84
72
|
"test:watch": "shipfox-vitest-watch",
|
|
85
73
|
"type": "shipfox-tsc-check",
|
package/src/config.ts
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import {bool, createConfig, num, str} from '@shipfox/config';
|
|
2
|
-
import {createConsoleMailer, createSmtpMailer, type Mailer} from '@shipfox/node-mailer';
|
|
3
2
|
|
|
4
3
|
export const config = createConfig({
|
|
5
|
-
AUTH_JWT_SECRET: str({
|
|
6
|
-
desc: 'Secret used to sign and verify user access tokens (JWTs). Required, with no default, so startup fails when it is missing.',
|
|
7
|
-
}),
|
|
8
4
|
AUTH_JWT_EXPIRES_IN: str({
|
|
9
5
|
desc: 'How long an access token stays valid. Accepts a duration string such as 15m, 1h, or 7d.',
|
|
10
6
|
default: '15m',
|
|
11
7
|
}),
|
|
12
|
-
AUTH_JOB_LEASE_TOKEN_SECRET: str({
|
|
13
|
-
desc: 'Secret used to sign and verify job lease tokens. Required, with no default, so startup fails when it is missing.',
|
|
14
|
-
}),
|
|
15
8
|
AUTH_JOB_LEASE_TOKEN_EXPIRES_IN: str({
|
|
16
9
|
desc: 'How long a job lease token stays valid. Set it longer than the longest job (JOB_MAX_DURATION is 60 minutes) plus a safety margin.',
|
|
17
10
|
default: '90m',
|
|
18
11
|
}),
|
|
19
|
-
AUTH_RUNNER_SESSION_TOKEN_SECRET: str({
|
|
20
|
-
desc: 'Secret used to sign and verify runner session tokens. Required, with no default, so startup fails when it is missing.',
|
|
21
|
-
}),
|
|
22
12
|
AUTH_RUNNER_SESSION_TOKEN_EXPIRES_IN: str({
|
|
23
13
|
desc: 'How long a runner session token stays valid. A revoked registration token can leave existing sessions usable until this lifetime ends.',
|
|
24
14
|
default: '1h',
|
|
@@ -39,54 +29,8 @@ export const config = createConfig({
|
|
|
39
29
|
desc: 'Whether password login is available. Use true or false. Defaults to true. When false, password and email-verification routes are not registered, and server startup requires another module to contribute a login method.',
|
|
40
30
|
default: true,
|
|
41
31
|
}),
|
|
42
|
-
RATE_LIMIT_IDENTIFIER_SECRET: str({
|
|
43
|
-
desc: 'Optional secret used to HMAC identifiers before storing rate-limit counters. Leave it unset to derive a stable key from AUTH_JWT_SECRET.',
|
|
44
|
-
default: undefined,
|
|
45
|
-
}),
|
|
46
32
|
CLIENT_BASE_URL: str({
|
|
47
33
|
desc: 'Base URL of the client app. Used to build links in emails such as password resets.',
|
|
48
34
|
default: 'http://localhost:5173',
|
|
49
35
|
}),
|
|
50
|
-
MAILER_TRANSPORT: str({
|
|
51
|
-
desc: 'How emails are delivered. Use console to print them to the log, or smtp to send them through an SMTP server.',
|
|
52
|
-
choices: ['console', 'smtp'],
|
|
53
|
-
default: 'console',
|
|
54
|
-
}),
|
|
55
|
-
MAILER_FROM: str({
|
|
56
|
-
desc: 'Sender address shown on outgoing emails.',
|
|
57
|
-
default: 'noreply@shipfox.local',
|
|
58
|
-
}),
|
|
59
|
-
SMTP_HOST: str({
|
|
60
|
-
desc: 'Hostname of the SMTP server. Required when MAILER_TRANSPORT is smtp.',
|
|
61
|
-
default: undefined,
|
|
62
|
-
}),
|
|
63
|
-
SMTP_PORT: num({
|
|
64
|
-
desc: 'Port of the SMTP server.',
|
|
65
|
-
default: 587,
|
|
66
|
-
}),
|
|
67
|
-
SMTP_USER: str({
|
|
68
|
-
desc: 'Username for SMTP authentication. Leave it unset if the server needs no login.',
|
|
69
|
-
default: undefined,
|
|
70
|
-
}),
|
|
71
|
-
SMTP_PASSWORD: str({
|
|
72
|
-
desc: 'Password for SMTP authentication. Leave it unset if the server needs no login.',
|
|
73
|
-
default: undefined,
|
|
74
|
-
}),
|
|
75
36
|
});
|
|
76
|
-
|
|
77
|
-
function createMailer(): Mailer {
|
|
78
|
-
if (config.MAILER_TRANSPORT === 'smtp') {
|
|
79
|
-
if (!config.SMTP_HOST) throw new Error('SMTP_HOST is required when MAILER_TRANSPORT=smtp');
|
|
80
|
-
return createSmtpMailer({
|
|
81
|
-
host: config.SMTP_HOST,
|
|
82
|
-
port: config.SMTP_PORT,
|
|
83
|
-
...(config.SMTP_USER ? {user: config.SMTP_USER} : {}),
|
|
84
|
-
...(config.SMTP_PASSWORD ? {password: config.SMTP_PASSWORD} : {}),
|
|
85
|
-
from: config.MAILER_FROM,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return createConsoleMailer({from: config.MAILER_FROM});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const mailer = createMailer();
|