Skip to content

fix(core): params, error system, crypto - #5

Closed
rmlearney-digicatapult wants to merge 29 commits into
aviarytech:design/did-resolver-query-paramsfrom
rmlearney-digicatapult:design/did-resolver-query-params
Closed

fix(core): params, error system, crypto#5
rmlearney-digicatapult wants to merge 29 commits into
aviarytech:design/did-resolver-query-paramsfrom
rmlearney-digicatapult:design/did-resolver-query-params

Conversation

@rmlearney-digicatapult

@rmlearney-digicatapult rmlearney-digicatapult commented Jun 26, 2026

Copy link
Copy Markdown

Wanted to help out by addressing the comments I raised.

This PR into your branch does the following:

  • bump dependencies
  • replace @stablelib/ed25519 with @noble/curves for better supported library aligning with existing @noble/hashes
  • remove casts through unknown for type safety
  • explicit switch-case returns, no fall-throughs

Bit bigger change to the internal error system:

  • use string union DidResolutionError for all errors, no separate WebvhErrorCode
  • remove InvalidDidUrl error class and exception-based control flow from resolver-result.ts
  • remove representationNotSupported error (not in spec)
  • string literal errors align to did-resolver output (JSON metadata)
  • reject matrix params (not part of DID spec) and only accept query params
  • non-throwing selector validation helper (validateSingleVersionSelector) with null or structured { code, detail } instead of previous assert
  • no try/catch for selector errors

Test suite extended:

  • tests for unknown query params and malformed percent encoding
  • positive test for lowercase hex encoding

Note

Replace invalidDidUrl error code with invalidDid and migrate Ed25519 crypto to @noble/curves

  • Replaces the invalidDidUrl and representationNotSupported error codes with invalidDid across the resolver, replacing the DidResolutionError enum with a 'invalidDid' | 'notFound' | 'internalError' string union type in src/interfaces.ts
  • Adds validateSingleVersionSelector in src/resolver-result.ts to return a structured error instead of throwing when conflicting version selectors are supplied
  • The webvh resolver in src/resolver.ts now rejects matrix-style version params, malformed percent-encoding, and unknown query parameters, all returning error='invalidDid'
  • Replaces @stablelib/ed25519 with @noble/curves for Ed25519 signature verification in src/verifier.ts
  • Risk: InvalidDidUrlError, WebvhErrorCode, and defaultVerifier are no longer exported from the package root; consumers relying on these or on invalidDidUrl error codes must update their code

Macroscope summarized 9193a84.

brianorwhatever and others added 29 commits June 25, 2026 02:33
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
…hape

- delete removed verificationMethod resolution tests
- convert resolution-failure assertions from throws to error results
- add getResolver integration + resolver-result/verifier unit tests
- apply biome formatting

Signed-off-by: Brian Richter <brian@aviary.tech>
…n shape

Signed-off-by: Brian Richter <brian@aviary.tech>
URLSearchParams applies application/x-www-form-urlencoded rules where '+'
decodes to a space. A DID URL query is a URI component (RFC 3986) where '+'
is literal, so a versionTime with a +HH:MM timezone offset was corrupted into
an Invalid Date. Parse the query manually with decodeURIComponent instead.

Signed-off-by: Brian Richter <brian@aviary.tech>
- resolver.ts: reject NaN versionNumber / Invalid Date versionTime as invalidDidUrl
- resolver-result.ts: tighten mapErrorToCode so validation errors embedding
  '404'/'not found' (attacker-controlled log data) aren't misclassified as notFound;
  only genuine log-fetch absence maps to notFound
- cli.ts: surface resolution errors in update/deactivate instead of TypeError on meta.updateKeys
- examples: return the resolution error before file-serving fallback (avoid https:/// fetch)
- tests: cover the new validation paths; reclassify invalid-update-key read as invalidDid

Signed-off-by: Brian Richter <brian@aviary.tech>
- resolver-result.ts: preserve a valid earlier document when returned alongside a
  warning-level error (e.g. explicit version selector resolves while a later entry
  fails witness verification) instead of dropping it
- resolver-result.ts: toErrorResult now synthesizes RFC9457 problemDetails (type/title/detail)
  so fetch/validation/invalidDidUrl errors keep structured error info
- cli.ts: resolve a deactivated DID's identifier from the log instead of printing an empty id
- tests: cover preserved-doc and problemDetails behavior

Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: Brian Richter <brian@aviary.tech>
- resolver-result.ts: add 'internalError' code; classify 5xx/network/transport
  failures as internalError instead of invalidDid (document-validation errors stay
  invalidDid). Synthesize problemDetails for it too.
- examples/express-resolver.ts: map resolution error codes to HTTP status
  (notFound->404, invalid*->400, internalError->500) instead of a blanket 400.
- tests: cover internalError classification; update network-failure expectation.

Signed-off-by: Brian Richter <brian@aviary.tech>
…rning error

Only bail on resolution error when didDocument is null; a valid earlier version
can be returned alongside warning-level error metadata (consistent with
toResolutionResult preserving the doc).

Signed-off-by: Brian Richter <brian@aviary.tech>
A valid DID served from an unauthorized (401/403), gone (410), rate-limited (429),
or failing (5xx) endpoint is a resolver-side internal error, not a document-validation
failure. 404/empty-log stay notFound; document-validation errors stay invalidDid.

Signed-off-by: Brian Richter <brian@aviary.tech>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
@brianorwhatever
brianorwhatever force-pushed the design/did-resolver-query-params branch from 2a84b6e to a2080de Compare July 13, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants