@awiki/dsh-plugin 0.3.17 → 0.3.19

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 (107) hide show
  1. package/README.md +4 -0
  2. package/README.zh.md +11 -0
  3. package/THIRD_PARTY_NOTICES.md +6 -0
  4. package/lib/client.js +4012 -671
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +603 -61
  7. package/lib/{sdk-adapter-DGcTiEZz.mjs → package-version.generated-nZcAVnm8.mjs} +103 -10
  8. package/lib/provider.js +5 -3
  9. package/lib/typert.host.js +553 -133
  10. package/lib/typert.remote-client.d.ts +11 -3
  11. package/lib/typert.remote-client.d.ts.map +1 -1
  12. package/lib/typert.remote-client.js +553 -133
  13. package/lib/types/backend-capabilities.d.ts +12 -0
  14. package/lib/types/backend-capabilities.d.ts.map +1 -0
  15. package/lib/types/backend-capabilities.js +48 -0
  16. package/lib/types/backend-capabilities.js.map +1 -0
  17. package/lib/types/client/AwikiAvatar.d.ts +40 -0
  18. package/lib/types/client/AwikiAvatar.d.ts.map +1 -0
  19. package/lib/types/client/AwikiAvatar.js +201 -0
  20. package/lib/types/client/AwikiAvatar.js.map +1 -0
  21. package/lib/types/client/AwikiAvatarEditor.d.ts +11 -0
  22. package/lib/types/client/AwikiAvatarEditor.d.ts.map +1 -0
  23. package/lib/types/client/AwikiAvatarEditor.js +113 -0
  24. package/lib/types/client/AwikiAvatarEditor.js.map +1 -0
  25. package/lib/types/client/AwikiAvatarPreview.d.ts +8 -0
  26. package/lib/types/client/AwikiAvatarPreview.d.ts.map +1 -0
  27. package/lib/types/client/AwikiAvatarPreview.js +68 -0
  28. package/lib/types/client/AwikiAvatarPreview.js.map +1 -0
  29. package/lib/types/client/AwikiGroupDetails.js +2 -2
  30. package/lib/types/client/AwikiGroupDetails.js.map +1 -1
  31. package/lib/types/client/AwikiIdentityAccess.d.ts +1 -0
  32. package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
  33. package/lib/types/client/AwikiIdentityAccess.js +21 -4
  34. package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
  35. package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
  36. package/lib/types/client/AwikiOverlay.js +97 -29
  37. package/lib/types/client/AwikiOverlay.js.map +1 -1
  38. package/lib/types/client/AwikiProfileCard.d.ts +1 -1
  39. package/lib/types/client/AwikiProfileCard.d.ts.map +1 -1
  40. package/lib/types/client/AwikiProfileCard.js +6 -2
  41. package/lib/types/client/AwikiProfileCard.js.map +1 -1
  42. package/lib/types/client/AwikiSettingsSection.d.ts +1 -0
  43. package/lib/types/client/AwikiSettingsSection.d.ts.map +1 -1
  44. package/lib/types/client/AwikiSettingsSection.js +5 -4
  45. package/lib/types/client/AwikiSettingsSection.js.map +1 -1
  46. package/lib/types/client/avatar-cache.d.ts +24 -0
  47. package/lib/types/client/avatar-cache.d.ts.map +1 -0
  48. package/lib/types/client/avatar-cache.js +336 -0
  49. package/lib/types/client/avatar-cache.js.map +1 -0
  50. package/lib/types/client/avatar-dialog.d.ts +3 -0
  51. package/lib/types/client/avatar-dialog.d.ts.map +1 -0
  52. package/lib/types/client/avatar-dialog.js +18 -0
  53. package/lib/types/client/avatar-dialog.js.map +1 -0
  54. package/lib/types/client/avatar-image.d.ts +26 -0
  55. package/lib/types/client/avatar-image.d.ts.map +1 -0
  56. package/lib/types/client/avatar-image.js +193 -0
  57. package/lib/types/client/avatar-image.js.map +1 -0
  58. package/lib/types/client/controller.d.ts +37 -4
  59. package/lib/types/client/controller.d.ts.map +1 -1
  60. package/lib/types/client/controller.js +306 -59
  61. package/lib/types/client/controller.js.map +1 -1
  62. package/lib/types/client/index.d.ts.map +1 -1
  63. package/lib/types/client/index.js +11 -2
  64. package/lib/types/client/index.js.map +1 -1
  65. package/lib/types/client/settings-locales.d.ts +1 -1
  66. package/lib/types/client/settings-locales.d.ts.map +1 -1
  67. package/lib/types/client/settings-locales.js +26 -2
  68. package/lib/types/client/settings-locales.js.map +1 -1
  69. package/lib/types/client/slots.d.ts +12 -3
  70. package/lib/types/client/slots.d.ts.map +1 -1
  71. package/lib/types/conversation-preferences.d.ts.map +1 -1
  72. package/lib/types/conversation-preferences.js +27 -0
  73. package/lib/types/conversation-preferences.js.map +1 -1
  74. package/lib/types/index.d.ts +26 -3
  75. package/lib/types/index.d.ts.map +1 -1
  76. package/lib/types/index.js +321 -33
  77. package/lib/types/index.js.map +1 -1
  78. package/lib/types/listener.d.ts.map +1 -1
  79. package/lib/types/listener.js +9 -8
  80. package/lib/types/listener.js.map +1 -1
  81. package/lib/types/package-version.generated.d.ts +2 -2
  82. package/lib/types/package-version.generated.js +2 -2
  83. package/lib/types/provider-api.d.ts +28 -3
  84. package/lib/types/provider-api.d.ts.map +1 -1
  85. package/lib/types/provider.d.ts.map +1 -1
  86. package/lib/types/provider.js +5 -2
  87. package/lib/types/provider.js.map +1 -1
  88. package/lib/types/sdk-adapter.d.ts +10 -3
  89. package/lib/types/sdk-adapter.d.ts.map +1 -1
  90. package/lib/types/sdk-adapter.js +78 -7
  91. package/lib/types/sdk-adapter.js.map +1 -1
  92. package/lib/types/tenant-capability-cache.d.ts +15 -0
  93. package/lib/types/tenant-capability-cache.d.ts.map +1 -0
  94. package/lib/types/tenant-capability-cache.js +45 -0
  95. package/lib/types/tenant-capability-cache.js.map +1 -0
  96. package/lib/types/tenant-registry.d.ts +2 -0
  97. package/lib/types/tenant-registry.d.ts.map +1 -1
  98. package/lib/types/tenant-registry.js +83 -16
  99. package/lib/types/tenant-registry.js.map +1 -1
  100. package/lib/types/types.d.ts +70 -7
  101. package/lib/types/types.d.ts.map +1 -1
  102. package/lib/types/types.js.map +1 -1
  103. package/lib/types/update-policy.d.ts +2 -2
  104. package/lib/types/update-policy.d.ts.map +1 -1
  105. package/lib/types/update-policy.js +10 -1
  106. package/lib/types/update-policy.js.map +1 -1
  107. package/package.json +33 -34
@@ -156,6 +156,7 @@ const RUST_FAILURE_CODES = {
156
156
  not_found: "not-found",
157
157
  permission_denied: "forbidden",
158
158
  group_not_member: "group-membership-required",
159
+ group_member_encryption_not_ready: "group-member-encryption-not-ready",
159
160
  group_identity_stale: "group-identity-stale",
160
161
  auth_revoked: "device-rejoin-required",
161
162
  local_identity_recovery_required: "identity-recovery-required",
@@ -397,6 +398,10 @@ function profile(value) {
397
398
  return {
398
399
  did: required(value.did),
399
400
  ...value.handle === void 0 ? {} : { handle: value.handle },
401
+ avatarUri: value.avatarUri ?? null,
402
+ avatarThumbnailUri: value.avatarThumbnailUri ?? null,
403
+ ...value.profileVersion === void 0 ? {} : { profileVersion: value.profileVersion },
404
+ avatarUploadEnabled: value.avatarUploadEnabled === true,
400
405
  displayName: value.displayName?.trim() ?? "",
401
406
  bio: value.bio ?? "",
402
407
  tags: [...value.tags],
@@ -460,7 +465,7 @@ function preview(value) {
460
465
  }
461
466
  /** Provider-only protocol events are not part of the browser's text/attachment history contract. */
462
467
  function displayableMessage(value) {
463
- return value.content.kind === "text" || value.content.kind === "attachment" || mentionPayload(value) !== void 0;
468
+ return value.encrypted && value.content.kind === "unsupported" || value.content.kind === "text" || value.content.kind === "attachment" || mentionPayload(value) !== void 0;
464
469
  }
465
470
  /** Copy one native page and brand its opaque cursor for the Host API. */
466
471
  function page(value, copy) {
@@ -498,9 +503,29 @@ function externalHttpAttempt(value) {
498
503
  }
499
504
  };
500
505
  }
506
+ /** Older published SDKs cannot confirm backend capabilities. Never infer support. */
507
+ function backendDiscoveryClient(client, method) {
508
+ if (typeof Reflect.get(client, method) !== "function") throw new AwikiSdkError("backend-unconfirmed");
509
+ return client;
510
+ }
501
511
  /** Adapt the Rust Node bridge to the frozen Host provider interface. */
502
512
  var RustSdkAdapter = class {
503
513
  onIdentity;
514
+ backendCapabilitiesSnapshot(authenticated = false) {
515
+ return this.run((client) => backendDiscoveryClient(client, "backendCapabilitiesSnapshot").backendCapabilitiesSnapshot(authenticated));
516
+ }
517
+ subscribeBackendCapabilities(authenticated = false) {
518
+ return this.run((client) => backendDiscoveryClient(client, "subscribeBackendCapabilities").subscribeBackendCapabilities(authenticated));
519
+ }
520
+ setBackendDiscoveryActive(active) {
521
+ return this.run(async (client) => {
522
+ if (typeof Reflect.get(client, "setBackendDiscoveryActive") !== "function") return;
523
+ await backendDiscoveryClient(client, "setBackendDiscoveryActive").setBackendDiscoveryActive(active);
524
+ });
525
+ }
526
+ backendCapabilities(authenticated = false, force = false) {
527
+ return this.run((client) => backendDiscoveryClient(client, "backendCapabilities").backendCapabilities(authenticated, force));
528
+ }
504
529
  trustedUserPresenceSupported = process.platform === "darwin" && process.arch === "x64";
505
530
  client;
506
531
  approvalManagement = /* @__PURE__ */ new Map();
@@ -514,13 +539,16 @@ var RustSdkAdapter = class {
514
539
  for (const peer of pending) this.refreshingDisplayPeers.delete(peer);
515
540
  });
516
541
  }
517
- getDisplayProfiles(peers) {
542
+ getDisplayProfiles(peers, refresh = false) {
518
543
  return this.run(async (client) => {
519
- const profiles = await client.hydrateDisplayProfiles({ peers });
520
- this.scheduleDisplayRefresh(client, peers);
544
+ const profiles = refresh ? await client.refreshDisplayProfiles({ peers }, true) : await client.hydrateDisplayProfiles({ peers });
545
+ if (!refresh) this.scheduleDisplayRefresh(client, peers);
521
546
  return profiles.flatMap((profile) => profile.did === void 0 ? [] : [{
522
547
  did: profile.did,
523
548
  cacheHit: profile.cacheHit,
549
+ ...displaySubjectType(profile) === void 0 ? {} : { subjectType: displaySubjectType(profile) },
550
+ avatarUri: profile.avatarUri ?? null,
551
+ avatarThumbnailUri: profile.avatarThumbnailUri ?? null,
524
552
  ...profile.handle === void 0 ? {} : { handle: profile.handle },
525
553
  ...profile.displayName === void 0 ? {} : { displayName: profile.displayName }
526
554
  }]);
@@ -602,7 +630,18 @@ var RustSdkAdapter = class {
602
630
  ...value.senderHandle === void 0 ? {} : { senderHandle: value.senderHandle },
603
631
  ...value.senderDisplayName === void 0 ? {} : { senderDisplayName: value.senderDisplayName },
604
632
  sentAt,
605
- outgoing: value.outgoing
633
+ outgoing: value.outgoing,
634
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
635
+ ...value.encryptionRequired === void 0 ? {} : { encryptionRequired: value.encryptionRequired },
636
+ ...value.decryptionState === void 0 ? {} : { decryptionState: value.decryptionState },
637
+ ...value.sendState === void 0 ? {} : { sendState: value.sendState }
638
+ };
639
+ if (value.encrypted && (value.content.kind === "unsupported" || !value.outgoing && value.decryptionState !== "decrypted")) return {
640
+ ...common,
641
+ content: {
642
+ kind: "text",
643
+ text: "无法解密此消息:本设备缺少密钥,请完成设备准备或联系群主修复。"
644
+ }
606
645
  };
607
646
  switch (value.content.kind) {
608
647
  case "text": return {
@@ -659,6 +698,11 @@ var RustSdkAdapter = class {
659
698
  kind: "direct",
660
699
  ...common,
661
700
  peerDid: required(profile?.did ?? value.peerDid),
701
+ ...profile?.cacheHit !== true ? {} : {
702
+ avatarUri: profile.avatarUri ?? null,
703
+ avatarThumbnailUri: profile.avatarThumbnailUri ?? null,
704
+ ...displaySubjectType(profile) === void 0 ? {} : { subjectType: displaySubjectType(profile) }
705
+ },
662
706
  ...profileHandle === void 0 && value.peerHandle === void 0 ? {} : { peerHandle: required(profileHandle ?? value.peerHandle) },
663
707
  ...displayName === void 0 || displayName.length === 0 ? {} : { displayName }
664
708
  };
@@ -676,14 +720,33 @@ var RustSdkAdapter = class {
676
720
  id: required(value.conversationId),
677
721
  groupDid: required(value.did),
678
722
  title: required(value.title),
723
+ avatarUri: value.avatarUri ?? null,
724
+ ...value.avatarMembers === void 0 ? {} : { avatarMembers: value.avatarMembers.map((member) => ({
725
+ memberKey: member.memberKey,
726
+ memberDid: member.memberDid,
727
+ ...member.memberHandle === void 0 ? {} : { memberHandle: member.memberHandle }
728
+ })) },
729
+ ...value.groupStateVersion === void 0 ? {} : { groupStateVersion: value.groupStateVersion },
679
730
  unreadCount: 0
680
731
  };
681
732
  }
682
733
  groupSnapshot(value) {
683
734
  return {
735
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
736
+ ...value.secureState === void 0 ? {} : { secureState: value.secureState },
737
+ ...value.canSendSecure === void 0 ? {} : { canSendSecure: value.canSendSecure },
738
+ ...value.secureProblem === void 0 ? {} : { secureProblem: value.secureProblem },
739
+ ...value.secureRetryable === void 0 ? {} : { secureRetryable: value.secureRetryable },
684
740
  groupDid: required(value.did),
685
741
  conversationId: required(value.conversationId),
686
742
  title: required(value.title),
743
+ avatarUri: value.avatarUri ?? null,
744
+ ...value.avatarMembers === void 0 ? {} : { avatarMembers: value.avatarMembers.map((member) => ({
745
+ memberKey: member.memberKey,
746
+ memberDid: member.memberDid,
747
+ ...member.memberHandle === void 0 ? {} : { memberHandle: member.memberHandle }
748
+ })) },
749
+ ...value.groupStateVersion === void 0 ? {} : { groupStateVersion: value.groupStateVersion },
687
750
  ...value.description === void 0 ? {} : { description: value.description },
688
751
  ...value.myRole === void 0 ? {} : { myRole: value.myRole },
689
752
  ...value.membershipStatus === void 0 ? {} : { membershipStatus: value.membershipStatus },
@@ -692,6 +755,7 @@ var RustSdkAdapter = class {
692
755
  }
693
756
  groupMember(value) {
694
757
  return {
758
+ ...value.operation === void 0 ? {} : { operation: value.operation },
695
759
  did: required(value.did),
696
760
  ...value.handle === void 0 ? {} : { handle: value.handle }
697
761
  };
@@ -735,9 +799,13 @@ var RustSdkAdapter = class {
735
799
  conversationKind: value.conversationKind,
736
800
  senderDid: required(value.senderDid),
737
801
  sentAt,
738
- outgoing: value.outgoing
802
+ outgoing: value.outgoing,
803
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
804
+ ...value.encryptionRequired === void 0 ? {} : { encryptionRequired: value.encryptionRequired },
805
+ ...value.decryptionState === void 0 ? {} : { decryptionState: value.decryptionState },
806
+ ...value.sendState === void 0 ? {} : { sendState: value.sendState }
739
807
  };
740
- return value.content.kind === "text" && value.content.text !== void 0 ? {
808
+ return (!value.encrypted || value.decryptionState === "decrypted") && value.content.kind === "text" && value.content.text !== void 0 ? {
741
809
  ...common,
742
810
  content: {
743
811
  kind: "text",
@@ -1041,6 +1109,12 @@ var RustSdkAdapter = class {
1041
1109
  updateDisplayName(request) {
1042
1110
  return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
1043
1111
  }
1112
+ setAvatar(request) {
1113
+ return this.run(async (client) => profile(await client.setAvatar(request)));
1114
+ }
1115
+ clearAvatar(request) {
1116
+ return this.run(async (client) => profile(await client.clearAvatar(request)));
1117
+ }
1044
1118
  getProfile() {
1045
1119
  return this.run(async (client) => profile(await client.getProfile()));
1046
1120
  }
@@ -1110,8 +1184,12 @@ var RustSdkAdapter = class {
1110
1184
  };
1111
1185
  });
1112
1186
  }
1113
- createGroup(name) {
1114
- return this.run(async (client) => this.createdGroup(await client.createGroup({ name })));
1187
+ createGroup(name, encrypted = false, operationId) {
1188
+ return this.run(async (client) => this.createdGroup(await client.createGroup({
1189
+ name,
1190
+ encrypted,
1191
+ ...operationId === void 0 ? {} : { operationId }
1192
+ })));
1115
1193
  }
1116
1194
  addGroupMember(groupDid, member) {
1117
1195
  return this.run(async (client) => this.groupMember(await client.addGroupMember({
@@ -1119,6 +1197,9 @@ var RustSdkAdapter = class {
1119
1197
  member
1120
1198
  })));
1121
1199
  }
1200
+ repairGroupSecurity(groupDid) {
1201
+ return this.run(async (client) => this.groupSnapshot(await client.repairGroupSecurity({ groupDid: String(groupDid) })));
1202
+ }
1122
1203
  getGroup(groupDid) {
1123
1204
  return this.run(async (client) => this.groupSnapshot(await client.getGroup({ groupDid: String(groupDid) })));
1124
1205
  }
@@ -1205,6 +1286,7 @@ var RustSdkAdapter = class {
1205
1286
  const clientMessageId = browserMessageId(request.idempotencyKey);
1206
1287
  const conversationId = await this.conversationId(client, request.target);
1207
1288
  if (request.mentions !== void 0 && request.mentions.length > 0) return this.message(await client.sendPayload({
1289
+ ...request.security === void 0 ? {} : { security: request.security },
1208
1290
  conversationId,
1209
1291
  payloadJson: JSON.stringify({
1210
1292
  text: request.text,
@@ -1227,6 +1309,7 @@ var RustSdkAdapter = class {
1227
1309
  idempotencyKey: request.idempotencyKey
1228
1310
  }));
1229
1311
  return this.message(await client.sendText({
1312
+ ...request.security === void 0 ? {} : { security: request.security },
1230
1313
  conversationId,
1231
1314
  text: request.text,
1232
1315
  ...clientMessageId === void 0 ? {} : { clientMessageId },
@@ -1238,6 +1321,7 @@ var RustSdkAdapter = class {
1238
1321
  return this.run(async (client) => {
1239
1322
  const clientMessageId = browserMessageId(request.idempotencyKey);
1240
1323
  return this.message(await client.sendAttachment({
1324
+ ...request.security === void 0 ? {} : { security: request.security },
1241
1325
  conversationId: await this.conversationId(client, request.target),
1242
1326
  fileName: request.attachment.fileName,
1243
1327
  mimeType: request.attachment.mimeType,
@@ -1334,5 +1418,14 @@ function downloadedAttachment(value) {
1334
1418
  bytesBase64: Buffer.from(value.bytes).toString("base64")
1335
1419
  };
1336
1420
  }
1421
+ function displaySubjectType(profile) {
1422
+ const value = profile.subjectType;
1423
+ return typeof value === "string" ? value : void 0;
1424
+ }
1425
+ //#endregion
1426
+ //#region lib/types/package-version.generated.js
1427
+ /** Generated from package.json by scripts/sync-package-versions.mjs. */
1428
+ const DSH_AWIKI_PACKAGE_VERSION = "0.3.19";
1429
+ const DSH_AWIKI_MODEL_PROXY_PACKAGE_VERSION = "0.1.13";
1337
1430
  //#endregion
1338
- export { fencedMailRecoveryObservability as a, failedMailRecoveryObservability as i, RustSdkAdapter as n, successfulMailRecoveryObservability as o, downloadedAttachment as r, isMessageTarget as s, AwikiSdkError as t };
1431
+ export { downloadedAttachment as a, successfulMailRecoveryObservability as c, RustSdkAdapter as i, isMessageTarget as l, DSH_AWIKI_PACKAGE_VERSION as n, failedMailRecoveryObservability as o, AwikiSdkError as r, fencedMailRecoveryObservability as s, DSH_AWIKI_MODEL_PROXY_PACKAGE_VERSION as t };
package/lib/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as RustSdkAdapter } from "./sdk-adapter-DGcTiEZz.mjs";
1
+ import { i as RustSdkAdapter, n as DSH_AWIKI_PACKAGE_VERSION } from "./package-version.generated-nZcAVnm8.mjs";
2
2
  import { setTimeout } from "node:timers/promises";
3
3
  import { openImCoreNodeClient } from "@awiki/im-core-node";
4
4
  import { AnpIdentityPluginError } from "@agent-network-protocol/dsh-anp-identity";
@@ -66,10 +66,12 @@ async function apply(ctx) {
66
66
  anpServiceEndpoint: new URL("/anp-im/rpc", options.messageServicePublicUrl).href,
67
67
  anpServiceDid: options.messageServiceDid,
68
68
  clientVersionInfo: {
69
- product: "awiki-daemon",
69
+ product: "awiki-dsh",
70
70
  release: "0815",
71
- version: "0.1.93"
71
+ version: DSH_AWIKI_PACKAGE_VERSION
72
72
  },
73
+ multiDeviceDirectE2eeEnabled: true,
74
+ multiDeviceGroupE2eeEnabled: true,
73
75
  multiDeviceHandleRecoveryEnabled: true,
74
76
  multiDeviceDeviceRevokeEnabled: true,
75
77
  multiDeviceAudience: "awiki-user-service",