@carecard/jwt-read 3.10.0 → 3.12.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 +20 -3
- package/.agents/skills/github-pr-create-update/SKILL.md +17 -7
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +40 -10
- package/.agents/skills/pkg-jwt-read-jwt-middleware-library/SKILL.md +4 -0
- package/.agents/skills/pkg-publish/SKILL.md +4 -0
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +4 -0
- package/lib/jwtLib.js +18 -24
- package/package.json +4 -4
- package/readme.md +4 -0
|
@@ -3,12 +3,29 @@ name: carecard-workspace-standards
|
|
|
3
3
|
description: 'Follow the shared SO_CareCardCa/CareCard workspace coding, testing, repository, dependency, shared package, frontend, database, API response, and security standards. Use before modifying, testing, reviewing, or debugging any ms-*, pkg-*, app-*, website, dashboard, or other CareCard repository in this workspace, especially when choosing validation commands, package boundaries, TypeScript types, dependencies, API contracts, database logic, service patterns, or frontend architecture.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# CareCard Workspace Standards
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
12
|
+
This requirement is non-negotiable and may be overridden only with the user's
|
|
13
|
+
explicit, direct approval.
|
|
14
|
+
|
|
15
|
+
A pre-existing test—defined as any test present before work on the current task
|
|
16
|
+
begins—must not be deleted, disabled, skipped, weakened, excluded from execution,
|
|
17
|
+
or otherwise removed. A pre-existing test must not be modified without the
|
|
18
|
+
user's explicit approval for the exact proposed change. If changing a
|
|
19
|
+
pre-existing test is believed necessary, stop before making the change and
|
|
20
|
+
request approval. The request must identify every affected test, describe the
|
|
21
|
+
precise proposed modification, provide detailed technical justification, and
|
|
22
|
+
explain all known or reasonably foreseeable regression risks. Until approval is
|
|
23
|
+
granted, leave every pre-existing test unchanged.
|
|
24
|
+
|
|
10
25
|
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
26
|
|
|
27
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
28
|
+
|
|
12
29
|
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.
|
|
13
30
|
|
|
14
31
|
## Purpose
|
|
@@ -85,7 +102,7 @@ config.
|
|
|
85
102
|
- Never suppress errors, TypeScript errors, linter warnings, authorization
|
|
86
103
|
failures, RLS failures, build failures, hydration issues, or failing tests.
|
|
87
104
|
Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or
|
|
88
|
-
similar suppression
|
|
105
|
+
similar suppression. Fix the root cause.
|
|
89
106
|
- Do not add dependencies unless clearly necessary. If one might be needed, ask
|
|
90
107
|
first with the reason, tradeoff, and why existing code cannot solve it.
|
|
91
108
|
- Before finalizing repository work, run the affected repository's relevant
|
|
@@ -215,7 +232,7 @@ build artifacts, logs, or `.DS_Store`.
|
|
|
215
232
|
Most JavaScript `ms-*` services use CommonJS, Mocha, Supertest, Docker Compose
|
|
216
233
|
database tests, `@carecard/*` packages, and `sub-apps`
|
|
217
234
|
controller/router/model patterns. TypeScript services such as `ms-messages`
|
|
218
|
-
|
|
235
|
+
use Jest or TypeScript tooling and should keep their
|
|
219
236
|
existing TypeScript style.
|
|
220
237
|
|
|
221
238
|
- Keep environment-specific files explicit: `.env.development`, `.env.test`,
|
|
@@ -380,7 +397,7 @@ the authenticated dashboard.
|
|
|
380
397
|
|
|
381
398
|
## Auth Service RLS Contract
|
|
382
399
|
|
|
383
|
-
- `ms-auth` follows the shared PostgreSQL/RLS pattern
|
|
400
|
+
- `ms-auth` follows the shared PostgreSQL/RLS pattern: auth tables live in the `carecard` schema, RLS is enabled and forced on every auth table, and application runtime queries use the unprivileged database role.
|
|
384
401
|
- Auth table policies allow normal JWT or server-auth users to access only
|
|
385
402
|
self-owned rows. Do not add redundant `user_id = <jwt sub>` SQL predicates to
|
|
386
403
|
duplicate self-row checks when RLS owns the authorization decision.
|
|
@@ -3,12 +3,16 @@ name: github-pr-create-update
|
|
|
3
3
|
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating or updating a PR, or marking a PR ready from the current repository branch into development or main.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# Pull Request Create
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
10
12
|
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
13
|
|
|
14
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
15
|
+
|
|
12
16
|
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.
|
|
13
17
|
|
|
14
18
|
## Purpose
|
|
@@ -77,14 +81,20 @@ Do not continue automatically when:
|
|
|
77
81
|
when `origin/development` is absent:
|
|
78
82
|
|
|
79
83
|
```sh
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
base
|
|
84
|
-
|
|
85
|
-
echo "No origin/development or origin/main branch exists."
|
|
86
|
-
exit 1
|
|
84
|
+
remote_base_refs="$(git ls-remote --heads origin development main)"
|
|
85
|
+
remote_query_status=$?
|
|
86
|
+
if [ "$remote_query_status" -ne 0 ]; then
|
|
87
|
+
printf 'Unable to inspect origin base branches (exit %s).\n' "$remote_query_status" >&2
|
|
88
|
+
exit "$remote_query_status"
|
|
87
89
|
fi
|
|
90
|
+
case "$remote_base_refs" in
|
|
91
|
+
*"refs/heads/development") base="development" ;;
|
|
92
|
+
*"refs/heads/main") base="main" ;;
|
|
93
|
+
*)
|
|
94
|
+
printf '%s\n' "No origin/development or origin/main branch exists." >&2
|
|
95
|
+
exit 1
|
|
96
|
+
;;
|
|
97
|
+
esac
|
|
88
98
|
git fetch origin "$base" --prune
|
|
89
99
|
```
|
|
90
100
|
|
|
@@ -3,12 +3,16 @@ name: github-pr-merge-cleanup
|
|
|
3
3
|
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating a missing PR, reviewing mergeability, validating, merging, deleting, or cleaning up a pull request branch.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# Pull Request Merge Close
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
10
12
|
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
13
|
|
|
14
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
15
|
+
|
|
12
16
|
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.
|
|
13
17
|
|
|
14
18
|
## Purpose
|
|
@@ -74,14 +78,20 @@ completion.
|
|
|
74
78
|
|
|
75
79
|
```sh
|
|
76
80
|
gh auth status
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
base
|
|
81
|
-
|
|
82
|
-
echo "No origin/development or origin/main branch exists."
|
|
83
|
-
exit 1
|
|
81
|
+
remote_base_refs="$(git ls-remote --heads origin development main)"
|
|
82
|
+
remote_query_status=$?
|
|
83
|
+
if [ "$remote_query_status" -ne 0 ]; then
|
|
84
|
+
printf 'Unable to inspect origin base branches (exit %s).\n' "$remote_query_status" >&2
|
|
85
|
+
exit "$remote_query_status"
|
|
84
86
|
fi
|
|
87
|
+
case "$remote_base_refs" in
|
|
88
|
+
*"refs/heads/development") base="development" ;;
|
|
89
|
+
*"refs/heads/main") base="main" ;;
|
|
90
|
+
*)
|
|
91
|
+
printf '%s\n' "No origin/development or origin/main branch exists." >&2
|
|
92
|
+
exit 1
|
|
93
|
+
;;
|
|
94
|
+
esac
|
|
85
95
|
target_branch="$(git branch --show-current)"
|
|
86
96
|
test -n "$target_branch"
|
|
87
97
|
test "$target_branch" != "$base"
|
|
@@ -171,7 +181,19 @@ completion.
|
|
|
171
181
|
not protected:
|
|
172
182
|
|
|
173
183
|
```sh
|
|
174
|
-
protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected'
|
|
184
|
+
protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected')"
|
|
185
|
+
protection_query_status=$?
|
|
186
|
+
if [ "$protection_query_status" -ne 0 ]; then
|
|
187
|
+
printf 'Unable to inspect branch protection (exit %s).\n' "$protection_query_status" >&2
|
|
188
|
+
exit "$protection_query_status"
|
|
189
|
+
fi
|
|
190
|
+
case "$protected" in
|
|
191
|
+
true|false) ;;
|
|
192
|
+
*)
|
|
193
|
+
printf 'Unexpected branch protection value: %s\n' "$protected" >&2
|
|
194
|
+
exit 1
|
|
195
|
+
;;
|
|
196
|
+
esac
|
|
175
197
|
if [ "$protected" = true ]; then
|
|
176
198
|
gh pr merge "$pr_number" --squash --admin
|
|
177
199
|
else
|
|
@@ -183,8 +205,16 @@ completion.
|
|
|
183
205
|
delete it explicitly:
|
|
184
206
|
|
|
185
207
|
```sh
|
|
186
|
-
if [ "$protected" != true ]
|
|
187
|
-
git
|
|
208
|
+
if [ "$protected" != true ]; then
|
|
209
|
+
remote_target_ref="$(git ls-remote --heads origin "$target_branch")"
|
|
210
|
+
remote_query_status=$?
|
|
211
|
+
if [ "$remote_query_status" -ne 0 ]; then
|
|
212
|
+
printf 'Unable to inspect the remote target branch (exit %s).\n' "$remote_query_status" >&2
|
|
213
|
+
exit "$remote_query_status"
|
|
214
|
+
fi
|
|
215
|
+
if [ -n "$remote_target_ref" ]; then
|
|
216
|
+
git push origin --delete "$target_branch"
|
|
217
|
+
fi
|
|
188
218
|
fi
|
|
189
219
|
```
|
|
190
220
|
|
|
@@ -3,12 +3,16 @@ name: pkg-jwt-read-jwt-middleware-library
|
|
|
3
3
|
description: 'Use when changing pkg-jwt-read JWT parsing, middleware, visitor tokens, role checks, auth context, package exports, or tests.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# Package JWT Read
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
10
12
|
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
13
|
|
|
14
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
15
|
+
|
|
12
16
|
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.
|
|
13
17
|
|
|
14
18
|
## Purpose
|
|
@@ -3,12 +3,16 @@ name: pkg-publish
|
|
|
3
3
|
description: 'Use when any pkg-* repository has non-Markdown package changes, including source code, public types, tests, scripts, package metadata, lockfiles, dependency behavior, or validation config, and the CareCard packages must be versioned, published in order with just-in-time package pushes, and propagated to pkg-*, ms-*, and app-dashboard consumers. Do not use for Markdown-only changes.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# pkg Publish
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
10
12
|
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
13
|
|
|
14
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
15
|
+
|
|
12
16
|
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.
|
|
13
17
|
|
|
14
18
|
## Trigger
|
|
@@ -3,12 +3,16 @@ name: software-design-patterns-and-clean-code
|
|
|
3
3
|
description: 'Use every time before coding, refactoring, debugging, or reviewing in this repository, alongside all other applicable skills, to apply pragmatic software design patterns, SOLID, Clean Code, and testable architecture.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
7
|
+
|
|
6
8
|
# Software Design Patterns And Clean Code
|
|
7
9
|
|
|
8
10
|
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
11
|
|
|
10
12
|
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
13
|
|
|
14
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
15
|
+
|
|
12
16
|
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.
|
|
13
17
|
|
|
14
18
|
## Purpose
|
package/lib/jwtLib.js
CHANGED
|
@@ -34,7 +34,15 @@ function doesJwtUserHasRole(req, userRole) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function throwError(customErrorFunction) {
|
|
37
|
-
typeof customErrorFunction
|
|
37
|
+
if (typeof customErrorFunction !== 'function') {
|
|
38
|
+
return throwLoginRequiredError();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const customError = customErrorFunction();
|
|
42
|
+
|
|
43
|
+
if (customError instanceof Error) throw customError;
|
|
44
|
+
|
|
45
|
+
throw new Error('Custom authentication error function returned without throwing');
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
function isJwtExpired(req, jwtValiditySeconds) {
|
|
@@ -123,15 +131,11 @@ function validateAndExtractServiceJwtObject(req, publicKey, expectedIssuer, expe
|
|
|
123
131
|
if (jwtString && isJwtSignatureValid) {
|
|
124
132
|
_extractJwtObject(req, jwtString, customErrorFunction);
|
|
125
133
|
} else {
|
|
126
|
-
|
|
127
|
-
if (req) {
|
|
128
|
-
req.jwt = null;
|
|
129
|
-
}
|
|
134
|
+
req.jwt = null;
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
if (!req?.jwt || !_isServiceJwtFor(req.jwt.payload, expectedIssuer, expectedAudience)) {
|
|
133
|
-
|
|
134
|
-
if (req) req.jwt = null;
|
|
138
|
+
req.jwt = null;
|
|
135
139
|
throwError(customErrorFunction);
|
|
136
140
|
}
|
|
137
141
|
|
|
@@ -337,16 +341,14 @@ function validateAndExtractOptionalUserAuthorizationObject(req, options, customE
|
|
|
337
341
|
|
|
338
342
|
const header = readUserAuthorizationHeader(req, config);
|
|
339
343
|
if (!header.present) {
|
|
340
|
-
|
|
341
|
-
if (req) req.userAuthorization = null;
|
|
344
|
+
req.userAuthorization = null;
|
|
342
345
|
return req;
|
|
343
346
|
}
|
|
344
347
|
|
|
345
348
|
if (isUserAuthorizationTokenAllowed(header.token, config)) {
|
|
346
349
|
_extractUserAuthorizationObjectNoThrow(req, header.token);
|
|
347
350
|
} else {
|
|
348
|
-
|
|
349
|
-
if (req) req.userAuthorization = null;
|
|
351
|
+
req.userAuthorization = null;
|
|
350
352
|
throwError(customErrorFunction);
|
|
351
353
|
}
|
|
352
354
|
|
|
@@ -362,10 +364,7 @@ function validateAndExtractOptionalUserAuthorizationObjectNoThrow(req, options)
|
|
|
362
364
|
if (header.present && isUserAuthorizationTokenAllowed(header.token, config)) {
|
|
363
365
|
_extractUserAuthorizationObjectNoThrow(req, header.token);
|
|
364
366
|
} else {
|
|
365
|
-
|
|
366
|
-
if (req) {
|
|
367
|
-
req.userAuthorization = null;
|
|
368
|
-
}
|
|
367
|
+
req.userAuthorization = null;
|
|
369
368
|
}
|
|
370
369
|
|
|
371
370
|
return req;
|
|
@@ -390,8 +389,7 @@ function tryValidateAndExtractJwtObject(req, publicKey) {
|
|
|
390
389
|
|
|
391
390
|
const isJwtSignatureValid = jwtVerifySignedToken(jwtString, publicKey);
|
|
392
391
|
if (!isJwtSignatureValid) {
|
|
393
|
-
|
|
394
|
-
if (req) req.jwt = null;
|
|
392
|
+
req.jwt = null;
|
|
395
393
|
return false;
|
|
396
394
|
}
|
|
397
395
|
|
|
@@ -569,7 +567,7 @@ function getRequestHeader(req, headerName) {
|
|
|
569
567
|
function isUserAuthorizationTokenAllowed(token, config) {
|
|
570
568
|
if (!token || !config.publicKey || !jwtVerifySignedToken(token, config.publicKey)) return false;
|
|
571
569
|
|
|
572
|
-
const payload =
|
|
570
|
+
const payload = readVerifiedJwtPayload(token);
|
|
573
571
|
if (!payload) return false;
|
|
574
572
|
if (isJwtPayloadIssuedInFuture(payload)) return false;
|
|
575
573
|
if (isJwtPayloadExpired(payload)) return false;
|
|
@@ -582,12 +580,8 @@ function isUserAuthorizationTokenAllowed(token, config) {
|
|
|
582
580
|
}
|
|
583
581
|
|
|
584
582
|
// Pattern: Pure Function - decodes payload defensively after signature and shape checks.
|
|
585
|
-
function
|
|
586
|
-
|
|
587
|
-
return jwtGetHeaderPayload(token)?.payload || null;
|
|
588
|
-
} catch {
|
|
589
|
-
return null;
|
|
590
|
-
}
|
|
583
|
+
function readVerifiedJwtPayload(token) {
|
|
584
|
+
return jwtGetHeaderPayload(token)?.payload || null;
|
|
591
585
|
}
|
|
592
586
|
|
|
593
587
|
// Pattern: Pure Function - supports either one expected audience or a small allowed set.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/jwt-read",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.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.12.0",
|
|
45
|
+
"@carecard/common-util": "3.12.0",
|
|
46
|
+
"@carecard/validate": "3.12.0"
|
|
47
47
|
},
|
|
48
48
|
"overrides": {
|
|
49
49
|
"diff": "8.0.4",
|
package/readme.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @carecard/jwt-read
|
|
2
2
|
|
|
3
|
+
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
4
|
+
|
|
3
5
|

|
|
4
6
|

|
|
5
7
|
|
|
@@ -14,6 +16,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
|
|
|
14
16
|
|
|
15
17
|
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
18
|
|
|
19
|
+
Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
|
|
20
|
+
|
|
17
21
|
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.
|
|
18
22
|
|
|
19
23
|
## Features
|