hazo_auth 5.2.0 → 5.3.1
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 +13 -0
- package/SETUP_CHECKLIST.md +46 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +1 -1
- package/cli-src/lib/auth/index.ts +1 -1
- package/cli-src/lib/services/email_service.ts +136 -289
- package/cli-src/lib/services/email_template_manifest.ts +104 -0
- package/cli-src/lib/services/email_templates/email_verification.html +18 -0
- package/cli-src/lib/services/email_templates/email_verification.txt +9 -0
- package/cli-src/lib/services/email_templates/forgot_password.html +18 -0
- package/cli-src/lib/services/email_templates/forgot_password.txt +9 -0
- package/cli-src/lib/services/email_templates/password_changed.html +14 -0
- package/cli-src/lib/services/email_templates/password_changed.txt +9 -0
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/lib/auth/hazo_get_auth.server.d.ts +6 -0
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +1 -1
- package/dist/lib/auth/index.d.ts +1 -1
- package/dist/lib/auth/index.d.ts.map +1 -1
- package/dist/lib/auth/index.js +1 -1
- package/dist/lib/services/email_service.d.ts +17 -4
- package/dist/lib/services/email_service.d.ts.map +1 -1
- package/dist/lib/services/email_service.js +93 -221
- package/dist/lib/services/email_template_manifest.d.ts +11 -0
- package/dist/lib/services/email_template_manifest.d.ts.map +1 -0
- package/dist/lib/services/email_template_manifest.js +95 -0
- package/dist/lib/services/email_templates/email_verification.html +18 -0
- package/dist/lib/services/email_templates/email_verification.txt +9 -0
- package/dist/lib/services/email_templates/forgot_password.html +18 -0
- package/dist/lib/services/email_templates/forgot_password.txt +9 -0
- package/dist/lib/services/email_templates/password_changed.html +14 -0
- package/dist/lib/services/email_templates/password_changed.txt +9 -0
- package/dist/server-lib.d.ts +1 -0
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +1 -0
- package/package.json +4 -3
- package/cli-src/assets/images/new_firm_default.jpg +0 -0
- package/cli-src/lib/auth/org_cache.ts +0 -148
- package/cli-src/lib/index.ts +0 -48
- package/cli-src/lib/services/org_service.ts +0 -965
- package/cli-src/lib/services/scope_labels_service.ts +0 -348
package/README.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
A reusable authentication UI component package powered by Next.js, TailwindCSS, and shadcn. It integrates `hazo_config` for configuration management and `hazo_connect` for data access, enabling future components to stay aligned with platform conventions.
|
|
4
4
|
|
|
5
|
+
### What's New in v5.3.1 🔧
|
|
6
|
+
|
|
7
|
+
**`get_client_ip(request)` exported from `hazo_auth/server-lib`** — extracts the client IP from `x-forwarded-for` (first element), falling back to `x-real-ip`, then `"unknown"`. Previously private to `hazo_get_auth.server.ts`. Useful for consumers that need consistent IP extraction across handlers (e.g., `hazo_feedback` audit logging).
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { get_client_ip } from "hazo_auth/server-lib";
|
|
11
|
+
|
|
12
|
+
export async function POST(request: NextRequest) {
|
|
13
|
+
const ip = get_client_ip(request);
|
|
14
|
+
// ...
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
5
18
|
### What's New in v5.1.39 🔧
|
|
6
19
|
|
|
7
20
|
**Postgres-Compatibility Schema Alignment** — fixes two long-standing drifts between the canonical SQLite schema and what the runtime actually writes. SQLite consumers see no behaviour change; Postgres + PostgREST consumers can now sign-up users without bespoke schema patches.
|
package/SETUP_CHECKLIST.md
CHANGED
|
@@ -2,6 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
This checklist provides step-by-step instructions for setting up the `hazo_auth` package in your Next.js project. AI assistants can follow this guide to ensure complete and correct setup.
|
|
4
4
|
|
|
5
|
+
## v5.3.0 Migration (from v5.2.x)
|
|
6
|
+
|
|
7
|
+
If you are already on hazo_auth `5.2.x`, the only mandatory work is wiring up hazo_notify's template manager at boot. Apps that don't use the templated email path (only the plain `send_email`) keep working unchanged after bumping the peer dep.
|
|
8
|
+
|
|
9
|
+
**1. Bump the peer dep.** Update your app's `package.json`:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
- "hazo_notify": "^1.1.0",
|
|
13
|
+
+ "hazo_notify": "^3.0.0",
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Then `npm install`.
|
|
17
|
+
|
|
18
|
+
**2. Apply the hazo_notify template-manager migration.** hazo_notify 3.0.0 introduces two new tables (`hazo_notify_template_cat`, `hazo_notify_templates`). If you are using SQLite via the existing schema seed, the tables are created on first connect when `initial_sql` is provided to the adapter (see step 4 below). If you are on PostgREST or you manage migrations explicitly, run `migrations/002_template_manager.sql` from hazo_notify.
|
|
19
|
+
|
|
20
|
+
**3. Register the `notify_templates_admin` permission (optional).** Users with this permission can edit auth email templates via the hazo_notify admin UI. Grant `notify_templates_super_admin` to also allow deleting system templates. These are hazo_notify permissions, declared in your app's permission set; hazo_auth does not grant them itself.
|
|
21
|
+
|
|
22
|
+
**4. Wire up `init_template_manager` and `set_hazo_notify_connect` at boot.** In your Next.js `instrumentation.ts` (or equivalent), feed hazo_auth's manifest into hazo_notify and register the connect instance with hazo_auth:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// instrumentation.ts
|
|
26
|
+
import { init_template_manager } from "hazo_notify/template_manager";
|
|
27
|
+
import { hazo_auth_template_manifest } from "hazo_auth/server-lib";
|
|
28
|
+
import { set_hazo_notify_connect } from "hazo_auth/server-lib"; // re-exported from email_service
|
|
29
|
+
import { build_my_hazo_notify_connect } from "./lib/hazo_notify_connect";
|
|
30
|
+
|
|
31
|
+
export async function register() {
|
|
32
|
+
if (process.env.NEXT_RUNTIME !== "nodejs") return;
|
|
33
|
+
|
|
34
|
+
const notify_connect = build_my_hazo_notify_connect();
|
|
35
|
+
|
|
36
|
+
await init_template_manager({
|
|
37
|
+
hazo_connect_factory: () => notify_connect,
|
|
38
|
+
manifests: [...hazo_auth_template_manifest],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
set_hazo_notify_connect(notify_connect);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`build_my_hazo_notify_connect()` is consuming-app code that wraps your `hazo_connect` adapter into the `HazoConnectInstance` shape hazo_notify expects (`list`/`findById`/`findBy`/`insert`/`updateById`/`deleteById`/`query`). hazo_auth's own test-app ships an example wrapper at `instrumentation_hazo_notify_connect.ts` you can copy.
|
|
46
|
+
|
|
47
|
+
**5. Migrate any custom templates.** The `[hazo_auth__email] email_template_main_directory` config key is deprecated and no longer overrides anything — a one-time `warn` log will fire on first send if it is set. Move any custom HTML/text into the admin UI as scope-specific (or super-admin-edited global) templates before `hazo_auth@6.0.0` removes the key.
|
|
48
|
+
|
|
49
|
+
**6. (Optional) Mount the template admin UI.** Use `<TemplateManagerAdmin />` from `hazo_notify/template_manager_admin` to give your admins a UI for managing the auth templates. See hazo_notify's docs for routing and permission-gating.
|
|
50
|
+
|
|
5
51
|
## Quick Start (Recommended)
|
|
6
52
|
|
|
7
53
|
The fastest way to set up hazo_auth:
|
|
@@ -64,7 +64,7 @@ function parse_app_user_data(
|
|
|
64
64
|
* @param request - NextRequest object
|
|
65
65
|
* @returns IP address string
|
|
66
66
|
*/
|
|
67
|
-
function get_client_ip(request: NextRequest): string {
|
|
67
|
+
export function get_client_ip(request: NextRequest): string {
|
|
68
68
|
const forwarded = request.headers.get("x-forwarded-for");
|
|
69
69
|
if (forwarded) {
|
|
70
70
|
return forwarded.split(",")[0].trim();
|