diff --git a/README.md b/README.md index 16ab42f..ece4c32 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ takes the following props: - `onRedirectCallback`: Called after exchanging the `authorization_code`. Can be used for things like redirecting to a "return to" path in the OAuth state. +- `onRefreshFailure`: Called when the session fails to refresh. Can be used to redirect the user to the sign in page or update the UI. ### `useAuth` diff --git a/package-lock.json b/package-lock.json index d085f3b..13d36fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.7.1", "license": "MIT", "dependencies": { - "@workos-inc/authkit-js": "0.7.1" + "@workos-inc/authkit-js": "0.7.2" }, "devDependencies": { "@types/react": "18.3.3", @@ -794,9 +794,9 @@ } }, "node_modules/@workos-inc/authkit-js": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@workos-inc/authkit-js/-/authkit-js-0.7.1.tgz", - "integrity": "sha512-tI3ubreO0Q72sgzOkH61fFTitJqiRH3nrZpao3BPZlI4FoQFBUVrsnk16N0DZVK+mR+ldzkjNWaxjLKJlC6hjQ==" + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@workos-inc/authkit-js/-/authkit-js-0.7.2.tgz", + "integrity": "sha512-3ACI2EdGrAxrq/M+SKj/XzjtuvWXzNGEKiUUv4cwdijwR4e1CdRDQPJhAw7RQJwYe2cDH2L+EfK6biIfY+UT8Q==" }, "node_modules/acorn": { "version": "8.12.1", diff --git a/package.json b/package.json index b77a673..20ff60f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "react": ">=17" }, "dependencies": { - "@workos-inc/authkit-js": "0.7.1" + "@workos-inc/authkit-js": "0.7.2" } } diff --git a/src/provider.tsx b/src/provider.tsx index 66cf5c1..509dd72 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -11,6 +11,9 @@ import { Context } from "./context"; import { Client, CreateClientOptions } from "./types"; import { initialState } from "./state"; +// TODO: delete this after authkit-js exports it +type onRefreshResponse = Omit; + interface AuthKitProviderProps extends CreateClientOptions { clientId: string; children: React.ReactNode; @@ -34,7 +37,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) { const [state, setState] = React.useState(initialState); const handleRefresh = React.useCallback( - (response: AuthenticationResponse) => { + (response: onRefreshResponse) => { const { user, accessToken, organizationId } = response; const { role = null, permissions = [] } = getClaims(accessToken); setState((prev) => {