split b64u functions into separate package
[squeep-mystery-box] / lib / common.js
index a47226f6e76fe355416380f3a77db24450481783..4c7e6392fe1f7e6f28a9321680d56fbf933404cb 100644 (file)
@@ -19,56 +19,7 @@ const fileScope = (filename) => {
 }
 
 
-/**
- * Convert Base64 to Base64URL.
- * @param {String} input
- * @returns {String}
- */
-const base64ToBase64URL = (input) => {
-  if (!input) {
-    return input;
-  }
-  return input
-    .replace(/=/g, '')
-    .replace(/\+/g, '-')
-    .replace(/\//g, '_');
-};
-
-
-/**
- * Convert Base64URL to normal Base64.
- * @param {String} input
- * @returns {String}
- */
-const base64URLToBase64 = (input) => {
-  if (!input) {
-    return input;
-  }
-  return base64RePad(input)
-    .replace(/-/g, '+')
-    .replace(/_/, '/');
-};
-
-
-/**
- * Add any missing trailing padding which may have been removed from Base64URL encoding.
- * @param {String} input
- */
-const base64RePad = (input) => {
-  const blockSize = 4;
-  const lastBlockSize = input.length % blockSize;
-  if (lastBlockSize) {
-    const missing = blockSize - lastBlockSize;
-    return input + '='.repeat(missing);
-  }
-  return input;
-};
-
-
 module.exports = {
-  base64ToBase64URL,
-  base64URLToBase64,
-  base64RePad,
   fileScope,
   randomBytesAsync,
 };
\ No newline at end of file