hazo_auth 10.11.0 → 10.15.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/README.md CHANGED
@@ -3291,6 +3291,18 @@ export default function Page(props) { return <OTPPage {...props} />; }
3291
3291
 
3292
3292
  Enable in config: `[hazo_auth__otp] enable_email_otp = true`. Run `npx hazo_auth migrate migrations/015_email_otp.sql`.
3293
3293
 
3294
+ The visual panel image defaults to `/hazo_auth/images/login_default.jpg` (what `npx hazo_auth init` copies into `public/`). Override it per-page or in config — apps serving the packaged images from the generated `/api/hazo_auth/assets/[name]` route want the latter path:
3295
+
3296
+ ```tsx
3297
+ <OTPPage {...props} image_src="/api/hazo_auth/assets/login_default.jpg" />
3298
+ ```
3299
+
3300
+ ```ini
3301
+ [hazo_auth__otp]
3302
+ otp_image_src = /api/hazo_auth/assets/login_default.jpg
3303
+ otp_image_alt = Sign in with a one-time code
3304
+ ```
3305
+
3294
3306
  ## Theming
3295
3307
 
3296
3308
  ```tsx
@@ -1,11 +1,19 @@
1
1
  // file_description: init command for hazo_auth
2
2
  // Creates directories and copies config files to consuming projects
3
3
 
4
+ import { createRequire } from "node:module";
4
5
  import { fileURLToPath } from "url";
5
6
  import * as fs from "fs";
6
7
  import * as path from "path";
7
8
 
8
9
  // section: esm_shim
10
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
11
+ // through tsx, so a bare require() here is a ReferenceError, not a fallback.
12
+ // better-sqlite3 is loaded lazily below (it is optional — only SQLite projects
13
+ // install it), and createRequire is what makes a lazy CommonJS load legal
14
+ // from ESM.
15
+ const require = createRequire(import.meta.url);
16
+
9
17
  // ESM-compatible __dirname shim
10
18
  const __filename = fileURLToPath(import.meta.url);
11
19
  const __dirname = path.dirname(__filename);
@@ -1,10 +1,20 @@
1
1
  // file_description: CLI command to initialize SQLite database with hazo_auth schema
2
2
  // Can be run standalone via: npx hazo_auth init-db
3
3
 
4
+ import { createRequire } from "node:module";
4
5
  import * as fs from "fs";
5
6
  import * as path from "path";
6
7
  import { SQLITE_SCHEMA } from "../lib/schema/sqlite_schema.js";
7
8
 
9
+ // section: esm_shim
10
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
11
+ // through tsx, so it is ESM: a bare require() is a ReferenceError, not a
12
+ // fallback. The better-sqlite3 loads below are deliberately lazy (the
13
+ // dependency is optional — only SQLite projects install it), which is why they
14
+ // are require() calls rather than static imports, and createRequire is what
15
+ // makes a lazy CommonJS load legal from ESM.
16
+ const require = createRequire(import.meta.url);
17
+
8
18
  // section: helpers
9
19
 
10
20
  /**
@@ -1,9 +1,18 @@
1
1
  // file_description: validation logic for hazo_auth setup verification
2
2
  // This module contains all the validation checks that can be run via CLI or programmatically
3
3
 
4
+ import { createRequire } from "node:module";
4
5
  import * as fs from "fs";
5
6
  import * as path from "path";
6
7
 
8
+ // section: esm_shim
9
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
10
+ // through tsx, so a bare require() here is a ReferenceError, not a fallback.
11
+ // The better-sqlite3 load below is deliberately lazy (the dependency is
12
+ // optional), and createRequire is what makes a lazy CommonJS load legal
13
+ // from ESM.
14
+ const require = createRequire(import.meta.url);
15
+
7
16
  // section: types
8
17
  type CheckStatus = "pass" | "fail" | "warn";
9
18
 
@@ -32,9 +32,18 @@ import {
32
32
  const DEFAULT_SCOPE_HEADER = "X-Hazo-Scope-Id";
33
33
 
34
34
  /**
35
- * Base cookie name for scope ID (will have prefix applied)
35
+ * Base cookie name for scope ID (will have prefix applied).
36
+ *
37
+ * Exported so a consuming app can SET the same cookie this module READS —
38
+ * without it, an app implementing a scope switcher has to duplicate the
39
+ * configured prefix and drift the moment it changes.
36
40
  */
37
- const BASE_SCOPE_COOKIE = "hazo_auth_scope_id";
41
+ export const SCOPE_COOKIE_BASE_NAME = "hazo_auth_scope_id";
42
+
43
+ /** The live, prefixed scope cookie name for this deployment. */
44
+ export function get_scope_cookie_name(): string {
45
+ return get_cookie_name(SCOPE_COOKIE_BASE_NAME);
46
+ }
38
47
 
39
48
  // section: helpers
40
49
 
@@ -57,7 +66,7 @@ export function extract_scope_id_from_request(
57
66
  }
58
67
 
59
68
  // Check cookie (with prefix)
60
- const cookie_name = options.scope_cookie_name || get_cookie_name(BASE_SCOPE_COOKIE);
69
+ const cookie_name = options.scope_cookie_name || get_cookie_name(SCOPE_COOKIE_BASE_NAME);
61
70
  const cookie_value = request.cookies.get(cookie_name)?.value;
62
71
  return cookie_value;
63
72
  }
@@ -19,6 +19,8 @@ export {
19
19
  hazo_get_tenant_auth,
20
20
  require_tenant_auth,
21
21
  extract_scope_id_from_request,
22
+ SCOPE_COOKIE_BASE_NAME,
23
+ get_scope_cookie_name,
22
24
  } from "./hazo_get_tenant_auth.server.js";
23
25
  export type {
24
26
  ScopeDetails,
@@ -18,6 +18,11 @@ export const OTP_CONFIG_DEFAULTS = {
18
18
  max_verify_attempts: 5,
19
19
  auto_assign_scope_id: "00000000-0000-0000-0000-000000000001",
20
20
  auto_assign_role_name: "member",
21
+ // Matches OTPLayout's own default. Apps that never ran `npx hazo_auth init`
22
+ // (so have no public/hazo_auth/images/) should point this at the packaged
23
+ // asset route instead: /api/hazo_auth/assets/login_default.jpg
24
+ image_src: "/hazo_auth/images/login_default.jpg",
25
+ image_alt: "Sign in with a one-time code",
21
26
  } as const;
22
27
 
23
28
  // section: types
@@ -44,6 +49,10 @@ export type OtpConfig = {
44
49
  auto_assign_scope_id: string;
45
50
  /** Role name to assign within the auto-assign scope */
46
51
  auto_assign_role_name: string;
52
+ /** Image shown in the OTP page's visual panel */
53
+ image_src: string;
54
+ /** Alt text for the OTP page's visual panel image */
55
+ image_alt: string;
47
56
  };
48
57
 
49
58
  // section: helpers
@@ -79,6 +88,8 @@ export function get_otp_config(): OtpConfig {
79
88
  max_verify_attempts: get_config_number(section, "otp_max_verify_attempts", d.max_verify_attempts),
80
89
  auto_assign_scope_id: get_config_value(section, "otp_auto_assign_scope_id", d.auto_assign_scope_id),
81
90
  auto_assign_role_name: get_config_value(section, "otp_auto_assign_role_name", d.auto_assign_role_name),
91
+ image_src: get_config_value(section, "otp_image_src", d.image_src),
92
+ image_alt: get_config_value(section, "otp_image_alt", d.image_alt),
82
93
  };
83
94
  }
84
95
 
@@ -123,6 +123,14 @@ enable_admin_ui = true
123
123
  # require_number = false
124
124
  # require_special = false
125
125
 
126
+ [hazo_auth__otp]
127
+ # Visual panel image on the email-OTP sign-in page.
128
+ # Default: /hazo_auth/images/login_default.jpg — i.e. the copy `npx hazo_auth init`
129
+ # places in your public/ directory. Apps that skipped that copy should point this
130
+ # at the packaged asset route instead:
131
+ # otp_image_src = /api/hazo_auth/assets/login_default.jpg
132
+ # otp_image_alt = Sign in with a one-time code
133
+
126
134
  [hazo_auth__login_layout]
127
135
  # Image configuration
128
136
  # image_src = /globe.svg
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAoJA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAqPjD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AA4JA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAqPjD"}
package/dist/cli/init.js CHANGED
@@ -1,9 +1,16 @@
1
1
  // file_description: init command for hazo_auth
2
2
  // Creates directories and copies config files to consuming projects
3
+ import { createRequire } from "node:module";
3
4
  import { fileURLToPath } from "url";
4
5
  import * as fs from "fs";
5
6
  import * as path from "path";
6
7
  // section: esm_shim
8
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
9
+ // through tsx, so a bare require() here is a ReferenceError, not a fallback.
10
+ // better-sqlite3 is loaded lazily below (it is optional — only SQLite projects
11
+ // install it), and createRequire is what makes a lazy CommonJS load legal
12
+ // from ESM.
13
+ const require = createRequire(import.meta.url);
7
14
  // ESM-compatible __dirname shim
8
15
  const __filename = fileURLToPath(import.meta.url);
9
16
  const __dirname = path.dirname(__filename);
@@ -1 +1 @@
1
- {"version":3,"file":"init_db.d.ts","sourceRoot":"","sources":["../../src/cli/init_db.ts"],"names":[],"mappings":"AAwEA,wBAAgB,cAAc,IAAI,IAAI,CAuErC"}
1
+ {"version":3,"file":"init_db.d.ts","sourceRoot":"","sources":["../../src/cli/init_db.ts"],"names":[],"mappings":"AAkFA,wBAAgB,cAAc,IAAI,IAAI,CAuErC"}
@@ -1,8 +1,17 @@
1
1
  // file_description: CLI command to initialize SQLite database with hazo_auth schema
2
2
  // Can be run standalone via: npx hazo_auth init-db
3
+ import { createRequire } from "node:module";
3
4
  import * as fs from "fs";
4
5
  import * as path from "path";
5
6
  import { SQLITE_SCHEMA } from "../lib/schema/sqlite_schema.js";
7
+ // section: esm_shim
8
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
9
+ // through tsx, so it is ESM: a bare require() is a ReferenceError, not a
10
+ // fallback. The better-sqlite3 loads below are deliberately lazy (the
11
+ // dependency is optional — only SQLite projects install it), which is why they
12
+ // are require() calls rather than static imports, and createRequire is what
13
+ // makes a lazy CommonJS load legal from ESM.
14
+ const require = createRequire(import.meta.url);
6
15
  // section: helpers
7
16
  /**
8
17
  * Reads sqlite_path from the config file
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/cli/validate.ts"],"names":[],"mappings":"AAOA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AA20BF,wBAAgB,cAAc,IAAI,iBAAiB,CA8FlD"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/cli/validate.ts"],"names":[],"mappings":"AAgBA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AA20BF,wBAAgB,cAAc,IAAI,iBAAiB,CA8FlD"}
@@ -1,7 +1,15 @@
1
1
  // file_description: validation logic for hazo_auth setup verification
2
2
  // This module contains all the validation checks that can be run via CLI or programmatically
3
+ import { createRequire } from "node:module";
3
4
  import * as fs from "fs";
4
5
  import * as path from "path";
6
+ // section: esm_shim
7
+ // package.json declares "type": "module" and bin/hazo_auth.mjs runs this file
8
+ // through tsx, so a bare require() here is a ReferenceError, not a fallback.
9
+ // The better-sqlite3 load below is deliberately lazy (the dependency is
10
+ // optional), and createRequire is what makes a lazy CommonJS load legal
11
+ // from ESM.
12
+ const require = createRequire(import.meta.url);
5
13
  // section: constants
6
14
  const REQUIRED_CONFIG_FILES = [
7
15
  "config/hazo_auth_config.ini",
@@ -1,6 +1,16 @@
1
1
  import "server-only";
2
2
  import { NextRequest } from "next/server";
3
3
  import type { TenantAuthOptions, TenantAuthResult, RequiredTenantAuthResult } from "./auth_types";
4
+ /**
5
+ * Base cookie name for scope ID (will have prefix applied).
6
+ *
7
+ * Exported so a consuming app can SET the same cookie this module READS —
8
+ * without it, an app implementing a scope switcher has to duplicate the
9
+ * configured prefix and drift the moment it changes.
10
+ */
11
+ export declare const SCOPE_COOKIE_BASE_NAME = "hazo_auth_scope_id";
12
+ /** The live, prefixed scope cookie name for this deployment. */
13
+ export declare function get_scope_cookie_name(): string;
4
14
  /**
5
15
  * Extracts scope ID from request headers or cookies
6
16
  * Priority: Header > Cookie
@@ -1 +1 @@
1
- {"version":3,"file":"hazo_get_tenant_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_tenant_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ1C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EAGzB,MAAM,cAAc,CAAC;AAqBtB;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,iBAAiB,GACzB,MAAM,GAAG,SAAS,CAYpB;AA8BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAwF3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CA0BnC"}
1
+ {"version":3,"file":"hazo_get_tenant_auth.server.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/hazo_get_tenant_auth.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ1C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EAGzB,MAAM,cAAc,CAAC;AActB;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAE3D,gEAAgE;AAChE,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAID;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,iBAAiB,GACzB,MAAM,GAAG,SAAS,CAYpB;AA8BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAwF3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CA0BnC"}
@@ -15,9 +15,17 @@ import { AuthenticationRequiredError, TenantRequiredError, TenantAccessDeniedErr
15
15
  */
16
16
  const DEFAULT_SCOPE_HEADER = "X-Hazo-Scope-Id";
17
17
  /**
18
- * Base cookie name for scope ID (will have prefix applied)
18
+ * Base cookie name for scope ID (will have prefix applied).
19
+ *
20
+ * Exported so a consuming app can SET the same cookie this module READS —
21
+ * without it, an app implementing a scope switcher has to duplicate the
22
+ * configured prefix and drift the moment it changes.
19
23
  */
20
- const BASE_SCOPE_COOKIE = "hazo_auth_scope_id";
24
+ export const SCOPE_COOKIE_BASE_NAME = "hazo_auth_scope_id";
25
+ /** The live, prefixed scope cookie name for this deployment. */
26
+ export function get_scope_cookie_name() {
27
+ return get_cookie_name(SCOPE_COOKIE_BASE_NAME);
28
+ }
21
29
  // section: helpers
22
30
  /**
23
31
  * Extracts scope ID from request headers or cookies
@@ -35,7 +43,7 @@ export function extract_scope_id_from_request(request, options) {
35
43
  return header_value;
36
44
  }
37
45
  // Check cookie (with prefix)
38
- const cookie_name = options.scope_cookie_name || get_cookie_name(BASE_SCOPE_COOKIE);
46
+ const cookie_name = options.scope_cookie_name || get_cookie_name(SCOPE_COOKIE_BASE_NAME);
39
47
  const cookie_value = (_a = request.cookies.get(cookie_name)) === null || _a === void 0 ? void 0 : _a.value;
40
48
  return cookie_value;
41
49
  }
@@ -3,7 +3,7 @@ export { hazo_get_auth, get_client_ip } from "./hazo_get_auth.server.js";
3
3
  export { get_authenticated_user, require_auth, is_authenticated, } from "./auth_utils.server.js";
4
4
  export type { AuthResult, AuthUser } from "./auth_utils.server";
5
5
  export { ensure_anon_id } from "./ensure_anon_id.server.js";
6
- export { hazo_get_tenant_auth, require_tenant_auth, extract_scope_id_from_request, } from "./hazo_get_tenant_auth.server.js";
6
+ export { hazo_get_tenant_auth, require_tenant_auth, extract_scope_id_from_request, SCOPE_COOKIE_BASE_NAME, get_scope_cookie_name, } from "./hazo_get_tenant_auth.server.js";
7
7
  export type { ScopeDetails, TenantOrganization, TenantAuthOptions, TenantAuthResult, RequiredTenantAuthResult, } from "./auth_types";
8
8
  export { HazoAuthError, AuthenticationRequiredError, TenantRequiredError, TenantAccessDeniedError, } from "./auth_types.js";
9
9
  export { get_server_auth_user } from "./server_auth.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC"}
@@ -7,7 +7,7 @@ export { get_authenticated_user, require_auth, is_authenticated, } from "./auth_
7
7
  // section: anon_id_exports (v5.2)
8
8
  export { ensure_anon_id } from "./ensure_anon_id.server.js";
9
9
  // section: tenant_auth_exports
10
- export { hazo_get_tenant_auth, require_tenant_auth, extract_scope_id_from_request, } from "./hazo_get_tenant_auth.server.js";
10
+ export { hazo_get_tenant_auth, require_tenant_auth, extract_scope_id_from_request, SCOPE_COOKIE_BASE_NAME, get_scope_cookie_name, } from "./hazo_get_tenant_auth.server.js";
11
11
  export { HazoAuthError, AuthenticationRequiredError, TenantRequiredError, TenantAccessDeniedError, } from "./auth_types.js";
12
12
  // section: client_exports
13
13
  export { get_server_auth_user } from "./server_auth.js";
@@ -11,6 +11,8 @@ export declare const OTP_CONFIG_DEFAULTS: {
11
11
  readonly max_verify_attempts: 5;
12
12
  readonly auto_assign_scope_id: "00000000-0000-0000-0000-000000000001";
13
13
  readonly auto_assign_role_name: "member";
14
+ readonly image_src: "/hazo_auth/images/login_default.jpg";
15
+ readonly image_alt: "Sign in with a one-time code";
14
16
  };
15
17
  export type OtpConfig = {
16
18
  /** Whether to automatically register a new user when an unrecognised email requests an OTP */
@@ -35,6 +37,10 @@ export type OtpConfig = {
35
37
  auto_assign_scope_id: string;
36
38
  /** Role name to assign within the auto-assign scope */
37
39
  auto_assign_role_name: string;
40
+ /** Image shown in the OTP page's visual panel */
41
+ image_src: string;
42
+ /** Alt text for the OTP page's visual panel image */
43
+ image_alt: string;
38
44
  };
39
45
  /**
40
46
  * Reads OTP configuration from hazo_auth_config.ini [hazo_auth__otp] section.
@@ -1 +1 @@
1
- {"version":3,"file":"otp_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/otp_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAMrB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAYtB,CAAC;AAGX,MAAM,MAAM,SAAS,GAAG;IACtB,8FAA8F;IAC9F,aAAa,EAAE,OAAO,CAAC;IACvB,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAC;IACzB,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,yBAAyB,EAAE,MAAM,CAAC;IAClC,kFAAkF;IAClF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,+BAA+B,EAAE,MAAM,CAAC;IACxC,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,4BAA4B,EAAE,MAAM,CAAC;IACrC,wEAAwE;IACxE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAGF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,SAAS,CA6B1C;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,MAAM,CAE1D"}
1
+ {"version":3,"file":"otp_config.server.d.ts","sourceRoot":"","sources":["../../src/lib/otp_config.server.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAMrB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;CAiBtB,CAAC;AAGX,MAAM,MAAM,SAAS,GAAG;IACtB,8FAA8F;IAC9F,aAAa,EAAE,OAAO,CAAC;IACvB,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAC;IACzB,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,yBAAyB,EAAE,MAAM,CAAC;IAClC,kFAAkF;IAClF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,+BAA+B,EAAE,MAAM,CAAC;IACxC,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,4BAA4B,EAAE,MAAM,CAAC;IACrC,wEAAwE;IACxE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,SAAS,CA+B1C;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,MAAM,CAE1D"}
@@ -16,6 +16,11 @@ export const OTP_CONFIG_DEFAULTS = {
16
16
  max_verify_attempts: 5,
17
17
  auto_assign_scope_id: "00000000-0000-0000-0000-000000000001",
18
18
  auto_assign_role_name: "member",
19
+ // Matches OTPLayout's own default. Apps that never ran `npx hazo_auth init`
20
+ // (so have no public/hazo_auth/images/) should point this at the packaged
21
+ // asset route instead: /api/hazo_auth/assets/login_default.jpg
22
+ image_src: "/hazo_auth/images/login_default.jpg",
23
+ image_alt: "Sign in with a one-time code",
19
24
  };
20
25
  // section: helpers
21
26
  /**
@@ -37,6 +42,8 @@ export function get_otp_config() {
37
42
  max_verify_attempts: get_config_number(section, "otp_max_verify_attempts", d.max_verify_attempts),
38
43
  auto_assign_scope_id: get_config_value(section, "otp_auto_assign_scope_id", d.auto_assign_scope_id),
39
44
  auto_assign_role_name: get_config_value(section, "otp_auto_assign_role_name", d.auto_assign_role_name),
45
+ image_src: get_config_value(section, "otp_image_src", d.image_src),
46
+ image_alt: get_config_value(section, "otp_image_alt", d.image_alt),
40
47
  };
41
48
  }
42
49
  /**
@@ -11,11 +11,11 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
11
11
  has_more: boolean;
12
12
  total_pages: number;
13
13
  };
14
- source: "project" | "node_modules";
14
+ source: "node_modules" | "project";
15
15
  }> | NextResponse<{
16
16
  success: boolean;
17
17
  categories: string[];
18
- source: "project" | "node_modules" | null;
18
+ source: "node_modules" | "project" | null;
19
19
  }> | NextResponse<{
20
20
  error: string;
21
21
  }>>;
@@ -29,6 +29,17 @@ export type OTPPageProps = {
29
29
  * with the brand panel on the left.
30
30
  */
31
31
  theme?: import("../theme/theme_types").HazoAuthTheme;
32
+ /**
33
+ * Image shown in the visual panel beside the form.
34
+ * Falls back to `[hazo_auth__otp] otp_image_src` in hazo_auth_config.ini,
35
+ * then to the packaged default login illustration.
36
+ */
37
+ image_src?: string;
38
+ /**
39
+ * Alt text for the visual panel image.
40
+ * Falls back to `[hazo_auth__otp] otp_image_alt`, then to a packaged default.
41
+ */
42
+ image_alt?: string;
32
43
  };
33
44
  /**
34
45
  * Zero-config OTPPage server component
@@ -51,6 +62,6 @@ export type OTPPageProps = {
51
62
  * @param props - Optional searchParams and title
52
63
  * @returns Server-rendered OTP sign-in page
53
64
  */
54
- export default function OTPPage({ searchParams, title, subtitle, ctaText, theme, }?: OTPPageProps): Promise<React.ReactElement>;
65
+ export default function OTPPage({ searchParams, title, subtitle, ctaText, theme, image_src, image_alt, }?: OTPPageProps): Promise<React.ReactElement>;
55
66
  export { OTPPage };
56
67
  //# sourceMappingURL=otp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["../../src/server_pages/otp.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,sBAAsB,EAAE,aAAa,CAAC;CACtD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,OAAO,CAAC,EACpC,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,GACN,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAyBjD;AAGD,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["../../src/server_pages/otp.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,sBAAsB,EAAE,aAAa,CAAC;IAErD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,OAAO,CAAC,EACpC,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAS,EACT,SAAS,GACV,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAqCjD;AAGD,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -5,6 +5,7 @@ import "server-only";
5
5
  import { OTPLayout } from "../components/layouts/otp/index.js";
6
6
  import { AuthPageShell } from "../components/layouts/shared/components/auth_page_shell.js";
7
7
  import { DEFAULT_STRINGS, readStrings } from "../strings.js";
8
+ import { get_otp_config } from "../lib/otp_config.server.js";
8
9
  // section: component
9
10
  /**
10
11
  * Zero-config OTPPage server component
@@ -27,7 +28,7 @@ import { DEFAULT_STRINGS, readStrings } from "../strings.js";
27
28
  * @param props - Optional searchParams and title
28
29
  * @returns Server-rendered OTP sign-in page
29
30
  */
30
- export default async function OTPPage({ searchParams, title, subtitle, ctaText, theme, } = {}) {
31
+ export default async function OTPPage({ searchParams, title, subtitle, ctaText, theme, image_src, image_alt, } = {}) {
31
32
  var _a, _b, _c, _d;
32
33
  const params = searchParams instanceof Promise
33
34
  ? await searchParams
@@ -39,7 +40,16 @@ export default async function OTPPage({ searchParams, title, subtitle, ctaText,
39
40
  const resolved_title = (_b = title !== null && title !== void 0 ? title : otp_strings.title) !== null && _b !== void 0 ? _b : DEFAULT_STRINGS.otp.title;
40
41
  const resolved_subtitle = (_c = subtitle !== null && subtitle !== void 0 ? subtitle : otp_strings.subtitle) !== null && _c !== void 0 ? _c : DEFAULT_STRINGS.otp.subtitle;
41
42
  const resolved_cta = (_d = ctaText !== null && ctaText !== void 0 ? ctaText : otp_strings.ctaText) !== null && _d !== void 0 ? _d : DEFAULT_STRINGS.otp.ctaText;
42
- return (_jsx(AuthPageShell, { children: _jsx(OTPLayout, { redirect_url: redirect_url, title: resolved_title, subtitle: resolved_subtitle, ctaText: resolved_cta, theme: theme }) }));
43
+ // Resolve the visual-panel image: prop > [hazo_auth__otp] config > default.
44
+ // Without this the OTPLayout default (/hazo_auth/images/login_default.jpg)
45
+ // was unreachable from consuming apps, so any app that serves its auth
46
+ // images from somewhere else — e.g. the packaged /api/hazo_auth/assets/
47
+ // route rather than a copied-out public/ directory — rendered this page with
48
+ // an empty visual panel and a 404 in the console.
49
+ const otp_config = get_otp_config();
50
+ const resolved_image_src = image_src !== null && image_src !== void 0 ? image_src : otp_config.image_src;
51
+ const resolved_image_alt = image_alt !== null && image_alt !== void 0 ? image_alt : otp_config.image_alt;
52
+ return (_jsx(AuthPageShell, { children: _jsx(OTPLayout, { redirect_url: redirect_url, title: resolved_title, subtitle: resolved_subtitle, ctaText: resolved_cta, theme: theme, image_src: resolved_image_src, image_alt: resolved_image_alt }) }));
43
53
  }
44
54
  // Named export for direct imports
45
55
  export { OTPPage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "10.11.0",
3
+ "version": "10.15.0",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",
@@ -221,9 +221,24 @@
221
221
  "demo:create": "tsx --conditions react-server scripts/demo.ts create",
222
222
  "demo:delete": "tsx --conditions react-server scripts/demo.ts delete",
223
223
  "test": "cross-env NODE_ENV=test jest --runInBand",
224
- "test:watch": "cross-env NODE_ENV=test jest --watch"
224
+ "test:watch": "cross-env NODE_ENV=test jest --watch",
225
+ "test:vitest": "vitest run"
225
226
  },
226
227
  "dependencies": {
228
+ "@radix-ui/react-accordion": "^1.2.0",
229
+ "@radix-ui/react-alert-dialog": "^1.1.0",
230
+ "@radix-ui/react-avatar": "^1.1.0",
231
+ "@radix-ui/react-checkbox": "^1.3.0",
232
+ "@radix-ui/react-dialog": "^1.1.0",
233
+ "@radix-ui/react-dropdown-menu": "^2.1.0",
234
+ "@radix-ui/react-hover-card": "^1.1.0",
235
+ "@radix-ui/react-label": "^2.1.0",
236
+ "@radix-ui/react-select": "^2.2.0",
237
+ "@radix-ui/react-separator": "^1.1.0",
238
+ "@radix-ui/react-slot": "^1.2.0",
239
+ "@radix-ui/react-switch": "^1.2.0",
240
+ "@radix-ui/react-tabs": "^1.1.0",
241
+ "@radix-ui/react-tooltip": "^1.2.0",
227
242
  "axios": "^1.13.2",
228
243
  "browser-image-compression": "^2.0.2",
229
244
  "class-variance-authority": "^0.7.1",
@@ -231,11 +246,15 @@
231
246
  "date-fns": "^4.1.0",
232
247
  "gravatar-url": "^4.0.1",
233
248
  "ini": "^6.0.0",
249
+ "input-otp": "^1.4.0",
234
250
  "jose": "^5.9.6",
235
251
  "jsonwebtoken": "^9.0.2",
252
+ "lucide-react": "^0.553.0",
236
253
  "mime-types": "^3.0.1",
254
+ "next-themes": "^0.4.0",
237
255
  "react-markdown": "^10.1.0",
238
256
  "server-only": "^0.0.1",
257
+ "sonner": "^2.0.7",
239
258
  "tailwind-merge": "^3.5.0",
240
259
  "tw-animate-css": "^1.4.0",
241
260
  "zod": "^4.1.12"
@@ -252,42 +271,20 @@
252
271
  "multer": "^2.0.2"
253
272
  },
254
273
  "peerDependencies": {
255
- "@radix-ui/react-accordion": "^1.2.0",
256
- "@radix-ui/react-alert-dialog": "^1.1.0",
257
- "@radix-ui/react-avatar": "^1.1.0",
258
- "@radix-ui/react-checkbox": "^1.3.0",
259
- "@radix-ui/react-dialog": "^1.1.0",
260
- "@radix-ui/react-dropdown-menu": "^2.1.0",
261
- "@radix-ui/react-hover-card": "^1.1.0",
262
- "@radix-ui/react-label": "^2.1.0",
263
- "@radix-ui/react-select": "^2.2.0",
264
- "@radix-ui/react-separator": "^1.1.0",
265
- "@radix-ui/react-slot": "^1.2.0",
266
- "@radix-ui/react-switch": "^1.2.0",
267
- "@radix-ui/react-tabs": "^1.1.0",
268
- "@radix-ui/react-tooltip": "^1.2.0",
269
- "hazo_api": "^2.6.0",
270
274
  "hazo_config": "^2.4.1",
271
- "hazo_connect": "^3.9.2",
275
+ "hazo_connect": "^4.0.0",
272
276
  "hazo_core": "^1.3.0",
273
277
  "hazo_logs": "^2.1.1",
274
278
  "hazo_notify": "^6.1.4",
275
279
  "hazo_secure": "^1.7.0",
276
280
  "hazo_theme": "^1.0.1",
277
281
  "hazo_ui": "^6.3.1",
278
- "input-otp": "^1.4.0",
279
- "lucide-react": "^0.553.0",
280
282
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
281
283
  "next-auth": "^4.24.0",
282
- "next-themes": "^0.4.0",
283
284
  "react": "^18.0.0 || ^19.0.0",
284
- "react-dom": "^18.0.0 || ^19.0.0",
285
- "sonner": "^2.0.7"
285
+ "react-dom": "^18.0.0 || ^19.0.0"
286
286
  },
287
287
  "peerDependenciesMeta": {
288
- "hazo_api": {
289
- "optional": true
290
- },
291
288
  "hazo_config": {
292
289
  "optional": false
293
290
  },
@@ -311,60 +308,6 @@
311
308
  },
312
309
  "hazo_ui": {
313
310
  "optional": true
314
- },
315
- "next-themes": {
316
- "optional": true
317
- },
318
- "sonner": {
319
- "optional": true
320
- },
321
- "@radix-ui/react-accordion": {
322
- "optional": true
323
- },
324
- "@radix-ui/react-alert-dialog": {
325
- "optional": true
326
- },
327
- "@radix-ui/react-avatar": {
328
- "optional": true
329
- },
330
- "@radix-ui/react-checkbox": {
331
- "optional": true
332
- },
333
- "@radix-ui/react-dialog": {
334
- "optional": true
335
- },
336
- "@radix-ui/react-dropdown-menu": {
337
- "optional": true
338
- },
339
- "@radix-ui/react-hover-card": {
340
- "optional": true
341
- },
342
- "@radix-ui/react-label": {
343
- "optional": true
344
- },
345
- "@radix-ui/react-select": {
346
- "optional": true
347
- },
348
- "@radix-ui/react-separator": {
349
- "optional": true
350
- },
351
- "@radix-ui/react-slot": {
352
- "optional": true
353
- },
354
- "@radix-ui/react-switch": {
355
- "optional": true
356
- },
357
- "@radix-ui/react-tabs": {
358
- "optional": true
359
- },
360
- "@radix-ui/react-tooltip": {
361
- "optional": true
362
- },
363
- "lucide-react": {
364
- "optional": true
365
- },
366
- "input-otp": {
367
- "optional": true
368
311
  }
369
312
  },
370
313
  "devDependencies": {
@@ -411,13 +354,13 @@
411
354
  "eslint-config-next": "^16.0.4",
412
355
  "eslint-plugin-storybook": "^10.0.6",
413
356
  "hazo_api": "^2.6.0",
414
- "hazo_config": "^2.4.1",
415
- "hazo_connect": "^3.9.2",
416
- "hazo_core": "^1.3.0",
417
- "hazo_logs": "^2.1.1",
418
- "hazo_notify": "^6.1.4",
419
- "hazo_theme": "^1.0.1",
420
- "hazo_ui": "^6.3.1",
357
+ "hazo_config": "^2.4.2",
358
+ "hazo_connect": "^4.0.0",
359
+ "hazo_core": "^1.3.1",
360
+ "hazo_logs": "^2.2.0",
361
+ "hazo_notify": "^6.1.5",
362
+ "hazo_theme": "^1.3.0",
363
+ "hazo_ui": "^6.8.0",
421
364
  "input-otp": "^1.4.0",
422
365
  "jest": "^30.2.0",
423
366
  "jest-environment-jsdom": "^30.0.0",
@@ -436,6 +379,7 @@
436
379
  "tailwindcss": "^4.2.4",
437
380
  "ts-jest": "^29.4.5",
438
381
  "tsx": "^4.20.6",
439
- "typescript": "^5.7.2"
382
+ "typescript": "^5.7.2",
383
+ "vitest": "^4.1.5"
440
384
  }
441
385
  }