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

@aloisklink

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/auth-js@0.0.0 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions