import { Injectable } from '@angular/core'; import { GrpcService } from './grpc.service'; import { create } from '@bufbuild/protobuf'; import { AddMyAuthFactorOTPSMSResponse, GetMyLoginPolicyResponse, GetMyLoginPolicyRequestSchema, GetMyPasswordComplexityPolicyResponse, GetMyUserResponse, ListMyAuthFactorsRequestSchema, ListMyAuthFactorsResponse, RemoveMyAuthFactorOTPEmailRequestSchema, RemoveMyAuthFactorOTPEmailResponse, RemoveMyAuthFactorOTPRequestSchema, RemoveMyAuthFactorOTPResponse, RemoveMyAuthFactorU2FRequestSchema, RemoveMyAuthFactorU2FResponse, RemoveMyAuthFactorOTPSMSRequestSchema, RemoveMyAuthFactorOTPSMSResponse, ListMyMetadataResponse, VerifyMyPhoneResponse, } from '@zitadel/proto/zitadel/auth_pb'; @Injectable({ providedIn: 'root', }) export class NewAuthService { constructor(private readonly grpcService: GrpcService) {} public getMyUser(): Promise { return this.grpcService.authNew.getMyUser({}); } public verifyMyPhone(code: string): Promise { return this.grpcService.authNew.verifyMyPhone({ code }); } public addMyAuthFactorOTPSMS(): Promise { return this.grpcService.authNew.addMyAuthFactorOTPSMS({}); } public listMyMetadata(): Promise { return this.grpcService.authNew.listMyMetadata({}); } public listMyMultiFactors(): Promise { return this.grpcService.authNew.listMyAuthFactors(create(ListMyAuthFactorsRequestSchema)); } public removeMyAuthFactorOTPSMS(): Promise { return this.grpcService.authNew.removeMyAuthFactorOTPSMS(create(RemoveMyAuthFactorOTPSMSRequestSchema)); } public getMyLoginPolicy(): Promise { return this.grpcService.authNew.getMyLoginPolicy(create(GetMyLoginPolicyRequestSchema)); } public removeMyMultiFactorOTP(): Promise { return this.grpcService.authNew.removeMyAuthFactorOTP(create(RemoveMyAuthFactorOTPRequestSchema)); } public removeMyMultiFactorU2F(tokenId: string): Promise { return this.grpcService.authNew.removeMyAuthFactorU2F(create(RemoveMyAuthFactorU2FRequestSchema, { tokenId })); } public removeMyAuthFactorOTPEmail(): Promise { return this.grpcService.authNew.removeMyAuthFactorOTPEmail(create(RemoveMyAuthFactorOTPEmailRequestSchema)); } public getMyPasswordComplexityPolicy(): Promise { return this.grpcService.authNew.getMyPasswordComplexityPolicy({}); } }