@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as nuxt_app from 'nuxt/app';
|
|
2
2
|
import { ShallowRef } from 'vue';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { HaexVaultSdk } from '../index.mjs';
|
|
4
|
+
import { ApplicationContext } from '../index.mjs';
|
|
5
5
|
import 'drizzle-orm/sqlite-proxy';
|
|
6
6
|
|
|
7
7
|
declare const _default: nuxt_app.Plugin<{
|
|
@@ -41,4 +41,5 @@ type HaexVaultNuxtPlugin = {
|
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export {
|
|
44
|
+
export { _default as default };
|
|
45
|
+
export type { HaexVaultNuxtPlugin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as nuxt_app from 'nuxt/app';
|
|
2
2
|
import { ShallowRef } from 'vue';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { HaexVaultSdk } from '../index.js';
|
|
4
|
+
import { ApplicationContext } from '../index.js';
|
|
5
5
|
import 'drizzle-orm/sqlite-proxy';
|
|
6
6
|
|
|
7
7
|
declare const _default: nuxt_app.Plugin<{
|
|
@@ -41,4 +41,5 @@ type HaexVaultNuxtPlugin = {
|
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export {
|
|
44
|
+
export { _default as default };
|
|
45
|
+
export type { HaexVaultNuxtPlugin };
|
|
@@ -25,6 +25,10 @@ var NOTIFICATION_EVENTS = {
|
|
|
25
25
|
/** A click on one of this extension's notifications (body or action button). */
|
|
26
26
|
CLICK: "haextension:notification:click"
|
|
27
27
|
};
|
|
28
|
+
var MODEL_JOB_EVENTS = {
|
|
29
|
+
/** A job of this frame ended: completed, failed or cancelled. */
|
|
30
|
+
COMPLETED: "haextension:model-job:completed"
|
|
31
|
+
};
|
|
28
32
|
var EXTERNAL_EVENTS = {
|
|
29
33
|
/** External request from authorized client */
|
|
30
34
|
REQUEST: "haextension:external:request",
|
|
@@ -316,6 +320,28 @@ var PASSWORD_COMMANDS = {
|
|
|
316
320
|
delete: "extension_password_delete"
|
|
317
321
|
};
|
|
318
322
|
|
|
323
|
+
// src/commands/contacts.ts
|
|
324
|
+
var CONTACT_COMMANDS = {
|
|
325
|
+
/** Contacts in scope, a page at a time, optionally of one group */
|
|
326
|
+
list: "extension_contacts_list",
|
|
327
|
+
/** One contact with all its values, by id */
|
|
328
|
+
read: "extension_contacts_read",
|
|
329
|
+
/** Contacts in scope whose name, organization, phone or e-mail matches */
|
|
330
|
+
search: "extension_contacts_search",
|
|
331
|
+
/** The JPEG of a contact's photo, by its hash */
|
|
332
|
+
photo: "extension_contacts_photo"
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/commands/models.ts
|
|
336
|
+
var MODEL_COMMANDS = {
|
|
337
|
+
/** The models the user allowed to this extension, without addresses or keys */
|
|
338
|
+
list: "extension_model_list",
|
|
339
|
+
/** Starts a job; the result follows as an event */
|
|
340
|
+
start: "extension_model_job_start",
|
|
341
|
+
/** Cancels a running job of this frame */
|
|
342
|
+
cancel: "extension_model_job_cancel"
|
|
343
|
+
};
|
|
344
|
+
|
|
319
345
|
// src/commands/mail.ts
|
|
320
346
|
var MAIL_COMMANDS = {
|
|
321
347
|
/** LIST mailboxes + optional STATUS counts */
|
|
@@ -1489,6 +1515,104 @@ var PasswordsAPI = class {
|
|
|
1489
1515
|
}
|
|
1490
1516
|
};
|
|
1491
1517
|
|
|
1518
|
+
// src/api/contacts.ts
|
|
1519
|
+
var ContactsAPI = class {
|
|
1520
|
+
constructor(client) {
|
|
1521
|
+
this.client = client;
|
|
1522
|
+
}
|
|
1523
|
+
/** One page of the contacts in scope, optionally of one group. */
|
|
1524
|
+
async listAsync(options = {}) {
|
|
1525
|
+
return this.client.request(CONTACT_COMMANDS.list, {
|
|
1526
|
+
...options
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
/** One contact with all its values. */
|
|
1530
|
+
async readAsync(id) {
|
|
1531
|
+
return this.client.request(CONTACT_COMMANDS.read, { id });
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* The contacts in scope whose name, organization, phone number or e-mail
|
|
1535
|
+
* address contains `query`, regardless of case and accents. The host's
|
|
1536
|
+
* default limit is 20, its maximum 200.
|
|
1537
|
+
*/
|
|
1538
|
+
async searchAsync(query, limit) {
|
|
1539
|
+
const answer = await this.client.request(
|
|
1540
|
+
CONTACT_COMMANDS.search,
|
|
1541
|
+
limit === void 0 ? { query } : { query, limit }
|
|
1542
|
+
);
|
|
1543
|
+
return answer.contacts;
|
|
1544
|
+
}
|
|
1545
|
+
/** The JPEG of a photo a readable contact uses, by its hash. */
|
|
1546
|
+
async photoAsync(hash) {
|
|
1547
|
+
const base64 = await this.client.request(CONTACT_COMMANDS.photo, {
|
|
1548
|
+
hash
|
|
1549
|
+
});
|
|
1550
|
+
return base64ToArrayBuffer(base64);
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
// src/api/models.ts
|
|
1555
|
+
var ModelsAPI = class {
|
|
1556
|
+
constructor(client) {
|
|
1557
|
+
this.client = client;
|
|
1558
|
+
}
|
|
1559
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
1560
|
+
async listAsync() {
|
|
1561
|
+
const answer = await this.client.request(
|
|
1562
|
+
MODEL_COMMANDS.list,
|
|
1563
|
+
{}
|
|
1564
|
+
);
|
|
1565
|
+
return answer.models;
|
|
1566
|
+
}
|
|
1567
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
1568
|
+
async startAsync(job) {
|
|
1569
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
1570
|
+
job
|
|
1571
|
+
});
|
|
1572
|
+
return { jobId: answer.jobId };
|
|
1573
|
+
}
|
|
1574
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
1575
|
+
async cancelAsync(jobId) {
|
|
1576
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
1577
|
+
jobId
|
|
1578
|
+
});
|
|
1579
|
+
return answer.cancelled;
|
|
1580
|
+
}
|
|
1581
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
1582
|
+
onCompleted(handler) {
|
|
1583
|
+
const wrapped = (event) => {
|
|
1584
|
+
const data = event.data;
|
|
1585
|
+
if (data) handler(data);
|
|
1586
|
+
};
|
|
1587
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
1588
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
1592
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
1593
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
1594
|
+
* until then.
|
|
1595
|
+
*/
|
|
1596
|
+
async runAsync(job) {
|
|
1597
|
+
const ended = /* @__PURE__ */ new Map();
|
|
1598
|
+
let waiting = null;
|
|
1599
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
1600
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
1601
|
+
else ended.set(completion.jobId, completion);
|
|
1602
|
+
});
|
|
1603
|
+
try {
|
|
1604
|
+
const { jobId } = await this.startAsync(job);
|
|
1605
|
+
return await new Promise((resolve) => {
|
|
1606
|
+
const early = ended.get(jobId);
|
|
1607
|
+
if (early) resolve(early);
|
|
1608
|
+
else waiting = { jobId, resolve };
|
|
1609
|
+
});
|
|
1610
|
+
} finally {
|
|
1611
|
+
unsubscribe();
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1492
1616
|
// src/api/mail.ts
|
|
1493
1617
|
var MailAPI = class {
|
|
1494
1618
|
constructor(client) {
|
|
@@ -2522,6 +2646,7 @@ var AI_COMMANDS = {
|
|
|
2522
2646
|
// src/client/permissionRetry.ts
|
|
2523
2647
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2524
2648
|
var MAX_PERMISSION_RETRIES = 3;
|
|
2649
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
2525
2650
|
function permissionKey(resourceType, action, target) {
|
|
2526
2651
|
return `${resourceType}:${action}:${target}`;
|
|
2527
2652
|
}
|
|
@@ -2557,14 +2682,18 @@ function toDeniedError(error) {
|
|
|
2557
2682
|
return { ...error, code: 1002 /* DENIED */ };
|
|
2558
2683
|
}
|
|
2559
2684
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
2685
|
+
const asked = /* @__PURE__ */ new Map();
|
|
2560
2686
|
for (let attempt = 0; ; attempt++) {
|
|
2561
2687
|
try {
|
|
2562
2688
|
return await send();
|
|
2563
2689
|
} catch (error) {
|
|
2564
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
2690
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
2565
2691
|
throw error;
|
|
2566
2692
|
}
|
|
2567
2693
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
2694
|
+
const times = asked.get(key) ?? 0;
|
|
2695
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
2696
|
+
asked.set(key, times + 1);
|
|
2568
2697
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
2569
2698
|
const outcome = await registry.wait(key, timeoutMs);
|
|
2570
2699
|
if (outcome === "granted") {
|
|
@@ -2632,6 +2761,8 @@ var HaexVaultSdk = class {
|
|
|
2632
2761
|
this.spaces = new SpacesAPI(this);
|
|
2633
2762
|
this.shell = new ShellAPI(this);
|
|
2634
2763
|
this.passwords = new PasswordsAPI(this);
|
|
2764
|
+
this.contacts = new ContactsAPI(this);
|
|
2765
|
+
this.models = new ModelsAPI(this);
|
|
2635
2766
|
this.mail = new MailAPI(this);
|
|
2636
2767
|
this.notifications = new NotificationsAPI(this);
|
|
2637
2768
|
this.tab = new TabAPI(this);
|