mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
committed by
GitHub
parent
4e9d31c70b
commit
c8992bb0bf
5
.changes/secure-rng.md
Normal file
5
.changes/secure-rng.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Use secure RNG on callback function names.
|
||||
@@ -7,27 +7,12 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
function s4(): string {
|
||||
return Math.floor((1 + Math.random()) * 0x10000)
|
||||
.toString(16)
|
||||
.substring(1)
|
||||
}
|
||||
|
||||
function uid(): string {
|
||||
return (
|
||||
s4() +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
'-' +
|
||||
s4() +
|
||||
s4() +
|
||||
s4()
|
||||
)
|
||||
const length = new Int8Array(1)
|
||||
window.crypto.getRandomValues(length)
|
||||
const array = new Uint8Array(Math.max(16, Math.abs(length[0])))
|
||||
window.crypto.getRandomValues(array)
|
||||
return array.join('')
|
||||
}
|
||||
|
||||
function transformCallback(
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,29 +7,14 @@ if (!String.prototype.startsWith) {
|
||||
}
|
||||
|
||||
(function () {
|
||||
function s4() {
|
||||
return Math.floor((1 + Math.random()) * 0x10000)
|
||||
.toString(16)
|
||||
.substring(1);
|
||||
function uid() {
|
||||
const length = new Int8Array(1)
|
||||
window.crypto.getRandomValues(length)
|
||||
const array = new Uint8Array(Math.max(16, Math.abs(length[0])))
|
||||
window.crypto.getRandomValues(array)
|
||||
return array.join('')
|
||||
}
|
||||
|
||||
var uid = function () {
|
||||
return (
|
||||
s4() +
|
||||
s4() +
|
||||
"-" +
|
||||
s4() +
|
||||
"-" +
|
||||
s4() +
|
||||
"-" +
|
||||
s4() +
|
||||
"-" +
|
||||
s4() +
|
||||
s4() +
|
||||
s4()
|
||||
);
|
||||
};
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
|
||||
Reference in New Issue
Block a user