@akanass/nestjsx-crypto
Version:
NestJS crypto module provides some functions for security features like AES key, Key pair, RSA key, PKCS12, Certificate, PEM and more
85 lines (84 loc) • 3.38 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PemService = void 0;
const rx_crypto_1 = require("@akanass/rx-crypto");
const common_1 = require("@nestjs/common");
const constantes_1 = require("../constantes");
let PemService = class PemService {
constructor(_config) {
this._config = _config;
if (this._config && this._config.pem) {
this._pem = new rx_crypto_1.PEM(this._config.pem);
}
else {
this._pem = new rx_crypto_1.PEM();
}
}
createPrivateKey(keyBitsize, options) {
return this._pem.createPrivateKey(keyBitsize, options);
}
createDhparam(keyBitsize) {
return this._pem.createDhparam(keyBitsize);
}
createEcparam(keyName, paramEnc, noOut) {
return this._pem.createEcparam(keyName, paramEnc, noOut);
}
createCSR(options) {
return this._pem.createCSR(options);
}
createCertificate(options) {
return this._pem.createCertificate(options);
}
readCertificateInfo(certificate) {
return this._pem.readCertificateInfo(certificate);
}
getPublicKey(certificate) {
return this._pem.getPublicKey(certificate);
}
createKeyPair(keyBitsize, options) {
return this._pem.createKeyPair(keyBitsize, options);
}
getFingerprint(certificate, hash) {
return this._pem.getFingerprint(certificate, hash);
}
getModulus(certificate, password) {
return this._pem.getModulus(certificate, password);
}
getDhparamInfo(dh) {
return this._pem.getDhparamInfo(dh);
}
createPkcs12(key, certificate, password, options) {
return this._pem.createPkcs12(key, certificate, password, options);
}
readPkcs12(bufferOrPath, options) {
return this._pem.readPkcs12(bufferOrPath, options);
}
checkPkcs12(bufferOrPath, passphrase) {
return this._pem.checkPkcs12(bufferOrPath, passphrase);
}
verifySigningChain(certificate, ca) {
return this._pem.verifySigningChain(certificate, ca);
}
checkCertificate(certificate, passphrase) {
return this._pem.checkCertificate(certificate, passphrase);
}
};
PemService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Optional)()),
__param(0, (0, common_1.Inject)(constantes_1.CRYPTO_CONFIG)),
__metadata("design:paramtypes", [Object])
], PemService);
exports.PemService = PemService;