Skip to content

Add a lightweight runtime check on registeredAt when anchors are loaded via AnchorService.registerBulkΒ #166

Description

@Jagadeeshftw

πŸ“Œ 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

  • isIsoTimestamp correctly distinguishes valid ISO-8601 timestamps from malformed strings and non-strings.
  • New tests pass; no existing behavior changes since nothing currently calls the new helper.

πŸ”’ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebackendBackend service workenhancementNew feature or improvement

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions