File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,10 +9,8 @@ export const DEFAULT_AUDIENCE = 'platform_api';
99export const DEFAULT_SCOPE = 'openid profile email offline_access transact' ;
1010export const IMMUTABLE_PROVIDER_ID = 'immutable' ;
1111export const DEFAULT_NEXTAUTH_BASE_PATH = '/api/auth' ;
12- export const DEFAULT_PRODUCTION_CLIENT_ID = 'PtQRK4iRJ8GkXjiz6xfImMAYhPhW0cYk' ;
1312export const DEFAULT_SANDBOX_CLIENT_ID = 'mjtCL8mt06BtbxSkp2vbrYStKWnXVZfo' ;
1413export const DEFAULT_REDIRECT_URI_PATH = '/callback' ;
15- export const DEFAULT_POPUP_REDIRECT_URI_PATH = '/callback' ;
1614export const DEFAULT_LOGOUT_REDIRECT_URI_PATH = '/' ;
1715export const DEFAULT_TOKEN_EXPIRY_MS = 900_000 ;
1816export const TOKEN_EXPIRY_BUFFER_MS = 60_000 ;
Original file line number Diff line number Diff line change 11/**
22 * Sandbox default redirect URI for zero-config mode.
33 * Defined locally to avoid importing from auth-next-server (which uses next/server).
4- * Server: path only. Client: full URL (origin + path) .
4+ * OAuth requires an absolute URL; this runs in the browser when login is invoked .
55 *
66 * @internal
77 */
@@ -10,7 +10,10 @@ import { DEFAULT_REDIRECT_URI_PATH } from './constants';
1010
1111export function deriveDefaultRedirectUri ( ) : string {
1212 if ( typeof window === 'undefined' ) {
13- return DEFAULT_REDIRECT_URI_PATH ;
13+ throw new Error (
14+ '[auth-next-client] deriveDefaultRedirectUri requires window. '
15+ + 'Login hooks run in the browser when the user triggers login.' ,
16+ ) ;
1417 }
1518 return `${ window . location . origin } ${ DEFAULT_REDIRECT_URI_PATH } ` ;
1619}
Original file line number Diff line number Diff line change @@ -68,9 +68,13 @@ function getSandboxLoginConfig(): LoginConfig {
6868}
6969
7070function getSandboxLogoutConfig ( ) : LogoutConfig {
71- const logoutRedirectUri = typeof window === 'undefined'
72- ? DEFAULT_LOGOUT_REDIRECT_URI_PATH
73- : window . location . origin + DEFAULT_LOGOUT_REDIRECT_URI_PATH ;
71+ if ( typeof window === 'undefined' ) {
72+ throw new Error (
73+ '[auth-next-client] getSandboxLogoutConfig requires window. '
74+ + 'Logout runs in the browser when the user triggers it.' ,
75+ ) ;
76+ }
77+ const logoutRedirectUri = window . location . origin + DEFAULT_LOGOUT_REDIRECT_URI_PATH ;
7478 return {
7579 clientId : DEFAULT_SANDBOX_CLIENT_ID ,
7680 logoutRedirectUri,
Original file line number Diff line number Diff line change @@ -66,10 +66,8 @@ export {
6666 DEFAULT_AUDIENCE ,
6767 DEFAULT_SCOPE ,
6868 IMMUTABLE_PROVIDER_ID ,
69- DEFAULT_PRODUCTION_CLIENT_ID ,
7069 DEFAULT_SANDBOX_CLIENT_ID ,
7170 DEFAULT_REDIRECT_URI_PATH ,
72- DEFAULT_POPUP_REDIRECT_URI_PATH ,
7371 DEFAULT_LOGOUT_REDIRECT_URI_PATH ,
7472} from './constants' ;
7573export { deriveDefaultRedirectUri } from './defaultConfig' ;
Original file line number Diff line number Diff line change @@ -87,23 +87,9 @@ async function validateTokens(
8787 * ```
8888 */
8989export function createAuthConfig ( config ?: ImmutableAuthConfig ) : NextAuthConfig {
90- let clientId : string ;
91- let redirectUri : string ;
92-
93- if ( config ) {
94- clientId = config . clientId ;
95- redirectUri = config . redirectUri ;
96- } else {
97- clientId = DEFAULT_SANDBOX_CLIENT_ID ;
98- redirectUri = deriveDefaultRedirectUri ( ) ;
99- }
100-
101- const resolvedConfig : ImmutableAuthConfig = {
102- clientId,
103- redirectUri,
104- audience : config ?. audience ,
105- scope : config ?. scope ,
106- authenticationDomain : config ?. authenticationDomain ,
90+ const resolvedConfig : ImmutableAuthConfig = config ?? {
91+ clientId : DEFAULT_SANDBOX_CLIENT_ID ,
92+ redirectUri : deriveDefaultRedirectUri ( ) ,
10793 } ;
10894 const authDomain = resolvedConfig . authenticationDomain || DEFAULT_AUTH_DOMAIN ;
10995
Original file line number Diff line number Diff line change @@ -57,22 +57,15 @@ export const TOKEN_EXPIRY_BUFFER_MS = TOKEN_EXPIRY_BUFFER_SECONDS * 1000;
5757export const DEFAULT_SESSION_MAX_AGE_SECONDS = 365 * 24 * 60 * 60 ;
5858
5959/**
60- * Public client IDs for Immutable's default applications.
61- * auth-next zero-config uses DEFAULT_SANDBOX_CLIENT_ID only.
60+ * Sandbox client ID for auth-next zero-config.
6261 */
63- export const DEFAULT_PRODUCTION_CLIENT_ID = 'PtQRK4iRJ8GkXjiz6xfImMAYhPhW0cYk' ;
6462export const DEFAULT_SANDBOX_CLIENT_ID = 'mjtCL8mt06BtbxSkp2vbrYStKWnXVZfo' ;
6563
6664/**
6765 * Default redirect URI path for sandbox zero-config.
6866 */
6967export const DEFAULT_REDIRECT_URI_PATH = '/callback' ;
7068
71- /**
72- * Default popup redirect URI path. Same as redirectUri to align with @imtbl/auth and @imtbl/wallet.
73- */
74- export const DEFAULT_POPUP_REDIRECT_URI_PATH = '/callback' ;
75-
7669/**
7770 * Default logout redirect URI path
7871 */
Original file line number Diff line number Diff line change @@ -51,10 +51,8 @@ export {
5151 DEFAULT_SCOPE ,
5252 IMMUTABLE_PROVIDER_ID ,
5353 DEFAULT_NEXTAUTH_BASE_PATH ,
54- DEFAULT_PRODUCTION_CLIENT_ID ,
5554 DEFAULT_SANDBOX_CLIENT_ID ,
5655 DEFAULT_REDIRECT_URI_PATH ,
57- DEFAULT_POPUP_REDIRECT_URI_PATH ,
5856 DEFAULT_LOGOUT_REDIRECT_URI_PATH ,
5957 DEFAULT_TOKEN_EXPIRY_MS ,
6058 TOKEN_EXPIRY_BUFFER_MS ,
You can’t perform that action at this time.
0 commit comments