@carecard/jwt-read 3.1.14 → 3.1.15
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/.agents/config.toml +2 -0
- package/.agents/skills/carecard-workspace-standards/SKILL.md +388 -0
- package/.agents/skills/carecard-workspace-standards/agents/openai.yaml +4 -0
- package/.agents/skills/github-pr-create-update/SKILL.md +188 -0
- package/.agents/skills/github-pr-create-update/agents/openai.yaml +5 -0
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +175 -0
- package/.agents/skills/github-pr-merge-cleanup/agents/openai.yaml +5 -0
- package/.agents/skills/pkg-jwt-read-jwt-middleware-library/SKILL.md +239 -0
- package/.agents/skills/pkg-jwt-read-jwt-middleware-library/agents/openai.yaml +4 -0
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +73 -0
- package/.codex/config.toml +2 -0
- package/index.d.ts +22 -1
- package/index.js +2 -0
- package/lib/jwtLib.js +74 -0
- package/package.json +8 -8
- package/readme.md +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/jwt-read",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.15",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/CareCard-ca/pkg-jwt-read.git"
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/express": "5.0.6",
|
|
32
32
|
"@types/mocha": "10.0.10",
|
|
33
|
-
"@types/node": "25.
|
|
33
|
+
"@types/node": "25.9.1",
|
|
34
34
|
"eslint": "9.39.4",
|
|
35
35
|
"husky": "9.1.7",
|
|
36
|
-
"lint-staged": "17.0.
|
|
37
|
-
"mocha": "11.7.
|
|
36
|
+
"lint-staged": "17.0.5",
|
|
37
|
+
"mocha": "11.7.6",
|
|
38
38
|
"nyc": "18.0.0",
|
|
39
39
|
"prettier": "3.8.3",
|
|
40
40
|
"ts-node": "10.9.2",
|
|
41
|
-
"typescript": "
|
|
41
|
+
"typescript": "6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@carecard/common-util": "3.1.
|
|
45
|
-
"@carecard/auth-util": "3.1.
|
|
46
|
-
"@carecard/validate": "3.1.
|
|
44
|
+
"@carecard/common-util": "3.1.15",
|
|
45
|
+
"@carecard/auth-util": "3.1.15",
|
|
46
|
+
"@carecard/validate": "3.1.24"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/readme.md
CHANGED
|
@@ -12,6 +12,7 @@ Utility package for reading, parsing, and verifying JWTs in the CareCard ecosyst
|
|
|
12
12
|
- **Role Mapping**: Simple utility for translating internal role codes to human-readable names.
|
|
13
13
|
- **Claims Extraction**: Easy extraction of `sub` (clientId) and other JWT payload claims.
|
|
14
14
|
- **Expiration Management**: Helpers to check if a JWT is expired and calculate its remaining TTL.
|
|
15
|
+
- **Service JWTs**: Helpers for verifying and extracting microservice-to-microservice JWTs with standard `iss`, `sub`, `aud`, `iat`, and `exp` claims.
|
|
15
16
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
@@ -59,6 +60,34 @@ console.log(getNameOfRole('ad')); // Result: 'admin'
|
|
|
59
60
|
console.log(getCodeOfRole('super_admin')); // Result: 'su'
|
|
60
61
|
```
|
|
61
62
|
|
|
63
|
+
### Service-To-Service JWTs
|
|
64
|
+
|
|
65
|
+
Use service JWT verification helpers for backend service calls. The sending
|
|
66
|
+
service signs the token with `@carecard/auth-util`. The receiving service uses
|
|
67
|
+
this package to verify the token with the sending service public key and check
|
|
68
|
+
the expected issuer and audience.
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
const { jwtCreateServiceAuthorizationHeader } = require('@carecard/auth-util');
|
|
72
|
+
const { jwtVerifyService } = require('@carecard/jwt-read');
|
|
73
|
+
|
|
74
|
+
const authorization = jwtCreateServiceAuthorizationHeader({
|
|
75
|
+
issuer: 'ms-institutions',
|
|
76
|
+
audience: 'ms-auth',
|
|
77
|
+
privateKey: institutionsPrivateKey,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
app.use(jwtVerifyService(institutionsPublicKey, 'ms-institutions', 'ms-auth', throwNotAuthorizedError));
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Service JWT payloads follow standard JWT semantics:
|
|
84
|
+
|
|
85
|
+
- `iss`: sending service
|
|
86
|
+
- `sub`: sending service identity
|
|
87
|
+
- `aud`: receiving service
|
|
88
|
+
- `iat`: issued-at NumericDate
|
|
89
|
+
- `exp`: expiration NumericDate
|
|
90
|
+
|
|
62
91
|
## Testing
|
|
63
92
|
|
|
64
93
|
Run tests using:
|