Repository navigation
Conversation
The repository is moving to one napi-rs version, and the recipher binding needs napi-rs 3. This moves @cipherstash/auth and @cipherstash/profile from napi-rs 2 to napi-rs 3: napi 3.16.2 and napi-derive 3.7.1, @napi-rs/cli 3.10.12. napi-build stays on 2 (2.6.0): napi-rs 3 has no stable napi-build 3, and its own crates build with napi-build 2. The one Rust change is the ThreadsafeFunction API, which napi-rs 3 rewrote. `ThreadsafeFunction<T, ErrorStrategy::Fatal>` becomes `ThreadsafeFunction<T, Promise<R>, T, Status, false>`: `false` is the old Fatal (no error-first argument, a throwing callback is fatal), and the return type moves from the closure into the type, so the callback now receives a `Result` and propagates it with `?` as the v2 closure did. The CLI changed under the release build. napi v2 turned off its generated loader with `--js false`; napi v3 reads `--js false` as a path and writes the loader to a file named `false`, which `git diff --exit-code` does not see because the file is untracked. The release build now passes `--no-js`, its tree check also fails on an added file, and auth-build-artifacts.test.mjs holds both. The package.json napi config moves to v3's `binaryName` and `targets`, which v3 reads without a deprecation warning; the six target triples and the binary names are unchanged. native.d.ts is regenerated: v3 sorts the declarations, changes the header, and types the three OidcFederationStrategy callbacks precisely instead of as `() => any`. index.d.ts, the published types entry, re-exports only the three unchanged interfaces from it, so consumers see no type change.
🦋 Changeset detectedLatest commit: 628a69f The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: |
Contributor
Mutation testing (cargo-mutants,
|
This branch has not been deployed
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.
Summary
@cipherstash/authand@cipherstash/profileare Node.js packages whose core is Rust, compiled into a native.nodefile with napi-rs (a Rust library plus a build CLI). This moves both from napi-rs 2 to napi-rs 3, so the repository uses one napi-rs version once the recipher binding (draft #1774) lands, which needs napi-rs 3.Nothing a user calls changes. The JavaScript API, the hand-written
index.d.ts, the loader, theexportsmap, the six platform packages and the.nodefile names are the same. The native binary that@cipherstash/authships is rebuilt, so this carries an@cipherstash/authpatch changeset.Changes
Rust
napi2.16.17 to 3.16.2 andnapi-derive2.16.13 to 3.7.1, in both crates.napi-buildstays at 2 (2.6.0). There is no stablenapi-build3: the only 3.x release is a yanked beta, and napi-rs 3's own crates build withnapi-build2. The napi-rs migration guide saysnapi-build = "3", which does not resolve.stack-auth-node: theThreadsafeFunctionAPI was rewritten in v3.ThreadsafeFunction<T, ErrorStrategy::Fatal>becomesThreadsafeFunction<T, Promise<R>, T, Status, false>. Thefalseis v2's "Fatal" mode (no error-first argument). The return type is now part of the type, so eachcall_with_return_valuecallback receives aResultand passes it on with?, as the v2 closure did.stack-profile-nodeneeded no source change.Cargo.lock:ctor1.0.14 (was 0.2.9),link-section,nohash-hasher,napi-sys3.4.1,napi-derive-backend7.0.1, plusconvert_caseandlibloadingbumps. All of them are at least 7 days old (the repository's Dependabot cooldown).napi3.16.3 andnapi-derive3.7.2 were published yesterday and are deliberately not used.CLI and config
@napi-rs/cli^2(2.18.4) to^3(3.10.12) in both packages. 3.11.0 is the latest, but it was published yesterday, and the 7-dayminimumReleaseAgeinpnpm-workspace.yamlrefuses it; pnpm picked 3.10.12.package.jsonnapiconfig:namebecomesbinaryName, andtriples: { defaults: false, additional: [...] }becomes a flattargetslist with the same six triples. v3 still reads the old keys but prints a deprecation warning on every build. The six triples map to the same platform names and.nodefile names as before (checked with v3's ownparseTriple).build:debugandbuild:nativescripts are unchanged:napi build [--release] --dts native.d.tsmeans the same thing in v3.Release build (
_build-auth-artifacts.yml) and its guard--js falsebecomes--no-js, in the host build and in the Alpine (musl) build. This is the important one. With--platform, napi writes its own generated loader over the committedindex.js. In v2,--js falseturned that off. In v3,--js falseis read as a file path: the build writes a 36 KB loader to a file namedfalse(I ran it).index.jsis left alone, so the existinggit diff --exit-codecheck passes, but the new file is untracked and nothing catches it. v3's flag is--no-js. Without either flag, v3 overwritesindex.jsexactly as v2 did (also checked).git status --porcelain). The.nodeoutput is gitignored, so it does not trip this.scripts/__tests__/auth-build-artifacts.test.mjsnow requires--no-js, refuses any--js <path>, requires the added-file check, and readsnapi.targets. I checked that it fails against each regression: putting--js falseback, having--no-jsand--js falsetogether, and removing the added-file check.--platform,--release,--target,--stripand--dtskeep the same names and meaning in v3. The output is stillstack-auth-node.<platform>.nodein the package directory, andnative.d.tsis still rewritten in place.Docs
AGENTS.md: "napi-rs v2" becomes "napi-rs v3"..changeset/auth-napi-rs-3.md:@cipherstash/authpatch. The six platform packages are in its fixed version group, so they move with it.native.d.ts, line by linenative.d.tsis the generated typings of the raw binding. The published types entry is the hand-writtenindex.d.ts, which re-exports onlyTokenResult,AuthResultandAutoStrategyOptionsfrom it and declares everything else itself.native.d.tsis in the tarball but is not in theexportsmap.@cipherstash/auth/native.d.ts:Header (cosmetic):
/* tslint:disable */ /* eslint-disable */ /* auto-generated by NAPI-RS */becomes/* auto-generated by NAPI-RS */ /* eslint-disable */.Order and spacing (cosmetic): v3 sorts the declarations (classes, then interfaces and functions, alphabetically) and puts a blank line between them. Every declaration's text, doc comment included, is unchanged except for the three below.
TokenResult,AuthResult,AutoStrategyOptions(the threeindex.d.tsre-exports): unchanged.Real type change, not visible to consumers: the three
OidcFederationStrategycallbacks are now typed precisely instead of asany:getJwt: () => anybecomesgetJwt: (() => Promise<string>)(increateandcreateWithStore)loadToken: () => anybecomesloadToken: (() => Promise<string | undefined | null>)saveToken: (arg: string) => anybecomessaveToken: ((arg: string) => Promise<undefined>)This comes from the v3
ThreadsafeFunctiontype carrying its return type. Consumers do not see it:index.d.tsdeclaresOidcFederationStrategyitself, with the wider() => Promise<string> | stringsignatures, andindex.jsalways passes the native side a Promise-returning wrapper.@cipherstash/profile/native.d.ts(private package): the header change only.What behaves differently at runtime
I built a v2 binary from
nextand a v3 binary from this branch and compared them through the real loader. The class and function names, every static and prototype member with its property descriptor and arity, and the CJS and ESM export names are byte-for-byte identical (a JSON dump of both, diffed). The release binary matches too. Three small differences exist, all in napi itself, all reachable only through the raw nativegetToken().index.js'sgetToken()callsgetJwtin JavaScript and does not take this path:getJwtwith no arguments. v2 passed oneundefined.index.jswrapsgetJwtin() => Promise.resolve(getJwt()), so a user's callback gets no arguments either way.getJwtrejects, the failure message readsgetJwt rejected: GenericFailure, no session. v2 read... GenericFailure, Error: no session. v3 reads the error'smessageinstead of converting the error to a string.napi_fatal_error, which aborts the process. v3 raises it withnapi_fatal_exception, an uncaught exception, so anuncaughtExceptionhandler can see it.index.jsalways passes a Promise-returning wrapper, butPromise.resolve(getJwt())still runsgetJwt()synchronously, so a throwinggetJwtreaches this path from the rawgetToken()only.Unchanged, and worth knowing: in both v2 and v3, a process that has created an
OidcFederationStrategydoes not exit on its own while the strategy is alive. The threadsafe functions hold the event loop open. I checked v2 and v3 side by side.Supply chain
pnpm install(pnpm 10.33.2,minimumReleaseAgehonoured) changedpnpm-lock.yamlfrom 738 to 834 packages: 97 added, 1 removed (@napi-rs/cli@2.18.4).@napi-rs/cli@3.10.12and its dependency tree. That is@inquirer/*(16 packages, interactive prompts fornapi new),@octokit/*(14, fornapi pre-publish),@napi-rs/cross-toolchain,@napi-rs/lzma+ 17 platform packages,@napi-rs/tar+ 16,@napi-rs/wasm-tools+ 13,@emnapi/core/@emnapi/runtime2.0.0-beta.3(the CLI's optional peers, a beta),@emnapi/wasi-threads,@napi-rs/wasm-runtime,@tybys/wasm-util,typescript@6.0.3(a direct dependency of the CLI, separate from the repository's TypeScript 5),js-yaml@5.5.0,es-toolkit,obugand 8 small utilities. The platform packages are prebuilt native binaries selected byos/cpu, so only the host's is installed.preinstall,installorpostinstallscript. I checked every one of the 97 against the registry. Two declareprepare(@tybys/wasm-util,content-type), which npm and pnpm do not run for a registry install.pnpm installreported no new ignored build scripts (the existingesbuildnotice is unchanged). Nothing was added toonlyBuiltDependencies.^20.17 || ^22.13 || >=23.5. CI uses Node 22 and the musl image isnode:22-alpine.e2e/tests/supply-chain.e2e.test.tspasses.Verification
Run locally on macOS arm64, Rust 1.94.1, pnpm 10.33.2. mise is not trusted in this worktree, so cargo ran as
MISE_DISABLE=1 RUSTUP_TOOLCHAIN=1.94.1 ~/.cargo/bin/cargo.cargo fmt --all --check: clean.cargo clippy --locked --no-deps --workspace --all-targets --all-features -- -D warnings(the CI command): clean.cargo nextest run --locked -p stack-auth-node -p stack-profile-node --all-features: 25 passed.test:cargo(cargo test --locked) fails 5 to 6 of thestart_pauseddevice-code tests instack-auth-node. It fails the same way onnextwith napi-rs 2 (checked, 3 runs each). That is the race AGENTS.md describes for plaincargo test; CI uses nextest.napi build --dts native.d.ts(debug) for both packages, then the drift guard's sequence (pnpm --filter @cipherstash/auth --filter @cipherstash/profile run build:debug) three more times, including once aftercargo clean -pof both crates, with v3'starget/napi-rstypings cache deleted and bothnative.d.tsremoved first. Both files came out byte-identical every time._build-auth-artifacts.ymlruns it for darwin-arm64:pnpm exec napi build --platform --release --target aarch64-apple-darwin --strip --dts native.d.ts --no-js. The output wasstack-auth-node.darwin-arm64.node(Mach-O arm64) in the package directory,index.jswas unchanged (same SHA), andnative.d.tswas identical to the debug build's. I then ran the workflow's next steps: the tree check passed, the binary was moved intoplatforms/darwin-arm64/,npm packran, and the tarball check passed.require('@cipherstash/auth-darwin-arm64')), in CJS and ESM. A smoke script ranAccessKeyStrategy.create(both arms),beginDeviceCodeFlow(INVALID_REGION),OidcFederationStrategy.create(INVALID_URL) andcreateWithStore, and the rawgetToken()through the threadsafe function, against an unroutable host with both a resolving and a rejectinggetJwt. All offline.pnpm --filter @cipherstash/auth --filter @cipherstash/profile test: profile 14 passed, auth 120 passed and 3 skipped (thewasm-inline-resultfile skips itself without a wasm build), Biome clean. The auth suite also passes against the release binary.pnpm run test:scripts: 96 files, 1597 passed, 29 skipped.pnpm run code:check: no errors (the existing warnings only).Not run: no test here needs credentials, so none were skipped for that reason.
mise run test:integration:*was not run through mise (untrusted). Its steps (a plain cargo build, a copy, vitest) were covered by the runs above.Before the next auth release
I cannot run
release.ymlor_build-auth-artifacts.yml. Only the darwin-arm64 leg was reproduced, locally. Before merging a Version Packages PR that releases@cipherstash/auth, dispatchauth-preflight.ymlagainst it. Not verified:--target), linux-x64-gnu, linux-arm64-gnu, win32-x64-msvc, and above all linux-x64-musl. That one builds inside the Alpine container withpnpm install --frozen-lockfile --ignore-scripts --filter "@cipherstash/auth...", which now installs the larger v3 CLI tree on musl. The CLI's own platform helpers (@napi-rs/lzma,tar,wasm-tools) havelinux-x64-muslbuilds and are not loaded bynapi build, but that has not been run..pdb) to the package directory. The new added-file check would fail the leg if it did.C librarycheck and the musl load test (node -e "require(...)"in Alpine) on a v3-built binary.-no_fixup_chainslinker flag inlanguages/typescript/packages/auth/.cargo/config.toml. napi 3 still registers exports throughctor(now 1.0), and the locally built v3 binary exports every class, so the flag still applies. Its comment is unchanged.Review notes
--no-jschange and its comment in_build-auth-artifacts.yml. The v3 failure is quiet: a stray untracked file instead of an overwrittenindex.js.languages/typescript/packages/auth/src/lib.rs: theThreadsafeFunctionport. The#[napi]factories write the full types instead of the aliases, because napi buildsnative.d.tsfrom the type as written and would print the alias name.@napi-rs/clidependency, and it also pinsnapi-build = "2".