Skip to content

Commit

Permalink
test fixes, mising tests and build code
Browse files Browse the repository at this point in the history
  • Loading branch information
niftyvictor committed Feb 14, 2025
1 parent 0311240 commit d79d6cb
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 331 deletions.
13 changes: 0 additions & 13 deletions lib/build/recipe/webauthn/api/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils");
const utils_2 = require("./utils");
const error_1 = __importDefault(require("../error"));
const authUtils_1 = require("../../../authUtils");
async function signUpAPI(apiImplementation, tenantId, options, userContext) {
if (apiImplementation.signUpPOST === undefined) {
Expand Down Expand Up @@ -59,13 +53,6 @@ async function signUpAPI(apiImplementation, tenantId, options, userContext) {
options.res,
Object.assign({ status: "OK" }, utils_1.getBackwardsCompatibleUserInfo(options.req, result, userContext))
);
} else if (result.status === "GENERAL_ERROR") {
utils_1.send200Response(options.res, result);
} else if (result.status === "EMAIL_ALREADY_EXISTS_ERROR") {
throw new error_1.default({
type: error_1.default.BAD_INPUT_ERROR,
message: "This email already exists. Please sign in instead.",
});
} else {
utils_1.send200Response(options.res, result);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/build/recipe/webauthn/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ export default class Wrapper {
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
status: "INVALID_CREDENTIALS_ERROR";
}
| {
status: "OPTIONS_NOT_FOUND_ERROR";
}
| {
status: "INVALID_OPTIONS_ERROR";
}
| {
status: "INVALID_CREDENTIALS_ERROR";
}
| {
status: "INVALID_AUTHENTICATOR_ERROR";
reason: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/build/recipe/webauthn/recipeImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ function getRecipeInterface(querier, getWebauthnConfig) {
new normalisedURLPath_1.default(
`/${
tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId
}/recipe/webauthn/options/${webauthnGeneratedOptionsId}`
}/recipe/webauthn/options/remove`
),
{},
{},
{ webauthnGeneratedOptionsId },
userContext
);
},
Expand Down
6 changes: 3 additions & 3 deletions lib/build/recipe/webauthn/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ declare type CreateNewRecipeUserErrorResponse =
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
status: "INVALID_CREDENTIALS_ERROR";
}
| {
status: "OPTIONS_NOT_FOUND_ERROR";
}
| {
status: "INVALID_OPTIONS_ERROR";
}
| {
status: "INVALID_CREDENTIALS_ERROR";
}
| {
status: "INVALID_AUTHENTICATOR_ERROR";
reason: string;
Expand Down
1 change: 0 additions & 1 deletion lib/ts/recipe/webauthn/api/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
} from "../../../utils";
import { validateWebauthnGeneratedOptionsIdOrThrowError, validateCredentialOrThrowError } from "./utils";
import { APIInterface, APIOptions } from "..";
import STError from "../error";
import { UserContext } from "../../../types";
import { AuthUtils } from "../../../authUtils";

Expand Down
6 changes: 2 additions & 4 deletions lib/ts/recipe/webauthn/recipeImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,10 @@ export default function getRecipeInterface(
removeGeneratedOptions: async function ({ webauthnGeneratedOptionsId, tenantId, userContext }) {
return await querier.sendDeleteRequest(
new NormalisedURLPath(
`/${
tenantId === undefined ? DEFAULT_TENANT_ID : tenantId
}/recipe/webauthn/options/${webauthnGeneratedOptionsId}`
`/${tenantId === undefined ? DEFAULT_TENANT_ID : tenantId}/recipe/webauthn/options/remove`
),
{},
{},
{ webauthnGeneratedOptionsId },
userContext
);
},
Expand Down
26 changes: 13 additions & 13 deletions lib/ts/recipe/webauthn/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,35 @@ type VerifyCredentialsErrorResponse =
type SignInErrorResponse =
| VerifyCredentialsErrorResponse
| {
status: "LINKING_TO_SESSION_USER_FAILED";
status: "LINKING_TO_SESSION_USER_FAILED"; // test no
reason:
| "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
};

type GenerateRecoverAccountTokenErrorResponse = { status: "UNKNOWN_USER_ID_ERROR" };
type GenerateRecoverAccountTokenErrorResponse = { status: "UNKNOWN_USER_ID_ERROR" }; // test yes

type ConsumeRecoverAccountTokenErrorResponse = { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" };
type ConsumeRecoverAccountTokenErrorResponse = { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" }; // test yes

type RegisterCredentialErrorResponse =
| { status: "INVALID_CREDENTIALS_ERROR" }
| { status: "OPTIONS_NOT_FOUND_ERROR" }
| { status: "INVALID_OPTIONS_ERROR" }
| { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string };
| { status: "INVALID_CREDENTIALS_ERROR" } // test yes
| { status: "OPTIONS_NOT_FOUND_ERROR" } // test yes
| { status: "INVALID_OPTIONS_ERROR" } // test yes
| { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string }; // test yes - only if cred is for other rpId

type GetUserFromRecoverAccountTokenErrorResponse = { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" };
type GetUserFromRecoverAccountTokenErrorResponse = { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" }; // test yes

type RemoveCredentialErrorResponse = { status: "CREDENTIAL_NOT_FOUND_ERROR" };
type RemoveCredentialErrorResponse = { status: "CREDENTIAL_NOT_FOUND_ERROR" }; // test yes

type GetCredentialErrorResponse = { status: "CREDENTIAL_NOT_FOUND_ERROR" };
type GetCredentialErrorResponse = { status: "CREDENTIAL_NOT_FOUND_ERROR" }; // test yes

type RemoveGeneratedOptionsErrorResponse = { status: "OPTIONS_NOT_FOUND_ERROR" };
type RemoveGeneratedOptionsErrorResponse = { status: "OPTIONS_NOT_FOUND_ERROR" }; // test yes

type GetGeneratedOptionsErrorResponse = { status: "OPTIONS_NOT_FOUND_ERROR" };
type GetGeneratedOptionsErrorResponse = { status: "OPTIONS_NOT_FOUND_ERROR" }; // test yes

type UpdateUserEmailErrorResponse = { status: "EMAIL_ALREADY_EXISTS_ERROR" } | { status: "UNKNOWN_USER_ID_ERROR" };
type UpdateUserEmailErrorResponse = { status: "EMAIL_ALREADY_EXISTS_ERROR" } | { status: "UNKNOWN_USER_ID_ERROR" }; // test yes

type Base64URLString = string;

Expand Down
2 changes: 1 addition & 1 deletion test/webauthn/apis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function
}
})
);
assert.equal(recoverAccountResponse.status, "INVALID_OPTIONS_ERROR");
assert.equal(recoverAccountResponse.status, "INVALID_AUTHENTICATOR_ERROR");
});
});
});
Loading

0 comments on commit d79d6cb

Please sign in to comment.