Replace crypto uuid (#408)
This commit is contained in:
Родитель
4be46609f4
Коммит
1d57d21bc7
|
@ -36,6 +36,7 @@
|
|||
"settings.js",
|
||||
"controller/translation/bergamotTranslatorVersion.js",
|
||||
"model/telemetry/schema.js",
|
||||
"model/uuid.js",
|
||||
"model/telemetry/PingSender.js",
|
||||
"controller/languageDetection/LanguageDetection.js",
|
||||
"controller/languageDetection/fasttext_wasm.js",
|
||||
|
@ -72,6 +73,7 @@
|
|||
"controller/languageDetection/LanguageDetection.js",
|
||||
"view/js/OutboundTranslation.js",
|
||||
"view/js/InPageTranslation.js",
|
||||
"model/uuid.js",
|
||||
"mediator.js"
|
||||
],
|
||||
"css": [
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/* global LanguageDetection, OutboundTranslation, Translation , browser,
|
||||
InPageTranslation, browser, modelRegistryVersion, reportErrorsWrap */
|
||||
InPageTranslation, browser, modelRegistryVersion, reportErrorsWrap, uuidv4 */
|
||||
|
||||
/* eslint-disable max-lines */
|
||||
|
||||
|
@ -126,7 +126,7 @@ class Mediator {
|
|||
}
|
||||
|
||||
if (message.payload.type === "outbound") {
|
||||
if (!sender.selectedTextArea.id) sender.selectedTextArea.id = self.crypto.randomUUID();
|
||||
if (!sender.selectedTextArea.id) sender.selectedTextArea.id = uuidv4();
|
||||
browser.runtime.sendMessage({
|
||||
command: "reportOutboundStats",
|
||||
tabId: this.tabId,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* sends telemetry pings to telemetry API
|
||||
*/
|
||||
|
||||
/* global settings, browser, Sentry */
|
||||
/* global settings, browser, Sentry, uuidv4 */
|
||||
|
||||
const DELETION_REQUEST_PING = "deletion-request";
|
||||
const TELEMETRY_APP_ID = "firefox-translations";
|
||||
|
@ -36,7 +36,7 @@ class PingSender {
|
|||
this._firstRunDate = state[STORAGE_FIRST_RUN];
|
||||
} else {
|
||||
// this information is generated once for a user
|
||||
this._clientId = self.crypto.randomUUID();
|
||||
this._clientId = uuidv4();
|
||||
this._seq = {};
|
||||
this._firstRunDate = new Date().toISOString()
|
||||
await this._save();
|
||||
|
@ -95,7 +95,7 @@ class PingSender {
|
|||
if ((!this._uploadEnabled && pingName !== DELETION_REQUEST_PING) || !settings.uploadTelemetry) {
|
||||
this._log("uploading is disabled, ping is not sent")
|
||||
} else {
|
||||
let uuid = self.crypto.randomUUID();
|
||||
let uuid = uuidv4();
|
||||
// we imitate behavior of glean.js 0.15.0
|
||||
let headers = {
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* crypto.randomUUID() is supported only starting from firefox 95
|
||||
* https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
|
||||
*/
|
||||
/* eslint-disable */
|
||||
const uuidv4 = () => {
|
||||
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
|
||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||
);
|
||||
}
|
Загрузка…
Ссылка в новой задаче