Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/actions/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe('Actions', () => {
externalId: null,
metadata: {},
},
authenticationMethod: 'Password',
ipAddress: '50.141.123.10',
userAgent: 'Mozilla/5.0',
deviceFingerprint: 'notafingerprint',
Expand Down Expand Up @@ -183,6 +184,7 @@ describe('Actions', () => {
firstName: 'Jane',
lastName: 'Doe',
},
authenticationMethod: 'GoogleOAuth',
ipAddress: '50.141.123.10',
userAgent: 'Mozilla/5.0',
deviceFingerprint: 'notafingerprint',
Expand All @@ -197,5 +199,19 @@ describe('Actions', () => {
}),
});
});

it('leaves the authentication method undefined when the payload omits it', async () => {
const { authentication_method: _omitted, ...payload } =
mockAuthActionContext;
const sigHeader = makeSigHeader(payload, secret);
const action = await workos.actions.constructAction({
payload,
sigHeader,
secret,
});

expect(action.authenticationMethod).toBeUndefined();
expect(action.object).toEqual('authentication_action_context');
});
});
});
1 change: 1 addition & 0 deletions src/actions/fixtures/authentication-action-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"created_at": "2024-10-22T17:12:50.746Z",
"updated_at": "2024-10-22T17:12:50.746Z"
},
"authentication_method": "Password",
"ip_address": "50.141.123.10",
"user_agent": "Mozilla/5.0",
"device_fingerprint": "notafingerprint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"first_name": "Jane",
"last_name": "Doe"
},
"authentication_method": "GoogleOAuth",
"ip_address": "50.141.123.10",
"user_agent": "Mozilla/5.0",
"device_fingerprint": "notafingerprint",
Expand Down
5 changes: 5 additions & 0 deletions src/actions/interfaces/action.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
OrganizationResponse,
} from '../../organizations/interfaces';
import {
AuthenticationMethod,
Invitation,
InvitationResponse,
OrganizationMembership,
Expand All @@ -17,6 +18,7 @@ interface AuthenticationActionContext {
user: User;
organization?: Organization;
organizationMembership?: OrganizationMembership;
authenticationMethod?: AuthenticationMethod;
ipAddress?: string;
userAgent?: string;
deviceFingerprint?: string;
Expand All @@ -36,6 +38,7 @@ interface UserRegistrationActionContext {
object: 'user_registration_action_context';
userData: UserData;
invitation?: Invitation;
authenticationMethod?: AuthenticationMethod;
ipAddress?: string;
userAgent?: string;
deviceFingerprint?: string;
Expand All @@ -50,6 +53,7 @@ interface AuthenticationActionPayload {
user: UserResponse;
organization?: OrganizationResponse;
organization_membership?: OrganizationMembershipResponse;
authentication_method?: AuthenticationMethod;
ip_address?: string;
user_agent?: string;
device_fingerprint?: string;
Expand All @@ -69,6 +73,7 @@ export interface UserRegistrationActionPayload {
object: 'user_registration_action_context';
user_data: UserDataPayload;
invitation?: InvitationResponse;
authentication_method?: AuthenticationMethod;
ip_address?: string;
user_agent?: string;
device_fingerprint?: string;
Expand Down
3 changes: 2 additions & 1 deletion src/actions/serializers/action.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const deserializeAction = (
invitation: actionPayload.invitation
? deserializeInvitation(actionPayload.invitation)
: undefined,

authenticationMethod: actionPayload.authentication_method,
ipAddress: actionPayload.ip_address,
userAgent: actionPayload.user_agent,
deviceFingerprint: actionPayload.device_fingerprint,
Expand All @@ -51,6 +51,7 @@ export const deserializeAction = (
actionPayload.organization_membership,
)
: undefined,
authenticationMethod: actionPayload.authentication_method,
ipAddress: actionPayload.ip_address,
userAgent: actionPayload.user_agent,
deviceFingerprint: actionPayload.device_fingerprint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Impersonator, ImpersonatorResponse } from './impersonator.interface';
import { OauthTokens, OauthTokensResponse } from './oauth-tokens.interface';
import { User, UserResponse } from './user.interface';

type AuthenticationMethod =
export type AuthenticationMethod =
| 'SSO'
| 'Password'
| 'Passkey'
Expand All @@ -12,6 +12,8 @@ type AuthenticationMethod =
| 'GitHubOAuth'
| 'GitLabOAuth'
| 'GoogleOAuth'
| 'GrokOAuth'
| 'XOAuth'
| 'IntuitOAuth'
| 'LinkedInOAuth'
| 'MicrosoftOAuth'
Expand Down