π Description
AnchorService.register/registerBulk always generate registeredAt internally via new Date().toISOString() β a caller can never supply their own value today. This is safe, but if a future import/restore feature (or a batch-migration script) ever needs to preserve original registration timestamps by accepting registeredAt as input, there's currently no validation helper ready for that, and it would be easy to accept an arbitrary string without checking it's actually a valid ISO-8601 timestamp.
π§© Requirements and context
- Add an
isIsoTimestamp(value: unknown): boolean (or similarly named) helper to utils/validation.ts, usable by any future feature that accepts a client-supplied timestamp.
- Add unit tests for the helper covering valid ISO-8601 strings, near-miss malformed strings (e.g. missing timezone, wrong separators), and non-string input.
- Do not change
AnchorService.register/registerBulk's current behavior (they still always generate registeredAt server-side) β this issue only adds the reusable validation primitive and its tests, as groundwork.
π οΈ Suggested execution
- Add
isIsoTimestamp to src/utils/validation.ts.
- Add tests to
src/utils/validation.test.ts.
- Add a short doc comment noting it's intended for future features that accept externally-supplied timestamps, and is not currently wired into any endpoint.
β
Acceptance criteria
π Security notes
N/A β additive validation primitive with no current call sites; groundwork for safely validating any future externally-supplied timestamp input.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
AnchorService.register/registerBulkalways generateregisteredAtinternally vianew Date().toISOString()β a caller can never supply their own value today. This is safe, but if a future import/restore feature (or a batch-migration script) ever needs to preserve original registration timestamps by acceptingregisteredAtas input, there's currently no validation helper ready for that, and it would be easy to accept an arbitrary string without checking it's actually a valid ISO-8601 timestamp.π§© Requirements and context
isIsoTimestamp(value: unknown): boolean(or similarly named) helper toutils/validation.ts, usable by any future feature that accepts a client-supplied timestamp.AnchorService.register/registerBulk's current behavior (they still always generateregisteredAtserver-side) β this issue only adds the reusable validation primitive and its tests, as groundwork.π οΈ Suggested execution
isIsoTimestamptosrc/utils/validation.ts.src/utils/validation.test.ts.β Acceptance criteria
isIsoTimestampcorrectly distinguishes valid ISO-8601 timestamps from malformed strings and non-strings.π Security notes
N/A β additive validation primitive with no current call sites; groundwork for safely validating any future externally-supplied timestamp input.
π Guidelines