Убрана зависимость от Object.keys и Object.assign

This commit is contained in:
Vitalii Goma 2017-06-08 16:55:04 +03:00
parent 4abcae1e2f
commit 0c407f2e2b
9 changed files with 652 additions and 635 deletions

View File

@ -7,7 +7,7 @@
- [Mozilla Firefox](https://www.mozilla.org/ru/firefox/new/) (v43+). Начиная с версии 52, с [расширением](https://www.cryptopro.ru/sites/default/files/products/cades/extensions/cryptopro_extension_for_cades_browser_plug_in-1.1.1-an+fx-windows.xpi).
- [Internet Explorer](http://windows.microsoft.com/ru-ru/internet-explorer/download-ie) (v8+).
Полифиллы необходимо подключать самостоятельно.
Полифилл для Promise необходимо подключать самостоятельно.
## Установка и настройка
```bash

60
dist/1.crypto-pro.js vendored
View File

@ -1,17 +1,28 @@
webpackJsonpCryptoPro([1],[
/* 0 */,
/* 1 */,
/* 2 */
/* 2 */,
/* 3 */,
/* 4 */
/***/ function(module, exports, __webpack_require__) {
var cryptoCommon = __webpack_require__(3),
var cryptoCommon = __webpack_require__(5),
cryptoConstants = __webpack_require__(7),
_certListCache;
function Certificate(item) {
this._cert = item._cert;
this.thumbprint = item.thumbprint;
this.subjectName = item.subjectName;
this.issuerName = item.issuerName;
this.validFrom = item.validFrom;
this.validTo = item.validTo;
}
_certProto = {
/**
* Проверяет, валиден ли сертификат
* */
isValid: function isValid() {
Certificate.prototype.isValid = function isValid() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -29,12 +40,12 @@ webpackJsonpCryptoPro([1],[
resolve(result);
});
});
},
};
/**
* Достает указанное свойство у сертификата
* */
getProp: function (propName) {
Certificate.prototype.getProp = function (propName) {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -51,12 +62,12 @@ webpackJsonpCryptoPro([1],[
resolve(result);
});
});
},
};
/**
* Экспорт base64 представления сертификата пользователя
* */
exportBase64: function exportBase64() {
Certificate.prototype.exportBase64 = function exportBase64() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -73,12 +84,12 @@ webpackJsonpCryptoPro([1],[
resolve(base64);
});
});
},
};
/**
* Возвращает информацию об алгоритме
* */
getAlgorithm: function getAlgorithm() {
Certificate.prototype.getAlgorithm = function getAlgorithm() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -100,28 +111,28 @@ webpackJsonpCryptoPro([1],[
resolve(result);
});
});
},
};
/**
* Разбирает SubjectName сертификата по тэгам
* */
getOwnerInfo: function getOwnerInfo() {
Certificate.prototype.getOwnerInfo = function getOwnerInfo() {
return getCertInfo.call(this, cryptoCommon.subjectNameTagsTranslations, 'SubjectName');
},
};
/**
* Разбирает IssuerName сертификата по тэгам
* */
getIssuerInfo: function getIssuerInfo() {
Certificate.prototype.getIssuerInfo = function getIssuerInfo() {
return getCertInfo.call(this, cryptoCommon.issuerNameTagsTranslations, 'IssuerName');
},
};
/**
* Получение OID сертификата
*
* @returns {Array} Возвращает массив OID (улучшенного ключа)
* */
getExtendedKeyUsage: function getExtendedKeyUsage() {
Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -155,14 +166,11 @@ webpackJsonpCryptoPro([1],[
resolve(OIDS);
});
});
},
};
getDecodedExtendedKeyUsage: cryptoCommon.getDecodedExtendedKeyUsage,
Certificate.prototype.getDecodedExtendedKeyUsage = cryptoCommon.getDecodedExtendedKeyUsage;
hasExtendedKeyUsage: cryptoCommon.hasExtendedKeyUsage
},
_certListCache;
Certificate.prototype.hasExtendedKeyUsage = cryptoCommon.hasExtendedKeyUsage;
/**
* Проверяет корректность настроек ЭП на машине
@ -331,7 +339,7 @@ webpackJsonpCryptoPro([1],[
while (count) {
item = yield certs.Item(count);
result.push(Object.assign(Object.create(_certProto), {
result.push(new Certificate({
_cert: yield item,
thumbprint: yield item.Thumbprint,
subjectName: yield item.SubjectName,
@ -553,10 +561,10 @@ webpackJsonpCryptoPro([1],[
};
/***/ },
/* 3 */
/* 5 */
/***/ function(module, exports, __webpack_require__) {
var bowser = __webpack_require__(4);
var bowser = __webpack_require__(1);
var oids = __webpack_require__(6);
var subjectNameTagsTranslations = [
@ -836,8 +844,6 @@ webpackJsonpCryptoPro([1],[
};
/***/ },
/* 4 */,
/* 5 */,
/* 6 */
/***/ function(module, exports) {

File diff suppressed because one or more lines are too long

58
dist/2.crypto-pro.js vendored
View File

@ -2,10 +2,12 @@ webpackJsonpCryptoPro([2],[
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */
/* 3 */,
/* 4 */,
/* 5 */
/***/ function(module, exports, __webpack_require__) {
var bowser = __webpack_require__(4);
var bowser = __webpack_require__(1);
var oids = __webpack_require__(6);
var subjectNameTagsTranslations = [
@ -285,8 +287,6 @@ webpackJsonpCryptoPro([2],[
};
/***/ },
/* 4 */,
/* 5 */,
/* 6 */
/***/ function(module, exports) {
@ -483,14 +483,23 @@ webpackJsonpCryptoPro([2],[
/* 8 */
/***/ function(module, exports, __webpack_require__) {
var cryptoCommon = __webpack_require__(3),
var cryptoCommon = __webpack_require__(5),
cryptoConstants = __webpack_require__(7),
_certListCache;
function Certificate(item) {
this._cert = item._cert;
this.thumbprint = item.thumbprint;
this.subjectName = item.subjectName;
this.issuerName = item.issuerName;
this.validFrom = item.validFrom;
this.validTo = item.validTo;
}
_certProto = {
/**
* Проверяет, валиден ли сертификат
* */
isValid: function isValid() {
Certificate.prototype.isValid = function isValid() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -506,12 +515,12 @@ webpackJsonpCryptoPro([2],[
resolve(result);
});
},
};
/**
* Достает указанное свойство у сертификата
* */
getProp: function (propName) {
Certificate.prototype.getProp = function (propName) {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -526,12 +535,12 @@ webpackJsonpCryptoPro([2],[
resolve(result);
});
},
};
/**
* Экспорт base64 представления сертификата пользователя
* */
exportBase64: function exportBase64() {
Certificate.prototype.exportBase64 = function exportBase64() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -546,12 +555,12 @@ webpackJsonpCryptoPro([2],[
resolve(base64);
});
},
};
/**
* Возвращает информацию об алгоритме
* */
getAlgorithm: function getAlgorithm() {
Certificate.prototype.getAlgorithm = function getAlgorithm() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -571,27 +580,27 @@ webpackJsonpCryptoPro([2],[
resolve(result);
});
},
};
/**
* Разбирает SubjectName сертификата по тэгам
* */
getOwnerInfo: function getOwnerInfo() {
Certificate.prototype.getOwnerInfo = function getOwnerInfo() {
return getCertInfo.call(this, cryptoCommon.subjectNameTagsTranslations, 'SubjectName');
},
};
/**
* Разбирает IssuerName сертификата по тэгам
* */
getIssuerInfo: function getIssuerInfo() {
Certificate.prototype.getIssuerInfo = function getIssuerInfo() {
return getCertInfo.call(this, cryptoCommon.issuerNameTagsTranslations, 'IssuerName');
},
};
/**
* Получение OID сертификата
* Возвращает массив OID (улучшенного ключа)
* */
getExtendedKeyUsage: function getExtendedKeyUsage() {
Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -623,14 +632,11 @@ webpackJsonpCryptoPro([2],[
resolve(OIDS);
});
},
};
getDecodedExtendedKeyUsage: cryptoCommon.getDecodedExtendedKeyUsage,
Certificate.prototype.getDecodedExtendedKeyUsage = cryptoCommon.getDecodedExtendedKeyUsage;
hasExtendedKeyUsage: cryptoCommon.hasExtendedKeyUsage
},
_certListCache;
Certificate.prototype.hasExtendedKeyUsage = cryptoCommon.hasExtendedKeyUsage;
/**
* Проверяет корректность настроек ЭП на машине
@ -792,7 +798,7 @@ webpackJsonpCryptoPro([2],[
while (count) {
item = certs.Item(count);
result.push(Object.assign(Object.create(_certProto), {
result.push(new Certificate({
_cert: item,
thumbprint: item.Thumbprint,
subjectName: item.SubjectName,

File diff suppressed because one or more lines are too long

21
dist/crypto-pro.js vendored
View File

@ -96,7 +96,7 @@ var CryptoPro =
/* 0 */
/***/ function(module, exports, __webpack_require__) {
var bowser = __webpack_require__(4),
var bowser = __webpack_require__(1),
browserInfo = bowser._detect(navigator.userAgent),
global = Function('return this')(),
canPromise = Boolean(global.Promise),
@ -110,7 +110,7 @@ var CryptoPro =
global.allow_firefox_cadesplugin_async = browserInfo.firefox && browserInfo.version >= 52;
__webpack_require__(10);
__webpack_require__(3);
cadesplugin = global.cadesplugin;
@ -179,7 +179,7 @@ var CryptoPro =
function () {
if (canAsync) {
__webpack_require__.e/* nsure */(1, function () {
cryptoService = __webpack_require__(2);
cryptoService = __webpack_require__(4);
finishLoading();
});
} else {
@ -207,10 +207,7 @@ var CryptoPro =
};
/***/ },
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/* 1 */
/***/ function(module, exports, __webpack_require__) {
/*!
@ -221,7 +218,7 @@ var CryptoPro =
!function (name, definition) {
if (typeof module != 'undefined' && module.exports) module.exports = definition()
else if (true) __webpack_require__(5)(name, definition)
else if (true) __webpack_require__(2)(name, definition)
else this[name] = definition()
}('bowser', function () {
/**
@ -796,18 +793,14 @@ var CryptoPro =
/***/ },
/* 5 */
/* 2 */
/***/ function(module, exports) {
module.exports = function() { throw new Error("define cannot be used indirect"); };
/***/ },
/* 6 */,
/* 7 */,
/* 8 */,
/* 9 */,
/* 10 */
/* 3 */
/***/ function(module, exports) {
;(function () {

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,20 @@
var cryptoCommon = require('./common'),
cryptoConstants = require('./constants'),
_certListCache;
_certProto = {
/**
function Certificate(item) {
this._cert = item._cert;
this.thumbprint = item.thumbprint;
this.subjectName = item.subjectName;
this.issuerName = item.issuerName;
this.validFrom = item.validFrom;
this.validTo = item.validTo;
}
/**
* Проверяет, валиден ли сертификат
* */
isValid: function isValid() {
Certificate.prototype.isValid = function isValid() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -23,12 +32,12 @@ var cryptoCommon = require('./common'),
resolve(result);
});
});
},
};
/**
/**
* Достает указанное свойство у сертификата
* */
getProp: function (propName) {
Certificate.prototype.getProp = function (propName) {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -45,12 +54,12 @@ var cryptoCommon = require('./common'),
resolve(result);
});
});
},
};
/**
/**
* Экспорт base64 представления сертификата пользователя
* */
exportBase64: function exportBase64() {
Certificate.prototype.exportBase64 = function exportBase64() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -67,12 +76,12 @@ var cryptoCommon = require('./common'),
resolve(base64);
});
});
},
};
/**
/**
* Возвращает информацию об алгоритме
* */
getAlgorithm: function getAlgorithm() {
Certificate.prototype.getAlgorithm = function getAlgorithm() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -94,28 +103,28 @@ var cryptoCommon = require('./common'),
resolve(result);
});
});
},
};
/**
/**
* Разбирает SubjectName сертификата по тэгам
* */
getOwnerInfo: function getOwnerInfo() {
Certificate.prototype.getOwnerInfo = function getOwnerInfo() {
return getCertInfo.call(this, cryptoCommon.subjectNameTagsTranslations, 'SubjectName');
},
};
/**
/**
* Разбирает IssuerName сертификата по тэгам
* */
getIssuerInfo: function getIssuerInfo() {
Certificate.prototype.getIssuerInfo = function getIssuerInfo() {
return getCertInfo.call(this, cryptoCommon.issuerNameTagsTranslations, 'IssuerName');
},
};
/**
/**
* Получение OID сертификата
*
* @returns {Array} Возвращает массив OID (улучшенного ключа)
* */
getExtendedKeyUsage: function getExtendedKeyUsage() {
Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -149,14 +158,11 @@ var cryptoCommon = require('./common'),
resolve(OIDS);
});
});
},
};
getDecodedExtendedKeyUsage: cryptoCommon.getDecodedExtendedKeyUsage,
Certificate.prototype.getDecodedExtendedKeyUsage = cryptoCommon.getDecodedExtendedKeyUsage;
hasExtendedKeyUsage: cryptoCommon.hasExtendedKeyUsage
},
_certListCache;
Certificate.prototype.hasExtendedKeyUsage = cryptoCommon.hasExtendedKeyUsage;
/**
* Проверяет корректность настроек ЭП на машине
@ -325,7 +331,7 @@ function getCertsList(resetCache) {
while (count) {
item = yield certs.Item(count);
result.push(Object.assign(Object.create(_certProto), {
result.push(new Certificate({
_cert: yield item,
thumbprint: yield item.Thumbprint,
subjectName: yield item.SubjectName,

View File

@ -1,11 +1,20 @@
var cryptoCommon = require('./common'),
cryptoConstants = require('./constants'),
_certListCache;
_certProto = {
/**
function Certificate(item) {
this._cert = item._cert;
this.thumbprint = item.thumbprint;
this.subjectName = item.subjectName;
this.issuerName = item.issuerName;
this.validFrom = item.validFrom;
this.validTo = item.validTo;
}
/**
* Проверяет, валиден ли сертификат
* */
isValid: function isValid() {
Certificate.prototype.isValid = function isValid() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -21,12 +30,12 @@ var cryptoCommon = require('./common'),
resolve(result);
});
},
};
/**
/**
* Достает указанное свойство у сертификата
* */
getProp: function (propName) {
Certificate.prototype.getProp = function (propName) {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -41,12 +50,12 @@ var cryptoCommon = require('./common'),
resolve(result);
});
},
};
/**
/**
* Экспорт base64 представления сертификата пользователя
* */
exportBase64: function exportBase64() {
Certificate.prototype.exportBase64 = function exportBase64() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -61,12 +70,12 @@ var cryptoCommon = require('./common'),
resolve(base64);
});
},
};
/**
/**
* Возвращает информацию об алгоритме
* */
getAlgorithm: function getAlgorithm() {
Certificate.prototype.getAlgorithm = function getAlgorithm() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -86,27 +95,27 @@ var cryptoCommon = require('./common'),
resolve(result);
});
},
};
/**
/**
* Разбирает SubjectName сертификата по тэгам
* */
getOwnerInfo: function getOwnerInfo() {
Certificate.prototype.getOwnerInfo = function getOwnerInfo() {
return getCertInfo.call(this, cryptoCommon.subjectNameTagsTranslations, 'SubjectName');
},
};
/**
/**
* Разбирает IssuerName сертификата по тэгам
* */
getIssuerInfo: function getIssuerInfo() {
Certificate.prototype.getIssuerInfo = function getIssuerInfo() {
return getCertInfo.call(this, cryptoCommon.issuerNameTagsTranslations, 'IssuerName');
},
};
/**
/**
* Получение OID сертификата
* Возвращает массив OID (улучшенного ключа)
* */
getExtendedKeyUsage: function getExtendedKeyUsage() {
Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() {
var cert = this._cert;
return new Promise(function (resolve, reject) {
@ -138,14 +147,11 @@ var cryptoCommon = require('./common'),
resolve(OIDS);
});
},
};
getDecodedExtendedKeyUsage: cryptoCommon.getDecodedExtendedKeyUsage,
Certificate.prototype.getDecodedExtendedKeyUsage = cryptoCommon.getDecodedExtendedKeyUsage;
hasExtendedKeyUsage: cryptoCommon.hasExtendedKeyUsage
},
_certListCache;
Certificate.prototype.hasExtendedKeyUsage = cryptoCommon.hasExtendedKeyUsage;
/**
* Проверяет корректность настроек ЭП на машине
@ -307,7 +313,7 @@ function getCertsList(resetCache) {
while (count) {
item = certs.Item(count);
result.push(Object.assign(Object.create(_certProto), {
result.push(new Certificate({
_cert: item,
thumbprint: item.Thumbprint,
subjectName: item.SubjectName,