hazo_auth 7.0.2 → 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/README.md +34 -0
- package/SETUP_CHECKLIST.md +31 -0
- package/cli-src/lib/AGENTS.md +26 -0
- package/cli-src/lib/app_logger.ts +3 -7
- package/cli-src/lib/auth/auth_types.ts +3 -0
- 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 +30 -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_config.server.ts +61 -0
- package/cli-src/lib/legal/legal_docs_reader.server.ts +36 -0
- package/cli-src/lib/legal/legal_docs_service.ts +197 -0
- package/cli-src/lib/legal/legal_docs_types.ts +31 -0
- 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/registration_service.ts +16 -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/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -0
- package/dist/components/layouts/index.d.ts +1 -0
- package/dist/components/layouts/index.d.ts.map +1 -1
- package/dist/components/layouts/index.js +2 -0
- package/dist/components/layouts/legal/index.d.ts +5 -0
- package/dist/components/layouts/legal/index.d.ts.map +1 -0
- package/dist/components/layouts/legal/index.js +4 -0
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts +7 -0
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -0
- package/dist/components/layouts/legal/legal_acceptance_gate.js +84 -0
- package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts +9 -0
- package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts.map +1 -0
- package/dist/components/layouts/legal/legal_doc_checkbox_list.js +11 -0
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts +9 -0
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -0
- package/dist/components/layouts/legal/legal_doc_combined_view.js +11 -0
- package/dist/components/layouts/legal/legal_doc_drawer.d.ts +8 -0
- package/dist/components/layouts/legal/legal_doc_drawer.d.ts.map +1 -0
- package/dist/components/layouts/legal/legal_doc_drawer.js +55 -0
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +5 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +25 -10
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +21 -1
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +45 -7
- package/dist/components/ui/input-otp.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +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_types.d.ts +2 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -1
- package/dist/lib/auth/auth_types.js +0 -2
- 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 +30 -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_config.server.d.ts +22 -0
- package/dist/lib/legal/legal_docs_config.server.d.ts.map +1 -0
- package/dist/lib/legal/legal_docs_config.server.js +52 -0
- package/dist/lib/legal/legal_docs_reader.server.d.ts +15 -0
- package/dist/lib/legal/legal_docs_reader.server.d.ts.map +1 -0
- package/dist/lib/legal/legal_docs_reader.server.js +24 -0
- package/dist/lib/legal/legal_docs_service.d.ts +49 -0
- package/dist/lib/legal/legal_docs_service.d.ts.map +1 -0
- package/dist/lib/legal/legal_docs_service.js +141 -0
- package/dist/lib/legal/legal_docs_types.d.ts +25 -0
- package/dist/lib/legal/legal_docs_types.d.ts.map +1 -0
- package/dist/lib/legal/legal_docs_types.js +2 -0
- 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/registration_service.d.ts +5 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +6 -0
- 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/page_components/index.d.ts +0 -5
- package/dist/page_components/index.d.ts.map +1 -1
- package/dist/page_components/index.js +0 -5
- package/dist/server/config/config_loader.js +2 -2
- package/dist/server/index.js +1 -1
- package/dist/server/routes/index.d.ts +3 -0
- package/dist/server/routes/index.d.ts.map +1 -1
- package/dist/server/routes/index.js +4 -0
- package/dist/server/routes/legal_docs_accept.d.ts +3 -0
- package/dist/server/routes/legal_docs_accept.d.ts.map +1 -0
- package/dist/server/routes/legal_docs_accept.js +43 -0
- package/dist/server/routes/legal_docs_get.d.ts +3 -0
- package/dist/server/routes/legal_docs_get.d.ts.map +1 -0
- package/dist/server/routes/legal_docs_get.js +49 -0
- package/dist/server/routes/legal_docs_publish.d.ts +3 -0
- package/dist/server/routes/legal_docs_publish.d.ts.map +1 -0
- package/dist/server/routes/legal_docs_publish.js +35 -0
- package/dist/server/routes/register.d.ts.map +1 -1
- package/dist/server/routes/register.js +26 -0
- 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 +2 -2
- package/dist/server/routes/user_management_users.d.ts.map +1 -1
- package/dist/server/routes/user_management_users.js +46 -2
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +7 -0
- package/dist/strings.d.ts +2 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/strings.js +3 -0
- package/package.json +33 -35
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write legal acceptance records. Call from:
|
|
3
|
+
* - registration_service (bundled with register POST, pre-session)
|
|
4
|
+
* - legal_docs_accept route (authenticated, post-login)
|
|
5
|
+
*
|
|
6
|
+
* Inserts one row per doc into hazo_legal_acceptances (audit history) and
|
|
7
|
+
* merges the result into the denormalised hazo_users.legal_acceptance JSONB
|
|
8
|
+
* column for fast "has this user accepted the current version?" queries.
|
|
9
|
+
*/
|
|
10
|
+
export declare function write_legal_acceptance(adapter: any, user_id: string, accepted: Record<string, {
|
|
11
|
+
hash: string;
|
|
12
|
+
}>, ip: string | null, user_agent: string | null): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Publish a doc version as the new required version (admin action).
|
|
15
|
+
* Upserts hazo_legal_doc_versions keyed on doc_key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function publish_doc_version(adapter: any, doc_key: string, required_hash: string, published_by_user_id: string): Promise<{
|
|
18
|
+
published_at: string;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Return required version info keyed by doc_key.
|
|
22
|
+
*/
|
|
23
|
+
export declare function get_required_versions(adapter: any, doc_keys: string[]): Promise<Record<string, {
|
|
24
|
+
required_hash: string;
|
|
25
|
+
published_at: string;
|
|
26
|
+
}>>;
|
|
27
|
+
/**
|
|
28
|
+
* Return acceptance history for a user across all doc keys, newest first.
|
|
29
|
+
*/
|
|
30
|
+
export declare function get_user_acceptance_history(adapter: any, user_id: string): Promise<Array<{
|
|
31
|
+
doc_key: string;
|
|
32
|
+
doc_hash: string;
|
|
33
|
+
accepted_at: string;
|
|
34
|
+
ip: string | null;
|
|
35
|
+
user_agent: string | null;
|
|
36
|
+
}>>;
|
|
37
|
+
/**
|
|
38
|
+
* Count how many users have accepted the current required hash for a doc key.
|
|
39
|
+
* Returns { current, total } where current is users on the required_hash and
|
|
40
|
+
* total is all users in the system (including those with no legal_acceptance data).
|
|
41
|
+
*
|
|
42
|
+
* Note: This performs an in-process scan over all users. For large user bases
|
|
43
|
+
* consider a dedicated SQL query in a future optimisation.
|
|
44
|
+
*/
|
|
45
|
+
export declare function get_compliance_count(adapter: any, doc_key: string, required_hash: string): Promise<{
|
|
46
|
+
current: number;
|
|
47
|
+
total: number;
|
|
48
|
+
}>;
|
|
49
|
+
//# sourceMappingURL=legal_docs_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legal_docs_service.d.ts","sourceRoot":"","sources":["../../../src/lib/legal/legal_docs_service.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAC1C,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CA2BnC;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAoB1E;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC,CAAC,CAeF;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkB7C"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// file_description: service functions for the legal document acceptance system
|
|
2
|
+
// section: imports
|
|
3
|
+
import { createCrudService } from 'hazo_connect/server';
|
|
4
|
+
import { generateRequestId } from 'hazo_core';
|
|
5
|
+
// section: helpers
|
|
6
|
+
function generate_id() {
|
|
7
|
+
return generateRequestId().slice(4);
|
|
8
|
+
}
|
|
9
|
+
// section: exports
|
|
10
|
+
/**
|
|
11
|
+
* Write legal acceptance records. Call from:
|
|
12
|
+
* - registration_service (bundled with register POST, pre-session)
|
|
13
|
+
* - legal_docs_accept route (authenticated, post-login)
|
|
14
|
+
*
|
|
15
|
+
* Inserts one row per doc into hazo_legal_acceptances (audit history) and
|
|
16
|
+
* merges the result into the denormalised hazo_users.legal_acceptance JSONB
|
|
17
|
+
* column for fast "has this user accepted the current version?" queries.
|
|
18
|
+
*/
|
|
19
|
+
export async function write_legal_acceptance(adapter, user_id, accepted, ip, user_agent) {
|
|
20
|
+
var _a;
|
|
21
|
+
const now = new Date().toISOString();
|
|
22
|
+
// 1. Insert one history row per doc
|
|
23
|
+
const history_service = createCrudService(adapter, 'hazo_legal_acceptances');
|
|
24
|
+
for (const [doc_key, { hash }] of Object.entries(accepted)) {
|
|
25
|
+
await history_service.insert({
|
|
26
|
+
id: generate_id(),
|
|
27
|
+
user_id,
|
|
28
|
+
doc_key,
|
|
29
|
+
doc_hash: hash,
|
|
30
|
+
accepted_at: now,
|
|
31
|
+
ip,
|
|
32
|
+
user_agent,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// 2. Merge into denormalized JSONB on hazo_users
|
|
36
|
+
const users_service = createCrudService(adapter, 'hazo_users');
|
|
37
|
+
const rows = await users_service.findBy({ id: user_id });
|
|
38
|
+
const existing_raw = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.legal_acceptance;
|
|
39
|
+
let existing = {};
|
|
40
|
+
if (existing_raw) {
|
|
41
|
+
try {
|
|
42
|
+
existing = typeof existing_raw === 'string'
|
|
43
|
+
? JSON.parse(existing_raw)
|
|
44
|
+
: existing_raw;
|
|
45
|
+
}
|
|
46
|
+
catch ( /* corrupt — start fresh */_b) { /* corrupt — start fresh */ }
|
|
47
|
+
}
|
|
48
|
+
const updated = Object.assign({}, existing);
|
|
49
|
+
for (const [doc_key, { hash }] of Object.entries(accepted)) {
|
|
50
|
+
updated[doc_key] = { hash, accepted_at: now, ip, user_agent };
|
|
51
|
+
}
|
|
52
|
+
await users_service.updateById(user_id, {
|
|
53
|
+
legal_acceptance: JSON.stringify(updated),
|
|
54
|
+
changed_at: now,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Publish a doc version as the new required version (admin action).
|
|
59
|
+
* Upserts hazo_legal_doc_versions keyed on doc_key.
|
|
60
|
+
*/
|
|
61
|
+
export async function publish_doc_version(adapter, doc_key, required_hash, published_by_user_id) {
|
|
62
|
+
const now = new Date().toISOString();
|
|
63
|
+
// createCrudService with doc_key as primary key so updateById works correctly
|
|
64
|
+
const versions_service = createCrudService(adapter, 'hazo_legal_doc_versions', {
|
|
65
|
+
primaryKeys: ['doc_key'],
|
|
66
|
+
autoId: false,
|
|
67
|
+
});
|
|
68
|
+
const existing = await versions_service.findBy({ doc_key });
|
|
69
|
+
if (existing.length > 0) {
|
|
70
|
+
await versions_service.updateById(doc_key, {
|
|
71
|
+
required_hash,
|
|
72
|
+
published_at: now,
|
|
73
|
+
published_by_user_id,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
await versions_service.insert({
|
|
78
|
+
doc_key,
|
|
79
|
+
required_hash,
|
|
80
|
+
published_at: now,
|
|
81
|
+
published_by_user_id,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return { published_at: now };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Return required version info keyed by doc_key.
|
|
88
|
+
*/
|
|
89
|
+
export async function get_required_versions(adapter, doc_keys) {
|
|
90
|
+
if (doc_keys.length === 0)
|
|
91
|
+
return {};
|
|
92
|
+
const versions_service = createCrudService(adapter, 'hazo_legal_doc_versions', {
|
|
93
|
+
primaryKeys: ['doc_key'],
|
|
94
|
+
autoId: false,
|
|
95
|
+
});
|
|
96
|
+
const rows = await versions_service.list((qb) => qb.whereIn('doc_key', doc_keys).select(['doc_key', 'required_hash', 'published_at']));
|
|
97
|
+
const result = {};
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
result[String(row.doc_key)] = {
|
|
100
|
+
required_hash: String(row.required_hash),
|
|
101
|
+
published_at: String(row.published_at),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Return acceptance history for a user across all doc keys, newest first.
|
|
108
|
+
*/
|
|
109
|
+
export async function get_user_acceptance_history(adapter, user_id) {
|
|
110
|
+
const history_service = createCrudService(adapter, 'hazo_legal_acceptances');
|
|
111
|
+
return history_service.list((qb) => qb
|
|
112
|
+
.where('user_id', 'eq', user_id)
|
|
113
|
+
.select(['doc_key', 'doc_hash', 'accepted_at', 'ip', 'user_agent'])
|
|
114
|
+
.order('accepted_at', 'desc'));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Count how many users have accepted the current required hash for a doc key.
|
|
118
|
+
* Returns { current, total } where current is users on the required_hash and
|
|
119
|
+
* total is all users in the system (including those with no legal_acceptance data).
|
|
120
|
+
*
|
|
121
|
+
* Note: This performs an in-process scan over all users. For large user bases
|
|
122
|
+
* consider a dedicated SQL query in a future optimisation.
|
|
123
|
+
*/
|
|
124
|
+
export async function get_compliance_count(adapter, doc_key, required_hash) {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
const users_service = createCrudService(adapter, 'hazo_users');
|
|
127
|
+
const all_users = await users_service.list((qb) => qb.select(['id', 'legal_acceptance']));
|
|
128
|
+
let current = 0;
|
|
129
|
+
for (const user of all_users) {
|
|
130
|
+
let map = {};
|
|
131
|
+
try {
|
|
132
|
+
map = typeof user.legal_acceptance === 'string'
|
|
133
|
+
? JSON.parse(user.legal_acceptance)
|
|
134
|
+
: ((_a = user.legal_acceptance) !== null && _a !== void 0 ? _a : {});
|
|
135
|
+
}
|
|
136
|
+
catch ( /* ignore corrupt rows */_c) { /* ignore corrupt rows */ }
|
|
137
|
+
if (((_b = map[doc_key]) === null || _b === void 0 ? void 0 : _b.hash) === required_hash)
|
|
138
|
+
current++;
|
|
139
|
+
}
|
|
140
|
+
return { current, total: all_users.length };
|
|
141
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface LegalDocConfig {
|
|
2
|
+
key: string;
|
|
3
|
+
title: string;
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LegalDocsConfig {
|
|
7
|
+
docs: LegalDocConfig[];
|
|
8
|
+
display_mode: 'separate' | 'combined';
|
|
9
|
+
}
|
|
10
|
+
export interface LegalDoc {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
content: string;
|
|
14
|
+
hash: string;
|
|
15
|
+
required_hash: string | null;
|
|
16
|
+
required_published_at: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface LegalAcceptanceRecord {
|
|
19
|
+
hash: string;
|
|
20
|
+
accepted_at: string;
|
|
21
|
+
ip: string | null;
|
|
22
|
+
user_agent: string | null;
|
|
23
|
+
}
|
|
24
|
+
export type LegalAcceptanceMap = Record<string, LegalAcceptanceRecord>;
|
|
25
|
+
//# sourceMappingURL=legal_docs_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legal_docs_types.d.ts","sourceRoot":"","sources":["../../../src/lib/legal/legal_docs_types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,YAAY,EAAE,UAAU,GAAG,UAAU,CAAC;CACvC;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAGD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/email_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/email_service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,4BAA4B,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAElH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAiBF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAE3E;AAmMD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA4ErG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,iBAAiB,EAChC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA4F/C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// file_description: service for sending emails with template support
|
|
2
2
|
// section: imports
|
|
3
3
|
import { create_app_logger } from "../app_logger.js";
|
|
4
|
+
import { HazoConfigError, optional_import } from "hazo_core";
|
|
4
5
|
import { read_config_section } from "../config/config_loader.server.js";
|
|
5
6
|
// section: singleton
|
|
6
7
|
/**
|
|
@@ -49,8 +50,11 @@ async function get_hazo_notify_instance() {
|
|
|
49
50
|
});
|
|
50
51
|
try {
|
|
51
52
|
// Dynamic import to avoid build-time issues with hazo_notify
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const hazo_notify_email_module = await optional_import('hazo_notify/adapters/email');
|
|
54
|
+
if (!hazo_notify_email_module) {
|
|
55
|
+
throw new Error("hazo_notify is not installed");
|
|
56
|
+
}
|
|
57
|
+
const { load_emailer_config } = hazo_notify_email_module;
|
|
54
58
|
hazo_notify_config = load_emailer_config();
|
|
55
59
|
}
|
|
56
60
|
catch (error) {
|
|
@@ -60,7 +64,7 @@ async function get_hazo_notify_instance() {
|
|
|
60
64
|
line_number: 0,
|
|
61
65
|
error: error_message,
|
|
62
66
|
});
|
|
63
|
-
throw new
|
|
67
|
+
throw new HazoConfigError({ code: 'HAZO_AUTH_CONFIG', pkg: 'hazo_auth', message: `Failed to load hazo_notify config: ${error_message}` });
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
return hazo_notify_config;
|
|
@@ -217,8 +221,12 @@ export async function send_email(options) {
|
|
|
217
221
|
// Get hazo_notify configuration instance
|
|
218
222
|
const notify_config = await get_hazo_notify_instance();
|
|
219
223
|
// Dynamic import to avoid build-time issues with hazo_notify
|
|
220
|
-
const
|
|
221
|
-
|
|
224
|
+
const hazo_notify_email_module = await optional_import('hazo_notify/adapters/email');
|
|
225
|
+
if (!hazo_notify_email_module) {
|
|
226
|
+
throw new Error("hazo_notify is not installed");
|
|
227
|
+
}
|
|
228
|
+
const { get_email_provider } = hazo_notify_email_module;
|
|
229
|
+
const provider = get_email_provider(notify_config);
|
|
222
230
|
// Get from email and from name (hazo_auth_config overrides hazo_notify_config)
|
|
223
231
|
// Priority: 1. options.from (explicit parameter), 2. hazo_auth_config.from_email, 3. hazo_notify_config.from_email
|
|
224
232
|
const from_email = options.from || await get_email_from(notify_config);
|
|
@@ -233,7 +241,7 @@ export async function send_email(options) {
|
|
|
233
241
|
from_name: from_name,
|
|
234
242
|
};
|
|
235
243
|
// Send email using hazo_notify
|
|
236
|
-
const result = await
|
|
244
|
+
const result = await provider.send_email(hazo_notify_options, notify_config);
|
|
237
245
|
if (result.success) {
|
|
238
246
|
logger.info("email_sent", {
|
|
239
247
|
filename: "email_service.ts",
|
|
@@ -306,9 +314,13 @@ export async function send_template_email(template_type, to, data) {
|
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
316
|
if (!hazo_notify_connect) {
|
|
309
|
-
throw new
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
throw new HazoConfigError({
|
|
318
|
+
code: 'HAZO_AUTH_CONFIG',
|
|
319
|
+
pkg: 'hazo_auth',
|
|
320
|
+
message: "hazo_notify connect not initialized. Call set_hazo_notify_connect() " +
|
|
321
|
+
"from instrumentation.ts with the same HazoConnectInstance you pass " +
|
|
322
|
+
"to init_template_manager({ hazo_connect_factory }).",
|
|
323
|
+
});
|
|
312
324
|
}
|
|
313
325
|
const notify_config = await get_hazo_notify_instance();
|
|
314
326
|
const from = await get_email_from(notify_config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firm_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/firm_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"firm_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/firm_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAKvD,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIzE,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAWF;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqEjE;AAqFD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA4E3B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAmCjE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCrudService } from "hazo_connect/server";
|
|
2
|
+
import { generateRequestId } from "hazo_core";
|
|
2
3
|
import { create_app_logger } from "../app_logger.js";
|
|
3
4
|
import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
|
|
4
5
|
import { create_scope } from "./scope_service.js";
|
|
@@ -101,7 +102,7 @@ async function assign_owner_permissions(adapter, role_id) {
|
|
|
101
102
|
let permission_id;
|
|
102
103
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
103
104
|
// Create permission with generated UUID
|
|
104
|
-
const perm_id =
|
|
105
|
+
const perm_id = generateRequestId().slice(4);
|
|
105
106
|
const inserted = await permission_service.insert({
|
|
106
107
|
id: perm_id,
|
|
107
108
|
permission_name: perm_name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/otp_service.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"otp_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/otp_service.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAWrB;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjE;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMtF;AAID,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,cAAc,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AAItE;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmHjC;AAID,MAAM,MAAM,oBAAoB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAAA;CAAE,CAAC;AAE3D,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAsHhC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import crypto from "node:crypto";
|
|
3
|
+
import { generateRequestId } from "hazo_core";
|
|
3
4
|
import argon2 from "argon2";
|
|
4
5
|
import { createCrudService } from "hazo_connect/server";
|
|
5
6
|
import { get_otp_config, hazo_auth_otp_session_ttl_seconds } from "../otp_config.server.js";
|
|
@@ -102,7 +103,7 @@ export async function request_email_otp(args) {
|
|
|
102
103
|
const code = generate_otp_code();
|
|
103
104
|
const otp_hash = await hash_otp_code(code);
|
|
104
105
|
const expires_at = new Date(Date.now() + cfg.code_ttl_seconds * 1000).toISOString();
|
|
105
|
-
const row_id =
|
|
106
|
+
const row_id = generateRequestId().slice(4);
|
|
106
107
|
await otp_table.insert({
|
|
107
108
|
id: row_id,
|
|
108
109
|
user_id: existing_user ? String(existing_user.id) : null,
|
|
@@ -191,7 +192,7 @@ export async function verify_email_otp(args) {
|
|
|
191
192
|
}
|
|
192
193
|
else if (cfg.auto_register) {
|
|
193
194
|
// Create user + bind scope/role
|
|
194
|
-
const new_user_id =
|
|
195
|
+
const new_user_id = generateRequestId().slice(4);
|
|
195
196
|
await users_table.insert({
|
|
196
197
|
id: new_user_id,
|
|
197
198
|
email_address: email,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_picture_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/profile_picture_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"profile_picture_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/profile_picture_service.ts"],"names":[],"mappings":"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C,EAAE,MAAM,GACjB,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CA+D7C;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,EAC3B,cAAc,EAAE,oBAAoB,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB/C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCrudService } from "hazo_connect/server";
|
|
2
2
|
import gravatarUrl from "gravatar-url";
|
|
3
|
+
import { fetchWithRequestId } from "hazo_core";
|
|
3
4
|
import { get_profile_picture_config } from "../profile_picture_config.server.js";
|
|
4
5
|
import { get_ui_sizes_config } from "../ui_sizes_config.server.js";
|
|
5
6
|
import { get_file_types_config } from "../file_types_config.server.js";
|
|
@@ -248,7 +249,7 @@ async function check_gravatar_exists(email) {
|
|
|
248
249
|
const uiSizes = get_ui_sizes_config();
|
|
249
250
|
const gravatar_url = get_gravatar_url(email, uiSizes.gravatar_size);
|
|
250
251
|
// Make HEAD request to check if image exists without downloading it
|
|
251
|
-
const response = await
|
|
252
|
+
const response = await fetchWithRequestId(gravatar_url, {
|
|
252
253
|
method: 'HEAD',
|
|
253
254
|
// Add timeout to prevent hanging
|
|
254
255
|
signal: AbortSignal.timeout(5000) // 5 second timeout
|
|
@@ -4,6 +4,11 @@ export type RegistrationData = {
|
|
|
4
4
|
password: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
url_on_logon?: string;
|
|
7
|
+
legal_accepted?: Record<string, {
|
|
8
|
+
hash: string;
|
|
9
|
+
}>;
|
|
10
|
+
ip?: string | null;
|
|
11
|
+
user_agent?: string | null;
|
|
7
12
|
};
|
|
8
13
|
export type RegistrationResult = {
|
|
9
14
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/registration_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"registration_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/registration_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAmBvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAmK7B"}
|
|
@@ -10,6 +10,7 @@ import { send_template_email } from "./email_service.js";
|
|
|
10
10
|
import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
|
|
11
11
|
import { get_line_number } from "../utils/api_route_helpers.js";
|
|
12
12
|
import { is_user_types_enabled, get_default_user_type, } from "../user_types_config.server.js";
|
|
13
|
+
import { write_legal_acceptance } from "../legal/legal_docs_service.js";
|
|
13
14
|
// section: helpers
|
|
14
15
|
/**
|
|
15
16
|
* Registers a new user in the database using hazo_connect
|
|
@@ -18,6 +19,7 @@ import { is_user_types_enabled, get_default_user_type, } from "../user_types_con
|
|
|
18
19
|
* @returns Registration result with success status and user_id or error
|
|
19
20
|
*/
|
|
20
21
|
export async function register_user(adapter, data) {
|
|
22
|
+
var _a, _b;
|
|
21
23
|
try {
|
|
22
24
|
const { email, password, name, url_on_logon } = data;
|
|
23
25
|
// Create CRUD service for hazo_users table
|
|
@@ -130,6 +132,10 @@ export async function register_user(adapter, data) {
|
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
134
|
}
|
|
135
|
+
// Write legal acceptance records if provided
|
|
136
|
+
if (data.legal_accepted && Object.keys(data.legal_accepted).length > 0) {
|
|
137
|
+
await write_legal_acceptance(adapter, user_id, data.legal_accepted, (_a = data.ip) !== null && _a !== void 0 ? _a : null, (_b = data.user_agent) !== null && _b !== void 0 ? _b : null);
|
|
138
|
+
}
|
|
133
139
|
return {
|
|
134
140
|
success: true,
|
|
135
141
|
user_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationship_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/relationship_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"relationship_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/relationship_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQvD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,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AAa,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8CzH;AAED;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAmBzC"}
|
|
@@ -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';
|