@arbidocs/client 0.4.49 → 0.4.50
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/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -7
- package/dist/index.d.ts +186 -7
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1085,7 +1085,9 @@ function passwordChangeErrorMessage(err) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
async function reEncryptDirectMessages(fetchClient, userExtId, oldSecretKey, newSecretKey) {
|
|
1087
1087
|
const { data } = await fetchClient.GET("/v1/notifications/");
|
|
1088
|
-
const messages = (data ?? []).filter(
|
|
1088
|
+
const messages = (data ?? []).filter(
|
|
1089
|
+
(n) => n.type === "user_message" && (n.content || n.attachments)
|
|
1090
|
+
);
|
|
1089
1091
|
const oldSecrets = {};
|
|
1090
1092
|
const newSecrets = {};
|
|
1091
1093
|
const updates = [];
|
|
@@ -1095,10 +1097,16 @@ async function reEncryptDirectMessages(fetchClient, userExtId, oldSecretKey, new
|
|
|
1095
1097
|
const id = other.external_id;
|
|
1096
1098
|
oldSecrets[id] ??= await computeSharedSecret(other.encryption_public_key, oldSecretKey);
|
|
1097
1099
|
newSecrets[id] ??= await computeSharedSecret(other.encryption_public_key, newSecretKey);
|
|
1098
|
-
const
|
|
1100
|
+
const reEncrypt = async (ciphertext) => encryptMessageWithSharedSecret(
|
|
1101
|
+
await decryptMessageWithSharedSecret(ciphertext, oldSecrets[id]),
|
|
1102
|
+
newSecrets[id]
|
|
1103
|
+
);
|
|
1104
|
+
const content = n.content ? await reEncrypt(n.content) : void 0;
|
|
1105
|
+
const attachments = n.attachments ? await reEncrypt(n.attachments) : void 0;
|
|
1099
1106
|
updates.push({
|
|
1100
1107
|
external_id: n.external_id,
|
|
1101
|
-
content:
|
|
1108
|
+
...content !== void 0 ? { content } : {},
|
|
1109
|
+
...attachments !== void 0 ? { attachments } : {}
|
|
1102
1110
|
});
|
|
1103
1111
|
} catch {
|
|
1104
1112
|
}
|