import { Method } from "axios"; import { A_AUTH_APIProvider } from "../A_AUTH_APIProvider.class"; import { A_AUTH_TYPES__IAuthenticator } from "@adaas/a-auth/types/A_AUTH_Authenticator.types"; import { A_AUTH_CONSTANTS__ERROR_CODES } from "@adaas/a-auth/constants/errors.constants"; import { A_AUTH_TYPES__APIProviderRequestConfig } from "@adaas/a-auth/types/A_AUTH_APIProvider.types"; import { A_SDK_TYPES__Required } from "@adaas/a-sdk-types"; import { A_AUTH_ServerDelegateAuthenticator } from "../authenticator/A_AUTH_ServerDelegate.authenticator"; import { A_AUTH_ContextClass } from "../A_AUTH_Context.class"; export class A_AUTH_ServerDelegate_APIProvider extends A_AUTH_APIProvider { protected async request( method: Method, url: string, auth: A_AUTH_TYPES__IAuthenticator, data?: any, params?: any, config?: A_SDK_TYPES__Required, ['authenticator']> ): Promise { if (this.context.environment !== 'server') this.context.Errors.throw(A_AUTH_CONSTANTS__ERROR_CODES.UNABLE_TO_USE_SERVER_DELEGATE_FROM_BROWSER); else if (!auth) this.context.Errors.throw(A_AUTH_CONSTANTS__ERROR_CODES.UNABLE_TO_USE_SERVER_DELEGATE_WITHOUT_AUTH); else return super.request(method, url, auth, data, params, config); } protected async post( url: string, body: any = {}, config: A_SDK_TYPES__Required, ['authenticator']> ): Promise { return super.post(url, body, config); } protected async get( url: string, params: any = {}, config: A_SDK_TYPES__Required, ['authenticator']> ): Promise { return super.get(url, params, config); } protected async put( url: string, body: any = {}, config: A_SDK_TYPES__Required, ['authenticator']> ): Promise { return super.put(url, body, config); } protected async delete( url: string, config: A_SDK_TYPES__Required, ['authenticator']> ): Promise { return super.delete(url, config); } protected async patch( url: string, body: any = {}, config: A_SDK_TYPES__Required, ['authenticator']> ): Promise { return super.patch(url, body, config); } }