@yoonion/mimi-seed-mcp 0.19.4 → 0.19.6

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.
@@ -5,7 +5,7 @@ export interface AppStoreCredentials {
5
5
  /**
6
6
  * Sales and Trends / Finance 리포트 전용 판매자 번호.
7
7
  *
8
- * **API 로는 조회할 수 없다** — ASC > 지급 및 재무 보고서 화면에서 눈으로 읽어
8
+ * **API 로는 조회할 수 없다** — ASC > Reports 화면의 Legal Entity Name 아래에서 눈으로 읽어
9
9
  * 여기 적어두는 수밖에 없다. 리포트 도구에만 쓰이므로 없어도 나머지는 다 동작한다.
10
10
  */
11
11
  vendorNumber?: string;
@@ -31,6 +31,16 @@ export interface AppStoreKey {
31
31
  keyId: string;
32
32
  privateKey: string;
33
33
  }
34
+ /** 빈 입력은 미설정으로 처리하고, 값이 있으면 Apple 보고서 필터에 안전한 숫자인지 확인한다. */
35
+ export declare function normalizeVendorNumber(vendorNumber?: string): string | undefined;
36
+ /**
37
+ * 최상위 ASC API 키를 교체하되 같은 파일에 저장된 선택 설정은 보존한다.
38
+ *
39
+ * 재인증은 primary key 교체이지 appstore.json 전체 초기화가 아니다. 특히
40
+ * vendorNumber 와 reportsKey 는 별도 화면/키에서 얻는 값이라 다시 묻지 않고
41
+ * 지우면 매출·분석 기능이 조용히 망가진다.
42
+ */
43
+ export declare function mergeAppStoreCredentials(existing: AppStoreCredentials | null, primary: AppStoreKey, vendorNumber?: string): AppStoreCredentials;
34
44
  export declare function getAppStoreCredentials(): AppStoreCredentials | null;
35
45
  export declare function saveAppStoreCredentials(creds: AppStoreCredentials): void;
36
46
  export declare function generateToken(creds: AppStoreCredentials): Promise<string>;
@@ -10,6 +10,30 @@ import { writeCredentialJson } from '../lib/atomic-write.js';
10
10
  // force a re-setup.
11
11
  const CONFIG_PATH = path.join(os.homedir(), '.mimi-seed', 'appstore.json');
12
12
  const LEGACY_CONFIG_PATH = path.join(os.homedir(), '.preseed', 'appstore.json');
13
+ /** 빈 입력은 미설정으로 처리하고, 값이 있으면 Apple 보고서 필터에 안전한 숫자인지 확인한다. */
14
+ export function normalizeVendorNumber(vendorNumber) {
15
+ const normalized = vendorNumber?.trim();
16
+ if (!normalized)
17
+ return undefined;
18
+ if (!/^\d+$/.test(normalized)) {
19
+ throw new Error('Vendor Number는 숫자만 입력하세요 (digits only).');
20
+ }
21
+ return normalized;
22
+ }
23
+ /**
24
+ * 최상위 ASC API 키를 교체하되 같은 파일에 저장된 선택 설정은 보존한다.
25
+ *
26
+ * 재인증은 primary key 교체이지 appstore.json 전체 초기화가 아니다. 특히
27
+ * vendorNumber 와 reportsKey 는 별도 화면/키에서 얻는 값이라 다시 묻지 않고
28
+ * 지우면 매출·분석 기능이 조용히 망가진다.
29
+ */
30
+ export function mergeAppStoreCredentials(existing, primary, vendorNumber) {
31
+ const merged = { ...(existing ?? {}), ...primary };
32
+ const normalizedVendorNumber = normalizeVendorNumber(vendorNumber);
33
+ if (normalizedVendorNumber)
34
+ merged.vendorNumber = normalizedVendorNumber;
35
+ return merged;
36
+ }
13
37
  export function getAppStoreCredentials() {
14
38
  const pathToRead = fs.existsSync(CONFIG_PATH)
15
39
  ? CONFIG_PATH
@@ -9,7 +9,7 @@
9
9
  // sandbox 가 들어오지 않는 창구를 봐야 하고, 그게 이 리포트다.
10
10
  import zlib from 'node:zlib';
11
11
  import { fetchWithTimeout } from '../lib/http.js';
12
- import { getAppStoreCredentials, getReportsAuthHeaders } from './auth.js';
12
+ import { getAppStoreCredentials, getReportsAuthHeaders, normalizeVendorNumber } from './auth.js';
13
13
  import { friendlyAppStoreError } from './errors.js';
14
14
  import { V1_BASE } from './http.js';
15
15
  /**
@@ -20,12 +20,13 @@ import { V1_BASE } from './http.js';
20
20
  * 매출 0 으로 둔갑하는 게 이 도구에서 제일 위험한 오답이라 사전에 막는다.
21
21
  */
22
22
  function resolveVendorNumber(explicit) {
23
- const vendorNumber = explicit?.trim() || getAppStoreCredentials()?.vendorNumber?.trim();
23
+ const vendorNumber = normalizeVendorNumber(explicit)
24
+ ?? normalizeVendorNumber(getAppStoreCredentials()?.vendorNumber);
24
25
  if (!vendorNumber) {
25
26
  throw new Error([
26
27
  '❌ vendorNumber 가 없어 — 매출 리포트는 판매자 번호가 반드시 필요해.',
27
28
  '',
28
- 'App Store Connect > 비즈니스(지급 및 재무 보고서) 상단에 있는 8~9자리 숫자야.',
29
+ 'App Store Connect > Reports > 왼쪽 위 Legal Entity Name 아래에 있는 숫자야.',
29
30
  'API 로는 조회할 수 없으니 한 번만 저장해 두면 이후 생략할 수 있어:',
30
31
  ' ~/.mimi-seed/appstore.json 에 "vendorNumber": "<번호>" 추가',
31
32
  '또는 이 도구의 vendorNumber 인자로 직접 넘겨.',
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { saveAppStoreCredentials, getAppStoreCredentials } from './auth.js';
2
+ import { getAppStoreCredentials, mergeAppStoreCredentials } from './auth.js';
3
+ import { collectExistingSetupIntent, verifyAndSaveAppStoreCredentials } from './setup.js';
3
4
  import readline from 'node:readline';
4
5
  import fs from 'node:fs';
5
6
  import { resolveLang } from '../lib/lang.js';
6
7
  // ko 가 원본이고 en 은 `typeof ko` 를 만족해야 한다 — 키를 빠뜨리면 컴파일이 깨진다.
7
8
  const ko = {
8
9
  title: ' 🍎 Mimi Seed — App Store Connect 연결',
9
- already: (keyId) => ` ✅ 이미 연결됨 (Key ID: ${keyId})`,
10
- reconnect: ' 다시 설정할래? (y/N): ',
10
+ already: (keyId) => ` ✅ 설정 파일 있음 (Key ID: ${keyId}) — API 권한은 다시 검증합니다`,
11
+ reconnect: ' API Key를 다시 설정할래? (y/N, v=Vendor Number만): ',
11
12
  needTitle: ' App Store Connect에서 API Key를 만들어야 해:',
12
13
  step1: ' 1. "키 생성" 클릭',
13
14
  step2: ' 2. 이름: Mimi Seed, 역할: Admin',
@@ -15,16 +16,20 @@ const ko = {
15
16
  askIssuerId: ' Issuer ID: ',
16
17
  askKeyId: ' Key ID: ',
17
18
  askP8Path: ' .p8 파일 경로: ',
19
+ askVendorNumber: ' Vendor Number (선택, Enter로 기존 값 유지): ',
18
20
  noFile: (p) => ` ❌ 파일 없음: ${p}`,
19
- done: ' ✅ 연결 완료!',
21
+ verifying: ' Apple API로 자격증명을 검증하는 중...',
22
+ verifyFailed: (stage, message) => ` ❌ 검증 실패 (${stage}) — 저장하지 않았습니다.\n${message}`,
23
+ done: ' ✅ 연결 완료! (App Store API 검증 성공)',
24
+ vendorDone: ' ✅ Vendor Number 저장 완료! (기존 App Store API 키 검증 성공)',
20
25
  nextTitle: ' 이제 Claude Code 또는 Codex에서:',
21
26
  nextExample1: ' "내 앱스토어 앱 목록 보여줘"',
22
27
  nextExample2: ' "TestFlight 빌드 목록 보여줘"',
23
28
  };
24
29
  const en = {
25
30
  title: ' 🍎 Mimi Seed — Connect App Store Connect',
26
- already: (keyId) => ` ✅ Already connected (Key ID: ${keyId})`,
27
- reconnect: ' Set it up again? (y/N): ',
31
+ already: (keyId) => ` ✅ Configuration found (Key ID: ${keyId}) — API access will be verified again`,
32
+ reconnect: ' Replace the API Key? (y/N, v=Vendor Number only): ',
28
33
  needTitle: ' You need to create an API Key in App Store Connect:',
29
34
  step1: ' 1. Click "Generate API Key"',
30
35
  step2: ' 2. Name: Mimi Seed, Access: Admin',
@@ -32,8 +37,12 @@ const en = {
32
37
  askIssuerId: ' Issuer ID: ',
33
38
  askKeyId: ' Key ID: ',
34
39
  askP8Path: ' Path to the .p8 file: ',
40
+ askVendorNumber: ' Vendor Number (optional, Enter keeps the saved value): ',
35
41
  noFile: (p) => ` ❌ File not found: ${p}`,
36
- done: ' ✅ Connected!',
42
+ verifying: ' Verifying the credentials with the Apple API...',
43
+ verifyFailed: (stage, message) => ` ❌ Verification failed (${stage}) — nothing was saved.\n${message}`,
44
+ done: ' ✅ Connected! (App Store API verification passed)',
45
+ vendorDone: ' ✅ Vendor Number saved! (existing App Store API key verification passed)',
37
46
  nextTitle: ' Now, in Claude Code or Codex:',
38
47
  nextExample1: ' "Show my App Store apps"',
39
48
  nextExample2: ' "List the TestFlight builds"',
@@ -41,15 +50,34 @@ const en = {
41
50
  const M = resolveLang() === 'en' ? en : ko;
42
51
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
43
52
  const ask = (q) => new Promise((r) => rl.question(q, r));
53
+ async function saveIfVerified(credentials) {
54
+ console.log(M.verifying);
55
+ const verification = await verifyAndSaveAppStoreCredentials(credentials);
56
+ if (verification.ok)
57
+ return true;
58
+ console.log(M.verifyFailed(verification.stage, verification.message));
59
+ process.exitCode = 1;
60
+ return false;
61
+ }
44
62
  async function main() {
45
63
  console.log('');
46
64
  console.log(M.title);
47
65
  console.log('');
48
66
  const existing = getAppStoreCredentials();
67
+ let vendorNumber;
49
68
  if (existing) {
50
69
  console.log(M.already(existing.keyId));
51
- const answer = await ask(M.reconnect);
52
- if (answer.toLowerCase() !== 'y') {
70
+ const intent = await collectExistingSetupIntent(ask, {
71
+ reconnect: M.reconnect,
72
+ vendorNumber: M.askVendorNumber,
73
+ });
74
+ if (!intent.replacePrimaryKey) {
75
+ vendorNumber = intent.vendorNumber;
76
+ if (vendorNumber.trim()) {
77
+ const credentials = mergeAppStoreCredentials(existing, existing, vendorNumber);
78
+ if (await saveIfVerified(credentials))
79
+ console.log(M.vendorDone);
80
+ }
53
81
  rl.close();
54
82
  return;
55
83
  }
@@ -64,6 +92,7 @@ async function main() {
64
92
  const issuerId = await ask(M.askIssuerId);
65
93
  const keyId = await ask(M.askKeyId);
66
94
  const p8Path = await ask(M.askP8Path);
95
+ vendorNumber = await ask(M.askVendorNumber);
67
96
  const trimmedPath = p8Path.trim().replace(/^["']|["']$/g, '');
68
97
  if (!fs.existsSync(trimmedPath)) {
69
98
  console.log(M.noFile(trimmedPath));
@@ -71,11 +100,11 @@ async function main() {
71
100
  process.exit(1);
72
101
  }
73
102
  const privateKey = fs.readFileSync(trimmedPath, 'utf-8');
74
- saveAppStoreCredentials({
75
- issuerId: issuerId.trim(),
76
- keyId: keyId.trim(),
77
- privateKey,
78
- });
103
+ const credentials = mergeAppStoreCredentials(existing, { issuerId: issuerId.trim(), keyId: keyId.trim(), privateKey }, vendorNumber);
104
+ if (!(await saveIfVerified(credentials))) {
105
+ rl.close();
106
+ return;
107
+ }
79
108
  console.log('');
80
109
  console.log(M.done);
81
110
  console.log('');
@@ -0,0 +1,18 @@
1
+ import { type AppStoreCredentials } from './auth.js';
2
+ import { type AppStoreVerifyResult } from './tools.js';
3
+ interface SetupDependencies {
4
+ verify: (credentials: AppStoreCredentials) => Promise<AppStoreVerifyResult>;
5
+ save: (credentials: AppStoreCredentials) => void;
6
+ }
7
+ export interface ExistingSetupIntent {
8
+ replacePrimaryKey: boolean;
9
+ vendorNumber: string;
10
+ }
11
+ /** 기존 사용자의 익숙한 첫 질문(API Key 재설정)을 바꾸지 않는 대화 순서 계약. */
12
+ export declare function collectExistingSetupIntent(ask: (question: string) => Promise<string>, prompts: {
13
+ reconnect: string;
14
+ vendorNumber: string;
15
+ }): Promise<ExistingSetupIntent>;
16
+ /** Apple API에서 실제로 쓸 수 있는 키인지 확인한 뒤에만 디스크에 저장한다. */
17
+ export declare function verifyAndSaveAppStoreCredentials(credentials: AppStoreCredentials, dependencies?: SetupDependencies): Promise<AppStoreVerifyResult>;
18
+ export {};
@@ -0,0 +1,28 @@
1
+ import { saveAppStoreCredentials, } from './auth.js';
2
+ import { verifyAppStoreCredentials, } from './tools.js';
3
+ const defaultDependencies = {
4
+ verify: verifyAppStoreCredentials,
5
+ save: saveAppStoreCredentials,
6
+ };
7
+ /** 기존 사용자의 익숙한 첫 질문(API Key 재설정)을 바꾸지 않는 대화 순서 계약. */
8
+ export async function collectExistingSetupIntent(ask, prompts) {
9
+ const reconnect = await ask(prompts.reconnect);
10
+ const action = reconnect.trim().toLowerCase();
11
+ if (action === 'y') {
12
+ return { replacePrimaryKey: true, vendorNumber: '' };
13
+ }
14
+ if (action !== 'v') {
15
+ return { replacePrimaryKey: false, vendorNumber: '' };
16
+ }
17
+ return {
18
+ replacePrimaryKey: false,
19
+ vendorNumber: await ask(prompts.vendorNumber),
20
+ };
21
+ }
22
+ /** Apple API에서 실제로 쓸 수 있는 키인지 확인한 뒤에만 디스크에 저장한다. */
23
+ export async function verifyAndSaveAppStoreCredentials(credentials, dependencies = defaultDependencies) {
24
+ const result = await dependencies.verify(credentials);
25
+ if (result.ok)
26
+ dependencies.save(credentials);
27
+ return result;
28
+ }
@@ -17,7 +17,7 @@ export interface AppStoreVerifyResult {
17
17
  * 파일 존재만 보는 requireAppStoreCreds 와 달리, 잘못된 .p8/keyId/issuerId 를
18
18
  * "첫 호출 401" 로 늦게 터지기 전에 setup 단계에서 잡아준다.
19
19
  */
20
- export declare function verifyAppStoreCredentials(): Promise<AppStoreVerifyResult>;
20
+ export declare function verifyAppStoreCredentials(creds?: import("./auth.js").AppStoreCredentials | null): Promise<AppStoreVerifyResult>;
21
21
  export declare function listApps(): Promise<any>;
22
22
  export declare function getApp(appId: string): Promise<any>;
23
23
  export declare function listVersions(appId: string): Promise<any>;
@@ -36,8 +36,7 @@ export async function apiGet(path, params) {
36
36
  * 파일 존재만 보는 requireAppStoreCreds 와 달리, 잘못된 .p8/keyId/issuerId 를
37
37
  * "첫 호출 401" 로 늦게 터지기 전에 setup 단계에서 잡아준다.
38
38
  */
39
- export async function verifyAppStoreCredentials() {
40
- const creds = getAppStoreCredentials();
39
+ export async function verifyAppStoreCredentials(creds = getAppStoreCredentials()) {
41
40
  if (!creds) {
42
41
  return {
43
42
  ok: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoonion/mimi-seed-mcp",
3
- "version": "0.19.4",
3
+ "version": "0.19.6",
4
4
  "description": "Mimi Seed MCP server \u2014 Firebase + AdMob + Google Play + App Store management for Claude Code / Codex / Cursor / any MCP client.",
5
5
  "type": "module",
6
6
  "bin": {