@fylib/crypto 0.1.0 → 0.2.1

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/engine.js CHANGED
@@ -35,6 +35,12 @@ async function importKey(secret) {
35
35
  export async function encrypt(text, cfg) {
36
36
  if (!cfg.enabled)
37
37
  return text;
38
+ if (!cfg.secret)
39
+ throw new Error('[fyLib/Crypto] secret is required when crypto is enabled');
40
+ if (!cfg.ivSize)
41
+ throw new Error('[fyLib/Crypto] ivSize is required when crypto is enabled');
42
+ if (!cfg.tagSize)
43
+ throw new Error('[fyLib/Crypto] tagSize is required when crypto is enabled');
38
44
  logger.debug('Crypto', 'Encrypting data');
39
45
  const subtle = getSubtle();
40
46
  if (!subtle) {
@@ -52,6 +58,12 @@ export async function encrypt(text, cfg) {
52
58
  export async function decrypt(payload, cfg) {
53
59
  if (!cfg.enabled)
54
60
  return payload;
61
+ if (!cfg.secret)
62
+ throw new Error('[fyLib/Crypto] secret is required when crypto is enabled');
63
+ if (!cfg.ivSize)
64
+ throw new Error('[fyLib/Crypto] ivSize is required when crypto is enabled');
65
+ if (!cfg.tagSize)
66
+ throw new Error('[fyLib/Crypto] tagSize is required when crypto is enabled');
55
67
  logger.debug('Crypto', 'Decrypting data');
56
68
  const subtle = getSubtle();
57
69
  if (!subtle) {
package/dist/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export interface CryptoConfig {
2
2
  enabled: boolean;
3
- secret: string;
4
- algorithm: string;
5
- transformation: string;
6
- ivSize: number;
7
- tagSize: number;
3
+ secret?: string;
4
+ algorithm?: string;
5
+ transformation?: string;
6
+ ivSize?: number;
7
+ tagSize?: number;
8
8
  }
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
- {
2
- "name": "@fylib/crypto",
3
- "version": "0.1.0",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "files": ["dist"],
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "scripts": {
11
- "build": "tsc -p tsconfig.json"
12
- },
13
- "dependencies": {
14
- "@fylib/core": "workspace:*",
15
- "@fylib/logger": "workspace:*"
16
- },
17
- "devDependencies": {
18
- "typescript": "catalog:",
19
- "@types/node": "catalog:"
20
- }
21
- }
1
+ {
2
+ "name": "@fylib/crypto",
3
+ "version": "0.2.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "dependencies": {
13
+ "@fylib/core": "0.2.1",
14
+ "@fylib/logger": "0.2.1"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.9.3",
18
+ "@types/node": "^20.17.19"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json"
22
+ }
23
+ }