Repository navigation
Own the library surface instead of shipping one by accident - #15
Merged
Merged
Conversation
`src/lib/index.ts` was a blanket `export *` over all seven lib modules, wired into the `exports` map since the first commit. It published 43 names, internals among them: adding a symbol to any module widened the public API and renaming one broke consumers, neither producing a diff that looked like an API change. Importing anything also pulled in the aggregator client, so verification — which needs no gateway, no API key and no filesystem — could not be used without them. Two explicit entry points replace it. `@unicitylabs/proof-cli/verify` carries offline verification: 80 modules, no transport, no `node:` import. The package root adds stamping. Both list every name they export. Making the verification entry point independent of the gateway: - `TimestampClient.ts` keeps stamping; `describeToken`, `verificationFailure`, `verify` and the result types move to `TimestampVerification.ts`, which does not import `AggregatorClient`. - `loadTrustBase` moves to `src/config.ts` along with `INetworkSelection`, leaving `src/lib/` free of filesystem access. `resolveNetwork` takes a parsed `trustBase` instead of a path, and is now synchronous. `PublicApiTest` pins both export lists, asserts a deep import is refused, and walks each built module graph: no module in this package may import from `node:`, and nothing reachable from `/verify` may be the aggregator client or its transport. Each guard was confirmed to fail on the drift it exists to catch. The build now removes `lib/` before compiling, so the deleted barrel stops shipping from working trees that built before its removal. Narrowing drops names 0.2.0 exported: `TIMESTAMP_BURN_REASON`, `TIMESTAMP_RECIPIENT_ENCODED`, `createUnicityCertificateVerifier`, `errorMessage`, `NO_PAYLOAD_MESSAGE`, `DEFAULT_POLL_INTERVAL_MS`, `certifyMintTransaction`, `TrustBaseSource`, `ITrustBaseChoice` and `loadTrustBase`. All remain available inside the package. Refs #14
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Closes #14.
src/lib/index.tswas a blanketexport *over all seven lib modules, wired intothe
exportsmap since the first commit and shipped in 0.2.0. It published 43names —
TIMESTAMP_RECIPIENT_ENCODED,errorMessage,createUnicityCertificateVerifierandcertifyMintTransactionamong them — withnothing recording which were meant to be stable. Adding a symbol to any module
widened the public API and renaming one broke consumers, neither producing a diff
that looked like an API change.
Two entry points
@unicitylabs/proof-cli/verify@unicitylabs/proof-clinode:crypto, fromuuidunder the Node conditionVerification needs no gateway, no API key and no filesystem, and
/verifynowcannot reach one: no aggregator client, no JSON-RPC transport, no
node:importanywhere in its graph. The package root adds stamping. Both files list every name
they export.
Getting there took two moves:
TimestampClient.tskeeps stamping.describeToken,verificationFailure,verifyand the result types move toTimestampVerification.ts, which does notimport
AggregatorClient.loadTrustBasemoves tosrc/config.tswithINetworkSelection, leavingsrc/lib/free of filesystem access.resolveNetworktakes a parsedtrustBaseinstead of a path and is synchronous.No CLI behaviour changes:
TIMESTAMP_TAG, the token type, the payload format andevery command and flag are untouched.
Guards
tests/unit/PublicApiTest.tsimports the package by name in a child process, soit sees what a consumer sees through the
exportsmap. It pins both export listsand the exported types, asserts a deep import is refused, and walks each built
module graph. Every guard was checked against the drift it exists to catch:
node:cryptoadded tosrc/lib/TimestampPayload.ts/verifyre-exportsstamp/verify, and the name listexport *added back tosrc/verify.tsexportsmap target points at a missing filesrc/verify.tsBreaking, deliberately
Narrowing removes names 0.2.0 exported:
TIMESTAMP_BURN_REASON,TIMESTAMP_RECIPIENT_ENCODED,createUnicityCertificateVerifier,errorMessage,NO_PAYLOAD_MESSAGE,DEFAULT_POLL_INTERVAL_MS,certifyMintTransaction,TrustBaseSource,ITrustBaseChoiceandloadTrustBase. All stay availableinside the package. No version bump here — releasing is a separate decision.
The build now removes
lib/before compiling, so the deleted barrel stopsshipping from working trees that built before its removal.
Verified:
npm run lint,npm run build:check, andnpm test(154 passed, 5skipped — the network suite, which needs a key).
npm pack --dry-runconfirmsboth entry points and their declarations ship and the old barrel does not. The
README examples were run against
tests/fixtures/testnet2-signed.cbor.