mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 06:42:59 +00:00
u2f registration request
This commit is contained in:
@@ -18,6 +18,12 @@ export async function POST(request: NextRequest) {
|
||||
const session = await getSession(sessionCookie.id, sessionCookie.token);
|
||||
|
||||
const userId = session?.session?.factors?.user?.id;
|
||||
console.log("payload", {
|
||||
passkeyId,
|
||||
passkeyName,
|
||||
publicKeyCredential,
|
||||
userId,
|
||||
});
|
||||
if (userId) {
|
||||
return verifyPasskeyRegistration({
|
||||
passkeyId,
|
||||
|
||||
@@ -22,12 +22,15 @@ export async function POST(request: NextRequest) {
|
||||
const userId = session?.session?.factors?.user?.id;
|
||||
|
||||
if (userId) {
|
||||
const req: PlainMessage<VerifyU2FRegistrationRequest> = {
|
||||
let req: PlainMessage<VerifyU2FRegistrationRequest> = {
|
||||
publicKeyCredential,
|
||||
u2fId,
|
||||
userId,
|
||||
tokenName: passkeyName,
|
||||
};
|
||||
|
||||
req = VerifyU2FRegistrationRequest.fromJson(request as any);
|
||||
|
||||
return verifyU2FRegistration(req)
|
||||
.then((resp) => {
|
||||
return NextResponse.json(resp);
|
||||
|
||||
@@ -435,7 +435,8 @@ export async function getActiveIdentityProviders(orgId?: string) {
|
||||
export async function verifyPasskeyRegistration(
|
||||
request: PartialMessage<VerifyPasskeyRegistrationRequest>,
|
||||
) {
|
||||
request.publicKeyCredential = (request.publicKeyCredential as any).toJson();
|
||||
// TODO: find a better way to handle this
|
||||
request = VerifyPasskeyRegistrationRequest.fromJson(request as any);
|
||||
return userService.verifyPasskeyRegistration(request, {});
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ export default function RegisterU2F({
|
||||
return submitRegister().then((resp: RegisterU2FResponse) => {
|
||||
const u2fId = resp.u2fId;
|
||||
const options: CredentialCreationOptions =
|
||||
(resp.publicKeyCredentialCreationOptions?.toJson() as CredentialCreationOptions) ??
|
||||
(resp.publicKeyCredentialCreationOptions as CredentialCreationOptions) ??
|
||||
{};
|
||||
|
||||
if (options.publicKey) {
|
||||
|
||||
Reference in New Issue
Block a user