@yoonion/mimi-seed-mcp 0.25.3 → 0.25.5
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.
- package/README.md +2 -1
- package/assets/agent-guide.md +37 -9
- package/dist/auth/cli.js +2 -2
- package/dist/auth/constants.js +4 -3
- package/dist/auth/errors.js +4 -1
- package/dist/auth/google-auth.d.ts +14 -0
- package/dist/auth/google-auth.js +19 -1
- package/dist/core/console-url.d.ts +17 -2
- package/dist/core/console-url.js +54 -16
- package/dist/core/credential-store.js +2 -0
- package/dist/crosspost/ledger.d.ts +52 -0
- package/dist/crosspost/ledger.js +269 -0
- package/dist/crosspost/tools.d.ts +136 -0
- package/dist/crosspost/tools.js +821 -0
- package/dist/drive/tools.d.ts +0 -1
- package/dist/drive/tools.js +19 -1
- package/dist/facebook/api.d.ts +3 -2
- package/dist/facebook/api.js +6 -2
- package/dist/i18n/manifest-en.js +3 -0
- package/dist/i18n/tools-en/android.d.ts +2 -2
- package/dist/i18n/tools-en/android.js +2 -2
- package/dist/i18n/tools-en/crosspost.d.ts +23 -0
- package/dist/i18n/tools-en/crosspost.js +22 -0
- package/dist/i18n/tools-en/index.js +2 -0
- package/dist/i18n/tools-en/jenkins.d.ts +4 -4
- package/dist/i18n/tools-en/jenkins.js +4 -4
- package/dist/instagram/api.d.ts +3 -2
- package/dist/instagram/api.js +6 -2
- package/dist/instagram/browser-login.js +2 -5
- package/dist/jenkins/credentials.d.ts +7 -3
- package/dist/jenkins/credentials.js +4 -0
- package/dist/jenkins/messages.d.ts +2 -0
- package/dist/jenkins/messages.js +15 -0
- package/dist/lib/human-approval.d.ts +1 -1
- package/dist/lib/human-approval.js +4 -3
- package/dist/lib/meta-auth.d.ts +9 -0
- package/dist/lib/meta-auth.js +12 -3
- package/dist/lib/tool-menu.js +2 -1
- package/dist/lib/tool-registrar.js +13 -5
- package/dist/registers/android.js +10 -7
- package/dist/registers/auth.js +11 -5
- package/dist/registers/crosspost.d.ts +2 -0
- package/dist/registers/crosspost.js +81 -0
- package/dist/registers/jenkins.js +20 -8
- package/dist/remote-sync.js +8 -4
- package/dist/server.js +2 -0
- package/dist/social/broker-base.d.ts +7 -0
- package/dist/social/broker-base.js +11 -0
- package/dist/social/meta-app-config.d.ts +19 -0
- package/dist/social/meta-app-config.js +83 -0
- package/dist/social/meta-direct-login.d.ts +45 -0
- package/dist/social/meta-direct-login.js +307 -0
- package/dist/social/setup-cli.js +228 -20
- package/dist/threads/api.d.ts +4 -3
- package/dist/threads/api.js +9 -7
- package/dist/threads/browser-login.js +2 -5
- package/dist/tiktok-business/posting.d.ts +11 -1
- package/dist/tiktok-business/posting.js +18 -1
- package/dist/video/youtube-publish.d.ts +41 -1
- package/dist/video/youtube-publish.js +16 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/tool-manifest.json +28 -8
|
@@ -97,7 +97,9 @@ export function effectiveHints(annotations) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
// ── confirm guard ──────────────────────────────────────────────────────────
|
|
100
|
-
|
|
100
|
+
// 키 이름으로 비밀을 가린다 (값은 모른다). `API_KEY`·`SIGNING_KEY`·`STORE_PASS`·`pwd` 같은 흔한 CI 파라미터 이름도 포함 —
|
|
101
|
+
// 빠져 있던 시절엔 ci_trigger_build 의 inputs 가 승인 대화상자에 그대로 보였다. `keystore_path` 같은 경로 이름은 걸리지 않는다.
|
|
102
|
+
const SECRET_KEY = /secret|token|passw(or)?d|passphrase|(^|_)pass$|pwd|private|base64|credential_json|serviceAccountJson|api_?key|signing_?key|access_?key|client_?key/i;
|
|
101
103
|
/**
|
|
102
104
|
* 중첩된 객체·배열 안의 비밀처럼 보이는 키도 가린다 — 예: jenkins_trigger_build 의
|
|
103
105
|
* `parameters: { DEPLOY_TOKEN: … }`. 최상위 키만 보던 시절엔 값이 preview 에 그대로 찍혔다.
|
|
@@ -147,11 +149,17 @@ export function previewArgLines(args) {
|
|
|
147
149
|
.map(([k, v]) => ` ${k}: ${previewValue(k, v)}`);
|
|
148
150
|
}
|
|
149
151
|
/**
|
|
150
|
-
* 줄바꿈·제어 문자에 더해, 화면에서 안 보이거나 글자 순서를 뒤집는
|
|
151
|
-
*
|
|
152
|
+
* 줄바꿈·제어 문자에 더해, 화면에서 안 보이거나 글자 순서를 뒤집는 문자를 `\uXXXX` / `\u{XXXXX}` 로 보이게 만든다:
|
|
153
|
+
* 형식 문자(Cf — zero-width, bidi override/isolate, BOM, soft hyphen, **태그 문자 U+E0000–E007F**)와 기본 무시 문자
|
|
154
|
+
* (Default_Ignorable — 한글 채움 문자 U+3164, 변형 선택자). 태그 문자·변형 선택자는 보이지 않는 ASCII 를 실어 나를 수
|
|
155
|
+
* 있어(“ASCII smuggling”), 사용자가 “Hellox” 를 승인했는데 숨은 지시가 함께 게시될 수 있었다. 코드포인트 단위로
|
|
156
|
+
* 매칭해야(u 플래그) BMP 밖 문자도 잡힌다. JSON.stringify 는 U+0020 미만만 이스케이프한다.
|
|
152
157
|
*/
|
|
153
|
-
const INVISIBLE = /[\u007F-\u009F\
|
|
154
|
-
const showInvisible = (s) => s.replace(INVISIBLE, (c) =>
|
|
158
|
+
const INVISIBLE = /[\p{Default_Ignorable_Code_Point}\p{Cf}\u007F-\u009F\u2028\u2029]/gu;
|
|
159
|
+
const showInvisible = (s) => s.replace(INVISIBLE, (c) => {
|
|
160
|
+
const cp = c.codePointAt(0) ?? 0;
|
|
161
|
+
return cp > 0xffff ? `\\u{${cp.toString(16)}}` : `\\u${cp.toString(16).padStart(4, '0')}`;
|
|
162
|
+
});
|
|
155
163
|
/** 승인 대화상자의 값 하나가 넘으면 가운데를 생략한다 — 앞 HEAD + 뒤 TAIL 은 항상 보인다. */
|
|
156
164
|
const APPROVAL_VALUE_MAX = 1500;
|
|
157
165
|
const APPROVAL_VALUE_HEAD = 1000;
|
|
@@ -8,7 +8,7 @@ import { generateKeystore, isKeytoolAvailable } from '../android/keystore.js';
|
|
|
8
8
|
import { keystoresDir, persistGeneratedKeystore } from '../android/keystore-store.js';
|
|
9
9
|
import { loadJenkinsConfig, requireJenkinsConfig } from '../jenkins/config.js';
|
|
10
10
|
import { inspectCredential, KIND_FILE, upsertSecretFile } from '../jenkins/credentials.js';
|
|
11
|
-
import { ambiguousDefaultIdNote, existingCredentialPreview } from '../jenkins/messages.js';
|
|
11
|
+
import { ambiguousDefaultIdNote, existingCredentialPreview, newCredentialPreview } from '../jenkins/messages.js';
|
|
12
12
|
import { loadPlayServiceAccountForUpload } from '../android/playstore-sa.js';
|
|
13
13
|
import { existingAppSigningPlanLines, newAppSigningPlanLines, keytoolMissingLines, keystoreGeneratedLines, playServiceAccountMissingLines, playServiceAccountUploadedLines, } from '../android/messages.js';
|
|
14
14
|
import { textResult } from '../lib/mcp-response.js';
|
|
@@ -124,8 +124,8 @@ export function registerAndroidTools(server) {
|
|
|
124
124
|
'~/.mimi-seed/play-service-accounts/{package_name}.json 을 읽어 base64로 변환 후 등록합니다.',
|
|
125
125
|
'iam_create_key 로 막 발급한 키를 올리려면 service_account_json_path 에 그 경로(~/.mimi-seed/keys/ 안)를 넘기세요.',
|
|
126
126
|
'setup_playstore_connection 실행 후 반드시 이 도구를 호출하세요.',
|
|
127
|
-
'
|
|
128
|
-
'
|
|
127
|
+
'confirm 생략/false 면 아무것도 보내지 않고 dry-run 만 반환한다 — 새 id 면 "생성 예정", 같은 id 가 있으면',
|
|
128
|
+
'"이미 존재"(기존 SA JSON 을 교체하면 되돌릴 수 없음). 사용자 승인 후 같은 인자에 confirm: true 로 재호출.',
|
|
129
129
|
].join(' '), {
|
|
130
130
|
package_name: androidPackageName.describe('Android 패키지명 (예: com.example.app)'),
|
|
131
131
|
// 기본값을 하드코딩 문자열에서 패키지명 파생으로 바꿨다 — 예전 기본값은 한 사설 앱
|
|
@@ -135,7 +135,7 @@ export function registerAndroidTools(server) {
|
|
|
135
135
|
.string()
|
|
136
136
|
.optional()
|
|
137
137
|
.describe('선택 — iam_create_key 가 저장한 키 파일 절대경로 (~/.mimi-seed/keys/ 안만 허용). 생략하면 패키지별 등록 SA 사용'),
|
|
138
|
-
confirm: z.boolean().optional().describe('
|
|
138
|
+
confirm: z.boolean().optional().describe('true 일 때만 Jenkins 로 보낸다 (새 id 생성 또는 기존 SA JSON 교체). 생략/false 면 dry-run'),
|
|
139
139
|
}, async ({ package_name, credential_id: credentialIdInput, service_account_json_path, confirm }) => {
|
|
140
140
|
const credential_id = credentialIdInput ?? `${credentialPrefix(package_name)}-playstore-sa`;
|
|
141
141
|
const sa = loadPlayServiceAccountForUpload(package_name, service_account_json_path);
|
|
@@ -143,19 +143,22 @@ export function registerAndroidTools(server) {
|
|
|
143
143
|
return textResult(playServiceAccountMissingLines(package_name, sa.path));
|
|
144
144
|
const saBase64 = Buffer.from(sa.raw, 'utf-8').toString('base64');
|
|
145
145
|
const cfg = requireJenkinsConfig();
|
|
146
|
-
// jenkins_upload_keystore / jenkins_create_credential 와 같은 규칙:
|
|
147
|
-
//
|
|
146
|
+
// jenkins_upload_keystore / jenkins_create_credential 와 같은 규칙: confirm 전에는 아무것도 보내지 않는다.
|
|
147
|
+
// 새 id 도 SA 키를 외부로 내보내는 작업이라 dry-run 을 거친다 (예전엔 새 id 는 바로, 기존 id 는 말없이 덮어썼다).
|
|
148
148
|
// 설명에 패키지명을 남긴다 — 기본 id 가 마지막 세그먼트만 써서 다른 앱과 겹쳐도 다음 dry-run 이 누구 것인지 보여준다.
|
|
149
149
|
const description = `Play Store service account for ${package_name}`;
|
|
150
150
|
const result = await upsertSecretFile(cfg, credential_id, saBase64, `${package_name}-sa.json`, description, {
|
|
151
151
|
allowReplace: confirm === true,
|
|
152
|
+
dryRun: confirm !== true,
|
|
152
153
|
});
|
|
153
|
-
if (result === 'exists') {
|
|
154
|
+
if (result === 'exists' || result === 'new') {
|
|
154
155
|
const notes = [];
|
|
155
156
|
if (credentialIdInput === undefined) {
|
|
156
157
|
notes.push(ambiguousDefaultIdNote(credential_id) ??
|
|
157
158
|
M().defaultIdNote(credential_id, package_name));
|
|
158
159
|
}
|
|
160
|
+
if (result === 'new')
|
|
161
|
+
return textResult(newCredentialPreview(credential_id, cfg.url, KIND_FILE, notes));
|
|
159
162
|
return textResult(existingCredentialPreview(credential_id, await inspectCredential(cfg, credential_id), KIND_FILE, notes));
|
|
160
163
|
}
|
|
161
164
|
return textResult(playServiceAccountUploadedLines({
|
package/dist/registers/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import os from 'node:os';
|
|
3
|
-
import { GOOGLE_PROFILE_ID, listGoogleProfiles, getAuthenticatedClient,
|
|
3
|
+
import { GOOGLE_PROFILE_ID, listGoogleProfiles, getAuthenticatedClient, getGoogleAuthAttempt, loginOAuthClient, youtubeUploadProfiles } from '../auth/google-auth.js';
|
|
4
4
|
import { verifyYouTubeChannel, YOUTUBE_CHANNEL_ID } from '../auth/youtube-channel.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { androidPackageName } from '../lib/package-name.js';
|
|
@@ -69,7 +69,8 @@ const A = catalog({
|
|
|
69
69
|
oauthMissing: '❌ Google OAuth — 미연결 → mimi_seed_auth_start',
|
|
70
70
|
youtubeUpload: '✅ YouTube — 업로드·상태 관리 권한 연결됨',
|
|
71
71
|
youtubeRead: '✅ YouTube — 채널·영상·성과 읽기 권한 연결됨',
|
|
72
|
-
youtubeMissing: '❌ YouTube — 미연결 → mimi_seed_auth_start(domains=["youtube"]) (선택)',
|
|
72
|
+
youtubeMissing: '❌ YouTube — 미연결 → mimi_seed_auth_start(profile="youtube", domains=["youtube"]) (선택)',
|
|
73
|
+
youtubeProfiles: (list, first) => `✅ YouTube — 업로드 권한 연결됨 (프로필 ${list}) — youtube_* 도구에 profile="${first}" 를 넘기세요`,
|
|
73
74
|
playOk: (count, detail) => `✅ Play Store SA — ${count}개 등록 (${detail})`,
|
|
74
75
|
playBroken: (broken, total, names) => `⚠️ Play Store SA — ${total}개 중 ${broken}개를 읽을 수 없음 (${names}) — 그 패키지는 SA 로 동작하지 않는다. setup_playstore_connection 으로 다시 등록`,
|
|
75
76
|
playMissing: '⚠️ Play Store SA — 미설정 (선택 — 로컬은 OAuth 로 가능, CI/헤드리스는 필수) → setup_playstore_connection',
|
|
@@ -167,7 +168,8 @@ const A = catalog({
|
|
|
167
168
|
oauthMissing: '❌ Google OAuth — not connected → mimi_seed_auth_start',
|
|
168
169
|
youtubeUpload: '✅ YouTube — upload and status management permission connected',
|
|
169
170
|
youtubeRead: '✅ YouTube — channel, video, and performance read permission connected',
|
|
170
|
-
youtubeMissing: '❌ YouTube — not connected → mimi_seed_auth_start(domains=["youtube"]) (optional)',
|
|
171
|
+
youtubeMissing: '❌ YouTube — not connected → mimi_seed_auth_start(profile="youtube", domains=["youtube"]) (optional)',
|
|
172
|
+
youtubeProfiles: (list, first) => `✅ YouTube — upload permission connected (profile ${list}) — pass profile="${first}" to youtube_* tools`,
|
|
171
173
|
playOk: (count, detail) => `✅ Play Store SA — ${count} registered (${detail})`,
|
|
172
174
|
playBroken: (broken, total, names) => `⚠️ Play Store SA — ${broken} of ${total} cannot be read (${names}) — those packages won't work with an SA. Re-register with setup_playstore_connection`,
|
|
173
175
|
playMissing: '⚠️ Play Store SA — not set up (optional — OAuth works locally; required for CI/headless) → setup_playstore_connection',
|
|
@@ -359,7 +361,11 @@ export function registerAuthTools(server) {
|
|
|
359
361
|
: m.youtubeRead);
|
|
360
362
|
}
|
|
361
363
|
else {
|
|
362
|
-
|
|
364
|
+
// The default login has no YouTube grant, but a named profile (the recommended setup) may.
|
|
365
|
+
const profiles = youtubeUploadProfiles();
|
|
366
|
+
lines.push(profiles.length > 0
|
|
367
|
+
? m.youtubeProfiles(profiles.map((p) => (p.channelTitle ? `${p.profile}: ${p.channelTitle}` : p.profile)).join(', '), profiles[0].profile)
|
|
368
|
+
: m.youtubeMissing);
|
|
363
369
|
}
|
|
364
370
|
// 2. Play Store SA
|
|
365
371
|
const saInfo = listRegisteredServiceAccounts();
|
|
@@ -562,7 +568,7 @@ export function registerAuthTools(server) {
|
|
|
562
568
|
let clientId;
|
|
563
569
|
let clientSecret;
|
|
564
570
|
try {
|
|
565
|
-
({ clientId, clientSecret } = await getMcpOAuthClient(
|
|
571
|
+
({ clientId, clientSecret } = await getMcpOAuthClient(loginOAuthClient(profile)));
|
|
566
572
|
}
|
|
567
573
|
catch (e) {
|
|
568
574
|
const p = classifyError(e, { phase: 'login' });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SOCIAL_PROFILE_ID_PATTERN } from '#core/project-manifest.js';
|
|
3
|
+
import { GOOGLE_PROFILE_ID } from '../auth/google-auth.js';
|
|
4
|
+
import { YOUTUBE_CHANNEL_ID } from '../auth/youtube-channel.js';
|
|
5
|
+
import { executePublish, planPublish, SOCIAL_TARGETS } from '../crosspost/tools.js';
|
|
6
|
+
import { jsonResult } from '../lib/mcp-response.js';
|
|
7
|
+
import { catalog } from '#core/lang.js';
|
|
8
|
+
const M = catalog({
|
|
9
|
+
httpsOnly: 'HTTPS URL만 허용합니다.',
|
|
10
|
+
absoluteOnly: '절대경로만 허용합니다.',
|
|
11
|
+
preview: 'dry-run — 아무것도 게시하지 않았습니다. 아래 계획을 사용자에게 보여주고 명시 승인을 받은 뒤, 같은 인자에 confirm: true 를 더해 다시 호출하세요.',
|
|
12
|
+
blocked: '문제가 있는 대상이 있어 아무 곳에도 게시하지 않았습니다. problems 를 고친 뒤 다시 미리보기하세요.',
|
|
13
|
+
requestIdRemoved: 'requestId 는 더 이상 받지 않습니다. 같은 게시물(플랫폼·계정·내용이 같음)은 requestId 없이도 한 번만 게시됩니다. requestId 를 빼고 다시 부르세요. 같은 내용을 일부러 다시 올리려면 repost 를 쓰세요.',
|
|
14
|
+
done: '게시를 마쳤습니다. 실패한 대상은 다시 호출하면 다시 보냅니다 — 이미 게시된 곳은 건너뜁니다. 결과를 알 수 없는 대상은 그 플랫폼에서 먼저 확인하세요.',
|
|
15
|
+
}, {
|
|
16
|
+
httpsOnly: 'Only HTTPS URLs are allowed.',
|
|
17
|
+
absoluteOnly: 'Only absolute paths are allowed.',
|
|
18
|
+
preview: 'dry-run — nothing was posted. Show the user the plan below, get their explicit approval, then call again with the same arguments plus confirm: true.',
|
|
19
|
+
blocked: 'Nothing was posted because some targets have problems. Fix the problems, then preview again.',
|
|
20
|
+
requestIdRemoved: 'requestId is no longer accepted. The same post (same platform, account, and content) is posted only once without it. Call again without requestId. To post the same content again on purpose, use repost.',
|
|
21
|
+
done: 'Publishing finished. Calling again resends the failed targets — platforms that already posted are skipped. Check any unknown-outcome target on its platform first.',
|
|
22
|
+
});
|
|
23
|
+
const httpsUrl = z.string().url().refine((value) => new URL(value).protocol === 'https:', { error: () => M().httpsOnly });
|
|
24
|
+
const absolutePath = z.string().min(1).refine((value) => value.startsWith('/') || /^[A-Za-z]:[\\/]/.test(value), {
|
|
25
|
+
error: () => M().absoluteOnly,
|
|
26
|
+
});
|
|
27
|
+
const socialProfile = z.string().regex(SOCIAL_PROFILE_ID_PATTERN).optional().describe('이 플랫폼에 쓸 소셜 프로필 ID (생략 시 프로젝트 매핑 또는 기본 설정)');
|
|
28
|
+
const metaOptions = z.object({
|
|
29
|
+
profile: socialProfile,
|
|
30
|
+
text: z.string().optional().describe('이 플랫폼에만 쓸 본문 (생략 시 공통 text)'),
|
|
31
|
+
}).optional();
|
|
32
|
+
const approval = z.object({
|
|
33
|
+
platform: z.enum(SOCIAL_TARGETS),
|
|
34
|
+
at: z.string().min(1).max(64).describe('계획에 표시된 그 기록의 at (승인 대상 기록을 정확히 지목)'),
|
|
35
|
+
});
|
|
36
|
+
export function registerCrosspostTools(server) {
|
|
37
|
+
server.tool('social_publish', [
|
|
38
|
+
'하나의 게시물을 여러 소셜 플랫폼(facebook, instagram, threads, youtube, tiktok)에 한 번에 게시합니다.',
|
|
39
|
+
'confirm 없이 부르면 dry-run 계획만 돌려줍니다: 플랫폼별 동작·본문·미디어와 게시를 막는 문제. 네트워크 호출은 하지 않습니다.',
|
|
40
|
+
'한 대상이라도 문제가 있으면 어디에도 게시하지 않습니다. 사용자에게 계획을 보여주고 명시 승인을 받은 뒤 confirm: true 로 다시 호출하세요.',
|
|
41
|
+
'미디어 규칙은 플랫폼별 도구와 같습니다: Facebook·Instagram 은 public HTTPS imageUrls(1~10장)가 필요하고, Threads 는 텍스트·이미지(1~20장)·videoUrl 중 하나, YouTube 는 로컬 videoFilePath 와 youtube.expectedChannelId, TikTok 은 tiktok_business_plan_video_post 로 만든 tiktok.planId 를 씁니다.',
|
|
42
|
+
'결과는 플랫폼별로 돌려줍니다. 같은 게시물(플랫폼·계정·내용이 같음)은 두 번 게시하지 않습니다: 다시 부르면 이미 게시된 곳은 건너뛰고, 실패한 곳만 보냅니다. 같은 내용을 일부러 다시 올리려면 repost: [{ platform, at }] 으로 계획에 표시된 그 게시 기록의 at 을 지정합니다. 결과를 알 수 없는 게시가 있는 계정은 내용이 달라도 막히며, 사람이 그 플랫폼에서 확인한 뒤 resendUnknown: [{ platform, at }] 으로 계획에 표시된 at 을 지정해야만 다시 보냅니다. 확인해 보니 이미 올라가 있다면 markPosted: [{ platform, at }] 으로 게시됨으로 기록합니다. 승인은 지정한 기록 하나에만 쓰입니다.',
|
|
43
|
+
].join(' '), {
|
|
44
|
+
targets: z.array(z.enum(SOCIAL_TARGETS)).min(1).max(SOCIAL_TARGETS.length).describe('게시할 플랫폼 목록 (이 순서대로 게시)'),
|
|
45
|
+
text: z.string().max(63_206).describe('공통 본문. 플랫폼별 text 로 덮어쓸 수 있습니다 (Threads 500자, Instagram 2,200자).'),
|
|
46
|
+
imageUrls: z.array(httpsUrl).min(1).max(20).optional().describe('이미지 public HTTPS URL (Facebook·Instagram 최대 10장, Threads 최대 20장)'),
|
|
47
|
+
videoUrl: httpsUrl.optional().describe('Threads 영상 게시용 public HTTPS URL'),
|
|
48
|
+
videoFilePath: absolutePath.optional().describe('YouTube 업로드용 로컬 영상 절대경로'),
|
|
49
|
+
facebook: metaOptions,
|
|
50
|
+
instagram: metaOptions,
|
|
51
|
+
threads: metaOptions,
|
|
52
|
+
youtube: z.object({
|
|
53
|
+
profile: z.string().regex(GOOGLE_PROFILE_ID).optional().describe('Google 로그인 프로필 (mimi-seed auth social 은 "youtube" 프로필에 연결합니다)'),
|
|
54
|
+
expectedChannelId: z.string().regex(YOUTUBE_CHANNEL_ID).describe('업로드 대상 채널 ID. 인증된 채널과 다르면 업로드 중단.'),
|
|
55
|
+
title: z.string().min(1).max(100).optional().describe('영상 제목 (생략 시 text 의 첫 줄)'),
|
|
56
|
+
description: z.string().max(5_000).optional().describe('영상 설명 (생략 시 text)'),
|
|
57
|
+
tags: z.array(z.string().min(1).max(500)).max(100).optional(),
|
|
58
|
+
privacyStatus: z.enum(['private', 'unlisted', 'public']).default('private').describe('기본 private. 계획에 표시되며 승인 대상입니다.'),
|
|
59
|
+
madeForKids: z.boolean().default(false),
|
|
60
|
+
containsSyntheticMedia: z.boolean().optional().describe('현실적으로 보이는 AI 생성·변형 콘텐츠 여부를 YouTube에 고지'),
|
|
61
|
+
}).optional(),
|
|
62
|
+
tiktok: z.object({
|
|
63
|
+
planId: z.string().min(1).max(128).describe('tiktok_business_plan_video_post 가 만든 계획 ID (캡션·설정은 계획의 값을 씁니다)'),
|
|
64
|
+
}).optional(),
|
|
65
|
+
resendUnknown: z.array(approval).max(SOCIAL_TARGETS.length * 2).optional().describe('사용자가 그 플랫폼에서 게시되지 않았음을 확인한, 결과를 알 수 없었던 기록. 계획에 표시된 플랫폼과 at 을 그대로 넘깁니다. 그 기록만 다시 보내며, 이후 새로 생긴 결과 불명은 다시 막힙니다.'),
|
|
66
|
+
repost: z.array(approval).max(SOCIAL_TARGETS.length * 2).optional().describe('사용자가 일부러 다시 게시하려는 이미 게시된 기록. 계획에 표시된 플랫폼과 at 을 그대로 넘깁니다. 한 번 다시 게시되면 그 승인은 더 이상 맞지 않아 재시도로 반복 게시되지 않습니다.'),
|
|
67
|
+
markPosted: z.array(approval).max(SOCIAL_TARGETS.length * 2).optional().describe('결과를 알 수 없었던 기록 중, 사용자가 그 플랫폼에서 실제로 올라가 있음을 확인한 것. 계획에 표시된 플랫폼과 at 을 그대로 넘깁니다. 그 기록을 게시됨으로 남기고 계정 차단을 풉니다 (보내지는 않음).'),
|
|
68
|
+
// Removed: the "same post" rule replaced it. Rejected rather than silently dropped, so a caller relying on it
|
|
69
|
+
// learns that it no longer chooses what counts as a retry.
|
|
70
|
+
requestId: z.never({ error: () => M().requestIdRemoved }).optional().describe('지원 중단 — 넘기면 거부합니다. 같은 게시물은 자동으로 한 번만 게시됩니다.'),
|
|
71
|
+
confirm: z.boolean().default(false).describe('사용자의 명시 승인 후 true. false 면 dry-run 계획만 반환합니다.'),
|
|
72
|
+
}, async ({ confirm, requestId: _removed, ...input }) => {
|
|
73
|
+
const plan = planPublish(input);
|
|
74
|
+
if (!confirm)
|
|
75
|
+
return jsonResult({ mode: 'dry-run', note: M().preview, ...plan });
|
|
76
|
+
if (!plan.ok)
|
|
77
|
+
return jsonResult({ mode: 'blocked', note: M().blocked, ...plan });
|
|
78
|
+
const results = await executePublish(input, plan);
|
|
79
|
+
return jsonResult({ mode: 'published', note: M().done, results });
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -5,7 +5,7 @@ import * as jobs from '../jenkins/jobs.js';
|
|
|
5
5
|
import * as builds from '../jenkins/builds.js';
|
|
6
6
|
import { jsonResult, textResult } from '../lib/mcp-response.js';
|
|
7
7
|
import { SIGNING_SECRET_FIELDS, resolveKeystoreInput, resolveSecretInput } from '../android/keystore-store.js';
|
|
8
|
-
import { ambiguousDefaultIdNote, existingCredentialPreview, jenkinsConfiguredLines, jenkinsNotConfiguredLines, } from '../jenkins/messages.js';
|
|
8
|
+
import { ambiguousDefaultIdNote, existingCredentialPreview, jenkinsConfiguredLines, jenkinsNotConfiguredLines, newCredentialPreview, } from '../jenkins/messages.js';
|
|
9
9
|
import { catalog } from '#core/lang.js';
|
|
10
10
|
const M = catalog({
|
|
11
11
|
corrupt: (file, reason) => `❌ ${file} 이 손상되어 읽을 수 없습니다 (${reason}). 다시 저장하면 새로 씁니다.`,
|
|
@@ -33,6 +33,10 @@ const M = catalog({
|
|
|
33
33
|
jobExists: (job) => `⚠️ Job \`${job}\` already exists. Use jenkins_update_job or call again with overwrite=true.`,
|
|
34
34
|
});
|
|
35
35
|
/** 기존 id 교체 dry-run — 무엇을 덮어쓰게 되는지(id·종류·설명)와 모호한 기본 id 경고를 싣는다. */
|
|
36
|
+
function newPreview(cfg, id, requested) {
|
|
37
|
+
const note = ambiguousDefaultIdNote(id);
|
|
38
|
+
return textResult(newCredentialPreview(id, cfg.url, requested, note ? [note] : []));
|
|
39
|
+
}
|
|
36
40
|
async function existingPreview(cfg, id, requested) {
|
|
37
41
|
const note = ambiguousDefaultIdNote(id);
|
|
38
42
|
return textResult(existingCredentialPreview(id, await creds.inspectCredential(cfg, id), requested, note ? [note] : []));
|
|
@@ -96,8 +100,8 @@ export function registerJenkinsTools(server) {
|
|
|
96
100
|
server.tool('jenkins_create_credential', [
|
|
97
101
|
'Jenkins에 Secret Text credential을 생성하거나 업데이트합니다.',
|
|
98
102
|
'비밀번호, API 키, 앱 시크릿 등 문자열 값에 사용하세요.',
|
|
99
|
-
'
|
|
100
|
-
'
|
|
103
|
+
'confirm 생략/false 면 아무것도 보내지 않고 dry-run 만 반환한다 — 새 id 면 "생성 예정", 같은 id 가 있으면',
|
|
104
|
+
'"이미 존재"(교체하면 되돌릴 수 없음). 사용자 승인 후 같은 인자에 confirm: true 로 재호출.',
|
|
101
105
|
'설정이 없으면 jenkins_status를 먼저 호출하세요.',
|
|
102
106
|
].join(' '), {
|
|
103
107
|
id: z.string().describe('Credential ID (예: my-app-android-key-password)'),
|
|
@@ -111,21 +115,26 @@ export function registerJenkinsTools(server) {
|
|
|
111
115
|
.optional()
|
|
112
116
|
.describe('secret_file 에서 꺼낼 필드 (storePassword / keyPassword / keyAlias)'),
|
|
113
117
|
description: z.string().optional().describe('설명 (선택)'),
|
|
114
|
-
confirm: z.boolean().optional().describe('
|
|
118
|
+
confirm: z.boolean().optional().describe('true 일 때만 Jenkins 로 보낸다 (새 id 생성 또는 기존 값 교체). 생략/false 면 dry-run'),
|
|
115
119
|
}, async ({ id, secret, secret_file, secret_field, description, confirm }) => {
|
|
116
120
|
const value = resolveSecretInput({ secret, secretFile: secret_file, secretField: secret_field });
|
|
117
121
|
const cfg = requireJenkinsConfig();
|
|
118
|
-
const result = await creds.upsertSecretText(cfg, id, value, description ?? '', {
|
|
122
|
+
const result = await creds.upsertSecretText(cfg, id, value, description ?? '', {
|
|
123
|
+
allowReplace: confirm === true,
|
|
124
|
+
dryRun: confirm !== true,
|
|
125
|
+
});
|
|
119
126
|
if (result === 'exists')
|
|
120
127
|
return existingPreview(cfg, id, creds.KIND_STRING);
|
|
128
|
+
if (result === 'new')
|
|
129
|
+
return newPreview(cfg, id, creds.KIND_STRING);
|
|
121
130
|
return textResult(`✅ Jenkins credential ${result}: \`${id}\``);
|
|
122
131
|
});
|
|
123
132
|
// ── 4. Secret File (keystore) ──────────────────────────────────────────────
|
|
124
133
|
server.tool('jenkins_upload_keystore', [
|
|
125
134
|
'Jenkins에 Android keystore 파일을 Secret File credential로 업로드합니다.',
|
|
126
135
|
'keystore_base64에 .jks/.p12 파일을 base64로 인코딩한 값을 전달하세요.',
|
|
127
|
-
'
|
|
128
|
-
'
|
|
136
|
+
'confirm 생략/false 면 아무것도 보내지 않고 dry-run 만 반환한다 — 새 id 면 "생성 예정", 같은 id 가 있으면',
|
|
137
|
+
'"이미 존재"(기존 keystore 를 교체하면 되돌릴 수 없음). 사용자 승인 후 같은 인자에 confirm: true 로 재호출.',
|
|
129
138
|
'설정이 없으면 jenkins_status를 먼저 호출하세요.',
|
|
130
139
|
].join(' '), {
|
|
131
140
|
id: z.string().describe('Credential ID (예: my-app-android-keystore)'),
|
|
@@ -136,15 +145,18 @@ export function registerJenkinsTools(server) {
|
|
|
136
145
|
.describe('권장 — android_generate_keystore 가 만든 keystore 절대경로 (~/.mimi-seed/keystores/ 안만 허용)'),
|
|
137
146
|
file_name: z.string().default('keystore.jks').describe('파일명 (기본: keystore.jks)'),
|
|
138
147
|
description: z.string().optional().describe('설명 (선택)'),
|
|
139
|
-
confirm: z.boolean().optional().describe('
|
|
148
|
+
confirm: z.boolean().optional().describe('true 일 때만 Jenkins 로 보낸다 (새 id 생성 또는 기존 keystore 교체). 생략/false 면 dry-run'),
|
|
140
149
|
}, async ({ id, keystore_base64, keystore_path, file_name, description, confirm }) => {
|
|
141
150
|
const keystore = resolveKeystoreInput({ base64: keystore_base64, path: keystore_path });
|
|
142
151
|
const cfg = requireJenkinsConfig();
|
|
143
152
|
const result = await creds.upsertSecretFile(cfg, id, keystore, file_name, description ?? '', {
|
|
144
153
|
allowReplace: confirm === true,
|
|
154
|
+
dryRun: confirm !== true,
|
|
145
155
|
});
|
|
146
156
|
if (result === 'exists')
|
|
147
157
|
return existingPreview(cfg, id, creds.KIND_FILE);
|
|
158
|
+
if (result === 'new')
|
|
159
|
+
return newPreview(cfg, id, creds.KIND_FILE);
|
|
148
160
|
return textResult(`✅ Jenkins keystore credential ${result}: \`${id}\` (${file_name})`);
|
|
149
161
|
});
|
|
150
162
|
// ── 5. 삭제 ───────────────────────────────────────────────────────────────
|
package/dist/remote-sync.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { consoleUrl } from '#core/console-url.js';
|
|
1
|
+
import { consoleBase, consoleBaseProblem, consoleUrl } from '#core/console-url.js';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { getAppStoreCredentials } from './appstore/auth.js';
|
|
@@ -28,6 +28,7 @@ const R = catalog({
|
|
|
28
28
|
oauthNotCopied: '- Google OAuth: 복사하지 않음 (원격 웹에서 별도 동의 필요)',
|
|
29
29
|
previewOnly: '미리보기만 수행했습니다. 원격 저장은 confirm=true일 때만 실행됩니다.',
|
|
30
30
|
noConfig: '원격 연결 정보가 없습니다. 팀 콘솔의 MIMI_SEED_WEB_BASE를 설정하고 `mimi-seed init`을 실행하세요.',
|
|
31
|
+
webBaseIgnored: (problem) => `MIMI_SEED_WEB_BASE 는 설정돼 있지만 받아들이지 않았습니다 (${problem}) — 팀 콘솔의 https 루트 주소(경로·?·# 없이)여야 합니다.`,
|
|
31
32
|
untrusted: (reason) => `원격 엔드포인트를 신뢰할 수 없어 전송하지 않았습니다: ${reason}`,
|
|
32
33
|
failed: '실패',
|
|
33
34
|
skippedResult: (name) => `- Play ${name}: 건너뜀 (등록되지 않은 패키지)`,
|
|
@@ -53,6 +54,7 @@ const R = catalog({
|
|
|
53
54
|
oauthNotCopied: '- Google OAuth: not copied (requires separate consent on the remote web)',
|
|
54
55
|
previewOnly: 'Preview only. Remote storage runs only with confirm=true.',
|
|
55
56
|
noConfig: 'No remote connection info. Set MIMI_SEED_WEB_BASE to your team console and run `mimi-seed init`.',
|
|
57
|
+
webBaseIgnored: (problem) => `MIMI_SEED_WEB_BASE is set but was not accepted (${problem}) — it must be the team console's https root address (no path, ? or #).`,
|
|
56
58
|
untrusted: (reason) => `The remote endpoint is not trusted, so nothing was sent: ${reason}`,
|
|
57
59
|
failed: 'failed',
|
|
58
60
|
skippedResult: (name) => `- Play ${name}: skipped (unregistered package)`,
|
|
@@ -62,7 +64,7 @@ const R = catalog({
|
|
|
62
64
|
function getRemoteConfig() {
|
|
63
65
|
const envToken = process.env.MIMI_SEED_TOKEN;
|
|
64
66
|
if (envToken) {
|
|
65
|
-
const webBase =
|
|
67
|
+
const webBase = consoleBase(process.env.MIMI_SEED_WEB_BASE);
|
|
66
68
|
if (!webBase)
|
|
67
69
|
return null;
|
|
68
70
|
return { token: envToken, endpoint: `${webBase}/api/mcp`, webBase };
|
|
@@ -73,7 +75,7 @@ function getRemoteConfig() {
|
|
|
73
75
|
if (!parsed.token || !parsed.endpoint)
|
|
74
76
|
return null;
|
|
75
77
|
const webBase = parsed.webBase ?? parsed.endpoint.replace(/\/api\/mcp\/?$/, '');
|
|
76
|
-
if (!
|
|
78
|
+
if (!consoleBase(webBase) || !consoleUrl(parsed.endpoint))
|
|
77
79
|
return null;
|
|
78
80
|
return { token: parsed.token, endpoint: parsed.endpoint, webBase };
|
|
79
81
|
}
|
|
@@ -202,7 +204,9 @@ export async function syncRemoteCredentials(options, dependencies = defaultDepen
|
|
|
202
204
|
return [...lines, '', m.previewOnly].join('\n');
|
|
203
205
|
}
|
|
204
206
|
if (!config) {
|
|
205
|
-
|
|
207
|
+
// 설정했는데 거부된 값은 "연결 정보 없음" 만으로는 원인을 알 수 없다 — 이유를 함께 보인다.
|
|
208
|
+
const problem = consoleBaseProblem(process.env.MIMI_SEED_WEB_BASE);
|
|
209
|
+
return [...lines, '', ...(problem ? [m.webBaseIgnored(problem)] : []), m.noConfig].join('\n');
|
|
206
210
|
}
|
|
207
211
|
if (!endpoint?.ok) {
|
|
208
212
|
return [...lines, '', m.untrusted(endpoint?.reason)].join('\n');
|
package/dist/server.js
CHANGED
|
@@ -12,6 +12,7 @@ import { registerAuthTools } from './registers/auth.js';
|
|
|
12
12
|
import { registerCiTools } from './registers/ci.js';
|
|
13
13
|
import { registerInstagramTools } from './registers/instagram.js';
|
|
14
14
|
import { registerThreadsTools } from './registers/threads.js';
|
|
15
|
+
import { registerCrosspostTools } from './registers/crosspost.js';
|
|
15
16
|
import { registerFacebookTools } from './registers/facebook.js';
|
|
16
17
|
import { registerGoogleAdsTools } from './registers/googleads.js';
|
|
17
18
|
import { registerGscTools } from './registers/gsc.js';
|
|
@@ -86,6 +87,7 @@ export function buildServer(version, options = {}) {
|
|
|
86
87
|
registerVideoTools(registrar);
|
|
87
88
|
registerYouTubeTools(registrar);
|
|
88
89
|
registerTikTokBusinessTools(registrar);
|
|
90
|
+
registerCrosspostTools(registrar);
|
|
89
91
|
registerDriveTools(registrar);
|
|
90
92
|
// 모든 언어에 적용한다 — `$schema` 제거는 언어와 무관하다. 번역은 en 일 때만.
|
|
91
93
|
localizeToolList(server, toolLang === 'en' ? translate : undefined);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The team console that brokers Instagram / Threads browser login, or null. One rule for the gate in setup-cli and
|
|
3
|
+
* for the brokers themselves: a console base (origin only — consoleBase) over HTTPS. The CLI also accepts a loopback
|
|
4
|
+
* `http://` console for development, which the broker refuses; when the gate used plain consoleBase, such a value
|
|
5
|
+
* picked the broker path, failed with "configuration", and never fell back to the local login.
|
|
6
|
+
*/
|
|
7
|
+
export declare function socialBrokerBase(value?: string | undefined): string | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { consoleBase } from '#core/console-url.js';
|
|
2
|
+
/**
|
|
3
|
+
* The team console that brokers Instagram / Threads browser login, or null. One rule for the gate in setup-cli and
|
|
4
|
+
* for the brokers themselves: a console base (origin only — consoleBase) over HTTPS. The CLI also accepts a loopback
|
|
5
|
+
* `http://` console for development, which the broker refuses; when the gate used plain consoleBase, such a value
|
|
6
|
+
* picked the broker path, failed with "configuration", and never fell back to the local login.
|
|
7
|
+
*/
|
|
8
|
+
export function socialBrokerBase(value = process.env.MIMI_SEED_WEB_BASE) {
|
|
9
|
+
const base = consoleBase(value);
|
|
10
|
+
return base && new URL(base).protocol === 'https:' ? base : null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type MetaLoginPlatform = 'instagram' | 'threads';
|
|
2
|
+
export interface MetaAppConfig {
|
|
3
|
+
appId: string;
|
|
4
|
+
appSecret: string;
|
|
5
|
+
/** Must match a redirect URI registered in the Meta app dashboard exactly. */
|
|
6
|
+
redirectUri: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function metaAppsPath(homeDir?: string): string;
|
|
9
|
+
/** A loopback redirect is captured by a local server; any other HTTPS redirect is pasted back by the user. */
|
|
10
|
+
export declare function isLoopbackRedirect(redirectUri: string): boolean;
|
|
11
|
+
export declare function isValidAppId(value: string): boolean;
|
|
12
|
+
export declare function isValidAppSecret(value: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* HTTPS anywhere, or plain HTTP only on a loopback host with an explicit port (so the local server
|
|
15
|
+
* knows where to listen). No credentials, query, or fragment: Meta compares the URI byte for byte.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isValidRedirectUri(value: string): boolean;
|
|
18
|
+
export declare function loadMetaApp(platform: MetaLoginPlatform, homeDir?: string): MetaAppConfig | null;
|
|
19
|
+
export declare function saveMetaApp(platform: MetaLoginPlatform, config: MetaAppConfig, homeDir?: string): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The user's own Meta app credentials for broker-free Instagram / Threads browser login.
|
|
2
|
+
//
|
|
3
|
+
// File: ~/.mimi-seed/meta-apps.json (0600) — { instagram?: MetaAppConfig, threads?: MetaAppConfig }.
|
|
4
|
+
// Instagram Login and Threads each have their own app ID and secret inside one Meta app, so they are
|
|
5
|
+
// stored per platform. The app is not per social profile: one app can sign in several accounts.
|
|
6
|
+
// This module is the only writer (one writer per credential file).
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { writeCredentialJson } from '#core/atomic-write.js';
|
|
11
|
+
import { readCredentialFileSync } from '#core/credential-read.js';
|
|
12
|
+
export function metaAppsPath(homeDir = os.homedir()) {
|
|
13
|
+
return path.join(homeDir, '.mimi-seed', 'meta-apps.json');
|
|
14
|
+
}
|
|
15
|
+
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
16
|
+
/** A loopback redirect is captured by a local server; any other HTTPS redirect is pasted back by the user. */
|
|
17
|
+
export function isLoopbackRedirect(redirectUri) {
|
|
18
|
+
const url = new URL(redirectUri);
|
|
19
|
+
return url.protocol === 'http:' && LOOPBACK_HOSTS.has(url.hostname) && url.port !== '';
|
|
20
|
+
}
|
|
21
|
+
export function isValidAppId(value) {
|
|
22
|
+
return /^\d{5,32}$/.test(value);
|
|
23
|
+
}
|
|
24
|
+
export function isValidAppSecret(value) {
|
|
25
|
+
return /^[A-Za-z0-9]{16,128}$/.test(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* HTTPS anywhere, or plain HTTP only on a loopback host with an explicit port (so the local server
|
|
29
|
+
* knows where to listen). No credentials, query, or fragment: Meta compares the URI byte for byte.
|
|
30
|
+
*/
|
|
31
|
+
export function isValidRedirectUri(value) {
|
|
32
|
+
let url;
|
|
33
|
+
try {
|
|
34
|
+
url = new URL(value);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
} // an unparsable URI is simply not a valid redirect
|
|
39
|
+
if (url.username || url.password || url.search || url.hash)
|
|
40
|
+
return false;
|
|
41
|
+
if (url.protocol === 'https:')
|
|
42
|
+
return true;
|
|
43
|
+
return url.protocol === 'http:' && LOOPBACK_HOSTS.has(url.hostname) && url.port !== '';
|
|
44
|
+
}
|
|
45
|
+
function isValidConfig(value) {
|
|
46
|
+
if (!value || typeof value !== 'object')
|
|
47
|
+
return false;
|
|
48
|
+
const v = value;
|
|
49
|
+
return typeof v.appId === 'string' && isValidAppId(v.appId) &&
|
|
50
|
+
typeof v.appSecret === 'string' && isValidAppSecret(v.appSecret) &&
|
|
51
|
+
typeof v.redirectUri === 'string' && isValidRedirectUri(v.redirectUri);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A missing file is "no app yet". A file that exists but cannot be read is an error, never "empty": treating it
|
|
55
|
+
* as empty would let the next save overwrite the other platform's app. The parse error is not quoted because
|
|
56
|
+
* recent V8 messages include a snippet of the file, which holds the app secret.
|
|
57
|
+
*/
|
|
58
|
+
function readDocument(homeDir) {
|
|
59
|
+
const file = metaAppsPath(homeDir);
|
|
60
|
+
if (!fs.existsSync(file))
|
|
61
|
+
return {};
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(readCredentialFileSync(file));
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw new Error(`Cannot read ${file}; it was left unchanged. Fix or delete it, then sign in again.`, { cause: error });
|
|
68
|
+
}
|
|
69
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
70
|
+
throw new Error(`${file} is not a JSON object; it was left unchanged. Fix or delete it, then sign in again.`);
|
|
71
|
+
}
|
|
72
|
+
return parsed;
|
|
73
|
+
}
|
|
74
|
+
export function loadMetaApp(platform, homeDir) {
|
|
75
|
+
const entry = readDocument(homeDir)[platform];
|
|
76
|
+
return isValidConfig(entry) ? { appId: entry.appId, appSecret: entry.appSecret, redirectUri: entry.redirectUri } : null;
|
|
77
|
+
}
|
|
78
|
+
export function saveMetaApp(platform, config, homeDir) {
|
|
79
|
+
if (!isValidConfig(config))
|
|
80
|
+
throw new Error(`Invalid ${platform} app settings; nothing was saved.`);
|
|
81
|
+
const doc = readDocument(homeDir);
|
|
82
|
+
writeCredentialJson(metaAppsPath(homeDir), { ...doc, [platform]: config });
|
|
83
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ConnectResult } from '../facebook/setup.js';
|
|
2
|
+
import { type SocialConfigOptions } from './profile-store.js';
|
|
3
|
+
import { type MetaAppConfig, type MetaLoginPlatform } from './meta-app-config.js';
|
|
4
|
+
export type MetaDirectLoginCode = 'configuration' | 'denied' | 'timeout' | 'state' | 'exchange' | 'validation';
|
|
5
|
+
export declare class MetaDirectLoginError extends Error {
|
|
6
|
+
readonly code: MetaDirectLoginCode;
|
|
7
|
+
/** Provider's own reason (e.g. a redirect_uri mismatch), already scrubbed of the code and secret. */
|
|
8
|
+
readonly detail?: string | undefined;
|
|
9
|
+
constructor(code: MetaDirectLoginCode,
|
|
10
|
+
/** Provider's own reason (e.g. a redirect_uri mismatch), already scrubbed of the code and secret. */
|
|
11
|
+
detail?: string | undefined);
|
|
12
|
+
}
|
|
13
|
+
interface ProviderSpec {
|
|
14
|
+
authorizeUrl: string;
|
|
15
|
+
tokenUrl: string;
|
|
16
|
+
longLivedUrl: string;
|
|
17
|
+
longLivedGrant: string;
|
|
18
|
+
scopes: string[];
|
|
19
|
+
}
|
|
20
|
+
/** Scopes cover what the instagram_* / threads_* tools call: account lookup and publishing. */
|
|
21
|
+
export declare const META_LOGIN_PROVIDERS: Record<MetaLoginPlatform, ProviderSpec>;
|
|
22
|
+
export declare function buildAuthorizeUrl(platform: MetaLoginPlatform, app: MetaAppConfig, state: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Extract the authorization code from a pasted redirect URL. The URL must point at the registered redirect
|
|
25
|
+
* (same origin and path) and carry the expected state; a bare code is refused because it cannot be tied to
|
|
26
|
+
* this login attempt.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parsePastedRedirect(input: string, app: MetaAppConfig, state: string): string;
|
|
29
|
+
export interface LongLivedToken {
|
|
30
|
+
accessToken: string;
|
|
31
|
+
expiresInSeconds: number;
|
|
32
|
+
}
|
|
33
|
+
/** code → short-lived token → long-lived token. The code is single-use, so the POST is never retried. */
|
|
34
|
+
export declare function exchangeCode(platform: MetaLoginPlatform, app: MetaAppConfig, code: string): Promise<LongLivedToken>;
|
|
35
|
+
export interface MetaDirectLoginOptions extends SocialConfigOptions {
|
|
36
|
+
app: MetaAppConfig;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
openBrowser?: (url: string) => Promise<void>;
|
|
39
|
+
/** Called with the authorize URL so a CLI can print it when the browser does not open. */
|
|
40
|
+
onUrl?: (url: string) => void;
|
|
41
|
+
/** Paste mode (non-loopback redirect): returns the full redirected URL the user copied. */
|
|
42
|
+
readRedirect?: () => Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
export declare function connectWithMetaApp(platform: MetaLoginPlatform, options: MetaDirectLoginOptions): Promise<ConnectResult>;
|
|
45
|
+
export {};
|