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
7 changes: 7 additions & 0 deletions .changeset/breezy-mirrors-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/clerk-js': patch
'@clerk/backend': patch
'@clerk/types': patch
---

Expose the 'external_account.phone_number' property. This represents the associated phone number, if exists, with the specific external account
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/ExternalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class ExternalAccount {
readonly lastName: string,
readonly imageUrl: string,
readonly username: string | null,
readonly phoneNumber: string | null,
readonly publicMetadata: Record<string, unknown> | null = {},
readonly label: string | null,
readonly verification: Verification | null,
Expand All @@ -30,6 +31,7 @@ export class ExternalAccount {
data.last_name,
data.image_url || '',
data.username,
data.phone_number,
data.public_metadata,
data.label,
data.verification && Verification.fromJSON(data.verification),
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface ExternalAccountJSON extends ClerkResourceJSON {
last_name: string;
image_url?: string;
username: string | null;
phone_number: string | null;
public_metadata?: Record<string, unknown> | null;
label: string | null;
verification: VerificationJSON | null;
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/fixtures/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"last_name": "Doe",
"avatar_url": "https://clerk.com/test.jpg",
"username": "jdoe",
"phone_number": "+306900000000",
"public_metadata": {},
"label": null,
"verification": null,
Expand Down
3 changes: 3 additions & 0 deletions packages/clerk-js/src/core/resources/ExternalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
lastName = '';
imageUrl = '';
username = '';
phoneNumber = '';
publicMetadata = {};
label = '';
verification: VerificationResource | null = null;
Expand Down Expand Up @@ -59,6 +60,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
// TODO: Send the provider name the `oauth` prefix from FAPI
this.provider = (data.provider || '').replace('oauth_', '') as OAuthProvider;
this.username = data.username;
this.phoneNumber = data.phone_number;
this.publicMetadata = data.public_metadata;
this.label = data.label;

Expand All @@ -81,6 +83,7 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
last_name: this.lastName,
image_url: this.imageUrl,
username: this.username,
phone_number: this.phoneNumber,
public_metadata: this.publicMetadata,
label: this.label,
verification: this.verification?.__internal_toSnapshot() || null,
Expand Down
1 change: 1 addition & 0 deletions packages/clerk-js/src/core/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const createExternalAccount = (params?: Partial<ExternalAccountJSON>): Ex
last_name: 'Last name',
image_url: '',
username: '',
phoneNumber: '',
verification: {
status: 'verified',
strategy: '',
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/externalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ExternalAccountResource extends ClerkResource {
lastName: string;
imageUrl: string;
username?: string;
phoneNumber?: string;
publicMetadata: Record<string, unknown>;
label?: string;
verification: VerificationResource | null;
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export interface ExternalAccountJSON extends ClerkResourceJSON {
last_name: string;
image_url: string;
username: string;
phone_number: string;
public_metadata: Record<string, unknown>;
label: string;
verification?: VerificationJSON;
Expand Down