bf38eb8cb1
* feat: Add async spam check integration and decoy booking response - Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: [email protected] <[email protected]> * Do checks in paralle * Fix leaking host name in title * Reduce expoiry time localstorage * refactor: Use sessionStorage instead of localStorage for decoy booking data - Replace localStorage with sessionStorage for automatic expiration on tab close - Remove timestamp tracking and TTL logic (no longer needed) - Improve privacy by auto-clearing data when browser tab/window closes - Update documentation to reflect sessionStorage behavior This change addresses privacy concerns by ensuring decoy booking data (including attendee email) is automatically removed when the user closes the tab, rather than persisting for 5 minutes or requiring manual cleanup. Co-Authored-By: [email protected] <[email protected]> * feat: Add sessionStorage wrapper to webstorage module Co-Authored-By: [email protected] <[email protected]> * Reset RegularBookingService.ts to main's version exactly * feat: Add 5-minute expiration timeout to decoy booking data - Adds timestamp to DecoyBookingData interface - Checks expiration when retrieving booking data - Automatically removes expired data from sessionStorage - Provides defense-in-depth against potential misuse - Works alongside sessionStorage auto-clear on tab close --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
/**
|
|
* Provides a wrapper around localStorage and sessionStorage to avoid errors in case of restricted storage access.
|
|
*
|
|
* TODO: In case of an embed if localStorage is not available(third party), use localStorage of parent(first party) that contains the iframe.
|
|
*/
|
|
export const localStorage = {
|
|
getItem(key: string) {
|
|
try {
|
|
return window.localStorage.getItem(key);
|
|
} catch {
|
|
// In case storage is restricted. Possible reasons
|
|
// 1. Third Party Context in Chrome Incognito mode.
|
|
return null;
|
|
}
|
|
},
|
|
setItem(key: string, value: string) {
|
|
try {
|
|
window.localStorage.setItem(key, value);
|
|
} catch {
|
|
// In case storage is restricted. Possible reasons
|
|
// 1. Third Party Context in Chrome Incognito mode.
|
|
// 2. Storage limit reached
|
|
return;
|
|
}
|
|
},
|
|
removeItem: (key: string) => {
|
|
try {
|
|
window.localStorage.removeItem(key);
|
|
} catch {
|
|
return;
|
|
}
|
|
},
|
|
};
|
|
|
|
export const sessionStorage = {
|
|
getItem(key: string) {
|
|
try {
|
|
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
|
return window.sessionStorage.getItem(key);
|
|
} catch {
|
|
// In case storage is restricted. Possible reasons
|
|
// 1. Third Party Context in Chrome Incognito mode.
|
|
return null;
|
|
}
|
|
},
|
|
setItem(key: string, value: string) {
|
|
try {
|
|
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
|
window.sessionStorage.setItem(key, value);
|
|
} catch {
|
|
// In case storage is restricted. Possible reasons
|
|
// 1. Third Party Context in Chrome Incognito mode.
|
|
// 2. Storage limit reached
|
|
return;
|
|
}
|
|
},
|
|
removeItem: (key: string) => {
|
|
try {
|
|
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
|
window.sessionStorage.removeItem(key);
|
|
} catch {
|
|
return;
|
|
}
|
|
},
|
|
};
|