@haex-space/vault-sdk 4.4.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-C44dqakd.d.ts → client-CcNhK76M.d.mts} +234 -2
- package/dist/{client-BCUfRZvU.d.mts → client-DIvNHfx-.d.ts} +234 -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/haex_bundle_bg.wasm +0 -0
- package/dist/index.d.mts +59 -7
- package/dist/index.d.ts +59 -7
- package/dist/index.js +153 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -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/nuxt.mjs.map +1 -1
- package/dist/react.d.mts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +146 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +145 -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 +132 -1
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +132 -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 +146 -5
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +145 -4
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-DoNvKiW_.d.mts → types-snPkjDCj.d.mts} +15 -1
- package/dist/{types-DoNvKiW_.d.ts → types-snPkjDCj.d.ts} +15 -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 +146 -5
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +145 -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",
|
|
@@ -761,6 +770,30 @@ var PASSWORD_COMMANDS = {
|
|
|
761
770
|
delete: "extension_password_delete"
|
|
762
771
|
};
|
|
763
772
|
|
|
773
|
+
// src/commands/contacts.ts
|
|
774
|
+
init_esm_shims();
|
|
775
|
+
var CONTACT_COMMANDS = {
|
|
776
|
+
/** Contacts in scope, a page at a time, optionally of one group */
|
|
777
|
+
list: "extension_contacts_list",
|
|
778
|
+
/** One contact with all its values, by id */
|
|
779
|
+
read: "extension_contacts_read",
|
|
780
|
+
/** Contacts in scope whose name, organization, phone or e-mail matches */
|
|
781
|
+
search: "extension_contacts_search",
|
|
782
|
+
/** The JPEG of a contact's photo, by its hash */
|
|
783
|
+
photo: "extension_contacts_photo"
|
|
784
|
+
};
|
|
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
|
+
|
|
764
797
|
// src/commands/mail.ts
|
|
765
798
|
init_esm_shims();
|
|
766
799
|
var MAIL_COMMANDS = {
|
|
@@ -1922,6 +1955,107 @@ var PasswordsAPI = class {
|
|
|
1922
1955
|
}
|
|
1923
1956
|
};
|
|
1924
1957
|
|
|
1958
|
+
// src/api/contacts.ts
|
|
1959
|
+
init_esm_shims();
|
|
1960
|
+
init_vaultKey();
|
|
1961
|
+
var ContactsAPI = class {
|
|
1962
|
+
constructor(client) {
|
|
1963
|
+
this.client = client;
|
|
1964
|
+
}
|
|
1965
|
+
/** One page of the contacts in scope, optionally of one group. */
|
|
1966
|
+
async listAsync(options = {}) {
|
|
1967
|
+
return this.client.request(CONTACT_COMMANDS.list, {
|
|
1968
|
+
...options
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
/** One contact with all its values. */
|
|
1972
|
+
async readAsync(id) {
|
|
1973
|
+
return this.client.request(CONTACT_COMMANDS.read, { id });
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* The contacts in scope whose name, organization, phone number or e-mail
|
|
1977
|
+
* address contains `query`, regardless of case and accents. The host's
|
|
1978
|
+
* default limit is 20, its maximum 200.
|
|
1979
|
+
*/
|
|
1980
|
+
async searchAsync(query, limit) {
|
|
1981
|
+
const answer = await this.client.request(
|
|
1982
|
+
CONTACT_COMMANDS.search,
|
|
1983
|
+
limit === void 0 ? { query } : { query, limit }
|
|
1984
|
+
);
|
|
1985
|
+
return answer.contacts;
|
|
1986
|
+
}
|
|
1987
|
+
/** The JPEG of a photo a readable contact uses, by its hash. */
|
|
1988
|
+
async photoAsync(hash) {
|
|
1989
|
+
const base64 = await this.client.request(CONTACT_COMMANDS.photo, {
|
|
1990
|
+
hash
|
|
1991
|
+
});
|
|
1992
|
+
return base64ToArrayBuffer(base64);
|
|
1993
|
+
}
|
|
1994
|
+
};
|
|
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
|
+
|
|
1925
2059
|
// src/api/mail.ts
|
|
1926
2060
|
init_esm_shims();
|
|
1927
2061
|
var MailAPI = class {
|
|
@@ -2878,6 +3012,7 @@ var AI_COMMANDS = {
|
|
|
2878
3012
|
init_esm_shims();
|
|
2879
3013
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2880
3014
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3015
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2881
3016
|
function permissionKey(resourceType, action, target) {
|
|
2882
3017
|
return `${resourceType}:${action}:${target}`;
|
|
2883
3018
|
}
|
|
@@ -2913,14 +3048,18 @@ function toDeniedError(error) {
|
|
|
2913
3048
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2914
3049
|
}
|
|
2915
3050
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3051
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2916
3052
|
for (let attempt = 0; ; attempt++) {
|
|
2917
3053
|
try {
|
|
2918
3054
|
return await send();
|
|
2919
3055
|
} catch (error) {
|
|
2920
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3056
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2921
3057
|
throw error;
|
|
2922
3058
|
}
|
|
2923
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);
|
|
2924
3063
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2925
3064
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2926
3065
|
if (outcome === "granted") {
|
|
@@ -2988,6 +3127,8 @@ var HaexVaultSdk = class {
|
|
|
2988
3127
|
this.spaces = new SpacesAPI(this);
|
|
2989
3128
|
this.shell = new ShellAPI(this);
|
|
2990
3129
|
this.passwords = new PasswordsAPI(this);
|
|
3130
|
+
this.contacts = new ContactsAPI(this);
|
|
3131
|
+
this.models = new ModelsAPI(this);
|
|
2991
3132
|
this.mail = new MailAPI(this);
|
|
2992
3133
|
this.notifications = new NotificationsAPI(this);
|
|
2993
3134
|
this.tab = new TabAPI(this);
|