@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/index.mjs
CHANGED
|
@@ -4,15 +4,20 @@ import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
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 __export = (target, all) => {
|
|
11
16
|
for (var name in all)
|
|
12
17
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
18
|
};
|
|
14
19
|
var init_esm_shims = __esm({
|
|
15
|
-
"node_modules/.pnpm/tsup@
|
|
20
|
+
"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"() {
|
|
16
21
|
}
|
|
17
22
|
});
|
|
18
23
|
|
|
@@ -756,6 +761,10 @@ var NOTIFICATION_EVENTS = {
|
|
|
756
761
|
/** A click on one of this extension's notifications (body or action button). */
|
|
757
762
|
CLICK: "haextension:notification:click"
|
|
758
763
|
};
|
|
764
|
+
var MODEL_JOB_EVENTS = {
|
|
765
|
+
/** A job of this frame ended: completed, failed or cancelled. */
|
|
766
|
+
COMPLETED: "haextension:model-job:completed"
|
|
767
|
+
};
|
|
759
768
|
var EXTERNAL_EVENTS = {
|
|
760
769
|
/** External request from authorized client */
|
|
761
770
|
REQUEST: "haextension:external:request",
|
|
@@ -1186,6 +1195,17 @@ var CONTACT_COMMANDS = {
|
|
|
1186
1195
|
photo: "extension_contacts_photo"
|
|
1187
1196
|
};
|
|
1188
1197
|
|
|
1198
|
+
// src/commands/models.ts
|
|
1199
|
+
init_esm_shims();
|
|
1200
|
+
var MODEL_COMMANDS = {
|
|
1201
|
+
/** The models the user allowed to this extension, without addresses or keys */
|
|
1202
|
+
list: "extension_model_list",
|
|
1203
|
+
/** Starts a job; the result follows as an event */
|
|
1204
|
+
start: "extension_model_job_start",
|
|
1205
|
+
/** Cancels a running job of this frame */
|
|
1206
|
+
cancel: "extension_model_job_cancel"
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1189
1209
|
// src/commands/mail.ts
|
|
1190
1210
|
init_esm_shims();
|
|
1191
1211
|
var MAIL_COMMANDS = {
|
|
@@ -1238,6 +1258,7 @@ var TAURI_COMMANDS = {
|
|
|
1238
1258
|
shell: SHELL_COMMANDS,
|
|
1239
1259
|
passwords: PASSWORD_COMMANDS,
|
|
1240
1260
|
contacts: CONTACT_COMMANDS,
|
|
1261
|
+
models: MODEL_COMMANDS,
|
|
1241
1262
|
mail: MAIL_COMMANDS,
|
|
1242
1263
|
notifications: NOTIFICATION_COMMANDS
|
|
1243
1264
|
};
|
|
@@ -2414,6 +2435,69 @@ var ContactsAPI = class {
|
|
|
2414
2435
|
}
|
|
2415
2436
|
};
|
|
2416
2437
|
|
|
2438
|
+
// src/api/models.ts
|
|
2439
|
+
init_esm_shims();
|
|
2440
|
+
var ModelsAPI = class {
|
|
2441
|
+
constructor(client) {
|
|
2442
|
+
this.client = client;
|
|
2443
|
+
}
|
|
2444
|
+
/** The models the user allowed to this extension; empty without any. */
|
|
2445
|
+
async listAsync() {
|
|
2446
|
+
const answer = await this.client.request(
|
|
2447
|
+
MODEL_COMMANDS.list,
|
|
2448
|
+
{}
|
|
2449
|
+
);
|
|
2450
|
+
return answer.models;
|
|
2451
|
+
}
|
|
2452
|
+
/** Starts a job; its end comes as {@link onCompleted}. Use {@link runAsync} to await it. */
|
|
2453
|
+
async startAsync(job) {
|
|
2454
|
+
const answer = await this.client.request(MODEL_COMMANDS.start, {
|
|
2455
|
+
job
|
|
2456
|
+
});
|
|
2457
|
+
return { jobId: answer.jobId };
|
|
2458
|
+
}
|
|
2459
|
+
/** Cancels a running job of this frame; `false` when it is unknown or already ended. */
|
|
2460
|
+
async cancelAsync(jobId) {
|
|
2461
|
+
const answer = await this.client.request(MODEL_COMMANDS.cancel, {
|
|
2462
|
+
jobId
|
|
2463
|
+
});
|
|
2464
|
+
return answer.cancelled;
|
|
2465
|
+
}
|
|
2466
|
+
/** Listens for the end of this frame's jobs. Returns an unsubscribe function. */
|
|
2467
|
+
onCompleted(handler) {
|
|
2468
|
+
const wrapped = (event) => {
|
|
2469
|
+
const data = event.data;
|
|
2470
|
+
if (data) handler(data);
|
|
2471
|
+
};
|
|
2472
|
+
this.client.on(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2473
|
+
return () => this.client.off(MODEL_JOB_EVENTS.COMPLETED, wrapped);
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* Starts a job and resolves with its end: `completed` with the result, or `failed` or
|
|
2477
|
+
* `cancelled` with the error. Errors of the start itself (an invalid job, a refused model or
|
|
2478
|
+
* consent, no fitting model) reject. The end can arrive before the start answers; it is kept
|
|
2479
|
+
* until then.
|
|
2480
|
+
*/
|
|
2481
|
+
async runAsync(job) {
|
|
2482
|
+
const ended = /* @__PURE__ */ new Map();
|
|
2483
|
+
let waiting = null;
|
|
2484
|
+
const unsubscribe = this.onCompleted((completion) => {
|
|
2485
|
+
if (waiting && completion.jobId === waiting.jobId) waiting.resolve(completion);
|
|
2486
|
+
else ended.set(completion.jobId, completion);
|
|
2487
|
+
});
|
|
2488
|
+
try {
|
|
2489
|
+
const { jobId } = await this.startAsync(job);
|
|
2490
|
+
return await new Promise((resolve) => {
|
|
2491
|
+
const early = ended.get(jobId);
|
|
2492
|
+
if (early) resolve(early);
|
|
2493
|
+
else waiting = { jobId, resolve };
|
|
2494
|
+
});
|
|
2495
|
+
} finally {
|
|
2496
|
+
unsubscribe();
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2417
2501
|
// src/api/mail.ts
|
|
2418
2502
|
init_esm_shims();
|
|
2419
2503
|
var MailAPI = class {
|
|
@@ -3370,6 +3454,7 @@ var AI_COMMANDS = {
|
|
|
3370
3454
|
init_esm_shims();
|
|
3371
3455
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
3372
3456
|
var MAX_PERMISSION_RETRIES = 3;
|
|
3457
|
+
var MAX_PERMISSION_PROMPTS = 8;
|
|
3373
3458
|
function permissionKey(resourceType, action, target) {
|
|
3374
3459
|
return `${resourceType}:${action}:${target}`;
|
|
3375
3460
|
}
|
|
@@ -3405,14 +3490,18 @@ function toDeniedError(error) {
|
|
|
3405
3490
|
return { ...error, code: 1002 /* DENIED */ };
|
|
3406
3491
|
}
|
|
3407
3492
|
async function withPermissionRetry(send, registry, log, timeoutMs = PERMISSION_DECISION_TIMEOUT_MS) {
|
|
3493
|
+
const asked = /* @__PURE__ */ new Map();
|
|
3408
3494
|
for (let attempt = 0; ; attempt++) {
|
|
3409
3495
|
try {
|
|
3410
3496
|
return await send();
|
|
3411
3497
|
} catch (error) {
|
|
3412
|
-
if (!isPermissionPromptError(error) || attempt >=
|
|
3498
|
+
if (!isPermissionPromptError(error) || attempt >= MAX_PERMISSION_PROMPTS) {
|
|
3413
3499
|
throw error;
|
|
3414
3500
|
}
|
|
3415
3501
|
const key = permissionKey(error.resourceType, error.action, error.target);
|
|
3502
|
+
const times = asked.get(key) ?? 0;
|
|
3503
|
+
if (times >= MAX_PERMISSION_RETRIES) throw error;
|
|
3504
|
+
asked.set(key, times + 1);
|
|
3416
3505
|
log(`Permission prompt required for ${key} \u2014 waiting for user decision`);
|
|
3417
3506
|
const outcome = await registry.wait(key, timeoutMs);
|
|
3418
3507
|
if (outcome === "granted") {
|
|
@@ -3481,6 +3570,7 @@ var HaexVaultSdk = class {
|
|
|
3481
3570
|
this.shell = new ShellAPI(this);
|
|
3482
3571
|
this.passwords = new PasswordsAPI(this);
|
|
3483
3572
|
this.contacts = new ContactsAPI(this);
|
|
3573
|
+
this.models = new ModelsAPI(this);
|
|
3484
3574
|
this.mail = new MailAPI(this);
|
|
3485
3575
|
this.notifications = new NotificationsAPI(this);
|
|
3486
3576
|
this.tab = new TabAPI(this);
|
|
@@ -4350,6 +4440,6 @@ function createHaexVaultSdk(config = {}) {
|
|
|
4350
4440
|
return new HaexVaultSdk(config);
|
|
4351
4441
|
}
|
|
4352
4442
|
|
|
4353
|
-
export { CONTACT_COMMANDS, COSE_ALGORITHM, ContactsAPI, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, ENCRYPTED_FOLDER_COMMANDS, EXTERNAL_EVENTS, EncryptedFoldersAPI, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, HostErrorCode, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, ToolsAPI, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
|
|
4443
|
+
export { CONTACT_COMMANDS, COSE_ALGORITHM, ContactsAPI, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, ENCRYPTED_FOLDER_COMMANDS, EXTERNAL_EVENTS, EncryptedFoldersAPI, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, HostErrorCode, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MODEL_COMMANDS, MODEL_JOB_EVENTS, MailAPI, ModelsAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, ToolsAPI, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
|
|
4354
4444
|
//# sourceMappingURL=index.mjs.map
|
|
4355
4445
|
//# sourceMappingURL=index.mjs.map
|