@alextheman/utility 5.10.1 → 5.11.0
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/node/index.cjs +0 -23
- package/dist/node/index.d.cts +1 -12
- package/dist/node/index.d.ts +1 -12
- package/dist/node/index.js +1 -22
- package/package.json +7 -8
package/dist/node/index.cjs
CHANGED
|
@@ -25,8 +25,6 @@ let node_path = require("node:path");
|
|
|
25
25
|
node_path = __toESM(node_path);
|
|
26
26
|
let zod = require("zod");
|
|
27
27
|
zod = __toESM(zod);
|
|
28
|
-
let libsodium_wrappers = require("libsodium-wrappers");
|
|
29
|
-
libsodium_wrappers = __toESM(libsodium_wrappers);
|
|
30
28
|
//#region src/node/functions/normalizeImportPath.ts
|
|
31
29
|
/**
|
|
32
30
|
* Normalizes an import path meant for use in an import statement in JavaScript.
|
|
@@ -656,27 +654,6 @@ function parseFilePath(filePath) {
|
|
|
656
654
|
//#region src/node/functions/sayHello.ts
|
|
657
655
|
var sayHello_default = sayHello;
|
|
658
656
|
//#endregion
|
|
659
|
-
//#region src/node/functions/security/encryptWithKey.ts
|
|
660
|
-
/**
|
|
661
|
-
* Encrypt a secret given the public base64 key and the thing you want to encrypt.
|
|
662
|
-
*
|
|
663
|
-
* @param publicKey - The public base64 key to encrypt with.
|
|
664
|
-
* @param plaintextValue - The value to encrypt in plaintext.
|
|
665
|
-
*
|
|
666
|
-
* @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
|
|
667
|
-
*/
|
|
668
|
-
async function encryptWithKey(publicKey, plaintextValue) {
|
|
669
|
-
try {
|
|
670
|
-
await libsodium_wrappers.default.ready;
|
|
671
|
-
const base64Key = libsodium_wrappers.default.from_base64(publicKey, libsodium_wrappers.default.base64_variants.ORIGINAL);
|
|
672
|
-
const encryptedValue = libsodium_wrappers.default.crypto_box_seal(plaintextValue, base64Key);
|
|
673
|
-
return libsodium_wrappers.default.to_base64(encryptedValue, libsodium_wrappers.default.base64_variants.ORIGINAL);
|
|
674
|
-
} catch {
|
|
675
|
-
throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
//#endregion
|
|
679
|
-
exports.encryptWithKey = encryptWithKey;
|
|
680
657
|
exports.normaliseImportPath = normaliseImportPath;
|
|
681
658
|
exports.normalizeImportPath = normalizeImportPath;
|
|
682
659
|
exports.parseFilePath = parseFilePath;
|
package/dist/node/index.d.cts
CHANGED
|
@@ -65,15 +65,4 @@ declare function sayHello(): string;
|
|
|
65
65
|
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
66
66
|
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
67
67
|
//#endregion
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Encrypt a secret given the public base64 key and the thing you want to encrypt.
|
|
71
|
-
*
|
|
72
|
-
* @param publicKey - The public base64 key to encrypt with.
|
|
73
|
-
* @param plaintextValue - The value to encrypt in plaintext.
|
|
74
|
-
*
|
|
75
|
-
* @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
|
|
76
|
-
*/
|
|
77
|
-
declare function encryptWithKey(publicKey: string, plaintextValue: string): Promise<string>;
|
|
78
|
-
//#endregion
|
|
79
|
-
export { type IsTypeArgumentString, encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
|
|
68
|
+
export { type IsTypeArgumentString, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -66,15 +66,4 @@ declare function sayHello(): string;
|
|
|
66
66
|
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
67
67
|
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
68
68
|
//#endregion
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Encrypt a secret given the public base64 key and the thing you want to encrypt.
|
|
72
|
-
*
|
|
73
|
-
* @param publicKey - The public base64 key to encrypt with.
|
|
74
|
-
* @param plaintextValue - The value to encrypt in plaintext.
|
|
75
|
-
*
|
|
76
|
-
* @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
|
|
77
|
-
*/
|
|
78
|
-
declare function encryptWithKey(publicKey: string, plaintextValue: string): Promise<string>;
|
|
79
|
-
//#endregion
|
|
80
|
-
export { type IsTypeArgumentString, encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
|
|
69
|
+
export { type IsTypeArgumentString, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello };
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import z from "zod";
|
|
3
|
-
import sodium from "libsodium-wrappers";
|
|
4
3
|
//#region src/node/functions/normalizeImportPath.ts
|
|
5
4
|
/**
|
|
6
5
|
* Normalizes an import path meant for use in an import statement in JavaScript.
|
|
@@ -630,24 +629,4 @@ function parseFilePath(filePath) {
|
|
|
630
629
|
//#region src/node/functions/sayHello.ts
|
|
631
630
|
var sayHello_default = sayHello;
|
|
632
631
|
//#endregion
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Encrypt a secret given the public base64 key and the thing you want to encrypt.
|
|
636
|
-
*
|
|
637
|
-
* @param publicKey - The public base64 key to encrypt with.
|
|
638
|
-
* @param plaintextValue - The value to encrypt in plaintext.
|
|
639
|
-
*
|
|
640
|
-
* @returns The encrypted string. This value will be different on repeat calls, but the result should always decrypt to the initial `plaintextValue` argument.
|
|
641
|
-
*/
|
|
642
|
-
async function encryptWithKey(publicKey, plaintextValue) {
|
|
643
|
-
try {
|
|
644
|
-
await sodium.ready;
|
|
645
|
-
const base64Key = sodium.from_base64(publicKey, sodium.base64_variants.ORIGINAL);
|
|
646
|
-
const encryptedValue = sodium.crypto_box_seal(plaintextValue, base64Key);
|
|
647
|
-
return sodium.to_base64(encryptedValue, sodium.base64_variants.ORIGINAL);
|
|
648
|
-
} catch {
|
|
649
|
-
throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
//#endregion
|
|
653
|
-
export { encryptWithKey, normaliseImportPath, normalizeImportPath, parseFilePath, sayHello_default as sayHello };
|
|
632
|
+
export { normaliseImportPath, normalizeImportPath, parseFilePath, sayHello_default as sayHello };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Helpful utility functions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,30 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"dotenv": "17.4.
|
|
33
|
+
"dotenv": "17.4.1",
|
|
34
34
|
"execa": "9.6.1",
|
|
35
|
-
"libsodium-wrappers": "0.8.2",
|
|
36
35
|
"zod": "4.3.6"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
38
|
"@alextheman/eslint-plugin": "5.12.0",
|
|
40
|
-
"@types/node": "25.
|
|
39
|
+
"@types/node": "25.6.0",
|
|
41
40
|
"alex-c-line": "2.5.0",
|
|
42
41
|
"cross-env": "10.1.0",
|
|
43
42
|
"dotenv-cli": "11.0.0",
|
|
44
43
|
"eslint": "10.2.0",
|
|
45
44
|
"globals": "17.4.0",
|
|
46
45
|
"husky": "9.1.7",
|
|
47
|
-
"jsdom": "29.0.
|
|
48
|
-
"prettier": "3.8.
|
|
46
|
+
"jsdom": "29.0.2",
|
|
47
|
+
"prettier": "3.8.2",
|
|
49
48
|
"tempy": "3.2.0",
|
|
50
49
|
"tsdown": "0.21.7",
|
|
51
50
|
"tsx": "4.21.0",
|
|
52
51
|
"typedoc": "0.28.18",
|
|
53
52
|
"typescript": "6.0.2",
|
|
54
|
-
"typescript-eslint": "8.58.
|
|
53
|
+
"typescript-eslint": "8.58.1",
|
|
55
54
|
"vite-tsconfig-paths": "6.1.1",
|
|
56
|
-
"vitest": "4.1.
|
|
55
|
+
"vitest": "4.1.4"
|
|
57
56
|
},
|
|
58
57
|
"engines": {
|
|
59
58
|
"node": ">=22.3.0"
|