@awiki/dsh-plugin 0.3.7-dsh-test.20260831.2 → 0.3.10
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 +66 -26
- package/README.zh.md +57 -23
- package/cordis.patch.yml +7 -5
- package/lib/builtin-tenants.json +22 -0
- package/lib/builtin-tenants.sha256 +1 -0
- package/lib/client.js +7123 -1635
- package/lib/client.js.map +1 -1
- package/lib/index.js +2534 -474
- package/lib/model-proxy-contract.js +11 -3
- package/lib/provider.js +6 -3
- package/lib/{sdk-adapter-FGaOi8It.mjs → sdk-adapter-CYcJH7sM.mjs} +210 -21
- package/lib/typert.host.js +1305 -106
- package/lib/typert.remote-client.d.ts +25 -1
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +1305 -106
- package/lib/types/builtin-tenant-config.d.ts +19 -0
- package/lib/types/builtin-tenant-config.d.ts.map +1 -0
- package/lib/types/builtin-tenant-config.js +57 -0
- package/lib/types/builtin-tenant-config.js.map +1 -0
- package/lib/types/client/AwikiDeviceJoinReminder.d.ts +15 -0
- package/lib/types/client/AwikiDeviceJoinReminder.d.ts.map +1 -0
- package/lib/types/client/AwikiDeviceJoinReminder.js +74 -0
- package/lib/types/client/AwikiDeviceJoinReminder.js.map +1 -0
- package/lib/types/client/AwikiDevices.d.ts +8 -3
- package/lib/types/client/AwikiDevices.d.ts.map +1 -1
- package/lib/types/client/AwikiDevices.js +64 -8
- package/lib/types/client/AwikiDevices.js.map +1 -1
- package/lib/types/client/AwikiGroupDetails.d.ts.map +1 -1
- package/lib/types/client/AwikiGroupDetails.js +16 -13
- package/lib/types/client/AwikiGroupDetails.js.map +1 -1
- package/lib/types/client/AwikiIdentityAccess.d.ts +10 -4
- package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
- package/lib/types/client/AwikiIdentityAccess.js +139 -36
- package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
- package/lib/types/client/AwikiIntegrationSettings.d.ts +21 -0
- package/lib/types/client/AwikiIntegrationSettings.d.ts.map +1 -0
- package/lib/types/client/AwikiIntegrationSettings.js +105 -0
- package/lib/types/client/AwikiIntegrationSettings.js.map +1 -0
- package/lib/types/client/AwikiMail.d.ts.map +1 -1
- package/lib/types/client/AwikiMail.js +12 -8
- package/lib/types/client/AwikiMail.js.map +1 -1
- package/lib/types/client/AwikiOverlay.d.ts +0 -1
- package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
- package/lib/types/client/AwikiOverlay.js +26 -21
- package/lib/types/client/AwikiOverlay.js.map +1 -1
- package/lib/types/client/AwikiProfileCard.d.ts.map +1 -1
- package/lib/types/client/AwikiProfileCard.js +17 -18
- package/lib/types/client/AwikiProfileCard.js.map +1 -1
- package/lib/types/client/AwikiRecoveryForm.d.ts +5 -1
- package/lib/types/client/AwikiRecoveryForm.d.ts.map +1 -1
- package/lib/types/client/AwikiRecoveryForm.js +73 -30
- package/lib/types/client/AwikiRecoveryForm.js.map +1 -1
- package/lib/types/client/AwikiSettingsSection.d.ts +28 -13
- package/lib/types/client/AwikiSettingsSection.d.ts.map +1 -1
- package/lib/types/client/AwikiSettingsSection.js +93 -61
- package/lib/types/client/AwikiSettingsSection.js.map +1 -1
- package/lib/types/client/AwikiUpdates.d.ts +10 -0
- package/lib/types/client/AwikiUpdates.d.ts.map +1 -0
- package/lib/types/client/AwikiUpdates.js +57 -0
- package/lib/types/client/AwikiUpdates.js.map +1 -0
- package/lib/types/client/awiki-client-bridge.d.ts +1 -1
- package/lib/types/client/awiki-client-bridge.d.ts.map +1 -1
- package/lib/types/client/awiki-client-bridge.js +4 -1
- package/lib/types/client/awiki-client-bridge.js.map +1 -1
- package/lib/types/client/controller.d.ts +65 -11
- package/lib/types/client/controller.d.ts.map +1 -1
- package/lib/types/client/controller.js +480 -127
- package/lib/types/client/controller.js.map +1 -1
- package/lib/types/client/drafts.d.ts +31 -0
- package/lib/types/client/drafts.d.ts.map +1 -0
- package/lib/types/client/drafts.js +94 -0
- package/lib/types/client/drafts.js.map +1 -0
- package/lib/types/client/image-cache.d.ts +2 -2
- package/lib/types/client/image-cache.d.ts.map +1 -1
- package/lib/types/client/image-cache.js +15 -2
- package/lib/types/client/image-cache.js.map +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +55 -15
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/integration-operation.d.ts +9 -0
- package/lib/types/client/integration-operation.d.ts.map +1 -0
- package/lib/types/client/integration-operation.js +54 -0
- package/lib/types/client/integration-operation.js.map +1 -0
- package/lib/types/client/mail-list-cache.d.ts +2 -0
- package/lib/types/client/mail-list-cache.d.ts.map +1 -1
- package/lib/types/client/mail-list-cache.js +18 -0
- package/lib/types/client/mail-list-cache.js.map +1 -1
- package/lib/types/client/otp-cooldown.d.ts +6 -0
- package/lib/types/client/otp-cooldown.d.ts.map +1 -0
- package/lib/types/client/otp-cooldown.js +18 -0
- package/lib/types/client/otp-cooldown.js.map +1 -0
- package/lib/types/client/settings-controller.d.ts +34 -0
- package/lib/types/client/settings-controller.d.ts.map +1 -1
- package/lib/types/client/settings-controller.js +182 -2
- package/lib/types/client/settings-controller.js.map +1 -1
- package/lib/types/client/settings-locales.d.ts +1 -1
- package/lib/types/client/settings-locales.d.ts.map +1 -1
- package/lib/types/client/settings-locales.js +184 -6
- package/lib/types/client/settings-locales.js.map +1 -1
- package/lib/types/client/slots.d.ts +11 -1
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/client/slots.js +0 -1
- package/lib/types/client/slots.js.map +1 -1
- package/lib/types/desktop-distribution.d.ts +25 -0
- package/lib/types/desktop-distribution.d.ts.map +1 -0
- package/lib/types/desktop-distribution.js +57 -0
- package/lib/types/desktop-distribution.js.map +1 -0
- package/lib/types/domain.d.ts +1 -1
- package/lib/types/domain.d.ts.map +1 -1
- package/lib/types/domain.js +2 -1
- package/lib/types/domain.js.map +1 -1
- package/lib/types/index.d.ts +112 -18
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +897 -205
- package/lib/types/index.js.map +1 -1
- package/lib/types/integration-client.d.ts +17 -0
- package/lib/types/integration-client.d.ts.map +1 -0
- package/lib/types/integration-client.js +233 -0
- package/lib/types/integration-client.js.map +1 -0
- package/lib/types/legacy-sent-mail-cache.d.ts +4 -0
- package/lib/types/legacy-sent-mail-cache.d.ts.map +1 -0
- package/lib/types/legacy-sent-mail-cache.js +29 -0
- package/lib/types/legacy-sent-mail-cache.js.map +1 -0
- package/lib/types/mail-list-client.d.ts +12 -0
- package/lib/types/mail-list-client.d.ts.map +1 -0
- package/lib/types/mail-list-client.js +254 -0
- package/lib/types/mail-list-client.js.map +1 -0
- package/lib/types/mail-recovery-observability.d.ts +8 -0
- package/lib/types/mail-recovery-observability.d.ts.map +1 -0
- package/lib/types/mail-recovery-observability.js +119 -0
- package/lib/types/mail-recovery-observability.js.map +1 -0
- package/lib/types/model-proxy-contract.d.ts.map +1 -1
- package/lib/types/model-proxy-contract.js +7 -0
- package/lib/types/model-proxy-contract.js.map +1 -1
- package/lib/types/package-version.generated.d.ts +4 -0
- package/lib/types/package-version.generated.d.ts.map +1 -0
- package/lib/types/package-version.generated.js +4 -0
- package/lib/types/package-version.generated.js.map +1 -0
- package/lib/types/profile-state.d.ts +6 -0
- package/lib/types/profile-state.d.ts.map +1 -0
- package/lib/types/profile-state.js +41 -0
- package/lib/types/profile-state.js.map +1 -0
- package/lib/types/provider-api.d.ts +36 -9
- package/lib/types/provider-api.d.ts.map +1 -1
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js +5 -2
- package/lib/types/provider.js.map +1 -1
- package/lib/types/realtime-supervisor.d.ts +6 -0
- package/lib/types/realtime-supervisor.d.ts.map +1 -1
- package/lib/types/realtime-supervisor.js +14 -1
- package/lib/types/realtime-supervisor.js.map +1 -1
- package/lib/types/sdk-adapter.d.ts +32 -6
- package/lib/types/sdk-adapter.d.ts.map +1 -1
- package/lib/types/sdk-adapter.js +127 -24
- package/lib/types/sdk-adapter.js.map +1 -1
- package/lib/types/settings-rpc-contract.d.ts +58 -0
- package/lib/types/settings-rpc-contract.d.ts.map +1 -1
- package/lib/types/settings-rpc-contract.js +103 -0
- package/lib/types/settings-rpc-contract.js.map +1 -1
- package/lib/types/settings-rpc.d.ts +14 -1
- package/lib/types/settings-rpc.d.ts.map +1 -1
- package/lib/types/settings-rpc.js +130 -1
- package/lib/types/settings-rpc.js.map +1 -1
- package/lib/types/tenant-registry.d.ts +74 -0
- package/lib/types/tenant-registry.d.ts.map +1 -0
- package/lib/types/tenant-registry.js +440 -0
- package/lib/types/tenant-registry.js.map +1 -0
- package/lib/types/types.d.ts +173 -1
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/lib/types/update-policy.d.ts +51 -0
- package/lib/types/update-policy.d.ts.map +1 -0
- package/lib/types/update-policy.js +379 -0
- package/lib/types/update-policy.js.map +1 -0
- package/lib/types/version.d.ts +4 -0
- package/lib/types/version.d.ts.map +1 -0
- package/lib/types/version.js +44 -0
- package/lib/types/version.js.map +1 -0
- package/package.json +34 -21
- package/lib/types/sent-mail-store.d.ts +0 -22
- package/lib/types/sent-mail-store.d.ts.map +0 -1
- package/lib/types/sent-mail-store.js +0 -246
- package/lib/types/sent-mail-store.js.map +0 -1
|
@@ -37,7 +37,7 @@ function decodeModelProxyUsage(value) {
|
|
|
37
37
|
return usage.every((item) => item !== void 0) ? usage : void 0;
|
|
38
38
|
}
|
|
39
39
|
function decodeRechargeOrder(value) {
|
|
40
|
-
if (!isRecord(value) || typeof value.out_trade_no !== "string" || !Number.isSafeInteger(value.amount_cents) || ![
|
|
40
|
+
if (!isRecord(value) || containsPrivateIdentityOwner(value) || typeof value.out_trade_no !== "string" || !Number.isSafeInteger(value.amount_cents) || ![
|
|
41
41
|
"pending",
|
|
42
42
|
"paid",
|
|
43
43
|
"closed"
|
|
@@ -61,7 +61,7 @@ function decodeCloseRechargeResult(value) {
|
|
|
61
61
|
return isRecord(value) && value.closed === true ? { closed: true } : void 0;
|
|
62
62
|
}
|
|
63
63
|
function decodeAccount(value) {
|
|
64
|
-
if (!(isRecord(value) && typeof value.did === "string" && Number.isSafeInteger(value.balance_cents) && typeof value.balance === "string" && value.currency === "CNY" && typeof value.model_access_available === "boolean" && (value.model_access_reason === null || typeof value.model_access_reason === "string") && ["strict", "development_bypass"].includes(String(value.billing_mode)) && typeof value.payments_available === "boolean")) return void 0;
|
|
64
|
+
if (!(isRecord(value) && !containsPrivateIdentityOwner(value) && typeof value.did === "string" && Number.isSafeInteger(value.balance_cents) && typeof value.balance === "string" && value.currency === "CNY" && typeof value.model_access_available === "boolean" && (value.model_access_reason === null || typeof value.model_access_reason === "string") && ["strict", "development_bypass"].includes(String(value.billing_mode)) && typeof value.payments_available === "boolean")) return void 0;
|
|
65
65
|
return {
|
|
66
66
|
did: value.did,
|
|
67
67
|
balance_cents: value.balance_cents,
|
|
@@ -74,7 +74,7 @@ function decodeAccount(value) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
function decodeUsage(value) {
|
|
77
|
-
if (!(isRecord(value) && Number.isSafeInteger(value.id) && typeof value.endpoint === "string" && typeof value.model === "string" && Number.isSafeInteger(value.cache_hit_tokens) && Number.isSafeInteger(value.cache_miss_tokens) && Number.isSafeInteger(value.completion_tokens) && ["strict", "development_bypass"].includes(String(value.billing_mode)) && (value.calculated_cost_micros === null || Number.isSafeInteger(value.calculated_cost_micros)) && Number.isSafeInteger(value.charged_micros) && typeof value.estimated === "boolean" && typeof value.created_at === "string")) return void 0;
|
|
77
|
+
if (!(isRecord(value) && !containsPrivateIdentityOwner(value) && Number.isSafeInteger(value.id) && typeof value.endpoint === "string" && typeof value.model === "string" && Number.isSafeInteger(value.cache_hit_tokens) && Number.isSafeInteger(value.cache_miss_tokens) && Number.isSafeInteger(value.completion_tokens) && ["strict", "development_bypass"].includes(String(value.billing_mode)) && (value.calculated_cost_micros === null || Number.isSafeInteger(value.calculated_cost_micros)) && Number.isSafeInteger(value.charged_micros) && typeof value.estimated === "boolean" && typeof value.created_at === "string")) return void 0;
|
|
78
78
|
return {
|
|
79
79
|
id: value.id,
|
|
80
80
|
endpoint: value.endpoint,
|
|
@@ -89,6 +89,14 @@ function decodeUsage(value) {
|
|
|
89
89
|
created_at: value.created_at
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
+
function containsPrivateIdentityOwner(value) {
|
|
93
|
+
return [
|
|
94
|
+
"canonical_did",
|
|
95
|
+
"stable_subject_hash",
|
|
96
|
+
"path",
|
|
97
|
+
"proof"
|
|
98
|
+
].some((key) => key in value) || "did" in value && !("balance_cents" in value);
|
|
99
|
+
}
|
|
92
100
|
function isRecord(value) {
|
|
93
101
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
94
102
|
}
|
package/lib/provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as RustSdkAdapter } from "./sdk-adapter-CYcJH7sM.mjs";
|
|
2
2
|
import { setTimeout } from "node:timers/promises";
|
|
3
3
|
import { openImCoreNodeClient } from "@awiki/im-core-node";
|
|
4
4
|
//#region lib/types/provider.js
|
|
@@ -44,7 +44,7 @@ async function apply(ctx) {
|
|
|
44
44
|
clientVersionInfo: {
|
|
45
45
|
product: "awiki-daemon",
|
|
46
46
|
release: "0815",
|
|
47
|
-
version: "0.1.
|
|
47
|
+
version: "0.1.93"
|
|
48
48
|
},
|
|
49
49
|
multiDeviceHandleRecoveryEnabled: true,
|
|
50
50
|
multiDeviceDeviceRevokeEnabled: true,
|
|
@@ -69,11 +69,14 @@ async function apply(ctx) {
|
|
|
69
69
|
}
|
|
70
70
|
async function waitForIdentityProvider(identity) {
|
|
71
71
|
const deadline = Date.now() + IDENTITY_PROVIDER_READY_TIMEOUT_MS;
|
|
72
|
-
while ((await identity.health())
|
|
72
|
+
while (!providerIsReady(await identity.health())) {
|
|
73
73
|
const remaining = deadline - Date.now();
|
|
74
74
|
if (remaining <= 0) throw new Error(`awiki: ANP Identity provider did not become ready within ${IDENTITY_PROVIDER_READY_TIMEOUT_MS}ms`);
|
|
75
75
|
await setTimeout(Math.min(IDENTITY_PROVIDER_READY_POLL_MS, remaining));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
function providerIsReady(health) {
|
|
79
|
+
return health.status !== "unavailable" && health.providerProtocol !== void 0;
|
|
80
|
+
}
|
|
78
81
|
//#endregion
|
|
79
82
|
export { apply, inject, name };
|
|
@@ -1,3 +1,105 @@
|
|
|
1
|
+
//#region lib/types/mail-recovery-observability.js
|
|
2
|
+
const MAIL_INGRESS_CLASSIFICATIONS = /* @__PURE__ */ new Set([
|
|
3
|
+
"reached",
|
|
4
|
+
"not_reached",
|
|
5
|
+
"unknown"
|
|
6
|
+
]);
|
|
7
|
+
const AUTH_STATUS_CLASSES = /* @__PURE__ */ new Set([
|
|
8
|
+
"accepted",
|
|
9
|
+
"rejected",
|
|
10
|
+
"dependency_unavailable",
|
|
11
|
+
"unknown"
|
|
12
|
+
]);
|
|
13
|
+
const MAIL_CLOSED_CLASSIFICATIONS = /* @__PURE__ */ new Set([
|
|
14
|
+
"success",
|
|
15
|
+
"authentication_rejected",
|
|
16
|
+
"dependency_unavailable",
|
|
17
|
+
"no_active_handle",
|
|
18
|
+
"multiple_active_handles",
|
|
19
|
+
"no_mailbox",
|
|
20
|
+
"owner_conflict",
|
|
21
|
+
"unknown"
|
|
22
|
+
]);
|
|
23
|
+
const STABLE_MACHINE_CODE = /^[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$/u;
|
|
24
|
+
const CLOSED_FAILURE_TUPLES = /* @__PURE__ */ new Set([
|
|
25
|
+
"reached:rejected:authentication_rejected",
|
|
26
|
+
"reached:dependency_unavailable:dependency_unavailable",
|
|
27
|
+
"not_reached:dependency_unavailable:dependency_unavailable",
|
|
28
|
+
"reached:accepted:no_active_handle",
|
|
29
|
+
"reached:accepted:multiple_active_handles",
|
|
30
|
+
"reached:accepted:no_mailbox",
|
|
31
|
+
"reached:accepted:owner_conflict"
|
|
32
|
+
]);
|
|
33
|
+
function property(value, key) {
|
|
34
|
+
try {
|
|
35
|
+
return typeof value === "object" && value !== null ? value[key] : void 0;
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function optionalProperty(value, key) {
|
|
41
|
+
try {
|
|
42
|
+
if (typeof value !== "object" || value === null || !(key in value)) return { status: "absent" };
|
|
43
|
+
return {
|
|
44
|
+
status: "present",
|
|
45
|
+
value: value[key]
|
|
46
|
+
};
|
|
47
|
+
} catch {
|
|
48
|
+
return { status: "unreadable" };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Copy only a complete upstream closed classification; arbitrary errors fail closed. */
|
|
52
|
+
function mailRecoveryFailureFields(error) {
|
|
53
|
+
const ingress = property(error, "mail_ingress_classification");
|
|
54
|
+
const authStatus = property(error, "auth_status_class");
|
|
55
|
+
const closed = property(error, "mail_closed_classification");
|
|
56
|
+
const retryable = property(error, "retryable");
|
|
57
|
+
if (typeof ingress !== "string" || !MAIL_INGRESS_CLASSIFICATIONS.has(ingress) || typeof authStatus !== "string" || !AUTH_STATUS_CLASSES.has(authStatus) || typeof closed !== "string" || !MAIL_CLOSED_CLASSIFICATIONS.has(closed) || ingress === "unknown" || authStatus === "unknown" || closed === "unknown" || closed === "success" || typeof retryable !== "boolean") return void 0;
|
|
58
|
+
const tuple = `${ingress}:${authStatus}:${closed}`;
|
|
59
|
+
if (!CLOSED_FAILURE_TUPLES.has(tuple)) return void 0;
|
|
60
|
+
const stableCode = optionalProperty(error, "auth_stable_machine_code");
|
|
61
|
+
if (stableCode.status === "unreadable" || stableCode.status === "present" && (typeof stableCode.value !== "string" || !STABLE_MACHINE_CODE.test(stableCode.value)) || stableCode.status === "present" && authStatus === "accepted") return void 0;
|
|
62
|
+
return {
|
|
63
|
+
mail_ingress_classification: ingress,
|
|
64
|
+
auth_status_class: authStatus,
|
|
65
|
+
...stableCode.status === "present" ? { auth_stable_machine_code: stableCode.value } : {},
|
|
66
|
+
retryable,
|
|
67
|
+
mail_closed_classification: closed
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function successfulMailRecoveryObservability() {
|
|
71
|
+
return {
|
|
72
|
+
current_principal_matches_recovery: true,
|
|
73
|
+
request_generation_classification: "current",
|
|
74
|
+
mail_ingress_classification: "reached",
|
|
75
|
+
auth_status_class: "accepted",
|
|
76
|
+
retryable: false,
|
|
77
|
+
mail_closed_classification: "success"
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function failedMailRecoveryObservability(error) {
|
|
81
|
+
return {
|
|
82
|
+
current_principal_matches_recovery: true,
|
|
83
|
+
request_generation_classification: "current",
|
|
84
|
+
...mailRecoveryFailureFields(error) ?? {
|
|
85
|
+
mail_ingress_classification: "unknown",
|
|
86
|
+
auth_status_class: "unknown",
|
|
87
|
+
retryable: false,
|
|
88
|
+
mail_closed_classification: "unknown"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function fencedMailRecoveryObservability(currentPrincipalMatchesRecovery, requestGenerationClassification) {
|
|
93
|
+
return {
|
|
94
|
+
current_principal_matches_recovery: currentPrincipalMatchesRecovery,
|
|
95
|
+
request_generation_classification: requestGenerationClassification,
|
|
96
|
+
mail_ingress_classification: currentPrincipalMatchesRecovery ? "unknown" : "not_reached",
|
|
97
|
+
auth_status_class: "unknown",
|
|
98
|
+
retryable: false,
|
|
99
|
+
mail_closed_classification: "unknown"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
1
103
|
//#region lib/types/sdk-adapter.js
|
|
2
104
|
/** Rust IM Core adapter that copies native values into Host-owned public DTOs. */
|
|
3
105
|
const GROUP_LOOKUP_LIMIT = 100;
|
|
@@ -17,7 +119,8 @@ const RUST_FAILURE_CODES = {
|
|
|
17
119
|
permission_denied: "forbidden",
|
|
18
120
|
group_not_member: "group-membership-required",
|
|
19
121
|
group_identity_stale: "group-identity-stale",
|
|
20
|
-
auth_revoked: "
|
|
122
|
+
auth_revoked: "device-rejoin-required",
|
|
123
|
+
local_identity_recovery_required: "identity-recovery-required",
|
|
21
124
|
conflict: "conflict",
|
|
22
125
|
join_required: "handle-unavailable",
|
|
23
126
|
state_in_use: "conflict",
|
|
@@ -36,10 +139,16 @@ var AwikiSdkError = class extends Error {
|
|
|
36
139
|
code;
|
|
37
140
|
realtimeFailureCode;
|
|
38
141
|
name = "AwikiSdkError";
|
|
39
|
-
|
|
142
|
+
mail_ingress_classification;
|
|
143
|
+
auth_status_class;
|
|
144
|
+
auth_stable_machine_code;
|
|
145
|
+
retryable;
|
|
146
|
+
mail_closed_classification;
|
|
147
|
+
constructor(code, realtimeFailureCode, mailRecoveryFailure) {
|
|
40
148
|
super(`AWiki SDK operation failed: ${code}`);
|
|
41
149
|
this.code = code;
|
|
42
150
|
this.realtimeFailureCode = realtimeFailureCode;
|
|
151
|
+
if (mailRecoveryFailure !== void 0) Object.assign(this, mailRecoveryFailure);
|
|
43
152
|
}
|
|
44
153
|
};
|
|
45
154
|
function fail(code = "remote") {
|
|
@@ -57,13 +166,25 @@ const REALTIME_RETRY_WARNING_PRIORITY = [
|
|
|
57
166
|
"sync.retry.service_unavailable",
|
|
58
167
|
"sync.retry.local_state_unavailable"
|
|
59
168
|
];
|
|
60
|
-
function realtimeSyncFailureCode(status, warnings) {
|
|
169
|
+
function realtimeSyncFailureCode(status, warnings, errorCode) {
|
|
61
170
|
if (status === "retryable_failure") return REALTIME_RETRY_WARNING_PRIORITY.find((code) => warnings.includes(code)) ?? "sync.retryable_failure";
|
|
62
171
|
if (status === "recovery_required") return "sync.recovery_required";
|
|
63
172
|
if (status === "auth_revoked") return "sync.auth_revoked";
|
|
64
|
-
if (status === "blocked")
|
|
173
|
+
if (status === "blocked") {
|
|
174
|
+
if (errorCode === "sync.client_upgrade_required") return "sync.blocked.client_upgrade_required";
|
|
175
|
+
if (errorCode === "device_reprovision_required") return "sync.blocked.device_reprovision_required";
|
|
176
|
+
if (errorCode === "server_repair_required") return "sync.blocked.server_repair_required";
|
|
177
|
+
if (errorCode === "sync.snapshot_item_too_large" || errorCode === "sync.snapshot_required_state_too_large") return "sync.blocked.snapshot_capacity";
|
|
178
|
+
if (errorCode === "sync.invalid_request") return "sync.blocked.invalid_request";
|
|
179
|
+
if (errorCode === "sync.invalid_cursor") return "sync.blocked.invalid_cursor";
|
|
180
|
+
return errorCode === void 0 ? "sync.blocked" : "sync.blocked.other";
|
|
181
|
+
}
|
|
65
182
|
return "sync.unexpected_status";
|
|
66
183
|
}
|
|
184
|
+
function syncResultErrorCode(result) {
|
|
185
|
+
if (!("errorCode" in result)) return void 0;
|
|
186
|
+
return typeof result.errorCode === "string" ? result.errorCode : void 0;
|
|
187
|
+
}
|
|
67
188
|
function mapError(error, ambiguousSend = false) {
|
|
68
189
|
if (error instanceof AwikiSdkError) throw error;
|
|
69
190
|
let code = "remote";
|
|
@@ -73,7 +194,7 @@ function mapError(error, ambiguousSend = false) {
|
|
|
73
194
|
if (value.name === "ImCoreNodeError" && typeof value.code === "string") code = ambiguousSend && (value.code === "timeout" || value.code === "transport_unavailable") ? "delivery-unknown" : RUST_FAILURE_CODES[value.code] ?? "remote";
|
|
74
195
|
}
|
|
75
196
|
} catch {}
|
|
76
|
-
|
|
197
|
+
throw new AwikiSdkError(code, void 0, mailRecoveryFailureFields(error));
|
|
77
198
|
}
|
|
78
199
|
function safeInteger(value, minimum = 0) {
|
|
79
200
|
if (!/^(?:0|[1-9]\d*)$/u.test(value)) fail();
|
|
@@ -341,7 +462,30 @@ function externalHttpAttempt(value) {
|
|
|
341
462
|
}
|
|
342
463
|
/** Adapt the Rust Node bridge to the frozen Host provider interface. */
|
|
343
464
|
var RustSdkAdapter = class {
|
|
465
|
+
trustedUserPresenceSupported = process.platform === "darwin" && process.arch === "x64";
|
|
344
466
|
client;
|
|
467
|
+
refreshingDisplayPeers = /* @__PURE__ */ new Set();
|
|
468
|
+
scheduleDisplayRefresh(client, peers) {
|
|
469
|
+
if (this.disposal !== void 0) return;
|
|
470
|
+
const pending = [...new Set(peers)].filter((peer) => peer.startsWith("did:") && !this.refreshingDisplayPeers.has(peer)).slice(0, 100);
|
|
471
|
+
if (pending.length === 0) return;
|
|
472
|
+
for (const peer of pending) this.refreshingDisplayPeers.add(peer);
|
|
473
|
+
client.refreshDisplayProfiles({ peers: pending }).catch(() => void 0).finally(() => {
|
|
474
|
+
for (const peer of pending) this.refreshingDisplayPeers.delete(peer);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
getDisplayProfiles(peers) {
|
|
478
|
+
return this.run(async (client) => {
|
|
479
|
+
const profiles = await client.hydrateDisplayProfiles({ peers });
|
|
480
|
+
this.scheduleDisplayRefresh(client, peers);
|
|
481
|
+
return profiles.flatMap((profile) => profile.did === void 0 ? [] : [{
|
|
482
|
+
did: profile.did,
|
|
483
|
+
cacheHit: profile.cacheHit,
|
|
484
|
+
...profile.handle === void 0 ? {} : { handle: profile.handle },
|
|
485
|
+
...profile.displayName === void 0 ? {} : { displayName: profile.displayName }
|
|
486
|
+
}]);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
345
489
|
attachmentConversations = /* @__PURE__ */ new Map();
|
|
346
490
|
disposal;
|
|
347
491
|
realtime;
|
|
@@ -373,16 +517,18 @@ var RustSdkAdapter = class {
|
|
|
373
517
|
}
|
|
374
518
|
async displayableMessages(client, values) {
|
|
375
519
|
const messages = values.filter(displayableMessage);
|
|
376
|
-
const peers = [...new Set(messages.filter((message) => message.conversationKind === "group" && !message.outgoing
|
|
520
|
+
const peers = [...new Set(messages.filter((message) => message.conversationKind === "group" && !message.outgoing).map((message) => message.senderDid))];
|
|
377
521
|
if (peers.length === 0) return [...messages];
|
|
378
522
|
const profiles = await client.hydrateDisplayProfiles({ peers });
|
|
523
|
+
this.scheduleDisplayRefresh(client, peers);
|
|
379
524
|
const byDid = /* @__PURE__ */ new Map();
|
|
380
525
|
for (const profile of profiles) if (profile.did !== void 0) byDid.set(profile.did, profile);
|
|
381
526
|
return messages.map((message) => {
|
|
382
527
|
const profile = byDid.get(message.senderDid);
|
|
383
|
-
if (profile === void 0) return message;
|
|
528
|
+
if (profile === void 0 || !profile.cacheHit) return message;
|
|
529
|
+
const { senderDisplayName: _snapshot, ...rest } = message;
|
|
384
530
|
return {
|
|
385
|
-
...
|
|
531
|
+
...rest,
|
|
386
532
|
...profile.handle === void 0 ? {} : { senderHandle: profile.handle },
|
|
387
533
|
...profile.displayName === void 0 ? {} : { senderDisplayName: profile.displayName }
|
|
388
534
|
};
|
|
@@ -515,7 +661,7 @@ var RustSdkAdapter = class {
|
|
|
515
661
|
...value.peerPersonaId === void 0 ? {} : { peerPersonaId: value.peerPersonaId },
|
|
516
662
|
...value.did === void 0 ? {} : { did: value.did },
|
|
517
663
|
...value.credentialDid === void 0 ? {} : { credentialDid: value.credentialDid },
|
|
518
|
-
...value.handle === void 0 ? {} : { handle: value.handle },
|
|
664
|
+
...(profile?.handle ?? value.handle) === void 0 ? {} : { handle: profile?.handle ?? value.handle },
|
|
519
665
|
...profile?.displayName === void 0 ? {} : { displayName: profile.displayName },
|
|
520
666
|
...value.role === void 0 ? {} : { role: value.role },
|
|
521
667
|
...value.status === void 0 ? {} : { status: value.status },
|
|
@@ -564,8 +710,12 @@ var RustSdkAdapter = class {
|
|
|
564
710
|
listenerSyncNow(reason) {
|
|
565
711
|
return this.run(async (client) => {
|
|
566
712
|
const result = await client.syncNow({ reason });
|
|
567
|
-
if (result.status === "idle" || result.status === "changed") return
|
|
568
|
-
|
|
713
|
+
if (result.status === "idle" || result.status === "changed") return {
|
|
714
|
+
pagesFetched: uint32(result.pagesFetched),
|
|
715
|
+
messagesHydrated: uint32(result.messagesHydrated),
|
|
716
|
+
olderHistoryExcluded: boolean(result.olderHistoryExcluded)
|
|
717
|
+
};
|
|
718
|
+
throw new AwikiSdkError(result.status === "auth_revoked" ? "device-rejoin-required" : "network", realtimeSyncFailureCode(result.status, result.warnings, syncResultErrorCode(result)));
|
|
569
719
|
});
|
|
570
720
|
}
|
|
571
721
|
listenerStartRealtime() {
|
|
@@ -705,6 +855,7 @@ var RustSdkAdapter = class {
|
|
|
705
855
|
listLocalDeviceJoinRequests() {
|
|
706
856
|
return this.run(async (client) => (await client.listLocalDeviceJoinRequests()).map((value) => ({
|
|
707
857
|
joinSessionId: required(value.joinSessionId),
|
|
858
|
+
protocolDeviceId: required(value.protocolDeviceId),
|
|
708
859
|
candidateKeyFingerprint: required(value.candidateKeyFingerprint),
|
|
709
860
|
issuedAt: required(value.issuedAt),
|
|
710
861
|
expiresAt: required(value.expiresAt),
|
|
@@ -747,6 +898,35 @@ var RustSdkAdapter = class {
|
|
|
747
898
|
});
|
|
748
899
|
});
|
|
749
900
|
}
|
|
901
|
+
confirmUserPresence(reason) {
|
|
902
|
+
return this.run((client) => client.confirmUserPresence({ reason }));
|
|
903
|
+
}
|
|
904
|
+
prepareRootKeyTransfer(deviceId) {
|
|
905
|
+
return this.run(async (client) => {
|
|
906
|
+
const value = await client.prepareRootKeyTransfer({ recipientDeviceId: deviceId });
|
|
907
|
+
return {
|
|
908
|
+
authorizationHandle: required(value.authorizationHandle),
|
|
909
|
+
recipient: {
|
|
910
|
+
did: required(value.recipient.did),
|
|
911
|
+
deviceId: required(value.recipient.deviceId),
|
|
912
|
+
registryVersion: required(value.recipient.registryVersion)
|
|
913
|
+
},
|
|
914
|
+
expiresAt: required(value.expiresAt)
|
|
915
|
+
};
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
confirmAndSendRootKeyTransfer(authorizationHandle) {
|
|
919
|
+
return this.run(async (client) => {
|
|
920
|
+
const value = await client.confirmAndSendRootKeyTransfer({
|
|
921
|
+
authorizationHandle,
|
|
922
|
+
userPresenceConfirmed: true
|
|
923
|
+
});
|
|
924
|
+
return {
|
|
925
|
+
recipientDeviceId: required(value.recipientDeviceId),
|
|
926
|
+
acceptedAt: required(value.acceptedAt)
|
|
927
|
+
};
|
|
928
|
+
});
|
|
929
|
+
}
|
|
750
930
|
updateDisplayName(request) {
|
|
751
931
|
return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
|
|
752
932
|
}
|
|
@@ -767,6 +947,7 @@ var RustSdkAdapter = class {
|
|
|
767
947
|
...value.previousDid === void 0 ? {} : { previousDid: value.previousDid },
|
|
768
948
|
currentDid: required(value.currentDid),
|
|
769
949
|
phase: value.phase,
|
|
950
|
+
allowedActions: [...value.allowedActions ?? []],
|
|
770
951
|
...value.failureCode === void 0 ? {} : { failureCode: value.failureCode },
|
|
771
952
|
retryable: boolean(value.retryable),
|
|
772
953
|
localOrdinaryDataWillMigrate: boolean(value.impact.localOrdinaryDataWillMigrate),
|
|
@@ -790,21 +971,18 @@ var RustSdkAdapter = class {
|
|
|
790
971
|
activateRecovery(request) {
|
|
791
972
|
return this.run(async (client) => this.recoveryProgress(await client.activateHandleRecovery(request)));
|
|
792
973
|
}
|
|
974
|
+
listPendingRecoveries() {
|
|
975
|
+
return this.run(async (client) => (await client.listPendingHandleRecoveryOperations()).map((value) => ({
|
|
976
|
+
operationId: required(value.operationId),
|
|
977
|
+
fullHandle: required(value.fullHandle)
|
|
978
|
+
})));
|
|
979
|
+
}
|
|
793
980
|
getRecoveryStatus(request) {
|
|
794
981
|
return this.run(async (client) => this.recoveryProgress(await client.getHandleRecoveryStatus(request)));
|
|
795
982
|
}
|
|
796
983
|
resumeRecovery(request) {
|
|
797
984
|
return this.run(async (client) => this.recoveryProgress(await client.resumeHandleRecovery(request)));
|
|
798
985
|
}
|
|
799
|
-
issueRecoveryAttestation(request) {
|
|
800
|
-
return this.run(async (client) => {
|
|
801
|
-
const value = await client.issueHandleRecoveryAttestation(request);
|
|
802
|
-
return {
|
|
803
|
-
attestation: required(value.attestation),
|
|
804
|
-
expiresAt: required(value.expiresAt)
|
|
805
|
-
};
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
986
|
discardRecovery(request) {
|
|
809
987
|
return this.run(async (client) => {
|
|
810
988
|
await client.discardHandleRecovery(request);
|
|
@@ -848,6 +1026,7 @@ var RustSdkAdapter = class {
|
|
|
848
1026
|
});
|
|
849
1027
|
const peers = [...new Set(value.items.flatMap((member) => member.did ?? member.handle ?? []))];
|
|
850
1028
|
const profiles = peers.length === 0 ? [] : await client.hydrateDisplayProfiles({ peers });
|
|
1029
|
+
this.scheduleDisplayRefresh(client, peers);
|
|
851
1030
|
const byPeer = /* @__PURE__ */ new Map();
|
|
852
1031
|
for (const [index, profile] of profiles.entries()) {
|
|
853
1032
|
const requested = peers[index];
|
|
@@ -1012,6 +1191,16 @@ var RustSdkAdapter = class {
|
|
|
1012
1191
|
clearLocalData() {
|
|
1013
1192
|
return this.run((client) => client.clearLocalData());
|
|
1014
1193
|
}
|
|
1194
|
+
retireDefaultIdentityForRejoin() {
|
|
1195
|
+
return this.run((client) => {
|
|
1196
|
+
const retire = client.retireDefaultIdentityForRejoin;
|
|
1197
|
+
if (typeof retire !== "function") throw Object.assign(/* @__PURE__ */ new Error("device rejoin is unavailable in this IM Core build"), {
|
|
1198
|
+
name: "AwikiSdkError",
|
|
1199
|
+
code: "remote"
|
|
1200
|
+
});
|
|
1201
|
+
return retire.call(client);
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1015
1204
|
dispose() {
|
|
1016
1205
|
this.disposal ??= this.client.then(async (client) => {
|
|
1017
1206
|
try {
|
|
@@ -1035,4 +1224,4 @@ function downloadedAttachment(value) {
|
|
|
1035
1224
|
};
|
|
1036
1225
|
}
|
|
1037
1226
|
//#endregion
|
|
1038
|
-
export {
|
|
1227
|
+
export { fencedMailRecoveryObservability as a, failedMailRecoveryObservability as i, RustSdkAdapter as n, successfulMailRecoveryObservability as o, downloadedAttachment as r, AwikiSdkError as t };
|