feat: expose authentication method on action contexts - #1671
Merged
Conversation
The API now sends authentication_method on both action payloads; surface it on ActionContext so Actions can branch on how the user authenticated or signed up. Also export AuthenticationMethod, which gains the GrokOAuth and XOAuth values the API already returns. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Original prompt from deborah.digges
|
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryThe PR exposes the signed Actions payload’s authentication method through the SDK and expands the shared authentication-method union.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix: make authenticationMethod optional ..." | Re-trigger Greptile |
Declaring the field as required made it a type-level breaking change for anyone constructing an ActionPayload or ActionContext, and the deserializer cannot honor the guarantee anyway: constructAction casts parsed JSON without validating it, so a payload sent before the API rollout completes yields undefined behind a type that promises a value. Actions gate allow/deny verdicts, so a policy branching on the method should be forced to handle its absence rather than trust a nominal guarantee. Optional on all four types keeps the payload and context shapes consistent; splitting them would not compile in the serializer under strict mode.
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.
Description
Follow-up to workos/workos#68754, which adds
authentication_methodto both Actions payloads. The SDK'sdeserializeActionbuilds its result field-by-field, so it silently drops the new field — SDK users can't see it until it's mapped here.interface UserRegistrationActionContext { userData: UserData; invitation?: Invitation; + authenticationMethod: AuthenticationMethod; }…and the same on
AuthenticationActionContext, so an Action can do:Two things worth flagging:
AuthenticationMethodwas private toauthentication-response.interface.ts; it's nowexported (so it's part of the public API via the existingexport *) and reused for actions rather than duplicated. While reusing it I noticed it was missingGrokOAuthandXOAuth, which the API's enum has had — added.ActionPayloadSchemaCommon. That's technically a breaking change for anyone hand-constructing anActionPayload(test fixtures, mocks); it doesn't affect runtime behavior, since nothing validates the payload — an older API that omitted the field would just yieldundefined.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
The Actions docs list the payload fields, so they'll want
authentication_methodadded — but that's driven by the API change in workos/workos#68754, not by this PR.Test plan
npx jest src/actions,npx tsc --noEmit,npx eslint, and prettier all pass locally; the action fixtures now carryauthentication_method(Password/GoogleOAuth) and theconstructActionassertions cover the deserialized value.Link to Devin session: https://app.devin.ai/sessions/d1b4af9c560e47399605005a3b923af6
Requested by: @Deborah-Digges