@joripspace/cli 0.7.0 → 0.8.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.
@@ -1,137 +1,137 @@
1
- # Third-party notices
2
-
3
- JoripSpace CLI is licensed under MIT. The dependencies below retain their own licenses and copyrights.
4
- They are installed separately by npm, not bundled into the CLI tarball. These notices record the versions in package-lock.json; other installed versions retain their accompanying licenses.
5
-
6
- ## fflate 0.8.3 — MIT
7
-
8
- https://www.npmjs.com/package/fflate/v/0.8.3
9
-
10
- MIT License
11
-
12
- Copyright (c) 2026 Arjun Barrett
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- The above copyright notice and this permission notice shall be included in all
22
- copies or substantial portions of the Software.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- SOFTWARE.
31
-
32
- ## jsonc-parser 3.3.1 — MIT
33
-
34
- https://www.npmjs.com/package/jsonc-parser/v/3.3.1
35
-
36
- The MIT License (MIT)
37
-
38
- Copyright (c) Microsoft
39
-
40
- Permission is hereby granted, free of charge, to any person obtaining a copy
41
- of this software and associated documentation files (the "Software"), to deal
42
- in the Software without restriction, including without limitation the rights
43
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
- copies of the Software, and to permit persons to whom the Software is
45
- furnished to do so, subject to the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be included in all
48
- copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
- SOFTWARE.
57
-
58
- ## smol-toml 1.9.1 — BSD-3-Clause
59
-
60
- https://www.npmjs.com/package/smol-toml/v/1.9.1
61
-
62
- Copyright (c) Squirrel Chat et al., All rights reserved.
63
-
64
- Redistribution and use in source and binary forms, with or without
65
- modification, are permitted provided that the following conditions are met:
66
-
67
- 1. Redistributions of source code must retain the above copyright notice, this
68
- list of conditions and the following disclaimer.
69
- 2. Redistributions in binary form must reproduce the above copyright notice,
70
- this list of conditions and the following disclaimer in the
71
- documentation and/or other materials provided with the distribution.
72
- 3. Neither the name of the copyright holder nor the names of its contributors
73
- may be used to endorse or promote products derived from this software without
74
- specific prior written permission.
75
-
76
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
77
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
79
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
80
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
81
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
82
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
83
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
84
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86
-
87
- ## @napi-rs/keyring 2.1.2
88
-
89
- MIT License
90
-
91
- Copyright (c) 2020 N-API for Rust
92
-
93
- Permission is hereby granted, free of charge, to any person obtaining a copy
94
- of this software and associated documentation files (the "Software"), to deal
95
- in the Software without restriction, including without limitation the rights
96
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97
- copies of the Software, and to permit persons to whom the Software is
98
- furnished to do so, subject to the following conditions:
99
-
100
- The above copyright notice and this permission notice shall be included in all
101
- copies or substantial portions of the Software.
102
-
103
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
109
- SOFTWARE.
110
-
111
- Platform binaries are npm dependencies; their bundled Rust dependency notices are included in each platform package's LICENSE.third-party.md. The Linux binary includes libdbus under AFL-2.1 OR GPL-2.0-or-later, with full license texts preserved in that dependency.
112
-
113
- ## ignore 7.0.12 — MIT
114
-
115
- https://www.npmjs.com/package/ignore/v/7.0.12
116
-
117
- Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
118
- http://kael.me/
119
-
120
- Permission is hereby granted, free of charge, to any person obtaining
121
- a copy of this software and associated documentation files (the
122
- "Software"), to deal in the Software without restriction, including
123
- without limitation the rights to use, copy, modify, merge, publish,
124
- distribute, sublicense, and/or sell copies of the Software, and to
125
- permit persons to whom the Software is furnished to do so, subject to
126
- the following conditions:
127
-
128
- The above copyright notice and this permission notice shall be
129
- included in all copies or substantial portions of the Software.
130
-
131
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
132
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
133
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
134
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
135
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
136
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ # Third-party notices
2
+
3
+ JoripSpace CLI is licensed under MIT. The dependencies below retain their own licenses and copyrights.
4
+ They are installed separately by npm, not bundled into the CLI tarball. These notices record the versions in package-lock.json; other installed versions retain their accompanying licenses.
5
+
6
+ ## fflate 0.8.3 — MIT
7
+
8
+ https://www.npmjs.com/package/fflate/v/0.8.3
9
+
10
+ MIT License
11
+
12
+ Copyright (c) 2026 Arjun Barrett
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+
32
+ ## jsonc-parser 3.3.1 — MIT
33
+
34
+ https://www.npmjs.com/package/jsonc-parser/v/3.3.1
35
+
36
+ The MIT License (MIT)
37
+
38
+ Copyright (c) Microsoft
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining a copy
41
+ of this software and associated documentation files (the "Software"), to deal
42
+ in the Software without restriction, including without limitation the rights
43
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
+ copies of the Software, and to permit persons to whom the Software is
45
+ furnished to do so, subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be included in all
48
+ copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
+ SOFTWARE.
57
+
58
+ ## smol-toml 1.9.1 — BSD-3-Clause
59
+
60
+ https://www.npmjs.com/package/smol-toml/v/1.9.1
61
+
62
+ Copyright (c) Squirrel Chat et al., All rights reserved.
63
+
64
+ Redistribution and use in source and binary forms, with or without
65
+ modification, are permitted provided that the following conditions are met:
66
+
67
+ 1. Redistributions of source code must retain the above copyright notice, this
68
+ list of conditions and the following disclaimer.
69
+ 2. Redistributions in binary form must reproduce the above copyright notice,
70
+ this list of conditions and the following disclaimer in the
71
+ documentation and/or other materials provided with the distribution.
72
+ 3. Neither the name of the copyright holder nor the names of its contributors
73
+ may be used to endorse or promote products derived from this software without
74
+ specific prior written permission.
75
+
76
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
77
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
78
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
79
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
80
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
81
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
82
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
83
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
84
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86
+
87
+ ## @napi-rs/keyring 2.1.2
88
+
89
+ MIT License
90
+
91
+ Copyright (c) 2020 N-API for Rust
92
+
93
+ Permission is hereby granted, free of charge, to any person obtaining a copy
94
+ of this software and associated documentation files (the "Software"), to deal
95
+ in the Software without restriction, including without limitation the rights
96
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97
+ copies of the Software, and to permit persons to whom the Software is
98
+ furnished to do so, subject to the following conditions:
99
+
100
+ The above copyright notice and this permission notice shall be included in all
101
+ copies or substantial portions of the Software.
102
+
103
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
109
+ SOFTWARE.
110
+
111
+ Platform binaries are npm dependencies; their bundled Rust dependency notices are included in each platform package's LICENSE.third-party.md. The Linux binary includes libdbus under AFL-2.1 OR GPL-2.0-or-later, with full license texts preserved in that dependency.
112
+
113
+ ## ignore 7.0.12 — MIT
114
+
115
+ https://www.npmjs.com/package/ignore/v/7.0.12
116
+
117
+ Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
118
+ http://kael.me/
119
+
120
+ Permission is hereby granted, free of charge, to any person obtaining
121
+ a copy of this software and associated documentation files (the
122
+ "Software"), to deal in the Software without restriction, including
123
+ without limitation the rights to use, copy, modify, merge, publish,
124
+ distribute, sublicense, and/or sell copies of the Software, and to
125
+ permit persons to whom the Software is furnished to do so, subject to
126
+ the following conditions:
127
+
128
+ The above copyright notice and this permission notice shall be
129
+ included in all copies or substantial portions of the Software.
130
+
131
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
132
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
133
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
134
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
135
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
136
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
137
137
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
- output(flags, { ...body, credential_storage: storage }, (value) => {
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. Get a new connection token at /connect/.',
1288
- '브라우저 쿠키, Bearer 문자열, 빈 자리표시자, 테스트 값은 CLI 연결 토큰으로 사용할 수 없습니다. /connect/에서 새 연결 토큰을 발급하세요.'
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
- let connectionCode = stringFlag(flags, 'code');
1633
- if (!connectionCode) {
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
- const exchangeApiBaseUrl = normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags));
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 --code.');
10
+ const error = new Error('Invalid connection credentials. Reconnect with login.');
11
11
  error.code = 'credential_store_invalid';
12
12
  throw error;
13
13
  }
@@ -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 --code.',
11
- 'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login --code로 다시 연결하세요.'
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.',