@awiki/dsh-plugin 0.3.3 → 0.3.4
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 +37 -31
- package/README.zh.md +30 -27
- package/cordis.patch.yml +17 -0
- package/lib/client.js +1269 -272
- package/lib/client.js.map +1 -1
- package/lib/index.js +874 -314
- package/lib/provider.js +52 -16
- package/lib/{sdk-adapter-CDLTgHJA.mjs → sdk-adapter-BeJakxLP.mjs} +142 -4
- package/lib/typert.host.js +419 -89
- package/lib/typert.remote-client.d.ts +19 -3
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +419 -89
- package/lib/types/client/AwikiDevices.d.ts +28 -0
- package/lib/types/client/AwikiDevices.d.ts.map +1 -0
- package/lib/types/client/AwikiDevices.js +85 -0
- package/lib/types/client/AwikiDevices.js.map +1 -0
- package/lib/types/client/AwikiIdentityAccess.d.ts +6 -5
- package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
- package/lib/types/client/AwikiIdentityAccess.js +88 -27
- package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
- package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
- package/lib/types/client/AwikiOverlay.js +4 -3
- package/lib/types/client/AwikiOverlay.js.map +1 -1
- package/lib/types/client/controller.d.ts +20 -5
- package/lib/types/client/controller.d.ts.map +1 -1
- package/lib/types/client/controller.js +38 -7
- 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 +8 -0
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/slots.d.ts +10 -2
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/index.d.ts +51 -10
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +675 -174
- package/lib/types/index.js.map +1 -1
- package/lib/types/listener-state.d.ts +5 -3
- package/lib/types/listener-state.d.ts.map +1 -1
- package/lib/types/listener-state.js +28 -13
- package/lib/types/listener-state.js.map +1 -1
- package/lib/types/listener.d.ts +9 -32
- package/lib/types/listener.d.ts.map +1 -1
- package/lib/types/listener.js +11 -127
- package/lib/types/listener.js.map +1 -1
- package/lib/types/provider-api.d.ts +96 -4
- package/lib/types/provider-api.d.ts.map +1 -1
- package/lib/types/provider.d.ts +7 -1
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js +53 -15
- package/lib/types/provider.js.map +1 -1
- package/lib/types/realtime-supervisor.d.ts +43 -0
- package/lib/types/realtime-supervisor.d.ts.map +1 -0
- package/lib/types/realtime-supervisor.js +166 -0
- package/lib/types/realtime-supervisor.js.map +1 -0
- package/lib/types/sdk-adapter.d.ts +28 -2
- package/lib/types/sdk-adapter.d.ts.map +1 -1
- package/lib/types/sdk-adapter.js +132 -3
- package/lib/types/sdk-adapter.js.map +1 -1
- package/lib/types/types.d.ts +76 -6
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +18 -18
- package/lib/types/profile-state.d.ts +0 -11
- package/lib/types/profile-state.d.ts.map +0 -1
- package/lib/types/profile-state.js +0 -48
- package/lib/types/profile-state.js.map +0 -1
package/lib/provider.js
CHANGED
|
@@ -1,26 +1,62 @@
|
|
|
1
|
-
import { t as RustSdkAdapter } from "./sdk-adapter-
|
|
1
|
+
import { t as RustSdkAdapter } from "./sdk-adapter-BeJakxLP.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
|
-
/**
|
|
8
|
-
const inject = ["awiki"];
|
|
7
|
+
/** AWiki orchestration and the independent identity service must load first. */
|
|
8
|
+
const inject = ["awiki", "anpIdentity"];
|
|
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
|
+
];
|
|
9
21
|
/** Register one SDK client whose disposal follows this provider's fiber. */
|
|
10
22
|
function apply(ctx) {
|
|
11
|
-
ctx.effect(() =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
ctx.effect(() => {
|
|
24
|
+
const lease = ctx.anpIdentity.acquireProvider({
|
|
25
|
+
consumer: "@awiki/dsh-plugin",
|
|
26
|
+
capabilities: [...IDENTITY_PROVIDER_CAPABILITIES],
|
|
27
|
+
ttlSeconds: 3600
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
const unregister = ctx.awiki.registerClientFactory((options) => {
|
|
31
|
+
const openOptions = {
|
|
32
|
+
stateRoot: options.stateRoot,
|
|
33
|
+
serviceBaseUrl: options.userServiceUrl,
|
|
34
|
+
didDomain: options.userServiceDomain,
|
|
35
|
+
userServiceEndpoint: options.userServiceUrl,
|
|
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");
|
|
24
60
|
}
|
|
25
61
|
//#endregion
|
|
26
62
|
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: "conflict",
|
|
24
24
|
rate_limited: "rate-limited",
|
|
25
25
|
timeout: "network",
|
|
26
26
|
transport_unavailable: "network",
|
|
@@ -197,6 +197,26 @@ function identity(value) {
|
|
|
197
197
|
registeredAt: safeInteger(value.registeredAtMs)
|
|
198
198
|
};
|
|
199
199
|
}
|
|
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
|
+
}
|
|
200
220
|
function profile(value) {
|
|
201
221
|
return {
|
|
202
222
|
did: required(value.did),
|
|
@@ -307,17 +327,25 @@ var RustSdkAdapter = class {
|
|
|
307
327
|
client;
|
|
308
328
|
attachmentConversations = /* @__PURE__ */ new Map();
|
|
309
329
|
disposal;
|
|
330
|
+
realtime;
|
|
331
|
+
agentInbox;
|
|
310
332
|
listener;
|
|
311
333
|
constructor(client) {
|
|
312
334
|
this.client = Promise.resolve(client);
|
|
313
|
-
this.
|
|
335
|
+
this.realtime = {
|
|
314
336
|
syncNow: (reason) => this.listenerSyncNow(reason),
|
|
315
|
-
startRealtime: () => this.listenerStartRealtime()
|
|
337
|
+
startRealtime: () => this.listenerStartRealtime()
|
|
338
|
+
};
|
|
339
|
+
this.agentInbox = {
|
|
316
340
|
listConversations: (request) => this.listenerConversations(request),
|
|
317
341
|
getHistory: (request) => this.listenerHistory(request),
|
|
318
342
|
markConversationRead: (conversationId) => this.markConversationRead(conversationId),
|
|
319
343
|
sendText: (request) => this.sendText(request)
|
|
320
344
|
};
|
|
345
|
+
this.listener = {
|
|
346
|
+
...this.realtime,
|
|
347
|
+
...this.agentInbox
|
|
348
|
+
};
|
|
321
349
|
}
|
|
322
350
|
async run(operation, ambiguousSend = false) {
|
|
323
351
|
try {
|
|
@@ -529,6 +557,9 @@ var RustSdkAdapter = class {
|
|
|
529
557
|
const session = await client.startRealtime();
|
|
530
558
|
return {
|
|
531
559
|
nextEvent: () => this.run(() => session.nextEvent()),
|
|
560
|
+
getStatus: () => this.run(async () => {
|
|
561
|
+
return { connected: (await session.getStatus()).connected };
|
|
562
|
+
}),
|
|
532
563
|
stop: () => this.run(() => session.stop())
|
|
533
564
|
};
|
|
534
565
|
});
|
|
@@ -591,7 +622,114 @@ var RustSdkAdapter = class {
|
|
|
591
622
|
});
|
|
592
623
|
}
|
|
593
624
|
registerIdentity(request) {
|
|
594
|
-
return this.run(async (client) =>
|
|
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
|
+
});
|
|
595
733
|
}
|
|
596
734
|
updateDisplayName(request) {
|
|
597
735
|
return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
|