@haex-space/vault-sdk 4.6.0 → 4.7.1

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.
@@ -212,6 +212,8 @@ interface PermissionErrorBase {
212
212
  resourceType: string;
213
213
  target: string;
214
214
  action: string;
215
+ /** holzi names the permission here: `resourceType`, `action` and `target`. */
216
+ details?: Record<string, unknown>;
215
217
  }
216
218
  /**
217
219
  * Error returned by haex-vault when a permission has been denied.
@@ -212,6 +212,8 @@ interface PermissionErrorBase {
212
212
  resourceType: string;
213
213
  target: string;
214
214
  action: string;
215
+ /** holzi names the permission here: `resourceType`, `action` and `target`. */
216
+ details?: Record<string, unknown>;
215
217
  }
216
218
  /**
217
219
  * Error returned by haex-vault when a permission has been denied.
package/dist/vue.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client-CcNhK76M.mjs';
1
+ import { S as StorageAPI } from './client-BlUizM-l.mjs';
2
2
  import { HaexVaultSdk } from './index.mjs';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { Ref } from 'vue';
package/dist/vue.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client-DIvNHfx-.js';
1
+ import { S as StorageAPI } from './client--CgEtJ4G.js';
2
2
  import { HaexVaultSdk } from './index.js';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { Ref } from 'vue';
package/dist/vue.js CHANGED
@@ -807,6 +807,12 @@ var MAIL_COMMANDS = {
807
807
  fetchMessage: "extension_mail_fetch_message",
808
808
  /** Fetch a single attachment's bytes (base64) by part index */
809
809
  fetchAttachment: "extension_mail_fetch_attachment",
810
+ /** Search a mailbox on the server by criteria; answers UIDs, newest first */
811
+ search: "extension_mail_search",
812
+ /** CREATE a mailbox (reports whether it was already there) */
813
+ createMailbox: "extension_mail_create_mailbox",
814
+ /** Delete messages for good: `\Deleted` plus UID EXPUNGE of exactly those UIDs */
815
+ deleteMessages: "extension_mail_delete_messages",
810
816
  /** Set or unset IMAP flags on a UID set */
811
817
  setFlags: "extension_mail_set_flags",
812
818
  /** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
@@ -2108,6 +2114,45 @@ var MailAPI = class {
2108
2114
  partIndex
2109
2115
  });
2110
2116
  }
2117
+ /**
2118
+ * Search a whole mailbox on the server. Answers the UIDs of the newest `limit` hits (1 to 1000;
2119
+ * all that fit one answer when omitted), newest first, and the number of all hits. Fetch their
2120
+ * envelopes with `fetchEnvelopesAsync` and a `uidList` range.
2121
+ */
2122
+ async searchMessagesAsync(imap, mailbox, criteria, limit) {
2123
+ return this.client.request(MAIL_COMMANDS.search, {
2124
+ imap,
2125
+ mailbox,
2126
+ criteria,
2127
+ limit
2128
+ });
2129
+ }
2130
+ /**
2131
+ * Create a mailbox. Resolves to `false`, not an error, when it already existed. The name may
2132
+ * contain the server's hierarchy delimiter; `*` and `%` are not allowed.
2133
+ */
2134
+ async createMailboxAsync(imap, mailbox) {
2135
+ const { created } = await this.client.request(
2136
+ MAIL_COMMANDS.createMailbox,
2137
+ { imap, mailbox }
2138
+ );
2139
+ return created;
2140
+ }
2141
+ /**
2142
+ * Delete messages for good: flags exactly these UIDs `\Deleted` and expunges exactly them, so
2143
+ * other messages marked `\Deleted` stay. Refused with an error on a server without UIDPLUS,
2144
+ * before anything is marked. If the expunge fails after marking, the messages stay in the
2145
+ * mailbox flagged `\Deleted` and the call rejects; do not show them as deleted. At most 1000 UIDs
2146
+ * per call. For a message that can still be recovered, use `moveMessagesAsync` into the trash
2147
+ * instead.
2148
+ */
2149
+ async deleteMessagesAsync(imap, mailbox, uids) {
2150
+ return this.client.request(MAIL_COMMANDS.deleteMessages, {
2151
+ imap,
2152
+ mailbox,
2153
+ uids
2154
+ });
2155
+ }
2111
2156
  /**
2112
2157
  * Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
2113
2158
  * mark messages as read; `add=false` removes the flag(s).
@@ -3046,6 +3091,11 @@ var PermissionWaiterRegistry = class {
3046
3091
  for (const callback of [...set]) callback(decision);
3047
3092
  }
3048
3093
  };
3094
+ function promptedKey(error) {
3095
+ const details = error.details ?? {};
3096
+ const field = (name) => typeof details[name] === "string" ? details[name] : error[name];
3097
+ return permissionKey(field("resourceType"), field("action"), field("target"));
3098
+ }
3049
3099
  function toDeniedError(error) {
3050
3100
  return { ...error, code: 1002 /* DENIED */ };
3051
3101
  }
@@ -3058,7 +3108,7 @@ async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_D
3058
3108
  if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
3059
3109
  throw error;
3060
3110
  }
3061
- const key = permissionKey(error.resourceType, error.action, error.target);
3111
+ const key = promptedKey(error);
3062
3112
  const times = asked.get(key) ?? 0;
3063
3113
  if (times >= MAX_PERMISSION_RETRIES) throw error;
3064
3114
  asked.set(key, times + 1);