Skip to content

Commit

Permalink
Add device fingerprint to action context payloads (#1199)
Browse files Browse the repository at this point in the history
When Radar is enabled, the device fingerprint captured by Radar is
forwarded in action request payloads. This PR adds the attribute to
action interfaces.

## Description

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
  • Loading branch information
debussyman authored Jan 13, 2025
1 parent 877f3a3 commit 31c51f7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/actions/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('Actions', () => {
},
ipAddress: '50.141.123.10',
userAgent: 'Mozilla/5.0',
deviceFingerprint: 'notafingerprint',
issuer: 'test',
object: 'authentication_action_context',
organization: {
Expand Down Expand Up @@ -175,6 +176,7 @@ describe('Actions', () => {
},
ipAddress: '50.141.123.10',
userAgent: 'Mozilla/5.0',
deviceFingerprint: 'notafingerprint',
invitation: expect.objectContaining({
object: 'invitation',
id: '01JBVZWH8HJ855YZ5BWHG1WNZN',
Expand Down
3 changes: 2 additions & 1 deletion src/actions/fixtures/authentication-action-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"ip_address": "50.141.123.10",
"user_agent": "Mozilla/5.0",
"device_fingerprint": "notafingerprint",
"issuer": "test",
"object": "authentication_action_context",
"organization": {
Expand All @@ -37,4 +38,4 @@
"created_at": "2024-10-22T17:12:50.746Z",
"updated_at": "2024-10-22T17:12:50.746Z"
}
}
}
5 changes: 3 additions & 2 deletions src/actions/fixtures/user-registration-action-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"ip_address": "50.141.123.10",
"user_agent": "Mozilla/5.0",
"device_fingerprint": "notafingerprint",
"object": "user_registration_action_context",
"invitation": {
"object": "invitation",
Expand All @@ -20,5 +21,5 @@
"revoked_at": null,
"organization_id": "01JBW46BTKAA98WZN8826XQ2YP",
"inviter_user_id": "01JBVZWAEPWAE3YYKBVT0AF81F"
}
}
}
}
4 changes: 4 additions & 0 deletions src/actions/interfaces/action.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface AuthenticationActionContext {
organizationMembership?: OrganizationMembership;
ipAddress?: string;
userAgent?: string;
deviceFingerprint?: string;
issuer?: string;
}

Expand All @@ -36,6 +37,7 @@ interface UserRegistrationActionContext {
invitation?: Invitation;
ipAddress?: string;
userAgent?: string;
deviceFingerprint?: string;
}

export type ActionContext =
Expand All @@ -50,6 +52,7 @@ interface AuthenticationActionPayload {
organization_membership?: OrganizationMembershipResponse;
ip_address?: string;
user_agent?: string;
device_fingerprint?: string;
issuer?: string;
}

Expand All @@ -67,6 +70,7 @@ export interface UserRegistrationActionPayload {
invitation?: InvitationResponse;
ip_address?: string;
user_agent?: string;
device_fingerprint?: string;
}

export type ActionPayload =
Expand Down
2 changes: 2 additions & 0 deletions src/actions/serializers/action.serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const deserializeAction = (

ipAddress: actionPayload.ip_address,
userAgent: actionPayload.user_agent,
deviceFingerprint: actionPayload.device_fingerprint,
};
case 'authentication_action_context':
return {
Expand All @@ -51,6 +52,7 @@ export const deserializeAction = (
: undefined,
ipAddress: actionPayload.ip_address,
userAgent: actionPayload.user_agent,
deviceFingerprint: actionPayload.device_fingerprint,
issuer: actionPayload.issuer,
};
}
Expand Down

0 comments on commit 31c51f7

Please sign in to comment.