@softwear/latestcollectioncore 1.0.140 → 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.
- package/dist/cryptography.d.ts +1 -1
- package/dist/cryptography.js +8 -8
- package/package.json +33 -32
- package/src/cryptography.ts +2 -2
package/dist/cryptography.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Buffer } from '
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
4
|
export declare function encrypt(plain: string, KEY: Buffer): string;
|
|
5
5
|
export declare function decrypt(enc: string, KEY: Buffer): string;
|
package/dist/cryptography.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decrypt = exports.encrypt = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
6
|
function encrypt(plain, KEY) {
|
|
7
|
-
const iv = (0,
|
|
8
|
-
const cipher = (0,
|
|
9
|
-
const ciphertext =
|
|
7
|
+
const iv = (0, crypto_1.randomBytes)(12);
|
|
8
|
+
const cipher = (0, crypto_1.createCipheriv)('aes-256-gcm', KEY, iv);
|
|
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, '');
|
|
12
12
|
return `v1:${b64(iv)}:${b64(ciphertext)}:${b64(tag)}`;
|
|
@@ -18,14 +18,14 @@ function decrypt(enc, KEY) {
|
|
|
18
18
|
throw new Error('Unsupported version');
|
|
19
19
|
const fromB64 = (s) => {
|
|
20
20
|
const pad = s.length % 4 ? '='.repeat(4 - (s.length % 4)) : '';
|
|
21
|
-
return
|
|
21
|
+
return buffer_1.Buffer.from(s.replace(/-/g, '+').replace(/_/g, '/') + pad, 'base64');
|
|
22
22
|
};
|
|
23
23
|
const iv = fromB64(ivB64);
|
|
24
24
|
const ct = fromB64(ctB64);
|
|
25
25
|
const tag = fromB64(tagB64);
|
|
26
|
-
const decipher = (0,
|
|
26
|
+
const decipher = (0, crypto_1.createDecipheriv)('aes-256-gcm', KEY, iv);
|
|
27
27
|
decipher.setAuthTag(tag);
|
|
28
|
-
const plain =
|
|
28
|
+
const plain = buffer_1.Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
29
29
|
return plain.toString('utf8');
|
|
30
30
|
}
|
|
31
31
|
exports.decrypt = decrypt;
|
package/package.json
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@softwear/latestcollectioncore",
|
|
3
|
+
"version": "1.0.142",
|
|
4
|
+
"description": "Core functions for LatestCollections applications",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.json",
|
|
9
|
+
"build:watch": "tsc -p tsconfig.json --watch",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest",
|
|
12
|
+
"dev": "concurrently \"npm:build:watch\" \"npm:test:watch\""
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+ssh://git@gitlab.com/softwearconnect/latestcollectioncore.git"
|
|
17
|
+
},
|
|
18
|
+
"author": "Jeroen de Vries",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://gitlab.com/softwearconnect/latestcollectioncore/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://gitlab.com/softwearconnect/latestcollectioncore#readme",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^18.11.17",
|
|
26
|
+
"concurrently": "^9.2.1",
|
|
27
|
+
"typescript": "^4.9.4",
|
|
28
|
+
"vitest": "^1.0.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"buffer": "^6.0.3",
|
|
32
|
+
"date-fns": "^2.29.3",
|
|
33
|
+
"filtrex": "^2.2.3"
|
|
34
|
+
}
|
|
34
35
|
}
|
package/src/cryptography.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Buffer } from '
|
|
2
|
-
import { createCipheriv, createDecipheriv, randomBytes } from '
|
|
1
|
+
import { Buffer } from 'buffer'
|
|
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)
|