зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1739563 - Replace screenshots' makeUuid.js with crypto.randomUUID(). r=sfoster
`crypto.randomUUID()` is a new Web API implemented in bug 1723674. It returns a random UUID string (without curly braces), so we no longer need to roll our own UUIDs in makeUuid.js. Differential Revision: https://phabricator.services.mozilla.com/D130442
This commit is contained in:
Родитель
91122391ce
Коммит
5ecb03e6cc
|
@ -3,7 +3,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* globals log */
|
||||
/* globals main, makeUuid, deviceInfo, analytics, catcher, communication, browser */
|
||||
/* globals main, deviceInfo, analytics, catcher, communication, browser */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -30,7 +30,7 @@ this.auth = (function() {
|
|||
|
||||
function generateRegistrationInfo() {
|
||||
const info = {
|
||||
secret: makeUuid(),
|
||||
secret: crypto.randomUUID(),
|
||||
registered: false,
|
||||
};
|
||||
return info;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* globals browser, getStrings, selectorLoader, analytics, communication, catcher, log, makeUuid, auth, senderror, startBackground, blobConverters, startSelectionWithOnboarding */
|
||||
/* globals browser, getStrings, selectorLoader, analytics, communication, catcher, log, auth, senderror, startBackground, blobConverters, startSelectionWithOnboarding */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -153,7 +153,7 @@ this.main = (function() {
|
|||
|
||||
communication.register("openShot", async (sender, { url, copied }) => {
|
||||
if (copied) {
|
||||
const id = makeUuid();
|
||||
const id = crypto.randomUUID();
|
||||
const [title, message] = await getStrings([
|
||||
{ id: "screenshots-notification-link-copied-title" },
|
||||
{ id: "screenshots-notification-link-copied-details" },
|
||||
|
|
|
@ -27,7 +27,6 @@ this.selectorLoader = (function() {
|
|||
|
||||
const selectorScripts = [
|
||||
"clipboard.js",
|
||||
"makeUuid.js",
|
||||
"build/selection.js",
|
||||
"build/shot.js",
|
||||
"randomString.js",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* globals startBackground, analytics, communication, makeUuid, Raven, catcher, auth, log, browser, getStrings */
|
||||
/* globals startBackground, analytics, communication, Raven, catcher, auth, log, browser, getStrings */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -60,7 +60,7 @@ this.senderror = (function() {
|
|||
return;
|
||||
}
|
||||
lastErrorTime = Date.now();
|
||||
const id = makeUuid();
|
||||
const id = crypto.randomUUID();
|
||||
let popupMessage = error.popupMessage || "generic";
|
||||
if (!messages[popupMessage]) {
|
||||
popupMessage = "generic";
|
||||
|
|
|
@ -47,7 +47,6 @@ this.startBackground = (function() {
|
|||
|
||||
const backgroundScripts = [
|
||||
"log.js",
|
||||
"makeUuid.js",
|
||||
"catcher.js",
|
||||
"blobConverters.js",
|
||||
"background/selectorLoader.js",
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
this.makeUuid = (function() {
|
||||
// generates a v4 UUID
|
||||
return function makeUuid() {
|
||||
// eslint-disable-line no-unused-vars
|
||||
// get sixteen unsigned 8 bit random values
|
||||
const randomValues = window.crypto.getRandomValues(new Uint8Array(36));
|
||||
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
||||
const i = Array.prototype.slice.call(arguments).slice(-2)[0]; // grab the `offset` parameter
|
||||
const r = randomValues[i] % 16 | 0,
|
||||
v = c === "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
})();
|
||||
null;
|
|
@ -18,7 +18,6 @@ FINAL_TARGET_FILES.features["screenshots@mozilla.org"] += [
|
|||
"clipboard.js",
|
||||
"domainFromUrl.js",
|
||||
"log.js",
|
||||
"makeUuid.js",
|
||||
"manifest.json",
|
||||
"moz.build",
|
||||
"randomString.js",
|
||||
|
|
Загрузка…
Ссылка в новой задаче