@awiki/dsh-plugin 0.3.6 → 0.3.7-dsh-test.20260831.2

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.
Files changed (95) hide show
  1. package/README.md +58 -60
  2. package/README.zh.md +45 -51
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/cordis.patch.yml +7 -8
  5. package/lib/client.js +1389 -1152
  6. package/lib/client.js.map +1 -1
  7. package/lib/index.js +1084 -792
  8. package/lib/provider.js +70 -17
  9. package/lib/{sdk-adapter--trNlr-T.mjs → sdk-adapter-FGaOi8It.mjs} +168 -84
  10. package/lib/typert.host.js +406 -178
  11. package/lib/typert.remote-client.d.ts +19 -7
  12. package/lib/typert.remote-client.d.ts.map +1 -1
  13. package/lib/typert.remote-client.js +406 -178
  14. package/lib/types/client/AwikiDevices.d.ts +28 -0
  15. package/lib/types/client/AwikiDevices.d.ts.map +1 -0
  16. package/lib/types/client/AwikiDevices.js +85 -0
  17. package/lib/types/client/AwikiDevices.js.map +1 -0
  18. package/lib/types/client/AwikiIdentityAccess.d.ts +6 -5
  19. package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
  20. package/lib/types/client/AwikiIdentityAccess.js +88 -27
  21. package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
  22. package/lib/types/client/AwikiMail.d.ts +1 -1
  23. package/lib/types/client/AwikiMail.d.ts.map +1 -1
  24. package/lib/types/client/AwikiMail.js +6 -130
  25. package/lib/types/client/AwikiMail.js.map +1 -1
  26. package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
  27. package/lib/types/client/AwikiOverlay.js +5 -12
  28. package/lib/types/client/AwikiOverlay.js.map +1 -1
  29. package/lib/types/client/AwikiRecoveryForm.d.ts.map +1 -1
  30. package/lib/types/client/AwikiRecoveryForm.js +1 -1
  31. package/lib/types/client/AwikiRecoveryForm.js.map +1 -1
  32. package/lib/types/client/controller.d.ts +20 -34
  33. package/lib/types/client/controller.d.ts.map +1 -1
  34. package/lib/types/client/controller.js +56 -203
  35. package/lib/types/client/controller.js.map +1 -1
  36. package/lib/types/client/index.d.ts.map +1 -1
  37. package/lib/types/client/index.js +8 -4
  38. package/lib/types/client/index.js.map +1 -1
  39. package/lib/types/client/settings-locales.js +8 -8
  40. package/lib/types/client/settings-locales.js.map +1 -1
  41. package/lib/types/client/slots.d.ts +10 -10
  42. package/lib/types/client/slots.d.ts.map +1 -1
  43. package/lib/types/conversation-preferences.d.ts.map +1 -1
  44. package/lib/types/conversation-preferences.js +0 -17
  45. package/lib/types/conversation-preferences.js.map +1 -1
  46. package/lib/types/index.d.ts +59 -30
  47. package/lib/types/index.d.ts.map +1 -1
  48. package/lib/types/index.js +804 -462
  49. package/lib/types/index.js.map +1 -1
  50. package/lib/types/listener-state.d.ts +5 -3
  51. package/lib/types/listener-state.d.ts.map +1 -1
  52. package/lib/types/listener-state.js +28 -13
  53. package/lib/types/listener-state.js.map +1 -1
  54. package/lib/types/listener.d.ts +9 -32
  55. package/lib/types/listener.d.ts.map +1 -1
  56. package/lib/types/listener.js +11 -127
  57. package/lib/types/listener.js.map +1 -1
  58. package/lib/types/mail.d.ts +2 -28
  59. package/lib/types/mail.d.ts.map +1 -1
  60. package/lib/types/mail.js +2 -78
  61. package/lib/types/mail.js.map +1 -1
  62. package/lib/types/provider-api.d.ts +102 -38
  63. package/lib/types/provider-api.d.ts.map +1 -1
  64. package/lib/types/provider.d.ts +8 -2
  65. package/lib/types/provider.d.ts.map +1 -1
  66. package/lib/types/provider.js +73 -16
  67. package/lib/types/provider.js.map +1 -1
  68. package/lib/types/realtime-supervisor.d.ts +54 -0
  69. package/lib/types/realtime-supervisor.d.ts.map +1 -0
  70. package/lib/types/realtime-supervisor.js +242 -0
  71. package/lib/types/realtime-supervisor.js.map +1 -0
  72. package/lib/types/sdk-adapter.d.ts +32 -7
  73. package/lib/types/sdk-adapter.d.ts.map +1 -1
  74. package/lib/types/sdk-adapter.js +163 -104
  75. package/lib/types/sdk-adapter.js.map +1 -1
  76. package/lib/types/sent-mail-store.d.ts +2 -7
  77. package/lib/types/sent-mail-store.d.ts.map +1 -1
  78. package/lib/types/sent-mail-store.js +23 -125
  79. package/lib/types/sent-mail-store.js.map +1 -1
  80. package/lib/types/tools.d.ts +1 -1
  81. package/lib/types/tools.d.ts.map +1 -1
  82. package/lib/types/tools.js +4 -20
  83. package/lib/types/tools.js.map +1 -1
  84. package/lib/types/types.d.ts +77 -66
  85. package/lib/types/types.d.ts.map +1 -1
  86. package/lib/types/types.js.map +1 -1
  87. package/package.json +20 -15
  88. package/lib/types/client/mail-attachment.d.ts +0 -40
  89. package/lib/types/client/mail-attachment.d.ts.map +0 -1
  90. package/lib/types/client/mail-attachment.js +0 -186
  91. package/lib/types/client/mail-attachment.js.map +0 -1
  92. package/lib/types/profile-state.d.ts +0 -17
  93. package/lib/types/profile-state.d.ts.map +0 -1
  94. package/lib/types/profile-state.js +0 -58
  95. package/lib/types/profile-state.js.map +0 -1
package/lib/provider.js CHANGED
@@ -1,26 +1,79 @@
1
- import { t as RustSdkAdapter } from "./sdk-adapter--trNlr-T.mjs";
1
+ import { t as RustSdkAdapter } from "./sdk-adapter-FGaOi8It.mjs";
2
+ import { setTimeout } from "node:timers/promises";
2
3
  import { openImCoreNodeClient } from "@awiki/im-core-node";
3
4
  //#region lib/types/provider.js
4
5
  /** Production AWiki provider backed by the versioned Rust IM Core Node bridge. */
5
6
  /** Cordis plugin name used by Loader diagnostics. */
6
7
  const name = "awiki-rust-sdk-provider";
7
- /** The AWiki service must own its provider registry before this plugin loads. */
8
- const inject = ["awiki"];
8
+ /** AWiki orchestration and the independent identity service must load first. */
9
+ const inject = ["awiki", "anpIdentity"];
10
+ const IDENTITY_PROVIDER_CAPABILITIES = [
11
+ "IDENTITY_READ",
12
+ "IDENTITY_CREATE",
13
+ "IDENTITY_IMPORT",
14
+ "IDENTITY_SIGN",
15
+ "IDENTITY_ECDH_SEALED",
16
+ "IDENTITY_DOCUMENT_UPDATE",
17
+ "IDENTITY_KEY_LIFECYCLE",
18
+ "IDENTITY_DELETE",
19
+ "IDENTITY_HTTP_SIGNATURE",
20
+ "AWIKI_LEGACY_ROOT_TRANSFER_V1"
21
+ ];
22
+ const IDENTITY_PROVIDER_READY_TIMEOUT_MS = 1e4;
23
+ const IDENTITY_PROVIDER_READY_POLL_MS = 50;
9
24
  /** Register one SDK client whose disposal follows this provider's fiber. */
10
- function apply(ctx) {
11
- ctx.effect(() => ctx.awiki.registerClientFactory((options) => new RustSdkAdapter(openImCoreNodeClient({
12
- stateRoot: options.stateRoot,
13
- serviceBaseUrl: options.userServiceUrl,
14
- didDomain: options.userServiceDomain,
15
- userServiceEndpoint: options.userServiceUrl,
16
- messageServiceEndpoint: options.messageServiceUrl,
17
- mailServiceEndpoint: options.mailServiceUrl,
18
- anpServiceEndpoint: options.messageServiceUrl,
19
- anpServiceDid: options.messageServiceDid,
20
- multiDeviceHandleRecoveryEnabled: true,
21
- multiDeviceAudience: "awiki-user-service",
22
- externalHttpAllowInsecureLoopbackForTesting: options.allowInsecureLoopbackForTesting
23
- }))), "awiki Rust SDK client");
25
+ async function apply(ctx) {
26
+ await waitForIdentityProvider(ctx.anpIdentity);
27
+ ctx.effect(() => {
28
+ const lease = ctx.anpIdentity.acquireProvider({
29
+ consumer: "@awiki/dsh-plugin",
30
+ capabilities: [...IDENTITY_PROVIDER_CAPABILITIES],
31
+ ttlSeconds: 3600
32
+ });
33
+ try {
34
+ const unregister = ctx.awiki.registerClientFactory((options) => {
35
+ const openOptions = {
36
+ stateRoot: options.stateRoot,
37
+ serviceBaseUrl: options.userServiceUrl,
38
+ didDomain: options.userServiceDomain,
39
+ userServiceEndpoint: options.userServiceUrl,
40
+ messageServiceEndpoint: options.messageServiceUrl,
41
+ mailServiceEndpoint: options.mailServiceUrl,
42
+ anpServiceEndpoint: options.messageServiceUrl,
43
+ anpServiceDid: options.messageServiceDid,
44
+ clientVersionInfo: {
45
+ product: "awiki-daemon",
46
+ release: "0815",
47
+ version: "0.1.91"
48
+ },
49
+ multiDeviceHandleRecoveryEnabled: true,
50
+ multiDeviceDeviceRevokeEnabled: true,
51
+ multiDeviceAudience: "awiki-user-service",
52
+ externalHttpAllowInsecureLoopbackForTesting: options.allowInsecureLoopbackForTesting,
53
+ identityProvider: lease
54
+ };
55
+ return new RustSdkAdapter(openImCoreNodeClient(openOptions));
56
+ });
57
+ return async () => {
58
+ try {
59
+ await unregister();
60
+ } finally {
61
+ lease.dispose();
62
+ }
63
+ };
64
+ } catch (error) {
65
+ lease.dispose();
66
+ throw error;
67
+ }
68
+ }, "awiki Rust SDK client");
69
+ }
70
+ async function waitForIdentityProvider(identity) {
71
+ const deadline = Date.now() + IDENTITY_PROVIDER_READY_TIMEOUT_MS;
72
+ while ((await identity.health()).status === "unavailable") {
73
+ const remaining = deadline - Date.now();
74
+ if (remaining <= 0) throw new Error(`awiki: ANP Identity provider did not become ready within ${IDENTITY_PROVIDER_READY_TIMEOUT_MS}ms`);
75
+ await setTimeout(Math.min(IDENTITY_PROVIDER_READY_POLL_MS, remaining));
76
+ }
24
77
  }
25
78
  //#endregion
26
79
  export { apply, inject, name };
@@ -20,11 +20,12 @@ const RUST_FAILURE_CODES = {
20
20
  auth_revoked: "identity-recovery-required",
21
21
  conflict: "conflict",
22
22
  join_required: "handle-unavailable",
23
- state_in_use: "state-in-use",
23
+ state_in_use: "conflict",
24
24
  rate_limited: "rate-limited",
25
25
  timeout: "network",
26
26
  transport_unavailable: "network",
27
27
  sync_failed: "network",
28
+ sync_blocked: "conflict",
28
29
  session_expired: "network",
29
30
  attachment_transfer_network: "network",
30
31
  recovery_reconciliation_unavailable: "network",
@@ -33,15 +34,36 @@ const RUST_FAILURE_CODES = {
33
34
  /** Closed provider error consumed by the Host's fixed public failure mapping. */
34
35
  var AwikiSdkError = class extends Error {
35
36
  code;
37
+ realtimeFailureCode;
36
38
  name = "AwikiSdkError";
37
- constructor(code) {
39
+ constructor(code, realtimeFailureCode) {
38
40
  super(`AWiki SDK operation failed: ${code}`);
39
41
  this.code = code;
42
+ this.realtimeFailureCode = realtimeFailureCode;
40
43
  }
41
44
  };
42
45
  function fail(code = "remote") {
43
46
  throw new AwikiSdkError(code);
44
47
  }
48
+ const REALTIME_RETRY_WARNING_PRIORITY = [
49
+ "sync.retry.local_state.actor_closed",
50
+ "sync.retry.local_state.database_busy",
51
+ "sync.retry.local_state.constraint_failed",
52
+ "sync.retry.local_state.schema_unavailable",
53
+ "sync.retry.local_state.storage_unavailable",
54
+ "sync.retry.local_state.codec_unavailable",
55
+ "sync.retry.local_state.other",
56
+ "sync.retry.transport_unavailable",
57
+ "sync.retry.service_unavailable",
58
+ "sync.retry.local_state_unavailable"
59
+ ];
60
+ function realtimeSyncFailureCode(status, warnings) {
61
+ if (status === "retryable_failure") return REALTIME_RETRY_WARNING_PRIORITY.find((code) => warnings.includes(code)) ?? "sync.retryable_failure";
62
+ if (status === "recovery_required") return "sync.recovery_required";
63
+ if (status === "auth_revoked") return "sync.auth_revoked";
64
+ if (status === "blocked") return "sync.blocked";
65
+ return "sync.unexpected_status";
66
+ }
45
67
  function mapError(error, ambiguousSend = false) {
46
68
  if (error instanceof AwikiSdkError) throw error;
47
69
  let code = "remote";
@@ -89,14 +111,6 @@ function mailAddress(value) {
89
111
  if (length < 3 || length > 320 || !value.includes("@") || /[\s\u0000-\u001f\u007f-\u009f]/u.test(value)) fail();
90
112
  return value;
91
113
  }
92
- function mailFileName(value) {
93
- if (typeof value !== "string" || value.length === 0 || value.trim() !== value || value.replace(/[. ]+$/u, "") !== value || value === "." || value === ".." || Buffer.byteLength(value, "utf8") > 255 || /[\\/\p{C}]/u.test(value)) fail();
94
- return value;
95
- }
96
- function mailContentType(value) {
97
- if (typeof value !== "string" || !/^[A-Za-z0-9!#$&^_.+-]+\/[A-Za-z0-9!#$&^_.+-]+$/u.test(value)) fail();
98
- return value;
99
- }
100
114
  function mailAddresses(value) {
101
115
  if (!Array.isArray(value) || value.length > 100) fail();
102
116
  return value.map(mailAddress);
@@ -111,11 +125,6 @@ function uint32(value) {
111
125
  if (!Number.isSafeInteger(value) || value < 0 || value > 4294967295) fail();
112
126
  return value;
113
127
  }
114
- function recoveryE2eeGroupCount(impact) {
115
- if (typeof impact !== "object" || impact === null) fail();
116
- const value = impact;
117
- return uint32(value.unsupportedE2eeGroupCount !== void 0 ? value.unsupportedE2eeGroupCount : value.unsupportedE2EeGroupCount);
118
- }
119
128
  function boolean(value) {
120
129
  if (typeof value !== "boolean") fail();
121
130
  return value;
@@ -205,6 +214,26 @@ function identity(value) {
205
214
  registeredAt: safeInteger(value.registeredAtMs)
206
215
  };
207
216
  }
217
+ function joinProgress(value) {
218
+ return {
219
+ joinSessionId: required(value.joinSessionId),
220
+ localPhase: value.localPhase,
221
+ remoteState: value.remoteState,
222
+ expiresAt: required(value.expiresAt),
223
+ ...value.sas === void 0 ? {} : { sas: required(value.sas) },
224
+ completed: boolean(value.completed),
225
+ ...value.identity === void 0 ? {} : { identity: identity(value.identity) }
226
+ };
227
+ }
228
+ function adminJoinProgress(value) {
229
+ return {
230
+ joinSessionId: required(value.joinSessionId),
231
+ localPhase: value.localPhase,
232
+ remoteState: value.remoteState,
233
+ expiresAt: required(value.expiresAt),
234
+ ...value.sas === void 0 ? {} : { sas: required(value.sas) }
235
+ };
236
+ }
208
237
  function profile(value) {
209
238
  return {
210
239
  did: required(value.did),
@@ -315,17 +344,25 @@ var RustSdkAdapter = class {
315
344
  client;
316
345
  attachmentConversations = /* @__PURE__ */ new Map();
317
346
  disposal;
347
+ realtime;
348
+ agentInbox;
318
349
  listener;
319
350
  constructor(client) {
320
351
  this.client = Promise.resolve(client);
321
- this.listener = {
352
+ this.realtime = {
322
353
  syncNow: (reason) => this.listenerSyncNow(reason),
323
- startRealtime: () => this.listenerStartRealtime(),
354
+ startRealtime: () => this.listenerStartRealtime()
355
+ };
356
+ this.agentInbox = {
324
357
  listConversations: (request) => this.listenerConversations(request),
325
358
  getHistory: (request) => this.listenerHistory(request),
326
359
  markConversationRead: (conversationId) => this.markConversationRead(conversationId),
327
360
  sendText: (request) => this.sendText(request)
328
361
  };
362
+ this.listener = {
363
+ ...this.realtime,
364
+ ...this.agentInbox
365
+ };
329
366
  }
330
367
  async run(operation, ambiguousSend = false) {
331
368
  try {
@@ -528,8 +565,7 @@ var RustSdkAdapter = class {
528
565
  return this.run(async (client) => {
529
566
  const result = await client.syncNow({ reason });
530
567
  if (result.status === "idle" || result.status === "changed") return;
531
- if (result.status === "auth_revoked") fail("identity-recovery-required");
532
- fail("network");
568
+ throw new AwikiSdkError(result.status === "auth_revoked" ? "identity-recovery-required" : "network", realtimeSyncFailureCode(result.status, result.warnings));
533
569
  });
534
570
  }
535
571
  listenerStartRealtime() {
@@ -537,6 +573,9 @@ var RustSdkAdapter = class {
537
573
  const session = await client.startRealtime();
538
574
  return {
539
575
  nextEvent: () => this.run(() => session.nextEvent()),
576
+ getStatus: () => this.run(async () => {
577
+ return { connected: (await session.getStatus()).connected };
578
+ }),
540
579
  stop: () => this.run(() => session.stop())
541
580
  };
542
581
  });
@@ -599,7 +638,114 @@ var RustSdkAdapter = class {
599
638
  });
600
639
  }
601
640
  registerIdentity(request) {
602
- return this.run(async (client) => identity(await client.completeRegistration(request)));
641
+ return this.run(async (client) => {
642
+ const value = await client.completeRegistrationWithOutcome(request);
643
+ if (value.status === "registered") return {
644
+ status: "registered",
645
+ identity: identity(value.identity)
646
+ };
647
+ return {
648
+ status: "join-required",
649
+ continuationId: required(value.existingHandle.continuationId),
650
+ fullHandle: required(value.existingHandle.fullHandle),
651
+ mode: value.existingHandle.mode === "handle_recovery_rebind" ? "handle-recovery-rebind" : "ordinary",
652
+ requiresUserPresence: boolean(value.existingHandle.requiresUserPresence)
653
+ };
654
+ });
655
+ }
656
+ beginDeviceJoin(request) {
657
+ return this.run(async (client) => joinProgress(await client.beginPreparedRegistrationJoin(request)));
658
+ }
659
+ getDeviceJoinStatus(joinSessionId) {
660
+ return this.run(async (client) => joinProgress(await client.resumePreparedRegistrationJoin({ joinSessionId })));
661
+ }
662
+ listLocalDeviceJoinSessions() {
663
+ return this.run(async (client) => (await client.listLocalDeviceJoinSessions()).map((value) => ({
664
+ joinSessionId: required(value.joinSessionId),
665
+ side: value.side,
666
+ localPhase: value.localPhase,
667
+ expiresAt: required(value.expiresAt)
668
+ })));
669
+ }
670
+ cancelDeviceJoin(joinSessionId) {
671
+ return this.run(async (client) => {
672
+ const value = await client.cancelPreparedRegistrationJoin({ joinSessionId });
673
+ return {
674
+ joinSessionId: required(value.joinSessionId),
675
+ side: value.side,
676
+ localPhase: value.localPhase,
677
+ expiresAt: required(value.expiresAt)
678
+ };
679
+ });
680
+ }
681
+ getCurrentDeviceSummary() {
682
+ return this.run(async (client) => {
683
+ const value = await client.getCurrentDeviceSummary();
684
+ return {
685
+ ...value.role === void 0 ? {} : { role: value.role },
686
+ readiness: value.readiness,
687
+ canManage: boolean(value.canManage)
688
+ };
689
+ });
690
+ }
691
+ syncDeviceManagement() {
692
+ return this.run(async (client) => {
693
+ await client.syncNow({ reason: "foreground_reconcile" });
694
+ });
695
+ }
696
+ getDeviceRegistry() {
697
+ return this.run(async (client) => (await client.getDeviceRegistry()).devices.map((value) => ({
698
+ deviceId: required(value.protocolDeviceId),
699
+ status: value.status,
700
+ role: value.role,
701
+ managementReady: boolean(value.managementReady),
702
+ isCurrent: boolean(value.isCurrent)
703
+ })));
704
+ }
705
+ listLocalDeviceJoinRequests() {
706
+ return this.run(async (client) => (await client.listLocalDeviceJoinRequests()).map((value) => ({
707
+ joinSessionId: required(value.joinSessionId),
708
+ candidateKeyFingerprint: required(value.candidateKeyFingerprint),
709
+ issuedAt: required(value.issuedAt),
710
+ expiresAt: required(value.expiresAt),
711
+ state: value.state,
712
+ claimedByCurrentDevice: boolean(value.claimedByCurrentDevice),
713
+ canStartVerification: boolean(value.canStartVerification)
714
+ })));
715
+ }
716
+ startDeviceJoinVerification(request) {
717
+ return this.run(async (client) => adminJoinProgress(await client.startDeviceJoinVerification(request)));
718
+ }
719
+ getLocalDeviceJoinVerificationProgress(joinSessionId) {
720
+ return this.run(async (client) => adminJoinProgress(await client.getLocalDeviceJoinVerificationProgress({ joinSessionId })));
721
+ }
722
+ prepareDeviceJoinApproval(joinSessionId) {
723
+ return this.run(async (client) => {
724
+ return { approvalHandle: required((await client.prepareDeviceJoinApproval({
725
+ joinSessionId,
726
+ sasConfirmed: true
727
+ })).approvalHandle) };
728
+ });
729
+ }
730
+ confirmDeviceJoinApproval(approvalHandle) {
731
+ return this.run(async (client) => adminJoinProgress(await client.confirmDeviceJoinApproval({
732
+ approvalHandle,
733
+ userPresenceConfirmed: true
734
+ })));
735
+ }
736
+ rejectDeviceJoin(joinSessionId, reason) {
737
+ return this.run(async (client) => adminJoinProgress(await client.rejectDeviceJoin({
738
+ joinSessionId,
739
+ reason
740
+ })));
741
+ }
742
+ revokeDevice(deviceId) {
743
+ return this.run(async (client) => {
744
+ await client.revokeDevice({
745
+ targetDeviceId: deviceId,
746
+ userPresenceConfirmed: true
747
+ });
748
+ });
603
749
  }
604
750
  updateDisplayName(request) {
605
751
  return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
@@ -624,9 +770,7 @@ var RustSdkAdapter = class {
624
770
  ...value.failureCode === void 0 ? {} : { failureCode: value.failureCode },
625
771
  retryable: boolean(value.retryable),
626
772
  localOrdinaryDataWillMigrate: boolean(value.impact.localOrdinaryDataWillMigrate),
627
- otherDevicesMustRejoin: boolean(value.impact.otherDevicesMustRejoin),
628
- unsupportedE2eeGroupCount: recoveryE2eeGroupCount(value.impact),
629
- unsupportedDidOnlyGroupCount: uint32(value.impact.unsupportedDidOnlyGroupCount)
773
+ otherDevicesMustRejoin: boolean(value.impact.otherDevicesMustRejoin)
630
774
  };
631
775
  }
632
776
  sendRecoveryOtp(request) {
@@ -728,41 +872,6 @@ var RustSdkAdapter = class {
728
872
  member
729
873
  })));
730
874
  }
731
- resumeGroupRebindRecovery() {
732
- return this.run(async (client) => {
733
- const value = await client.resumeGroupRebindRecovery(100);
734
- const journal = value;
735
- const statuses = /* @__PURE__ */ new Map();
736
- for (const item of journal.items ?? []) {
737
- const { groupDid: rawGroupDid, layer: rawLayer, phase: rawPhase } = item;
738
- if (typeof rawGroupDid !== "string" || typeof rawLayer !== "string" || typeof rawPhase !== "string" || typeof item.blocked !== "boolean") throw new TypeError("invalid group recovery item");
739
- const groupDid = required(rawGroupDid);
740
- const layer = required(rawLayer);
741
- const phase = required(rawPhase);
742
- if (layer !== "p4" && layer !== "p6") throw new TypeError("invalid group recovery item");
743
- if (phase === "complete") continue;
744
- const status = item.blocked || phase === "blocked" ? "blocked" : "pending";
745
- if (statuses.get(groupDid) !== "blocked") statuses.set(groupDid, status);
746
- }
747
- for (const group of journal.sendPausedGroups ?? []) {
748
- if (typeof group !== "string") throw new TypeError("invalid paused recovery group");
749
- const groupDid = required(group);
750
- if (!statuses.has(groupDid)) statuses.set(groupDid, "pending");
751
- }
752
- const items = [...statuses].map(([groupDid, status]) => ({
753
- groupDid,
754
- status
755
- }));
756
- const hasJournal = journal.items !== void 0 || journal.sendPausedGroups !== void 0;
757
- return {
758
- processed: uint32(value.processed),
759
- completed: uint32(value.completed),
760
- pending: hasJournal ? items.filter((item) => item.status === "pending").length : uint32(value.pending),
761
- blocked: hasJournal ? items.filter((item) => item.status === "blocked").length : uint32(value.blocked),
762
- items
763
- };
764
- });
765
- }
766
875
  listConversations(request) {
767
876
  return this.run(async (client) => {
768
877
  const conversations = await client.listConversations(request);
@@ -884,21 +993,12 @@ var RustSdkAdapter = class {
884
993
  });
885
994
  }
886
995
  sendMail(request) {
887
- const attachments = request.attachments?.map((attachment) => ({
888
- fileName: attachment.fileName,
889
- contentType: attachment.contentType,
890
- bytes: Uint8Array.from(attachment.bytes)
891
- }));
892
996
  return this.run(async (client) => {
893
- const input = {
997
+ const value = await client.sendMail({
894
998
  to: [...request.to],
895
999
  ...request.cc === void 0 ? {} : { cc: [...request.cc] },
896
1000
  subject: request.subject,
897
1001
  bodyText: request.bodyText
898
- };
899
- const value = await client.sendMail({
900
- ...input,
901
- ...attachments === void 0 || attachments.length === 0 ? {} : { attachments }
902
1002
  });
903
1003
  if (!Array.isArray(value.warnings) || value.warnings.length > 100) fail();
904
1004
  const messageId = value.messageId === void 0 ? void 0 : mailToken(value.messageId, 2048);
@@ -909,22 +1009,6 @@ var RustSdkAdapter = class {
909
1009
  };
910
1010
  }, true);
911
1011
  }
912
- downloadMailAttachment(request) {
913
- return this.run(async (client) => {
914
- const value = await client.downloadMailAttachment({
915
- messageId: mailToken(request.messageId, 2048),
916
- attachmentIndex: uint32(request.attachmentIndex)
917
- });
918
- const sizeBytes = safeInteger(remoteString(value.sizeBytes, 20));
919
- if (!(value.bytes instanceof Uint8Array) || value.bytes.byteLength !== sizeBytes) fail();
920
- return {
921
- fileName: mailFileName(value.fileName),
922
- contentType: mailContentType(value.contentType),
923
- sizeBytes,
924
- bytes: Uint8Array.from(value.bytes)
925
- };
926
- });
927
- }
928
1012
  clearLocalData() {
929
1013
  return this.run((client) => client.clearLocalData());
930
1014
  }