Skip to content

Commit 6452530

Browse files
feat: webauthn test flows (#883)
## Summary of change This PR adds e2e test flows for webauthn and accountlinking ## Related issues ## Test Plan All webauthn accountlinking tests should pass ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) ## Checklist for important updates - [ ] Changelog has been updated - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - In `package.json` - In `package-lock.json` - In `lib/ts/version.ts` - [x] Had run `npm run build-pretty` - [x] Had installed and ran the pre-commit hook - [x] Issue this PR against the latest non released version branch. - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - If no such branch exists, then create one from the latest released branch. - [ ] If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like `someFunc: function () {..}`). - [ ] If I added a new recipe, I also added the recipe entry point into the `size-limit` section of `package.json` with the size limit set to the current size rounded up. - [ ] If I added a new recipe, I also added the recipe entry point into the `rollup.config.mjs` - [ ] If I added a new login method, I modified the list in `lib/ts/types.ts` - [ ] If I added a factor id, I modified the list in `lib/ts/recipe/multifactorauth/types.ts`
1 parent 1fa2cb1 commit 6452530

File tree

13 files changed

+306
-49
lines changed

13 files changed

+306
-49
lines changed

.github/workflows/pre-commit-hook-run.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@ jobs:
1212
pr-title:
1313
name: Pre commit hook check
1414
runs-on: ubuntu-latest
15-
container: rishabhpoddar/supertokens_website_sdk_testing_node_16
1615
steps:
17-
- uses: actions/checkout@v2
18-
- run: git init && git add --all && git -c user.name='test' -c user.email='[email protected]' commit -m 'init for pr action'
19-
- run: npm i --force || true
20-
# the below command is there cause otherwise running npm run check-circular-dependencies gives an error like:
21-
# Your cache folder contains root-owned files, due to a bug in
22-
# npm ERR! previous versions of npm which has since been addressed.
23-
- run: chown -R 1001:121 "/github/home/.npm"
24-
- run: npm i --force
25-
- run: cd test/with-typescript && npm i --force
16+
- uses: actions/checkout@v4
17+
- run: npm ci
18+
- run: cd test/with-typescript && npm ci
2619
- run: ./hooks/pre-commit.sh

.github/workflows/test-examples.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
outputs:
77
matrix: ${{ steps.set-matrix.outputs.matrix }}
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1010
- run: bash test/findExamplesWithTests.sh
1111
- id: set-matrix
1212
run: echo "::set-output name=matrix::{\"include\":$(bash test/findExamplesWithTests.sh)}"
@@ -24,7 +24,7 @@ jobs:
2424
run:
2525
working-directory: ${{ matrix.examplePath }}
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
2828
- run: bash ../../test/updateExampleAppDeps.sh .
2929
- run: npm install [email protected] [email protected] puppeteer@^11.0.0 isomorphic-fetch@^3.0.0
3030
- run: npm run build || true
@@ -36,7 +36,7 @@ jobs:
3636
)
3737
- name: The job has failed
3838
if: ${{ failure() }}
39-
uses: actions/upload-artifact@v3
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: screenshots
4242
path: ./**/*screenshot.jpeg

.github/workflows/tests-pass-check-pr.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/with-account-linking/frontend/src/LinkingPage/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const LinkingPage: React.FC = () => {
5454
try {
5555
let response = await Passwordless.createCode({
5656
phoneNumber,
57+
shouldTryLinkingWithSessionUser: true,
5758
});
5859

5960
if (cancel) {

examples/with-multifactorauth-phone-chooser/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react-dom": "^18.2.0",
1616
"react-router-dom": "^6.2.1",
1717
"react-scripts": "5.0.1",
18-
"supertokens-auth-react": "github:supertokens/supertokens-auth-react#feat/mfa_redirect",
18+
"supertokens-auth-react": "github:supertokens/supertokens-auth-react",
1919
"supertokens-web-js": "latest",
2020
"typescript": "^4.8.2",
2121
"web-vitals": "^2.1.4"

examples/with-multifactorauth-phone-chooser/frontend/src/SelectPhone/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export default function SelectPhone() {
2323
navigate: nav,
2424
});
2525
} else if (loadedInfo.user.phoneNumbers.length === 1) {
26-
await Passwordless.createCode({ phoneNumber: loadedInfo.user.phoneNumbers[0] });
26+
await Passwordless.createCode({
27+
phoneNumber: loadedInfo.user.phoneNumbers[0],
28+
shouldTryLinkingWithSessionUser: true,
29+
});
2730
await MultiFactorAuth.redirectToFactor({
2831
factorId: MultiFactorAuth.FactorIds.OTP_PHONE,
2932
redirectBack: false,
@@ -60,7 +63,7 @@ export default function SelectPhone() {
6063
<li
6164
className="phoneNumberCard"
6265
onClick={() => {
63-
Passwordless.createCode({ phoneNumber: number })
66+
Passwordless.createCode({ phoneNumber: number, shouldTryLinkingWithSessionUser: true })
6467
.then(async (info) => {
6568
if (info.status !== "OK") {
6669
setError(info.reason);
@@ -72,6 +75,7 @@ export default function SelectPhone() {
7275
contactMethod: "PHONE",
7376
contactInfo: number,
7477
hasOtherPhoneNumbers: true,
78+
shouldTryLinkingWithSessionUser: true,
7579
},
7680
});
7781
return MultiFactorAuth.redirectToFactor({

examples/with-multiple-email-sign-in/api-server/epOverride.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function epOverride(oI: APIInterface): APIInterface {
77
signInPOST: async function (input) {
88
const emailField = input.formFields.find((f) => f.id === "email")!;
99

10-
let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value);
10+
let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value as string);
1111
if (primaryEmail !== undefined) {
1212
emailField.value = primaryEmail;
1313
}
@@ -16,7 +16,7 @@ export function epOverride(oI: APIInterface): APIInterface {
1616
signUpPOST: async function (input) {
1717
const emailField = input.formFields.find((f) => f.id === "email")!;
1818

19-
let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value);
19+
let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value as string);
2020
if (primaryEmail !== undefined) {
2121
emailField.value = primaryEmail;
2222
}

examples/with-phone-password-mfa/api-server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ supertokens.init({
7777
// We format the phone number here to get it to a standard format
7878
const emailField = input.formFields.find((field) => field.id === "email");
7979
if (emailField) {
80-
const phoneNumber = parsePhoneNumber(emailField.value);
80+
const phoneNumber = parsePhoneNumber(emailField.value as string);
8181
if (phoneNumber !== undefined && phoneNumber.isValid()) {
8282
emailField.value = phoneNumber.number;
8383
}
@@ -93,7 +93,7 @@ supertokens.init({
9393
// We format the phone number here to get it to a standard format
9494
const emailField = input.formFields.find((field) => field.id === "email");
9595
if (emailField) {
96-
const phoneNumber = parsePhoneNumber(emailField.value);
96+
const phoneNumber = parsePhoneNumber(emailField.value as string);
9797
if (phoneNumber !== undefined && phoneNumber.isValid()) {
9898
emailField.value = phoneNumber.number;
9999
}

examples/with-phone-password/api-server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ supertokens.init({
7575
// We format the phone number here to get it to a standard format
7676
const emailField = input.formFields.find((field) => field.id === "email");
7777
if (emailField) {
78-
const phoneNumber = parsePhoneNumber(emailField.value);
78+
const phoneNumber = parsePhoneNumber(emailField.value as string);
7979
if (phoneNumber !== undefined && phoneNumber.isValid()) {
8080
emailField.value = phoneNumber.number;
8181
}
@@ -91,7 +91,7 @@ supertokens.init({
9191
// We format the phone number here to get it to a standard format
9292
const emailField = input.formFields.find((field) => field.id === "email");
9393
if (emailField) {
94-
const phoneNumber = parsePhoneNumber(emailField.value);
94+
const phoneNumber = parsePhoneNumber(emailField.value as string);
9595
if (phoneNumber !== undefined && phoneNumber.isValid()) {
9696
emailField.value = phoneNumber.number;
9797
}

examples/with-svelte-react-thirdpartyemailpassword/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
"sirv-cli": "^2.0.0",
4444
"supertokens-auth-react": "latest",
4545
"supertokens-node": "latest",
46-
"svelte-navigator": "^3.1.5"
46+
"svelte-navigator": "latest"
4747
}
4848
}

0 commit comments

Comments
 (0)