Skip to content

Commit f6f275d

Browse files
authored
feat(backend,clerk-js,types): Expose 'external_account.phone_number' property (#5557)
1 parent d7c0269 commit f6f275d

File tree

8 files changed

+17
-0
lines changed

8 files changed

+17
-0
lines changed

.changeset/breezy-mirrors-think.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/backend': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Expose the 'external_account.phone_number' property. This represents the associated phone number, if exists, with the specific external account

packages/backend/src/api/resources/ExternalAccount.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class ExternalAccount {
1313
readonly lastName: string,
1414
readonly imageUrl: string,
1515
readonly username: string | null,
16+
readonly phoneNumber: string | null,
1617
readonly publicMetadata: Record<string, unknown> | null = {},
1718
readonly label: string | null,
1819
readonly verification: Verification | null,
@@ -30,6 +31,7 @@ export class ExternalAccount {
3031
data.last_name,
3132
data.image_url || '',
3233
data.username,
34+
data.phone_number,
3335
data.public_metadata,
3436
data.label,
3537
data.verification && Verification.fromJSON(data.verification),

packages/backend/src/api/resources/JSON.ts

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export interface ExternalAccountJSON extends ClerkResourceJSON {
120120
last_name: string;
121121
image_url?: string;
122122
username: string | null;
123+
phone_number: string | null;
123124
public_metadata?: Record<string, unknown> | null;
124125
label: string | null;
125126
verification: VerificationJSON | null;

packages/backend/src/fixtures/user.json

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"last_name": "Doe",
8484
"avatar_url": "https://clerk.com/test.jpg",
8585
"username": "jdoe",
86+
"phone_number": "+306900000000",
8687
"public_metadata": {},
8788
"label": null,
8889
"verification": null,

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

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
2222
lastName = '';
2323
imageUrl = '';
2424
username = '';
25+
phoneNumber = '';
2526
publicMetadata = {};
2627
label = '';
2728
verification: VerificationResource | null = null;
@@ -59,6 +60,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
5960
// TODO: Send the provider name the `oauth` prefix from FAPI
6061
this.provider = (data.provider || '').replace('oauth_', '') as OAuthProvider;
6162
this.username = data.username;
63+
this.phoneNumber = data.phone_number;
6264
this.publicMetadata = data.public_metadata;
6365
this.label = data.label;
6466

@@ -81,6 +83,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
8183
last_name: this.lastName,
8284
image_url: this.imageUrl,
8385
username: this.username,
86+
phone_number: this.phoneNumber,
8487
public_metadata: this.publicMetadata,
8588
label: this.label,
8689
verification: this.verification?.__internal_toSnapshot() || null,

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

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const createExternalAccount = (params?: Partial<ExternalAccountJSON>): Ex
118118
last_name: 'Last name',
119119
image_url: '',
120120
username: '',
121+
phoneNumber: '',
121122
verification: {
122123
status: 'verified',
123124
strategy: '',

packages/types/src/externalAccount.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ExternalAccountResource extends ClerkResource {
2121
lastName: string;
2222
imageUrl: string;
2323
username?: string;
24+
phoneNumber?: string;
2425
publicMetadata: Record<string, unknown>;
2526
label?: string;
2627
verification: VerificationResource | null;

packages/types/src/json.ts

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export interface ExternalAccountJSON extends ClerkResourceJSON {
196196
last_name: string;
197197
image_url: string;
198198
username: string;
199+
phone_number: string;
199200
public_metadata: Record<string, unknown>;
200201
label: string;
201202
verification?: VerificationJSON;

0 commit comments

Comments
 (0)