@yoonion/mimi-seed-mcp 0.24.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/admob/cli.js +34 -5
  2. package/dist/admob/errors.js +39 -14
  3. package/dist/ai/client.js +35 -14
  4. package/dist/ai/notes.js +14 -3
  5. package/dist/ai/review.js +17 -4
  6. package/dist/android/keystore-store.js +28 -8
  7. package/dist/android/keystore.d.ts +17 -2
  8. package/dist/android/keystore.js +110 -21
  9. package/dist/android/messages.d.ts +13 -11
  10. package/dist/android/messages.js +166 -72
  11. package/dist/android/playstore-sa.js +6 -3
  12. package/dist/appstore/analytics.js +46 -14
  13. package/dist/appstore/app-info-policy.js +7 -1
  14. package/dist/appstore/app-info.js +13 -3
  15. package/dist/appstore/apps.js +7 -1
  16. package/dist/appstore/asset-library-write.js +119 -37
  17. package/dist/appstore/asset-library.js +19 -5
  18. package/dist/appstore/auth.d.ts +2 -0
  19. package/dist/appstore/auth.js +31 -5
  20. package/dist/appstore/client.js +27 -6
  21. package/dist/appstore/declarations.js +22 -6
  22. package/dist/appstore/errors.d.ts +1 -1
  23. package/dist/appstore/errors.js +60 -34
  24. package/dist/appstore/http.d.ts +6 -0
  25. package/dist/appstore/http.js +22 -5
  26. package/dist/appstore/messages.js +86 -28
  27. package/dist/appstore/previews.js +22 -6
  28. package/dist/appstore/product-localization.js +10 -2
  29. package/dist/appstore/product-review.js +29 -10
  30. package/dist/appstore/products.js +20 -6
  31. package/dist/appstore/read-response.js +13 -3
  32. package/dist/appstore/release-target.js +13 -3
  33. package/dist/appstore/release.js +59 -22
  34. package/dist/appstore/review-preview.js +17 -6
  35. package/dist/appstore/review-submission.js +86 -35
  36. package/dist/appstore/sales.js +96 -44
  37. package/dist/appstore/screenshots.js +19 -5
  38. package/dist/appstore/testflight.js +41 -18
  39. package/dist/appstore/upload-parts.js +12 -3
  40. package/dist/appstore/versions.js +22 -10
  41. package/dist/auth/bigquery-auth.js +44 -15
  42. package/dist/auth/bigquery-setup-cli.js +1 -1
  43. package/dist/auth/cli.js +4 -2
  44. package/dist/auth/constants.js +13 -3
  45. package/dist/auth/drive-auth.d.ts +3 -2
  46. package/dist/auth/drive-auth.js +47 -17
  47. package/dist/auth/drive-setup-cli.js +1 -0
  48. package/dist/auth/errors.d.ts +75 -0
  49. package/dist/auth/errors.js +190 -86
  50. package/dist/auth/google-auth.d.ts +3 -1
  51. package/dist/auth/google-auth.js +39 -27
  52. package/dist/auth/playstore-auth.d.ts +1 -0
  53. package/dist/auth/playstore-auth.js +35 -15
  54. package/dist/auth/scopes.d.ts +11 -29
  55. package/dist/auth/scopes.js +38 -11
  56. package/dist/auth/youtube-channel.d.ts +8 -0
  57. package/dist/auth/youtube-channel.js +11 -3
  58. package/dist/bigquery/ids.js +19 -5
  59. package/dist/bigquery/tools.js +24 -8
  60. package/dist/billing/tools.js +22 -6
  61. package/dist/checks/appstore-submission.d.ts +1 -1
  62. package/dist/checks/appstore-submission.js +29 -8
  63. package/dist/checks/plan.js +169 -62
  64. package/dist/checks/release-status.js +10 -2
  65. package/dist/checks/risks.js +230 -63
  66. package/dist/checks/screenshots.d.ts +4 -4
  67. package/dist/checks/screenshots.js +63 -22
  68. package/dist/ci/config.js +8 -5
  69. package/dist/ci/gitlab.js +3 -1
  70. package/dist/core/atomic-write.d.ts +5 -2
  71. package/dist/core/atomic-write.js +8 -4
  72. package/dist/core/catch-scan.d.ts +17 -0
  73. package/dist/core/catch-scan.js +111 -0
  74. package/dist/core/checks/billing.d.ts +5 -0
  75. package/dist/core/checks/billing.js +36 -5
  76. package/dist/core/checks/lockfile.js +2 -0
  77. package/dist/core/checks/release-doctor/fcm.js +1 -0
  78. package/dist/core/checks/release-doctor/files.d.ts +3 -1
  79. package/dist/core/checks/release-doctor/files.js +12 -1
  80. package/dist/core/checks/release-doctor/gradle-apply.js +1 -0
  81. package/dist/core/checks/release-doctor/ios-xcode.js +22 -3
  82. package/dist/core/checks/release-doctor/target-sdk.js +1 -1
  83. package/dist/core/checks/release-doctor/util.d.ts +5 -0
  84. package/dist/core/checks/release-doctor/util.js +56 -0
  85. package/dist/core/checks/release-doctor.js +59 -16
  86. package/dist/core/credential-envelope.d.ts +25 -0
  87. package/dist/core/credential-envelope.js +66 -0
  88. package/dist/core/credential-keystore.d.ts +51 -0
  89. package/dist/core/credential-keystore.js +331 -0
  90. package/dist/core/credential-read.d.ts +33 -0
  91. package/dist/core/credential-read.js +112 -0
  92. package/dist/core/credential-store.d.ts +61 -0
  93. package/dist/core/credential-store.js +240 -0
  94. package/dist/core/http-errors.js +1 -0
  95. package/dist/core/i18n-scan.d.ts +10 -0
  96. package/dist/core/i18n-scan.js +79 -0
  97. package/dist/core/json-file.d.ts +30 -0
  98. package/dist/core/json-file.js +53 -0
  99. package/dist/core/lang.d.ts +14 -0
  100. package/dist/core/lang.js +22 -2
  101. package/dist/core/project-manifest.d.ts +24 -1
  102. package/dist/core/project-manifest.js +27 -16
  103. package/dist/drive/tools.js +86 -34
  104. package/dist/facebook/api.js +3 -1
  105. package/dist/facebook/config.js +11 -3
  106. package/dist/facebook/setup.d.ts +2 -0
  107. package/dist/facebook/setup.js +32 -9
  108. package/dist/firebase/cli.js +39 -5
  109. package/dist/firebase/tools.js +36 -10
  110. package/dist/ga4/cli.js +48 -4
  111. package/dist/ga4/tools.js +4 -2
  112. package/dist/googleads/config.js +24 -8
  113. package/dist/googleads/tools.js +3 -1
  114. package/dist/gsc/tools.js +10 -2
  115. package/dist/helpers.d.ts +4 -2
  116. package/dist/helpers.js +66 -32
  117. package/dist/i18n/manifest-en.d.ts +6 -0
  118. package/dist/i18n/manifest-en.js +53 -0
  119. package/dist/i18n/tools-en/admob.d.ts +25 -0
  120. package/dist/i18n/tools-en/admob.js +24 -0
  121. package/dist/i18n/tools-en/ai.d.ts +14 -0
  122. package/dist/i18n/tools-en/ai.js +13 -0
  123. package/dist/i18n/tools-en/android.d.ts +14 -0
  124. package/dist/i18n/tools-en/android.js +13 -0
  125. package/dist/i18n/tools-en/appstore.d.ts +240 -0
  126. package/dist/i18n/tools-en/appstore.js +239 -0
  127. package/dist/i18n/tools-en/auth.d.ts +16 -0
  128. package/dist/i18n/tools-en/auth.js +15 -0
  129. package/dist/i18n/tools-en/bigquery.d.ts +16 -0
  130. package/dist/i18n/tools-en/bigquery.js +15 -0
  131. package/dist/i18n/tools-en/billing.d.ts +17 -0
  132. package/dist/i18n/tools-en/billing.js +16 -0
  133. package/dist/i18n/tools-en/checks.d.ts +23 -0
  134. package/dist/i18n/tools-en/checks.js +22 -0
  135. package/dist/i18n/tools-en/ci.d.ts +21 -0
  136. package/dist/i18n/tools-en/ci.js +20 -0
  137. package/dist/i18n/tools-en/drive.d.ts +33 -0
  138. package/dist/i18n/tools-en/drive.js +32 -0
  139. package/dist/i18n/tools-en/facebook.d.ts +14 -0
  140. package/dist/i18n/tools-en/facebook.js +13 -0
  141. package/dist/i18n/tools-en/firebase.d.ts +42 -0
  142. package/dist/i18n/tools-en/firebase.js +41 -0
  143. package/dist/i18n/tools-en/ga4.d.ts +35 -0
  144. package/dist/i18n/tools-en/ga4.js +34 -0
  145. package/dist/i18n/tools-en/googleads.d.ts +15 -0
  146. package/dist/i18n/tools-en/googleads.js +14 -0
  147. package/dist/i18n/tools-en/gsc.d.ts +27 -0
  148. package/dist/i18n/tools-en/gsc.js +26 -0
  149. package/dist/i18n/tools-en/iam.d.ts +15 -0
  150. package/dist/i18n/tools-en/iam.js +14 -0
  151. package/dist/i18n/tools-en/index.d.ts +7 -0
  152. package/dist/i18n/tools-en/index.js +58 -0
  153. package/dist/i18n/tools-en/instagram.d.ts +16 -0
  154. package/dist/i18n/tools-en/instagram.js +15 -0
  155. package/dist/i18n/tools-en/jenkins.d.ts +41 -0
  156. package/dist/i18n/tools-en/jenkins.js +40 -0
  157. package/dist/i18n/tools-en/naver.d.ts +10 -0
  158. package/dist/i18n/tools-en/naver.js +9 -0
  159. package/dist/i18n/tools-en/playstore.d.ts +148 -0
  160. package/dist/i18n/tools-en/playstore.js +147 -0
  161. package/dist/i18n/tools-en/registrar.d.ts +6 -0
  162. package/dist/i18n/tools-en/registrar.js +6 -0
  163. package/dist/i18n/tools-en/threads.d.ts +21 -0
  164. package/dist/i18n/tools-en/threads.js +20 -0
  165. package/dist/i18n/tools-en/tiktok.d.ts +21 -0
  166. package/dist/i18n/tools-en/tiktok.js +20 -0
  167. package/dist/i18n/tools-en/video.d.ts +59 -0
  168. package/dist/i18n/tools-en/video.js +58 -0
  169. package/dist/i18n/tools-en/youtube.d.ts +44 -0
  170. package/dist/i18n/tools-en/youtube.js +43 -0
  171. package/dist/iam/key-files.js +13 -3
  172. package/dist/instagram/api.js +19 -5
  173. package/dist/instagram/config.js +11 -3
  174. package/dist/instagram/setup.js +37 -11
  175. package/dist/jenkins/builds.d.ts +2 -2
  176. package/dist/jenkins/builds.js +70 -30
  177. package/dist/jenkins/config.d.ts +5 -0
  178. package/dist/jenkins/config.js +25 -6
  179. package/dist/jenkins/credentials.js +33 -13
  180. package/dist/jenkins/http.js +6 -3
  181. package/dist/jenkins/jobs.js +19 -5
  182. package/dist/jenkins/messages.js +93 -36
  183. package/dist/lib/cli-args.js +13 -7
  184. package/dist/lib/google-errors.js +31 -9
  185. package/dist/lib/http.js +10 -3
  186. package/dist/lib/json-file.d.ts +15 -0
  187. package/dist/lib/json-file.js +65 -0
  188. package/dist/lib/meta-auth.d.ts +1 -1
  189. package/dist/lib/meta-auth.js +26 -8
  190. package/dist/lib/package-name.js +15 -4
  191. package/dist/lib/package-root.js +1 -1
  192. package/dist/lib/paginate.js +10 -2
  193. package/dist/lib/path-containment.js +22 -6
  194. package/dist/lib/resource-id.js +10 -3
  195. package/dist/lib/store-create-result.js +54 -13
  196. package/dist/lib/text-validators.js +20 -5
  197. package/dist/lib/tool-registrar.d.ts +9 -0
  198. package/dist/lib/tool-registrar.js +33 -14
  199. package/dist/lib/tool-text.d.ts +31 -0
  200. package/dist/lib/tool-text.js +52 -0
  201. package/dist/lib/toolsets.js +13 -3
  202. package/dist/lib/url-path.js +3 -1
  203. package/dist/naver/tools.js +138 -46
  204. package/dist/playstore/data-safety.js +16 -4
  205. package/dist/playstore/errors.js +33 -8
  206. package/dist/playstore/financials.js +83 -35
  207. package/dist/playstore/listing.js +7 -1
  208. package/dist/playstore/messages.js +179 -57
  209. package/dist/playstore/products.js +10 -2
  210. package/dist/playstore/recovery.js +10 -2
  211. package/dist/playstore/releases.js +34 -14
  212. package/dist/playstore/reviews.js +14 -4
  213. package/dist/playstore/statistics.js +3 -1
  214. package/dist/prompts.js +160 -50
  215. package/dist/registers/admob.js +36 -11
  216. package/dist/registers/android.js +25 -9
  217. package/dist/registers/appstore/apps.js +22 -6
  218. package/dist/registers/appstore/customer-reviews.js +7 -1
  219. package/dist/registers/appstore/declarations.js +63 -19
  220. package/dist/registers/appstore/media.js +76 -24
  221. package/dist/registers/appstore/metadata.js +26 -8
  222. package/dist/registers/appstore/products.js +53 -19
  223. package/dist/registers/appstore/review-submission.js +31 -9
  224. package/dist/registers/appstore/testflight.js +82 -24
  225. package/dist/registers/appstore/versions.js +88 -30
  226. package/dist/registers/auth.js +343 -90
  227. package/dist/registers/bigquery.js +54 -14
  228. package/dist/registers/billing.js +18 -4
  229. package/dist/registers/checks.js +20 -5
  230. package/dist/registers/ci.js +60 -20
  231. package/dist/registers/drive.js +18 -7
  232. package/dist/registers/facebook.js +31 -9
  233. package/dist/registers/firebase.js +21 -7
  234. package/dist/registers/googleads.js +23 -6
  235. package/dist/registers/gsc.js +3 -1
  236. package/dist/registers/iam.js +44 -13
  237. package/dist/registers/instagram.js +19 -5
  238. package/dist/registers/jenkins.js +43 -14
  239. package/dist/registers/naver.js +13 -3
  240. package/dist/registers/playstore/financials.d.ts +6 -0
  241. package/dist/registers/playstore/financials.js +48 -0
  242. package/dist/registers/playstore/listing.d.ts +15 -0
  243. package/dist/registers/playstore/listing.js +138 -0
  244. package/dist/registers/playstore/media.d.ts +6 -0
  245. package/dist/registers/playstore/media.js +56 -0
  246. package/dist/registers/playstore/products.d.ts +21 -0
  247. package/dist/registers/playstore/products.js +238 -0
  248. package/dist/registers/playstore/recovery.d.ts +11 -0
  249. package/dist/registers/playstore/recovery.js +105 -0
  250. package/dist/registers/playstore/releases.d.ts +8 -0
  251. package/dist/registers/playstore/releases.js +157 -0
  252. package/dist/registers/playstore/reviews.d.ts +6 -0
  253. package/dist/registers/playstore/reviews.js +43 -0
  254. package/dist/registers/playstore/service-accounts.d.ts +13 -0
  255. package/dist/registers/playstore/service-accounts.js +127 -0
  256. package/dist/registers/playstore/shared.d.ts +12 -0
  257. package/dist/registers/playstore/shared.js +24 -0
  258. package/dist/registers/playstore.d.ts +8 -0
  259. package/dist/registers/playstore.js +28 -734
  260. package/dist/registers/threads.js +28 -8
  261. package/dist/registers/tiktok.js +4 -2
  262. package/dist/registers/video.js +3 -1
  263. package/dist/remote-sync.js +80 -28
  264. package/dist/resources.d.ts +0 -8
  265. package/dist/resources.js +73 -32
  266. package/dist/server.d.ts +2 -0
  267. package/dist/server.js +9 -1
  268. package/dist/social/profile-store.js +36 -12
  269. package/dist/social/setup-cli.js +1 -1
  270. package/dist/threads/api.js +23 -6
  271. package/dist/threads/setup.js +42 -14
  272. package/dist/tiktok-business/api.js +13 -3
  273. package/dist/tiktok-business/auth.js +10 -2
  274. package/dist/tiktok-business/config.js +8 -3
  275. package/dist/tiktok-business/posting.d.ts +6 -0
  276. package/dist/tiktok-business/posting.js +118 -36
  277. package/dist/tiktok-business/setup-cli.js +3 -1
  278. package/dist/tools-cli.js +4 -5
  279. package/dist/video/captions.js +3 -1
  280. package/dist/video/files.js +13 -3
  281. package/dist/video/project.js +65 -21
  282. package/dist/video/providers.js +52 -16
  283. package/dist/video/render.js +71 -22
  284. package/dist/video/research.js +10 -2
  285. package/dist/video/schemas.js +19 -5
  286. package/dist/video/youtube-publish.js +62 -32
  287. package/package.json +1 -1
@@ -1,16 +1,20 @@
1
1
  import { google } from '../lib/googleapis-lite.js';
2
2
  import http from 'node:http';
3
3
  import { randomUUID } from 'node:crypto';
4
- import { verifyYouTubeChannel, YOUTUBE_CHANNEL_ID } from './youtube-channel.js';
4
+ import { verifyYouTubeChannel, YOUTUBE_CHANNEL_ID, YouTubeChannelError } from './youtube-channel.js';
5
5
  import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import os from 'node:os';
8
8
  import { getMcpOAuthClient } from './constants.js';
9
- import { AuthError, classifyError } from './errors.js';
9
+ import { jsonFileProblem } from '../lib/json-file.js';
10
+ import { AuthError, authText, classifyError } from './errors.js';
10
11
  // 스코프 목록의 SSOT 는 scopes.ts (도메인 → 스코프 매핑). 여기서는 로그인 요청 조립만 한다.
11
12
  import { scopesForDomains, IDENTITY_SCOPES } from './scopes.js';
12
13
  import { writeCredentialJson } from '#core/atomic-write.js';
13
14
  import { fetchWithTimeout } from '../lib/http.js';
15
+ import { catalog } from '#core/lang.js';
16
+ import { readCredentialFileSync } from '#core/credential-read.js';
17
+ const M = catalog({ changed: '요청을 준비하는 동안 Google 인증이 변경됐습니다. 같은 프로필로 다시 시도하세요.' }, { changed: 'Google authentication changed while the request was being prepared. Try again with the same profile.' });
14
18
  // Primary config dir. Legacy `~/.preseed` is read as a fallback during the
15
19
  // rebrand so existing auth sessions don't force a re-login; new writes go to
16
20
  // the new dir.
@@ -28,11 +32,11 @@ export function googleProfilePath(profile) {
28
32
  function readProfile(profile) {
29
33
  const file = googleProfilePath(profile);
30
34
  try {
31
- return JSON.parse(fs.readFileSync(file, 'utf-8'));
35
+ return JSON.parse(readCredentialFileSync(file));
32
36
  }
33
37
  catch {
34
38
  return null;
35
- }
39
+ } // 깨진 프로필은 '로그인 안 됨' — ensureFreshAccessToken 이 jsonFileProblem 으로 원인을 따로 알린다
36
40
  }
37
41
  /** Only safe metadata; never return tokens or OAuth client secrets to MCP callers. */
38
42
  export function listGoogleProfiles() {
@@ -64,6 +68,7 @@ export function emailFromIdToken(idToken) {
64
68
  return typeof json.email === 'string' && json.email ? json.email : undefined;
65
69
  }
66
70
  catch {
71
+ // 표시용 email 일 뿐 — 형식이 다른 id_token 은 '모름'으로 둔다
67
72
  return undefined;
68
73
  }
69
74
  }
@@ -73,16 +78,23 @@ export function getStoredCredentials(profile) {
73
78
  if (!fs.existsSync(CREDENTIALS_PATH))
74
79
  return null;
75
80
  try {
76
- const data = JSON.parse(fs.readFileSync(CREDENTIALS_PATH, 'utf-8'));
81
+ const data = JSON.parse(readCredentialFileSync(CREDENTIALS_PATH));
77
82
  return { clientId: data.clientId, clientSecret: data.clientSecret };
78
83
  }
79
84
  catch {
85
+ // 읽을 수 없으면 '미설정' — 깨진 파일은 mimi_seed_status 가 json-file 로 따로 보고한다
80
86
  return null;
81
87
  }
82
88
  }
83
89
  export function saveCredentials(clientId, clientSecret) {
84
90
  writeCredentialJson(CREDENTIALS_PATH, { clientId, clientSecret });
85
91
  }
92
+ /** getStoredTokens 가 읽는 파일 — 프로필이면 그 파일, 아니면 tokens.json (없으면 레거시 경로). */
93
+ export function googleTokenFilePath(profile) {
94
+ if (profile !== undefined)
95
+ return googleProfilePath(profile);
96
+ return !fs.existsSync(TOKEN_PATH) && fs.existsSync(LEGACY_TOKEN_PATH) ? LEGACY_TOKEN_PATH : TOKEN_PATH;
97
+ }
86
98
  export function getStoredTokens(profile) {
87
99
  if (profile !== undefined)
88
100
  return readProfile(profile)?.tokens ?? null;
@@ -95,9 +107,10 @@ export function getStoredTokens(profile) {
95
107
  if (!pathToRead)
96
108
  return null;
97
109
  try {
98
- return JSON.parse(fs.readFileSync(pathToRead, 'utf-8'));
110
+ return JSON.parse(readCredentialFileSync(pathToRead));
99
111
  }
100
112
  catch {
113
+ // 깨진 토큰은 '로그인 안 됨' — ensureFreshAccessToken 이 jsonFileProblem 으로 원인을 따로 알린다
101
114
  return null;
102
115
  }
103
116
  }
@@ -115,7 +128,7 @@ export function getTokensLastRefreshMs(profile) {
115
128
  }
116
129
  catch {
117
130
  return null;
118
- }
131
+ } // 파일이 없으면 갱신 시각도 없다 — auth_status 표시용 부가 정보
119
132
  }
120
133
  const pathToRead = fs.existsSync(TOKEN_PATH)
121
134
  ? TOKEN_PATH
@@ -128,6 +141,7 @@ export function getTokensLastRefreshMs(profile) {
128
141
  return fs.statSync(pathToRead).mtimeMs;
129
142
  }
130
143
  catch {
144
+ // 파일이 없으면 갱신 시각도 없다 — auth_status 표시용 부가 정보
131
145
  return null;
132
146
  }
133
147
  }
@@ -154,18 +168,12 @@ export const OAUTH_REDIRECT_URI = `http://localhost:${OAUTH_CALLBACK_PORT}/callb
154
168
  export const OAUTH_CALLBACK_HOSTS = ['127.0.0.1', '::1'];
155
169
  /** ::1 을 못 여는 머신(IPv6 비활성)에서 나는 에러 — 무시하고 127.0.0.1 만 쓴다. */
156
170
  const IPV6_UNAVAILABLE_CODES = new Set(['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EINVAL']);
157
- /** 콜백 포트가 한 루프백 주소에서 점유됐을 때의 안내 (한/영). */
171
+ /** 콜백 포트가 한 루프백 주소에서 점유됐을 때의 안내 (현재 언어). */
158
172
  export function callbackPortInUse(host, err) {
159
173
  const address = host.includes(':') ? `[${host}]:${OAUTH_CALLBACK_PORT}` : `${host}:${OAUTH_CALLBACK_PORT}`;
160
174
  return {
161
175
  code: 'CALLBACK_PORT_IN_USE',
162
- message: `OAuth 콜백 주소 ${address} 를 다른 프로세스가 사용 중입니다. `
163
- + `/ The OAuth callback address ${address} is already in use by another process.`,
164
- hint: `localhost 는 127.0.0.1 과 ::1 어느 쪽으로도 풀릴 수 있어 로그인은 두 주소의 ${OAUTH_CALLBACK_PORT} 포트를 모두 엽니다. `
165
- + `점유 프로세스를 찾아 종료한 뒤 다시 시도하세요 — macOS/Linux: \`lsof -nP -i :${OAUTH_CALLBACK_PORT}\`, `
166
- + `Windows: \`netstat -ano | findstr :${OAUTH_CALLBACK_PORT}\`. 중단된 이전 로그인이면 잠시 후 재시도해도 됩니다. `
167
- + `/ Login listens on port ${OAUTH_CALLBACK_PORT} on both 127.0.0.1 and ::1 because localhost can resolve to either. `
168
- + 'Find and stop the process holding it (commands above), or wait for an abandoned earlier login to time out, then retry.',
176
+ ...authText().callbackAddressInUse(address, OAUTH_CALLBACK_PORT),
169
177
  retriable: true,
170
178
  needsReauth: false,
171
179
  cause: err.message,
@@ -188,7 +196,7 @@ export function getAuthenticatedClient(profile, expectedTokens) {
188
196
  if (expectedTokens && (tokens.refresh_token !== expectedTokens.refresh_token ||
189
197
  tokens.access_token !== expectedTokens.access_token ||
190
198
  tokens.scope !== expectedTokens.scope)) {
191
- throw new Error('요청을 준비하는 동안 Google 인증이 변경됐습니다. 같은 프로필로 다시 시도하세요.');
199
+ throw new Error(M().changed);
192
200
  }
193
201
  const client = createOAuth2Client(creds.clientId, creds.clientSecret);
194
202
  client.setCredentials(tokens);
@@ -321,8 +329,7 @@ export function startAuth(clientId, clientSecret, options = {}) {
321
329
  attempt.status = 'failed';
322
330
  reject(new AuthError({
323
331
  code: 'TOKEN_RESPONSE_INVALID',
324
- message: 'Google 응답에 access_token 또는 refresh_token이 누락되었습니다.',
325
- hint: 'OAuth 동의 화면에서 모든 권한에 동의했는지 확인하세요.',
332
+ ...authText().tokenResponseInvalid,
326
333
  retriable: true,
327
334
  needsReauth: true,
328
335
  cause: JSON.stringify({ has_access: !!tokens.access_token, has_refresh: !!tokens.refresh_token }),
@@ -348,12 +355,13 @@ export function startAuth(clientId, clientSecret, options = {}) {
348
355
  if (attempt.status !== 'pending')
349
356
  throw new Error('Login cancelled or timed out; credentials were not saved.');
350
357
  saveTokens(stored, profile, { clientId, clientSecret });
358
+ const page = authText().callbackPage;
351
359
  res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
352
360
  res.end(`
353
- <html><body style="font-family:system-ui;display:flex;justify-content:center;align-items:center;height:100vh;margin:0">
361
+ <html lang="${page.lang}"><body style="font-family:system-ui;display:flex;justify-content:center;align-items:center;height:100vh;margin:0">
354
362
  <div style="text-align:center">
355
- <h1>✅ Mimi Seed 인증 완료!</h1>
356
- <p>이 창을 닫고 Claude Code 또는 Codex로 돌아가세요.</p>
363
+ <h1>${page.title}</h1>
364
+ <p>${page.body}</p>
357
365
  </div>
358
366
  </body></html>
359
367
  `);
@@ -363,8 +371,10 @@ export function startAuth(clientId, clientSecret, options = {}) {
363
371
  }
364
372
  catch (err) {
365
373
  try {
366
- res.writeHead(500);
367
- res.end(err instanceof Error && err.message.startsWith('YouTube') ? err.message : 'Auth error. Check the MCP/CLI login status.');
374
+ // 사용자가 고칠 수 있는 채널 검증 실패만 그대로 보여주고, 나머지는 일반 문구로 가린다 — 판단은 문구가 아니라
375
+ // 에러 종류로 한다. 메시지에는 채널 제목(사용자 입력)이 들어가므로 text/plain + nosniff 로 HTML 해석을 막는다.
376
+ res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff' });
377
+ res.end(err instanceof YouTubeChannelError ? err.message : 'Auth error. Check the MCP/CLI login status.');
368
378
  }
369
379
  catch { /* noop — already responded */ }
370
380
  try {
@@ -460,12 +470,14 @@ async function ensureFreshAccessTokenOnce(marginMs, profile) {
460
470
  const grant = profile === undefined ? undefined : readProfile(profile);
461
471
  const tokens = profile === undefined ? getStoredTokens() : grant?.tokens;
462
472
  if (!tokens) {
473
+ // "토큰 없음"과 "토큰 파일이 깨짐"은 복구 명령은 같아도(재로그인) 원인은 다르다 — 깨졌으면 그렇다고 말한다.
474
+ const file = googleTokenFilePath(profile);
475
+ const problem = jsonFileProblem(file);
463
476
  return {
464
477
  status: 'unauthenticated',
465
478
  error: {
466
479
  code: 'UNAUTHENTICATED',
467
- message: '저장된 인증 토큰이 없습니다.',
468
- hint: 'mimi-seed-auth 로 로그인하세요.',
480
+ ...(problem ? authText().tokenFileInvalid(file, problem) : authText().unauthenticated),
469
481
  retriable: false,
470
482
  needsReauth: true,
471
483
  },
@@ -482,8 +494,7 @@ async function ensureFreshAccessTokenOnce(marginMs, profile) {
482
494
  tokens,
483
495
  error: {
484
496
  code: 'NO_REFRESH_TOKEN',
485
- message: '저장된 토큰에 refresh_token이 없습니다 (offline_access 미발급).',
486
- hint: 'mimi-seed-auth 로 재로그인하면 prompt=consent로 새 refresh_token이 발급됩니다.',
497
+ ...authText().noRefreshToken,
487
498
  retriable: false,
488
499
  needsReauth: true,
489
500
  },
@@ -577,6 +588,7 @@ export async function resolveAccountEmail(profile) {
577
588
  return email;
578
589
  }
579
590
  catch {
591
+ // 상태 표시용 이메일 조회 — 네트워크·응답 실패는 '모름'으로 두며 인증 자체에는 영향이 없다
580
592
  return null;
581
593
  }
582
594
  }
@@ -8,6 +8,7 @@ export declare function serviceAccountPathForPackage(packageName: string): strin
8
8
  /**
9
9
  * 패키지별 → 레거시(default) 순으로 SA JSON을 로드.
10
10
  * 여러 앱이 다른 GCP 프로젝트의 SA를 쓰는 환경 지원.
11
+ * 패키지별 SA 파일이 있는데 읽을 수 없거나 비었으면 레거시로 넘어가지 않고 throw.
11
12
  */
12
13
  export declare function getServiceAccountJson(packageName?: string): string | null;
13
14
  /**
@@ -5,6 +5,15 @@ import os from 'node:os';
5
5
  import { PLAY_DEVELOPER_REPORTING_SCOPE } from './scopes.js';
6
6
  import { writeCredentialFile } from '#core/atomic-write.js';
7
7
  import { assertAndroidPackageName, isValidAndroidPackageName } from '../lib/package-name.js';
8
+ import { catalog } from '#core/lang.js';
9
+ import { readCredentialFileSync } from '#core/credential-read.js';
10
+ const M = catalog({
11
+ outside: (dir) => `서비스 계정 경로가 ${dir} 밖을 가리킵니다.`,
12
+ unreadable: (file) => `❌ 서비스 계정 키 파일을 읽을 수 없습니다: ${file}\n → 파일을 고치거나 지운 뒤 playstore_register_service_account 로 다시 등록하세요.`,
13
+ }, {
14
+ outside: (dir) => `The service account path points outside ${dir}.`,
15
+ unreadable: (file) => `❌ The service account key file cannot be read: ${file}\n → Fix or delete the file, then register it again with playstore_register_service_account.`,
16
+ });
8
17
  const CONFIG_DIR = path.join(os.homedir(), '.mimi-seed');
9
18
  const SA_DIR = path.join(CONFIG_DIR, 'play-service-accounts');
10
19
  const LEGACY_SA_PATH = path.join(CONFIG_DIR, 'play-service-account.json');
@@ -18,29 +27,34 @@ export function serviceAccountPathForPackage(packageName) {
18
27
  const dir = path.resolve(SA_DIR);
19
28
  const resolved = path.resolve(dir, `${packageName}.json`);
20
29
  if (path.dirname(resolved) !== dir) {
21
- throw new Error(`서비스 계정 경로가 ${dir} 밖을 가리킵니다.`);
30
+ throw new Error(M().outside(dir));
22
31
  }
23
32
  return resolved;
24
33
  }
25
34
  function safeReadFile(p) {
26
35
  try {
27
- return fs.readFileSync(p, 'utf-8');
36
+ return readCredentialFileSync(p);
28
37
  }
29
38
  catch {
39
+ // 못 읽는 파일을 어떻게 다룰지는 호출자가 정한다 — getServiceAccountJson 은 등록된 패키지별 SA 면 throw, 목록은 이메일 '모름'
30
40
  return null;
31
41
  }
32
42
  }
33
43
  /**
34
44
  * 패키지별 → 레거시(default) 순으로 SA JSON을 로드.
35
45
  * 여러 앱이 다른 GCP 프로젝트의 SA를 쓰는 환경 지원.
46
+ * 패키지별 SA 파일이 있는데 읽을 수 없거나 비었으면 레거시로 넘어가지 않고 throw.
36
47
  */
37
48
  export function getServiceAccountJson(packageName) {
38
49
  if (packageName) {
39
50
  const perPkg = serviceAccountPathForPackage(packageName);
40
51
  if (fs.existsSync(perPkg)) {
41
52
  const json = safeReadFile(perPkg);
42
- if (json)
53
+ if (json?.trim())
43
54
  return json;
55
+ // 패키지별 SA 가 등록돼 있는데 못 읽으면 레거시 SA(다른 GCP 프로젝트일 수 있다)로 넘어가지 않는다 —
56
+ // 원격 동기화가 그 키를 이 패키지의 SA 로 보내거나, Play 호출이 엉뚱한 계정으로 나간다.
57
+ throw new Error(M().unreadable(perPkg));
44
58
  }
45
59
  }
46
60
  if (fs.existsSync(LEGACY_SA_PATH)) {
@@ -123,20 +137,26 @@ export function getServiceAccountClient(packageName) {
123
137
  const json = getServiceAccountJson(packageName);
124
138
  if (!json)
125
139
  return null;
140
+ let parsed;
126
141
  try {
127
- const parsed = JSON.parse(json);
128
- return newJWT({
129
- email: parsed.client_email,
130
- key: parsed.private_key,
131
- // androidpublisher(edits/리스팅 등) + Developer Reporting(vitals 통계). 통계 도구가
132
- // Reporting API 를 쓰므로 이 스코프가 없으면 SA 경로에서도 통계만 403 으로 죽는다.
133
- scopes: [
134
- 'https://www.googleapis.com/auth/androidpublisher',
135
- PLAY_DEVELOPER_REPORTING_SCOPE,
136
- ],
137
- });
142
+ parsed = JSON.parse(json);
138
143
  }
139
144
  catch {
140
- return null;
145
+ // 깨진 SA 를 null 로 돌려주면 requirePlayStoreAuth 가 사용자 OAuth 로 조용히 넘어간다 (다른 주체로 호출).
146
+ // cause 는 싣지 않는다 — JSON.parse 메시지는 입력(개인키) 조각을 인용한다.
147
+ const file = packageName && fs.existsSync(serviceAccountPathForPackage(packageName))
148
+ ? serviceAccountPathForPackage(packageName)
149
+ : LEGACY_SA_PATH;
150
+ throw new Error(M().unreadable(file));
141
151
  }
152
+ return newJWT({
153
+ email: parsed.client_email,
154
+ key: parsed.private_key,
155
+ // androidpublisher(edits/리스팅 등) + Developer Reporting(vitals 통계). 통계 도구가
156
+ // Reporting API 를 쓰므로 이 스코프가 없으면 SA 경로에서도 통계만 403 으로 죽는다.
157
+ scopes: [
158
+ 'https://www.googleapis.com/auth/androidpublisher',
159
+ PLAY_DEVELOPER_REPORTING_SCOPE,
160
+ ],
161
+ });
142
162
  }
@@ -1,21 +1,3 @@
1
- /**
2
- * Google OAuth "권한 도메인" → 스코프 매핑의 SSOT.
3
- *
4
- * mimi-seed 는 통합 플랫폼이라 여러 구글 서비스 스코프를 다루는데, 예전엔 로그인 한 번에
5
- * 전부(full-scope)를 강제로 요청했다. OAuth 앱 심사(verification)의 "Requesting Minimum
6
- * Scopes" 요건과 least-privilege 원칙에 맞추기 위해, 사용자가 쓸 도메인만 골라 동의하는
7
- * 선택형(incremental) 인증으로 바꿨다:
8
- *
9
- * - 로그인 시 도메인 서브셋만 요청 가능 (`mimi-seed-auth --domains ga4,googleads`,
10
- * MCP `mimi_seed_auth_start` 의 `domains` 파라미터). 미지정 시 기존과 동일한 전체 요청.
11
- * - `include_granted_scopes=true` 로 요청하므로, 나중에 도메인을 추가해도 기존 부여
12
- * 권한은 유지된 채 새 권한만 얹힌다 (Google incremental authorization).
13
- * - 도구 쪽은 `requireAuth(<scope>)` pre-flight 가 미부여 도메인을 결정적으로 안내한다.
14
- *
15
- * 도메인 경계는 "어느 도구 군이 어느 스코프를 실제 소비하는가" 기준이다. 특히
16
- * cloud-platform 은 IAM API(서비스 계정 생성·키 발급)가 더 좁은 대안 스코프를 제공하지
17
- * 않아서 유지하되, `gcp` 도메인으로 격리해 그 도구를 쓰는 사용자만 요청하게 한다.
18
- */
19
1
  export interface AuthDomainDef {
20
2
  /** 사람이 읽을 라벨 (동의 화면 아님 — CLI/도구 안내용) */
21
3
  label: string;
@@ -27,57 +9,57 @@ export declare const AUTH_DOMAINS: {
27
9
  readonly firebase: {
28
10
  readonly label: "Firebase";
29
11
  readonly scopes: readonly ["https://www.googleapis.com/auth/firebase"];
30
- readonly summary: "firebase_* — 프로젝트/앱/설정 조회·생성 (프로젝트 신규 생성·서비스 활성화는 gcp 도 필요)";
12
+ readonly summary: string;
31
13
  };
32
14
  readonly gcp: {
33
15
  readonly label: "Google Cloud (cloud-platform)";
34
16
  readonly scopes: readonly ["https://www.googleapis.com/auth/cloud-platform"];
35
- readonly summary: "iam_* (서비스 계정·키·IAM 바인딩 — IAM API 는 이 스코프의 좁은 대안이 없음), firebase 프로젝트 생성·서비스 활성화, BigQuery OAuth fallback";
17
+ readonly summary: string;
36
18
  };
37
19
  readonly admob: {
38
20
  readonly label: "AdMob";
39
21
  readonly scopes: readonly ["https://www.googleapis.com/auth/admob.readonly", "https://www.googleapis.com/auth/admob.monetization"];
40
- readonly summary: "admob_* — 수익 리포트, 앱·광고 단위 생성";
22
+ readonly summary: string;
41
23
  };
42
24
  readonly playstore: {
43
25
  readonly label: "Play Store";
44
26
  readonly scopes: readonly ["https://www.googleapis.com/auth/androidpublisher", "https://www.googleapis.com/auth/playdeveloperreporting"];
45
- readonly summary: "playstore_* — OAuth 로 하는 Play Console 작업 + Android vitals 통계";
27
+ readonly summary: string;
46
28
  };
47
29
  readonly googleads: {
48
30
  readonly label: "Google Ads";
49
31
  readonly scopes: readonly ["https://www.googleapis.com/auth/adwords"];
50
- readonly summary: "googleads_* — 캠페인·UAC 리포트";
32
+ readonly summary: string;
51
33
  };
52
34
  readonly gsc: {
53
35
  readonly label: "Search Console";
54
36
  readonly scopes: readonly ["https://www.googleapis.com/auth/webmasters"];
55
- readonly summary: "gsc_* — 사이트·사이트맵·검색 성과 (사이트맵 제출 포함)";
37
+ readonly summary: string;
56
38
  };
57
39
  readonly gsc_readonly: {
58
40
  readonly label: "Search Console (read-only)";
59
41
  readonly scopes: readonly ["https://www.googleapis.com/auth/webmasters.readonly"];
60
- readonly summary: "사이트·사이트맵·URL 색인 상태·검색 성과 조회";
42
+ readonly summary: string;
61
43
  };
62
44
  readonly ga4: {
63
45
  readonly label: "Google Analytics (GA4)";
64
46
  readonly scopes: readonly ["https://www.googleapis.com/auth/analytics.edit", "https://www.googleapis.com/auth/analytics.readonly"];
65
- readonly summary: "ga4_* — property/data stream 생성·조회 + 리포트";
47
+ readonly summary: string;
66
48
  };
67
49
  readonly youtube: {
68
50
  readonly label: "YouTube";
69
51
  readonly scopes: readonly ["https://www.googleapis.com/auth/youtube.force-ssl"];
70
- readonly summary: "youtube_* — 영상 업로드·처리 상태 조회·공개 상태 변경";
52
+ readonly summary: string;
71
53
  };
72
54
  readonly youtube_analytics: {
73
55
  readonly label: "YouTube Analytics (read-only)";
74
56
  readonly scopes: readonly ["https://www.googleapis.com/auth/youtube.readonly", "https://www.googleapis.com/auth/yt-analytics.readonly"];
75
- readonly summary: "youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — 채널·영상·성과 읽기";
57
+ readonly summary: string;
76
58
  };
77
59
  readonly drive: {
78
60
  readonly label: "Google Drive (drive.file)";
79
61
  readonly scopes: readonly ["https://www.googleapis.com/auth/drive.file"];
80
- readonly summary: "drive_* — mimi-seed 가 만든 파일·폴더 업로드·갱신·정리 (기존 폴더·공유 드라이브는 Drive 서비스 계정)";
62
+ readonly summary: string;
81
63
  };
82
64
  };
83
65
  export type AuthDomainId = keyof typeof AUTH_DOMAINS;
@@ -1,3 +1,4 @@
1
+ import { catalog } from '#core/lang.js';
1
2
  /**
2
3
  * Google OAuth "권한 도메인" → 스코프 매핑의 SSOT.
3
4
  *
@@ -16,16 +17,42 @@
16
17
  * cloud-platform 은 IAM API(서비스 계정 생성·키 발급)가 더 좁은 대안 스코프를 제공하지
17
18
  * 않아서 유지하되, `gcp` 도메인으로 격리해 그 도구를 쓰는 사용자만 요청하게 한다.
18
19
  */
20
+ /** 도메인 요약 — 사람이 읽는 안내 문구라 언어를 따른다 (AUTH_DOMAINS[id].summary 가 호출 시점에 고른다). */
21
+ const SUMMARY = catalog({
22
+ firebase: 'firebase_* — 프로젝트/앱/설정 조회·생성 (프로젝트 신규 생성·서비스 활성화는 gcp 도 필요)',
23
+ gcp: 'iam_* (서비스 계정·키·IAM 바인딩 — IAM API 는 이 스코프의 좁은 대안이 없음), firebase 프로젝트 생성·서비스 활성화, BigQuery OAuth fallback',
24
+ admob: 'admob_* — 수익 리포트, 앱·광고 단위 생성',
25
+ playstore: 'playstore_* — OAuth 로 하는 Play Console 작업 + Android vitals 통계',
26
+ googleads: 'googleads_* — 캠페인·UAC 리포트',
27
+ gsc: 'gsc_* — 사이트·사이트맵·검색 성과 (사이트맵 제출 포함)',
28
+ gsc_readonly: '사이트·사이트맵·URL 색인 상태·검색 성과 조회',
29
+ ga4: 'ga4_* — property/data stream 생성·조회 + 리포트',
30
+ youtube: 'youtube_* — 영상 업로드·처리 상태 조회·공개 상태 변경',
31
+ youtube_analytics: 'youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — 채널·영상·성과 읽기',
32
+ drive: 'drive_* — mimi-seed 가 만든 파일·폴더 업로드·갱신·정리 (기존 폴더·공유 드라이브는 Drive 서비스 계정)',
33
+ }, {
34
+ firebase: 'firebase_* — read/create projects/apps/config (creating a new project and enabling services also need gcp)',
35
+ gcp: 'iam_* (service accounts, keys, IAM bindings — the IAM API has no narrower alternative to this scope), firebase project creation and service enablement, BigQuery OAuth fallback',
36
+ admob: 'admob_* — earnings reports, create apps and ad units',
37
+ playstore: 'playstore_* — Play Console work over OAuth + Android vitals statistics',
38
+ googleads: 'googleads_* — campaign and UAC reports',
39
+ gsc: 'gsc_* — sites, sitemaps, search performance (including sitemap submission)',
40
+ gsc_readonly: 'Read sites, sitemaps, URL index status, and search performance',
41
+ ga4: 'ga4_* — create/read properties and data streams + reports',
42
+ youtube: 'youtube_* — video upload, processing status, privacy status changes',
43
+ youtube_analytics: 'youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — read channel, videos, and performance',
44
+ drive: 'drive_* — upload, update, and clean up files and folders mimi-seed created (existing folders and shared drives use the Drive service account)',
45
+ });
19
46
  export const AUTH_DOMAINS = {
20
47
  firebase: {
21
48
  label: 'Firebase',
22
49
  scopes: ['https://www.googleapis.com/auth/firebase'],
23
- summary: 'firebase_* — 프로젝트/앱/설정 조회·생성 (프로젝트 신규 생성·서비스 활성화는 gcp 도 필요)',
50
+ get summary() { return SUMMARY().firebase; },
24
51
  },
25
52
  gcp: {
26
53
  label: 'Google Cloud (cloud-platform)',
27
54
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
28
- summary: 'iam_* (서비스 계정·키·IAM 바인딩 — IAM API 는 이 스코프의 좁은 대안이 없음), firebase 프로젝트 생성·서비스 활성화, BigQuery OAuth fallback',
55
+ get summary() { return SUMMARY().gcp; },
29
56
  },
30
57
  admob: {
31
58
  label: 'AdMob',
@@ -33,7 +60,7 @@ export const AUTH_DOMAINS = {
33
60
  'https://www.googleapis.com/auth/admob.readonly',
34
61
  'https://www.googleapis.com/auth/admob.monetization',
35
62
  ],
36
- summary: 'admob_* — 수익 리포트, 앱·광고 단위 생성',
63
+ get summary() { return SUMMARY().admob; },
37
64
  },
38
65
  playstore: {
39
66
  label: 'Play Store',
@@ -44,22 +71,22 @@ export const AUTH_DOMAINS = {
44
71
  // 403(ACCESS_TOKEN_SCOPE_INSUFFICIENT)으로 죽고, 다른 Play 도구는 멀쩡해 원인 추적이 어렵다.
45
72
  'https://www.googleapis.com/auth/playdeveloperreporting',
46
73
  ],
47
- summary: 'playstore_* — OAuth 로 하는 Play Console 작업 + Android vitals 통계',
74
+ get summary() { return SUMMARY().playstore; },
48
75
  },
49
76
  googleads: {
50
77
  label: 'Google Ads',
51
78
  scopes: ['https://www.googleapis.com/auth/adwords'],
52
- summary: 'googleads_* — 캠페인·UAC 리포트',
79
+ get summary() { return SUMMARY().googleads; },
53
80
  },
54
81
  gsc: {
55
82
  label: 'Search Console',
56
83
  scopes: ['https://www.googleapis.com/auth/webmasters'],
57
- summary: 'gsc_* — 사이트·사이트맵·검색 성과 (사이트맵 제출 포함)',
84
+ get summary() { return SUMMARY().gsc; },
58
85
  },
59
86
  gsc_readonly: {
60
87
  label: 'Search Console (read-only)',
61
88
  scopes: ['https://www.googleapis.com/auth/webmasters.readonly'],
62
- summary: '사이트·사이트맵·URL 색인 상태·검색 성과 조회',
89
+ get summary() { return SUMMARY().gsc_readonly; },
63
90
  },
64
91
  ga4: {
65
92
  label: 'Google Analytics (GA4)',
@@ -70,12 +97,12 @@ export const AUTH_DOMAINS = {
70
97
  // (ga4/tools.ts 의 GA4_DATA_SCOPE 주석, 2026-07 실사고 참고.)
71
98
  'https://www.googleapis.com/auth/analytics.readonly',
72
99
  ],
73
- summary: 'ga4_* — property/data stream 생성·조회 + 리포트',
100
+ get summary() { return SUMMARY().ga4; },
74
101
  },
75
102
  youtube: {
76
103
  label: 'YouTube',
77
104
  scopes: ['https://www.googleapis.com/auth/youtube.force-ssl'],
78
- summary: 'youtube_* — 영상 업로드·처리 상태 조회·공개 상태 변경',
105
+ get summary() { return SUMMARY().youtube; },
79
106
  },
80
107
  youtube_analytics: {
81
108
  label: 'YouTube Analytics (read-only)',
@@ -83,7 +110,7 @@ export const AUTH_DOMAINS = {
83
110
  'https://www.googleapis.com/auth/youtube.readonly',
84
111
  'https://www.googleapis.com/auth/yt-analytics.readonly',
85
112
  ],
86
- summary: 'youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — 채널·영상·성과 읽기',
113
+ get summary() { return SUMMARY().youtube_analytics; },
87
114
  },
88
115
  drive: {
89
116
  label: 'Google Drive (drive.file)',
@@ -91,7 +118,7 @@ export const AUTH_DOMAINS = {
91
118
  // 기존 폴더·공유 드라이브 전체를 다루려면 Drive 서비스 계정(mimi-seed-drive-auth)을 쓴다.
92
119
  // 전체 drive 스코프는 제한(restricted) 스코프라 OAuth 앱 보안 심사가 필요해 여기 넣지 않는다.
93
120
  scopes: ['https://www.googleapis.com/auth/drive.file'],
94
- summary: 'drive_* — mimi-seed 가 만든 파일·폴더 업로드·갱신·정리 (기존 폴더·공유 드라이브는 Drive 서비스 계정)',
121
+ get summary() { return SUMMARY().drive; },
95
122
  },
96
123
  };
97
124
  /** z.enum 등 튜플이 필요한 자리에 쓰는 도메인 id 목록 (선언 순서 유지). */
@@ -1,5 +1,13 @@
1
1
  import type { OAuth2Client } from 'google-auth-library';
2
2
  export declare const YOUTUBE_CHANNEL_ID: RegExp;
3
+ /**
4
+ * 채널 검증 실패 — 사용자가 직접 고칠 수 있는 원인(잘못된 채널 ID · 채널이 여럿/없음 · 다른 채널로 로그인)이다.
5
+ * OAuth 콜백 페이지는 이 클래스일 때만 메시지를 보여주고, 나머지 오류는 일반 문구로 가린다.
6
+ * 예전엔 `message.startsWith('YouTube')` 로 골랐다 — 문구를 바꾸면 보여줄 오류가 숨거나 내부 오류가 드러난다.
7
+ */
8
+ export declare class YouTubeChannelError extends Error {
9
+ name: string;
10
+ }
3
11
  /** A channel ID is a guard, not a videos.insert routing parameter. Google selects
4
12
  * the personal/Brand channel during OAuth; ambiguous or mismatched grants fail closed. */
5
13
  export declare function verifyYouTubeChannel(auth: OAuth2Client, expectedChannelId?: string): Promise<{
@@ -1,11 +1,19 @@
1
1
  import { google } from '../lib/googleapis-lite.js';
2
2
  import { friendlyGoogleError } from '../lib/google-errors.js';
3
3
  export const YOUTUBE_CHANNEL_ID = /^UC[\w-]{22}$/;
4
+ /**
5
+ * 채널 검증 실패 — 사용자가 직접 고칠 수 있는 원인(잘못된 채널 ID · 채널이 여럿/없음 · 다른 채널로 로그인)이다.
6
+ * OAuth 콜백 페이지는 이 클래스일 때만 메시지를 보여주고, 나머지 오류는 일반 문구로 가린다.
7
+ * 예전엔 `message.startsWith('YouTube')` 로 골랐다 — 문구를 바꾸면 보여줄 오류가 숨거나 내부 오류가 드러난다.
8
+ */
9
+ export class YouTubeChannelError extends Error {
10
+ name = 'YouTubeChannelError';
11
+ }
4
12
  /** A channel ID is a guard, not a videos.insert routing parameter. Google selects
5
13
  * the personal/Brand channel during OAuth; ambiguous or mismatched grants fail closed. */
6
14
  export async function verifyYouTubeChannel(auth, expectedChannelId) {
7
15
  if (expectedChannelId !== undefined && !YOUTUBE_CHANNEL_ID.test(expectedChannelId)) {
8
- throw new Error('Invalid YouTube channel ID (expected UC + 22 characters).');
16
+ throw new YouTubeChannelError('Invalid YouTube channel ID (expected UC + 22 characters).');
9
17
  }
10
18
  let response;
11
19
  try {
@@ -16,11 +24,11 @@ export async function verifyYouTubeChannel(auth, expectedChannelId) {
16
24
  }
17
25
  const channels = response.data.items ?? [];
18
26
  if (channels.length !== 1 || !channels[0].id || response.data.nextPageToken) {
19
- throw new Error('YouTube login must resolve to exactly one channel. Sign in again and select the intended personal/Brand channel.');
27
+ throw new YouTubeChannelError('YouTube login must resolve to exactly one channel. Sign in again and select the intended personal/Brand channel.');
20
28
  }
21
29
  const channel = { id: channels[0].id, title: channels[0].snippet?.title ?? '' };
22
30
  if (expectedChannelId && channel.id !== expectedChannelId) {
23
- throw new Error(`YouTube channel mismatch: expected ${expectedChannelId}, authenticated ${channel.id} (${channel.title}). Sign in again with the intended channel. Nothing was uploaded.`);
31
+ throw new YouTubeChannelError(`YouTube channel mismatch: expected ${expectedChannelId}, authenticated ${channel.id} (${channel.title}). Sign in again with the intended channel. Nothing was uploaded.`);
24
32
  }
25
33
  return channel;
26
34
  }
@@ -1,3 +1,17 @@
1
+ import { catalog } from '#core/lang.js';
2
+ const M = catalog({
3
+ invalid: (label, v) => `BigQuery ${label} 형식이 올바르지 않습니다: ${v}`,
4
+ project: '프로젝트 ID',
5
+ dataset: '데이터셋 ID',
6
+ table: '테이블 ID',
7
+ job: '작업 ID',
8
+ }, {
9
+ invalid: (label, v) => `Invalid BigQuery ${label} format: ${v}`,
10
+ project: 'project ID',
11
+ dataset: 'dataset ID',
12
+ table: 'table ID',
13
+ job: 'job ID',
14
+ });
1
15
  // BigQuery 식별자 검증.
2
16
  //
3
17
  // googleapis 의 BigQuery v2 는 projectId/datasetId/tableId/jobId 를 **예약 확장**(`{+tableId}`)으로
@@ -20,11 +34,11 @@ const TABLE_ID = /^[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}$]+$/u;
20
34
  const JOB_ID = /^[A-Za-z0-9_-]+$/;
21
35
  function check(value, pattern, label) {
22
36
  if (typeof value !== 'string' || value.length === 0 || value.length > MAX_ID_LENGTH || !pattern.test(value)) {
23
- throw new Error(`BigQuery ${label} 형식이 올바르지 않습니다: ${JSON.stringify(String(value).slice(0, 80))}`);
37
+ throw new Error(M().invalid(M()[label], JSON.stringify(String(value).slice(0, 80))));
24
38
  }
25
39
  return value;
26
40
  }
27
- export const bqProjectId = (v) => check(v, PROJECT_ID, '프로젝트 ID');
28
- export const bqDatasetId = (v) => check(v, DATASET_ID, '데이터셋 ID');
29
- export const bqTableId = (v) => check(v, TABLE_ID, '테이블 ID');
30
- export const bqJobId = (v) => check(v, JOB_ID, '작업 ID');
41
+ export const bqProjectId = (v) => check(v, PROJECT_ID, 'project');
42
+ export const bqDatasetId = (v) => check(v, DATASET_ID, 'dataset');
43
+ export const bqTableId = (v) => check(v, TABLE_ID, 'table');
44
+ export const bqJobId = (v) => check(v, JOB_ID, 'job');