Skip to content

Rename FodId hash to matchKey to match the Model Terms vocabulary - #186

Merged
jwrosewell merged 3 commits into
mainfrom
refactor/51did-match-key-rename
Aug 31, 2026
Merged

jwrosewell merged 3 commits into
mainfrom
refactor/51did-match-key-rename

Conversation

@jwrosewell

Copy link
Copy Markdown
Contributor

The stable, comparable part of a 51Did (the payload bytes after the flags and licence id) is called the match key in the Model Terms for Marketing, which will be published later, and in the patent. The Node reader previously exposed those bytes as FodId.hash, so the code now uses the same word as the documents. This mirrors the .NET rename (51Degrees/pipeline-dotnet#348) and the Rust rename (51Degrees/rust#19), and builds on the parse hardening merged today (#185).

What changed

  • The public getter FodId.hash is renamed to FodId.matchKey, returning a defensive copy of the match key bytes (a 32-byte SHA-256 for Probabilistic and HashedEmail identifiers, or 16 GUID bytes for Random).
  • hash stays as a deprecated getter forwarding to matchKey, marked @deprecated in the JSDoc and in the regenerated types/fodId.d.ts, so existing callers keep working and get the same bytes. It will be removed in a future release.
  • Internal names that carry the same bytes move to the match key vocabulary as well, being the _matchKey field, the matchKey member of the unpacked payload, and the matchKeyLength locals in the payload walk in fodId.js and the length check in didClient.js.
  • HASH_OFFSET and HASH_LENGTH keep their names, because the SHA-256 wording behind them stays true, and gain comments saying they describe the match key field. HashedEmail and SHA-256 wording is unchanged throughout.
  • The readme (terminology, payload layout tables, usage and comparison snippets), the package.json and remote_package.json descriptions and examples/fodIdExample.js now say match key. The readme usage section notes the deprecated alias. The creator context web example does not read the match key, so it is unchanged.
  • The tests read matchKey, the envelope helper that builds the canonical bytes is canonicalMatchKey, and one new test asserts the deprecated hash getter returns the same bytes as matchKey and hands out a copy.
  • types/fodId.d.ts is regenerated with tsc -b --force in the package. No other declaration file changed in content.

Before and after for a caller

// Before
const value = fodId.hash;

// After
const matchKey = fodId.matchKey;
// fodId.hash still works and returns the same bytes, with a deprecation note.

Verification

  • npm test in fiftyone.pipeline.did: 139 passed, 2 skipped (the live cloud tests), 141 total. Main gives 138 passed, so the difference is the new alias test.
  • node examples/fodIdExample.js runs to completion and prints the match key and the "same match key across reissues" check.
  • Lint with the repository's eslint 8.57.0 setup from ci/setup-environment.ps1 over the five changed JavaScript files reports 54 problems on both main and this branch, so the change adds none. The repository lint already fails on main for reasons outside this change (a parsing error on the 0b1000_0101 numeric separator in tests/fodId.test.js under ecmaVersion 2020) and that is left alone here.

Commits

  1. Rename FodId.hash to matchKey with a deprecated hash alias (fodId.js, didClient.js, types/fodId.d.ts).
  2. Move the readme, package descriptions and example to the match key.
  3. Move the tests to matchKey and cover the deprecated hash alias.

Part of the cross-repository match key vocabulary rename (documentation, website, .NET reader, Rust reader and cloud internals in separate PRs).

Produced with AI assistance under James Rosewell's direction and needs human review.

The stable, comparable part of a 51Did (the payload bytes after the
flags and licence id) is called the match key in the Model Terms for
Marketing and in the patent, so the reader now uses the same word. The
public getter is matchKey, and hash stays as a deprecated getter that
forwards to matchKey and returns the same bytes, so existing callers
keep working until a future release removes the alias.

The internal names that carry the same bytes (the _matchKey field, the
matchKey member of the unpacked payload and the matchKeyLength locals in
the payload walk and the client length check) move to the match key
vocabulary too. HASH_OFFSET and HASH_LENGTH keep their names, because
the SHA-256 wording behind them stays true, and their comments now say
which field they describe. The declarations are regenerated with
tsc -b --force and carry the @deprecated tag on hash.
The terminology section, the payload layout tables, the usage and
comparison snippets and the package descriptions now say match key
where they said value, and the usage section notes that hash remains
as a deprecated alias. The offline example prints and compares the
match key.
The tests read matchKey and the envelope helper that builds the
canonical bytes is canonicalMatchKey. One new test asserts the
deprecated hash getter returns the same bytes as matchKey and hands
out a copy, so the old name still cannot reach the stored bytes.
@jwrosewell
jwrosewell merged commit 9216eca into main Aug 31, 2026
1 check passed
@jwrosewell
jwrosewell deleted the refactor/51did-match-key-rename branch August 31, 2026 15:17
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.

1 participant