From 520470380654f1ff37180898c59bca31641d7b4a Mon Sep 17 00:00:00 2001 From: skocheri Date: Mon, 15 Jun 2020 13:24:07 -0700 Subject: [PATCH] Moving sharedID generation within sharedId module --- modules/sharedIdSystem.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/sharedIdSystem.js b/modules/sharedIdSystem.js index 9c973f13991..5c2a3df0595 100644 --- a/modules/sharedIdSystem.js +++ b/modules/sharedIdSystem.js @@ -13,6 +13,13 @@ const MODULE_NAME = 'sharedId'; const ID_SVC = 'https://id.sharedid.org/id'; const DEFAULT_24_HOURS = 86400; const OPT_OUT_VALUE = '00000000000000000000000000'; +// These values should NEVER change. If +// they do, we're no longer making ulids! +const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; // Crockford's Base32 +const ENCODING_LEN = ENCODING.length; +const TIME_MAX = Math.pow(2, 48) - 1; +const TIME_LEN = 10; +const RANDOM_LEN = 16; const id = factory(); /** * Constructs cookie value @@ -151,14 +158,6 @@ function encodeId(value) { return sharedId; } -// These values should NEVER change. If -// they do, we're no longer making ulids! -const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; // Crockford's Base32 -const ENCODING_LEN = ENCODING.length; -const TIME_MAX = Math.pow(2, 48) - 1; -const TIME_LEN = 10; -const RANDOM_LEN = 16; - /** * the factory to generate unique identifier based on time and current pseudorandom number * @param {string} the current pseudorandom number generator