-
Notifications
You must be signed in to change notification settings - Fork 4
feat: abstract google & facebook account as external_accounts, fix (d… #14
Conversation
@yourtallness We should do the same in the go SDK about google and facebook, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍 - just a tiny issue with the canned JSON responses.
I checked the go sdk with @alex-ntousias and the external_accounts are not typed there, so currently nothing to do there. |
87f0b03
to
499f8d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done @yourtallness . Happy for this to get merged. 💯 🚀
| primaryEmailAddressID | string | | ||
| primaryPhoneNumberID | string | | ||
| publicMetadata | Record<string, unknown> | | ||
| privateMetadata | Record<string, unknown> | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Out of curiosity, what is Record
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to SO:
Record is JavaScript's Object used as a map (key-value pair).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -37,6 +36,16 @@ export class UserApi extends AbstractApi { | |||
userId: string, | |||
params: UserParams = {} | |||
): Promise<User> { | |||
// The Clerk server API requires metadata fields to be stringified | |||
|
|||
if (params.publicMetadata && !(typeof params.publicMetadata == 'string')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Why do you check if the public metadata is already string? To cover for cases where the user has already stringify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have at least one known case of a dev passing it stringified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…e)serialization for public & private metadata
499f8d9
to
0a9d071
Compare
…e)serialization for public & private metadata
BREAKING:
GoogleAccount
resource is no more, replaced byExternalAccount
.Also serializes public / private metadata to string to match the format the server expects.
Public / Private metadata converted to
Record<string, unknown>
(fromobject
) to enable attribute access.