@solarpunkltd/swarm-id 0.0.0-stage → 0.8.1

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 (111) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +89 -2
  3. package/dist/bus/account-bus.d.ts +104 -0
  4. package/dist/bus/account-delta.d.ts +52 -0
  5. package/dist/bus/bus-context.d.ts +7 -0
  6. package/dist/bus/envelope.d.ts +9 -0
  7. package/dist/bus/messages.d.ts +241 -0
  8. package/dist/bus/presence.d.ts +62 -0
  9. package/dist/bus/signaling-transport.d.ts +79 -0
  10. package/dist/chunk/bmt.d.ts +16 -0
  11. package/dist/chunk/cac.d.ts +17 -0
  12. package/dist/chunk/constants.d.ts +10 -0
  13. package/dist/chunk/encrypted-cac.d.ts +47 -0
  14. package/dist/chunk/encryption.d.ts +85 -0
  15. package/dist/chunk/index.d.ts +5 -0
  16. package/dist/chunks/chat-binding-DO5aGhPl.js +23 -0
  17. package/dist/chunks/chat-binding-DO5aGhPl.js.map +1 -0
  18. package/dist/errors.d.ts +35 -0
  19. package/dist/index.d.ts +27 -0
  20. package/dist/internal.d.ts +49 -0
  21. package/dist/internal.esm.js +2 -0
  22. package/dist/internal.esm.js.map +1 -0
  23. package/dist/proxy/act/act.d.ts +58 -0
  24. package/dist/proxy/act/crypto.d.ts +46 -0
  25. package/dist/proxy/act/grantee-list.d.ts +81 -0
  26. package/dist/proxy/act/history.d.ts +182 -0
  27. package/dist/proxy/act/index.d.ts +114 -0
  28. package/dist/proxy/app-stamp-limits.d.ts +62 -0
  29. package/dist/proxy/chunk-upload-stream.d.ts +37 -0
  30. package/dist/proxy/chunking.d.ts +15 -0
  31. package/dist/proxy/collection.d.ts +38 -0
  32. package/dist/proxy/download-data.d.ts +27 -0
  33. package/dist/proxy/errors.d.ts +8 -0
  34. package/dist/proxy/feed-manifest.d.ts +60 -0
  35. package/dist/proxy/feeds/epochs/async-finder.d.ts +70 -0
  36. package/dist/proxy/feeds/epochs/epoch.d.ts +79 -0
  37. package/dist/proxy/feeds/epochs/finder.d.ts +60 -0
  38. package/dist/proxy/feeds/epochs/index.d.ts +30 -0
  39. package/dist/proxy/feeds/epochs/types.d.ts +110 -0
  40. package/dist/proxy/feeds/epochs/updater.d.ts +76 -0
  41. package/dist/proxy/feeds/epochs/utils.d.ts +21 -0
  42. package/dist/proxy/feeds/index.d.ts +4 -0
  43. package/dist/proxy/feeds/sequence/async-finder.d.ts +14 -0
  44. package/dist/proxy/feeds/sequence/finder.d.ts +11 -0
  45. package/dist/proxy/feeds/sequence/index.d.ts +22 -0
  46. package/dist/proxy/feeds/sequence/types.d.ts +82 -0
  47. package/dist/proxy/feeds/sequence/updater.d.ts +20 -0
  48. package/dist/proxy/index.d.ts +5 -0
  49. package/dist/proxy/manifest-builder.d.ts +164 -0
  50. package/dist/proxy/mantaray.d.ts +76 -0
  51. package/dist/proxy/soc-restamp-slots.d.ts +48 -0
  52. package/dist/proxy/stamp-chunk.d.ts +45 -0
  53. package/dist/proxy/stamp-worker-handler.d.ts +32 -0
  54. package/dist/proxy/stamp-worker-pool.d.ts +52 -0
  55. package/dist/proxy/stamp-worker.d.ts +1 -0
  56. package/dist/proxy/types.d.ts +38 -0
  57. package/dist/proxy/upload.d.ts +207 -0
  58. package/dist/schemas.d.ts +671 -0
  59. package/dist/stamp-worker.iife.js +1 -0
  60. package/dist/storage/debounced-uploader.d.ts +61 -0
  61. package/dist/storage/utilization-store.d.ts +113 -0
  62. package/dist/swarm-id-client.d.ts +1143 -0
  63. package/dist/swarm-id-proxy.d.ts +1079 -0
  64. package/dist/swarm-id.esm.js +2 -0
  65. package/dist/swarm-id.esm.js.map +1 -0
  66. package/dist/sync/batch-write-coordinator.d.ts +348 -0
  67. package/dist/sync/device-roster.d.ts +59 -0
  68. package/dist/sync/device-state.d.ts +199 -0
  69. package/dist/sync/fold-account-from-swarm.d.ts +53 -0
  70. package/dist/sync/index.d.ts +11 -0
  71. package/dist/sync/merge-snapshot.d.ts +57 -0
  72. package/dist/sync/partition-intent.d.ts +218 -0
  73. package/dist/sync/partition-lease.d.ts +531 -0
  74. package/dist/sync/partition-lock.d.ts +218 -0
  75. package/dist/sync/partition-state.d.ts +287 -0
  76. package/dist/sync/session-check.d.ts +29 -0
  77. package/dist/sync/store-interfaces.d.ts +48 -0
  78. package/dist/sync/sync-account.d.ts +45 -0
  79. package/dist/sync/timing-constants.d.ts +32 -0
  80. package/dist/sync/types.d.ts +18 -0
  81. package/dist/types.d.ts +3042 -0
  82. package/dist/utils/account-state-snapshot.d.ts +43 -0
  83. package/dist/utils/active-devices.d.ts +45 -0
  84. package/dist/utils/avatar.d.ts +30 -0
  85. package/dist/utils/batch-utilization.d.ts +840 -0
  86. package/dist/utils/batch-write-lock.d.ts +12 -0
  87. package/dist/utils/bee-error.d.ts +11 -0
  88. package/dist/utils/chat-binding.d.ts +113 -0
  89. package/dist/utils/coalesced-task.d.ts +28 -0
  90. package/dist/utils/collection.d.ts +6 -0
  91. package/dist/utils/connection-info.d.ts +11 -0
  92. package/dist/utils/constants.d.ts +28 -0
  93. package/dist/utils/device-id.d.ts +109 -0
  94. package/dist/utils/hex.d.ts +31 -0
  95. package/dist/utils/json-rpc.d.ts +34 -0
  96. package/dist/utils/key-derivation.d.ts +124 -0
  97. package/dist/utils/lock-soc.d.ts +35 -0
  98. package/dist/utils/postage-contract.d.ts +143 -0
  99. package/dist/utils/postage-stamp-association.d.ts +39 -0
  100. package/dist/utils/promise.d.ts +37 -0
  101. package/dist/utils/sealed-values.d.ts +23 -0
  102. package/dist/utils/seed-encryption.d.ts +17 -0
  103. package/dist/utils/site-allow-list.d.ts +54 -0
  104. package/dist/utils/stamp-lifespan.d.ts +37 -0
  105. package/dist/utils/storage-managers.d.ts +62 -0
  106. package/dist/utils/storage-probe.d.ts +40 -0
  107. package/dist/utils/tag.d.ts +11 -0
  108. package/dist/utils/ttl.d.ts +120 -0
  109. package/dist/utils/url.d.ts +55 -0
  110. package/dist/utils/versioned-storage.d.ts +183 -0
  111. package/package.json +91 -3
@@ -0,0 +1,671 @@
1
+ /**
2
+ * Entity Schemas with Zod
3
+ *
4
+ * Defines Zod schemas for storage entities with transforms to convert
5
+ * serialized primitives to bee-js runtime types. Types are derived using
6
+ * z.infer to guarantee schema/type consistency.
7
+ */
8
+ import { z } from "zod";
9
+ import { EthAddress, BatchId as BeeBatchId, PrivateKey as BeePrivateKey } from "@ethersphere/bee-js";
10
+ export declare const DEFAULT_BEE_NODE_URL = "https://api.gateway.ethswarm.org/";
11
+ export declare const DEFAULT_GNOSIS_RPC_URL = "https://xdai.fairdatasociety.org/";
12
+ export declare const ReferenceSchema: z.ZodString;
13
+ export declare const BatchIdSchema: z.ZodString;
14
+ export declare const AddressSchema: z.ZodString;
15
+ export declare const PrivateKeySchema: z.ZodString;
16
+ export declare const CompressedPublicKeySchema: z.ZodString;
17
+ export declare const EncryptionKeySchema: z.ZodString;
18
+ export declare const IdentifierSchema: z.ZodString;
19
+ export declare const SignatureSchema: z.ZodString;
20
+ export declare const ChunkAddressSchema: z.ZodString;
21
+ /** Batch id, index, timestamp and signature: 113 bytes, as Bee's `swarm-postage-stamp` header takes them */
22
+ export declare const MarshaledStampSchema: z.ZodString;
23
+ export declare const TimestampSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
24
+ export declare const FeedIndexSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
25
+ export type Reference = z.infer<typeof ReferenceSchema>;
26
+ export type BatchId = z.infer<typeof BatchIdSchema>;
27
+ export type Address = z.infer<typeof AddressSchema>;
28
+ export type PrivateKey = z.infer<typeof PrivateKeySchema>;
29
+ export type CompressedPublicKey = z.infer<typeof CompressedPublicKeySchema>;
30
+ export type Identifier = z.infer<typeof IdentifierSchema>;
31
+ export type Signature = z.infer<typeof SignatureSchema>;
32
+ export type Timestamp = z.infer<typeof TimestampSchema>;
33
+ export type FeedIndex = z.infer<typeof FeedIndexSchema>;
34
+ /**
35
+ * Device Schema V1
36
+ * Tracks devices that have accessed an account for multi-device support.
37
+ */
38
+ export declare const DeviceSchemaV1: z.ZodObject<{
39
+ deviceId: z.ZodString;
40
+ createdAt: z.ZodNumber;
41
+ lastSignedInAt: z.ZodNumber;
42
+ name: z.ZodOptional<z.ZodString>;
43
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
44
+ removedAt: z.ZodOptional<z.ZodNumber>;
45
+ }, z.core.$strip>;
46
+ /**
47
+ * Longer than any binding message can be: four short lines around a site
48
+ * origin, whose host is at most 253 characters. A bound on what is stored and
49
+ * carried, not a check of the format, which `verifyChatBinding` does.
50
+ */
51
+ export declare const CHAT_BINDING_MAX_LENGTH = 512;
52
+ /**
53
+ * The account's signed statement that the chat address on one site is its
54
+ * own (`utils/chat-binding.ts`, docs/Chat-Binding.md). Public, and true on
55
+ * every device of the account, so it travels with its connection rather than
56
+ * staying device-local like the app secret.
57
+ */
58
+ export declare const ChatBindingSchema: z.ZodObject<{
59
+ message: z.ZodString;
60
+ signature: z.ZodString;
61
+ }, z.core.$strip>;
62
+ /**
63
+ * Connected App Schema V1.
64
+ *
65
+ * Account-owned: keyed by `appUrl` within its owning account (the `identityId`
66
+ * pointer was removed when the identity tier was collapsed into the account).
67
+ */
68
+ export declare const ConnectedAppSchemaV1: z.ZodObject<{
69
+ appUrl: z.ZodString;
70
+ appName: z.ZodString;
71
+ lastConnectedAt: z.ZodNumber;
72
+ appIcon: z.ZodOptional<z.ZodString>;
73
+ appDescription: z.ZodOptional<z.ZodString>;
74
+ connectedUntil: z.ZodOptional<z.ZodNumber>;
75
+ appSecret: z.ZodOptional<z.ZodString>;
76
+ postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
77
+ postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
78
+ revokedAt: z.ZodOptional<z.ZodNumber>;
79
+ disconnectedAt: z.ZodOptional<z.ZodNumber>;
80
+ chatBinding: z.ZodOptional<z.ZodObject<{
81
+ message: z.ZodString;
82
+ signature: z.ZodString;
83
+ }, z.core.$strip>>;
84
+ }, z.core.$strip>;
85
+ /**
86
+ * Postage Stamp Schema V1
87
+ */
88
+ export declare const PostageStampSchemaV1: z.ZodObject<{
89
+ batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
90
+ signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
91
+ name: z.ZodOptional<z.ZodString>;
92
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
93
+ utilization: z.ZodNumber;
94
+ usable: z.ZodBoolean;
95
+ depth: z.ZodNumber;
96
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
97
+ bucketDepth: z.ZodNumber;
98
+ blockNumber: z.ZodNumber;
99
+ immutableFlag: z.ZodBoolean;
100
+ exists: z.ZodBoolean;
101
+ batchTTL: z.ZodOptional<z.ZodNumber>;
102
+ createdAt: z.ZodNumber;
103
+ updatedAt: z.ZodOptional<z.ZodNumber>;
104
+ deletedAt: z.ZodOptional<z.ZodNumber>;
105
+ }, z.core.$strip>;
106
+ /**
107
+ * Access Method Schema V1
108
+ *
109
+ * Every account is a BIP-39 seed account; the access method is simply HOW that
110
+ * seed is protected/encrypted at rest on this device (and thus how it is
111
+ * unlocked). Fields are device-local crypto material (plain hex / numbers) —
112
+ * never bee-js byte classes — so they round-trip as-is. Paired with
113
+ * `encryptedSeed` on the account.
114
+ *
115
+ * The eth-wallet method stores only the encryption salt — NOT the wallet
116
+ * address: a wrong wallet simply fails to decrypt the seed, and the account's
117
+ * own `id` is already the address of its (BIP-39) key, so a separate wallet
118
+ * address would be redundant.
119
+ */
120
+ export declare const AccessMethodSchemaV1: z.ZodDiscriminatedUnion<[z.ZodObject<{
121
+ type: z.ZodLiteral<"passkey">;
122
+ credentialId: z.ZodString;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ type: z.ZodLiteral<"eth-wallet">;
125
+ encryptionSalt: z.ZodString;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ type: z.ZodLiteral<"password">;
128
+ kdfSalt: z.ZodString;
129
+ kdfIterations: z.ZodNumber;
130
+ }, z.core.$strip>], "type">;
131
+ /**
132
+ * Local Vault Schema V1
133
+ *
134
+ * The device-local seed vault. Every account is a BIP-39 seed account: `access`
135
+ * records how the seed is protected/unlocked on THIS device (passkey /
136
+ * eth-wallet / password) and `encryptedSeed` is that seed encrypted at rest
137
+ * under the key the access method derives (hex: IV || ciphertext — width varies
138
+ * with the seed size: 12-word seed → 88 chars, 24-word → 120, so no fixed
139
+ * length). The vault never leaves the device: `SyncedAccountSchemaV1` has no
140
+ * vault fields. A sign-out RETAINS the vault (it is encrypted at rest) while
141
+ * stripping the synced data, so signing back in only takes the access method.
142
+ */
143
+ export declare const LocalVaultSchemaV1: z.ZodObject<{
144
+ access: z.ZodDiscriminatedUnion<[z.ZodObject<{
145
+ type: z.ZodLiteral<"passkey">;
146
+ credentialId: z.ZodString;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ type: z.ZodLiteral<"eth-wallet">;
149
+ encryptionSalt: z.ZodString;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ type: z.ZodLiteral<"password">;
152
+ kdfSalt: z.ZodString;
153
+ kdfIterations: z.ZodNumber;
154
+ }, z.core.$strip>], "type">;
155
+ encryptedSeed: z.ZodString;
156
+ }, z.core.$strip>;
157
+ /**
158
+ * Synced Account Schema V1
159
+ *
160
+ * The single, unified account model. There is exactly one kind of account: a
161
+ * BIP-39 seed account. What used to be distinct `type`s (passkey / ethereum /
162
+ * agent) were really just different ways of protecting the seed — now expressed
163
+ * uniformly by the device-local vault (`LocalVaultSchemaV1`). No `type`
164
+ * discriminant remains.
165
+ *
166
+ * This is the portable projection of the account — every field that may travel
167
+ * off the device, and nothing device-local. Backup files serialize/parse it
168
+ * directly and the sync feed carries the same shape (serialize with
169
+ * `serializeSyncedAccount`, which additionally strips the live per-app session
170
+ * material). What localStorage holds is `LocalAccountSchemaV1` = this plus the
171
+ * device-local tail.
172
+ *
173
+ * The account is the single-level aggregate root (the identity tier was
174
+ * collapsed into it). It is the app-facing identity: `id` is the address apps
175
+ * connect to and `publicKey` is surfaced to dApps. Apps receive a per-app
176
+ * DERIVED key (`deriveSecret(masterKey, appOrigin)` → app key) — never the
177
+ * account private key, which is the mnemonic-equivalent root and is exposed only
178
+ * after an explicit permission/signing request. The account OWNS its connected
179
+ * apps and postage stamps as nested collections rather than via foreign-key
180
+ * pointers.
181
+ */
182
+ export declare const SyncedAccountSchemaV1: z.ZodObject<{
183
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
184
+ name: z.ZodString;
185
+ createdAt: z.ZodNumber;
186
+ derivationKey: z.ZodString;
187
+ publicKey: z.ZodString;
188
+ defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
189
+ devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
190
+ deviceId: z.ZodString;
191
+ createdAt: z.ZodNumber;
192
+ lastSignedInAt: z.ZodNumber;
193
+ name: z.ZodOptional<z.ZodString>;
194
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
195
+ removedAt: z.ZodOptional<z.ZodNumber>;
196
+ }, z.core.$strip>>>;
197
+ connectedApps: z.ZodDefault<z.ZodArray<z.ZodObject<{
198
+ appUrl: z.ZodString;
199
+ appName: z.ZodString;
200
+ lastConnectedAt: z.ZodNumber;
201
+ appIcon: z.ZodOptional<z.ZodString>;
202
+ appDescription: z.ZodOptional<z.ZodString>;
203
+ connectedUntil: z.ZodOptional<z.ZodNumber>;
204
+ appSecret: z.ZodOptional<z.ZodString>;
205
+ postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
206
+ postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
207
+ revokedAt: z.ZodOptional<z.ZodNumber>;
208
+ disconnectedAt: z.ZodOptional<z.ZodNumber>;
209
+ chatBinding: z.ZodOptional<z.ZodObject<{
210
+ message: z.ZodString;
211
+ signature: z.ZodString;
212
+ }, z.core.$strip>>;
213
+ }, z.core.$strip>>>;
214
+ postageStamps: z.ZodDefault<z.ZodArray<z.ZodObject<{
215
+ batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
216
+ signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
217
+ name: z.ZodOptional<z.ZodString>;
218
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
219
+ utilization: z.ZodNumber;
220
+ usable: z.ZodBoolean;
221
+ depth: z.ZodNumber;
222
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
223
+ bucketDepth: z.ZodNumber;
224
+ blockNumber: z.ZodNumber;
225
+ immutableFlag: z.ZodBoolean;
226
+ exists: z.ZodBoolean;
227
+ batchTTL: z.ZodOptional<z.ZodNumber>;
228
+ createdAt: z.ZodNumber;
229
+ updatedAt: z.ZodOptional<z.ZodNumber>;
230
+ deletedAt: z.ZodOptional<z.ZodNumber>;
231
+ }, z.core.$strip>>>;
232
+ settings: z.ZodOptional<z.ZodObject<{
233
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
234
+ }, z.core.$strip>>;
235
+ accountNameAt: z.ZodOptional<z.ZodNumber>;
236
+ defaultStampAt: z.ZodOptional<z.ZodNumber>;
237
+ settingsAt: z.ZodOptional<z.ZodNumber>;
238
+ lastModified: z.ZodOptional<z.ZodNumber>;
239
+ partitionCount: z.ZodOptional<z.ZodNumber>;
240
+ }, z.core.$strip>;
241
+ /**
242
+ * Signed-in variant: the synced data plus the device vault. `signedOutAt` is
243
+ * declared undefined-only (not merely omitted) so a record carrying BOTH a
244
+ * vault and a sign-out marker fails this variant — and the signed-out one —
245
+ * and is quarantined at load, instead of silently parsing as signed-in and
246
+ * dropping the marker.
247
+ */
248
+ declare const SignedInAccountSchemaV1: z.ZodObject<{
249
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
250
+ name: z.ZodString;
251
+ createdAt: z.ZodNumber;
252
+ derivationKey: z.ZodString;
253
+ publicKey: z.ZodString;
254
+ defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
255
+ devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
256
+ deviceId: z.ZodString;
257
+ createdAt: z.ZodNumber;
258
+ lastSignedInAt: z.ZodNumber;
259
+ name: z.ZodOptional<z.ZodString>;
260
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
261
+ removedAt: z.ZodOptional<z.ZodNumber>;
262
+ }, z.core.$strip>>>;
263
+ connectedApps: z.ZodDefault<z.ZodArray<z.ZodObject<{
264
+ appUrl: z.ZodString;
265
+ appName: z.ZodString;
266
+ lastConnectedAt: z.ZodNumber;
267
+ appIcon: z.ZodOptional<z.ZodString>;
268
+ appDescription: z.ZodOptional<z.ZodString>;
269
+ connectedUntil: z.ZodOptional<z.ZodNumber>;
270
+ appSecret: z.ZodOptional<z.ZodString>;
271
+ postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
272
+ postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
273
+ revokedAt: z.ZodOptional<z.ZodNumber>;
274
+ disconnectedAt: z.ZodOptional<z.ZodNumber>;
275
+ chatBinding: z.ZodOptional<z.ZodObject<{
276
+ message: z.ZodString;
277
+ signature: z.ZodString;
278
+ }, z.core.$strip>>;
279
+ }, z.core.$strip>>>;
280
+ postageStamps: z.ZodDefault<z.ZodArray<z.ZodObject<{
281
+ batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
282
+ signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
283
+ name: z.ZodOptional<z.ZodString>;
284
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
285
+ utilization: z.ZodNumber;
286
+ usable: z.ZodBoolean;
287
+ depth: z.ZodNumber;
288
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
289
+ bucketDepth: z.ZodNumber;
290
+ blockNumber: z.ZodNumber;
291
+ immutableFlag: z.ZodBoolean;
292
+ exists: z.ZodBoolean;
293
+ batchTTL: z.ZodOptional<z.ZodNumber>;
294
+ createdAt: z.ZodNumber;
295
+ updatedAt: z.ZodOptional<z.ZodNumber>;
296
+ deletedAt: z.ZodOptional<z.ZodNumber>;
297
+ }, z.core.$strip>>>;
298
+ settings: z.ZodOptional<z.ZodObject<{
299
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
300
+ }, z.core.$strip>>;
301
+ accountNameAt: z.ZodOptional<z.ZodNumber>;
302
+ defaultStampAt: z.ZodOptional<z.ZodNumber>;
303
+ settingsAt: z.ZodOptional<z.ZodNumber>;
304
+ lastModified: z.ZodOptional<z.ZodNumber>;
305
+ partitionCount: z.ZodOptional<z.ZodNumber>;
306
+ signedOutAt: z.ZodOptional<z.ZodUndefined>;
307
+ access: z.ZodDiscriminatedUnion<[z.ZodObject<{
308
+ type: z.ZodLiteral<"passkey">;
309
+ credentialId: z.ZodString;
310
+ }, z.core.$strip>, z.ZodObject<{
311
+ type: z.ZodLiteral<"eth-wallet">;
312
+ encryptionSalt: z.ZodString;
313
+ }, z.core.$strip>, z.ZodObject<{
314
+ type: z.ZodLiteral<"password">;
315
+ kdfSalt: z.ZodString;
316
+ kdfIterations: z.ZodNumber;
317
+ }, z.core.$strip>], "type">;
318
+ encryptedSeed: z.ZodString;
319
+ }, z.core.$strip>;
320
+ /**
321
+ * Signed-out variant: the minimal remnant of a sign-out. The vault SURVIVES
322
+ * (it is encrypted at rest, so retaining it matches the sign-out security
323
+ * posture) and lets the user sign back in with the existing access method —
324
+ * no recovery phrase. The synced state (collections, settings, clocks, and
325
+ * the secret `derivationKey`) is stripped from disk as PLAINTEXT but kept as
326
+ * `encryptedState`: an AES-GCM snapshot keyed off the derivation-key chain,
327
+ * decrypted and restored on sign-back-in so a sign-out can never lose data —
328
+ * even offline or when the Swarm copy is gone. Absent only on a record signed
329
+ * out because its sealed keys could not be opened on this device (the
330
+ * wrapping key was lost), where sign-back-in restores from Swarm. The display
331
+ * fields (`name`, `createdAt`) stay so the account chooser can list the row.
332
+ * Being a plain object (not a `SyncedAccountSchemaV1` extension), parsing a
333
+ * pre-shrink record under this arm strips its plaintext synced fields.
334
+ */
335
+ declare const SignedOutAccountSchemaV1: z.ZodObject<{
336
+ encryptedState: z.ZodOptional<z.ZodString>;
337
+ storageWarning: z.ZodOptional<z.ZodBoolean>;
338
+ soonestDriveExpiry: z.ZodOptional<z.ZodNumber>;
339
+ signedOutAt: z.ZodNumber;
340
+ access: z.ZodDiscriminatedUnion<[z.ZodObject<{
341
+ type: z.ZodLiteral<"passkey">;
342
+ credentialId: z.ZodString;
343
+ }, z.core.$strip>, z.ZodObject<{
344
+ type: z.ZodLiteral<"eth-wallet">;
345
+ encryptionSalt: z.ZodString;
346
+ }, z.core.$strip>, z.ZodObject<{
347
+ type: z.ZodLiteral<"password">;
348
+ kdfSalt: z.ZodString;
349
+ kdfIterations: z.ZodNumber;
350
+ }, z.core.$strip>], "type">;
351
+ encryptedSeed: z.ZodString;
352
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
353
+ name: z.ZodString;
354
+ createdAt: z.ZodNumber;
355
+ }, z.core.$strip>;
356
+ /**
357
+ * Local Account Schema V1 — parse entrypoint for stored account records (what
358
+ * localStorage holds), modeled as a union so the signed-in/signed-out states
359
+ * are encoded in the data itself: a signed-in account is the synced projection
360
+ * plus the vault and no `signedOutAt`; a signed-out one is the minimal remnant
361
+ * (display fields + vault) with `signedOutAt` set. Both carry the vault —
362
+ * `signedOutAt` presence alone discriminates; vault-less records (the
363
+ * pre-retention sign-out shape) fail both arms and are quarantined.
364
+ *
365
+ * This only validates at parse (load) time — the accounts loader SKIPS a
366
+ * violating record rather than failing the document — but unlike a refinement
367
+ * the union also carries into the TYPE system: `Account` is a discriminated
368
+ * union (discriminate on `signedOutAt` presence, or narrow with
369
+ * `isSignedOutAccount`), so writers can't produce a half-signed-out record
370
+ * without a type error.
371
+ */
372
+ export declare const LocalAccountSchemaV1: z.ZodUnion<readonly [z.ZodObject<{
373
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
374
+ name: z.ZodString;
375
+ createdAt: z.ZodNumber;
376
+ derivationKey: z.ZodString;
377
+ publicKey: z.ZodString;
378
+ defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
379
+ devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
380
+ deviceId: z.ZodString;
381
+ createdAt: z.ZodNumber;
382
+ lastSignedInAt: z.ZodNumber;
383
+ name: z.ZodOptional<z.ZodString>;
384
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
385
+ removedAt: z.ZodOptional<z.ZodNumber>;
386
+ }, z.core.$strip>>>;
387
+ connectedApps: z.ZodDefault<z.ZodArray<z.ZodObject<{
388
+ appUrl: z.ZodString;
389
+ appName: z.ZodString;
390
+ lastConnectedAt: z.ZodNumber;
391
+ appIcon: z.ZodOptional<z.ZodString>;
392
+ appDescription: z.ZodOptional<z.ZodString>;
393
+ connectedUntil: z.ZodOptional<z.ZodNumber>;
394
+ appSecret: z.ZodOptional<z.ZodString>;
395
+ postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
396
+ postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
397
+ revokedAt: z.ZodOptional<z.ZodNumber>;
398
+ disconnectedAt: z.ZodOptional<z.ZodNumber>;
399
+ chatBinding: z.ZodOptional<z.ZodObject<{
400
+ message: z.ZodString;
401
+ signature: z.ZodString;
402
+ }, z.core.$strip>>;
403
+ }, z.core.$strip>>>;
404
+ postageStamps: z.ZodDefault<z.ZodArray<z.ZodObject<{
405
+ batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
406
+ signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
407
+ name: z.ZodOptional<z.ZodString>;
408
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
409
+ utilization: z.ZodNumber;
410
+ usable: z.ZodBoolean;
411
+ depth: z.ZodNumber;
412
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
413
+ bucketDepth: z.ZodNumber;
414
+ blockNumber: z.ZodNumber;
415
+ immutableFlag: z.ZodBoolean;
416
+ exists: z.ZodBoolean;
417
+ batchTTL: z.ZodOptional<z.ZodNumber>;
418
+ createdAt: z.ZodNumber;
419
+ updatedAt: z.ZodOptional<z.ZodNumber>;
420
+ deletedAt: z.ZodOptional<z.ZodNumber>;
421
+ }, z.core.$strip>>>;
422
+ settings: z.ZodOptional<z.ZodObject<{
423
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
424
+ }, z.core.$strip>>;
425
+ accountNameAt: z.ZodOptional<z.ZodNumber>;
426
+ defaultStampAt: z.ZodOptional<z.ZodNumber>;
427
+ settingsAt: z.ZodOptional<z.ZodNumber>;
428
+ lastModified: z.ZodOptional<z.ZodNumber>;
429
+ partitionCount: z.ZodOptional<z.ZodNumber>;
430
+ signedOutAt: z.ZodOptional<z.ZodUndefined>;
431
+ access: z.ZodDiscriminatedUnion<[z.ZodObject<{
432
+ type: z.ZodLiteral<"passkey">;
433
+ credentialId: z.ZodString;
434
+ }, z.core.$strip>, z.ZodObject<{
435
+ type: z.ZodLiteral<"eth-wallet">;
436
+ encryptionSalt: z.ZodString;
437
+ }, z.core.$strip>, z.ZodObject<{
438
+ type: z.ZodLiteral<"password">;
439
+ kdfSalt: z.ZodString;
440
+ kdfIterations: z.ZodNumber;
441
+ }, z.core.$strip>], "type">;
442
+ encryptedSeed: z.ZodString;
443
+ }, z.core.$strip>, z.ZodObject<{
444
+ encryptedState: z.ZodOptional<z.ZodString>;
445
+ storageWarning: z.ZodOptional<z.ZodBoolean>;
446
+ soonestDriveExpiry: z.ZodOptional<z.ZodNumber>;
447
+ signedOutAt: z.ZodNumber;
448
+ access: z.ZodDiscriminatedUnion<[z.ZodObject<{
449
+ type: z.ZodLiteral<"passkey">;
450
+ credentialId: z.ZodString;
451
+ }, z.core.$strip>, z.ZodObject<{
452
+ type: z.ZodLiteral<"eth-wallet">;
453
+ encryptionSalt: z.ZodString;
454
+ }, z.core.$strip>, z.ZodObject<{
455
+ type: z.ZodLiteral<"password">;
456
+ kdfSalt: z.ZodString;
457
+ kdfIterations: z.ZodNumber;
458
+ }, z.core.$strip>], "type">;
459
+ encryptedSeed: z.ZodString;
460
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
461
+ name: z.ZodString;
462
+ createdAt: z.ZodNumber;
463
+ }, z.core.$strip>]>;
464
+ /**
465
+ * Account Metadata Schema V1
466
+ */
467
+ export declare const AccountMetadataSchemaV1: z.ZodObject<{
468
+ accountName: z.ZodString;
469
+ defaultPostageStampBatchID: z.ZodOptional<z.ZodString>;
470
+ publicKey: z.ZodString;
471
+ settings: z.ZodOptional<z.ZodObject<{
472
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
473
+ }, z.core.$strip>>;
474
+ accountNameAt: z.ZodOptional<z.ZodNumber>;
475
+ defaultStampAt: z.ZodOptional<z.ZodNumber>;
476
+ settingsAt: z.ZodOptional<z.ZodNumber>;
477
+ createdAt: z.ZodNumber;
478
+ lastModified: z.ZodNumber;
479
+ devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
480
+ deviceId: z.ZodString;
481
+ createdAt: z.ZodNumber;
482
+ lastSignedInAt: z.ZodNumber;
483
+ name: z.ZodOptional<z.ZodString>;
484
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
485
+ removedAt: z.ZodOptional<z.ZodNumber>;
486
+ }, z.core.$strip>>>;
487
+ partitionCount: z.ZodDefault<z.ZodNumber>;
488
+ }, z.core.$strip>;
489
+ /**
490
+ * Unified account state snapshot schema used by both file export and Swarm sync.
491
+ *
492
+ * Wire/export projection of the nested account: metadata (non-secret account
493
+ * fields) plus the account-owned `connectedApps` and `postageStamps`. Account
494
+ * secrets (`derivationKey`, `credentialId`, ethereum encrypted fields) are
495
+ * deliberately excluded — only `metadata` + the nested collections travel.
496
+ */
497
+ export declare const AccountStateSnapshotSchemaV1: z.ZodObject<{
498
+ version: z.ZodLiteral<1>;
499
+ timestamp: z.ZodNumber;
500
+ accountId: z.ZodString;
501
+ metadata: z.ZodObject<{
502
+ accountName: z.ZodString;
503
+ defaultPostageStampBatchID: z.ZodOptional<z.ZodString>;
504
+ publicKey: z.ZodString;
505
+ settings: z.ZodOptional<z.ZodObject<{
506
+ appSessionDuration: z.ZodOptional<z.ZodNumber>;
507
+ }, z.core.$strip>>;
508
+ accountNameAt: z.ZodOptional<z.ZodNumber>;
509
+ defaultStampAt: z.ZodOptional<z.ZodNumber>;
510
+ settingsAt: z.ZodOptional<z.ZodNumber>;
511
+ createdAt: z.ZodNumber;
512
+ lastModified: z.ZodNumber;
513
+ devices: z.ZodDefault<z.ZodArray<z.ZodObject<{
514
+ deviceId: z.ZodString;
515
+ createdAt: z.ZodNumber;
516
+ lastSignedInAt: z.ZodNumber;
517
+ name: z.ZodOptional<z.ZodString>;
518
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
519
+ removedAt: z.ZodOptional<z.ZodNumber>;
520
+ }, z.core.$strip>>>;
521
+ partitionCount: z.ZodDefault<z.ZodNumber>;
522
+ }, z.core.$strip>;
523
+ connectedApps: z.ZodArray<z.ZodObject<{
524
+ appUrl: z.ZodString;
525
+ appName: z.ZodString;
526
+ lastConnectedAt: z.ZodNumber;
527
+ appIcon: z.ZodOptional<z.ZodString>;
528
+ appDescription: z.ZodOptional<z.ZodString>;
529
+ connectedUntil: z.ZodOptional<z.ZodNumber>;
530
+ appSecret: z.ZodOptional<z.ZodString>;
531
+ postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
532
+ postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
533
+ revokedAt: z.ZodOptional<z.ZodNumber>;
534
+ disconnectedAt: z.ZodOptional<z.ZodNumber>;
535
+ chatBinding: z.ZodOptional<z.ZodObject<{
536
+ message: z.ZodString;
537
+ signature: z.ZodString;
538
+ }, z.core.$strip>>;
539
+ }, z.core.$strip>>;
540
+ postageStamps: z.ZodArray<z.ZodObject<{
541
+ batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
542
+ signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
543
+ name: z.ZodOptional<z.ZodString>;
544
+ nameUpdatedAt: z.ZodOptional<z.ZodNumber>;
545
+ utilization: z.ZodNumber;
546
+ usable: z.ZodBoolean;
547
+ depth: z.ZodNumber;
548
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
549
+ bucketDepth: z.ZodNumber;
550
+ blockNumber: z.ZodNumber;
551
+ immutableFlag: z.ZodBoolean;
552
+ exists: z.ZodBoolean;
553
+ batchTTL: z.ZodOptional<z.ZodNumber>;
554
+ createdAt: z.ZodNumber;
555
+ updatedAt: z.ZodOptional<z.ZodNumber>;
556
+ deletedAt: z.ZodOptional<z.ZodNumber>;
557
+ }, z.core.$strip>>;
558
+ }, z.core.$strip>;
559
+ export type Device = z.infer<typeof DeviceSchemaV1>;
560
+ export type AccessMethod = z.infer<typeof AccessMethodSchemaV1>;
561
+ export type LocalVault = z.infer<typeof LocalVaultSchemaV1>;
562
+ export type SyncedAccount = z.infer<typeof SyncedAccountSchemaV1>;
563
+ export type SignedInAccount = z.infer<typeof SignedInAccountSchemaV1>;
564
+ export type SignedOutAccount = z.infer<typeof SignedOutAccountSchemaV1>;
565
+ /** The local (on-device) account record: `SignedInAccount | SignedOutAccount`. */
566
+ export type Account = z.infer<typeof LocalAccountSchemaV1>;
567
+ export type ConnectedApp = z.infer<typeof ConnectedAppSchemaV1>;
568
+ export type PostageStamp = z.infer<typeof PostageStampSchemaV1>;
569
+ export type AccountMetadata = z.infer<typeof AccountMetadataSchemaV1>;
570
+ export type AccountStateSnapshot = z.infer<typeof AccountStateSnapshotSchemaV1>;
571
+ /**
572
+ * An account is "signed out" on this device when `signedOutAt` is set: the
573
+ * synced data was stripped from disk, but the encrypted vault survives, so the
574
+ * user signs back in with the existing access method (which re-derives and
575
+ * re-folds the rest). Narrows: the true branch exposes `signedOutAt` as a
576
+ * number; the vault fields are non-optional on BOTH branches.
577
+ */
578
+ export declare function isSignedOutAccount(account: Account): account is SignedOutAccount;
579
+ /**
580
+ * Fencing token for the partition lock. Two writers with equal `timestampMs`
581
+ * are ordered by `tiebreaker` (hex of the first 8 bytes of
582
+ * `keccak256(deviceId)`).
583
+ */
584
+ export declare const PartitionLockGenerationSchemaV1: z.ZodObject<{
585
+ timestampMs: z.ZodNumber;
586
+ tiebreaker: z.ZodString;
587
+ }, z.core.$strip>;
588
+ /**
589
+ * Payload stored (as encrypted JSON) in a partition-lock SOC. The format is
590
+ * versioned by the SOC identifier domain (`swarm-id-partition-lock-v1`), so no
591
+ * in-payload version field is needed. `holderDeviceId` is `""` for the
592
+ * `NO_HOLDER_DEVICE_ID` sentinel (e.g. after an explicit release).
593
+ */
594
+ export declare const PartitionLockPayloadSchemaV1: z.ZodObject<{
595
+ holderDeviceId: z.ZodString;
596
+ generation: z.ZodObject<{
597
+ timestampMs: z.ZodNumber;
598
+ tiebreaker: z.ZodString;
599
+ }, z.core.$strip>;
600
+ acquiredAt: z.ZodNumber;
601
+ leasedUntil: z.ZodNumber;
602
+ }, z.core.$strip>;
603
+ export type PartitionLockGeneration = z.infer<typeof PartitionLockGenerationSchemaV1>;
604
+ export type PartitionLockPayload = z.infer<typeof PartitionLockPayloadSchemaV1>;
605
+ /**
606
+ * Payload stored (as encrypted JSON) in a per-device partition-INTENT SOC,
607
+ * which doubles as a holder PRESENCE BEACON. Written before a fresh claim so
608
+ * rival contenders agree on a single winner by `generation`, AND re-published
609
+ * by the holder on every refresh tick so a later joiner can detect the live
610
+ * holder — both via a fresh per-epoch address that forces a network retrieval
611
+ * (bypassing the gateway's frozen lock-SOC cache). `deviceId` is carried for
612
+ * diagnostics (the address already encodes it). `leasedUntil` is present on a
613
+ * heartbeat so a reader can apply the same `leasedUntil > now` liveness test
614
+ * the lock SOC uses; it is omitted on a legacy pre-claim intent (then the
615
+ * reader falls back to epoch-bucket freshness).
616
+ */
617
+ export declare const PartitionIntentPayloadSchemaV1: z.ZodObject<{
618
+ deviceId: z.ZodString;
619
+ generation: z.ZodObject<{
620
+ timestampMs: z.ZodNumber;
621
+ tiebreaker: z.ZodString;
622
+ }, z.core.$strip>;
623
+ leasedUntil: z.ZodOptional<z.ZodNumber>;
624
+ }, z.core.$strip>;
625
+ export type PartitionIntentPayload = z.infer<typeof PartitionIntentPayloadSchemaV1>;
626
+ /**
627
+ * Network Settings Schema V1
628
+ * Stores user-configurable network endpoints (Bee node and Gnosis RPC)
629
+ */
630
+ export declare const NetworkSettingsSchemaV1: z.ZodObject<{
631
+ beeNodeUrl: z.ZodString;
632
+ gnosisRpcUrl: z.ZodString;
633
+ }, z.core.$strip>;
634
+ export type NetworkSettings = z.infer<typeof NetworkSettingsSchemaV1>;
635
+ /**
636
+ * A Bee address a site gives the frame for its own session (`beeApiUrl` on
637
+ * `parentIdentify` and `setBeeApiUrl`). Never stored: it lives in the frame
638
+ * that site embeds, and only while it is open.
639
+ */
640
+ export declare const BeeApiUrlSchema: z.ZodString;
641
+ /**
642
+ * Bucket update entry for cross-tab synchronization
643
+ */
644
+ export declare const BucketUpdateSchema: z.ZodObject<{
645
+ index: z.ZodNumber;
646
+ value: z.ZodNumber;
647
+ }, z.core.$strip>;
648
+ /**
649
+ * Utilization update broadcast on the account bus after a write.
650
+ *
651
+ * `buckets` carry the writer's PER-PARTITION counter `j`, not an absolute slot
652
+ * — the physical slot is `partitionCount + partition + partitionCount·j`
653
+ * (`dataSlot`, `utils/batch-utilization.ts`). So a delta is only foldable by a
654
+ * context bound to the SAME lane, and the lane travels with the message: the
655
+ * bus reaches other devices, which hold other partitions of the same batch, and
656
+ * folding their `j` in would skip the receiver past its own unused slots.
657
+ * Legacy single-partition writers publish `partition: 0, partitionCount: 1`.
658
+ */
659
+ export declare const UtilizationUpdateMessageSchema: z.ZodObject<{
660
+ type: z.ZodLiteral<"utilization-updated">;
661
+ batchId: z.ZodString;
662
+ partition: z.ZodNumber;
663
+ partitionCount: z.ZodNumber;
664
+ buckets: z.ZodArray<z.ZodObject<{
665
+ index: z.ZodNumber;
666
+ value: z.ZodNumber;
667
+ }, z.core.$strip>>;
668
+ }, z.core.$strip>;
669
+ export type BucketUpdate = z.infer<typeof BucketUpdateSchema>;
670
+ export type UtilizationUpdateMessage = z.infer<typeof UtilizationUpdateMessageSchema>;
671
+ export {};