fix: replace unguarded crypto.randomUUID() with safe generateUUID() utility
This commit is contained in:
@@ -6,6 +6,7 @@ import { debug } from '@/lib/debug';
|
||||
import { normalizeAllDayDuration } from '@/lib/calendar-utils';
|
||||
import { sanitizeOutgoingCalendarEventData } from '@/lib/calendar-event-normalization';
|
||||
import { expandRecurringEvents } from '@/lib/recurrence-expansion';
|
||||
import { generateUUID } from '@/lib/utils';
|
||||
|
||||
export type CalendarViewMode = 'month' | 'week' | 'day' | 'agenda' | 'tasks';
|
||||
|
||||
@@ -722,9 +723,7 @@ export const useCalendarStore = create<CalendarStore>()(
|
||||
if (!calendar) throw new Error('Failed to create calendar');
|
||||
|
||||
const subscription: ICalSubscription = {
|
||||
id: typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
||||
? crypto.randomUUID()
|
||||
: `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
|
||||
id: generateUUID(),
|
||||
url,
|
||||
calendarId: calendar.id,
|
||||
name,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import type { ContactCard, AddressBook, ContactName } from '@/lib/jmap/types';
|
||||
import type { IJMAPClient } from '@/lib/jmap/client-interface';
|
||||
import { generateUUID } from '@/lib/utils';
|
||||
|
||||
export function getContactDisplayName(contact: ContactCard): string {
|
||||
if (contact.name?.components) {
|
||||
@@ -378,7 +379,7 @@ export const useContactStore = create<ContactStore>()(
|
||||
set((state) => ({ contacts: [...state.contacts, created] }));
|
||||
} else {
|
||||
const localGroup: ContactCard = {
|
||||
id: `local-${crypto.randomUUID()}`,
|
||||
id: `local-${generateUUID()}`,
|
||||
addressBookIds: {},
|
||||
...groupData,
|
||||
} as ContactCard;
|
||||
@@ -617,7 +618,7 @@ export const useContactStore = create<ContactStore>()(
|
||||
} else {
|
||||
const localContact: ContactCard = {
|
||||
...contact,
|
||||
id: `local-${crypto.randomUUID()}`,
|
||||
id: `local-${generateUUID()}`,
|
||||
};
|
||||
set((state) => ({ contacts: [...state.contacts, localContact] }));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import type { SmimeKeyRecord, SmimePublicCert } from '@/lib/smime/types';
|
||||
import { generateUUID } from '@/lib/utils';
|
||||
import {
|
||||
saveKeyRecord,
|
||||
listKeyRecords,
|
||||
@@ -287,7 +288,7 @@ export const useSmimeStore = create<SmimeStore>()(
|
||||
const email = info.emailAddresses[0] ?? '';
|
||||
|
||||
const publicCert: SmimePublicCert = {
|
||||
id: crypto.randomUUID(),
|
||||
id: generateUUID(),
|
||||
accountId: get().currentAccountId ?? undefined,
|
||||
email: email.toLowerCase(),
|
||||
certificate: der,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
importTemplates as importUtil,
|
||||
filterTemplates,
|
||||
} from '@/lib/template-utils';
|
||||
import { generateUUID } from '@/lib/utils';
|
||||
|
||||
const MAX_RECENT = 5;
|
||||
|
||||
@@ -39,7 +40,7 @@ export const useTemplateStore = create<TemplateStore>()(
|
||||
const now = new Date().toISOString();
|
||||
const template: EmailTemplate = {
|
||||
...data,
|
||||
id: crypto.randomUUID(),
|
||||
id: generateUUID(),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
@@ -73,8 +74,9 @@ export const useTemplateStore = create<TemplateStore>()(
|
||||
const now = new Date().toISOString();
|
||||
const duplicate: EmailTemplate = {
|
||||
...original,
|
||||
id: crypto.randomUUID(),
|
||||
id: generateUUID(),
|
||||
name: `${original.name} ${nameSuffix || '(copy)'}`,
|
||||
|
||||
isFavorite: false,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
|
||||
Reference in New Issue
Block a user