Add build and allow dist

This commit is contained in:
Sambo Chea 2022-02-14 16:15:32 +07:00
parent 3d8f9c5d78
commit 3c12c69606
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
39 changed files with 11173 additions and 3 deletions

4
.gitignore vendored
View File

@ -85,7 +85,7 @@ out
# Nuxt.js build / generate output
.nuxt
dist
# dist
# Gatsby files
.cache/
@ -117,4 +117,4 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
package-lock.json
# package-lock.json

3
dist/config/index.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export declare const DEFAULT_AES_ALGORITHM = "aes-256-cbc"
export declare const DEFAULT_BUFFER_TYPE = "base64"
export declare const DEFAULT_ENCODING_TYPE = "utf-8"

10
dist/config/index.js vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.DEFAULT_ENCODING_TYPE =
exports.DEFAULT_BUFFER_TYPE =
exports.DEFAULT_AES_ALGORITHM =
void 0
exports.DEFAULT_AES_ALGORITHM = "aes-256-cbc"
exports.DEFAULT_BUFFER_TYPE = "base64"
exports.DEFAULT_ENCODING_TYPE = "utf-8"
//# sourceMappingURL=index.js.map

1
dist/config/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,aAAa,CAAA;AACrC,QAAA,mBAAmB,GAAG,QAAQ,CAAA;AAC9B,QAAA,qBAAqB,GAAG,OAAO,CAAA"}

12
dist/crypto/core/default.crypto.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/// <reference types="node" />
declare const encrypt: (
data: string | Buffer,
key: string | Buffer,
iv?: string | Buffer | null | undefined
) => string
declare const decrypt: (
data: string | Buffer,
key: string | Buffer,
iv?: string | Buffer | null | undefined
) => string
export { encrypt, decrypt }

82
dist/crypto/core/default.crypto.js vendored Normal file
View File

@ -0,0 +1,82 @@
"use strict"
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k]
},
})
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k
o[k2] = m[k]
})
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v,
})
}
: function (o, v) {
o["default"] = v
})
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod
var result = {}
if (mod != null)
for (var k in mod)
if (
k !== "default" &&
Object.prototype.hasOwnProperty.call(mod, k)
)
__createBinding(result, mod, k)
__setModuleDefault(result, mod)
return result
}
Object.defineProperty(exports, "__esModule", { value: true })
exports.decrypt = exports.encrypt = void 0
var crypto = __importStar(require("crypto"))
var config_1 = require("../../config")
var util_1 = require("../../util")
var encrypt = function (data, key, iv) {
var cipher = crypto.createCipheriv(
config_1.DEFAULT_AES_ALGORITHM,
(0, util_1.stringToBuffer)(key),
(0, util_1.stringToBuffer)(iv || key)
)
var _data = (0, util_1.bufferToString)(data)
var encrypted = cipher.update(
_data,
config_1.DEFAULT_ENCODING_TYPE,
config_1.DEFAULT_BUFFER_TYPE
)
encrypted += cipher.final(config_1.DEFAULT_BUFFER_TYPE)
return encrypted
}
exports.encrypt = encrypt
var decrypt = function (data, key, iv) {
var decipher = crypto.createDecipheriv(
config_1.DEFAULT_AES_ALGORITHM,
(0, util_1.stringToBuffer)(key),
(0, util_1.stringToBuffer)(iv || key)
)
var _data = (0, util_1.bufferToString)(data)
var decrypted = decipher.update(
_data,
config_1.DEFAULT_BUFFER_TYPE,
config_1.DEFAULT_ENCODING_TYPE
)
decrypted += decipher.final(config_1.DEFAULT_ENCODING_TYPE)
return decrypted
}
exports.decrypt = decrypt
//# sourceMappingURL=default.crypto.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"default.crypto.js","sourceRoot":"","sources":["../../../src/crypto/core/default.crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgC;AAChC,uCAIqB;AACrB,mCAA2D;AAE3D,IAAM,OAAO,GAAG,UACZ,IAAqB,EACrB,GAAoB,EACpB,EAA2B;IAE3B,IAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAChC,8BAAqB,EACrB,IAAA,qBAAc,EAAC,GAAG,CAAC,EACnB,IAAA,qBAAc,EAAC,EAAE,IAAI,GAAG,CAAC,CAC5B,CAAA;IACD,IAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAA;IAClC,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CACzB,KAAK,EACL,8BAAqB,EACrB,4BAAmB,CACtB,CAAA;IACD,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,4BAAmB,CAAC,CAAA;IAC9C,OAAO,SAAS,CAAA;AACpB,CAAC,CAAA;AAsBQ,0BAAO;AApBhB,IAAM,OAAO,GAAG,UACZ,IAAqB,EACrB,GAAoB,EACpB,EAA2B;IAE3B,IAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CACpC,8BAAqB,EACrB,IAAA,qBAAc,EAAC,GAAG,CAAC,EACnB,IAAA,qBAAc,EAAC,EAAE,IAAI,GAAG,CAAC,CAC5B,CAAA;IACD,IAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAA;IAClC,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAC3B,KAAK,EACL,4BAAmB,EACnB,8BAAqB,CACxB,CAAA;IACD,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,8BAAqB,CAAC,CAAA;IAClD,OAAO,SAAS,CAAA;AACpB,CAAC,CAAA;AAEiB,0BAAO"}

11
dist/crypto/core/e2e.crypto.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
/// <reference types="node" />
declare const encrypt: (
data: string | Buffer,
privateOrPublicKey: string
) => string
declare const decrypt: (
data: string | Buffer,
privateKey: string,
passphrase?: string | null | undefined
) => string
export { encrypt, decrypt }

68
dist/crypto/core/e2e.crypto.js vendored Normal file
View File

@ -0,0 +1,68 @@
"use strict"
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k]
},
})
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k
o[k2] = m[k]
})
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v,
})
}
: function (o, v) {
o["default"] = v
})
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod
var result = {}
if (mod != null)
for (var k in mod)
if (
k !== "default" &&
Object.prototype.hasOwnProperty.call(mod, k)
)
__createBinding(result, mod, k)
__setModuleDefault(result, mod)
return result
}
Object.defineProperty(exports, "__esModule", { value: true })
exports.decrypt = exports.encrypt = void 0
var crypto = __importStar(require("crypto"))
var config_1 = require("../../config")
var util_1 = require("../../util")
var encrypt = function (data, privateOrPublicKey) {
var buffer = (0, util_1.stringToBuffer)(data)
var encrypted = crypto.publicEncrypt(privateOrPublicKey, buffer)
return encrypted.toString(config_1.DEFAULT_BUFFER_TYPE)
}
exports.encrypt = encrypt
var decrypt = function (data, privateKey, passphrase) {
var buffer = (0, util_1.stringToBuffer)(data)
var decrypted = crypto.privateDecrypt(
{
key: privateKey,
passphrase: passphrase || "",
},
buffer
)
return decrypted.toString(config_1.DEFAULT_ENCODING_TYPE)
}
exports.decrypt = decrypt
//# sourceMappingURL=e2e.crypto.js.map

1
dist/crypto/core/e2e.crypto.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"e2e.crypto.js","sourceRoot":"","sources":["../../../src/crypto/core/e2e.crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgC;AAEhC,uCAAyE;AACzE,mCAA2C;AAE3C,IAAM,OAAO,GAAG,UAAC,IAAqB,EAAE,kBAA0B;IAC9D,IAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAA;IACnC,IAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;IAClE,OAAO,SAAS,CAAC,QAAQ,CAAC,4BAAmB,CAAC,CAAA;AAClD,CAAC,CAAA;AAkBQ,0BAAO;AAhBhB,IAAM,OAAO,GAAG,UACZ,IAAqB,EACrB,UAAkB,EAClB,UAA0B;IAE1B,IAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAA;IACnC,IAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CACnC;QACI,GAAG,EAAE,UAAU;QACf,UAAU,EAAE,UAAU,IAAI,EAAE;KAC/B,EACD,MAAM,CACT,CAAA;IACD,OAAO,SAAS,CAAC,QAAQ,CAAC,8BAAqB,CAAC,CAAA;AACpD,CAAC,CAAA;AAEiB,0BAAO"}

10
dist/crypto/crypto.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/// <reference types="node" />
import { ICryptoProvider } from "./provider.crypto"
export declare class CryptoProvider {
private readonly provider
constructor(provider: ICryptoProvider)
encrypt(data: string | Buffer): string
decrypt(data: string): string
private static _instance
static newInstance(provider: ICryptoProvider): CryptoProvider
}

23
dist/crypto/crypto.js vendored Normal file
View File

@ -0,0 +1,23 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.CryptoProvider = void 0
var CryptoProvider = /** @class */ (function () {
function CryptoProvider(provider) {
this.provider = provider
}
CryptoProvider.prototype.encrypt = function (data) {
return this.provider.encrypt(data)
}
CryptoProvider.prototype.decrypt = function (data) {
return this.provider.decrypt(data)
}
CryptoProvider.newInstance = function (provider) {
if (!CryptoProvider._instance) {
CryptoProvider._instance = new CryptoProvider(provider)
}
return CryptoProvider._instance
}
return CryptoProvider
})()
exports.CryptoProvider = CryptoProvider
//# sourceMappingURL=crypto.js.map

1
dist/crypto/crypto.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto/crypto.ts"],"names":[],"mappings":";;;AAEA;IACI,wBAA6B,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;IAAG,CAAC;IAEnD,gCAAO,GAAd,UAAe,IAAqB;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAEM,gCAAO,GAAd,UAAe,IAAY;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAGa,0BAAW,GAAzB,UAA0B,QAAyB;QAC/C,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YAC3B,cAAc,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;SAC1D;QACD,OAAO,cAAc,CAAC,SAAS,CAAA;IACnC,CAAC;IACL,qBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,wCAAc"}

16
dist/crypto/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import { decrypt, encrypt } from "./core/default.crypto"
import { encrypt as e2eEncrypt, decrypt as e2eDecrypt } from "./core/e2e.crypto"
import { CryptoProvider } from "./crypto"
import { ICryptoProvider } from "./provider.crypto"
import { DefaultCryptoProvider } from "./provider/default.provider"
import { E2ECryptoProvider } from "./provider/e2e.provider"
export {
encrypt,
decrypt,
e2eEncrypt,
e2eDecrypt,
ICryptoProvider,
DefaultCryptoProvider,
E2ECryptoProvider,
CryptoProvider,
}

58
dist/crypto/index.js vendored Normal file
View File

@ -0,0 +1,58 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.CryptoProvider =
exports.E2ECryptoProvider =
exports.DefaultCryptoProvider =
exports.e2eDecrypt =
exports.e2eEncrypt =
exports.decrypt =
exports.encrypt =
void 0
var default_crypto_1 = require("./core/default.crypto")
Object.defineProperty(exports, "decrypt", {
enumerable: true,
get: function () {
return default_crypto_1.decrypt
},
})
Object.defineProperty(exports, "encrypt", {
enumerable: true,
get: function () {
return default_crypto_1.encrypt
},
})
var e2e_crypto_1 = require("./core/e2e.crypto")
Object.defineProperty(exports, "e2eEncrypt", {
enumerable: true,
get: function () {
return e2e_crypto_1.encrypt
},
})
Object.defineProperty(exports, "e2eDecrypt", {
enumerable: true,
get: function () {
return e2e_crypto_1.decrypt
},
})
var crypto_1 = require("./crypto")
Object.defineProperty(exports, "CryptoProvider", {
enumerable: true,
get: function () {
return crypto_1.CryptoProvider
},
})
var default_provider_1 = require("./provider/default.provider")
Object.defineProperty(exports, "DefaultCryptoProvider", {
enumerable: true,
get: function () {
return default_provider_1.DefaultCryptoProvider
},
})
var e2e_provider_1 = require("./provider/e2e.provider")
Object.defineProperty(exports, "E2ECryptoProvider", {
enumerable: true,
get: function () {
return e2e_provider_1.E2ECryptoProvider
},
})
//# sourceMappingURL=index.js.map

1
dist/crypto/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AASpD,wFATK,wBAAO,OASL;AADP,wFARc,wBAAO,OAQd;AAPX,gDAAgF;AAS5E,2FATgB,oBAAU,OAShB;AACV,2FAVuC,oBAAU,OAUvC;AATd,mCAAyC;AAerC,+FAfK,uBAAc,OAeL;AAblB,gEAAmE;AAU/D,sGAVK,wCAAqB,OAUL;AATzB,wDAA2D;AAUvD,kGAVK,gCAAiB,OAUL"}

5
dist/crypto/provider.crypto.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="node" />
export interface ICryptoProvider {
encrypt(data: string | Buffer): string
decrypt(data: string): string
}

3
dist/crypto/provider.crypto.js vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
//# sourceMappingURL=provider.crypto.js.map

1
dist/crypto/provider.crypto.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"provider.crypto.js","sourceRoot":"","sources":["../../src/crypto/provider.crypto.ts"],"names":[],"mappings":""}

View 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 {}

View 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

View File

@ -0,0 +1 @@
{"version":3,"file":"default.provider.js","sourceRoot":"","sources":["../../../src/crypto/provider/default.provider.ts"],"names":[],"mappings":";;;AAAA,mCAImB;AAEnB,2DAAyE;AASz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ptoProvider } 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
View 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

View 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,sBA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AU,CAAA;QAC7C,OAAO,IAAA,cAAU,EAAC,IAAI,EAAE,GAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC5C,CAAC;IAED,mCAAO,GAAP,UAAQ,IAAY;QAChB,OAAO,IAAA,cAAU,EAAC,IAAI,EAAE,IAAI,CAAC,UAAW,CAAC,QAAQ,EAAE,CAAC,CAAA;IACxD,CAAC;IACL,wBAAC;AAAD,CAAC,AA3ED,IA2EC;AA3EY,8CAAiB"}

6
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
import {
CryptoProvider,
DefaultCryptoProvider,
E2ECryptoProvider,
} from "./crypto"
export { CryptoProvider, DefaultCryptoProvider, E2ECryptoProvider }

26
dist/index.js vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.E2ECryptoProvider =
exports.DefaultCryptoProvider =
exports.CryptoProvider =
void 0
var crypto_1 = require("./crypto")
Object.defineProperty(exports, "CryptoProvider", {
enumerable: true,
get: function () {
return crypto_1.CryptoProvider
},
})
Object.defineProperty(exports, "DefaultCryptoProvider", {
enumerable: true,
get: function () {
return crypto_1.DefaultCryptoProvider
},
})
Object.defineProperty(exports, "E2ECryptoProvider", {
enumerable: true,
get: function () {
return crypto_1.E2ECryptoProvider
},
})
//# sourceMappingURL=index.js.map

1
dist/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAIiB;AAER,+FALL,uBAAc,OAKK;AAAE,sGAJrB,8BAAqB,OAIqB;AAAE,kGAH5C,0BAAiB,OAG4C"}

4
dist/util/file.util.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
export declare const readFileToStringDefaultEncoding: (
relativeFilePath: string
) => string
export declare const readFileToJson: (relativeFilePath: string) => any

61
dist/util/file.util.js vendored Normal file
View File

@ -0,0 +1,61 @@
"use strict"
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k]
},
})
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k
o[k2] = m[k]
})
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v,
})
}
: function (o, v) {
o["default"] = v
})
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod
var result = {}
if (mod != null)
for (var k in mod)
if (
k !== "default" &&
Object.prototype.hasOwnProperty.call(mod, k)
)
__createBinding(result, mod, k)
__setModuleDefault(result, mod)
return result
}
Object.defineProperty(exports, "__esModule", { value: true })
exports.readFileToJson = exports.readFileToStringDefaultEncoding = void 0
var fs = __importStar(require("fs"))
var path = __importStar(require("path"))
var config_1 = require("../config")
var readFileToStringDefaultEncoding = function (relativeFilePath) {
var absolutePath = path.resolve(relativeFilePath)
return fs.readFileSync(absolutePath, config_1.DEFAULT_ENCODING_TYPE)
}
exports.readFileToStringDefaultEncoding = readFileToStringDefaultEncoding
var readFileToJson = function (relativeFilePath) {
return JSON.parse(
(0, exports.readFileToStringDefaultEncoding)(relativeFilePath)
)
}
exports.readFileToJson = readFileToJson
//# sourceMappingURL=file.util.js.map

1
dist/util/file.util.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"file.util.js","sourceRoot":"","sources":["../../src/util/file.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAwB;AACxB,yCAA4B;AAC5B,oCAAiD;AAE1C,IAAM,+BAA+B,GAAG,UAC3C,gBAAwB;IAExB,IAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACnD,OAAO,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,8BAAqB,CAAC,CAAA;AAC/D,CAAC,CAAA;AALY,QAAA,+BAA+B,mCAK3C;AAEM,IAAM,cAAc,GAAG,UAAC,gBAAwB;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,uCAA+B,EAAC,gBAAgB,CAAC,CAAC,CAAA;AACxE,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B"}

20
dist/util/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
/// <reference types="node" />
import { readFileToStringDefaultEncoding, readFileToJson } from "./file.util"
import {
assertNotNullOrUndefined,
assertNotNullOrUndefinedOrEmpty,
isNullOrUndefined,
isNullOrUndefinedOrEmpty,
} from "./test.util"
declare const stringToBuffer: (data: string | Buffer) => Buffer
declare const bufferToString: (data: string | Buffer) => string
export {
readFileToStringDefaultEncoding as readFileToString,
readFileToJson,
stringToBuffer,
bufferToString,
assertNotNullOrUndefined,
assertNotNullOrUndefinedOrEmpty,
isNullOrUndefined,
isNullOrUndefinedOrEmpty,
}

67
dist/util/index.js vendored Normal file
View File

@ -0,0 +1,67 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.isNullOrUndefinedOrEmpty =
exports.isNullOrUndefined =
exports.assertNotNullOrUndefinedOrEmpty =
exports.assertNotNullOrUndefined =
exports.bufferToString =
exports.stringToBuffer =
exports.readFileToJson =
exports.readFileToString =
void 0
var config_1 = require("../config")
var file_util_1 = require("./file.util")
Object.defineProperty(exports, "readFileToString", {
enumerable: true,
get: function () {
return file_util_1.readFileToStringDefaultEncoding
},
})
Object.defineProperty(exports, "readFileToJson", {
enumerable: true,
get: function () {
return file_util_1.readFileToJson
},
})
var test_util_1 = require("./test.util")
Object.defineProperty(exports, "assertNotNullOrUndefined", {
enumerable: true,
get: function () {
return test_util_1.assertNotNullOrUndefined
},
})
Object.defineProperty(exports, "assertNotNullOrUndefinedOrEmpty", {
enumerable: true,
get: function () {
return test_util_1.assertNotNullOrUndefinedOrEmpty
},
})
Object.defineProperty(exports, "isNullOrUndefined", {
enumerable: true,
get: function () {
return test_util_1.isNullOrUndefined
},
})
Object.defineProperty(exports, "isNullOrUndefinedOrEmpty", {
enumerable: true,
get: function () {
return test_util_1.isNullOrUndefinedOrEmpty
},
})
var stringToBuffer = function (data) {
if (data instanceof Buffer) {
return data
} else {
return Buffer.from(data, config_1.DEFAULT_BUFFER_TYPE)
}
}
exports.stringToBuffer = stringToBuffer
var bufferToString = function (data) {
if (data instanceof Buffer) {
return data.toString(config_1.DEFAULT_ENCODING_TYPE)
} else {
return data
}
}
exports.bufferToString = bufferToString
//# sourceMappingURL=index.js.map

1
dist/util/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA,oCAAsE;AACtE,yCAA6E;AAyBtC,iGAzB9B,2CAA+B,OAyBe;AACnD,+FA1BsC,0BAAc,OA0BtC;AAzBlB,yCAKoB;AAuBhB,yGA3BA,oCAAwB,OA2BA;AACxB,gHA3BA,2CAA+B,OA2BA;AAC/B,kGA3BA,6BAAiB,OA2BA;AACjB,yGA3BA,oCAAwB,OA2BA;AAxB5B,IAAM,cAAc,GAAG,UAAC,IAAqB;IACzC,IAAI,IAAI,YAAY,MAAM,EAAE;QACxB,OAAO,IAAI,CAAA;KACd;SAAM;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,4BAAmB,CAAC,CAAA;KAChD;AACL,CAAC,CAAA;AAaG,wCAAc;AAXlB,IAAM,cAAc,GAAG,UAAC,IAAqB;IACzC,IAAI,IAAI,YAAY,MAAM,EAAE;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,8BAAqB,CAAC,CAAA;KAC9C;SAAM;QACH,OAAO,IAAI,CAAA;KACd;AACL,CAAC,CAAA;AAMG,wCAAc"}

10
dist/util/test.util.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
export declare const assertNotNullOrUndefined: (
value: unknown,
msg?: string | undefined
) => void
export declare const assertNotNullOrUndefinedOrEmpty: (
value: unknown,
msg?: string | undefined
) => void
export declare const isNullOrUndefined: (value: unknown) => boolean
export declare const isNullOrUndefinedOrEmpty: (value: unknown) => boolean

28
dist/util/test.util.js vendored Normal file
View File

@ -0,0 +1,28 @@
"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.isNullOrUndefinedOrEmpty =
exports.isNullOrUndefined =
exports.assertNotNullOrUndefinedOrEmpty =
exports.assertNotNullOrUndefined =
void 0
var assertNotNullOrUndefined = function (value, msg) {
if ((0, exports.isNullOrUndefined)(value)) {
throw new Error(msg || "value is null or undefined")
}
}
exports.assertNotNullOrUndefined = assertNotNullOrUndefined
var assertNotNullOrUndefinedOrEmpty = function (value, msg) {
if ((0, exports.isNullOrUndefinedOrEmpty)(value)) {
throw new Error(msg || "value is null or undefined or empty")
}
}
exports.assertNotNullOrUndefinedOrEmpty = assertNotNullOrUndefinedOrEmpty
var isNullOrUndefined = function (value) {
return value === null || value === undefined
}
exports.isNullOrUndefined = isNullOrUndefined
var isNullOrUndefinedOrEmpty = function (value) {
return (0, exports.isNullOrUndefined)(value) || value === ""
}
exports.isNullOrUndefinedOrEmpty = isNullOrUndefinedOrEmpty
//# sourceMappingURL=test.util.js.map

1
dist/util/test.util.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"test.util.js","sourceRoot":"","sources":["../../src/util/test.util.ts"],"names":[],"mappings":";;;AAAO,IAAM,wBAAwB,GAAG,UAAC,KAAc,EAAE,GAAY;IACjE,IAAI,IAAA,yBAAiB,EAAC,KAAK,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,4BAA4B,CAAC,CAAA;KACvD;AACL,CAAC,CAAA;AAJY,QAAA,wBAAwB,4BAIpC;AAEM,IAAM,+BAA+B,GAAG,UAC3C,KAAc,EACd,GAAY;IAEZ,IAAI,IAAA,gCAAwB,EAAC,KAAK,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,qCAAqC,CAAC,CAAA;KAChE;AACL,CAAC,CAAA;AAPY,QAAA,+BAA+B,mCAO3C;AAEM,IAAM,iBAAiB,GAAG,UAAC,KAAc;IAC5C,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAA;AAChD,CAAC,CAAA;AAFY,QAAA,iBAAiB,qBAE7B;AAEM,IAAM,wBAAwB,GAAG,UAAC,KAAc;IACnD,OAAO,IAAA,yBAAiB,EAAC,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAA;AACnD,CAAC,CAAA;AAFY,QAAA,wBAAwB,4BAEpC"}

10487
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"sourceMap": true,
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
@ -11,6 +11,7 @@
"lib": ["ES2015"],
"skipLibCheck": true,
"experimentalDecorators": true,
"declaration": true,
"paths": {
"@/*": ["./*"]
}