create-authhero 0.33.0 โ†’ 0.34.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.
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command as I } from "commander";
3
- import m from "inquirer";
3
+ import g from "inquirer";
4
4
  import a from "fs";
5
5
  import l from "path";
6
6
  import { spawn as E } from "child_process";
7
- const T = new I(), p = {
7
+ const D = new I(), i = {
8
8
  local: {
9
9
  name: "Local (SQLite)",
10
10
  description: "Local development setup with SQLite database - great for getting started",
@@ -145,15 +145,15 @@ function P(o, e = !1, r = "authhero-local") {
145
145
  "https://local.authhero.net/auth-callback",
146
146
  "http://localhost:5173/auth-callback",
147
147
  "https://localhost:3000/auth-callback"
148
- ], i = e ? [
148
+ ], d = e ? [
149
149
  `https://localhost.emobix.co.uk:8443/test/a/${r}/callback`,
150
150
  `https://localhost:8443/test/a/${r}/callback`
151
- ] : [], g = [...s, ...i], f = [
151
+ ] : [], m = [...s, ...d], f = [
152
152
  "https://manage.authhero.net",
153
153
  "https://local.authhero.net",
154
154
  "http://localhost:5173",
155
155
  "https://localhost:3000"
156
- ], v = e ? ["https://localhost:8443/", "https://localhost.emobix.co.uk:8443/"] : [], w = [...f, ...v], A = e ? `
156
+ ], v = e ? ["https://localhost:8443/", "https://localhost.emobix.co.uk:8443/"] : [], w = [...f, ...v], b = e ? `
157
157
  // Create OpenID Conformance Suite test clients and user
158
158
  console.log("Creating conformance test clients and user...");
159
159
 
@@ -278,11 +278,11 @@ async function main() {
278
278
  adminPassword,
279
279
  tenantId: "${n}",
280
280
  tenantName: "${t}",
281
- isControlPlane: ${o},
282
- callbacks: ${JSON.stringify(g)},
281
+ isControlPlane: ${!!o},
282
+ callbacks: ${JSON.stringify(m)},
283
283
  allowedLogoutUrls: ${JSON.stringify(w)},
284
284
  });
285
- ${A}
285
+ ${b}
286
286
  await db.destroy();
287
287
  }
288
288
 
@@ -295,6 +295,15 @@ import { swaggerUI } from "@hono/swagger-ui";
295
295
  import { AuthHeroConfig, DataAdapters } from "authhero";
296
296
  import { serveStatic } from "@hono/node-server/serve-static";
297
297
  import { initMultiTenant } from "@authhero/multi-tenancy";
298
+ import path from "path";
299
+ import { fileURLToPath } from "url";
300
+
301
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
302
+
303
+ const widgetPath = path.resolve(
304
+ __dirname,
305
+ "../node_modules/@authhero/widget/dist/authhero-widget",
306
+ );
298
307
 
299
308
  // Control plane configuration
300
309
  const CONTROL_PLANE_TENANT_ID = "control_plane";
@@ -304,6 +313,10 @@ export default function createApp(config: AuthHeroConfig & { dataAdapter: DataAd
304
313
  // Initialize multi-tenant AuthHero - syncs resource servers, roles, and connections by default
305
314
  const { app } = initMultiTenant({
306
315
  ...config,
316
+ widgetHandler: serveStatic({
317
+ root: widgetPath,
318
+ rewriteRequestPath: (p) => p.replace("/u/widget", ""),
319
+ }),
307
320
  controlPlane: {
308
321
  tenantId: CONTROL_PLANE_TENANT_ID,
309
322
  clientId: CONTROL_PLANE_CLIENT_ID,
@@ -328,23 +341,7 @@ export default function createApp(config: AuthHeroConfig & { dataAdapter: DataAd
328
341
  controlPlaneTenant: CONTROL_PLANE_TENANT_ID,
329
342
  });
330
343
  })
331
- .get("/docs", swaggerUI({ url: "/api/v2/spec" }))
332
- // Serve widget assets from @authhero/widget package
333
- .get(
334
- "/u/widget/*",
335
- serveStatic({
336
- root: "./node_modules/@authhero/widget/dist/authhero-widget",
337
- rewriteRequestPath: (path) => path.replace("/u/widget", ""),
338
- }),
339
- )
340
- // Serve static assets (CSS, JS) from authhero package
341
- .get(
342
- "/u/*",
343
- serveStatic({
344
- root: "./node_modules/authhero/dist/assets/u",
345
- rewriteRequestPath: (path) => path.replace("/u", ""),
346
- }),
347
- );
344
+ .get("/docs", swaggerUI({ url: "/api/v2/spec" }));
348
345
 
349
346
  return app;
350
347
  }
@@ -352,9 +349,24 @@ export default function createApp(config: AuthHeroConfig & { dataAdapter: DataAd
352
349
  import { AuthHeroConfig, init } from "authhero";
353
350
  import { swaggerUI } from "@hono/swagger-ui";
354
351
  import { serveStatic } from "@hono/node-server/serve-static";
352
+ import path from "path";
353
+ import { fileURLToPath } from "url";
354
+
355
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
356
+
357
+ const widgetPath = path.resolve(
358
+ __dirname,
359
+ "../node_modules/@authhero/widget/dist/authhero-widget",
360
+ );
355
361
 
356
362
  export default function createApp(config: AuthHeroConfig) {
357
- const { app } = init(config);
363
+ const { app } = init({
364
+ ...config,
365
+ widgetHandler: serveStatic({
366
+ root: widgetPath,
367
+ rewriteRequestPath: (p) => p.replace("/u/widget", ""),
368
+ }),
369
+ });
358
370
 
359
371
  app
360
372
  .onError((err, ctx) => {
@@ -371,23 +383,7 @@ export default function createApp(config: AuthHeroConfig) {
371
383
  status: "running",
372
384
  });
373
385
  })
374
- .get("/docs", swaggerUI({ url: "/api/v2/spec" }))
375
- // Serve widget assets from @authhero/widget package
376
- .get(
377
- "/u/widget/*",
378
- serveStatic({
379
- root: "./node_modules/@authhero/widget/dist/authhero-widget",
380
- rewriteRequestPath: (path) => path.replace("/u/widget", ""),
381
- }),
382
- )
383
- // Serve static assets (CSS, JS) from authhero package
384
- .get(
385
- "/u/*",
386
- serveStatic({
387
- root: "./node_modules/authhero/dist/assets/u",
388
- rewriteRequestPath: (path) => path.replace("/u", ""),
389
- }),
390
- );
386
+ .get("/docs", swaggerUI({ url: "/api/v2/spec" }));
391
387
 
392
388
  return app;
393
389
  }
@@ -422,7 +418,7 @@ export default {
422
418
  issuer,
423
419
  tenantId: "${o ? "control_plane" : "main"}",
424
420
  tenantName: "${o ? "Control Plane" : "Main"}",
425
- isControlPlane: ${o},
421
+ isControlPlane: ${!!o},
426
422
  });
427
423
 
428
424
  return new Response(
@@ -533,7 +529,7 @@ export default function createApp(config: AuthHeroConfig) {
533
529
  }
534
530
  `;
535
531
  }
536
- function j(o) {
532
+ function L(o) {
537
533
  return o ? `import { Context } from "hono";
538
534
  import { swaggerUI } from "@hono/swagger-ui";
539
535
  import { AuthHeroConfig, DataAdapters } from "authhero";
@@ -639,7 +635,7 @@ export default function createApp(config: AppConfig) {
639
635
  }
640
636
  `;
641
637
  }
642
- function L(o) {
638
+ function j(o) {
643
639
  return `import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
644
640
  import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
645
641
  import createAdapters from "@authhero/aws";
@@ -670,7 +666,7 @@ async function main() {
670
666
  adminPassword,
671
667
  tenantId: "${o ? "control_plane" : "main"}",
672
668
  tenantName: "${o ? "Control Plane" : "Main"}",
673
- isControlPlane: ${o},
669
+ isControlPlane: ${!!o},
674
670
  });
675
671
 
676
672
  console.log("โœ… Database seeded successfully!");
@@ -683,10 +679,10 @@ function $(o, e) {
683
679
  const r = l.join(o, "src");
684
680
  a.writeFileSync(
685
681
  l.join(r, "app.ts"),
686
- j(e)
682
+ L(e)
687
683
  ), a.writeFileSync(
688
684
  l.join(r, "seed.ts"),
689
- L(e)
685
+ j(e)
690
686
  );
691
687
  }
692
688
  function k() {
@@ -808,7 +804,7 @@ function M(o) {
808
804
  "type-check": "tsc --noEmit"
809
805
  }, a.writeFileSync(r, JSON.stringify(n, null, 2));
810
806
  }
811
- function S(o, e) {
807
+ function A(o, e) {
812
808
  return new Promise((r, n) => {
813
809
  const t = E(o, [], {
814
810
  cwd: e,
@@ -837,14 +833,14 @@ function x() {
837
833
  ), console.log("๐ŸŒ Portal available at https://local.authhero.net"), console.log("โ”€".repeat(50) + `
838
834
  `);
839
835
  }
840
- function D() {
836
+ function _() {
841
837
  console.log(`
842
838
  ` + "โ”€".repeat(50)), console.log("โœ… Self-signed certificates generated with openssl"), console.log("โš ๏ธ You may need to trust the certificate in your browser"), console.log("๐Ÿ” AuthHero server running at https://localhost:3000"), console.log("๐Ÿ“š API documentation available at https://localhost:3000/docs"), console.log(
843
839
  "๐Ÿš€ Open https://localhost:3000/setup to complete initial setup"
844
840
  ), console.log("๐ŸŒ Portal available at https://local.authhero.net"), console.log("โ”€".repeat(50) + `
845
841
  `);
846
842
  }
847
- T.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option("-t, --template <type>", "template type: local or cloudflare").option(
843
+ D.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option("-t, --template <type>", "template type: local or cloudflare").option(
848
844
  "--package-manager <pm>",
849
845
  "package manager to use: npm, yarn, pnpm, or bun"
850
846
  ).option("--multi-tenant", "enable multi-tenant mode").option("--skip-install", "skip installing dependencies").option("--skip-migrate", "skip running database migrations").option("--skip-start", "skip starting the development server").option("--github-ci", "include GitHub CI workflows with semantic versioning").option("--conformance", "add OpenID conformance suite test clients").option(
@@ -859,84 +855,74 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
859
855
  ๐Ÿ” Welcome to AuthHero!
860
856
  `);
861
857
  let n = o;
862
- n || (r ? (n = "auth-server", console.log(`Using default project name: ${n}`)) : n = (await m.prompt([
858
+ n || (r ? (n = "auth-server", console.log(`Using default project name: ${n}`)) : n = (await g.prompt([
863
859
  {
864
860
  type: "input",
865
861
  name: "projectName",
866
862
  message: "Project name:",
867
863
  default: "auth-server",
868
- validate: (u) => u !== "" || "Project name cannot be empty"
864
+ validate: (p) => p !== "" || "Project name cannot be empty"
869
865
  }
870
866
  ])).projectName);
871
867
  const t = l.join(process.cwd(), n);
872
868
  a.existsSync(t) && (console.error(`โŒ Project "${n}" already exists.`), process.exit(1));
873
869
  let s;
874
- e.template ? (["local", "cloudflare", "aws-sst"].includes(e.template) || (console.error(`โŒ Invalid template: ${e.template}`), console.error("Valid options: local, cloudflare, aws-sst"), process.exit(1)), s = e.template, console.log(`Using template: ${p[s].name}`)) : s = (await m.prompt([
870
+ e.template ? (["local", "cloudflare", "aws-sst"].includes(e.template) || (console.error(`โŒ Invalid template: ${e.template}`), console.error("Valid options: local, cloudflare, aws-sst"), process.exit(1)), s = e.template, console.log(`Using template: ${i[s].name}`)) : s = (await g.prompt([
875
871
  {
876
872
  type: "list",
877
873
  name: "setupType",
878
874
  message: "Select your setup type:",
879
875
  choices: [
880
876
  {
881
- name: `${p.local.name}
882
- ${p.local.description}`,
877
+ name: `${i.local.name}
878
+ ${i.local.description}`,
883
879
  value: "local",
884
- short: p.local.name
880
+ short: i.local.name
885
881
  },
886
882
  {
887
- name: `${p.cloudflare.name}
888
- ${p.cloudflare.description}`,
883
+ name: `${i.cloudflare.name}
884
+ ${i.cloudflare.description}`,
889
885
  value: "cloudflare",
890
- short: p.cloudflare.name
886
+ short: i.cloudflare.name
891
887
  },
892
888
  {
893
- name: `${p["aws-sst"].name}
894
- ${p["aws-sst"].description}`,
889
+ name: `${i["aws-sst"].name}
890
+ ${i["aws-sst"].description}`,
895
891
  value: "aws-sst",
896
- short: p["aws-sst"].name
892
+ short: i["aws-sst"].name
897
893
  }
898
894
  ]
899
895
  }
900
896
  ])).setupType;
901
- let i;
902
- e.multiTenant !== void 0 ? (i = e.multiTenant, console.log(`Multi-tenant mode: ${i ? "enabled" : "disabled"}`)) : r ? i = !1 : i = (await m.prompt([
903
- {
904
- type: "confirm",
905
- name: "multiTenant",
906
- message: `Would you like to enable multi-tenant mode?
907
- (Allows managing multiple tenants from a control plane)`,
908
- default: !1
909
- }
910
- ])).multiTenant;
911
- const g = e.conformance || !1, f = e.conformanceAlias || "authhero-local";
912
- g && console.log(
897
+ const d = e.multiTenant, m = e.conformance || !1, f = e.conformanceAlias || "authhero-local";
898
+ m && console.log(
913
899
  `OpenID Conformance Suite: enabled (alias: ${f})`
914
900
  );
915
901
  const v = e.workspace || !1;
916
902
  v && console.log("Workspace mode: enabled (using workspace:* dependencies)");
917
- const w = p[s];
903
+ const w = i[s];
918
904
  a.mkdirSync(t, { recursive: !0 }), a.writeFileSync(
919
905
  l.join(t, "package.json"),
920
906
  JSON.stringify(
921
- w.packageJson(n, i, g, v),
907
+ w.packageJson(n, d, m, v),
922
908
  null,
923
909
  2
924
910
  )
925
911
  );
926
- const A = w.templateDir, b = l.join(
912
+ const b = w.templateDir, S = l.join(
927
913
  import.meta.url.replace("file://", "").replace("/create-authhero.js", ""),
928
- A
914
+ b
929
915
  );
930
- if (a.existsSync(b) ? N(b, t) : (console.error(`โŒ Template directory not found: ${b}`), process.exit(1)), s === "cloudflare" && F(t, i), s === "cloudflare") {
931
- const c = l.join(t, "wrangler.toml"), u = l.join(t, "wrangler.local.toml");
932
- a.existsSync(c) && a.copyFileSync(c, u);
933
- const d = l.join(t, ".dev.vars.example"), h = l.join(t, ".dev.vars");
934
- a.existsSync(d) && a.copyFileSync(d, h), console.log(
916
+ if (a.existsSync(S) ? N(S, t) : (console.error(`โŒ Template directory not found: ${S}`), process.exit(1)), s === "cloudflare" && F(t, d), s === "cloudflare") {
917
+ const c = l.join(t, "wrangler.toml"), p = l.join(t, "wrangler.local.toml");
918
+ a.existsSync(c) && a.copyFileSync(c, p);
919
+ const u = l.join(t, ".dev.vars.example"), h = l.join(t, ".dev.vars");
920
+ a.existsSync(u) && a.copyFileSync(u, h), console.log(
935
921
  "๐Ÿ“ Created wrangler.local.toml and .dev.vars for local development"
936
922
  );
937
923
  }
938
924
  let C = !1;
939
- if (s === "cloudflare" && (e.githubCi !== void 0 ? (C = e.githubCi, C && console.log("Including GitHub CI workflows with semantic versioning")) : r || (C = (await m.prompt([
925
+ if (s === "cloudflare" && (e.githubCi !== void 0 ? (C = e.githubCi, C && console.log("Including GitHub CI workflows with semantic versioning")) : r || (C = (await g.prompt([
940
926
  {
941
927
  type: "confirm",
942
928
  name: "includeGithubCi",
@@ -945,15 +931,15 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
945
931
  }
946
932
  ])).includeGithubCi), C && (H(t), M(t))), s === "local") {
947
933
  const c = P(
948
- i,
949
- g,
934
+ d,
935
+ m,
950
936
  f
951
937
  );
952
938
  a.writeFileSync(l.join(t, "src/seed.ts"), c);
953
- const u = R(i);
954
- a.writeFileSync(l.join(t, "src/app.ts"), u);
939
+ const p = R(d);
940
+ a.writeFileSync(l.join(t, "src/app.ts"), p);
955
941
  }
956
- if (s === "aws-sst" && $(t, i), g) {
942
+ if (s === "aws-sst" && $(t, d), m) {
957
943
  const c = {
958
944
  alias: f,
959
945
  description: "AuthHero Conformance Test",
@@ -979,14 +965,14 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
979
965
  "๐Ÿ“ Created conformance-config.json for OpenID Conformance Suite"
980
966
  );
981
967
  }
982
- const _ = i ? "multi-tenant" : "single-tenant";
968
+ const T = d ? "multi-tenant" : "single-tenant";
983
969
  console.log(
984
970
  `
985
- โœ… Project "${n}" has been created with ${w.name} (${_}) setup!
971
+ โœ… Project "${n}" has been created with ${w.name} (${T}) setup!
986
972
  `
987
973
  );
988
974
  let y;
989
- if (e.skipInstall ? y = !1 : r ? y = !0 : y = (await m.prompt([
975
+ if (e.skipInstall ? y = !1 : r ? y = !0 : y = (await g.prompt([
990
976
  {
991
977
  type: "confirm",
992
978
  name: "shouldInstall",
@@ -997,7 +983,7 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
997
983
  let c;
998
984
  e.packageManager ? (["npm", "yarn", "pnpm", "bun"].includes(e.packageManager) || (console.error(
999
985
  `โŒ Invalid package manager: ${e.packageManager}`
1000
- ), console.error("Valid options: npm, yarn, pnpm, bun"), process.exit(1)), c = e.packageManager) : r ? c = "pnpm" : c = (await m.prompt([
986
+ ), console.error("Valid options: npm, yarn, pnpm, bun"), process.exit(1)), c = e.packageManager) : r ? c = "pnpm" : c = (await g.prompt([
1001
987
  {
1002
988
  type: "list",
1003
989
  name: "packageManager",
@@ -1014,14 +1000,14 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
1014
1000
  ๐Ÿ“ฆ Installing dependencies with ${c}...
1015
1001
  `);
1016
1002
  try {
1017
- const u = c === "pnpm" ? "pnpm install --ignore-workspace" : `${c} install`;
1018
- if (await S(u, t), s === "local" && (console.log(`
1003
+ const p = c === "pnpm" ? "pnpm install --ignore-workspace" : `${c} install`;
1004
+ if (await A(p, t), s === "local" && (console.log(`
1019
1005
  ๐Ÿ”ง Building native modules...
1020
- `), await S("npm rebuild better-sqlite3", t)), console.log(`
1006
+ `), await A("npm rebuild better-sqlite3", t)), console.log(`
1021
1007
  โœ… Dependencies installed successfully!
1022
1008
  `), (s === "local" || s === "cloudflare") && !e.skipMigrate) {
1023
1009
  let h;
1024
- r ? h = !0 : h = (await m.prompt([
1010
+ r ? h = !0 : h = (await g.prompt([
1025
1011
  {
1026
1012
  type: "confirm",
1027
1013
  name: "shouldMigrate",
@@ -1030,23 +1016,23 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
1030
1016
  }
1031
1017
  ])).shouldMigrate, h && (console.log(`
1032
1018
  ๐Ÿ”„ Running migrations...
1033
- `), await S(`${c} run migrate`, t));
1019
+ `), await A(`${c} run migrate`, t));
1034
1020
  }
1035
- let d;
1036
- e.skipStart || r ? d = !1 : d = (await m.prompt([
1021
+ let u;
1022
+ e.skipStart || r ? u = !1 : u = (await g.prompt([
1037
1023
  {
1038
1024
  type: "confirm",
1039
1025
  name: "shouldStart",
1040
1026
  message: "Would you like to start the development server?",
1041
1027
  default: !0
1042
1028
  }
1043
- ])).shouldStart, d && (s === "cloudflare" ? x() : s === "aws-sst" ? k() : D(), console.log(`๐Ÿš€ Starting development server...
1044
- `), await S(`${c} run dev`, t)), r && !d && (console.log(`
1029
+ ])).shouldStart, u && (s === "cloudflare" ? x() : s === "aws-sst" ? k() : _(), console.log(`๐Ÿš€ Starting development server...
1030
+ `), await A(`${c} run dev`, t)), r && !u && (console.log(`
1045
1031
  โœ… Setup complete!`), console.log(`
1046
- To start the development server:`), console.log(` cd ${n}`), console.log(" npm run dev"), s === "cloudflare" ? x() : s === "aws-sst" ? k() : D());
1047
- } catch (u) {
1032
+ To start the development server:`), console.log(` cd ${n}`), console.log(" npm run dev"), s === "cloudflare" ? x() : s === "aws-sst" ? k() : _());
1033
+ } catch (p) {
1048
1034
  console.error(`
1049
- โŒ An error occurred:`, u), process.exit(1);
1035
+ โŒ An error occurred:`, p), process.exit(1);
1050
1036
  }
1051
1037
  }
1052
1038
  y || (console.log("Next steps:"), console.log(` cd ${n}`), s === "local" ? (console.log(" npm install"), console.log(" npm run migrate"), console.log(" npm run dev"), console.log(
@@ -1061,7 +1047,7 @@ Open https://localhost:3000/setup to complete initial setup`
1061
1047
  `
1062
1048
  Open your server URL /setup to complete initial setup`
1063
1049
  )), console.log(`
1064
- Server will be available at: https://localhost:3000`), console.log("Portal available at: https://local.authhero.net"), g && (console.log(`
1050
+ Server will be available at: https://localhost:3000`), console.log("Portal available at: https://local.authhero.net"), m && (console.log(`
1065
1051
  ๐Ÿงช OpenID Conformance Suite Testing:`), console.log(
1066
1052
  " 1. Clone and start the conformance suite (if not already running):"
1067
1053
  ), console.log(
@@ -1072,4 +1058,4 @@ Server will be available at: https://localhost:3000`), console.log("Portal avail
1072
1058
  For more information, visit: https://authhero.net/docs
1073
1059
  `));
1074
1060
  });
1075
- T.parse(process.argv);
1061
+ D.parse(process.argv);
@@ -3,6 +3,7 @@ import { AuthHeroConfig, init } from "authhero";
3
3
  import { swaggerUI } from "@hono/swagger-ui";
4
4
  import { serveStatic } from "@hono/node-server/serve-static";
5
5
  import path from "path";
6
+ import fs from "fs";
6
7
  import { fileURLToPath } from "url";
7
8
 
8
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -13,9 +14,15 @@ const widgetPath = path.resolve(
13
14
  "../node_modules/@authhero/widget/dist/authhero-widget",
14
15
  );
15
16
 
17
+ const adminDistPath = path.resolve(
18
+ __dirname,
19
+ "../node_modules/@authhero/react-admin/dist",
20
+ );
21
+ const adminIndexPath = path.join(adminDistPath, "index.html");
22
+
16
23
  export default function createApp(config: AuthHeroConfig) {
17
- // Configure widget handler before init() to serve widget files at /u/widget/*
18
- const configWithWidget: AuthHeroConfig = {
24
+ // Configure widget and admin handlers before init()
25
+ const configWithHandlers: AuthHeroConfig = {
19
26
  ...config,
20
27
  widgetHandler: serveStatic({
21
28
  root: widgetPath,
@@ -23,7 +30,26 @@ export default function createApp(config: AuthHeroConfig) {
23
30
  }),
24
31
  };
25
32
 
26
- const { app } = init(configWithWidget);
33
+ // Add admin UI handler if the package is installed
34
+ if (fs.existsSync(adminIndexPath)) {
35
+ const issuer =
36
+ process.env.ISSUER || `https://localhost:${process.env.PORT || 3000}/`;
37
+ const rawHtml = fs.readFileSync(adminIndexPath, "utf-8");
38
+ const configJson = JSON.stringify({
39
+ domain: issuer.replace(/\/$/, ""),
40
+ basePath: "/admin",
41
+ }).replace(/</g, "\\u003c");
42
+ configWithHandlers.adminIndexHtml = rawHtml.replace(
43
+ "</head>",
44
+ `<script>window.__AUTHHERO_ADMIN_CONFIG__=${configJson};</script>\n</head>`,
45
+ );
46
+ configWithHandlers.adminHandler = serveStatic({
47
+ root: adminDistPath,
48
+ rewriteRequestPath: (p: string) => p.replace("/admin", ""),
49
+ });
50
+ }
51
+
52
+ const { app } = init(configWithHandlers);
27
53
 
28
54
  app
29
55
  .get("/", async (ctx: Context) => {
@@ -90,6 +90,7 @@ const app = createApp({
90
90
  "https://manage.authhero.net",
91
91
  "https://local.authhero.net",
92
92
  "http://localhost:5173",
93
+ "https://localhost:5173",
93
94
  ],
94
95
  });
95
96
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/markusahlstrand/authhero"
7
7
  },
8
- "version": "0.33.0",
8
+ "version": "0.34.0",
9
9
  "type": "module",
10
10
  "main": "dist/create-authhero.js",
11
11
  "bin": {
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsc && vite build",
32
+ "dev": "pnpm build && rm -rf auth-server && node dist/create-authhero.js auth-server --workspace --skip-install --skip-start && pnpm -w install --force --filter auth-server... && pnpm --filter auth-server migrate && pnpm --filter auth-server dev",
32
33
  "start": "pnpm build && node dist/create-authhero.js"
33
34
  }
34
35
  }