Socket
Socket
Sign inDemoInstall

js-encoding-utils

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-encoding-utils - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

9

dist/jseu.bundle.js

@@ -1,1 +0,8 @@

!function(r,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.jseu=n():r.jseu=n()}(this,function(){return function(r){var n={};function t(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return r[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=n,t.d=function(r,n,e){t.o(r,n)||Object.defineProperty(r,n,{enumerable:!0,get:e})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,n){if(1&n&&(r=t(r)),8&n)return r;if(4&n&&"object"==typeof r&&r&&r.__esModule)return r;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:r}),2&n&&"string"!=typeof r)for(var o in r)t.d(e,o,function(n){return r[n]}.bind(null,o));return e},t.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(n,"a",n),n},t.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},t.p="/Users/jun/ProjectJavaScript/js_buffer_utils/dist",t(t.s=1)}([function(r,n){},function(r,n,t){r.exports=t(2)},function(r,n,t){"use strict";t.r(n);var e={};t.r(e),t.d(e,"encodeBase64",function(){return f}),t.d(e,"decodeBase64",function(){return a}),t.d(e,"encodeBase64Url",function(){return s}),t.d(e,"decodeBase64Url",function(){return l}),t.d(e,"arrayBufferToHexString",function(){return p}),t.d(e,"hexStringToArrayBuffer",function(){return d}),t.d(e,"arrayBufferToString",function(){return y}),t.d(e,"stringToArrayBuffer",function(){return g});var o={};t.r(o),t.d(o,"pemToBin",function(){return w}),t.d(o,"binToPem",function(){return m});var u=function(r){var n=t(0).Buffer,e=Object.prototype.toString.call(r).slice(8,-1);return(n.isBuffer(r)?r:["ArrayBuffer","TypedArray","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].indexOf(e)>=0?n.from(r):new n.from(r.toString(),"binary")).toString("base64")},i=function(r){return new(t(0).Buffer.from)(r,"base64").toString("binary")};function f(r){var n="";return n="string"==typeof r?r:y(r),("undefined"!=typeof window?window.btoa:u)(n)}function a(r){return function(r){if(r instanceof Uint8Array){for(var n=!0,t=0;t<r.length;t++)if(r[t]>126||r[t]<32&&13!==r[t]&&10!==r[t]){n=!1;break}var e=null;if(n){e="";for(var o=0;o<r.length;o++)e+=String.fromCharCode(r[o])}else e=r;return e}throw new Error("Input data must be an Uint8Array")}(g(("undefined"!=typeof window?window.atob:i)(r)))}function c(r){if(r instanceof Uint8Array)return r;if(ArrayBuffer.isView(r)&&void 0!==r.buffer)return new Uint8Array(r.buffer);if(r instanceof ArrayBuffer)return new Uint8Array(r);throw new Error("Input must be an ArrayBuffer or a TypedArray")}function s(r){return f(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function l(r){if("string"!=typeof r)throw new Error("Input must be string");return a(r=r.replace(/-/g,"+").replace(/_/g,"/"))}function p(r){for(var n=c(r),t="",e=0;e<n.length;e++){var o=(255&n[e]).toString(16);t+=o=1===o.length?"0".concat(o):o}return t}function d(r){if(!r||"string"!=typeof r)throw new Error("Input arg must be a non-null string");for(var n=[],t=r.length,e=0;e<t;e+=2)n.push(parseInt(r.substr(e,2),16));return new Uint8Array(n)}function y(r){var n=c(r);return String.fromCharCode.apply(null,n)}function g(r){if(!r||"string"!=typeof r)throw new Error("Input arg must be a non-null string");for(var n=new Uint8Array(r.length),t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n}var b={public:"PUBLIC KEY",private:"PRIVATE KEY",certificate:"CERTIFICATE",certRequest:"CERTIFICATE REQUEST"};function w(r){return a(function(r){if(!r||"string"!=typeof r)throw new Error("Input arg must be a non-null string");var n=RegExp("^-----[s]*BEGIN[^-]*-----$","gm"),t=RegExp("^-----[s]*END[^-]*-----$","gm");try{var e=r.split(n)[1].split(t)[0];return e=e.replace(/\r?\n/g,"")}catch(r){throw new Error("Invalid format as PEM")}}(r))}function m(r,n){return function(r,n){if(!r||"string"!=typeof r)throw new Error("Input arg must be a non-null string");if(!n||"string"!=typeof n)throw new Error("Input arg must be a non-null string");if(Object.keys(b).indexOf(n)<0)throw new Error("Unsupported type");var t=b[n],e="-----BEGIN ".concat(t,"-----\n");for(;r.length>0;)e+="".concat(r.substring(0,64),"\n"),r=r.substring(64);return e="".concat(e,"-----END ").concat(t,"-----")}(f(r),n)}t.d(n,"encoder",function(){return e}),t.d(n,"formatter",function(){return o});n.default={encoder:e,formatter:o}}])});
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.jseu=r():t.jseu=r()}(this,function(){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="/Users/jun/ProjectJavaScript/js_buffer_utils/dist",n(n.s=1)}([function(t,r,n){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var e=n(3),i=n(4),o=n(5);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(t,r){if(u()<r)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=a.prototype:(null===t&&(t=new a(r)),t.length=r),t}function a(t,r,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,r,n);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return s(this,t,r,n)}function s(t,r,n,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,n,e){if(r.byteLength,n<0||r.byteLength<n)throw new RangeError("'offset' is out of bounds");if(r.byteLength<n+(e||0))throw new RangeError("'length' is out of bounds");r=void 0===n&&void 0===e?new Uint8Array(r):void 0===e?new Uint8Array(r,n):new Uint8Array(r,n,e);a.TYPED_ARRAY_SUPPORT?(t=r).__proto__=a.prototype:t=l(t,r);return t}(t,r,n,e):"string"==typeof r?function(t,r,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var e=0|g(r,n),i=(t=f(t,e)).write(r,n);i!==e&&(t=t.slice(0,i));return t}(t,r,n):function(t,r){if(a.isBuffer(r)){var n=0|p(r.length);return 0===(t=f(t,n)).length?t:(r.copy(t,0,0,n),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||function(t){return t!=t}(r.length)?f(t,0):l(t,r);if("Buffer"===r.type&&o(r.data))return l(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function c(t,r){if(h(r),t=f(t,r<0?0:0|p(r)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<r;++n)t[n]=0;return t}function l(t,r){var n=r.length<0?0:0|p(r.length);t=f(t,n);for(var e=0;e<n;e+=1)t[e]=255&r[e];return t}function p(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function g(t,r){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var e=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(t).length;default:if(e)return k(t).length;r=(""+r).toLowerCase(),e=!0}}function y(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function d(t,r,n,e,i){if(0===t.length)return-1;if("string"==typeof n?(e=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=a.from(r,e)),a.isBuffer(r))return 0===r.length?-1:w(t,r,n,e,i);if("number"==typeof r)return r&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):w(t,[r],n,e,i);throw new TypeError("val must be string, number or Buffer")}function w(t,r,n,e,i){var o,u=1,f=t.length,a=r.length;if(void 0!==e&&("ucs2"===(e=String(e).toLowerCase())||"ucs-2"===e||"utf16le"===e||"utf-16le"===e)){if(t.length<2||r.length<2)return-1;u=2,f/=2,a/=2,n/=2}function s(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var h=-1;for(o=n;o<f;o++)if(s(t,o)===s(r,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===a)return h*u}else-1!==h&&(o-=o-h),h=-1}else for(n+a>f&&(n=f-a),o=n;o>=0;o--){for(var c=!0,l=0;l<a;l++)if(s(t,o+l)!==s(r,l)){c=!1;break}if(c)return o}return-1}function v(t,r,n,e){n=Number(n)||0;var i=t.length-n;e?(e=Number(e))>i&&(e=i):e=i;var o=r.length;if(o%2!=0)throw new TypeError("Invalid hex string");e>o/2&&(e=o/2);for(var u=0;u<e;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[n+u]=f}return u}function A(t,r,n,e){return z(k(r,t.length-n),t,n,e)}function b(t,r,n,e){return z(function(t){for(var r=[],n=0;n<t.length;++n)r.push(255&t.charCodeAt(n));return r}(r),t,n,e)}function E(t,r,n,e){return b(t,r,n,e)}function m(t,r,n,e){return z(F(r),t,n,e)}function _(t,r,n,e){return z(function(t,r){for(var n,e,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=t.charCodeAt(u),e=n>>8,i=n%256,o.push(i),o.push(e);return o}(r,t.length-n),t,n,e)}function R(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function B(t,r,n){n=Math.min(t.length,n);for(var e=[],i=r;i<n;){var o,u,f,a,s=t[i],h=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=n)switch(c){case 1:s<128&&(h=s);break;case 2:128==(192&(o=t[i+1]))&&(a=(31&s)<<6|63&o)>127&&(h=a);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(a=(15&s)<<12|(63&o)<<6|63&u)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(a=(15&s)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&a<1114112&&(h=a)}null===h?(h=65533,c=1):h>65535&&(h-=65536,e.push(h>>>10&1023|55296),h=56320|1023&h),e.push(h),i+=c}return function(t){var r=t.length;if(r<=T)return String.fromCharCode.apply(String,t);var n="",e=0;for(;e<r;)n+=String.fromCharCode.apply(String,t.slice(e,e+=T));return n}(e)}r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),r.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,r,n){return s(null,t,r,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,r,n){return function(t,r,n,e){return h(r),r<=0?f(t,r):void 0!==n?"string"==typeof e?f(t,r).fill(n,e):f(t,r).fill(n):f(t,r)}(null,t,r,n)},a.allocUnsafe=function(t){return c(null,t)},a.allocUnsafeSlow=function(t){return c(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,r){if(!a.isBuffer(t)||!a.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,e=r.length,i=0,o=Math.min(n,e);i<o;++i)if(t[i]!==r[i]){n=t[i],e=r[i];break}return n<e?-1:e<n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,r){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var n;if(void 0===r)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var e=a.allocUnsafe(r),i=0;for(n=0;n<t.length;++n){var u=t[n];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(e,i),i+=u.length}return e},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)y(this,r,r+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)y(this,r,r+3),y(this,r+1,r+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)y(this,r,r+7),y(this,r+1,r+6),y(this,r+2,r+5),y(this,r+3,r+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?B(this,0,t):function(t,r,n){var e=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,r,n);case"utf8":case"utf-8":return B(this,r,n);case"ascii":return P(this,r,n);case"latin1":case"binary":return U(this,r,n);case"base64":return R(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,r,n);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",n=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,r,n,e,i){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===e&&(e=0),void 0===i&&(i=this.length),r<0||n>t.length||e<0||i>this.length)throw new RangeError("out of range index");if(e>=i&&r>=n)return 0;if(e>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,e>>>=0,i>>>=0,this===t)return 0;for(var o=i-e,u=n-r,f=Math.min(o,u),s=this.slice(e,i),h=t.slice(r,n),c=0;c<f;++c)if(s[c]!==h[c]){o=s[c],u=h[c];break}return o<u?-1:u<o?1:0},a.prototype.includes=function(t,r,n){return-1!==this.indexOf(t,r,n)},a.prototype.indexOf=function(t,r,n){return d(this,t,r,n,!0)},a.prototype.lastIndexOf=function(t,r,n){return d(this,t,r,n,!1)},a.prototype.write=function(t,r,n,e){if(void 0===r)e="utf8",n=this.length,r=0;else if(void 0===n&&"string"==typeof r)e=r,n=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(n)?(n|=0,void 0===e&&(e="utf8")):(e=n,n=void 0)}var i=this.length-r;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");for(var o=!1;;)switch(e){case"hex":return v(this,t,r,n);case"utf8":case"utf-8":return A(this,t,r,n);case"ascii":return b(this,t,r,n);case"latin1":case"binary":return E(this,t,r,n);case"base64":return m(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function P(t,r,n){var e="";n=Math.min(t.length,n);for(var i=r;i<n;++i)e+=String.fromCharCode(127&t[i]);return e}function U(t,r,n){var e="";n=Math.min(t.length,n);for(var i=r;i<n;++i)e+=String.fromCharCode(t[i]);return e}function S(t,r,n){var e=t.length;(!r||r<0)&&(r=0),(!n||n<0||n>e)&&(n=e);for(var i="",o=r;o<n;++o)i+=N(t[o]);return i}function I(t,r,n){for(var e=t.slice(r,n),i="",o=0;o<e.length;o+=2)i+=String.fromCharCode(e[o]+256*e[o+1]);return i}function Y(t,r,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>n)throw new RangeError("Trying to access beyond buffer length")}function C(t,r,n,e,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(n+e>t.length)throw new RangeError("Index out of range")}function O(t,r,n,e){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(r&255<<8*(e?i:1-i))>>>8*(e?i:1-i)}function x(t,r,n,e){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=r>>>8*(e?i:3-i)&255}function M(t,r,n,e,i,o){if(n+e>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,r,n,e,o){return o||M(t,0,n,4),i.write(t,r,n,e,23,4),n+4}function D(t,r,n,e,o){return o||M(t,0,n,8),i.write(t,r,n,e,52,8),n+8}a.prototype.slice=function(t,r){var n,e=this.length;if(t=~~t,r=void 0===r?e:~~r,t<0?(t+=e)<0&&(t=0):t>e&&(t=e),r<0?(r+=e)<0&&(r=0):r>e&&(r=e),r<t&&(r=t),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,r)).__proto__=a.prototype;else{var i=r-t;n=new a(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},a.prototype.readUIntLE=function(t,r,n){t|=0,r|=0,n||Y(t,r,this.length);for(var e=this[t],i=1,o=0;++o<r&&(i*=256);)e+=this[t+o]*i;return e},a.prototype.readUIntBE=function(t,r,n){t|=0,r|=0,n||Y(t,r,this.length);for(var e=this[t+--r],i=1;r>0&&(i*=256);)e+=this[t+--r]*i;return e},a.prototype.readUInt8=function(t,r){return r||Y(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,r){return r||Y(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,r){return r||Y(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,r){return r||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,r){return r||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,r,n){t|=0,r|=0,n||Y(t,r,this.length);for(var e=this[t],i=1,o=0;++o<r&&(i*=256);)e+=this[t+o]*i;return e>=(i*=128)&&(e-=Math.pow(2,8*r)),e},a.prototype.readIntBE=function(t,r,n){t|=0,r|=0,n||Y(t,r,this.length);for(var e=r,i=1,o=this[t+--e];e>0&&(i*=256);)o+=this[t+--e]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},a.prototype.readInt8=function(t,r){return r||Y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,r){r||Y(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,r){r||Y(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,r){return r||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,r){return r||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,r){return r||Y(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,r){return r||Y(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,r){return r||Y(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,r){return r||Y(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,r,n,e){(t=+t,r|=0,n|=0,e)||C(this,t,r,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[r]=255&t;++o<n&&(i*=256);)this[r+o]=t/i&255;return r+n},a.prototype.writeUIntBE=function(t,r,n,e){(t=+t,r|=0,n|=0,e)||C(this,t,r,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+n},a.prototype.writeUInt8=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},a.prototype.writeUInt16LE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},a.prototype.writeUInt16BE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},a.prototype.writeUInt32LE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):x(this,t,r,!0),r+4},a.prototype.writeUInt32BE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):x(this,t,r,!1),r+4},a.prototype.writeIntLE=function(t,r,n,e){if(t=+t,r|=0,!e){var i=Math.pow(2,8*n-1);C(this,t,r,n,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<n&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+n},a.prototype.writeIntBE=function(t,r,n,e){if(t=+t,r|=0,!e){var i=Math.pow(2,8*n-1);C(this,t,r,n,i-1,-i)}var o=n-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+n},a.prototype.writeInt8=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},a.prototype.writeInt16LE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},a.prototype.writeInt16BE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},a.prototype.writeInt32LE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):x(this,t,r,!0),r+4},a.prototype.writeInt32BE=function(t,r,n){return t=+t,r|=0,n||C(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):x(this,t,r,!1),r+4},a.prototype.writeFloatLE=function(t,r,n){return L(this,t,r,!0,n)},a.prototype.writeFloatBE=function(t,r,n){return L(this,t,r,!1,n)},a.prototype.writeDoubleLE=function(t,r,n){return D(this,t,r,!0,n)},a.prototype.writeDoubleBE=function(t,r,n){return D(this,t,r,!1,n)},a.prototype.copy=function(t,r,n,e){if(n||(n=0),e||0===e||(e=this.length),r>=t.length&&(r=t.length),r||(r=0),e>0&&e<n&&(e=n),e===n)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),t.length-r<e-n&&(e=t.length-r+n);var i,o=e-n;if(this===t&&n<r&&r<e)for(i=o-1;i>=0;--i)t[i+r]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),r);return o},a.prototype.fill=function(t,r,n,e){if("string"==typeof t){if("string"==typeof r?(e=r,r=0,n=this.length):"string"==typeof n&&(e=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==e&&"string"!=typeof e)throw new TypeError("encoding must be a string");if("string"==typeof e&&!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;var o;if(r>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=r;o<n;++o)this[o]=t;else{var u=a.isBuffer(t)?t:k(new a(t,e).toString()),f=u.length;for(o=0;o<n-r;++o)this[o+r]=u[o%f]}return this};var j=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function k(t,r){var n;r=r||1/0;for(var e=t.length,i=null,o=[],u=0;u<e;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!i){if(n>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===e){(r-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(r-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((r-=1)<0)break;o.push(n)}else if(n<2048){if((r-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((r-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function F(t){return e.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,r,n,e){for(var i=0;i<e&&!(i+n>=r.length||i>=t.length);++i)r[i+n]=t[i];return i}}).call(this,n(2))},function(t,r,n){t.exports=n(6)},function(t,r){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,r,n){"use strict";r.byteLength=function(t){var r=s(t),n=r[0],e=r[1];return 3*(n+e)/4-e},r.toByteArray=function(t){for(var r,n=s(t),e=n[0],u=n[1],f=new o(function(t,r,n){return 3*(r+n)/4-n}(0,e,u)),a=0,h=u>0?e-4:e,c=0;c<h;c+=4)r=i[t.charCodeAt(c)]<<18|i[t.charCodeAt(c+1)]<<12|i[t.charCodeAt(c+2)]<<6|i[t.charCodeAt(c+3)],f[a++]=r>>16&255,f[a++]=r>>8&255,f[a++]=255&r;2===u&&(r=i[t.charCodeAt(c)]<<2|i[t.charCodeAt(c+1)]>>4,f[a++]=255&r);1===u&&(r=i[t.charCodeAt(c)]<<10|i[t.charCodeAt(c+1)]<<4|i[t.charCodeAt(c+2)]>>2,f[a++]=r>>8&255,f[a++]=255&r);return f},r.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],u=0,f=n-i;u<f;u+=16383)o.push(c(t,u,u+16383>f?f:u+16383));1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"="));return o.join("")};for(var e=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,a=u.length;f<a;++f)e[f]=u[f],i[u.charCodeAt(f)]=f;function s(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=r),[n,n===r?0:4-n%4]}function h(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function c(t,r,n){for(var e,i=[],o=r;o<n;o+=3)e=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(h(e));return i.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,r){r.read=function(t,r,n,e,i){var o,u,f=8*i-e-1,a=(1<<f)-1,s=a>>1,h=-7,c=n?i-1:0,l=n?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-h)-1,p>>=-h,h+=f;h>0;o=256*o+t[r+c],c+=l,h-=8);for(u=o&(1<<-h)-1,o>>=-h,h+=e;h>0;u=256*u+t[r+c],c+=l,h-=8);if(0===o)o=1-s;else{if(o===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,e),o-=s}return(p?-1:1)*u*Math.pow(2,o-e)},r.write=function(t,r,n,e,i,o){var u,f,a,s=8*o-i-1,h=(1<<s)-1,c=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=e?0:o-1,g=e?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,u=h):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),(r+=u+c>=1?l/a:l*Math.pow(2,1-c))*a>=2&&(u++,a/=2),u+c>=h?(f=0,u=h):u+c>=1?(f=(r*a-1)*Math.pow(2,i),u+=c):(f=r*Math.pow(2,c-1)*Math.pow(2,i),u=0));i>=8;t[n+p]=255&f,p+=g,f/=256,i-=8);for(u=u<<i|f,s+=i;s>0;t[n+p]=255&u,p+=g,u/=256,s-=8);t[n+p-g]|=128*y}},function(t,r){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,r,n){"use strict";n.r(r);var e={};n.r(e),n.d(e,"encodeBase64",function(){return f}),n.d(e,"decodeBase64",function(){return a}),n.d(e,"encodeBase64Url",function(){return h}),n.d(e,"decodeBase64Url",function(){return c}),n.d(e,"arrayBufferToHexString",function(){return l}),n.d(e,"hexStringToArrayBuffer",function(){return p}),n.d(e,"arrayBufferToString",function(){return g}),n.d(e,"stringToArrayBuffer",function(){return y});var i={};n.r(i),n.d(i,"pemToBin",function(){return w}),n.d(i,"binToPem",function(){return v});var o=function(t){var r=n(0).Buffer,e=Object.prototype.toString.call(t).slice(8,-1);return(r.isBuffer(t)?t:["ArrayBuffer","TypedArray","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].indexOf(e)>=0?r.from(t):new r.from(t.toString(),"binary")).toString("base64")},u=function(t){return new(n(0).Buffer.from)(t,"base64").toString("binary")};function f(t){var r="";return r="string"==typeof t?t:g(t),("undefined"!=typeof window?window.btoa:o)(r)}function a(t){return function(t){if(t instanceof Uint8Array){for(var r=!0,n=0;n<t.length;n++)if(t[n]>126||t[n]<32&&13!==t[n]&&10!==t[n]){r=!1;break}var e=null;if(r){e="";for(var i=0;i<t.length;i++)e+=String.fromCharCode(t[i])}else e=t;return e}throw new Error("Input data must be an Uint8Array")}(y(("undefined"!=typeof window?window.atob:u)(t)))}function s(t){if(t instanceof Uint8Array)return t;if(ArrayBuffer.isView(t)&&void 0!==t.buffer)return new Uint8Array(t.buffer);if(t instanceof ArrayBuffer)return new Uint8Array(t);throw new Error("Input must be an ArrayBuffer or a TypedArray")}function h(t){return f(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function c(t){if("string"!=typeof t)throw new Error("Input must be string");return a(t=t.replace(/-/g,"+").replace(/_/g,"/"))}function l(t){for(var r=s(t),n="",e=0;e<r.length;e++){var i=(255&r[e]).toString(16);n+=i=1===i.length?"0".concat(i):i}return n}function p(t){if(!t||"string"!=typeof t)throw new Error("Input arg must be a non-null string");for(var r=[],n=t.length,e=0;e<n;e+=2)r.push(parseInt(t.substr(e,2),16));return new Uint8Array(r)}function g(t){var r=s(t);return String.fromCharCode.apply(null,r)}function y(t){if(!t||"string"!=typeof t)throw new Error("Input arg must be a non-null string");for(var r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}var d={public:"PUBLIC KEY",private:"PRIVATE KEY",certificate:"CERTIFICATE",certRequest:"CERTIFICATE REQUEST"};function w(t){return a(function(t){if(!t||"string"!=typeof t)throw new Error("Input arg must be a non-null string");var r=RegExp("^-----[s]*BEGIN[^-]*-----$","gm"),n=RegExp("^-----[s]*END[^-]*-----$","gm");try{var e=t.split(r)[1].split(n)[0];return e=e.replace(/\r?\n/g,"")}catch(t){throw new Error("Invalid format as PEM")}}(t))}function v(t,r){return function(t,r){if(!t||"string"!=typeof t)throw new Error("Input arg must be a non-null string");if(!r||"string"!=typeof r)throw new Error("Input arg must be a non-null string");if(Object.keys(d).indexOf(r)<0)throw new Error("Unsupported type");var n=d[r],e="-----BEGIN ".concat(n,"-----\n");for(;t.length>0;)e+="".concat(t.substring(0,64),"\n"),t=t.substring(64);return e="".concat(e,"-----END ").concat(n,"-----")}(f(t),r)}n.d(r,"encoder",function(){return e}),n.d(r,"formatter",function(){return i});r.default={encoder:e,formatter:i}}])});

5

package.json
{
"name": "js-encoding-utils",
"version": "0.2.1",
"version": "0.2.2",
"description": "Miscellaneous Encoding Utilities for Crypto-related Objects in JavaScript",

@@ -56,6 +56,3 @@ "main": "dist/jseu.bundle.js",

"@babel/runtime": "7.0.0"
},
"browser": {
"buffer": false
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc