hazo_auth 6.1.1 → 7.0.2
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 +65 -167
- package/SETUP_CHECKLIST.md +28 -100
- package/cli-src/cli/generate.ts +1 -10
- package/cli-src/cli/validate.ts +0 -4
- package/cli-src/lib/auth/auth_types.ts +12 -21
- package/cli-src/lib/auth/hazo_get_tenant_auth.server.ts +24 -25
- package/cli-src/lib/auth/index.ts +2 -2
- package/cli-src/lib/auth/nextauth_config.ts +61 -1
- package/cli-src/lib/auth/with_auth.server.ts +15 -15
- package/cli-src/lib/config/default_config.ts +8 -0
- package/cli-src/lib/cookies_config.server.ts +1 -1
- package/cli-src/lib/login_config.server.ts +2 -18
- package/cli-src/lib/oauth_config.server.ts +32 -0
- package/cli-src/lib/register_config.server.ts +4 -0
- package/cli-src/lib/services/email_template_manifest.ts +0 -17
- package/cli-src/lib/services/index.ts +2 -8
- package/cli-src/lib/services/oauth_service.ts +143 -0
- package/cli-src/lib/services/otp_service.ts +7 -2
- package/cli-src/lib/services/session_token_service.ts +0 -2
- package/config/hazo_auth_config.example.ini +0 -38
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +1 -10
- package/dist/cli/validate.d.ts.map +1 -1
- package/dist/cli/validate.js +0 -4
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -1
- package/dist/components/layouts/login/index.d.ts +5 -7
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +5 -2
- package/dist/components/layouts/otp/index.d.ts +12 -1
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +4 -2
- package/dist/components/layouts/register/index.d.ts +4 -0
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +4 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts +21 -0
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -0
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +47 -0
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -8
- package/dist/components/layouts/shared/index.d.ts +2 -0
- package/dist/components/layouts/shared/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/index.js +1 -0
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +39 -2
- package/dist/consent/consent_state.d.ts +18 -0
- package/dist/consent/consent_state.d.ts.map +1 -0
- package/dist/consent/consent_state.js +29 -0
- package/dist/consent/cookie_consent_banner.d.ts +11 -0
- package/dist/consent/cookie_consent_banner.d.ts.map +1 -0
- package/dist/consent/cookie_consent_banner.js +40 -0
- package/dist/consent/gtm_mapping.d.ts +13 -0
- package/dist/consent/gtm_mapping.d.ts.map +1 -0
- package/dist/consent/gtm_mapping.js +30 -0
- package/dist/consent/index.d.ts +7 -0
- package/dist/consent/index.d.ts.map +1 -0
- package/dist/consent/index.js +7 -0
- package/dist/consent/manage_modal.d.ts +2 -0
- package/dist/consent/manage_modal.d.ts.map +1 -0
- package/dist/consent/manage_modal.js +33 -0
- package/dist/consent/read_consent.d.ts +15 -0
- package/dist/consent/read_consent.d.ts.map +1 -0
- package/dist/consent/read_consent.js +23 -0
- package/dist/consent/use_consent.d.ts +7 -0
- package/dist/consent/use_consent.d.ts.map +1 -0
- package/dist/consent/use_consent.js +55 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/auth/auth_types.d.ts +12 -13
- package/dist/lib/auth/auth_types.d.ts.map +1 -1
- package/dist/lib/auth/auth_types.js +0 -8
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts +7 -8
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_tenant_auth.server.js +22 -23
- package/dist/lib/auth/index.d.ts +2 -2
- package/dist/lib/auth/index.d.ts.map +1 -1
- package/dist/lib/auth/nextauth_config.d.ts.map +1 -1
- package/dist/lib/auth/nextauth_config.js +50 -1
- package/dist/lib/auth/with_auth.server.d.ts +13 -13
- package/dist/lib/auth/with_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/with_auth.server.js +2 -2
- package/dist/lib/config/default_config.d.ts +16 -0
- package/dist/lib/config/default_config.d.ts.map +1 -1
- package/dist/lib/config/default_config.js +8 -0
- package/dist/lib/cookies_config.server.d.ts +1 -1
- package/dist/lib/cookies_config.server.js +1 -1
- package/dist/lib/login_config.server.d.ts +0 -6
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +2 -11
- package/dist/lib/oauth_config.server.d.ts +8 -0
- package/dist/lib/oauth_config.server.d.ts.map +1 -1
- package/dist/lib/oauth_config.server.js +10 -0
- package/dist/lib/register_config.server.d.ts +2 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +2 -0
- package/dist/lib/services/email_template_manifest.d.ts.map +1 -1
- package/dist/lib/services/email_template_manifest.js +0 -17
- package/dist/lib/services/index.d.ts +0 -2
- package/dist/lib/services/index.d.ts.map +1 -1
- package/dist/lib/services/index.js +0 -1
- package/dist/lib/services/oauth_service.d.ts +13 -0
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +122 -0
- package/dist/lib/services/otp_service.d.ts +1 -1
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +6 -1
- package/dist/lib/services/session_token_service.d.ts +0 -2
- package/dist/lib/services/session_token_service.d.ts.map +1 -1
- package/dist/lib/services/session_token_service.js +0 -2
- package/dist/server/routes/assets.d.ts +8 -0
- package/dist/server/routes/assets.d.ts.map +1 -0
- package/dist/server/routes/assets.js +38 -0
- package/dist/server/routes/consent_me.d.ts +4 -0
- package/dist/server/routes/consent_me.d.ts.map +1 -0
- package/dist/server/routes/consent_me.js +15 -0
- package/dist/server/routes/index.d.ts +6 -3
- package/dist/server/routes/index.d.ts.map +1 -1
- package/dist/server/routes/index.js +9 -4
- package/dist/server/routes/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +1 -43
- package/dist/server/routes/oauth_facebook_callback.d.ts +8 -0
- package/dist/server/routes/oauth_facebook_callback.d.ts.map +1 -0
- package/dist/server/routes/oauth_facebook_callback.js +164 -0
- package/dist/server/routes/otp/verify.js +2 -2
- package/dist/server/routes/strings_defaults.d.ts +4 -0
- package/dist/server/routes/strings_defaults.d.ts.map +1 -0
- package/dist/server/routes/strings_defaults.js +7 -0
- package/dist/server/routes/user_management_users.d.ts +11 -0
- package/dist/server/routes/user_management_users.d.ts.map +1 -1
- package/dist/server/routes/user_management_users.js +50 -0
- package/dist/server-lib.d.ts +0 -3
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +0 -2
- package/dist/server_pages/forgot_password.d.ts +1 -1
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +9 -3
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +3 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +2 -2
- package/dist/server_pages/index.d.ts +2 -0
- package/dist/server_pages/index.d.ts.map +1 -1
- package/dist/server_pages/index.js +1 -0
- package/dist/server_pages/login.d.ts +1 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +12 -3
- package/dist/server_pages/login_client_wrapper.d.ts +4 -1
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +2 -2
- package/dist/server_pages/my_settings.d.ts +1 -1
- package/dist/server_pages/my_settings.d.ts.map +1 -1
- package/dist/server_pages/my_settings.js +1 -2
- package/dist/server_pages/otp.d.ts +16 -2
- package/dist/server_pages/otp.d.ts.map +1 -1
- package/dist/server_pages/otp.js +10 -3
- package/dist/server_pages/register.d.ts +1 -1
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +11 -3
- package/dist/server_pages/register_client_wrapper.d.ts +3 -1
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +2 -2
- package/dist/server_pages/reset_password.d.ts +1 -1
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +9 -3
- package/dist/server_pages/reset_password_client_wrapper.d.ts +3 -1
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +2 -2
- package/dist/server_pages/verify_email.d.ts +1 -1
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +8 -3
- package/dist/server_pages/verify_email_client_wrapper.d.ts +3 -1
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +2 -2
- package/dist/strings/default_strings.d.ts +47 -0
- package/dist/strings/default_strings.d.ts.map +1 -0
- package/dist/strings/default_strings.js +18 -0
- package/dist/strings/index.d.ts +4 -0
- package/dist/strings/index.d.ts.map +1 -0
- package/dist/strings/index.js +3 -0
- package/dist/strings/strings_context.d.ts +12 -0
- package/dist/strings/strings_context.d.ts.map +1 -0
- package/dist/strings/strings_context.js +23 -0
- package/dist/strings/strings_provider.d.ts +26 -0
- package/dist/strings/strings_provider.d.ts.map +1 -0
- package/dist/strings/strings_provider.js +45 -0
- package/dist/theme/create_theme.d.ts +7 -0
- package/dist/theme/create_theme.d.ts.map +1 -0
- package/dist/theme/create_theme.js +97 -0
- package/dist/theme/hex_to_hsl.d.ts +16 -0
- package/dist/theme/hex_to_hsl.d.ts.map +1 -0
- package/dist/theme/hex_to_hsl.js +110 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/luminance.d.ts +11 -0
- package/dist/theme/luminance.d.ts.map +1 -0
- package/dist/theme/luminance.js +45 -0
- package/dist/theme/theme_provider.d.ts +14 -0
- package/dist/theme/theme_provider.d.ts.map +1 -0
- package/dist/theme/theme_provider.js +23 -0
- package/dist/theme/theme_types.d.ts +36 -0
- package/dist/theme/theme_types.d.ts.map +1 -0
- package/dist/theme/theme_types.js +1 -0
- package/dist/themes/index.d.ts +2 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +2 -0
- package/dist/themes/preset_neutral.d.ts +3 -0
- package/dist/themes/preset_neutral.d.ts.map +1 -0
- package/dist/themes/preset_neutral.js +14 -0
- package/package.json +25 -22
|
@@ -11,6 +11,14 @@ export type GoogleOAuthData = {
|
|
|
11
11
|
/** Whether Google has verified this email */
|
|
12
12
|
email_verified: boolean;
|
|
13
13
|
};
|
|
14
|
+
export type FacebookOAuthData = {
|
|
15
|
+
facebook_id: string;
|
|
16
|
+
email: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
profile_picture_url?: string;
|
|
19
|
+
/** Facebook does not always verify emails — only link when hazo user is verified */
|
|
20
|
+
email_verified: boolean;
|
|
21
|
+
};
|
|
14
22
|
export type OAuthLoginResult = {
|
|
15
23
|
success: boolean;
|
|
16
24
|
user_id?: string;
|
|
@@ -45,6 +53,11 @@ export type AuthProvidersResult = {
|
|
|
45
53
|
* @returns OAuth login result with user_id and status flags
|
|
46
54
|
*/
|
|
47
55
|
export declare function handle_google_oauth_login(adapter: HazoConnectAdapter, data: GoogleOAuthData): Promise<OAuthLoginResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Handles Facebook OAuth login: find-by-facebook_id → find-by-email+link → create new.
|
|
58
|
+
* Mirrors handle_google_oauth_login exactly. Uses auto_link_unverified_accounts gate.
|
|
59
|
+
*/
|
|
60
|
+
export declare function handle_facebook_oauth_login(adapter: HazoConnectAdapter, data: FacebookOAuthData): Promise<OAuthLoginResult>;
|
|
48
61
|
/**
|
|
49
62
|
* Links a Google account to an existing user
|
|
50
63
|
* @param adapter - The hazo_connect adapter instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/oauth_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASvD,MAAM,MAAM,eAAe,GAAG;IAC5B,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,kBAAkB,EA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AAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAgE3B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA2C9B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0D/C"}
|
|
@@ -167,6 +167,128 @@ export async function handle_google_oauth_login(adapter, data) {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Handles Facebook OAuth login: find-by-facebook_id → find-by-email+link → create new.
|
|
172
|
+
* Mirrors handle_google_oauth_login exactly. Uses auto_link_unverified_accounts gate.
|
|
173
|
+
*/
|
|
174
|
+
export async function handle_facebook_oauth_login(adapter, data) {
|
|
175
|
+
const logger = create_app_logger();
|
|
176
|
+
try {
|
|
177
|
+
const { facebook_id, email, name, profile_picture_url, email_verified } = data;
|
|
178
|
+
const oauth_config = get_oauth_config();
|
|
179
|
+
const users_service = createCrudService(adapter, "hazo_users");
|
|
180
|
+
const now = new Date().toISOString();
|
|
181
|
+
// Step 1: existing user with this facebook_id
|
|
182
|
+
const users_by_fb_id = await users_service.findBy({ facebook_id });
|
|
183
|
+
if (Array.isArray(users_by_fb_id) && users_by_fb_id.length > 0) {
|
|
184
|
+
const user = users_by_fb_id[0];
|
|
185
|
+
await users_service.updateById(user.id, { last_logon: now, changed_at: now });
|
|
186
|
+
logger.info("oauth_service_facebook_login_existing_fb_user", {
|
|
187
|
+
filename: "oauth_service.ts",
|
|
188
|
+
user_id: user.id,
|
|
189
|
+
email: user.email_address,
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
user_id: user.id,
|
|
194
|
+
is_new_user: false,
|
|
195
|
+
was_linked: false,
|
|
196
|
+
email: user.email_address,
|
|
197
|
+
name: user.name,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// Step 2: existing user with matching email
|
|
201
|
+
const users_by_email = await users_service.findBy({ email_address: email });
|
|
202
|
+
if (Array.isArray(users_by_email) && users_by_email.length > 0) {
|
|
203
|
+
const user = users_by_email[0];
|
|
204
|
+
const user_email_verified = user.email_verified;
|
|
205
|
+
if (!user_email_verified && !oauth_config.auto_link_unverified_accounts) {
|
|
206
|
+
return {
|
|
207
|
+
success: false,
|
|
208
|
+
error: "An account with this email exists but is not verified. Please verify your email first.",
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const current_auth_providers = user.auth_providers || "email";
|
|
212
|
+
const new_auth_providers = current_auth_providers.includes("facebook")
|
|
213
|
+
? current_auth_providers
|
|
214
|
+
: `${current_auth_providers},facebook`;
|
|
215
|
+
const update_data = {
|
|
216
|
+
facebook_id,
|
|
217
|
+
auth_providers: new_auth_providers,
|
|
218
|
+
last_logon: now,
|
|
219
|
+
changed_at: now,
|
|
220
|
+
};
|
|
221
|
+
if (!user_email_verified && email_verified) {
|
|
222
|
+
update_data.email_verified = true;
|
|
223
|
+
}
|
|
224
|
+
if (!user.name && name)
|
|
225
|
+
update_data.name = name;
|
|
226
|
+
if (!user.profile_picture_url && profile_picture_url) {
|
|
227
|
+
update_data.profile_picture_url = profile_picture_url;
|
|
228
|
+
update_data.profile_source = "custom";
|
|
229
|
+
}
|
|
230
|
+
await users_service.updateById(user.id, update_data);
|
|
231
|
+
logger.info("oauth_service_facebook_linked_to_existing", {
|
|
232
|
+
filename: "oauth_service.ts",
|
|
233
|
+
user_id: user.id,
|
|
234
|
+
email,
|
|
235
|
+
was_unverified: !user_email_verified,
|
|
236
|
+
});
|
|
237
|
+
return {
|
|
238
|
+
success: true,
|
|
239
|
+
user_id: user.id,
|
|
240
|
+
is_new_user: false,
|
|
241
|
+
was_linked: true,
|
|
242
|
+
email: user.email_address,
|
|
243
|
+
name: user.name,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
// Step 3: create new user
|
|
247
|
+
const user_id = randomUUID();
|
|
248
|
+
const insert_data = {
|
|
249
|
+
id: user_id,
|
|
250
|
+
email_address: email,
|
|
251
|
+
facebook_id,
|
|
252
|
+
auth_providers: "facebook",
|
|
253
|
+
email_verified: email_verified,
|
|
254
|
+
last_logon: now,
|
|
255
|
+
created_at: now,
|
|
256
|
+
changed_at: now,
|
|
257
|
+
};
|
|
258
|
+
if (name)
|
|
259
|
+
insert_data.name = name;
|
|
260
|
+
if (profile_picture_url) {
|
|
261
|
+
insert_data.profile_picture_url = profile_picture_url;
|
|
262
|
+
insert_data.profile_source = "custom";
|
|
263
|
+
}
|
|
264
|
+
const inserted = await users_service.insert(insert_data);
|
|
265
|
+
if (!Array.isArray(inserted) || inserted.length === 0) {
|
|
266
|
+
return { success: false, error: "Failed to create user account" };
|
|
267
|
+
}
|
|
268
|
+
logger.info("oauth_service_facebook_new_user_created", {
|
|
269
|
+
filename: "oauth_service.ts",
|
|
270
|
+
user_id,
|
|
271
|
+
email,
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
success: true,
|
|
275
|
+
user_id,
|
|
276
|
+
is_new_user: true,
|
|
277
|
+
was_linked: false,
|
|
278
|
+
email,
|
|
279
|
+
name,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
const user_friendly_error = sanitize_error_for_user(error, {
|
|
284
|
+
logToConsole: true,
|
|
285
|
+
logToLogger: true,
|
|
286
|
+
logger,
|
|
287
|
+
context: { filename: "oauth_service.ts", email: data.email, operation: "handle_facebook_oauth_login" },
|
|
288
|
+
});
|
|
289
|
+
return { success: false, error: user_friendly_error };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
170
292
|
/**
|
|
171
293
|
* Links a Google account to an existing user
|
|
172
294
|
* @param adapter - The hazo_connect adapter instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/otp_service.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAUrB;;;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,
|
|
1
|
+
{"version":3,"file":"otp_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/otp_service.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAUrB;;;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"}
|
|
@@ -111,6 +111,11 @@ export async function request_email_otp(args) {
|
|
|
111
111
|
expires_at,
|
|
112
112
|
attempt_count: 0,
|
|
113
113
|
requester_ip: ip,
|
|
114
|
+
// Explicitly pass created_at in JS ISO format ("2024-01-01T00:00:00.000Z") rather
|
|
115
|
+
// than relying on SQLite's DEFAULT (datetime('now') = "2024-01-01 00:00:00").
|
|
116
|
+
// The space-separated SQLite format compares as less-than the T-separated JS ISO
|
|
117
|
+
// threshold used in rate-limit WHERE clauses, causing the counter to always read 0.
|
|
118
|
+
created_at: new Date().toISOString(),
|
|
114
119
|
});
|
|
115
120
|
// 7. Dispatch email — fire-and-forget; errors are logged but do not surface to caller
|
|
116
121
|
try {
|
|
@@ -155,7 +160,7 @@ export async function verify_email_otp(args) {
|
|
|
155
160
|
// 2. Check expiry
|
|
156
161
|
const expires_at_ms = Date.parse(String(row.expires_at));
|
|
157
162
|
if (Number.isNaN(expires_at_ms) || expires_at_ms < Date.now()) {
|
|
158
|
-
return { ok: false, error: "
|
|
163
|
+
return { ok: false, error: "expired" };
|
|
159
164
|
}
|
|
160
165
|
// 3. argon2 verify
|
|
161
166
|
const is_valid = await verify_otp_code(String(row.otp_hash), code);
|
|
@@ -16,8 +16,6 @@ export type ValidateSessionTokenResult = {
|
|
|
16
16
|
* Token includes user_id, email, issued at time, and expiration
|
|
17
17
|
* @param user_id - User ID
|
|
18
18
|
* @param email - User email address
|
|
19
|
-
* @param managed_by_user_id - Optional: ID of the managing user (for impersonation)
|
|
20
|
-
* @param ttl_seconds - Optional: token lifetime in seconds (default: 30 days). Use 604800 for 7-day OTP sessions.
|
|
21
19
|
* @returns JWT token string
|
|
22
20
|
*/
|
|
23
21
|
export declare function create_session_token(user_id: string, email: string, managed_by_user_id?: string, ttl_seconds?: number): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/session_token_service.ts"],"names":[],"mappings":"AAQA,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
|
|
1
|
+
{"version":3,"file":"session_token_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/session_token_service.ts"],"names":[],"mappings":"AAQA,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"}
|
|
@@ -41,8 +41,6 @@ function get_session_token_expiry_seconds() {
|
|
|
41
41
|
* Token includes user_id, email, issued at time, and expiration
|
|
42
42
|
* @param user_id - User ID
|
|
43
43
|
* @param email - User email address
|
|
44
|
-
* @param managed_by_user_id - Optional: ID of the managing user (for impersonation)
|
|
45
|
-
* @param ttl_seconds - Optional: token lifetime in seconds (default: 30 days). Use 604800 for 7-day OTP sessions.
|
|
46
44
|
* @returns JWT token string
|
|
47
45
|
*/
|
|
48
46
|
export async function create_session_token(user_id, email, managed_by_user_id, ttl_seconds) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/server/routes/assets.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,WAAW,EACrB,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACvC,OAAO,CAAC,YAAY,CAAC,CAuBvB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// file_description: Route handler serving static assets from the package dist directory
|
|
2
|
+
import "server-only";
|
|
3
|
+
import { NextResponse } from "next/server";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
const ASSETS_DIR = path.join(path.dirname(require.resolve("hazo_auth/package.json")), "dist", "assets", "images");
|
|
7
|
+
const MIME = {
|
|
8
|
+
".jpg": "image/jpeg",
|
|
9
|
+
".jpeg": "image/jpeg",
|
|
10
|
+
".png": "image/png",
|
|
11
|
+
".webp": "image/webp",
|
|
12
|
+
".svg": "image/svg+xml",
|
|
13
|
+
".gif": "image/gif",
|
|
14
|
+
};
|
|
15
|
+
export async function assetGET(_request, { params }) {
|
|
16
|
+
const name = params.name;
|
|
17
|
+
// Reject path traversal
|
|
18
|
+
if (name.includes("..") || name.includes("/") || name.includes("\\")) {
|
|
19
|
+
return new NextResponse("Not found", { status: 404 });
|
|
20
|
+
}
|
|
21
|
+
const ext = path.extname(name).toLowerCase();
|
|
22
|
+
const mime = MIME[ext];
|
|
23
|
+
if (!mime) {
|
|
24
|
+
return new NextResponse("Not found", { status: 404 });
|
|
25
|
+
}
|
|
26
|
+
const file_path = path.join(ASSETS_DIR, name);
|
|
27
|
+
if (!fs.existsSync(file_path)) {
|
|
28
|
+
return new NextResponse("Not found", { status: 404 });
|
|
29
|
+
}
|
|
30
|
+
const buffer = fs.readFileSync(file_path);
|
|
31
|
+
return new NextResponse(buffer, {
|
|
32
|
+
status: 200,
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": mime,
|
|
35
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent_me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/consent_me.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYxD,wBAAsB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAG9E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// file_description: Route handler returning the current user's parsed consent state
|
|
2
|
+
import "server-only";
|
|
3
|
+
import { NextResponse } from "next/server";
|
|
4
|
+
import { read_consent } from "../../consent/read_consent.js";
|
|
5
|
+
const DEFAULT_CONSENT = {
|
|
6
|
+
necessary: true,
|
|
7
|
+
functional: false,
|
|
8
|
+
analytics: false,
|
|
9
|
+
marketing: false,
|
|
10
|
+
version: 1,
|
|
11
|
+
};
|
|
12
|
+
export async function consentMeGET(request) {
|
|
13
|
+
const consent = read_consent(request.headers);
|
|
14
|
+
return NextResponse.json(consent !== null && consent !== void 0 ? consent : DEFAULT_CONSENT, { status: 200 });
|
|
15
|
+
}
|
|
@@ -8,8 +8,6 @@ export { POST as changePasswordPOST } from "./change_password.js";
|
|
|
8
8
|
export { GET as validateResetTokenGET } from "./validate_reset_token.js";
|
|
9
9
|
export { GET as verifyEmailGET } from "./verify_email.js";
|
|
10
10
|
export { POST as resendVerificationPOST } from "./resend_verification.js";
|
|
11
|
-
export { otpRequestPOST } from "./otp/request.js";
|
|
12
|
-
export { otpVerifyPOST } from "./otp/verify.js";
|
|
13
11
|
export { PATCH as updateUserPATCH } from "./update_user.js";
|
|
14
12
|
export { POST as uploadProfilePicturePOST } from "./upload_profile_picture.js";
|
|
15
13
|
export { DELETE as removeProfilePictureDELETE } from "./remove_profile_picture.js";
|
|
@@ -18,7 +16,7 @@ export { GET as libraryPhotoGET } from "./library_photo.js";
|
|
|
18
16
|
export { GET as profilePictureFilenameGET } from "./profile_picture_filename.js";
|
|
19
17
|
export { POST as getAuthPOST } from "./get_auth.js";
|
|
20
18
|
export { POST as invalidateCachePOST } from "./invalidate_cache.js";
|
|
21
|
-
export { GET as userManagementUsersGET, PATCH as userManagementUsersPATCH, POST as userManagementUsersPOST } from "./user_management_users.js";
|
|
19
|
+
export { GET as userManagementUsersGET, PATCH as userManagementUsersPATCH, POST as userManagementUsersPOST, DELETE as userManagementUsersDELETE } from "./user_management_users.js";
|
|
22
20
|
export { GET as userManagementPermissionsGET, POST as userManagementPermissionsPOST, PUT as userManagementPermissionsPUT, DELETE as userManagementPermissionsDELETE } from "./user_management_permissions.js";
|
|
23
21
|
export { GET as userManagementRolesGET, POST as userManagementRolesPOST, PUT as userManagementRolesPUT } from "./user_management_roles.js";
|
|
24
22
|
export { GET as userManagementUsersRolesGET, POST as userManagementUsersRolesPOST, PUT as userManagementUsersRolesPUT } from "./user_management_users_roles.js";
|
|
@@ -28,9 +26,14 @@ export { GET as invitationsGET, POST as invitationsPOST, PATCH as invitationsPAT
|
|
|
28
26
|
export { POST as createFirmPOST } from "./create_firm.js";
|
|
29
27
|
export { GET as nextauthGET, POST as nextauthPOST } from "./nextauth.js";
|
|
30
28
|
export { GET as oauthGoogleCallbackGET } from "./oauth_google_callback.js";
|
|
29
|
+
export { GET as oauthFacebookCallbackGET } from "./oauth_facebook_callback.js";
|
|
31
30
|
export { POST as setPasswordPOST } from "./set_password.js";
|
|
32
31
|
export { GET as relationshipsGET, POST as relationshipsPOST, PATCH as relationshipsPATCH, DELETE as relationshipsDELETE } from "./relationships.js";
|
|
33
32
|
export { POST as relationshipSelfPOST } from "./relationship_self.js";
|
|
34
33
|
export { POST as relationshipUpgradePOST } from "./relationship_upgrade.js";
|
|
35
34
|
export { POST as pinLoginPOST } from "./pin_login.js";
|
|
35
|
+
export { otpRequestPOST } from "./otp/request.js";
|
|
36
|
+
export { otpVerifyPOST } from "./otp/verify.js";
|
|
37
|
+
export { consentMeGET } from "./consent_me.js";
|
|
38
|
+
export { stringsDefaultsGET } from "./strings_defaults.js";
|
|
36
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/routes/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,IAAI,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,GAAG,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,IAAI,IAAI,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/routes/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,Y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nE,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -13,9 +13,6 @@ export { GET as validateResetTokenGET } from "./validate_reset_token.js";
|
|
|
13
13
|
// Email verification routes
|
|
14
14
|
export { GET as verifyEmailGET } from "./verify_email.js";
|
|
15
15
|
export { POST as resendVerificationPOST } from "./resend_verification.js";
|
|
16
|
-
// OTP routes (one-time password via email)
|
|
17
|
-
export { otpRequestPOST } from "./otp/request.js";
|
|
18
|
-
export { otpVerifyPOST } from "./otp/verify.js";
|
|
19
16
|
// User profile routes
|
|
20
17
|
export { PATCH as updateUserPATCH } from "./update_user.js";
|
|
21
18
|
export { POST as uploadProfilePicturePOST } from "./upload_profile_picture.js";
|
|
@@ -27,7 +24,7 @@ export { GET as profilePictureFilenameGET } from "./profile_picture_filename.js"
|
|
|
27
24
|
export { POST as getAuthPOST } from "./get_auth.js";
|
|
28
25
|
export { POST as invalidateCachePOST } from "./invalidate_cache.js";
|
|
29
26
|
// User management routes
|
|
30
|
-
export { GET as userManagementUsersGET, PATCH as userManagementUsersPATCH, POST as userManagementUsersPOST } from "./user_management_users.js";
|
|
27
|
+
export { GET as userManagementUsersGET, PATCH as userManagementUsersPATCH, POST as userManagementUsersPOST, DELETE as userManagementUsersDELETE } from "./user_management_users.js";
|
|
31
28
|
export { GET as userManagementPermissionsGET, POST as userManagementPermissionsPOST, PUT as userManagementPermissionsPUT, DELETE as userManagementPermissionsDELETE } from "./user_management_permissions.js";
|
|
32
29
|
export { GET as userManagementRolesGET, POST as userManagementRolesPOST, PUT as userManagementRolesPUT } from "./user_management_roles.js";
|
|
33
30
|
export { GET as userManagementUsersRolesGET, POST as userManagementUsersRolesPOST, PUT as userManagementUsersRolesPUT } from "./user_management_users_roles.js";
|
|
@@ -41,9 +38,17 @@ export { POST as createFirmPOST } from "./create_firm.js";
|
|
|
41
38
|
// OAuth routes
|
|
42
39
|
export { GET as nextauthGET, POST as nextauthPOST } from "./nextauth.js";
|
|
43
40
|
export { GET as oauthGoogleCallbackGET } from "./oauth_google_callback.js";
|
|
41
|
+
export { GET as oauthFacebookCallbackGET } from "./oauth_facebook_callback.js";
|
|
44
42
|
export { POST as setPasswordPOST } from "./set_password.js";
|
|
45
43
|
// Relationship routes (managed sub-profiles)
|
|
46
44
|
export { GET as relationshipsGET, POST as relationshipsPOST, PATCH as relationshipsPATCH, DELETE as relationshipsDELETE } from "./relationships.js";
|
|
47
45
|
export { POST as relationshipSelfPOST } from "./relationship_self.js";
|
|
48
46
|
export { POST as relationshipUpgradePOST } from "./relationship_upgrade.js";
|
|
49
47
|
export { POST as pinLoginPOST } from "./pin_login.js";
|
|
48
|
+
// OTP sign-in routes
|
|
49
|
+
export { otpRequestPOST } from "./otp/request.js";
|
|
50
|
+
export { otpVerifyPOST } from "./otp/verify.js";
|
|
51
|
+
// Consent routes
|
|
52
|
+
export { consentMeGET } from "./consent_me.js";
|
|
53
|
+
// Strings routes
|
|
54
|
+
export { stringsDefaultsGET } from "./strings_defaults.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/server/routes/me.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBxD;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;IA+G7C"}
|
package/dist/server/routes/me.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// file_description: API route handler to get current authenticated user information with permissions
|
|
2
2
|
// section: imports
|
|
3
3
|
import { NextResponse } from "next/server";
|
|
4
|
-
import { jwtVerify } from "jose";
|
|
5
4
|
import { hazo_get_auth } from "../../lib/auth/hazo_get_auth.server.js";
|
|
6
5
|
import { get_hazo_connect_instance } from "../../lib/hazo_connect_instance.server.js";
|
|
7
6
|
import { createCrudService } from "hazo_connect/server";
|
|
@@ -9,9 +8,6 @@ import { map_db_source_to_ui } from "../../lib/services/profile_picture_source_m
|
|
|
9
8
|
import { create_app_logger } from "../../lib/app_logger.js";
|
|
10
9
|
import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
|
|
11
10
|
import { is_user_types_enabled, get_user_type_by_key, } from "../../lib/user_types_config.server.js";
|
|
12
|
-
import { get_cookie_name, get_cookie_options, BASE_COOKIE_NAMES, } from "../../lib/cookies_config.server.js";
|
|
13
|
-
import { create_session_token } from "../../lib/services/session_token_service.js";
|
|
14
|
-
import { get_otp_config, hazo_auth_otp_session_ttl_seconds, } from "../../lib/otp_config.server.js";
|
|
15
11
|
// section: helpers
|
|
16
12
|
function strip_sentinel_email(email) {
|
|
17
13
|
if (!email)
|
|
@@ -28,7 +24,6 @@ function strip_sentinel_email(email) {
|
|
|
28
24
|
* Always returns the same format to prevent downstream variations.
|
|
29
25
|
*/
|
|
30
26
|
export async function GET(request) {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f;
|
|
32
27
|
const logger = create_app_logger();
|
|
33
28
|
try {
|
|
34
29
|
// Use hazo_get_auth to get user with permissions
|
|
@@ -75,7 +70,7 @@ export async function GET(request) {
|
|
|
75
70
|
}
|
|
76
71
|
// Return unified format with all fields
|
|
77
72
|
const profile_pic = auth_result.user.profile_picture_url;
|
|
78
|
-
|
|
73
|
+
return NextResponse.json({
|
|
79
74
|
authenticated: true,
|
|
80
75
|
// Top-level fields for backward compatibility
|
|
81
76
|
user_id: auth_result.user.id,
|
|
@@ -105,43 +100,6 @@ export async function GET(request) {
|
|
|
105
100
|
permission_ok: auth_result.permission_ok,
|
|
106
101
|
missing_permissions: auth_result.missing_permissions,
|
|
107
102
|
}, { status: 200 });
|
|
108
|
-
// --- OTP sliding-session hook ---
|
|
109
|
-
const session_kind = (_a = request.cookies.get(get_cookie_name(BASE_COOKIE_NAMES.SESSION_KIND))) === null || _a === void 0 ? void 0 : _a.value;
|
|
110
|
-
if (session_kind === "otp") {
|
|
111
|
-
try {
|
|
112
|
-
const session_cookie = (_b = request.cookies.get(get_cookie_name(BASE_COOKIE_NAMES.SESSION))) === null || _b === void 0 ? void 0 : _b.value;
|
|
113
|
-
if (session_cookie) {
|
|
114
|
-
const secret = new TextEncoder().encode((_c = process.env.JWT_SECRET) !== null && _c !== void 0 ? _c : "");
|
|
115
|
-
const { payload } = await jwtVerify(session_cookie, secret);
|
|
116
|
-
const exp = Number((_d = payload.exp) !== null && _d !== void 0 ? _d : 0);
|
|
117
|
-
const now_seconds = Math.floor(Date.now() / 1000);
|
|
118
|
-
const otp_cfg = get_otp_config();
|
|
119
|
-
const seconds_until_exp = exp - now_seconds;
|
|
120
|
-
if (seconds_until_exp > 0 && seconds_until_exp < otp_cfg.slide_when_within_seconds) {
|
|
121
|
-
const ttl_seconds = hazo_auth_otp_session_ttl_seconds();
|
|
122
|
-
const user_id = String((_e = payload.user_id) !== null && _e !== void 0 ? _e : "");
|
|
123
|
-
const user_email = String((_f = payload.email) !== null && _f !== void 0 ? _f : "");
|
|
124
|
-
const new_token = await create_session_token(user_id, user_email, undefined, ttl_seconds);
|
|
125
|
-
const cookie_options = get_cookie_options({
|
|
126
|
-
httpOnly: true,
|
|
127
|
-
secure: process.env.NODE_ENV === "production",
|
|
128
|
-
sameSite: "lax",
|
|
129
|
-
path: "/",
|
|
130
|
-
maxAge: ttl_seconds,
|
|
131
|
-
});
|
|
132
|
-
response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.SESSION), new_token, cookie_options);
|
|
133
|
-
response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_ID), user_id, cookie_options);
|
|
134
|
-
response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.USER_EMAIL), user_email, cookie_options);
|
|
135
|
-
response.cookies.set(get_cookie_name(BASE_COOKIE_NAMES.SESSION_KIND), "otp", cookie_options);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (slide_err) {
|
|
140
|
-
// Slide is best-effort — never break /me for this
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// --- end OTP sliding-session hook ---
|
|
144
|
-
return response;
|
|
145
103
|
}
|
|
146
104
|
catch (error) {
|
|
147
105
|
const error_message = error instanceof Error ? error.message : "Unknown error";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from "next/server";
|
|
2
|
+
/**
|
|
3
|
+
* Handles the OAuth callback after Facebook sign-in
|
|
4
|
+
* The user creation/linking is done in NextAuth signIn callback
|
|
5
|
+
* This route just sets the hazo_auth session cookies
|
|
6
|
+
*/
|
|
7
|
+
export declare function GET(original_request: NextRequest): Promise<NextResponse<unknown>>;
|
|
8
|
+
//# sourceMappingURL=oauth_facebook_callback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth_facebook_callback.d.ts","sourceRoot":"","sources":["../../../src/server/routes/oauth_facebook_callback.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAuBxD;;;;GAIG;AACH,wBAAsB,GAAG,CAAC,gBAAgB,EAAE,WAAW,kCAiLtD"}
|