@alinsafawi/aegis-auth 0.1.8 → 0.1.9
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/dist/index.js +63 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23443,6 +23443,60 @@ export default config
|
|
|
23443
23443
|
}
|
|
23444
23444
|
|
|
23445
23445
|
// src/generators/env.ts
|
|
23446
|
+
function generateEnvFile(cookiePrefix, infra, features) {
|
|
23447
|
+
const lines = [
|
|
23448
|
+
`# \u2500\u2500\u2500 Aegis Auth \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
23449
|
+
`# Fill in every value before running: npx prisma migrate dev --name init`,
|
|
23450
|
+
``,
|
|
23451
|
+
`# Generate with (PowerShell): [Convert]::ToBase64String((1..32|%{[byte](Get-Random -Max 256)}))`,
|
|
23452
|
+
`# Generate with (Unix): openssl rand -base64 32`,
|
|
23453
|
+
`AEGIS_JWT_SECRET=`,
|
|
23454
|
+
``,
|
|
23455
|
+
`# Set to the previous secret when rotating \u2014 gives active sessions a grace period`,
|
|
23456
|
+
`# AEGIS_JWT_SECRET_PREVIOUS=`,
|
|
23457
|
+
``,
|
|
23458
|
+
`# \u2500\u2500\u2500 Database \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
23459
|
+
`# Neon: postgresql://user:pass@host/db?sslmode=require`,
|
|
23460
|
+
`# Supabase: postgresql://postgres:pass@db.xxx.supabase.co:5432/postgres`,
|
|
23461
|
+
`# Local: postgresql://postgres:password@localhost:5432/mydb`,
|
|
23462
|
+
`DATABASE_URL=`,
|
|
23463
|
+
``
|
|
23464
|
+
];
|
|
23465
|
+
if (features.emailVerification || features.passwordReset || features.accountLockout) {
|
|
23466
|
+
lines.push(
|
|
23467
|
+
`# \u2500\u2500\u2500 Email (SMTP) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
23468
|
+
`# Works with Resend, Sendgrid, Postmark, Gmail, etc.`
|
|
23469
|
+
);
|
|
23470
|
+
if (infra.setupSmtp && infra.smtpHost) {
|
|
23471
|
+
lines.push(
|
|
23472
|
+
`AEGIS_SMTP_HOST=${infra.smtpHost}`,
|
|
23473
|
+
`AEGIS_SMTP_PORT=${infra.smtpPort ?? 587}`,
|
|
23474
|
+
`AEGIS_SMTP_USER=${infra.smtpUser ?? ""}`,
|
|
23475
|
+
`AEGIS_SMTP_PASS=`,
|
|
23476
|
+
`AEGIS_SMTP_FROM=${infra.smtpFrom ?? ""}`
|
|
23477
|
+
);
|
|
23478
|
+
} else {
|
|
23479
|
+
lines.push(
|
|
23480
|
+
`AEGIS_SMTP_HOST=`,
|
|
23481
|
+
`AEGIS_SMTP_PORT=587`,
|
|
23482
|
+
`AEGIS_SMTP_USER=`,
|
|
23483
|
+
`AEGIS_SMTP_PASS=`,
|
|
23484
|
+
`AEGIS_SMTP_FROM=`
|
|
23485
|
+
);
|
|
23486
|
+
}
|
|
23487
|
+
lines.push(``);
|
|
23488
|
+
}
|
|
23489
|
+
if (infra.rateLimitProvider === "upstash") {
|
|
23490
|
+
lines.push(
|
|
23491
|
+
`# \u2500\u2500\u2500 Upstash Redis (rate limiting) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
23492
|
+
`# Get these from upstash.com \u2014 free tier available`,
|
|
23493
|
+
`UPSTASH_REDIS_REST_URL=`,
|
|
23494
|
+
`UPSTASH_REDIS_REST_TOKEN=`,
|
|
23495
|
+
``
|
|
23496
|
+
);
|
|
23497
|
+
}
|
|
23498
|
+
return lines.join("\n");
|
|
23499
|
+
}
|
|
23446
23500
|
function generateEnvExample(cookiePrefix, infra, features) {
|
|
23447
23501
|
const lines = [
|
|
23448
23502
|
`# \u2500\u2500\u2500 Aegis Auth \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
@@ -23710,6 +23764,7 @@ function generatePackageJson(name, packageManager) {
|
|
|
23710
23764
|
"react-dom": "^19.0.0"
|
|
23711
23765
|
},
|
|
23712
23766
|
devDependencies: {
|
|
23767
|
+
"@alinsafawi/aegis-auth": "latest",
|
|
23713
23768
|
"@types/node": "^20.0.0",
|
|
23714
23769
|
"@types/react": "^19.0.0",
|
|
23715
23770
|
"@types/react-dom": "^19.0.0",
|
|
@@ -23939,7 +23994,8 @@ dist
|
|
|
23939
23994
|
const e = language === "typescript" ? "tsx" : "jsx";
|
|
23940
23995
|
await writeFile(`src/app/(auth)/login/page.${e}`, generateLoginPage(app.appName, style.primaryColor, language));
|
|
23941
23996
|
});
|
|
23942
|
-
await step("
|
|
23997
|
+
await step("Creating .env and .env.example", async () => {
|
|
23998
|
+
await writeFile(".env", generateEnvFile(app.cookiePrefix, infra, features));
|
|
23943
23999
|
await writeFile(".env.example", generateEnvExample(app.cookiePrefix, infra, features));
|
|
23944
24000
|
});
|
|
23945
24001
|
if (!isDry && mode === "new") {
|
|
@@ -23957,13 +24013,13 @@ dist
|
|
|
23957
24013
|
}] : [],
|
|
23958
24014
|
{
|
|
23959
24015
|
n: 1,
|
|
23960
|
-
title:
|
|
24016
|
+
title: `Fill in ${import_chalk8.default.yellow(".env")} ${import_chalk8.default.dim("(created for you \u2014 open it and add your values)")}`,
|
|
23961
24017
|
lines: [
|
|
23962
|
-
`${import_chalk8.default.cyan("
|
|
23963
|
-
`${import_chalk8.default.cyan("
|
|
23964
|
-
features.emailVerification || features.passwordReset ? `${import_chalk8.default.cyan("AEGIS_SMTP_HOST=")}` :
|
|
23965
|
-
infra.rateLimitProvider === "upstash" ? `${import_chalk8.default.cyan("UPSTASH_REDIS_REST_URL=")}` :
|
|
23966
|
-
]
|
|
24018
|
+
`${import_chalk8.default.cyan("DATABASE_URL=")} ${import_chalk8.default.dim("\u2190 your Postgres connection string (Neon, Supabase, local)")}`,
|
|
24019
|
+
`${import_chalk8.default.cyan("AEGIS_JWT_SECRET=")} ${import_chalk8.default.dim(process.platform === "win32" ? "\u2190 [Convert]::ToBase64String((1..32|%{[byte](Get-Random -Max 256)}))" : "\u2190 openssl rand -base64 32")}`,
|
|
24020
|
+
...features.emailVerification || features.passwordReset ? [`${import_chalk8.default.cyan("AEGIS_SMTP_HOST=")} ${import_chalk8.default.dim("\u2190 and SMTP_PORT, SMTP_USER, SMTP_PASS, SMTP_FROM")}`] : [],
|
|
24021
|
+
...infra.rateLimitProvider === "upstash" ? [`${import_chalk8.default.cyan("UPSTASH_REDIS_REST_URL=")} ${import_chalk8.default.dim("\u2190 and UPSTASH_REDIS_REST_TOKEN")}`] : []
|
|
24022
|
+
]
|
|
23967
24023
|
},
|
|
23968
24024
|
{
|
|
23969
24025
|
n: 2,
|