feat(render-method-2024): add digestMultibase generation via async constructor#25
Merged
Merged
Conversation
Contributor
This was referenced May 15, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two new exports:
generateDigestMultibase, a primitive that hashes content to a multibase-encoded multihash string, andconstructRenderMethodAsync, an async sibling ofconstructRenderMethodthat auto-fillsdigestMultibaseforRenderTemplate2024outputs when aurlis supplied. The synchronousconstructRenderMethodis unchanged, so existing callers continue to work without modification.Gating:
digestMultibaseis only emitted when the caller signals remote hosting intent by settingurl. For inline templates without aurl, the digest is redundant since the signed credential already covers the template bytes, so it is omitted. A caller-supplieddigestMultibaseis preserved verbatim.The digest is computed over the raw
templatebytes BEFORE whitespace normalisation, on the precondition that those raw bytes are what the caller intends to host aturl. If a caller supplies both inlinetemplateandurl, the cleaned inlinetemplatefield stored in the output will NOT hash todigestMultibase; a verifier must hash bytes fetched fromurl, not the inline field. See the JSDoc onconstructRenderMethodAsyncfor the full contract.Defaults are
sha2-256andbase58btc, matching the conventional choices in UNTP and W3C VC examples. Both are configurable via the helper's options and exported asDEFAULT_DIGEST_ALGORITHMandDEFAULT_DIGEST_BASEfor callers who want to be explicit. The implementation builds on the newly published @uncefact/untp-utilsMultibaseDigestprimitive.The Jest config gains
transformIgnorePatternsplus targetedmoduleNameMapperentries so the ESM-only@uncefact/untp-utilsand itsmultiformatssubpath imports resolve correctly without a wholesale ESM migration. No changes to existing tests required. The mapper paths are coupled tomultiformats's internaldist/layout; a comment injest.config.cjsnotes the future migration path.Closes #24
Test plan
generateDigestMultibaseproduces a verifiablesha2-256+base58btcdigest by defaultconstructRenderMethodAsyncauto-fillsdigestMultibaseonly whenurlis a non-empty string and the template is non-emptyurl, non-stringurl, and emptytemplateall skip digest generationdigestMultibaseis preserved verbatim; an empty-stringdigestMultibasetriggers regenerationWebRenderingTemplate2022output is identical to the synchronous constructor