File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ export interface OAuthAuthConfig {
5151 clientSecret ?: string ;
5252 scopes ?: string [ ] ;
5353 accountManagerHost ?: string ;
54+ /** Override redirect URI for implicit OAuth flow (e.g., for port forwarding in remote environments) */
55+ redirectUri ?: string ;
56+ /** Custom browser opener for implicit OAuth flow. Receives the authorization URL. */
57+ openBrowser ?: ( url : string ) => Promise < void > ;
5458}
5559
5660/**
Original file line number Diff line number Diff line change @@ -460,7 +460,10 @@ export function buildAuthConfigFromNormalized(config: NormalizedConfig): AuthCon
460460 * await instance.webdav.mkcol('Cartridges/v1');
461461 * ```
462462 */
463- export function createInstanceFromConfig ( config : NormalizedConfig ) : B2CInstance {
463+ export function createInstanceFromConfig (
464+ config : NormalizedConfig ,
465+ options ?: { redirectUri ?: string ; openBrowser ?: ( url : string ) => Promise < void > } ,
466+ ) : B2CInstance {
464467 if ( ! config . hostname ) {
465468 throw new Error ( 'Hostname is required. Set in dw.json or provide via overrides.' ) ;
466469 }
@@ -482,5 +485,14 @@ export function createInstanceFromConfig(config: NormalizedConfig): B2CInstance
482485
483486 const authConfig = buildAuthConfigFromNormalized ( config ) ;
484487
488+ // Inject implicit auth options into OAuth config when present
489+ if ( authConfig . oauth && ( options ?. redirectUri || options ?. openBrowser ) ) {
490+ authConfig . oauth = {
491+ ...authConfig . oauth ,
492+ redirectUri : options . redirectUri ,
493+ openBrowser : options . openBrowser ,
494+ } ;
495+ }
496+
485497 return new B2CInstance ( instanceConfig , authConfig ) ;
486498}
Original file line number Diff line number Diff line change @@ -55,11 +55,11 @@ export class ResolvedConfigImpl implements ResolvedB2CConfig {
5555
5656 // Factory methods
5757
58- createB2CInstance ( ) : B2CInstance {
58+ createB2CInstance ( options ?: Pick < CreateOAuthOptions , 'redirectUri' | 'openBrowser' > ) : B2CInstance {
5959 if ( ! this . hasB2CInstanceConfig ( ) ) {
6060 throw new Error ( 'B2C instance requires hostname' ) ;
6161 }
62- return createInstanceFromConfig ( this . values ) ;
62+ return createInstanceFromConfig ( this . values , options ) ;
6363 }
6464
6565 createBasicAuth ( ) : AuthStrategy {
Original file line number Diff line number Diff line change @@ -426,9 +426,10 @@ export interface ResolvedB2CConfig {
426426
427427 /**
428428 * Creates a B2CInstance from the resolved configuration.
429+ * @param options - Options for implicit OAuth (redirectUri, openBrowser)
429430 * @throws Error if hostname is not configured
430431 */
431- createB2CInstance ( ) : B2CInstance ;
432+ createB2CInstance ( options ?: Pick < CreateOAuthOptions , 'redirectUri' | 'openBrowser' > ) : B2CInstance ;
432433
433434 /**
434435 * Creates a Basic auth strategy.
Original file line number Diff line number Diff line change @@ -184,6 +184,8 @@ export class B2CInstance {
184184 clientSecret : this . auth . oauth . clientSecret ,
185185 scopes : this . auth . oauth . scopes ,
186186 accountManagerHost : this . auth . oauth . accountManagerHost ,
187+ redirectUri : this . auth . oauth . redirectUri ,
188+ openBrowser : this . auth . oauth . openBrowser ,
187189 } ;
188190
189191 // Filter to only OAuth methods (client-credentials, implicit)
Original file line number Diff line number Diff line change @@ -311,7 +311,8 @@ export class B2CExtensionConfig implements vscode.Disposable {
311311 return ;
312312 }
313313
314- this . instance = config . createB2CInstance ( ) ;
314+ const implicitAuthOpts = await this . getImplicitAuthOptions ( ) ;
315+ this . instance = config . createB2CInstance ( implicitAuthOpts ) ;
315316 this . configError = null ;
316317 this . log . appendLine ( `[Config] Resolved instance: ${ this . instance . config . hostname } ` ) ;
317318 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments