@stnd/account 0.1.3 → 0.2.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/CHANGELOG.md +11 -0
- package/auth.js +57 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/auth.js
CHANGED
|
@@ -89,18 +89,51 @@ export function initAuth(env) {
|
|
|
89
89
|
"tauri://localhost",
|
|
90
90
|
];
|
|
91
91
|
|
|
92
|
+
const isDev = import.meta.env.DEV;
|
|
93
|
+
const resolvedSecret =
|
|
94
|
+
accountConfig.secret ||
|
|
95
|
+
env.BETTER_AUTH_SECRET ||
|
|
96
|
+
env.JWT_SECRET;
|
|
97
|
+
|
|
98
|
+
if (!resolvedSecret) {
|
|
99
|
+
if (!isDev) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"FATAL: BETTER_AUTH_SECRET (or JWT_SECRET) is required in production environments. Set it with `wrangler secret put BETTER_AUTH_SECRET`."
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
log.warn("Using insecure fallback 'dev-secret-key' in development mode.");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const secret = resolvedSecret || "dev-secret-key";
|
|
108
|
+
|
|
92
109
|
const auth = betterAuth({
|
|
93
110
|
baseURL:
|
|
94
111
|
resolvedBaseURL ||
|
|
95
112
|
(env.BASE_URL ? env.BASE_URL : "http://localhost:8089"),
|
|
96
|
-
secret
|
|
97
|
-
accountConfig.secret ||
|
|
98
|
-
env.BETTER_AUTH_SECRET ||
|
|
99
|
-
env.JWT_SECRET ||
|
|
100
|
-
"dev-secret-key",
|
|
113
|
+
secret,
|
|
101
114
|
advanced: {
|
|
102
115
|
trustedOrigins: resolvedTrustedOrigins,
|
|
103
|
-
|
|
116
|
+
useSecureCookies: !isDev,
|
|
117
|
+
},
|
|
118
|
+
session: {
|
|
119
|
+
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
|
120
|
+
updateAge: 60 * 60 * 24, // Refresh every 24 hours
|
|
121
|
+
cookieCache: {
|
|
122
|
+
enabled: true,
|
|
123
|
+
maxAge: 60 * 5, // 5 minutes cache in signed cookie
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
rateLimit: {
|
|
127
|
+
enabled: true,
|
|
128
|
+
window: 60,
|
|
129
|
+
max: 100,
|
|
130
|
+
customRules: {
|
|
131
|
+
"/sign-in/email": { window: 60, max: 5 },
|
|
132
|
+
"/sign-up/email": { window: 60, max: 3 },
|
|
133
|
+
"/magic-link/send": { window: 60, max: 3 },
|
|
134
|
+
"/email-otp/send-verification-otp": { window: 60, max: 3 },
|
|
135
|
+
"/passkey/verify-authentication": { window: 60, max: 10 },
|
|
136
|
+
},
|
|
104
137
|
},
|
|
105
138
|
database: {
|
|
106
139
|
db: new Kysely({
|
|
@@ -112,6 +145,8 @@ export function initAuth(env) {
|
|
|
112
145
|
},
|
|
113
146
|
emailAndPassword: {
|
|
114
147
|
enabled: true,
|
|
148
|
+
minPasswordLength: 8,
|
|
149
|
+
maxPasswordLength: 128,
|
|
115
150
|
},
|
|
116
151
|
user: {
|
|
117
152
|
additionalFields: {
|
|
@@ -169,12 +204,20 @@ export function initAuth(env) {
|
|
|
169
204
|
from: accountConfig.emailFrom || "auth@standard.garden",
|
|
170
205
|
to: email,
|
|
171
206
|
subject: `Your login link to ${accountConfig.rpName || "Standard App"}`,
|
|
207
|
+
headers: {
|
|
208
|
+
"List-Unsubscribe": `<${resolvedBaseURL || "https://standard.garden"}>, <mailto:support@standard.garden?subject=unsubscribe>`,
|
|
209
|
+
},
|
|
172
210
|
html: `
|
|
173
211
|
<div style="font-family: system-ui, sans-serif; max-width: 600px; margin: 0 auto; color: #111;">
|
|
174
212
|
<h1>Welcome!</h1>
|
|
175
213
|
<p>Click the link below to sign in:</p>
|
|
176
214
|
<a href="${url}" style="display:inline-block; padding:12px 24px; background:#111; color:#fff; text-decoration:none; border-radius:4px; font-weight:bold;">Sign In</a>
|
|
177
215
|
<p style="margin-top:24px; color:#666; font-size:14px;">This link expires in 15 minutes.</p>
|
|
216
|
+
<hr style="border:none; border-top:1px solid #e5e7eb; margin:24px 0;" />
|
|
217
|
+
<p style="color:#888; font-size:12px; line-height:1.5; margin:0;">
|
|
218
|
+
Vous recevez ce courriel suite à une demande de connexion sur ${accountConfig.rpName || "Standard Garden"}.<br />
|
|
219
|
+
Pour gérer vos préférences, vous désinscrire ou exercer votre droit à l'oubli, accédez à vos <a href="${resolvedBaseURL || "https://standard.garden"}" style="color:#444; text-decoration:underline;">paramètres de compte</a>.
|
|
220
|
+
</p>
|
|
178
221
|
</div>
|
|
179
222
|
`,
|
|
180
223
|
}),
|
|
@@ -206,6 +249,9 @@ export function initAuth(env) {
|
|
|
206
249
|
from: accountConfig.emailFrom || "auth@standard.garden",
|
|
207
250
|
to: email,
|
|
208
251
|
subject: `Your login code: ${otp}`,
|
|
252
|
+
headers: {
|
|
253
|
+
"List-Unsubscribe": `<${resolvedBaseURL || "https://standard.garden"}>, <mailto:support@standard.garden?subject=unsubscribe>`,
|
|
254
|
+
},
|
|
209
255
|
html: `
|
|
210
256
|
<div style="font-family: system-ui, sans-serif; max-width: 600px; margin: 0 auto; color: #111;">
|
|
211
257
|
<h1>Your Login Code</h1>
|
|
@@ -214,6 +260,11 @@ export function initAuth(env) {
|
|
|
214
260
|
${otp}
|
|
215
261
|
</div>
|
|
216
262
|
<p style="color:#666; font-size:14px;">This code expires in 10 minutes.</p>
|
|
263
|
+
<hr style="border:none; border-top:1px solid #e5e7eb; margin:24px 0;" />
|
|
264
|
+
<p style="color:#888; font-size:12px; line-height:1.5; margin:0;">
|
|
265
|
+
Vous recevez ce courriel suite à une demande de connexion sur ${accountConfig.rpName || "Standard Garden"}.<br />
|
|
266
|
+
Pour gérer vos préférences, vous désinscrire ou exercer votre droit à l'oubli, accédez à vos <a href="${resolvedBaseURL || "https://standard.garden"}" style="color:#444; text-decoration:underline;">paramètres de compte</a>.
|
|
267
|
+
</p>
|
|
217
268
|
</div>
|
|
218
269
|
`,
|
|
219
270
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stnd/account",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"svelte": "./ui/UserMenu.svelte",
|
|
6
6
|
"main": "./index.module.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@stnd/art": "0.1.1",
|
|
28
28
|
"@stnd/icon": "0.2.2",
|
|
29
29
|
"@stnd/log": "0.5.1",
|
|
30
|
-
"@stnd/styles": "0.
|
|
30
|
+
"@stnd/styles": "0.6.0",
|
|
31
31
|
"@stnd/utils": "0.5.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|