avancement planning
This commit is contained in:
+8
-5
@@ -14,12 +14,15 @@ async function getRandomValues(size) {
|
||||
*/
|
||||
async function random(size) {
|
||||
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
||||
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
||||
let result = "";
|
||||
const randomUints = await getRandomValues(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
// cap the value of the randomIndex to mask.length - 1
|
||||
const randomIndex = randomUints[i] % mask.length;
|
||||
result += mask[randomIndex];
|
||||
while (result.length < size) {
|
||||
const randomBytes = await getRandomValues(size - result.length);
|
||||
for (const randomByte of randomBytes) {
|
||||
if (randomByte < evenDistCutoff) {
|
||||
result += mask[randomByte % mask.length];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+8
-5
@@ -22,12 +22,15 @@ async function getRandomValues(size) {
|
||||
*/
|
||||
async function random(size) {
|
||||
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
||||
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
||||
let result = "";
|
||||
const randomUints = await getRandomValues(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
// cap the value of the randomIndex to mask.length - 1
|
||||
const randomIndex = randomUints[i] % mask.length;
|
||||
result += mask[randomIndex];
|
||||
while (result.length < size) {
|
||||
const randomBytes = await getRandomValues(size - result.length);
|
||||
for (const randomByte of randomBytes) {
|
||||
if (randomByte < evenDistCutoff) {
|
||||
result += mask[randomByte % mask.length];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+8
-5
@@ -17,12 +17,15 @@ async function getRandomValues(size) {
|
||||
*/
|
||||
async function random(size) {
|
||||
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
||||
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
||||
let result = "";
|
||||
const randomUints = await getRandomValues(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
// cap the value of the randomIndex to mask.length - 1
|
||||
const randomIndex = randomUints[i] % mask.length;
|
||||
result += mask[randomIndex];
|
||||
while (result.length < size) {
|
||||
const randomBytes = await getRandomValues(size - result.length);
|
||||
for (const randomByte of randomBytes) {
|
||||
if (randomByte < evenDistCutoff) {
|
||||
result += mask[randomByte % mask.length];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pkce-challenge",
|
||||
"version": "5.0.0",
|
||||
"version": "5.0.1",
|
||||
"description": "Generate or verify a Proof Key for Code Exchange (PKCE) challenge pair",
|
||||
"browser": "dist/index.browser.js",
|
||||
"type": "module",
|
||||
@@ -21,7 +21,8 @@
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
"dist/",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"scripts": {
|
||||
"watch": "tsc --watch --declaration",
|
||||
|
||||
Reference in New Issue
Block a user