vibesurf 0.1.20__py3-none-any.whl → 0.1.21__py3-none-any.whl
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.
Potentially problematic release.
This version of vibesurf might be problematic. Click here for more details.
- vibe_surf/_version.py +2 -2
- vibe_surf/backend/api/task.py +1 -1
- vibe_surf/backend/api/voices.py +481 -0
- vibe_surf/backend/database/migrations/v004_add_voice_profiles.sql +35 -0
- vibe_surf/backend/database/models.py +38 -1
- vibe_surf/backend/database/queries.py +189 -1
- vibe_surf/backend/main.py +2 -0
- vibe_surf/backend/shared_state.py +1 -1
- vibe_surf/backend/voice_model_config.py +25 -0
- vibe_surf/browser/agen_browser_profile.py +2 -0
- vibe_surf/browser/agent_browser_session.py +3 -3
- vibe_surf/chrome_extension/background.js +224 -9
- vibe_surf/chrome_extension/content.js +147 -0
- vibe_surf/chrome_extension/manifest.json +11 -2
- vibe_surf/chrome_extension/permission-iframe.html +38 -0
- vibe_surf/chrome_extension/permission-request.html +104 -0
- vibe_surf/chrome_extension/scripts/api-client.js +61 -0
- vibe_surf/chrome_extension/scripts/main.js +8 -2
- vibe_surf/chrome_extension/scripts/permission-iframe-request.js +188 -0
- vibe_surf/chrome_extension/scripts/permission-request.js +118 -0
- vibe_surf/chrome_extension/scripts/settings-manager.js +690 -3
- vibe_surf/chrome_extension/scripts/ui-manager.js +730 -119
- vibe_surf/chrome_extension/scripts/user-settings-storage.js +422 -0
- vibe_surf/chrome_extension/scripts/voice-recorder.js +514 -0
- vibe_surf/chrome_extension/sidepanel.html +106 -29
- vibe_surf/chrome_extension/styles/components.css +35 -0
- vibe_surf/chrome_extension/styles/input.css +164 -1
- vibe_surf/chrome_extension/styles/layout.css +1 -1
- vibe_surf/chrome_extension/styles/settings-environment.css +138 -0
- vibe_surf/chrome_extension/styles/settings-forms.css +7 -7
- vibe_surf/chrome_extension/styles/variables.css +51 -0
- vibe_surf/tools/voice_asr.py +79 -8
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/METADATA +8 -12
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/RECORD +38 -31
- vibe_surf/chrome_extension/icons/convert-svg.js +0 -33
- vibe_surf/chrome_extension/icons/logo-preview.html +0 -187
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/WHEEL +0 -0
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/entry_points.txt +0 -0
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/licenses/LICENSE +0 -0
- {vibesurf-0.1.20.dist-info → vibesurf-0.1.21.dist-info}/top_level.txt +0 -0
|
@@ -53,10 +53,36 @@
|
|
|
53
53
|
sendResponse(clickResult);
|
|
54
54
|
break;
|
|
55
55
|
|
|
56
|
+
case 'INJECT_MICROPHONE_PERMISSION_IFRAME':
|
|
57
|
+
this.injectMicrophonePermissionIframe()
|
|
58
|
+
.then(result => sendResponse(result))
|
|
59
|
+
.catch(error => sendResponse({ success: false, error: error.message }));
|
|
60
|
+
return true; // Will respond asynchronously
|
|
61
|
+
|
|
62
|
+
case 'REMOVE_MICROPHONE_PERMISSION_IFRAME':
|
|
63
|
+
this.removeMicrophonePermissionIframe();
|
|
64
|
+
sendResponse({ success: true });
|
|
65
|
+
break;
|
|
66
|
+
|
|
56
67
|
default:
|
|
57
68
|
console.warn('[VibeSurf Content] Unknown message type:', message.type);
|
|
58
69
|
}
|
|
59
70
|
});
|
|
71
|
+
|
|
72
|
+
// Listen for postMessage from iframe
|
|
73
|
+
window.addEventListener('message', (event) => {
|
|
74
|
+
if (event.data && event.data.type === 'MICROPHONE_PERMISSION_RESULT') {
|
|
75
|
+
console.log('[VibeSurf Content] Received permission result from iframe:', event.data);
|
|
76
|
+
|
|
77
|
+
// Forward to extension
|
|
78
|
+
chrome.runtime.sendMessage({
|
|
79
|
+
type: 'MICROPHONE_PERMISSION_RESULT',
|
|
80
|
+
...event.data
|
|
81
|
+
}).catch(() => {
|
|
82
|
+
// Ignore if no listeners
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
60
86
|
}
|
|
61
87
|
|
|
62
88
|
collectPageContext() {
|
|
@@ -233,6 +259,127 @@
|
|
|
233
259
|
}
|
|
234
260
|
}
|
|
235
261
|
|
|
262
|
+
// Inject hidden iframe for microphone permission request
|
|
263
|
+
async injectMicrophonePermissionIframe() {
|
|
264
|
+
try {
|
|
265
|
+
console.log('[VibeSurf Content] Injecting microphone permission iframe...');
|
|
266
|
+
|
|
267
|
+
// Check if iframe already exists
|
|
268
|
+
const existingIframe = document.getElementById('vibesurf-permission-iframe');
|
|
269
|
+
if (existingIframe) {
|
|
270
|
+
console.log('[VibeSurf Content] Permission iframe already exists');
|
|
271
|
+
return { success: true, alreadyExists: true };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Create the iframe element
|
|
275
|
+
const iframe = document.createElement('iframe');
|
|
276
|
+
iframe.setAttribute('id', 'vibesurf-permission-iframe');
|
|
277
|
+
iframe.setAttribute('allow', 'microphone');
|
|
278
|
+
iframe.setAttribute('hidden', 'hidden');
|
|
279
|
+
iframe.style.display = 'none';
|
|
280
|
+
iframe.style.width = '0px';
|
|
281
|
+
iframe.style.height = '0px';
|
|
282
|
+
iframe.style.border = 'none';
|
|
283
|
+
iframe.style.position = 'fixed';
|
|
284
|
+
iframe.style.top = '-9999px';
|
|
285
|
+
iframe.style.left = '-9999px';
|
|
286
|
+
iframe.style.zIndex = '-1';
|
|
287
|
+
|
|
288
|
+
// Set the source to our permission iframe page
|
|
289
|
+
const iframeUrl = chrome.runtime.getURL('permission-iframe.html');
|
|
290
|
+
iframe.src = iframeUrl;
|
|
291
|
+
|
|
292
|
+
console.log('[VibeSurf Content] Creating iframe with URL:', iframeUrl);
|
|
293
|
+
|
|
294
|
+
// Return a promise that resolves when permission is granted/denied
|
|
295
|
+
return new Promise((resolve, reject) => {
|
|
296
|
+
const timeout = setTimeout(() => {
|
|
297
|
+
console.log('[VibeSurf Content] Permission iframe timeout');
|
|
298
|
+
this.removeMicrophonePermissionIframe();
|
|
299
|
+
reject(new Error('Permission request timeout'));
|
|
300
|
+
}, 30000); // 30 second timeout
|
|
301
|
+
|
|
302
|
+
// Listen for permission result
|
|
303
|
+
const messageHandler = (event) => {
|
|
304
|
+
if (event.data && event.data.type === 'MICROPHONE_PERMISSION_RESULT') {
|
|
305
|
+
console.log('[VibeSurf Content] Received permission result:', event.data);
|
|
306
|
+
|
|
307
|
+
clearTimeout(timeout);
|
|
308
|
+
window.removeEventListener('message', messageHandler);
|
|
309
|
+
|
|
310
|
+
if (event.data.success) {
|
|
311
|
+
resolve({
|
|
312
|
+
success: true,
|
|
313
|
+
granted: event.data.granted,
|
|
314
|
+
source: 'iframe'
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
resolve({
|
|
318
|
+
success: false,
|
|
319
|
+
granted: false,
|
|
320
|
+
error: event.data.error || 'Permission denied',
|
|
321
|
+
userMessage: event.data.userMessage
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Clean up iframe after a short delay
|
|
326
|
+
setTimeout(() => {
|
|
327
|
+
this.removeMicrophonePermissionIframe();
|
|
328
|
+
}, 1000);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
window.addEventListener('message', messageHandler);
|
|
333
|
+
|
|
334
|
+
// Handle iframe load
|
|
335
|
+
iframe.onload = () => {
|
|
336
|
+
console.log('[VibeSurf Content] Permission iframe loaded successfully');
|
|
337
|
+
|
|
338
|
+
// Send message to iframe to start permission request
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
if (iframe.contentWindow) {
|
|
341
|
+
iframe.contentWindow.postMessage({
|
|
342
|
+
type: 'REQUEST_MICROPHONE_PERMISSION'
|
|
343
|
+
}, '*');
|
|
344
|
+
}
|
|
345
|
+
}, 100);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
iframe.onerror = (error) => {
|
|
349
|
+
console.error('[VibeSurf Content] Permission iframe load error:', error);
|
|
350
|
+
clearTimeout(timeout);
|
|
351
|
+
window.removeEventListener('message', messageHandler);
|
|
352
|
+
this.removeMicrophonePermissionIframe();
|
|
353
|
+
reject(new Error('Failed to load permission iframe'));
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// Append to document body
|
|
357
|
+
document.body.appendChild(iframe);
|
|
358
|
+
console.log('[VibeSurf Content] Permission iframe injected into page');
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
} catch (error) {
|
|
362
|
+
console.error('[VibeSurf Content] Failed to inject permission iframe:', error);
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Remove microphone permission iframe
|
|
368
|
+
removeMicrophonePermissionIframe() {
|
|
369
|
+
try {
|
|
370
|
+
const iframe = document.getElementById('vibesurf-permission-iframe');
|
|
371
|
+
if (iframe) {
|
|
372
|
+
console.log('[VibeSurf Content] Removing permission iframe');
|
|
373
|
+
iframe.remove();
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
return false;
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.error('[VibeSurf Content] Error removing permission iframe:', error);
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
236
383
|
// Utility method to send context updates to background
|
|
237
384
|
sendContextUpdate() {
|
|
238
385
|
try {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"contextMenus",
|
|
17
17
|
"tabs",
|
|
18
18
|
"clipboardWrite",
|
|
19
|
-
"scripting"
|
|
19
|
+
"scripting",
|
|
20
|
+
"microphone"
|
|
20
21
|
],
|
|
21
22
|
"host_permissions": [
|
|
22
23
|
"http://localhost:*/*",
|
|
@@ -48,7 +49,15 @@
|
|
|
48
49
|
|
|
49
50
|
"web_accessible_resources": [
|
|
50
51
|
{
|
|
51
|
-
"resources": [
|
|
52
|
+
"resources": [
|
|
53
|
+
"sidepanel.html",
|
|
54
|
+
"permission-request.html",
|
|
55
|
+
"permission-iframe.html",
|
|
56
|
+
"styles/*",
|
|
57
|
+
"scripts/*",
|
|
58
|
+
"config.js",
|
|
59
|
+
"icons/*"
|
|
60
|
+
],
|
|
52
61
|
"matches": ["<all_urls>"]
|
|
53
62
|
}
|
|
54
63
|
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Microphone Permission Request</title>
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 10px;
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
background: #f5f5f5;
|
|
13
|
+
color: #333;
|
|
14
|
+
}
|
|
15
|
+
.status {
|
|
16
|
+
padding: 8px;
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
text-align: center;
|
|
19
|
+
}
|
|
20
|
+
.loading {
|
|
21
|
+
background: #bee3f8;
|
|
22
|
+
color: #2a4365;
|
|
23
|
+
}
|
|
24
|
+
.success {
|
|
25
|
+
background: #c6f6d5;
|
|
26
|
+
color: #22543d;
|
|
27
|
+
}
|
|
28
|
+
.error {
|
|
29
|
+
background: #fed7d7;
|
|
30
|
+
color: #742a2a;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<div id="status" class="status loading">Requesting microphone access...</div>
|
|
36
|
+
<script src="scripts/permission-iframe-request.js"></script>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>VibeSurf - Microphone Permission</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
min-height: 100vh;
|
|
14
|
+
margin: 0;
|
|
15
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
16
|
+
color: #333;
|
|
17
|
+
}
|
|
18
|
+
.container {
|
|
19
|
+
background: white;
|
|
20
|
+
padding: 40px;
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
23
|
+
text-align: center;
|
|
24
|
+
max-width: 400px;
|
|
25
|
+
}
|
|
26
|
+
.logo {
|
|
27
|
+
width: 60px;
|
|
28
|
+
height: 60px;
|
|
29
|
+
margin-bottom: 20px;
|
|
30
|
+
}
|
|
31
|
+
h1 {
|
|
32
|
+
color: #2d3748;
|
|
33
|
+
margin-bottom: 10px;
|
|
34
|
+
font-size: 24px;
|
|
35
|
+
}
|
|
36
|
+
p {
|
|
37
|
+
color: #718096;
|
|
38
|
+
margin-bottom: 30px;
|
|
39
|
+
line-height: 1.6;
|
|
40
|
+
}
|
|
41
|
+
.button-group {
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: 12px;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
}
|
|
46
|
+
button {
|
|
47
|
+
padding: 12px 24px;
|
|
48
|
+
border: none;
|
|
49
|
+
border-radius: 6px;
|
|
50
|
+
font-size: 16px;
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
transition: all 0.2s;
|
|
54
|
+
}
|
|
55
|
+
.allow-btn {
|
|
56
|
+
background: #4299e1;
|
|
57
|
+
color: white;
|
|
58
|
+
}
|
|
59
|
+
.allow-btn:hover {
|
|
60
|
+
background: #3182ce;
|
|
61
|
+
transform: translateY(-1px);
|
|
62
|
+
}
|
|
63
|
+
.deny-btn {
|
|
64
|
+
background: #e2e8f0;
|
|
65
|
+
color: #4a5568;
|
|
66
|
+
}
|
|
67
|
+
.deny-btn:hover {
|
|
68
|
+
background: #cbd5e0;
|
|
69
|
+
}
|
|
70
|
+
#status {
|
|
71
|
+
margin-top: 20px;
|
|
72
|
+
padding: 12px;
|
|
73
|
+
border-radius: 6px;
|
|
74
|
+
font-weight: 500;
|
|
75
|
+
}
|
|
76
|
+
.success {
|
|
77
|
+
background: #c6f6d5;
|
|
78
|
+
color: #22543d;
|
|
79
|
+
}
|
|
80
|
+
.error {
|
|
81
|
+
background: #fed7d7;
|
|
82
|
+
color: #742a2a;
|
|
83
|
+
}
|
|
84
|
+
.loading {
|
|
85
|
+
background: #bee3f8;
|
|
86
|
+
color: #2a4365;
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
89
|
+
</head>
|
|
90
|
+
<body>
|
|
91
|
+
<div class="container">
|
|
92
|
+
<img src="icons/logo.png" alt="VibeSurf" class="logo">
|
|
93
|
+
<h1>Microphone Permission Required</h1>
|
|
94
|
+
<p>VibeSurf needs access to your microphone to enable voice input. This permission is used only when you click the microphone button.</p>
|
|
95
|
+
<div class="button-group">
|
|
96
|
+
<button id="allowBtn" class="allow-btn">Allow Microphone</button>
|
|
97
|
+
<button id="denyBtn" class="deny-btn">Deny</button>
|
|
98
|
+
</div>
|
|
99
|
+
<div id="status"></div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<script src="scripts/permission-request.js"></script>
|
|
103
|
+
</body>
|
|
104
|
+
</html>
|
|
@@ -410,6 +410,67 @@ class VibeSurfAPIClient {
|
|
|
410
410
|
return this.get(`/config/llm/providers/${encodeURIComponent(providerName)}/models`);
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
// Voice Profile Management
|
|
414
|
+
async getVoiceProfiles(activeOnly = true, voiceModelType = null, limit = 50, offset = 0) {
|
|
415
|
+
const params = { active_only: activeOnly, limit, offset };
|
|
416
|
+
if (voiceModelType) {
|
|
417
|
+
params.voice_model_type = voiceModelType;
|
|
418
|
+
}
|
|
419
|
+
return this.get('/voices/voice-profiles', { params });
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async getVoiceProfile(profileName) {
|
|
423
|
+
return this.get(`/voices/${encodeURIComponent(profileName)}`);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async createVoiceProfile(profileData) {
|
|
427
|
+
return this.post('/voices/voice-profiles', profileData);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
async updateVoiceProfile(profileName, updateData) {
|
|
431
|
+
return this.put(`/voices/voice-profiles/${encodeURIComponent(profileName)}`, updateData);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
async deleteVoiceProfile(profileName) {
|
|
435
|
+
return this.delete(`/voices/voice-profiles/${encodeURIComponent(profileName)}`);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Voice Models - matches the backend route @router.get("/models")
|
|
439
|
+
async getVoiceModels(modelType = null) {
|
|
440
|
+
let url = '/voices/models';
|
|
441
|
+
if (modelType) {
|
|
442
|
+
url += `?model_type=${encodeURIComponent(modelType)}`;
|
|
443
|
+
}
|
|
444
|
+
return this.get(url);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Voice Recording API
|
|
448
|
+
async transcribeAudio(audioBlob, voiceProfileName = null) {
|
|
449
|
+
const formData = new FormData();
|
|
450
|
+
formData.append('audio_file', audioBlob, 'recording.webm');
|
|
451
|
+
|
|
452
|
+
// Add voice profile name if provided
|
|
453
|
+
const params = {};
|
|
454
|
+
if (voiceProfileName) {
|
|
455
|
+
params.voice_profile_name = voiceProfileName;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return this.post('/voices/asr', formData, {
|
|
459
|
+
params,
|
|
460
|
+
headers: {} // Let browser set Content-Type with boundary for FormData
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Get available ASR profiles
|
|
465
|
+
async getASRProfiles(activeOnly = true) {
|
|
466
|
+
return this.get('/voices/voice-profiles', {
|
|
467
|
+
params: {
|
|
468
|
+
voice_model_type: 'asr',
|
|
469
|
+
active_only: activeOnly
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
413
474
|
// Environment Variables
|
|
414
475
|
async getEnvironmentVariables() {
|
|
415
476
|
return this.get('/config/environments');
|
|
@@ -154,11 +154,11 @@ class VibeSurfApp {
|
|
|
154
154
|
|
|
155
155
|
async initializeUIManager() {
|
|
156
156
|
this.uiManager = new VibeSurfUIManager(this.sessionManager, this.apiClient);
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
// Initialize UI with loaded data
|
|
159
159
|
await this.uiManager.initialize();
|
|
160
160
|
|
|
161
|
-
console.log('[VibeSurf] UI manager initialized');
|
|
161
|
+
console.log('[VibeSurf] UI manager initialized successfully');
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
setupErrorHandling() {
|
|
@@ -482,6 +482,12 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
|
482
482
|
.catch(error => sendResponse({ success: false, error: error.message }));
|
|
483
483
|
return true; // Keep message channel open for async response
|
|
484
484
|
|
|
485
|
+
case 'MICROPHONE_PERMISSION_RESULT':
|
|
486
|
+
console.log('[VibeSurf] Received microphone permission result:', message);
|
|
487
|
+
// This message is typically handled by voice recorder, just acknowledge
|
|
488
|
+
sendResponse({ acknowledged: true });
|
|
489
|
+
break;
|
|
490
|
+
|
|
485
491
|
default:
|
|
486
492
|
console.warn('[VibeSurf] Unknown message type:', message.type);
|
|
487
493
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Permission iframe request script
|
|
2
|
+
// This script runs inside the iframe to request microphone permissions
|
|
3
|
+
|
|
4
|
+
(function() {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
console.log('[PermissionIframe] Permission iframe script loaded');
|
|
8
|
+
console.log('[PermissionIframe] Current URL:', window.location.href);
|
|
9
|
+
console.log('[PermissionIframe] Parent origin:', window.parent.location.origin);
|
|
10
|
+
console.log('[PermissionIframe] Is secure context:', window.isSecureContext);
|
|
11
|
+
|
|
12
|
+
const statusEl = document.getElementById('status');
|
|
13
|
+
|
|
14
|
+
// Function to request microphone permission
|
|
15
|
+
async function requestMicrophonePermission() {
|
|
16
|
+
try {
|
|
17
|
+
console.log('[PermissionIframe] Starting microphone permission request...');
|
|
18
|
+
console.log('[PermissionIframe] Window location:', window.location.href);
|
|
19
|
+
console.log('[PermissionIframe] Is top window:', window === window.top);
|
|
20
|
+
console.log('[PermissionIframe] Document domain:', document.domain);
|
|
21
|
+
|
|
22
|
+
// Check if media devices are available
|
|
23
|
+
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
|
24
|
+
throw new Error('Media devices not supported in this context');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log('[PermissionIframe] Media devices available, requesting getUserMedia...');
|
|
28
|
+
statusEl.textContent = 'Requesting microphone access...';
|
|
29
|
+
statusEl.className = 'status loading';
|
|
30
|
+
|
|
31
|
+
// Request microphone access with minimal constraints
|
|
32
|
+
console.log('[PermissionIframe] About to call getUserMedia...');
|
|
33
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
34
|
+
audio: true,
|
|
35
|
+
video: false
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
console.log('[PermissionIframe] Permission granted! Stream received');
|
|
39
|
+
console.log('[PermissionIframe] Stream tracks:', stream.getTracks().length);
|
|
40
|
+
|
|
41
|
+
// Stop all tracks immediately after getting permission
|
|
42
|
+
stream.getTracks().forEach(track => {
|
|
43
|
+
console.log('[PermissionIframe] Stopping track:', track.kind);
|
|
44
|
+
track.stop();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Update status
|
|
48
|
+
statusEl.textContent = 'Microphone access granted!';
|
|
49
|
+
statusEl.className = 'status success';
|
|
50
|
+
|
|
51
|
+
// Send success message to parent window
|
|
52
|
+
console.log('[PermissionIframe] Sending success message to parent...');
|
|
53
|
+
console.log('[PermissionIframe] Parent window:', window.parent);
|
|
54
|
+
|
|
55
|
+
// First try to send to parent window
|
|
56
|
+
try {
|
|
57
|
+
window.parent.postMessage({
|
|
58
|
+
type: 'MICROPHONE_PERMISSION_RESULT',
|
|
59
|
+
success: true,
|
|
60
|
+
granted: true,
|
|
61
|
+
source: 'iframe'
|
|
62
|
+
}, '*');
|
|
63
|
+
console.log('[PermissionIframe] PostMessage to parent sent successfully');
|
|
64
|
+
} catch (postMessageError) {
|
|
65
|
+
console.error('[PermissionIframe] Failed to send postMessage to parent:', postMessageError);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Also try to send to extension if available
|
|
69
|
+
if (typeof chrome !== 'undefined' && chrome.runtime) {
|
|
70
|
+
try {
|
|
71
|
+
chrome.runtime.sendMessage({
|
|
72
|
+
type: 'MICROPHONE_PERMISSION_RESULT',
|
|
73
|
+
success: true,
|
|
74
|
+
granted: true,
|
|
75
|
+
source: 'iframe'
|
|
76
|
+
}, (response) => {
|
|
77
|
+
if (chrome.runtime.lastError) {
|
|
78
|
+
console.log('[PermissionIframe] Chrome runtime error:', chrome.runtime.lastError);
|
|
79
|
+
} else {
|
|
80
|
+
console.log('[PermissionIframe] Extension message sent successfully:', response);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error('[PermissionIframe] Could not send to extension:', e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return true;
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('[PermissionIframe] Permission request failed:', error);
|
|
92
|
+
console.error('[PermissionIframe] Error details:', {
|
|
93
|
+
name: error.name,
|
|
94
|
+
message: error.message,
|
|
95
|
+
stack: error.stack
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Update status with error
|
|
99
|
+
let errorMessage = '';
|
|
100
|
+
let userMessage = '';
|
|
101
|
+
|
|
102
|
+
if (error.name === 'NotAllowedError') {
|
|
103
|
+
errorMessage = 'Microphone access denied';
|
|
104
|
+
userMessage = 'Please allow microphone access when prompted by your browser';
|
|
105
|
+
} else if (error.name === 'NotFoundError') {
|
|
106
|
+
errorMessage = 'No microphone found';
|
|
107
|
+
userMessage = 'Please ensure a microphone is connected';
|
|
108
|
+
} else if (error.name === 'NotReadableError') {
|
|
109
|
+
errorMessage = 'Microphone in use';
|
|
110
|
+
userMessage = 'Please close other apps using the microphone';
|
|
111
|
+
} else if (error.name === 'SecurityError') {
|
|
112
|
+
errorMessage = 'Security restriction';
|
|
113
|
+
userMessage = 'Cannot access microphone due to security settings';
|
|
114
|
+
} else {
|
|
115
|
+
errorMessage = 'Permission failed';
|
|
116
|
+
userMessage = error.message;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
statusEl.textContent = `${errorMessage}: ${userMessage}`;
|
|
120
|
+
statusEl.className = 'status error';
|
|
121
|
+
|
|
122
|
+
// Send error message to parent window
|
|
123
|
+
console.log('[PermissionIframe] Sending error message to parent...');
|
|
124
|
+
console.log('[PermissionIframe] Error details:', { name: error.name, message: error.message });
|
|
125
|
+
|
|
126
|
+
// First try to send to parent window
|
|
127
|
+
try {
|
|
128
|
+
window.parent.postMessage({
|
|
129
|
+
type: 'MICROPHONE_PERMISSION_RESULT',
|
|
130
|
+
success: false,
|
|
131
|
+
granted: false,
|
|
132
|
+
error: error.message,
|
|
133
|
+
errorName: error.name,
|
|
134
|
+
userMessage: userMessage,
|
|
135
|
+
source: 'iframe'
|
|
136
|
+
}, '*');
|
|
137
|
+
console.log('[PermissionIframe] Error postMessage to parent sent successfully');
|
|
138
|
+
} catch (postMessageError) {
|
|
139
|
+
console.error('[PermissionIframe] Failed to send error postMessage to parent:', postMessageError);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Also try to send to extension if available
|
|
143
|
+
if (typeof chrome !== 'undefined' && chrome.runtime) {
|
|
144
|
+
try {
|
|
145
|
+
chrome.runtime.sendMessage({
|
|
146
|
+
type: 'MICROPHONE_PERMISSION_RESULT',
|
|
147
|
+
success: false,
|
|
148
|
+
granted: false,
|
|
149
|
+
error: error.message,
|
|
150
|
+
errorName: error.name,
|
|
151
|
+
userMessage: userMessage,
|
|
152
|
+
source: 'iframe'
|
|
153
|
+
}, (response) => {
|
|
154
|
+
if (chrome.runtime.lastError) {
|
|
155
|
+
console.log('[PermissionIframe] Chrome runtime error for error message:', chrome.runtime.lastError);
|
|
156
|
+
} else {
|
|
157
|
+
console.log('[PermissionIframe] Error extension message sent successfully:', response);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.error('[PermissionIframe] Could not send error to extension:', e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Start permission request when iframe loads
|
|
170
|
+
if (document.readyState === 'loading') {
|
|
171
|
+
document.addEventListener('DOMContentLoaded', requestMicrophonePermission);
|
|
172
|
+
} else {
|
|
173
|
+
requestMicrophonePermission();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Also listen for messages from parent requesting permission
|
|
177
|
+
window.addEventListener('message', (event) => {
|
|
178
|
+
console.log('[PermissionIframe] Received message from parent:', event.data);
|
|
179
|
+
|
|
180
|
+
if (event.data && event.data.type === 'REQUEST_MICROPHONE_PERMISSION') {
|
|
181
|
+
console.log('[PermissionIframe] Parent requested permission, starting request...');
|
|
182
|
+
requestMicrophonePermission();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
console.log('[PermissionIframe] Permission iframe script initialized');
|
|
187
|
+
|
|
188
|
+
})();
|