nameslink 1.0.5 → 1.1.16
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 +29 -9
- package/package.json +1 -1
- package/skill/nameslink/SKILL.md +22 -8
- package/src/cli.mjs +8 -1
- package/src/client.mjs +29 -0
- package/src/hosted-site.mjs +42 -13
- package/src/i18n.mjs +32 -2
- package/src/oauth.mjs +26 -0
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# NamesLink CLI
|
|
2
2
|
|
|
3
|
+
Hosted preview receipts are checked against the selected API environment. Production API
|
|
4
|
+
hosts accept production preview URLs; the explicit HTTPS PRE API hosts accept only PRE
|
|
5
|
+
preview URLs. Custom endpoints still require a process-local opt-in; environment admission
|
|
6
|
+
and business login remain separate. Resuming the same preview keeps its original upload.
|
|
7
|
+
|
|
3
8
|
Agent integrations can set `NAMESLINK_TOUCHPOINT=CODEX_PLUGIN` on an individual CLI process.
|
|
4
9
|
It uses the existing journey, request headers and OAuth state, preserves an earlier first touch,
|
|
5
10
|
and labels later touches. This client-reported label is not installation proof or authorization.
|
|
@@ -76,6 +81,20 @@ Running `nameslink` with no arguments in an interactive terminal shows a compact
|
|
|
76
81
|
and the safest starting commands. Piped output, CI, Agent JSON mode, and `nameslink help` remain
|
|
77
82
|
stable and do not receive decorative output.
|
|
78
83
|
|
|
84
|
+
## CLI sign-in authorization
|
|
85
|
+
|
|
86
|
+
During `nameslink login`, choose **Full authorization** to verify your identity once. The same CLI
|
|
87
|
+
sign-in can buy domains, create or update DNS records, and publish a site without another MFA
|
|
88
|
+
challenge. The permission lasts until that sign-in ends, including across access-token renewals.
|
|
89
|
+
Each purchase still requires reviewing and approving the domain and price. Account security changes
|
|
90
|
+
can invalidate the authorization. Domain transfers and access key creation retain their own checks.
|
|
91
|
+
|
|
92
|
+
Choose **On-demand authorization** to finish sign-in without an additional verification. The CLI
|
|
93
|
+
opens the browser when a protected operation requires MFA and continues the original command after
|
|
94
|
+
verification. With `--json`, the command emits `mfa.browser` on stderr while it waits. The browser
|
|
95
|
+
opens locally for the signed-in customer. `nameslink whoami --json` reports `authorizationMode`
|
|
96
|
+
as `FULL` or `ON_DEMAND` for sessions granted with either mode.
|
|
97
|
+
|
|
79
98
|
## Try it safely
|
|
80
99
|
|
|
81
100
|
```bash
|
|
@@ -185,7 +204,9 @@ Update and delete resolve the record ID in the named zone before submitting the
|
|
|
185
204
|
server independently enforces the current account and zone ownership.
|
|
186
205
|
|
|
187
206
|
DNS create/update/delete use the same `EMAIL_FALLBACK` MFA policy as the NamesLink web console.
|
|
188
|
-
|
|
207
|
+
Full authorization covers DNS create/update for the current sign-in. On-demand sessions use browser
|
|
208
|
+
verification when required. For earlier OAuth CLI sessions, DNS verification is reusable for one
|
|
209
|
+
account, endpoint, profile/session and DNS zone
|
|
189
210
|
for **one hour after all factors pass**. It covers record create/update in that zone and cleanup of unchanged records actually created by
|
|
190
211
|
this CLI session. The server create task records the exact returned record ID and content digest.
|
|
191
212
|
Other records or changed content require separate MFA scoped to that ID/snapshot;
|
|
@@ -211,8 +232,8 @@ resume with its returned command, never generate a new challenge to resend a cod
|
|
|
211
232
|
session returns `Account.Mfa.CliSessionRevoked`; run `nameslink login` again.
|
|
212
233
|
This contract requires the matching backend and CLI rollout; source tests do not prove deployment.
|
|
213
234
|
|
|
214
|
-
|
|
215
|
-
factor
|
|
235
|
+
For an earlier session or AK/SK authentication, use the returned command-line challenge and its
|
|
236
|
+
listed factor inputs. By default the CLI follows the
|
|
216
237
|
account-scoped task/batch operation until it succeeds or fails; `--no-wait` deliberately returns
|
|
217
238
|
after acceptance. Task success is not public propagation proof, so use
|
|
218
239
|
`nameslink dns records list <domain>` and an independent resolver to verify the resulting state.
|
|
@@ -570,11 +591,10 @@ title, falling back to the filename. `rename` changes only that label. First pub
|
|
|
570
591
|
reviewed version and destination;
|
|
571
592
|
when DNS or HTTPS is pending, it returns the original operation and next action, without claiming
|
|
572
593
|
publication success. For a NamesLink-managed destination, publish includes bounded automatic DNS
|
|
573
|
-
setup
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
`domain check` on
|
|
577
|
-
formal public verification. Sites bound to external DNS before 2026-10-10 keep updating on their
|
|
594
|
+
setup under the selected CLI authorization mode. The server continues after the CLI exits. Existing
|
|
595
|
+
records are preserved and conflicts require review. `status` reports DNS readiness
|
|
596
|
+
(`domainSetup.status`) independently of site publication (`site.status`). If DNS status is
|
|
597
|
+
`UNKNOWN`, run `domain check` on the original plan. The formal URL appears after public verification. Sites bound to external DNS before 2026-10-10 keep updating on their
|
|
578
598
|
existing binding and still read
|
|
579
599
|
stage-specific records through `domain show`; new bindings to external domains are refused. One site
|
|
580
600
|
binds one single-label subdomain; `www`, `blog`, and other
|
|
@@ -595,7 +615,7 @@ nameslink site hosted stop <site-id> --yes --json
|
|
|
595
615
|
|
|
596
616
|
Retained successful history is restored through a new operation on the same domain, even after its
|
|
597
617
|
old preview expires. Stop retains history and DNS records and requires a fresh ordinary MFA check.
|
|
598
|
-
DNS apply
|
|
618
|
+
DNS apply follows the current CLI authorization mode. AK/SK authentication retains ordinary MFA.
|
|
599
619
|
|
|
600
620
|
For a stopped site, `status --watch` returns `REMOVED` without waiting for it to become live.
|
|
601
621
|
Prepare and review a new candidate on the same site ID, then review the full host in its returned
|
package/package.json
CHANGED
package/skill/nameslink/SKILL.md
CHANGED
|
@@ -49,7 +49,11 @@ value. Never choose the last repeated value on the user's behalf.
|
|
|
49
49
|
and on the authorization page choose "Use another account" instead of confirming; that clears the
|
|
50
50
|
browser session and returns to the NamesLink login page, where email or Google both work. Always
|
|
51
51
|
read back the account the page says it is about to authorize and check it against what the user
|
|
52
|
-
asked for before approving.
|
|
52
|
+
asked for before approving. Let the customer choose the authorization mode in the browser.
|
|
53
|
+
Full authorization verifies their identity at sign-in and covers purchases, DNS create/update,
|
|
54
|
+
and site publishing for that CLI sign-in. On-demand authorization verifies protected operations
|
|
55
|
+
in the browser when required. Both modes keep exact purchase approval. Read `authorizationMode`
|
|
56
|
+
from `nameslink whoami --json` to identify the active mode when the server provides it.
|
|
53
57
|
Confirm the reported endpoint and environment before sending credentials or performing a paid
|
|
54
58
|
action. Official remote endpoints require HTTPS; custom HTTPS and loopback HTTP endpoints are
|
|
55
59
|
development-only, require an explicit process-local opt-in, and are never persisted. If
|
|
@@ -108,10 +112,20 @@ After approval, run:
|
|
|
108
112
|
nameslink apply <plan-id> --approve <digest> --watch --json
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
When stderr (or the live `--output-file` progress stream) emits `mfa.browser` with
|
|
116
|
+
`status=WAITING_FOR_USER` and `agentAction=NOTIFY_USER_AND_WAIT`, immediately tell the customer
|
|
117
|
+
to complete MFA in the NamesLink browser page. Pause dependent work and keep this same command
|
|
118
|
+
running; do not kill it, start another copy, or claim the operation has succeeded. Use a live or
|
|
119
|
+
background execution handle and read progress while it runs, so the notification reaches the
|
|
120
|
+
customer before the command finishes. If `browserOpened=false`, give the customer the returned
|
|
121
|
+
verification link; otherwise use the browser already opened by the CLI. Never ask for, collect,
|
|
122
|
+
or type the customer's MFA codes in this browser flow. The browser handles every factor.
|
|
123
|
+
Wait for the original command's final result: after verification it automatically resumes the
|
|
124
|
+
same request. If it exits with `Account.Mfa.FlowExpired`, tell the customer verification timed out;
|
|
125
|
+
do not claim success or silently switch to collecting codes in chat.
|
|
126
|
+
|
|
127
|
+
If the command exits with `Cli.Mfa.ChallengePending`, use the command-line challenge's `data`
|
|
128
|
+
envelope. The challenge lives on the server for its stated lifetime. Continue in two steps:
|
|
115
129
|
|
|
116
130
|
1. **Send the code.** The initial challenge sends nothing. For each EMAIL/SMS factor run the exact
|
|
117
131
|
command from `nextAction.sendCodeCommands[]`, for example
|
|
@@ -143,9 +157,9 @@ file, and delete the file as soon as the command returns.
|
|
|
143
157
|
|
|
144
158
|
**Two things an agent must never do**, both of which caused real incidents:
|
|
145
159
|
|
|
146
|
-
- **Do not build an interactive session**: no FIFO, no long-lived background process
|
|
147
|
-
`screen … stuff`, no writing into a still-running CLI.
|
|
148
|
-
|
|
160
|
+
- **Do not build an interactive code entry session**: no FIFO, no long-lived background process
|
|
161
|
+
for code entry, no `screen … stuff`, and no writing codes into a still-running CLI. Use the
|
|
162
|
+
supported browser or command-line flow.
|
|
149
163
|
- **Do not drive the interactive `--mfa-stdin` prompt flow.** Prompting inside one live process is
|
|
150
164
|
for a human at a real TTY. As an agent, always take the two-step path above.
|
|
151
165
|
|
package/src/cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
saveSkillCheckMetadata, saveUpdateCheckMetadata, validateEndpoint,
|
|
12
12
|
} from './config.mjs';
|
|
13
13
|
import { createI18n, formatCode, formatContractLabel, formatDisplayLabel, formatRecoveryGuidance, localizeServerMessage } from './i18n.mjs';
|
|
14
|
-
import { browserLogin } from './oauth.mjs';
|
|
14
|
+
import { browserLogin, browserMfa } from './oauth.mjs';
|
|
15
15
|
import { completeProfile } from './profile.mjs';
|
|
16
16
|
import {
|
|
17
17
|
ensureOfficialSkill, inspectOfficialSkillInstallations, installOfficialSkill, planSkillReminder,
|
|
@@ -556,6 +556,12 @@ export async function main(argv, runtime = {}) {
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
const client = new NamesLinkClient(config, i18n, invocation.context);
|
|
559
|
+
if (!parsed.options['mfa-stdin'] && !parsed.options['mfa-code-file'] && !parsed.options['mfa-challenge']) {
|
|
560
|
+
client.mfaBrowser = (url, { expiresAt } = {}) => browserMfa(url, i18n, {
|
|
561
|
+
json: parsed.options.json, expiresAt, openBrowser: parsed.options['no-browser'] !== true,
|
|
562
|
+
writeProgress: runtime.writeProgress,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
559
565
|
const profileRuntime = {
|
|
560
566
|
interactive: runtime.interactive ?? Boolean(stdin.isTTY && !parsed.options.json),
|
|
561
567
|
ask: runtime.ask || prompt,
|
|
@@ -1676,6 +1682,7 @@ function authStatusSummary(config) {
|
|
|
1676
1682
|
method:
|
|
1677
1683
|
credentials?.type === 'ak' ? 'NAMESLINK_AK_SK' : credentials?.type === 'oauth' ? 'NAMESLINK_OAUTH_PKCE' : 'NONE',
|
|
1678
1684
|
accountNo: credentials?.accountNo || null,
|
|
1685
|
+
...(credentials?.authorizationMode ? { authorizationMode: credentials.authorizationMode } : {}),
|
|
1679
1686
|
sessionMode: credentials?.type === 'oauth' ? 'oauth-bearer' : credentials?.type === 'ak' ? 'ak-signature' : 'none',
|
|
1680
1687
|
credentialStorage: config.credentialStorage || 'none',
|
|
1681
1688
|
};
|
package/src/client.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { saveConfig, validateEndpoint } from './config.mjs';
|
|
4
4
|
import { createI18n } from './i18n.mjs';
|
|
5
5
|
import { prepareJourney, requestJourneyHeaders } from './journey.mjs';
|
|
6
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
7
|
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
8
9
|
const { version: packageVersion } = require('../package.json');
|
|
@@ -273,6 +274,12 @@ export class NamesLinkClient {
|
|
|
273
274
|
// high-risk operations cannot accidentally acquire or reuse DNS assurance.
|
|
274
275
|
const sessionSecret = usesMfaSession(method, reference) ? mfaSessionSecret(this.config) : null;
|
|
275
276
|
if (sessionSecret) headers['X-NamesLink-Mfa-Session'] = sessionSecret;
|
|
277
|
+
const browserMfa = this.mfaBrowser && this.config.credentials.type === 'oauth'
|
|
278
|
+
&& this.config.credentials.authorizationMode && !body?.mfaVerification;
|
|
279
|
+
if (browserMfa) {
|
|
280
|
+
headers['X-NamesLink-Mfa-Browser'] = '1';
|
|
281
|
+
if (options.mfaPromptId) headers['X-NamesLink-Mfa-Prompt'] = options.mfaPromptId;
|
|
282
|
+
}
|
|
276
283
|
const response = await fetchOrThrow(this.config, this.endpoint, url, {
|
|
277
284
|
method,
|
|
278
285
|
headers,
|
|
@@ -304,6 +311,10 @@ export class NamesLinkClient {
|
|
|
304
311
|
await this.prefetchCsrf(true);
|
|
305
312
|
return this.request(method, reference, body, { ...options, retry: false });
|
|
306
313
|
}
|
|
314
|
+
if (browserMfa && !options.mfaPromptId && payload?.code === 'Account.Mfa.BrowserRequired') {
|
|
315
|
+
const mfaPromptId = await this.waitForBrowserMfa(payload.data);
|
|
316
|
+
return this.request(method, reference, body, { ...options, mfaPromptId });
|
|
317
|
+
}
|
|
307
318
|
if (payload?.data?.resumeToken) {
|
|
308
319
|
this.config.lastInterruption = {
|
|
309
320
|
resumeToken: payload.data.resumeToken,
|
|
@@ -319,6 +330,24 @@ export class NamesLinkClient {
|
|
|
319
330
|
return payload.data;
|
|
320
331
|
}
|
|
321
332
|
|
|
333
|
+
async waitForBrowserMfa({ ticket, expiresAt } = {}) {
|
|
334
|
+
if (typeof ticket !== 'string' || !/^[a-f0-9-]{36}$/.test(ticket) || !Number.isFinite(expiresAt)) {
|
|
335
|
+
throw new Error('The server returned an invalid browser verification request.');
|
|
336
|
+
}
|
|
337
|
+
const prompt = new URL(`${this.endpoint}/account/oauth/cli/mfa-prompt`);
|
|
338
|
+
prompt.searchParams.set('ticket', ticket);
|
|
339
|
+
prompt.searchParams.set('lang', this.i18n.language);
|
|
340
|
+
const deadline = Math.min(expiresAt, Date.now() + 300_000);
|
|
341
|
+
await this.mfaBrowser(prompt.toString(), { expiresAt: deadline });
|
|
342
|
+
while (Date.now() < deadline) {
|
|
343
|
+
const result = await this.request('GET', `/account/oauth/cli/mfa-prompts/${ticket}`);
|
|
344
|
+
if (result?.status === 'APPROVED') return ticket;
|
|
345
|
+
await delay(2000);
|
|
346
|
+
}
|
|
347
|
+
throw new ApiError({ code: 'Account.Mfa.FlowExpired', message: 'Browser verification expired.' }, 400,
|
|
348
|
+
this.i18n, this.endpoint);
|
|
349
|
+
}
|
|
350
|
+
|
|
322
351
|
async refresh() {
|
|
323
352
|
assertCredentialEndpoint(this.config);
|
|
324
353
|
const response = await fetchOrThrow(this.config, this.endpoint, `${this.endpoint}/account/oauth/cli/refresh`, {
|
package/src/hosted-site.mjs
CHANGED
|
@@ -8,7 +8,9 @@ import { inspectUndeployableSiteSource } from './site-source-guidance.mjs';
|
|
|
8
8
|
import { withHostedJournal } from './hosted-journal.mjs';
|
|
9
9
|
|
|
10
10
|
const SITE_FIELDS = ['hostedSiteId', 'displayName', 'host', 'status', 'generation', 'bindingId',
|
|
11
|
-
'candidateReleaseId', 'lastVerifiedReleaseId', 'pendingReleaseId', 'historyComplete', 'legacy', 'version', 'url', 'problemCode', 'lastPublishedAt', 'previewSiteId'];
|
|
11
|
+
'candidateReleaseId', 'lastVerifiedReleaseId', 'pendingReleaseId', 'historyComplete', 'legacy', 'version', 'url', 'problemCode', 'domainConnectionProblem', 'lastPublishedAt', 'previewSiteId'];
|
|
12
|
+
const INITIAL_PUBLICATION_STATES = ['OWNERSHIP_PENDING', 'SAAS_PENDING', 'SAAS_HOSTNAME_CREATED', 'SAAS_ROUTE_CREATED',
|
|
13
|
+
'DNS_CERT_READY', 'KV_CANDIDATE_READY', 'ACTIVATING'];
|
|
12
14
|
const RELEASE_FIELDS = ['releaseId', 'versionNumber', 'previewSiteId', 'retentionState', 'firstVerifiedAt',
|
|
13
15
|
'lastVerifiedAt', 'recoverable', 'lastVerified', 'candidate'];
|
|
14
16
|
const OP_FIELDS = ['operationId', 'hostedSiteId', 'releaseId', 'bindingId', 'kind', 'generation', 'status', 'nextAction'];
|
|
@@ -85,9 +87,9 @@ export async function hostedSiteCommand(client, positionals, options, i18n, runt
|
|
|
85
87
|
};
|
|
86
88
|
if (options.watch) site = await poll(read, site,
|
|
87
89
|
(item) => ['DRAFT', 'ACTIVE', 'REMOVED', 'UNBOUND', 'UPDATE_UNKNOWN', 'ACTIVATION_UNKNOWN', 'UPDATE_FAILED', 'FAILED'].includes(item.status)
|
|
88
|
-
||
|
|
90
|
+
|| dnsNeedsAttention(dns), runtime);
|
|
89
91
|
return output({ site, complete: Boolean(site.url), ...(dns ? { domainSetup: dns } : {}), nextAction: site.url ? 'VISIT_SITE' :
|
|
90
|
-
publicationNextAction(dns) ||
|
|
92
|
+
publicationNextAction(dns, site) ||
|
|
91
93
|
(site.status === 'REMOVED' ? (site.candidateReleaseId ? 'REVIEW_PREVIEW_THEN_PUBLISH' : 'CREATE_PREVIEW') :
|
|
92
94
|
['UPDATE_UNKNOWN', 'ACTIVATION_UNKNOWN'].includes(site.status) ? 'READ_ORIGINAL_OPERATION' : 'INSPECT_SITE'),
|
|
93
95
|
...activationRecovery(site),
|
|
@@ -224,7 +226,7 @@ async function operationResult(client, siteId, original, operationKey, options,
|
|
|
224
226
|
operation, (item) => item.status === 'SUCCEEDED' || (item.status !== 'RUNNING' && !progressing()), runtime);
|
|
225
227
|
return { operation, site, idempotencyKey: operationKey, complete: operation.status === 'SUCCEEDED',
|
|
226
228
|
...(dns ? { domainSetup: dns } : {}),
|
|
227
|
-
nextAction: publicationNextAction(dns) || operation.nextAction,
|
|
229
|
+
nextAction: operation.status === 'SUCCEEDED' ? operation.nextAction : publicationNextAction(dns, site) || operation.nextAction,
|
|
228
230
|
...(current() ? activationRecovery(site) : {}),
|
|
229
231
|
statusCommand: `nameslink site hosted status ${siteId} --watch --json` };
|
|
230
232
|
}
|
|
@@ -242,19 +244,34 @@ function activationRecovery(site) {
|
|
|
242
244
|
] };
|
|
243
245
|
}
|
|
244
246
|
|
|
245
|
-
/**
|
|
247
|
+
/** Read DNS setup separately from publication, including after the site is live. */
|
|
246
248
|
async function publicationProgress(client, site) {
|
|
247
|
-
if (!site.bindingId ||
|
|
248
|
-
'
|
|
249
|
-
|
|
249
|
+
if (!site.bindingId || site.domainConnectionProblem
|
|
250
|
+
|| ![...INITIAL_PUBLICATION_STATES, 'ACTIVE', 'ACTIVATION_UNKNOWN', 'FAILED'].includes(site.status)) return null;
|
|
251
|
+
let value;
|
|
252
|
+
try {
|
|
253
|
+
value = await get(client, 'sites.publicationDns', { siteId: site.hostedSiteId });
|
|
254
|
+
} catch (error) {
|
|
255
|
+
if (error instanceof ApiError || isUnknown(error) || error.body?.data?.operation === 'sites.publicationDns') {
|
|
256
|
+
return { status: 'UNAVAILABLE' };
|
|
257
|
+
}
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
250
260
|
if (value === null) return null;
|
|
251
261
|
if (!value || !['RUNNING', 'SUCCEEDED', 'UNKNOWN', 'CONFLICT', 'EXPIRED', 'REVIEW'].includes(value.status)
|
|
252
|
-
|| !Number.isFinite(Date.parse(value.expiresAt)) || value.planId != null && !/^[A-Za-z0-9_-]{1,128}$/.test(value.planId))
|
|
262
|
+
|| !Number.isFinite(Date.parse(value.expiresAt)) || value.planId != null && !/^[A-Za-z0-9_-]{1,128}$/.test(value.planId)) {
|
|
263
|
+
return { status: 'UNAVAILABLE' };
|
|
264
|
+
}
|
|
253
265
|
return pick(value, ['status', 'planId', 'expiresAt']);
|
|
254
266
|
}
|
|
255
267
|
|
|
256
|
-
function
|
|
257
|
-
|
|
268
|
+
function dnsNeedsAttention(dns) {
|
|
269
|
+
return ['UNKNOWN', 'CONFLICT', 'EXPIRED', 'REVIEW'].includes(dns?.status);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function publicationNextAction(dns, site) {
|
|
273
|
+
if (!dns || dns.status === 'UNAVAILABLE') return null;
|
|
274
|
+
if (dns.status === 'SUCCEEDED') return INITIAL_PUBLICATION_STATES.includes(site.status) ? 'WAIT_FOR_PUBLICATION' : null;
|
|
258
275
|
if (dns.status === 'RUNNING') return 'WAIT_FOR_PUBLICATION';
|
|
259
276
|
if (dns.status === 'UNKNOWN') return 'CHECK_ORIGINAL_DNS_PLAN';
|
|
260
277
|
return 'REVIEW_DOMAIN_SETUP';
|
|
@@ -508,7 +525,11 @@ function validateSession(session, expected) {
|
|
|
508
525
|
function validatedPreviewUrl(endpoint, apiEndpoint) {
|
|
509
526
|
let url;
|
|
510
527
|
try { url = new URL(endpoint.url); } catch { throw failure('InvalidReceipt'); }
|
|
511
|
-
|
|
528
|
+
let api;
|
|
529
|
+
try { api = new URL(apiEndpoint); } catch { throw failure('InvalidReceipt'); }
|
|
530
|
+
const pre = api.protocol === 'https:' && !api.port && !api.username && !api.password
|
|
531
|
+
&& ['pre.nameslink.com', 'preo.nameslink.com', 'apipre.nameslink.com'].includes(api.hostname);
|
|
532
|
+
const suffix = pre ? '.pre.nameslink.site' : '.nameslink.site';
|
|
512
533
|
const slug = url.hostname.slice(0, -suffix.length);
|
|
513
534
|
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash
|
|
514
535
|
|| !url.hostname.endsWith(suffix) || !/^[a-z0-9-]{3,48}$/.test(slug)
|
|
@@ -603,9 +624,17 @@ function output(value, options, runtime) {
|
|
|
603
624
|
const lines = [];
|
|
604
625
|
if (value.site) {
|
|
605
626
|
lines.push(`${value.site.displayName || value.site.hostedSiteId}${value.site.host ? ` · ${value.site.host}` : ''}`);
|
|
606
|
-
|
|
627
|
+
const connectionProblem = value.site.domainConnectionProblem;
|
|
628
|
+
lines.push(connectionProblem
|
|
629
|
+
? i18n?.optional(`hosted.connection.${connectionProblem}`) || connectionProblem
|
|
630
|
+
: i18n?.optional(`hosted.status.${value.site.status}`) || value.site.status);
|
|
607
631
|
if (value.site.url) lines.push(value.site.url);
|
|
608
632
|
}
|
|
633
|
+
if (value.domainSetup) {
|
|
634
|
+
const label = i18n?.optional('hosted.dns.label') || 'Automatic DNS';
|
|
635
|
+
const status = value.domainSetup.status;
|
|
636
|
+
lines.push(`${label}${i18n?.colon || ': '}${i18n?.optional(`hosted.dns.${status}`) || status}`);
|
|
637
|
+
}
|
|
609
638
|
if (value.previewUrl) lines.push(`${i18n?.t('hosted.preview') || 'Preview'}${i18n?.colon || ': '}${value.previewUrl}`);
|
|
610
639
|
if (value.release?.versionNumber) lines.push(`${i18n?.t('hosted.version') || 'Version'}${i18n?.colon || ': '}${value.release.versionNumber}`);
|
|
611
640
|
if (value.nextAction) lines.push(i18n?.optional(`hosted.next.${value.nextAction}`) || value.nextAction);
|
package/src/i18n.mjs
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { absoluteConsoleUrl } from './urls.mjs';
|
|
2
2
|
|
|
3
3
|
const EN_US = {
|
|
4
|
-
'hosted.next.WAIT_FOR_PUBLICATION': 'NamesLink is publishing your site
|
|
4
|
+
'hosted.next.WAIT_FOR_PUBLICATION': 'NamesLink is publishing your site. Follow the status command to check progress.',
|
|
5
|
+
'hosted.dns.label': 'Automatic DNS',
|
|
6
|
+
'hosted.dns.RUNNING': 'Configuring',
|
|
7
|
+
'hosted.dns.SUCCEEDED': 'Ready',
|
|
8
|
+
'hosted.dns.UNKNOWN': 'Checking the original attempt',
|
|
9
|
+
'hosted.dns.CONFLICT': 'Conflicting records',
|
|
10
|
+
'hosted.dns.EXPIRED': 'Setup timed out',
|
|
11
|
+
'hosted.dns.REVIEW': 'Needs review',
|
|
12
|
+
'hosted.dns.UNAVAILABLE': 'Status unavailable',
|
|
13
|
+
'hosted.connection.DNS_HOSTING_MOVED': 'Domain disconnected. DNS hosting has moved.',
|
|
14
|
+
'hosted.connection.DNS_RECORD_CHANGED': 'Domain disconnected. The DNS records no longer point to this site.',
|
|
5
15
|
'hosted.next.CHECK_ORIGINAL_DNS_PLAN': 'Check the original DNS plan shown in domainSetup.planId. Do not start another publication.',
|
|
6
16
|
'hosted.next.REVIEW_DOMAIN_SETUP': 'Automatic setup paused. Review the domain settings and the original plan before continuing.',
|
|
7
17
|
'apiError.Cli.Hosted.DestinationUnavailable': 'We could not check this address. Check the full hostname and try again.',
|
|
@@ -18,6 +28,9 @@ const EN_US = {
|
|
|
18
28
|
'apiError.Drop.Hosted.Dns.INCONSISTENT': 'We could not verify the DNS setup records. Contact support with the original plan ID.',
|
|
19
29
|
'hosted.preview': "Preview",
|
|
20
30
|
'hosted.version': "Version",
|
|
31
|
+
'hosted.status.DNS_CERT_READY': "Preparing publication",
|
|
32
|
+
'hosted.status.KV_CANDIDATE_READY': "Preparing publication",
|
|
33
|
+
'hosted.status.ACTIVATING': "Verifying the site",
|
|
21
34
|
'hosted.status.ACTIVE': "Published",
|
|
22
35
|
'hosted.status.DRAFT': "Not published",
|
|
23
36
|
'hosted.next.REVIEW_PREVIEW_THEN_PUBLISH': "Review the preview, then explicitly publish this version to your domain.",
|
|
@@ -212,6 +225,8 @@ const EN_US = {
|
|
|
212
225
|
'error.walletTopUpTimeout':
|
|
213
226
|
'The top-up has not been credited yet. Do not create or pay another top-up. Check `{balanceCommand}`; after the balance arrives, continue the same reviewed purchase with `{resumeCommand}`.',
|
|
214
227
|
'login.opening': 'Opening NamesLink authorization in your browser…',
|
|
228
|
+
'mfa.browserWaiting': 'Waiting for you to complete MFA in the browser that just opened. Remind the customer and keep this command running; it continues automatically after verification. Do not ask for their verification codes in chat.',
|
|
229
|
+
'mfa.browserManual': 'Open the link below to complete MFA in your browser. Remind the customer and keep this command running; it continues automatically after verification. Do not ask for their verification codes in chat.',
|
|
215
230
|
'login.openingManual': 'Open this NamesLink authorization URL in your browser:',
|
|
216
231
|
'login.browserUnavailable': 'Could not open a browser automatically. Continue with the URL below. A remote shell needs access to this CLI process\'s loopback callback; --no-browser does not provide cross-device login.',
|
|
217
232
|
'login.openingHint':
|
|
@@ -737,7 +752,17 @@ const EN_US = {
|
|
|
737
752
|
};
|
|
738
753
|
|
|
739
754
|
const ZH_CN = {
|
|
740
|
-
'hosted.next.WAIT_FOR_PUBLICATION': 'NamesLink
|
|
755
|
+
'hosted.next.WAIT_FOR_PUBLICATION': 'NamesLink 正在发布网站。可用返回的状态命令查看进度。',
|
|
756
|
+
'hosted.dns.label': '自动 DNS',
|
|
757
|
+
'hosted.dns.RUNNING': '配置中',
|
|
758
|
+
'hosted.dns.SUCCEEDED': '已就绪',
|
|
759
|
+
'hosted.dns.UNKNOWN': '正在核对原操作',
|
|
760
|
+
'hosted.dns.CONFLICT': '记录冲突',
|
|
761
|
+
'hosted.dns.EXPIRED': '配置超时',
|
|
762
|
+
'hosted.dns.REVIEW': '需要检查',
|
|
763
|
+
'hosted.dns.UNAVAILABLE': '暂时无法查询状态',
|
|
764
|
+
'hosted.connection.DNS_HOSTING_MOVED': '域名已断开,DNS 托管已迁移。',
|
|
765
|
+
'hosted.connection.DNS_RECORD_CHANGED': '域名已断开,DNS 记录已不再指向本站。',
|
|
741
766
|
'hosted.next.CHECK_ORIGINAL_DNS_PLAN': '请核对 domainSetup.planId 中的原解析计划,不要重新发布。',
|
|
742
767
|
'hosted.next.REVIEW_DOMAIN_SETUP': '自动配置已暂停。请检查域名设置和原解析计划,再继续。',
|
|
743
768
|
'apiError.Cli.Hosted.DestinationUnavailable': '暂时无法确认这个地址,请检查完整域名后重试。',
|
|
@@ -754,6 +779,9 @@ const ZH_CN = {
|
|
|
754
779
|
'apiError.Drop.Hosted.Dns.INCONSISTENT': '解析配置记录需要核对,请携带原计划编号联系支持。',
|
|
755
780
|
'hosted.preview': "预览地址",
|
|
756
781
|
'hosted.version': "版本",
|
|
782
|
+
'hosted.status.DNS_CERT_READY': "正在准备发布",
|
|
783
|
+
'hosted.status.KV_CANDIDATE_READY': "正在准备发布",
|
|
784
|
+
'hosted.status.ACTIVATING': "正在验证站点",
|
|
757
785
|
'hosted.status.ACTIVE': "已发布",
|
|
758
786
|
'hosted.status.DRAFT': "未发布",
|
|
759
787
|
'hosted.next.REVIEW_PREVIEW_THEN_PUBLISH': "请查看预览效果,再明确发布此版本到自有域名。",
|
|
@@ -945,6 +973,8 @@ const ZH_CN = {
|
|
|
945
973
|
'login.opening': '正在打开 NamesLink 授权页…',
|
|
946
974
|
'login.openingManual': '请在浏览器中打开以下 NamesLink 授权链接:',
|
|
947
975
|
'login.browserUnavailable': '无法自动打开浏览器,请用下方链接继续。远程终端仍需能访问此 CLI 进程的本机回调,--no-browser 不代表支持跨设备登录。',
|
|
976
|
+
'mfa.browserWaiting': '正在等待客户在已打开的浏览器中完成 MFA。请提醒客户完成验证,并保持当前命令运行;验证后会自动继续。不要在对话中索取验证码。',
|
|
977
|
+
'mfa.browserManual': '请打开下方链接,在浏览器中完成 MFA。请提醒客户完成验证,并保持当前命令运行;验证后会自动继续。不要在对话中索取验证码。',
|
|
948
978
|
'login.openingHint': '页面上会写明将要授权哪个账号。同一账号就直接确认;要换账号请点页面上的「换其他账号」——退出 CLI 并不会退出浏览器登录态。',
|
|
949
979
|
'login.success': 'NamesLink 登录成功,账号:{accountNo}。',
|
|
950
980
|
'logout.success':
|
package/src/oauth.mjs
CHANGED
|
@@ -10,6 +10,30 @@ import {
|
|
|
10
10
|
import { createI18n } from './i18n.mjs';
|
|
11
11
|
import { appendJourneyQuery, requestJourneyHeaders } from './journey.mjs';
|
|
12
12
|
|
|
13
|
+
/** Open the customer handoff and notify the calling agent before verification polling starts. */
|
|
14
|
+
export async function browserMfa(url, i18n = createI18n('en-US'), options = {}) {
|
|
15
|
+
let browserOpened = options.openBrowser !== false;
|
|
16
|
+
let launchFailed = false;
|
|
17
|
+
if (browserOpened) {
|
|
18
|
+
try {
|
|
19
|
+
await (options.openBrowserFn || openBrowser)(url);
|
|
20
|
+
} catch {
|
|
21
|
+
browserOpened = false;
|
|
22
|
+
launchFailed = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const message = i18n.t(browserOpened ? 'mfa.browserWaiting' : 'mfa.browserManual');
|
|
26
|
+
const writeProgress = options.writeProgress || ((value) => process.stderr.write(value));
|
|
27
|
+
writeProgress(options.json
|
|
28
|
+
? `${JSON.stringify({ type: 'mfa.browser', status: 'WAITING_FOR_USER',
|
|
29
|
+
agentAction: 'NOTIFY_USER_AND_WAIT',
|
|
30
|
+
nextAction: browserOpened ? 'COMPLETE_BROWSER_MFA' : 'OPEN_VERIFICATION_URL',
|
|
31
|
+
browserOpened, message, url, expiresAt: options.expiresAt,
|
|
32
|
+
...(launchFailed ? { reason: 'BROWSER_UNAVAILABLE' } : {}),
|
|
33
|
+
})}\n`
|
|
34
|
+
: `${message}\n${browserOpened ? '' : `${url}\n`}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
13
37
|
export async function browserLogin(endpoint, i18n = createI18n('en-US'), options = {}) {
|
|
14
38
|
const verifier = randomBytes(32).toString('base64url');
|
|
15
39
|
const challenge = createHash('sha256').update(verifier).digest('base64url');
|
|
@@ -152,6 +176,8 @@ export async function exchangeOAuthCode(
|
|
|
152
176
|
// A new secure-store nonce separates logins even if the server issues equal JWTs in one second.
|
|
153
177
|
mfaSessionNonce: randomBytes(32).toString('base64url'),
|
|
154
178
|
accountNo: payload.data.accountNo,
|
|
179
|
+
...(['FULL', 'ON_DEMAND'].includes(payload.data.authorizationMode)
|
|
180
|
+
? { authorizationMode: payload.data.authorizationMode } : {}),
|
|
155
181
|
};
|
|
156
182
|
}
|
|
157
183
|
|