Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: user management support API types #944

Draft
wants to merge 12 commits into
base: 21.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/build/recipe/emailpassword/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,41 @@ 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
>;
};
export declare type TypeEmailPasswordPasswordResetEmailDeliveryInput = {
type: "PASSWORD_RESET";
Expand Down
55 changes: 55 additions & 0 deletions lib/build/recipe/multifactorauth/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,61 @@ export declare type APIInterface = {
}
| GeneralErrorResponse
>);
factorsSetupForUserGET?: (input: {
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
factors: {
id: string;
details: JSONObject;
}[];
backupCodes: string[] | undefined;
}
| GeneralErrorResponse
>;
addFactorForUserPOST?: (input: {
factor: {
id: string;
};
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
backupCodes: string[];
}
| GeneralErrorResponse
>;
deleteFactorForUserDELETE?: (input: {
factorId: string;
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
}
| GeneralErrorResponse
>;
generateBackupCodesPOST?: (input: {
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
backupCodes: string[];
}
| {
status: "NO_FACTORS_ARE_SETUP";
reason: string;
}
| GeneralErrorResponse
>;
};
export declare type GetFactorsSetupForUserFromOtherRecipesFunc = (
user: User,
Expand Down
34 changes: 34 additions & 0 deletions lib/build/recipe/session/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,40 @@ 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
>;
verifySession(input: {
verifySessionOptions: VerifySessionOptions | undefined;
options: APIOptions;
Expand Down
24 changes: 24 additions & 0 deletions lib/build/recipe/thirdparty/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,29 @@ 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 {};
174 changes: 172 additions & 2 deletions lib/build/recipe/usermetadata/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-nocheck
import { BaseRequest, BaseResponse } from "../../framework";
import OverrideableBuilder from "supertokens-js-override";
import { JSONObject, UserContext } from "../../types";
import { GeneralErrorResponse, JSONObject, UserContext } from "../../types";
import { SessionContainerInterface } from "../session/types";
export declare type TypeInput = {
override?: {
functions?: (
Expand All @@ -19,7 +21,175 @@ export declare type TypeNormalisedInput = {
apis: (originalImplementation: APIInterface, builder?: OverrideableBuilder<APIInterface>) => APIInterface;
};
};
export declare type APIInterface = {};
export declare type APIOptions = {
recipeImplementation: RecipeInterface;
config: TypeNormalisedInput;
recipeId: string;
isInServerlessEnv: boolean;
req: BaseRequest;
res: BaseResponse;
};
export declare type APIInterface = {
userDetailsGET?: (input: {
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
details: {
name?: string;
};
}
| GeneralErrorResponse
>;
updateUserDetailsPOST?: (input: {
session: SessionContainerInterface;
details: {
name?: string;
};
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
details: {
name: string | undefined;
};
}
| {
status: "USER_DETAILS_UPDATE_NOT_ALLOWED";
reason: string;
}
| GeneralErrorResponse
>;
userEmailsGET?: (input: {
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
emails: Array<{
id: string;
isVerified: boolean;
isPrimary: boolean;
}>;
}
| GeneralErrorResponse
>;
addEmailForUserPOST?: (input: {
email: {
id: string;
isVerified?: boolean;
isPrimary?: boolean;
};
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
}
| {
status: "UNVERIFIED_EMAIL_CANNOT_BE_PRIMARY";
reason: string;
}
| GeneralErrorResponse
>;
updateEmailForUserPATCH?: (input: {
emailId: string;
details: {
isVerified?: boolean;
isPrimary?: boolean;
};
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
}
| {
status: "UNVERIFIED_EMAIL_CANNOT_BE_PRIMARY";
reason: string;
}
| GeneralErrorResponse
>;
removeEmailForUserDELETE?: (
emailId: string,
session: SessionContainerInterface,
options: APIOptions,
userContext: UserContext
) => Promise<
| {
status: "OK";
email: {
id: string;
isVerified: boolean;
isPrimary: boolean;
};
}
| {
status: "AT_LEAST_ONE_VERIFIED_EMAIL_IS_REQUIRED";
reason: string;
}
| GeneralErrorResponse
>;
userPhoneNumbersGET?: (input: {
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
phones: Array<{
number: string;
isVerified: boolean;
}>;
}
| GeneralErrorResponse
>;
addPhoneNumberForUserPOST?: (input: {
phone: {
number: string;
isVerified?: boolean;
};
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
}
| GeneralErrorResponse
>;
updatePhoneNumberForUserPATCH?: (input: {
phoneNumber: string;
details: {
isVerified?: boolean;
};
session: SessionContainerInterface;
options: APIOptions;
userContext: UserContext;
}) => Promise<
| {
status: "OK";
}
| GeneralErrorResponse
>;
removePhoneNumberForUserDELETE?: (
phoneNumber: string,
session: SessionContainerInterface,
options: APIOptions,
userContext: UserContext
) => Promise<
| {
status: "OK";
}
| GeneralErrorResponse
>;
};
export declare type RecipeInterface = {
getUserMetadata: (input: {
userId: string;
Expand Down
Loading
Loading