Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(vault): align protected record envelope with avault (#790)
Call White894fd144c944
diff --git a/ui/src/lib/useProtectedVault.ts b/ui/src/lib/useProtectedVault.tsindex 68f11e2cb..2c974e413 100644--- a/ui/src/lib/useProtectedVault.ts+++ b/ui/src/lib/useProtectedVault.ts@@ -89,7 +89,7 @@ function base64ToBase64Url(b64: string): string {return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');}-/** Strip a stored record's DEK fields back to the bare VMK wrap_meta ({v, copies}). */+/** Strip a stored record's DEK fields back to the bare VMK wrap_meta ({v, copies, scheme?}). */function baseVmkWrapMeta(wrapMeta: string): string {const parsed = JSON.parse(wrapMeta) as Record<string, unknown>;delete parsed.dek_nonce;diff --git a/ui/src/lib/vaultCrypto.test.ts b/ui/src/lib/vaultCrypto.test.tsindex b5bf26735..ec3d833a0 100644--- a/ui/src/lib/vaultCrypto.test.ts+++ b/ui/src/lib/vaultCrypto.test.ts@@ -393,6 +393,7 @@ describe('vaultCrypto protected hierarchy', () => {const released = await releaseProtectedDek(sealed, vmk, avaultPublicKey, recordContext, context);expect(dek).toHaveLength(32);+ expect(protectedRecordAadHex(recordContext)).toBe('4f50454e41495f4150495f4b45596d616368696e652d61657367636d2d763101');expect(protectedRecordAadHex(recordContext)).not.toBe(protectedRecordAadHex({ name: 'OTHER_SIGNING_KEY' }));expect(released.scheme).toBe(BLIND_BOX_SCHEME);expect(base64ToBytes(released.enc)).toHaveLength(32);@@ -514,6 +515,7 @@ describe('protected record storage composition', () => {const sealed = await sealProtected(new TextEncoder().encode('sk-secret-value'), vmk, context);const envelope = packProtectedRecord(sealed, wrapMeta);+ expect(JSON.parse(envelope.wrap_meta).scheme).toBe(WRAP_SCHEME);const restored = unpackProtectedRecord(envelope);const vmkAgain = await unwrapVmk(restored.vmkWrapMeta, 'vault-password');const opened = await openProtected(restored.sealed, vmkAgain, context);diff --git a/ui/src/lib/vaultCrypto.ts b/ui/src/lib/vaultCrypto.tsindex 0082502da..9f09e733b 100644--- a/ui/src/lib/vaultCrypto.ts+++ b/ui/src/lib/vaultCrypto.ts@@ -699,11 +699,13 @@ export function passkeyPrfSaltEntries(wrapMeta: string | WrapMeta): PasskeyPrfSa}function protectedRecordAad(context: ProtectedRecordContext): Uint8Array {- const out: number[] = [];- pushLengthPrefixed(out, utf8(validateSecretName(context.name)));- pushLengthPrefixed(out, utf8(context.scheme ?? WRAP_SCHEME));- pushLengthPrefixed(out, new Uint8Array([context.version ?? WRAP_META_VERSION]));- return new Uint8Array(out);+ const name = utf8(validateSecretName(context.name));+ const scheme = utf8(context.scheme ?? WRAP_SCHEME);+ const out = new Uint8Array(name.length + scheme.length + 1);+ out.set(name, 0);+ out.set(scheme, name.length);+ out[name.length + scheme.length] = context.version ?? WRAP_META_VERSION;+ return out;}export function protectedRecordAadHex(context: ProtectedRecordContext): string {@@ -1284,10 +1286,13 @@ export function packProtectedRecord(sealed: ProtectedSealed, vmkWrapMeta: stringif ('dek_nonce' in meta || 'wrapped_dek' in meta) {throw new Error('vmk wrap_meta must not already carry a wrapped DEK');}+ if ('scheme' in meta && meta.scheme !== WRAP_SCHEME) {+ throw new Error('protected wrap_meta has unsupported scheme');+ }return {ciphertext: sealed.ciphertext,nonce: sealed.nonce,- wrap_meta: JSON.stringify({ ...meta, dek_nonce: sealed.dek_nonce, wrapped_dek: sealed.wrapped_dek }),+ wrap_meta: JSON.stringify({ ...meta, scheme: WRAP_SCHEME, dek_nonce: sealed.dek_nonce, wrapped_dek: sealed.wrapped_dek }),};}