Merged
Conversation
- AuthService 생성: login(), logout(), refreshTokens(), isAuthenticated() - AuthEventEmitter 도입: LOGIN, LOGOUT, TOKEN_REFRESH 이벤트 발행/구독 - TokenStorage 캡슐화: localStorage 직접 접근을 내부로 은닉 - 기존 tokenController 사용처 모두 authService로 마이그레이션
- appBridge 유틸리티 객체 구현 - isInApp(): WebView 환경 감지 - sendToApp(): 앱으로 메시지 전송 (postMessage) - onAppMessage(): 앱 메시지 수신 리스너 - waitForAppToken(): 토큰 수신 Promise 대기 - Window.ReactNativeWebView 타입 확장 (global.d.ts) - AppMessageType 정의 (READY, AUTH_TOKEN, TOKEN_REFRESHED, LOGOUT)
- AppBridgeProvider 구현 - useAppBridge() 훅으로 isApp 상태 제공 - authService 이벤트 구독 → 앱에 자동 알림 - LOGOUT, TOKEN_REFRESHED 메시지 전송 - AppAuthProvider 구현 - 앱 환경에서 토큰 수신 대기 (waitForAppToken) - 웹 환경에서는 즉시 children 렌더링 - loadingFallback, errorFallback 커스터마이징 지원
- layout.tsx에 Provider 적용 - AppAuthProvider: 앱 환경 토큰 수신 대기 - AppBridgeProvider: Auth 이벤트 → 앱 알림 - 커스텀 loading/error fallback UI 설정 - useAutoLogout 앱 환경 대응 - useAppBridge() 훅으로 isApp 상태 확인 - 앱 환경에서는 토큰 체크 스킵 (AppAuthProvider가 처리)
- AppMessageType 변경: AUTH_TOKEN → SYNC_TOKEN_TO_WEB, TOKEN_REFRESHED → SYNC_TOKEN_TO_APP - AppBridgeProvider에 authService.onLogin() 구독 추가 - 웹뷰 내 로그인/토큰 갱신 시 앱에 SYNC_TOKEN_TO_APP 메시지 전송
앱 환경에서 회원가입 완료/뒤로가기 시 네이티브 로그인 화면으로 이동 - AppMessageType에 NAVIGATE_TO_NATIVE_LOGIN 추가 - PageHeader에 onBackClick 콜백 prop 추가 - signup, login/email 페이지에 앱/웹 환경 분기 처리 적용 - signupDialogButton 성공 모달에 앱/웹 환경 분기 처리 적용
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
React Native 앱과 웹뷰 간 토큰 동기화 및 통신을 위한 App Bridge 시스템 구현
주요 변경사항
1. Auth 모듈 리팩토링
tokenController→authService로 통합 (로그인/로그아웃/토큰 갱신)authEventEmitter)tokenStorage)2. App Bridge 모듈 구현 (
src/shared/lib/appBridge/)isInApp)sendToApp,onAppMessage)waitForAppToken)3. Provider 구현
AppAuthProvider: 앱 환경에서 토큰 수신 후 렌더링AppBridgeProvider: Auth 이벤트 → 앱 알림 연동4. 네이티브 로그인 화면 이동
PageHeader에onBackClickprop 추가메시지 프로토콜
READYSYNC_TOKEN_TO_WEBSYNC_TOKEN_TO_APPLOGOUTNAVIGATE_TO_NATIVE_LOGIN