Skip to content

Commit

Permalink
fix: omit cookies from API requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Jun 3, 2024
1 parent 20b3d46 commit cb4811e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ async function getWitSpeechApiResult(apiKey, audioContent) {
const result = {};

const rsp = await fetch('https://api.wit.ai/speech?v=20240304', {
mode: 'cors',
method: 'POST',
headers: {
Authorization: 'Bearer ' + apiKey
},
body: new Blob([audioContent], {type: 'audio/wav'})
body: new Blob([audioContent], {type: 'audio/wav'}),
credentials: 'omit'
});

if (rsp.status !== 200) {
Expand Down Expand Up @@ -472,9 +472,9 @@ async function getGoogleSpeechApiResult(
const rsp = await fetch(
`https://speech.googleapis.com/v1p1beta1/speech:recognize?key=${apiKey}`,
{
mode: 'cors',
method: 'POST',
body: JSON.stringify(data)
body: JSON.stringify(data),
credentials: 'omit'
}
);

Expand Down Expand Up @@ -512,12 +512,12 @@ async function getIbmSpeechApiResult(apiUrl, apiKey, audioContent, model) {

if (targetEnv === 'firefox') {
const rsp = await fetch('https://iam.cloud.ibm.com/identity/token', {
mode: 'cors',
method: 'POST',
body: new URLSearchParams({
grant_type: 'urn:ibm:params:oauth:grant-type:apikey',
apikey: apiKey
})
}),
credentials: 'omit'
});

if (rsp.status !== 200) {
Expand Down Expand Up @@ -585,15 +585,15 @@ async function getIbmSpeechApiResult(apiUrl, apiKey, audioContent, model) {
const rsp = await fetch(
`${apiUrl}/v1/recognize?model=${model}&profanity_filter=false`,
{
mode: 'cors',
method: 'POST',
headers: {
Authorization: 'Basic ' + self.btoa('apikey:' + apiKey),
'X-Watson-Learning-Opt-Out': 'true',
// Invalid value, see description above
Priority: '1'
},
body: new Blob([audioContent], {type: 'audio/wav'})
body: new Blob([audioContent], {type: 'audio/wav'}),
credentials: 'omit'
}
);

Expand All @@ -617,13 +617,13 @@ async function getMicrosoftSpeechApiResult(
const rsp = await fetch(
`https://${apiLocation}.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=${language}&format=detailed&profanity=raw`,
{
mode: 'cors',
method: 'POST',
headers: {
'Ocp-Apim-Subscription-Key': apiKey,
'Content-type': 'audio/wav; codec=audio/pcm; samplerate=16000'
},
body: new Blob([audioContent], {type: 'audio/wav'})
body: new Blob([audioContent], {type: 'audio/wav'}),
credentials: 'omit'
}
);

Expand Down
3 changes: 0 additions & 3 deletions src/setup/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export default {
data.append('session', this.session);
await fetch(`${this.apiUrl}/setup/close`, {
mode: 'cors',
method: 'POST',
body: data
});
Expand All @@ -150,7 +149,6 @@ export default {
data.append('targetEnv', this.$env.targetEnv);
const rsp = await fetch(`${this.apiUrl}/setup/location`, {
mode: 'cors',
method: 'POST',
body: data
});
Expand All @@ -175,7 +173,6 @@ export default {
data.append('extension', this.getExtensionId());
const rsp = await fetch(`${this.apiUrl}/setup/install`, {
mode: 'cors',
method: 'POST',
body: data
});
Expand Down

0 comments on commit cb4811e

Please sign in to comment.