import { Injectable } from '@angular/core'; import { BehaviorSubject, catchError, finalize, from, map, Observable, of, Subject, switchMap, tap } from 'rxjs'; import { ActivateLabelPolicyRequest, ActivateLabelPolicyResponse, ActivateSMSProviderRequest, ActivateSMSProviderResponse, AddCustomDomainPolicyRequest, AddCustomOrgIAMPolicyResponse, AddGenericOIDCProviderRequest, AddGenericOIDCProviderResponse, AddGoogleProviderRequest, AddGoogleProviderResponse, AddIAMMemberRequest, AddIAMMemberResponse, AddIDPToLoginPolicyRequest, AddIDPToLoginPolicyResponse, AddJWTProviderRequest, AddJWTProviderResponse, AddMultiFactorToLoginPolicyRequest, AddMultiFactorToLoginPolicyResponse, AddNotificationPolicyRequest, AddNotificationPolicyResponse, AddOIDCSettingsRequest, AddOIDCSettingsResponse, AddSecondFactorToLoginPolicyRequest, AddSecondFactorToLoginPolicyResponse, AddSMSProviderTwilioRequest, AddSMSProviderTwilioResponse, AddSMTPConfigRequest, AddSMTPConfigResponse, DeactivateIDPRequest, DeactivateIDPResponse, DeactivateSMSProviderRequest, DeactivateSMSProviderResponse, DeleteProviderRequest, DeleteProviderResponse, GetCustomDomainClaimedMessageTextRequest, GetCustomDomainClaimedMessageTextResponse, GetCustomDomainPolicyRequest, GetCustomDomainPolicyResponse, GetCustomInitMessageTextRequest, GetCustomInitMessageTextResponse, GetCustomLoginTextsRequest, GetCustomLoginTextsResponse, GetCustomPasswordChangeMessageTextRequest, GetCustomPasswordChangeMessageTextResponse, GetCustomPasswordlessRegistrationMessageTextRequest, GetCustomPasswordlessRegistrationMessageTextResponse, GetCustomPasswordResetMessageTextRequest, GetCustomPasswordResetMessageTextResponse, GetCustomVerifyEmailMessageTextRequest, GetCustomVerifyEmailMessageTextResponse, GetCustomVerifyPhoneMessageTextRequest, GetCustomVerifyPhoneMessageTextResponse, GetDefaultDomainClaimedMessageTextRequest, GetDefaultDomainClaimedMessageTextResponse, GetDefaultInitMessageTextRequest, GetDefaultInitMessageTextResponse, GetDefaultLanguageRequest, GetDefaultLanguageResponse, GetDefaultLoginTextsRequest, GetDefaultLoginTextsResponse, GetDefaultPasswordChangeMessageTextRequest, GetDefaultPasswordChangeMessageTextResponse, GetDefaultPasswordlessRegistrationMessageTextRequest, GetDefaultPasswordlessRegistrationMessageTextResponse, GetDefaultPasswordResetMessageTextRequest, GetDefaultPasswordResetMessageTextResponse, GetDefaultVerifyEmailMessageTextRequest, GetDefaultVerifyEmailMessageTextResponse, GetDefaultVerifyPhoneMessageTextRequest, GetDefaultVerifyPhoneMessageTextResponse, GetDomainPolicyRequest, GetDomainPolicyResponse, GetFileSystemNotificationProviderRequest, GetFileSystemNotificationProviderResponse, GetLabelPolicyRequest, GetLabelPolicyResponse, GetLockoutPolicyRequest, GetLockoutPolicyResponse, GetLoginPolicyRequest, GetLoginPolicyResponse, GetLogNotificationProviderRequest, GetLogNotificationProviderResponse, GetMyInstanceRequest, GetMyInstanceResponse, GetNotificationPolicyRequest, GetNotificationPolicyResponse, GetOIDCSettingsRequest, GetOIDCSettingsResponse, GetPasswordAgePolicyRequest, GetPasswordAgePolicyResponse, GetPasswordComplexityPolicyRequest, GetPasswordComplexityPolicyResponse, GetPreviewLabelPolicyRequest, GetPreviewLabelPolicyResponse, GetPrivacyPolicyRequest, GetPrivacyPolicyResponse, GetProviderByIDRequest, GetProviderByIDResponse, GetSecretGeneratorRequest, GetSecretGeneratorResponse, GetSecurityPolicyRequest, GetSecurityPolicyResponse, GetSMSProviderRequest, GetSMSProviderResponse, GetSMTPConfigRequest, GetSMTPConfigResponse, GetSupportedLanguagesRequest, GetSupportedLanguagesResponse, ListAggregateTypesRequest, ListAggregateTypesResponse, ListEventsRequest, ListEventsResponse, ListEventTypesRequest, ListEventTypesResponse, ListFailedEventsRequest, ListFailedEventsResponse, ListIAMMemberRolesRequest, ListIAMMemberRolesResponse, ListIAMMembersRequest, ListIAMMembersResponse, ListLoginPolicyIDPsRequest, ListLoginPolicyIDPsResponse, ListLoginPolicyMultiFactorsRequest, ListLoginPolicyMultiFactorsResponse, ListLoginPolicySecondFactorsRequest, ListLoginPolicySecondFactorsResponse, ListProvidersRequest, ListProvidersResponse, ListSecretGeneratorsRequest, ListSecretGeneratorsResponse, ListSMSProvidersRequest, ListSMSProvidersResponse, ListViewsRequest, ListViewsResponse, ReactivateIDPRequest, ReactivateIDPResponse, RemoveFailedEventRequest, RemoveFailedEventResponse, RemoveIAMMemberRequest, RemoveIAMMemberResponse, RemoveIDPFromLoginPolicyRequest, RemoveIDPFromLoginPolicyResponse, RemoveIDPRequest, RemoveIDPResponse, RemoveLabelPolicyFontRequest, RemoveLabelPolicyFontResponse, RemoveLabelPolicyIconDarkRequest, RemoveLabelPolicyIconDarkResponse, RemoveLabelPolicyIconRequest, RemoveLabelPolicyIconResponse, RemoveLabelPolicyLogoDarkRequest, RemoveLabelPolicyLogoDarkResponse, RemoveLabelPolicyLogoRequest, RemoveLabelPolicyLogoResponse, RemoveMultiFactorFromLoginPolicyRequest, RemoveMultiFactorFromLoginPolicyResponse, RemoveSecondFactorFromLoginPolicyRequest, RemoveSecondFactorFromLoginPolicyResponse, RemoveSMSProviderRequest, RemoveSMSProviderResponse, ResetCustomDomainPolicyToDefaultRequest, ResetCustomDomainPolicyToDefaultResponse, ResetCustomLoginTextsToDefaultRequest, ResetCustomLoginTextsToDefaultResponse, SetCustomLoginTextsRequest, SetCustomLoginTextsResponse, SetDefaultDomainClaimedMessageTextRequest, SetDefaultDomainClaimedMessageTextResponse, SetDefaultInitMessageTextRequest, SetDefaultInitMessageTextResponse, SetDefaultLanguageRequest, SetDefaultLanguageResponse, SetDefaultOrgRequest, SetDefaultOrgResponse, SetDefaultPasswordChangeMessageTextRequest, SetDefaultPasswordChangeMessageTextResponse, SetDefaultPasswordlessRegistrationMessageTextRequest, SetDefaultPasswordlessRegistrationMessageTextResponse, SetDefaultPasswordResetMessageTextRequest, SetDefaultPasswordResetMessageTextResponse, SetDefaultVerifyEmailMessageTextRequest, SetDefaultVerifyEmailMessageTextResponse, SetDefaultVerifyPhoneMessageTextRequest, SetDefaultVerifyPhoneMessageTextResponse, SetSecurityPolicyRequest, SetSecurityPolicyResponse, SetUpOrgRequest, SetUpOrgResponse, UpdateCustomDomainPolicyRequest, UpdateCustomDomainPolicyResponse, UpdateDomainPolicyRequest, UpdateDomainPolicyResponse, UpdateGenericOIDCProviderRequest, UpdateGenericOIDCProviderResponse, UpdateGoogleProviderRequest, UpdateGoogleProviderResponse, UpdateIAMMemberRequest, UpdateIAMMemberResponse, UpdateJWTProviderRequest, UpdateJWTProviderResponse, UpdateLabelPolicyRequest, UpdateLabelPolicyResponse, UpdateLockoutPolicyRequest, UpdateLockoutPolicyResponse, UpdateLoginPolicyRequest, UpdateLoginPolicyResponse, UpdateNotificationPolicyRequest, UpdateNotificationPolicyResponse, UpdateOIDCSettingsRequest, UpdateOIDCSettingsResponse, UpdatePasswordAgePolicyRequest, UpdatePasswordAgePolicyResponse, UpdatePasswordComplexityPolicyRequest, UpdatePasswordComplexityPolicyResponse, UpdatePrivacyPolicyRequest, UpdatePrivacyPolicyResponse, UpdateSecretGeneratorRequest, UpdateSecretGeneratorResponse, UpdateSMSProviderTwilioRequest, UpdateSMSProviderTwilioResponse, UpdateSMSProviderTwilioTokenRequest, UpdateSMSProviderTwilioTokenResponse, UpdateSMTPConfigPasswordRequest, UpdateSMTPConfigPasswordResponse, UpdateSMTPConfigRequest, UpdateSMTPConfigResponse, } from '../proto/generated/zitadel/admin_pb'; import { Event } from '../proto/generated/zitadel/event_pb'; import { SearchQuery } from '../proto/generated/zitadel/member_pb'; import { ListQuery } from '../proto/generated/zitadel/object_pb'; import { GrpcService } from './grpc.service'; import { StorageLocation, StorageService } from './storage.service'; export interface OnboardingActions { order: number; eventType: string; oneof: string[]; link: string | string[]; fragment?: string | undefined; } type OnboardingEvent = { order: number; link: string; fragment: string | undefined; event: Event.AsObject | undefined }; type OnboardingEventEntries = Array<[string, OnboardingEvent]> | []; @Injectable({ providedIn: 'root', }) export class AdminService { public hideOnboarding: boolean = false; public loadEvents: Subject = new Subject(); public onboardingLoading: BehaviorSubject = new BehaviorSubject(false); public progressEvents$: Observable = this.loadEvents.pipe( tap(() => this.onboardingLoading.next(true)), switchMap((actions) => { const searchForTypes = actions.map((oe) => oe.oneof).flat(); const eventsReq = new ListEventsRequest().setAsc(true).setEventTypesList(searchForTypes).setAsc(false); return from(this.listEvents(eventsReq)).pipe( map((events) => { const el = events.toObject().eventsList.filter((e) => e.editor?.service !== 'System-API'); let obj: { [type: string]: OnboardingEvent } = {}; actions.map((action) => { const filtered = el.filter((event) => event.type?.type && action.oneof.includes(event.type.type)); (obj as any)[action.eventType] = filtered.length ? { order: action.order, link: action.link, fragment: action.fragment, event: filtered[0] } : { order: action.order, link: action.link, fragment: action.fragment, event: undefined }; }); const toArray = Object.entries(obj).sort(([key0, a], [key1, b]) => a.order - b.order); const toDo = toArray.filter(([key, value]) => value.event === undefined); const done = toArray.filter(([key, value]) => !!value.event); return [...toDo, ...done]; }), tap((events) => { const total = events.length; const done = events.map(([type, value]) => value.event !== undefined).filter((res) => !!res).length; const percentage = Math.round((done / total) * 100); this.progressDone.next(done); this.progressTotal.next(total); this.progressPercentage.next(percentage); this.progressAllDone.next(done === total); }), catchError((error) => { console.error(error); return of([]); }), finalize(() => this.onboardingLoading.next(false)), ); }), ); public progressEvents: BehaviorSubject = new BehaviorSubject([]); public progressPercentage: BehaviorSubject = new BehaviorSubject(0); public progressDone: BehaviorSubject = new BehaviorSubject(0); public progressTotal: BehaviorSubject = new BehaviorSubject(0); public progressAllDone: BehaviorSubject = new BehaviorSubject(true); constructor(private readonly grpcService: GrpcService, private storageService: StorageService) { this.progressEvents$.subscribe(this.progressEvents); this.hideOnboarding = this.storageService.getItem('onboarding-dismissed', StorageLocation.local) === 'true' ? true : false; } public setDefaultOrg(orgId: string): Promise { const req = new SetDefaultOrgRequest(); req.setOrgId(orgId); return this.grpcService.admin.setDefaultOrg(req, null).then((resp) => resp.toObject()); } public listEvents(req: ListEventsRequest): Promise { return this.grpcService.admin.listEvents(req, null).then((resp) => resp); } public listEventTypes(req: ListEventTypesRequest): Promise { return this.grpcService.admin.listEventTypes(req, null).then((resp) => resp.toObject()); } public listAggregateTypes(req: ListAggregateTypesRequest): Promise { return this.grpcService.admin.listAggregateTypes(req, null).then((resp) => resp.toObject()); } public getSupportedLanguages(): Promise { const req = new GetSupportedLanguagesRequest(); return this.grpcService.admin.getSupportedLanguages(req, null).then((resp) => resp.toObject()); } public getDefaultLoginTexts(req: GetDefaultLoginTextsRequest): Promise { return this.grpcService.admin.getDefaultLoginTexts(req, null).then((resp) => resp.toObject()); } public getCustomLoginTexts(req: GetCustomLoginTextsRequest): Promise { return this.grpcService.admin.getCustomLoginTexts(req, null).then((resp) => resp.toObject()); } public setCustomLoginText(req: SetCustomLoginTextsRequest): Promise { return this.grpcService.admin.setCustomLoginText(req, null).then((resp) => resp.toObject()); } public resetCustomLoginTextToDefault(lang: string): Promise { const req = new ResetCustomLoginTextsToDefaultRequest(); req.setLanguage(lang); return this.grpcService.admin.resetCustomLoginTextToDefault(req, null).then((resp) => resp.toObject()); } // message texts public getDefaultInitMessageText( req: GetDefaultInitMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultInitMessageText(req, null).then((resp) => resp.toObject()); } public getCustomInitMessageText(req: GetCustomInitMessageTextRequest): Promise { return this.grpcService.admin.getCustomInitMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultInitMessageText( req: SetDefaultInitMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultInitMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultVerifyEmailMessageText( req: GetDefaultVerifyEmailMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultVerifyEmailMessageText(req, null).then((resp) => resp.toObject()); } public getCustomVerifyEmailMessageText( req: GetCustomVerifyEmailMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomVerifyEmailMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultVerifyEmailMessageText( req: SetDefaultVerifyEmailMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultVerifyEmailMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultVerifyPhoneMessageText( req: GetDefaultVerifyPhoneMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultVerifyPhoneMessageText(req, null).then((resp) => resp.toObject()); } public getCustomVerifyPhoneMessageText( req: GetCustomVerifyPhoneMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomVerifyPhoneMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultVerifyPhoneMessageText( req: SetDefaultVerifyPhoneMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultVerifyPhoneMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultPasswordResetMessageText( req: GetDefaultPasswordResetMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultPasswordResetMessageText(req, null).then((resp) => resp.toObject()); } public getCustomPasswordResetMessageText( req: GetCustomPasswordResetMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomPasswordResetMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultPasswordResetMessageText( req: SetDefaultPasswordResetMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultPasswordResetMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultDomainClaimedMessageText( req: GetDefaultDomainClaimedMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultDomainClaimedMessageText(req, null).then((resp) => resp.toObject()); } public getCustomDomainClaimedMessageText( req: GetCustomDomainClaimedMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomDomainClaimedMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultDomainClaimedMessageText( req: SetDefaultDomainClaimedMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultDomainClaimedMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultPasswordlessRegistrationMessageText( req: GetDefaultPasswordlessRegistrationMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultPasswordlessRegistrationMessageText(req, null).then((resp) => resp.toObject()); } public getCustomPasswordlessRegistrationMessageText( req: GetCustomPasswordlessRegistrationMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomPasswordlessRegistrationMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultPasswordlessRegistrationMessageText( req: SetDefaultPasswordlessRegistrationMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultPasswordlessRegistrationMessageText(req, null).then((resp) => resp.toObject()); } public getDefaultPasswordChangeMessageText( req: GetDefaultPasswordChangeMessageTextRequest, ): Promise { return this.grpcService.admin.getDefaultPasswordChangeMessageText(req, null).then((resp) => resp.toObject()); } public getCustomPasswordChangeMessageText( req: GetCustomPasswordChangeMessageTextRequest, ): Promise { return this.grpcService.admin.getCustomPasswordChangeMessageText(req, null).then((resp) => resp.toObject()); } public setDefaultPasswordChangeMessageText( req: SetDefaultPasswordChangeMessageTextRequest, ): Promise { return this.grpcService.admin.setDefaultPasswordChangeMessageText(req, null).then((resp) => resp.toObject()); } public SetUpOrg(org: SetUpOrgRequest.Org, human: SetUpOrgRequest.Human): Promise { const req = new SetUpOrgRequest(); req.setOrg(org); req.setHuman(human); return this.grpcService.admin.setUpOrg(req, null).then((resp) => resp.toObject()); } public listLoginPolicyMultiFactors(): Promise { const req = new ListLoginPolicyMultiFactorsRequest(); return this.grpcService.admin.listLoginPolicyMultiFactors(req, null).then((resp) => resp.toObject()); } public addMultiFactorToLoginPolicy( req: AddMultiFactorToLoginPolicyRequest, ): Promise { return this.grpcService.admin.addMultiFactorToLoginPolicy(req, null).then((resp) => resp.toObject()); } public removeMultiFactorFromLoginPolicy( req: RemoveMultiFactorFromLoginPolicyRequest, ): Promise { return this.grpcService.admin.removeMultiFactorFromLoginPolicy(req, null).then((resp) => resp.toObject()); } public listLoginPolicySecondFactors(): Promise { const req = new ListLoginPolicySecondFactorsRequest(); return this.grpcService.admin.listLoginPolicySecondFactors(req, null).then((resp) => resp.toObject()); } public addSecondFactorToLoginPolicy( req: AddSecondFactorToLoginPolicyRequest, ): Promise { return this.grpcService.admin.addSecondFactorToLoginPolicy(req, null).then((resp) => resp.toObject()); } public removeSecondFactorFromLoginPolicy( req: RemoveSecondFactorFromLoginPolicyRequest, ): Promise { return this.grpcService.admin.removeSecondFactorFromLoginPolicy(req, null).then((resp) => resp.toObject()); } public listIAMMemberRoles(): Promise { const req = new ListIAMMemberRolesRequest(); return this.grpcService.admin.listIAMMemberRoles(req, null).then((resp) => resp.toObject()); } public listViews(): Promise { const req = new ListViewsRequest(); return this.grpcService.admin.listViews(req, null).then((resp) => resp.toObject()); } public listFailedEvents(): Promise { const req = new ListFailedEventsRequest(); return this.grpcService.admin.listFailedEvents(req, null).then((resp) => resp.toObject()); } public removeFailedEvent(viewname: string, db: string, sequence: number): Promise { const req = new RemoveFailedEventRequest(); req.setDatabase(db); req.setViewName(viewname); req.setFailedSequence(sequence); return this.grpcService.admin.removeFailedEvent(req, null).then((resp) => resp.toObject()); } public getMyInstance(): Promise { const req = new GetMyInstanceRequest(); return this.grpcService.admin.getMyInstance(req, null).then((resp) => resp.toObject()); } public getPrivacyPolicy(): Promise { const req = new GetPrivacyPolicyRequest(); return this.grpcService.admin.getPrivacyPolicy(req, null).then((resp) => resp.toObject()); } public updatePrivacyPolicy(req: UpdatePrivacyPolicyRequest): Promise { return this.grpcService.admin.updatePrivacyPolicy(req, null).then((resp) => resp.toObject()); } /* Policies */ /* complexity */ public getPasswordComplexityPolicy(): Promise { const req = new GetPasswordComplexityPolicyRequest(); return this.grpcService.admin.getPasswordComplexityPolicy(req, null).then((resp) => resp.toObject()); } public updatePasswordComplexityPolicy( hasLowerCase: boolean, hasUpperCase: boolean, hasNumber: boolean, hasSymbol: boolean, minLength: number, ): Promise { const req = new UpdatePasswordComplexityPolicyRequest(); req.setHasLowercase(hasLowerCase); req.setHasUppercase(hasUpperCase); req.setHasNumber(hasNumber); req.setHasSymbol(hasSymbol); req.setMinLength(minLength); return this.grpcService.admin.updatePasswordComplexityPolicy(req, null).then((resp) => resp.toObject()); } /* age */ public getPasswordAgePolicy(): Promise { const req = new GetPasswordAgePolicyRequest(); return this.grpcService.admin.getPasswordAgePolicy(req, null).then((resp) => resp.toObject()); } public updatePasswordAgePolicy( maxAgeDays: number, expireWarnDays: number, ): Promise { const req = new UpdatePasswordAgePolicyRequest(); req.setMaxAgeDays(maxAgeDays); req.setExpireWarnDays(expireWarnDays); return this.grpcService.admin.updatePasswordAgePolicy(req, null).then((resp) => resp.toObject()); } /* default language */ public getDefaultLanguage(): Promise { const req = new GetDefaultLanguageRequest(); return this.grpcService.admin.getDefaultLanguage(req, null).then((resp) => resp.toObject()); } public setDefaultLanguage(language: string): Promise { const req = new SetDefaultLanguageRequest(); req.setLanguage(language); return this.grpcService.admin.setDefaultLanguage(req, null).then((resp) => resp.toObject()); } /* notification policy */ public getNotificationPolicy(): Promise { const req = new GetNotificationPolicyRequest(); return this.grpcService.admin.getNotificationPolicy(req, null).then((resp) => resp.toObject()); } public updateNotificationPolicy(req: UpdateNotificationPolicyRequest): Promise { return this.grpcService.admin.updateNotificationPolicy(req, null).then((resp) => resp.toObject()); } public addNotificationPolicy(req: AddNotificationPolicyRequest): Promise { return this.grpcService.admin.addNotificationPolicy(req, null).then((resp) => resp.toObject()); } /* security policy */ public getSecurityPolicy(): Promise { const req = new GetSecurityPolicyRequest(); return this.grpcService.admin.getSecurityPolicy(req, null).then((resp) => resp.toObject()); } public setSecurityPolicy(req: SetSecurityPolicyRequest): Promise { return this.grpcService.admin.setSecurityPolicy(req, null).then((resp) => resp.toObject()); } /* notification settings */ public getSMTPConfig(): Promise { const req = new GetSMTPConfigRequest(); return this.grpcService.admin.getSMTPConfig(req, null).then((resp) => resp.toObject()); } public addSMTPConfig(req: AddSMTPConfigRequest): Promise { return this.grpcService.admin.addSMTPConfig(req, null).then((resp) => resp.toObject()); } public updateSMTPConfig(req: UpdateSMTPConfigRequest): Promise { return this.grpcService.admin.updateSMTPConfig(req, null).then((resp) => resp.toObject()); } public updateSMTPConfigPassword(req: UpdateSMTPConfigPasswordRequest): Promise { return this.grpcService.admin.updateSMTPConfigPassword(req, null).then((resp) => resp.toObject()); } /* sms */ public listSMSProviders(): Promise { const req = new ListSMSProvidersRequest(); return this.grpcService.admin.listSMSProviders(req, null).then((resp) => resp.toObject()); } public getSMSProvider(): Promise { const req = new GetSMSProviderRequest(); return this.grpcService.admin.getSMSProvider(req, null).then((resp) => resp.toObject()); } public addSMSProviderTwilio(req: AddSMSProviderTwilioRequest): Promise { return this.grpcService.admin.addSMSProviderTwilio(req, null).then((resp) => resp.toObject()); } public updateSMSProviderTwilio(req: UpdateSMSProviderTwilioRequest): Promise { return this.grpcService.admin.updateSMSProviderTwilio(req, null).then((resp) => resp.toObject()); } public removeSMSProvider(id: string): Promise { const req = new RemoveSMSProviderRequest(); req.setId(id); return this.grpcService.admin.removeSMSProvider(req, null).then((resp) => resp.toObject()); } public activateSMSProvider(id: string): Promise { const req = new ActivateSMSProviderRequest(); req.setId(id); return this.grpcService.admin.activateSMSProvider(req, null).then((resp) => resp.toObject()); } public deactivateSMSProvider(id: string): Promise { const req = new DeactivateSMSProviderRequest(); req.setId(id); return this.grpcService.admin.deactivateSMSProvider(req, null).then((resp) => resp.toObject()); } public updateSMSProviderTwilioToken( req: UpdateSMSProviderTwilioTokenRequest, ): Promise { return this.grpcService.admin.updateSMSProviderTwilioToken(req, null).then((resp) => resp.toObject()); } /* lockout */ public getLockoutPolicy(): Promise { const req = new GetLockoutPolicyRequest(); return this.grpcService.admin.getLockoutPolicy(req, null).then((resp) => resp.toObject()); } public updateLockoutPolicy(maxAttempts: number): Promise { const req = new UpdateLockoutPolicyRequest(); req.setMaxPasswordAttempts(maxAttempts); return this.grpcService.admin.updateLockoutPolicy(req, null).then((resp) => resp.toObject()); } /* label */ public getLabelPolicy(): Promise { const req = new GetLabelPolicyRequest(); return this.grpcService.admin.getLabelPolicy(req, null).then((resp) => resp.toObject()); } public updateLabelPolicy(req: UpdateLabelPolicyRequest): Promise { return this.grpcService.admin.updateLabelPolicy(req, null).then((resp) => resp.toObject()); } public getPreviewLabelPolicy(): Promise { const req = new GetPreviewLabelPolicyRequest(); return this.grpcService.admin.getPreviewLabelPolicy(req, null).then((resp) => resp.toObject()); } public activateLabelPolicy(): Promise { const req = new ActivateLabelPolicyRequest(); return this.grpcService.admin.activateLabelPolicy(req, null).then((resp) => resp.toObject()); } public removeLabelPolicyFont(): Promise { const req = new RemoveLabelPolicyFontRequest(); return this.grpcService.admin.removeLabelPolicyFont(req, null).then((resp) => resp.toObject()); } public removeLabelPolicyIcon(): Promise { const req = new RemoveLabelPolicyIconRequest(); return this.grpcService.admin.removeLabelPolicyIcon(req, null).then((resp) => resp.toObject()); } public removeLabelPolicyIconDark(): Promise { const req = new RemoveLabelPolicyIconDarkRequest(); return this.grpcService.admin.removeLabelPolicyIconDark(req, null).then((resp) => resp.toObject()); } public removeLabelPolicyLogo(): Promise { const req = new RemoveLabelPolicyLogoRequest(); return this.grpcService.admin.removeLabelPolicyLogo(req, null).then((resp) => resp.toObject()); } public removeLabelPolicyLogoDark(): Promise { const req = new RemoveLabelPolicyLogoDarkRequest(); return this.grpcService.admin.removeLabelPolicyLogoDark(req, null).then((resp) => resp.toObject()); } /* login */ public getLoginPolicy(): Promise { const req = new GetLoginPolicyRequest(); return this.grpcService.admin.getLoginPolicy(req, null).then((resp) => resp.toObject()); } public updateLoginPolicy(req: UpdateLoginPolicyRequest): Promise { return this.grpcService.admin.updateLoginPolicy(req, null).then((resp) => resp.toObject()); } /* OIDC Configuration */ public getOIDCSettings(): Promise { const req = new GetOIDCSettingsRequest(); return this.grpcService.admin.getOIDCSettings(req, null).then((resp) => resp.toObject()); } public updateOIDCSettings(req: UpdateOIDCSettingsRequest): Promise { return this.grpcService.admin.updateOIDCSettings(req, null).then((resp) => resp.toObject()); } public addOIDCSettings(req: AddOIDCSettingsRequest): Promise { return this.grpcService.admin.addOIDCSettings(req, null).then((resp) => resp.toObject()); } /* LOG and FILE Notifications */ public getLogNotificationProvider(): Promise { const req = new GetLogNotificationProviderRequest(); return this.grpcService.admin.getLogNotificationProvider(req, null).then((resp) => resp.toObject()); } public getFileSystemNotificationProvider(): Promise { const req = new GetFileSystemNotificationProviderRequest(); return this.grpcService.admin.getFileSystemNotificationProvider(req, null).then((resp) => resp.toObject()); } /* secrets generator */ public listSecretGenerators(): Promise { const req = new ListSecretGeneratorsRequest(); return this.grpcService.admin.listSecretGenerators(req, null).then((resp) => resp.toObject()); } public getSecretGenerator(req: GetSecretGeneratorRequest): Promise { return this.grpcService.admin.getSecretGenerator(req, null).then((resp) => resp.toObject()); } public updateSecretGenerator(req: UpdateSecretGeneratorRequest): Promise { return this.grpcService.admin.updateSecretGenerator(req, null).then((resp) => resp.toObject()); } /* org domain policy */ public getDomainPolicy(): Promise { const req = new GetDomainPolicyRequest(); return this.grpcService.admin.getDomainPolicy(req, null).then((resp) => resp.toObject()); } public updateDomainPolicy(req: UpdateDomainPolicyRequest): Promise { return this.grpcService.admin.updateDomainPolicy(req, null).then((resp) => resp.toObject()); } public getCustomDomainPolicy(orgId: string): Promise { const req = new GetCustomDomainPolicyRequest(); req.setOrgId(orgId); return this.grpcService.admin.getCustomDomainPolicy(req, null).then((resp) => resp.toObject()); } public addCustomDomainPolicy(req: AddCustomDomainPolicyRequest): Promise { return this.grpcService.admin.addCustomDomainPolicy(req, null).then((resp) => resp.toObject()); } public updateCustomDomainPolicy(req: UpdateCustomDomainPolicyRequest): Promise { return this.grpcService.admin.updateCustomDomainPolicy(req, null).then((resp) => resp.toObject()); } public resetCustomDomainPolicyToDefault(orgId: string): Promise { const req = new ResetCustomDomainPolicyToDefaultRequest(); req.setOrgId(orgId); return this.grpcService.admin.resetCustomDomainPolicyToDefault(req, null).then((resp) => resp.toObject()); } /* policies end */ public addIDPToLoginPolicy(idpId: string): Promise { const req = new AddIDPToLoginPolicyRequest(); req.setIdpId(idpId); return this.grpcService.admin.addIDPToLoginPolicy(req, null).then((resp) => resp.toObject()); } public removeIDPFromLoginPolicy(idpId: string): Promise { const req = new RemoveIDPFromLoginPolicyRequest(); req.setIdpId(idpId); return this.grpcService.admin.removeIDPFromLoginPolicy(req, null).then((resp) => resp.toObject()); } public listLoginPolicyIDPs(limit?: number, offset?: number): Promise { const req = new ListLoginPolicyIDPsRequest(); const query = new ListQuery(); if (limit) { query.setLimit(limit); } if (offset) { query.setOffset(offset); } req.setQuery(query); return this.grpcService.admin.listLoginPolicyIDPs(req, null).then((resp) => resp.toObject()); } public removeIDP(id: string): Promise { const req = new RemoveIDPRequest(); req.setIdpId(id); return this.grpcService.admin.removeIDP(req, null).then((resp) => resp.toObject()); } public deactivateIDP(id: string): Promise { const req = new DeactivateIDPRequest(); req.setIdpId(id); return this.grpcService.admin.deactivateIDP(req, null).then((resp) => resp.toObject()); } public reactivateIDP(id: string): Promise { const req = new ReactivateIDPRequest(); req.setIdpId(id); return this.grpcService.admin.reactivateIDP(req, null).then((resp) => resp.toObject()); } // idp templates public addGoogleProvider(req: AddGoogleProviderRequest): Promise { return this.grpcService.admin.addGoogleProvider(req, null).then((resp) => resp.toObject()); } public updateGoogleProvider(req: UpdateGoogleProviderRequest): Promise { return this.grpcService.admin.updateGoogleProvider(req, null).then((resp) => resp.toObject()); } public addGenericOIDCProvider(req: AddGenericOIDCProviderRequest): Promise { return this.grpcService.admin.addGenericOIDCProvider(req, null).then((resp) => resp.toObject()); } public updateGenericOIDCProvider( req: UpdateGenericOIDCProviderRequest, ): Promise { return this.grpcService.admin.updateGenericOIDCProvider(req, null).then((resp) => resp.toObject()); } public addJWTProvider(req: AddJWTProviderRequest): Promise { return this.grpcService.admin.addJWTProvider(req, null).then((resp) => resp.toObject()); } public updateJWTProvider(req: UpdateJWTProviderRequest): Promise { return this.grpcService.admin.updateJWTProvider(req, null).then((resp) => resp.toObject()); } public deleteProvider(req: DeleteProviderRequest): Promise { return this.grpcService.admin.deleteProvider(req, null).then((resp) => resp.toObject()); } public listProviders(req: ListProvidersRequest): Promise { return this.grpcService.admin.listProviders(req, null).then((resp) => resp.toObject()); } public getProviderByID(req: GetProviderByIDRequest): Promise { return this.grpcService.admin.getProviderByID(req, null).then((resp) => resp.toObject()); } public listIAMMembers( limit: number, offset: number, queriesList?: SearchQuery[], ): Promise { const req = new ListIAMMembersRequest(); const metadata = new ListQuery(); if (limit) { metadata.setLimit(limit); } if (offset) { metadata.setOffset(offset); } if (queriesList) { req.setQueriesList(queriesList); } req.setQuery(metadata); return this.grpcService.admin.listIAMMembers(req, null).then((resp) => resp.toObject()); } public removeIAMMember(userId: string): Promise { const req = new RemoveIAMMemberRequest(); req.setUserId(userId); return this.grpcService.admin.removeIAMMember(req, null).then((resp) => resp.toObject()); } public addIAMMember(userId: string, rolesList: string[]): Promise { const req = new AddIAMMemberRequest(); req.setUserId(userId); req.setRolesList(rolesList); return this.grpcService.admin.addIAMMember(req, null).then((resp) => resp.toObject()); } public updateIAMMember(userId: string, rolesList: string[]): Promise { const req = new UpdateIAMMemberRequest(); req.setUserId(userId); req.setRolesList(rolesList); return this.grpcService.admin.updateIAMMember(req, null).then((resp) => resp.toObject()); } }