@softwear/latestcollectioncore 1.0.141 → 1.0.142

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.
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decrypt = exports.encrypt = void 0;
4
4
  const buffer_1 = require("buffer");
5
- const node_crypto_1 = require("node:crypto");
5
+ const crypto_1 = require("crypto");
6
6
  function encrypt(plain, KEY) {
7
- const iv = (0, node_crypto_1.randomBytes)(12);
8
- const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', KEY, iv);
7
+ const iv = (0, crypto_1.randomBytes)(12);
8
+ const cipher = (0, crypto_1.createCipheriv)('aes-256-gcm', KEY, iv);
9
9
  const ciphertext = buffer_1.Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
10
10
  const tag = cipher.getAuthTag();
11
11
  const b64 = (b) => b.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
@@ -23,7 +23,7 @@ function decrypt(enc, KEY) {
23
23
  const iv = fromB64(ivB64);
24
24
  const ct = fromB64(ctB64);
25
25
  const tag = fromB64(tagB64);
26
- const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', KEY, iv);
26
+ const decipher = (0, crypto_1.createDecipheriv)('aes-256-gcm', KEY, iv);
27
27
  decipher.setAuthTag(tag);
28
28
  const plain = buffer_1.Buffer.concat([decipher.update(ct), decipher.final()]);
29
29
  return plain.toString('utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.141",
3
+ "version": "1.0.142",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from 'buffer'
2
- import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
2
+ import { createCipheriv, createDecipheriv, randomBytes } from 'crypto'
3
3
 
4
4
  export function encrypt(plain: string, KEY: Buffer): string {
5
5
  const iv = randomBytes(12)