@carecard/auth-util 3.18.0 → 3.20.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 +49 -20
- package/.agents/skills/github-pr-create-update/SKILL.md +22 -1
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +22 -1
- package/.agents/skills/pkg-auth-util-auth-crypto-library/SKILL.md +40 -15
- package/.agents/skills/pkg-auth-util-coding-standards-and-best-practices/SKILL.md +42 -7
- package/.agents/skills/pkg-publish/SKILL.md +22 -1
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +23 -3
- package/.prettierrc.js +4 -2
- package/AGENTS.md +19 -0
- package/eslint.config.mjs +52 -0
- package/index.d.ts +30 -6
- package/index.js +2 -1
- package/lib/jwtUtilAuth.js +59 -13
- package/lib/pwdUtilAuth.js +50 -21
- package/lib/stringUtilAuth.js +9 -3
- package/lint-staged.config.mjs +36 -0
- package/package.json +19 -13
- package/readme.md +22 -1
- package/scripts/canonicalTestCommand.test.mjs +33 -0
- package/scripts/packageTaskRunner.audit.mjs +37 -0
- package/scripts/packageTaskRunner.test.mjs +4 -26
- package/scripts/runPackageTask.mjs +63 -16
- package/scripts/testOrder/randomizeTestOrder.cjs +15 -5
- package/scripts/testOrder/{testOrderPolicy.test.mjs → testOrderPolicy.audit.mjs} +8 -2
- package/scripts/testParallel/{parallelTestPolicy.test.mjs → parallelTestPolicy.audit.mjs} +28 -9
- package/scripts/testParallel/runIndexedMochaTests.cjs +3 -1
- package/scripts/testParallel/runIndexedMochaTests.test.mjs +8 -2
|
@@ -15,10 +15,13 @@ Non-negotiable test order invariance rule: Every test must pass independently of
|
|
|
15
15
|
|
|
16
16
|
Non-negotiable parallel test execution rule: Run independent test files in parallel with repository-native worker support wherever resource isolation makes parallel execution safe. Tests that share a mutable database, application server, browser state, filesystem fixture, port, or cluster resource must remain in an explicitly isolated serial group until every worker owns a separate resource. Parallel execution must preserve ordinary test selection and must never use randomized ordering, retries, locks, or error suppression to conceal coupling.
|
|
17
17
|
|
|
18
|
-
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,
|
|
18
|
+
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, run the relevant focused non-test
|
|
19
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
20
|
+
prose, files, or repository structure.
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
The TDD and validation requirements are non-negotiable and cannot be
|
|
23
|
+
overridden. The separate pre-existing-test protection still requires the
|
|
24
|
+
user's fresh, explicit permission for each exact proposed test modification.
|
|
22
25
|
|
|
23
26
|
A pre-existing test—defined as any test present before work on the current task
|
|
24
27
|
begins—must not be deleted, disabled, skipped, weakened, excluded from execution,
|
|
@@ -30,6 +33,11 @@ precise proposed modification, provide detailed technical justification, and
|
|
|
30
33
|
explain all known or reasonably foreseeable regression risks. Until approval is
|
|
31
34
|
granted, leave every pre-existing test unchanged.
|
|
32
35
|
|
|
36
|
+
An implementation-detail test remains invalid under the authoritative TDD and
|
|
37
|
+
validation policy. Identify the exact test and obtain the user's explicit
|
|
38
|
+
approval before rewriting or removing it. Until approval is granted, leave the
|
|
39
|
+
test unchanged and report the blocked correction.
|
|
40
|
+
|
|
33
41
|
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.
|
|
34
42
|
|
|
35
43
|
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.
|
|
@@ -70,8 +78,10 @@ Use before modifying, testing, reviewing, or debugging any CareCard workspace re
|
|
|
70
78
|
|
|
71
79
|
## Testing Expectations
|
|
72
80
|
|
|
73
|
-
- Write
|
|
74
|
-
|
|
81
|
+
- Write a new failing consumer-facing test through the supported package root
|
|
82
|
+
before behavior or public API changes. Modify a pre-existing test only after
|
|
83
|
+
the user grants fresh, explicit permission for that exact change.
|
|
84
|
+
- Include consumer-facing runtime and compilation tests through the supported package root. Exercise public behavior and realistic type usage without inspecting export objects, source files, or module layout.
|
|
75
85
|
- Run package test, lint, type, and Husky validation commands required by the changed area.
|
|
76
86
|
|
|
77
87
|
## Safety Constraints
|
|
@@ -106,9 +116,10 @@ config.
|
|
|
106
116
|
- Follow the owner's coding style, naming conventions, and project structure.
|
|
107
117
|
- Put code, tests, docs, services, validation, transforms, components, and
|
|
108
118
|
helpers where the current repository expects them.
|
|
109
|
-
- Use Test-Driven Development for behavior changes: write
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
- Use Test-Driven Development for behavior changes: write a focused
|
|
120
|
+
functional test first or, after fresh permission for the exact change,
|
|
121
|
+
update a pre-existing test. Run the selected test, confirm it fails for the
|
|
122
|
+
missing behavior, then implement.
|
|
112
123
|
- Never suppress errors, TypeScript errors, linter warnings, authorization
|
|
113
124
|
failures, RLS failures, build failures, hydration issues, or failing tests.
|
|
114
125
|
Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or
|
|
@@ -309,10 +320,11 @@ existing TypeScript style.
|
|
|
309
320
|
## Tests
|
|
310
321
|
|
|
311
322
|
- Testing is mandatory before finalizing code changes.
|
|
312
|
-
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
- Use coverage reports only as diagnostics for potentially untested observable
|
|
324
|
+
behavior. Percentages for lines, branches, functions, and statements are not
|
|
325
|
+
functional evidence and must not determine test assertions. Never add
|
|
326
|
+
implementation-detail tests to preserve a metric or lower thresholds to hide
|
|
327
|
+
a failing check; report any conflict with the behavior-only policy.
|
|
316
328
|
- Keep tests readable and domain-specific.
|
|
317
329
|
- Tests must cover desired or happy paths and prevention or rejection of
|
|
318
330
|
undesired behavior.
|
|
@@ -324,14 +336,14 @@ existing TypeScript style.
|
|
|
324
336
|
Selenium for end-to-end flows.
|
|
325
337
|
- For database tests, use existing seed, migration, rollback, and cleanup
|
|
326
338
|
patterns.
|
|
327
|
-
-
|
|
328
|
-
|
|
329
|
-
|
|
339
|
+
- Test row-level security through app-equivalent SQL operations under the
|
|
340
|
+
intended caller context. Assert returned rows, successful writes, and
|
|
341
|
+
authorization denials without calling internal RLS helpers or inspecting SQL
|
|
342
|
+
text.
|
|
330
343
|
- Add tests for API success responses, validation errors, auth/authz errors,
|
|
331
344
|
JWT errors, not-found/conflict cases, and unexpected error handling when
|
|
332
345
|
those paths change.
|
|
333
|
-
- For frontend changes, test validation,
|
|
334
|
-
components, and user-visible flows at the narrowest practical level first.
|
|
346
|
+
- For frontend changes, test rendered UI, public HTTP or network outcomes, navigation, accessibility, and user-visible flows at the narrowest practical level first. Use focused non-test dependency checks for validation, transform, query, mutation, hook, and module organization.
|
|
335
347
|
- If a test or repository check fails, fix the issue and rerun the failing
|
|
336
348
|
command. Only finalize with failing checks when the failure is unrelated or
|
|
337
349
|
blocked by environment constraints, and document that explicitly.
|
|
@@ -370,9 +382,7 @@ Dashboard service and test conventions:
|
|
|
370
382
|
- Profile, settings, notifications, institutions, and user authorization UI
|
|
371
383
|
prefer service snackbar helpers for user-friendly fallback errors, technical
|
|
372
384
|
error filtering, mutation result handling, and duplicate error suppression.
|
|
373
|
-
-
|
|
374
|
-
inert in the shell-level page test to avoid async imports resolving after
|
|
375
|
-
Vitest tears down jsdom in CI.
|
|
385
|
+
- Profile page tests assert visible loading, navigation, form, and error behavior through the rendered route. They must not depend on dynamic-import structure or a specific mocking strategy.
|
|
376
386
|
|
|
377
387
|
## Public Website Frontends
|
|
378
388
|
|
|
@@ -432,3 +442,22 @@ the authenticated dashboard.
|
|
|
432
442
|
intact unless a task explicitly changes them.
|
|
433
443
|
- Document remaining security concerns that require product, infrastructure, or
|
|
434
444
|
deployment decisions.
|
|
445
|
+
|
|
446
|
+
## TDD And Validation
|
|
447
|
+
|
|
448
|
+
Test Driven Development is a non-negotiable requirement.
|
|
449
|
+
|
|
450
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
451
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
452
|
+
|
|
453
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
454
|
+
|
|
455
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
456
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
457
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
458
|
+
|
|
459
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
460
|
+
|
|
461
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
462
|
+
|
|
463
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
7
7
|
|
|
8
8
|
# Pull Request Create
|
|
9
9
|
|
|
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,
|
|
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, run the relevant focused non-test
|
|
11
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
12
|
+
prose, files, or repository structure.
|
|
11
13
|
|
|
12
14
|
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.
|
|
13
15
|
|
|
@@ -181,3 +183,22 @@ Do not continue automatically when:
|
|
|
181
183
|
10. Final response should include the PR URL, selected base branch, whether a
|
|
182
184
|
rebase was performed, whether an existing PR was reused or marked ready,
|
|
183
185
|
and any validation that could not be run.
|
|
186
|
+
|
|
187
|
+
## TDD And Validation
|
|
188
|
+
|
|
189
|
+
Test Driven Development is a non-negotiable requirement.
|
|
190
|
+
|
|
191
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
192
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
193
|
+
|
|
194
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
195
|
+
|
|
196
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
197
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
198
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
199
|
+
|
|
200
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
201
|
+
|
|
202
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
203
|
+
|
|
204
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
7
7
|
|
|
8
8
|
# Pull Request Merge Close
|
|
9
9
|
|
|
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,
|
|
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, run the relevant focused non-test
|
|
11
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
12
|
+
prose, files, or repository structure.
|
|
11
13
|
|
|
12
14
|
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.
|
|
13
15
|
|
|
@@ -233,3 +235,22 @@ completion.
|
|
|
233
235
|
cleanup commit was added, whether the remote target branch was deleted or
|
|
234
236
|
protected, whether the local target branch was deleted, and whether local
|
|
235
237
|
base branch is up to date.
|
|
238
|
+
|
|
239
|
+
## TDD And Validation
|
|
240
|
+
|
|
241
|
+
Test Driven Development is a non-negotiable requirement.
|
|
242
|
+
|
|
243
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
244
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
245
|
+
|
|
246
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
247
|
+
|
|
248
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
249
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
250
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
251
|
+
|
|
252
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
253
|
+
|
|
254
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
255
|
+
|
|
256
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
7
7
|
|
|
8
8
|
# Package Auth Util
|
|
9
9
|
|
|
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,
|
|
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, run the relevant focused non-test
|
|
11
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
12
|
+
prose, files, or repository structure.
|
|
11
13
|
|
|
12
14
|
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.
|
|
13
15
|
|
|
@@ -49,8 +51,10 @@ CareCard auth utility package for JWT creation/verification primitives, password
|
|
|
49
51
|
|
|
50
52
|
## Testing Expectations
|
|
51
53
|
|
|
52
|
-
- Write
|
|
53
|
-
|
|
54
|
+
- Write a new failing consumer-facing test through the supported package root
|
|
55
|
+
before behavior or public API changes. Modify a pre-existing test only after
|
|
56
|
+
the user grants fresh, explicit permission for that exact change.
|
|
57
|
+
- Include consumer-facing runtime and compilation tests through the supported package root. Exercise public behavior and realistic type usage without inspecting export objects, source files, or module layout.
|
|
54
58
|
- Run package test, lint, type, and Husky validation commands required by the changed area.
|
|
55
59
|
|
|
56
60
|
## Safety Constraints
|
|
@@ -82,8 +86,10 @@ depend on those folders being present.
|
|
|
82
86
|
- Internal helpers use the established underscore prefix.
|
|
83
87
|
- Keep public exports in `index.js`, declarations in `index.d.ts`,
|
|
84
88
|
implementation modules in `lib`, and tests in `test`.
|
|
85
|
-
- Use Test-Driven Development. Add
|
|
86
|
-
changing behavior or exported
|
|
89
|
+
- Use Test-Driven Development. Add a new failing consumer-facing Mocha or type
|
|
90
|
+
test through the supported package root before changing behavior or exported
|
|
91
|
+
API. Modify a pre-existing test only after the user grants fresh, explicit
|
|
92
|
+
permission for that exact change.
|
|
87
93
|
- Never suppress errors, type errors, linter warnings, crypto failures, or
|
|
88
94
|
failing tests. Fix the cause.
|
|
89
95
|
- Do not add dependencies unless absolutely required. Ask for confirmation first
|
|
@@ -168,20 +174,20 @@ depend on those folders being present.
|
|
|
168
174
|
- Keep `index.d.ts` in sync with every public export in `index.js`.
|
|
169
175
|
- Avoid new loose index signatures. If payloads need custom claims, type them as
|
|
170
176
|
`Record<string, unknown>` or a named claim interface.
|
|
171
|
-
- Keep deprecated APIs marked as deprecated and prefer direct
|
|
172
|
-
|
|
173
|
-
-
|
|
174
|
-
|
|
177
|
+
- Keep deprecated APIs marked as deprecated and prefer direct public-package
|
|
178
|
+
usage examples in documentation.
|
|
179
|
+
- When public types, overloads, return values, payload shapes, or declaration
|
|
180
|
+
behavior change, compile realistic consumer usage through the supported
|
|
181
|
+
package root. Do not assert that a named export or declaration node exists.
|
|
175
182
|
|
|
176
183
|
## Tests
|
|
177
184
|
|
|
178
185
|
- Use Mocha for runtime tests under `test`.
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
- `test/types.test.ts` verifies TypeScript declarations with `tsc`.
|
|
186
|
+
- Exercise runtime scenarios only through the supported package root. Tests
|
|
187
|
+
must not mirror `lib` modules, depend on internal file layout, or inspect
|
|
188
|
+
named exports for existence.
|
|
189
|
+
- Compile realistic consumer code through the package root with `tsc` to
|
|
190
|
+
verify externally visible declaration behavior.
|
|
185
191
|
- Cover success and failure cases for JWT parsing, signature verification,
|
|
186
192
|
password hashing, saved-hash verification, key generation, base64 conversion,
|
|
187
193
|
URL-safe conversion, and string parsing.
|
|
@@ -267,3 +273,22 @@ immediately when no helper remains, allow only a bounded 250 ms settlement
|
|
|
267
273
|
window for already-stopping helpers, fail persistent descendants, preserve
|
|
268
274
|
failures and output, use exit code `124` only for a real outer deadline, and
|
|
269
275
|
remain a final guard rather than a substitute for explicit cleanup.
|
|
276
|
+
|
|
277
|
+
## TDD And Validation
|
|
278
|
+
|
|
279
|
+
Test Driven Development is a non-negotiable requirement.
|
|
280
|
+
|
|
281
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
282
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
283
|
+
|
|
284
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
285
|
+
|
|
286
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
287
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
288
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
289
|
+
|
|
290
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
291
|
+
|
|
292
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
293
|
+
|
|
294
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -5,6 +5,19 @@ description: 'Mandatory for every pkg-auth-util task, including analysis, clarif
|
|
|
5
5
|
|
|
6
6
|
# Pkg Auth Util Coding Standards And Best Practices
|
|
7
7
|
|
|
8
|
+
## JavaScript And TypeScript Style Contract
|
|
9
|
+
|
|
10
|
+
- Require braces around every optional control-flow body through ESLint core
|
|
11
|
+
`curly: ['error', 'all']`. Single-expression arrow functions may remain
|
|
12
|
+
expression-bodied.
|
|
13
|
+
- Require semicolons on every applicable statement through Prettier's
|
|
14
|
+
`semi: true` option. Do not add a second semicolon linter.
|
|
15
|
+
- Keep the shared Prettier baseline and lint-staged command order consistent
|
|
16
|
+
across CareCard repositories: run ESLint fixes before Prettier writes.
|
|
17
|
+
- Use `lint`, `lint:fix`, `format`, `format:check`, and `lint-staged` as the
|
|
18
|
+
direct script names. Whole-repository lint and formatting checks must fail on
|
|
19
|
+
warnings or style drift.
|
|
20
|
+
|
|
8
21
|
Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
9
22
|
root cause, use the stronger solution, and deliver a correct, durable,
|
|
10
23
|
production-quality result. Never treat a temporary workaround, resource
|
|
@@ -65,9 +78,11 @@ completion rules below without weakening those companion skills.
|
|
|
65
78
|
|
|
66
79
|
- Treat every workspace repository as independent and validate it from its own
|
|
67
80
|
root.
|
|
68
|
-
- Update every skill, document, source,
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
- Update every skill, document, source, export, declaration, consumer, and
|
|
82
|
+
package version genuinely required for a coherent task, and add every new
|
|
83
|
+
consumer-facing runtime or type test the behavior requires. Modify a
|
|
84
|
+
pre-existing test only after the user grants fresh, explicit permission for
|
|
85
|
+
that exact change.
|
|
71
86
|
- Do not broaden the task into unrelated cleanup.
|
|
72
87
|
- Preserve CommonJS structure, established public surfaces, naming, and test
|
|
73
88
|
conventions unless the task explicitly replaces them.
|
|
@@ -101,8 +116,8 @@ overloads, duplicate exports, dual paths, transitional names, or fallback
|
|
|
101
116
|
behavior solely to preserve the superseded contract.
|
|
102
117
|
|
|
103
118
|
Delete obsolete functions and exports after all intended consumers have
|
|
104
|
-
migrated and repository-native search, runtime
|
|
105
|
-
|
|
119
|
+
migrated and repository-native search proves them unused, while runtime and type tests
|
|
120
|
+
verify the remaining public contract. This does not authorize unrelated API removal. If an existing
|
|
106
121
|
published or security contract requires compatibility and the request does not
|
|
107
122
|
clearly supersede it, explain the conflict and ask before changing it.
|
|
108
123
|
|
|
@@ -110,8 +125,9 @@ clearly supersede it, explain the conflict and ask before changing it.
|
|
|
110
125
|
|
|
111
126
|
Follow `$carecard-workspace-standards` and
|
|
112
127
|
`$pkg-auth-util-auth-crypto-library` for the complete failing-test-first and
|
|
113
|
-
root-cause workflow. Documentation and skill changes require
|
|
114
|
-
|
|
128
|
+
root-cause workflow. Documentation and skill changes require focused non-test validation before
|
|
129
|
+
prose changes; do not add automated tests that inspect prose, files, or
|
|
130
|
+
repository structure. Do not accept retries, suppressed
|
|
115
131
|
diagnostics, weakened types, disabled tests, forced success, compatibility
|
|
116
132
|
patches, or symptom-only workarounds as completion.
|
|
117
133
|
|
|
@@ -160,3 +176,22 @@ them unused and replaced.
|
|
|
160
176
|
5. Fix every in-scope failure at its root cause and rerun the exact command.
|
|
161
177
|
6. Report exact commands, results, limitations, and remaining risk.
|
|
162
178
|
7. Do not perform remote Git or GitHub operations unless explicitly requested.
|
|
179
|
+
|
|
180
|
+
## TDD And Validation
|
|
181
|
+
|
|
182
|
+
Test Driven Development is a non-negotiable requirement.
|
|
183
|
+
|
|
184
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
185
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
186
|
+
|
|
187
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
188
|
+
|
|
189
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
190
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
191
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
192
|
+
|
|
193
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
194
|
+
|
|
195
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
196
|
+
|
|
197
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -9,7 +9,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
9
9
|
|
|
10
10
|
Non-negotiable test order invariance rule: Every test must pass independently of which tests run before or after it, and the suite must pass in every execution order. Each test must establish the state it needs, isolate mutable state, and clean up state it owns; it must never rely on another test's setup, mutations, or cleanup. Default test, CI, and Husky commands must use the test framework's ordinary ordering and must not force randomized ordering. Random-order execution is an explicit diagnostic only, and every failure it exposes must be fixed at the root cause.
|
|
11
11
|
|
|
12
|
-
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,
|
|
12
|
+
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, run the relevant focused non-test
|
|
13
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
14
|
+
prose, files, or repository structure.
|
|
13
15
|
|
|
14
16
|
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.
|
|
15
17
|
|
|
@@ -123,3 +125,22 @@ For each changed repository:
|
|
|
123
125
|
Finish by verifying that all five packages are published at the same target
|
|
124
126
|
version and every declared `@carecard/*` dependency in `pkg-*`, `ms-*`, and
|
|
125
127
|
`app-dashboard` is pinned to that version.
|
|
128
|
+
|
|
129
|
+
## TDD And Validation
|
|
130
|
+
|
|
131
|
+
Test Driven Development is a non-negotiable requirement.
|
|
132
|
+
|
|
133
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
134
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
135
|
+
|
|
136
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
137
|
+
|
|
138
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
139
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
140
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
141
|
+
|
|
142
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
143
|
+
|
|
144
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
145
|
+
|
|
146
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
|
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
7
7
|
|
|
8
8
|
# Software Design Patterns And Clean Code
|
|
9
9
|
|
|
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,
|
|
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, run the relevant focused non-test
|
|
11
|
+
validation before changing the prose; do not add automated tests that inspect
|
|
12
|
+
prose, files, or repository structure.
|
|
11
13
|
|
|
12
14
|
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.
|
|
13
15
|
|
|
@@ -41,8 +43,7 @@ validation commands, and API contracts.
|
|
|
41
43
|
- Keep side effects minimal, localized, and easy to identify.
|
|
42
44
|
- Use explicit error handling. Do not swallow failures or hide actionable
|
|
43
45
|
error context.
|
|
44
|
-
- Design code so behavior can be tested through focused
|
|
45
|
-
service tests without fragile setup.
|
|
46
|
+
- Design code so behavior can be tested through focused public interfaces, integration boundaries, and observable outcomes without fragile setup or internal-module assertions.
|
|
46
47
|
- Avoid unnecessary dependencies. Use existing language, framework, and local
|
|
47
48
|
helper capabilities before adding packages.
|
|
48
49
|
|
|
@@ -83,3 +84,22 @@ async function loadProfile(...) { ... }
|
|
|
83
84
|
only have one trivial implementation unless they clarify a boundary.
|
|
84
85
|
- Preserve the repository's existing style, naming, module system, and testing
|
|
85
86
|
approach.
|
|
87
|
+
|
|
88
|
+
## TDD And Validation
|
|
89
|
+
|
|
90
|
+
Test Driven Development is a non-negotiable requirement.
|
|
91
|
+
|
|
92
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
93
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
94
|
+
|
|
95
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
96
|
+
|
|
97
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
98
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
99
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
100
|
+
|
|
101
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
102
|
+
|
|
103
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
104
|
+
|
|
105
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
package/.prettierrc.js
CHANGED
package/AGENTS.md
CHANGED
|
@@ -13,3 +13,22 @@
|
|
|
13
13
|
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.
|
|
14
14
|
|
|
15
15
|
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
|
+
|
|
17
|
+
## TDD And Validation
|
|
18
|
+
|
|
19
|
+
Test Driven Development is a non-negotiable requirement.
|
|
20
|
+
|
|
21
|
+
The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
|
|
22
|
+
Tests must validate what the system does through its public interfaces and expected outcomes.
|
|
23
|
+
|
|
24
|
+
Tests must not assert, inspect, or depend on implementation details, including but not limited to:
|
|
25
|
+
|
|
26
|
+
- The existence of specific lines of code, statements, functions, classes, files, or modules.
|
|
27
|
+
- Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
|
|
28
|
+
- Any internal structure that can change without changing externally observable behavior.
|
|
29
|
+
|
|
30
|
+
A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
|
|
31
|
+
|
|
32
|
+
Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
|
|
33
|
+
|
|
34
|
+
This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
|
package/eslint.config.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tsParser from '@typescript-eslint/parser';
|
|
1
3
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
4
|
+
import globals from 'globals';
|
|
2
5
|
|
|
3
6
|
const eslintConfig = defineConfig([
|
|
4
7
|
globalIgnores([
|
|
@@ -8,7 +11,56 @@ const eslintConfig = defineConfig([
|
|
|
8
11
|
'build/**',
|
|
9
12
|
'next-env.d.ts',
|
|
10
13
|
'node_modules/**',
|
|
14
|
+
'coverage/**',
|
|
15
|
+
'dist/**',
|
|
11
16
|
]),
|
|
17
|
+
{
|
|
18
|
+
name: 'carecard/braced-control-flow',
|
|
19
|
+
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
|
|
20
|
+
languageOptions: {
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
parserOptions: {
|
|
23
|
+
ecmaFeatures: {
|
|
24
|
+
jsx: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
curly: ['error', 'all'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'carecard/javascript-recommended',
|
|
34
|
+
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
ecmaVersion: 'latest',
|
|
37
|
+
sourceType: 'commonjs',
|
|
38
|
+
globals: {
|
|
39
|
+
...globals.node,
|
|
40
|
+
...globals.mocha,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
rules: {
|
|
44
|
+
...js.configs.recommended.rules,
|
|
45
|
+
eqeqeq: ['error', 'smart'],
|
|
46
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
|
47
|
+
'no-var': 'error',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'carecard/esm-source-type',
|
|
52
|
+
files: ['**/*.mjs'],
|
|
53
|
+
languageOptions: {
|
|
54
|
+
sourceType: 'module',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'carecard/typescript-parser',
|
|
59
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
parser: tsParser,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
12
64
|
]);
|
|
13
65
|
|
|
14
66
|
export default eslintConfig;
|
package/index.d.ts
CHANGED
|
@@ -150,7 +150,11 @@ export const jwtUtilAuth: {
|
|
|
150
150
|
* @param privateKey - PEM formatted private key to sign the token.
|
|
151
151
|
* @returns Signed JWT string, or null when the private key is missing. Unexpected failures throw.
|
|
152
152
|
*/
|
|
153
|
-
createSignedJwtFromObject: (
|
|
153
|
+
createSignedJwtFromObject: (
|
|
154
|
+
headerObject: JwtHeader,
|
|
155
|
+
payloadObject: JwtPayload,
|
|
156
|
+
privateKey: string,
|
|
157
|
+
) => string | null;
|
|
154
158
|
/**
|
|
155
159
|
* Verifies the signature of a JWT using a public key.
|
|
156
160
|
* @param jwt - The JWT string to verify.
|
|
@@ -179,7 +183,11 @@ export const pwdUtilAuth: {
|
|
|
179
183
|
* @param algorithm - The hashing algorithm to use (e.g., 'sha256').
|
|
180
184
|
* @returns A string containing the formatted hash with metadata ($1$alg$hash$salt$) or null if an error occurs.
|
|
181
185
|
*/
|
|
182
|
-
createPasswordHashWithRandomSalt: (
|
|
186
|
+
createPasswordHashWithRandomSalt: (
|
|
187
|
+
password: string,
|
|
188
|
+
secret: string,
|
|
189
|
+
algorithm: string,
|
|
190
|
+
) => string | null;
|
|
183
191
|
/**
|
|
184
192
|
* Generates a password hash using the same algorithm and salt from a previously saved hash.
|
|
185
193
|
* Useful for verifying a password against a stored hash.
|
|
@@ -188,7 +196,11 @@ export const pwdUtilAuth: {
|
|
|
188
196
|
* @param secret - The pepper/secret key used for hashing.
|
|
189
197
|
* @returns A hash string that should match the saved hash if the password is correct, or null if an error occurs.
|
|
190
198
|
*/
|
|
191
|
-
createPasswordHashBasedOnSavedAlgorithmSalt: (
|
|
199
|
+
createPasswordHashBasedOnSavedAlgorithmSalt: (
|
|
200
|
+
password: string,
|
|
201
|
+
savedPasswordHash: string,
|
|
202
|
+
secret: string,
|
|
203
|
+
) => string | null;
|
|
192
204
|
};
|
|
193
205
|
|
|
194
206
|
/**
|
|
@@ -273,7 +285,11 @@ export function generateKeyPair(algorithm?: 'ed25519' | 'rsa' | string): KeyPair
|
|
|
273
285
|
* @param privateKey - PEM formatted private key to sign the token.
|
|
274
286
|
* @returns Signed JWT string or null if an error occurs.
|
|
275
287
|
*/
|
|
276
|
-
export function jwtCreateSignedToken(
|
|
288
|
+
export function jwtCreateSignedToken(
|
|
289
|
+
headerObject: JwtHeader,
|
|
290
|
+
payloadObject: JwtPayload,
|
|
291
|
+
privateKey: string,
|
|
292
|
+
): string | null;
|
|
277
293
|
|
|
278
294
|
/**
|
|
279
295
|
* Creates a signed service-to-service JWT using the issuing service's private key.
|
|
@@ -312,7 +328,11 @@ export function jwtGetHeaderPayload(jwt: string): JwtParts | null;
|
|
|
312
328
|
* @param algorithm - The hashing algorithm to use (e.g., 'sha256').
|
|
313
329
|
* @returns A string containing the formatted hash with metadata ($1$alg$hash$salt$) or null if an error occurs.
|
|
314
330
|
*/
|
|
315
|
-
export function passwordCreateHashWithRandomSalt(
|
|
331
|
+
export function passwordCreateHashWithRandomSalt(
|
|
332
|
+
password: string,
|
|
333
|
+
secret: string,
|
|
334
|
+
algorithm: string,
|
|
335
|
+
): string | null;
|
|
316
336
|
|
|
317
337
|
/**
|
|
318
338
|
* Generates a password hash using the same algorithm and salt from a previously saved hash.
|
|
@@ -322,4 +342,8 @@ export function passwordCreateHashWithRandomSalt(password: string, secret: strin
|
|
|
322
342
|
* @param secret - The pepper/secret key used for hashing.
|
|
323
343
|
* @returns A hash string that should match the saved hash if the password is correct, or null if an error occurs.
|
|
324
344
|
*/
|
|
325
|
-
export function passwordCreateHashFromSavedHash(
|
|
345
|
+
export function passwordCreateHashFromSavedHash(
|
|
346
|
+
password: string,
|
|
347
|
+
savedPasswordHash: string,
|
|
348
|
+
secret: string,
|
|
349
|
+
): string | null;
|
package/index.js
CHANGED
|
@@ -27,7 +27,8 @@ module.exports = {
|
|
|
27
27
|
*/
|
|
28
28
|
pwdUtilAuth: {
|
|
29
29
|
createPasswordHashWithRandomSalt: pwdUtilAuth.createPasswordHashWithRandomSalt,
|
|
30
|
-
createPasswordHashBasedOnSavedAlgorithmSalt:
|
|
30
|
+
createPasswordHashBasedOnSavedAlgorithmSalt:
|
|
31
|
+
pwdUtilAuth.createPasswordHashBasedOnSavedAlgorithmSalt,
|
|
31
32
|
},
|
|
32
33
|
/**
|
|
33
34
|
* @deprecated Use native Buffer methods or other modern alternatives.
|