You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 87cb74e
Browse filesBrowse the repository at this point in the historyBrowse files
fix: keep the permission prompt inside the user's gesture on Firefox
From the review on #11. Firefox allows permissions.request only while the
user's gesture is live, and any earlier await in the handler ends it. The
"no active window" fix awaited permissions.contains first, which would have
broken every save that needs a prompt on Firefox desktop: Vercel, TypeSafe,
and custom endpoints.
The granted origins are now read once when the popup opens (and again on
every grant or revocation), the comparison is synchronous, and the prompt
is the first thing the save handler awaits. A grant that covers every site
counts as covering the origin.
// The browser has nowhere to draw the prompt. Say what to do, not what
70
-
// went wrong inside.
71
-
if(/window/i.test(errorMessage(error))){
72
-
thrownewError(
73
-
`This browser cannot ask for permission to reach ${missing.map(host).join(', ')} from here. OpenRouter needs no extra permission, so it works on phones; the other providers need a desktop browser.`,
74
-
);
75
-
}
76
-
throwerror;
77
-
});
78
-
if(!granted)thrownewError('Permission to reach the provider was not granted.');
63
+
* ones not yet granted. Two rules meet here. The prompt needs a browser
64
+
* window, and a popup opened as a tab (Kiwi, and Firefox on a phone) has none,
65
+
* so asking for an origin the manifest already covers would fail there with
66
+
* "no active window" and block the save for nothing. And Firefox allows the
67
+
* prompt only while the user's gesture is live, which any `await` ends. So the
68
+
* granted set is read from a cache filled when the popup opened, the comparison
69
+
* is synchronous, and `permissions.request` is the first thing awaited. */
// The browser has nowhere to draw the prompt. Say what to do, not what
77
+
// went wrong inside.
78
+
if(/window/i.test(errorMessage(error))){
79
+
thrownewError(
80
+
`This browser cannot ask for permission to reach ${missing.map(host).join(', ')} from here. OpenRouter needs no extra permission, so it works on phones; the other providers need a desktop browser.`,
81
+
);
82
+
}
83
+
throwerror;
84
+
})
85
+
.then((ok)=>{
86
+
if(!ok)thrownewError('Permission to reach the provider was not granted.');
87
+
});
88
+
}
89
+
90
+
/** Every origin the browser has granted, kept current. Read once when the popup
91
+
* opens, then on every grant or revocation, so a save can compare without
0 commit comments