@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/react.js
CHANGED
|
@@ -4,13 +4,18 @@ var react = require('react');
|
|
|
4
4
|
var sqliteProxy = require('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
|
|
|
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/cjs_shims.js
|
|
12
17
|
var init_cjs_shims = __esm({
|
|
13
|
-
"node_modules/.pnpm/tsup@
|
|
18
|
+
"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/cjs_shims.js"() {
|
|
14
19
|
}
|
|
15
20
|
});
|
|
16
21
|
|
|
@@ -450,6 +455,10 @@ var NOTIFICATION_EVENTS = {
|
|
|
450
455
|
/** A click on one of this extension's notifications (body or action button). */
|
|
451
456
|
CLICK: "haextension:notification:click"
|
|
452
457
|
};
|
|
458
|
+
var MODEL_JOB_EVENTS = {
|
|
459
|
+
/** A job of this frame ended: completed, failed or cancelled. */
|
|
460
|
+
COMPLETED: "haextension:model-job:completed"
|
|
461
|
+
};
|
|
453
462
|
var EXTERNAL_EVENTS = {
|
|
454
463
|
/** External request from authorized client */
|
|
455
464
|
REQUEST: "haextension:external:request",
|
|
@@ -776,6 +785,17 @@ var CONTACT_COMMANDS = {
|
|
|
776
785
|
photo: "extension_contacts_photo"
|
|
777
786
|
};
|
|
778
787
|
|
|
788
|
+
// src/commands/models.ts
|
|
789
|
+
init_cjs_shims();
|
|
790
|
+
var MODEL_COMMANDS = {
|
|
791
|
+
/** The models the user allowed to this extension, without addresses or keys */
|
|
792
|
+
list: "extension_model_list",
|
|
793
|
+
/** Starts a job; the result follows as an event */
|
|
794
|
+
start: "extension_model_job_start",
|
|
795
|
+
/** Cancels a running job of this frame */
|
|
796
|
+
cancel: "extension_model_job_cancel"
|
|
797
|
+
};
|
|
798
|
+
|
|
779
799
|
// src/commands/mail.ts
|
|
780
800
|
init_cjs_shims();
|
|
781
801
|
var MAIL_COMMANDS = {
|
|
@@ -787,6 +807,12 @@ var MAIL_COMMANDS = {
|
|
|
787
807
|
fetchMessage: "extension_mail_fetch_message",
|
|
788
808
|
/** Fetch a single attachment's bytes (base64) by part index */
|
|
789
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",
|
|
790
816
|
/** Set or unset IMAP flags on a UID set */
|
|
791
817
|
setFlags: "extension_mail_set_flags",
|
|
792
818
|
/** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
|
|
@@ -1975,6 +2001,69 @@ var ContactsAPI = class {
|
|
|
1975
2001
|
}
|
|
1976
2002
|
};
|
|
1977
2003
|
|
|
2004
|
+
// src/api/models.ts
|
|
2005
|
+
init_cjs_shims();
|
|
2006
|
+
var ModelsAPI = class {
|
|
2007
|
+
constructor(client) {
|
|
2008
|
+
this.client = client;
|
|
2009
|
+
}
|
|
2010
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
2011
|
+
async listAsync() {
|
|
2012
|
+
const answer = await this.client.request(
|
|
2013
|
+
MODEL_COMMANDS.list,
|
|
2014
|
+
{}
|
|
2015
|
+
);
|
|
2016
|
+
return answer.models;
|
|
2017
|
+
}
|
|
2018
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
2019
|
+
async startAsync(job) {
|
|
2020
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
2021
|
+
job
|
|
2022
|
+
});
|
|
2023
|
+
return { jobId: answer.jobId };
|
|
2024
|
+
}
|
|
2025
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
2026
|
+
async cancelAsync(jobId) {
|
|
2027
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
2028
|
+
jobId
|
|
2029
|
+
});
|
|
2030
|
+
return answer.cancelled;
|
|
2031
|
+
}
|
|
2032
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
2033
|
+
onCompleted(handler) {
|
|
2034
|
+
const wrapped = (event) => {
|
|
2035
|
+
const data = event.data;
|
|
2036
|
+
if (data) handler(data);
|
|
2037
|
+
};
|
|
2038
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2039
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
2043
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2044
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2045
|
+
* until then.
|
|
2046
|
+
*/
|
|
2047
|
+
async runAsync(job) {
|
|
2048
|
+
const ended = /* @__PURE__ */ new Map();
|
|
2049
|
+
let waiting = null;
|
|
2050
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
2051
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2052
|
+
else ended.set(completion.jobId, completion);
|
|
2053
|
+
});
|
|
2054
|
+
try {
|
|
2055
|
+
const { jobId } = await this.startAsync(job);
|
|
2056
|
+
return await new Promise((resolve) => {
|
|
2057
|
+
const early = ended.get(jobId);
|
|
2058
|
+
if (early) resolve(early);
|
|
2059
|
+
else waiting = { jobId, resolve };
|
|
2060
|
+
});
|
|
2061
|
+
} finally {
|
|
2062
|
+
unsubscribe();
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
|
|
1978
2067
|
// src/api/mail.ts
|
|
1979
2068
|
init_cjs_shims();
|
|
1980
2069
|
var MailAPI = class {
|
|
@@ -2025,6 +2114,45 @@ var MailAPI = class {
|
|
|
2025
2114
|
partIndex
|
|
2026
2115
|
});
|
|
2027
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
|
+
}
|
|
2028
2156
|
/**
|
|
2029
2157
|
* Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
|
|
2030
2158
|
* mark messages as read; `add=false` removes the flag(s).
|
|
@@ -2931,6 +3059,7 @@ var AI_COMMANDS = {
|
|
|
2931
3059
|
init_cjs_shims();
|
|
2932
3060
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2933
3061
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3062
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2934
3063
|
function permissionKey(resourceType, action, target) {
|
|
2935
3064
|
return `${resourceType}:${action}:${target}`;
|
|
2936
3065
|
}
|
|
@@ -2966,14 +3095,18 @@ function toDeniedError(error) {
|
|
|
2966
3095
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2967
3096
|
}
|
|
2968
3097
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3098
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2969
3099
|
for (let attempt = 0; ; attempt++) {
|
|
2970
3100
|
try {
|
|
2971
3101
|
return await send();
|
|
2972
3102
|
} catch (error) {
|
|
2973
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3103
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2974
3104
|
throw error;
|
|
2975
3105
|
}
|
|
2976
3106
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
3107
|
+
const times = asked.get(key) ?? 0;
|
|
3108
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
3109
|
+
asked.set(key, times + 1);
|
|
2977
3110
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2978
3111
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2979
3112
|
if (outcome === "granted") {
|
|
@@ -3042,6 +3175,7 @@ var HaexVaultSdk = class {
|
|
|
3042
3175
|
this.shell = new ShellAPI(this);
|
|
3043
3176
|
this.passwords = new PasswordsAPI(this);
|
|
3044
3177
|
this.contacts = new ContactsAPI(this);
|
|
3178
|
+
this.models = new ModelsAPI(this);
|
|
3045
3179
|
this.mail = new MailAPI(this);
|
|
3046
3180
|
this.notifications = new NotificationsAPI(this);
|
|
3047
3181
|
this.tab = new TabAPI(this);
|