mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:32:39 +00:00
u2fId
This commit is contained in:
@@ -6,7 +6,7 @@ import { NextRequest, NextResponse, userAgent } from "next/server";
|
|||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
if (body) {
|
if (body) {
|
||||||
let { passkeyId, passkeyName, publicKeyCredential, sessionId } = body;
|
let { u2fId, passkeyName, publicKeyCredential, sessionId } = body;
|
||||||
|
|
||||||
if (!!!passkeyName) {
|
if (!!!passkeyName) {
|
||||||
const { browser, device, os } = userAgent(request);
|
const { browser, device, os } = userAgent(request);
|
||||||
@@ -27,7 +27,7 @@ export async function POST(request: NextRequest) {
|
|||||||
if (userId) {
|
if (userId) {
|
||||||
const req: VerifyU2FRegistrationRequest = {
|
const req: VerifyU2FRegistrationRequest = {
|
||||||
publicKeyCredential,
|
publicKeyCredential,
|
||||||
u2fId: passkeyId,
|
u2fId,
|
||||||
userId,
|
userId,
|
||||||
tokenName: passkeyName,
|
tokenName: passkeyName,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
CreateSessionResponse,
|
CreateSessionResponse,
|
||||||
GetBrandingSettingsResponse,
|
GetBrandingSettingsResponse,
|
||||||
GetPasswordComplexitySettingsResponse,
|
GetPasswordComplexitySettingsResponse,
|
||||||
AddMyAuthFactorOTPResponse,
|
RegisterU2FResponse,
|
||||||
GetLegalAndSupportSettingsResponse,
|
GetLegalAndSupportSettingsResponse,
|
||||||
AddHumanUserResponse,
|
AddHumanUserResponse,
|
||||||
BrandingSettings,
|
BrandingSettings,
|
||||||
@@ -509,7 +509,7 @@ export async function createPasskeyRegistrationLink(
|
|||||||
export async function registerU2F(
|
export async function registerU2F(
|
||||||
userId: string,
|
userId: string,
|
||||||
domain: string
|
domain: string
|
||||||
): Promise<any> {
|
): Promise<RegisterU2FResponse> {
|
||||||
const userservice = user.getUser(server);
|
const userservice = user.getUser(server);
|
||||||
|
|
||||||
return userservice.registerU2F({
|
return userservice.registerU2F({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useForm } from "react-hook-form";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Spinner } from "./Spinner";
|
import { Spinner } from "./Spinner";
|
||||||
import Alert from "./Alert";
|
import Alert from "./Alert";
|
||||||
import { AuthRequest, RegisterPasskeyResponse } from "@zitadel/server";
|
import { RegisterU2FResponse } from "@zitadel/server";
|
||||||
import { coerceToArrayBuffer, coerceToBase64Url } from "#/utils/base64";
|
import { coerceToArrayBuffer, coerceToBase64Url } from "#/utils/base64";
|
||||||
type Inputs = {};
|
type Inputs = {};
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ export default function RegisterU2F({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submitVerify(
|
async function submitVerify(
|
||||||
passkeyId: string,
|
u2fId: string,
|
||||||
passkeyName: string,
|
passkeyName: string,
|
||||||
publicKeyCredential: any,
|
publicKeyCredential: any,
|
||||||
sessionId: string
|
sessionId: string
|
||||||
@@ -67,7 +67,7 @@ export default function RegisterU2F({
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
passkeyId,
|
u2fId,
|
||||||
passkeyName,
|
passkeyName,
|
||||||
publicKeyCredential,
|
publicKeyCredential,
|
||||||
sessionId,
|
sessionId,
|
||||||
@@ -85,8 +85,8 @@ export default function RegisterU2F({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitRegisterAndContinue(value: Inputs): Promise<boolean | void> {
|
function submitRegisterAndContinue(value: Inputs): Promise<boolean | void> {
|
||||||
return submitRegister().then((resp: RegisterPasskeyResponse) => {
|
return submitRegister().then((resp: RegisterU2FResponse) => {
|
||||||
const passkeyId = resp.passkeyId;
|
const u2fId = resp.u2fId;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
resp.publicKeyCredentialCreationOptions &&
|
resp.publicKeyCredentialCreationOptions &&
|
||||||
@@ -145,7 +145,7 @@ export default function RegisterU2F({
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return submitVerify(passkeyId, "", data, sessionId).then(() => {
|
return submitVerify(u2fId, "", data, sessionId).then(() => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ export {
|
|||||||
VerifyTOTPRegistrationResponse,
|
VerifyTOTPRegistrationResponse,
|
||||||
VerifyU2FRegistrationRequest,
|
VerifyU2FRegistrationRequest,
|
||||||
VerifyU2FRegistrationResponse,
|
VerifyU2FRegistrationResponse,
|
||||||
|
RegisterU2FResponse,
|
||||||
|
RegisterU2FRequest,
|
||||||
} from "./proto/server/zitadel/user/v2beta/user_service";
|
} from "./proto/server/zitadel/user/v2beta/user_service";
|
||||||
|
|
||||||
export { AuthFactor } from "./proto/server/zitadel/user";
|
export { AuthFactor } from "./proto/server/zitadel/user";
|
||||||
|
|||||||
Reference in New Issue
Block a user