@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.
@@ -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, add or update the relevant validation check before changing the prose.
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
- This requirement is non-negotiable and may be overridden only with the user's
21
- explicit, direct approval.
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 or update package tests before behavior or public API changes.
74
- - Include type/export compatibility tests where the package already has them.
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 or update focused
110
- tests first, verify they fail for the missing behavior when practical, then
111
- implement.
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
- - Code coverage percentage must not decrease from the previous commit; it can
313
- stay the same or increase. When coverage tooling exists, compare against the
314
- previous commit or recorded baseline, add tests to maintain or improve
315
- coverage, and never reduce coverage thresholds to pass checks.
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
- - In database `rls_logic.test.js` files, assert RLS logic only by calling
328
- `carecard.can_access_row(...)` and checking the intended boolean. Put table
329
- CRUD and lower RLS helper checks in query/enforcement tests.
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, transforms, query/mutation wrappers,
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
- - `tests/app/dashboard/profile/page.test.tsx` keeps dynamic profile children
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, add or update the relevant validation check before changing the prose.
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, add or update the relevant validation check before changing the prose.
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, add or update the relevant validation check before changing the prose.
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 or update package tests before behavior or public API changes.
53
- - Include type/export compatibility tests where the package already has them.
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 or update Mocha and type tests before
86
- changing behavior or exported API.
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 export examples in
172
- docs and tests.
173
- - Update type tests whenever public exports, overloads, return values, payload
174
- shapes, or declaration behavior changes.
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
- - Every implementation module in `lib` should have matching tests under `test`.
180
- For example, `lib/jwtUtilAuth.js` should be covered by
181
- `test/jwtUtilAuth.test.js`.
182
- - `test/index.test.js` should cover scenarios through the public exports from
183
- `index.js`.
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, runtime test, type test, export,
69
- declaration, consumer, and package version genuinely required for a coherent
70
- task.
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 tests, and type tests prove them
105
- unused. This does not authorize unrelated API removal. If an existing
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 a focused
114
- structural validation before prose changes. Do not accept retries, suppressed
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, add or update the relevant validation check before changing the prose.
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, add or update the relevant validation check before changing the prose.
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 unit, integration, or
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
@@ -4,7 +4,9 @@ module.exports = {
4
4
  bracketSpacing: true,
5
5
  singleQuote: true,
6
6
  trailingComma: 'all',
7
- printWidth: 140,
7
+ printWidth: 100,
8
+ semi: true,
9
+ tabWidth: 2,
8
10
  useTabs: false,
9
- endOfLine: 'auto',
11
+ endOfLine: 'lf',
10
12
  };
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: (headerObject: JwtHeader, payloadObject: JwtPayload, privateKey: string) => string | null;
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: (password: string, secret: string, algorithm: string) => string | null;
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: (password: string, savedPasswordHash: string, secret: string) => string | null;
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(headerObject: JwtHeader, payloadObject: JwtPayload, privateKey: string): string | null;
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(password: string, secret: string, algorithm: string): string | null;
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(password: string, savedPasswordHash: string, secret: string): string | null;
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: pwdUtilAuth.createPasswordHashBasedOnSavedAlgorithmSalt,
30
+ createPasswordHashBasedOnSavedAlgorithmSalt:
31
+ pwdUtilAuth.createPasswordHashBasedOnSavedAlgorithmSalt,
31
32
  },
32
33
  /**
33
34
  * @deprecated Use native Buffer methods or other modern alternatives.