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

mfa.enroll's return type has a TypeScript breaking change in v2.65.0 #955

Closed
2 tasks done
aloisklink opened this issue Sep 17, 2024 · 0 comments · Fixed by #956
Closed
2 tasks done

mfa.enroll's return type has a TypeScript breaking change in v2.65.0 #955

aloisklink opened this issue Sep 17, 2024 · 0 comments · Fixed by #956
Labels
bug Something isn't working

Comments

@aloisklink
Copy link
Contributor

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

As of v2.65.0 and b957c30, the mfa.enroll function's return-type has changed, so that the following code in the official TOTP docs now throws a TypeScript error:

https://github.com/supabase/supabase/blob/7f0a216c40dafdd14ae99b7a6efe4801e8306144/apps/docs/content/guides/auth/auth-mfa/totp.mdx?plain=1#L122-L133

To Reproduce

Add the following test to this repo:

diff --git a/test/GoTrueClient.test.ts b/test/GoTrueClient.test.ts
index 6378ae1..7d42651 100644
--- a/test/GoTrueClient.test.ts
+++ b/test/GoTrueClient.test.ts
@@ -904,6 +904,20 @@ describe('User management', () => {
   })
 })

+describe('MFA', () => {
+  test('enroll({factorType: "totp"}) returns totp', async () => {
+    const { data, error } = await authWithSession.mfa.enroll({
+      factorType: 'totp',
+    })
+
+    if (error) {
+      throw error
+    }
+
+    expect(data.totp.qr_code).not.toBeNull()
+  })
+})
+
 describe('GoTrueClient with storageisServer = true', () => {
   const originalWarn = console.warn
   let warnings: any[][] = []

Running the tests will then cause the following TypeScript error in v2.65.0, but not before v2.65.0:

> @supabase/[email protected] test:suite
> jest --runInBand

 FAIL  test/GoTrueClient.test.ts
  ● Test suite failed to run

    test/GoTrueClient.test.ts:917:17 - error TS2339: Property 'totp' does not exist on type '{ id: string; type: "totp"; totp: { qr_code: string; secret: string; uri: string; }; friendly_name?: string | undefined; } | { id: string; type: "phone"; friendly_name?: string | undefined; phone: string; }'.
      Property 'totp' does not exist on type '{ id: string; type: "phone"; friendly_name?: string | undefined; phone: string; }'.

    917     expect(data.totp.qr_code).not.toBeNull()

Expected behavior

Either:

Screenshots

N/A

System information

Additional context

N/A

@aloisklink aloisklink added the bug Something isn't working label Sep 17, 2024
@J0 J0 closed this as completed in #956 Sep 17, 2024
@J0 J0 closed this as completed in 8a1ec06 Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant