Skip to content

Commit

Permalink
Remove array fill (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Hamley authored May 21, 2019
1 parent 82ac066 commit 01e2066
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util/sku_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ type SkuTokenObject = {|
const SKU_ID = '01';

function createSkuToken(): SkuTokenObject {
// these fields are specified by an internal schema and should not change
// SKU_ID and TOKEN_VERSION are specified by an internal schema and should not change
const TOKEN_VERSION = '1';
// sessionRandomizer is a randomized 10-digit base-62 number
const base62chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const sessionRandomizer = new Array(10).fill().map(() => base62chars[Math.floor(Math.random() * 62)]).join('');
// sessionRandomizer is a randomized 10-digit base-62 number
let sessionRandomizer = '';
for (let i = 0; i < 10; i++) {
sessionRandomizer += base62chars[Math.floor(Math.random() * 62)];
}
const expiration = 12 * 60 * 60 * 1000; // 12 hours
const token = [TOKEN_VERSION, SKU_ID, sessionRandomizer].join('');
const tokenExpiresAt = Date.now() + expiration;
Expand Down

0 comments on commit 01e2066

Please sign in to comment.