Skip to content

Commit

Permalink
Update type definitions based on requested/discussed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Oct 14, 2024
1 parent 0f982c8 commit b70a8ab
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 188 deletions.
71 changes: 70 additions & 1 deletion lib/build/recipe/accountlinking/types.d.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/emailpassword/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ function getAPIImplementation() {
user: postAuthChecks.user,
};
},
updatePasswordPOST: undefined,
changeEmailPOST: undefined,
};
}
exports.default = getAPIImplementation;
78 changes: 43 additions & 35 deletions lib/build/recipe/emailpassword/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/session/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function getAPIInterface() {
status: "OK",
};
},
allSessionsGET: undefined,
revokeSessionPOST: undefined,
};
}
exports.default = getAPIInterface;
60 changes: 26 additions & 34 deletions lib/build/recipe/session/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 0 additions & 24 deletions lib/build/recipe/thirdparty/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,29 +330,5 @@ export declare type APIInterface = {
options: APIOptions;
userContext: UserContext;
}) => Promise<void>);
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 {};
73 changes: 72 additions & 1 deletion lib/ts/recipe/accountlinking/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions lib/ts/recipe/emailpassword/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,5 +926,8 @@ export default function getAPIImplementation(): APIInterface {
user: postAuthChecks.user,
};
},

updatePasswordPOST: undefined,
changeEmailPOST: undefined,
};
}
Loading

0 comments on commit b70a8ab

Please sign in to comment.