|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import { TranscriptionStatus } from "@/services/transcription" |
7 | | -import type { |
8 | | - TranscriptionIntelligence, |
9 | | - TranscriptionSegment, |
10 | | -} from "@/types/transcription" |
| 7 | +import type { TranscriptionIntelligence } from "@/types/transcription" |
11 | 8 |
|
12 | | -export type { TranscriptionSegment } |
| 9 | +export type { TranscriptionSegment } from "@/types/transcription" |
13 | 10 |
|
14 | 11 | export interface TranscriptionSession { |
15 | 12 | id: string // Unique session ID |
@@ -55,13 +52,13 @@ const DEFAULT_SESSION_EXPIRY_HOURS = 24 |
55 | 52 | const initDb = (): Promise<IDBDatabase> => { |
56 | 53 | return new Promise((resolve, reject) => { |
57 | 54 | // Check for IndexedDB support |
58 | | - if (!window.indexedDB) { |
| 55 | + if (!globalThis.indexedDB) { |
59 | 56 | console.error("Your browser doesn't support IndexedDB") |
60 | 57 | reject(new Error("IndexedDB not supported")) |
61 | 58 | return |
62 | 59 | } |
63 | 60 |
|
64 | | - const request = window.indexedDB.open(DB_NAME, DB_VERSION) |
| 61 | + const request = globalThis.indexedDB.open(DB_NAME, DB_VERSION) |
65 | 62 |
|
66 | 63 | request.onerror = (event) => { |
67 | 64 | console.error("Database error:", event) |
@@ -94,7 +91,11 @@ const initDb = (): Promise<IDBDatabase> => { |
94 | 91 | */ |
95 | 92 | export const createSessionId = (): string => { |
96 | 93 | const timestamp = Date.now() |
97 | | - const randomString = Math.random().toString(36).substring(2, 10) |
| 94 | + const randomBytes = new Uint8Array(5) |
| 95 | + crypto.getRandomValues(randomBytes) |
| 96 | + const randomString = Array.from(randomBytes) |
| 97 | + .map((b) => b.toString(16).padStart(2, "0")) |
| 98 | + .join("") |
98 | 99 | const sessionId = `${timestamp}-${randomString}` |
99 | 100 |
|
100 | 101 | // Set session cookie |
|
0 commit comments