@awiki/dsh-plugin 0.3.17 → 0.3.18

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 (87) hide show
  1. package/README.md +4 -0
  2. package/THIRD_PARTY_NOTICES.md +6 -0
  3. package/lib/client.js +3543 -746
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +218 -41
  6. package/lib/{sdk-adapter-DGcTiEZz.mjs → package-version.generated-D0MSDRZn.mjs} +83 -10
  7. package/lib/provider.js +5 -3
  8. package/lib/typert.host.js +481 -127
  9. package/lib/typert.remote-client.d.ts +9 -3
  10. package/lib/typert.remote-client.d.ts.map +1 -1
  11. package/lib/typert.remote-client.js +481 -127
  12. package/lib/types/client/AwikiAvatar.d.ts +40 -0
  13. package/lib/types/client/AwikiAvatar.d.ts.map +1 -0
  14. package/lib/types/client/AwikiAvatar.js +201 -0
  15. package/lib/types/client/AwikiAvatar.js.map +1 -0
  16. package/lib/types/client/AwikiAvatarEditor.d.ts +11 -0
  17. package/lib/types/client/AwikiAvatarEditor.d.ts.map +1 -0
  18. package/lib/types/client/AwikiAvatarEditor.js +113 -0
  19. package/lib/types/client/AwikiAvatarEditor.js.map +1 -0
  20. package/lib/types/client/AwikiAvatarPreview.d.ts +8 -0
  21. package/lib/types/client/AwikiAvatarPreview.d.ts.map +1 -0
  22. package/lib/types/client/AwikiAvatarPreview.js +68 -0
  23. package/lib/types/client/AwikiAvatarPreview.js.map +1 -0
  24. package/lib/types/client/AwikiGroupDetails.js +2 -2
  25. package/lib/types/client/AwikiGroupDetails.js.map +1 -1
  26. package/lib/types/client/AwikiIdentityAccess.d.ts +1 -0
  27. package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
  28. package/lib/types/client/AwikiIdentityAccess.js +10 -2
  29. package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
  30. package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
  31. package/lib/types/client/AwikiOverlay.js +92 -27
  32. package/lib/types/client/AwikiOverlay.js.map +1 -1
  33. package/lib/types/client/AwikiProfileCard.d.ts +1 -1
  34. package/lib/types/client/AwikiProfileCard.d.ts.map +1 -1
  35. package/lib/types/client/AwikiProfileCard.js +6 -2
  36. package/lib/types/client/AwikiProfileCard.js.map +1 -1
  37. package/lib/types/client/avatar-cache.d.ts +24 -0
  38. package/lib/types/client/avatar-cache.d.ts.map +1 -0
  39. package/lib/types/client/avatar-cache.js +336 -0
  40. package/lib/types/client/avatar-cache.js.map +1 -0
  41. package/lib/types/client/avatar-dialog.d.ts +3 -0
  42. package/lib/types/client/avatar-dialog.d.ts.map +1 -0
  43. package/lib/types/client/avatar-dialog.js +18 -0
  44. package/lib/types/client/avatar-dialog.js.map +1 -0
  45. package/lib/types/client/avatar-image.d.ts +26 -0
  46. package/lib/types/client/avatar-image.d.ts.map +1 -0
  47. package/lib/types/client/avatar-image.js +193 -0
  48. package/lib/types/client/avatar-image.js.map +1 -0
  49. package/lib/types/client/controller.d.ts +30 -4
  50. package/lib/types/client/controller.d.ts.map +1 -1
  51. package/lib/types/client/controller.js +267 -56
  52. package/lib/types/client/controller.js.map +1 -1
  53. package/lib/types/client/index.d.ts.map +1 -1
  54. package/lib/types/client/index.js +10 -2
  55. package/lib/types/client/index.js.map +1 -1
  56. package/lib/types/client/slots.d.ts +12 -3
  57. package/lib/types/client/slots.d.ts.map +1 -1
  58. package/lib/types/conversation-preferences.d.ts.map +1 -1
  59. package/lib/types/conversation-preferences.js +27 -0
  60. package/lib/types/conversation-preferences.js.map +1 -1
  61. package/lib/types/index.d.ts +8 -2
  62. package/lib/types/index.d.ts.map +1 -1
  63. package/lib/types/index.js +76 -11
  64. package/lib/types/index.js.map +1 -1
  65. package/lib/types/listener.d.ts.map +1 -1
  66. package/lib/types/listener.js +9 -8
  67. package/lib/types/listener.js.map +1 -1
  68. package/lib/types/package-version.generated.d.ts +2 -2
  69. package/lib/types/package-version.generated.js +2 -2
  70. package/lib/types/provider-api.d.ts +9 -3
  71. package/lib/types/provider-api.d.ts.map +1 -1
  72. package/lib/types/provider.d.ts.map +1 -1
  73. package/lib/types/provider.js +5 -2
  74. package/lib/types/provider.js.map +1 -1
  75. package/lib/types/sdk-adapter.d.ts +6 -3
  76. package/lib/types/sdk-adapter.d.ts.map +1 -1
  77. package/lib/types/sdk-adapter.js +58 -7
  78. package/lib/types/sdk-adapter.js.map +1 -1
  79. package/lib/types/tenant-registry.d.ts +2 -0
  80. package/lib/types/tenant-registry.d.ts.map +1 -1
  81. package/lib/types/tenant-registry.js +83 -16
  82. package/lib/types/tenant-registry.js.map +1 -1
  83. package/lib/types/types.d.ts +63 -7
  84. package/lib/types/types.d.ts.map +1 -1
  85. package/lib/types/types.js.map +1 -1
  86. package/lib/types/update-policy.d.ts +2 -2
  87. 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) {
@@ -514,13 +519,16 @@ var RustSdkAdapter = class {
514
519
  for (const peer of pending) this.refreshingDisplayPeers.delete(peer);
515
520
  });
516
521
  }
517
- getDisplayProfiles(peers) {
522
+ getDisplayProfiles(peers, refresh = false) {
518
523
  return this.run(async (client) => {
519
- const profiles = await client.hydrateDisplayProfiles({ peers });
520
- this.scheduleDisplayRefresh(client, peers);
524
+ const profiles = refresh ? await client.refreshDisplayProfiles({ peers }, true) : await client.hydrateDisplayProfiles({ peers });
525
+ if (!refresh) this.scheduleDisplayRefresh(client, peers);
521
526
  return profiles.flatMap((profile) => profile.did === void 0 ? [] : [{
522
527
  did: profile.did,
523
528
  cacheHit: profile.cacheHit,
529
+ ...displaySubjectType(profile) === void 0 ? {} : { subjectType: displaySubjectType(profile) },
530
+ avatarUri: profile.avatarUri ?? null,
531
+ avatarThumbnailUri: profile.avatarThumbnailUri ?? null,
524
532
  ...profile.handle === void 0 ? {} : { handle: profile.handle },
525
533
  ...profile.displayName === void 0 ? {} : { displayName: profile.displayName }
526
534
  }]);
@@ -602,7 +610,18 @@ var RustSdkAdapter = class {
602
610
  ...value.senderHandle === void 0 ? {} : { senderHandle: value.senderHandle },
603
611
  ...value.senderDisplayName === void 0 ? {} : { senderDisplayName: value.senderDisplayName },
604
612
  sentAt,
605
- outgoing: value.outgoing
613
+ outgoing: value.outgoing,
614
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
615
+ ...value.encryptionRequired === void 0 ? {} : { encryptionRequired: value.encryptionRequired },
616
+ ...value.decryptionState === void 0 ? {} : { decryptionState: value.decryptionState },
617
+ ...value.sendState === void 0 ? {} : { sendState: value.sendState }
618
+ };
619
+ if (value.encrypted && (value.content.kind === "unsupported" || !value.outgoing && value.decryptionState !== "decrypted")) return {
620
+ ...common,
621
+ content: {
622
+ kind: "text",
623
+ text: "无法解密此消息:本设备缺少密钥,请完成设备准备或联系群主修复。"
624
+ }
606
625
  };
607
626
  switch (value.content.kind) {
608
627
  case "text": return {
@@ -659,6 +678,11 @@ var RustSdkAdapter = class {
659
678
  kind: "direct",
660
679
  ...common,
661
680
  peerDid: required(profile?.did ?? value.peerDid),
681
+ ...profile?.cacheHit !== true ? {} : {
682
+ avatarUri: profile.avatarUri ?? null,
683
+ avatarThumbnailUri: profile.avatarThumbnailUri ?? null,
684
+ ...displaySubjectType(profile) === void 0 ? {} : { subjectType: displaySubjectType(profile) }
685
+ },
662
686
  ...profileHandle === void 0 && value.peerHandle === void 0 ? {} : { peerHandle: required(profileHandle ?? value.peerHandle) },
663
687
  ...displayName === void 0 || displayName.length === 0 ? {} : { displayName }
664
688
  };
@@ -676,14 +700,33 @@ var RustSdkAdapter = class {
676
700
  id: required(value.conversationId),
677
701
  groupDid: required(value.did),
678
702
  title: required(value.title),
703
+ avatarUri: value.avatarUri ?? null,
704
+ ...value.avatarMembers === void 0 ? {} : { avatarMembers: value.avatarMembers.map((member) => ({
705
+ memberKey: member.memberKey,
706
+ memberDid: member.memberDid,
707
+ ...member.memberHandle === void 0 ? {} : { memberHandle: member.memberHandle }
708
+ })) },
709
+ ...value.groupStateVersion === void 0 ? {} : { groupStateVersion: value.groupStateVersion },
679
710
  unreadCount: 0
680
711
  };
681
712
  }
682
713
  groupSnapshot(value) {
683
714
  return {
715
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
716
+ ...value.secureState === void 0 ? {} : { secureState: value.secureState },
717
+ ...value.canSendSecure === void 0 ? {} : { canSendSecure: value.canSendSecure },
718
+ ...value.secureProblem === void 0 ? {} : { secureProblem: value.secureProblem },
719
+ ...value.secureRetryable === void 0 ? {} : { secureRetryable: value.secureRetryable },
684
720
  groupDid: required(value.did),
685
721
  conversationId: required(value.conversationId),
686
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 },
687
730
  ...value.description === void 0 ? {} : { description: value.description },
688
731
  ...value.myRole === void 0 ? {} : { myRole: value.myRole },
689
732
  ...value.membershipStatus === void 0 ? {} : { membershipStatus: value.membershipStatus },
@@ -692,6 +735,7 @@ var RustSdkAdapter = class {
692
735
  }
693
736
  groupMember(value) {
694
737
  return {
738
+ ...value.operation === void 0 ? {} : { operation: value.operation },
695
739
  did: required(value.did),
696
740
  ...value.handle === void 0 ? {} : { handle: value.handle }
697
741
  };
@@ -735,9 +779,13 @@ var RustSdkAdapter = class {
735
779
  conversationKind: value.conversationKind,
736
780
  senderDid: required(value.senderDid),
737
781
  sentAt,
738
- outgoing: value.outgoing
782
+ outgoing: value.outgoing,
783
+ ...value.encrypted === void 0 ? {} : { encrypted: value.encrypted },
784
+ ...value.encryptionRequired === void 0 ? {} : { encryptionRequired: value.encryptionRequired },
785
+ ...value.decryptionState === void 0 ? {} : { decryptionState: value.decryptionState },
786
+ ...value.sendState === void 0 ? {} : { sendState: value.sendState }
739
787
  };
740
- return value.content.kind === "text" && value.content.text !== void 0 ? {
788
+ return (!value.encrypted || value.decryptionState === "decrypted") && value.content.kind === "text" && value.content.text !== void 0 ? {
741
789
  ...common,
742
790
  content: {
743
791
  kind: "text",
@@ -1041,6 +1089,12 @@ var RustSdkAdapter = class {
1041
1089
  updateDisplayName(request) {
1042
1090
  return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
1043
1091
  }
1092
+ setAvatar(request) {
1093
+ return this.run(async (client) => profile(await client.setAvatar(request)));
1094
+ }
1095
+ clearAvatar(request) {
1096
+ return this.run(async (client) => profile(await client.clearAvatar(request)));
1097
+ }
1044
1098
  getProfile() {
1045
1099
  return this.run(async (client) => profile(await client.getProfile()));
1046
1100
  }
@@ -1110,8 +1164,12 @@ var RustSdkAdapter = class {
1110
1164
  };
1111
1165
  });
1112
1166
  }
1113
- createGroup(name) {
1114
- return this.run(async (client) => this.createdGroup(await client.createGroup({ name })));
1167
+ createGroup(name, encrypted = false, operationId) {
1168
+ return this.run(async (client) => this.createdGroup(await client.createGroup({
1169
+ name,
1170
+ encrypted,
1171
+ ...operationId === void 0 ? {} : { operationId }
1172
+ })));
1115
1173
  }
1116
1174
  addGroupMember(groupDid, member) {
1117
1175
  return this.run(async (client) => this.groupMember(await client.addGroupMember({
@@ -1119,6 +1177,9 @@ var RustSdkAdapter = class {
1119
1177
  member
1120
1178
  })));
1121
1179
  }
1180
+ repairGroupSecurity(groupDid) {
1181
+ return this.run(async (client) => this.groupSnapshot(await client.repairGroupSecurity({ groupDid: String(groupDid) })));
1182
+ }
1122
1183
  getGroup(groupDid) {
1123
1184
  return this.run(async (client) => this.groupSnapshot(await client.getGroup({ groupDid: String(groupDid) })));
1124
1185
  }
@@ -1205,6 +1266,7 @@ var RustSdkAdapter = class {
1205
1266
  const clientMessageId = browserMessageId(request.idempotencyKey);
1206
1267
  const conversationId = await this.conversationId(client, request.target);
1207
1268
  if (request.mentions !== void 0 && request.mentions.length > 0) return this.message(await client.sendPayload({
1269
+ ...request.security === void 0 ? {} : { security: request.security },
1208
1270
  conversationId,
1209
1271
  payloadJson: JSON.stringify({
1210
1272
  text: request.text,
@@ -1227,6 +1289,7 @@ var RustSdkAdapter = class {
1227
1289
  idempotencyKey: request.idempotencyKey
1228
1290
  }));
1229
1291
  return this.message(await client.sendText({
1292
+ ...request.security === void 0 ? {} : { security: request.security },
1230
1293
  conversationId,
1231
1294
  text: request.text,
1232
1295
  ...clientMessageId === void 0 ? {} : { clientMessageId },
@@ -1238,6 +1301,7 @@ var RustSdkAdapter = class {
1238
1301
  return this.run(async (client) => {
1239
1302
  const clientMessageId = browserMessageId(request.idempotencyKey);
1240
1303
  return this.message(await client.sendAttachment({
1304
+ ...request.security === void 0 ? {} : { security: request.security },
1241
1305
  conversationId: await this.conversationId(client, request.target),
1242
1306
  fileName: request.attachment.fileName,
1243
1307
  mimeType: request.attachment.mimeType,
@@ -1334,5 +1398,14 @@ function downloadedAttachment(value) {
1334
1398
  bytesBase64: Buffer.from(value.bytes).toString("base64")
1335
1399
  };
1336
1400
  }
1401
+ function displaySubjectType(profile) {
1402
+ const value = profile.subjectType;
1403
+ return typeof value === "string" ? value : void 0;
1404
+ }
1405
+ //#endregion
1406
+ //#region lib/types/package-version.generated.js
1407
+ /** Generated from package.json by scripts/sync-package-versions.mjs. */
1408
+ const DSH_AWIKI_PACKAGE_VERSION = "0.3.18";
1409
+ const DSH_AWIKI_MODEL_PROXY_PACKAGE_VERSION = "0.1.12";
1337
1410
  //#endregion
1338
- export { fencedMailRecoveryObservability as a, failedMailRecoveryObservability as i, RustSdkAdapter as n, successfulMailRecoveryObservability as o, downloadedAttachment as r, isMessageTarget as s, AwikiSdkError as t };
1411
+ 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-D0MSDRZn.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",