feat(mock): getConsentedUserData mock 추가 — env1 미측정 실 export 배선#801
Merged
Conversation
@apps-in-toss/web-framework의 실 export인 getConsentedUserData가 mock에 없어 env1(브라우저+mock)에서 호출 자체가 불가능했다(devtools#798). 사용자 동의 기반 데이터 조회 async bridge를 auth 도메인에 추가하고 상태(aitState. auth.consentedUserData)로 값을 구성 가능하게 했다. - 이 API는 web-framework 2.x 라인에만 존재(@apps-in-toss/web-bridge 경유), 3.0-beta 표면엔 대응 export가 없음 — PermissionError(반대 방향 비대칭)와 같은 방식으로 두 __typecheck 파일 모두 AssertIfPresent로 capability-gate. - 선언 밖 필드는 추가하지 않음(devtools#783).
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.
배경
getConsentedUserData는@apps-in-toss/web-framework의 실 export지만(node_modules의.d.ts에 선언돼 있음) devtools mock(src/mock/)에는 구현이 없었다. env1(브라우저 + mock SDK)에서 이 API를 호출할 방법 자체가 없어 env1↔env3 fidelity diff에서도 보이지 않는 사각지대였다(devtools#798).SDK 시그니처
이 API는 web-framework 2.x stable 라인에만 존재한다(
@apps-in-toss/web-bridge경유 —web-framework가export * from '@apps-in-toss/web-bridge'로 top-level 재export). 3.0-beta 라인 표면엔 대응 export가 없다 —@apps-in-toss/webview-bridge/web-framework3.0-beta core.d.ts 어디에도getConsentedUserData/ConsentedUserData*심볼이 없음을 직접 확인했다.2.x 선언(
@apps-in-toss/web-bridge/dist/getConsentedUserData.d.ts):구현
src/mock/types.ts:ConsentedUserDataKey/ConsentedUserData타입 추가 (SDK 선언과 이름·shape 동일).src/mock/auth/index.ts:appLogin/getAnonymousKey/getUserKeyForGame과 같은 auth 도메인 async bridge 패턴을 그대로 따라getConsentedUserData추가. 어떤 키가 채워지는지는 콘솔에 등록된 동의문/데이터 묶음에 달려 있어 mock이 알 수 없으므로,consentedUserDataKey파라미터와 무관하게aitState.state.auth.consentedUserData(최소 plausible 객체, 기본값{ USER_NAME: 'mock-user-name' })를 그대로 resolve한다.src/mock/index.ts: 함수 + 타입을 mock 공개 표면에 export (@ait-co/devtools/mock에서 resolve됨).src/mock/state.ts:auth.consentedUserData상태 필드 추가 (aitState.patch('auth', { consentedUserData: {...} })로 dial 가능 —userKeyHash/anonymousKeyHash와 같은 자리).두 SDK 라인 typecheck (devtools#775 device-fidelity 원칙)
이 API는 2.x에만 있고 3.0-beta엔 없는, PermissionError(3.0 신규, 2.x 부재)의 반대 방향 비대칭이다. 두
__typecheck*.ts모두 기존AssertIfPresentcapability-gate 패턴을 그대로 적용했다:src/__typecheck.ts(3.0-beta 라인):Original에 심볼이 없으므로 skip(true).src/__typecheck-2x.ts(2.x 라인):Original.getConsentedUserData가 실존하므로 엄격AssertCompat으로 강제 검증 — 이게 실제 primary gate다.mock 함수 시그니처는 SDK 선언과 동일한 파라미터/리턴 shape을 로컬로 재선언했기 때문에(런타임에 실 SDK 패키지를 import하지 않음 — peer optional 정책),
as unknown as캐스트가 필요 없었다. 캐스트가 필요한 경우는 선언 타입과 실측 런타임이 어긋날 때(Storage.setItem→null,getSafeAreaInsets→ 객체 등, 기존 #775 사례)인데, 이 API는 아직 실기기 캡처가 없어 "선언 타입 그대로의 값"을 resolve하는 낙관적 패턴을 택했다 — devtools#783 원칙(실측/타입 밖 추정 금지)에 따라 SDK가 선언한 8개 키 중 하나만 담은 최소 객체를 반환하고, 그 이상의 필드는 만들지 않았다.검증
pnpm build && pnpm typecheck— green (3.0-beta·2.x 두 라인 + e2e fixture + scripts tsconfig 전부 통과)pnpm lint— clean (Biome, exit 0; 기존 무관 파일의 info 32건은 이 PR 이전부터 있던 것)pnpm test—Test Files 111 passed (111),Tests 2501 passed | 1 todo (2502)Out of scope
sdk-example 쪽 페이지/테스트 추가 및 실기기 캡처를 통한 device-fidelity 보강(failureModes 다이얼 등)은 별도 트래킹 — sdk-example#331.
Closes #798