fix(organizations): correct member and switch response types#95
Merged
Conversation
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
Audit every client response type against the API's declared response schemas, and fix the three that were wrong.
Closes #90.
Method
seamless-auth-apideclares a response schema per route insrc/routes/*.routes.ts. That is a stronger source than reading controller bodies and does not need a running server, so I mapped every route the SDK calls to its declared schema and compared each against the SDK type.Fixed
addOrganizationMember{ membership }{ members, total }updateOrganizationMember{ membership }{ members, total }removeOrganizationMember{ message }{ members, total }switchOrganization{ message, token, sub, sessionId, organizationId, organization, ttl }{ organization }The first three are the same defect as #88: a caller reading
.membersgetsundefined.switchOrganizationwas not broken, since{ organization }is a subset, but it hidmessageandorganizationIdfrom consumers.Confirmed correct, no change
The rest of the surface matched, including the parts I was least sure about:
/users/mematchesCurrentUserResultexactly, including the optionalorganizationsand nullableactiveOrganizationStepUpStatusmatchesStepUpStatusSchemafield for field, andStepUpSuccessSchemaconfirms themessage/fresh/methodtriple thattoStepUpStatuschecksTotpStatusandTotpEnrollmentStartResultmatchGET /organizations,GET /:id,POST /,PATCH /:id, andGET /:id/membersmatchregister, the OTP endpoints, magic-link verify, and the WebAuthn finish endpoints all carrymessage, soMessageResultis accurateI also confirmed the literal
message === 'Success'comparisons the code depends on.registration.ts,authentication.ts,stepUp.ts, andsessionIssuance.tsall send exactly'Success'.The magic-link fix is confirmed correct
GET /magic-link/checkdeclares both200: MagicLinkPollSuccessSchemaand204: MessageSchema, and its success path runs throughissueSessionAndRespond, which sends200 { message: 'Success' }. That is exactly what the fix in #86 checks for, and the not-yet-clicked paths return a bodyless 204. Independent confirmation that the fix matches the real contract rather than only the test.A deliberate omission
OrganizationSwitchResultmodelsmessage,organizationId, andorganization, but not thetoken,sub,sessionId, andttlthe endpoint also returns. This SDK is cookie-based, so adopters have no reason to handle raw session material, and typing it would invite them to. The fields are still present at runtime for anyone who needs them.Note for the end-to-end run
Several endpoints answer
201rather than200(POST /organizations,POST /:id/members). That is handled correctly, since success is determined byresponse.ok, not an exact status. The one place an exact status mattered was the magic-link poll, which is now explicit.Checks
npm run typecheck,npm run lint,npm run format:checkclean