@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
|
@@ -0,0 +1,240 @@
|
|
|
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, Bytes, 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 EncryptionKeySchema: z.ZodString;
|
|
17
|
+
export declare const IdentifierSchema: z.ZodString;
|
|
18
|
+
export declare const SignatureSchema: z.ZodString;
|
|
19
|
+
export declare const TimestampSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
20
|
+
export declare const FeedIndexSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
21
|
+
export type Reference = z.infer<typeof ReferenceSchema>;
|
|
22
|
+
export type BatchId = z.infer<typeof BatchIdSchema>;
|
|
23
|
+
export type Address = z.infer<typeof AddressSchema>;
|
|
24
|
+
export type PrivateKey = z.infer<typeof PrivateKeySchema>;
|
|
25
|
+
export type Identifier = z.infer<typeof IdentifierSchema>;
|
|
26
|
+
export type Signature = z.infer<typeof SignatureSchema>;
|
|
27
|
+
export type Timestamp = z.infer<typeof TimestampSchema>;
|
|
28
|
+
export type FeedIndex = z.infer<typeof FeedIndexSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Passkey Account Schema V1
|
|
31
|
+
*/
|
|
32
|
+
export declare const PasskeyAccountSchemaV1: z.ZodObject<{
|
|
33
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
createdAt: z.ZodNumber;
|
|
36
|
+
type: z.ZodLiteral<"passkey">;
|
|
37
|
+
credentialId: z.ZodString;
|
|
38
|
+
swarmEncryptionKey: z.ZodString;
|
|
39
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
/**
|
|
42
|
+
* Ethereum Account Schema V1
|
|
43
|
+
*/
|
|
44
|
+
export declare const EthereumAccountSchemaV1: z.ZodObject<{
|
|
45
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
createdAt: z.ZodNumber;
|
|
48
|
+
type: z.ZodLiteral<"ethereum">;
|
|
49
|
+
ethereumAddress: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
50
|
+
encryptedMasterKey: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
51
|
+
encryptionSalt: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
52
|
+
encryptedSecretSeed: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
53
|
+
swarmEncryptionKey: z.ZodString;
|
|
54
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
/**
|
|
57
|
+
* Agent Account Schema V1
|
|
58
|
+
* For automated testing and programmatic use with BIP39 seed phrases
|
|
59
|
+
* Seed phrase is NOT stored - must be re-entered on each authentication (like passkey)
|
|
60
|
+
*/
|
|
61
|
+
export declare const AgentAccountSchemaV1: z.ZodObject<{
|
|
62
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
createdAt: z.ZodNumber;
|
|
65
|
+
type: z.ZodLiteral<"agent">;
|
|
66
|
+
swarmEncryptionKey: z.ZodString;
|
|
67
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
/**
|
|
70
|
+
* Account Schema V1 (discriminated union)
|
|
71
|
+
*/
|
|
72
|
+
export declare const AccountSchemaV1: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
73
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
createdAt: z.ZodNumber;
|
|
76
|
+
type: z.ZodLiteral<"passkey">;
|
|
77
|
+
credentialId: z.ZodString;
|
|
78
|
+
swarmEncryptionKey: z.ZodString;
|
|
79
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
80
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
81
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
82
|
+
name: z.ZodString;
|
|
83
|
+
createdAt: z.ZodNumber;
|
|
84
|
+
type: z.ZodLiteral<"ethereum">;
|
|
85
|
+
ethereumAddress: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
86
|
+
encryptedMasterKey: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
87
|
+
encryptionSalt: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
88
|
+
encryptedSecretSeed: z.ZodPipe<z.ZodArray<z.ZodNumber>, z.ZodTransform<Bytes, number[]>>;
|
|
89
|
+
swarmEncryptionKey: z.ZodString;
|
|
90
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
91
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
92
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
createdAt: z.ZodNumber;
|
|
95
|
+
type: z.ZodLiteral<"agent">;
|
|
96
|
+
swarmEncryptionKey: z.ZodString;
|
|
97
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
98
|
+
}, z.core.$strip>], "type">;
|
|
99
|
+
/**
|
|
100
|
+
* Identity Schema V1
|
|
101
|
+
*/
|
|
102
|
+
export declare const IdentitySchemaV1: z.ZodObject<{
|
|
103
|
+
id: z.ZodString;
|
|
104
|
+
accountId: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
105
|
+
name: z.ZodString;
|
|
106
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
107
|
+
createdAt: z.ZodNumber;
|
|
108
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
appSessionDuration: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
/**
|
|
113
|
+
* Connected App Schema V1 (no transforms needed - all primitives)
|
|
114
|
+
*/
|
|
115
|
+
export declare const ConnectedAppSchemaV1: z.ZodObject<{
|
|
116
|
+
appUrl: z.ZodString;
|
|
117
|
+
appName: z.ZodString;
|
|
118
|
+
lastConnectedAt: z.ZodNumber;
|
|
119
|
+
identityId: z.ZodString;
|
|
120
|
+
appIcon: z.ZodOptional<z.ZodString>;
|
|
121
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
122
|
+
connectedUntil: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
appSecret: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
/**
|
|
126
|
+
* Postage Stamp Schema V1
|
|
127
|
+
*/
|
|
128
|
+
export declare const PostageStampSchemaV1: z.ZodObject<{
|
|
129
|
+
accountId: z.ZodString;
|
|
130
|
+
batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
|
|
131
|
+
signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
|
|
132
|
+
utilization: z.ZodNumber;
|
|
133
|
+
usable: z.ZodBoolean;
|
|
134
|
+
depth: z.ZodNumber;
|
|
135
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
136
|
+
bucketDepth: z.ZodNumber;
|
|
137
|
+
blockNumber: z.ZodNumber;
|
|
138
|
+
immutableFlag: z.ZodBoolean;
|
|
139
|
+
exists: z.ZodBoolean;
|
|
140
|
+
batchTTL: z.ZodOptional<z.ZodNumber>;
|
|
141
|
+
createdAt: z.ZodNumber;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
/**
|
|
144
|
+
* Account Metadata Schema V1
|
|
145
|
+
*/
|
|
146
|
+
export declare const AccountMetadataSchemaV1: z.ZodObject<{
|
|
147
|
+
accountName: z.ZodString;
|
|
148
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodString>;
|
|
149
|
+
createdAt: z.ZodNumber;
|
|
150
|
+
lastModified: z.ZodNumber;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
/**
|
|
153
|
+
* Unified account state snapshot schema used by both file export and Swarm sync.
|
|
154
|
+
* Contains minimal metadata instead of the full Account object.
|
|
155
|
+
*/
|
|
156
|
+
export declare const AccountStateSnapshotSchemaV1: z.ZodObject<{
|
|
157
|
+
version: z.ZodLiteral<1>;
|
|
158
|
+
timestamp: z.ZodNumber;
|
|
159
|
+
accountId: z.ZodString;
|
|
160
|
+
metadata: z.ZodObject<{
|
|
161
|
+
accountName: z.ZodString;
|
|
162
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodString>;
|
|
163
|
+
createdAt: z.ZodNumber;
|
|
164
|
+
lastModified: z.ZodNumber;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
identities: z.ZodArray<z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
accountId: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
169
|
+
name: z.ZodString;
|
|
170
|
+
defaultPostageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>>;
|
|
171
|
+
createdAt: z.ZodNumber;
|
|
172
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
appSessionDuration: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
connectedApps: z.ZodArray<z.ZodObject<{
|
|
177
|
+
appUrl: z.ZodString;
|
|
178
|
+
appName: z.ZodString;
|
|
179
|
+
lastConnectedAt: z.ZodNumber;
|
|
180
|
+
identityId: z.ZodString;
|
|
181
|
+
appIcon: z.ZodOptional<z.ZodString>;
|
|
182
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
183
|
+
connectedUntil: z.ZodOptional<z.ZodNumber>;
|
|
184
|
+
appSecret: z.ZodOptional<z.ZodString>;
|
|
185
|
+
}, z.core.$strip>>;
|
|
186
|
+
postageStamps: z.ZodArray<z.ZodObject<{
|
|
187
|
+
accountId: z.ZodString;
|
|
188
|
+
batchID: z.ZodPipe<z.ZodString, z.ZodTransform<BeeBatchId, string>>;
|
|
189
|
+
signerKey: z.ZodPipe<z.ZodString, z.ZodTransform<BeePrivateKey, string>>;
|
|
190
|
+
utilization: z.ZodNumber;
|
|
191
|
+
usable: z.ZodBoolean;
|
|
192
|
+
depth: z.ZodNumber;
|
|
193
|
+
amount: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
194
|
+
bucketDepth: z.ZodNumber;
|
|
195
|
+
blockNumber: z.ZodNumber;
|
|
196
|
+
immutableFlag: z.ZodBoolean;
|
|
197
|
+
exists: z.ZodBoolean;
|
|
198
|
+
batchTTL: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
createdAt: z.ZodNumber;
|
|
200
|
+
}, z.core.$strip>>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type PasskeyAccount = z.infer<typeof PasskeyAccountSchemaV1>;
|
|
203
|
+
export type EthereumAccount = z.infer<typeof EthereumAccountSchemaV1>;
|
|
204
|
+
export type AgentAccount = z.infer<typeof AgentAccountSchemaV1>;
|
|
205
|
+
export type Account = z.infer<typeof AccountSchemaV1>;
|
|
206
|
+
export type Identity = z.infer<typeof IdentitySchemaV1>;
|
|
207
|
+
export type ConnectedApp = z.infer<typeof ConnectedAppSchemaV1>;
|
|
208
|
+
export type PostageStamp = z.infer<typeof PostageStampSchemaV1>;
|
|
209
|
+
export type AccountMetadata = z.infer<typeof AccountMetadataSchemaV1>;
|
|
210
|
+
export type AccountStateSnapshot = z.infer<typeof AccountStateSnapshotSchemaV1>;
|
|
211
|
+
/**
|
|
212
|
+
* Network Settings Schema V1
|
|
213
|
+
* Stores user-configurable network endpoints (Bee node and Gnosis RPC)
|
|
214
|
+
*/
|
|
215
|
+
export declare const NetworkSettingsSchemaV1: z.ZodObject<{
|
|
216
|
+
beeNodeUrl: z.ZodString;
|
|
217
|
+
gnosisRpcUrl: z.ZodString;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
export type NetworkSettings = z.infer<typeof NetworkSettingsSchemaV1>;
|
|
220
|
+
/**
|
|
221
|
+
* Bucket update entry for cross-tab synchronization
|
|
222
|
+
*/
|
|
223
|
+
export declare const BucketUpdateSchema: z.ZodObject<{
|
|
224
|
+
index: z.ZodNumber;
|
|
225
|
+
value: z.ZodNumber;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
/**
|
|
228
|
+
* Utilization update message sent via BroadcastChannel
|
|
229
|
+
*/
|
|
230
|
+
export declare const UtilizationUpdateMessageSchema: z.ZodObject<{
|
|
231
|
+
type: z.ZodLiteral<"utilization-updated">;
|
|
232
|
+
batchId: z.ZodString;
|
|
233
|
+
buckets: z.ZodArray<z.ZodObject<{
|
|
234
|
+
index: z.ZodNumber;
|
|
235
|
+
value: z.ZodNumber;
|
|
236
|
+
}, z.core.$strip>>;
|
|
237
|
+
}, z.core.$strip>;
|
|
238
|
+
export type BucketUpdate = z.infer<typeof BucketUpdateSchema>;
|
|
239
|
+
export type UtilizationUpdateMessage = z.infer<typeof UtilizationUpdateMessageSchema>;
|
|
240
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,UAAU,EACV,OAAO,IAAI,UAAU,EACrB,KAAK,EACL,UAAU,IAAI,aAAa,EAC5B,MAAM,qBAAqB,CAAA;AAM5B,eAAO,MAAM,oBAAoB,sCAAsC,CAAA;AACvE,eAAO,MAAM,sBAAsB,sCAAsC,CAAA;AAYzE,eAAO,MAAM,eAAe,aAKxB,CAAA;AACJ,eAAO,MAAM,aAAa,aAAgB,CAAA;AAC1C,eAAO,MAAM,aAAa,aAAgB,CAAA;AAC1C,eAAO,MAAM,gBAAgB,aAAgB,CAAA;AAC7C,eAAO,MAAM,mBAAmB,aAAgB,CAAA;AAChD,eAAO,MAAM,gBAAgB,aAAgB,CAAA;AAC7C,eAAO,MAAM,eAAe,aAAiB,CAAA;AAC7C,eAAO,MAAM,eAAe,8FAG3B,CAAA;AACD,eAAO,MAAM,eAAe,8FAG3B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AACvD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,SAAS,GAAG,CAAC,C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ACvD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAC/D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAC/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACrE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAM/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAMrE;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;iBAIzC,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounced Utilization Uploader
|
|
3
|
+
*
|
|
4
|
+
* Batches multiple utilization updates together to minimize upload frequency.
|
|
5
|
+
* Uses a per-batch debounce mechanism with configurable delay.
|
|
6
|
+
*/
|
|
7
|
+
import type { DirtyChunkTracker } from "../utils/batch-utilization";
|
|
8
|
+
/**
|
|
9
|
+
* Debounced uploader for batch utilization data
|
|
10
|
+
*
|
|
11
|
+
* Batches multiple updates within a time window and uploads only once.
|
|
12
|
+
* Each batch has its own independent debounce timer.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DebouncedUtilizationUploader {
|
|
15
|
+
private pendingUploads;
|
|
16
|
+
private defaultDelay;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new debounced uploader
|
|
19
|
+
* @param delay - Debounce delay in milliseconds (default: 1000ms = 1s)
|
|
20
|
+
*/
|
|
21
|
+
constructor(delay?: number);
|
|
22
|
+
/**
|
|
23
|
+
* Schedule an upload for a batch (debounced)
|
|
24
|
+
*
|
|
25
|
+
* If multiple updates occur within the debounce window, they are merged
|
|
26
|
+
* and only one upload is performed.
|
|
27
|
+
*
|
|
28
|
+
* @param batchId - Batch ID (hex string)
|
|
29
|
+
* @param tracker - Dirty chunk tracker with current changes
|
|
30
|
+
* @param uploadFn - Function to execute upload
|
|
31
|
+
* @param delay - Optional custom delay for this upload
|
|
32
|
+
* @returns Promise that resolves when upload completes
|
|
33
|
+
*/
|
|
34
|
+
scheduleUpload(batchId: string, tracker: DirtyChunkTracker, uploadFn: () => Promise<void>, delay?: number): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Flush pending upload for a batch immediately (cancel debounce)
|
|
37
|
+
* @param batchId - Batch ID to flush
|
|
38
|
+
*/
|
|
39
|
+
flush(batchId: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Flush all pending uploads immediately
|
|
42
|
+
*/
|
|
43
|
+
flushAll(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Cancel pending upload for a batch (discard changes)
|
|
46
|
+
* @param batchId - Batch ID to cancel
|
|
47
|
+
*/
|
|
48
|
+
cancel(batchId: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Cancel all pending uploads (discard all changes)
|
|
51
|
+
*/
|
|
52
|
+
cancelAll(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get count of pending uploads
|
|
55
|
+
*/
|
|
56
|
+
getPendingCount(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a batch has a pending upload
|
|
59
|
+
*/
|
|
60
|
+
hasPending(batchId: string): boolean;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=debounced-uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounced-uploader.d.ts","sourceRoot":"","sources":["../../src/storage/debounced-uploader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAwBnE;;;;;GAKG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,cAAc,CAAmC;IACzD,OAAO,CAAC,YAAY,CAAQ;IAE5B;;;OAGG;gBACS,KAAK,SAA4B;IAI7C;;;;;;;;;;;OAWG;IACH,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC7B,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAkDhB;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB3C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAa7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAUjB;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGrC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB Cache for Batch Utilization Chunks
|
|
3
|
+
*
|
|
4
|
+
* Provides fast local caching of 4KB utilization chunks to avoid
|
|
5
|
+
* repeated Swarm downloads. Each chunk is 4096 bytes containing
|
|
6
|
+
* 1024 bucket counters (uint32).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Cache entry for a single utilization chunk
|
|
10
|
+
*/
|
|
11
|
+
export interface ChunkCacheEntry {
|
|
12
|
+
/** Batch ID (hex string) */
|
|
13
|
+
batchId: string;
|
|
14
|
+
/** Chunk index (0-63) */
|
|
15
|
+
chunkIndex: number;
|
|
16
|
+
/** Serialized chunk data (4KB) */
|
|
17
|
+
data: Uint8Array;
|
|
18
|
+
/** Content hash for change detection */
|
|
19
|
+
contentHash: string;
|
|
20
|
+
/** SOC reference if uploaded to Swarm */
|
|
21
|
+
socReference?: string;
|
|
22
|
+
/** Last access timestamp (for eviction) */
|
|
23
|
+
lastAccess: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Metadata for a batch's utilization state
|
|
27
|
+
*/
|
|
28
|
+
export interface BatchMetadata {
|
|
29
|
+
batchId: string;
|
|
30
|
+
lastSync: number;
|
|
31
|
+
chunkCount: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Manages IndexedDB cache for batch utilization chunks
|
|
35
|
+
*/
|
|
36
|
+
export declare class UtilizationStoreDB {
|
|
37
|
+
private db;
|
|
38
|
+
/**
|
|
39
|
+
* Open the IndexedDB database
|
|
40
|
+
*/
|
|
41
|
+
open(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a chunk from cache
|
|
44
|
+
* @param batchId - Batch ID (hex string)
|
|
45
|
+
* @param chunkIndex - Chunk index (0-63)
|
|
46
|
+
* @returns Cache entry or undefined if not found
|
|
47
|
+
*/
|
|
48
|
+
getChunk(batchId: string, chunkIndex: number): Promise<ChunkCacheEntry | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Store a chunk in cache
|
|
51
|
+
* @param entry - Cache entry to store
|
|
52
|
+
*/
|
|
53
|
+
putChunk(entry: ChunkCacheEntry): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get all chunks for a batch
|
|
56
|
+
* @param batchId - Batch ID (hex string)
|
|
57
|
+
* @returns Array of cache entries (sorted by chunkIndex)
|
|
58
|
+
*/
|
|
59
|
+
getAllChunks(batchId: string): Promise<ChunkCacheEntry[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Clear all chunks for a batch
|
|
62
|
+
* @param batchId - Batch ID (hex string)
|
|
63
|
+
*/
|
|
64
|
+
clearBatch(batchId: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Update lastAccess timestamp for a chunk
|
|
67
|
+
* @param batchId - Batch ID (hex string)
|
|
68
|
+
* @param chunkIndex - Chunk index (0-63)
|
|
69
|
+
*/
|
|
70
|
+
private touchChunk;
|
|
71
|
+
/**
|
|
72
|
+
* Get batch metadata
|
|
73
|
+
* @param batchId - Batch ID (hex string)
|
|
74
|
+
* @returns Metadata or undefined if not found
|
|
75
|
+
*/
|
|
76
|
+
getMetadata(batchId: string): Promise<BatchMetadata | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Update batch metadata
|
|
79
|
+
* @param metadata - Metadata to store
|
|
80
|
+
*/
|
|
81
|
+
putMetadata(metadata: BatchMetadata): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Close the database connection
|
|
84
|
+
*/
|
|
85
|
+
close(): void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Policy for cache eviction
|
|
89
|
+
*/
|
|
90
|
+
export interface CacheEvictionPolicy {
|
|
91
|
+
/** Maximum age in milliseconds (default: 7 days) */
|
|
92
|
+
maxAge?: number;
|
|
93
|
+
/** Maximum number of chunks to keep (default: 640 = 10 batches) */
|
|
94
|
+
maxChunks?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Evict old cache entries based on policy
|
|
98
|
+
* @param cache - Cache database instance
|
|
99
|
+
* @param policy - Eviction policy
|
|
100
|
+
*/
|
|
101
|
+
export declare function evictOldEntries(cache: UtilizationStoreDB, policy?: CacheEvictionPolicy): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Calculate content hash for chunk data
|
|
104
|
+
* @param data - Chunk data (4KB)
|
|
105
|
+
* @returns Hex string hash
|
|
106
|
+
*/
|
|
107
|
+
export declare function calculateContentHash(data: Uint8Array): string;
|
|
108
|
+
//# sourceMappingURL=utilization-store.d.ts.map
|
|
@@ -0,0 +1 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Aa,GAAG,OAAO,CAAC,IAAI,CAAC;IAezD;;OAEG;IACH,KAAK,IAAI,IAAI;CAMd;AAMD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,kBAAkB,EACzB,MAAM,GAAE,mBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqDf;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAG7D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AuthOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Swarm ID Auth - Runs in the authentication popup
|
|
4
|
+
*
|
|
5
|
+
* Responsibilities:
|
|
6
|
+
* - Load or generate master identity
|
|
7
|
+
* - Derive app-specific secrets
|
|
8
|
+
* - Send secrets to iframe via postMessage
|
|
9
|
+
* - Manage master key storage
|
|
10
|
+
*/
|
|
11
|
+
export declare class SwarmIdAuth {
|
|
12
|
+
private appOrigin;
|
|
13
|
+
private masterKey;
|
|
14
|
+
private masterKeyStorageKey;
|
|
15
|
+
private postageBatchId;
|
|
16
|
+
private signerKey;
|
|
17
|
+
constructor(options?: AuthOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Initialize the auth popup
|
|
20
|
+
*/
|
|
21
|
+
initialize(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the app origin
|
|
24
|
+
*/
|
|
25
|
+
getAppOrigin(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get the master key (for display purposes, should be truncated)
|
|
28
|
+
*/
|
|
29
|
+
getMasterKey(): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Check if master key exists
|
|
32
|
+
*/
|
|
33
|
+
hasMasterKey(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Set the postage batch ID
|
|
36
|
+
*/
|
|
37
|
+
setPostageBatchId(batchId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the postage batch ID
|
|
40
|
+
*/
|
|
41
|
+
getPostageBatchId(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Set the signer key
|
|
44
|
+
*/
|
|
45
|
+
setSignerKey(key: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the signer key
|
|
48
|
+
*/
|
|
49
|
+
getSignerKey(): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Set authentication data (batch ID and/or signer key)
|
|
52
|
+
*/
|
|
53
|
+
setAuthData({ postageBatchId, signerKey, }: {
|
|
54
|
+
postageBatchId?: string;
|
|
55
|
+
signerKey?: string;
|
|
56
|
+
}): void;
|
|
57
|
+
/**
|
|
58
|
+
* Setup new identity (generate and store master key)
|
|
59
|
+
*/
|
|
60
|
+
setupNewIdentity(): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Authenticate - derive app-specific secret and send to iframe
|
|
63
|
+
*/
|
|
64
|
+
authenticate(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Close the popup window
|
|
67
|
+
*/
|
|
68
|
+
close(delay?: number): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Initialize auth popup (called from HTML page)
|
|
72
|
+
*/
|
|
73
|
+
export declare function initAuth(options?: AuthOptions): Promise<SwarmIdAuth>;
|
|
74
|
+
//# sourceMappingURL=swarm-id-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-id-auth.d.ts","sourceRoot":"","sources":["../src/swarm-id-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,mBAAmB,CAAQ;IACnC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,SAAS,CAAoB;gBAEzB,OAAO,GAAE,WAAgB;IAIrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4CjC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACH,iBAAiB,IAAI,MAAM,GAAG,SAAS;IAIvC;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;OAEG;IACH,WAAW,CAAC,EACV,cAAc,EACd,SAAS,GACV,EAAE;QACD,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,GAAG,IAAI;IAKR;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAWzC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAkDnC;;OAEG;IACH,KAAK,CAAC,KAAK,GAAE,MAAa,GAAG,IAAI;CAKlC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAI1E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function e(e,r){console.log("[KeyDerivation] Deriving secret for app:",r);const n=new TextEncoder,o=function(e){const t=e.replace(/\s/g,"");if(t.length%2!=0)throw new Error("Invalid hex string: length must be even");const r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)r[e/2]=parseInt(t.substring(e,e+2),16);return r}(e),i=n.encode(r),a=await crypto.subtle.importKey("raw",o,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),s=await crypto.subtle.sign("HMAC",a,i),g=t(new Uint8Array(s));return console.log("[KeyDerivation] Secret derived:",g.substring(0,16)+"..."),g}function t(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}class r{constructor(e={}){this.masterKeyStorageKey=e.masterKeyStorageKey||"swarm-master-key"}async initialize(){if(!window.opener)throw new Error("No opener window found. This page must be opened by Swarm ID iframe.");try{const e=window.opener.location.origin;if(e!==window.location.origin)throw new Error(`Opener origin (${e}) does not match expected origin`);console.log("[Auth] Security: Opener origin validated ✓")}catch{throw new Error("Cannot verify opener origin - cross-origin access denied")}const e=new URLSearchParams(window.location.search);if(this.appOrigin=e.get("origin")??void 0,!this.appOrigin)throw new Error("No origin parameter found in URL");console.log("[Auth] Got app origin from URL parameter:",this.appOrigin),this.masterKey=localStorage.getItem(this.masterKeyStorageKey)??void 0,this.masterKey?console.log("[Auth] Master key loaded from localStorage"):console.log("[Auth] No master key found")}getAppOrigin(){return this.appOrigin}getMasterKey(){return this.masterKey}hasMasterKey(){return void 0!==this.masterKey}setPostageBatchId(e){this.postageBatchId=e}getPostageBatchId(){return this.postageBatchId}setSignerKey(e){this.signerKey=e}getSignerKey(){return this.signerKey}setAuthData({postageBatchId:e,signerKey:t}){this.postageBatchId=e,this.signerKey=t}async setupNewIdentity(){console.log("[Auth] Setting up new identity...");const e=await async function(){console.log("[KeyDerivation] Generating random master key...");const e=new Uint8Array(32);crypto.getRandomValues(e);const r=t(e);return console.log("[KeyDerivation] Master key generated:",r.substring(0,16)+"..."),r}();return localStorage.setItem(this.masterKeyStorageKey,e),this.masterKey=e,console.log("[Auth] New master key generated and stored"),e}async authenticate(){if(!this.masterKey)throw new Error("No master key available. Please set up an identity first.");if(!this.appOrigin)throw new Error("Unknown app origin. Cannot authenticate.");if(!this.postageBatchId&&!this.signerKey)throw new Error("No postage batch ID or signer key provided. Cannot authenticate.");console.log("[Auth] Starting authentication for app:",this.appOrigin);const t=await e(this.masterKey,this.appOrigin);if(console.log("[Auth] App secret derived:",t.substring(0,16)+"..."),!window.opener||window.opener.closed)throw new Error("Opener window not available");console.log("[Auth] Sending auth data to iframe..."),window.opener.postMessage({type:"setSecret",appOrigin:this.appOrigin,data:{secret:t,postageBatchId:this.postageBatchId,signerKey:this.signerKey}},window.location.origin),console.log("[Auth] Auth data sent to iframe")}close(e=1500){setTimeout(()=>{window.close()},e)}}async function n(e){const t=new r(e);return await t.initialize(),t}export{r as SwarmIdAuth,n as initAuth};
|
|
2
|
+
//# sourceMappingURL=swarm-id-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-id-auth.js","sources":["../src/utils/key-derivation.ts","../src/swarm-id-auth.ts"],"sourcesContent":["/**\n * Swarm Identity - Key Derivation Utilities\n *\n * Provides cryptographic functions for deriving app-specific secrets\n * from a master identity key.\n */\n\n/**\n * Derive an app-specific secret from a master key and app origin\n *\n * Uses HMAC-SHA256 to create a deterministic, unique secret for each app.\n * The same master key + app origin will always produce the same secret.\n *\n * @param masterKey - The master identity key (hex string)\n * @param appOrigin - The app's origin (e.g., \"https://swarm-app.local:8080\")\n * @returns The derived secret as a hex string\n */\nexport async function deriveSecret(\n masterKey: string,\n appOrigin: string,\n): Promise<string> {\n console.log(\"[KeyDerivation] Deriving secret for app:\", appOrigin)\n\n const encoder = new TextEncoder()\n\n // Convert master key from hex string to Uint8Array\n const keyData = hexToUint8Array(masterKey)\n const message = encoder.encode(appOrigin)\n\n // Import the master key for HMAC\n const cryptoKey = await crypto.subtle.importKey(\n \"raw\",\n keyData,\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"],\n )\n\n // Sign the app origin with the master key\n const signature = await crypto.subtle.sign(\"HMAC\", cryptoKey, message)\n\n // Convert to hex string\n const secretHex = uint8ArrayToHex(new Uint8Array(signature))\n console.log(\n \"[KeyDerivation] Secret derived:\",\n secretHex.substring(0, 16) + \"...\",\n )\n\n return secretHex\n}\n\n/**\n * Generate a random master key for testing/demo purposes\n *\n * In production, this would be derived from a user's mnemonic or\n * imported from an existing identity.\n *\n * @returns A random 32-byte key as a hex string\n */\nexport async function generateMasterKey(): Promise<string> {\n console.log(\"[KeyDerivation] Generating random master key...\")\n\n const randomBytes = new Uint8Array(32)\n crypto.getRandomValues(randomBytes)\n\n const masterKey = uint8ArrayToHex(randomBytes)\n console.log(\n \"[KeyDerivation] Master key generated:\",\n masterKey.substring(0, 16) + \"...\",\n )\n\n return masterKey\n}\n\n/**\n * Convert a hex string to Uint8Array\n *\n * @param hexString - Hex string (e.g., \"deadbeef\")\n * @returns Uint8Array\n */\nexport function hexToUint8Array(hexString: string): Uint8Array {\n // Remove any whitespace and ensure even length\n const hex = hexString.replace(/\\s/g, \"\")\n if (hex.length % 2 !== 0) {\n throw new Error(\"Invalid hex string: length must be even\")\n }\n\n const bytes = new Uint8Array(hex.length / 2)\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16)\n }\n\n return bytes\n}\n\n/**\n * Convert a Uint8Array to hex string\n *\n * @param bytes - Uint8Array to convert\n * @returns Hex string (e.g., \"deadbeef\")\n */\nexport function uint8ArrayToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\")\n}\n\n/**\n * Verify that a derived secret matches the expected value\n *\n * Useful for testing.\n *\n * @param masterKey - Master key hex string\n * @param appOrigin - App origin\n * @param expectedSecret - Expected secret hex string\n * @returns true if the derived secret matches the expected secret\n */\nexport async function verifySecret(\n masterKey: string,\n appOrigin: string,\n expectedSecret: string,\n): Promise<boolean> {\n const derived = await deriveSecret(masterKey, appOrigin)\n return derived === expectedSecret\n}\n\n// Export utility functions for testing\nexport const utils = {\n hexToUint8Array,\n uint8ArrayToHex,\n}\n","import type { AuthOptions } from \"./types\"\nimport { deriveSecret, generateMasterKey } from \"./utils/key-derivation\"\n\n/**\n * Swarm ID Auth - Runs in the authentication popup\n *\n * Responsibilities:\n * - Load or generate master identity\n * - Derive app-specific secrets\n * - Send secrets to iframe via postMessage\n * - Manage master key storage\n */\nexport class SwarmIdAuth {\n private appOrigin: string | undefined\n private masterKey: string | undefined\n private masterKeyStorageKey: string\n private postageBatchId: string | undefined\n private signerKey: string | undefined\n\n constructor(options: AuthOptions = {}) {\n this.masterKeyStorageKey = options.masterKeyStorageKey || \"swarm-master-key\"\n }\n\n /**\n * Initialize the auth popup\n */\n async initialize(): Promise<void> {\n // Security: Validate that opener is from our own origin\n if (!window.opener) {\n throw new Error(\n \"No opener window found. This page must be opened by Swarm ID iframe.\",\n )\n }\n\n // Check opener origin by trying to access its location\n try {\n const openerOrigin = (window.opener as Window).location.origin\n if (openerOrigin !== window.location.origin) {\n throw new Error(\n `Opener origin (${openerOrigin}) does not match expected origin`,\n )\n }\n console.log(\"[Auth] Security: Opener origin validated ✓\")\n } catch {\n // If we can't access opener.location, it's cross-origin - this is suspicious\n throw new Error(\n \"Cannot verify opener origin - cross-origin access denied\",\n )\n }\n\n // Get app origin from URL parameter\n const urlParams = new URLSearchParams(window.location.search)\n this.appOrigin = urlParams.get(\"origin\") ?? undefined\n\n if (!this.appOrigin) {\n throw new Error(\"No origin parameter found in URL\")\n }\n\n console.log(\"[Auth] Got app origin from URL parameter:\", this.appOrigin)\n\n // Load master key\n this.masterKey = localStorage.getItem(this.masterKeyStorageKey) ?? undefined\n\n if (!this.masterKey) {\n console.log(\"[Auth] No master key found\")\n } else {\n console.log(\"[Auth] Master key loaded from localStorage\")\n }\n }\n\n /**\n * Get the app origin\n */\n getAppOrigin(): string | undefined {\n return this.appOrigin\n }\n\n /**\n * Get the master key (for display purposes, should be truncated)\n */\n getMasterKey(): string | undefined {\n return this.masterKey\n }\n\n /**\n * Check if master key exists\n */\n hasMasterKey(): boolean {\n return this.masterKey !== undefined\n }\n\n /**\n * Set the postage batch ID\n */\n setPostageBatchId(batchId: string): void {\n this.postageBatchId = batchId\n }\n\n /**\n * Get the postage batch ID\n */\n getPostageBatchId(): string | undefined {\n return this.postageBatchId\n }\n\n /**\n * Set the signer key\n */\n setSignerKey(key: string): void {\n this.signerKey = key\n }\n\n /**\n * Get the signer key\n */\n getSignerKey(): string | undefined {\n return this.signerKey\n }\n\n /**\n * Set authentication data (batch ID and/or signer key)\n */\n setAuthData({\n postageBatchId,\n signerKey,\n }: {\n postageBatchId?: string\n signerKey?: string\n }): void {\n this.postageBatchId = postageBatchId\n this.signerKey = signerKey\n }\n\n /**\n * Setup new identity (generate and store master key)\n */\n async setupNewIdentity(): Promise<string> {\n console.log(\"[Auth] Setting up new identity...\")\n\n const newMasterKey = await generateMasterKey()\n localStorage.setItem(this.masterKeyStorageKey, newMasterKey)\n this.masterKey = newMasterKey\n\n console.log(\"[Auth] New master key generated and stored\")\n return newMasterKey\n }\n\n /**\n * Authenticate - derive app-specific secret and send to iframe\n */\n async authenticate(): Promise<void> {\n if (!this.masterKey) {\n throw new Error(\n \"No master key available. Please set up an identity first.\",\n )\n }\n\n if (!this.appOrigin) {\n throw new Error(\"Unknown app origin. Cannot authenticate.\")\n }\n\n if (!this.postageBatchId && !this.signerKey) {\n throw new Error(\n \"No postage batch ID or signer key provided. Cannot authenticate.\",\n )\n }\n\n console.log(\"[Auth] Starting authentication for app:\", this.appOrigin)\n\n // Derive app-specific secret\n const appSecret = await deriveSecret(this.masterKey, this.appOrigin)\n console.log(\n \"[Auth] App secret derived:\",\n appSecret.substring(0, 16) + \"...\",\n )\n\n // Send secret to opener (the iframe that opened this popup)\n if (!window.opener || (window.opener as Window).closed) {\n throw new Error(\"Opener window not available\")\n }\n\n console.log(\"[Auth] Sending auth data to iframe...\")\n\n // Send structured auth data to iframe via postMessage\n ;(window.opener as WindowProxy).postMessage(\n {\n type: \"setSecret\",\n appOrigin: this.appOrigin,\n data: {\n secret: appSecret,\n postageBatchId: this.postageBatchId,\n signerKey: this.signerKey,\n },\n },\n window.location.origin, // Target the iframe's origin (same as this popup)\n )\n\n console.log(\"[Auth] Auth data sent to iframe\")\n }\n\n /**\n * Close the popup window\n */\n close(delay: number = 1500): void {\n setTimeout(() => {\n window.close()\n }, delay)\n }\n}\n\n/**\n * Initialize auth popup (called from HTML page)\n */\nexport async function initAuth(options?: AuthOptions): Promise<SwarmIdAuth> {\n const auth = new SwarmIdAuth(options)\n await auth.initialize()\n return auth\n}\n"],"names":["async","deriveSecret","masterKey","appOrigin","console","log","encoder","TextEncoder","keyData","hexString","hex","replace","length","Error","bytes","Uint8Array","i","parseInt","substring","hexToUint8Array","message","encode","cryptoKey","crypto","subtle","importKey","name","hash","signature","sign","secretHex","uint8ArrayToHex","Array","from","map","b","toString","padStart","join","SwarmIdAuth","constructor","options","this","masterKeyStorageKey","initialize","window","opener","openerOrigin","location","origin","urlParams","URLSearchParams","search","get","undefined","localStorage","getItem","getAppOrigin","getMasterKey","hasMasterKey","setPostageBatchId","batchId","postageBatchId","getPostageBatchId","setSignerKey","key","signerKey","getSignerKey","setAuthData","setupNewIdentity","newMasterKey","randomBytes","getRandomValues","generateMasterKey","setItem","authenticate","appSecret","closed","postMessage","type","data","secret","close","delay","setTimeout","initAuth","auth"],"mappings":"AAiBOA,eAAeC,EACpBC,EACAC,GAEAC,QAAQC,IAAI,2CAA4CF,GAExD,MAAMG,EAAU,IAAIC,YAGdC,EAsDF,SAA0BC,GAE9B,MAAMC,EAAMD,EAAUE,QAAQ,MAAO,IACrC,GAAID,EAAIE,OAAS,GAAM,EACrB,MAAM,IAAIC,MAAM,2CAGlB,MAAMC,EAAQ,IAAIC,WAAWL,EAAIE,OAAS,GAC1C,IAAK,IAAII,EAAI,EAAGA,EAAIN,EAAIE,OAAQI,GAAK,EACnCF,EAAME,EAAI,GAAKC,SAASP,EAAIQ,UAAUF,EAAGA,EAAI,GAAI,IAGnD,OAAOF,CACT,CAnEkBK,CAAgBjB,GAC1BkB,EAAUd,EAAQe,OAAOlB,GAGzBmB,QAAkBC,OAAOC,OAAOC,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