crypto-pro-js/dist/crypto-pro-js.min.js

11 lines
132 KiB
JavaScript
Raw Permalink Normal View History

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("cryptoPro",[],r):"object"==typeof exports?exports.cryptoPro=r():e.cryptoPro=r()}(window,(function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var _=r[n]={i:n,l:!1,exports:{}};return e[n].call(_.exports,_,_.exports,t),_.l=!0,_.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var _ in e)t.d(n,_,function(r){return e[r]}.bind(null,_));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=17)}([function(e,r,t){"use strict";var n=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(_,a){function s(e){try{i(n.next(e))}catch(e){a(e)}}function o(e){try{i(n.throw(e))}catch(e){a(e)}}function i(e){var r;e.done?_(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},_=this&&this.__generator||function(e,r){var t,n,_,a,s={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(_=2&a[0]?n.return:a[0]?n.throw||((_=n.return)&&_.call(n),0):n.next)&&!(_=_.call(n,a[1])).done)return _;switch(n=0,_&&(a=[2&a[0],_.value]),a[0]){case 0:case 1:_=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(_=s.trys,(_=_.length>0&&_[_.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!_||a[1]>_[0]&&a[1]<_[3])){s.label=a[1];break}if(6===a[0]&&s.label<_[1]){s.label=_[1],_=a;break}if(_&&s.label<_[2]){s.label=_[2],s.ops.push(a);break}_[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],n=0}finally{t=_=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}};Object.defineProperty(r,"__esModule",{value:!0}),r._afterPluginsLoaded=void 0;var a=t(1),s=!1,o=!1;r._afterPluginsLoaded=function(e){var r=Boolean(window.Promise);return function(){for(var i=[],c=0;c<arguments.length;c++)i[c]=arguments[c];return n(this,void 0,void 0,(function(){var n,c;return _(this,(function(_){switch(_.label){case 0:if(!o){try{t(20)}catch(e){throw console.error(e),new Error(a._extractMeaningfulErrorMessage(e)||"Ошибка при подключении модуля для работы с Cades plugin")}o=!0}if(n=window.cadesplugin,!r)throw new Error("Необходим полифилл для Promise");if(!n)throw new Error("Не подключен модуль для работы с Cades plugin");s||(n.set_log_level(n.LOG_LEVEL_ERROR),s=!0),_.label=1;case 1:return _.trys.push([1,3,,4]),[4,n];case 2:return _.sent(),[3,4];case 3:throw c=_.sent(),console.error(c),new Error(a._extractMeaningfulErrorMessage(c)||"Ошибка при инициализации модуля для работы с Cades plugin");case 4:return[4,e.apply(this,i)];case 5:return[2,_.sent()]}}))}))}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r._extractMeaningfulErrorMessage=void 0,r._extractMeaningfulErrorMessage=function(e){var r,t=(null===(r=window.cadesplugin)||void 0===r?void 0:r.getLastError)&&window.cadesplugin.getLastError(e);if(!(null==t?void 0:t.message)){if(!e.message)return null;t=e}if(!/[а-яА-Я]/.test(t.message))return null;var n=t.mes
2021-06-04 18:44:56 +03:00
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var n=t(44),_=t(45),a=t(46);function s(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,r){if(s()<r)throw new RangeError("Invalid typed array length");return i.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(r)).__proto__=i.prototype:(null===e&&(e=new i(r)),e.length=r),e}function i(e,r,t){if(!(i.TYPED_ARRAY_SUPPORT||this instanceof i))return new i(e,r,t);if("number"==typeof e){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,r,t)}function c(e,r,t,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(e,r,t,n){if(r.byteLength,t<0||r.byteLength<t)throw new RangeError("'offset' is out of bounds");if(r.byteLength<t+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===t&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,t):new Uint8Array(r,t,n);i.TYPED_ARRAY_SUPPORT?(e=r).__proto__=i.prototype:e=d(e,r);return e}(e,r,t,n):"string"==typeof r?function(e,r,t){"string"==typeof t&&""!==t||(t="utf8");if(!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=0|E(r,t),_=(e=o(e,n)).write(r,t);_!==n&&(e=e.slice(0,_));return e}(e,r,t):function(e,r){if(i.isBuffer(r)){var t=0|C(r.length);return 0===(e=o(e,t)).length||r.copy(e,0,0,t),e}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(n=r.length)!=n?o(e,0):d(e,r);if("Buffer"===r.type&&a(r.data))return d(e,r.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,r)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,r){if(u(r),e=o(e,r<0?0:0|C(r)),!i.TYPED_ARRAY_SUPPORT)for(var t=0;t<r;++t)e[t]=0;return e}function d(e,r){var t=r.length<0?0:0|C(r.length);e=o(e,t);for(var n=0;n<t;n+=1)e[n]=255&r[n];return e}function C(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function E(e,r){if(i.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var t=e.length;if(0===t)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return Y(e).length;default:if(n)return G(e).length;r=(""+r).toLowerCase(),n=!0}}function f(e,r,t){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(r>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return b(this,r,t);case"utf8":case"utf-8":return y(this,r,t);case"ascii":return R(this,r,t);case"latin1":case"binary":return w(this,r,t);case"base64":return P(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,r,t){var n=e[r];e[r]=e[t],e[t]=n}function p(e,r,t,n,_){if(0===e.length)return-1;if("string"==typeof t?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=_?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(_)return-1;t=e.length-1}else if(t<0){if(!_)return-1;t=0}if("string"==typeof r&&(r=i.from(r,n)),i.isBuffer(r))return 0===r.length?-1:A(e,r,t,n,_);if("number"==typeof r)return r&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?_?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):A(e,[r],t,n,_);throw new TypeError("val must be string, number or Buffer")}function A(e,r,t,n,_){var a,s=1,o=e.length,i=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs
2021-06-04 18:44:56 +03:00
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
r.read=function(e,r,t,n,_){var a,s,o=8*_-n-1,i=(1<<o)-1,c=i>>1,u=-7,l=t?_-1:0,d=t?-1:1,C=e[r+l];for(l+=d,a=C&(1<<-u)-1,C>>=-u,u+=o;u>0;a=256*a+e[r+l],l+=d,u-=8);for(s=a&(1<<-u)-1,a>>=-u,u+=n;u>0;s=256*s+e[r+l],l+=d,u-=8);if(0===a)a=1-c;else{if(a===i)return s?NaN:1/0*(C?-1:1);s+=Math.pow(2,n),a-=c}return(C?-1:1)*s*Math.pow(2,a-n)},r.write=function(e,r,t,n,_,a){var s,o,i,c=8*a-_-1,u=(1<<c)-1,l=u>>1,d=23===_?Math.pow(2,-24)-Math.pow(2,-77):0,C=n?0:a-1,E=n?1:-1,f=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(o=isNaN(r)?1:0,s=u):(s=Math.floor(Math.log(r)/Math.LN2),r*(i=Math.pow(2,-s))<1&&(s--,i*=2),(r+=s+l>=1?d/i:d*Math.pow(2,1-l))*i>=2&&(s++,i/=2),s+l>=u?(o=0,s=u):s+l>=1?(o=(r*i-1)*Math.pow(2,_),s+=l):(o=r*Math.pow(2,l-1)*Math.pow(2,_),s=0));_>=8;e[t+C]=255&o,C+=E,o/=256,_-=8);for(s=s<<_|o,c+=_;c>0;e[t+C]=255&s,C+=E,s/=256,c-=8);e[t+C-E]|=128*f}},function(e,r){var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},function(module,exports,__webpack_require__){"use strict";(function(Buffer){var __awaiter=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(_,a){function s(e){try{i(n.next(e))}catch(e){a(e)}}function o(e){try{i(n.throw(e))}catch(e){a(e)}}function i(e){var r;e.done?_(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,n,_,a,s={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(_=2&a[0]?n.return:a[0]?n.throw||((_=n.return)&&_.call(n),0):n.next)&&!(_=_.call(n,a[1])).done)return _;switch(n=0,_&&(a=[2&a[0],_.value]),a[0]){case 0:case 1:_=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(_=s.trys,(_=_.length>0&&_[_.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!_||a[1]>_[0]&&a[1]<_[3])){s.label=a[1];break}if(6===a[0]&&s.label<_[1]){s.label=_[1],_=a;break}if(_&&s.label<_[2]){s.label=_[2],s.ops.push(a);break}_[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],n=0}finally{t=_=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.addAttachedSignature=void 0;var constants_1=__webpack_require__(3),_afterPluginsLoaded_1=__webpack_require__(0),_extractMeaningfulErrorMessage_1=__webpack_require__(1),_generateCadesFn_1=__webpack_require__(2),_getCadesCert_1=__webpack_require__(5),_getDateObj_1=__webpack_require__(7);exports.addAttachedSignature=_afterPluginsLoaded_1._afterPluginsLoaded((function(thumbprint,signedMessage){return __awaiter(void 0,void 0,void 0,(function(){var cadesplugin,cadesCertificate;return __generator(this,(function(_a){switch(_a.label){case 0:return cadesplugin=window.cadesplugin,[4,_getCadesCert_1._getCadesCert(thumbprint)];case 1:return cadesCertificate=_a.sent(),[2,eval(_generateCadesFn_1._generateCadesFn((function(){var e,r,t;try{e=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CADESCOM.CPAttribute"),r=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CadesSignedData"),t=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CPSigner")}catch(e){throw console.error(e),new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(e)||"Ошибка при инициализации подписи")}var n,_,a,s=_getDateObj_1._getDateObj(new Date);try{_generateCadesFn_1.__cadesAsyncToken__,e.propset_Name(constants_1.CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME),_generateCadesFn_1.__cadesAsyncToken__,e.propset_Value(s)}catch(e){throw console.error(e),new Error(_extractMeaningfulErrorMessage_1._extractMeaning
2021-06-04 18:44:56 +03:00
//# sourceMappingURL=crypto-pro-js.min.js.map