Skip to content

Commit 93068ea

Browse files
authored
fix(clerk-js): Rename the sendCaptchaToken to __internal_sendCaptchaToken (#5581)
1 parent 4f52bdc commit 93068ea

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

.changeset/eight-wombats-hunt.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Rename the `sendCaptchaToken` to `__internal_sendCaptchaToken`.

packages/clerk-js/src/core/auth/CaptchaHeartbeat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class CaptchaHeartbeat {
2828

2929
try {
3030
const params = await this.captchaChallenge.invisible({ action: 'heartbeat' });
31-
await this.clerk.client.sendCaptchaToken(params);
31+
await this.clerk.client.__internal_sendCaptchaToken(params);
3232
} catch {
3333
// Ignore unhandled errors
3434
}

packages/clerk-js/src/core/fraudProtection.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('FraudProtectionService', () => {
2929
);
3030

3131
const mockClientInstance = {
32-
sendCaptchaToken: jest.fn().mockResolvedValue({}),
32+
__internal_sendCaptchaToken: jest.fn().mockResolvedValue({}),
3333
};
3434

3535
mockClient = {
@@ -55,7 +55,7 @@ describe('FraudProtectionService', () => {
5555

5656
// only one will need to call the captcha as the other will be blocked
5757
expect(mockManagedInModal).toHaveBeenCalledTimes(0);
58-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(0);
58+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(0);
5959
expect(fn1).toHaveBeenCalledTimes(1);
6060
});
6161

@@ -68,7 +68,7 @@ describe('FraudProtectionService', () => {
6868
const fn1res = sut.execute(mockClerk, fn1);
6969
expect(fn1res).rejects.toEqual(unrelatedError);
7070
expect(mockManagedInModal).toHaveBeenCalledTimes(0);
71-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(0);
71+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(0);
7272
expect(fn1).toHaveBeenCalledTimes(1);
7373
});
7474

@@ -88,7 +88,7 @@ describe('FraudProtectionService', () => {
8888

8989
// only one will need to call the captcha as the other will be blocked
9090
expect(mockManagedInModal).toHaveBeenCalledTimes(1);
91-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(1);
91+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(1);
9292
expect(fn1).toHaveBeenCalledTimes(2);
9393
});
9494

@@ -108,7 +108,7 @@ describe('FraudProtectionService', () => {
108108

109109
// captcha will only be called once
110110
expect(mockManagedInModal).toHaveBeenCalledTimes(1);
111-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(1);
111+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(1);
112112
// but all failed requests will be retried
113113
expect(fn1).toHaveBeenCalledTimes(2);
114114
expect(fn2).toHaveBeenCalledTimes(2);
@@ -135,7 +135,7 @@ describe('FraudProtectionService', () => {
135135
await Promise.all([fn1res, fn2res]);
136136

137137
expect(mockManagedInModal).toHaveBeenCalledTimes(1);
138-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(1);
138+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(1);
139139
expect(fn1).toHaveBeenCalledTimes(2);
140140
expect(fn2).toHaveBeenCalledTimes(1);
141141
});
@@ -168,7 +168,7 @@ describe('FraudProtectionService', () => {
168168
await Promise.all([fn2res, fn3res]);
169169

170170
expect(mockManagedInModal).toHaveBeenCalledTimes(1);
171-
expect(mockClient.getOrCreateInstance().sendCaptchaToken).toHaveBeenCalledTimes(1);
171+
expect(mockClient.getOrCreateInstance().__internal_sendCaptchaToken).toHaveBeenCalledTimes(1);
172172

173173
expect(fn1).toHaveBeenCalledTimes(2);
174174
expect(fn2).toHaveBeenCalledTimes(2);

packages/clerk-js/src/core/fraudProtection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class FraudProtection {
6060
try {
6161
const captchaParams: any = await this.managedChallenge(clerk);
6262
if (captchaParams?.captchaError !== 'modal_component_not_ready') {
63-
await this.client.getOrCreateInstance().sendCaptchaToken(captchaParams);
63+
await this.client.getOrCreateInstance().__internal_sendCaptchaToken(captchaParams);
6464
this.captchaRetryCount = 0; // Reset the retry count on success
6565
}
6666
} catch (err) {

packages/clerk-js/src/core/resources/Client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class Client extends BaseResource implements ClientResource {
117117
.toString();
118118
}
119119

120-
public sendCaptchaToken(params: unknown): Promise<ClientResource> {
120+
public __internal_sendCaptchaToken(params: unknown): Promise<ClientResource> {
121121
return this._basePostBypass({ body: params, path: this.path() + '/verify' });
122122
}
123123

packages/clerk-js/src/core/resources/__tests__/Client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createSession, createSignIn, createSignUp, createUser } from '../../tes
44
import { BaseResource, Client } from '../internal';
55

66
describe('Client Singleton', () => {
7-
describe('sendCaptchaToken', () => {
7+
describe('__internal_sendCaptchaToken', () => {
88
it('sends captcha token', async () => {
99
const user = createUser({ first_name: 'John', last_name: 'Doe', id: 'user_1' });
1010
const session = createSession({ id: 'session_1' }, user);
@@ -24,7 +24,7 @@ describe('Client Singleton', () => {
2424
BaseResource._baseFetch = jest.fn();
2525

2626
const client = Client.getOrCreateInstance().fromJSON(clientObjectJSON);
27-
await client.sendCaptchaToken({ captcha_token: 'test_captcha_token' });
27+
await client.__internal_sendCaptchaToken({ captcha_token: 'test_captcha_token' });
2828
// @ts-expect-error This is a private method that we are mocking
2929
expect(BaseResource._baseFetch).toHaveBeenCalledWith({
3030
method: 'POST',
@@ -54,7 +54,7 @@ describe('Client Singleton', () => {
5454
BaseResource._baseFetch = jest.fn().mockResolvedValueOnce(Promise.resolve(null));
5555

5656
const client = Client.getOrCreateInstance().fromJSON(clientObjectJSON);
57-
await client.sendCaptchaToken({ captcha_token: 'test_captcha_token' });
57+
await client.__internal_sendCaptchaToken({ captcha_token: 'test_captcha_token' });
5858
// @ts-expect-error This is a private method that we are mocking
5959
expect(BaseResource._baseFetch).toHaveBeenCalledWith({
6060
method: 'POST',

packages/types/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface ClientResource extends ClerkResource {
1111
signIn: SignInResource;
1212
isNew: () => boolean;
1313
create: () => Promise<ClientResource>;
14-
sendCaptchaToken: (params: unknown) => Promise<ClientResource>;
1514
destroy: () => Promise<void>;
1615
removeSessions: () => Promise<ClientResource>;
1716
clearCache: () => void;
@@ -22,6 +21,7 @@ export interface ClientResource extends ClerkResource {
2221
cookieExpiresAt: Date | null;
2322
createdAt: Date | null;
2423
updatedAt: Date | null;
24+
__internal_sendCaptchaToken: (params: unknown) => Promise<ClientResource>;
2525
__internal_toSnapshot: () => ClientJSONSnapshot;
2626
/**
2727
* @deprecated Use `signedInSessions` instead

0 commit comments

Comments
 (0)