@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.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as StorageAPI } from './client-CcNhK76M.mjs';
|
|
2
|
+
import { HaexVaultSdk } from './index.mjs';
|
|
2
3
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
4
|
import { Readable } from 'svelte/store';
|
|
4
|
-
import {
|
|
5
|
+
import { ApplicationContext, ExtensionInfo, HaexHubConfig } from './index.mjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Initialize the HaexVault SDK for Svelte
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as StorageAPI } from './client-DIvNHfx-.js';
|
|
2
|
+
import { HaexVaultSdk } from './index.js';
|
|
2
3
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
4
|
import { Readable } from 'svelte/store';
|
|
4
|
-
import {
|
|
5
|
+
import { ApplicationContext, ExtensionInfo, HaexHubConfig } from './index.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Initialize the HaexVault SDK for Svelte
|
package/dist/svelte.js
CHANGED
|
@@ -4,13 +4,18 @@ var store = require('svelte/store');
|
|
|
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",
|
|
@@ -763,6 +772,30 @@ var PASSWORD_COMMANDS = {
|
|
|
763
772
|
delete: "extension_password_delete"
|
|
764
773
|
};
|
|
765
774
|
|
|
775
|
+
// src/commands/contacts.ts
|
|
776
|
+
init_cjs_shims();
|
|
777
|
+
var CONTACT_COMMANDS = {
|
|
778
|
+
/** Contacts in scope, a page at a time, optionally of one group */
|
|
779
|
+
list: "extension_contacts_list",
|
|
780
|
+
/** One contact with all its values, by id */
|
|
781
|
+
read: "extension_contacts_read",
|
|
782
|
+
/** Contacts in scope whose name, organization, phone or e-mail matches */
|
|
783
|
+
search: "extension_contacts_search",
|
|
784
|
+
/** The JPEG of a contact's photo, by its hash */
|
|
785
|
+
photo: "extension_contacts_photo"
|
|
786
|
+
};
|
|
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
|
+
|
|
766
799
|
// src/commands/mail.ts
|
|
767
800
|
init_cjs_shims();
|
|
768
801
|
var MAIL_COMMANDS = {
|
|
@@ -1924,6 +1957,107 @@ var PasswordsAPI = class {
|
|
|
1924
1957
|
}
|
|
1925
1958
|
};
|
|
1926
1959
|
|
|
1960
|
+
// src/api/contacts.ts
|
|
1961
|
+
init_cjs_shims();
|
|
1962
|
+
init_vaultKey();
|
|
1963
|
+
var ContactsAPI = class {
|
|
1964
|
+
constructor(client) {
|
|
1965
|
+
this.client = client;
|
|
1966
|
+
}
|
|
1967
|
+
/** One page of the contacts in scope, optionally of one group. */
|
|
1968
|
+
async listAsync(options = {}) {
|
|
1969
|
+
return this.client.request(CONTACT_COMMANDS.list, {
|
|
1970
|
+
...options
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
/** One contact with all its values. */
|
|
1974
|
+
async readAsync(id) {
|
|
1975
|
+
return this.client.request(CONTACT_COMMANDS.read, { id });
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* The contacts in scope whose name, organization, phone number or e-mail
|
|
1979
|
+
* address contains `query`, regardless of case and accents. The host's
|
|
1980
|
+
* default limit is 20, its maximum 200.
|
|
1981
|
+
*/
|
|
1982
|
+
async searchAsync(query, limit) {
|
|
1983
|
+
const answer = await this.client.request(
|
|
1984
|
+
CONTACT_COMMANDS.search,
|
|
1985
|
+
limit === void 0 ? { query } : { query, limit }
|
|
1986
|
+
);
|
|
1987
|
+
return answer.contacts;
|
|
1988
|
+
}
|
|
1989
|
+
/** The JPEG of a photo a readable contact uses, by its hash. */
|
|
1990
|
+
async photoAsync(hash) {
|
|
1991
|
+
const base64 = await this.client.request(CONTACT_COMMANDS.photo, {
|
|
1992
|
+
hash
|
|
1993
|
+
});
|
|
1994
|
+
return base64ToArrayBuffer(base64);
|
|
1995
|
+
}
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
// src/api/models.ts
|
|
1999
|
+
init_cjs_shims();
|
|
2000
|
+
var ModelsAPI = class {
|
|
2001
|
+
constructor(client) {
|
|
2002
|
+
this.client = client;
|
|
2003
|
+
}
|
|
2004
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
2005
|
+
async listAsync() {
|
|
2006
|
+
const answer = await this.client.request(
|
|
2007
|
+
MODEL_COMMANDS.list,
|
|
2008
|
+
{}
|
|
2009
|
+
);
|
|
2010
|
+
return answer.models;
|
|
2011
|
+
}
|
|
2012
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
2013
|
+
async startAsync(job) {
|
|
2014
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
2015
|
+
job
|
|
2016
|
+
});
|
|
2017
|
+
return { jobId: answer.jobId };
|
|
2018
|
+
}
|
|
2019
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
2020
|
+
async cancelAsync(jobId) {
|
|
2021
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
2022
|
+
jobId
|
|
2023
|
+
});
|
|
2024
|
+
return answer.cancelled;
|
|
2025
|
+
}
|
|
2026
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
2027
|
+
onCompleted(handler) {
|
|
2028
|
+
const wrapped = (event) => {
|
|
2029
|
+
const data = event.data;
|
|
2030
|
+
if (data) handler(data);
|
|
2031
|
+
};
|
|
2032
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2033
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
2036
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
2037
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2038
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2039
|
+
* until then.
|
|
2040
|
+
*/
|
|
2041
|
+
async runAsync(job) {
|
|
2042
|
+
const ended = /* @__PURE__ */ new Map();
|
|
2043
|
+
let waiting = null;
|
|
2044
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
2045
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2046
|
+
else ended.set(completion.jobId, completion);
|
|
2047
|
+
});
|
|
2048
|
+
try {
|
|
2049
|
+
const { jobId } = await this.startAsync(job);
|
|
2050
|
+
return await new Promise((resolve) => {
|
|
2051
|
+
const early = ended.get(jobId);
|
|
2052
|
+
if (early) resolve(early);
|
|
2053
|
+
else waiting = { jobId, resolve };
|
|
2054
|
+
});
|
|
2055
|
+
} finally {
|
|
2056
|
+
unsubscribe();
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
|
|
1927
2061
|
// src/api/mail.ts
|
|
1928
2062
|
init_cjs_shims();
|
|
1929
2063
|
var MailAPI = class {
|
|
@@ -2880,6 +3014,7 @@ var AI_COMMANDS = {
|
|
|
2880
3014
|
init_cjs_shims();
|
|
2881
3015
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2882
3016
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3017
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2883
3018
|
function permissionKey(resourceType, action, target) {
|
|
2884
3019
|
return `${resourceType}:${action}:${target}`;
|
|
2885
3020
|
}
|
|
@@ -2915,14 +3050,18 @@ function toDeniedError(error) {
|
|
|
2915
3050
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2916
3051
|
}
|
|
2917
3052
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3053
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2918
3054
|
for (let attempt = 0; ; attempt++) {
|
|
2919
3055
|
try {
|
|
2920
3056
|
return await send();
|
|
2921
3057
|
} catch (error) {
|
|
2922
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3058
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2923
3059
|
throw error;
|
|
2924
3060
|
}
|
|
2925
3061
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
3062
|
+
const times = asked.get(key) ?? 0;
|
|
3063
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
3064
|
+
asked.set(key, times + 1);
|
|
2926
3065
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2927
3066
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2928
3067
|
if (outcome === "granted") {
|
|
@@ -2990,6 +3129,8 @@ var HaexVaultSdk = class {
|
|
|
2990
3129
|
this.spaces = new SpacesAPI(this);
|
|
2991
3130
|
this.shell = new ShellAPI(this);
|
|
2992
3131
|
this.passwords = new PasswordsAPI(this);
|
|
3132
|
+
this.contacts = new ContactsAPI(this);
|
|
3133
|
+
this.models = new ModelsAPI(this);
|
|
2993
3134
|
this.mail = new MailAPI(this);
|
|
2994
3135
|
this.notifications = new NotificationsAPI(this);
|
|
2995
3136
|
this.tab = new TabAPI(this);
|