@supersdk/supercli 0.2.1-staging.20 → 0.2.1-staging.21
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/dist/api/consoleClient.js +17 -12
- package/dist/api/consoleClient.js.map +1 -1
- package/dist/auth/browserAuth.js +42 -44
- package/dist/auth/browserAuth.js.map +1 -1
- package/dist/auth/tokenAuth.js +46 -0
- package/dist/auth/tokenAuth.js.map +1 -0
- package/dist/cli.js +66 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/accounts.js +89 -31
- package/dist/commands/accounts.js.map +1 -1
- package/dist/commands/login.js +75 -48
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +20 -25
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/publishSite.js +142 -83
- package/dist/commands/publishSite.js.map +1 -1
- package/dist/commands/switchaccount.js +36 -24
- package/dist/commands/switchaccount.js.map +1 -1
- package/dist/config/environments.js +17 -1
- package/dist/config/environments.js.map +1 -1
- package/dist/exit/exitCodes.js +55 -0
- package/dist/exit/exitCodes.js.map +1 -0
- package/dist/output/envelope.js +104 -0
- package/dist/output/envelope.js.map +1 -0
- package/dist/output/resultPrinter.js +70 -0
- package/dist/output/resultPrinter.js.map +1 -0
- package/dist/publish/siteClient.js +14 -4
- package/dist/publish/siteClient.js.map +1 -1
- package/dist/store/accountStore.js +2 -2
- package/dist/store/accountStore.js.map +1 -1
- package/dist/store/backends/encryptedFile.js +4 -1
- package/dist/store/backends/encryptedFile.js.map +1 -1
- package/dist/store/backends/osKeyring.js +4 -8
- package/dist/store/backends/osKeyring.js.map +1 -1
- package/dist/store/credentialStore.js +22 -0
- package/dist/store/credentialStore.js.map +1 -1
- package/dist/util/log.js +10 -1
- package/dist/util/log.js.map +1 -1
- package/dist/util/prompt.js +25 -0
- package/dist/util/prompt.js.map +1 -1
- package/package.json +1 -1
- package/dist/auth/refresh.js +0 -32
- package/dist/auth/refresh.js.map +0 -1
package/dist/commands/login.js
CHANGED
|
@@ -1,20 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runLogin = runLogin;
|
|
3
4
|
exports.registerLoginCommand = registerLoginCommand;
|
|
4
5
|
const consoleClient_1 = require("../api/consoleClient");
|
|
5
6
|
const browserAuth_1 = require("../auth/browserAuth");
|
|
6
7
|
const environments_1 = require("../config/environments");
|
|
7
8
|
const credentialStore_1 = require("../store/credentialStore");
|
|
8
|
-
const
|
|
9
|
+
const resultPrinter_1 = require("../output/resultPrinter");
|
|
9
10
|
const prompt_1 = require("../util/prompt");
|
|
10
|
-
// 授权页把 cli_version
|
|
11
|
-
// **自己**的版本。原先取 process.env.npm_package_version —— 那是「当前 npm 脚本所属包」
|
|
12
|
-
// 的版本:全局安装直接跑时它没有值(显示 0.0.0),在业务工程里经 npm run xxx 调用时显示的
|
|
13
|
-
// 是那个业务工程的版本。
|
|
11
|
+
// 授权页把 cli_version 展示给真人看,必须是 supercli **自己**的版本(不是 npm_package_version)。
|
|
14
12
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
13
|
const pkg = require('../../package.json');
|
|
16
14
|
/** --credential-backend 的合法取值,与 --help 文案同源。 */
|
|
17
15
|
const CREDENTIAL_BACKENDS = ['os-keyring', 'encrypted-file'];
|
|
16
|
+
const defaultLoginRunDeps = {
|
|
17
|
+
performLogin: browserAuth_1.login,
|
|
18
|
+
selectBackend: credentialStore_1.selectCredentialBackend,
|
|
19
|
+
createClient: (apiOrigin) => new consoleClient_1.ConsoleClient(apiOrigin),
|
|
20
|
+
isNonInteractive: prompt_1.isNonInteractive,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Core login flow (AC-2/AC-4). In a non-interactive session (`--output json` or
|
|
24
|
+
* `--no-input`) it fails fast WITHOUT touching stdin — an Agent must never hang
|
|
25
|
+
* on the browser-paste prompt; the message points at SUPERCLI_TOKEN (TC-006/007).
|
|
26
|
+
*/
|
|
27
|
+
async function runLogin(opts, deps = {}) {
|
|
28
|
+
const d = { ...defaultLoginRunDeps, ...deps };
|
|
29
|
+
if (d.isNonInteractive()) {
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
kind: 'usage_error',
|
|
33
|
+
message: 'login is interactive (browser authorization + paste a code) and cannot run under --output json / --no-input; ' +
|
|
34
|
+
'set SUPERCLI_TOKEN to a token from a prior interactive `supercli login` to run unattended',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const env = (0, environments_1.resolveEnvironment)({
|
|
39
|
+
environment: opts.environment,
|
|
40
|
+
apiOrigin: opts.apiOrigin,
|
|
41
|
+
webOrigin: opts.webOrigin,
|
|
42
|
+
});
|
|
43
|
+
// 🔴 必须校验枚举(origin/staging 修复并入 runLogin):拼错一个字母(encrypted-fil)
|
|
44
|
+
// 会**静默**回落到系统钥匙串,用户以为凭据进了口令加密文件。返回 usage_error 而非静默。
|
|
45
|
+
if (opts.credentialBackend !== undefined && !CREDENTIAL_BACKENDS.includes(opts.credentialBackend)) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
kind: 'usage_error',
|
|
49
|
+
message: `invalid --credential-backend "${opts.credentialBackend}" (expected ${CREDENTIAL_BACKENDS.join('|')})`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const allowEncryptedFallback = opts.credentialBackend === 'encrypted-file';
|
|
53
|
+
const backend = d.selectBackend({
|
|
54
|
+
allowEncryptedFallback,
|
|
55
|
+
passphraseProvider: allowEncryptedFallback
|
|
56
|
+
? () => (0, prompt_1.promptHiddenSync)('Encryption passphrase (for the local credential vault): ')
|
|
57
|
+
: undefined,
|
|
58
|
+
});
|
|
59
|
+
const client = d.createClient(env.apiOrigin);
|
|
60
|
+
const result = await d.performLogin({
|
|
61
|
+
client,
|
|
62
|
+
backend,
|
|
63
|
+
env,
|
|
64
|
+
openBrowser: browserAuth_1.defaultOpenBrowser,
|
|
65
|
+
promptCode: () => (0, prompt_1.promptLineSync)('Paste the authorization code from your browser: '),
|
|
66
|
+
cliVersion: pkg.version,
|
|
67
|
+
});
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
return { ok: false, kind: 'business_error', message: result.message ?? 'login failed' };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
ok: true,
|
|
73
|
+
result: { accountKey: result.account?.accountKey, env: env.label, org: result.account?.orgId },
|
|
74
|
+
humanMessage: `logged in as ${result.account?.accountKey} (${env.label})`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
if (err instanceof prompt_1.NonInteractiveError) {
|
|
79
|
+
return { ok: false, kind: 'usage_error', message: err.message };
|
|
80
|
+
}
|
|
81
|
+
return { ok: false, kind: 'business_error', message: `login error: ${err.message}` };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
18
84
|
function registerLoginCommand(program) {
|
|
19
85
|
program
|
|
20
86
|
.command('login')
|
|
@@ -23,49 +89,10 @@ function registerLoginCommand(program) {
|
|
|
23
89
|
.option('--api-origin <url>', 'custom Console API origin (implies a custom environment)')
|
|
24
90
|
.option('--web-origin <url>', 'custom Console web origin (defaults to --api-origin, custom only)')
|
|
25
91
|
.option('--credential-backend <backend>', 'os-keyring (default) or encrypted-file')
|
|
26
|
-
.action(async (opts) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
apiOrigin: opts.apiOrigin,
|
|
31
|
-
webOrigin: opts.webOrigin,
|
|
32
|
-
});
|
|
33
|
-
// 🔴 必须校验枚举:原先只做 `=== 'encrypted-file'` 等值判断,于是拼错一个字母
|
|
34
|
-
// (encrypted_file / encrypted-fil)会**静默**回落到系统钥匙串 —— 用户以为凭据进了
|
|
35
|
-
// 口令加密文件,实际进了 OS keyring,全程零提示。同一 CLI 的 --environment /
|
|
36
|
-
// --channel / --platform 都是严格校验的,这里不该例外。
|
|
37
|
-
if (opts.credentialBackend !== undefined && !CREDENTIAL_BACKENDS.includes(opts.credentialBackend)) {
|
|
38
|
-
log_1.log.error(`invalid --credential-backend "${opts.credentialBackend}" (expected ${CREDENTIAL_BACKENDS.join('|')})`);
|
|
39
|
-
process.exitCode = 1;
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const allowEncryptedFallback = opts.credentialBackend === 'encrypted-file';
|
|
43
|
-
const backend = (0, credentialStore_1.selectCredentialBackend)({
|
|
44
|
-
allowEncryptedFallback,
|
|
45
|
-
passphraseProvider: allowEncryptedFallback
|
|
46
|
-
? () => (0, prompt_1.promptHiddenSync)('Encryption passphrase (for the local credential vault): ')
|
|
47
|
-
: undefined,
|
|
48
|
-
});
|
|
49
|
-
const client = new consoleClient_1.ConsoleClient(env.apiOrigin);
|
|
50
|
-
const result = await (0, browserAuth_1.login)({
|
|
51
|
-
client,
|
|
52
|
-
backend,
|
|
53
|
-
env,
|
|
54
|
-
openBrowser: browserAuth_1.defaultOpenBrowser,
|
|
55
|
-
promptCode: () => (0, prompt_1.promptLineSync)('Paste the authorization code from your browser: '),
|
|
56
|
-
cliVersion: pkg.version,
|
|
57
|
-
});
|
|
58
|
-
if (!result.ok) {
|
|
59
|
-
log_1.log.error(result.message ?? 'login failed');
|
|
60
|
-
process.exitCode = 1;
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
log_1.log.info(`logged in as ${result.account?.email} [${result.account?.accountKey}] (${env.label})`);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
log_1.log.error(`login error: ${err.message}`);
|
|
67
|
-
process.exitCode = 1;
|
|
68
|
-
}
|
|
92
|
+
.action(async (opts, cmd) => {
|
|
93
|
+
const mode = cmd.optsWithGlobals?.()?.output === 'json' ? 'json' : 'human';
|
|
94
|
+
const outcome = await runLogin(opts);
|
|
95
|
+
new resultPrinter_1.ResultPrinter(mode).emit(outcome);
|
|
69
96
|
});
|
|
70
97
|
}
|
|
71
98
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;AAyCA,4BA8DC;AAED,oDAaC;AArHD,wDAAqD;AACrD,qDAAkH;AAClH,yDAA4D;AAC5D,8DAAsH;AACtH,2DAA8F;AAC9F,2CAAyG;AAEzG,0EAA0E;AAC1E,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAwB,CAAC;AAEjE,gDAAgD;AAChD,MAAM,mBAAmB,GAAsB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAgBhF,MAAM,mBAAmB,GAAiB;IACxC,YAAY,EAAZ,mBAAY;IACZ,aAAa,EAAE,yCAAuB;IACtC,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,6BAAa,CAAC,SAAS,CAAC;IACzD,gBAAgB,EAAhB,yBAAgB;CACjB,CAAC;AAEF;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAAC,IAAkB,EAAE,OAA8B,EAAE;IACjF,MAAM,CAAC,GAAG,EAAE,GAAG,mBAAmB,EAAE,GAAG,IAAI,EAAE,CAAC;IAE9C,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;QACzB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,aAAa;YACnB,OAAO,EACL,+GAA+G;gBAC/G,2FAA2F;SAC9F,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,iCAAkB,EAAC;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,gEAAgE;QAChE,sDAAsD;QACtD,IA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5
5
|
const consoleClient_1 = require("../api/consoleClient");
|
|
6
6
|
const accountStore_1 = require("../store/accountStore");
|
|
7
7
|
const credentialStore_1 = require("../store/credentialStore");
|
|
8
|
-
const
|
|
8
|
+
const resultPrinter_1 = require("../output/resultPrinter");
|
|
9
9
|
const prompt_1 = require("../util/prompt");
|
|
10
|
+
const log_1 = require("../util/log");
|
|
10
11
|
const defaultDeps = {
|
|
11
12
|
resolveBackend: (account) => (0, credentialStore_1.backendForAccount)(account.backend, {
|
|
12
13
|
passphraseProvider: account.backend === 'encrypted-file'
|
|
13
|
-
? () => (0, prompt_1.promptHiddenSync)(`Encryption passphrase for ${account.email}: `)
|
|
14
|
+
? () => (0, prompt_1.promptHiddenSync)(`Encryption passphrase for ${account.email ?? account.accountKey}: `)
|
|
14
15
|
: undefined,
|
|
15
16
|
}),
|
|
16
17
|
createClient: (apiOrigin) => new consoleClient_1.ConsoleClient(apiOrigin),
|
|
17
18
|
};
|
|
18
19
|
function resolveTarget(selector) {
|
|
19
|
-
if (!selector)
|
|
20
|
+
if (!selector)
|
|
20
21
|
return (0, accountStore_1.getCurrentAccount)();
|
|
21
|
-
}
|
|
22
22
|
const resolution = (0, accountStore_1.resolveSelector)((0, accountStore_1.listAccounts)(), selector);
|
|
23
23
|
if (resolution.kind === 'found')
|
|
24
24
|
return resolution.account;
|
|
@@ -27,73 +27,68 @@ function resolveTarget(selector) {
|
|
|
27
27
|
return 'not_found';
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Core logout
|
|
31
|
-
*
|
|
32
|
-
* network — registerLogoutCommand() below is a thin CLI-wiring wrapper around
|
|
33
|
-
* this with production defaults.
|
|
30
|
+
* Core logout (D-5 self-revoke). Remote self-revoke runs BEFORE local removal;
|
|
31
|
+
* a failed remote revoke preserves local state. `--local-only` skips remote.
|
|
34
32
|
*/
|
|
35
33
|
async function runLogout(selector, opts, deps = defaultDeps) {
|
|
36
34
|
const target = resolveTarget(selector);
|
|
37
35
|
if (target === 'ambiguous') {
|
|
38
|
-
return { ok: false, message: `"${selector}" matches more than one saved account — use an account key to disambiguate` };
|
|
36
|
+
return { ok: false, kind: 'business_error', message: `"${selector}" matches more than one saved account — use an account key to disambiguate` };
|
|
39
37
|
}
|
|
40
38
|
if (target === 'not_found' || target === null) {
|
|
41
39
|
return {
|
|
42
40
|
ok: false,
|
|
41
|
+
kind: 'business_error',
|
|
43
42
|
message: selector ? `no saved account matches "${selector}"` : 'no current account and no selector given',
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
const account = target;
|
|
47
46
|
if (opts.localOnly) {
|
|
48
47
|
try {
|
|
49
|
-
const backend = deps.resolveBackend(account);
|
|
50
48
|
// delete() never needs the passphrase — see encryptedFile.ts.
|
|
51
|
-
|
|
49
|
+
deps.resolveBackend(account).delete(account.accountKey);
|
|
52
50
|
}
|
|
53
51
|
catch (err) {
|
|
54
52
|
log_1.log.warn('local credential cleanup failed (continuing)', { error: err.message });
|
|
55
53
|
}
|
|
56
54
|
(0, accountStore_1.removeAccount)(account.accountKey);
|
|
57
|
-
return { ok: true,
|
|
55
|
+
return { ok: true, result: { removed: account.accountKey, remoteRevoked: false }, humanMessage: `removed local state for ${account.accountKey} (remote not contacted, --local-only)` };
|
|
58
56
|
}
|
|
59
57
|
let backend;
|
|
60
58
|
try {
|
|
61
59
|
backend = deps.resolveBackend(account);
|
|
62
60
|
}
|
|
63
61
|
catch (err) {
|
|
64
|
-
return { ok: false, message: `cannot access the credential store to revoke remotely: ${err.message}` };
|
|
62
|
+
return { ok: false, kind: 'infra_error', message: `cannot access the credential store to revoke remotely: ${err.message}` };
|
|
65
63
|
}
|
|
66
64
|
const secret = backend.get(account.accountKey);
|
|
67
65
|
if (!secret) {
|
|
68
66
|
// Nothing live to revoke remotely from this machine's perspective.
|
|
69
67
|
(0, accountStore_1.removeAccount)(account.accountKey);
|
|
70
|
-
return { ok: true,
|
|
68
|
+
return { ok: true, result: { removed: account.accountKey, remoteRevoked: false }, humanMessage: `removed local state for ${account.accountKey} (no credential on file)` };
|
|
71
69
|
}
|
|
72
70
|
const client = deps.createClient(account.apiOrigin);
|
|
73
|
-
const outcome = await client.
|
|
71
|
+
const outcome = await client.revokeSelfToken(secret.token);
|
|
74
72
|
if (outcome.kind !== 'success') {
|
|
73
|
+
const kind = outcome.kind === 'rate_limited' ? 'rate_limited' : outcome.kind === 'auth_invalid' ? 'auth_invalid' : 'infra_error';
|
|
75
74
|
return {
|
|
76
75
|
ok: false,
|
|
76
|
+
kind,
|
|
77
77
|
message: `remote revoke failed (${outcome.kind}) — local account state preserved; retry, or pass --local-only to force removal`,
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
backend.delete(account.accountKey);
|
|
81
81
|
(0, accountStore_1.removeAccount)(account.accountKey);
|
|
82
|
-
return { ok: true,
|
|
82
|
+
return { ok: true, result: { removed: account.accountKey, remoteRevoked: true }, humanMessage: `logged out ${account.accountKey}` };
|
|
83
83
|
}
|
|
84
84
|
function registerLogoutCommand(program) {
|
|
85
85
|
program
|
|
86
86
|
.command('logout [selector]')
|
|
87
|
-
.description('Log out of an account (defaults to current). Remote revoke runs before local removal.')
|
|
87
|
+
.description('Log out of an account (defaults to current). Remote self-revoke runs before local removal.')
|
|
88
88
|
.option('--local-only', 'skip the remote revoke call and only remove local state')
|
|
89
|
-
.action(async (selector, opts) => {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
log_1.log.error(result.message ?? 'logout failed');
|
|
93
|
-
process.exitCode = 1;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
log_1.log.info(result.message ?? 'logged out');
|
|
89
|
+
.action(async (selector, opts, cmd) => {
|
|
90
|
+
const mode = cmd.optsWithGlobals?.()?.output === 'json' ? 'json' : 'human';
|
|
91
|
+
new resultPrinter_1.ResultPrinter(mode).emit(await runLogout(selector, opts));
|
|
97
92
|
});
|
|
98
93
|
}
|
|
99
94
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;AA8CA,8BAyDC;AAED,sDASC;AAjHD,wDAA0F;AAC1F,wDAA4H;AAC5H,8DAAqF;AACrF,2DAA8F;AAC9F,2CAAkD;AAClD,qCAAkC;AAiBlC,MAAM,WAAW,GAAe;IAC9B,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAC1B,IAAA,mCAAiB,EAAC,OAAO,CAAC,OAAO,EAAE;QACjC,kBAAkB,EAChB,OAAO,CAAC,OAAO,KAAK,gBAAgB;YAClC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAA,yBAAgB,EAAC,6BAA6B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC;YAC9F,CAAC,CAAC,SAAS;KAChB,CAAC;IACJ,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,6BAAa,CAAC,SAAS,CAAC;CAC1D,CAAC;AAEF,SAAS,aAAa,CAAC,QAA4B;IACjD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAA,gCAAiB,GAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,IAAA,8BAAe,EAAC,IAAA,2BAAY,GAAE,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC,OAAO,CAAC;IAC3D,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IACxD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,SAAS,CAC7B,QAA4B,EAC5B,IAAmB,EACnB,OAAmB,WAAW;IAE9B,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,WAAW,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