@carecard/jwt-read 3.8.0 → 3.10.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/.agents/skills/carecard-workspace-standards/SKILL.md +4 -2
- package/.agents/skills/github-pr-create-update/SKILL.md +2 -0
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +2 -0
- package/.agents/skills/pkg-jwt-read-jwt-middleware-library/SKILL.md +5 -0
- package/.agents/skills/pkg-publish/SKILL.md +2 -0
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +2 -0
- package/lib/jwtLib.js +13 -1
- package/package.json +4 -4
- package/readme.md +6 -0
|
@@ -7,6 +7,8 @@ description: 'Follow the shared SO_CareCardCa/CareCard workspace coding, testing
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Purpose
|
|
@@ -212,7 +214,7 @@ build artifacts, logs, or `.DS_Store`.
|
|
|
212
214
|
|
|
213
215
|
Most JavaScript `ms-*` services use CommonJS, Mocha, Supertest, Docker Compose
|
|
214
216
|
database tests, `@carecard/*` packages, and `sub-apps`
|
|
215
|
-
controller/router/model patterns. TypeScript services such as `ms-
|
|
217
|
+
controller/router/model patterns. TypeScript services such as `ms-messages`
|
|
216
218
|
and `ms-template-ts` use Jest or TypeScript tooling and should keep their
|
|
217
219
|
existing TypeScript style.
|
|
218
220
|
|
|
@@ -311,7 +313,7 @@ existing TypeScript style.
|
|
|
311
313
|
|
|
312
314
|
`app-dashboard` is a Next.js App Router TypeScript app using MUI, React Query,
|
|
313
315
|
`next-intl`, and shared CareCard utilities. It consumes `ms-auth`,
|
|
314
|
-
`ms-institutions`, `ms-
|
|
316
|
+
`ms-institutions`, `ms-messages`, and `ms-user-profiles` through service
|
|
315
317
|
modules.
|
|
316
318
|
|
|
317
319
|
- Keep backend URL definitions centralized in `src/services/api.routes.ts`.
|
|
@@ -7,6 +7,8 @@ description: 'Use only when the user explicitly asks for remote Git or GitHub PR
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Purpose
|
|
@@ -7,6 +7,8 @@ description: 'Use only when the user explicitly asks for remote Git or GitHub PR
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Purpose
|
|
@@ -7,6 +7,8 @@ description: 'Use when changing pkg-jwt-read JWT parsing, middleware, visitor to
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Purpose
|
|
@@ -118,6 +120,9 @@ depend on those folders being present.
|
|
|
118
120
|
- Server-auth request attachment behavior that normalizes introspected claims
|
|
119
121
|
into `req.jwt.payload` with `authMode: "server-auth"` and
|
|
120
122
|
`auth_mode: "server-auth"`.
|
|
123
|
+
- Server-auth email confirmation claims are copied only when present. The
|
|
124
|
+
`emailVerified`, `email_verified`, `emailConfirmed`, and `email_confirmed`
|
|
125
|
+
aliases retain their exact names and values, and omission remains omission.
|
|
121
126
|
- Integration with `@carecard/common-util` for standardized login and
|
|
122
127
|
authorization errors.
|
|
123
128
|
|
|
@@ -7,6 +7,8 @@ description: 'Use when any pkg-* repository has non-Markdown package changes, in
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Trigger
|
|
@@ -7,6 +7,8 @@ description: 'Use every time before coding, refactoring, debugging, or reviewing
|
|
|
7
7
|
|
|
8
8
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
9
9
|
|
|
10
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
11
|
+
|
|
10
12
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
11
13
|
|
|
12
14
|
## Purpose
|
package/lib/jwtLib.js
CHANGED
|
@@ -5,6 +5,7 @@ const { throwLoginRequiredError, throwNotAuthorizedError } = require('@carecard/
|
|
|
5
5
|
|
|
6
6
|
const DEFAULT_USER_AUTHORIZATION_HEADER_NAME = 'X-Authorization-Context';
|
|
7
7
|
const DEFAULT_USER_AUTHORIZATION_MAX_TOKEN_LENGTH = 2048;
|
|
8
|
+
const EMAIL_CONFIRMATION_CLAIM_NAMES = ['emailVerified', 'email_verified', 'emailConfirmed', 'email_confirmed'];
|
|
8
9
|
|
|
9
10
|
function jwtClientId(req) {
|
|
10
11
|
const jwtObj = req?.jwt || this;
|
|
@@ -437,11 +438,22 @@ function attachServerAuthClaims(req, claims, customErrorFunction) {
|
|
|
437
438
|
_attachJwtMethods(req.jwt);
|
|
438
439
|
}
|
|
439
440
|
|
|
441
|
+
// Pattern: Projection - copies only authoritative confirmation aliases and preserves their exact values.
|
|
442
|
+
function pickEmailConfirmationClaims(claims) {
|
|
443
|
+
return Object.fromEntries(
|
|
444
|
+
EMAIL_CONFIRMATION_CLAIM_NAMES.filter(claimName => Object.prototype.hasOwnProperty.call(claims, claimName)).map(claimName => [
|
|
445
|
+
claimName,
|
|
446
|
+
claims[claimName],
|
|
447
|
+
]),
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Pattern: Mapper - attaches server-auth metadata while preserving authoritative confirmation claims.
|
|
440
452
|
function createServerAuthPayload(claims) {
|
|
441
453
|
return {
|
|
442
454
|
sub: claims.sub || claims.userId || claims.user_id,
|
|
443
455
|
email: claims.email || '',
|
|
444
|
-
|
|
456
|
+
...pickEmailConfirmationClaims(claims),
|
|
445
457
|
roles: Array.isArray(claims.roles) ? claims.roles : [],
|
|
446
458
|
authMode: 'server-auth',
|
|
447
459
|
auth_mode: 'server-auth',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/jwt-read",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/CareCard-ca/pkg-jwt-read.git"
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"typescript": "6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@carecard/auth-util": "3.
|
|
45
|
-
"@carecard/common-util": "3.
|
|
46
|
-
"@carecard/validate": "3.
|
|
44
|
+
"@carecard/auth-util": "3.10.0",
|
|
45
|
+
"@carecard/common-util": "3.10.0",
|
|
46
|
+
"@carecard/validate": "3.10.0"
|
|
47
47
|
},
|
|
48
48
|
"overrides": {
|
|
49
49
|
"diff": "8.0.4",
|
package/readme.md
CHANGED
|
@@ -12,6 +12,8 @@ introspected by `ms-auth`.
|
|
|
12
12
|
|
|
13
13
|
Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
|
|
14
14
|
|
|
15
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
|
|
16
|
+
|
|
15
17
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
16
18
|
|
|
17
19
|
## Features
|
|
@@ -142,6 +144,10 @@ those claims onto `req.jwt.payload` with `authMode: "server-auth"` and
|
|
|
142
144
|
`auth_mode: "server-auth"` so services can keep their existing JWT-backed
|
|
143
145
|
database context and role checks.
|
|
144
146
|
|
|
147
|
+
Server-auth email confirmation claims are copied only when present. The
|
|
148
|
+
`emailVerified`, `email_verified`, `emailConfirmed`, and `email_confirmed`
|
|
149
|
+
aliases retain their exact names and values, and omission remains omission.
|
|
150
|
+
|
|
145
151
|
### Scoped User Authorization Context
|
|
146
152
|
|
|
147
153
|
Use `jwtVerifyUserAuthorization` when a route needs to verify only the compact
|