@haex-space/vault-sdk 4.5.0 → 4.7.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/README.md +40 -0
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{client-Dw2uH1EM.d.ts → client-DS-j-fHu.d.mts} +179 -2
- package/dist/{client-D4VYF0bP.d.mts → client-DkVe1o-u.d.ts} +179 -2
- package/dist/{config-D_HXjsEV.d.mts → config-P_6DqTHl.d.mts} +2 -1
- package/dist/{config-D_HXjsEV.d.ts → config-P_6DqTHl.d.ts} +2 -1
- package/dist/index.d.mts +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +143 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -5
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +4 -3
- package/dist/node.d.ts +4 -3
- package/dist/node.mjs +1 -1
- package/dist/node.mjs.map +1 -1
- package/dist/nuxt.d.mts +2 -1
- package/dist/nuxt.d.ts +2 -1
- package/dist/nuxt.js +1 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/react.d.mts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +139 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +138 -4
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +4 -3
- package/dist/runtime/nuxt.plugin.client.d.ts +4 -3
- package/dist/runtime/nuxt.plugin.client.js +128 -1
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +128 -1
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +3 -2
- package/dist/svelte.d.ts +3 -2
- package/dist/svelte.js +139 -5
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +138 -4
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-CYuW3glJ.d.mts → types-snPkjDCj.d.mts} +10 -1
- package/dist/{types-CYuW3glJ.d.ts → types-snPkjDCj.d.ts} +10 -1
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vue.d.mts +3 -2
- package/dist/vue.d.ts +3 -2
- package/dist/vue.js +139 -5
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +138 -4
- package/dist/vue.mjs.map +1 -1
- package/package.json +3 -3
package/dist/svelte.mjs
CHANGED
|
@@ -4,11 +4,16 @@ import { writable, readonly } from 'svelte/store';
|
|
|
4
4
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
5
5
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __esm = (fn, res) => function __init() {
|
|
8
|
-
|
|
7
|
+
var __esm = (fn, res, err) => function __init() {
|
|
8
|
+
if (err) throw err[0];
|
|
9
|
+
try {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw err = [e], e;
|
|
13
|
+
}
|
|
9
14
|
};
|
|
10
15
|
var init_esm_shims = __esm({
|
|
11
|
-
"node_modules/.pnpm/tsup@
|
|
16
|
+
"node_modules/.pnpm/tsup@9.0.0_jiti@2.7.0_postcss@8.5.31_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
12
17
|
}
|
|
13
18
|
});
|
|
14
19
|
|
|
@@ -448,6 +453,10 @@ var NOTIFICATION_EVENTS = {
|
|
|
448
453
|
/** A click on one of this extension's notifications (body or action button). */
|
|
449
454
|
CLICK: "haextension:notification:click"
|
|
450
455
|
};
|
|
456
|
+
var MODEL_JOB_EVENTS = {
|
|
457
|
+
/** A job of this frame ended: completed, failed or cancelled. */
|
|
458
|
+
COMPLETED: "haextension:model-job:completed"
|
|
459
|
+
};
|
|
451
460
|
var EXTERNAL_EVENTS = {
|
|
452
461
|
/** External request from authorized client */
|
|
453
462
|
REQUEST: "haextension:external:request",
|
|
@@ -774,6 +783,17 @@ var CONTACT_COMMANDS = {
|
|
|
774
783
|
photo: "extension_contacts_photo"
|
|
775
784
|
};
|
|
776
785
|
|
|
786
|
+
// src/commands/models.ts
|
|
787
|
+
init_esm_shims();
|
|
788
|
+
var MODEL_COMMANDS = {
|
|
789
|
+
/** The models the user allowed to this extension, without addresses or keys */
|
|
790
|
+
list: "extension_model_list",
|
|
791
|
+
/** Starts a job; the result follows as an event */
|
|
792
|
+
start: "extension_model_job_start",
|
|
793
|
+
/** Cancels a running job of this frame */
|
|
794
|
+
cancel: "extension_model_job_cancel"
|
|
795
|
+
};
|
|
796
|
+
|
|
777
797
|
// src/commands/mail.ts
|
|
778
798
|
init_esm_shims();
|
|
779
799
|
var MAIL_COMMANDS = {
|
|
@@ -785,6 +805,12 @@ var MAIL_COMMANDS = {
|
|
|
785
805
|
fetchMessage: "extension_mail_fetch_message",
|
|
786
806
|
/** Fetch a single attachment's bytes (base64) by part index */
|
|
787
807
|
fetchAttachment: "extension_mail_fetch_attachment",
|
|
808
|
+
/** Search a mailbox on the server by criteria; answers UIDs, newest first */
|
|
809
|
+
search: "extension_mail_search",
|
|
810
|
+
/** CREATE a mailbox (reports whether it was already there) */
|
|
811
|
+
createMailbox: "extension_mail_create_mailbox",
|
|
812
|
+
/** Delete messages for good: `\Deleted` plus UID EXPUNGE of exactly those UIDs */
|
|
813
|
+
deleteMessages: "extension_mail_delete_messages",
|
|
788
814
|
/** Set or unset IMAP flags on a UID set */
|
|
789
815
|
setFlags: "extension_mail_set_flags",
|
|
790
816
|
/** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
|
|
@@ -1973,6 +1999,69 @@ var ContactsAPI = class {
|
|
|
1973
1999
|
}
|
|
1974
2000
|
};
|
|
1975
2001
|
|
|
2002
|
+
// src/api/models.ts
|
|
2003
|
+
init_esm_shims();
|
|
2004
|
+
var ModelsAPI = class {
|
|
2005
|
+
constructor(client) {
|
|
2006
|
+
this.client = client;
|
|
2007
|
+
}
|
|
2008
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
2009
|
+
async listAsync() {
|
|
2010
|
+
const answer = await this.client.request(
|
|
2011
|
+
MODEL_COMMANDS.list,
|
|
2012
|
+
{}
|
|
2013
|
+
);
|
|
2014
|
+
return answer.models;
|
|
2015
|
+
}
|
|
2016
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
2017
|
+
async startAsync(job) {
|
|
2018
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
2019
|
+
job
|
|
2020
|
+
});
|
|
2021
|
+
return { jobId: answer.jobId };
|
|
2022
|
+
}
|
|
2023
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
2024
|
+
async cancelAsync(jobId) {
|
|
2025
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
2026
|
+
jobId
|
|
2027
|
+
});
|
|
2028
|
+
return answer.cancelled;
|
|
2029
|
+
}
|
|
2030
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
2031
|
+
onCompleted(handler) {
|
|
2032
|
+
const wrapped = (event) => {
|
|
2033
|
+
const data = event.data;
|
|
2034
|
+
if (data) handler(data);
|
|
2035
|
+
};
|
|
2036
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2037
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
2041
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2042
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2043
|
+
* until then.
|
|
2044
|
+
*/
|
|
2045
|
+
async runAsync(job) {
|
|
2046
|
+
const ended = /* @__PURE__ */ new Map();
|
|
2047
|
+
let waiting = null;
|
|
2048
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
2049
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2050
|
+
else ended.set(completion.jobId, completion);
|
|
2051
|
+
});
|
|
2052
|
+
try {
|
|
2053
|
+
const { jobId } = await this.startAsync(job);
|
|
2054
|
+
return await new Promise((resolve) => {
|
|
2055
|
+
const early = ended.get(jobId);
|
|
2056
|
+
if (early) resolve(early);
|
|
2057
|
+
else waiting = { jobId, resolve };
|
|
2058
|
+
});
|
|
2059
|
+
} finally {
|
|
2060
|
+
unsubscribe();
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
};
|
|
2064
|
+
|
|
1976
2065
|
// src/api/mail.ts
|
|
1977
2066
|
init_esm_shims();
|
|
1978
2067
|
var MailAPI = class {
|
|
@@ -2023,6 +2112,45 @@ var MailAPI = class {
|
|
|
2023
2112
|
partIndex
|
|
2024
2113
|
});
|
|
2025
2114
|
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Search a whole mailbox on the server. Answers the UIDs of the newest `limit` hits (1 to 1000;
|
|
2117
|
+
* all that fit one answer when omitted), newest first, and the number of all hits. Fetch their
|
|
2118
|
+
* envelopes with `fetchEnvelopesAsync` and a `uidList` range.
|
|
2119
|
+
*/
|
|
2120
|
+
async searchMessagesAsync(imap, mailbox, criteria, limit) {
|
|
2121
|
+
return this.client.request(MAIL_COMMANDS.search, {
|
|
2122
|
+
imap,
|
|
2123
|
+
mailbox,
|
|
2124
|
+
criteria,
|
|
2125
|
+
limit
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Create a mailbox. Resolves to `false`, not an error, when it already existed. The name may
|
|
2130
|
+
* contain the server's hierarchy delimiter; `*` and `%` are not allowed.
|
|
2131
|
+
*/
|
|
2132
|
+
async createMailboxAsync(imap, mailbox) {
|
|
2133
|
+
const { created } = await this.client.request(
|
|
2134
|
+
MAIL_COMMANDS.createMailbox,
|
|
2135
|
+
{ imap, mailbox }
|
|
2136
|
+
);
|
|
2137
|
+
return created;
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Delete messages for good: flags exactly these UIDs `\Deleted` and expunges exactly them, so
|
|
2141
|
+
* other messages marked `\Deleted` stay. Refused with an error on a server without UIDPLUS,
|
|
2142
|
+
* before anything is marked. If the expunge fails after marking, the messages stay in the
|
|
2143
|
+
* mailbox flagged `\Deleted` and the call rejects; do not show them as deleted. At most 1000 UIDs
|
|
2144
|
+
* per call. For a message that can still be recovered, use `moveMessagesAsync` into the trash
|
|
2145
|
+
* instead.
|
|
2146
|
+
*/
|
|
2147
|
+
async deleteMessagesAsync(imap, mailbox, uids) {
|
|
2148
|
+
return this.client.request(MAIL_COMMANDS.deleteMessages, {
|
|
2149
|
+
imap,
|
|
2150
|
+
mailbox,
|
|
2151
|
+
uids
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2026
2154
|
/**
|
|
2027
2155
|
* Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
|
|
2028
2156
|
* mark messages as read; `add=false` removes the flag(s).
|
|
@@ -2929,6 +3057,7 @@ var AI_COMMANDS = {
|
|
|
2929
3057
|
init_esm_shims();
|
|
2930
3058
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2931
3059
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3060
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2932
3061
|
function permissionKey(resourceType, action, target) {
|
|
2933
3062
|
return `${resourceType}:${action}:${target}`;
|
|
2934
3063
|
}
|
|
@@ -2964,14 +3093,18 @@ function toDeniedError(error) {
|
|
|
2964
3093
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2965
3094
|
}
|
|
2966
3095
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3096
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2967
3097
|
for (let attempt = 0; ; attempt++) {
|
|
2968
3098
|
try {
|
|
2969
3099
|
return await send();
|
|
2970
3100
|
} catch (error) {
|
|
2971
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3101
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2972
3102
|
throw error;
|
|
2973
3103
|
}
|
|
2974
3104
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
3105
|
+
const times = asked.get(key) ?? 0;
|
|
3106
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
3107
|
+
asked.set(key, times + 1);
|
|
2975
3108
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2976
3109
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2977
3110
|
if (outcome === "granted") {
|
|
@@ -3040,6 +3173,7 @@ var HaexVaultSdk = class {
|
|
|
3040
3173
|
this.shell = new ShellAPI(this);
|
|
3041
3174
|
this.passwords = new PasswordsAPI(this);
|
|
3042
3175
|
this.contacts = new ContactsAPI(this);
|
|
3176
|
+
this.models = new ModelsAPI(this);
|
|
3043
3177
|
this.mail = new MailAPI(this);
|
|
3044
3178
|
this.notifications = new NotificationsAPI(this);
|
|
3045
3179
|
this.tab = new TabAPI(this);
|