create-kontrolia-auth 2.4.5 → 2.4.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/steps/application.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAYpD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgG1E"}
1
+ {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/steps/application.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAYpD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAwF1E"}
@@ -66,7 +66,6 @@ export async function askApplicationStep(db) {
66
66
  }
67
67
  const s = p.spinner();
68
68
  s.start(`Registrando ${name} (${slug}) y ${permissions.length} permiso(s)`);
69
- let apiKey;
70
69
  try {
71
70
  const result = await registerApplication({
72
71
  connectionString: db.databaseUrl,
@@ -75,7 +74,6 @@ export async function askApplicationStep(db) {
75
74
  environment,
76
75
  permissions,
77
76
  });
78
- apiKey = result.apiKey;
79
77
  s.stop(`Aplicación ${slug} registrada: ${result.permissionKeys.join(", ")}`);
80
78
  }
81
79
  catch (error) {
@@ -83,16 +81,12 @@ export async function askApplicationStep(db) {
83
81
  p.log.error(error.message);
84
82
  return;
85
83
  }
86
- if (apiKey) {
87
- p.note(`${apiKey}\n\n` +
88
- `Guárdala ahora no se puede volver a mostrar (solo se guarda su hash). Ponla en ${name} como una variable ` +
89
- `de entorno (p. ej. KONTROLIA_APPLICATION_API_KEY) y úsala para actualizar su catálogo de permisos desde su ` +
90
- `propio pipeline de despliegue, sin volver a tocar esta base de datos POST {tu-auth-server}/api/applications/sync. ` +
91
- `Ver la guía "Registro de aplicaciones" en la documentación para el formato exacto.`, `Clave de sincronización de ${slug}`);
92
- }
93
- else {
94
- p.note(`${slug} ya existía — su clave de sincronización (si tiene una) no cambió. Si la perdiste, tendrás que borrar ` +
95
- "y volver a registrar la aplicación para generar una nueva.", "Aplicación existente");
96
- }
84
+ // No API key comes out of this step — keys are org-scoped (an app can
85
+ // have several, one per organization that generates one) and no
86
+ // organization necessarily exists yet at this point in the install.
87
+ p.note(`Cuando una organización habilite ${name} desde admin-panel, cualquiera de sus Owner/Admin puede generar una ` +
88
+ `clave de sincronización desde Aplicaciones ${name} API Keysesa clave es lo que necesitas para ` +
89
+ `POST {tu-auth-server}/api/applications/sync desde el pipeline de despliegue de ${name}. Ver la guía ` +
90
+ `"Registro de aplicaciones" en la documentación.`, `Siguiente paso para ${slug}`);
97
91
  p.note("Para habilitarla en una organización, entra a admin-panel → \"Aplicaciones\" — cualquier owner/admin puede activarla ahí con un clic.", "Siguiente paso");
98
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/steps/deployment.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AA+K7F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwJvG"}
1
+ {"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/steps/deployment.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AA+K7F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkMvG"}
@@ -1,6 +1,7 @@
1
1
  import * as p from "@clack/prompts";
2
2
  import { readEnvFile, updateEnvValue, writeEnvFile } from "../utils/files.js";
3
3
  import { registerOAuthClient } from "../utils/oauth-client.js";
4
+ import { extractProjectRef } from "../utils/supabase-management-api.js";
4
5
  import { createVercelProject, detectCurrentBranch, detectGitHubRepo, triggerVercelDeployment } from "../utils/vercel-api.js";
5
6
  /**
6
7
  * Catches a `http://` URL for a real domain before it gets baked into env
@@ -228,6 +229,43 @@ export async function askDeploymentStep(repoRoot, db) {
228
229
  "auth-server y admin-panel comparten dominio (o subdominios con NEXT_PUBLIC_COOKIE_DOMAIN). " +
229
230
  "Si en el futuro necesitas dominios completamente distintos, habilita esa opción en tu proyecto y vuelve a correr el instalador.", "Paso manual pendiente");
230
231
  }
232
+ // Optional: lets admin-panel's "Inicio de sesión social" screen activate
233
+ // Google/Microsoft login live via Supabase's Management API instead of
234
+ // requiring a dashboard visit. Only possible on a Supabase Cloud project
235
+ // (self-hosted has no equivalent API) — skipped entirely otherwise.
236
+ const projectRef = extractProjectRef(db.supabaseUrl);
237
+ let managementApiToken = "";
238
+ if (projectRef) {
239
+ const prevToken = prevAuthServerEnv?.SUPABASE_MANAGEMENT_API_TOKEN;
240
+ if (prevToken) {
241
+ const reuseToken = await p.confirm({
242
+ message: "Ya tengo guardado un Personal Access Token de Supabase de antes (para activar login social en vivo desde admin-panel) — ¿lo sigo usando?",
243
+ initialValue: true,
244
+ });
245
+ if (!p.isCancel(reuseToken) && reuseToken)
246
+ managementApiToken = prevToken;
247
+ }
248
+ if (!managementApiToken) {
249
+ const wantsSocialLogin = await p.confirm({
250
+ message: "¿Quieres poder activar el login con Google/Microsoft más adelante desde admin-panel " +
251
+ "(Configuración → Inicio de sesión social), sin entrar al dashboard de Supabase? Es opcional — " +
252
+ "se puede configurar después. Necesita un Personal Access Token de tu cuenta Supabase.",
253
+ initialValue: false,
254
+ });
255
+ if (!p.isCancel(wantsSocialLogin) && wantsSocialLogin) {
256
+ p.note("1. Entra a supabase.com/dashboard/account/tokens\n" +
257
+ '2. Dale click a "Generate new token"\n' +
258
+ "3. Ponle un nombre, confirma y cópialo (solo se ve una vez)\n" +
259
+ "4. Pégalo aquí abajo", "Cómo conseguir el Personal Access Token de Supabase");
260
+ const token = await p.password({
261
+ message: "Personal Access Token de Supabase (se guarda en tu .env.local, igual que el resto de tus llaves)",
262
+ validate: (value) => (value.trim() ? undefined : "Requerido"),
263
+ });
264
+ if (!p.isCancel(token))
265
+ managementApiToken = token;
266
+ }
267
+ }
268
+ }
231
269
  const s = p.spinner();
232
270
  s.start("Generando apps/auth-server/.env.local y apps/admin-panel/.env.local");
233
271
  const authServerEnv = {
@@ -237,6 +275,7 @@ export async function askDeploymentStep(repoRoot, db) {
237
275
  SUPABASE_SERVICE_ROLE_KEY: db.serviceRoleKey,
238
276
  NEXT_PUBLIC_ADMIN_PANEL_URL: adminPanelUrl,
239
277
  NEXT_PUBLIC_COOKIE_DOMAIN: cookieDomain,
278
+ SUPABASE_MANAGEMENT_API_TOKEN: managementApiToken,
240
279
  };
241
280
  await writeEnvFile(`${repoRoot}/apps/auth-server/.env.local`, authServerEnv);
242
281
  const adminPanelEnv = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kontrolia-auth",
3
- "version": "2.4.5",
3
+ "version": "2.4.7",
4
4
  "license": "MIT",
5
5
  "description": "Turnkey installer for KontrolIA Auth. `npx create-kontrolia-auth mi-app` checks requirements, downloads the repo, installs deps, and runs a wizard: (1) connect to an existing Supabase project or create a new self-hosted one via Docker; (2) where to deploy auth-server/admin-panel (Docker, Vercel, Railway, Render, Coolify). Also exposes `update`, `migrate` and `doctor` subcommands.",
6
6
  "keywords": [
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@clack/prompts": "^0.9.1",
37
37
  "jose": "^5.9.6",
38
- "@kontrolia/db": "2.1.3"
38
+ "@kontrolia/db": "2.1.5"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^22.10.2",