Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export interface AuthenticateWithCodeAndVerifierOptions extends AuthenticateWith
codeVerifier: string;
code: string;
invitationToken?: string;
signalsId?: string;
}

export interface SerializedAuthenticateWithCodeAndVerifierOptions extends SerializedAuthenticatePublicClientBase {
grant_type: 'authorization_code';
code_verifier: string;
code: string;
invitation_token?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface AuthenticateWithCodeOptions extends AuthenticateWithOptionsBase
codeVerifier?: string;
code: string;
invitationToken?: string;
signalsId?: string;
}

export interface AuthenticateUserWithCodeCredentials {
Expand All @@ -18,4 +19,5 @@ export interface SerializedAuthenticateWithCodeOptions extends SerializedAuthent
code_verifier?: string;
code: string;
invitation_token?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface AuthenticateWithMagicAuthOptions extends AuthenticateWithOption
invitationToken?: string;
linkAuthorizationCode?: string;
radarAuthAttemptId?: string;
signalsId?: string;
}

export interface AuthenticateUserWithMagicAuthCredentials {
Expand All @@ -22,4 +23,5 @@ export interface SerializedAuthenticateWithMagicAuthOptions extends SerializedAu
invitation_token?: string;
link_authorization_code?: string;
radar_auth_attempt_id?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface AuthenticateWithPasswordOptions extends AuthenticateWithOptions
password: string;
invitationToken?: string;
radarAuthAttemptId?: string;
signalsId?: string;
}

export interface AuthenticateUserWithPasswordCredentials {
Expand All @@ -20,4 +21,5 @@ export interface SerializedAuthenticateWithPasswordOptions extends SerializedAut
password: string;
invitation_token?: string;
radar_auth_attempt_id?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface CreateMagicAuthOptions {
ipAddress?: string;
userAgent?: string;
radarAuthAttemptId?: string;
signalsId?: string;
}

export interface SerializedCreateMagicAuthOptions {
Expand All @@ -12,4 +13,5 @@ export interface SerializedCreateMagicAuthOptions {
ip_address?: string;
user_agent?: string;
radar_auth_attempt_id?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface CreateUserOptions {
metadata?: Record<string, string>;
ipAddress?: string;
userAgent?: string;
signalsId?: string;
}

export interface SerializedCreateUserOptions {
Expand All @@ -28,4 +29,5 @@ export interface SerializedCreateUserOptions {
metadata?: Record<string, string>;
ip_address?: string;
user_agent?: string;
signals_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const serializeAuthenticateWithCodeAndVerifierOptions = (
invitation_token: options.invitationToken,
ip_address: options.ipAddress,
user_agent: options.userAgent,
signals_id: options.signalsId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const serializeAuthenticateWithCodeOptions = (
invitation_token: options.invitationToken,
ip_address: options.ipAddress,
user_agent: options.userAgent,
signals_id: options.signalsId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export const serializeAuthenticateWithMagicAuthOptions = (
ip_address: options.ipAddress,
user_agent: options.userAgent,
radar_auth_attempt_id: options.radarAuthAttemptId,
signals_id: options.signalsId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const serializeAuthenticateWithPasswordOptions = (
ip_address: options.ipAddress,
user_agent: options.userAgent,
radar_auth_attempt_id: options.radarAuthAttemptId,
signals_id: options.signalsId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const serializeCreateMagicAuthOptions = (
ip_address: options.ipAddress,
user_agent: options.userAgent,
radar_auth_attempt_id: options.radarAuthAttemptId,
signals_id: options.signalsId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const serializeCreateUserOptions = (
metadata: options.metadata,
ip_address: options.ipAddress,
user_agent: options.userAgent,
signals_id: options.signalsId,
});
85 changes: 85 additions & 0 deletions src/user-management/user-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ describe('UserManagement', () => {

expect(user.radarAuthAttemptId).toBeUndefined();
});

it('sends signals_id when provided', async () => {
fetchOnce(userFixture);

await workos.userManagement.createUser({
email: 'test01@example.com',
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});
});

describe('authenticateUserWithMagicAuth', () => {
Expand Down Expand Up @@ -242,6 +255,21 @@ describe('UserManagement', () => {
});
});

it('sends signals_id when provided', async () => {
fetchOnce({ user: userFixture });

await workos.userManagement.authenticateWithMagicAuth({
clientId: 'proj_whatever',
code: '123456',
email: userFixture.email,
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});

describe('when sealSession = true', () => {
beforeEach(() => {
fetchOnce({
Expand Down Expand Up @@ -324,6 +352,21 @@ describe('UserManagement', () => {
});
});

it('sends signals_id when provided', async () => {
fetchOnce({ user: userFixture });

await workos.userManagement.authenticateWithPassword({
clientId: 'proj_whatever',
email: 'test01@example.com',
password: 'extra-secure',
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});

describe('when sealSession = true', () => {
beforeEach(() => {
fetchOnce({
Expand Down Expand Up @@ -400,6 +443,20 @@ describe('UserManagement', () => {
});
});

it('sends signals_id when provided', async () => {
fetchOnce({ user: userFixture });

await workos.userManagement.authenticateWithCode({
clientId: 'proj_whatever',
code: 'or this',
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});

describe('public client mode (with codeVerifier, no API key)', () => {
let publicWorkos: WorkOS;
let originalApiKey: string | undefined;
Expand Down Expand Up @@ -718,6 +775,21 @@ describe('UserManagement', () => {
});
});

it('sends signals_id when provided', async () => {
fetchOnce({ user: userFixture });

await workos.userManagement.authenticateWithCodeAndVerifier({
clientId: 'proj_whatever',
code: 'auth_code_123',
codeVerifier: 'required_code_verifier',
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});

describe('when sealSession = true', () => {
beforeEach(() => {
fetchOnce({
Expand Down Expand Up @@ -1847,6 +1919,19 @@ describe('UserManagement', () => {

expect(response.radarAuthAttemptId).toBeUndefined();
});

it('sends signals_id when provided', async () => {
fetchOnce(magicAuthFixture);

await workos.userManagement.createMagicAuth({
email: 'bob.loblaw@example.com',
signalsId: 'signals_01ABC',
});

expect(fetchBody()).toMatchObject({
signals_id: 'signals_01ABC',
});
});
});

describe('getPasswordReset', () => {
Expand Down
Loading