@awiki/dsh-plugin 0.3.4 → 0.3.6
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/README.md +60 -51
- package/README.zh.md +51 -43
- package/cordis.patch.yml +7 -21
- package/lib/client.js +785 -1308
- package/lib/client.js.map +1 -1
- package/lib/index.js +715 -1017
- package/lib/provider.js +16 -52
- package/lib/{sdk-adapter-BeJakxLP.mjs → sdk-adapter--trNlr-T.mjs} +38 -143
- package/lib/typert.host.js +139 -414
- package/lib/typert.remote-client.d.ts +5 -19
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +139 -414
- package/lib/types/client/AwikiIdentityAccess.d.ts +5 -6
- package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
- package/lib/types/client/AwikiIdentityAccess.js +27 -88
- package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
- package/lib/types/client/AwikiMail.d.ts +1 -1
- package/lib/types/client/AwikiMail.d.ts.map +1 -1
- package/lib/types/client/AwikiMail.js +130 -6
- package/lib/types/client/AwikiMail.js.map +1 -1
- package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
- package/lib/types/client/AwikiOverlay.js +3 -4
- package/lib/types/client/AwikiOverlay.js.map +1 -1
- package/lib/types/client/controller.d.ts +11 -20
- package/lib/types/client/controller.d.ts.map +1 -1
- package/lib/types/client/controller.js +48 -53
- package/lib/types/client/controller.js.map +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +2 -8
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/mail-attachment.d.ts +40 -0
- package/lib/types/client/mail-attachment.d.ts.map +1 -0
- package/lib/types/client/mail-attachment.js +186 -0
- package/lib/types/client/mail-attachment.js.map +1 -0
- package/lib/types/client/settings-locales.js +8 -8
- package/lib/types/client/settings-locales.js.map +1 -1
- package/lib/types/client/slots.d.ts +6 -10
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/index.d.ts +28 -59
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +417 -800
- package/lib/types/index.js.map +1 -1
- package/lib/types/listener-state.d.ts +3 -5
- package/lib/types/listener-state.d.ts.map +1 -1
- package/lib/types/listener-state.js +13 -28
- package/lib/types/listener-state.js.map +1 -1
- package/lib/types/listener.d.ts +32 -9
- package/lib/types/listener.d.ts.map +1 -1
- package/lib/types/listener.js +127 -11
- package/lib/types/listener.js.map +1 -1
- package/lib/types/mail.d.ts +28 -2
- package/lib/types/mail.d.ts.map +1 -1
- package/lib/types/mail.js +78 -2
- package/lib/types/mail.js.map +1 -1
- package/lib/types/profile-state.d.ts +17 -0
- package/lib/types/profile-state.d.ts.map +1 -0
- package/lib/types/profile-state.js +58 -0
- package/lib/types/profile-state.js.map +1 -0
- package/lib/types/provider-api.d.ts +36 -100
- package/lib/types/provider-api.d.ts.map +1 -1
- package/lib/types/provider.d.ts +1 -7
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js +15 -53
- package/lib/types/provider.js.map +1 -1
- package/lib/types/sdk-adapter.d.ts +5 -30
- package/lib/types/sdk-adapter.d.ts.map +1 -1
- package/lib/types/sdk-adapter.js +48 -133
- package/lib/types/sdk-adapter.js.map +1 -1
- package/lib/types/sent-mail-store.d.ts +7 -2
- package/lib/types/sent-mail-store.d.ts.map +1 -1
- package/lib/types/sent-mail-store.js +125 -23
- package/lib/types/sent-mail-store.js.map +1 -1
- package/lib/types/tools.d.ts +1 -1
- package/lib/types/tools.d.ts.map +1 -1
- package/lib/types/tools.js +20 -4
- package/lib/types/tools.js.map +1 -1
- package/lib/types/types.d.ts +45 -77
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +4 -6
- package/lib/types/client/AwikiDevices.d.ts +0 -28
- package/lib/types/client/AwikiDevices.d.ts.map +0 -1
- package/lib/types/client/AwikiDevices.js +0 -85
- package/lib/types/client/AwikiDevices.js.map +0 -1
- package/lib/types/realtime-supervisor.d.ts +0 -43
- package/lib/types/realtime-supervisor.d.ts.map +0 -1
- package/lib/types/realtime-supervisor.js +0 -166
- package/lib/types/realtime-supervisor.js.map +0 -1
package/lib/provider.js
CHANGED
|
@@ -1,62 +1,26 @@
|
|
|
1
|
-
import { t as RustSdkAdapter } from "./sdk-adapter-
|
|
1
|
+
import { t as RustSdkAdapter } from "./sdk-adapter--trNlr-T.mjs";
|
|
2
2
|
import { openImCoreNodeClient } from "@awiki/im-core-node";
|
|
3
3
|
//#region lib/types/provider.js
|
|
4
4
|
/** Production AWiki provider backed by the versioned Rust IM Core Node bridge. */
|
|
5
5
|
/** Cordis plugin name used by Loader diagnostics. */
|
|
6
6
|
const name = "awiki-rust-sdk-provider";
|
|
7
|
-
/** AWiki
|
|
8
|
-
const inject = ["awiki"
|
|
9
|
-
const IDENTITY_PROVIDER_CAPABILITIES = [
|
|
10
|
-
"IDENTITY_READ",
|
|
11
|
-
"IDENTITY_CREATE",
|
|
12
|
-
"IDENTITY_IMPORT",
|
|
13
|
-
"IDENTITY_SIGN",
|
|
14
|
-
"IDENTITY_ECDH_SEALED",
|
|
15
|
-
"IDENTITY_DOCUMENT_UPDATE",
|
|
16
|
-
"IDENTITY_KEY_LIFECYCLE",
|
|
17
|
-
"IDENTITY_DELETE",
|
|
18
|
-
"IDENTITY_HTTP_SIGNATURE",
|
|
19
|
-
"AWIKI_LEGACY_ROOT_TRANSFER_V1"
|
|
20
|
-
];
|
|
7
|
+
/** The AWiki service must own its provider registry before this plugin loads. */
|
|
8
|
+
const inject = ["awiki"];
|
|
21
9
|
/** Register one SDK client whose disposal follows this provider's fiber. */
|
|
22
10
|
function apply(ctx) {
|
|
23
|
-
ctx.effect(() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
messageServiceEndpoint: options.messageServiceUrl,
|
|
37
|
-
mailServiceEndpoint: options.mailServiceUrl,
|
|
38
|
-
anpServiceEndpoint: options.messageServiceUrl,
|
|
39
|
-
anpServiceDid: options.messageServiceDid,
|
|
40
|
-
multiDeviceHandleRecoveryEnabled: true,
|
|
41
|
-
multiDeviceDeviceRevokeEnabled: true,
|
|
42
|
-
multiDeviceAudience: "awiki-user-service",
|
|
43
|
-
externalHttpAllowInsecureLoopbackForTesting: options.allowInsecureLoopbackForTesting,
|
|
44
|
-
identityProvider: lease
|
|
45
|
-
};
|
|
46
|
-
return new RustSdkAdapter(openImCoreNodeClient(openOptions));
|
|
47
|
-
});
|
|
48
|
-
return async () => {
|
|
49
|
-
try {
|
|
50
|
-
await unregister();
|
|
51
|
-
} finally {
|
|
52
|
-
lease.dispose();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
} catch (error) {
|
|
56
|
-
lease.dispose();
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
}, "awiki Rust SDK client");
|
|
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");
|
|
60
24
|
}
|
|
61
25
|
//#endregion
|
|
62
26
|
export { apply, inject, name };
|
|
@@ -20,7 +20,7 @@ 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: "
|
|
23
|
+
state_in_use: "state-in-use",
|
|
24
24
|
rate_limited: "rate-limited",
|
|
25
25
|
timeout: "network",
|
|
26
26
|
transport_unavailable: "network",
|
|
@@ -89,6 +89,14 @@ function mailAddress(value) {
|
|
|
89
89
|
if (length < 3 || length > 320 || !value.includes("@") || /[\s\u0000-\u001f\u007f-\u009f]/u.test(value)) fail();
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
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
|
+
}
|
|
92
100
|
function mailAddresses(value) {
|
|
93
101
|
if (!Array.isArray(value) || value.length > 100) fail();
|
|
94
102
|
return value.map(mailAddress);
|
|
@@ -197,26 +205,6 @@ function identity(value) {
|
|
|
197
205
|
registeredAt: safeInteger(value.registeredAtMs)
|
|
198
206
|
};
|
|
199
207
|
}
|
|
200
|
-
function joinProgress(value) {
|
|
201
|
-
return {
|
|
202
|
-
joinSessionId: required(value.joinSessionId),
|
|
203
|
-
localPhase: value.localPhase,
|
|
204
|
-
remoteState: value.remoteState,
|
|
205
|
-
expiresAt: required(value.expiresAt),
|
|
206
|
-
...value.sas === void 0 ? {} : { sas: required(value.sas) },
|
|
207
|
-
completed: boolean(value.completed),
|
|
208
|
-
...value.identity === void 0 ? {} : { identity: identity(value.identity) }
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function adminJoinProgress(value) {
|
|
212
|
-
return {
|
|
213
|
-
joinSessionId: required(value.joinSessionId),
|
|
214
|
-
localPhase: value.localPhase,
|
|
215
|
-
remoteState: value.remoteState,
|
|
216
|
-
expiresAt: required(value.expiresAt),
|
|
217
|
-
...value.sas === void 0 ? {} : { sas: required(value.sas) }
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
208
|
function profile(value) {
|
|
221
209
|
return {
|
|
222
210
|
did: required(value.did),
|
|
@@ -327,25 +315,17 @@ var RustSdkAdapter = class {
|
|
|
327
315
|
client;
|
|
328
316
|
attachmentConversations = /* @__PURE__ */ new Map();
|
|
329
317
|
disposal;
|
|
330
|
-
realtime;
|
|
331
|
-
agentInbox;
|
|
332
318
|
listener;
|
|
333
319
|
constructor(client) {
|
|
334
320
|
this.client = Promise.resolve(client);
|
|
335
|
-
this.
|
|
321
|
+
this.listener = {
|
|
336
322
|
syncNow: (reason) => this.listenerSyncNow(reason),
|
|
337
|
-
startRealtime: () => this.listenerStartRealtime()
|
|
338
|
-
};
|
|
339
|
-
this.agentInbox = {
|
|
323
|
+
startRealtime: () => this.listenerStartRealtime(),
|
|
340
324
|
listConversations: (request) => this.listenerConversations(request),
|
|
341
325
|
getHistory: (request) => this.listenerHistory(request),
|
|
342
326
|
markConversationRead: (conversationId) => this.markConversationRead(conversationId),
|
|
343
327
|
sendText: (request) => this.sendText(request)
|
|
344
328
|
};
|
|
345
|
-
this.listener = {
|
|
346
|
-
...this.realtime,
|
|
347
|
-
...this.agentInbox
|
|
348
|
-
};
|
|
349
329
|
}
|
|
350
330
|
async run(operation, ambiguousSend = false) {
|
|
351
331
|
try {
|
|
@@ -557,9 +537,6 @@ var RustSdkAdapter = class {
|
|
|
557
537
|
const session = await client.startRealtime();
|
|
558
538
|
return {
|
|
559
539
|
nextEvent: () => this.run(() => session.nextEvent()),
|
|
560
|
-
getStatus: () => this.run(async () => {
|
|
561
|
-
return { connected: (await session.getStatus()).connected };
|
|
562
|
-
}),
|
|
563
540
|
stop: () => this.run(() => session.stop())
|
|
564
541
|
};
|
|
565
542
|
});
|
|
@@ -622,114 +599,7 @@ var RustSdkAdapter = class {
|
|
|
622
599
|
});
|
|
623
600
|
}
|
|
624
601
|
registerIdentity(request) {
|
|
625
|
-
return this.run(async (client) =>
|
|
626
|
-
const value = await client.completeRegistrationWithOutcome(request);
|
|
627
|
-
if (value.status === "registered") return {
|
|
628
|
-
status: "registered",
|
|
629
|
-
identity: identity(value.identity)
|
|
630
|
-
};
|
|
631
|
-
return {
|
|
632
|
-
status: "join-required",
|
|
633
|
-
continuationId: required(value.existingHandle.continuationId),
|
|
634
|
-
fullHandle: required(value.existingHandle.fullHandle),
|
|
635
|
-
mode: value.existingHandle.mode === "handle_recovery_rebind" ? "handle-recovery-rebind" : "ordinary",
|
|
636
|
-
requiresUserPresence: boolean(value.existingHandle.requiresUserPresence)
|
|
637
|
-
};
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
beginDeviceJoin(request) {
|
|
641
|
-
return this.run(async (client) => joinProgress(await client.beginPreparedRegistrationJoin(request)));
|
|
642
|
-
}
|
|
643
|
-
getDeviceJoinStatus(joinSessionId) {
|
|
644
|
-
return this.run(async (client) => joinProgress(await client.resumePreparedRegistrationJoin({ joinSessionId })));
|
|
645
|
-
}
|
|
646
|
-
listLocalDeviceJoinSessions() {
|
|
647
|
-
return this.run(async (client) => (await client.listLocalDeviceJoinSessions()).map((value) => ({
|
|
648
|
-
joinSessionId: required(value.joinSessionId),
|
|
649
|
-
side: value.side,
|
|
650
|
-
localPhase: value.localPhase,
|
|
651
|
-
expiresAt: required(value.expiresAt)
|
|
652
|
-
})));
|
|
653
|
-
}
|
|
654
|
-
cancelDeviceJoin(joinSessionId) {
|
|
655
|
-
return this.run(async (client) => {
|
|
656
|
-
const value = await client.cancelPreparedRegistrationJoin({ joinSessionId });
|
|
657
|
-
return {
|
|
658
|
-
joinSessionId: required(value.joinSessionId),
|
|
659
|
-
side: value.side,
|
|
660
|
-
localPhase: value.localPhase,
|
|
661
|
-
expiresAt: required(value.expiresAt)
|
|
662
|
-
};
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
getCurrentDeviceSummary() {
|
|
666
|
-
return this.run(async (client) => {
|
|
667
|
-
const value = await client.getCurrentDeviceSummary();
|
|
668
|
-
return {
|
|
669
|
-
...value.role === void 0 ? {} : { role: value.role },
|
|
670
|
-
readiness: value.readiness,
|
|
671
|
-
canManage: boolean(value.canManage)
|
|
672
|
-
};
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
syncDeviceManagement() {
|
|
676
|
-
return this.run(async (client) => {
|
|
677
|
-
await client.syncNow({ reason: "foreground_reconcile" });
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
getDeviceRegistry() {
|
|
681
|
-
return this.run(async (client) => (await client.getDeviceRegistry()).devices.map((value) => ({
|
|
682
|
-
deviceId: required(value.protocolDeviceId),
|
|
683
|
-
status: value.status,
|
|
684
|
-
role: value.role,
|
|
685
|
-
managementReady: boolean(value.managementReady),
|
|
686
|
-
isCurrent: boolean(value.isCurrent)
|
|
687
|
-
})));
|
|
688
|
-
}
|
|
689
|
-
listLocalDeviceJoinRequests() {
|
|
690
|
-
return this.run(async (client) => (await client.listLocalDeviceJoinRequests()).map((value) => ({
|
|
691
|
-
joinSessionId: required(value.joinSessionId),
|
|
692
|
-
candidateKeyFingerprint: required(value.candidateKeyFingerprint),
|
|
693
|
-
issuedAt: required(value.issuedAt),
|
|
694
|
-
expiresAt: required(value.expiresAt),
|
|
695
|
-
state: value.state,
|
|
696
|
-
claimedByCurrentDevice: boolean(value.claimedByCurrentDevice),
|
|
697
|
-
canStartVerification: boolean(value.canStartVerification)
|
|
698
|
-
})));
|
|
699
|
-
}
|
|
700
|
-
startDeviceJoinVerification(request) {
|
|
701
|
-
return this.run(async (client) => adminJoinProgress(await client.startDeviceJoinVerification(request)));
|
|
702
|
-
}
|
|
703
|
-
getLocalDeviceJoinVerificationProgress(joinSessionId) {
|
|
704
|
-
return this.run(async (client) => adminJoinProgress(await client.getLocalDeviceJoinVerificationProgress({ joinSessionId })));
|
|
705
|
-
}
|
|
706
|
-
prepareDeviceJoinApproval(joinSessionId) {
|
|
707
|
-
return this.run(async (client) => {
|
|
708
|
-
return { approvalHandle: required((await client.prepareDeviceJoinApproval({
|
|
709
|
-
joinSessionId,
|
|
710
|
-
sasConfirmed: true
|
|
711
|
-
})).approvalHandle) };
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
confirmDeviceJoinApproval(approvalHandle) {
|
|
715
|
-
return this.run(async (client) => adminJoinProgress(await client.confirmDeviceJoinApproval({
|
|
716
|
-
approvalHandle,
|
|
717
|
-
userPresenceConfirmed: true
|
|
718
|
-
})));
|
|
719
|
-
}
|
|
720
|
-
rejectDeviceJoin(joinSessionId, reason) {
|
|
721
|
-
return this.run(async (client) => adminJoinProgress(await client.rejectDeviceJoin({
|
|
722
|
-
joinSessionId,
|
|
723
|
-
reason
|
|
724
|
-
})));
|
|
725
|
-
}
|
|
726
|
-
revokeDevice(deviceId) {
|
|
727
|
-
return this.run(async (client) => {
|
|
728
|
-
await client.revokeDevice({
|
|
729
|
-
targetDeviceId: deviceId,
|
|
730
|
-
userPresenceConfirmed: true
|
|
731
|
-
});
|
|
732
|
-
});
|
|
602
|
+
return this.run(async (client) => identity(await client.completeRegistration(request)));
|
|
733
603
|
}
|
|
734
604
|
updateDisplayName(request) {
|
|
735
605
|
return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
|
|
@@ -1014,12 +884,21 @@ var RustSdkAdapter = class {
|
|
|
1014
884
|
});
|
|
1015
885
|
}
|
|
1016
886
|
sendMail(request) {
|
|
887
|
+
const attachments = request.attachments?.map((attachment) => ({
|
|
888
|
+
fileName: attachment.fileName,
|
|
889
|
+
contentType: attachment.contentType,
|
|
890
|
+
bytes: Uint8Array.from(attachment.bytes)
|
|
891
|
+
}));
|
|
1017
892
|
return this.run(async (client) => {
|
|
1018
|
-
const
|
|
893
|
+
const input = {
|
|
1019
894
|
to: [...request.to],
|
|
1020
895
|
...request.cc === void 0 ? {} : { cc: [...request.cc] },
|
|
1021
896
|
subject: request.subject,
|
|
1022
897
|
bodyText: request.bodyText
|
|
898
|
+
};
|
|
899
|
+
const value = await client.sendMail({
|
|
900
|
+
...input,
|
|
901
|
+
...attachments === void 0 || attachments.length === 0 ? {} : { attachments }
|
|
1023
902
|
});
|
|
1024
903
|
if (!Array.isArray(value.warnings) || value.warnings.length > 100) fail();
|
|
1025
904
|
const messageId = value.messageId === void 0 ? void 0 : mailToken(value.messageId, 2048);
|
|
@@ -1030,6 +909,22 @@ var RustSdkAdapter = class {
|
|
|
1030
909
|
};
|
|
1031
910
|
}, true);
|
|
1032
911
|
}
|
|
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
|
+
}
|
|
1033
928
|
clearLocalData() {
|
|
1034
929
|
return this.run((client) => client.clearLocalData());
|
|
1035
930
|
}
|