@snaha/swarm-id 0.0.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.
- package/README.md +431 -0
- package/dist/chunk/bmt.d.ts +17 -0
- package/dist/chunk/bmt.d.ts.map +1 -0
- package/dist/chunk/cac.d.ts +18 -0
- package/dist/chunk/cac.d.ts.map +1 -0
- package/dist/chunk/constants.d.ts +10 -0
- package/dist/chunk/constants.d.ts.map +1 -0
- package/dist/chunk/encrypted-cac.d.ts +48 -0
- package/dist/chunk/encrypted-cac.d.ts.map +1 -0
- package/dist/chunk/encryption.d.ts +86 -0
- package/dist/chunk/encryption.d.ts.map +1 -0
- package/dist/chunk/index.d.ts +6 -0
- package/dist/chunk/index.d.ts.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/proxy/act/act.d.ts +78 -0
- package/dist/proxy/act/act.d.ts.map +1 -0
- package/dist/proxy/act/crypto.d.ts +44 -0
- package/dist/proxy/act/crypto.d.ts.map +1 -0
- package/dist/proxy/act/grantee-list.d.ts +82 -0
- package/dist/proxy/act/grantee-list.d.ts.map +1 -0
- package/dist/proxy/act/history.d.ts +183 -0
- package/dist/proxy/act/history.d.ts.map +1 -0
- package/dist/proxy/act/index.d.ts +104 -0
- package/dist/proxy/act/index.d.ts.map +1 -0
- package/dist/proxy/chunking-encrypted.d.ts +14 -0
- package/dist/proxy/chunking-encrypted.d.ts.map +1 -0
- package/dist/proxy/chunking.d.ts +15 -0
- package/dist/proxy/chunking.d.ts.map +1 -0
- package/dist/proxy/download-data.d.ts +16 -0
- package/dist/proxy/download-data.d.ts.map +1 -0
- package/dist/proxy/feed-manifest.d.ts +62 -0
- package/dist/proxy/feed-manifest.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/async-finder.d.ts +77 -0
- package/dist/proxy/feeds/epochs/async-finder.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/epoch.d.ts +88 -0
- package/dist/proxy/feeds/epochs/epoch.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/finder.d.ts +67 -0
- package/dist/proxy/feeds/epochs/finder.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/index.d.ts +35 -0
- package/dist/proxy/feeds/epochs/index.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/test-utils.d.ts +93 -0
- package/dist/proxy/feeds/epochs/test-utils.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/types.d.ts +109 -0
- package/dist/proxy/feeds/epochs/types.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/updater.d.ts +68 -0
- package/dist/proxy/feeds/epochs/updater.d.ts.map +1 -0
- package/dist/proxy/feeds/epochs/utils.d.ts +22 -0
- package/dist/proxy/feeds/epochs/utils.d.ts.map +1 -0
- package/dist/proxy/feeds/index.d.ts +5 -0
- package/dist/proxy/feeds/index.d.ts.map +1 -0
- package/dist/proxy/feeds/sequence/async-finder.d.ts +14 -0
- package/dist/proxy/feeds/sequence/async-finder.d.ts.map +1 -0
- package/dist/proxy/feeds/sequence/finder.d.ts +17 -0
- package/dist/proxy/feeds/sequence/finder.d.ts.map +1 -0
- package/dist/proxy/feeds/sequence/index.d.ts +23 -0
- package/dist/proxy/feeds/sequence/index.d.ts.map +1 -0
- package/dist/proxy/feeds/sequence/types.d.ts +80 -0
- package/dist/proxy/feeds/sequence/types.d.ts.map +1 -0
- package/dist/proxy/feeds/sequence/updater.d.ts +26 -0
- package/dist/proxy/feeds/sequence/updater.d.ts.map +1 -0
- package/dist/proxy/index.d.ts +6 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/manifest-builder.d.ts +183 -0
- package/dist/proxy/manifest-builder.d.ts.map +1 -0
- package/dist/proxy/mantaray-encrypted.d.ts +27 -0
- package/dist/proxy/mantaray-encrypted.d.ts.map +1 -0
- package/dist/proxy/mantaray.d.ts +26 -0
- package/dist/proxy/mantaray.d.ts.map +1 -0
- package/dist/proxy/types.d.ts +29 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/upload-data.d.ts +17 -0
- package/dist/proxy/upload-data.d.ts.map +1 -0
- package/dist/proxy/upload-encrypted-data.d.ts +103 -0
- package/dist/proxy/upload-encrypted-data.d.ts.map +1 -0
- package/dist/schemas.d.ts +240 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/storage/debounced-uploader.d.ts +62 -0
- package/dist/storage/debounced-uploader.d.ts.map +1 -0
- package/dist/storage/utilization-store.d.ts +108 -0
- package/dist/storage/utilization-store.d.ts.map +1 -0
- package/dist/swarm-id-auth.d.ts +74 -0
- package/dist/swarm-id-auth.d.ts.map +1 -0
- package/dist/swarm-id-auth.js +2 -0
- package/dist/swarm-id-auth.js.map +1 -0
- package/dist/swarm-id-client.d.ts +878 -0
- package/dist/swarm-id-client.d.ts.map +1 -0
- package/dist/swarm-id-client.js +2 -0
- package/dist/swarm-id-client.js.map +1 -0
- package/dist/swarm-id-proxy.d.ts +236 -0
- package/dist/swarm-id-proxy.d.ts.map +1 -0
- package/dist/swarm-id-proxy.js +2 -0
- package/dist/swarm-id-proxy.js.map +1 -0
- package/dist/swarm-id.esm.js +2 -0
- package/dist/swarm-id.esm.js.map +1 -0
- package/dist/swarm-id.umd.js +2 -0
- package/dist/swarm-id.umd.js.map +1 -0
- package/dist/sync/index.d.ts +9 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/key-derivation.d.ts +25 -0
- package/dist/sync/key-derivation.d.ts.map +1 -0
- package/dist/sync/restore-account.d.ts +28 -0
- package/dist/sync/restore-account.d.ts.map +1 -0
- package/dist/sync/serialization.d.ts +16 -0
- package/dist/sync/serialization.d.ts.map +1 -0
- package/dist/sync/store-interfaces.d.ts +53 -0
- package/dist/sync/store-interfaces.d.ts.map +1 -0
- package/dist/sync/sync-account.d.ts +44 -0
- package/dist/sync/sync-account.d.ts.map +1 -0
- package/dist/sync/types.d.ts +13 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/test-fixtures.d.ts +17 -0
- package/dist/test-fixtures.d.ts.map +1 -0
- package/dist/types-BD_VkNn0.js +2 -0
- package/dist/types-BD_VkNn0.js.map +1 -0
- package/dist/types-lJCaT-50.js +2 -0
- package/dist/types-lJCaT-50.js.map +1 -0
- package/dist/types.d.ts +2157 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/account-payload.d.ts +94 -0
- package/dist/utils/account-payload.d.ts.map +1 -0
- package/dist/utils/account-state-snapshot.d.ts +38 -0
- package/dist/utils/account-state-snapshot.d.ts.map +1 -0
- package/dist/utils/backup-encryption.d.ts +127 -0
- package/dist/utils/backup-encryption.d.ts.map +1 -0
- package/dist/utils/batch-utilization.d.ts +432 -0
- package/dist/utils/batch-utilization.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +11 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/hex.d.ts +17 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/key-derivation.d.ts +92 -0
- package/dist/utils/key-derivation.d.ts.map +1 -0
- package/dist/utils/storage-managers.d.ts +65 -0
- package/dist/utils/storage-managers.d.ts.map +1 -0
- package/dist/utils/swarm-id-export.d.ts +24 -0
- package/dist/utils/swarm-id-export.d.ts.map +1 -0
- package/dist/utils/ttl.d.ts +49 -0
- package/dist/utils/ttl.d.ts.map +1 -0
- package/dist/utils/url.d.ts +41 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/versioned-storage.d.ts +131 -0
- package/dist/utils/versioned-storage.d.ts.map +1 -0
- package/package.json +78 -0
- package/src/chunk/bmt.test.ts +217 -0
- package/src/chunk/bmt.ts +57 -0
- package/src/chunk/cac.test.ts +214 -0
- package/src/chunk/cac.ts +65 -0
- package/src/chunk/constants.ts +18 -0
- package/src/chunk/encrypted-cac.test.ts +385 -0
- package/src/chunk/encrypted-cac.ts +131 -0
- package/src/chunk/encryption.test.ts +352 -0
- package/src/chunk/encryption.ts +300 -0
- package/src/chunk/index.ts +47 -0
- package/src/index.ts +430 -0
- package/src/proxy/act/act.test.ts +278 -0
- package/src/proxy/act/act.ts +158 -0
- package/src/proxy/act/bee-compat.test.ts +948 -0
- package/src/proxy/act/crypto.test.ts +436 -0
- package/src/proxy/act/crypto.ts +376 -0
- package/src/proxy/act/grantee-list.test.ts +393 -0
- package/src/proxy/act/grantee-list.ts +239 -0
- package/src/proxy/act/history.test.ts +360 -0
- package/src/proxy/act/history.ts +413 -0
- package/src/proxy/act/index.test.ts +748 -0
- package/src/proxy/act/index.ts +853 -0
- package/src/proxy/chunking-encrypted.ts +95 -0
- package/src/proxy/chunking.ts +65 -0
- package/src/proxy/download-data.ts +448 -0
- package/src/proxy/feed-manifest.ts +174 -0
- package/src/proxy/feeds/epochs/async-finder.ts +372 -0
- package/src/proxy/feeds/epochs/epoch.test.ts +249 -0
- package/src/proxy/feeds/epochs/epoch.ts +181 -0
- package/src/proxy/feeds/epochs/finder.ts +282 -0
- package/src/proxy/feeds/epochs/index.ts +73 -0
- package/src/proxy/feeds/epochs/integration.test.ts +1336 -0
- package/src/proxy/feeds/epochs/test-utils.ts +274 -0
- package/src/proxy/feeds/epochs/types.ts +128 -0
- package/src/proxy/feeds/epochs/updater.ts +192 -0
- package/src/proxy/feeds/epochs/utils.ts +62 -0
- package/src/proxy/feeds/index.ts +5 -0
- package/src/proxy/feeds/sequence/async-finder.ts +31 -0
- package/src/proxy/feeds/sequence/finder.ts +73 -0
- package/src/proxy/feeds/sequence/index.ts +54 -0
- package/src/proxy/feeds/sequence/integration.test.ts +966 -0
- package/src/proxy/feeds/sequence/types.ts +103 -0
- package/src/proxy/feeds/sequence/updater.ts +71 -0
- package/src/proxy/index.ts +5 -0
- package/src/proxy/manifest-builder.test.ts +427 -0
- package/src/proxy/manifest-builder.ts +679 -0
- package/src/proxy/mantaray-encrypted.ts +78 -0
- package/src/proxy/mantaray.ts +104 -0
- package/src/proxy/types.ts +32 -0
- package/src/proxy/upload-data.ts +189 -0
- package/src/proxy/upload-encrypted-data.ts +658 -0
- package/src/schemas.ts +299 -0
- package/src/storage/debounced-uploader.ts +192 -0
- package/src/storage/utilization-store.ts +397 -0
- package/src/swarm-id-client.test.ts +99 -0
- package/src/swarm-id-client.ts +3095 -0
- package/src/swarm-id-proxy.ts +3891 -0
- package/src/sync/index.ts +28 -0
- package/src/sync/restore-account.ts +90 -0
- package/src/sync/serialization.ts +39 -0
- package/src/sync/store-interfaces.ts +62 -0
- package/src/sync/sync-account.test.ts +302 -0
- package/src/sync/sync-account.ts +396 -0
- package/src/sync/types.ts +11 -0
- package/src/test-fixtures.ts +109 -0
- package/src/types.ts +1651 -0
- package/src/utils/account-state-snapshot.test.ts +595 -0
- package/src/utils/account-state-snapshot.ts +94 -0
- package/src/utils/backup-encryption.test.ts +442 -0
- package/src/utils/backup-encryption.ts +352 -0
- package/src/utils/batch-utilization.ts +1309 -0
- package/src/utils/constants.ts +20 -0
- package/src/utils/hex.ts +27 -0
- package/src/utils/key-derivation.ts +197 -0
- package/src/utils/storage-managers.ts +365 -0
- package/src/utils/ttl.ts +129 -0
- package/src/utils/url.test.ts +136 -0
- package/src/utils/url.ts +71 -0
- package/src/utils/versioned-storage.ts +323 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm ID Library
|
|
3
|
+
*
|
|
4
|
+
* A TypeScript library for integrating Swarm ID authentication
|
|
5
|
+
* and Bee API operations into dApps.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Main client for parent windows
|
|
9
|
+
export { SwarmIdClient } from "./swarm-id-client"
|
|
10
|
+
|
|
11
|
+
// Proxy for iframe
|
|
12
|
+
export { SwarmIdProxy, initProxy } from "./swarm-id-proxy"
|
|
13
|
+
|
|
14
|
+
// Key derivation utilities
|
|
15
|
+
export {
|
|
16
|
+
deriveSecret,
|
|
17
|
+
deriveIdentityKey,
|
|
18
|
+
generateMasterKey,
|
|
19
|
+
hexToUint8Array,
|
|
20
|
+
uint8ArrayToHex,
|
|
21
|
+
verifySecret,
|
|
22
|
+
utils,
|
|
23
|
+
} from "./utils/key-derivation"
|
|
24
|
+
|
|
25
|
+
// Hex address utility
|
|
26
|
+
export { hexAddress } from "./utils/hex"
|
|
27
|
+
|
|
28
|
+
// Batch utilization tracking
|
|
29
|
+
export {
|
|
30
|
+
initializeBatchUtilization,
|
|
31
|
+
calculateUtilizationUpdate,
|
|
32
|
+
updateAfterWrite,
|
|
33
|
+
saveUtilizationState,
|
|
34
|
+
loadUtilizationState,
|
|
35
|
+
calculateUtilization,
|
|
36
|
+
toBucket,
|
|
37
|
+
assignChunksToBuckets,
|
|
38
|
+
serializeUint32Array,
|
|
39
|
+
deserializeUint32Array,
|
|
40
|
+
splitIntoChunks,
|
|
41
|
+
reconstructFromChunks,
|
|
42
|
+
calculateMaxSlotsPerBucket,
|
|
43
|
+
hasBucketCapacity,
|
|
44
|
+
createStamper,
|
|
45
|
+
prepareBucketState,
|
|
46
|
+
UtilizationAwareStamper,
|
|
47
|
+
NUM_BUCKETS,
|
|
48
|
+
BUCKET_DEPTH,
|
|
49
|
+
UTILIZATION_SLOTS_PER_BUCKET,
|
|
50
|
+
DATA_COUNTER_START,
|
|
51
|
+
CHUNK_SIZE,
|
|
52
|
+
DEFAULT_BATCH_DEPTH,
|
|
53
|
+
} from "./utils/batch-utilization"
|
|
54
|
+
|
|
55
|
+
// Utilization storage (IndexedDB cache)
|
|
56
|
+
export {
|
|
57
|
+
UtilizationStoreDB,
|
|
58
|
+
evictOldEntries,
|
|
59
|
+
calculateContentHash,
|
|
60
|
+
} from "./storage/utilization-store"
|
|
61
|
+
|
|
62
|
+
export type {
|
|
63
|
+
ChunkCacheEntry,
|
|
64
|
+
BatchMetadata,
|
|
65
|
+
CacheEvictionPolicy,
|
|
66
|
+
} from "./storage/utilization-store"
|
|
67
|
+
|
|
68
|
+
// Debounced utilization uploader
|
|
69
|
+
export { DebouncedUtilizationUploader } from "./storage/debounced-uploader"
|
|
70
|
+
|
|
71
|
+
// Versioned storage utilities
|
|
72
|
+
export {
|
|
73
|
+
VersionedStorageManager,
|
|
74
|
+
LocalStorageAdapter,
|
|
75
|
+
MemoryStorageAdapter,
|
|
76
|
+
createLocalStorageManager,
|
|
77
|
+
createMemoryStorageManager,
|
|
78
|
+
createZodParser,
|
|
79
|
+
VersionedStorageSchema,
|
|
80
|
+
} from "./utils/versioned-storage"
|
|
81
|
+
|
|
82
|
+
// Storage managers for entities
|
|
83
|
+
export {
|
|
84
|
+
createAccountsStorageManager,
|
|
85
|
+
createIdentitiesStorageManager,
|
|
86
|
+
createConnectedAppsStorageManager,
|
|
87
|
+
createPostageStampsStorageManager,
|
|
88
|
+
createNetworkSettingsStorageManager,
|
|
89
|
+
serializeAccount,
|
|
90
|
+
serializeIdentity,
|
|
91
|
+
serializeConnectedApp,
|
|
92
|
+
serializePostageStamp,
|
|
93
|
+
serializeNetworkSettings,
|
|
94
|
+
disconnectApp,
|
|
95
|
+
} from "./utils/storage-managers"
|
|
96
|
+
|
|
97
|
+
// Storage manager types
|
|
98
|
+
export type { NetworkSettingsStorageManager } from "./utils/storage-managers"
|
|
99
|
+
|
|
100
|
+
// Account state snapshot (shared by file export and Swarm sync)
|
|
101
|
+
export {
|
|
102
|
+
serializeAccountStateSnapshot,
|
|
103
|
+
deserializeAccountStateSnapshot,
|
|
104
|
+
AccountStateSnapshotSchemaV1,
|
|
105
|
+
} from "./utils/account-state-snapshot"
|
|
106
|
+
|
|
107
|
+
export type {
|
|
108
|
+
AccountStateSnapshot,
|
|
109
|
+
AccountStateSnapshotResult,
|
|
110
|
+
} from "./utils/account-state-snapshot"
|
|
111
|
+
|
|
112
|
+
// Encrypted backup (.swarmid) support
|
|
113
|
+
export {
|
|
114
|
+
deriveBackupEncryptionKey,
|
|
115
|
+
encryptBackupPayload,
|
|
116
|
+
decryptBackupPayload,
|
|
117
|
+
buildBackupHeader,
|
|
118
|
+
createEncryptedExport,
|
|
119
|
+
decryptEncryptedExport,
|
|
120
|
+
parseEncryptedExportHeader,
|
|
121
|
+
PasskeyBackupHeaderSchemaV1,
|
|
122
|
+
EthereumBackupHeaderSchemaV1,
|
|
123
|
+
AgentBackupHeaderSchemaV1,
|
|
124
|
+
EncryptedSwarmIdExportSchemaV1,
|
|
125
|
+
} from "./utils/backup-encryption"
|
|
126
|
+
|
|
127
|
+
export type {
|
|
128
|
+
PasskeyBackupHeader,
|
|
129
|
+
EthereumBackupHeader,
|
|
130
|
+
AgentBackupHeader,
|
|
131
|
+
EncryptedSwarmIdExport,
|
|
132
|
+
BackupHeaderWithoutCiphertext,
|
|
133
|
+
ParseHeaderResult,
|
|
134
|
+
} from "./utils/backup-encryption"
|
|
135
|
+
|
|
136
|
+
// Epoch-based feeds - implementations
|
|
137
|
+
export {
|
|
138
|
+
EpochIndex,
|
|
139
|
+
SyncEpochFinder,
|
|
140
|
+
AsyncEpochFinder,
|
|
141
|
+
BasicEpochUpdater,
|
|
142
|
+
lca,
|
|
143
|
+
next,
|
|
144
|
+
createSyncEpochFinder,
|
|
145
|
+
createAsyncEpochFinder,
|
|
146
|
+
createEpochUpdater,
|
|
147
|
+
createEpochFinder, // deprecated alias for createSyncEpochFinder
|
|
148
|
+
MAX_LEVEL,
|
|
149
|
+
} from "./proxy/feeds/epochs"
|
|
150
|
+
|
|
151
|
+
// State sync to Swarm
|
|
152
|
+
export {
|
|
153
|
+
// Account-level key derivation
|
|
154
|
+
deriveAccountBackupKey,
|
|
155
|
+
deriveAccountSwarmEncryptionKey,
|
|
156
|
+
backupKeyToPrivateKey,
|
|
157
|
+
serializeAccountState,
|
|
158
|
+
deserializeAccountState,
|
|
159
|
+
// Sync account
|
|
160
|
+
createSyncAccount,
|
|
161
|
+
ACCOUNT_SYNC_TOPIC_PREFIX,
|
|
162
|
+
// Restore account from Swarm
|
|
163
|
+
restoreAccountFromSwarm,
|
|
164
|
+
} from "./sync"
|
|
165
|
+
|
|
166
|
+
// State sync types
|
|
167
|
+
export type {
|
|
168
|
+
SyncResult,
|
|
169
|
+
// Sync account types
|
|
170
|
+
SyncAccountOptions,
|
|
171
|
+
SyncAccountFunction,
|
|
172
|
+
// Store interfaces
|
|
173
|
+
AccountsStoreInterface,
|
|
174
|
+
IdentitiesStoreInterface,
|
|
175
|
+
ConnectedAppsStoreInterface,
|
|
176
|
+
PostageStampsStoreInterface,
|
|
177
|
+
StamperOptions,
|
|
178
|
+
FlushableStamper,
|
|
179
|
+
// Restore account types
|
|
180
|
+
RestoreAccountResult,
|
|
181
|
+
} from "./sync"
|
|
182
|
+
|
|
183
|
+
// Type exports
|
|
184
|
+
export type {
|
|
185
|
+
ClientOptions,
|
|
186
|
+
AuthStatus,
|
|
187
|
+
ButtonStyles,
|
|
188
|
+
UploadResult,
|
|
189
|
+
FileData,
|
|
190
|
+
PostageBatch,
|
|
191
|
+
UploadOptions,
|
|
192
|
+
ActUploadOptions,
|
|
193
|
+
SOCReader,
|
|
194
|
+
SOCWriter,
|
|
195
|
+
SingleOwnerChunk,
|
|
196
|
+
SocUploadResult,
|
|
197
|
+
SocRawUploadResult,
|
|
198
|
+
FeedReaderOptions,
|
|
199
|
+
FeedWriterOptions,
|
|
200
|
+
FeedReader,
|
|
201
|
+
FeedWriter,
|
|
202
|
+
SequentialFeedReaderOptions,
|
|
203
|
+
SequentialFeedWriterOptions,
|
|
204
|
+
SequentialFeedUpdateOptions,
|
|
205
|
+
SequentialFeedUploadOptions,
|
|
206
|
+
SequentialFeedPayloadResult,
|
|
207
|
+
SequentialFeedReferenceResult,
|
|
208
|
+
SequentialFeedUploadResult,
|
|
209
|
+
SequentialFeedReader,
|
|
210
|
+
SequentialFeedWriter,
|
|
211
|
+
UploadProgress,
|
|
212
|
+
RequestOptions,
|
|
213
|
+
DownloadOptions,
|
|
214
|
+
ParentToIframeMessage,
|
|
215
|
+
IframeToParentMessage,
|
|
216
|
+
PopupToIframeMessage,
|
|
217
|
+
SetSecretMessage,
|
|
218
|
+
AuthData,
|
|
219
|
+
AppMetadata,
|
|
220
|
+
ButtonConfig,
|
|
221
|
+
ConnectionInfo,
|
|
222
|
+
// ACT message types
|
|
223
|
+
ActUploadDataMessage,
|
|
224
|
+
ActDownloadDataMessage,
|
|
225
|
+
ActAddGranteesMessage,
|
|
226
|
+
ActRevokeGranteesMessage,
|
|
227
|
+
ActGetGranteesMessage,
|
|
228
|
+
ActUploadDataResponseMessage,
|
|
229
|
+
ActDownloadDataResponseMessage,
|
|
230
|
+
ActAddGranteesResponseMessage,
|
|
231
|
+
ActRevokeGranteesResponseMessage,
|
|
232
|
+
ActGetGranteesResponseMessage,
|
|
233
|
+
SocUploadMessage,
|
|
234
|
+
SocRawUploadMessage,
|
|
235
|
+
SocDownloadMessage,
|
|
236
|
+
SocRawDownloadMessage,
|
|
237
|
+
SocGetOwnerMessage,
|
|
238
|
+
EpochFeedDownloadReferenceMessage,
|
|
239
|
+
EpochFeedUploadReferenceMessage,
|
|
240
|
+
FeedGetOwnerMessage,
|
|
241
|
+
SequentialFeedGetOwnerMessage,
|
|
242
|
+
SequentialFeedDownloadPayloadMessage,
|
|
243
|
+
SequentialFeedDownloadRawPayloadMessage,
|
|
244
|
+
SequentialFeedDownloadReferenceMessage,
|
|
245
|
+
SequentialFeedUploadPayloadMessage,
|
|
246
|
+
SequentialFeedUploadRawPayloadMessage,
|
|
247
|
+
SequentialFeedUploadReferenceMessage,
|
|
248
|
+
SocUploadResponseMessage,
|
|
249
|
+
SocRawUploadResponseMessage,
|
|
250
|
+
SocDownloadResponseMessage,
|
|
251
|
+
SocRawDownloadResponseMessage,
|
|
252
|
+
SocGetOwnerResponseMessage,
|
|
253
|
+
EpochFeedDownloadReferenceResponseMessage,
|
|
254
|
+
EpochFeedUploadReferenceResponseMessage,
|
|
255
|
+
FeedGetOwnerResponseMessage,
|
|
256
|
+
SequentialFeedGetOwnerResponseMessage,
|
|
257
|
+
SequentialFeedDownloadPayloadResponseMessage,
|
|
258
|
+
SequentialFeedDownloadRawPayloadResponseMessage,
|
|
259
|
+
SequentialFeedDownloadReferenceResponseMessage,
|
|
260
|
+
SequentialFeedUploadPayloadResponseMessage,
|
|
261
|
+
SequentialFeedUploadRawPayloadResponseMessage,
|
|
262
|
+
SequentialFeedUploadReferenceResponseMessage,
|
|
263
|
+
} from "./types"
|
|
264
|
+
|
|
265
|
+
// Entity types from schemas
|
|
266
|
+
export type {
|
|
267
|
+
Account,
|
|
268
|
+
PasskeyAccount,
|
|
269
|
+
EthereumAccount,
|
|
270
|
+
AgentAccount,
|
|
271
|
+
Identity,
|
|
272
|
+
ConnectedApp,
|
|
273
|
+
PostageStamp,
|
|
274
|
+
AccountMetadata,
|
|
275
|
+
NetworkSettings,
|
|
276
|
+
} from "./schemas"
|
|
277
|
+
|
|
278
|
+
// Network settings constants and schema
|
|
279
|
+
export {
|
|
280
|
+
DEFAULT_BEE_NODE_URL,
|
|
281
|
+
DEFAULT_GNOSIS_RPC_URL,
|
|
282
|
+
NetworkSettingsSchemaV1,
|
|
283
|
+
} from "./schemas"
|
|
284
|
+
|
|
285
|
+
// Base validation schemas and types
|
|
286
|
+
export {
|
|
287
|
+
ReferenceSchema,
|
|
288
|
+
BatchIdSchema,
|
|
289
|
+
AddressSchema,
|
|
290
|
+
PrivateKeySchema,
|
|
291
|
+
EncryptionKeySchema,
|
|
292
|
+
IdentifierSchema,
|
|
293
|
+
SignatureSchema,
|
|
294
|
+
TimestampSchema,
|
|
295
|
+
FeedIndexSchema,
|
|
296
|
+
} from "./schemas"
|
|
297
|
+
export type {
|
|
298
|
+
Reference,
|
|
299
|
+
BatchId,
|
|
300
|
+
Address,
|
|
301
|
+
PrivateKey,
|
|
302
|
+
Identifier,
|
|
303
|
+
Signature,
|
|
304
|
+
Timestamp,
|
|
305
|
+
FeedIndex,
|
|
306
|
+
} from "./schemas"
|
|
307
|
+
|
|
308
|
+
// Batch utilization types
|
|
309
|
+
export type {
|
|
310
|
+
BatchUtilizationState,
|
|
311
|
+
ChunkWithBucket,
|
|
312
|
+
UtilizationUpdate,
|
|
313
|
+
} from "./utils/batch-utilization"
|
|
314
|
+
|
|
315
|
+
// Versioned storage types
|
|
316
|
+
export type {
|
|
317
|
+
VersionedStorage,
|
|
318
|
+
StorageAdapter,
|
|
319
|
+
VersionParser,
|
|
320
|
+
Serializer,
|
|
321
|
+
VersionedStorageOptions,
|
|
322
|
+
} from "./utils/versioned-storage"
|
|
323
|
+
|
|
324
|
+
// Epoch feed types
|
|
325
|
+
export type {
|
|
326
|
+
Epoch,
|
|
327
|
+
EpochFinder,
|
|
328
|
+
EpochUpdater,
|
|
329
|
+
EpochFeedOptions,
|
|
330
|
+
EpochFeedWriterOptions,
|
|
331
|
+
EpochLookupResult,
|
|
332
|
+
} from "./proxy/feeds/epochs"
|
|
333
|
+
|
|
334
|
+
// Schema exports (for validation)
|
|
335
|
+
export {
|
|
336
|
+
UploadOptionsSchema,
|
|
337
|
+
ActUploadOptionsSchema,
|
|
338
|
+
RequestOptionsSchema,
|
|
339
|
+
DownloadOptionsSchema,
|
|
340
|
+
UploadResultSchema,
|
|
341
|
+
FileDataSchema,
|
|
342
|
+
PostageBatchSchema,
|
|
343
|
+
AuthStatusSchema,
|
|
344
|
+
ButtonStylesSchema,
|
|
345
|
+
ParentToIframeMessageSchema,
|
|
346
|
+
IframeToParentMessageSchema,
|
|
347
|
+
PopupToIframeMessageSchema,
|
|
348
|
+
SetSecretMessageSchema,
|
|
349
|
+
AuthDataSchema,
|
|
350
|
+
// ACT message schemas
|
|
351
|
+
ActUploadDataMessageSchema,
|
|
352
|
+
ActDownloadDataMessageSchema,
|
|
353
|
+
ActAddGranteesMessageSchema,
|
|
354
|
+
ActRevokeGranteesMessageSchema,
|
|
355
|
+
ActGetGranteesMessageSchema,
|
|
356
|
+
ActUploadDataResponseMessageSchema,
|
|
357
|
+
ActDownloadDataResponseMessageSchema,
|
|
358
|
+
ActAddGranteesResponseMessageSchema,
|
|
359
|
+
ActRevokeGranteesResponseMessageSchema,
|
|
360
|
+
ActGetGranteesResponseMessageSchema,
|
|
361
|
+
} from "./types"
|
|
362
|
+
|
|
363
|
+
// Download data utility
|
|
364
|
+
export { downloadDataWithChunkAPI } from "./proxy/download-data"
|
|
365
|
+
|
|
366
|
+
// ACT (Access Control Tries) exports
|
|
367
|
+
export {
|
|
368
|
+
createActForContent,
|
|
369
|
+
decryptActReference,
|
|
370
|
+
addGranteesToAct,
|
|
371
|
+
revokeGranteesFromAct,
|
|
372
|
+
getGranteesFromAct,
|
|
373
|
+
parseCompressedPublicKey,
|
|
374
|
+
publicKeyFromPrivate,
|
|
375
|
+
compressPublicKey,
|
|
376
|
+
publicKeyFromCompressed,
|
|
377
|
+
} from "./proxy/act"
|
|
378
|
+
|
|
379
|
+
export type { ActEntry } from "./proxy/act"
|
|
380
|
+
|
|
381
|
+
// Constant exports
|
|
382
|
+
export { SWARM_SECRET_PREFIX, STORAGE_CHALLENGE_KEY } from "./types"
|
|
383
|
+
|
|
384
|
+
// URL building utilities
|
|
385
|
+
export { buildAuthUrl } from "./utils/url"
|
|
386
|
+
|
|
387
|
+
// Manifest builder utilities for /bzz/ feed compatibility
|
|
388
|
+
export {
|
|
389
|
+
buildBzzCompatibleManifest,
|
|
390
|
+
buildBzzManifestNode,
|
|
391
|
+
buildMinimalManifest,
|
|
392
|
+
extractReferenceFromManifest,
|
|
393
|
+
extractEntryFromManifest,
|
|
394
|
+
extractContentFromFlatManifest,
|
|
395
|
+
padPayloadForSOCDetection,
|
|
396
|
+
MAX_PADDED_PAYLOAD_SIZE,
|
|
397
|
+
} from "./proxy/manifest-builder"
|
|
398
|
+
|
|
399
|
+
export type {
|
|
400
|
+
BzzCompatibleManifestResult,
|
|
401
|
+
BzzManifestNodeResult,
|
|
402
|
+
} from "./proxy/manifest-builder"
|
|
403
|
+
|
|
404
|
+
// Mantaray tree utilities for recursive upload/download
|
|
405
|
+
export {
|
|
406
|
+
saveMantarayTreeRecursively,
|
|
407
|
+
loadMantarayTreeWithChunkAPI,
|
|
408
|
+
} from "./proxy/mantaray"
|
|
409
|
+
|
|
410
|
+
export type { UploadCallback } from "./proxy/mantaray"
|
|
411
|
+
|
|
412
|
+
// Time and session constants
|
|
413
|
+
export {
|
|
414
|
+
SECOND,
|
|
415
|
+
MINUTE,
|
|
416
|
+
HOUR,
|
|
417
|
+
DAY,
|
|
418
|
+
DEFAULT_SESSION_DURATION,
|
|
419
|
+
} from "./utils/constants"
|
|
420
|
+
|
|
421
|
+
// TTL calculation and formatting utilities
|
|
422
|
+
export {
|
|
423
|
+
calculateTTLSeconds,
|
|
424
|
+
formatTTL,
|
|
425
|
+
getBlockTimestamp,
|
|
426
|
+
calculateExpiryTimestamp,
|
|
427
|
+
fetchSwarmPrice,
|
|
428
|
+
SWARMSCAN_STATS_URL,
|
|
429
|
+
GNOSIS_BLOCK_TIME,
|
|
430
|
+
} from "./utils/ttl"
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for ACT data structure and serialization (Bee-compatible Simple Manifest JSON format)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect } from "vitest"
|
|
6
|
+
import {
|
|
7
|
+
serializeAct,
|
|
8
|
+
deserializeAct,
|
|
9
|
+
findEntryByLookupKey,
|
|
10
|
+
publicKeysEqual,
|
|
11
|
+
type ActEntry,
|
|
12
|
+
} from "./act"
|
|
13
|
+
import { publicKeyFromPrivate } from "./crypto"
|
|
14
|
+
|
|
15
|
+
// Helper to create a random 32-byte array
|
|
16
|
+
function randomBytes(length: number): Uint8Array {
|
|
17
|
+
const bytes = new Uint8Array(length)
|
|
18
|
+
crypto.getRandomValues(bytes)
|
|
19
|
+
return bytes
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Helper to create a test public key
|
|
23
|
+
function createTestPublicKey(seed: number): { x: Uint8Array; y: Uint8Array } {
|
|
24
|
+
const privKey = new Uint8Array(32)
|
|
25
|
+
privKey[31] = seed
|
|
26
|
+
return publicKeyFromPrivate(privKey)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Helper to convert bytes to hex
|
|
30
|
+
function toHex(bytes: Uint8Array): string {
|
|
31
|
+
return Array.from(bytes)
|
|
32
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
33
|
+
.join("")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("serializeAct/deserializeAct (Bee-compatible Simple Manifest JSON format)", () => {
|
|
37
|
+
it("should serialize and deserialize single entry", () => {
|
|
38
|
+
const lookupKey = randomBytes(32)
|
|
39
|
+
const encryptedAccessKey = randomBytes(32)
|
|
40
|
+
|
|
41
|
+
const entries: ActEntry[] = [{ lookupKey, encryptedAccessKey }]
|
|
42
|
+
|
|
43
|
+
const serialized = serializeAct(entries)
|
|
44
|
+
const deserialized = deserializeAct(serialized)
|
|
45
|
+
|
|
46
|
+
expect(deserialized.length).toBe(1)
|
|
47
|
+
expect(deserialized[0].lookupKey).toEqual(lookupKey)
|
|
48
|
+
expect(deserialized[0].encryptedAccessKey).toEqual(encryptedAccessKey)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it("should handle multiple entries", () => {
|
|
52
|
+
const entries: ActEntry[] = []
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < 5; i++) {
|
|
55
|
+
entries.push({
|
|
56
|
+
lookupKey: randomBytes(32),
|
|
57
|
+
encryptedAccessKey: randomBytes(32),
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const serialized = serializeAct(entries)
|
|
62
|
+
const deserialized = deserializeAct(serialized)
|
|
63
|
+
|
|
64
|
+
expect(deserialized.length).toBe(5)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("should handle zero entries", () => {
|
|
68
|
+
const entries: ActEntry[] = []
|
|
69
|
+
|
|
70
|
+
const serialized = serializeAct(entries)
|
|
71
|
+
const deserialized = deserializeAct(serialized)
|
|
72
|
+
|
|
73
|
+
expect(deserialized.length).toBe(0)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it("should produce valid JSON format", () => {
|
|
77
|
+
const lookupKey = randomBytes(32)
|
|
78
|
+
const encryptedAccessKey = randomBytes(32)
|
|
79
|
+
|
|
80
|
+
const entries: ActEntry[] = [{ lookupKey, encryptedAccessKey }]
|
|
81
|
+
|
|
82
|
+
const serialized = serializeAct(entries)
|
|
83
|
+
|
|
84
|
+
// Should be valid JSON
|
|
85
|
+
const json = new TextDecoder().decode(serialized)
|
|
86
|
+
const parsed = JSON.parse(json)
|
|
87
|
+
|
|
88
|
+
// Should have entries object
|
|
89
|
+
expect(parsed).toHaveProperty("entries")
|
|
90
|
+
expect(typeof parsed.entries).toBe("object")
|
|
91
|
+
|
|
92
|
+
// Entry key should be hex-encoded lookup key
|
|
93
|
+
const lookupKeyHex = toHex(lookupKey)
|
|
94
|
+
expect(parsed.entries).toHaveProperty(lookupKeyHex)
|
|
95
|
+
|
|
96
|
+
// Entry value should have reference (hex-encoded encrypted access key)
|
|
97
|
+
expect(parsed.entries[lookupKeyHex]).toHaveProperty("reference")
|
|
98
|
+
expect(parsed.entries[lookupKeyHex].reference).toBe(
|
|
99
|
+
toHex(encryptedAccessKey),
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("should handle entries with same lookup key (last wins)", () => {
|
|
104
|
+
const lookupKey = randomBytes(32)
|
|
105
|
+
const encryptedAccessKey1 = randomBytes(32)
|
|
106
|
+
const encryptedAccessKey2 = randomBytes(32)
|
|
107
|
+
|
|
108
|
+
// Two entries with same lookup key
|
|
109
|
+
const entries: ActEntry[] = [
|
|
110
|
+
{ lookupKey, encryptedAccessKey: encryptedAccessKey1 },
|
|
111
|
+
{ lookupKey, encryptedAccessKey: encryptedAccessKey2 },
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
const serialized = serializeAct(entries)
|
|
115
|
+
const deserialized = deserializeAct(serialized)
|
|
116
|
+
|
|
117
|
+
// Should only have one entry (second overwrites first)
|
|
118
|
+
expect(deserialized.length).toBe(1)
|
|
119
|
+
expect(deserialized[0].encryptedAccessKey).toEqual(encryptedAccessKey2)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it("should produce Bee-compatible Simple Manifest structure", () => {
|
|
123
|
+
const lookupKey = new Uint8Array(32)
|
|
124
|
+
lookupKey.fill(0xaa)
|
|
125
|
+
const encryptedAccessKey = new Uint8Array(32)
|
|
126
|
+
encryptedAccessKey.fill(0xbb)
|
|
127
|
+
|
|
128
|
+
const entries: ActEntry[] = [{ lookupKey, encryptedAccessKey }]
|
|
129
|
+
|
|
130
|
+
const serialized = serializeAct(entries)
|
|
131
|
+
|
|
132
|
+
// Parse and check structure matches Bee's Simple Manifest
|
|
133
|
+
const json = new TextDecoder().decode(serialized)
|
|
134
|
+
const manifest = JSON.parse(json)
|
|
135
|
+
|
|
136
|
+
// Bee Simple Manifest format:
|
|
137
|
+
// { "entries": { "<path>": { "reference": "<hex>", "metadata": {} } } }
|
|
138
|
+
expect(manifest).toHaveProperty("entries")
|
|
139
|
+
|
|
140
|
+
const lookupKeyHex = "aa".repeat(32)
|
|
141
|
+
expect(manifest.entries).toHaveProperty(lookupKeyHex)
|
|
142
|
+
expect(manifest.entries[lookupKeyHex]).toHaveProperty("reference")
|
|
143
|
+
expect(manifest.entries[lookupKeyHex].reference).toBe("bb".repeat(32))
|
|
144
|
+
expect(manifest.entries[lookupKeyHex]).toHaveProperty("metadata")
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it("should handle large number of entries", () => {
|
|
148
|
+
const numEntries = 100
|
|
149
|
+
const entries: ActEntry[] = []
|
|
150
|
+
for (let i = 0; i < numEntries; i++) {
|
|
151
|
+
entries.push({
|
|
152
|
+
lookupKey: randomBytes(32),
|
|
153
|
+
encryptedAccessKey: randomBytes(32),
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const serialized = serializeAct(entries)
|
|
158
|
+
const deserialized = deserializeAct(serialized)
|
|
159
|
+
|
|
160
|
+
expect(deserialized.length).toBe(numEntries)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it("should preserve all data through serialize/deserialize cycle", () => {
|
|
164
|
+
const entries: ActEntry[] = []
|
|
165
|
+
for (let i = 0; i < 10; i++) {
|
|
166
|
+
entries.push({
|
|
167
|
+
lookupKey: randomBytes(32),
|
|
168
|
+
encryptedAccessKey: randomBytes(32),
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const serialized = serializeAct(entries)
|
|
173
|
+
const deserialized = deserializeAct(serialized)
|
|
174
|
+
|
|
175
|
+
expect(deserialized.length).toBe(entries.length)
|
|
176
|
+
|
|
177
|
+
// Each entry should be found
|
|
178
|
+
for (const entry of entries) {
|
|
179
|
+
const found = findEntryByLookupKey(deserialized, entry.lookupKey)
|
|
180
|
+
expect(found).toBeDefined()
|
|
181
|
+
expect(found?.encryptedAccessKey).toEqual(entry.encryptedAccessKey)
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
describe("findEntryByLookupKey", () => {
|
|
187
|
+
it("should find matching entry", () => {
|
|
188
|
+
const lookupKey1 = randomBytes(32)
|
|
189
|
+
const lookupKey2 = randomBytes(32)
|
|
190
|
+
const lookupKey3 = randomBytes(32)
|
|
191
|
+
|
|
192
|
+
const entries: ActEntry[] = [
|
|
193
|
+
{ lookupKey: lookupKey1, encryptedAccessKey: randomBytes(32) },
|
|
194
|
+
{ lookupKey: lookupKey2, encryptedAccessKey: randomBytes(32) },
|
|
195
|
+
{ lookupKey: lookupKey3, encryptedAccessKey: randomBytes(32) },
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
const found = findEntryByLookupKey(entries, lookupKey2)
|
|
199
|
+
expect(found).toBeDefined()
|
|
200
|
+
expect(found?.lookupKey).toEqual(lookupKey2)
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it("should return undefined for non-matching key", () => {
|
|
204
|
+
const entries: ActEntry[] = [
|
|
205
|
+
{ lookupKey: randomBytes(32), encryptedAccessKey: randomBytes(32) },
|
|
206
|
+
{ lookupKey: randomBytes(32), encryptedAccessKey: randomBytes(32) },
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
const notFound = findEntryByLookupKey(entries, randomBytes(32))
|
|
210
|
+
expect(notFound).toBeUndefined()
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it("should return undefined for empty entries", () => {
|
|
214
|
+
const notFound = findEntryByLookupKey([], randomBytes(32))
|
|
215
|
+
expect(notFound).toBeUndefined()
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it("should match exact bytes only", () => {
|
|
219
|
+
const lookupKey = new Uint8Array(32)
|
|
220
|
+
lookupKey[0] = 0x01
|
|
221
|
+
lookupKey[31] = 0xff
|
|
222
|
+
|
|
223
|
+
const entries: ActEntry[] = [
|
|
224
|
+
{ lookupKey, encryptedAccessKey: randomBytes(32) },
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
// Same content should match
|
|
228
|
+
const sameContent = new Uint8Array(32)
|
|
229
|
+
sameContent[0] = 0x01
|
|
230
|
+
sameContent[31] = 0xff
|
|
231
|
+
expect(findEntryByLookupKey(entries, sameContent)).toBeDefined()
|
|
232
|
+
|
|
233
|
+
// Different content should not match
|
|
234
|
+
const different = new Uint8Array(32)
|
|
235
|
+
different[0] = 0x01
|
|
236
|
+
different[31] = 0xfe // Different!
|
|
237
|
+
expect(findEntryByLookupKey(entries, different)).toBeUndefined()
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
describe("publicKeysEqual", () => {
|
|
242
|
+
it("should return true for equal public keys", () => {
|
|
243
|
+
const key1 = createTestPublicKey(30)
|
|
244
|
+
const key2 = {
|
|
245
|
+
x: new Uint8Array(key1.x),
|
|
246
|
+
y: new Uint8Array(key1.y),
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
expect(publicKeysEqual(key1, key2)).toBe(true)
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
it("should return false for different x coordinates", () => {
|
|
253
|
+
const key1 = createTestPublicKey(31)
|
|
254
|
+
const key2 = createTestPublicKey(32)
|
|
255
|
+
|
|
256
|
+
expect(publicKeysEqual(key1, key2)).toBe(false)
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it("should return false for different y coordinates", () => {
|
|
260
|
+
const key1 = createTestPublicKey(33)
|
|
261
|
+
const key2 = {
|
|
262
|
+
x: new Uint8Array(key1.x), // Same x
|
|
263
|
+
y: randomBytes(32), // Different y
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
expect(publicKeysEqual(key1, key2)).toBe(false)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
it("should return false for different lengths", () => {
|
|
270
|
+
const key1 = createTestPublicKey(34)
|
|
271
|
+
const key2 = {
|
|
272
|
+
x: new Uint8Array(16), // Wrong length
|
|
273
|
+
y: key1.y,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
expect(publicKeysEqual(key1, key2)).toBe(false)
|
|
277
|
+
})
|
|
278
|
+
})
|