hazo_auth 8.0.1 → 9.0.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/cli-src/lib/AGENTS.md +26 -0
- package/cli-src/lib/app_logger.ts +3 -7
- package/cli-src/lib/auth/auth_utils.server.ts +2 -1
- package/cli-src/lib/auth/ensure_anon_id.server.ts +2 -1
- package/cli-src/lib/auth/hazo_get_auth.server.ts +11 -4
- package/cli-src/lib/config/hazo_auth_core_config.ts +44 -0
- package/cli-src/lib/cookies_config.server.ts +13 -10
- package/cli-src/lib/hazo_connect_setup.server.ts +19 -11
- package/cli-src/lib/legal/legal_docs_service.ts +2 -1
- package/cli-src/lib/services/email_service.ts +22 -11
- package/cli-src/lib/services/firm_service.ts +2 -1
- package/cli-src/lib/services/otp_service.ts +3 -2
- package/cli-src/lib/services/profile_picture_service.ts +2 -1
- package/cli-src/lib/services/relationship_service.ts +5 -4
- package/cli-src/lib/services/session_token_service.ts +3 -2
- package/cli-src/lib/utils/api_route_helpers.ts +4 -59
- package/cli-src/lib/utils/get_origin_url.ts +5 -61
- package/cli-src/lib/utils.ts +4 -10
- package/config/hazo_auth_config.example.ini +6 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/lib/app_logger.d.ts +2 -3
- package/dist/lib/app_logger.d.ts.map +1 -1
- package/dist/lib/app_logger.js +3 -5
- package/dist/lib/auth/auth_utils.server.d.ts.map +1 -1
- package/dist/lib/auth/auth_utils.server.js +2 -1
- package/dist/lib/auth/ensure_anon_id.server.d.ts.map +1 -1
- package/dist/lib/auth/ensure_anon_id.server.js +2 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +11 -4
- package/dist/lib/config/hazo_auth_core_config.d.ts +44 -0
- package/dist/lib/config/hazo_auth_core_config.d.ts.map +1 -0
- package/dist/lib/config/hazo_auth_core_config.js +40 -0
- package/dist/lib/cookies_config.server.d.ts.map +1 -1
- package/dist/lib/cookies_config.server.js +12 -7
- package/dist/lib/hazo_connect_setup.server.d.ts.map +1 -1
- package/dist/lib/hazo_connect_setup.server.js +18 -5
- package/dist/lib/legal/legal_docs_service.d.ts.map +1 -1
- package/dist/lib/legal/legal_docs_service.js +2 -1
- package/dist/lib/services/email_service.d.ts +1 -1
- package/dist/lib/services/email_service.d.ts.map +1 -1
- package/dist/lib/services/email_service.js +21 -9
- package/dist/lib/services/firm_service.d.ts.map +1 -1
- package/dist/lib/services/firm_service.js +2 -1
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +3 -2
- package/dist/lib/services/profile_picture_service.d.ts.map +1 -1
- package/dist/lib/services/profile_picture_service.js +2 -1
- package/dist/lib/services/relationship_service.d.ts.map +1 -1
- package/dist/lib/services/relationship_service.js +5 -4
- package/dist/lib/services/session_token_service.d.ts.map +1 -1
- package/dist/lib/services/session_token_service.js +3 -2
- package/dist/lib/utils/api_route_helpers.d.ts +1 -12
- package/dist/lib/utils/api_route_helpers.d.ts.map +1 -1
- package/dist/lib/utils/api_route_helpers.js +4 -57
- package/dist/lib/utils/get_origin_url.d.ts +1 -22
- package/dist/lib/utils/get_origin_url.d.ts.map +1 -1
- package/dist/lib/utils/get_origin_url.js +5 -57
- package/dist/lib/utils.d.ts +2 -3
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +4 -9
- package/dist/server/config/config_loader.js +2 -2
- package/dist/server/index.js +1 -1
- package/dist/server/routes/remove_profile_picture.d.ts.map +1 -1
- package/dist/server/routes/remove_profile_picture.js +6 -1
- package/dist/server/routes/upload_profile_picture.d.ts.map +1 -1
- package/dist/server/routes/upload_profile_picture.js +6 -1
- package/dist/server/routes/user_management_users.d.ts +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +7 -0
- package/package.json +29 -14
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCrudService } from "hazo_connect/server";
|
|
2
|
+
import { generateRequestId } from "hazo_core";
|
|
2
3
|
import argon2 from "argon2";
|
|
3
4
|
import { create_app_logger } from "../app_logger.js";
|
|
4
5
|
import { get_relationships_config, get_allowed_relationship_types } from "../relationships_config.server.js";
|
|
@@ -16,7 +17,7 @@ export function get_display_email(email) {
|
|
|
16
17
|
return is_sentinel_email(email) ? null : email;
|
|
17
18
|
}
|
|
18
19
|
function generate_sentinel_email() {
|
|
19
|
-
return `${SENTINEL_PREFIX}${
|
|
20
|
+
return `${SENTINEL_PREFIX}${generateRequestId().slice(4)}${SENTINEL_DOMAIN}`;
|
|
20
21
|
}
|
|
21
22
|
// section: helpers
|
|
22
23
|
/**
|
|
@@ -66,8 +67,8 @@ export async function create_managed_child(adapter, data) {
|
|
|
66
67
|
pin_hash = await argon2.hash(data.pin);
|
|
67
68
|
}
|
|
68
69
|
// Generate IDs
|
|
69
|
-
const child_user_id =
|
|
70
|
-
const relationship_id =
|
|
70
|
+
const child_user_id = generateRequestId().slice(4);
|
|
71
|
+
const relationship_id = generateRequestId().slice(4);
|
|
71
72
|
const now = new Date().toISOString();
|
|
72
73
|
// Insert managed child user
|
|
73
74
|
await users_service.insert({
|
|
@@ -276,7 +277,7 @@ export async function create_self_relationship(adapter, parent_user_id) {
|
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
279
|
const config = get_relationships_config();
|
|
279
|
-
const relationship_id =
|
|
280
|
+
const relationship_id = generateRequestId().slice(4);
|
|
280
281
|
const now = new Date().toISOString();
|
|
281
282
|
await relationships_service.insert({
|
|
282
283
|
id: relationship_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/session_token_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/session_token_service.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAuCF;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,kBAAkB,CAAC,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CA4CjB;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,0BAA0B,CAAC,CAkDrC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Uses jose library for Edge-compatible JWT operations
|
|
3
3
|
// section: imports
|
|
4
4
|
import { SignJWT, jwtVerify } from "jose";
|
|
5
|
+
import { HazoConfigError, HazoAuthError } from "hazo_core";
|
|
5
6
|
import { create_app_logger } from "../app_logger.js";
|
|
6
7
|
import { get_filename, get_line_number } from "../utils/api_route_helpers.js";
|
|
7
8
|
// section: helpers
|
|
@@ -19,7 +20,7 @@ function get_jwt_secret() {
|
|
|
19
20
|
line_number: get_line_number(),
|
|
20
21
|
error: "JWT_SECRET environment variable is required",
|
|
21
22
|
});
|
|
22
|
-
throw new
|
|
23
|
+
throw new HazoConfigError({ code: 'HAZO_AUTH_CONFIG', pkg: 'hazo_auth', message: 'JWT_SECRET environment variable is required' });
|
|
23
24
|
}
|
|
24
25
|
// Convert string secret to Uint8Array for jose
|
|
25
26
|
return new TextEncoder().encode(jwt_secret);
|
|
@@ -79,7 +80,7 @@ export async function create_session_token(user_id, email, managed_by_user_id, t
|
|
|
79
80
|
error_message,
|
|
80
81
|
error_stack,
|
|
81
82
|
});
|
|
82
|
-
throw new
|
|
83
|
+
throw new HazoAuthError({ code: 'HAZO_AUTH_INVALID_TOKEN', pkg: 'hazo_auth', message: 'Failed to create session token' });
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Gets the filename from the call stack
|
|
3
|
-
* This is a simplified version that extracts the filename from the error stack
|
|
4
|
-
* @returns Filename or "route.ts" as default
|
|
5
|
-
*/
|
|
6
|
-
export declare function get_filename(): string;
|
|
7
|
-
/**
|
|
8
|
-
* Gets the line number from the call stack
|
|
9
|
-
* This is a simplified version that extracts the line number from the error stack
|
|
10
|
-
* @returns Line number or 0
|
|
11
|
-
*/
|
|
12
|
-
export declare function get_line_number(): number;
|
|
1
|
+
export { get_filename, get_line_number } from 'hazo_logs';
|
|
13
2
|
//# sourceMappingURL=api_route_helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_route_helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/api_route_helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api_route_helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/api_route_helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,58 +1,5 @@
|
|
|
1
1
|
// file_description: shared helper functions for API routes to get filename and line number
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @returns Filename or "route.ts" as default
|
|
7
|
-
*/
|
|
8
|
-
export function get_filename() {
|
|
9
|
-
try {
|
|
10
|
-
const stack = new Error().stack;
|
|
11
|
-
if (!stack) {
|
|
12
|
-
return "route.ts";
|
|
13
|
-
}
|
|
14
|
-
// Parse stack trace to find the caller's file
|
|
15
|
-
const lines = stack.split("\n");
|
|
16
|
-
// Skip Error line and get_filename line, get the actual caller
|
|
17
|
-
for (let i = 2; i < lines.length; i++) {
|
|
18
|
-
const line = lines[i];
|
|
19
|
-
// Match file paths in stack trace (e.g., "at /path/to/file.ts:123:45")
|
|
20
|
-
const match = line.match(/([^/\\]+\.tsx?):(\d+):(\d+)/);
|
|
21
|
-
if (match) {
|
|
22
|
-
return match[1];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return "route.ts";
|
|
26
|
-
}
|
|
27
|
-
catch (_a) {
|
|
28
|
-
return "route.ts";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the line number from the call stack
|
|
33
|
-
* This is a simplified version that extracts the line number from the error stack
|
|
34
|
-
* @returns Line number or 0
|
|
35
|
-
*/
|
|
36
|
-
export function get_line_number() {
|
|
37
|
-
try {
|
|
38
|
-
const stack = new Error().stack;
|
|
39
|
-
if (!stack) {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
// Parse stack trace to find the caller's line number
|
|
43
|
-
const lines = stack.split("\n");
|
|
44
|
-
// Skip Error line and get_line_number line, get the actual caller
|
|
45
|
-
for (let i = 2; i < lines.length; i++) {
|
|
46
|
-
const line = lines[i];
|
|
47
|
-
// Match line numbers in stack trace (e.g., "at /path/to/file.ts:123:45")
|
|
48
|
-
const match = line.match(/([^/\\]+\.tsx?):(\d+):(\d+)/);
|
|
49
|
-
if (match) {
|
|
50
|
-
return parseInt(match[2], 10) || 0;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
catch (_a) {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
2
|
+
// Canonical location moved to hazo_logs/src/lib/utils/caller_info.ts.
|
|
3
|
+
// This re-export maintains backward compatibility for hazo_auth consumers.
|
|
4
|
+
// Will be removed in hazo_auth v9 — import from 'hazo_logs' directly.
|
|
5
|
+
export { get_filename, get_line_number } from 'hazo_logs';
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Gets the public-facing origin URL for redirect construction.
|
|
3
|
-
*
|
|
4
|
-
* Behind reverse proxies (Cloudflare, nginx, etc.), `request.url` contains the
|
|
5
|
-
* internal address (e.g. `http://localhost:3000`), not the public domain.
|
|
6
|
-
* This function returns the correct origin from environment variables.
|
|
7
|
-
*
|
|
8
|
-
* Priority: NEXTAUTH_URL > APP_DOMAIN_NAME > NEXT_PUBLIC_APP_URL > APP_URL > request.url
|
|
9
|
-
*
|
|
10
|
-
* @param request_url - The request.url to use as fallback
|
|
11
|
-
* @returns The origin URL (e.g. "https://gotimer.org")
|
|
12
|
-
*/
|
|
13
|
-
export declare function get_origin_url(request_url: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a URL using the public-facing origin instead of request.url.
|
|
16
|
-
* Drop-in replacement for `new URL(path, request.url)` in route handlers.
|
|
17
|
-
*
|
|
18
|
-
* @param path - The path or relative URL (e.g. "/hazo_auth/login")
|
|
19
|
-
* @param request_url - The request.url (used as fallback only)
|
|
20
|
-
* @returns A URL object with the correct public origin
|
|
21
|
-
*/
|
|
22
|
-
export declare function create_redirect_url(path: string, request_url: string): URL;
|
|
1
|
+
export { get_origin_url, create_redirect_url } from 'hazo_core';
|
|
23
2
|
//# sourceMappingURL=get_origin_url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_origin_url.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/get_origin_url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_origin_url.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/get_origin_url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,57 +1,5 @@
|
|
|
1
|
-
// file_description:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
* Gets the public-facing origin URL for redirect construction.
|
|
7
|
-
*
|
|
8
|
-
* Behind reverse proxies (Cloudflare, nginx, etc.), `request.url` contains the
|
|
9
|
-
* internal address (e.g. `http://localhost:3000`), not the public domain.
|
|
10
|
-
* This function returns the correct origin from environment variables.
|
|
11
|
-
*
|
|
12
|
-
* Priority: NEXTAUTH_URL > APP_DOMAIN_NAME > NEXT_PUBLIC_APP_URL > APP_URL > request.url
|
|
13
|
-
*
|
|
14
|
-
* @param request_url - The request.url to use as fallback
|
|
15
|
-
* @returns The origin URL (e.g. "https://gotimer.org")
|
|
16
|
-
*/
|
|
17
|
-
export function get_origin_url(request_url) {
|
|
18
|
-
// NEXTAUTH_URL is the standard for NextAuth.js apps
|
|
19
|
-
const nextauth_url = process.env.NEXTAUTH_URL;
|
|
20
|
-
if (nextauth_url) {
|
|
21
|
-
return nextauth_url.replace(/\/$/, "");
|
|
22
|
-
}
|
|
23
|
-
// APP_DOMAIN_NAME (with protocol handling)
|
|
24
|
-
const app_domain = process.env.APP_DOMAIN_NAME;
|
|
25
|
-
if (app_domain) {
|
|
26
|
-
const domain = app_domain.trim();
|
|
27
|
-
if (domain.startsWith("http://") || domain.startsWith("https://")) {
|
|
28
|
-
return domain.replace(/\/$/, "");
|
|
29
|
-
}
|
|
30
|
-
return `https://${domain}`;
|
|
31
|
-
}
|
|
32
|
-
// Other common env vars
|
|
33
|
-
const env_url = process.env.NEXT_PUBLIC_APP_URL || process.env.APP_URL;
|
|
34
|
-
if (env_url) {
|
|
35
|
-
return env_url.replace(/\/$/, "");
|
|
36
|
-
}
|
|
37
|
-
// Fallback to request.url (works in development without a proxy)
|
|
38
|
-
try {
|
|
39
|
-
const url = new URL(request_url);
|
|
40
|
-
return url.origin;
|
|
41
|
-
}
|
|
42
|
-
catch (_a) {
|
|
43
|
-
return request_url;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Creates a URL using the public-facing origin instead of request.url.
|
|
48
|
-
* Drop-in replacement for `new URL(path, request.url)` in route handlers.
|
|
49
|
-
*
|
|
50
|
-
* @param path - The path or relative URL (e.g. "/hazo_auth/login")
|
|
51
|
-
* @param request_url - The request.url (used as fallback only)
|
|
52
|
-
* @returns A URL object with the correct public origin
|
|
53
|
-
*/
|
|
54
|
-
export function create_redirect_url(path, request_url) {
|
|
55
|
-
const origin = get_origin_url(request_url);
|
|
56
|
-
return new URL(path, origin);
|
|
57
|
-
}
|
|
1
|
+
// file_description: Re-exports get_origin_url and create_redirect_url from hazo_core.
|
|
2
|
+
// Canonical location moved to hazo_core/http in hazo_core v1.
|
|
3
|
+
// This re-export maintains backward compatibility for hazo_auth consumers.
|
|
4
|
+
// Will be removed in hazo_auth v9 — import from 'hazo_core' directly.
|
|
5
|
+
export { get_origin_url, create_redirect_url } from 'hazo_core';
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
1
|
+
export { cn } from "hazo_ui";
|
|
2
|
+
export { cn as merge_class_names } from "hazo_ui";
|
|
4
3
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG7B,OAAO,EAAE,EAAE,IAAI,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
// file_description:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function merge_class_names(...inputs) {
|
|
6
|
-
return twMerge(clsx(inputs));
|
|
7
|
-
}
|
|
8
|
-
// section: shadcn_compatibility_helper
|
|
9
|
-
export const cn = (...inputs) => merge_class_names(...inputs);
|
|
1
|
+
// file_description: re-exports cn and merge_class_names from hazo_ui (canonical source)
|
|
2
|
+
export { cn } from "hazo_ui";
|
|
3
|
+
// merge_class_names alias — kept for backward compatibility
|
|
4
|
+
export { cn as merge_class_names } from "hazo_ui";
|
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
import axios from "axios";
|
|
6
6
|
import { HazoConfig } from "hazo_config/server";
|
|
7
|
-
import { createLogger } from "
|
|
7
|
+
import { createLogger } from "hazo_core";
|
|
8
8
|
const is_string_record = (value) => !!value &&
|
|
9
9
|
typeof value === "object" &&
|
|
10
10
|
!Array.isArray(value) &&
|
|
@@ -268,7 +268,7 @@ export const load_runtime_configuration = (options) => {
|
|
|
268
268
|
const fallback_logger = createLogger("hazo_auth_config");
|
|
269
269
|
const parsed_options = sanitize_configuration_options(options, fallback_logger);
|
|
270
270
|
const direct_configuration = parsed_options.direct_configuration;
|
|
271
|
-
const logger = (_a = direct_configuration === null || direct_configuration === void 0 ? void 0 : direct_configuration.logger) !== null && _a !== void 0 ? _a : fallback_logger;
|
|
271
|
+
const logger = ((_a = direct_configuration === null || direct_configuration === void 0 ? void 0 : direct_configuration.logger) !== null && _a !== void 0 ? _a : fallback_logger);
|
|
272
272
|
let hazo_config;
|
|
273
273
|
try {
|
|
274
274
|
const config_file_path = (_b = parsed_options === null || parsed_options === void 0 ? void 0 : parsed_options.config_file_path) !== null && _b !== void 0 ? _b : default_config_path;
|
package/dist/server/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var _a;
|
|
|
3
3
|
// section: imports
|
|
4
4
|
import http from "http";
|
|
5
5
|
import { create_server_app } from "./server.js";
|
|
6
|
-
import { createLogger } from "
|
|
6
|
+
import { createLogger } from "hazo_core";
|
|
7
7
|
// section: constants
|
|
8
8
|
const default_port = Number((_a = process.env.PORT) !== null && _a !== void 0 ? _a : 4100);
|
|
9
9
|
// section: bootstrap_runner
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove_profile_picture.d.ts","sourceRoot":"","sources":["../../../src/server/routes/remove_profile_picture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"remove_profile_picture.d.ts","sourceRoot":"","sources":["../../../src/server/routes/remove_profile_picture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQxD,wBAAsB,MAAM,CAAC,OAAO,EAAE,WAAW;;;;;IAsGhD"}
|
|
@@ -5,6 +5,7 @@ import { get_hazo_connect_instance } from "../../lib/hazo_connect_instance.serve
|
|
|
5
5
|
import { create_app_logger } from "../../lib/app_logger.js";
|
|
6
6
|
import { remove_user_profile_picture } from "../../lib/services/profile_picture_remove_service.js";
|
|
7
7
|
import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
|
|
8
|
+
import { optional_import } from "hazo_core";
|
|
8
9
|
// section: api_handler
|
|
9
10
|
export async function DELETE(request) {
|
|
10
11
|
const logger = create_app_logger();
|
|
@@ -36,7 +37,11 @@ export async function DELETE(request) {
|
|
|
36
37
|
return NextResponse.json({ error: "Relationship accounts not enabled" }, { status: 403 });
|
|
37
38
|
}
|
|
38
39
|
const hazoConnect_rel = get_hazo_connect_instance();
|
|
39
|
-
const
|
|
40
|
+
const hazo_connect_module = await optional_import("hazo_connect/server");
|
|
41
|
+
if (!hazo_connect_module) {
|
|
42
|
+
return NextResponse.json({ error: "hazo_connect not available" }, { status: 503 });
|
|
43
|
+
}
|
|
44
|
+
const { createCrudService } = hazo_connect_module;
|
|
40
45
|
const rel_service = createCrudService(hazoConnect_rel, "hazo_user_relationships");
|
|
41
46
|
const rels = await rel_service.findBy({ parent_user_id: user_id, child_user_id: target_user_id });
|
|
42
47
|
if (!rels || rels.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload_profile_picture.d.ts","sourceRoot":"","sources":["../../../src/server/routes/upload_profile_picture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"upload_profile_picture.d.ts","sourceRoot":"","sources":["../../../src/server/routes/upload_profile_picture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAcxD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;;;IAsR9C"}
|
|
@@ -9,6 +9,7 @@ import { update_user_profile_picture } from "../../lib/services/profile_picture_
|
|
|
9
9
|
import { createCrudService } from "hazo_connect/server";
|
|
10
10
|
import { map_db_source_to_ui } from "../../lib/services/profile_picture_source_mapper.js";
|
|
11
11
|
import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
|
|
12
|
+
import { optional_import } from "hazo_core";
|
|
12
13
|
import fs from "fs";
|
|
13
14
|
import path from "path";
|
|
14
15
|
// section: api_handler
|
|
@@ -42,7 +43,11 @@ export async function POST(request) {
|
|
|
42
43
|
return NextResponse.json({ error: "Relationship accounts not enabled" }, { status: 403 });
|
|
43
44
|
}
|
|
44
45
|
const hazoConnect = get_hazo_connect_instance();
|
|
45
|
-
const
|
|
46
|
+
const hazo_connect_module = await optional_import("hazo_connect/server");
|
|
47
|
+
if (!hazo_connect_module) {
|
|
48
|
+
return NextResponse.json({ error: "hazo_connect not available" }, { status: 503 });
|
|
49
|
+
}
|
|
50
|
+
const { createCrudService: createRelCrudService } = hazo_connect_module;
|
|
46
51
|
const rel_service = createRelCrudService(hazoConnect, "hazo_user_relationships");
|
|
47
52
|
const rels = await rel_service.findBy({ parent_user_id: user_id, child_user_id: target_user_id });
|
|
48
53
|
if (!rels || rels.length === 0) {
|
|
@@ -26,7 +26,7 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
|
|
|
26
26
|
profile_source: {} | null;
|
|
27
27
|
user_type: string | null;
|
|
28
28
|
app_user_data: Record<string, unknown> | null;
|
|
29
|
-
legal_acceptance_status: "current" | "
|
|
29
|
+
legal_acceptance_status: "current" | "none" | "outdated";
|
|
30
30
|
}[];
|
|
31
31
|
}>>;
|
|
32
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,eAAO,MAAM,iBAAiB,QAAO,WAoBpC,CAAC"}
|
package/dist/server/server.js
CHANGED
|
@@ -7,6 +7,7 @@ import cookie_parser from "cookie-parser";
|
|
|
7
7
|
import compression from "compression";
|
|
8
8
|
import { create_root_router } from "./routes/root_router.js";
|
|
9
9
|
import { create_app_context } from "./config/config_loader.js";
|
|
10
|
+
import { withContext, generateRequestId, REQUEST_ID_HEADER } from "hazo_core";
|
|
10
11
|
// section: app_factory
|
|
11
12
|
export const create_server_app = () => {
|
|
12
13
|
const server_app = express();
|
|
@@ -15,6 +16,12 @@ export const create_server_app = () => {
|
|
|
15
16
|
server_app.use(express.json({ limit: "1mb" }));
|
|
16
17
|
server_app.use(express.urlencoded({ extended: true }));
|
|
17
18
|
server_app.use(cookie_parser());
|
|
19
|
+
server_app.use((request, response, next) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const correlationId = (_a = request.headers[REQUEST_ID_HEADER]) !== null && _a !== void 0 ? _a : generateRequestId();
|
|
22
|
+
response.setHeader(REQUEST_ID_HEADER, correlationId);
|
|
23
|
+
withContext({ correlationId }, () => next());
|
|
24
|
+
});
|
|
18
25
|
server_app.use(compression());
|
|
19
26
|
server_app.use((request, _response, next) => {
|
|
20
27
|
request.context = create_app_context();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.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",
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
"dev:server": "tsx src/server/index.ts",
|
|
207
207
|
"migrate": "tsx scripts/apply_migration.ts",
|
|
208
208
|
"init-users": "tsx scripts/init_users.ts init_users",
|
|
209
|
-
"test": "cross-env NODE_ENV=test
|
|
210
|
-
"test:watch": "cross-env NODE_ENV=test
|
|
209
|
+
"test": "cross-env NODE_ENV=test jest --runInBand",
|
|
210
|
+
"test:watch": "cross-env NODE_ENV=test jest --watch"
|
|
211
211
|
},
|
|
212
212
|
"dependencies": {
|
|
213
213
|
"axios": "^1.13.2",
|
|
@@ -252,13 +252,16 @@
|
|
|
252
252
|
"@radix-ui/react-switch": "^1.2.0",
|
|
253
253
|
"@radix-ui/react-tabs": "^1.1.0",
|
|
254
254
|
"@radix-ui/react-tooltip": "^1.2.0",
|
|
255
|
-
"
|
|
256
|
-
"
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
"
|
|
255
|
+
"hazo_api": "^2.1.0",
|
|
256
|
+
"hazo_config": "^2.1.5",
|
|
257
|
+
"hazo_connect": "^3.0.0",
|
|
258
|
+
"hazo_core": "^1.0.0",
|
|
259
|
+
"hazo_logs": "^2.0.0",
|
|
260
|
+
"hazo_notify": "^6.0.0",
|
|
261
|
+
"hazo_ui": "^3.1.0",
|
|
262
|
+
"input-otp": "^1.4.0",
|
|
260
263
|
"lucide-react": "^0.553.0",
|
|
261
|
-
"next": "
|
|
264
|
+
"next": "^14.0.0",
|
|
262
265
|
"next-auth": "^4.24.0",
|
|
263
266
|
"next-themes": "^0.4.0",
|
|
264
267
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -266,12 +269,18 @@
|
|
|
266
269
|
"sonner": "^2.0.7"
|
|
267
270
|
},
|
|
268
271
|
"peerDependenciesMeta": {
|
|
272
|
+
"hazo_api": {
|
|
273
|
+
"optional": true
|
|
274
|
+
},
|
|
269
275
|
"hazo_config": {
|
|
270
276
|
"optional": false
|
|
271
277
|
},
|
|
272
278
|
"hazo_connect": {
|
|
273
279
|
"optional": false
|
|
274
280
|
},
|
|
281
|
+
"hazo_core": {
|
|
282
|
+
"optional": false
|
|
283
|
+
},
|
|
275
284
|
"hazo_logs": {
|
|
276
285
|
"optional": false
|
|
277
286
|
},
|
|
@@ -331,6 +340,9 @@
|
|
|
331
340
|
},
|
|
332
341
|
"lucide-react": {
|
|
333
342
|
"optional": true
|
|
343
|
+
},
|
|
344
|
+
"input-otp": {
|
|
345
|
+
"optional": true
|
|
334
346
|
}
|
|
335
347
|
},
|
|
336
348
|
"devDependencies": {
|
|
@@ -376,11 +388,14 @@
|
|
|
376
388
|
"eslint": "^9.39.1",
|
|
377
389
|
"eslint-config-next": "^16.0.4",
|
|
378
390
|
"eslint-plugin-storybook": "^10.0.6",
|
|
379
|
-
"
|
|
380
|
-
"
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
"
|
|
391
|
+
"hazo_api": "^2.1.0",
|
|
392
|
+
"hazo_config": "^2.1.6",
|
|
393
|
+
"hazo_connect": "^3.0.0",
|
|
394
|
+
"hazo_core": "^1.0.0",
|
|
395
|
+
"hazo_logs": "^2.0.1",
|
|
396
|
+
"hazo_notify": "^6.0.0",
|
|
397
|
+
"hazo_ui": "^3.1.0",
|
|
398
|
+
"input-otp": "^1.4.0",
|
|
384
399
|
"jest": "^30.2.0",
|
|
385
400
|
"jest-environment-jsdom": "^30.0.0",
|
|
386
401
|
"lucide-react": "^0.553.0",
|