refactor(passkey): derive the policy codes by subtraction so additions break the build - #145
Open
Bccorb wants to merge 1 commit into
Open
refactor(passkey): derive the policy codes by subtraction so additions break the build#145Bccorb wants to merge 1 commit into
Bccorb wants to merge 1 commit into
Conversation
…s break the build PasskeyPolicyErrorCode already came from @seamless-auth/types 0.16.0, but it picked its four members out of WebAuthnErrorCode with Extract. That catches a rename or a removal upstream, since the name resolves to never, and misses the case the check exists for: a code added to WebAuthnErrorCode is simply not extracted, PASSKEY_POLICY_ERROR_CODES still compiles, and the SDK quietly degrades the new refusal to generic messaging. Take the union minus prf_output_not_allowed instead. A new code lands in PasskeyPolicyErrorCode, and both Record maps over it, the recognition list here and POLICY_REFUSAL_MESSAGES in PassKeyRegistration, fail to compile until it is handled or excluded on purpose. prf_output_not_allowed stays out. It is a 400 from login and step-up finish (webauthn.ts verifyWebAuthn, stepUp.ts finishWebAuthnStepUp), reporting a caller that failed to strip PRF output rather than a deployment refusing an authenticator, so getPasskeyPolicyErrorCode should not report it as a policy refusal. The type resolves to the same four members, so no behaviour changes and no changeset is needed.
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.
What
PasskeyPolicyErrorCodeinsrc/client/errors.tsalready came from@seamless-auth/types0.16.0 (WebAuthnErrorCode), and the dependency isalready on
^0.16.0, so the switch the AGENTS.md note asked for had landed. Whathad not landed is the property the note wanted from it.
Extract<WebAuthnErrorCode, 'attachment_not_allowed' | ...>catches a rename ora removal upstream, since the missing name resolves to
never. It misses anaddition: a code added to
WebAuthnErrorCodeis simply not extracted,PASSKEY_POLICY_ERROR_CODESstill compiles, and the SDK quietly degrades the newrefusal to generic messaging. That is the silent drift the union exists to
prevent.
This takes the union minus
prf_output_not_allowedinstead. A new upstream codelands in
PasskeyPolicyErrorCode, and bothRecords over it fail to compileuntil it is handled or excluded deliberately.
Confirmed by temporarily adding a member to the installed
WebAuthnErrorCodeSchemadeclaration and runningnpm run typecheck:The second one is the point: an addition forces the user-facing copy in
POLICY_REFUSAL_MESSAGESto be written too, not just the recognition list.prf_output_not_allowed stays out
The published union includes it, and
getPasskeyPolicyErrorCode()should notrecognize it. In the API it is a
400from login finish and step-up finish(
webauthn.tsverifyWebAuthn,stepUp.tsfinishWebAuthnStepUp), never fromregistration. It reports a caller that failed to strip PRF output, not a
deployment refusing an authenticator, so reporting it as a policy refusal would
point an integrator at their configuration for what is a bug in their own code.
tests/errors.test.tsalready asserts it is ignored.Docs
The AGENTS.md paragraph claiming the types package publishes no such union and
that the list is a local copy is replaced with what the code now does, including
why the type is derived by subtraction rather than by listing the wanted names.
Checks
npm run typecheckcleannpm run lintcleannpm run format:checkcleannpm test32 suites, 319 tests, all passingNo changeset: the type resolves to the same four members and no runtime
behaviour or public type changes.