diff --git a/packages/react-auth/CHANGELOG.md b/packages/react-auth/CHANGELOG.md index 39c3ed500..6e3b0ce40 100644 --- a/packages/react-auth/CHANGELOG.md +++ b/packages/react-auth/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.0.21 - 2025-11-25 + +### Changed + +- Support onRedirectCallback parameter + +## 0.0.20 - 2025-11-19 + +### Changed + +- Upgraded @pangeacyber/vanilla-js auth client version + ## 0.0.19 - 2025-11-19 ### Changed diff --git a/packages/react-auth/package.json b/packages/react-auth/package.json index 43ddfa6eb..40c07fced 100644 --- a/packages/react-auth/package.json +++ b/packages/react-auth/package.json @@ -1,7 +1,7 @@ { "name": "@pangeacyber/react-auth", "description": "Pangea auth provider React component", - "version": "0.0.19", + "version": "0.0.21", "type": "commonjs", "source": "src/index.ts", "main": "dist/index.cjs", diff --git a/packages/react-auth/src/AuthProvider/index.tsx b/packages/react-auth/src/AuthProvider/index.tsx index 88556b771..6b45699c9 100644 --- a/packages/react-auth/src/AuthProvider/index.tsx +++ b/packages/react-auth/src/AuthProvider/index.tsx @@ -81,6 +81,12 @@ export interface AuthProviderProps { */ redirectPathname?: string; + /** + * When passed in, AuthProvider will call this function when needing to redirect + * @example "/docs/"" + */ + onRedirectCallback?: (url: string) => void; + /** * When set to true users will be redirected to the hosted page on logout. * @@ -152,6 +158,7 @@ export const AuthProvider: FC = ({ cookieOptions = { useCookie: false }, redirectUri, redirectPathname, + onRedirectCallback, redirectOnLogout = false, useStrictStateCheck = true, passAuthMethod = false, @@ -378,7 +385,11 @@ export const AuthProvider: FC = ({ const redirectTo = loginURL; const url = queryParams ? `${redirectTo}?${queryParams}` : redirectTo; - window.location.replace(url); + if (onRedirectCallback) { + onRedirectCallback(url); + } else { + window.location.replace(url); + } }; const logout = useCallback(async () => { @@ -400,7 +411,11 @@ export const AuthProvider: FC = ({ const url = `${logoutURL}?${toUrlEncoded(query)}`; setLoggedOut(); - window.location.replace(url); + if (onRedirectCallback) { + onRedirectCallback(url); + } else { + window.location.replace(url); + } } // call the logout endpoint else { diff --git a/packages/vanilla-js/CHANGELOG.md b/packages/vanilla-js/CHANGELOG.md index 004b69d3a..b612c0c66 100644 --- a/packages/vanilla-js/CHANGELOG.md +++ b/packages/vanilla-js/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.1.16] - 2025-11-19 +## [0.1.17] - 2025-11-19 ### Added diff --git a/packages/vanilla-js/package.json b/packages/vanilla-js/package.json index 3194d1d05..46ecf3cd6 100644 --- a/packages/vanilla-js/package.json +++ b/packages/vanilla-js/package.json @@ -1,7 +1,7 @@ { "name": "@pangeacyber/vanilla-js", "description": "Generic javascript integrations with Pangea", - "version": "0.1.16", + "version": "0.1.17", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/index.d.ts", diff --git a/packages/vanilla-js/src/AuthNClient/index.ts b/packages/vanilla-js/src/AuthNClient/index.ts index 9c885b56f..c95a108e4 100644 --- a/packages/vanilla-js/src/AuthNClient/index.ts +++ b/packages/vanilla-js/src/AuthNClient/index.ts @@ -156,6 +156,10 @@ export class AuthNClient { } if (!!this.config.apiPathPrefix) { + if (this.config.apiPathPrefix.startsWith("http")) { + return `${this.config.apiPathPrefix}${version_}${endpoint}`; + } + return `${window.location.origin}${this.config.apiPathPrefix}${version_}${endpoint}`; }