Skip to content

Commit

Permalink
added webauthn details to user object
Browse files Browse the repository at this point in the history
  • Loading branch information
niftyvictor committed Oct 18, 2024
1 parent 8c8d711 commit ced57b1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/ts/recipe/accountlinking/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export type AccountInfo = {
id: string;
userId: string;
};
webauthn?: {
credentialIds: string[];
};
};

export type AccountInfoWithRecipeId = {
Expand Down
3 changes: 3 additions & 0 deletions lib/ts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export type User = {
id: string;
userId: string;
}[];
webauthn: {
credentialIds: string[];
}[];
loginMethods: (RecipeLevelUser & {
verified: boolean;
hasSameEmailAs: (email: string | undefined) => boolean;
Expand Down
16 changes: 14 additions & 2 deletions lib/ts/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class LoginMethod implements RecipeLevelUser {
public readonly email?: string;
public readonly phoneNumber?: string;
public readonly thirdParty?: RecipeLevelUser["thirdParty"];
public readonly webauthn?: RecipeLevelUser["webauthn"];
public readonly verified: boolean;

public readonly timeJoined: number;
Expand All @@ -23,7 +24,7 @@ export class LoginMethod implements RecipeLevelUser {
this.email = loginMethod.email;
this.phoneNumber = loginMethod.phoneNumber;
this.thirdParty = loginMethod.thirdParty;

this.webauthn = loginMethod.webauthn;
this.timeJoined = loginMethod.timeJoined;
this.verified = loginMethod.verified;
}
Expand Down Expand Up @@ -73,6 +74,7 @@ export class LoginMethod implements RecipeLevelUser {
email: this.email,
phoneNumber: this.phoneNumber,
thirdParty: this.thirdParty,
webauthn: this.webauthn,
timeJoined: this.timeJoined,
verified: this.verified,
};
Expand All @@ -90,6 +92,9 @@ export class User implements UserType {
id: string;
userId: string;
}[];
public readonly webauthn: {
credentialIds: string[];
}[];
public readonly loginMethods: LoginMethod[];

public readonly timeJoined: number; // minimum timeJoined value from linkedRecipes
Expand All @@ -102,7 +107,7 @@ export class User implements UserType {
this.emails = user.emails;
this.phoneNumbers = user.phoneNumbers;
this.thirdParty = user.thirdParty;

this.webauthn = user.webauthn;
this.timeJoined = user.timeJoined;

this.loginMethods = user.loginMethods.map((m) => new LoginMethod(m));
Expand All @@ -117,6 +122,7 @@ export class User implements UserType {
emails: this.emails,
phoneNumbers: this.phoneNumbers,
thirdParty: this.thirdParty,
webauthn: this.webauthn,
loginMethods: this.loginMethods.map((m) => m.toJson()),

timeJoined: this.timeJoined,
Expand All @@ -135,6 +141,9 @@ export type UserWithoutHelperFunctions = {
id: string;
userId: string;
}[];
webauthn: {
credentialIds: string[];
}[];
loginMethods: {
recipeId: "emailpassword" | "thirdparty" | "passwordless" | "webauthn";
recipeUserId: string;
Expand All @@ -146,6 +155,9 @@ export type UserWithoutHelperFunctions = {
id: string;
userId: string;
};
webauthn?: {
credentialIds: string[];
};

verified: boolean;
timeJoined: number;
Expand Down

0 comments on commit ced57b1

Please sign in to comment.