From 1b15df0cccddbb487eca951eb33b3129e87b3108 Mon Sep 17 00:00:00 2001 From: Bernd Trappe Date: Thu, 21 Aug 2025 14:56:59 +0200 Subject: [PATCH] Add WebView support for OAuth flow without popups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add webview prop to ezp-printing and ezp-auth components - Implement direct window redirect in WebView mode instead of popup - Add @Watch('code') decorator for dynamic code handling from Flutter - Support Flutter OAuth redirect handler (ezeep://oauth) integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/components/ezp-auth/ezp-auth.tsx | 20 +++++++++++++++++++- src/components/ezp-printing/ezp-printing.tsx | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/ezp-auth/ezp-auth.tsx b/src/components/ezp-auth/ezp-auth.tsx index 978d538..e61cfa3 100644 --- a/src/components/ezp-auth/ezp-auth.tsx +++ b/src/components/ezp-auth/ezp-auth.tsx @@ -1,4 +1,4 @@ -import { Component, Host, h, Prop, State, Event, EventEmitter, Listen } from '@stencil/core' +import { Component, Host, h, Prop, State, Event, EventEmitter, Listen, Watch } from '@stencil/core' import { EzpAuthorizationService } from '../../services/auth' import authStore from '../../services/auth' import i18next from 'i18next' @@ -13,6 +13,7 @@ export class EzpAuth { @Prop() hidelogin: boolean @Prop() trigger: string @Prop() code: string + @Prop() webview: boolean = false @State() auth: EzpAuthorizationService @State() authURI: string @@ -37,6 +38,17 @@ export class EzpAuth { this.authCancel.emit() } + @Watch('code') + async watchCode(newCode: string) { + if (newCode && newCode.length > 0) { + authStore.state.code = newCode + this.auth.getAccessToken().then(() => { + this.authCancel.emit() + this.authSuccess.emit() + }) + } + } + oauthPopupWindow: Window = null previousUrl = null @@ -47,6 +59,12 @@ export class EzpAuth { return } + // WebView mode: redirect current window instead of opening popup + if (this.webview) { + window.location.href = url + return + } + // remove any existing event listeners window.removeEventListener('message', this.receiveMessage) diff --git a/src/components/ezp-printing/ezp-printing.tsx b/src/components/ezp-printing/ezp-printing.tsx index 022cacd..d7cd9a7 100644 --- a/src/components/ezp-printing/ezp-printing.tsx +++ b/src/components/ezp-printing/ezp-printing.tsx @@ -50,6 +50,7 @@ export class EzpPrinting { @Prop() code: string @Prop() filedata: string @Prop() seamless: boolean = false + @Prop() webview: boolean = false /** * @@ -365,6 +366,7 @@ export class EzpPrinting { hidelogin={this.hidelogin} trigger={this.trigger} code={this.code} + webview={this.webview} > ) : this.printOpen ? (