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

passwordless interface changes for account linking #444

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion lib/build/recipe/passwordless/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function getAPIImplementation() {
if (emailVerificationInstance) {
const tokenResponse = yield emailVerificationInstance.recipeInterfaceImpl.createEmailVerificationToken(
{
userId: user.id,
userId: user.recipeUserId,
email: user.email,
userContext: input.userContext,
}
Expand All @@ -85,6 +85,7 @@ function getAPIImplementation() {
return {
status: "OK",
createdNewUser: response.createdNewUser,
createdNewRecipeUser: false,
user: response.user,
session,
};
Expand Down Expand Up @@ -287,6 +288,14 @@ function getAPIImplementation() {
}
});
},
linkAccountToExistingAccountPOST: function (_input) {
return __awaiter(this, void 0, void 0, function* () {
return {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR",
description: "",
};
});
},
};
}
exports.default = getAPIImplementation;
47 changes: 47 additions & 0 deletions lib/build/recipe/passwordless/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export declare type APIInterface = {
| {
status: "OK";
createdNewUser: boolean;
createdNewRecipeUser: boolean;
user: User;
session: SessionContainerInterface;
}
Expand All @@ -323,7 +324,53 @@ export declare type APIInterface = {
| {
status: "RESTART_FLOW_ERROR";
}
| {
status: "SIGNUP_NOT_ALLOWED";
reason: string;
}
>;
linkAccountToExistingAccountPOST:
| undefined
| ((
input: (
| {
userInputCode: string;
deviceId: string;
preAuthSessionId: string;
}
| {
linkCode: string;
preAuthSessionId: string;
}
) & {
session: SessionContainerInterface;
options: APIOptions;
userContext: any;
}
) => Promise<
| {
status: "OK";
user: User;
createdNewRecipeUser: boolean;
session: SessionContainerInterface;
wereAccountsAlreadyLinked: boolean;
}
| {
status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_INFO_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR";
description: string;
}
| GeneralErrorResponse
>);
emailExistsGET?: (input: {
email: string;
options: APIOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const implementation_2 = require("../../thirdparty/api/implementation");
const passwordlessAPIImplementation_1 = require("./passwordlessAPIImplementation");
const thirdPartyAPIImplementation_1 = require("./thirdPartyAPIImplementation");
function getAPIImplementation() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
let passwordlessImplementation = implementation_1.default();
let thirdPartyImplementation = implementation_2.default();
return {
Expand Down Expand Up @@ -45,6 +45,10 @@ function getAPIImplementation() {
(_j = thirdPartyImplementation.appleRedirectHandlerPOST) === null || _j === void 0
? void 0
: _j.bind(thirdPartyAPIImplementation_1.default(this)),
linkPasswordlessAccountToExistingAccountPOST:
(_k = passwordlessImplementation.linkAccountToExistingAccountPOST) === null || _k === void 0
? void 0
: _k.bind(passwordlessAPIImplementation_1.default(this)),
};
}
exports.default = getAPIImplementation;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getIterfaceImpl(apiImplmentation) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
return {
emailExistsGET:
(_a = apiImplmentation.passwordlessUserEmailExistsGET) === null || _a === void 0
Expand All @@ -17,6 +17,10 @@ function getIterfaceImpl(apiImplmentation) {
: _d.bind(apiImplmentation),
resendCodePOST:
(_e = apiImplmentation.resendCodePOST) === null || _e === void 0 ? void 0 : _e.bind(apiImplmentation),
linkAccountToExistingAccountPOST:
(_f = apiImplmentation.linkPasswordlessAccountToExistingAccountPOST) === null || _f === void 0
? void 0
: _f.bind(apiImplmentation),
};
}
exports.default = getIterfaceImpl;
47 changes: 47 additions & 0 deletions lib/build/recipe/thirdpartypasswordless/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export declare type APIInterface = {
| {
status: "OK";
createdNewUser: boolean;
createdNewRecipeUser: boolean;
user: User;
session: SessionContainerInterface;
}
Expand All @@ -438,6 +439,10 @@ export declare type APIInterface = {
| {
status: "RESTART_FLOW_ERROR";
}
| {
status: "SIGNUP_NOT_ALLOWED";
reason: string;
}
>);
passwordlessUserEmailExistsGET:
| undefined
Expand Down Expand Up @@ -465,6 +470,48 @@ export declare type APIInterface = {
}
| GeneralErrorResponse
>);
linkPasswordlessAccountToExistingAccountPOST:
| undefined
| ((
input: (
| {
userInputCode: string;
deviceId: string;
preAuthSessionId: string;
}
| {
linkCode: string;
preAuthSessionId: string;
}
) & {
session: SessionContainerInterface;
options: PasswordlessAPIOptions;
userContext: any;
}
) => Promise<
| {
status: "OK";
user: User;
createdNewRecipeUser: boolean;
session: SessionContainerInterface;
wereAccountsAlreadyLinked: boolean;
}
| {
status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_INFO_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR";
description: string;
}
| GeneralErrorResponse
>);
};
export declare type TypeThirdPartyPasswordlessEmailDeliveryInput = TypePasswordlessEmailDeliveryInput;
export declare type TypeThirdPartyPasswordlessSmsDeliveryInput = TypePasswordlessSmsDeliveryInput;
9 changes: 8 additions & 1 deletion lib/ts/recipe/passwordless/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function getAPIImplementation(): APIInterface {
if (emailVerificationInstance) {
const tokenResponse = await emailVerificationInstance.recipeInterfaceImpl.createEmailVerificationToken(
{
userId: user.id,
userId: user.recipeUserId,
email: user.email,
userContext: input.userContext,
}
Expand All @@ -59,6 +59,7 @@ export default function getAPIImplementation(): APIInterface {
return {
status: "OK",
createdNewUser: response.createdNewUser,
createdNewRecipeUser: false, // TODO
user: response.user,
session,
};
Expand Down Expand Up @@ -264,5 +265,11 @@ export default function getAPIImplementation(): APIInterface {
};
}
},
linkAccountToExistingAccountPOST: async function (_input) {
return {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR",
description: "",
};
},
};
}
55 changes: 54 additions & 1 deletion lib/ts/recipe/passwordless/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export type RecipeInterface = {
getUserByPhoneNumber: (input: { phoneNumber: string; userContext: any }) => Promise<User | undefined>;

updateUser: (input: {
userId: string;
userId: string; // the id can be either recipeUserId or primaryUserId
email?: string | null;
phoneNumber?: string | null;
userContext: any;
Expand Down Expand Up @@ -359,6 +359,7 @@ export type APIInterface = {
| {
status: "OK";
createdNewUser: boolean;
createdNewRecipeUser: boolean;
user: User;
session: SessionContainerInterface;
}
Expand All @@ -369,8 +370,60 @@ export type APIInterface = {
}
| GeneralErrorResponse
| { status: "RESTART_FLOW_ERROR" }
| {
status: "SIGNUP_NOT_ALLOWED";
reason: string;
}
>;

linkAccountToExistingAccountPOST:
| undefined
| ((
input: (
| {
userInputCode: string;
deviceId: string;
preAuthSessionId: string;
}
| {
linkCode: string;
preAuthSessionId: string;
}
) & {
session: SessionContainerInterface;
options: APIOptions;
userContext: any;
}
) => Promise<
| {
status: "OK";
user: User;
createdNewRecipeUser: boolean;
session: SessionContainerInterface;
wereAccountsAlreadyLinked: boolean;
}
| {
status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_INFO_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR";
description: string;
}
// | {
// status: "ACCOUNT_NOT_VERIFIED_ERROR"; This error is not possible
// isNotVerifiedAccountFromInputSession: boolean;
// description: string;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is possible

| GeneralErrorResponse
>);

emailExistsGET?: (input: {
email: string;
options: APIOptions;
Expand Down
3 changes: 3 additions & 0 deletions lib/ts/recipe/thirdpartypasswordless/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ export default function getAPIImplementation(): APIInterface {
authorisationUrlGET: thirdPartyImplementation.authorisationUrlGET?.bind(DerivedTP(this)),
thirdPartySignInUpPOST: thirdPartyImplementation.signInUpPOST?.bind(DerivedTP(this)),
appleRedirectHandlerPOST: thirdPartyImplementation.appleRedirectHandlerPOST?.bind(DerivedTP(this)),
linkPasswordlessAccountToExistingAccountPOST: passwordlessImplementation.linkAccountToExistingAccountPOST?.bind(
DerivedPwdless(this)
),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export default function getIterfaceImpl(apiImplmentation: ThirdPartyPasswordless
createCodePOST: apiImplmentation.createCodePOST?.bind(apiImplmentation),
phoneNumberExistsGET: apiImplmentation.passwordlessUserPhoneNumberExistsGET?.bind(apiImplmentation),
resendCodePOST: apiImplmentation.resendCodePOST?.bind(apiImplmentation),
linkAccountToExistingAccountPOST: apiImplmentation.linkPasswordlessAccountToExistingAccountPOST?.bind(
apiImplmentation
),
};
}
48 changes: 48 additions & 0 deletions lib/ts/recipe/thirdpartypasswordless/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ export type APIInterface = {
| {
status: "OK";
createdNewUser: boolean;
createdNewRecipeUser: boolean;
user: User;
session: SessionContainerInterface;
}
Expand All @@ -482,6 +483,10 @@ export type APIInterface = {
}
| GeneralErrorResponse
| { status: "RESTART_FLOW_ERROR" }
| {
status: "SIGNUP_NOT_ALLOWED";
reason: string;
}
>);

passwordlessUserEmailExistsGET:
Expand Down Expand Up @@ -511,6 +516,49 @@ export type APIInterface = {
}
| GeneralErrorResponse
>);

linkPasswordlessAccountToExistingAccountPOST:
| undefined
| ((
input: (
| {
userInputCode: string;
deviceId: string;
preAuthSessionId: string;
}
| {
linkCode: string;
preAuthSessionId: string;
}
) & {
session: SessionContainerInterface;
options: PasswordlessAPIOptions;
userContext: any;
}
) => Promise<
| {
status: "OK";
user: User;
createdNewRecipeUser: boolean;
session: SessionContainerInterface;
wereAccountsAlreadyLinked: boolean;
}
| {
status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_INFO_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
primaryUserId: string;
description: string;
}
| {
status: "ACCOUNT_LINKING_NOT_ALLOWED_ERROR";
description: string;
}
| GeneralErrorResponse
>);
};

export type TypeThirdPartyPasswordlessEmailDeliveryInput = TypePasswordlessEmailDeliveryInput;
Expand Down