diff --git a/lib/build/recipe/accountlinking/types.d.ts b/lib/build/recipe/accountlinking/types.d.ts index 3530940ee..44ad3929f 100644 --- a/lib/build/recipe/accountlinking/types.d.ts +++ b/lib/build/recipe/accountlinking/types.d.ts @@ -1,6 +1,7 @@ // @ts-nocheck +import type { BaseRequest, BaseResponse } from "../../framework"; import OverrideableBuilder from "supertokens-js-override"; -import type { User, UserContext } from "../../types"; +import type { GeneralErrorResponse, NormalisedAppinfo, User, UserContext } from "../../types"; import RecipeUserId from "../../recipeUserId"; import { SessionContainerInterface } from "../session/types"; export declare type TypeInput = { @@ -175,6 +176,74 @@ export declare type RecipeInterface = { status: "OK"; }>; }; +export declare type APIOptions = { + recipeImplementation: RecipeInterface; + appInfo: NormalisedAppinfo; + config: TypeNormalisedInput; + recipeId: string; + isInServerlessEnv: boolean; + req: BaseRequest; + res: BaseResponse; +}; +export declare type APIInterface = { + userDetailsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + user: User; + } + | GeneralErrorResponse + >); + userEnabledDetailsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + enabledRecipes: string[]; + shouldDoAutomaticAccountLinking: boolean; + } + | GeneralErrorResponse + >); + loginMethodDELETE: + | undefined + | ((input: { + recipeId: string; + recipeUserId: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + >); + updateUserDetailsPOST: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { + status: "USER_DETAILS_UPDATE_NOT_ALLOWED"; + reason: string; + } + | GeneralErrorResponse + >); +}; export declare type AccountInfo = { email?: string; phoneNumber?: string; diff --git a/lib/build/recipe/emailpassword/api/implementation.js b/lib/build/recipe/emailpassword/api/implementation.js index 6619c14cf..6eea377fe 100644 --- a/lib/build/recipe/emailpassword/api/implementation.js +++ b/lib/build/recipe/emailpassword/api/implementation.js @@ -775,6 +775,8 @@ function getAPIImplementation() { user: postAuthChecks.user, }; }, + updatePasswordPOST: undefined, + changeEmailPOST: undefined, }; } exports.default = getAPIImplementation; diff --git a/lib/build/recipe/emailpassword/types.d.ts b/lib/build/recipe/emailpassword/types.d.ts index 94d655389..9757645b2 100644 --- a/lib/build/recipe/emailpassword/types.d.ts +++ b/lib/build/recipe/emailpassword/types.d.ts @@ -322,41 +322,49 @@ export declare type APIInterface = { } | GeneralErrorResponse >); - passwordStateGET?: (input: { - email: string; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - exists: boolean; - } - | GeneralErrorResponse - >; - updatePasswordPOST?: (input: { - details: { - email: string; - newPassword: string; - oldPassword?: string; - }; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - } - | { - status: "OLD_PASSWORD_IS_REQUIRED_FOR_VERIFICATION"; - reason: string; - } - | { - status: "PASSWORD_POLICY_VIOLATED_ERROR"; - failureReason: string; - } - | GeneralErrorResponse - >; + updatePasswordPOST: + | undefined + | ((input: { + newPassword: string; + oldPassword: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { + status: "WRONG_CREDENTIALS_ERROR"; + } + | { + status: "PASSWORD_POLICY_VIOLATED_ERROR"; + failureReason: string; + } + | GeneralErrorResponse + >); + changeEmailPOST: + | undefined + | ((input: { + email: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { + status: "EMAIL_VERIFICATION_SENT"; + } + | { + status: "EMAIL_ALREADY_EXISTS_ERROR"; + } + | { + status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR"; + } + | GeneralErrorResponse + >); }; export declare type TypeEmailPasswordPasswordResetEmailDeliveryInput = { type: "PASSWORD_RESET"; diff --git a/lib/build/recipe/session/api/implementation.js b/lib/build/recipe/session/api/implementation.js index d079f77e9..b03e57366 100644 --- a/lib/build/recipe/session/api/implementation.js +++ b/lib/build/recipe/session/api/implementation.js @@ -51,6 +51,8 @@ function getAPIInterface() { status: "OK", }; }, + allSessionsGET: undefined, + revokeSessionPOST: undefined, }; } exports.default = getAPIInterface; diff --git a/lib/build/recipe/session/types.d.ts b/lib/build/recipe/session/types.d.ts index 89950bfa8..ffd51104d 100644 --- a/lib/build/recipe/session/types.d.ts +++ b/lib/build/recipe/session/types.d.ts @@ -323,40 +323,32 @@ export declare type APIInterface = { } | GeneralErrorResponse >); - allSessionsGET?: (input: { - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - sessions: SessionInformation[]; - } - | GeneralErrorResponse - >; - revokeAllSessionsPOST?: (input: { - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - sessionRemoveCount: number; - } - | GeneralErrorResponse - >; - revokeSessionPOST?: (input: { - sessionHandle: string; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - wasRemoved: boolean; - } - | GeneralErrorResponse - >; + allSessionsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + sessions: SessionInformation[]; + } + | GeneralErrorResponse + >); + revokeSessionPOST: + | undefined + | ((input: { + sessionHandle: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + >); verifySession(input: { verifySessionOptions: VerifySessionOptions | undefined; options: APIOptions; diff --git a/lib/build/recipe/thirdparty/types.d.ts b/lib/build/recipe/thirdparty/types.d.ts index 2e38a977d..8d0198e3b 100644 --- a/lib/build/recipe/thirdparty/types.d.ts +++ b/lib/build/recipe/thirdparty/types.d.ts @@ -330,29 +330,5 @@ export declare type APIInterface = { options: APIOptions; userContext: UserContext; }) => Promise); - connectedAccountsGET?: (input: { - session: SessionContainerInterface; - options: APIOptions; - }) => Promise< - | { - status: "OK"; - accounts: { - id: string; - userId: string; - }[]; - } - | GeneralErrorResponse - >; - removeAccountDELETE?: (input: { - id: string; - session: SessionContainerInterface; - options: APIOptions; - }) => Promise< - | { - status: "OK"; - wasDeleted: boolean; - } - | GeneralErrorResponse - >; }; export {}; diff --git a/lib/ts/recipe/accountlinking/types.ts b/lib/ts/recipe/accountlinking/types.ts index 83aec5230..0867494d3 100644 --- a/lib/ts/recipe/accountlinking/types.ts +++ b/lib/ts/recipe/accountlinking/types.ts @@ -13,8 +13,9 @@ * under the License. */ +import type { BaseRequest, BaseResponse } from "../../framework"; import OverrideableBuilder from "supertokens-js-override"; -import type { User, UserContext } from "../../types"; +import type { GeneralErrorResponse, NormalisedAppinfo, User, UserContext } from "../../types"; import RecipeUserId from "../../recipeUserId"; import { SessionContainerInterface } from "../session/types"; @@ -185,6 +186,76 @@ export type RecipeInterface = { }) => Promise<{ status: "OK" }>; }; +export type APIOptions = { + recipeImplementation: RecipeInterface; + appInfo: NormalisedAppinfo; + config: TypeNormalisedInput; + recipeId: string; + isInServerlessEnv: boolean; + req: BaseRequest; + res: BaseResponse; +}; + +export type APIInterface = { + userDetailsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + user: User; + } + | GeneralErrorResponse + >); + + userEnabledDetailsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + enabledRecipes: string[]; + shouldDoAutomaticAccountLinking: boolean; + } + | GeneralErrorResponse + >); + + loginMethodDELETE: + | undefined + | ((input: { + recipeId: string; + recipeUserId: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + >); + + updateUserDetailsPOST: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { status: "USER_DETAILS_UPDATE_NOT_ALLOWED"; reason: string } + | GeneralErrorResponse + >); +}; + export type AccountInfo = { email?: string; phoneNumber?: string; diff --git a/lib/ts/recipe/emailpassword/api/implementation.ts b/lib/ts/recipe/emailpassword/api/implementation.ts index 635ff2bd6..1eb46e992 100644 --- a/lib/ts/recipe/emailpassword/api/implementation.ts +++ b/lib/ts/recipe/emailpassword/api/implementation.ts @@ -926,5 +926,8 @@ export default function getAPIImplementation(): APIInterface { user: postAuthChecks.user, }; }, + + updatePasswordPOST: undefined, + changeEmailPOST: undefined, }; } diff --git a/lib/ts/recipe/emailpassword/types.ts b/lib/ts/recipe/emailpassword/types.ts index 39ad2dfe6..fc780ea15 100644 --- a/lib/ts/recipe/emailpassword/types.ts +++ b/lib/ts/recipe/emailpassword/types.ts @@ -326,39 +326,39 @@ export type APIInterface = { | GeneralErrorResponse >); - passwordStateGET?: (input: { - email: string; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - exists: boolean; - } - | GeneralErrorResponse - >; + updatePasswordPOST: + | undefined + | ((input: { + newPassword: string; + oldPassword: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { status: "WRONG_CREDENTIALS_ERROR" } + | { status: "PASSWORD_POLICY_VIOLATED_ERROR"; failureReason: string } + | GeneralErrorResponse + >); - updatePasswordPOST?: (input: { - details: { - email: string; - newPassword: string; - oldPassword?: string; - }; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - } - | { - status: "OLD_PASSWORD_IS_REQUIRED_FOR_VERIFICATION"; - reason: string; - } - | { status: "PASSWORD_POLICY_VIOLATED_ERROR"; failureReason: string } - | GeneralErrorResponse - >; + changeEmailPOST: + | undefined + | ((input: { + email: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | { status: "EMAIL_VERIFICATION_SENT" } + | { status: "EMAIL_ALREADY_EXISTS_ERROR" } + | { status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR" } + | GeneralErrorResponse + >); }; export type TypeEmailPasswordPasswordResetEmailDeliveryInput = { diff --git a/lib/ts/recipe/session/api/implementation.ts b/lib/ts/recipe/session/api/implementation.ts index e6b799e9d..084e722a7 100644 --- a/lib/ts/recipe/session/api/implementation.ts +++ b/lib/ts/recipe/session/api/implementation.ts @@ -80,5 +80,8 @@ export default function getAPIInterface(): APIInterface { status: "OK", }; }, + + allSessionsGET: undefined, + revokeSessionPOST: undefined, }; } diff --git a/lib/ts/recipe/session/types.ts b/lib/ts/recipe/session/types.ts index 9cfc67459..253aee8cb 100644 --- a/lib/ts/recipe/session/types.ts +++ b/lib/ts/recipe/session/types.ts @@ -394,42 +394,33 @@ export type APIInterface = { | GeneralErrorResponse >); - allSessionsGET?: (input: { - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - sessions: SessionInformation[]; - } - | GeneralErrorResponse - >; - - revokeAllSessionsPOST?: (input: { - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - sessionRemoveCount: number; - } - | GeneralErrorResponse - >; + allSessionsGET: + | undefined + | ((input: { + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + sessions: SessionInformation[]; + } + | GeneralErrorResponse + >); - revokeSessionPOST?: (input: { - sessionHandle: string; - session: SessionContainerInterface; - options: APIOptions; - userContext: UserContext; - }) => Promise< - | { - status: "OK"; - wasRemoved: boolean; - } - | GeneralErrorResponse - >; + revokeSessionPOST: + | undefined + | ((input: { + sessionHandle: string; + session: SessionContainerInterface; + options: APIOptions; + userContext: UserContext; + }) => Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + >); verifySession(input: { verifySessionOptions: VerifySessionOptions | undefined; diff --git a/lib/ts/recipe/thirdparty/types.ts b/lib/ts/recipe/thirdparty/types.ts index 62ea24b1a..71e9847d3 100644 --- a/lib/ts/recipe/thirdparty/types.ts +++ b/lib/ts/recipe/thirdparty/types.ts @@ -316,30 +316,4 @@ export type APIInterface = { options: APIOptions; userContext: UserContext; }) => Promise); - - connectedAccountsGET?: (input: { - session: SessionContainerInterface; - options: APIOptions; - }) => Promise< - | { - status: "OK"; - accounts: { - id: string; - userId: string; - }[]; - } - | GeneralErrorResponse - >; - - removeAccountDELETE?: (input: { - id: string; - session: SessionContainerInterface; - options: APIOptions; - }) => Promise< - | { - status: "OK"; - wasDeleted: boolean; - } - | GeneralErrorResponse - >; };