@nivinjoseph/n-sec 6.0.1 → 6.0.3

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.
@@ -38,6 +38,14 @@
38
38
  "editor.defaultFormatter": "vscode.css-language-features"
39
39
  },
40
40
  "scss.format.braceStyle": "expand",
41
+ "eslint.enable": true,
42
+ "eslint.validate": [
43
+ "typescript"
44
+ ],
45
+ "eslint.options": {
46
+ "overrideConfigFile": "eslint.config.js"
47
+ },
48
+ "eslint.useFlatConfig": true,
41
49
  "cSpell.words": [
42
50
  "acumin",
43
51
  "arrowless",
package/README.md CHANGED
@@ -1,8 +1,121 @@
1
1
  # n-sec
2
- Security library
3
2
 
3
+ A comprehensive security library for Node.js applications providing cryptographic operations and API security features.
4
4
 
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @nivinjoseph/n-sec
9
+ # or
10
+ yarn add @nivinjoseph/n-sec
11
+ ```
12
+
13
+ ## Features
14
+
15
+ ### Cryptographic Operations
16
+
17
+ 1. **Hash**
18
+ - Secure hashing operations using SHA-512
19
+ - Generate hash digests for data
20
+ - Support for salted hashing
21
+
22
+ 2. **HMAC (Hash-based Message Authentication Code)**
23
+ - Generate HMAC signatures using SHA-256
24
+
25
+ 3. **Symmetric Encryption**
26
+ - AES-256-CBC encryption and decryption
27
+ - Secure key generation
28
+ - IV (Initialization Vector) handling
29
+
30
+ ### API Security
31
+
32
+ 1. **JSON Web Tokens (JWT)**
33
+ - JWT creation and validation
34
+ - Support for HMAC algorithm
35
+ - Token expiration handling
36
+ - Claims management
37
+
38
+ 2. **Claims-based Identity**
39
+ - Claims management
40
+ - Identity verification
41
+ - Custom claims support
42
+
43
+ 3. **Security Tokens**
44
+ - Token generation and validation
45
+ - Token expiration handling
46
+ - Invalid token detection
47
+
48
+ ## Usage
49
+
50
+ ### Cryptographic Operations
51
+
52
+ ```typescript
53
+ import { Hash, Hmac, SymmetricEncryption } from '@nivinjoseph/n-sec';
54
+
55
+ // Hashing
56
+ const hash = Hash.create('your-data');
57
+ const saltedHash = Hash.createUsingSalt('your-data', 'your-salt');
58
+
59
+ // HMAC
60
+ const hmac = Hmac.create('your-secret-key', 'your-data');
61
+
62
+ // Symmetric Encryption
63
+ const key = await SymmetricEncryption.generateKey();
64
+ const encrypted = await SymmetricEncryption.encrypt(key, 'your-data');
65
+ const decrypted = SymmetricEncryption.decrypt(key, encrypted);
66
+ ```
67
+
68
+ ### API Security
69
+
70
+ ```typescript
71
+ import { JsonWebToken, ClaimsIdentity, Claim, AlgType } from '@nivinjoseph/n-sec';
72
+
73
+ // Create a claims identity
74
+ const claims = [
75
+ new Claim('sub', 'user123'),
76
+ new Claim('role', 'admin')
77
+ ];
78
+
79
+ // Create a JWT
80
+ const jwt = JsonWebToken.fromClaims(
81
+ 'your-issuer',
82
+ AlgType.hmac,
83
+ 'your-secret-key',
84
+ Date.now() + 3600000, // 1 hour expiry
85
+ claims
86
+ );
87
+ const token = jwt.generateToken();
88
+
89
+ // Verify a JWT
90
+ const verifiedJwt = JsonWebToken.fromToken(
91
+ 'your-issuer',
92
+ AlgType.hmac,
93
+ 'your-secret-key',
94
+ token
95
+ );
96
+ const verifiedClaims = verifiedJwt.claims;
97
+ ```
98
+
99
+ ## Error Handling
100
+
101
+ The library provides specific exception types for error handling:
102
+
103
+ - `CryptoException`: Base exception for cryptographic operations
104
+ - `ExpiredTokenException`: Thrown when a token has expired
105
+ - `InvalidTokenException`: Thrown when a token is invalid
106
+
107
+ ## Requirements
108
+
109
+ - Node.js >= 20.10
110
+ - TypeScript support
111
+
112
+ ## Contributing
113
+
114
+ Feel free to submit issues and pull requests.
5
115
  For Windows development:
6
116
  - Build tools => Open PowerShell as admin and run => npm install -g windows-build-tools
7
117
  - OpenSSL => Go to https://slproweb.com/products/Win32OpenSSL.html => Get version Win64 OpenSSL v1.0.2q
8
118
 
119
+ ## License
120
+
121
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/dist/bin.js CHANGED
@@ -10,6 +10,7 @@ const supportedCommandsString = JSON.stringify(TypeHelper.enumTypeToTuples(Suppo
10
10
  async function executeCommand(command) {
11
11
  // given(command, "command").ensureHasValue().ensureIsString();
12
12
  switch (command) {
13
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
13
14
  case SupportedCommands.generateSymmetricKey:
14
15
  {
15
16
  const key = await SymmetricEncryption.generateKey();
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IAElB,oEAA+C,CAAA;AACnD,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9G,KAAK,UAAU,cAAc,CAAC,OAA0B;IAEpD,+DAA+D;IAE/D,QAAQ,OAAO,EACf,CAAC;QACG,KAAK,iBAAiB,CAAC,oBAAoB;YACvC,CAAC;gBACG,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,WAAW,EAAE,CAAC;gBACpD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;gBACtC,MAAM;YACV,CAAC;QACL;YACI,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,6BAA6B,uBAAuB,GAAG,CAAC,CAAC;IAC1G,CAAC;AACL,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EACrB,CAAC;IACG,OAAO,CAAC,KAAK,CAAC,yDAAyD,uBAAuB,GAAG,CAAC,CAAC;IACnG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;AACxC,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;AAE7C,cAAc,CAAC,OAAO,CAAC;KAClB,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,CAAC,EAAE;IAEP,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IAElB,oEAA+C,CAAA;AACnD,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9G,KAAK,UAAU,cAAc,CAAC,OAA0B;IAEpD,+DAA+D;IAE/D,QAAQ,OAAO,EACf,CAAC;QACG,uEAAuE;QACvE,KAAK,iBAAiB,CAAC,oBAAoB;YACvC,CAAC;gBACG,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,WAAW,EAAE,CAAC;gBACpD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;gBACtC,MAAM;YACV,CAAC;QACL;YACI,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,6BAA6B,uBAAuB,GAAG,CAAC,CAAC;IAC1G,CAAC;AACL,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EACrB,CAAC;IACG,OAAO,CAAC,KAAK,CAAC,yDAAyD,uBAAuB,GAAG,CAAC,CAAC;IACnG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;AACxC,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;AAE7C,cAAc,CAAC,OAAO,CAAC;KAClB,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,CAAC,EAAE;IAEP,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,591 @@
1
+ import eslint from "@eslint/js";
2
+ import tsEslint from "typescript-eslint";
3
+ import { defineConfig } from "eslint/config";
4
+ import importPlugin from "eslint-plugin-import";
5
+ import tsParser from "@typescript-eslint/parser";
6
+
7
+ import stylistic from "@stylistic/eslint-plugin";
8
+
9
+ export default defineConfig(
10
+ eslint.configs.recommended,
11
+ tsEslint.configs.recommended,
12
+ importPlugin.flatConfigs.recommended,
13
+ {
14
+ ignores: ["dist/**", "node_modules/**", "**/*.js", "**/*.map", "**/*d.ts"]
15
+ },
16
+ {
17
+ files: ["**/*.ts"],
18
+ extends: [importPlugin.flatConfigs.recommended, importPlugin.flatConfigs.typescript],
19
+ languageOptions: {
20
+ parser: tsParser,
21
+ ecmaVersion: "latest",
22
+ sourceType: "module"
23
+ },
24
+ settings: {
25
+ "import/parsers": {
26
+ "@typescript-eslint/parser": [".ts", ".tsx"]
27
+ },
28
+ // "import/resolver": {
29
+ // "node": {
30
+ // "extensions": [".js", ".jsx"],
31
+ // "moduleDirectory": ["node_modules"]
32
+ // }
33
+ // },
34
+ "import/resolver": {
35
+ node: {
36
+ extensions: [".js", ".jsx", ".ts", ".tsx"]
37
+ },
38
+ typescript: {
39
+ // Point to your tsconfig if needed:
40
+ project: "./tsconfig.json"
41
+ }
42
+ },
43
+ },
44
+ rules: {
45
+ // "import/no-unresolved": "off",
46
+ "import/no-extraneous-dependencies": ["error"]
47
+ }
48
+ },
49
+ {
50
+ files: ["**/*.ts"],
51
+ languageOptions: {
52
+ parserOptions: {
53
+ project: [
54
+ "./tsconfig.json"
55
+ ],
56
+ tsconfigRootDir: import.meta.dirname,
57
+ projectService: true
58
+ }
59
+ },
60
+ plugins: {
61
+ "@stylistic/ts": stylistic
62
+ },
63
+ "rules": {
64
+ "import/extensions": [
65
+ "error",
66
+ "always",
67
+ {
68
+ "ts": "never",
69
+ "js": "always"
70
+ }
71
+ ],
72
+ // "quotes": "off",
73
+ "quotes": [
74
+ "error",
75
+ "double",
76
+ {
77
+ "allowTemplateLiterals": true
78
+ }
79
+ ],
80
+ "no-eval": "error",
81
+ "no-void": "error",
82
+ "no-with": "error",
83
+ "@typescript-eslint/adjacent-overload-signatures": "error",
84
+ "@typescript-eslint/array-type": [
85
+ "error",
86
+ {
87
+ "default": "generic",
88
+ "readonly": "generic"
89
+ }
90
+ ],
91
+ // "@typescript-eslint/consistent-type-assertions": ["error", {
92
+ // assertionStyle: "as",
93
+ // objectLiteralTypeAssertions: "allow-as-parameter"
94
+ // }],
95
+ "@typescript-eslint/await-thenable": "error",
96
+ "@typescript-eslint/ban-ts-comment": [
97
+ "error",
98
+ {
99
+ "ts-expect-error": "allow-with-description",
100
+ "ts-ignore": "allow-with-description",
101
+ "ts-nocheck": true,
102
+ "ts-check": true
103
+ }
104
+ ],
105
+ "@typescript-eslint/ban-tslint-comment": "error",
106
+ "@typescript-eslint/no-empty-object-type": "error",
107
+ "@typescript-eslint/no-unsafe-function-type": "error",
108
+ "@typescript-eslint/no-wrapper-object-types": "off",
109
+ "@typescript-eslint/no-restricted-types": [
110
+ "error",
111
+ {
112
+ "types": {
113
+ "String": {
114
+ "message": "Use string instead",
115
+ "fixWith": "string"
116
+ },
117
+ "Boolean": {
118
+ "message": "Use boolean instead",
119
+ "fixWith": "boolean"
120
+ },
121
+ "Number": {
122
+ "message": "Use number instead",
123
+ "fixWith": "number"
124
+ },
125
+ "Symbol": {
126
+ "message": "Use symbol instead",
127
+ "fixWith": "symbol"
128
+ }
129
+ }
130
+ }
131
+ ],
132
+ "brace-style": "off",
133
+ "@stylistic/ts/brace-style": [
134
+ "error",
135
+ "allman",
136
+ {
137
+ "allowSingleLine": true
138
+ }
139
+ ],
140
+ "@typescript-eslint/class-literal-property-style": [
141
+ "off",
142
+ "getters"
143
+ ],
144
+ "comma-dangle": "off",
145
+ "@stylistic/ts/comma-dangle": [
146
+ "error",
147
+ {
148
+ "arrays": "never",
149
+ "objects": "only-multiline",
150
+ "imports": "never",
151
+ "exports": "never",
152
+ "functions": "never",
153
+ "enums": "only-multiline"
154
+ }
155
+ ],
156
+ "default-param-last": "off",
157
+ "@typescript-eslint/default-param-last": "error",
158
+ "@typescript-eslint/explicit-function-return-type": "error",
159
+ "@typescript-eslint/explicit-member-accessibility": "error",
160
+ "@typescript-eslint/explicit-module-boundary-types": "error",
161
+ "func-call-spacing": "off",
162
+ "@stylistic/ts/function-call-spacing": [
163
+ "error",
164
+ "never"
165
+ ],
166
+ "@stylistic/ts/member-delimiter-style": [
167
+ "error",
168
+ {
169
+ "multiline": {
170
+ "delimiter": "semi",
171
+ "requireLast": true
172
+ },
173
+ "singleline": {
174
+ "delimiter": "semi",
175
+ "requireLast": true
176
+ },
177
+ "multilineDetection": "brackets"
178
+ }
179
+ ],
180
+ "@typescript-eslint/member-ordering": [
181
+ "error",
182
+ {
183
+ "default": [
184
+ // Index signature
185
+ "signature",
186
+ // Fields
187
+ "private-static-field",
188
+ "protected-static-field",
189
+ "public-static-field",
190
+ // "private-decorated-field",
191
+ // "protected-decorated-field",
192
+ // "public-decorated-field",
193
+ "private-instance-field",
194
+ "protected-instance-field",
195
+ "public-instance-field",
196
+ // "public-abstract-field",
197
+ // "protected-abstract-field",
198
+ // "private-abstract-field",
199
+ // "private-field",
200
+ // "protected-field",
201
+ // "public-field",
202
+ // "static-field",
203
+ // "instance-field",
204
+ // "abstract-field",
205
+ // "decorated-field",
206
+ // "field",
207
+ // Getters
208
+ // "public-static-get",
209
+ // "protected-static-get",
210
+ // "private-static-get",
211
+ // "public-decorated-get",
212
+ // "protected-decorated-get",
213
+ // "private-decorated-get",
214
+ // "public-instance-get",
215
+ // "protected-instance-get",
216
+ // "private-instance-get",
217
+ // "public-abstract-get",
218
+ // "protected-abstract-get",
219
+ // "private-abstract-get",
220
+ // "public-get",
221
+ // "protected-get",
222
+ // "private-get",
223
+ // "static-get",
224
+ // "instance-get",
225
+ // "abstract-get",
226
+ // "decorated-get",
227
+ // "get",
228
+ // Setters
229
+ // "public-static-set",
230
+ // "protected-static-set",
231
+ // "private-static-set",
232
+ // "public-decorated-set",
233
+ // "protected-decorated-set",
234
+ // "private-decorated-set",
235
+ // "public-instance-set",
236
+ // "protected-instance-set",
237
+ // "private-instance-set",
238
+ // "public-abstract-set",
239
+ // "protected-abstract-set",
240
+ // "private-abstract-set",
241
+ // "public-set",
242
+ // "protected-set",
243
+ // "private-set",
244
+ // "static-set",
245
+ // "instance-set",
246
+ // "abstract-set",
247
+ // "decorated-set",
248
+ // "set",
249
+ // [
250
+ // "get",
251
+ // "set"
252
+ // ],
253
+ [
254
+ "private-static-get",
255
+ "private-static-set"
256
+ ],
257
+ [
258
+ "protected-static-get",
259
+ "protected-static-set"
260
+ ],
261
+ [
262
+ "public-static-get",
263
+ "public-static-set"
264
+ ],
265
+ [
266
+ "private-instance-get",
267
+ "private-instance-set"
268
+ ],
269
+ [
270
+ "protected-instance-get",
271
+ "protected-instance-set"
272
+ ],
273
+ [
274
+ "public-instance-get",
275
+ "public-instance-set"
276
+ ],
277
+ // Constructors
278
+ "public-constructor",
279
+ "protected-constructor",
280
+ "private-constructor",
281
+ // "constructor",
282
+ // Methods
283
+ "public-static-method",
284
+ "protected-static-method",
285
+ "private-static-method",
286
+ // "public-decorated-method",
287
+ // "protected-decorated-method",
288
+ // "private-decorated-method",
289
+ "public-instance-method",
290
+ "protected-instance-method",
291
+ "private-instance-method"
292
+ // "public-abstract-method",
293
+ // "protected-abstract-method",
294
+ // "private-abstract-method",
295
+ // "public-method",
296
+ // "protected-method",
297
+ // "private-method",
298
+ // "static-method",
299
+ // "instance-method",
300
+ // "abstract-method",
301
+ // "decorated-method",
302
+ // "method"
303
+ ]
304
+ }
305
+ ],
306
+ "@typescript-eslint/method-signature-style": [
307
+ "error",
308
+ "method"
309
+ ],
310
+ "@typescript-eslint/naming-convention": [
311
+ "error",
312
+ {
313
+ "selector": "memberLike",
314
+ "modifiers": [
315
+ "private"
316
+ ],
317
+ "format": [
318
+ "camelCase"
319
+ ],
320
+ "leadingUnderscore": "require"
321
+ }
322
+ ],
323
+ "@typescript-eslint/no-confusing-non-null-assertion": "error",
324
+ "@typescript-eslint/no-confusing-void-expression": [
325
+ "error",
326
+ {
327
+ "ignoreArrowShorthand": true
328
+ }
329
+ ],
330
+ "no-dupe-class-members": "off",
331
+ "@typescript-eslint/no-dupe-class-members": "error",
332
+ "@typescript-eslint/no-duplicate-enum-values": "error",
333
+ "no-duplicate-imports": "error",
334
+ "no-empty-function": "off",
335
+ "@typescript-eslint/no-empty-function": [
336
+ "error",
337
+ {
338
+ "allow": [
339
+ "private-constructors"
340
+ ]
341
+ }
342
+ ],
343
+ "@typescript-eslint/no-explicit-any": "off",
344
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
345
+ "no-extra-parens": "off",
346
+ "@stylistic/ts/no-extra-parens": [
347
+ "error",
348
+ "all",
349
+ {
350
+ "nestedBinaryExpressions": false
351
+ }
352
+ ],
353
+ "no-extra-semi": "off",
354
+ "@stylistic/ts/no-extra-semi": "error",
355
+ "@typescript-eslint/no-floating-promises": "error",
356
+ "@typescript-eslint/no-for-in-array": "error",
357
+ "no-implied-eval": "off",
358
+ "@typescript-eslint/no-implied-eval": "error",
359
+ "no-invalid-this": "off",
360
+ "@typescript-eslint/no-invalid-this": "error",
361
+ "@typescript-eslint/no-invalid-void-type": "error",
362
+ "no-loop-func": "off",
363
+ "@typescript-eslint/no-loop-func": "error",
364
+ "no-loss-of-precision": "off",
365
+ "@typescript-eslint/no-loss-of-precision": "error",
366
+ "@typescript-eslint/no-meaningless-void-operator": "error",
367
+ "@typescript-eslint/no-misused-new": "error",
368
+ "@typescript-eslint/no-misused-promises": "error",
369
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
370
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
371
+ "@typescript-eslint/no-non-null-assertion": "off",
372
+ "no-redeclare": "off",
373
+ "@typescript-eslint/no-redeclare": "error",
374
+ "@typescript-eslint/no-this-alias": "error",
375
+ "no-throw-literal": "error",
376
+ "@typescript-eslint/no-unnecessary-condition": [
377
+ "error",
378
+ {
379
+ "allowConstantLoopConditions": true
380
+ }
381
+ ],
382
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
383
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
384
+ "@typescript-eslint/no-unsafe-call": "error",
385
+ "@typescript-eslint/no-unsafe-return": "error",
386
+ "no-unused-expressions": "off",
387
+ "@typescript-eslint/no-unused-expressions": "error",
388
+ "no-unused-vars": "off",
389
+ "@typescript-eslint/no-unused-vars": "off",
390
+ "no-use-before-define": "off",
391
+ "@typescript-eslint/no-use-before-define": "off",
392
+ "no-useless-constructor": "off",
393
+ "@typescript-eslint/no-useless-constructor": "error",
394
+ "@typescript-eslint/no-useless-empty-export": "error",
395
+ "@typescript-eslint/no-var-requires": "off",
396
+ "@typescript-eslint/parameter-properties": "error",
397
+ "@typescript-eslint/prefer-enum-initializers": "error",
398
+ "@typescript-eslint/prefer-includes": "error",
399
+ "@typescript-eslint/prefer-literal-enum-member": "error",
400
+ "@typescript-eslint/prefer-readonly": "error",
401
+ "@typescript-eslint/prefer-reduce-type-parameter": "error",
402
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
403
+ "@typescript-eslint/prefer-ts-expect-error": "error",
404
+ "@typescript-eslint/require-array-sort-compare": "error",
405
+ "no-return-await": "off",
406
+ "@typescript-eslint/return-await": "error",
407
+ "semi": "off",
408
+ "@stylistic/ts/semi": "error",
409
+ "@typescript-eslint/unbound-method": "error",
410
+ "@typescript-eslint/no-require-imports": [
411
+ "error",
412
+ {
413
+ allow: ["/.*-view.html$"]
414
+ }
415
+ ]
416
+ }
417
+ }
418
+ );
419
+
420
+
421
+
422
+ // export default [
423
+ // {
424
+ // ignores: ["dist/**", "node_modules/**", "**/*.js", "**/*.map"]
425
+ // },
426
+ // {
427
+ // files: ["**/*.ts"],
428
+ // languageOptions: {
429
+ // parser: tsParser,
430
+ // parserOptions: {
431
+ // project: "./tsconfig.json",
432
+ // ecmaVersion: "latest",
433
+ // sourceType: "module"
434
+ // }
435
+ // },
436
+ // plugins: {
437
+ // "@typescript-eslint": tsEslint,
438
+ // "require-extensions": requireExtensions
439
+ // },
440
+ // rules: {
441
+ // // Base ESLint recommended rules
442
+ // ...js.configs.recommended.rules,
443
+ // // TypeScript ESLint recommended rules
444
+ // ...tsEslint.configs.recommended.rules,
445
+ // ...tsEslint.configs["eslint-recommended"].overrides[0].rules,
446
+ // // Require extensions recommended rules
447
+ // ...requireExtensions.configs.recommended.rules,
448
+
449
+ // // Your custom rules
450
+ // "quotes": "off",
451
+ // "@typescript-eslint/quotes": ["error", "double", { allowTemplateLiterals: true }],
452
+ // "no-eval": "error",
453
+ // "no-void": "error",
454
+ // "no-with": "error",
455
+ // "@typescript-eslint/adjacent-overload-signatures": "error",
456
+ // "@typescript-eslint/array-type": ["error", { default: "generic", readonly: "generic" }],
457
+ // "@typescript-eslint/await-thenable": "error",
458
+ // "@typescript-eslint/ban-ts-comment": ["error", {
459
+ // "ts-expect-error": "allow-with-description",
460
+ // "ts-ignore": "allow-with-description",
461
+ // "ts-nocheck": true,
462
+ // "ts-check": true
463
+ // }],
464
+ // "@typescript-eslint/ban-tslint-comment": "error",
465
+ // "@typescript-eslint/ban-types": ["error", {
466
+ // extendDefaults: false,
467
+ // types: {
468
+ // "String": { message: "Use string instead", fixWith: "string" },
469
+ // "Boolean": { message: "Use boolean instead", fixWith: "boolean" },
470
+ // "Number": { message: "Use number instead", fixWith: "number" },
471
+ // "Symbol": { message: "Use symbol instead", fixWith: "symbol" }
472
+ // }
473
+ // }],
474
+ // "brace-style": "off",
475
+ // "@typescript-eslint/brace-style": ["error", "allman", { allowSingleLine: true }],
476
+ // "@typescript-eslint/class-literal-property-style": ["off", "getters"],
477
+ // "comma-dangle": "off",
478
+ // "@typescript-eslint/comma-dangle": ["error", "never"],
479
+ // "default-param-last": "off",
480
+ // "@typescript-eslint/default-param-last": "error",
481
+ // "@typescript-eslint/explicit-function-return-type": "error",
482
+ // "@typescript-eslint/explicit-member-accessibility": "error",
483
+ // "@typescript-eslint/explicit-module-boundary-types": "error",
484
+ // "func-call-spacing": "off",
485
+ // "@typescript-eslint/func-call-spacing": ["error", "never"],
486
+ // "@typescript-eslint/member-delimiter-style": ["error", {
487
+ // multiline: { delimiter: "semi", requireLast: true },
488
+ // singleline: { delimiter: "semi", requireLast: true },
489
+ // multilineDetection: "brackets"
490
+ // }],
491
+ // "@typescript-eslint/member-ordering": ["error", {
492
+ // default: [
493
+ // "signature",
494
+ // "private-static-field",
495
+ // "protected-static-field",
496
+ // "public-static-field",
497
+ // "private-instance-field",
498
+ // "protected-instance-field",
499
+ // "public-instance-field",
500
+ // ["private-static-get", "private-static-set"],
501
+ // ["protected-static-get", "protected-static-set"],
502
+ // ["public-static-get", "public-static-set"],
503
+ // ["private-instance-get", "private-instance-set"],
504
+ // ["protected-instance-get", "protected-instance-set"],
505
+ // ["public-instance-get", "public-instance-set"],
506
+ // "public-constructor",
507
+ // "protected-constructor",
508
+ // "private-constructor",
509
+ // "public-static-method",
510
+ // "protected-static-method",
511
+ // "private-static-method",
512
+ // "public-instance-method",
513
+ // "protected-instance-method",
514
+ // "private-instance-method"
515
+ // ]
516
+ // }],
517
+ // "@typescript-eslint/method-signature-style": ["error", "method"],
518
+ // "@typescript-eslint/naming-convention": ["error", {
519
+ // selector: "memberLike",
520
+ // modifiers: ["private"],
521
+ // format: ["camelCase"],
522
+ // leadingUnderscore: "require"
523
+ // }],
524
+ // "@typescript-eslint/no-confusing-non-null-assertion": "error",
525
+ // "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
526
+ // "no-dupe-class-members": "off",
527
+ // "@typescript-eslint/no-dupe-class-members": "error",
528
+ // "@typescript-eslint/no-duplicate-enum-values": "error",
529
+ // "no-duplicate-imports": "error",
530
+ // "no-empty-function": "off",
531
+ // "@typescript-eslint/no-empty-function": ["error", { allow: ["private-constructors"] }],
532
+ // "@typescript-eslint/no-explicit-any": "off",
533
+ // "@typescript-eslint/no-extra-non-null-assertion": "error",
534
+ // "no-extra-parens": "off",
535
+ // "@typescript-eslint/no-extra-parens": ["error", "all", { nestedBinaryExpressions: false }],
536
+ // "no-extra-semi": "off",
537
+ // "@typescript-eslint/no-extra-semi": "error",
538
+ // "@typescript-eslint/no-floating-promises": "error",
539
+ // "@typescript-eslint/no-for-in-array": "error",
540
+ // "no-implied-eval": "off",
541
+ // "@typescript-eslint/no-implied-eval": "error",
542
+ // "no-invalid-this": "off",
543
+ // "@typescript-eslint/no-invalid-this": "error",
544
+ // "@typescript-eslint/no-invalid-void-type": "error",
545
+ // "no-loop-func": "off",
546
+ // "@typescript-eslint/no-loop-func": "error",
547
+ // "no-loss-of-precision": "off",
548
+ // "@typescript-eslint/no-loss-of-precision": "error",
549
+ // "@typescript-eslint/no-meaningless-void-operator": "error",
550
+ // "@typescript-eslint/no-misused-new": "error",
551
+ // "@typescript-eslint/no-misused-promises": "error",
552
+ // "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
553
+ // "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
554
+ // "@typescript-eslint/no-non-null-assertion": "off",
555
+ // "no-redeclare": "off",
556
+ // "@typescript-eslint/no-redeclare": "error",
557
+ // "@typescript-eslint/no-this-alias": "error",
558
+ // "@typescript-eslint/no-throw-literal": "error",
559
+ // "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
560
+ // "@typescript-eslint/no-unnecessary-type-assertion": "error",
561
+ // "@typescript-eslint/no-unnecessary-type-constraint": "error",
562
+ // "@typescript-eslint/no-unsafe-call": "error",
563
+ // "@typescript-eslint/no-unsafe-return": "error",
564
+ // "no-unused-expressions": "off",
565
+ // "@typescript-eslint/no-unused-expressions": "error",
566
+ // "no-unused-vars": "off",
567
+ // "@typescript-eslint/no-unused-vars": "off",
568
+ // "no-use-before-define": "off",
569
+ // "@typescript-eslint/no-use-before-define": "off",
570
+ // "no-useless-constructor": "off",
571
+ // "@typescript-eslint/no-useless-constructor": "error",
572
+ // "@typescript-eslint/no-useless-empty-export": "error",
573
+ // "@typescript-eslint/no-var-requires": "off",
574
+ // "@typescript-eslint/parameter-properties": "error",
575
+ // "@typescript-eslint/prefer-enum-initializers": "error",
576
+ // "@typescript-eslint/prefer-includes": "error",
577
+ // "@typescript-eslint/prefer-literal-enum-member": "error",
578
+ // "@typescript-eslint/prefer-readonly": "error",
579
+ // "@typescript-eslint/prefer-reduce-type-parameter": "error",
580
+ // "@typescript-eslint/prefer-string-starts-ends-with": "error",
581
+ // "@typescript-eslint/prefer-ts-expect-error": "error",
582
+ // "@typescript-eslint/require-array-sort-compare": "error",
583
+ // "no-return-await": "off",
584
+ // "@typescript-eslint/return-await": "error",
585
+ // "semi": "off",
586
+ // "@typescript-eslint/semi": "error",
587
+ // "@typescript-eslint/unbound-method": "error"
588
+ // }
589
+ // }
590
+ // ];
591
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivinjoseph/n-sec",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Security library",
5
5
  "packageManager": "yarn@4.0.2",
6
6
  "type": "module",
@@ -12,8 +12,8 @@
12
12
  "ts-lint": "eslint . --ext .ts",
13
13
  "ts-build": "yarn ts-compile && yarn ts-lint",
14
14
  "ts-build-dist": "yarn ts-build && tsc -p ./dist",
15
- "test": "yarn ts-build && node --test --enable-source-maps ./test",
16
- "publish-package": "yarn ts-build-dist && git add . && git commit -m 'preparing to publish new version' && npm version patch && git push && npm publish --access=public"
15
+ "test": "yarn ts-build && node --test --enable-source-maps ./test/**/*.test.js",
16
+ "publish-package": "yarn ts-build-dist && git add . && git commit -m 'preparing to publish new version' && git push && npm publish --access=public"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -30,21 +30,22 @@
30
30
  },
31
31
  "homepage": "https://github.com/nivinjoseph/n-sec#readme",
32
32
  "devDependencies": {
33
- "@types/node": "^20.10",
34
- "@typescript-eslint/eslint-plugin": "^6.15.0",
35
- "@typescript-eslint/parser": "^6.15.0",
36
- "eslint": "^8.56.0",
37
- "eslint-plugin-require-extensions": "^0.1.3",
38
- "typescript": "^5.3.3"
33
+ "@eslint/js": "^9.39.1",
34
+ "@stylistic/eslint-plugin": "^5.5.0",
35
+ "@types/node": "^24.10",
36
+ "eslint": "^9.39.1",
37
+ "eslint-import-resolver-typescript": "^4.4.4",
38
+ "eslint-plugin-import": "^2.32.0",
39
+ "typescript": "^5.9.3",
40
+ "typescript-eslint": "^8.46.3"
39
41
  },
40
42
  "dependencies": {
41
- "@nivinjoseph/n-defensive": "^2.0.1",
42
- "@nivinjoseph/n-exception": "^2.0.1",
43
- "@nivinjoseph/n-ext": "^2.0.1",
44
- "@nivinjoseph/n-util": "^2.0.1"
43
+ "@nivinjoseph/n-defensive": "^2.0.2",
44
+ "@nivinjoseph/n-exception": "^2.0.2",
45
+ "@nivinjoseph/n-ext": "^2.0.2",
46
+ "@nivinjoseph/n-util": "^3.2.0"
45
47
  },
46
- "engineStrict": true,
47
48
  "engines": {
48
- "node": ">=20.10"
49
+ "node": ">=24.10"
49
50
  }
50
51
  }
package/src/bin.ts CHANGED
@@ -17,6 +17,7 @@ async function executeCommand(command: SupportedCommands): Promise<void>
17
17
 
18
18
  switch (command)
19
19
  {
20
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
21
  case SupportedCommands.generateSymmetricKey:
21
22
  {
22
23
  const key = await SymmetricEncryption.generateKey();
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- dist
package/.eslintrc DELETED
@@ -1,344 +0,0 @@
1
- {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "plugins": [
5
- "@typescript-eslint",
6
- "require-extensions"
7
- ],
8
- "extends": [
9
- "eslint:recommended",
10
- "plugin:@typescript-eslint/eslint-recommended",
11
- "plugin:@typescript-eslint/recommended",
12
- "plugin:require-extensions/recommended"
13
- ],
14
- "parserOptions": {
15
- "project": "tsconfig.json"
16
- },
17
- "rules": {
18
- "quotes": "off",
19
- "@typescript-eslint/quotes": [
20
- "error",
21
- "double",
22
- {
23
- "allowTemplateLiterals": true
24
- }
25
- ],
26
- "no-eval": "error",
27
- "no-void": "error",
28
- "no-with": "error",
29
- "@typescript-eslint/adjacent-overload-signatures": "error",
30
- "@typescript-eslint/array-type": [
31
- "error",
32
- {
33
- "default": "generic",
34
- "readonly": "generic"
35
- }
36
- ],
37
- "@typescript-eslint/await-thenable": "error",
38
- "@typescript-eslint/ban-ts-comment": [
39
- "error",
40
- {
41
- "ts-expect-error": "allow-with-description",
42
- "ts-ignore": "allow-with-description",
43
- "ts-nocheck": true,
44
- "ts-check": true
45
- }
46
- ],
47
- "@typescript-eslint/ban-tslint-comment": "error",
48
- "@typescript-eslint/ban-types": [
49
- "error",
50
- {
51
- "extendDefaults": false,
52
- "types": {
53
- "String": {
54
- "message": "Use string instead",
55
- "fixWith": "string"
56
- },
57
- "Boolean": {
58
- "message": "Use boolean instead",
59
- "fixWith": "boolean"
60
- },
61
- "Number": {
62
- "message": "Use number instead",
63
- "fixWith": "number"
64
- },
65
- "Symbol": {
66
- "message": "Use symbol instead",
67
- "fixWith": "symbol"
68
- }
69
- }
70
- }
71
- ],
72
- "brace-style": "off",
73
- "@typescript-eslint/brace-style": [
74
- "error",
75
- "allman",
76
- {
77
- "allowSingleLine": true
78
- }
79
- ],
80
- "@typescript-eslint/class-literal-property-style": [
81
- "off",
82
- "getters"
83
- ],
84
- "comma-dangle": "off",
85
- "@typescript-eslint/comma-dangle": [
86
- "error",
87
- "never"
88
- ],
89
- "default-param-last": "off",
90
- "@typescript-eslint/default-param-last": "error",
91
- "@typescript-eslint/explicit-function-return-type": "error",
92
- "@typescript-eslint/explicit-member-accessibility": "error",
93
- "@typescript-eslint/explicit-module-boundary-types": "error",
94
- "func-call-spacing": "off",
95
- "@typescript-eslint/func-call-spacing": [
96
- "error",
97
- "never"
98
- ],
99
- "@typescript-eslint/member-delimiter-style": [
100
- "error",
101
- {
102
- "multiline": {
103
- "delimiter": "semi",
104
- "requireLast": true
105
- },
106
- "singleline": {
107
- "delimiter": "semi",
108
- "requireLast": true
109
- },
110
- "multilineDetection": "brackets"
111
- }
112
- ],
113
- "@typescript-eslint/member-ordering": [
114
- "error",
115
- {
116
- "default": [
117
- // Index signature
118
- "signature",
119
- // Fields
120
- "private-static-field",
121
- "protected-static-field",
122
- "public-static-field",
123
- // "private-decorated-field",
124
- // "protected-decorated-field",
125
- // "public-decorated-field",
126
- "private-instance-field",
127
- "protected-instance-field",
128
- "public-instance-field",
129
- // "public-abstract-field",
130
- // "protected-abstract-field",
131
- // "private-abstract-field",
132
- // "private-field",
133
- // "protected-field",
134
- // "public-field",
135
- // "static-field",
136
- // "instance-field",
137
- // "abstract-field",
138
- // "decorated-field",
139
- // "field",
140
- // Getters
141
- // "public-static-get",
142
- // "protected-static-get",
143
- // "private-static-get",
144
- // "public-decorated-get",
145
- // "protected-decorated-get",
146
- // "private-decorated-get",
147
- // "public-instance-get",
148
- // "protected-instance-get",
149
- // "private-instance-get",
150
- // "public-abstract-get",
151
- // "protected-abstract-get",
152
- // "private-abstract-get",
153
- // "public-get",
154
- // "protected-get",
155
- // "private-get",
156
- // "static-get",
157
- // "instance-get",
158
- // "abstract-get",
159
- // "decorated-get",
160
- // "get",
161
- // Setters
162
- // "public-static-set",
163
- // "protected-static-set",
164
- // "private-static-set",
165
- // "public-decorated-set",
166
- // "protected-decorated-set",
167
- // "private-decorated-set",
168
- // "public-instance-set",
169
- // "protected-instance-set",
170
- // "private-instance-set",
171
- // "public-abstract-set",
172
- // "protected-abstract-set",
173
- // "private-abstract-set",
174
- // "public-set",
175
- // "protected-set",
176
- // "private-set",
177
- // "static-set",
178
- // "instance-set",
179
- // "abstract-set",
180
- // "decorated-set",
181
- // "set",
182
- // [
183
- // "get",
184
- // "set"
185
- // ],
186
- [
187
- "private-static-get",
188
- "private-static-set"
189
- ],
190
- [
191
- "protected-static-get",
192
- "protected-static-set"
193
- ],
194
- [
195
- "public-static-get",
196
- "public-static-set"
197
- ],
198
- [
199
- "private-instance-get",
200
- "private-instance-set"
201
- ],
202
- [
203
- "protected-instance-get",
204
- "protected-instance-set"
205
- ],
206
- [
207
- "public-instance-get",
208
- "public-instance-set"
209
- ],
210
- // Constructors
211
- "public-constructor",
212
- "protected-constructor",
213
- "private-constructor",
214
- // "constructor",
215
- // Methods
216
- "public-static-method",
217
- "protected-static-method",
218
- "private-static-method",
219
- // "public-decorated-method",
220
- // "protected-decorated-method",
221
- // "private-decorated-method",
222
- "public-instance-method",
223
- "protected-instance-method",
224
- "private-instance-method",
225
- // "public-abstract-method",
226
- // "protected-abstract-method",
227
- // "private-abstract-method",
228
- // "public-method",
229
- // "protected-method",
230
- // "private-method",
231
- // "static-method",
232
- // "instance-method",
233
- // "abstract-method",
234
- // "decorated-method",
235
- // "method"
236
- ]
237
- }
238
- ],
239
- "@typescript-eslint/method-signature-style": [
240
- "error",
241
- "method"
242
- ],
243
- "@typescript-eslint/naming-convention": [
244
- "error",
245
- {
246
- "selector": "memberLike",
247
- "modifiers": [
248
- "private"
249
- ],
250
- "format": [
251
- "camelCase"
252
- ],
253
- "leadingUnderscore": "require"
254
- }
255
- ],
256
- "@typescript-eslint/no-confusing-non-null-assertion": "error",
257
- "@typescript-eslint/no-confusing-void-expression": [
258
- "error",
259
- {
260
- "ignoreArrowShorthand": true
261
- }
262
- ],
263
- "no-dupe-class-members": "off",
264
- "@typescript-eslint/no-dupe-class-members": "error",
265
- "@typescript-eslint/no-duplicate-enum-values": "error",
266
- "no-duplicate-imports": "error",
267
- "no-empty-function": "off",
268
- "@typescript-eslint/no-empty-function": [
269
- "error",
270
- {
271
- "allow": [
272
- "private-constructors"
273
- ]
274
- }
275
- ],
276
- "@typescript-eslint/no-explicit-any": "off",
277
- "@typescript-eslint/no-extra-non-null-assertion": "error",
278
- "no-extra-parens": "off",
279
- "@typescript-eslint/no-extra-parens": [
280
- "error",
281
- "all",
282
- {
283
- "nestedBinaryExpressions": false
284
- }
285
- ],
286
- "no-extra-semi": "off",
287
- "@typescript-eslint/no-extra-semi": "error",
288
- "@typescript-eslint/no-floating-promises": "error",
289
- "@typescript-eslint/no-for-in-array": "error",
290
- "no-implied-eval": "off",
291
- "@typescript-eslint/no-implied-eval": "error",
292
- "no-invalid-this": "off",
293
- "@typescript-eslint/no-invalid-this": "error",
294
- "@typescript-eslint/no-invalid-void-type": "error",
295
- "no-loop-func": "off",
296
- "@typescript-eslint/no-loop-func": "error",
297
- "no-loss-of-precision": "off",
298
- "@typescript-eslint/no-loss-of-precision": "error",
299
- "@typescript-eslint/no-meaningless-void-operator": "error",
300
- "@typescript-eslint/no-misused-new": "error",
301
- "@typescript-eslint/no-misused-promises": "error",
302
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
303
- "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
304
- "@typescript-eslint/no-non-null-assertion": "off",
305
- "no-redeclare": "off",
306
- "@typescript-eslint/no-redeclare": "error",
307
- "@typescript-eslint/no-this-alias": "error",
308
- "@typescript-eslint/no-throw-literal": "error",
309
- "@typescript-eslint/no-unnecessary-condition": [
310
- "error",
311
- {
312
- "allowConstantLoopConditions": true
313
- }
314
- ],
315
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
316
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
317
- "@typescript-eslint/no-unsafe-call": "error",
318
- "@typescript-eslint/no-unsafe-return": "error",
319
- "no-unused-expressions": "off",
320
- "@typescript-eslint/no-unused-expressions": "error",
321
- "no-unused-vars": "off",
322
- "@typescript-eslint/no-unused-vars": "off",
323
- "no-use-before-define": "off",
324
- "@typescript-eslint/no-use-before-define": "off",
325
- "no-useless-constructor": "off",
326
- "@typescript-eslint/no-useless-constructor": "error",
327
- "@typescript-eslint/no-useless-empty-export": "error",
328
- "@typescript-eslint/no-var-requires": "off",
329
- "@typescript-eslint/parameter-properties": "error",
330
- "@typescript-eslint/prefer-enum-initializers": "error",
331
- "@typescript-eslint/prefer-includes": "error",
332
- "@typescript-eslint/prefer-literal-enum-member": "error",
333
- "@typescript-eslint/prefer-readonly": "error",
334
- "@typescript-eslint/prefer-reduce-type-parameter": "error",
335
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
336
- "@typescript-eslint/prefer-ts-expect-error": "error",
337
- "@typescript-eslint/require-array-sort-compare": "error",
338
- "no-return-await": "off",
339
- "@typescript-eslint/return-await": "error",
340
- "semi": "off",
341
- "@typescript-eslint/semi": "error",
342
- "@typescript-eslint/unbound-method": "error"
343
- }
344
- }