-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into locale-update
- Loading branch information
Showing
68 changed files
with
790 additions
and
6,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
'@clerk/clerk-expo': minor | ||
--- | ||
|
||
Introduce `getClerkInstance()` to avoid importing the Clerk class from clerk-js manually. | ||
|
||
This enables developers to create and access a Clerk instance in their application outside of React. | ||
```tsx | ||
import { ClerkProvider, getClerkInstance } from "@clerk/expo" | ||
|
||
const clerkInstance = getClerkInstance({ publishableKey: 'xxxx' }) | ||
|
||
// Always pass the `publishableKey` to `ClerkProvider` | ||
<ClerkProvider publishableKey={'xxxx'}> | ||
... | ||
</ClerkProvider> | ||
|
||
// Somewhere in your code, outside of React you can do | ||
const token = await clerkInstance.session?.getToken(); | ||
fetch('http://example.com/', {headers: {Authorization: token }) | ||
``` | ||
```tsx | ||
import { ClerkProvider, getClerkInstance } from "@clerk/expo" | ||
|
||
// Always pass the `publishableKey` to `ClerkProvider` | ||
<ClerkProvider publishableKey={'xxxx'}> | ||
... | ||
</ClerkProvider> | ||
|
||
// If you sure that this code will run after the ClerkProvider has rendered then you can use `getClerkIntance` without options | ||
const token = await getClerkInstance().session?.getToken(); | ||
fetch('http://example.com/', {headers: {Authorization: token }) | ||
|
||
``` | ||
Attention: If `getClerkInstance` is called without a publishable key, and ClerkProvider has not rendered yet, an error will be thrown | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@clerk/shared": patch | ||
--- | ||
|
||
Update `js-cookie` from `3.0.1` to `3.0.5`. Update `swr` from `2.2.0` to `2.2.5`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-react': patch | ||
--- | ||
|
||
Update `SignUpButton` and `SignInButton` to respect `forceRedirect` and `fallbackRedirect` props. Previously, these were getting ignored and successful completions of the flows would fallback to the default redirect URL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
--- | ||
|
||
Fixed a bug where Clerk components rendered in modals were wrapped with `aria-hidden`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
integration/templates/next-app-router/src/app/buttons/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SignInButton, SignUpButton } from '@clerk/nextjs'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<SignInButton | ||
mode='modal' | ||
forceRedirectUrl='/protected' | ||
> | ||
Sign in button (force) | ||
</SignInButton> | ||
|
||
<SignInButton | ||
mode='modal' | ||
fallbackRedirectUrl='/protected' | ||
> | ||
Sign in button (fallback) | ||
</SignInButton> | ||
|
||
<SignUpButton | ||
mode='modal' | ||
forceRedirectUrl='/protected' | ||
> | ||
Sign up button (force) | ||
</SignUpButton> | ||
|
||
<SignUpButton | ||
mode='modal' | ||
fallbackRedirectUrl='/protected' | ||
> | ||
Sign up button (fallback) | ||
</SignUpButton> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { test } from '@playwright/test'; | ||
|
||
import { appConfigs } from '../presets'; | ||
import type { FakeUser } from '../testUtils'; | ||
import { createTestUtils, testAgainstRunningApps } from '../testUtils'; | ||
|
||
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('redirect props @nextjs', ({ app }) => { | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
let fakeUser: FakeUser; | ||
|
||
test.beforeAll(async () => { | ||
const u = createTestUtils({ app }); | ||
fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
await u.services.users.createBapiUser(fakeUser); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await fakeUser.deleteIfExists(); | ||
await app.teardown(); | ||
}); | ||
|
||
test.afterEach(async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
await u.page.signOut(); | ||
await u.page.context().clearCookies(); | ||
}); | ||
|
||
test.describe('SignInButton', () => { | ||
test('sign in button respects forceRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
await u.po.expect.toBeSignedOut(); | ||
|
||
await u.page.getByText('Sign in button (force)').click(); | ||
|
||
await u.po.signIn.waitForMounted(); | ||
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
await u.po.expect.toBeSignedIn(); | ||
}); | ||
|
||
test('sign in button respects fallbackRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
await u.po.expect.toBeSignedOut(); | ||
|
||
await u.page.getByText('Sign in button (fallback)').click(); | ||
|
||
await u.po.signIn.waitForMounted(); | ||
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
await u.po.expect.toBeSignedIn(); | ||
}); | ||
}); | ||
|
||
test.describe('SignUpButton', () => { | ||
test('sign up button respects forceRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
const fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
|
||
await u.page.getByText('Sign up button (force)').click(); | ||
|
||
// Fill in sign up form | ||
await u.po.signUp.signUpWithEmailAndPassword({ | ||
email: fakeUser.email, | ||
password: fakeUser.password, | ||
}); | ||
|
||
// Verify email | ||
await u.po.signUp.enterTestOtpCode(); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
// Check if user is signed in | ||
await u.po.expect.toBeSignedIn(); | ||
|
||
await fakeUser.deleteIfExists(); | ||
}); | ||
|
||
test('sign up button respects fallbackRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
const fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
|
||
await u.page.getByText('Sign up button (fallback)').click(); | ||
|
||
// Fill in sign up form | ||
await u.po.signUp.signUpWithEmailAndPassword({ | ||
email: fakeUser.email, | ||
password: fakeUser.password, | ||
}); | ||
|
||
// Verify email | ||
await u.po.signUp.enterTestOtpCode(); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
// Check if user is signed in | ||
await u.po.expect.toBeSignedIn(); | ||
|
||
await fakeUser.deleteIfExists(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.