@dxnow/zl-cli 0.0.5 → 0.0.6
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/authorization-callback.js +117 -0
- package/dist/index.js +11 -9
- package/package.json +1 -1
- package/skills/zhilian-crm/SKILL.md +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export function renderAuthorizationCallback(accepted) {
|
|
2
|
+
const title = accepted ? '已接收授权' : '未能接收授权';
|
|
3
|
+
const statusIcon = accepted ? 'm5 12 4 4L19 6' : 'M12 7v5m0 4h.01';
|
|
4
|
+
const instruction = accepted ? '返回发起登录的应用' : '重新发起授权';
|
|
5
|
+
const detail = accepted
|
|
6
|
+
? '请在发起登录的应用中查看登录结果。此标签页可以关闭。'
|
|
7
|
+
: '请回到发起登录的应用,重新发起登录并在浏览器中确认授权。';
|
|
8
|
+
return `<!doctype html>
|
|
9
|
+
<html lang="zh-CN">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8">
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
13
|
+
<title>${title} · 智连 CLI</title>
|
|
14
|
+
<style>
|
|
15
|
+
:root {
|
|
16
|
+
--ink: #121a2c;
|
|
17
|
+
--text: #1d283b;
|
|
18
|
+
--muted: #5c687d;
|
|
19
|
+
--line: #e2e7ef;
|
|
20
|
+
--canvas: #f2f4f8;
|
|
21
|
+
--accent: #3054e0;
|
|
22
|
+
--mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
|
|
23
|
+
}
|
|
24
|
+
* { box-sizing: border-box; }
|
|
25
|
+
body { margin: 0; color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; }
|
|
26
|
+
main { display: grid; grid-template-columns: minmax(400px, 46%) minmax(0, 1fr); min-height: 100vh; }
|
|
27
|
+
.stage {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
padding: 36px 56px 40px;
|
|
32
|
+
background: radial-gradient(ellipse at bottom right, #24366b, transparent 48%), var(--ink);
|
|
33
|
+
}
|
|
34
|
+
.stage::before {
|
|
35
|
+
position: absolute;
|
|
36
|
+
inset: 0;
|
|
37
|
+
background-image: radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1px);
|
|
38
|
+
background-size: 22px 22px;
|
|
39
|
+
mask-image: linear-gradient(165deg, #000 10%, transparent 70%);
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
content: '';
|
|
42
|
+
}
|
|
43
|
+
.stage > * { position: relative; }
|
|
44
|
+
.brand { display: flex; align-items: center; gap: 10px; color: #a7b1c6; font-size: 13px; }
|
|
45
|
+
.brand strong { color: #fff; font-size: 18px; font-weight: 650; }
|
|
46
|
+
.brand-sub { padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .16); }
|
|
47
|
+
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; background: var(--accent); }
|
|
48
|
+
svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
|
|
49
|
+
.stage-body { width: 100%; max-width: 460px; margin: auto 0; padding: 48px 0 24px; }
|
|
50
|
+
.eyebrow { margin: 0 0 12px; color: #93a8ff; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
|
|
51
|
+
.stage-title { margin: 0; color: #fff; font-size: 36px; font-weight: 650; line-height: 1.3; letter-spacing: -.02em; }
|
|
52
|
+
.terminal { margin-top: 36px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; background: #0a101e; box-shadow: 0 24px 48px rgba(0, 0, 0, .32); font-family: var(--mono); font-size: 13px; }
|
|
53
|
+
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
|
|
54
|
+
.terminal-bar i { width: 9px; height: 9px; border-radius: 50%; background: #29334d; }
|
|
55
|
+
.terminal-bar span { margin-left: 8px; color: #9aa6c0; font-size: 11px; }
|
|
56
|
+
.terminal-body { padding: 14px 18px 18px; color: #d7ddeb; line-height: 1.95; }
|
|
57
|
+
.terminal-body p { margin: 0; }
|
|
58
|
+
.terminal-body b { margin-right: 10px; color: #7f9bff; font-weight: 500; }
|
|
59
|
+
.terminal-body .terminal-status { color: ${accepted ? '#82d7b1' : '#f2c76a'}; }
|
|
60
|
+
.result-area { display: grid; place-items: center; padding: 56px 48px; }
|
|
61
|
+
.result { width: 100%; max-width: 460px; }
|
|
62
|
+
.status-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 20px; border-radius: 16px; color: ${accepted ? '#13845e' : '#a5680f'}; background: ${accepted ? '#edf7f2' : '#fdf3e3'}; }
|
|
63
|
+
.result-label { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
|
|
64
|
+
h1 { margin: 0 0 24px; font-size: 32px; font-weight: 650; line-height: 1.3; letter-spacing: -.02em; }
|
|
65
|
+
.next-step { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8f9fc; }
|
|
66
|
+
.next-step svg { margin-top: 2px; color: var(--accent); }
|
|
67
|
+
.next-step h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
|
|
68
|
+
.next-step p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
|
|
69
|
+
@media (max-width: 1100px) {
|
|
70
|
+
.stage { padding: 32px 40px; }
|
|
71
|
+
.stage-title { font-size: 30px; }
|
|
72
|
+
.result-area { padding: 48px 32px; }
|
|
73
|
+
}
|
|
74
|
+
@media (max-width: 900px) {
|
|
75
|
+
main { display: block; background: var(--canvas); }
|
|
76
|
+
.stage { padding: 20px 20px 76px; }
|
|
77
|
+
.stage-body { max-width: none; padding: 32px 0 0; }
|
|
78
|
+
.stage-title { font-size: 26px; }
|
|
79
|
+
.terminal { margin-top: 20px; }
|
|
80
|
+
.terminal-body { padding: 10px 14px 12px; }
|
|
81
|
+
.result-area { display: block; margin-top: -52px; padding: 0 12px 32px; }
|
|
82
|
+
.result { position: relative; max-width: 560px; margin: 0 auto; padding: 24px 20px; border-radius: 16px; background: #fff; box-shadow: 0 12px 32px rgba(18, 26, 44, .1); }
|
|
83
|
+
h1 { font-size: 26px; }
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
86
|
+
</head>
|
|
87
|
+
<body>
|
|
88
|
+
<main>
|
|
89
|
+
<div class="stage">
|
|
90
|
+
<div class="brand">
|
|
91
|
+
<span class="logo" aria-hidden="true"><svg width="17" height="17" viewBox="0 0 24 24"><path d="m13 5 6 6m-3-3 3-3m-1 5 3-3M5 19l3-3m-4 4 1-1m3-3-2-2 6-6 4 4-6 6z"/></svg></span>
|
|
92
|
+
<strong>智连</strong><span class="brand-sub">桌面应用授权</span>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="stage-body" aria-hidden="true">
|
|
95
|
+
<p class="eyebrow">智连 CLI · 桌面应用连接</p>
|
|
96
|
+
<p class="stage-title">连接你的智连工作空间</p>
|
|
97
|
+
<div class="terminal">
|
|
98
|
+
<div class="terminal-bar"><i></i><i></i><i></i><span>terminal</span></div>
|
|
99
|
+
<div class="terminal-body"><p><b>$</b>dxnow auth login</p><p class="terminal-status">${title}</p></div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
<section class="result-area" aria-labelledby="result-title">
|
|
104
|
+
<div class="result">
|
|
105
|
+
<div class="status-icon" aria-hidden="true"><svg width="26" height="26" viewBox="0 0 24 24"><path d="${statusIcon}"/></svg></div>
|
|
106
|
+
<p class="result-label">授权结果</p>
|
|
107
|
+
<h1 id="result-title">${title}</h1>
|
|
108
|
+
<div class="next-step">
|
|
109
|
+
<svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M12 16v4m-4 0h8"/></svg>
|
|
110
|
+
<div><h2>${instruction}</h2><p>${detail}</p></div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</section>
|
|
114
|
+
</main>
|
|
115
|
+
</body>
|
|
116
|
+
</html>`;
|
|
117
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { homedir } from 'node:os';
|
|
|
7
7
|
import { isAbsolute, join } from 'node:path';
|
|
8
8
|
import { parseArgs } from 'node:util';
|
|
9
9
|
import { Entry } from '@napi-rs/keyring';
|
|
10
|
+
import { renderAuthorizationCallback } from './authorization-callback.js';
|
|
10
11
|
class ApiError extends Error {
|
|
11
12
|
code;
|
|
12
13
|
constructor(code, message) {
|
|
@@ -151,7 +152,6 @@ async function login(server, store) {
|
|
|
151
152
|
const codePromise = new Promise((resolve, reject) => { complete = resolve; fail = reject; });
|
|
152
153
|
const listener = createServer((req, res) => {
|
|
153
154
|
res.setHeader('Cache-Control', 'no-store');
|
|
154
|
-
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
155
155
|
const url = new URL(req.url || '/', 'http://127.0.0.1');
|
|
156
156
|
if (req.method !== 'GET' || url.pathname !== '/oauth/callback') {
|
|
157
157
|
res.writeHead(404).end();
|
|
@@ -159,13 +159,15 @@ async function login(server, store) {
|
|
|
159
159
|
}
|
|
160
160
|
const actualState = url.searchParams.get('state') || '';
|
|
161
161
|
const code = url.searchParams.get('code') || '';
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
const accepted = Buffer.byteLength(actualState) === Buffer.byteLength(state)
|
|
163
|
+
&& timingSafeEqual(Buffer.from(actualState), Buffer.from(state)) && /^[A-Za-z0-9_-]{43}$/.test(code);
|
|
164
|
+
res.writeHead(accepted ? 200 : 400, {
|
|
165
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
166
|
+
'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'",
|
|
167
|
+
'Referrer-Policy': 'no-referrer'
|
|
168
|
+
}).end(renderAuthorizationCallback(accepted));
|
|
169
|
+
if (accepted)
|
|
170
|
+
complete(code);
|
|
169
171
|
});
|
|
170
172
|
await new Promise((resolve, reject) => { listener.once('error', reject); listener.listen(0, '127.0.0.1', resolve); });
|
|
171
173
|
const address = listener.address();
|
|
@@ -201,7 +203,7 @@ async function login(server, store) {
|
|
|
201
203
|
}
|
|
202
204
|
async function main() {
|
|
203
205
|
if (values.version) {
|
|
204
|
-
process.stdout.write('0.0.
|
|
206
|
+
process.stdout.write('0.0.6\n');
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
207
209
|
if (values.help || positionals.length === 0) {
|
package/package.json
CHANGED
|
@@ -62,7 +62,7 @@ description: 通过智连 CLI 检索和读取联系人、线索、机会(商
|
|
|
62
62
|
- `has_more:true` 表示还有下一页,按用户范围继续查询;当前页无匹配不能声称全库无结果。不要为了回答一个问题批量导出全部对象。
|
|
63
63
|
- 同名对象有多个时,展示候选名称和 ID 让用户确认,再读取;不自行选第一个。
|
|
64
64
|
- `read` 自动识别联系人、线索、商机、公司链接,以及当前站点配置的短链。跨环境链接要先确认目标站点并切换授权,不能把当前凭证发送给链接站点。
|
|
65
|
-
- 读取结果包含 `type/id/name/dataset/dataset_scope/fields/url/short_url/request_id
|
|
65
|
+
- 读取结果包含 `type/id/name/dataset/dataset_scope/fields/url/short_url/request_id`。公司目前仅返回基础信息。联系人详情的 `fields` 不包含手机号或地址。无联系人敏感信息权限时,联系人的数据集仅包含基础信息,姓名和邮箱按现有规则脱敏。不要将 `basic_info` 描述为完整上下文。
|
|
66
66
|
- 今日推进按服务器系统时区当天的可见推进动态发生时间判断;`progress_count` 是推进事件数量,不是成交数,也不保证每条都是积极进展。以返回的 `date/timezone` 为准,列表按商机去重。
|
|
67
67
|
|
|
68
68
|
## 返回给用户
|