@openvireo/core-wasm 0.0.0-stage → 1.2.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/LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bongani Mbigi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,263 @@
1
- # Temporary Holding Version
1
+ # `@openvireo/core-wasm` (bindings/ov-wasm)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ openvireo-core compiled to WebAssembly with wasm-bindgen. `cargo xtask wasm` builds the package into
4
+ `bindings/ov-wasm/pkg/`. It contains two modules:
5
+
6
+ | Module | Crate | What it has | Size after wasm-opt (raw / gzip -9) |
7
+ |---|---|---|---|
8
+ | **full** | `bindings/ov-wasm` | the facade handles (`OvClient`, `Account`, `Vault`, …) plus every low-level export below | 2,196,927 B / 882,649 B |
9
+ | **lite** | `bindings/ov-wasm-lite` | primitives (SHA-256, HKDF, XChaCha20-Poly1305, Argon2, random), share links, TOTP | 405,134 B / 191,467 B |
10
+
11
+ With the module embedded as base64 (the default), a lite-only browser bundle built with esbuild is
12
+ 558 KB raw / 244 KB gzip -9, which is what the public share page pays. The full module costs about
13
+ 1.15 MB gzip -9 embedded. These figures come from `cargo xtask wasm` and `test/bundle.node.test.js`
14
+ on 2026-11-19.
15
+
16
+ The lite crate has no source of its own. It compiles the full crate's *shared* modules (`convert`,
17
+ `error`, `primitives`, `share`, `wipe`) a second time through `#[path]`, so a lite export behaves
18
+ exactly like the full export of the same name. CI's wasm32 build and clippy of `ov-wasm` therefore
19
+ cover the lite code too.
20
+
21
+ ## Entry points
22
+
23
+ | Import | Function | Notes |
24
+ |---|---|---|
25
+ | `@openvireo/core-wasm` | `loadCore(opts?) → Promise<Core>` | Full module, async. `{ wasm }` takes the .wasm as bytes, a `WebAssembly.Module`, a URL or a `Response`. `{ fresh: true }` gives a new instance (after a panic); it needs Node, Bun or unbundled ESM. |
26
+ | `@openvireo/core-wasm/sync` | `loadCoreSync(opts?) → Core` | Full module, **no top-level await**. Uses wasm-bindgen's `initSync` on the first call, then caches it. It shares its instance with `loadCore()`. |
27
+ | `@openvireo/core-wasm/lite` | `loadLite(opts?) → Promise<LiteCore>` | Lite module, async. |
28
+ | `@openvireo/core-wasm/lite-sync` | `loadLiteSync(opts?) → LiteCore` | Lite module, sync. It shares its instance with `loadLite()`. |
29
+ | `@openvireo/core-wasm/host` | `fetchTransport`, `indexedDbCache`, `memoryStore`, `memoryCache`, `systemClock`, `consoleLog` | JS Host adapters for `OvClient`. |
30
+ | `@openvireo/core-wasm/ov_wasm_bg.wasm`, `/ov_wasm_lite_bg.wasm` | | The raw modules, for `{ wasm: new URL(...) }`. |
31
+
32
+ - **Bundlers.** Every import in the loaders is a literal (`import("./gen/ov_wasm.js")`), so webpack,
33
+ Turbopack, esbuild and Rollup/Vite include the glue and the embedded module. The SDK's
34
+ `vendor/core-wasm/loader.patch` is no longer needed. The only computed import is `fresh: true`,
35
+ which carries `webpackIgnore`, `turbopackIgnore` and `@vite-ignore` comments.
36
+ `test/bundle.node.test.js` bundles all four entries with esbuild and runs the bundle in Node with
37
+ no `node_modules` next to it.
38
+ - **Synchronous APIs.** A library whose public functions are synchronous (the SDK's `sha256`,
39
+ `wrap`, `seal`, keysets, …) calls `loadCoreSync()` or `loadLiteSync()` inside those functions.
40
+ Synchronous compilation works in Node, Bun, Deno and workers. Browsers may refuse to compile a
41
+ large module synchronously on the main thread. There, `await loadCore()` once at startup, and the
42
+ synchronous calls that follow reuse the same instance.
43
+ - **Errors** are `OvError` (`code` is the wire string, plus `status`, `retryAfter`, `details` and
44
+ `serverCode`). It is one class shared by all entries. The SDK maps it to `OpenVireoError` with
45
+ the same code.
46
+ - **Panics** become `OvError("internal")` and poison that instance only (see `npm/internal.js`).
47
+
48
+ ## Conventions
49
+
50
+ - **Secrets in and out.** Secret bytes are `Uint8Array`, and the caller wipes what it receives.
51
+ Text secrets (passwords, passcodes, links, tokens, the Secret Key display) are accepted as a
52
+ `string` *or* UTF-8 `Uint8Array` as input, and are always returned as `Uint8Array`. Field values
53
+ in share payloads and TOTP codes are UTF-8 `Uint8Array`, as in the facade records.
54
+ - **Wire-shaped records cross as their JSON, with snake_case keys:** `PublicKeysJson`,
55
+ `WrappedKeysetJson`, JWT claims, `Jwks`, and the `newSaSecret` body. The SDK passes these to and
56
+ from the server unchanged. Binary records use camelCase: `Keyset` (flat, as the SDK's), and
57
+ `PublicKeys`, which adds `fingerprint`.
58
+ - **Option names follow the SDK:** `DeriveAukOptions { allowWeak, kdfMin }`,
59
+ `SealOptions { ephemeralSecretKey, nonce }`, `Argon2Params { type, password, salt, m, t, p, dkLen }`,
60
+ `VerifyJwtOptions { issuer, audience, now?, skew? }`, `TotpParams.steam`. The facade's
61
+ `encoder: "steam"` is accepted too. `nonce`/`seed`/`ephemeralSecretKey` arguments exist for test
62
+ vectors only.
63
+ - **KDBX ids** are kdbxweb's: base64 of the 16 UUID bytes, as the SDK's `getUuidString`. Hex and
64
+ hyphenated UUIDs are accepted as input. The facade's `EntryRecord.id` is hex. Times are Unix
65
+ seconds, except snapshots, which use milliseconds as the SDK does.
66
+ - **OPAQUE** client state is opaque bytes between steps, the same as the SDK's
67
+ `OpaqueClientState.sec`.
68
+
69
+ ## Wiping linear memory
70
+
71
+ wasm-bindgen copies `&[u8]`/`&str` arguments into the module's memory and frees them unzeroed.
72
+ `src/wipe.rs` and the exports deal with this in three ways:
73
+
74
+ 1. Exports take secret arguments owned (`Vec<u8>`, or read from a `JsValue`) and wrap them in
75
+ `Zeroizing`. They build outputs as a `Uint8Array` straight from a `Zeroizing` buffer.
76
+ 2. The module's global allocator on wasm32 (`ZeroOnFree`) zeroes every heap block when it is freed.
77
+ This covers wasm-bindgen's own copies, Argon2's memory blocks and the serde buffers in the domain
78
+ crates. Cost: one `memory.fill` per free, about 10–20 ms per 64 MiB Argon2 run.
79
+ 3. The loaders call the hidden `__scrubStack` export after every call returns, and when an async
80
+ call settles. It zeroes the 64 KiB of dead shadow stack.
81
+
82
+ `test/wipe.node.test.js` scans the instance's memory after AEAD, passcode, share-link, AUK, OPAQUE
83
+ and KDBX calls, and finds no copy of the secrets.
84
+
85
+ ## SDK export → binding map
86
+
87
+ How `@openvireo/sdk` (`packages/sdk/src/index.ts` and its subpaths) can implement each public
88
+ export:
89
+
90
+ - **L** means the call is in both modules (lite and full).
91
+ - **F** means the call is in the full module only.
92
+ - "TS" means the export stays TypeScript, for the reason given.
93
+
94
+ Calls are synchronous unless the SDK export is async. An async SDK export keeps its signature and
95
+ resolves with the core's result.
96
+
97
+ ### `@openvireo/sdk/crypto` (also re-exported at the top level)
98
+
99
+ | SDK export | Binding |
100
+ |---|---|
101
+ | `sha256` | `sha256` (L) |
102
+ | `hkdf(ikm, salt, info, length)` | `hkdfSha256(ikm, salt, utf8(info), length)` (L) |
103
+ | `argon2(params)` | `argon2(params)` (L): same `Argon2Params`, all three types, any `dkLen` |
104
+ | `setArgon2Impl`, `nobleArgon2` | TS. The hook stays; the default implementation becomes `argon2`. `nobleArgon2` is a pure-JS fallback that needs `@noble/hashes`, so it can't be a wrapper. Keep it, or drop it from the public API. |
105
+ | `SECRET_KEY_BYTES`, `generateSecretKey`, `formatSecretKey`, `parseSecretKey` | constant: TS. The functions are `generateSecretKey`, `fromUtf8(formatSecretKey(raw))` and `parseSecretKey` (F). |
106
+ | `KDF_DEFAULTS`, `KDF_MIN`, `newKdfParams`, `checkKdfParams`, `passwordBytes`, `stretchPassword`, `deriveAuk` | constants: TS. The functions are the same names (F). `stretchPassword` and `deriveAuk` are async in the SDK. |
107
+ | `wrap`, `unwrap`, `seal`, `sealDerivedKey`, `unseal`, `sealVaultKey`, `unsealVaultKey`, `sealSaMaster`, `unsealSaMaster` | same names (F); `aad` is a string |
108
+ | `AAD` | TS (string constants) |
109
+ | `keysetFromSecrets`, `generateKeyset`, `verifyPublicKeys`, `publicKeysFromJson`, `trustedPublicKeys`, `publicKeysToJson`, `wrapKeyset`, `unwrapKeyset` | same names (F) |
110
+ | `fingerprint(pub)` | `fingerprint(pub.encPk, pub.signPk)` (F) |
111
+ | `wipeKeyset` | TS (fills the arrays) |
112
+ | `vaultNameKey`, `encryptVaultName`, `decryptVaultName` | same names (F) |
113
+ | `SA_TOKEN_PREFIX`, `REFRESH_TOKEN_PREFIX` | TS |
114
+ | `buildSaToken`, `parseSaToken`, `saSecretHash`, `saSecretPrefix`, `wrapSaMaster`, `unwrapSaMaster`, `refreshTokenHash`, `newRefreshToken`, `newSaSecret` | same names (F). Token outputs are UTF-8: wrap them in `fromUtf8`. |
115
+ | `decodeJwt`, `isJwt` | same names (F) |
116
+ | `verifyJwt(token, jwks, opts)` | `verifyJwt` (F). For `opts.refetchJwks`, the SDK catches the unknown-kid `unauthorized`, refetches once and calls again (the core has `verify_jwt_refetching`, but a JS callback inside a synchronous call isn't worth it). |
117
+ | `restoreProofMessage`, `restoreProof`, `verifyRestoreProof`, `resealVaultKey` | same names (F) |
118
+ | `SHARE_KEY_BYTES`, `SHARE_PAD`, `SHARE_MAX_CT_BYTES` | TS |
119
+ | `padShare`, `unpadShare`, `sharePasscodeKey`, `shareContentKey`, `shareAuth`, `shareAuthHash`, `encryptSharePayload`, `decryptSharePayload`, `shareRefKey`, `encryptShareRef`, `decryptShareRef`, `shareKeyFromHash` | same names (L). Payloads map `shared_by` ↔ `sharedBy`, and string values ↔ UTF-8. |
120
+ | `shareLink` | `fromUtf8(shareLink(...))` (L) |
121
+ | `parseShareLink` | `parseShareLink` (L) |
122
+ | `utf8`, `fromUtf8`, `concat`, `toHex`, `fromHex`, `b64u`, `fromB64u`, `ctEqual`, `wipe`, `randomBytes`, `exactBuffer`, `randomUuid` | TS (byte helpers; `randomBytes` could call `randomBytes` (L), from the same CSPRNG) |
123
+ | errors (`OpenVireoError`, `isOpenVireoError`, `isUnreachable`) | TS. The SDK's error class; `OvError` maps to it. |
124
+ | X25519/Ed25519 (internal to the SDK's crypto) | `x25519PublicKey`, `x25519Shared`, `x25519RandomSecret`, `ed25519PublicKey`, `ed25519Sign`, `ed25519Verify` (F) |
125
+
126
+ ### `@openvireo/sdk/opaque`
127
+
128
+ | SDK export | Binding |
129
+ |---|---|
130
+ | `OPAQUE_CONTEXT` | TS |
131
+ | `opaqueIds` | `opaqueIds` (F) |
132
+ | `loadOpaque` | `loadCore()` (F); the SDK can keep the name |
133
+ | `OpaqueClientState` | TS class around the `state` bytes |
134
+ | `startRegistration` / `finishRegistration` / `startLogin` / `finishLogin` | `opaqueStartRegistration` / `opaqueFinishRegistration(state.sec, …)` / `opaqueStartLogin` / `opaqueFinishLogin(state.sec, …)` (F). A failed login is `opaque_failed` "wrong password". |
135
+ | `opaqueServerForTests.{registrationResponse, storeRecord, credentialResponse, userAuth}` | `opaqueServerRegistrationResponse`, `opaqueServerStoreRecord`, `opaqueServerCredentialResponse`, `opaqueServerUserAuth` (F) |
136
+
137
+ ### `@openvireo/sdk/share` and the top-level share exports
138
+
139
+ | SDK export | Binding |
140
+ |---|---|
141
+ | `DEFAULT_SHARE_FIELDS` | `defaultShareFields()` (L) |
142
+ | `shareableFields(item)` | `shareableFields(fields)` (L), with `item.fields` mapped to `FieldRecord[]` |
143
+ | `itemSharePayload` | `itemSharePayload` (L) |
144
+ | `textSharePayload` | `textSharePayload` (L) |
145
+ | `getShareInfo(api, id, http)` | TS `fetch` of `GET {api}/public/shares/{id}`, or `OvClient.shareInfo` (F) |
146
+ | `openShare(link, passcode, http)` | TS `fetch` + `new ShareOpen(link, info.kdf, passcode)`, then `requestBody()` and `decrypt(ct)` (L); or `OvClient.openShare` (F). The share page then loads only the lite module. |
147
+ | `parseTotpUri` | `parseTotpUri` (L) |
148
+ | `totpCode(params, now)` | `totpCode(params, now)`, with `code` read through `fromUtf8` (L) |
149
+ | `entryTotpUri(fields, label)` | `entryTotpUri(Object.entries(fields).map(([name, value]) => ({ name, value: utf8(value), protected: false })), label)` (L) |
150
+ | `base32Decode` | `base32Decode(text)` (L), `ov_share::base32_decode` (public since W3-A3) |
151
+
152
+ ### `@openvireo/sdk/vault` and `@openvireo/sdk/merge`
153
+
154
+ kdbxweb objects can't cross the boundary, so the binding's KDBX is bytes in and bytes out. `Kdbx`
155
+ is one decrypted database: `Kdbx.read(bytes, key)`, operations, then `write()`. `kdbxMerge` is the
156
+ whole sync merge on file bytes. Entry editing is the facade's `Vault`
157
+ (`Vault.openLocal`/`createLocal`/`saveLocal`).
158
+
159
+ | SDK export | Binding |
160
+ |---|---|
161
+ | `openKdbx` / `saveKdbx` | `Kdbx.read` / `kdbx.write()` (F) |
162
+ | `passwordHash` | `kdbxPasswordHash` (F) |
163
+ | `createVaultKdbx` | `Kdbx.createVault` (F) |
164
+ | `rekeyToVaultKey` / `applyVaultKdf` / `kdfSettings` / `copyKdbx` / `dropServerRemotes` / `openWithKeyVersions` / `syncGeneration` / `setSyncGeneration` | `kdbx.rekeyToVaultKey` / `applyVaultKdf` / `kdfSettings` / `clone` / `dropServerRemotes` / `Kdbx.openWithKeyVersions` / `syncGeneration` / `setSyncGeneration` (F) |
165
+ | `collectAllDbData` | `kdbx.entries()` + `groups()` (F) |
166
+ | `mergeDatabases(local, remote, base)` | `local.mergeWithBase(remote, base)` or `local.merge(remote)`, or `kdbxMerge(localBytes, remoteBytes, baseBytes, key)` (F). The report's `conflicts` is an array of `{ uuid, fields }`; the SDK builds its `Map` from it. |
167
+ | `snapshotOf` / `needsCommonBase` / `findConflicts` / `hasPendingDeletions` | `kdbx.snapshot()` (a `Record<id, ms>`, as the SDK's `Snapshot`) / `needsCommonBase` / `findConflicts` / `hasPendingDeletions` (F) |
168
+ | `importInto` / `importAsCopies` / `importTargets` | `target.importFrom(source)` / `importAsCopies` / `importTargets` (F) |
169
+ | `VAULT_KDF`, `REMOTE_SETTINGS_KEY`, `SYNC_GENERATION_KEY`, `parseReference`, `formatReference`, `REFERENCE_PATTERN`, `DEFAULT_ATTRIBUTES`, `seconds`, `entrySeconds` | TS (constants and string or date helpers) |
170
+
171
+ These **can't be thin wrappers while the SDK's public types are kdbxweb's** (`Kdbx`, `KdbxEntry`,
172
+ `KdbxGroup`, `CredentialsFactory`):
173
+
174
+ - `initKdbx`, `vaultCredentials`, `passwordCredentials`, `passwordHashCredentials`
175
+ - `decryptKdbx`, `createNewKdbx`
176
+ - `getUuidString`, `fieldText`, `findGroupInKdbx`, `findEntryInKdbx`
177
+ - `addEntryToDb`, `editEntryInDb`, `deleteEntryFromDb`, `createGroupInDb`, `deleteGroupFromDb`,
178
+ `emptyRecycleBinInDb`, `renameGroupInDb`, `setGroupIconInDb`, `exportSelectedGroupsToKdbx`
179
+ - `findEntry`, `resolveFieldName`, `readField`, `writeField`
180
+ - `parseItemReference`, `entryId`, `itemOf`, `listItems`, `isProtectedByDefault`, `setItemFields`
181
+ - `binaryBytes`, `fieldsOf`, `sameValue`, `sameFields`, `fieldName`, `applyField`,
182
+ `resolveFields`, `conflictingFields`, `combineEntries`
183
+
184
+ Each takes or returns a live kdbxweb object and mutates it in place. The core has all of them
185
+ (`ov-kdbx::entries`, `ov-merge`, and the facade `Vault`), but on its own model. Wrapping them would
186
+ mean a KDBX decrypt and encrypt (an Argon2 run) per call, or keeping kdbxweb next to the core.
187
+ Either the SDK keeps kdbxweb for these, or a major version replaces the kdbxweb types with handles
188
+ (`Kdbx`/`Vault`). That is a user decision.
189
+
190
+ ### `@openvireo/sdk/auth`, `@openvireo/sdk/sync`, and the account classes
191
+
192
+ | SDK export | Binding |
193
+ |---|---|
194
+ | `Account`, `AccountVault`, `deletionExpired`, `ServiceAccount`, `SelfHostedSync` | the facade: `OvClient` + `Account` / `Vault` / `ServiceAccount` / `SelfHosted` handles, and `deletionExpired` (F). There is one Rust method for each public method (core `docs/api-coverage.md`). |
195
+ | `VaultUploadError` | TS (error class) |
196
+ | `AuthClient`, `discover`, `fetchJwks`, `staticToken`, `SyncClient`, `BlobHandle`, `HttpError` | TS. These are typed `fetch` clients (JSON in and out, one call per endpoint). `ov-protocol`'s builders and parsers aren't exported. They would add a wasm hop per request and share no logic worth the surface. The logic that matters (token refresh, the sync engine, conflict handling) is the facade's. |
197
+ | `TokenManager`, storage classes (`MemoryStorage`, `IndexedDbStorage`, `EncryptedStorage`, `NamespacedStorage`, `browserStorage`, `nonExtractableIdbKey`, `FileStorage`) | TS. Platform storage is a non-goal of the core. The facade takes it as the Host `SecureStore`. |
198
+ | `syncKdbx`, `serializeSyncState`, `deserializeSyncState`, `isClockSkewed`, `CLOCK_SKEW_WARNING_MS` | `syncKdbx` drives `SyncClient` and kdbxweb databases, so it isn't thin. Its merge step can call `kdbxMerge` (F); the whole engine is the facade's `Vault.sync()`. The others stay TS (JSON and arithmetic). |
199
+ | `SseParser`, `toSyncEvent`, `EventStream`, `subscribeEvents` | TS (a string-chunk parser with no crypto), or the facade's `Account.events()` |
200
+ | `isMfaChallenge`, `APPLE_SUBSCRIPTIONS_URL` and the `auth/types` types | TS |
201
+
202
+ ### Facade additions in contract-v1.6
203
+
204
+ User decision 2026-11-19: the SDK's next major exposes the core's handles instead of kdbxweb, so the
205
+ kdbxweb-shaped exports above become `Vault` calls. These were added to the facade for that (and for
206
+ iOS); all on the full module (F):
207
+
208
+ | Need | Binding |
209
+ |---|---|
210
+ | local files on the app's clock | `client.openLocal(kdbx, credentials, signal?)`, `client.createLocal(name, credentials, signal?)` (`Vault.openLocal` / `createLocal` keep working, on the system clock) |
211
+ | last use of an entry | `EntrySummary` / `EntryRecord`: `lastAccessAt?` (only when `usageCount > 0`), `usageCount` |
212
+ | colours, custom icon, field order | `EntryInput`: `foregroundColor?` / `backgroundColor?` (`"#RRGGBB"`, `""` clears), `customIcon?` (`null` clears, absent keeps), `fieldOrder?` |
213
+ | every entry with values | `vault.entryRecords(includeRecycleBin)` |
214
+ | an entry with a chosen id | `vault.addEntryWithId(id, groupId, input)` (`conflict` if taken) |
215
+ | attachment protected flag | `AttachmentInfo.protected`; `vault.setAttachmentWith(entryId, name, data, protected?)` |
216
+ | import one open vault into another | `vault.importFrom(source, { kind: "merge" } \| { kind: "copies", parentGroupId? })` → `ImportSummary`; `source.importPreview()` → `{ entries, groups }`; `vault.importTargets()` |
217
+ | file metadata | `vault.setName(name)` (local), `metaCustomData(key)`, `setMetaCustomData(key, value?)` |
218
+ | "save a copy" / KDF | `vault.copyWithoutRemotes(credentials?)`, `vault.setKdf(kdf)` (local), `vault.exportKdbxWith(credentials, groupIds?, kdf)`; `KdbxKdf` is `{ kind: "databaseDefault" }`, `{ kind: "argon2d" \| "argon2id", memory, iterations, parallelism }` or `{ kind: "aesKdf", rounds }` |
219
+ | self-hosted version history | `selfHosted.history(databaseId)`, `selfHosted.openVersion(databaseId, revision, credentials)` |
220
+ | a service account's server | `sa.serverConfig()`, `sa.issuer()` |
221
+ | sync an account vault held as a file (desktop-style) | `account.syncVaultKdbx(vaultId, kdbx, base?, options?)` → `VaultKdbxSyncResult { kdbx, credentials, report }`; `account.vaultKdbxCredentials(vaultId)`; `SyncOptions.acceptServerState?` ("continue anyway" after `server_rolled_back` / `server_lost_database`, also for `vault.sync`) |
222
+ | borrow the session token | `account.accessToken(forceRefresh)` (UTF-8 JWT bytes; never log it) |
223
+
224
+ ### Facade additions in contract-v1.7
225
+
226
+ | Need | Binding |
227
+ |---|---|
228
+ | open or sync a file with the kept password hash | `KdbxCredentials.passwordHash?` (`core.kdbxPasswordHash(password)`, 32 bytes; not together with `password`) on `Vault.openLocal`, `client.openLocal`, `selfHosted.syncDatabase*`, `exportKdbx*`, imports |
229
+ | self-hosted sync without a download when nothing changed | `selfHosted.syncDatabaseWith(databaseId, kdbx, credentials, { localChanged, acceptServerState })`: `localChanged: false` sends a HEAD; unchanged → `report.outcome === "unchanged"` and the same bytes back |
230
+ | one wrong-key code | a wrong local-file key is `vault_key_mismatch` (was `kdbx_error`) |
231
+ | wrong Secret Key vs wrong password | sign-in `unauthorized` errors have `details.reason` `"keyset_unwrap_failed"` or `"opaque_refused"` |
232
+
233
+ ### Facade additions in contract-v1.8
234
+
235
+ | Need | Binding |
236
+ |---|---|
237
+ | share to the keys the user confirmed | `account.shareVaultWithKeys(vaultId, grantee, role, publicKeys)` (`invalid_public_keys` if they changed) |
238
+ | a self-hosted database's bytes without its key | `selfHosted.download(databaseId)` → `Uint8Array \| undefined` |
239
+ | a service account's vault as a file | `sa.vaultKdbxCredentials(vaultId)`, `sa.syncVaultKdbx(vaultId, kdbx, base?, options?)` |
240
+ | the profile's KDF and keyset keys | `Profile.kdf`, `Profile.publicKeys` |
241
+ | not a sync server | `selfHosted.health()` rejects with `code: "not_sync_server"` |
242
+
243
+ Behaviour changes (no new calls): Recycle Bin restore to the previous group (files become KDBX 4.1 when
244
+ needed), `vault.sync()` keeps edits made while it runs, `restoreEntry` on a binned entry keeps its
245
+ history, `exportPlain` = the ExportDialog's bytes, `rotation_pending`, deletion `details`, accidental
246
+ session ends keep unsynced edits, `openVault` is one GET.
247
+
248
+ Record fields added in v1.6 (`usageCount`, `AttachmentInfo.protected`, `SyncOptions.acceptServerState`) default when a JS record that
249
+ lacks them comes back in (`applyAutofillEdits`, `keepAutofillEdit`).
250
+
251
+ ## Building and testing
252
+
253
+ ```sh
254
+ cargo xtask wasm # builds both modules into pkg/ (needs wasm-bindgen-cli 0.2.130 and binaryen)
255
+ cd bindings/ov-wasm && npm ci
256
+ npx vitest run # 11 files: smoke (Node, jsdom), host, low-level vectors, shared/lite parity, wipe, lite panic, esbuild bundle, contract-v1.6, contract-v1.7, contract-v1.8
257
+ npx tsc -p tsconfig.json # the .d.ts describe the API (test/types.ts)
258
+ ```
259
+
260
+ `cargo xtask wasm` honours `$CARGO_TARGET_DIR` (`$CARGO_TARGET_DIR/wasm-pkg`). If the target dir is
261
+ shared with another checkout, give each checkout its own xtask binary
262
+ (`cargo run -p xtask --target-dir <own dir> -- wasm`). The `cargo xtask` alias runs whichever
263
+ `target/debug/xtask` was built last.
package/error.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ export interface OvErrorOptions {
2
+ status?: number;
3
+ retryAfter?: number;
4
+ details?: Record<string, unknown> | string;
5
+ serverCode?: string;
6
+ cause?: unknown;
7
+ }
8
+
9
+ /** The one error type of the core. `code` is the stable wire string (`"plan_limit"`, `"internal"`, …). */
10
+ export class OvError extends Error {
11
+ constructor(code: string, message: string, opts?: OvErrorOptions);
12
+ readonly name: "OvError";
13
+ /** The wire code: an `OvErrorCode` string, or an untyped server code. */
14
+ code: string;
15
+ status?: number;
16
+ retryAfter?: number;
17
+ /** The SDK's camelCase details object. */
18
+ details?: Record<string, unknown> | string;
19
+ /** A server code the core has no variant for (then `code` holds it too). */
20
+ serverCode?: string;
21
+ /** Network error or 502/503/504 (the SDK's `isUnreachable`). */
22
+ readonly isUnreachable: boolean;
23
+ }
package/error.js ADDED
@@ -0,0 +1,19 @@
1
+ // The core's one error type, shared by every entry point of the package (index, sync, lite, lite-sync).
2
+
3
+ /** The one error type of the core. `code` is the stable wire string (`"plan_limit"`, `"internal"`, …). */
4
+ export class OvError extends Error {
5
+ constructor(code, message, opts = {}) {
6
+ super(message, opts.cause === undefined ? undefined : { cause: opts.cause });
7
+ this.name = "OvError";
8
+ this.code = code;
9
+ if (opts.status !== undefined) this.status = opts.status;
10
+ if (opts.retryAfter !== undefined) this.retryAfter = opts.retryAfter;
11
+ if (opts.details !== undefined) this.details = opts.details;
12
+ if (opts.serverCode !== undefined) this.serverCode = opts.serverCode;
13
+ }
14
+
15
+ /** Whether the server couldn't be reached (network error or 502/503/504), as the SDK's `isUnreachable`. */
16
+ get isUnreachable() {
17
+ return this.code === "network_error" || this.status === 502 || this.status === 503 || this.status === 504;
18
+ }
19
+ }