@haex-space/vault-sdk 4.5.0 → 4.6.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-CcNhK76M.d.mts} +131 -2
- package/dist/{client-D4VYF0bP.d.mts → client-DIvNHfx-.d.ts} +131 -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 +32 -7
- package/dist/index.d.ts +32 -7
- package/dist/index.js +98 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -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 +94 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +93 -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 +83 -1
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +83 -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 +94 -5
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +93 -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 +94 -5
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +93 -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 = {
|
|
@@ -1973,6 +1993,69 @@ var ContactsAPI = class {
|
|
|
1973
1993
|
}
|
|
1974
1994
|
};
|
|
1975
1995
|
|
|
1996
|
+
// src/api/models.ts
|
|
1997
|
+
init_esm_shims();
|
|
1998
|
+
var ModelsAPI = class {
|
|
1999
|
+
constructor(client) {
|
|
2000
|
+
this.client = client;
|
|
2001
|
+
}
|
|
2002
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
2003
|
+
async listAsync() {
|
|
2004
|
+
const answer = await this.client.request(
|
|
2005
|
+
MODEL_COMMANDS.list,
|
|
2006
|
+
{}
|
|
2007
|
+
);
|
|
2008
|
+
return answer.models;
|
|
2009
|
+
}
|
|
2010
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
2011
|
+
async startAsync(job) {
|
|
2012
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
2013
|
+
job
|
|
2014
|
+
});
|
|
2015
|
+
return { jobId: answer.jobId };
|
|
2016
|
+
}
|
|
2017
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
2018
|
+
async cancelAsync(jobId) {
|
|
2019
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
2020
|
+
jobId
|
|
2021
|
+
});
|
|
2022
|
+
return answer.cancelled;
|
|
2023
|
+
}
|
|
2024
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
2025
|
+
onCompleted(handler) {
|
|
2026
|
+
const wrapped = (event) => {
|
|
2027
|
+
const data = event.data;
|
|
2028
|
+
if (data) handler(data);
|
|
2029
|
+
};
|
|
2030
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2031
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
2035
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2036
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2037
|
+
* until then.
|
|
2038
|
+
*/
|
|
2039
|
+
async runAsync(job) {
|
|
2040
|
+
const ended = /* @__PURE__ */ new Map();
|
|
2041
|
+
let waiting = null;
|
|
2042
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
2043
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2044
|
+
else ended.set(completion.jobId, completion);
|
|
2045
|
+
});
|
|
2046
|
+
try {
|
|
2047
|
+
const { jobId } = await this.startAsync(job);
|
|
2048
|
+
return await new Promise((resolve) => {
|
|
2049
|
+
const early = ended.get(jobId);
|
|
2050
|
+
if (early) resolve(early);
|
|
2051
|
+
else waiting = { jobId, resolve };
|
|
2052
|
+
});
|
|
2053
|
+
} finally {
|
|
2054
|
+
unsubscribe();
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
|
|
1976
2059
|
// src/api/mail.ts
|
|
1977
2060
|
init_esm_shims();
|
|
1978
2061
|
var MailAPI = class {
|
|
@@ -2929,6 +3012,7 @@ var AI_COMMANDS = {
|
|
|
2929
3012
|
init_esm_shims();
|
|
2930
3013
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2931
3014
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3015
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2932
3016
|
function permissionKey(resourceType, action, target) {
|
|
2933
3017
|
return `${resourceType}:${action}:${target}`;
|
|
2934
3018
|
}
|
|
@@ -2964,14 +3048,18 @@ function toDeniedError(error) {
|
|
|
2964
3048
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2965
3049
|
}
|
|
2966
3050
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3051
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2967
3052
|
for (let attempt = 0; ; attempt++) {
|
|
2968
3053
|
try {
|
|
2969
3054
|
return await send();
|
|
2970
3055
|
} catch (error) {
|
|
2971
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3056
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2972
3057
|
throw error;
|
|
2973
3058
|
}
|
|
2974
3059
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
3060
|
+
const times = asked.get(key) ?? 0;
|
|
3061
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
3062
|
+
asked.set(key, times + 1);
|
|
2975
3063
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2976
3064
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2977
3065
|
if (outcome === "granted") {
|
|
@@ -3040,6 +3128,7 @@ var HaexVaultSdk = class {
|
|
|
3040
3128
|
this.shell = new ShellAPI(this);
|
|
3041
3129
|
this.passwords = new PasswordsAPI(this);
|
|
3042
3130
|
this.contacts = new ContactsAPI(this);
|
|
3131
|
+
this.models = new ModelsAPI(this);
|
|
3043
3132
|
this.mail = new MailAPI(this);
|
|
3044
3133
|
this.notifications = new NotificationsAPI(this);
|
|
3045
3134
|
this.tab = new TabAPI(this);
|