@senguoyun/dsh-arkme 0.1.77 → 0.1.78

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/client.js CHANGED
@@ -560,7 +560,15 @@ window.__ModuleLoader__.load({
560
560
  captcha
561
561
  }, signal);
562
562
  }
563
- /** Verify a phone code and refresh the account auth/profile state. */
563
+ async checkPhoneUnbindEligibility(expectedUserId, signal) {
564
+ return await this.call("auth.phone.unbind.check", { expectedUserId }, signal);
565
+ }
566
+ async sendPhoneUnbindCode(captcha, signal) {
567
+ return await this.call("auth.phone.unbind.send", { captcha }, signal);
568
+ }
569
+ async unbindPhone(code, signal) {
570
+ return await this.call("auth.phone.unbind", { code: code.trim() }, signal);
571
+ }
564
572
  async verifyPhoneCode(phone, code, signal) {
565
573
  const normalized = phone.replace(/[\s-]/g, "");
566
574
  const normalizedCode = code.trim();
@@ -33917,6 +33925,12 @@ TA 公开分享的内容|Publicly shared content
33917
33925
  微信号|WeChat
33918
33926
  绑定|Connect
33919
33927
  换绑|Change
33928
+ 解/换绑|Disconnect / change
33929
+ 解绑手机号|Disconnect phone number
33930
+ 返回更换手机号|Back to changing phone number
33931
+ 确认解绑|Confirm disconnect
33932
+ 当前仅绑定了手机号,请先绑定其他登录方式|Link another sign-in method before unlinking your phone number.
33933
+ 账号状态未确认,请重新打开账号设置|Account status could not be confirmed. Reopen account settings.
33920
33934
  绑定中…|Connecting…
33921
33935
  通用|General
33922
33936
  隐私与权限|Privacy & permissions
@@ -202678,7 +202692,7 @@ registerProcessor('arkme-pcm-journal', ArkmePcmJournal);
202678
202692
  const c$3 = e$24;
202679
202693
  //#endregion
202680
202694
  //#region package.json
202681
- var version = "0.1.77";
202695
+ var version = "0.1.78";
202682
202696
  //#endregion
202683
202697
  //#region src/client/profile-change-store.ts
202684
202698
  let revision = 0;
@@ -227802,6 +227816,21 @@ button.arkme-account-info-row {
227802
227816
  cursor: default;
227803
227817
  }
227804
227818
 
227819
+ .arkme-account-dialog-actions button.arkme-phone-mode-action, body[data-ds-dark-theme] .arkme-account-dialog-actions button.arkme-phone-mode-action {
227820
+ min-width: 0;
227821
+ color: var(--dsw-alias-label-tertiary, #858992);
227822
+ background: none;
227823
+ border: 0;
227824
+ margin-right: auto;
227825
+ padding: 0;
227826
+ font-size: 12px;
227827
+ }
227828
+
227829
+ .arkme-account-dialog-actions button.arkme-phone-mode-action:hover:not(:disabled) {
227830
+ color: var(--dsw-alias-label-primary, #343944);
227831
+ text-decoration: underline;
227832
+ }
227833
+
227805
227834
  .arkme-account-dialog-status {
227806
227835
  color: #13a85b;
227807
227836
  margin: 0;
@@ -235197,15 +235226,24 @@ body[data-ds-dark-theme] .arkme-member-label[data-tier="2"] {
235197
235226
  });
235198
235227
  }
235199
235228
  function PhoneBindDialog({ config, profile, onClose, onUpdated }) {
235229
+ const [unbind, setUnbind] = (0, react$1.useState)(false);
235230
+ const busyRef = (0, react$1.useRef)(false);
235231
+ const mountedRef = (0, react$1.useRef)(true);
235232
+ (0, react$1.useEffect)(() => {
235233
+ mountedRef.current = true;
235234
+ return () => {
235235
+ mountedRef.current = false;
235236
+ };
235237
+ }, []);
235200
235238
  useArkmeLocale();
235201
235239
  const [phone, setPhone] = (0, react$1.useState)("");
235202
235240
  const [code, setCode] = (0, react$1.useState)("");
235203
235241
  const [phoneBusy, setPhoneBusy] = (0, react$1.useState)(false);
235204
235242
  const [status, setStatus] = (0, react$1.useState)("");
235205
235243
  const [countdown, setCountdown] = (0, react$1.useState)(0);
235206
- const phoneValid = /^1[3-9][0-9]{9}$/.test(phone.replace(/[\s-]/g, ""));
235244
+ const phoneValid = unbind || /^1[3-9][0-9]{9}$/.test(phone.replace(/[\s-]/g, ""));
235207
235245
  const codeValid = /^[0-9]{6}$/.test(code.trim());
235208
- const actionLabel = profile.contact.phoneMasked === void 0 ? "绑定手机号" : "更换手机号";
235246
+ const actionLabel = tr$1(unbind ? "解绑手机号" : profile.contact.phoneMasked === void 0 ? "绑定手机号" : "更换手机号");
235209
235247
  (0, react$1.useEffect)(() => {
235210
235248
  if (countdown <= 0) return;
235211
235249
  const timer = window.setTimeout(() => {
@@ -235215,52 +235253,99 @@ body[data-ds-dark-theme] .arkme-member-label[data-tier="2"] {
235215
235253
  window.clearTimeout(timer);
235216
235254
  };
235217
235255
  }, [countdown]);
235256
+ const changePhoneMode = async () => {
235257
+ if (busyRef.current) return;
235258
+ if (unbind) {
235259
+ setUnbind(false);
235260
+ setCode("");
235261
+ setStatus("");
235262
+ setCountdown(0);
235263
+ return;
235264
+ }
235265
+ busyRef.current = true;
235266
+ setPhoneBusy(true);
235267
+ setStatus("");
235268
+ try {
235269
+ const result = await callArkme("auth.phone.unbind.check", { expectedUserId: profile.userId });
235270
+ if (!mountedRef.current) return;
235271
+ if (result.allowed !== true) {
235272
+ setStatus(result.allowed === false ? tr$1("当前仅绑定了手机号,请先绑定其他登录方式") : tr$1("账号状态未确认,请重新打开账号设置"));
235273
+ return;
235274
+ }
235275
+ setUnbind(true);
235276
+ setCode("");
235277
+ setCountdown(0);
235278
+ } catch (caught) {
235279
+ if (mountedRef.current) setStatus(caught instanceof Error ? caught.message : String(caught));
235280
+ } finally {
235281
+ busyRef.current = false;
235282
+ if (mountedRef.current) setPhoneBusy(false);
235283
+ }
235284
+ };
235218
235285
  const sendCode = async () => {
235286
+ if (busyRef.current || countdown > 0) return;
235219
235287
  if (!phoneValid) {
235220
235288
  setStatus("请输入正确的手机号");
235221
235289
  return;
235222
235290
  }
235291
+ busyRef.current = true;
235223
235292
  setPhoneBusy(true);
235224
235293
  setStatus("");
235225
235294
  try {
235226
235295
  const captcha = await verifyPhoneCaptcha(config?.captchaId ?? "", phone);
235227
- await callArkme("auth.phone.send", {
235296
+ await callArkme(unbind ? "auth.phone.unbind.send" : "auth.phone.send", unbind ? { captcha } : {
235228
235297
  phone,
235229
235298
  captcha
235230
235299
  });
235300
+ if (!mountedRef.current) return;
235231
235301
  setCountdown(60);
235232
235302
  setStatus("已发送验证码");
235233
235303
  } catch (caught) {
235304
+ if (!mountedRef.current) return;
235234
235305
  setStatus(caught instanceof Error ? caught.message : String(caught));
235235
235306
  } finally {
235236
- setPhoneBusy(false);
235307
+ busyRef.current = false;
235308
+ if (mountedRef.current) setPhoneBusy(false);
235237
235309
  }
235238
235310
  };
235239
235311
  const verify = async (event) => {
235240
235312
  event.preventDefault();
235313
+ if (busyRef.current) return;
235241
235314
  if (!phoneValid || !codeValid) {
235242
235315
  setStatus("请输入正确的手机号和验证码");
235243
235316
  return;
235244
235317
  }
235318
+ busyRef.current = true;
235245
235319
  setPhoneBusy(true);
235246
235320
  setStatus("");
235247
235321
  try {
235248
- const auth = await callArkme("auth.phone.verify", {
235322
+ const auth = await callArkme(unbind ? "auth.phone.unbind" : "auth.phone.verify", unbind ? { code } : {
235249
235323
  phone,
235250
235324
  code
235251
235325
  });
235326
+ if (!mountedRef.current) return;
235252
235327
  arkmeAuthStore.setAuth(auth);
235253
- onUpdated(await callArkme("user.profile.refresh"), auth);
235328
+ if (unbind && auth.status === "binding-required") {
235329
+ onClose();
235330
+ return;
235331
+ }
235332
+ const snapshot = await callArkme("user.profile.refresh");
235333
+ if (!mountedRef.current) return;
235334
+ onUpdated(snapshot, auth);
235254
235335
  onClose();
235255
235336
  } catch (caught) {
235337
+ if (!mountedRef.current) return;
235256
235338
  setStatus(caught instanceof Error ? caught.message : String(caught));
235257
235339
  } finally {
235258
- setPhoneBusy(false);
235340
+ busyRef.current = false;
235341
+ if (mountedRef.current) setPhoneBusy(false);
235259
235342
  }
235260
235343
  };
235261
235344
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsDialog, {
235262
235345
  title: actionLabel,
235263
- onClose,
235346
+ onClose: () => {
235347
+ if (!busyRef.current) onClose();
235348
+ },
235264
235349
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
235265
235350
  className: "arkme-account-form",
235266
235351
  onSubmit: (event) => {
@@ -235275,7 +235360,7 @@ body[data-ds-dark-theme] .arkme-member-label[data-tier="2"] {
235275
235360
  profile.contact.phoneMasked
235276
235361
  ]
235277
235362
  }) : null,
235278
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr$1("手机号") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
235363
+ !unbind && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tr$1("手机号") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
235279
235364
  value: phone,
235280
235365
  autoFocus: true,
235281
235366
  inputMode: "tel",
@@ -235311,21 +235396,35 @@ body[data-ds-dark-theme] .arkme-member-label[data-tier="2"] {
235311
235396
  }) : null,
235312
235397
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
235313
235398
  className: "arkme-account-dialog-actions",
235314
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
235315
- "data-arkme-feedback": "neutral",
235316
- type: "button",
235317
- onClick: onClose,
235318
- children: tr$1("取消")
235319
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
235320
- "data-arkme-feedback": "primary",
235321
- type: "submit",
235322
- disabled: phoneBusy || !phoneValid || !codeValid,
235323
- children: [phoneBusy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(s$14, {
235324
- className: "arkme-icon-spin",
235325
- size: 16,
235326
- "aria-hidden": true
235327
- }) : null, profile.contact.phoneMasked === void 0 ? tr$1("绑 定") : tr$1("更 换")]
235328
- })]
235399
+ children: [
235400
+ profile.contact.phoneMasked !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
235401
+ "data-arkme-feedback": "neutral",
235402
+ className: "arkme-phone-mode-action",
235403
+ type: "button",
235404
+ disabled: phoneBusy,
235405
+ onClick: () => {
235406
+ changePhoneMode();
235407
+ },
235408
+ children: tr$1(unbind ? "返回更换手机号" : "解绑手机号")
235409
+ }),
235410
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
235411
+ "data-arkme-feedback": "neutral",
235412
+ type: "button",
235413
+ disabled: phoneBusy,
235414
+ onClick: onClose,
235415
+ children: tr$1("取消")
235416
+ }),
235417
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
235418
+ "data-arkme-feedback": "primary",
235419
+ type: "submit",
235420
+ disabled: phoneBusy || !phoneValid || !codeValid,
235421
+ children: [phoneBusy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(s$14, {
235422
+ className: "arkme-icon-spin",
235423
+ size: 16,
235424
+ "aria-hidden": true
235425
+ }) : null, tr$1(unbind ? "确认解绑" : profile.contact.phoneMasked === void 0 ? "绑 定" : "更 换")]
235426
+ })
235427
+ ]
235329
235428
  })
235330
235429
  ]
235331
235430
  })
@@ -235695,7 +235794,7 @@ body[data-ds-dark-theme] .arkme-member-label[data-tier="2"] {
235695
235794
  icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(s$8, { size: 18 }),
235696
235795
  title: tr$1("手机号"),
235697
235796
  value: phoneMasked ?? tr$1("未绑定"),
235698
- action: tr$1(phoneMasked === void 0 ? "绑定" : "换绑"),
235797
+ action: tr$1(phoneMasked === void 0 ? "绑定" : "解/换绑"),
235699
235798
  disabled: profile === void 0,
235700
235799
  onClick: profile !== void 0 ? () => {
235701
235800
  setActiveAccountDialog("phone");