generated from cubetiq/ts-project
Add build and allow dist
This commit is contained in:
16
dist/crypto/provider/default.provider.d.ts
vendored
Normal file
16
dist/crypto/provider/default.provider.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference types="node" />
|
||||
import { ICryptoProvider } from "../provider.crypto"
|
||||
interface DefaultCryptoProviderOptions {
|
||||
key?: string | Buffer | null | undefined
|
||||
iv?: string | Buffer | null | undefined
|
||||
keyiVPath?: string | null | undefined
|
||||
jsonPath?: string | null | undefined
|
||||
}
|
||||
export declare class DefaultCryptoProvider implements ICryptoProvider {
|
||||
private _key
|
||||
private _iv
|
||||
constructor(options: DefaultCryptoProviderOptions)
|
||||
encrypt(data: string | Buffer): string
|
||||
decrypt(data: string): string
|
||||
}
|
||||
export {}
|
||||
35
dist/crypto/provider/default.provider.js
vendored
Normal file
35
dist/crypto/provider/default.provider.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict"
|
||||
Object.defineProperty(exports, "__esModule", { value: true })
|
||||
exports.DefaultCryptoProvider = void 0
|
||||
var util_1 = require("../../util")
|
||||
var default_crypto_1 = require("./../core/default.crypto")
|
||||
var DefaultCryptoProvider = /** @class */ (function () {
|
||||
function DefaultCryptoProvider(options) {
|
||||
var key = options.key,
|
||||
iv = options.iv,
|
||||
keyiVPath = options.keyiVPath,
|
||||
jsonPath = options.jsonPath
|
||||
if (keyiVPath) {
|
||||
var json = (0, util_1.readFileToJson)(keyiVPath)
|
||||
this._key = json.key
|
||||
this._iv = json.iv
|
||||
} else if (jsonPath) {
|
||||
var json = (0, util_1.readFileToJson)(jsonPath)
|
||||
this._key = (0, util_1.readFileToString)(json.keyPath)
|
||||
this._iv = (0, util_1.readFileToString)(json.ivPath)
|
||||
} else {
|
||||
this._key = key
|
||||
this._iv = iv || key
|
||||
}
|
||||
;(0, util_1.assertNotNullOrUndefined)(this._key, "key is required")
|
||||
}
|
||||
DefaultCryptoProvider.prototype.encrypt = function (data) {
|
||||
return (0, default_crypto_1.encrypt)(data, this._key, this._iv)
|
||||
}
|
||||
DefaultCryptoProvider.prototype.decrypt = function (data) {
|
||||
return (0, default_crypto_1.decrypt)(data, this._key, this._iv)
|
||||
}
|
||||
return DefaultCryptoProvider
|
||||
})()
|
||||
exports.DefaultCryptoProvider = DefaultCryptoProvider
|
||||
//# sourceMappingURL=default.provider.js.map
|
||||
1
dist/crypto/provider/default.provider.js.map
vendored
Normal file
1
dist/crypto/provider/default.provider.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default.provider.js","sourceRoot":"","sources":["../../../src/crypto/provider/default.provider.ts"],"names":[],"mappings":";;;AAAA,mCAImB;AAEnB,2DAAyE;AASzE;IAII,+BAAY,OAAqC;QACrC,IAAA,GAAG,GAA8B,OAAO,IAArC,EAAE,EAAE,GAA0B,OAAO,GAAjC,EAAE,SAAS,GAAe,OAAO,UAAtB,EAAE,QAAQ,GAAK,OAAO,SAAZ,CAAY;QAEhD,IAAI,SAAS,EAAE;YACX,IAAM,IAAI,GAAQ,IAAA,qBAAc,EAAC,SAAS,CAAC,CAAA;YAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAA;YACpB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAA;SACrB;aAAM,IAAI,QAAQ,EAAE;YACjB,IAAM,IAAI,GAAQ,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAA;YAC1C,IAAI,CAAC,IAAI,GAAG,IAAA,uBAAgB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC1C,IAAI,CAAC,GAAG,GAAG,IAAA,uBAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAC3C;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;YACf,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,GAAG,CAAA;SACvB;QAED,IAAA,+BAAwB,EAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;IAC1D,CAAC;IAED,uCAAO,GAAP,UAAQ,IAAqB;QACzB,OAAO,IAAA,wBAAG,EAAC,IAAI,EAAE,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;IAED,uCAAO,GAAP,UAAQ,IAAY;QAChB,OAAO,IAAA,wBAAG,EAAC,IAAI,EAAE,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;IACL,4BAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,sDAAqB"}
|
||||
17
dist/crypto/provider/e2e.provider.d.ts
vendored
Normal file
17
dist/crypto/provider/e2e.provider.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference types="node" />
|
||||
import { ICryptoProvider } from "../provider.crypto"
|
||||
interface E2ECryptoProviderOptions {
|
||||
privateKey?: string | Buffer | null | undefined
|
||||
publicKey?: string | Buffer | null | undefined
|
||||
privateKeyPath?: string | null | undefined
|
||||
publicKeyPath?: string | null | undefined
|
||||
jsonPath?: string | null | undefined
|
||||
}
|
||||
export declare class E2ECryptoProvider implements ICryptoProvider {
|
||||
private privateKey
|
||||
private publicKey
|
||||
constructor(options: E2ECryptoProviderOptions)
|
||||
encrypt(data: string | Buffer): string
|
||||
decrypt(data: string): string
|
||||
}
|
||||
export {}
|
||||
79
dist/crypto/provider/e2e.provider.js
vendored
Normal file
79
dist/crypto/provider/e2e.provider.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict"
|
||||
Object.defineProperty(exports, "__esModule", { value: true })
|
||||
exports.E2ECryptoProvider = void 0
|
||||
var __1 = require("..")
|
||||
var util_1 = require("../../util")
|
||||
var E2ECryptoProvider = /** @class */ (function () {
|
||||
function E2ECryptoProvider(options) {
|
||||
var privateKey = options.privateKey,
|
||||
publicKey = options.publicKey,
|
||||
privateKeyPath = options.privateKeyPath,
|
||||
publicKeyPath = options.publicKeyPath,
|
||||
jsonPath = options.jsonPath
|
||||
var isPrivateKeyInitialized = false
|
||||
var isPublicKeyInitialized = false
|
||||
if (privateKeyPath) {
|
||||
this.privateKey = (0, util_1.readFileToString)(privateKeyPath)
|
||||
isPrivateKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.privateKey
|
||||
)
|
||||
}
|
||||
if (publicKeyPath) {
|
||||
this.publicKey = (0, util_1.readFileToString)(publicKeyPath)
|
||||
isPublicKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.publicKey
|
||||
)
|
||||
}
|
||||
if (!isPrivateKeyInitialized && !isPublicKeyInitialized && jsonPath) {
|
||||
var json = (0, util_1.readFileToJson)(jsonPath)
|
||||
if (json.privateKey) {
|
||||
this.privateKey = json.privateKey
|
||||
isPrivateKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.privateKey
|
||||
)
|
||||
}
|
||||
if (json.publicKey) {
|
||||
this.publicKey = json.publicKey
|
||||
isPublicKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.publicKey
|
||||
)
|
||||
}
|
||||
if (!isPrivateKeyInitialized && json.privateKeyPath) {
|
||||
this.privateKey = (0, util_1.readFileToString)(
|
||||
json.privateKeyPath
|
||||
)
|
||||
isPrivateKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.privateKey
|
||||
)
|
||||
}
|
||||
if (!isPublicKeyInitialized && json.publicKeyPath) {
|
||||
this.publicKey = (0, util_1.readFileToString)(
|
||||
json.publicKeyPath
|
||||
)
|
||||
isPublicKeyInitialized = !(0, util_1.isNullOrUndefinedOrEmpty)(
|
||||
this.publicKey
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!isPrivateKeyInitialized) {
|
||||
this.privateKey = privateKey
|
||||
}
|
||||
if (!isPublicKeyInitialized) {
|
||||
this.publicKey = publicKey
|
||||
}
|
||||
;(0, util_1.assertNotNullOrUndefined)(
|
||||
this.privateKey,
|
||||
"Private key is required"
|
||||
)
|
||||
}
|
||||
E2ECryptoProvider.prototype.encrypt = function (data) {
|
||||
var key = this.publicKey || this.privateKey
|
||||
return (0, __1.e2eEncrypt)(data, key.toString())
|
||||
}
|
||||
E2ECryptoProvider.prototype.decrypt = function (data) {
|
||||
return (0, __1.e2eDecrypt)(data, this.privateKey.toString())
|
||||
}
|
||||
return E2ECryptoProvider
|
||||
})()
|
||||
exports.E2ECryptoProvider = E2ECryptoProvider
|
||||
//# sourceMappingURL=e2e.provider.js.map
|
||||
1
dist/crypto/provider/e2e.provider.js.map
vendored
Normal file
1
dist/crypto/provider/e2e.provider.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"e2e.provider.js","sourceRoot":"","sources":["../../../src/crypto/provider/e2e.provider.ts"],"names":[],"mappings":";;;AAAA,wBAA2C;AAC3C,mCAKmB;AAWnB;IAII,2BAAY,OAAiC;QAErC,IAAA,UAAU,GAKV,OAAO,WALG,EACV,SAAS,GAIT,OAAO,UAJE,EACT,cAAc,GAGd,OAAO,eAHO,EACd,aAAa,GAEb,OAAO,cAFM,EACb,QAAQ,GACR,OAAO,SADC,CACD;QAEX,IAAI,uBAAuB,GAAG,KAAK,CAAA;QACnC,IAAI,sBAAsB,GAAG,KAAK,CAAA;QAClC,IAAI,cAAc,EAAE;YAChB,IAAI,CAAC,UAAU,GAAG,IAAA,uBAAgB,EAAC,cAAc,CAAC,CAAA;YAClD,uBAAuB,GAAG,CAAC,IAAA,+BAAwB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SACvE;QAED,IAAI,aAAa,EAAE;YACf,IAAI,CAAC,SAAS,GAAG,IAAA,uBAAgB,EAAC,aAAa,CAAC,CAAA;YAChD,sBAAsB,GAAG,CAAC,IAAA,+BAAwB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SACrE;QAED,IAAI,CAAC,uBAAuB,IAAI,CAAC,sBAAsB,IAAI,QAAQ,EAAE;YACjE,IAAM,IAAI,GAAG,IA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