Skip to content

Commit

Permalink
Merge pull request #76 from FusionAuth/react--v2.1.0
Browse files Browse the repository at this point in the history
React SDK v2.1.0
  • Loading branch information
JakeLo123 authored Apr 29, 2024
2 parents f346c41 + 876cd79 commit d9b6074
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 27 deletions.
4 changes: 4 additions & 0 deletions packages/sdk-react/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
fusionauth-react-sdk Changes

Changes in 2.1.0

- `scope` has been added back to the `FusionAuthProviderConfig` to be more compatible with [FusionAuth v1.50](https://fusionauth.io/docs/release-notes/#version-1-50-0)

Changes in 2.0.0

Breaking changes were made to provide new configuration options. These options include enabling automatic SDK functionality vs writing your own implementation via methods exposed by the `useFusionAuth` hook. These changes are also aimed at using more consistent verbiage within the SDK documentation.
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Doing this will overwrite your file, but fix prettier's objections.
## Releases
To perform a release to NPM, create a release on GitHub. That will automatically publish a release to GitHub.
This package is released via GitHub actions.
## Upgrade Policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Config for FusionAuthProvider
- [onRedirect](FusionAuthProviderConfig.FusionAuthProviderConfig.md#onredirect)
- [redirectUri](FusionAuthProviderConfig.FusionAuthProviderConfig.md#redirecturi)
- [registerPath](FusionAuthProviderConfig.FusionAuthProviderConfig.md#registerpath)
- [scope](FusionAuthProviderConfig.FusionAuthProviderConfig.md#scope)
- [serverUrl](FusionAuthProviderConfig.FusionAuthProviderConfig.md#serverurl)
- [shouldAutoFetchUserInfo](FusionAuthProviderConfig.FusionAuthProviderConfig.md#shouldautofetchuserinfo)
- [shouldAutoRefresh](FusionAuthProviderConfig.FusionAuthProviderConfig.md#shouldautorefresh)
Expand All @@ -35,7 +36,7 @@ Only set this if you are hosting server that uses a custom name for the 'app.at_

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:69](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L69)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:74](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L74)

---

Expand All @@ -47,7 +48,7 @@ The number of seconds before the access token expiry when the auto refresh funct

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:33](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L33)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:38](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L38)

---

Expand All @@ -59,7 +60,7 @@ The client id of the application.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L13)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L13)

---

Expand All @@ -71,7 +72,7 @@ The path to the login endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:43](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L43)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:48](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L48)

---

Expand All @@ -83,7 +84,7 @@ The path to the logout endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:53](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L53)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:58](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L58)

---

Expand All @@ -95,7 +96,7 @@ The path to the me endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:63](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L63)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:68](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L68)

---

Expand All @@ -121,7 +122,7 @@ Callback function to be invoked with the `state` value upon redirect from login

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:38](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L38)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:43](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L43)

---

Expand All @@ -133,7 +134,7 @@ The redirect URI of the application.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:18](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L18)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:18](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L18)

---

Expand All @@ -145,7 +146,19 @@ The path to the register endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:48](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L48)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:53](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L53)

---

### scope

**scope**: `string`

The OAuth2 scope parameter passed to the `/oauth2/authorize` endpoint. If not specified fusionauth will default this to `openid offline_access`.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:23](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L23)

---

Expand All @@ -157,7 +170,7 @@ The URL of the server that performs the token exchange.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L8)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L8)

---

Expand All @@ -169,7 +182,7 @@ Enables the SDK to automatically handle fetching user info when logged in. Defau

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:28](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L28)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:33](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L33)

---

Expand All @@ -181,7 +194,7 @@ Enables automatic token refreshing. Defaults to false.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:23](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L23)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:28](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L28)

---

Expand All @@ -193,4 +206,4 @@ The path to the token refresh endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:58](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L58)
[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:63](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L63)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Error occurred while fetching userInfo.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:30](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L30)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:30](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L30)

---

Expand All @@ -52,7 +52,7 @@ This is handled automatically if the SDK is configured with `shouldAutoFetchUser

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:20](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L20)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:20](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L20)

---

Expand All @@ -73,7 +73,7 @@ This is handled automatically if the SDK is configured with `shouldAutoRefresh`.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:59](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L59)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:59](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L59)

---

Expand All @@ -85,7 +85,7 @@ Indicates that the fetchUserInfo call is unresolved.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:25](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L25)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:25](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L25)

---

Expand All @@ -97,7 +97,7 @@ Whether the user is logged in.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L8)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L8)

---

Expand All @@ -118,7 +118,7 @@ This is handled automatically if the SDK is configured with `shouldAutoRefresh`.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:53](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L53)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:53](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L53)

---

Expand All @@ -144,7 +144,7 @@ Initiates login flow.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:36](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L36)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:36](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L36)

---

Expand All @@ -164,7 +164,7 @@ Initiates logout flow.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:47](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L47)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:47](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L47)

---

Expand All @@ -190,7 +190,7 @@ Initiates register flow.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:42](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L42)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:42](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L42)

---

Expand All @@ -202,4 +202,4 @@ Data fetched from the configured 'me' endpoint.

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L13)
[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L13)
4 changes: 2 additions & 2 deletions packages/sdk-react/docs/modules/FusionAuthProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:9](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L9)
[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:9](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L9)

---

Expand All @@ -44,4 +44,4 @@ A hook that returns `FusionAuthProviderContext`

#### Defined in

[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:64](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/70d5b677cad1a2b11d090d5c6c3e06a3a491f098/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L64)
[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:64](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6f1de893735ee6b106ed805dd8ba2011e08e1cfc/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L64)
2 changes: 1 addition & 1 deletion packages/sdk-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fusionauth/react-sdk",
"version": "2.0.0",
"version": "2.1.0",
"private": false,
"description": "FusionAuth solves the problem of building essential security without adding risk or distracting from your primary application",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('FusionAuthProvider', () => {
expectedUrl.pathname = '/app/login';
expectedUrl.searchParams.set('client_id', TEST_CONFIG.clientId);
expectedUrl.searchParams.set('redirect_uri', TEST_CONFIG.redirectUri);
expectedUrl.searchParams.set('scope', TEST_CONFIG.scope!);
expectedUrl.searchParams.set('state', stateValue);

expect(mockedLocation.assign).toHaveBeenCalledWith(expectedUrl);
Expand Down Expand Up @@ -78,6 +79,10 @@ describe('FusionAuthProvider', () => {
expectedUrl.pathname = '/app/register';
expectedUrl.searchParams.set('client_id', TEST_CONFIG.clientId);
expectedUrl.searchParams.set('redirect_uri', TEST_CONFIG.redirectUri);
expectedUrl.searchParams.set(
'scope',
'openid email profile offline_access',
);
expectedUrl.searchParams.set('state', stateValue);

expect(localStorage.getItem('fa-sdk-redirect-value')).toContain(stateValue); // this asserts that `state` was echoed back.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export interface FusionAuthProviderConfig {
*/
redirectUri: string;

/**
* The OAuth2 scope parameter passed to the `/oauth2/authorize` endpoint. If not specified fusionauth will default this to `openid offline_access`.
*/
scope?: string;

/**
* Enables automatic token refreshing. Defaults to false.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-react/src/testing-tools/mocks/testConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const TEST_CONFIG: FusionAuthProviderConfig = {
clientId: '85a03867-dccf-4882-adde-1a79aeec50df',
serverUrl: 'http://localhost:9000',
redirectUri: 'http://localhost',
scope: 'openid email profile offline_access',
};

0 comments on commit d9b6074

Please sign in to comment.