Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed Jan 20, 2024
2 parents 00f95cc + 20a0916 commit b41d641
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ export class WebAuthnStrategy<User> extends Strategy<
return rp;
}

async generateOptions(
async generateOptions<ExtraData>(
request: Request,
sessionStorage: SessionStorage<SessionData, SessionData>,
user: User | null
user: User | null,
extraData?: ExtraData
) {
let session = await sessionStorage.getSession(
request.headers.get("Cookie")
Expand Down Expand Up @@ -226,7 +227,8 @@ export class WebAuthnStrategy<User> extends Strategy<

const crypto = await import("tiny-webcrypto");

const options: WebAuthnOptionsResponse = {
type ExtraKey = ExtraData extends undefined ? undefined : ExtraData;
const options: WebAuthnOptionsResponse & { extra: ExtraKey } = {
usernameAvailable,
rp,
user: userDetails
Expand All @@ -240,6 +242,7 @@ export class WebAuthnStrategy<User> extends Strategy<
type: "public-key",
transports: transports as AuthenticatorTransportFuture[],
})),
extra: extraData as ExtraKey
};

session.set("challenge", options.challenge);
Expand Down

0 comments on commit b41d641

Please sign in to comment.