Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into CORE-2086/suffixed-cookies-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdouvlis committed Jul 3, 2024
2 parents 02c6f00 + 81bd03b commit b6a8f19
Show file tree
Hide file tree
Showing 25 changed files with 167 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@types/node": "^20.12.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"next": "14.1.1",
"next": "14.2.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.4.5"
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/chrome-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 1.1.2

### Patch Changes

- Ensure client cookie URLs resolve appropriately ([#3658](https://github.com/clerk/javascript/pull/3658)) by [@tmilewski](https://github.com/tmilewski)

- Updated dependencies [[`427fcdeaa`](https://github.com/clerk/javascript/commit/427fcdeaaba4e77273be29b4d7cca43f9aa18693)]:
- @clerk/[email protected]

## 1.1.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/chrome-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clerk/chrome-extension",
"version": "1.1.1",
"version": "1.1.2",
"description": "Clerk SDK for Chrome extensions",
"keywords": [
"auth",
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@clerk/clerk-js": "5.8.0",
"@clerk/clerk-react": "5.2.6",
"@clerk/clerk-react": "5.2.7",
"@clerk/shared": "2.3.2",
"webextension-polyfill": "^0.10.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome-extension/src/singleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function buildClerk({
// Set up cookie params based on environment
const getClientCookieParams: GetClientCookieParams = isProd
? {
urls: key.frontendApi,
urls: `https://${key.frontendApi}`,
name: CLIENT_JWT_KEY,
}
: {
Expand Down
13 changes: 11 additions & 2 deletions packages/chrome-extension/src/utils/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ export type GetClientCookieParams = {
name: string;
};

function isSingleHost(urls: string | string[]): urls is string {
return typeof urls === 'string';
}

function ensureFormattedUrl(url: string): string {
return url.startsWith('http') ? url : `https://${url}`;
}

export async function getClientCookie({ urls, name }: GetClientCookieParams) {
// Handle single host request
if (typeof urls === 'string') {
return browser.cookies.get({ url: urls, name });
if (isSingleHost(urls)) {
const url = ensureFormattedUrl(urls);
return await browser.cookies.get({ url, name });
}

// Handle multi-host request
Expand Down
2 changes: 2 additions & 0 deletions packages/elements/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @clerk/elements

## 0.10.1

## 0.10.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clerk/elements",
"version": "0.10.0",
"version": "0.10.1",
"description": "Clerk Elements",
"keywords": [
"clerk",
Expand Down Expand Up @@ -78,7 +78,7 @@
"xstate": "^5.13.0"
},
"devDependencies": {
"@clerk/clerk-react": "5.2.6",
"@clerk/clerk-react": "5.2.7",
"@clerk/eslint-config-custom": "*",
"@clerk/shared": "2.3.2",
"@statelyai/inspect": "^0.3.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/expo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 1.2.5

### Patch Changes

- Updated dependencies [[`427fcdeaa`](https://github.com/clerk/javascript/commit/427fcdeaaba4e77273be29b4d7cca43f9aa18693)]:
- @clerk/clerk-react@5.2.7

## 1.2.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/expo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clerk/clerk-expo",
"version": "1.2.4",
"version": "1.2.5",
"description": "Clerk React Native/Expo library",
"keywords": [
"react",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@clerk/clerk-js": "5.8.0",
"@clerk/clerk-react": "5.2.6",
"@clerk/clerk-react": "5.2.7",
"@clerk/shared": "2.3.2",
"@clerk/types": "4.7.0",
"base-64": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-clerk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@clerk/backend": "1.3.0",
"@clerk/clerk-react": "5.2.6",
"@clerk/clerk-react": "5.2.7",
"@clerk/clerk-sdk-node": "5.0.14",
"@clerk/types": "4.7.0",
"cookie": "0.5.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 5.2.1

### Patch Changes

- Updated dependencies [[`427fcdeaa`](https://github.com/clerk/javascript/commit/427fcdeaaba4e77273be29b4d7cca43f9aa18693)]:
- @clerk/clerk-react@5.2.7

## 5.2.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clerk/nextjs",
"version": "5.2.0",
"version": "5.2.1",
"description": "Clerk SDK for NextJS",
"keywords": [
"clerk",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"dependencies": {
"@clerk/backend": "1.3.0",
"@clerk/clerk-react": "5.2.6",
"@clerk/clerk-react": "5.2.7",
"@clerk/shared": "2.3.2",
"@clerk/types": "4.7.0",
"crypto-js": "4.2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 5.2.7

### Patch Changes

- Fix race condition on updating ClerkProvider props before ClerkJS has loaded ([#3655](https://github.com/clerk/javascript/pull/3655)) by [@anagstef](https://github.com/anagstef)

## 5.2.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clerk/clerk-react",
"version": "5.2.6",
"version": "5.2.7",
"description": "Clerk React library",
"keywords": [
"clerk",
Expand Down
52 changes: 52 additions & 0 deletions packages/react/src/__tests__/isomorphicClerk.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { IsomorphicClerk } from '../isomorphicClerk';

describe('isomorphicClerk', () => {
beforeAll(() => {
jest.useFakeTimers();
});

afterAll(() => {
jest.useRealTimers();
});

it('instantiates a IsomorphicClerk instance', () => {
expect(() => {
new IsomorphicClerk({ publishableKey: 'pk_test_XXX' });
}).not.toThrow();
});

it('updates props asynchronously after clerkjs has loaded', async () => {
const propsHistory: any[] = [];
const dummyClerkJS = {
__unstable__updateProps: (props: any) => propsHistory.push(props),
};

const isomorphicClerk = new IsomorphicClerk({ publishableKey: 'pk_test_XXX' });
(isomorphicClerk as any).clerkjs = dummyClerkJS as any;

void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'dark' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'light' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'purple' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'yellow' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'red' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'blue' } });
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'green' } });
expect(propsHistory).toEqual([]);

jest.spyOn(isomorphicClerk, 'loaded', 'get').mockReturnValue(true);
isomorphicClerk.emitLoaded();
void isomorphicClerk.__unstable__updateProps({ appearance: { baseTheme: 'white' } });
await jest.runAllTimersAsync();

expect(propsHistory).toEqual([
{ appearance: { baseTheme: 'dark' } },
{ appearance: { baseTheme: 'light' } },
{ appearance: { baseTheme: 'purple' } },
{ appearance: { baseTheme: 'yellow' } },
{ appearance: { baseTheme: 'red' } },
{ appearance: { baseTheme: 'blue' } },
{ appearance: { baseTheme: 'green' } },
{ appearance: { baseTheme: 'white' } },
]);
});
});
4 changes: 2 additions & 2 deletions packages/react/src/contexts/ClerkContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ const useLoadedIsomorphicClerk = (options: IsomorphicClerkOptions) => {
const isomorphicClerk = React.useMemo(() => IsomorphicClerk.getOrCreateInstance(options), []);

React.useEffect(() => {
isomorphicClerk.__unstable__updateProps({ appearance: options.appearance });
void isomorphicClerk.__unstable__updateProps({ appearance: options.appearance });
}, [options.appearance]);

React.useEffect(() => {
isomorphicClerk.__unstable__updateProps({ options });
void isomorphicClerk.__unstable__updateProps({ options });
}, [options.localization]);

React.useEffect(() => {
Expand Down
Loading

0 comments on commit b6a8f19

Please sign in to comment.