@joripspace/cli 0.7.0 → 0.9.0
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 +286 -252
- package/bin/joripspace.js +34 -163
- package/lib/approval-login.js +88 -0
- package/lib/connection-persistence.js +1 -1
- package/lib/credential-store.js +2 -2
- package/lib/help.js +18 -16
- package/lib/login-command.js +19 -0
- package/lib/project-create.js +1 -1
- package/lib/secret-commands.js +5 -5
- package/lib/start-command.js +12 -11
- package/lib/start.js +50 -16
- package/package.json +1 -1
- package/vendor/core/cli-onboarding.cjs +26 -9
- package/vendor/core/onboarding.cjs +31 -27
- package/vendor/core/secret-entry.cjs +38 -0
package/bin/joripspace.js
CHANGED
|
@@ -6,7 +6,6 @@ const fs = require('node:fs');
|
|
|
6
6
|
const os = require('node:os');
|
|
7
7
|
const path = require('node:path');
|
|
8
8
|
const { spawn } = require('node:child_process');
|
|
9
|
-
const readline = require('node:readline/promises');
|
|
10
9
|
const { formatDeploymentFailure } = require('../lib/deployment-error');
|
|
11
10
|
const {
|
|
12
11
|
printHelp,
|
|
@@ -40,6 +39,16 @@ const { createCredentialStore, normalizeCredentialApiUrl } = require('../lib/cre
|
|
|
40
39
|
const credentialStore = createCredentialStore();
|
|
41
40
|
const { persistProjectConnection } = require('../lib/connection-persistence');
|
|
42
41
|
const { createStartProjectCommand } = require('../lib/start-command');
|
|
42
|
+
const { createApprovalLogin } = require('../lib/approval-login');
|
|
43
|
+
const { createLoginCommand } = require('../lib/login-command');
|
|
44
|
+
const approvalLogin = createApprovalLogin({
|
|
45
|
+
apiRequest,
|
|
46
|
+
openExternalUrl,
|
|
47
|
+
saveToken: (flags, token, apiBaseUrl, options) => saveBrowserConnectTokenWithOptions(
|
|
48
|
+
flags, normalizeConnectToken(token), 'approval-link', apiBaseUrl, options
|
|
49
|
+
),
|
|
50
|
+
});
|
|
51
|
+
const login = createLoginCommand({ ensureProjectEnvIgnored, projectWorkspaceDir, stringFlag, normalizeCredentialApiUrl, unauthenticatedApiBaseUrl, normalizeConnectToken, saveBrowserConnectToken, resolveConnection, approvalLogin });
|
|
43
52
|
const { legacyCredentialSessionConnection, readProjectMarker } = require('../lib/start');
|
|
44
53
|
const { buildTemplateDeployRequest, listTemplates } = loadTemplatesPackage();
|
|
45
54
|
const templateCommands = createTemplateCommands({
|
|
@@ -152,8 +161,8 @@ async function main() {
|
|
|
152
161
|
return;
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
if (command === 'report' && (flags.help || flags.h)) {
|
|
156
|
-
printReportHelp();
|
|
164
|
+
if ((command === 'report' || command === 'feedback') && (flags.help || flags.h)) {
|
|
165
|
+
printReportHelp(command);
|
|
157
166
|
return;
|
|
158
167
|
}
|
|
159
168
|
|
|
@@ -207,6 +216,9 @@ async function main() {
|
|
|
207
216
|
case 'report':
|
|
208
217
|
await reportAgentIssue(flags);
|
|
209
218
|
return;
|
|
219
|
+
case 'feedback':
|
|
220
|
+
await reportAgentIssue({ ...flags, category: 'feedback' });
|
|
221
|
+
return;
|
|
210
222
|
case 'db':
|
|
211
223
|
await dbCommand(rest, flags);
|
|
212
224
|
return;
|
|
@@ -348,50 +360,6 @@ async function main() {
|
|
|
348
360
|
}
|
|
349
361
|
}
|
|
350
362
|
|
|
351
|
-
async function login(flags) {
|
|
352
|
-
const connectionCode = stringFlag(flags, 'code');
|
|
353
|
-
if (connectionCode) {
|
|
354
|
-
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
355
|
-
const exchangeApiBaseUrl = normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags));
|
|
356
|
-
const exchange = await apiRequest(flags, '/v1/auth/connection-code/exchange', {
|
|
357
|
-
method: 'POST',
|
|
358
|
-
body: { code: normalizeConnectionCode(connectionCode) },
|
|
359
|
-
apiBaseUrl: exchangeApiBaseUrl,
|
|
360
|
-
});
|
|
361
|
-
const exchangedToken = normalizeConnectToken(exchange.connect_token);
|
|
362
|
-
await saveBrowserConnectToken(flags, exchangedToken, 'connection-code', exchangeApiBaseUrl);
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
const connectToken =
|
|
366
|
-
stringFlag(flags, 'connect-token') || stringFlag(flags, 'api-token') || stringFlag(flags, 'token');
|
|
367
|
-
if (connectToken) {
|
|
368
|
-
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
369
|
-
await saveBrowserConnectToken(flags, normalizeConnectToken(connectToken));
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
let existing;
|
|
373
|
-
try {
|
|
374
|
-
existing = resolveConnection(flags);
|
|
375
|
-
} catch (error) {
|
|
376
|
-
if (error.code !== 'credential_store_unavailable') throw error;
|
|
377
|
-
// Reauthentication can obtain a new token even when an older OS login is inaccessible.
|
|
378
|
-
}
|
|
379
|
-
if (existing?.apiToken) {
|
|
380
|
-
await saveBrowserConnectToken(
|
|
381
|
-
flags,
|
|
382
|
-
normalizeConnectToken(existing.apiToken),
|
|
383
|
-
existing.source,
|
|
384
|
-
existing.apiBaseUrl
|
|
385
|
-
);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const enteredCode = await promptConnectionCode(flags);
|
|
389
|
-
if (enteredCode !== null) {
|
|
390
|
-
await login({ ...flags, code: normalizeConnectionCode(enteredCode) });
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
output(flags, browserConnectInstructions(), printBrowserConnectInstructions);
|
|
394
|
-
}
|
|
395
363
|
|
|
396
364
|
async function saveBrowserConnectToken(flags, apiToken, source = 'browser-connect', selectedApiBaseUrl = '') {
|
|
397
365
|
return saveBrowserConnectTokenWithOptions(flags, apiToken, source, selectedApiBaseUrl);
|
|
@@ -503,7 +471,17 @@ async function saveBrowserConnectTokenWithOptions(
|
|
|
503
471
|
const storage = persistProjectConnection(credentialStore, workspaceDir, { ...connection, accountId: body.account_id });
|
|
504
472
|
scrubGlobalSessionToken();
|
|
505
473
|
if (options.output !== false) {
|
|
506
|
-
|
|
474
|
+
const next = {
|
|
475
|
+
status: 'connected',
|
|
476
|
+
next_action: selected ? 'run_start_project' : 'choose_project_then_run_start',
|
|
477
|
+
...(selected ? { next_command: {
|
|
478
|
+
command: process.execPath,
|
|
479
|
+
args: [...(process.pkg ? [] : [path.resolve(process.argv[1])]), 'start', selected.project_slug || selected.project_id,
|
|
480
|
+
'--cwd', workspaceDir, '--api-url', connection.apiBaseUrl, '--json'],
|
|
481
|
+
cwd: workspaceDir,
|
|
482
|
+
} } : {}),
|
|
483
|
+
};
|
|
484
|
+
output(flags, { ...body, credential_storage: storage, ...next }, (value) => {
|
|
507
485
|
console.log(message(`Connected: ${value.account_id}`, `연결 완료: ${value.account_id}`));
|
|
508
486
|
console.log(
|
|
509
487
|
storage === 'project-env-fallback' ? message(
|
|
@@ -1200,6 +1178,7 @@ async function apiRequest(flags, apiPath, options) {
|
|
|
1200
1178
|
options.apiToken,
|
|
1201
1179
|
options.adminToken,
|
|
1202
1180
|
options.body?.code,
|
|
1181
|
+
options.body?.request_secret,
|
|
1203
1182
|
])
|
|
1204
1183
|
);
|
|
1205
1184
|
requestError.code = 'request_failed';
|
|
@@ -1211,7 +1190,7 @@ async function apiRequest(flags, apiPath, options) {
|
|
|
1211
1190
|
const body = text ? parseJson(text) : {};
|
|
1212
1191
|
|
|
1213
1192
|
if (!response.ok) {
|
|
1214
|
-
const safe = redactAuthError(body, [options.apiToken, options.adminToken, options.body?.code]);
|
|
1193
|
+
const safe = redactAuthError(body, [options.apiToken, options.adminToken, options.body?.code, options.body?.request_secret]);
|
|
1215
1194
|
const message =
|
|
1216
1195
|
safe?.error?.message || safe?.message || JSON.stringify(safe) || `HTTP ${response.status}`;
|
|
1217
1196
|
const apiError = new Error(formatDeploymentFailure(message, safe?.error?.details));
|
|
@@ -1236,41 +1215,6 @@ function isDeploymentMutation(apiPath, method) {
|
|
|
1236
1215
|
return method === 'POST' && (/\/deploy(?:[/?]|$)/.test(apiPath) || /\/rollback(?:[/?]|$)/.test(apiPath));
|
|
1237
1216
|
}
|
|
1238
1217
|
|
|
1239
|
-
function browserConnectInstructions() {
|
|
1240
|
-
return {
|
|
1241
|
-
status: 'browser_connection_required',
|
|
1242
|
-
connect_url: 'https://joripspace.com/connect/',
|
|
1243
|
-
message: message(
|
|
1244
|
-
'No email address is required. Sign in to JoripSpace in your browser, approve the connection, and copy the one-time code, valid for five minutes.',
|
|
1245
|
-
'이메일 주소는 필요 없습니다. 브라우저에서 JoripSpace에 로그인한 뒤 연결을 승인하고 5분 일회용 연결 코드를 복사하세요.'
|
|
1246
|
-
),
|
|
1247
|
-
save_command: 'joripspace login --code "CONNECTION_CODE"',
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
function printBrowserConnectInstructions(value) {
|
|
1252
|
-
console.log(
|
|
1253
|
-
message(
|
|
1254
|
-
'Approve the JoripSpace connection in your browser.',
|
|
1255
|
-
'브라우저에서 JoripSpace 연결을 승인하세요.'
|
|
1256
|
-
)
|
|
1257
|
-
);
|
|
1258
|
-
console.log(
|
|
1259
|
-
message(
|
|
1260
|
-
'No email address or email verification is required.',
|
|
1261
|
-
'이메일 주소 입력이나 메일 확인은 필요 없습니다.'
|
|
1262
|
-
)
|
|
1263
|
-
);
|
|
1264
|
-
console.log(message(`Connection page: ${value.connect_url}`, `연결 페이지: ${value.connect_url}`));
|
|
1265
|
-
console.log(
|
|
1266
|
-
message(
|
|
1267
|
-
'After approval, exchange the displayed five-minute one-time code using this command.',
|
|
1268
|
-
'승인 후 화면에 표시되는 5분 일회용 연결 코드를 아래 명령으로 교환하세요.'
|
|
1269
|
-
)
|
|
1270
|
-
);
|
|
1271
|
-
console.log(value.save_command);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
1218
|
function normalizeConnectToken(value) {
|
|
1275
1219
|
const token = String(value || '').trim();
|
|
1276
1220
|
if (!token) {
|
|
@@ -1284,29 +1228,14 @@ function normalizeConnectToken(value) {
|
|
|
1284
1228
|
) {
|
|
1285
1229
|
throw new Error(
|
|
1286
1230
|
message(
|
|
1287
|
-
'Browser cookies, Bearer strings, empty placeholders, and test values cannot be used as CLI connection tokens.
|
|
1288
|
-
'브라우저 쿠키, Bearer 문자열, 빈 자리표시자, 테스트 값은 CLI 연결 토큰으로 사용할 수 없습니다.
|
|
1231
|
+
'Browser cookies, Bearer strings, empty placeholders, and test values cannot be used as CLI connection tokens. Run login to approve a new connection.',
|
|
1232
|
+
'브라우저 쿠키, Bearer 문자열, 빈 자리표시자, 테스트 값은 CLI 연결 토큰으로 사용할 수 없습니다. login을 실행해 새 연결을 승인하세요.'
|
|
1289
1233
|
)
|
|
1290
1234
|
);
|
|
1291
1235
|
}
|
|
1292
1236
|
return token;
|
|
1293
1237
|
}
|
|
1294
1238
|
|
|
1295
|
-
function normalizeConnectionCode(value) {
|
|
1296
|
-
const normalized = String(value || '')
|
|
1297
|
-
.replace(/[\s-]+/g, '')
|
|
1298
|
-
.toUpperCase();
|
|
1299
|
-
if (!/^[0-9A-HJKMNP-TV-Z]{16}$/.test(normalized)) {
|
|
1300
|
-
throw new Error(
|
|
1301
|
-
message(
|
|
1302
|
-
'The connection code must be the 16-character alphanumeric value shown on the connection page.',
|
|
1303
|
-
'연결 코드는 화면에 표시된 16자리 영숫자 값이어야 합니다.'
|
|
1304
|
-
)
|
|
1305
|
-
);
|
|
1306
|
-
}
|
|
1307
|
-
return normalized.match(/.{1,4}/g).join('-');
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
1239
|
function parseArgs(argv) {
|
|
1311
1240
|
const flags = {};
|
|
1312
1241
|
const positional = [];
|
|
@@ -1629,72 +1558,14 @@ function canonicalWorkspaceEntry(directory, expected) {
|
|
|
1629
1558
|
}
|
|
1630
1559
|
|
|
1631
1560
|
async function connectForStart(flags, context) {
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
connectionCode = await promptConnectionCode(flags);
|
|
1635
|
-
if (connectionCode === null) return resolveConnection(flags);
|
|
1561
|
+
if (flags.code !== undefined || flags['legacy-code'] !== undefined) {
|
|
1562
|
+
throw Object.assign(new Error('Run login to approve the connection in your browser.'), { code: 'unsupported_login_option' });
|
|
1636
1563
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
ensureProjectEnvIgnored(context.cwd);
|
|
1640
|
-
const exchange = await apiRequest(flags, '/v1/auth/connection-code/exchange', {
|
|
1641
|
-
method: 'POST',
|
|
1642
|
-
body: { code: normalizeConnectionCode(connectionCode) },
|
|
1643
|
-
apiBaseUrl: exchangeApiBaseUrl,
|
|
1644
|
-
});
|
|
1645
|
-
const exchangedToken = normalizeConnectToken(exchange.connect_token);
|
|
1646
|
-
await saveBrowserConnectTokenWithOptions(
|
|
1647
|
-
{ ...flags, cwd: context.cwd },
|
|
1648
|
-
exchangedToken,
|
|
1649
|
-
'connection-code',
|
|
1650
|
-
exchangeApiBaseUrl,
|
|
1651
|
-
{ output: false }
|
|
1652
|
-
);
|
|
1564
|
+
if (flags.json || !process.stdin.isTTY || !process.stdout.isTTY) return resolveConnection(flags);
|
|
1565
|
+
await approvalLogin.login({ ...flags, cwd: context.cwd }, normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags)), { output: false });
|
|
1653
1566
|
return resolveConnection({ ...flags, cwd: context.cwd });
|
|
1654
1567
|
}
|
|
1655
1568
|
|
|
1656
|
-
async function promptConnectionCode(flags) {
|
|
1657
|
-
if (flags.json || !process.stdin.isTTY || !process.stdout.isTTY) return null;
|
|
1658
|
-
const instructions = browserConnectInstructions();
|
|
1659
|
-
console.log(
|
|
1660
|
-
message(
|
|
1661
|
-
'Approve the JoripSpace connection in your browser.',
|
|
1662
|
-
'브라우저에서 JoripSpace 연결을 승인하세요.'
|
|
1663
|
-
)
|
|
1664
|
-
);
|
|
1665
|
-
console.log(
|
|
1666
|
-
message(`Connection page: ${instructions.connect_url}`, `연결 페이지: ${instructions.connect_url}`)
|
|
1667
|
-
);
|
|
1668
|
-
console.log(
|
|
1669
|
-
message(
|
|
1670
|
-
'After approval, paste the displayed five-minute one-time code into this terminal.',
|
|
1671
|
-
'승인 후 표시된 5분 일회용 연결 코드를 이 터미널에 붙여 넣으세요.'
|
|
1672
|
-
)
|
|
1673
|
-
);
|
|
1674
|
-
openExternalUrl(instructions.connect_url);
|
|
1675
|
-
const prompt = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1676
|
-
const cancellation = new AbortController();
|
|
1677
|
-
prompt.once('close', () => cancellation.abort());
|
|
1678
|
-
try {
|
|
1679
|
-
return await prompt.question(message('Connection code: ', '연결 코드: '), {
|
|
1680
|
-
signal: cancellation.signal,
|
|
1681
|
-
});
|
|
1682
|
-
} catch (error) {
|
|
1683
|
-
if (error?.code !== 'ABORT_ERR') throw error;
|
|
1684
|
-
const cancelled = new Error(
|
|
1685
|
-
message(
|
|
1686
|
-
'Connection code entry was cancelled. Run login again.',
|
|
1687
|
-
'연결 코드 입력이 취소되었습니다. login을 다시 실행하세요.'
|
|
1688
|
-
)
|
|
1689
|
-
);
|
|
1690
|
-
cancelled.code = 'connection_required';
|
|
1691
|
-
cancelled.exitCode = 2;
|
|
1692
|
-
throw cancelled;
|
|
1693
|
-
} finally {
|
|
1694
|
-
prompt.close();
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
1569
|
function openExternalUrl(url) {
|
|
1699
1570
|
const command =
|
|
1700
1571
|
process.platform === 'win32'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const { message } = require('./locale');
|
|
2
|
+
|
|
3
|
+
function createApprovalLogin({
|
|
4
|
+
apiRequest,
|
|
5
|
+
openExternalUrl,
|
|
6
|
+
saveToken,
|
|
7
|
+
writePending = (value) => console.error(JSON.stringify(value)),
|
|
8
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
9
|
+
}) {
|
|
10
|
+
async function supported(flags, apiBaseUrl) {
|
|
11
|
+
try {
|
|
12
|
+
const result = await apiRequest(flags, '/v1/auth/approval-link/capabilities', {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
apiBaseUrl,
|
|
15
|
+
});
|
|
16
|
+
return result.approval_link === true && result.version === 1;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if ([404, 405].includes(error.status)) return false;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function login(flags, apiBaseUrl, { output = true } = {}) {
|
|
23
|
+
if (!(await supported(flags, apiBaseUrl))) throw Object.assign(new Error('This server does not support approval-link login. Update the server before reconnecting.'), { code: 'approval_link_unsupported' });
|
|
24
|
+
const request = await apiRequest(flags, '/v1/auth/approval-link/requests', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
apiBaseUrl,
|
|
27
|
+
body: { client: 'cli' },
|
|
28
|
+
});
|
|
29
|
+
const url = new URL(request.approval_url);
|
|
30
|
+
if (
|
|
31
|
+
url.href !== `https://joripspace.com/connect/device/?request=${request.request_id}` ||
|
|
32
|
+
url.searchParams.get('request') !== request.request_id ||
|
|
33
|
+
!/^[A-Za-z0-9_-]{32,128}$/.test(request.request_id || '') ||
|
|
34
|
+
!/^[A-Za-z0-9_-]{32,128}$/.test(request.request_secret || '') ||
|
|
35
|
+
!Number.isFinite(Date.parse(request.expires_at)) ||
|
|
36
|
+
Date.parse(request.expires_at) > Date.now() + 310000
|
|
37
|
+
) {
|
|
38
|
+
throw new Error('Invalid approval-link response.');
|
|
39
|
+
}
|
|
40
|
+
// Only the public URL leaves this process. The polling secret stays in memory.
|
|
41
|
+
writePending({
|
|
42
|
+
status: 'approval_pending',
|
|
43
|
+
approval_url: url.href,
|
|
44
|
+
expires_at: request.expires_at,
|
|
45
|
+
next_action: 'ask_user_to_approve_then_wait',
|
|
46
|
+
interval: 5,
|
|
47
|
+
message: message(
|
|
48
|
+
'Open the link and approve the connection. No code entry is needed.',
|
|
49
|
+
'링크를 열어 연결을 승인하세요. 코드 입력은 필요하지 않습니다.'
|
|
50
|
+
),
|
|
51
|
+
});
|
|
52
|
+
if (!flags['no-open']) openExternalUrl(url.href);
|
|
53
|
+
while (Date.now() < Date.parse(request.expires_at)) {
|
|
54
|
+
const result = await apiRequest(flags, '/v1/auth/approval-link/status', {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
apiBaseUrl,
|
|
57
|
+
body: { request_id: request.request_id, request_secret: request.request_secret },
|
|
58
|
+
});
|
|
59
|
+
if (result.status === 'connected') {
|
|
60
|
+
await saveToken(flags, result.connect_token, apiBaseUrl, { output });
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (result.status !== 'pending') {
|
|
64
|
+
const error = new Error(
|
|
65
|
+
message(
|
|
66
|
+
`Connection approval ${result.status}. Run login to try again.`,
|
|
67
|
+
`연결 승인 상태: ${result.status}. 다시 시도하려면 login을 실행하세요.`
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
error.code = `approval_${result.status}`;
|
|
71
|
+
error.details = { status: result.status, next_action: 'stop_and_report_approval_result' };
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
await sleep(Math.max(5, Math.min(30, Number(result.interval) || 5)) * 1000);
|
|
75
|
+
}
|
|
76
|
+
const error = new Error(
|
|
77
|
+
message(
|
|
78
|
+
'The connection approval link expired. Run login again.',
|
|
79
|
+
'연결 승인 링크가 만료되었습니다. login을 다시 실행하세요.'
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
error.code = 'approval_expired';
|
|
83
|
+
error.details = { status: 'expired', next_action: 'ask_user_before_starting_new_approval' };
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
return { supported, login };
|
|
87
|
+
}
|
|
88
|
+
module.exports = { createApprovalLogin };
|
|
@@ -7,7 +7,7 @@ function persistProjectConnection(store, workspaceDir, connection) {
|
|
|
7
7
|
const apiBaseUrl = normalizeCredentialApiUrl(connection.apiBaseUrl);
|
|
8
8
|
if (!connection.accountId || typeof connection.accountId !== 'string' ||
|
|
9
9
|
typeof connection.apiToken !== 'string' || !connection.apiToken.trim() || /[\r\n]/.test(connection.apiToken)) {
|
|
10
|
-
const error = new Error('Invalid connection credentials. Reconnect with login
|
|
10
|
+
const error = new Error('Invalid connection credentials. Reconnect with login.');
|
|
11
11
|
error.code = 'credential_store_invalid';
|
|
12
12
|
throw error;
|
|
13
13
|
}
|
package/lib/credential-store.js
CHANGED
|
@@ -7,8 +7,8 @@ function storeError(code = 'credential_store_unavailable') {
|
|
|
7
7
|
const error = new Error(
|
|
8
8
|
code === 'credential_store_invalid'
|
|
9
9
|
? message(
|
|
10
|
-
'The JoripSpace connection in the OS credential store is invalid. Reconnect with login
|
|
11
|
-
'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login
|
|
10
|
+
'The JoripSpace connection in the OS credential store is invalid. Reconnect with login.',
|
|
11
|
+
'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login로 다시 연결하세요.'
|
|
12
12
|
)
|
|
13
13
|
: message(
|
|
14
14
|
'The OS credential store could not complete this operation. Check Windows Credential Manager, macOS Keychain, or Linux Secret Service. Login uses .env.joripspace only when the store is unavailable before writing; failed writes or verification are not bypassed.',
|
package/lib/help.js
CHANGED
|
@@ -6,15 +6,14 @@ function printHelp() {
|
|
|
6
6
|
|
|
7
7
|
Usage:
|
|
8
8
|
joripspace login
|
|
9
|
-
joripspace login --
|
|
10
|
-
joripspace login --connect-token "CONNECTION_TOKEN" --cwd PROJECT_FOLDER
|
|
9
|
+
joripspace login --no-open --cwd PROJECT_FOLDER --json
|
|
11
10
|
joripspace logout
|
|
12
11
|
joripspace me
|
|
13
12
|
joripspace projects
|
|
14
13
|
joripspace create --name NAME
|
|
15
14
|
joripspace create --name NAME --agree-noncommercial --agree-billing --agree-retention --json
|
|
16
15
|
joripspace link --project PROJECT --cwd PATH
|
|
17
|
-
joripspace start PROJECT --cwd PATH --json
|
|
16
|
+
joripspace start PROJECT --cwd PATH [--guide-only] --json
|
|
18
17
|
joripspace github prepare --project PROJECT --cwd PATH [--entrypoint worker.js]
|
|
19
18
|
joripspace knowledge search --query "USER_REQUEST"
|
|
20
19
|
joripspace realtime-v2 docs
|
|
@@ -42,6 +41,7 @@ Usage:
|
|
|
42
41
|
joripspace template pull --project PROJECT --token TOKEN --dir . [--yes]
|
|
43
42
|
joripspace get --project PROJECT --token TOKEN
|
|
44
43
|
joripspace report --project PROJECT --category problem|bug|feedback --summary "REPORT_SUMMARY" [--details TEXT] [--expected TEXT] [--actual TEXT] [--error-code CODE]
|
|
44
|
+
joripspace feedback --project PROJECT --summary "FEEDBACK_SUMMARY" [--details TEXT] [--expected TEXT] [--actual TEXT] [--error-code CODE]
|
|
45
45
|
joripspace deployments --project PROJECT --token TOKEN [--include-failure-details] [--json]
|
|
46
46
|
joripspace deployment get --project PROJECT --deployment DEPLOYMENT_ID --json
|
|
47
47
|
joripspace deployment pull --project PROJECT --deployment DEPLOYMENT_ID --cwd PATH [--force]
|
|
@@ -55,6 +55,7 @@ Usage:
|
|
|
55
55
|
joripspace rollback --project PROJECT --token TOKEN --deployment DEPLOYMENT_ID
|
|
56
56
|
joripspace secrets --project PROJECT
|
|
57
57
|
joripspace secret list --project PROJECT
|
|
58
|
+
joripspace secret list --project PROJECT --name API_KEY --json
|
|
58
59
|
joripspace secret generate --project PROJECT --name SESSION_SECRET
|
|
59
60
|
joripspace secret set --project PROJECT --name API_KEY --value-stdin
|
|
60
61
|
joripspace secret update --project PROJECT --name API_KEY --value-stdin
|
|
@@ -81,12 +82,12 @@ Environment:
|
|
|
81
82
|
JORIPSPACE_CONNECT_TOKEN Used when no API token is provided
|
|
82
83
|
|
|
83
84
|
Login:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
Reuse existing valid logins; otherwise login creates a five-minute approval link.
|
|
86
|
+
Agents run login --no-open --json and show approval_url from stderr.
|
|
87
|
+
Keep the process running; stdout returns one final JSON result with next_action.
|
|
88
|
+
The user signs in and approves. No code entry is needed.
|
|
89
|
+
--no-open prevents launching a browser. Errors never trigger another authentication flow.
|
|
90
|
+
If authentication is missing, do not inspect cookies, browser storage or profile pages.
|
|
90
91
|
New logins store tokens in Windows Credential Manager, macOS Keychain, or Linux Secret Service.
|
|
91
92
|
Saved connections are reused in other project folders on the same OS user account.
|
|
92
93
|
New logins prefer the OS credential store. If unavailable before writing, the token is saved
|
|
@@ -119,7 +120,7 @@ Security:
|
|
|
119
120
|
Manage members, billing, token issuance, webhooks, and project deletion in the web UI.
|
|
120
121
|
tokens current returns the current token ID without its secret.
|
|
121
122
|
tokens revoke disables a token server-side within your account. --current ends this connection;
|
|
122
|
-
|
|
123
|
+
run login to reconnect by approval link. logout only removes local credentials.
|
|
123
124
|
|
|
124
125
|
${message('Language', '언어')}:
|
|
125
126
|
${message('Messages follow the OS default locale: Korean or English. Unsupported locales use English.', '안내는 OS 기본 로캘에 따라 한국어 또는 영어로 표시합니다. 미지원 로캘은 영어를 사용합니다.')}
|
|
@@ -133,17 +134,18 @@ Global flags:
|
|
|
133
134
|
`);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
function printReportHelp() {
|
|
137
|
-
|
|
137
|
+
function printReportHelp(command = 'report') {
|
|
138
|
+
const feedback = command === 'feedback';
|
|
139
|
+
console.log(`JoripSpace ${command}
|
|
138
140
|
|
|
139
141
|
Submit a project-related problem, bug, or improvement suggestion to JoripSpace.
|
|
140
142
|
|
|
141
143
|
Usage:
|
|
142
|
-
joripspace
|
|
144
|
+
joripspace ${command} --project PROJECT ${feedback ? '' : '--category problem|bug|feedback '}--summary "SUMMARY"
|
|
143
145
|
|
|
144
146
|
Options:
|
|
145
147
|
--project PROJECT Existing project name; defaults to the current linked project.
|
|
146
|
-
--category TYPE problem (default), bug, or feedback (suggestions and improvements).
|
|
148
|
+
${feedback ? ' Category is always feedback. This command wraps report --category feedback.' : ' --category TYPE problem (default), bug, or feedback (suggestions and improvements).'}
|
|
147
149
|
--summary TEXT Required summary, up to 160 characters. --message is an alias.
|
|
148
150
|
--details TEXT Context or reproduction steps, up to 8000 characters.
|
|
149
151
|
--expected TEXT Expected behavior or desired improvement, up to 4000 characters.
|
|
@@ -153,8 +155,8 @@ Options:
|
|
|
153
155
|
--json Return structured success or failure without prompting.
|
|
154
156
|
|
|
155
157
|
Examples:
|
|
156
|
-
joripspace
|
|
157
|
-
joripspace
|
|
158
|
+
joripspace ${command}${feedback ? '' : ' --category bug'} --summary "${feedback ? 'Add filtering to deployment history' : 'Deployment status is incorrect'}"
|
|
159
|
+
joripspace feedback --summary "Add filtering to deployment history"
|
|
158
160
|
|
|
159
161
|
The command sends a report; it does not just save a local draft.
|
|
160
162
|
Use an existing login. Never include credentials, personal data, or private source.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function createLoginCommand({ ensureProjectEnvIgnored, projectWorkspaceDir, stringFlag, normalizeCredentialApiUrl, unauthenticatedApiBaseUrl, normalizeConnectToken, saveBrowserConnectToken, resolveConnection, approvalLogin }) {
|
|
2
|
+
return async function login(flags) {
|
|
3
|
+
if (flags['connect-token'] !== undefined || flags.code !== undefined || flags['legacy-code'] !== undefined) {
|
|
4
|
+
throw Object.assign(new Error('Run login without code options to approve the connection in your browser.'), { code: 'unsupported_login_option' });
|
|
5
|
+
}
|
|
6
|
+
let existing;
|
|
7
|
+
try { existing = resolveConnection(flags); }
|
|
8
|
+
catch (error) { if (error.code !== 'credential_store_unavailable') throw error; }
|
|
9
|
+
if (existing?.apiToken) {
|
|
10
|
+
try {
|
|
11
|
+
await saveBrowserConnectToken(flags, normalizeConnectToken(existing.apiToken), existing.source, existing.apiBaseUrl);
|
|
12
|
+
return;
|
|
13
|
+
} catch (error) { if (error.status !== 401) throw error; }
|
|
14
|
+
}
|
|
15
|
+
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
16
|
+
await approvalLogin.login({ ...flags, 'no-open': flags['no-open'] || !!flags.json }, normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags)));
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
module.exports = { createLoginCommand };
|
package/lib/project-create.js
CHANGED
|
@@ -140,7 +140,7 @@ function loginRequired(name) {
|
|
|
140
140
|
);
|
|
141
141
|
error.exitCode = 2;
|
|
142
142
|
error.details = {
|
|
143
|
-
|
|
143
|
+
connection_method: 'approval_link',
|
|
144
144
|
login_args: ['login', '--json'],
|
|
145
145
|
resume_args: ['create', '--name', name, '--json'],
|
|
146
146
|
next_action: 'login-then-retry-create; obtain-explicit-agreement-after-login',
|
package/lib/secret-commands.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { message } = require('./locale');
|
|
2
|
-
|
|
3
|
-
function secretManagementUrl(project) {
|
|
4
|
-
return `https://joripspace.com/projects/${encodeURIComponent(project)}/?tab=secrets`;
|
|
5
|
-
}
|
|
2
|
+
const { secretEntryName, secretManagementUrl, secretEntryHandoff } = require('../vendor/core/secret-entry.cjs');
|
|
6
3
|
|
|
7
4
|
function createSecretCommands(deps) {
|
|
8
5
|
return async function secrets(rest, flags) {
|
|
@@ -14,12 +11,15 @@ function createSecretCommands(deps) {
|
|
|
14
11
|
throw new Error('secret command requires: list, generate, set, or update');
|
|
15
12
|
}
|
|
16
13
|
const project = deps.requireProjectId(flags);
|
|
17
|
-
const
|
|
14
|
+
const requestedName = deps.stringFlag(flags, 'name');
|
|
15
|
+
if (requestedName && !secretEntryName(requestedName)) throw new Error('Invalid or reserved secret name.');
|
|
16
|
+
const url = secretManagementUrl(project, requestedName);
|
|
18
17
|
const auth = deps.projectAuth(flags);
|
|
19
18
|
const endpoint = `/v1/projects/${encodeURIComponent(project)}/secrets`;
|
|
20
19
|
let result;
|
|
21
20
|
if (subcommand === 'list') {
|
|
22
21
|
result = await deps.apiRequest(flags, endpoint, { method: 'GET', ...auth });
|
|
22
|
+
if (requestedName) result = { ...result, secret_entry: secretEntryHandoff(project, requestedName, result.secrets || []) };
|
|
23
23
|
} else {
|
|
24
24
|
const name = deps.stringFlag(flags, 'name').toUpperCase();
|
|
25
25
|
if (!name || !/^[_A-Z][_A-Z0-9]{0,127}$/.test(name)) {
|
package/lib/start-command.js
CHANGED
|
@@ -28,7 +28,8 @@ function createStartProjectCommand(
|
|
|
28
28
|
: projectWorkspaceDir(flags);
|
|
29
29
|
const cwd = resolveProjectRoot(requestedCwd, 'git');
|
|
30
30
|
readProjectEnv(cwd);
|
|
31
|
-
|
|
31
|
+
const guideOnly = flags['guide-only'] === true || flags['guide-only'] === 'true';
|
|
32
|
+
if (!guideOnly && fs.existsSync(path.join(cwd, '.env.joripspace'))) {
|
|
32
33
|
ensureProjectEnvIgnored(cwd);
|
|
33
34
|
}
|
|
34
35
|
const executable = path.resolve(
|
|
@@ -46,25 +47,24 @@ function createStartProjectCommand(
|
|
|
46
47
|
const apiUrlArgument = connection?.apiBaseUrl
|
|
47
48
|
? ` --api-url ${quoteCliArgument(connection.apiBaseUrl)}`
|
|
48
49
|
: '';
|
|
50
|
+
const loginMethod = `--no-open --project ${quoteCliArgument(project)}`;
|
|
49
51
|
const invocation = `${executable === path.resolve(process.argv[1] || '') ? quoteCliArgument(process.execPath) + ' ' : ''}${quoteCliArgument(executable)}`;
|
|
50
|
-
const loginCommand = `${invocation} login
|
|
51
|
-
const resumeCommand = `${invocation} start ${quoteCliArgument(project)} --cwd ${quoteCliArgument(cwd)} --json`;
|
|
52
|
+
const loginCommand = `${invocation} login ${loginMethod} --cwd ${quoteCliArgument(cwd)}${apiUrlArgument} --json`;
|
|
53
|
+
const resumeCommand = `${invocation} start ${quoteCliArgument(project)} --cwd ${quoteCliArgument(cwd)}${guideOnly ? ' --guide-only' : ''} --json`;
|
|
52
54
|
const value = {
|
|
53
55
|
ok: false,
|
|
54
56
|
status: 'connection_required',
|
|
55
57
|
project,
|
|
56
58
|
cwd,
|
|
57
59
|
executable,
|
|
58
|
-
|
|
59
|
-
message: message(
|
|
60
|
-
'Approve the connection in your browser and exchange the displayed five-minute one-time code first.',
|
|
61
|
-
'브라우저에서 연결을 승인하고 표시된 5분 일회용 연결 코드를 먼저 교환하세요.'
|
|
62
|
-
),
|
|
60
|
+
message: message('Run login_command, show its approval_url to the user, wait for approval, then run resume_command.', 'login_command를 실행하고 반환된 승인 링크를 사용자에게 보여주세요. 연결 완료 후 resume_command를 실행하세요.'),
|
|
63
61
|
login_command: loginCommand,
|
|
64
62
|
resume_command: resumeCommand,
|
|
65
63
|
next_action: 'run-login-command-then-resume-command',
|
|
64
|
+
connection_method: 'approval_link',
|
|
65
|
+
next_command: createStartOnboarding(executable, cwd, project, false, connection?.apiBaseUrl, '', guideOnly).commands.login,
|
|
66
66
|
continue_with: 'cli',
|
|
67
|
-
onboarding: createStartOnboarding(executable, cwd, project, false, connection?.apiBaseUrl),
|
|
67
|
+
onboarding: createStartOnboarding(executable, cwd, project, false, connection?.apiBaseUrl, '', guideOnly),
|
|
68
68
|
};
|
|
69
69
|
throw startCommandError(value.status, value.message, value);
|
|
70
70
|
}
|
|
@@ -82,6 +82,7 @@ function createStartProjectCommand(
|
|
|
82
82
|
apiToken,
|
|
83
83
|
apiRequest: (apiPath, options) => apiRequest(connectionFlags, apiPath, options),
|
|
84
84
|
executable,
|
|
85
|
+
guideOnly,
|
|
85
86
|
allowLegacyCredentialSession: connection.source === 'legacy-project-session',
|
|
86
87
|
beforeWorkspaceMigration: persistConnection
|
|
87
88
|
? (context) => persistConnection(resolvedFlags, connection, context)
|
|
@@ -89,7 +90,7 @@ function createStartProjectCommand(
|
|
|
89
90
|
}).catch((error) => {
|
|
90
91
|
error.details = {
|
|
91
92
|
...error.details,
|
|
92
|
-
onboarding: createStartOnboarding(executable, cwd, project, false, connection.apiBaseUrl),
|
|
93
|
+
onboarding: createStartOnboarding(executable, cwd, project, false, connection.apiBaseUrl, '', guideOnly),
|
|
93
94
|
};
|
|
94
95
|
throw error;
|
|
95
96
|
});
|
|
@@ -107,7 +108,7 @@ function createStartProjectCommand(
|
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
if (!value.ok) {
|
|
110
|
-
value.onboarding = createStartOnboarding(executable, cwd, project, false, connection.apiBaseUrl);
|
|
111
|
+
value.onboarding = createStartOnboarding(executable, cwd, project, false, connection.apiBaseUrl, '', guideOnly);
|
|
111
112
|
throw startCommandError(
|
|
112
113
|
value.status || 'start_incomplete',
|
|
113
114
|
`JoripSpace start stopped: ${value.status || 'incomplete'}`,
|