choose factor when multiple, register u2f, verify u2f

This commit is contained in:
peintnermax
2024-04-30 10:39:34 +02:00
parent 88030ff2b9
commit b01ca12e53
13 changed files with 863 additions and 235 deletions

View File

@@ -1,3 +1,4 @@
import { VerifyU2FRegistrationRequest } from "@zitadel/server";
import {
GetUserByIDResponse,
RegisterTOTPResponse,
@@ -348,14 +349,6 @@ export async function getUserByID(
return userService.getUserByID({ userId }, {});
}
export async function listHumanAuthFactors(
server: ZitadelServer,
userId: string
): Promise<ListHumanAuthFactorsResponse> {
const managementService = management.getManagement(server);
return managementService.listHumanAuthFactors({ userId }, {});
}
export async function listUsers(
userName: string,
organizationId: string
@@ -483,16 +476,63 @@ export async function setEmail(
* @returns the newly set email
*/
export async function createPasskeyRegistrationLink(
userId: string
userId: string,
token?: string
): Promise<any> {
const userservice = user.getUser(server);
let userService;
if (token) {
const authConfig: ZitadelServerOptions = {
name: "zitadel login",
apiUrl: process.env.ZITADEL_API_URL ?? "",
token: token,
};
return userservice.createPasskeyRegistrationLink({
const sessionUser = initializeServer(authConfig);
userService = user.getUser(sessionUser);
} else {
userService = user.getUser(server);
}
return userService.createPasskeyRegistrationLink({
userId,
returnCode: {},
});
}
/**
*
* @param server
* @param userId the id of the user where the email should be set
* @param domain the domain on which the factor is registered
* @returns the newly set email
*/
export async function registerU2F(
userId: string,
domain: string
): Promise<any> {
const userservice = user.getUser(server);
return userservice.registerU2F({
userId,
domain,
});
}
/**
*
* @param server
* @param userId the id of the user where the email should be set
* @param domain the domain on which the factor is registered
* @returns the newly set email
*/
export async function verifyU2FRegistration(
request: VerifyU2FRegistrationRequest
): Promise<any> {
const userservice = user.getUser(server);
return userservice.verifyU2FRegistration(request, {});
}
/**
*
* @param server