@haex-space/vault-sdk 3.7.0 → 4.1.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.
Files changed (51) hide show
  1. package/README.md +51 -19
  2. package/dist/cli/index.js +437 -355
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli/index.mjs +428 -339
  5. package/dist/cli/index.mjs.map +1 -1
  6. package/dist/{client-DH4Km77u.d.ts → client-CD5QZi7F.d.ts} +76 -12
  7. package/dist/{client-Dn4AbXbT.d.mts → client-Cx4ZyQFL.d.mts} +76 -12
  8. package/dist/haex_bundle_bg.wasm +0 -0
  9. package/dist/index.d.mts +16 -61
  10. package/dist/index.d.ts +16 -61
  11. package/dist/index.js +185 -116
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +204 -134
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/node.d.mts +53 -2
  16. package/dist/node.d.ts +53 -2
  17. package/dist/node.js +319 -2
  18. package/dist/node.js.map +1 -1
  19. package/dist/node.mjs +320 -5
  20. package/dist/node.mjs.map +1 -1
  21. package/dist/nuxt.js +7 -5
  22. package/dist/nuxt.js.map +1 -1
  23. package/dist/nuxt.mjs +3 -2
  24. package/dist/nuxt.mjs.map +1 -1
  25. package/dist/react.d.mts +2 -2
  26. package/dist/react.d.ts +2 -2
  27. package/dist/react.js +192 -18
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +212 -38
  30. package/dist/react.mjs.map +1 -1
  31. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  32. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  33. package/dist/runtime/nuxt.plugin.client.js +100 -18
  34. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  35. package/dist/runtime/nuxt.plugin.client.mjs +100 -18
  36. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  37. package/dist/svelte.d.mts +2 -2
  38. package/dist/svelte.d.ts +2 -2
  39. package/dist/svelte.js +192 -18
  40. package/dist/svelte.js.map +1 -1
  41. package/dist/svelte.mjs +212 -38
  42. package/dist/svelte.mjs.map +1 -1
  43. package/dist/{types-DQZCRfC-.d.mts → types-BwFKGH70.d.mts} +11 -3
  44. package/dist/{types-DQZCRfC-.d.ts → types-BwFKGH70.d.ts} +11 -3
  45. package/dist/vue.d.mts +2 -2
  46. package/dist/vue.d.ts +2 -2
  47. package/dist/vue.js +192 -18
  48. package/dist/vue.js.map +1 -1
  49. package/dist/vue.mjs +212 -38
  50. package/dist/vue.mjs.map +1 -1
  51. package/package.json +9 -7
package/README.md CHANGED
@@ -1037,6 +1037,20 @@ const depTable = client.getDependencyTableName(
1037
1037
  // → "MCowBQYDK2VwAyEAp1q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k__password-manager__credentials"
1038
1038
  ```
1039
1039
 
1040
+ ### Dialogs
1041
+
1042
+ Extensions run in a sandboxed frame without `allow-modals`: `window.confirm()` returns `false` at once.
1043
+ Ask through the host instead; it draws the dialog over your own tab:
1044
+
1045
+ ```ts
1046
+ const sure = await client.dialog.confirm({
1047
+ message: "Delete this note?",
1048
+ confirmLabel: "Delete",
1049
+ destructive: true,
1050
+ });
1051
+ if (sure) await deleteNoteAsync(id);
1052
+ ```
1053
+
1040
1054
  ### Database Operations
1041
1055
 
1042
1056
  #### Query
@@ -1221,20 +1235,24 @@ Your extension needs a `manifest.json` file:
1221
1235
  "version": "1.0.0",
1222
1236
  "description": "My awesome extension",
1223
1237
 
1224
- "publicKey": "-----BEGIN PUBLIC KEY-----\n...",
1225
- "signature": "...",
1238
+ "publicKey": "<64 hex digits, written by haex sign>",
1226
1239
 
1227
1240
  "namespace": "johndoe",
1228
1241
  "displayName": "My Extension",
1229
1242
  "author": "John Doe <john@example.com>",
1230
1243
  "icon": "icon.png",
1231
- "main": "index.html",
1244
+ "entry": "index.html",
1232
1245
 
1233
- "permissions": ["http.fetch", "notifications.show"],
1246
+ "permissions": {
1247
+ "database": [],
1248
+ "filesystem": [],
1249
+ "http": [],
1250
+ "shell": []
1251
+ },
1234
1252
 
1235
1253
  "dependencies": [
1236
1254
  {
1237
- "publicKey": "MCowBQYDK2VwAyEAp1q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k",
1255
+ "publicKey": "<64 hex digits: public key of the password-manager extension>",
1238
1256
  "name": "password-manager",
1239
1257
  "minVersion": "1.0.0",
1240
1258
  "reason": "To access stored credentials",
@@ -1287,7 +1305,7 @@ await db.insert(credentialsTable, {
1287
1305
 
1288
1306
  "dependencies": [
1289
1307
  {
1290
- "publicKey": "MCowBQYDK2VwAyEAp1q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k",
1308
+ "publicKey": "<64 hex digits: public key of the password-manager extension>",
1291
1309
  "name": "password-manager",
1292
1310
  "minVersion": "1.0.0",
1293
1311
  "reason": "Access stored credentials for email sync",
@@ -1392,7 +1410,7 @@ Then build and package:
1392
1410
  npm run build:release
1393
1411
  ```
1394
1412
 
1395
- This creates `your-extension-1.0.0.haextension` - a signed ZIP file ready for distribution.
1413
+ This creates `your-extension-1.0.0.xt` - a signed ZIP file ready for distribution.
1396
1414
 
1397
1415
  **OR** build your extension and run:
1398
1416
 
@@ -1400,25 +1418,34 @@ This creates `your-extension-1.0.0.haextension` - a signed ZIP file ready for di
1400
1418
  npx haex sign dist -k private.key
1401
1419
  ```
1402
1420
 
1403
- ### 4. What Gets Signed?
1421
+ ### 4. What Gets Signed? (format `haextension-bundle/2`)
1422
+
1423
+ `haex sign`:
1404
1424
 
1405
- The signing process:
1425
+ 1. Collects the build output, the extra files of `haextension/` and the migrations (`migrationsDir`).
1426
+ Symlinks abort signing; `haextension.config.json`, `public.key` and `private.key` are never packaged.
1427
+ 2. Writes `haextension/manifest.json` as canonical JSON (RFC 8785) without a `signature` field.
1428
+ 3. Writes `haextension/signature.json` listing path, size and SHA-256 of every file, signed with
1429
+ Ed25519 over `"haextension-bundle/2\n"` + the canonical JSON of that list and the public key.
1430
+ 4. Packs everything into a deterministic `.xt` ZIP (fixed timestamps, no directory entries) and verifies it.
1406
1431
 
1407
- 1. Computes SHA-256 hash of all files in your extension
1408
- 2. Signs the hash with your private key using Ed25519
1409
- 3. Adds `public_key` and `signature` to your `manifest.json`
1410
- 4. Creates a `.haextension` file (ZIP archive)
1432
+ Moving content between files, renaming, adding or removing a file all break the signature.
1411
1433
 
1412
1434
  ### 5. Verification
1413
1435
 
1414
- When users install your extension:
1436
+ ```bash
1437
+ npx haex verify your-extension-1.0.0.xt
1438
+ ```
1415
1439
 
1416
- 1. HaexVault extracts the `.haextension` file
1417
- 2. Verifies the signature using the `public_key`
1418
- 3. Computes the hash and checks it matches
1419
- 4. Rejects installation if verification fails
1440
+ checks the bundle exactly like the host does and names the first failing rule (for example
1441
+ `file_mismatch { path: "index.html" }`). Bundles signed by SDK 3.x (signature inside the manifest) are
1442
+ rejected with `legacy_signature_format`: re-sign them with `haex sign`. Shared test vectors for hosts are in
1443
+ `test-vectors/bundles/`.
1420
1444
 
1421
- This ensures the extension hasn't been modified since you signed it.
1445
+ The format has exactly one implementation: the Rust crate `crates/haex-bundle`. Hosts such as holzi use it
1446
+ natively, and `haex sign` / `haex verify` call its WebAssembly build, so the tool and the hosts cannot apply
1447
+ different rules. From Node.js the same functions are available as `verifyBundle` and `buildBundle` from
1448
+ `@haex-space/vault-sdk/node`.
1422
1449
 
1423
1450
  ### 6. Key Management Best Practices
1424
1451
 
@@ -1499,6 +1526,11 @@ try {
1499
1526
 
1500
1527
  ## Development
1501
1528
 
1529
+ Building and testing need, besides Node.js and pnpm, a Rust toolchain with the `wasm32-unknown-unknown`
1530
+ target and `wasm-bindgen` in the version `crates/haex-bundle/Cargo.toml` pins
1531
+ (`cargo install wasm-bindgen-cli --version <pin>`). `pnpm build`, `pnpm test` and `pnpm typecheck` build the
1532
+ WebAssembly module first (`pnpm build:wasm`); run that once before `pnpm test:watch`.
1533
+
1502
1534
  ```bash
1503
1535
  # Install dependencies
1504
1536
  pnpm install