cortex-auth 0.0.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.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @cortex-shared/auth
2
+
3
+ Shared authentication utilities for Node.js and Next.js applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @cortex-shared/auth
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - JWT token generation and verification
14
+ - Password hashing and verification
15
+ - Email and password validation
16
+ - Password strength checker
17
+
18
+ ## Usage
19
+
20
+ ### JWT Utilities
21
+
22
+ ```typescript
23
+ import { generateToken, verifyToken } from '@cortex-shared/auth';
24
+
25
+ const secret = 'your-secret-key';
26
+ const payload = { id: '123', email: 'user@example.com' };
27
+
28
+ // Generate token
29
+ const token = generateToken(payload, secret);
30
+
31
+ // Verify token
32
+ const decoded = verifyToken(token, secret);
33
+ ```
34
+
35
+ ### Password Utilities
36
+
37
+ ```typescript
38
+ import { hashPassword, verifyPassword } from '@cortex-shared/auth';
39
+
40
+ // Hash password
41
+ const hash = await hashPassword('myPassword123!');
42
+
43
+ // Verify password
44
+ const isMatch = await verifyPassword('myPassword123!', hash);
45
+ ```
46
+
47
+ ### Validation Utilities
48
+
49
+ ```typescript
50
+ import {
51
+ isValidEmail,
52
+ isStrongPassword,
53
+ getPasswordStrengthFeedback,
54
+ sanitizeEmail,
55
+ } from '@cortex-shared/auth';
56
+
57
+ // Validate email
58
+ if (isValidEmail('user@example.com')) {
59
+ const sanitized = sanitizeEmail(' User@Example.com ');
60
+ // 'user@example.com'
61
+ }
62
+
63
+ // Check password strength
64
+ if (isStrongPassword('MyPassword123!')) {
65
+ const feedback = getPasswordStrengthFeedback('weak');
66
+ // { score: 1, feedback: [...] }
67
+ }
68
+ ```
69
+
70
+ ## Development
71
+
72
+ ```bash
73
+ pnpm dev # Watch mode
74
+ pnpm build # Build
75
+ pnpm lint # Lint
76
+ pnpm type-check # Type check
77
+ ```
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "cortex-auth",
3
+ "version": "0.0.1",
4
+ "description": "Shared authentication utilities for Node.js and Next.js applications",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": ["dist"],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/cortex-reply/shared-components.git",
12
+ "directory": "packages/auth"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
18
+ "scripts": {
19
+ "dev": "tsc --watch",
20
+ "build": "tsc",
21
+ "type-check": "tsc --noEmit",
22
+ "lint": "eslint src/**/*.ts"
23
+ },
24
+ "keywords": [
25
+ "authentication",
26
+ "jwt",
27
+ "password",
28
+ "security"
29
+ ],
30
+ "author": "Cortex Reply",
31
+ "license": "MIT",
32
+ "dependencies": {
33
+ "jsonwebtoken": "^9.0.3",
34
+ "bcryptjs": "^2.4.3"
35
+ },
36
+ "devDependencies": {
37
+ "@types/jsonwebtoken": "^9.0.7",
38
+ "@types/bcryptjs": "^2.4.6",
39
+ "@types/node": "^20.10.5",
40
+ "@typescript-eslint/eslint-plugin": "^6.15.0",
41
+ "@typescript-eslint/parser": "^6.15.0",
42
+ "eslint": "^8.56.0",
43
+ "typescript": "^5.3.3"
44
+ }
45
+ }