@awiki/dsh-plugin 0.3.11 → 0.3.16

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 (97) hide show
  1. package/README.md +24 -2
  2. package/README.zh.md +12 -2
  3. package/cordis.patch.yml +1 -0
  4. package/lib/client.js +1119 -176
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +362 -79
  7. package/lib/provider.js +3 -2
  8. package/lib/{sdk-adapter-DpqT2en9.mjs → sdk-adapter-DGcTiEZz.mjs} +110 -9
  9. package/lib/typert.host.js +359 -68
  10. package/lib/typert.remote-client.d.ts +9 -1
  11. package/lib/typert.remote-client.d.ts.map +1 -1
  12. package/lib/typert.remote-client.js +359 -68
  13. package/lib/types/client/AwikiDeviceJoinReminder.d.ts.map +1 -1
  14. package/lib/types/client/AwikiDeviceJoinReminder.js +1 -1
  15. package/lib/types/client/AwikiDeviceJoinReminder.js.map +1 -1
  16. package/lib/types/client/AwikiDevices.d.ts +5 -1
  17. package/lib/types/client/AwikiDevices.d.ts.map +1 -1
  18. package/lib/types/client/AwikiDevices.js +2 -1
  19. package/lib/types/client/AwikiDevices.js.map +1 -1
  20. package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
  21. package/lib/types/client/AwikiIdentityAccess.js +72 -24
  22. package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
  23. package/lib/types/client/AwikiIdentityServices.d.ts +9 -0
  24. package/lib/types/client/AwikiIdentityServices.d.ts.map +1 -0
  25. package/lib/types/client/AwikiIdentityServices.js +66 -0
  26. package/lib/types/client/AwikiIdentityServices.js.map +1 -0
  27. package/lib/types/client/AwikiOverlay.js +1 -1
  28. package/lib/types/client/AwikiOverlay.js.map +1 -1
  29. package/lib/types/client/AwikiSettingsSection.js +1 -1
  30. package/lib/types/client/AwikiSettingsSection.js.map +1 -1
  31. package/lib/types/client/AwikiUpdates.d.ts.map +1 -1
  32. package/lib/types/client/AwikiUpdates.js +21 -10
  33. package/lib/types/client/AwikiUpdates.js.map +1 -1
  34. package/lib/types/client/controller.d.ts +8 -0
  35. package/lib/types/client/controller.d.ts.map +1 -1
  36. package/lib/types/client/controller.js +21 -3
  37. package/lib/types/client/controller.js.map +1 -1
  38. package/lib/types/client/index.d.ts.map +1 -1
  39. package/lib/types/client/index.js +8 -0
  40. package/lib/types/client/index.js.map +1 -1
  41. package/lib/types/client/settings-controller.d.ts +1 -0
  42. package/lib/types/client/settings-controller.d.ts.map +1 -1
  43. package/lib/types/client/settings-controller.js +24 -10
  44. package/lib/types/client/settings-controller.js.map +1 -1
  45. package/lib/types/client/settings-locales.d.ts +1 -1
  46. package/lib/types/client/settings-locales.d.ts.map +1 -1
  47. package/lib/types/client/settings-locales.js +10 -4
  48. package/lib/types/client/settings-locales.js.map +1 -1
  49. package/lib/types/client/slots.d.ts +3 -1
  50. package/lib/types/client/slots.d.ts.map +1 -1
  51. package/lib/types/desktop-distribution.d.ts +7 -3
  52. package/lib/types/desktop-distribution.d.ts.map +1 -1
  53. package/lib/types/desktop-distribution.js +27 -8
  54. package/lib/types/desktop-distribution.js.map +1 -1
  55. package/lib/types/index.d.ts +8 -2
  56. package/lib/types/index.d.ts.map +1 -1
  57. package/lib/types/index.js +154 -47
  58. package/lib/types/index.js.map +1 -1
  59. package/lib/types/listener.js +1 -1
  60. package/lib/types/listener.js.map +1 -1
  61. package/lib/types/message-target.d.ts +4 -0
  62. package/lib/types/message-target.d.ts.map +1 -0
  63. package/lib/types/message-target.js +14 -0
  64. package/lib/types/message-target.js.map +1 -0
  65. package/lib/types/package-version.generated.d.ts +2 -2
  66. package/lib/types/package-version.generated.d.ts.map +1 -1
  67. package/lib/types/package-version.generated.js +2 -2
  68. package/lib/types/package-version.generated.js.map +1 -1
  69. package/lib/types/provider-api.d.ts +17 -1
  70. package/lib/types/provider-api.d.ts.map +1 -1
  71. package/lib/types/provider.d.ts.map +1 -1
  72. package/lib/types/provider.js +2 -1
  73. package/lib/types/provider.js.map +1 -1
  74. package/lib/types/registration-policy.d.ts +1 -1
  75. package/lib/types/registration-policy.d.ts.map +1 -1
  76. package/lib/types/registration-policy.js +1 -1
  77. package/lib/types/registration-policy.js.map +1 -1
  78. package/lib/types/sdk-adapter.d.ts +17 -1
  79. package/lib/types/sdk-adapter.d.ts.map +1 -1
  80. package/lib/types/sdk-adapter.js +90 -5
  81. package/lib/types/sdk-adapter.js.map +1 -1
  82. package/lib/types/settings-rpc-contract.d.ts +1 -0
  83. package/lib/types/settings-rpc-contract.d.ts.map +1 -1
  84. package/lib/types/settings-rpc-contract.js +2 -0
  85. package/lib/types/settings-rpc-contract.js.map +1 -1
  86. package/lib/types/types.d.ts +68 -2
  87. package/lib/types/types.d.ts.map +1 -1
  88. package/lib/types/types.js.map +1 -1
  89. package/lib/types/update-installation.d.ts +18 -0
  90. package/lib/types/update-installation.d.ts.map +1 -0
  91. package/lib/types/update-installation.js +101 -0
  92. package/lib/types/update-installation.js.map +1 -0
  93. package/lib/types/update-policy.d.ts +5 -2
  94. package/lib/types/update-policy.d.ts.map +1 -1
  95. package/lib/types/update-policy.js +14 -8
  96. package/lib/types/update-policy.js.map +1 -1
  97. package/package.json +7 -6
package/lib/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as RustSdkAdapter } from "./sdk-adapter-DpqT2en9.mjs";
1
+ import { n as RustSdkAdapter } from "./sdk-adapter-DGcTiEZz.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";
@@ -57,12 +57,13 @@ async function apply(ctx) {
57
57
  const unregister = ctx.awiki.registerClientFactory((options) => {
58
58
  const openOptions = {
59
59
  stateRoot: options.stateRoot,
60
+ ...options.caBundle === void 0 ? {} : { caBundle: options.caBundle },
60
61
  serviceBaseUrl: options.userServiceUrl,
61
62
  didDomain: options.userServiceDomain,
62
63
  userServiceEndpoint: options.userServiceUrl,
63
64
  messageServiceEndpoint: options.messageServiceUrl,
64
65
  mailServiceEndpoint: options.mailServiceUrl,
65
- anpServiceEndpoint: options.messageServiceUrl,
66
+ anpServiceEndpoint: new URL("/anp-im/rpc", options.messageServicePublicUrl).href,
66
67
  anpServiceDid: options.messageServiceDid,
67
68
  clientVersionInfo: {
68
69
  product: "awiki-daemon",
@@ -1,3 +1,16 @@
1
+ //#region lib/types/message-target.js
2
+ /** Validate the public target shape; Core alone validates conversation ownership and routing. */
3
+ function isMessageTarget(value) {
4
+ if (typeof value !== "object" || value === null) return false;
5
+ const target = value;
6
+ const nonempty = (field) => typeof field === "string" && field.trim() !== "";
7
+ if (target.kind === "direct") {
8
+ if ("conversationId" in target) return !("peer" in target) && nonempty(target.conversationId);
9
+ return nonempty(target.peer);
10
+ }
11
+ return target.kind === "group" && nonempty(target.group);
12
+ }
13
+ //#endregion
1
14
  //#region lib/types/mail-recovery-observability.js
2
15
  const MAIL_INGRESS_CLASSIFICATIONS = /* @__PURE__ */ new Set([
3
16
  "reached",
@@ -104,6 +117,30 @@ function fencedMailRecoveryObservability(currentPrincipalMatchesRecovery, reques
104
117
  /** Rust IM Core adapter that copies native values into Host-owned public DTOs. */
105
118
  const GROUP_LOOKUP_LIMIT = 100;
106
119
  const MAX_GROUP_LOOKUP_PAGES = 20;
120
+ function methodCapabilities(value) {
121
+ return {
122
+ method: value.method,
123
+ handleRecovery: boolean(value.handleRecovery),
124
+ rootImport: boolean(value.rootImport),
125
+ rootTransfer: boolean(value.rootTransfer),
126
+ servicesUpdate: boolean(value.servicesUpdate)
127
+ };
128
+ }
129
+ function publicDocumentService(raw) {
130
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) fail("invalid-request");
131
+ const value = raw;
132
+ if (typeof value.id !== "string" || typeof value.type !== "string" || typeof value.serviceEndpoint !== "string") fail("invalid-request");
133
+ if (value.serviceDid !== void 0 && typeof value.serviceDid !== "string") fail("invalid-request");
134
+ for (const field of ["profiles", "securityProfiles"]) if (value[field] !== void 0 && (!Array.isArray(value[field]) || !value[field].every((item) => typeof item === "string"))) fail("invalid-request");
135
+ return {
136
+ id: value.id,
137
+ type: value.type,
138
+ serviceEndpoint: value.serviceEndpoint,
139
+ ...value.serviceDid === void 0 ? {} : { serviceDid: value.serviceDid },
140
+ ...value.profiles === void 0 ? {} : { profiles: [...value.profiles] },
141
+ ...value.securityProfiles === void 0 ? {} : { securityProfiles: [...value.securityProfiles] }
142
+ };
143
+ }
107
144
  const RUST_FAILURE_CODES = {
108
145
  invalid_input: "invalid-request",
109
146
  invalid_state_root: "invalid-request",
@@ -466,6 +503,7 @@ var RustSdkAdapter = class {
466
503
  onIdentity;
467
504
  trustedUserPresenceSupported = process.platform === "darwin" && process.arch === "x64";
468
505
  client;
506
+ approvalManagement = /* @__PURE__ */ new Map();
469
507
  refreshingDisplayPeers = /* @__PURE__ */ new Set();
470
508
  scheduleDisplayRefresh(client, peers) {
471
509
  if (this.disposal !== void 0) return;
@@ -750,7 +788,11 @@ var RustSdkAdapter = class {
750
788
  });
751
789
  }
752
790
  async conversationId(client, target) {
753
- if (target.kind === "direct") return required((await client.resolvePeer(target.peer)).conversationId);
791
+ if (!isMessageTarget(target)) fail("invalid-request");
792
+ if (target.kind === "direct") {
793
+ if ("conversationId" in target) return target.conversationId;
794
+ return required((await client.resolvePeer(target.peer)).conversationId);
795
+ }
754
796
  let cursor;
755
797
  for (let index = 0; index < MAX_GROUP_LOOKUP_PAGES; index += 1) {
756
798
  const result = await client.listConversations({
@@ -784,6 +826,48 @@ var RustSdkAdapter = class {
784
826
  return result;
785
827
  });
786
828
  }
829
+ identityCreationMethods() {
830
+ return this.run(async (client) => [...await client.identityCreationMethods()]);
831
+ }
832
+ pendingIdentityRegistrations() {
833
+ return this.run(async (client) => (await client.pendingIdentityRegistrations()).map((value) => ({
834
+ did: value.did,
835
+ fullHandle: value.fullHandle,
836
+ method: value.method,
837
+ displayName: value.displayName,
838
+ verificationKind: value.verificationKind,
839
+ phase: value.phase
840
+ })));
841
+ }
842
+ identityMethodCapabilities(did) {
843
+ return this.run(async (client) => methodCapabilities(await client.identityMethodCapabilities(did)));
844
+ }
845
+ getIdentityServices() {
846
+ return this.run(async (client) => {
847
+ const currentIdentity = await client.getDefaultIdentity();
848
+ if (currentIdentity === null) fail("not-registered");
849
+ const capabilities = await client.identityMethodCapabilities(currentIdentity.did);
850
+ const current = await client.getCurrentDeviceSummary();
851
+ const document = await client.identityDocument();
852
+ if (document.id !== currentIdentity.did || !Array.isArray(document.service)) fail("remote");
853
+ return {
854
+ did: currentIdentity.did,
855
+ canManage: capabilities.servicesUpdate && current.canManage && current.role === "admin" && current.readiness === "admin_ready",
856
+ pending: await client.identityServicesUpdatePending(),
857
+ services: document.service.map(publicDocumentService)
858
+ };
859
+ });
860
+ }
861
+ updateIdentityServices(request) {
862
+ return this.run(async (client) => {
863
+ await client.updateIdentityServices(request.services.map(publicDocumentService));
864
+ });
865
+ }
866
+ resumeIdentityServicesUpdate() {
867
+ return this.run(async (client) => {
868
+ await client.resumeIdentityServicesUpdate();
869
+ });
870
+ }
787
871
  sendRegistrationOtp(request) {
788
872
  return this.run(async (client) => {
789
873
  const value = await client.requestRegistrationOtp(request);
@@ -809,7 +893,8 @@ var RustSdkAdapter = class {
809
893
  continuationId: required(value.existingHandle.continuationId),
810
894
  fullHandle: required(value.existingHandle.fullHandle),
811
895
  mode: value.existingHandle.mode === "handle_recovery_rebind" ? "handle-recovery-rebind" : "ordinary",
812
- requiresUserPresence: boolean(value.existingHandle.requiresUserPresence)
896
+ requiresUserPresence: boolean(value.existingHandle.requiresUserPresence),
897
+ methodCapabilities: methodCapabilities(await client.identityMethodCapabilities(value.existingHandle.expectedDid))
813
898
  };
814
899
  });
815
900
  }
@@ -882,17 +967,33 @@ var RustSdkAdapter = class {
882
967
  }
883
968
  prepareDeviceJoinApproval(joinSessionId) {
884
969
  return this.run(async (client) => {
885
- return { approvalHandle: required((await client.prepareDeviceJoinApproval({
970
+ const identity = await client.getDefaultIdentity();
971
+ if (identity === null) fail("not-registered");
972
+ const capabilities = await client.identityMethodCapabilities(identity.did);
973
+ const value = await client.prepareDeviceJoinApproval({
886
974
  joinSessionId,
887
975
  sasConfirmed: true
888
- })).approvalHandle) };
976
+ });
977
+ this.approvalManagement.set(value.approvalHandle, capabilities.rootTransfer);
978
+ return { approvalHandle: required(value.approvalHandle) };
889
979
  });
890
980
  }
981
+ deviceJoinManagementStatus() {
982
+ return this.run((client) => client.deviceJoinManagementStatus());
983
+ }
984
+ retryDeviceJoinManagement(joinSessionId) {
985
+ return this.run((client) => client.retryDeviceJoinManagement({ joinSessionId }));
986
+ }
891
987
  confirmDeviceJoinApproval(approvalHandle) {
892
- return this.run(async (client) => adminJoinProgress(await client.confirmDeviceJoinApproval({
893
- approvalHandle,
894
- userPresenceConfirmed: true
895
- })));
988
+ return this.run(async (client) => {
989
+ const request = {
990
+ approvalHandle,
991
+ userPresenceConfirmed: true
992
+ };
993
+ const result = this.approvalManagement.get(approvalHandle) === false ? await client.confirmDeviceJoinApproval(request) : await client.confirmDeviceJoinWithManagement(request);
994
+ this.approvalManagement.delete(approvalHandle);
995
+ return adminJoinProgress(result);
996
+ });
896
997
  }
897
998
  rejectDeviceJoin(joinSessionId, reason) {
898
999
  return this.run(async (client) => adminJoinProgress(await client.rejectDeviceJoin({
@@ -1234,4 +1335,4 @@ function downloadedAttachment(value) {
1234
1335
  };
1235
1336
  }
1236
1337
  //#endregion
1237
- export { fencedMailRecoveryObservability as a, failedMailRecoveryObservability as i, RustSdkAdapter as n, successfulMailRecoveryObservability as o, downloadedAttachment as r, AwikiSdkError as t };
1338
+ export { fencedMailRecoveryObservability as a, failedMailRecoveryObservability as i, RustSdkAdapter as n, successfulMailRecoveryObservability as o, downloadedAttachment as r, isMessageTarget as s, AwikiSdkError as t };