@wanji_dsh/dsh-sales 0.11.9 → 0.11.10
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.zh.md +1 -1
- package/dist/client.js +32 -76
- package/dist/host.js +87 -64
- package/package.json +1 -1
- package/runtime/wechat-manifest.json +1 -1
package/README.zh.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
DeepSeek Harness 内的销售辅助工作台。插件在左侧菜单注册“销售助手”,主区域展示原生 React 页面。“用销售技能生成”调用当前Flash和WeKnora检索,但不发送微信、不操作付款、开通或上架。复制和编辑由销售掌握。
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
在销售助手页头选择「绑定钉钉」和「使用钉钉登录」,再到浏览器完成授权。登录状态暂时读不到时仍可发起登录,无需填写本人的花名或手机号。经万机企业通讯录验证的成员可使用公司 DeepSeek Flash,并在页头查看花名、岗位或解绑。
|
|
20
20
|
|
|
21
21
|
如需使用自有模型,在万机大脑的模型设置选择已授权的 DeepSeek V4.1 Flash。支持 DSH 内置账号的 `deepseek-account/deepseek-flash` 和已有的 `deepseek-v4.1-flash` 路由,调用时使用各自的原始模型 ID。管理员可在 Host 设置销售插件的 `modelProvider` 和 `model`。微信会话可先同步,未绑定 CRM 的会话也可起草。
|
|
22
22
|
|
package/dist/client.js
CHANGED
|
@@ -7505,88 +7505,66 @@ function CompanyIdentityPanel({ rpc, t, disabled }) {
|
|
|
7505
7505
|
const request = (0, import_react5.useRef)(void 0);
|
|
7506
7506
|
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
7507
7507
|
const [view, setView] = (0, import_react5.useState)();
|
|
7508
|
-
const [busy, setBusy] = (0, import_react5.useState)(
|
|
7509
|
-
const [failed, setFailed] = (0, import_react5.useState)(false);
|
|
7508
|
+
const [busy, setBusy] = (0, import_react5.useState)();
|
|
7510
7509
|
const [bindFailed, setBindFailed] = (0, import_react5.useState)(false);
|
|
7511
|
-
const
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7510
|
+
const perform = (0, import_react5.useCallback)(async (operation) => {
|
|
7511
|
+
if (request.current) {
|
|
7512
|
+
if (operation !== "bind" || request.current.operation !== "status") return;
|
|
7513
|
+
request.current.controller.abort();
|
|
7514
|
+
}
|
|
7515
7515
|
const controller = new AbortController();
|
|
7516
|
-
request.current = controller;
|
|
7517
|
-
setBusy(
|
|
7518
|
-
if (
|
|
7519
|
-
if (payload.operation === "bind") setBindFailed(false);
|
|
7516
|
+
request.current = { operation, controller };
|
|
7517
|
+
setBusy(operation);
|
|
7518
|
+
if (operation === "bind") setBindFailed(false);
|
|
7520
7519
|
try {
|
|
7521
|
-
const res = await rpc.call("/api", COMPANY_IDENTITY_ENDPOINT,
|
|
7520
|
+
const res = await rpc.call("/api", COMPANY_IDENTITY_ENDPOINT, { operation }, controller.signal);
|
|
7522
7521
|
if (controller.signal.aborted) return;
|
|
7523
7522
|
if (!res.ok || !res.value || typeof res.value !== "object" || !("status" in res.value)) throw Error("company identity unavailable");
|
|
7524
7523
|
const identity = res.value;
|
|
7525
7524
|
setView(identity);
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
window.open(identity.authorizeUrl, "_blank", "noopener,noreferrer");
|
|
7531
|
-
} catch {
|
|
7532
|
-
}
|
|
7525
|
+
if (operation === "bind" && identity.status === "awaiting" && !identity.verificationCode) {
|
|
7526
|
+
try {
|
|
7527
|
+
window.open(identity.authorizeUrl, "_blank", "noopener,noreferrer");
|
|
7528
|
+
} catch {
|
|
7533
7529
|
}
|
|
7534
|
-
setAlias("");
|
|
7535
|
-
setPhone("");
|
|
7536
7530
|
}
|
|
7537
7531
|
} catch {
|
|
7538
7532
|
if (!controller.signal.aborted) {
|
|
7539
|
-
if (
|
|
7540
|
-
else
|
|
7541
|
-
setView(void 0);
|
|
7542
|
-
setFailed(true);
|
|
7543
|
-
}
|
|
7533
|
+
if (operation === "bind") setBindFailed(true);
|
|
7534
|
+
else setView(void 0);
|
|
7544
7535
|
}
|
|
7545
7536
|
} finally {
|
|
7546
|
-
if (request.current === controller) {
|
|
7537
|
+
if (request.current?.controller === controller) {
|
|
7547
7538
|
request.current = void 0;
|
|
7548
|
-
setBusy(
|
|
7539
|
+
setBusy(void 0);
|
|
7549
7540
|
}
|
|
7550
7541
|
}
|
|
7551
7542
|
}, [rpc]);
|
|
7552
7543
|
(0, import_react5.useEffect)(() => {
|
|
7553
|
-
const refresh = () => void perform(
|
|
7544
|
+
const refresh = () => void perform("status");
|
|
7554
7545
|
refresh();
|
|
7555
7546
|
window.addEventListener("focus", refresh);
|
|
7556
7547
|
return () => {
|
|
7557
7548
|
window.removeEventListener("focus", refresh);
|
|
7558
|
-
request.current?.abort();
|
|
7549
|
+
request.current?.controller.abort();
|
|
7559
7550
|
request.current = void 0;
|
|
7560
7551
|
};
|
|
7561
7552
|
}, [perform]);
|
|
7562
7553
|
const awaiting = view?.status === "awaiting";
|
|
7563
7554
|
(0, import_react5.useEffect)(() => {
|
|
7564
7555
|
if (!open || !awaiting) return;
|
|
7565
|
-
const timer = window.setInterval(() => void perform(
|
|
7556
|
+
const timer = window.setInterval(() => void perform("status"), 3e3);
|
|
7566
7557
|
return () => window.clearInterval(timer);
|
|
7567
7558
|
}, [open, awaiting, perform]);
|
|
7568
7559
|
const close = () => {
|
|
7569
7560
|
setOpen(false);
|
|
7570
7561
|
setBindFailed(false);
|
|
7571
|
-
setAlias("");
|
|
7572
|
-
setPhone("");
|
|
7573
7562
|
trigger.current?.focus();
|
|
7574
7563
|
};
|
|
7575
7564
|
const bound = view?.status === "bound" ? view : void 0;
|
|
7576
7565
|
const label2 = bound ? [bound.alias, bound.position].filter(Boolean).join(" \xB7 ") : t("companyBind");
|
|
7577
7566
|
const unavailable = !view || view.status === "unavailable";
|
|
7578
|
-
const
|
|
7579
|
-
const connectDisabled = busy || disabled;
|
|
7580
|
-
(0, import_react5.useEffect)(() => {
|
|
7581
|
-
if (!open || !bindable) return;
|
|
7582
|
-
const controller = new AbortController();
|
|
7583
|
-
void rpc.call("/api", COMPANY_IDENTITY_ENDPOINT, { operation: "account-phone" }, controller.signal).then((result) => {
|
|
7584
|
-
if (controller.signal.aborted || !result.ok || !result.value || typeof result.value !== "object" || !("phone" in result.value)) return;
|
|
7585
|
-
const hint = result.value.phone;
|
|
7586
|
-
if (typeof hint === "string" && /^1\d{10}$/.test(hint)) setPhone((current) => current || hint);
|
|
7587
|
-
}).catch(() => void 0);
|
|
7588
|
-
return () => controller.abort();
|
|
7589
|
-
}, [rpc, open, bindable]);
|
|
7567
|
+
const connectDisabled = disabled || busy === "bind" || busy === "unbind";
|
|
7590
7568
|
return /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update ws-company-identity", onKeyDown: (event) => {
|
|
7591
7569
|
if (open && event.key === "Escape") close();
|
|
7592
7570
|
} }, /* @__PURE__ */ import_react5.default.createElement(
|
|
@@ -7602,33 +7580,17 @@ function CompanyIdentityPanel({ rpc, t, disabled }) {
|
|
|
7602
7580
|
if (open) close();
|
|
7603
7581
|
else {
|
|
7604
7582
|
setOpen(true);
|
|
7605
|
-
void perform(
|
|
7583
|
+
void perform("status");
|
|
7606
7584
|
}
|
|
7607
7585
|
}
|
|
7608
7586
|
},
|
|
7609
7587
|
label2
|
|
7610
|
-
), open && /* @__PURE__ */ import_react5.default.createElement("section", { id, className: "ws-update-card ws-company-identity-card", "aria-label": t("companyIdentity") }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-heading" }, /* @__PURE__ */ import_react5.default.createElement("strong", null, t("companyIdentity")), /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-icon-button", "aria-label": t("updateClose"), onClick: close }, "\xD7")), bound && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("dl", { className: "ws-company-identity-data" }, /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyAlias")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.alias)), bound.position && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyPosition")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.position)), bound.company && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyOrganization")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.company)), bound.department && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyDepartment")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.department))), /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t(bound.modelReady ? "companyModelReady" : "companyModelUnavailable")), /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-button", disabled:
|
|
7611
|
-
event.preventDefault();
|
|
7612
|
-
void perform({ operation: "bind", ...alias.trim() ? { alias: alias.trim() } : {}, ...phone.trim() ? { phone: phone.trim() } : {} });
|
|
7613
|
-
} }, /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t(view.status === "ineligible" ? "companyIneligible" : "companyHint")), bindFailed && /* @__PURE__ */ import_react5.default.createElement("p", { role: "alert" }, t("companyBindingFailed")), /* @__PURE__ */ import_react5.default.createElement("label", null, t("companyAliasOptional"), /* @__PURE__ */ import_react5.default.createElement("input", { value: alias, maxLength: 96, onChange: (event) => setAlias(event.target.value) })), /* @__PURE__ */ import_react5.default.createElement("label", null, t("companyPhoneOptional"), /* @__PURE__ */ import_react5.default.createElement(
|
|
7614
|
-
"input",
|
|
7615
|
-
{
|
|
7616
|
-
value: phone,
|
|
7617
|
-
type: "tel",
|
|
7618
|
-
inputMode: "tel",
|
|
7619
|
-
maxLength: 14,
|
|
7620
|
-
pattern: "(?:\\+86)?1[0-9]{10}",
|
|
7621
|
-
autoComplete: "off",
|
|
7622
|
-
onChange: (event) => setPhone(event.target.value)
|
|
7623
|
-
}
|
|
7624
|
-
)), /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, /* @__PURE__ */ import_react5.default.createElement("button", { type: "submit", className: "ws-button ws-primary", disabled: connectDisabled }, t("companyContinue")))), unavailable && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t(failed ? "companyRetryHint" : busy ? "companyChecking" : "companyUnavailable")), !busy && /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-button", onClick: () => void perform({ operation: "status" }) }, t("companyRetry"))))));
|
|
7588
|
+
), open && /* @__PURE__ */ import_react5.default.createElement("section", { id, className: "ws-update-card ws-company-identity-card", "aria-label": t("companyIdentity") }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-heading" }, /* @__PURE__ */ import_react5.default.createElement("strong", null, t("companyIdentity")), /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-icon-button", "aria-label": t("updateClose"), onClick: close }, "\xD7")), bound && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("dl", { className: "ws-company-identity-data" }, /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyAlias")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.alias)), bound.position && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyPosition")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.position)), bound.company && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyOrganization")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.company)), bound.department && /* @__PURE__ */ import_react5.default.createElement("div", null, /* @__PURE__ */ import_react5.default.createElement("dt", null, t("companyDepartment")), /* @__PURE__ */ import_react5.default.createElement("dd", null, bound.department))), /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t(bound.modelReady ? "companyModelReady" : "companyModelUnavailable")), /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-button", disabled: disabled || !!busy, onClick: () => void perform("unbind") }, t("companyUnbind")))), view?.status === "awaiting" && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t("companyAwaiting")), view.verificationCode && /* @__PURE__ */ import_react5.default.createElement("p", null, t("companyPairingCode"), " ", /* @__PURE__ */ import_react5.default.createElement("strong", null, view.verificationCode)), /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, /* @__PURE__ */ import_react5.default.createElement("button", { className: "ws-button", type: "button", disabled: disabled || !!busy, onClick: () => void perform("unbind") }, t("companyCancel")), /* @__PURE__ */ import_react5.default.createElement("a", { className: "ws-button ws-primary", href: view.authorizeUrl, target: "_blank", rel: "noopener noreferrer" }, t("companyVerify")))), !bound && !awaiting && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("p", { role: "status" }, t(view?.status === "ineligible" ? "companyIneligible" : unavailable ? busy === "status" ? "companyChecking" : "companyRetryHint" : "companyHint")), bindFailed && /* @__PURE__ */ import_react5.default.createElement("p", { role: "alert" }, t("companyBindingFailed")), /* @__PURE__ */ import_react5.default.createElement("div", { className: "ws-update-actions" }, unavailable && /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-button", disabled: !!busy, onClick: () => void perform("status") }, t("companyRetry")), /* @__PURE__ */ import_react5.default.createElement("button", { type: "button", className: "ws-button ws-primary", disabled: connectDisabled, onClick: () => void perform("bind") }, t("companyContinue"))))));
|
|
7625
7589
|
}
|
|
7626
7590
|
var companyIdentityStyles = `
|
|
7627
7591
|
.ws-company-identity-trigger{display:block;max-width:190px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
7628
|
-
.ws-company-identity-card p,.ws-company-identity-
|
|
7629
|
-
.ws-company-identity-
|
|
7630
|
-
.ws-company-identity-form label{display:grid;gap:4px;color:var(--ws-muted)}
|
|
7631
|
-
.ws-company-identity-form input{width:100%;min-width:0;padding:7px 9px;border:1px solid var(--ws-line);border-radius:6px;background:var(--ws-bg);color:inherit}
|
|
7592
|
+
.ws-company-identity-card p,.ws-company-identity-data{font-size:13px;line-height:1.6}
|
|
7593
|
+
.ws-company-identity-data{display:grid;gap:10px}
|
|
7632
7594
|
.ws-company-identity-card a{text-decoration:none}
|
|
7633
7595
|
.ws-company-identity-data>div{display:flex;justify-content:space-between;gap:12px}
|
|
7634
7596
|
.ws-company-identity-data dt{color:var(--ws-muted)}
|
|
@@ -10101,7 +10063,7 @@ var knowledgeEn = {
|
|
|
10101
10063
|
|
|
10102
10064
|
// src/locales.ts
|
|
10103
10065
|
var zh = {
|
|
10104
|
-
companyIdentity: "\
|
|
10066
|
+
companyIdentity: "\u9489\u9489\u767B\u5F55",
|
|
10105
10067
|
companyBind: "\u7ED1\u5B9A\u9489\u9489",
|
|
10106
10068
|
companyAlias: "\u82B1\u540D",
|
|
10107
10069
|
companyPosition: "\u5C97\u4F4D",
|
|
@@ -10116,13 +10078,10 @@ var zh = {
|
|
|
10116
10078
|
companyVerify: "\u6253\u5F00\u9489\u9489\u767B\u5F55",
|
|
10117
10079
|
companyHint: "\u4E07\u673A\u4F01\u4E1A\u6210\u5458\u7ED1\u5B9A\u672C\u4EBA\u7684\u9489\u9489\u8D26\u53F7\u540E\uFF0C\u5373\u53EF\u4F7F\u7528\u516C\u53F8\u6A21\u578B\u3002",
|
|
10118
10080
|
companyIneligible: "\u672A\u80FD\u9A8C\u8BC1\u5F53\u524D\u8D26\u53F7\u7684\u4E07\u673A\u4F01\u4E1A\u6210\u5458\u8EAB\u4EFD\u3002",
|
|
10119
|
-
companyAliasOptional: "\u82B1\u540D\uFF08\u9009\u586B\uFF09",
|
|
10120
|
-
companyPhoneOptional: "\u624B\u673A\u53F7\uFF08\u9009\u586B\uFF09",
|
|
10121
10081
|
companyContinue: "\u4F7F\u7528\u9489\u9489\u767B\u5F55",
|
|
10122
10082
|
companyBindingFailed: "\u672A\u80FD\u53D1\u8D77\u9489\u9489\u767B\u5F55\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
10123
|
-
companyRetryHint: "\u6682\u65F6\u65E0\u6CD5\
|
|
10124
|
-
companyChecking: "\u6B63\u5728\
|
|
10125
|
-
companyUnavailable: "\u516C\u53F8\u8EAB\u4EFD\u670D\u52A1\u5C1A\u672A\u63A5\u5165\u3002",
|
|
10083
|
+
companyRetryHint: "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u9489\u9489\u767B\u5F55\u72B6\u6001\uFF0C\u53EF\u4EE5\u76F4\u63A5\u767B\u5F55\u3002",
|
|
10084
|
+
companyChecking: "\u6B63\u5728\u8BFB\u53D6\u9489\u9489\u767B\u5F55\u72B6\u6001\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u767B\u5F55\u3002",
|
|
10126
10085
|
companyRetry: "\u91CD\u8BD5",
|
|
10127
10086
|
wxImageActualSize: "\u5B9E\u9645\u5927\u5C0F",
|
|
10128
10087
|
wxVideoMessage: "\u5FAE\u4FE1\u89C6\u9891",
|
|
@@ -10437,7 +10396,7 @@ var zh = {
|
|
|
10437
10396
|
contextHint: "\u57FA\u4E8E\u5F53\u524D\u793A\u4F8B\u804A\u5929\u6574\u7406"
|
|
10438
10397
|
};
|
|
10439
10398
|
var en = {
|
|
10440
|
-
companyIdentity: "
|
|
10399
|
+
companyIdentity: "DingTalk sign-in",
|
|
10441
10400
|
companyBind: "Link DingTalk",
|
|
10442
10401
|
companyAlias: "Display name",
|
|
10443
10402
|
companyPosition: "Job title",
|
|
@@ -10452,13 +10411,10 @@ var en = {
|
|
|
10452
10411
|
companyVerify: "Open DingTalk sign-in",
|
|
10453
10412
|
companyHint: "Wanji employees can link their own DingTalk account to use the company model.",
|
|
10454
10413
|
companyIneligible: "We could not verify this account\u2019s Wanji membership.",
|
|
10455
|
-
companyAliasOptional: "Display name (optional)",
|
|
10456
|
-
companyPhoneOptional: "Mobile number (optional)",
|
|
10457
10414
|
companyContinue: "Sign in with DingTalk",
|
|
10458
10415
|
companyBindingFailed: "DingTalk sign-in could not start. Try again.",
|
|
10459
|
-
companyRetryHint: "
|
|
10460
|
-
companyChecking: "Checking
|
|
10461
|
-
companyUnavailable: "The company identity service is not connected.",
|
|
10416
|
+
companyRetryHint: "DingTalk status is unavailable. You can sign in directly.",
|
|
10417
|
+
companyChecking: "Checking DingTalk status. You can sign in now.",
|
|
10462
10418
|
companyRetry: "Try again",
|
|
10463
10419
|
wxImageActualSize: "Actual size",
|
|
10464
10420
|
wxVideoMessage: "WeChat video",
|
package/dist/host.js
CHANGED
|
@@ -15839,7 +15839,7 @@ import { homedir, release } from "node:os";
|
|
|
15839
15839
|
import { isAbsolute, join } from "node:path";
|
|
15840
15840
|
|
|
15841
15841
|
// src/update/version.ts
|
|
15842
|
-
var RUNNING_VERSION = true ? "0.11.
|
|
15842
|
+
var RUNNING_VERSION = true ? "0.11.10" : "0.0.0-dev";
|
|
15843
15843
|
|
|
15844
15844
|
// src/diagnostics.ts
|
|
15845
15845
|
var MAX_FILE_BYTES = 512 * 1024;
|
|
@@ -45153,6 +45153,7 @@ function createCompanyConnection({ credentials, settings, fetch: request2 = fetc
|
|
|
45153
45153
|
}
|
|
45154
45154
|
let pending;
|
|
45155
45155
|
let verified = false;
|
|
45156
|
+
let statusRequests = new AbortController();
|
|
45156
45157
|
let queue = Promise.resolve();
|
|
45157
45158
|
function ordered(signal, apply4) {
|
|
45158
45159
|
const action = queue.then(() => {
|
|
@@ -45178,9 +45179,15 @@ function createCompanyConnection({ credentials, settings, fetch: request2 = fetc
|
|
|
45178
45179
|
...hint ? { body: JSON.stringify(hint) } : {}
|
|
45179
45180
|
}), signal);
|
|
45180
45181
|
}
|
|
45181
|
-
async function
|
|
45182
|
+
async function revokeOnServer(secret, signal) {
|
|
45182
45183
|
const response = await send("unbind", signal, secret);
|
|
45183
|
-
if (response.status !== 204)
|
|
45184
|
+
if (response.status !== 204) {
|
|
45185
|
+
await response.body?.cancel();
|
|
45186
|
+
throw Error("company unbind failed");
|
|
45187
|
+
}
|
|
45188
|
+
}
|
|
45189
|
+
async function revoke(secret, signal) {
|
|
45190
|
+
await revokeOnServer(secret, signal);
|
|
45184
45191
|
pending = void 0;
|
|
45185
45192
|
verified = false;
|
|
45186
45193
|
await credentials.unset(CREDENTIAL);
|
|
@@ -45188,44 +45195,10 @@ function createCompanyConnection({ credentials, settings, fetch: request2 = fetc
|
|
|
45188
45195
|
const identity = {
|
|
45189
45196
|
authorizeOrigin: COMPANY_ORIGIN,
|
|
45190
45197
|
canUseSharedModel: () => verified,
|
|
45191
|
-
refresh: (
|
|
45192
|
-
const
|
|
45193
|
-
|
|
45194
|
-
|
|
45195
|
-
verified = false;
|
|
45196
|
-
pending = void 0;
|
|
45197
|
-
return { status: "unbound" };
|
|
45198
|
-
}
|
|
45199
|
-
const response = await send("status", signal, secret);
|
|
45200
|
-
if (response.status === 401) {
|
|
45201
|
-
await credentials.unset(CREDENTIAL);
|
|
45202
|
-
verified = false;
|
|
45203
|
-
pending = void 0;
|
|
45204
|
-
return { status: "unbound" };
|
|
45205
|
-
}
|
|
45206
|
-
if (!response.ok) throw Error("company status unavailable");
|
|
45207
|
-
const value = object5(await response.json());
|
|
45208
|
-
if (value?.status === "awaiting") {
|
|
45209
|
-
verified = false;
|
|
45210
|
-
if (pending) return pending;
|
|
45211
|
-
await revoke(secret, signal);
|
|
45212
|
-
return { status: "unbound" };
|
|
45213
|
-
}
|
|
45214
|
-
pending = void 0;
|
|
45215
|
-
if (value?.status === "ineligible") {
|
|
45216
|
-
verified = false;
|
|
45217
|
-
return { status: "ineligible" };
|
|
45218
|
-
}
|
|
45219
|
-
if (value?.status !== "bound" || typeof value.alias !== "string") throw Error("invalid company profile");
|
|
45220
|
-
verified = true;
|
|
45221
|
-
if (!ready()) await ensureRoute().then(() => diagnostic("dingtalk.model-route", "ok"), (error) => diagnostic("dingtalk.model-route", "failed", {}, error));
|
|
45222
|
-
return {
|
|
45223
|
-
status: "bound",
|
|
45224
|
-
alias: value.alias,
|
|
45225
|
-
...typeof value.company === "string" ? { company: value.company } : {},
|
|
45226
|
-
...typeof value.position === "string" ? { position: value.position } : {}
|
|
45227
|
-
};
|
|
45228
|
-
}),
|
|
45198
|
+
refresh: (callerSignal) => {
|
|
45199
|
+
const signal = AbortSignal.any([callerSignal, statusRequests.signal]);
|
|
45200
|
+
return ordered(signal, () => refreshStatus(signal));
|
|
45201
|
+
},
|
|
45229
45202
|
async transcribeVoice(audio, signal) {
|
|
45230
45203
|
if (!verified && (await identity.refresh(signal)).status !== "bound") return;
|
|
45231
45204
|
const secret = await token();
|
|
@@ -45249,29 +45222,12 @@ function createCompanyConnection({ credentials, settings, fetch: request2 = fetc
|
|
|
45249
45222
|
}
|
|
45250
45223
|
return readWechatTranscript(response, signal);
|
|
45251
45224
|
},
|
|
45252
|
-
begin: (hint, signal) =>
|
|
45253
|
-
const previous = await token();
|
|
45254
|
-
if (previous) await revoke(previous, signal);
|
|
45255
|
-
const response = await send("start", signal, void 0, { ...hint, flow: "oauth" });
|
|
45256
|
-
if (!response.ok) throw Error("company binding unavailable");
|
|
45257
|
-
const value = object5(await response.json());
|
|
45258
|
-
if (value?.status !== "awaiting" || typeof value.token !== "string" || !tokenPattern.test(value.token) || typeof value.authorizeUrl !== "string") {
|
|
45259
|
-
throw Error("invalid company challenge");
|
|
45260
|
-
}
|
|
45261
|
-
const url = new URL(value.authorizeUrl);
|
|
45262
|
-
const code4 = value.verificationCode;
|
|
45263
|
-
const oneClick = isDingTalkLaunchUrl(url) && code4 === void 0;
|
|
45264
|
-
const legacy = !url.hash && url.pathname === ROOT + "/device/verify" && url.searchParams.size === 1 && tokenPattern.test(url.searchParams.get("device") ?? "") && typeof code4 === "string" && /^\d{8}$/u.test(code4);
|
|
45265
|
-
if (url.origin !== COMPANY_ORIGIN || url.username || url.password || !(oneClick || legacy)) {
|
|
45266
|
-
throw Error("invalid company verification URL");
|
|
45267
|
-
}
|
|
45225
|
+
begin: (hint, signal) => {
|
|
45268
45226
|
signal.throwIfAborted();
|
|
45269
|
-
|
|
45270
|
-
|
|
45271
|
-
|
|
45272
|
-
|
|
45273
|
-
return pending;
|
|
45274
|
-
}),
|
|
45227
|
+
statusRequests.abort();
|
|
45228
|
+
statusRequests = new AbortController();
|
|
45229
|
+
return ordered(signal, () => beginBinding(hint, signal));
|
|
45230
|
+
},
|
|
45275
45231
|
unbind: (signal) => ordered(signal, async () => {
|
|
45276
45232
|
const secret = await token();
|
|
45277
45233
|
if (secret) await revoke(secret, signal);
|
|
@@ -45279,6 +45235,73 @@ function createCompanyConnection({ credentials, settings, fetch: request2 = fetc
|
|
|
45279
45235
|
pending = void 0;
|
|
45280
45236
|
})
|
|
45281
45237
|
};
|
|
45238
|
+
async function refreshStatus(signal) {
|
|
45239
|
+
const secret = await token();
|
|
45240
|
+
signal.throwIfAborted();
|
|
45241
|
+
if (!secret) {
|
|
45242
|
+
diagnostic("dingtalk.device-credential", "unavailable");
|
|
45243
|
+
verified = false;
|
|
45244
|
+
pending = void 0;
|
|
45245
|
+
return { status: "unbound" };
|
|
45246
|
+
}
|
|
45247
|
+
const response = await send("status", signal, secret);
|
|
45248
|
+
signal.throwIfAborted();
|
|
45249
|
+
if (response.status === 401) {
|
|
45250
|
+
await credentials.unset(CREDENTIAL);
|
|
45251
|
+
verified = false;
|
|
45252
|
+
pending = void 0;
|
|
45253
|
+
return { status: "unbound" };
|
|
45254
|
+
}
|
|
45255
|
+
if (!response.ok) throw Error("company status unavailable");
|
|
45256
|
+
const value = object5(await response.json());
|
|
45257
|
+
signal.throwIfAborted();
|
|
45258
|
+
if (value?.status === "awaiting") {
|
|
45259
|
+
verified = false;
|
|
45260
|
+
if (pending) return pending;
|
|
45261
|
+
await revoke(secret, signal);
|
|
45262
|
+
return { status: "unbound" };
|
|
45263
|
+
}
|
|
45264
|
+
pending = void 0;
|
|
45265
|
+
if (value?.status === "ineligible") {
|
|
45266
|
+
verified = false;
|
|
45267
|
+
return { status: "ineligible" };
|
|
45268
|
+
}
|
|
45269
|
+
if (value?.status !== "bound" || typeof value.alias !== "string") throw Error("invalid company profile");
|
|
45270
|
+
verified = true;
|
|
45271
|
+
if (!ready()) await ensureRoute().then(() => diagnostic("dingtalk.model-route", "ok"), (error) => diagnostic("dingtalk.model-route", "failed", {}, error));
|
|
45272
|
+
return {
|
|
45273
|
+
status: "bound",
|
|
45274
|
+
alias: value.alias,
|
|
45275
|
+
...typeof value.company === "string" ? { company: value.company } : {},
|
|
45276
|
+
...typeof value.position === "string" ? { position: value.position } : {}
|
|
45277
|
+
};
|
|
45278
|
+
}
|
|
45279
|
+
async function beginBinding(hint, signal) {
|
|
45280
|
+
const previous = await token();
|
|
45281
|
+
signal.throwIfAborted();
|
|
45282
|
+
const response = await send("start", signal, void 0, { ...hint, flow: "oauth" });
|
|
45283
|
+
if (!response.ok) throw Error("company binding unavailable");
|
|
45284
|
+
const value = object5(await response.json());
|
|
45285
|
+
if (value?.status !== "awaiting" || typeof value.token !== "string" || !tokenPattern.test(value.token) || typeof value.authorizeUrl !== "string") {
|
|
45286
|
+
throw Error("invalid company challenge");
|
|
45287
|
+
}
|
|
45288
|
+
const url = new URL(value.authorizeUrl);
|
|
45289
|
+
const code4 = value.verificationCode;
|
|
45290
|
+
const oneClick = isDingTalkLaunchUrl(url) && code4 === void 0;
|
|
45291
|
+
const legacy = !url.hash && url.pathname === ROOT + "/device/verify" && url.searchParams.size === 1 && tokenPattern.test(url.searchParams.get("device") ?? "") && typeof code4 === "string" && /^\d{8}$/u.test(code4);
|
|
45292
|
+
if (url.origin !== COMPANY_ORIGIN || url.username || url.password || !(oneClick || legacy)) {
|
|
45293
|
+
throw Error("invalid company verification URL");
|
|
45294
|
+
}
|
|
45295
|
+
signal.throwIfAborted();
|
|
45296
|
+
await credentials.set(CREDENTIAL, value.token);
|
|
45297
|
+
verified = false;
|
|
45298
|
+
if (previous && previous !== value.token) {
|
|
45299
|
+
void revokeOnServer(previous, AbortSignal.timeout(3e3)).catch((error) => diagnostic("dingtalk.previous-grant-revoke", "failed", {}, error));
|
|
45300
|
+
}
|
|
45301
|
+
diagnostic(oneClick ? "dingtalk.oauth-challenge" : "dingtalk.legacy-challenge", "ok");
|
|
45302
|
+
pending = { status: "awaiting", authorizeUrl: url.href, ...legacy ? { verificationCode: code4 } : {} };
|
|
45303
|
+
return pending;
|
|
45304
|
+
}
|
|
45282
45305
|
return { identity, ready };
|
|
45283
45306
|
}
|
|
45284
45307
|
function companyConnectionFor(credentials, settings) {
|
|
@@ -45328,7 +45351,7 @@ function safeView(identity, service, ready) {
|
|
|
45328
45351
|
async function readAccountPhone(account) {
|
|
45329
45352
|
if (typeof account?.getProfile !== "function") return;
|
|
45330
45353
|
const result = await account.getProfile({
|
|
45331
|
-
version: true ? "0.11.
|
|
45354
|
+
version: true ? "0.11.10" : "0.0.0",
|
|
45332
45355
|
locale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
45333
45356
|
timezoneOffsetSeconds: -(/* @__PURE__ */ new Date()).getTimezoneOffset() * 60
|
|
45334
45357
|
});
|
package/package.json
CHANGED