import { NormalisedAppInfo } from "./types"; import { PostAPIHookFunction, PreAPIHookFunction, RecipeFunctionOptions, RecipePostAPIHookFunction, RecipePreAPIHookFunction, } from "./recipe/recipeModule/types"; import { PathParam, RequestInitWithInferredBody, ResponseBody, Method, RequestInitWithInferredBodyRequired, } from "./sdk/types"; /** * When network calls are made the Querier calls .clone() on the response before: * 1. Calling the post API hook * 2. Calling .json() when trying to read the body * * This is because the SDK needs to read the json body but we also want to allow users to read * the json body themselves (either in the post api hook or from the result of recipe functions) * for custom response handling. Since the body can only be read once we use .clone() to allow * for multiple reads. */ export default class Querier { private readonly recipeId; private readonly appInfo; constructor(recipeId: string, appInfo: NormalisedAppInfo); private getPath; private safelyStringifyBody; get: < P extends | "/mfa/info" | "/totp/device/list" | "/totp/device" | "/totp/device/remove" | "/totp/device/verify" | "/totp/verify" | "//signinup/code" | "//signinup/code/resend" | "//signinup/code/consume" | "//signup/email/exists⠀⠀" | "//passwordless/email/exists" | "//signup/phoneNumber/exists" | "//passwordless/phonenumber/exists" | "/signout" | "/session/refresh" | "//signin" | "//signup" | "//signup/email/exists" | "//emailpassword/email/exists" | "//user/password/reset/token" | "//user/password/reset" | "//signinup" | "//authorisationurl" | "//loginmethods" | "/callback/apple" | "/user/email/verify/token" | "//user/email/verify" | "/user/email/verify" | "/jwt/jwks.json" | "/.well-known/openid-configuration" | "/oauth/login" | "/oauth/auth" | "/oauth/token" | "/oauth/userinfo" | "/oauth/revoke" | "/oauth/introspect" | "/oauth/end_session" | "/oauth/login/info" | "/oauth/logout" | "/example" | "//webauthn/options/register" | "//webauthn/options/signin" | "//webauthn/signup" | "//webauthn/signin" | "//webauthn/recover/account/token" | "//webauthn/recover/account" | "//webauthn/credential" | "//webauthn/credential/remove" | "//webauthn/credential/list" | "//webauthn/email/exists" | "//user/webauthn/reset/token" | "//user/webauthn/reset" >( template: PathParam, config: RequestInitWithInferredBody, preAPIHook?: PreAPIHookFunction, postAPIHook?: PostAPIHookFunction ) => Promise<{ jsonBody: import("./sdk/types").RemoveGeneralError< import("./sdk/types").UncleanedResponseBody > extends infer T ? T extends import("./sdk/types").RemoveGeneralError> ? T extends any ? { [K in keyof T]-?: NonNullable } : never : never : never; fetchResponse: Response; }>; post: < P extends | "/mfa/info" | "/totp/device/list" | "/totp/device" | "/totp/device/remove" | "/totp/device/verify" | "/totp/verify" | "//signinup/code" | "//signinup/code/resend" | "//signinup/code/consume" | "//signup/email/exists⠀⠀" | "//passwordless/email/exists" | "//signup/phoneNumber/exists" | "//passwordless/phonenumber/exists" | "/signout" | "/session/refresh" | "//signin" | "//signup" | "//signup/email/exists" | "//emailpassword/email/exists" | "//user/password/reset/token" | "//user/password/reset" | "//signinup" | "//authorisationurl" | "//loginmethods" | "/callback/apple" | "/user/email/verify/token" | "//user/email/verify" | "/user/email/verify" | "/jwt/jwks.json" | "/.well-known/openid-configuration" | "/oauth/login" | "/oauth/auth" | "/oauth/token" | "/oauth/userinfo" | "/oauth/revoke" | "/oauth/introspect" | "/oauth/end_session" | "/oauth/login/info" | "/oauth/logout" | "/example" | "//webauthn/options/register" | "//webauthn/options/signin" | "//webauthn/signup" | "//webauthn/signin" | "//webauthn/recover/account/token" | "//webauthn/recover/account" | "//webauthn/credential" | "//webauthn/credential/remove" | "//webauthn/credential/list" | "//webauthn/email/exists" | "//user/webauthn/reset/token" | "//user/webauthn/reset" >( template: PathParam, config: RequestInitWithInferredBodyRequired, preAPIHook?: PreAPIHookFunction, postAPIHook?: PostAPIHookFunction ) => Promise<{ jsonBody: import("./sdk/types").RemoveGeneralError< import("./sdk/types").UncleanedResponseBody > extends infer T ? T extends import("./sdk/types").RemoveGeneralError> ? T extends any ? { [K in keyof T]-?: NonNullable } : never : never : never; fetchResponse: Response; }>; delete: < P extends | "/mfa/info" | "/totp/device/list" | "/totp/device" | "/totp/device/remove" | "/totp/device/verify" | "/totp/verify" | "//signinup/code" | "//signinup/code/resend" | "//signinup/code/consume" | "//signup/email/exists⠀⠀" | "//passwordless/email/exists" | "//signup/phoneNumber/exists" | "//passwordless/phonenumber/exists" | "/signout" | "/session/refresh" | "//signin" | "//signup" | "//signup/email/exists" | "//emailpassword/email/exists" | "//user/password/reset/token" | "//user/password/reset" | "//signinup" | "//authorisationurl" | "//loginmethods" | "/callback/apple" | "/user/email/verify/token" | "//user/email/verify" | "/user/email/verify" | "/jwt/jwks.json" | "/.well-known/openid-configuration" | "/oauth/login" | "/oauth/auth" | "/oauth/token" | "/oauth/userinfo" | "/oauth/revoke" | "/oauth/introspect" | "/oauth/end_session" | "/oauth/login/info" | "/oauth/logout" | "/example" | "//webauthn/options/register" | "//webauthn/options/signin" | "//webauthn/signup" | "//webauthn/signin" | "//webauthn/recover/account/token" | "//webauthn/recover/account" | "//webauthn/credential" | "//webauthn/credential/remove" | "//webauthn/credential/list" | "//webauthn/email/exists" | "//user/webauthn/reset/token" | "//user/webauthn/reset" >( template: PathParam, config: RequestInitWithInferredBody, preAPIHook?: PreAPIHookFunction, postAPIHook?: PostAPIHookFunction ) => Promise<{ jsonBody: import("./sdk/types").RemoveGeneralError< import("./sdk/types").UncleanedResponseBody > extends infer T ? T extends import("./sdk/types").RemoveGeneralError< import("./sdk/types").UncleanedResponseBody > ? T extends any ? { [K in keyof T]-?: NonNullable } : never : never : never; fetchResponse: Response; }>; put: < P extends | "/mfa/info" | "/totp/device/list" | "/totp/device" | "/totp/device/remove" | "/totp/device/verify" | "/totp/verify" | "//signinup/code" | "//signinup/code/resend" | "//signinup/code/consume" | "//signup/email/exists⠀⠀" | "//passwordless/email/exists" | "//signup/phoneNumber/exists" | "//passwordless/phonenumber/exists" | "/signout" | "/session/refresh" | "//signin" | "//signup" | "//signup/email/exists" | "//emailpassword/email/exists" | "//user/password/reset/token" | "//user/password/reset" | "//signinup" | "//authorisationurl" | "//loginmethods" | "/callback/apple" | "/user/email/verify/token" | "//user/email/verify" | "/user/email/verify" | "/jwt/jwks.json" | "/.well-known/openid-configuration" | "/oauth/login" | "/oauth/auth" | "/oauth/token" | "/oauth/userinfo" | "/oauth/revoke" | "/oauth/introspect" | "/oauth/end_session" | "/oauth/login/info" | "/oauth/logout" | "/example" | "//webauthn/options/register" | "//webauthn/options/signin" | "//webauthn/signup" | "//webauthn/signin" | "//webauthn/recover/account/token" | "//webauthn/recover/account" | "//webauthn/credential" | "//webauthn/credential/remove" | "//webauthn/credential/list" | "//webauthn/email/exists" | "//user/webauthn/reset/token" | "//user/webauthn/reset" >( template: PathParam, config: RequestInitWithInferredBody, preAPIHook?: PreAPIHookFunction, postAPIHook?: PostAPIHookFunction ) => Promise<{ jsonBody: import("./sdk/types").RemoveGeneralError< import("./sdk/types").UncleanedResponseBody > extends infer T ? T extends import("./sdk/types").RemoveGeneralError> ? T extends any ? { [K in keyof T]-?: NonNullable } : never : never : never; fetchResponse: Response; }>; fetch: ( url: string, config: RequestInit, preAPIHook?: PreAPIHookFunction, postAPIHook?: PostAPIHookFunction ) => Promise; callPreAPIHook: (context: { preAPIHook?: PreAPIHookFunction; requestInit: RequestInit; url: string }) => Promise<{ url: string; requestInit: RequestInit; }>; getFullUrl: < P extends | "/mfa/info" | "/totp/device/list" | "/totp/device" | "/totp/device/remove" | "/totp/device/verify" | "/totp/verify" | "//signinup/code" | "//signinup/code/resend" | "//signinup/code/consume" | "//signup/email/exists⠀⠀" | "//passwordless/email/exists" | "//signup/phoneNumber/exists" | "//passwordless/phonenumber/exists" | "/signout" | "/session/refresh" | "//signin" | "//signup" | "//signup/email/exists" | "//emailpassword/email/exists" | "//user/password/reset/token" | "//user/password/reset" | "//signinup" | "//authorisationurl" | "//loginmethods" | "/callback/apple" | "/user/email/verify/token" | "//user/email/verify" | "/user/email/verify" | "/jwt/jwks.json" | "/.well-known/openid-configuration" | "/oauth/login" | "/oauth/auth" | "/oauth/token" | "/oauth/userinfo" | "/oauth/revoke" | "/oauth/introspect" | "/oauth/end_session" | "/oauth/login/info" | "/oauth/logout" | "/example" | "//webauthn/options/register" | "//webauthn/options/signin" | "//webauthn/signup" | "//webauthn/signin" | "//webauthn/recover/account/token" | "//webauthn/recover/account" | "//webauthn/credential" | "//webauthn/credential/remove" | "//webauthn/credential/list" | "//webauthn/email/exists" | "//user/webauthn/reset/token" | "//user/webauthn/reset", M extends Method >( path: PathParam ) => string; getResponseJsonOrThrowGeneralError: (response: Response) => Promise; static preparePreAPIHook: ({ recipePreAPIHook, action, options, userContext, }: { recipePreAPIHook: RecipePreAPIHookFunction; action: Action; options?: RecipeFunctionOptions | undefined; userContext: any; }) => PreAPIHookFunction; static preparePostAPIHook: ({ recipePostAPIHook, action, userContext, }: { recipePostAPIHook: RecipePostAPIHookFunction; action: Action; userContext: any; }) => PostAPIHookFunction; }