Skip to content

Commit

Permalink
Remove return types from getUser as they were not correct. (#156)
Browse files Browse the repository at this point in the history
Co-authored-by: Fahad Sadiq <fahad.sadiq@vtnetzwelt.com>
Co-authored-by: =fahadsadiq <=fahad_sadiq@live.com>
  • Loading branch information
3 people authored Mar 27, 2024
1 parent 4b908cd commit 7e1017b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/cognito-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ interface GetCredentialsForIdentityResponse {
IdentityId: string;
}

interface GetUserResponse {
MFAOptions: {
AttributeName: string;
DeliveryMedium: string;
}[];
PreferredMfaSetting: string;
UserAttributes: {
Name: string;
Value: string;
}[];
UserMFASettingList: string[];
Username: string;
}

export function isErrorResponse(obj: unknown): obj is ErrorResponse {
return (
!!obj && typeof obj === "object" && "__type" in obj && "message" in obj
Expand Down Expand Up @@ -363,7 +377,7 @@ export async function getUser({
}: {
abort?: AbortSignal;
accessToken?: string;
}): Promise<{ Name: string; Value: string }[]> {
}) {
const { fetch, cognitoIdpEndpoint, proxyApiHeaders } = configure();
const token = accessToken ?? (await retrieveTokens())?.accessToken;
return await fetch(
Expand All @@ -384,7 +398,7 @@ export async function getUser({
}
)
.then(throwIfNot2xx)
.then((res) => res.json() as Promise<{ Name: string; Value: string }[]>);
.then((res) => res.json() as Promise<GetUserResponse | ErrorResponse>);
}

export async function getCredentialsForIdentity({
Expand Down

0 comments on commit 7e1017b

Please sign in to comment.