@meebon/meebon-crypto 1.2.10 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import { RequestHandler } from 'express';
2
+ import { MeebonCryptoKeyPair } from '../types/global';
3
+ /**
4
+ * Middleware for encrypting incoming request data and decrypting outgoing response data.
5
+ *
6
+ * @param {MeebonCryptoKeyPair} keys - An object containing the privateKey and publicKey in PEM format.
7
+ * @returns {RequestHandler} The Express middleware function.
8
+ */
9
+ declare function EncryptionMiddleware({ privateKey, publicKey }: MeebonCryptoKeyPair): RequestHandler;
10
+ export { EncryptionMiddleware };
11
+ //# sourceMappingURL=ExpressEncryptionMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressEncryptionMiddleware.d.ts","sourceRoot":"","sources":["../lib/ExpressEncryptionMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;GAKG;AACH,iBAAS,oBAAoB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,cAAc,CAkC5F;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,52 @@
1
+ import forge from 'node-forge';
2
+ import { MeebonCryptoKeyPair, MeebonCryptoProps } from '../types/global';
3
+ export declare class MeebonCrypto {
4
+ protected privateKeyPem: string;
5
+ protected publicKeyPem: string;
6
+ privateKey: forge.pki.rsa.PrivateKey;
7
+ publicKey: forge.pki.rsa.PublicKey;
8
+ protected schema: forge.pki.rsa.EncryptionScheme;
9
+ private constructor();
10
+ /**
11
+ * Initializes a new instance of MeebonCrypto.
12
+ * @param props - The crypto properties including keys and optional encryption scheme.
13
+ * @returns {MeebonCrypto} The initialized MeebonCrypto instance.
14
+ */
15
+ static init(props: MeebonCryptoProps): MeebonCrypto;
16
+ /**
17
+ * Encrypts data using the instance's public key.
18
+ * @param {string} plainText - The data to encrypt.
19
+ * @returns {string} The Base64-encoded encrypted data.
20
+ */
21
+ encrypt(plainText: string): string;
22
+ /**
23
+ * Decrypts data using the instance's private key.
24
+ * @param {string} encryptedData - The Base64-encoded encrypted data.
25
+ * @returns {string} The decrypted data.
26
+ */
27
+ decrypt(encryptedData: string): string;
28
+ /**
29
+ * Generates an RSA key pair with the specified key size.
30
+ *
31
+ * @param {number} [length=3072] - The length of the RSA key in bits (defaults to 3072).
32
+ * @returns {MeebonCryptoKeyPair} An object containing the generated public and private keys in PEM format.
33
+ */
34
+ static generateKeyPair(length?: number): MeebonCryptoKeyPair;
35
+ /**
36
+ * Encrypts data with a provided public key.
37
+ * @param {string} data - The data to encrypt.
38
+ * @param {string} publicKey - The public key in PEM format.
39
+ * @param {string} [scheme='RSA-OAEP'] - The encryption scheme to use (defaults to 'RSA-OAEP').
40
+ * @returns {string} The Base64-encoded encrypted data.
41
+ */
42
+ static encryptData(data: string, publicKey: string, scheme?: forge.pki.rsa.EncryptionScheme): string;
43
+ /**
44
+ * Decrypts data with a provided private key.
45
+ * @param {string} encryptedData - The Base64-encoded encrypted data.
46
+ * @param {string} privateKey - The private key in PEM format.
47
+ * @param {string} [scheme='RSA-OAEP'] - The decryption scheme to use (defaults to 'RSA-OAEP').
48
+ * @returns {string} The decrypted data.
49
+ */
50
+ static decryptData(encryptedData: string, privateKey: string, scheme?: forge.pki.rsa.EncryptionScheme): string;
51
+ }
52
+ //# sourceMappingURL=MeebonCrypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeebonCrypto.d.ts","sourceRoot":"","sources":["../lib/MeebonCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,qBAAa,YAAY;IACvB,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAExB,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;IACrC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;IAE1C,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAEjD,OAAO;IASP;;;;OAIG;WACW,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY;IAI1D;;;;OAIG;IACI,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAKzC;;;;OAIG;IACI,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAK7C;;;;;OAKG;WACW,eAAe,CAAC,MAAM,GAAE,MAAa,GAAG,mBAAmB;IAQzE;;;;;;OAMG;WACW,WAAW,CACvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,gBAA6B,GAClD,MAAM;IAMT;;;;;;OAMG;WACW,WAAW,CACvB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,gBAA6B,GAClD,MAAM;CAKV"}
@@ -0,0 +1,4 @@
1
+ import { MeebonCrypto } from "./MeebonCrypto";
2
+ import { EncryptionMiddleware } from "./ExpressEncryptionMiddleware";
3
+ export { EncryptionMiddleware, MeebonCrypto };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meebon/meebon-crypto",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "",
5
5
  "author": "kajalanS <103587022+kajalanS@users.noreply.github.com>",
6
6
  "homepage": "https://github.com/KsoftmHub/meebon-crypto?tab=readme-ov-file#getting-started",
@@ -14,8 +14,8 @@
14
14
  "types": "types"
15
15
  },
16
16
  "files": [
17
- "dist/*.js",
18
- "types/**/*.ts"
17
+ "dist",
18
+ "types"
19
19
  ],
20
20
  "release": {
21
21
  "branches": [
@@ -44,6 +44,12 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/KsoftmHub/meebon-crypto/issues"
46
46
  },
47
+ "exports": {
48
+ ".": {
49
+ "import": "./dist/index.js",
50
+ "require": "./dist/index.js"
51
+ }
52
+ },
47
53
  "devDependencies": {
48
54
  "@eslint/js": "^9.18.0",
49
55
  "@jest/globals": "^29.7.0",