-
Notifications
You must be signed in to change notification settings - Fork 656
feat(auth): auth.resend() consistent confirmation flow #2144
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
f976688
3684e8a
2606650
1bc0eda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -605,6 +605,16 @@ describe('GoTrueClient', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(error).toBeNull() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('resend with email and PKCE flowType', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { email } = mockUserCredentials() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { error } = await pkceClient.resend({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| email, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'signup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options: { emailRedirectTo: 'http://localhost:9999/welcome' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(error).toBeNull() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { error } = await pkceClient.resend({ | |
| email, | |
| type: 'signup', | |
| options: { emailRedirectTo: 'http://localhost:9999/welcome' }, | |
| }) | |
| expect(error).toBeNull() | |
| const fetchSpy = jest | |
| .spyOn(globalThis as any, 'fetch') | |
| .mockImplementation(async (_input: any, init?: any) => { | |
| if (init && typeof init.body === 'string') { | |
| const body = JSON.parse(init.body) | |
| expect(body.code_challenge).toEqual(expect.any(String)) | |
| expect(body.code_challenge_method).toBe('S256') | |
| } | |
| return Promise.resolve({ | |
| ok: true, | |
| status: 200, | |
| json: async () => ({}), | |
| }) as any | |
| }) | |
| try { | |
| const { error } = await pkceClient.resend({ | |
| email, | |
| type: 'signup', | |
| options: { emailRedirectTo: 'http://localhost:9999/welcome' }, | |
| }) | |
| expect(error).toBeNull() | |
| const storedCodeVerifier = await memoryLocalStorageAdapter.getItem( | |
| `${STORAGE_KEY}-code-verifier` | |
| ) | |
| expect(storedCodeVerifier).toEqual(expect.any(String)) | |
| } finally { | |
| fetchSpy.mockRestore() | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the non-PKCE case,
code_challenge/code_challenge_methodare still being included in the/resendrequest body as explicitnullvalues. This changes the payload compared to prior versions and can trigger backend validation differences vs omitting the fields entirely. Consider only adding these properties to the body whenthis.flowType === 'pkce'(e.g., via a conditional object spread) so implicit-flow resend requests remain unchanged.