@yoonion/mimi-seed-mcp 0.3.39 → 0.3.40
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.
|
@@ -6,5 +6,9 @@ export interface JenkinsCredentialSummary {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function listCredentials(cfg: JenkinsConfig): Promise<JenkinsCredentialSummary[]>;
|
|
8
8
|
export declare function upsertSecretText(cfg: JenkinsConfig, id: string, secret: string, description?: string): Promise<'created' | 'updated'>;
|
|
9
|
+
/**
|
|
10
|
+
* Secret File credential 생성/교체. Jenkins는 파일을 multipart 로 받고
|
|
11
|
+
* json 본문이 "file": "<필드명>" 으로 참조한다 (secretBytes JSON 직접 입력은 불가).
|
|
12
|
+
*/
|
|
9
13
|
export declare function upsertSecretFile(cfg: JenkinsConfig, id: string, fileBase64: string, fileName: string, description?: string): Promise<'created' | 'updated'>;
|
|
10
14
|
export declare function deleteCredential(cfg: JenkinsConfig, id: string): Promise<void>;
|
|
@@ -1,17 +1,45 @@
|
|
|
1
|
+
const FILE_CLASS = 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl';
|
|
2
|
+
const TEXT_CLASS = 'org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl';
|
|
1
3
|
function basicAuth(username, token) {
|
|
2
4
|
return 'Basic ' + Buffer.from(`${username}:${token}`).toString('base64');
|
|
3
5
|
}
|
|
4
|
-
|
|
6
|
+
// 도메인(_ = 전역) 레벨 — 목록 조회 / createCredentials 의 베이스
|
|
7
|
+
function storeBase(url) {
|
|
5
8
|
return `${url.replace(/\/$/, '')}/credentials/store/system/domain/_`;
|
|
6
9
|
}
|
|
10
|
+
// 개별 credential 레벨 — 반드시 /credential/<id> 세그먼트 필요 (조회/업데이트/삭제)
|
|
11
|
+
function credentialBase(url, id) {
|
|
12
|
+
return `${storeBase(url)}/credential/${encodeURIComponent(id)}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* CSRF crumb (best-effort). crumb issuer 비활성이거나 API 토큰으로 면제되면 빈 객체.
|
|
16
|
+
* 구버전 Jenkins / 비밀번호 인증 환경에서 POST 403 방지.
|
|
17
|
+
*/
|
|
18
|
+
async function getCrumb(cfg) {
|
|
19
|
+
try {
|
|
20
|
+
const res = await fetch(`${cfg.url.replace(/\/$/, '')}/crumbIssuer/api/json`, {
|
|
21
|
+
headers: { Authorization: basicAuth(cfg.username, cfg.token) },
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok)
|
|
24
|
+
return {};
|
|
25
|
+
const data = (await res.json());
|
|
26
|
+
if (data.crumbRequestField && data.crumb) {
|
|
27
|
+
return { [data.crumbRequestField]: data.crumb };
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
7
35
|
async function credentialExists(cfg, id) {
|
|
8
|
-
const res = await fetch(`${
|
|
36
|
+
const res = await fetch(`${credentialBase(cfg.url, id)}/api/json`, {
|
|
9
37
|
headers: { Authorization: basicAuth(cfg.username, cfg.token) },
|
|
10
38
|
});
|
|
11
39
|
return res.ok;
|
|
12
40
|
}
|
|
13
41
|
export async function listCredentials(cfg) {
|
|
14
|
-
const res = await fetch(`${
|
|
42
|
+
const res = await fetch(`${storeBase(cfg.url)}/api/json?depth=1`, {
|
|
15
43
|
headers: { Authorization: basicAuth(cfg.username, cfg.token) },
|
|
16
44
|
});
|
|
17
45
|
if (!res.ok)
|
|
@@ -24,60 +52,67 @@ export async function listCredentials(cfg) {
|
|
|
24
52
|
}));
|
|
25
53
|
}
|
|
26
54
|
export async function upsertSecretText(cfg, id, secret, description = '') {
|
|
27
|
-
const
|
|
28
|
-
|
|
55
|
+
const exists = await credentialExists(cfg, id);
|
|
56
|
+
const payload = {
|
|
29
57
|
credentials: {
|
|
30
58
|
scope: 'GLOBAL',
|
|
31
59
|
id,
|
|
32
60
|
description,
|
|
33
61
|
secret,
|
|
34
|
-
|
|
35
|
-
'
|
|
62
|
+
$class: TEXT_CLASS,
|
|
63
|
+
'stapler-class': TEXT_CLASS,
|
|
36
64
|
},
|
|
37
|
-
}
|
|
38
|
-
const base = credentialsBase(cfg.url);
|
|
39
|
-
const exists = await credentialExists(cfg, id);
|
|
65
|
+
};
|
|
40
66
|
const endpoint = exists
|
|
41
|
-
? `${
|
|
42
|
-
: `${
|
|
67
|
+
? `${credentialBase(cfg.url, id)}/updateSubmit`
|
|
68
|
+
: `${storeBase(cfg.url)}/createCredentials`;
|
|
69
|
+
const crumb = await getCrumb(cfg);
|
|
43
70
|
const res = await fetch(endpoint, {
|
|
44
71
|
method: 'POST',
|
|
45
72
|
headers: {
|
|
46
73
|
Authorization: basicAuth(cfg.username, cfg.token),
|
|
47
74
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
75
|
+
...crumb,
|
|
48
76
|
},
|
|
49
|
-
body: new URLSearchParams({ json: payload }).toString(),
|
|
77
|
+
body: new URLSearchParams({ json: JSON.stringify(payload) }).toString(),
|
|
50
78
|
});
|
|
51
79
|
if (!res.ok && res.status !== 302) {
|
|
52
80
|
throw new Error(`Jenkins credential ${exists ? 'update' : 'create'} 실패 (${res.status})`);
|
|
53
81
|
}
|
|
54
82
|
return exists ? 'updated' : 'created';
|
|
55
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Secret File credential 생성/교체. Jenkins는 파일을 multipart 로 받고
|
|
86
|
+
* json 본문이 "file": "<필드명>" 으로 참조한다 (secretBytes JSON 직접 입력은 불가).
|
|
87
|
+
*/
|
|
56
88
|
export async function upsertSecretFile(cfg, id, fileBase64, fileName, description = '') {
|
|
57
|
-
const
|
|
58
|
-
|
|
89
|
+
const exists = await credentialExists(cfg, id);
|
|
90
|
+
const payload = {
|
|
59
91
|
credentials: {
|
|
60
92
|
scope: 'GLOBAL',
|
|
61
93
|
id,
|
|
62
94
|
description,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'stapler-class':
|
|
66
|
-
'$class': 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl',
|
|
95
|
+
file: 'file0',
|
|
96
|
+
$class: FILE_CLASS,
|
|
97
|
+
'stapler-class': FILE_CLASS,
|
|
67
98
|
},
|
|
68
|
-
}
|
|
69
|
-
const
|
|
70
|
-
|
|
99
|
+
};
|
|
100
|
+
const form = new FormData();
|
|
101
|
+
form.append('json', JSON.stringify(payload));
|
|
102
|
+
const bytes = Buffer.from(fileBase64, 'base64');
|
|
103
|
+
form.append('file0', new Blob([bytes]), fileName);
|
|
71
104
|
const endpoint = exists
|
|
72
|
-
? `${
|
|
73
|
-
: `${
|
|
105
|
+
? `${credentialBase(cfg.url, id)}/updateSubmit`
|
|
106
|
+
: `${storeBase(cfg.url)}/createCredentials`;
|
|
107
|
+
const crumb = await getCrumb(cfg);
|
|
108
|
+
// Content-Type 은 fetch 가 multipart boundary 와 함께 자동 설정 — 수동 지정 금지
|
|
74
109
|
const res = await fetch(endpoint, {
|
|
75
110
|
method: 'POST',
|
|
76
111
|
headers: {
|
|
77
112
|
Authorization: basicAuth(cfg.username, cfg.token),
|
|
78
|
-
|
|
113
|
+
...crumb,
|
|
79
114
|
},
|
|
80
|
-
body:
|
|
115
|
+
body: form,
|
|
81
116
|
});
|
|
82
117
|
if (!res.ok && res.status !== 302) {
|
|
83
118
|
throw new Error(`Jenkins secret file credential ${exists ? 'update' : 'create'} 실패 (${res.status})`);
|
|
@@ -85,9 +120,13 @@ export async function upsertSecretFile(cfg, id, fileBase64, fileName, descriptio
|
|
|
85
120
|
return exists ? 'updated' : 'created';
|
|
86
121
|
}
|
|
87
122
|
export async function deleteCredential(cfg, id) {
|
|
88
|
-
const
|
|
123
|
+
const crumb = await getCrumb(cfg);
|
|
124
|
+
const res = await fetch(`${credentialBase(cfg.url, id)}/doDelete`, {
|
|
89
125
|
method: 'POST',
|
|
90
|
-
headers: {
|
|
126
|
+
headers: {
|
|
127
|
+
Authorization: basicAuth(cfg.username, cfg.token),
|
|
128
|
+
...crumb,
|
|
129
|
+
},
|
|
91
130
|
});
|
|
92
131
|
if (!res.ok && res.status !== 302) {
|
|
93
132
|
throw new Error(`Jenkins credential 삭제 실패 (${res.status})`);
|
|
@@ -152,6 +152,10 @@ export function registerAndroidTools(server) {
|
|
|
152
152
|
text: [
|
|
153
153
|
'✅ Android upload keystore 생성 완료',
|
|
154
154
|
'',
|
|
155
|
+
'🔒 아래 비밀번호는 채팅 기록에 평문으로 남습니다.',
|
|
156
|
+
' Jenkins 등록을 마친 뒤에는 이 대화/세션을 삭제하는 것을 권장합니다.',
|
|
157
|
+
' keystore 파일과 비밀번호는 분실 시 앱 서명을 영구히 잃으니 별도 안전한 곳에도 백업하세요.',
|
|
158
|
+
'',
|
|
155
159
|
'── 생성된 값 (지금 바로 Jenkins에 등록하세요) ────',
|
|
156
160
|
`keyAlias: ${ks.keyAlias}`,
|
|
157
161
|
`storePassword: ${ks.storePassword}`,
|
package/package.json
CHANGED