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 e669f8e55..7a2b54516 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", @@ -39,7 +39,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@pangeacyber/vanilla-js": "0.1.16", + "@pangeacyber/vanilla-js": "0.1.17", "jose": "^6.1.0", "lodash": "^4.17.21" }, 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/react-auth/yarn.lock b/packages/react-auth/yarn.lock index dd5858e93..2ffe766cf 100644 --- a/packages/react-auth/yarn.lock +++ b/packages/react-auth/yarn.lock @@ -472,7 +472,7 @@ __metadata: "@arethetypeswrong/cli": "npm:^0.18.2" "@babel/core": "npm:^7.28.5" "@futureportal/parcel-transformer-package-version": "npm:^1.0.0" - "@pangeacyber/vanilla-js": "npm:0.1.16" + "@pangeacyber/vanilla-js": "npm:0.1.17" "@parcel/config-default": "npm:^2.16.1" "@parcel/packager-ts": "npm:^2.16.1" "@parcel/plugin": "npm:^2.16.1" @@ -496,12 +496,12 @@ __metadata: languageName: unknown linkType: soft -"@pangeacyber/vanilla-js@npm:0.1.16": - version: 0.1.16 - resolution: "@pangeacyber/vanilla-js@npm:0.1.16" +"@pangeacyber/vanilla-js@npm:0.1.17": + version: 0.1.17 + resolution: "@pangeacyber/vanilla-js@npm:0.1.17" dependencies: lodash: "npm:^4.17.21" - checksum: 10c0/20f27efd8433e199ac9a20d7f532fe5891f61d00e3ff71c6df20f62d5790863c15e14de3687a94982cf466ca852766fb59e2309c7b3cf3796b863fe7dd8a5e1a + checksum: 10c0/bd7fb7491d73fbc3f98f3d859ab6a46adbfd1e32f426393ffaa6d1f7cafcae9e07cf967fed1e06873eabce3448a927c5a3bedbf93f8ca9cd23872d9f46cbf500 languageName: node linkType: hard 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 8157bd7de..fbe7e7585 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}`; }