Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

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

Closed

Description

@aloisklink

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

Activity

  1. added
    bug
    on Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions