Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/react-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/react-auth/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
},
Expand Down
19 changes: 17 additions & 2 deletions packages/react-auth/src/AuthProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -152,6 +158,7 @@ export const AuthProvider: FC<AuthProviderProps> = ({
cookieOptions = { useCookie: false },
redirectUri,
redirectPathname,
onRedirectCallback,
redirectOnLogout = false,
useStrictStateCheck = true,
passAuthMethod = false,
Expand Down Expand Up @@ -378,7 +385,11 @@ export const AuthProvider: FC<AuthProviderProps> = ({
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 () => {
Expand All @@ -400,7 +411,11 @@ export const AuthProvider: FC<AuthProviderProps> = ({
const url = `${logoutURL}?${toUrlEncoded(query)}`;

setLoggedOut();
window.location.replace(url);
if (onRedirectCallback) {
onRedirectCallback(url);
} else {
window.location.replace(url);
}
}
// call the logout endpoint
else {
Expand Down
10 changes: 5 additions & 5 deletions packages/react-auth/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla-js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/vanilla-js/src/AuthNClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

Expand Down