@seed-hypermedia/client 0.0.77 → 0.0.79

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 (36) hide show
  1. package/dist/auto-link.mjs +3 -3
  2. package/dist/blocks-to-markdown.mjs +2 -2
  3. package/dist/capability.mjs +2 -2
  4. package/dist/{chunk-I6T7E6NR.mjs → chunk-3UP4S7XZ.mjs} +1 -1
  5. package/dist/{chunk-NXWZWZWS.mjs → chunk-473ELALL.mjs} +3 -3
  6. package/dist/{chunk-EGDF5YHG.mjs → chunk-4HJWSEWS.mjs} +5 -1
  7. package/dist/{chunk-E2S3ZLBH.mjs → chunk-5HHKGULK.mjs} +2 -2
  8. package/dist/{chunk-5ARN5GTL.mjs → chunk-AC3EMQZG.mjs} +1 -1
  9. package/dist/{chunk-YMF2Y7UO.mjs → chunk-AOCNYES4.mjs} +1 -1
  10. package/dist/{chunk-HYCHOIRR.mjs → chunk-CCVGF25A.mjs} +1 -1
  11. package/dist/{chunk-6ZDWVCC2.mjs → chunk-CVUWZ27W.mjs} +1 -1
  12. package/dist/{chunk-DBHL3BYB.mjs → chunk-EZ5UFUMQ.mjs} +78 -1
  13. package/dist/{chunk-FT4OR5WY.mjs → chunk-LJI66S7C.mjs} +1 -1
  14. package/dist/{chunk-YYQPNBQK.mjs → chunk-M7ZYWWI3.mjs} +1 -1
  15. package/dist/{chunk-LLRVL4BP.mjs → chunk-R5FOS4BW.mjs} +1 -1
  16. package/dist/{chunk-7UUGEBS3.mjs → chunk-UX7OUR3C.mjs} +1 -1
  17. package/dist/{chunk-3NKBUTZO.mjs → chunk-ZFQ6SZ5C.mjs} +1 -1
  18. package/dist/client.mjs +2 -2
  19. package/dist/comment.mjs +2 -2
  20. package/dist/document-state.mjs +2 -2
  21. package/dist/editorblock-to-hmblock.mjs +2 -2
  22. package/dist/hm-resolver.mjs +2 -2
  23. package/dist/hm-types.d.ts +81 -0
  24. package/dist/hm-types.mjs +1 -1
  25. package/dist/hmblock-to-editorblock.mjs +2 -2
  26. package/dist/index.mjs +13 -13
  27. package/dist/pdf-to-blocks.mjs +3 -3
  28. package/dist/resource-read.mjs +4 -4
  29. package/dist/tei-to-blocks.mjs +2 -2
  30. package/dist/unicode.mjs +1 -1
  31. package/dist/vault-local.mjs +1 -1
  32. package/dist/vault-merge.d.ts +67 -0
  33. package/dist/vault-merge.mjs +332 -0
  34. package/dist/vault.d.ts +23 -0
  35. package/dist/vault.mjs +9 -1
  36. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  resolveIdWithClient
3
- } from "./chunk-NXWZWZWS.mjs";
4
- import "./chunk-I6T7E6NR.mjs";
5
- import "./chunk-6ZDWVCC2.mjs";
3
+ } from "./chunk-473ELALL.mjs";
4
+ import "./chunk-3UP4S7XZ.mjs";
5
+ import "./chunk-CVUWZ27W.mjs";
6
6
  import "./chunk-CBELM7KX.mjs";
7
7
  import "./chunk-JT57MV7Y.mjs";
8
8
  import "./chunk-PJ2RFT5A.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-EGDF5YHG.mjs";
11
+ import "./chunk-4HJWSEWS.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  resolveIdWithClient
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-HYCHOIRR.mjs";
4
- import "./chunk-EGDF5YHG.mjs";
3
+ } from "./chunk-CCVGF25A.mjs";
4
+ import "./chunk-4HJWSEWS.mjs";
5
5
  import "./chunk-7P6ASYW6.mjs";
6
6
  export {
7
7
  teiToBlocks
package/dist/unicode.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  codePointLength,
9
9
  isSurrogate
10
- } from "./chunk-EGDF5YHG.mjs";
10
+ } from "./chunk-4HJWSEWS.mjs";
11
11
  import "./chunk-7P6ASYW6.mjs";
12
12
  export {
13
13
  AnnotationSet,
@@ -5,7 +5,7 @@ import {
5
5
  principalFromPublicKey,
6
6
  principalToString,
7
7
  unwrapDEK
8
- } from "./chunk-DBHL3BYB.mjs";
8
+ } from "./chunk-EZ5UFUMQ.mjs";
9
9
  import {
10
10
  readOSSecret,
11
11
  stripGoKeyringPrefix
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Vault state merge — a line-for-line port of the Go implementation in
3
+ * backend/storage/vault/vault.go (normalizeState/mergeNormalizedStates/
4
+ * statesEqual and helpers, vault.go:2387-2790).
5
+ *
6
+ * Byte-compatibility with Go is the prime directive here: the merge is what
7
+ * keeps every device's vault convergent, and any divergence makes devices
8
+ * oscillate or silently lose identities. Notable Go semantics preserved:
9
+ *
10
+ * - Accounts are keyed by PRINCIPAL (base58 account ID derived from the seed),
11
+ * never by display name. Two accounts may share a display name.
12
+ * - ALL string comparisons are byte-wise (Go's `<`/`>` on strings), NEVER
13
+ * locale-aware: base58 principals are mixed-case and ICU collation orders
14
+ * them differently than Go does.
15
+ * - Tombstones kill an account only when `tombstone >= latestLiveCreateTime`
16
+ * (and > 0); otherwise the tombstone is deleted (resurrection).
17
+ * - Unknown CBOR fields (Go's `Extra`) merge as remote's overlaid by local's,
18
+ * and participate in equality via dag-cbor byte comparison.
19
+ *
20
+ * Merge decisions are logged through the `log` callback (default: console.log
21
+ * with the same 🔑 VAULT-MERGE marker the Go daemon uses) — this path has
22
+ * burned the team before, keep it loud and greppable.
23
+ */
24
+ import './base64';
25
+ import { type Account, type State } from './vault';
26
+ /** Loud, greppable marker matching Go's vaultMergeLogPrefix. */
27
+ export declare const VAULT_MERGE_LOG_PREFIX = "\uD83D\uDD11 VAULT-MERGE";
28
+ export type VaultMergeLogger = (message: string, fields?: Record<string, unknown>) => void;
29
+ export type NormalizedAccount = {
30
+ principal: string;
31
+ account: Account;
32
+ };
33
+ export type NormalizedState = {
34
+ notificationServerUrl: string;
35
+ /** Accounts keyed by principal (base58 account ID). */
36
+ accounts: Map<string, NormalizedAccount>;
37
+ /** Tombstones keyed by principal. */
38
+ deletedAccounts: Record<string, number>;
39
+ /** Unknown top-level CBOR fields (Go State.Extra), preserved through the merge. */
40
+ extra: Record<string, unknown>;
41
+ };
42
+ /**
43
+ * Normalize a state for merging: key accounts by principal, resolve duplicate
44
+ * principals, normalize display names (merge-time only) and dedupe delegations
45
+ * by capability CID. Throws on invalid (non-32-byte) seeds, like Go errors.
46
+ * `source` labels error messages ('local' or 'remote').
47
+ */
48
+ export declare function normalizeState(state: State, source: string): NormalizedState;
49
+ /** Semantic state equality, matching Go's statesEqual (never compares serialized bytes). */
50
+ export declare function statesEqual(left: State, right: State): boolean;
51
+ /**
52
+ * Merge two states, matching Go's mergeStates convenience path:
53
+ * normalize both sides, then mergeNormalizedStates.
54
+ */
55
+ export declare function mergeStates(local: State, remote: State, localVersion: number, remoteVersion: number, log?: VaultMergeLogger): {
56
+ merged: State;
57
+ changedFromLocal: boolean;
58
+ };
59
+ /**
60
+ * The merge algorithm itself (Go mergeNormalizedStates). `changedFromLocal`
61
+ * reports whether the merged result differs semantically from `local` — the
62
+ * caller uses it to decide whether the local vault needs rewriting.
63
+ */
64
+ export declare function mergeNormalizedStates(local: NormalizedState, remote: NormalizedState, localVersion: number, remoteVersion: number, log?: VaultMergeLogger): {
65
+ merged: State;
66
+ changedFromLocal: boolean;
67
+ };
@@ -0,0 +1,332 @@
1
+ import {
2
+ VAULT_VERSION,
3
+ accountIdFromSeed,
4
+ getUnknownFields,
5
+ setUnknownFields
6
+ } from "./chunk-EZ5UFUMQ.mjs";
7
+ import "./chunk-UOL3F6XQ.mjs";
8
+ import "./chunk-2MD3FXKB.mjs";
9
+ import "./chunk-IT5LLTMP.mjs";
10
+ import "./chunk-DR3HJ6BV.mjs";
11
+ import "./chunk-3TPCJCVO.mjs";
12
+ import "./chunk-7P6ASYW6.mjs";
13
+
14
+ // src/vault-merge.ts
15
+ import * as dagCBOR from "@ipld/dag-cbor";
16
+ import * as cborg from "cborg";
17
+ var cborEncodeOpts = {
18
+ ...dagCBOR.encodeOptions,
19
+ typeEncoders: {
20
+ ...dagCBOR.encodeOptions.typeEncoders,
21
+ undefined: () => null
22
+ }
23
+ };
24
+ var localKeyNameFormat = /^[a-zA-Z0-9_-]+$/;
25
+ var ED25519_SEED_SIZE = 32;
26
+ var VAULT_MERGE_LOG_PREFIX = "\u{1F511} VAULT-MERGE";
27
+ var defaultLog = (message, fields) => {
28
+ if (fields === void 0) {
29
+ console.log(`${VAULT_MERGE_LOG_PREFIX} ${message}`);
30
+ } else {
31
+ console.log(`${VAULT_MERGE_LOG_PREFIX} ${message}`, fields);
32
+ }
33
+ };
34
+ function normalizeState(state, source) {
35
+ const normalized = {
36
+ notificationServerUrl: state.notificationServerUrl ?? "",
37
+ accounts: /* @__PURE__ */ new Map(),
38
+ deletedAccounts: { ...state.deletedAccounts ?? {} },
39
+ extra: { ...getUnknownFields(state) }
40
+ };
41
+ state.accounts.forEach((account, idx) => {
42
+ if (account.seed.length !== ED25519_SEED_SIZE) {
43
+ throw new Error(
44
+ `${source} account ${idx} has invalid seed length: got ${account.seed.length}, expected ${ED25519_SEED_SIZE}`
45
+ );
46
+ }
47
+ const principal = accountIdFromSeed(account.seed);
48
+ let normalizedDelegations;
49
+ try {
50
+ normalizedDelegations = normalizeDelegations(account.delegations);
51
+ } catch (err) {
52
+ throw new Error(`${source} account ${idx} has invalid delegations: ${err.message}`);
53
+ }
54
+ const nextAccount = {
55
+ name: normalizeKeyName(account.name, principal),
56
+ seed: new Uint8Array(account.seed),
57
+ createTime: account.createTime,
58
+ delegations: normalizedDelegations
59
+ };
60
+ setUnknownFields(nextAccount, getUnknownFields(account));
61
+ const next = { principal, account: nextAccount };
62
+ const existing = normalized.accounts.get(principal);
63
+ if (!existing) {
64
+ normalized.accounts.set(principal, next);
65
+ return;
66
+ }
67
+ normalized.accounts.set(principal, mergeDuplicateAccount(existing, next));
68
+ });
69
+ return normalized;
70
+ }
71
+ function statesEqual(left, right) {
72
+ return normalizedStatesEqual(normalizeState(left, "local"), normalizeState(right, "remote"));
73
+ }
74
+ function mergeStates(local, remote, localVersion, remoteVersion, log = defaultLog) {
75
+ return mergeNormalizedStates(
76
+ normalizeState(local, "local"),
77
+ normalizeState(remote, "remote"),
78
+ localVersion,
79
+ remoteVersion,
80
+ log
81
+ );
82
+ }
83
+ function mergeNormalizedStates(local, remote, localVersion, remoteVersion, log = defaultLog) {
84
+ const mergedDeleted = { ...local.deletedAccounts };
85
+ for (const [accountID, deleteTime] of Object.entries(remote.deletedAccounts)) {
86
+ if ((mergedDeleted[accountID] ?? 0) < deleteTime) {
87
+ mergedDeleted[accountID] = deleteTime;
88
+ }
89
+ }
90
+ const merged = {
91
+ version: VAULT_VERSION,
92
+ accounts: []
93
+ };
94
+ const notificationServerUrl = chooseMergedNotificationServerURL(
95
+ local.notificationServerUrl,
96
+ remote.notificationServerUrl,
97
+ localVersion,
98
+ remoteVersion
99
+ );
100
+ if (notificationServerUrl) {
101
+ merged.notificationServerUrl = notificationServerUrl;
102
+ }
103
+ setUnknownFields(merged, { ...remote.extra, ...local.extra });
104
+ const accountIDs = /* @__PURE__ */ new Set([
105
+ ...local.accounts.keys(),
106
+ ...remote.accounts.keys(),
107
+ ...Object.keys(mergedDeleted)
108
+ ]);
109
+ const accountIDsList = [...accountIDs].sort(compareStringsBytewise);
110
+ for (const accountID of accountIDsList) {
111
+ const localAccount = local.accounts.get(accountID);
112
+ const remoteAccount = remote.accounts.get(accountID);
113
+ const localTombstone = local.deletedAccounts[accountID] ?? 0;
114
+ const remoteTombstone = remote.deletedAccounts[accountID] ?? 0;
115
+ const winningTombstone = Math.max(localTombstone, remoteTombstone);
116
+ let latestLiveCreateTime = 0;
117
+ if (localAccount && localAccount.account.createTime > latestLiveCreateTime) {
118
+ latestLiveCreateTime = localAccount.account.createTime;
119
+ }
120
+ if (remoteAccount && remoteAccount.account.createTime > latestLiveCreateTime) {
121
+ latestLiveCreateTime = remoteAccount.account.createTime;
122
+ }
123
+ if (winningTombstone >= latestLiveCreateTime && winningTombstone > 0) {
124
+ mergedDeleted[accountID] = winningTombstone;
125
+ log("account deleted by tombstone", { accountID, winningTombstone, latestLiveCreateTime });
126
+ continue;
127
+ }
128
+ delete mergedDeleted[accountID];
129
+ if (!localAccount && !remoteAccount) continue;
130
+ let next;
131
+ if (localAccount && remoteAccount) {
132
+ if (bytesEqual(localAccount.account.seed, remoteAccount.account.seed)) {
133
+ next = mergeMatchingAccounts(localAccount.account, remoteAccount.account);
134
+ } else if (accountWinsByTiebreak(localAccount, remoteAccount)) {
135
+ log("divergent key material for principal: REMOTE account won the tiebreak", { accountID });
136
+ next = remoteAccount.account;
137
+ } else {
138
+ log("divergent key material for principal: LOCAL account won the tiebreak", { accountID });
139
+ next = localAccount.account;
140
+ }
141
+ } else if (localAccount) {
142
+ next = localAccount.account;
143
+ } else {
144
+ next = remoteAccount.account;
145
+ }
146
+ merged.accounts.push(next);
147
+ }
148
+ merged.accounts.sort((a, b) => {
149
+ const nameDiff = compareStringsBytewise(a.name ?? "", b.name ?? "");
150
+ if (nameDiff !== 0) return nameDiff;
151
+ return compareStringsBytewise(accountIdFromSeed(a.seed), accountIdFromSeed(b.seed));
152
+ });
153
+ if (Object.keys(mergedDeleted).length > 0) {
154
+ merged.deletedAccounts = mergedDeleted;
155
+ }
156
+ const mergedNormalized = normalizeState(merged, "local");
157
+ const changedFromLocal = !normalizedStatesEqual(local, mergedNormalized);
158
+ log("mergeNormalizedStates result (local \u2295 remote \u2192 merged)", {
159
+ localVersion,
160
+ remoteVersion,
161
+ changedLocalVault: changedFromLocal,
162
+ localIdentityCount: local.accounts.size,
163
+ remoteIdentityCount: remote.accounts.size,
164
+ mergedIdentityCount: merged.accounts.length,
165
+ mergedIdentities: merged.accounts.map((account) => `${account.name ?? ""} (${accountIdFromSeed(account.seed)})`),
166
+ mergedTombstones: Object.keys(mergedDeleted).sort(compareStringsBytewise)
167
+ });
168
+ return { merged, changedFromLocal };
169
+ }
170
+ function normalizedStatesEqual(left, right) {
171
+ if (left.notificationServerUrl !== right.notificationServerUrl) return false;
172
+ if (!equalDeletedAccounts(left.deletedAccounts, right.deletedAccounts)) return false;
173
+ if (!cborValuesEqual(left.extra, right.extra)) return false;
174
+ if (left.accounts.size !== right.accounts.size) return false;
175
+ for (const [principal, leftAccount] of left.accounts) {
176
+ const rightAccount = right.accounts.get(principal);
177
+ if (!rightAccount) return false;
178
+ if (!bytesEqual(leftAccount.account.seed, rightAccount.account.seed)) return false;
179
+ if (!cborValuesEqual(accountToEncodable(leftAccount.account), accountToEncodable(rightAccount.account))) {
180
+ return false;
181
+ }
182
+ }
183
+ return true;
184
+ }
185
+ function accountWinsByTiebreak(current, candidate) {
186
+ if (candidate.account.createTime > current.account.createTime) return true;
187
+ if (candidate.account.createTime < current.account.createTime) return false;
188
+ const principalDiff = compareStringsBytewise(candidate.principal, current.principal);
189
+ if (principalDiff > 0) return true;
190
+ if (principalDiff < 0) return false;
191
+ return compareStringsBytewise(candidate.account.name ?? "", current.account.name ?? "") > 0;
192
+ }
193
+ function mergeDuplicateAccount(existing, candidate) {
194
+ if (bytesEqual(existing.account.seed, candidate.account.seed)) {
195
+ const mergedDelegations = normalizeDelegations([...existing.account.delegations, ...candidate.account.delegations]);
196
+ if (accountWinsByTiebreak(existing, candidate)) {
197
+ candidate.account.delegations = mergedDelegations;
198
+ return candidate;
199
+ }
200
+ existing.account.delegations = mergedDelegations;
201
+ return existing;
202
+ }
203
+ if (accountWinsByTiebreak(existing, candidate)) return candidate;
204
+ return existing;
205
+ }
206
+ function mergeMatchingAccounts(local, remote) {
207
+ const mergedDelegations = normalizeDelegations([...local.delegations, ...remote.delegations]);
208
+ const merged = {
209
+ name: local.name || remote.name,
210
+ seed: local.seed.length > 0 ? new Uint8Array(local.seed) : remote.seed,
211
+ createTime: Math.max(local.createTime, remote.createTime),
212
+ delegations: mergedDelegations
213
+ };
214
+ setUnknownFields(merged, { ...getUnknownFields(remote), ...getUnknownFields(local) });
215
+ return merged;
216
+ }
217
+ function normalizeDelegations(delegations) {
218
+ if (!delegations || delegations.length === 0) return [];
219
+ const byCID = /* @__PURE__ */ new Map();
220
+ delegations.forEach((delegation, idx) => {
221
+ let cidKey;
222
+ try {
223
+ cidKey = delegationCapabilityCIDKey(delegation);
224
+ } catch (err) {
225
+ throw new Error(`delegation ${idx}: ${err.message}`);
226
+ }
227
+ const existing = byCID.get(cidKey);
228
+ if (!existing || delegationWinsByTiebreak(existing, delegation)) {
229
+ byCID.set(cidKey, delegation);
230
+ }
231
+ });
232
+ const keys = [...byCID.keys()].sort(compareStringsBytewise);
233
+ return keys.map((key) => byCID.get(key));
234
+ }
235
+ function delegationWinsByTiebreak(current, candidate) {
236
+ if (candidate.createTime > current.createTime) return true;
237
+ if (candidate.createTime < current.createTime) return false;
238
+ const clientDiff = compareStringsBytewise(candidate.clientId, current.clientId);
239
+ if (clientDiff > 0) return true;
240
+ if (clientDiff < 0) return false;
241
+ return compareStringsBytewise(candidate.deviceType ?? "", current.deviceType ?? "") > 0;
242
+ }
243
+ function delegationCapabilityCIDKey(delegation) {
244
+ var _a;
245
+ const cid = (_a = delegation.capability) == null ? void 0 : _a.cid;
246
+ if (!cid) {
247
+ throw new Error("delegation capability CID is missing");
248
+ }
249
+ return dagCBOR.encode(cid).toBase64({ alphabet: "base64url", omitPadding: true });
250
+ }
251
+ function chooseMergedNotificationServerURL(local, remote, localVersion, remoteVersion) {
252
+ if (remoteVersion > localVersion) return remote;
253
+ if (localVersion > remoteVersion) return local;
254
+ if (local !== "" || remote === "") return local;
255
+ return remote;
256
+ }
257
+ function normalizeKeyName(name, principal) {
258
+ const normalized = (name ?? "").trim();
259
+ if (normalized === "" || !localKeyNameFormat.test(normalized)) return principal;
260
+ return normalized;
261
+ }
262
+ function equalDeletedAccounts(left, right) {
263
+ const leftEntries = Object.entries(left);
264
+ if (leftEntries.length !== Object.keys(right).length) return false;
265
+ for (const [name, leftValue] of leftEntries) {
266
+ if (right[name] !== leftValue) return false;
267
+ }
268
+ return true;
269
+ }
270
+ function cborValuesEqual(left, right) {
271
+ let leftEncoded;
272
+ let rightEncoded;
273
+ try {
274
+ leftEncoded = cborg.encode(left, cborEncodeOpts);
275
+ rightEncoded = cborg.encode(right, cborEncodeOpts);
276
+ } catch {
277
+ return false;
278
+ }
279
+ return bytesEqual(leftEncoded, rightEncoded);
280
+ }
281
+ function accountToEncodable(account) {
282
+ const out = {
283
+ ...getUnknownFields(account),
284
+ seed: account.seed,
285
+ createTime: account.createTime,
286
+ delegations: account.delegations.map((delegation) => delegationToEncodable(delegation))
287
+ };
288
+ if (account.name) out.name = account.name;
289
+ return out;
290
+ }
291
+ function delegationToEncodable(delegation) {
292
+ const out = {
293
+ ...getUnknownFields(delegation),
294
+ clientId: delegation.clientId,
295
+ capability: capabilityToEncodable(delegation.capability),
296
+ createTime: delegation.createTime
297
+ };
298
+ if (delegation.deviceType) out.deviceType = delegation.deviceType;
299
+ return out;
300
+ }
301
+ function capabilityToEncodable(capability) {
302
+ return {
303
+ ...getUnknownFields(capability),
304
+ cid: capability.cid,
305
+ delegate: capability.delegate
306
+ };
307
+ }
308
+ var utf8Encoder = new TextEncoder();
309
+ function compareStringsBytewise(a, b) {
310
+ const aBytes = utf8Encoder.encode(a);
311
+ const bBytes = utf8Encoder.encode(b);
312
+ const len = Math.min(aBytes.length, bBytes.length);
313
+ for (let i = 0; i < len; i++) {
314
+ const diff = aBytes[i] - bBytes[i];
315
+ if (diff !== 0) return diff;
316
+ }
317
+ return aBytes.length - bBytes.length;
318
+ }
319
+ function bytesEqual(a, b) {
320
+ if (a.length !== b.length) return false;
321
+ for (let i = 0; i < a.length; i++) {
322
+ if (a[i] !== b[i]) return false;
323
+ }
324
+ return true;
325
+ }
326
+ export {
327
+ VAULT_MERGE_LOG_PREFIX,
328
+ mergeNormalizedStates,
329
+ mergeStates,
330
+ normalizeState,
331
+ statesEqual
332
+ };
package/dist/vault.d.ts CHANGED
@@ -78,12 +78,34 @@ export interface State {
78
78
  /** List of Hypermedia accounts. */
79
79
  accounts: Account[];
80
80
  }
81
+ type UnknownFields = Record<string, unknown>;
81
82
  /** Create an empty vault. */
82
83
  export declare function createEmpty(): State;
83
84
  /** Serialize vault data: CBOR encode → gzip compress. Returns compressed bytes. */
84
85
  export declare function serialize(data: State): Promise<Uint8Array>;
85
86
  /** Deserialize vault data: gzip decompress → CBOR decode. Throws if version mismatches. */
86
87
  export declare function deserialize(compressed: Uint8Array): Promise<State>;
88
+ /**
89
+ * Go-parity serialize: CBOR encode → gzip, matching backend/storage/vault
90
+ * state.go `encodeState`. Never dedupes or renames accounts; only fills
91
+ * whitespace-empty names with the account principal.
92
+ */
93
+ export declare function serializeState(data: State): Promise<Uint8Array>;
94
+ /**
95
+ * Go-parity deserialize: gzip decompress → CBOR decode, matching
96
+ * backend/storage/vault state.go `decodeState`. Never dedupes or renames
97
+ * accounts; only fills whitespace-empty names with the account principal.
98
+ * Throws if the schema version mismatches.
99
+ */
100
+ export declare function deserializeState(compressed: Uint8Array): Promise<State>;
101
+ /**
102
+ * Read the unknown CBOR fields preserved on a decoded vault object (Go's
103
+ * `Extra` / mapstructure ",remain" fields). Returns the live extras object
104
+ * (empty when none) — treat it as read-only.
105
+ */
106
+ export declare function getUnknownFields(target: State | Account | DelegatedSession | CapabilityMeta): UnknownFields;
107
+ /** Replace the unknown CBOR fields carried by a vault object (stores a shallow copy). */
108
+ export declare function setUnknownFields(target: State | Account | DelegatedSession | CapabilityMeta, extras: UnknownFields): void;
87
109
  /** Ensure account name compatibility for older vault records that have no label. */
88
110
  export declare function getAccountName(account: Pick<Account, 'name' | 'seed'>): string;
89
111
  /**
@@ -139,3 +161,4 @@ export declare function unwrapDEK(envelope: VaultEnvelope, wrappingKey: Uint8Arr
139
161
  * Decrypt and decode the vault state from an envelope using the unwrapped DEK.
140
162
  */
141
163
  export declare function decryptVaultState(envelope: VaultEnvelope, dek: Uint8Array): Promise<State>;
164
+ export {};
package/dist/vault.mjs CHANGED
@@ -8,13 +8,17 @@ import {
8
8
  deriveHKDFKey,
9
9
  deriveSecretCredentialAuthKey,
10
10
  deserialize,
11
+ deserializeState,
11
12
  getAccountName,
13
+ getUnknownFields,
12
14
  parseVaultEnvelope,
13
15
  principalFromPublicKey,
14
16
  principalToString,
15
17
  serialize,
18
+ serializeState,
19
+ setUnknownFields,
16
20
  unwrapDEK
17
- } from "./chunk-DBHL3BYB.mjs";
21
+ } from "./chunk-EZ5UFUMQ.mjs";
18
22
  import "./chunk-UOL3F6XQ.mjs";
19
23
  import "./chunk-2MD3FXKB.mjs";
20
24
  import "./chunk-IT5LLTMP.mjs";
@@ -31,10 +35,14 @@ export {
31
35
  deriveHKDFKey,
32
36
  deriveSecretCredentialAuthKey,
33
37
  deserialize,
38
+ deserializeState,
34
39
  getAccountName,
40
+ getUnknownFields,
35
41
  parseVaultEnvelope,
36
42
  principalFromPublicKey,
37
43
  principalToString,
38
44
  serialize,
45
+ serializeState,
46
+ setUnknownFields,
39
47
  unwrapDEK
40
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",