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

11 lines
110 KiB
JavaScript
Raw Permalink Normal View History

2021-09-15 14:00:09 +03:00
!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 a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.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 a in e)t.d(n,a,function(r){return e[r]}.bind(null,a));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=12)}([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){_(e)}}function o(e){try{i(n.throw(e))}catch(e){_(e)}}function i(e){var r;e.done?a(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())}))},a=this&&this.__generator||function(e,r){var t,n,a,_,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return _={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(_[Symbol.iterator]=function(){return this}),_;function o(_){return function(o){return function(_){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=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 s.label++,{value:_[1],done:!1};case 5:s.label++,n=_[1],_=[0];continue;case 7:_=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==_[0]&&2!==_[0])){s=0;continue}if(3===_[0]&&(!a||_[1]>a[0]&&_[1]<a[3])){s.label=_[1];break}if(6===_[0]&&s.label<a[1]){s.label=a[1],a=_;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(_);break}a[2]&&s.ops.pop(),s.trys.pop();continue}_=r.call(e,s)}catch(e){_=[6,e],n=0}finally{t=a=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([_,o])}}};Object.defineProperty(r,"__esModule",{value:!0});var _=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 a(this,(function(a){switch(a.label){case 0:if(!o){try{t(15)}catch(e){throw console.error(e),new Error(_._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),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,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!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.message.match(/^(.*?)(?:(?:\.?\s?\(?(0x[0-9a-zA-Z]{1,8})\)?)|(?:\.?$))/)
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
*/
2021-09-15 14:00:09 +03:00
var n=t(38),a=t(39),_=t(40);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|g(r,t),a=(e=o(e,n)).write(r,t);a!==n&&(e=e.slice(0,a));return e}(e,r,t):function(e,r){if(i.isBuffer(r)){var t=0|f(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&&_(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|f(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|f(r.length);e=o(e,t);for(var n=0;n<t;n+=1)e[n]=255&r[n];return e}function f(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function g(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 B(e).length;default:if(n)return G(e).length;r=(""+r).toLowerCase(),n=!0}}function p(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 v(this,r,t);case"utf8":case"utf-8":return w(this,r,t);case"ascii":return S(this,r,t);case"latin1":case"binary":return P(this,r,t);case"base64":return b(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function C(e,r,t){var n=e[r];e[r]=e[t],e[t]=n}function E(e,r,t,n,a){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=a?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(a)return-1;t=e.length-1}else if(t<0){if(!a)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,a);if("number"==typeof r)return r&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):A(e,[r],t,n,a);throw new TypeError("val must be string, number or Buffer")}function A(e,r,t,n,a){var _,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> */
2021-09-15 14:00:09 +03:00
r.read=function(e,r,t,n,a){var _,s,o=8*a-n-1,i=(1<<o)-1,c=i>>1,u=-7,l=t?a-1:0,d=t?-1:1,f=e[r+l];for(l+=d,_=f&(1<<-u)-1,f>>=-u,u+=o;u>0;_=256*_+e[r+l],l+=d,u-=8);for(s=_&(1<<-u)-1,_>>=-u,u+=n;u>0;s=256*s+e[r+l],l+=d,u-=8);if(0===_)_=1-c;else{if(_===i)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),_-=c}return(f?-1:1)*s*Math.pow(2,_-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===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:_-1,g=n?1:-1,p=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,a),s+=l):(o=r*Math.pow(2,l-1)*Math.pow(2,a),s=0));a>=8;e[t+f]=255&o,f+=g,o/=256,a-=8);for(s=s<<a|o,c+=a;c>0;e[t+f]=255&s,f+=g,s/=256,c-=8);e[t+f-g]|=128*p}},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){_(e)}}function o(e){try{i(n.throw(e))}catch(e){_(e)}}function i(e){var r;e.done?a(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&a[0])throw a[1];return a[1]},trys:[],ops:[]};return _={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(_[Symbol.iterator]=function(){return this}),_;function o(_){return function(o){return function(_){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=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 s.label++,{value:_[1],done:!1};case 5:s.label++,n=_[1],_=[0];continue;case 7:_=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==_[0]&&2!==_[0])){s=0;continue}if(3===_[0]&&(!a||_[1]>a[0]&&_[1]<a[3])){s.label=_[1];break}if(6===_[0]&&s.label<a[1]){s.label=a[1],a=_;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(_);break}a[2]&&s.ops.pop(),s.trys.pop();continue}_=r.call(e,s)}catch(e){_=[6,e],n=0}finally{t=a=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([_,o])}}};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,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._extractMeaningfulErrorMessage(e)||"Ошибка п
2021-06-04 18:44:56 +03:00
//# sourceMappingURL=crypto-pro-js.min.js.map