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

11 lines
110 KiB
JavaScript
Raw Permalink Normal View History

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