@zhin.js/core 1.6.0 → 1.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.
- package/lib/built/interactive-segments/types.d.ts +6 -0
- package/lib/built/login-assist.d.ts +317 -14
- package/lib/built/login-assist.js +1139 -64
- package/lib/built/login-captcha.d.ts +62 -0
- package/lib/built/login-captcha.js +107 -0
- package/lib/built/user-interaction.d.ts +3 -1
- package/lib/built/user-interaction.js +2 -0
- package/lib/feature/command-public-api.d.ts +1 -1
- package/lib/feature/command-public-api.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/plugin-runtime/im/command-suggestion.d.ts +13 -0
- package/lib/plugin-runtime/im/command-suggestion.js +32 -0
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +52 -2
- package/lib/plugin-runtime/im/endpoint-runtime.js +74 -2
- package/lib/plugin-runtime/im/host/database-config.js +38 -0
- package/lib/plugin-runtime/im/host/database-console-schema.d.ts +79 -0
- package/lib/plugin-runtime/im/host/database-console-schema.js +477 -0
- package/lib/plugin-runtime/im/host/database-console-sql.d.ts +66 -0
- package/lib/plugin-runtime/im/host/database-console-sql.js +459 -0
- package/lib/plugin-runtime/im/host/database-host-installer.d.ts +48 -17
- package/lib/plugin-runtime/im/host/database-host-installer.js +770 -46
- package/lib/plugin-runtime/im/im-runtime.js +1 -0
- package/lib/plugin-runtime/im/inbound-runtime.js +2 -0
- package/lib/plugin-runtime/im/inbound-spine.d.ts +6 -1
- package/lib/plugin-runtime/im/inbound-spine.js +51 -1
- package/lib/plugin-runtime/im/index.d.ts +1 -1
- package/lib/plugin-runtime/im/message-dispatcher.js +2 -1
- package/lib/plugin-runtime/im/message-events.d.ts +5 -1
- package/lib/plugin-runtime/im/message-events.js +38 -3
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +1 -1
- package/package.json +13 -13
|
@@ -27,6 +27,12 @@ export type KeyboardFallback = {
|
|
|
27
27
|
export type KeyboardSegmentData = {
|
|
28
28
|
rows: ButtonData[][];
|
|
29
29
|
fallback?: KeyboardFallback;
|
|
30
|
+
/**
|
|
31
|
+
* Optional presentation marker set by the Host (`UserInteractionRequest.purpose`):
|
|
32
|
+
* `approval` = a human approval prompt. Surfaces that understand it (Sandbox Console)
|
|
33
|
+
* label the card; every other renderer ignores it.
|
|
34
|
+
*/
|
|
35
|
+
purpose?: 'approval';
|
|
30
36
|
};
|
|
31
37
|
export type ActionSegmentData = {
|
|
32
38
|
id: string;
|
|
@@ -1,17 +1,31 @@
|
|
|
1
|
+
import type { LoginChallengeKind } from '@zhin.js/adapter';
|
|
2
|
+
import { type LoginCaptchaMedia } from './login-captcha.js';
|
|
1
3
|
/**
|
|
2
|
-
* LoginAssist —
|
|
4
|
+
* LoginAssist — 登录辅助(ADR 0058 Login Assist v2)
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* 适配器在需要人为辅助登录时(扫码、短信、滑块等)开启一个 **登录流程(LoginFlow)**:
|
|
7
|
+
* 每个 Endpoint 同时只有一个流程,流程内同时只有一个待答的 **挑战(LoginChallenge)**。
|
|
8
|
+
* Web 控制台、命令行等消费者拉取挑战并提交;提交后流程自动进入「验证中」,
|
|
9
|
+
* 适配器再通过 `outcome()` / `online()` / `fail()` 报告真实结果。
|
|
10
|
+
*
|
|
11
|
+
* 旧 API `waitForInput()` 继续可用:它在隐式流程中开出一个挑战(旧 payload 映射为描述符)。
|
|
7
12
|
*
|
|
8
13
|
* 事件:
|
|
9
|
-
* endpoint.login.
|
|
10
|
-
* endpoint.login.
|
|
14
|
+
* endpoint.login.flow — 流程快照(按 id 去重,revision 大者为准)
|
|
15
|
+
* endpoint.login.pending — 有新待办时触发,payload: PendingLoginTask(兼容)
|
|
16
|
+
* endpoint.login.expired — 超时自动取消时触发,payload: PendingLoginTask(兼容)
|
|
17
|
+
* endpoint.login.resolved — 待办结束(提交或取消)时触发,payload: PendingLoginTask(兼容)
|
|
18
|
+
*
|
|
19
|
+
* 安全:快照、日志与事件从不包含提交的值(验证码、ticket);二维码图片只挂在当前活动挑战上,
|
|
20
|
+
* 挑战结束或过期即删除;时间线只有文本。
|
|
11
21
|
*/
|
|
12
22
|
export type LoginAssistType = 'qrcode' | 'sms' | 'slider' | 'device' | 'auth' | 'other';
|
|
13
23
|
/** 默认 5 分钟;扫码/滑块长期挂起会泄漏 Promise 与 Map 条目 */
|
|
14
24
|
export declare const DEFAULT_LOGIN_ASSIST_TIMEOUT_MS: number;
|
|
25
|
+
/** 提交后多久仍无结果即标记「结果待确认」(不是失败)。 */
|
|
26
|
+
export declare const DEFAULT_LOGIN_VERIFY_TIMEOUT_MS: number;
|
|
27
|
+
/** 每个流程保留的时间线步骤上限。 */
|
|
28
|
+
export declare const LOGIN_FLOW_STEP_LIMIT = 20;
|
|
15
29
|
export interface PendingLoginTaskPayload {
|
|
16
30
|
/** 说明文案(如「请扫码登录」) */
|
|
17
31
|
message?: string;
|
|
@@ -38,6 +52,10 @@ export interface PendingLoginTask {
|
|
|
38
52
|
createdAt: number;
|
|
39
53
|
/** 到期时间戳(ms);无超时则为 undefined */
|
|
40
54
|
expiresAt?: number;
|
|
55
|
+
/** ADR 0058: owning login flow. */
|
|
56
|
+
flowId?: string;
|
|
57
|
+
/** ADR 0058: challenge this task answers (descriptor is in the flow snapshot). */
|
|
58
|
+
challengeId?: string;
|
|
41
59
|
}
|
|
42
60
|
export interface WaitForInputOptions {
|
|
43
61
|
/** Endpoint-instance owner. Only this owner may cancel the task during rollback/retirement. */
|
|
@@ -51,10 +69,229 @@ export interface WaitForInputOptions {
|
|
|
51
69
|
*/
|
|
52
70
|
timeoutMs?: number;
|
|
53
71
|
}
|
|
54
|
-
export type
|
|
72
|
+
export type LoginAssistTaskEventName = 'endpoint.login.pending' | 'endpoint.login.resolved' | 'endpoint.login.expired';
|
|
73
|
+
export type LoginAssistEventName = LoginAssistTaskEventName | 'endpoint.login.flow';
|
|
55
74
|
/** Minimal bus shared by the runtime host and lightweight test emitters. */
|
|
56
75
|
export interface LoginAssistBus {
|
|
57
|
-
emit(name: LoginAssistEventName,
|
|
76
|
+
emit(name: LoginAssistEventName, payload: PendingLoginTask | LoginFlowSnapshot): void;
|
|
77
|
+
}
|
|
78
|
+
export type { LoginChallengeKind } from '@zhin.js/adapter';
|
|
79
|
+
export type LoginFlowState = 'active' | 'online' | 'failed' | 'cancelled' | 'expired';
|
|
80
|
+
export type LoginStepKind = 'connect' | 'challenge' | 'verifying' | 'info';
|
|
81
|
+
export type LoginStepStatus = 'active' | 'done' | 'failed' | 'skipped';
|
|
82
|
+
export type LoginErrorCode = 'code_invalid' | 'rate_limited' | 'challenge_expired' | 'risk_blocked' | 'credential_invalid' | 'network' | 'unknown';
|
|
83
|
+
export type LoginOutcomeResult = 'accepted' | 'rejected' | 'expired' | 'needs_new_challenge' | 'online' | 'failed';
|
|
84
|
+
export type LoginNextAction = 'retry_input' | 'refresh_challenge' | 'relogin' | 'wait' | 'none';
|
|
85
|
+
export declare const LOGIN_ERROR_CODES: readonly LoginErrorCode[];
|
|
86
|
+
export interface LoginOutcome {
|
|
87
|
+
readonly result: LoginOutcomeResult;
|
|
88
|
+
readonly code?: LoginErrorCode;
|
|
89
|
+
/** Sanitized single-line text; never contains submitted values. */
|
|
90
|
+
readonly message?: string;
|
|
91
|
+
readonly next?: LoginNextAction;
|
|
92
|
+
readonly retryAfterMs?: number;
|
|
93
|
+
}
|
|
94
|
+
export interface LoginChallengeAction {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly label: string;
|
|
97
|
+
readonly variant: 'primary' | 'secondary' | 'danger';
|
|
98
|
+
readonly requiresInput?: boolean;
|
|
99
|
+
readonly cooldownMs?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface LoginChallengeInput {
|
|
102
|
+
readonly kind: 'none' | 'code' | 'ticket' | 'text';
|
|
103
|
+
readonly label: string;
|
|
104
|
+
/** Regular expression source the trimmed input must match. */
|
|
105
|
+
readonly pattern?: string;
|
|
106
|
+
/** Live validation hint shown while the input does not match `pattern`. */
|
|
107
|
+
readonly patternHint?: string;
|
|
108
|
+
readonly length?: number;
|
|
109
|
+
/** Never echoed (stdin) and never logged. */
|
|
110
|
+
readonly secret?: boolean;
|
|
111
|
+
/** Pull a ticket out of a pasted JSON object or URL before validation ({@link parseLoginTicket}). */
|
|
112
|
+
readonly extract?: 'ticket-json-or-url';
|
|
113
|
+
}
|
|
114
|
+
export interface LoginChallengeMedia {
|
|
115
|
+
/** Image URL or data URL; only present while the challenge is active. */
|
|
116
|
+
readonly qrImage?: string;
|
|
117
|
+
/** Set on event payloads that omitted `qrImage`; read the flow with `login.flow.get`. */
|
|
118
|
+
readonly qrImageOmitted?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Set on event payloads that omitted verification links (`media.link`, `media.captcha` and link
|
|
121
|
+
* blocks of slider / device / auth / link_verify challenges, which carry a session id); read them
|
|
122
|
+
* with `login.flow.get`.
|
|
123
|
+
*/
|
|
124
|
+
readonly linkOmitted?: boolean;
|
|
125
|
+
/** Only http / https links are kept. */
|
|
126
|
+
readonly link?: Readonly<{
|
|
127
|
+
url: string;
|
|
128
|
+
label: string;
|
|
129
|
+
}>;
|
|
130
|
+
readonly expiresAt?: number;
|
|
131
|
+
readonly refreshable?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Hosted captcha helper (slider): the Console opens the helper page on its own origin with this
|
|
134
|
+
* query; the ticket comes back by `postMessage` (see `login-captcha.ts`).
|
|
135
|
+
*/
|
|
136
|
+
readonly captcha?: LoginCaptchaMedia;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* One guided instruction. `blockId` points at the block the step is about; `doneWhen` lets the UI
|
|
140
|
+
* tick the step off when that block was copied / opened (`manual` = the person ticks it).
|
|
141
|
+
*/
|
|
142
|
+
export type LoginHelpStep = string | Readonly<{
|
|
143
|
+
text: string;
|
|
144
|
+
blockId?: string;
|
|
145
|
+
doneWhen?: 'copied' | 'opened' | 'manual';
|
|
146
|
+
}>;
|
|
147
|
+
export interface LoginChallengeHelp {
|
|
148
|
+
readonly short: string;
|
|
149
|
+
/** Ordered instructions. */
|
|
150
|
+
readonly steps?: readonly LoginHelpStep[];
|
|
151
|
+
/** Emphasized warning (e.g. never paste the device JSON on other sites). */
|
|
152
|
+
readonly warning?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Material handed to the person, rendered in order between help and input.
|
|
156
|
+
*
|
|
157
|
+
* - `copy`: monospace text with a copy button. `sensitive` content (device info, tokens) is hidden
|
|
158
|
+
* until revealed, never logged, and exists only while the challenge is active. `format: 'script'`
|
|
159
|
+
* is static Adapter text — never interpolate user or device data into it; `bookmarklet` offers a
|
|
160
|
+
* draggable `javascript:` link built from the same text. `thenOpen` names a link block: the UI
|
|
161
|
+
* offers one "copy and open" button.
|
|
162
|
+
* - `link`: http/https only; `showQr` also renders the URL as a QR code (client-side) for a phone.
|
|
163
|
+
* - `note`: a short remark.
|
|
164
|
+
*/
|
|
165
|
+
export type LoginChallengeBlock = Readonly<{
|
|
166
|
+
kind: 'copy';
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
content: string;
|
|
170
|
+
format: 'json' | 'script' | 'text';
|
|
171
|
+
sensitive?: boolean;
|
|
172
|
+
collapsed?: boolean;
|
|
173
|
+
collapsedLabel?: string;
|
|
174
|
+
bookmarklet?: boolean;
|
|
175
|
+
thenOpen?: string;
|
|
176
|
+
/** Set on snapshots where sensitive content was removed (inactive challenge or event payload). */
|
|
177
|
+
redacted?: boolean;
|
|
178
|
+
}> | Readonly<{
|
|
179
|
+
kind: 'link';
|
|
180
|
+
id?: string;
|
|
181
|
+
label: string;
|
|
182
|
+
url: string;
|
|
183
|
+
showQr?: boolean;
|
|
184
|
+
}> | Readonly<{
|
|
185
|
+
kind: 'note';
|
|
186
|
+
id?: string;
|
|
187
|
+
text: string;
|
|
188
|
+
tone?: 'info' | 'warning';
|
|
189
|
+
}>;
|
|
190
|
+
export interface LoginChallenge {
|
|
191
|
+
readonly id: string;
|
|
192
|
+
readonly kind: LoginChallengeKind;
|
|
193
|
+
readonly title: string;
|
|
194
|
+
readonly help?: LoginChallengeHelp;
|
|
195
|
+
readonly blocks?: readonly LoginChallengeBlock[];
|
|
196
|
+
readonly media?: LoginChallengeMedia;
|
|
197
|
+
readonly input?: LoginChallengeInput;
|
|
198
|
+
readonly actions: readonly LoginChallengeAction[];
|
|
199
|
+
readonly expiresAt?: number;
|
|
200
|
+
}
|
|
201
|
+
/** What an Adapter passes to `flow.challenge()`; `id` and `actions` get defaults. */
|
|
202
|
+
export type LoginChallengeDescriptor = Omit<LoginChallenge, 'id' | 'actions'> & {
|
|
203
|
+
readonly id?: string;
|
|
204
|
+
readonly actions?: readonly LoginChallengeAction[];
|
|
205
|
+
};
|
|
206
|
+
export interface LoginStep {
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly kind: LoginStepKind;
|
|
209
|
+
readonly status: LoginStepStatus;
|
|
210
|
+
readonly title: string;
|
|
211
|
+
readonly titleKey?: string;
|
|
212
|
+
readonly detail?: string;
|
|
213
|
+
readonly at: number;
|
|
214
|
+
readonly endedAt?: number;
|
|
215
|
+
readonly challenge?: LoginChallenge;
|
|
216
|
+
/** LoginAssist task answering this challenge (while it is active). */
|
|
217
|
+
readonly taskId?: string;
|
|
218
|
+
readonly outcome?: LoginOutcome;
|
|
219
|
+
}
|
|
220
|
+
export interface LoginFlowSnapshot {
|
|
221
|
+
readonly id: string;
|
|
222
|
+
readonly adapter: string;
|
|
223
|
+
readonly endpointKey: string;
|
|
224
|
+
readonly endpointIdentity?: LoginAssistEndpointIdentity;
|
|
225
|
+
readonly startedAt: number;
|
|
226
|
+
readonly updatedAt: number;
|
|
227
|
+
/** Increases with every change; consumers keep the highest revision per flow id. */
|
|
228
|
+
readonly revision: number;
|
|
229
|
+
readonly attempt: number;
|
|
230
|
+
readonly state: LoginFlowState;
|
|
231
|
+
/** Id of the step the flow is on (the last active step). */
|
|
232
|
+
readonly currentStep?: string;
|
|
233
|
+
readonly steps: readonly LoginStep[];
|
|
234
|
+
readonly lastOutcome?: LoginOutcome;
|
|
235
|
+
/** Submitted, but no result within the verify timeout: "result pending confirmation", not a failure. */
|
|
236
|
+
readonly pendingConfirmation?: boolean;
|
|
237
|
+
/** Task id of the active challenge (answer it with `submit`). */
|
|
238
|
+
readonly activeTaskId?: string;
|
|
239
|
+
}
|
|
240
|
+
/** What the person answered: the chosen action and the input values (never stored or emitted). */
|
|
241
|
+
export interface LoginChallengeAnswer {
|
|
242
|
+
readonly actionId: string;
|
|
243
|
+
readonly values: Readonly<Record<string, string>>;
|
|
244
|
+
}
|
|
245
|
+
export interface BeginLoginFlowOptions {
|
|
246
|
+
readonly adapter: string;
|
|
247
|
+
readonly endpointKey: string;
|
|
248
|
+
readonly owner: object;
|
|
249
|
+
readonly signal?: AbortSignal;
|
|
250
|
+
readonly endpointIdentity?: LoginAssistEndpointIdentity;
|
|
251
|
+
}
|
|
252
|
+
export interface LoginChallengeOptions {
|
|
253
|
+
/** Overrides the default challenge timeout; `0` disables it. */
|
|
254
|
+
readonly timeoutMs?: number;
|
|
255
|
+
}
|
|
256
|
+
/** Producer handle of one login flow. Calls after the flow ended are ignored. */
|
|
257
|
+
export interface LoginFlow {
|
|
258
|
+
readonly id: string;
|
|
259
|
+
snapshot(): LoginFlowSnapshot;
|
|
260
|
+
/** Append a timeline step; returns its id. `info` steps are marks (done at once). */
|
|
261
|
+
step(kind: Exclude<LoginStepKind, 'challenge'>, title: string, detail?: string, titleKey?: string): string;
|
|
262
|
+
/** Open the flow's active challenge (replacing the previous one) and wait for the answer. */
|
|
263
|
+
challenge(descriptor: LoginChallengeDescriptor, options?: LoginChallengeOptions): Promise<LoginChallengeAnswer>;
|
|
264
|
+
/** Label the verifying step (inserted automatically on submit). */
|
|
265
|
+
verifying(label: string): void;
|
|
266
|
+
outcome(outcome: LoginOutcome): void;
|
|
267
|
+
online(): void;
|
|
268
|
+
fail(code: LoginErrorCode, message?: string, next?: LoginNextAction): void;
|
|
269
|
+
/** End without a login result (`cancelled`, `expired`, `superseded`, …). */
|
|
270
|
+
end(reason?: string): void;
|
|
271
|
+
}
|
|
272
|
+
/** Thrown by `submit` when an answer does not fit the challenge. The message never contains the value. */
|
|
273
|
+
export declare class LoginSubmissionError extends Error {
|
|
274
|
+
readonly code: 'invalid_action' | 'input_required' | 'input_invalid';
|
|
275
|
+
constructor(code: 'invalid_action' | 'input_required' | 'input_invalid', message: string);
|
|
276
|
+
}
|
|
277
|
+
/** Raised from a challenge promise when a newer challenge replaced it. */
|
|
278
|
+
export declare class LoginChallengeReplacedError extends Error {
|
|
279
|
+
constructor();
|
|
280
|
+
}
|
|
281
|
+
export interface SubmitAndWaitResult {
|
|
282
|
+
readonly accepted: boolean;
|
|
283
|
+
readonly outcome?: LoginOutcome;
|
|
284
|
+
readonly pending?: boolean;
|
|
285
|
+
readonly flow?: LoginFlowSnapshot;
|
|
286
|
+
}
|
|
287
|
+
export interface LoginAssistOptions {
|
|
288
|
+
defaultTimeoutMs?: number;
|
|
289
|
+
/** "Result pending confirmation" delay after a submit. Default 20 s. */
|
|
290
|
+
verifyTimeoutMs?: number;
|
|
291
|
+
/** Title of the automatically inserted verifying step. */
|
|
292
|
+
verifyingTitle?: string;
|
|
293
|
+
/** Host-configured captcha helper page, filled into `media.captcha.helperUrl` when absent. */
|
|
294
|
+
captchaHelperUrl?: string;
|
|
58
295
|
}
|
|
59
296
|
export declare class LoginAssist {
|
|
60
297
|
#private;
|
|
@@ -63,29 +300,67 @@ export declare class LoginAssist {
|
|
|
63
300
|
private readonly local;
|
|
64
301
|
/** 构造时默认超时;可被 waitForInput options 覆盖 */
|
|
65
302
|
private readonly defaultTimeoutMs;
|
|
66
|
-
constructor(bus?: LoginAssistBus | null, options?:
|
|
67
|
-
|
|
68
|
-
|
|
303
|
+
constructor(bus?: LoginAssistBus | null, options?: LoginAssistOptions);
|
|
304
|
+
/** Host configuration (`console.loginAssist`); an invalid helper URL is ignored. */
|
|
305
|
+
configure(options: Pick<LoginAssistOptions, 'captchaHelperUrl'>): void;
|
|
69
306
|
/**
|
|
70
307
|
* Subscribe without requiring a Plugin EventEmitter.
|
|
71
308
|
* Returns unsubscribe.
|
|
72
309
|
*/
|
|
73
|
-
subscribe(name:
|
|
310
|
+
subscribe(name: 'endpoint.login.flow', listener: (flow: LoginFlowSnapshot) => void): () => void;
|
|
311
|
+
subscribe(name: LoginAssistTaskEventName, listener: (task: PendingLoginTask) => void): () => void;
|
|
312
|
+
/**
|
|
313
|
+
* Start the login flow of one Endpoint. A previous unfinished flow of the same Endpoint instance
|
|
314
|
+
* (owner) is ended as `superseded`; the attempt counter continues unless the last flow went online.
|
|
315
|
+
*/
|
|
316
|
+
beginFlow(options: BeginLoginFlowOptions): LoginFlow;
|
|
317
|
+
/** Latest flow per Endpoint (all states). Snapshots include the active challenge's material. */
|
|
318
|
+
listFlows(): LoginFlowSnapshot[];
|
|
319
|
+
getFlow(adapter: string, endpointKey: string): LoginFlowSnapshot | undefined;
|
|
320
|
+
getFlowById(id: string): LoginFlowSnapshot | undefined;
|
|
321
|
+
/**
|
|
322
|
+
* Event-safe form of a snapshot ({@link withoutLoginMedia}): what Console readers without
|
|
323
|
+
* `endpoint.operate` on the flow's Endpoint receive from `login.flow.*` (ADR 0058 §8).
|
|
324
|
+
*/
|
|
325
|
+
eventSafeFlow(flow: LoginFlowSnapshot): LoginFlowSnapshot;
|
|
326
|
+
/** Flow a pending task belongs to. */
|
|
327
|
+
flowOfTask(taskId: string): LoginFlowSnapshot | undefined;
|
|
328
|
+
/**
|
|
329
|
+
* True while an unfinished flow of this Endpoint waits for an answer. Adapters use it to
|
|
330
|
+
* suppress automatic relogin while a person is answering a challenge.
|
|
331
|
+
*/
|
|
332
|
+
hasActiveChallenge(endpointKey: string, adapter?: string): boolean;
|
|
74
333
|
/**
|
|
75
334
|
* 生产者:等待用户输入后 resolve。会发出 endpoint.login.pending 事件,未消费前可被 listPending 拉取(刷新后可继续消费)。
|
|
76
335
|
* 超时后 reject 并 emit `endpoint.login.expired`。
|
|
336
|
+
*
|
|
337
|
+
* ADR 0058: the task is a challenge of the Endpoint's current flow (an implicit flow when the
|
|
338
|
+
* Adapter never called `beginFlow`); the payload is mapped to a challenge descriptor.
|
|
77
339
|
*/
|
|
78
340
|
waitForInput(adapter: string, endpointKey: string, type: LoginAssistType, payload: PendingLoginTaskPayload, options: WaitForInputOptions): Promise<string | Record<string, unknown>>;
|
|
79
341
|
/**
|
|
80
|
-
* 消费者:提交结果,对应 waitForInput 的 Promise 会 resolve。
|
|
342
|
+
* 消费者:提交结果,对应 waitForInput / challenge 的 Promise 会 resolve。
|
|
343
|
+
* `value` is a string (legacy) or `{ action, values }`. An answer that does not fit a
|
|
344
|
+
* `beginFlow` challenge throws {@link LoginSubmissionError} and leaves the challenge open.
|
|
81
345
|
*/
|
|
82
346
|
submit(id: string, value: string | Record<string, unknown>, endpointIdentity?: LoginAssistEndpointIdentity): boolean;
|
|
83
347
|
/**
|
|
84
|
-
*
|
|
348
|
+
* Submit and wait for the flow's next result (outcome, online, failure, end or a following
|
|
349
|
+
* challenge) for at most `timeoutMs` (default 15 s). Without a result: `pending: true`.
|
|
350
|
+
*/
|
|
351
|
+
submitAndWait(id: string, value: string | Record<string, unknown>, options?: {
|
|
352
|
+
endpointIdentity?: LoginAssistEndpointIdentity;
|
|
353
|
+
timeoutMs?: number;
|
|
354
|
+
}): Promise<SubmitAndWaitResult>;
|
|
355
|
+
/**
|
|
356
|
+
* 消费者:取消某条待办,对应 Promise 会 reject;所属流程以 `cancelled` 结束。
|
|
85
357
|
*/
|
|
86
358
|
cancel(id: string, reason?: string, endpointIdentity?: LoginAssistEndpointIdentity): boolean;
|
|
87
359
|
/**
|
|
88
360
|
* Cancel pending tasks created by one exact Endpoint instance.
|
|
361
|
+
*
|
|
362
|
+
* Flow mapping of the reason: `replaced_by_*` only retires the active challenge (a new one
|
|
363
|
+
* follows); `online` reports the flow online; `login_error` fails it; anything else ends it.
|
|
89
364
|
*/
|
|
90
365
|
cancelOwned(owner: object, reason?: string): number;
|
|
91
366
|
/**
|
|
@@ -95,3 +370,31 @@ export declare class LoginAssist {
|
|
|
95
370
|
hasPending(adapter?: string, endpointKey?: string): boolean;
|
|
96
371
|
dispose(): void;
|
|
97
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Event / history-safe copy of a flow snapshot: QR images are replaced by `qrImageOmitted`,
|
|
375
|
+
* sensitive copy blocks are redacted, and verification links (`media.link`, `media.captcha`, link
|
|
376
|
+
* blocks) of slider / device / auth / link_verify challenges — they carry a session id — are
|
|
377
|
+
* dropped with `linkOmitted`. Operators (`endpoint.operate` on the Endpoint) read
|
|
378
|
+
* the live material with `login.flow.get`; read-only Console callers receive this form there too.
|
|
379
|
+
*/
|
|
380
|
+
export declare function withoutLoginMedia(flow: LoginFlowSnapshot): LoginFlowSnapshot;
|
|
381
|
+
/** Alias that names the purpose: what may enter events, history and logs. */
|
|
382
|
+
export declare const eventSafeLoginFlow: typeof withoutLoginMedia;
|
|
383
|
+
/** Default next action for an error code. */
|
|
384
|
+
export declare function defaultNext(code: LoginErrorCode): LoginNextAction;
|
|
385
|
+
export type LoginTicketParseResult = Readonly<{
|
|
386
|
+
ok: true;
|
|
387
|
+
ticket: string;
|
|
388
|
+
randstr?: string;
|
|
389
|
+
}> | Readonly<{
|
|
390
|
+
ok: false;
|
|
391
|
+
error: string;
|
|
392
|
+
}>;
|
|
393
|
+
/**
|
|
394
|
+
* Pure parser behind `input.extract: 'ticket-json-or-url'` (shared by Console, SDK and stdin).
|
|
395
|
+
* Accepts a raw ticket, `ticket,randstr`, a JSON response body (`{ ticket, randstr }`, also nested
|
|
396
|
+
* one level under `data` / `result`), or a URL with a `ticket=` query parameter.
|
|
397
|
+
*/
|
|
398
|
+
export declare function parseLoginTicket(raw: unknown): LoginTicketParseResult;
|
|
399
|
+
/** Ticket text for an input with `extract: 'ticket-json-or-url'` (the raw text when unparseable). */
|
|
400
|
+
export declare function extractLoginTicket(raw: string): string;
|