Sha256: 35ba28767d4e3bc8f96603de57ff9e0c586deeb3ea6500066552ff89844e73d3

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

/**
 * The code was extracted from:
 * https://github.com/davidchambers/Base64.js
 */

var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

function InvalidCharacterError(message) {
  this.message = message;
}

InvalidCharacterError.prototype = new Error();
InvalidCharacterError.prototype.name = 'InvalidCharacterError';

function polyfill (input) {
  var str = String(input).replace(/=+$/, '');
  if (str.length % 4 == 1) {
    throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
  }
  for (
    // initialize result and counters
    var bc = 0, bs, buffer, idx = 0, output = '';
    // get next character
    buffer = str.charAt(idx++);
    // character found in table? initialize bit storage and add its ascii value;
    ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
      // and if not first of each 4 characters,
      // convert the first 8 bits to one ascii character
      bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
  ) {
    // try to find character in table (0-63, not found => -1)
    buffer = chars.indexOf(buffer);
  }
  return output;
}


module.exports = typeof window !== 'undefined' && window.atob && window.atob.bind(window) || polyfill;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
authing_ruby-1.1.4 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.1.3 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.1.2 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.1.1 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.1.0 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.0.9 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.0.8 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.0.7 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js
authing_ruby-1.0.6 lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js