Socket
Socket
Sign inDemoInstall

ts-configurable

Package Overview
Dependencies
21
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 1.0.0

5

CHANGELOG.md
# CHANGELOG
## 1.0.0
- Breaking changes: values are base64 encoded before being encrypted and base64 decoded after being decrypted. This way, when providing multiple keys, a correct decryption can be determined by checking whether the plaintext only contains charactesr from the base64 characterset.
- Export the `decrypt` method from the package so the consumer can test the correct functionality of encryption and decryption.
## 0.3.1

@@ -4,0 +9,0 @@

2

index.d.ts
export { IConstructorOptions, IEnvOptions, IDecoratorOptions } from './lib/interfaces';
export { Configurable } from './lib/configurable';
export { BaseConfig } from './lib/base-config';
export { encrypt } from './lib/encryption-utils';
export { encrypt, decrypt } from './lib/encryption-utils';

@@ -9,2 +9,3 @@ "use strict";

exports.encrypt = encryption_utils_1.encrypt;
exports.decrypt = encryption_utils_1.decrypt;
//# sourceMappingURL=index.js.map

@@ -12,6 +12,6 @@ /// <reference types="node" />

* Decrypt the given ciphertext
* @param key decryption key
* @param keyOrSecret decryption secret (string) or derived key (Buffer)
* @param ciphertext ciphertext to decrypt
*/
export declare function decrypt(key: Buffer, ciphertext: string): string;
export declare function decrypt(keyOrSecret: Buffer | string, ciphertext: string): string;
export declare function attemptDecryption(keys: Buffer[], ciphertext: any): any;

@@ -104,5 +104,5 @@ "use strict";

const iv = crypto_1.randomBytes(ivBytelength);
// Encrypt plaintext
// Encrypt base64-encoded plaintext
const cipher = crypto_1.createCipheriv(cipherAlgorithm, key, iv);
let encrypted = cipher.update(plaintext);
let encrypted = cipher.update(Buffer.from(plaintext).toString('base64'));
encrypted = Buffer.concat([encrypted, cipher.final()]);

@@ -115,6 +115,7 @@ // Return the serialized cipher (its string representation)

* Decrypt the given ciphertext
* @param key decryption key
* @param keyOrSecret decryption secret (string) or derived key (Buffer)
* @param ciphertext ciphertext to decrypt
*/
function decrypt(key, ciphertext) {
function decrypt(keyOrSecret, ciphertext) {
const key = typeof keyOrSecret === 'string' ? keyFromSecret(keyOrSecret) : keyOrSecret;
const { iv, encrypted } = deserializeCipher(ciphertext);

@@ -125,3 +126,3 @@ // Decrypt value

decrypted = Buffer.concat([decrypted, decipher.final()]);
const plaintext = decrypted.toString();
const plaintext = Buffer.from(decrypted.toString(), 'base64').toString();
return plaintext;

@@ -128,0 +129,0 @@ }

{
"name": "ts-configurable",
"version": "0.3.1",
"version": "1.0.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Benjamin Assadsolimani (derbenoo)",

@@ -308,3 +308,3 @@ # TS-Configurable

console.log(`CIPHER: ${cipher}`);
// output: CIPHER: $ENC$.f60399294c2152fe8bbffc1cd9e8d22a.e44f27a1290864635acc3fd32b09f66a086de3743a26479c85edb3724f9ca8ad
// output: CIPHER: $ENC$.6aaa302f81c67ce6fe2da026ba7a2d0b.91b5db5ffea63e0d2c89c350760ca54152e6d4b5526ef06f8d6952407120891c
```

@@ -311,0 +311,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc