@glyphteck/veyl 0.50.0 → 0.51.0

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/account.js CHANGED
@@ -7985,6 +7985,7 @@ async function openVaultAccountSession(vault, password, options = {}) {
7985
7985
  onSettingsUnlocked,
7986
7986
  onSeedDecrypted,
7987
7987
  onStage,
7988
+ masterSeed: suppliedMasterSeed = null,
7988
7989
  isCurrent = () => true,
7989
7990
  diag = null
7990
7991
  } = options;
@@ -8051,10 +8052,17 @@ async function openVaultAccountSession(vault, password, options = {}) {
8051
8052
  onStage?.("decrypting");
8052
8053
  const decryptStartedAt = Date.now();
8053
8054
  mark(diag, "vault.unlock.decrypt.start", { source });
8054
- try {
8055
- masterSeed = await decryptSeed(ct, salt, iv, normalizePassword(password), kdf);
8056
- } catch (error) {
8057
- throw vaultPasswordError(error);
8055
+ if (suppliedMasterSeed) {
8056
+ if (!(suppliedMasterSeed instanceof Uint8Array) || suppliedMasterSeed.length !== 32) {
8057
+ throw new Error("vault master seed required");
8058
+ }
8059
+ masterSeed = suppliedMasterSeed.slice();
8060
+ } else {
8061
+ try {
8062
+ masterSeed = await decryptSeed(ct, salt, iv, normalizePassword(password), kdf);
8063
+ } catch (error) {
8064
+ throw vaultPasswordError(error);
8065
+ }
8058
8066
  }
8059
8067
  mark(diag, "vault.unlock.decrypt.done", { elapsedMs: Date.now() - decryptStartedAt, source });
8060
8068
  onStage?.("seed-decrypted");
@@ -12959,6 +12967,16 @@ function createChatDelete({
12959
12967
  }
12960
12968
  return [...byId.values()];
12961
12969
  };
12970
+ const revokeTargetDeliveries = async (targets) => {
12971
+ const capabilities = targets.filter((target) => target.deliveryRegistered && target.linkId && target.peerChatPK && chatPK && notificationPrivateKey).map((target) => deriveInboundDeliveryCapability(notificationPrivateKey, {
12972
+ linkId: target.linkId,
12973
+ chatId: target.chatId,
12974
+ selfChatPK: chatPK,
12975
+ peerChatPK: target.peerChatPK
12976
+ }));
12977
+ await Promise.all(capabilities.map((capability) => cloud.delivery.revoke(capability)));
12978
+ return capabilities.length;
12979
+ };
12962
12980
  const deleteChat = async (chat, options = {}) => {
12963
12981
  const targets = getDeleteTargets(chat);
12964
12982
  if (!targets.length)
@@ -12972,13 +12990,8 @@ function createChatDelete({
12972
12990
  try {
12973
12991
  hideDeletingChats(chatIds, options);
12974
12992
  try {
12975
- const capabilities = targets.filter((target) => target.deliveryRegistered && target.linkId && target.peerChatPK && chatPK && notificationPrivateKey).map((target) => deriveInboundDeliveryCapability(notificationPrivateKey, {
12976
- linkId: target.linkId,
12977
- chatId: target.chatId,
12978
- selfChatPK: chatPK,
12979
- peerChatPK: target.peerChatPK
12980
- }));
12981
- await Promise.all(capabilities.map((capability) => cloud.delivery.revoke(capability)));
12993
+ await revokeTargetDeliveries(targets);
12994
+ await options.onDeliveryRevoked?.();
12982
12995
  await cloud.chat.delete(targets, { cleanup: options.cleanup !== false });
12983
12996
  confirmDeletedChats(chatIds);
12984
12997
  } catch (error) {
@@ -20852,16 +20865,18 @@ function createChatSession({
20852
20865
  const dropChat = (...args) => deleteActions.dropChat(...args);
20853
20866
  const dropUnavailableChat = (...args) => deleteActions.dropUnavailableChat(...args);
20854
20867
  const deleteChat = (...args) => deleteActions.deleteChat(...args);
20855
- const retirePeerChat = async (peerChatPK) => {
20868
+ const retirePeerChat = async (peerChatPK, options = {}) => {
20856
20869
  const sendOptions = sendOptionsForPeer(peerChatPK);
20857
- if (!sendOptions?.chatId)
20870
+ if (!sendOptions?.chatId) {
20871
+ await options.onDeliveryRevoked?.();
20858
20872
  return false;
20873
+ }
20859
20874
  const chat = sendOptions.ownEntry || getChatEntry(sendOptions.chatId) || {
20860
20875
  id: sendOptions.chatId,
20861
20876
  linkId: sendOptions.linkId,
20862
20877
  peerChatPK
20863
20878
  };
20864
- return deleteChat(chat, { cleanup: false });
20879
+ return deleteChat(chat, { ...options, cleanup: false });
20865
20880
  };
20866
20881
  const restoreDeletedChat = (...args) => deleteActions.restoreDeletedChat(...args);
20867
20882
  const wasChatDeletedLocally = (...args) => deleteActions.wasChatDeletedLocally(...args);
@@ -23219,11 +23234,13 @@ function getReportAttachmentMeta(msg) {
23219
23234
  mimeType: cleanText(msg?.m) || reportAttachmentMime(kind)
23220
23235
  };
23221
23236
  }
23222
- function buildReportFields({ msg, note } = {}) {
23237
+ function buildReportFields({ msg, note, chatId } = {}) {
23223
23238
  const type = cleanText(msg?.t);
23224
23239
  const content = type === "txt" ? cleanText(msg?.c) : "";
23225
23240
  const cleanedNote = cleanText(note);
23226
23241
  const report = {};
23242
+ const sourceChatId = cleanText(chatId);
23243
+ const sourceMessageId = cleanText(msg?.cid) || cleanText(msg?.actionId) || cleanText(msg?.id);
23227
23244
  if (type) {
23228
23245
  report.type = type;
23229
23246
  }
@@ -23233,6 +23250,13 @@ function buildReportFields({ msg, note } = {}) {
23233
23250
  if (cleanedNote) {
23234
23251
  report.note = cleanedNote;
23235
23252
  }
23253
+ if (type) {
23254
+ if (!sourceChatId || !sourceMessageId) {
23255
+ throw new Error("message report source required");
23256
+ }
23257
+ report.chatId = sourceChatId;
23258
+ report.messageId = sourceMessageId;
23259
+ }
23236
23260
  return report;
23237
23261
  }
23238
23262
 
@@ -23330,7 +23354,7 @@ function openSupport({ cloud, getUid } = {}) {
23330
23354
  }
23331
23355
  await cloud.reports.submit({
23332
23356
  uid,
23333
- ...buildReportFields({ msg: message, note: options.note }),
23357
+ ...buildReportFields({ msg: message, note: options.note, chatId: options.chatId }),
23334
23358
  ...path ? { path } : {}
23335
23359
  });
23336
23360
  return { submitted: true, attachmentIncluded: !!path };
@@ -29343,6 +29367,7 @@ function openAccount(options = {}) {
29343
29367
  },
29344
29368
  onSeedDecrypted: unlockOptions.onSeedDecrypted,
29345
29369
  onStage: (stage) => setStage(stage, unlockOptions.onStage),
29370
+ masterSeed: unlockOptions.masterSeed,
29346
29371
  isCurrent,
29347
29372
  diag
29348
29373
  });