@alinsafawi/aegis-auth 0.1.7 → 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 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23139,9 +23139,6 @@ function roleModel(id, role, features) {
|
|
|
23139
23139
|
if (isStatic && storage === "json") {
|
|
23140
23140
|
lines.push(` permissions Json @default("{}")`);
|
|
23141
23141
|
}
|
|
23142
|
-
if (features.sessionTracking) {
|
|
23143
|
-
lines.push(` sessions AuthSession[]`);
|
|
23144
|
-
}
|
|
23145
23142
|
lines.push(`}`);
|
|
23146
23143
|
return lines.join("\n");
|
|
23147
23144
|
}
|
|
@@ -23446,6 +23443,60 @@ export default config
|
|
|
23446
23443
|
}
|
|
23447
23444
|
|
|
23448
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
|
+
}
|
|
23449
23500
|
function generateEnvExample(cookiePrefix, infra, features) {
|
|
23450
23501
|
const lines = [
|
|
23451
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`,
|
|
@@ -23713,6 +23764,7 @@ function generatePackageJson(name, packageManager) {
|
|
|
23713
23764
|
"react-dom": "^19.0.0"
|
|
23714
23765
|
},
|
|
23715
23766
|
devDependencies: {
|
|
23767
|
+
"@alinsafawi/aegis-auth": "latest",
|
|
23716
23768
|
"@types/node": "^20.0.0",
|
|
23717
23769
|
"@types/react": "^19.0.0",
|
|
23718
23770
|
"@types/react-dom": "^19.0.0",
|
|
@@ -23942,7 +23994,8 @@ dist
|
|
|
23942
23994
|
const e = language === "typescript" ? "tsx" : "jsx";
|
|
23943
23995
|
await writeFile(`src/app/(auth)/login/page.${e}`, generateLoginPage(app.appName, style.primaryColor, language));
|
|
23944
23996
|
});
|
|
23945
|
-
await step("
|
|
23997
|
+
await step("Creating .env and .env.example", async () => {
|
|
23998
|
+
await writeFile(".env", generateEnvFile(app.cookiePrefix, infra, features));
|
|
23946
23999
|
await writeFile(".env.example", generateEnvExample(app.cookiePrefix, infra, features));
|
|
23947
24000
|
});
|
|
23948
24001
|
if (!isDry && mode === "new") {
|
|
@@ -23960,13 +24013,13 @@ dist
|
|
|
23960
24013
|
}] : [],
|
|
23961
24014
|
{
|
|
23962
24015
|
n: 1,
|
|
23963
|
-
title:
|
|
24016
|
+
title: `Fill in ${import_chalk8.default.yellow(".env")} ${import_chalk8.default.dim("(created for you \u2014 open it and add your values)")}`,
|
|
23964
24017
|
lines: [
|
|
23965
|
-
`${import_chalk8.default.cyan("
|
|
23966
|
-
`${import_chalk8.default.cyan("
|
|
23967
|
-
features.emailVerification || features.passwordReset ? `${import_chalk8.default.cyan("AEGIS_SMTP_HOST=")}` :
|
|
23968
|
-
infra.rateLimitProvider === "upstash" ? `${import_chalk8.default.cyan("UPSTASH_REDIS_REST_URL=")}` :
|
|
23969
|
-
]
|
|
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
|
+
]
|
|
23970
24023
|
},
|
|
23971
24024
|
{
|
|
23972
24025
|
n: 2,
|