@kheopskit/core 5.1.0 → 5.1.2
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/dist/errors-Caq2csKx.mjs +181 -0
- package/dist/errors-Caq2csKx.mjs.map +1 -0
- package/dist/errors-DPw6pc2H.js +222 -0
- package/dist/errors-DPw6pc2H.js.map +1 -0
- package/dist/ethereum.d.mts +39 -38
- package/dist/ethereum.d.ts +39 -38
- package/dist/ethereum.js +214 -281
- package/dist/ethereum.js.map +1 -1
- package/dist/ethereum.mjs +211 -282
- package/dist/ethereum.mjs.map +1 -1
- package/dist/{getCachedObservable-C4E8dfMp.d.ts → getCachedObservable-LUq9IfEx.d.mts} +5 -2
- package/dist/{getCachedObservable-C4E8dfMp.d.mts → getCachedObservable-LUq9IfEx.d.ts} +5 -2
- package/dist/iconCache-BSa42Sui.mjs +343 -0
- package/dist/iconCache-BSa42Sui.mjs.map +1 -0
- package/dist/iconCache-DS4zNiP1.js +396 -0
- package/dist/iconCache-DS4zNiP1.js.map +1 -0
- package/dist/index.d.mts +65 -59
- package/dist/index.d.ts +65 -59
- package/dist/index.js +901 -1015
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +885 -1016
- package/dist/index.mjs.map +1 -1
- package/dist/injectedWallets-B1MCxAE9.js +148 -0
- package/dist/injectedWallets-B1MCxAE9.js.map +1 -0
- package/dist/injectedWallets-B3Vysfvr.mjs +119 -0
- package/dist/injectedWallets-B3Vysfvr.mjs.map +1 -0
- package/dist/internal.d.mts +18 -16
- package/dist/internal.d.ts +18 -16
- package/dist/internal.js +9 -20
- package/dist/internal.mjs +3 -20
- package/dist/polkadot.d.mts +37 -36
- package/dist/polkadot.d.ts +37 -36
- package/dist/polkadot.js +178 -220
- package/dist/polkadot.js.map +1 -1
- package/dist/polkadot.mjs +175 -221
- package/dist/polkadot.mjs.map +1 -1
- package/dist/polkadotExtensions-BoVKhNU_.mjs +23 -0
- package/dist/polkadotExtensions-BoVKhNU_.mjs.map +1 -0
- package/dist/polkadotExtensions-y4J9UzYl.js +28 -0
- package/dist/polkadotExtensions-y4J9UzYl.js.map +1 -0
- package/dist/solana.d.mts +50 -48
- package/dist/solana.d.ts +50 -48
- package/dist/solana.js +320 -378
- package/dist/solana.js.map +1 -1
- package/dist/solana.mjs +314 -379
- package/dist/solana.mjs.map +1 -1
- package/dist/types-Cb-vuEru.d.mts +330 -0
- package/dist/types-Cb-vuEru.d.ts +330 -0
- package/dist/types-DKU-SNio.js +169 -0
- package/dist/{chunk-P7BPHHVV.js.map → types-DKU-SNio.js.map} +1 -1
- package/dist/types-jnifAAA0.mjs +104 -0
- package/dist/types-jnifAAA0.mjs.map +1 -0
- package/package.json +12 -12
- package/dist/chunk-3Y5N4N3Q.mjs +0 -267
- package/dist/chunk-3Y5N4N3Q.mjs.map +0 -1
- package/dist/chunk-BWUUHUDK.mjs +0 -24
- package/dist/chunk-BWUUHUDK.mjs.map +0 -1
- package/dist/chunk-D3EQMFZ2.js +0 -24
- package/dist/chunk-D3EQMFZ2.js.map +0 -1
- package/dist/chunk-DF7EKK4G.mjs +0 -106
- package/dist/chunk-DF7EKK4G.mjs.map +0 -1
- package/dist/chunk-EH73P476.js +0 -106
- package/dist/chunk-EH73P476.js.map +0 -1
- package/dist/chunk-JVSCMJY5.mjs +0 -147
- package/dist/chunk-JVSCMJY5.mjs.map +0 -1
- package/dist/chunk-P7BPHHVV.js +0 -76
- package/dist/chunk-SO64R7Z6.js +0 -267
- package/dist/chunk-SO64R7Z6.js.map +0 -1
- package/dist/chunk-WOPCW2OX.mjs +0 -76
- package/dist/chunk-WOPCW2OX.mjs.map +0 -1
- package/dist/chunk-XOGQMEV2.js +0 -147
- package/dist/chunk-XOGQMEV2.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs.map +0 -1
- package/dist/types-0iDBydsK.d.mts +0 -327
- package/dist/types-0iDBydsK.d.ts +0 -327
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { n as isWalletConnectWallet, o as parseWalletId } from "./types-jnifAAA0.mjs";
|
|
2
|
+
import { t as POLKADOT_EXTENSIONS } from "./polkadotExtensions-BoVKhNU_.mjs";
|
|
3
|
+
//#region src/utils/hydrateState.ts
|
|
4
|
+
/**
|
|
5
|
+
* Looks up the icon for a wallet from known Polkadot extensions only.
|
|
6
|
+
* Ethereum icons will be populated from the localStorage icon cache via the merge function.
|
|
7
|
+
*
|
|
8
|
+
* Note: We DON'T use localStorage icon cache here because hydrateWallet is called
|
|
9
|
+
* during SSR (server) and client hydration. localStorage isn't available on server,
|
|
10
|
+
* so using it would cause a hydration mismatch. Icons for Ethereum wallets will be
|
|
11
|
+
* populated when the hydration buffer merges cached wallets with live wallets.
|
|
12
|
+
*/
|
|
13
|
+
const lookupWalletIcon = (platform, identifier) => {
|
|
14
|
+
if (platform === "polkadot") return POLKADOT_EXTENSIONS[identifier]?.icon ?? "";
|
|
15
|
+
return "";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when trying to use a placeholder wallet that hasn't fully loaded yet.
|
|
19
|
+
*/
|
|
20
|
+
var PendingWalletError = class extends Error {
|
|
21
|
+
constructor(walletId) {
|
|
22
|
+
super(`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`);
|
|
23
|
+
this.name = "PendingWalletError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Converts a CachedWallet to a placeholder wallet for SSR hydration display.
|
|
28
|
+
*
|
|
29
|
+
* The placeholder carries only the SDK-free {@link BaseWallet} fields; the real
|
|
30
|
+
* wallet (with its injected provider/extension/standard-wallet handle) replaces
|
|
31
|
+
* it once it loads. connect/disconnect throw until then.
|
|
32
|
+
*/
|
|
33
|
+
const hydrateWallet = (cached) => {
|
|
34
|
+
const throwPending = () => {
|
|
35
|
+
throw new PendingWalletError(cached.id);
|
|
36
|
+
};
|
|
37
|
+
if (cached.type === "walletconnect") return {
|
|
38
|
+
id: cached.id,
|
|
39
|
+
type: "walletconnect",
|
|
40
|
+
platforms: [],
|
|
41
|
+
name: cached.name,
|
|
42
|
+
icon: "",
|
|
43
|
+
isConnected: cached.isConnected,
|
|
44
|
+
connect: throwPending,
|
|
45
|
+
disconnect: throwPending
|
|
46
|
+
};
|
|
47
|
+
const { platform, identifier } = parseWalletId(cached.id);
|
|
48
|
+
return {
|
|
49
|
+
id: cached.id,
|
|
50
|
+
platform: cached.platform,
|
|
51
|
+
type: cached.type,
|
|
52
|
+
name: cached.name,
|
|
53
|
+
icon: lookupWalletIcon(platform, identifier),
|
|
54
|
+
isConnected: cached.isConnected,
|
|
55
|
+
connect: throwPending,
|
|
56
|
+
disconnect: throwPending
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Converts a CachedAccount to a placeholder account for SSR hydration display.
|
|
61
|
+
*
|
|
62
|
+
* The placeholder carries the SDK-free {@link BaseWalletAccount} fields plus the
|
|
63
|
+
* plain, serializable platform data that lives in the cache — Ethereum `chainId`
|
|
64
|
+
* and the Polkadot key `type`. Those render immediately on reload (no blank →
|
|
65
|
+
* value flicker) and match what the live account will report. Only the SDK
|
|
66
|
+
* handles (`client`/`signer`/`polkadotSigner`) are absent until the real account
|
|
67
|
+
* replaces this placeholder; signing stays gated on `isHydrating` until then.
|
|
68
|
+
*/
|
|
69
|
+
const hydrateAccount = (cached) => ({
|
|
70
|
+
id: cached.id,
|
|
71
|
+
platform: cached.platform,
|
|
72
|
+
address: cached.address,
|
|
73
|
+
name: cached.name,
|
|
74
|
+
walletId: cached.walletId,
|
|
75
|
+
walletName: cached.walletName,
|
|
76
|
+
...cached.platform === "ethereum" && { chainId: cached.chainId },
|
|
77
|
+
...cached.platform === "polkadot" && { type: cached.polkadotAccountType }
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Converts a wallet to a CachedWallet for storage.
|
|
81
|
+
* Only extracts the serializable properties needed for hydration.
|
|
82
|
+
*/
|
|
83
|
+
const serializeWallet = (wallet) => ({
|
|
84
|
+
id: wallet.id,
|
|
85
|
+
platform: isWalletConnectWallet(wallet) ? void 0 : wallet.platform,
|
|
86
|
+
type: wallet.type,
|
|
87
|
+
name: wallet.name,
|
|
88
|
+
isConnected: wallet.isConnected
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Converts an account to a CachedAccount for storage.
|
|
92
|
+
* Only extracts the serializable properties needed for hydration. Platform-only
|
|
93
|
+
* fields (Ethereum chainId, Polkadot key type) are read defensively so this
|
|
94
|
+
* stays SDK-free.
|
|
95
|
+
*/
|
|
96
|
+
const serializeAccount = (account) => ({
|
|
97
|
+
id: account.id,
|
|
98
|
+
platform: account.platform,
|
|
99
|
+
address: account.address,
|
|
100
|
+
name: account.name,
|
|
101
|
+
chainId: account.platform === "ethereum" ? account.chainId : void 0,
|
|
102
|
+
polkadotAccountType: account.platform === "polkadot" ? account.type : void 0,
|
|
103
|
+
walletId: account.walletId,
|
|
104
|
+
walletName: account.walletName
|
|
105
|
+
});
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/utils/storage.ts
|
|
108
|
+
/**
|
|
109
|
+
* A no-op storage implementation that does nothing.
|
|
110
|
+
* Useful for testing or SSR environments where no storage is needed.
|
|
111
|
+
*/
|
|
112
|
+
const noopStorage = {
|
|
113
|
+
getItem: () => null,
|
|
114
|
+
setItem: () => {},
|
|
115
|
+
removeItem: () => {}
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Cached localStorage wrapper instance.
|
|
119
|
+
* Lazily initialized on first access to avoid SSR issues.
|
|
120
|
+
*/
|
|
121
|
+
let _safeLocalStorage = null;
|
|
122
|
+
/**
|
|
123
|
+
* Creates the localStorage wrapper, testing for availability.
|
|
124
|
+
* Returns noopStorage if localStorage is unavailable (SSR, private browsing, etc.)
|
|
125
|
+
*/
|
|
126
|
+
const createSafeLocalStorage = () => {
|
|
127
|
+
if (typeof window === "undefined") return noopStorage;
|
|
128
|
+
try {
|
|
129
|
+
const testKey = "__kheopskit_test__";
|
|
130
|
+
window.localStorage.setItem(testKey, testKey);
|
|
131
|
+
window.localStorage.removeItem(testKey);
|
|
132
|
+
return {
|
|
133
|
+
getItem: (key) => window.localStorage.getItem(key),
|
|
134
|
+
setItem: (key, value) => window.localStorage.setItem(key, value),
|
|
135
|
+
removeItem: (key) => window.localStorage.removeItem(key),
|
|
136
|
+
subscribe: (key, callback) => {
|
|
137
|
+
const handler = (event) => {
|
|
138
|
+
if (event.key === key) callback(event.newValue);
|
|
139
|
+
};
|
|
140
|
+
window.addEventListener("storage", handler);
|
|
141
|
+
return () => window.removeEventListener("storage", handler);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
} catch {
|
|
145
|
+
return noopStorage;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* A safe localStorage wrapper that falls back to noopStorage
|
|
150
|
+
* when localStorage is not available (e.g., during SSR).
|
|
151
|
+
* Includes cross-tab sync via the native 'storage' event.
|
|
152
|
+
*
|
|
153
|
+
* Lazily initialized on first access to be SSR-safe.
|
|
154
|
+
*/
|
|
155
|
+
const getSafeLocalStorage = () => {
|
|
156
|
+
if (_safeLocalStorage === null) _safeLocalStorage = createSafeLocalStorage();
|
|
157
|
+
return _safeLocalStorage;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated Use getSafeLocalStorage() instead. This is kept for backward compatibility.
|
|
161
|
+
* Returns a proxy that lazily initializes on first method call.
|
|
162
|
+
*/
|
|
163
|
+
const safeLocalStorage = {
|
|
164
|
+
getItem: (key) => getSafeLocalStorage().getItem(key),
|
|
165
|
+
setItem: (key, value) => getSafeLocalStorage().setItem(key, value),
|
|
166
|
+
removeItem: (key) => getSafeLocalStorage().removeItem(key),
|
|
167
|
+
subscribe: (key, callback) => {
|
|
168
|
+
return getSafeLocalStorage().subscribe?.(key, callback) ?? (() => {});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Parse a cookie string to extract the value for a specific key.
|
|
173
|
+
* @param cookieString - The full cookie header string (e.g., document.cookie or req.headers.cookie)
|
|
174
|
+
* @param key - The cookie key to find
|
|
175
|
+
* @returns The cookie value or null if not found
|
|
176
|
+
*/
|
|
177
|
+
const parseCookie = (cookieString, key) => {
|
|
178
|
+
if (!cookieString) return null;
|
|
179
|
+
for (const cookie of cookieString.split(";")) {
|
|
180
|
+
const [k, ...v] = cookie.split("=");
|
|
181
|
+
if (k?.trim() === key) try {
|
|
182
|
+
return decodeURIComponent(v.join("=").trim());
|
|
183
|
+
} catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Maximum recommended size for cookie storage (3KB to stay well under 4KB limit).
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* Cookie storage is subject to browser limits (typically 4KB per cookie).
|
|
194
|
+
* When users connect many wallets, the auto-reconnect list may exceed this limit.
|
|
195
|
+
* If this happens:
|
|
196
|
+
* - A console warning will be logged
|
|
197
|
+
* - Some browsers may silently reject the cookie
|
|
198
|
+
* - Consider using fewer simultaneous wallet connections
|
|
199
|
+
*
|
|
200
|
+
* The stored data includes wallet IDs in format `platform:identifier`
|
|
201
|
+
* (e.g., `polkadot:talisman`, `ethereum:io.metamask`).
|
|
202
|
+
*/
|
|
203
|
+
const COOKIE_MAX_SIZE = 3 * 1024;
|
|
204
|
+
/**
|
|
205
|
+
* BroadcastChannel name for cross-tab cookie sync.
|
|
206
|
+
*/
|
|
207
|
+
const BROADCAST_CHANNEL_NAME = "kheopskit-storage-sync";
|
|
208
|
+
/**
|
|
209
|
+
* Singleton BroadcastChannel for cross-tab cookie sync.
|
|
210
|
+
* Created once and shared across all cookieStorage instances.
|
|
211
|
+
*/
|
|
212
|
+
let sharedBroadcastChannel = null;
|
|
213
|
+
const getBroadcastChannel = () => {
|
|
214
|
+
if (sharedBroadcastChannel) return sharedBroadcastChannel;
|
|
215
|
+
if (typeof BroadcastChannel === "undefined") return null;
|
|
216
|
+
try {
|
|
217
|
+
sharedBroadcastChannel = new BroadcastChannel(BROADCAST_CHANNEL_NAME);
|
|
218
|
+
} catch {}
|
|
219
|
+
return sharedBroadcastChannel;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Check if the current connection is secure (HTTPS).
|
|
223
|
+
* Must be called at runtime (inside methods) to work correctly after SSR hydration.
|
|
224
|
+
*/
|
|
225
|
+
const isSecureConnection = () => typeof window !== "undefined" && window.location.protocol === "https:";
|
|
226
|
+
/**
|
|
227
|
+
* A cookie-based storage implementation for SSR environments.
|
|
228
|
+
* Reads cookies from an optional initial cookie string (for SSR hydration),
|
|
229
|
+
* writes to document.cookie on the client.
|
|
230
|
+
*
|
|
231
|
+
* Features:
|
|
232
|
+
* - Secure flag automatically added for HTTPS connections
|
|
233
|
+
* - Cross-tab synchronization via BroadcastChannel API
|
|
234
|
+
* - Size limit warning when data exceeds recommended limits
|
|
235
|
+
*
|
|
236
|
+
* @param initialCookies - Optional cookie string for server-side hydration
|
|
237
|
+
*/
|
|
238
|
+
const cookieStorage = (initialCookies) => {
|
|
239
|
+
return {
|
|
240
|
+
getItem: (key) => {
|
|
241
|
+
const cookieString = typeof document !== "undefined" ? document.cookie : initialCookies;
|
|
242
|
+
return parseCookie(cookieString, key);
|
|
243
|
+
},
|
|
244
|
+
setItem: (key, value) => {
|
|
245
|
+
if (typeof document === "undefined") return;
|
|
246
|
+
const encodedValue = encodeURIComponent(value);
|
|
247
|
+
if (encodedValue.length > 3072) console.warn(`[kheopskit] Cookie value for "${key}" exceeds recommended size limit (${encodedValue.length} > ${COOKIE_MAX_SIZE} bytes). This may cause issues with cookie storage. Consider reducing the number of connected wallets.`);
|
|
248
|
+
const expires = /* @__PURE__ */ new Date();
|
|
249
|
+
expires.setFullYear(expires.getFullYear() + 1);
|
|
250
|
+
let cookieStr = `${key}=${encodedValue};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
|
|
251
|
+
if (isSecureConnection()) cookieStr += ";Secure";
|
|
252
|
+
document.cookie = cookieStr;
|
|
253
|
+
getBroadcastChannel()?.postMessage({
|
|
254
|
+
type: "set",
|
|
255
|
+
key,
|
|
256
|
+
value
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
removeItem: (key) => {
|
|
260
|
+
if (typeof document === "undefined") return;
|
|
261
|
+
let cookieStr = `${key}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=Lax`;
|
|
262
|
+
if (isSecureConnection()) cookieStr += ";Secure";
|
|
263
|
+
document.cookie = cookieStr;
|
|
264
|
+
getBroadcastChannel()?.postMessage({
|
|
265
|
+
type: "remove",
|
|
266
|
+
key
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
subscribe: (key, callback) => {
|
|
270
|
+
const channel = getBroadcastChannel();
|
|
271
|
+
if (!channel) return () => {};
|
|
272
|
+
const handler = (event) => {
|
|
273
|
+
const data = event.data;
|
|
274
|
+
if (data.key === key) {
|
|
275
|
+
if (data.type === "set") callback(data.value ?? null);
|
|
276
|
+
else if (data.type === "remove") callback(null);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
channel.addEventListener("message", handler);
|
|
280
|
+
return () => {
|
|
281
|
+
channel.removeEventListener("message", handler);
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/utils/iconCache.ts
|
|
288
|
+
/**
|
|
289
|
+
* Storage key for the icon cache in localStorage.
|
|
290
|
+
*/
|
|
291
|
+
const ICON_CACHE_KEY = "kheopskit-icons";
|
|
292
|
+
/**
|
|
293
|
+
* In-memory cache to avoid repeated localStorage reads.
|
|
294
|
+
*/
|
|
295
|
+
let memoryCache = null;
|
|
296
|
+
/**
|
|
297
|
+
* Loads the icon cache from localStorage.
|
|
298
|
+
*/
|
|
299
|
+
const loadCache = () => {
|
|
300
|
+
if (memoryCache !== null) return memoryCache;
|
|
301
|
+
try {
|
|
302
|
+
const stored = safeLocalStorage.getItem(ICON_CACHE_KEY);
|
|
303
|
+
memoryCache = stored ? JSON.parse(stored) : {};
|
|
304
|
+
} catch {
|
|
305
|
+
memoryCache = {};
|
|
306
|
+
}
|
|
307
|
+
return memoryCache;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Saves the icon cache to localStorage.
|
|
311
|
+
*/
|
|
312
|
+
const saveCache = (cache) => {
|
|
313
|
+
try {
|
|
314
|
+
safeLocalStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cache));
|
|
315
|
+
memoryCache = cache;
|
|
316
|
+
} catch {}
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Gets a cached icon for a wallet.
|
|
320
|
+
* @param walletId - The wallet ID (e.g., "ethereum:io.talisman")
|
|
321
|
+
* @returns The cached icon data URI, or undefined if not cached
|
|
322
|
+
*/
|
|
323
|
+
const getCachedIcon = (walletId) => {
|
|
324
|
+
return loadCache()[walletId] || void 0;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Sets multiple cached icons at once.
|
|
328
|
+
* More efficient than calling setCachedIcon multiple times.
|
|
329
|
+
* @param icons - Map of wallet ID to icon
|
|
330
|
+
*/
|
|
331
|
+
const setCachedIcons = (icons) => {
|
|
332
|
+
const cache = loadCache();
|
|
333
|
+
let changed = false;
|
|
334
|
+
for (const [walletId, icon] of Object.entries(icons)) if (icon && cache[walletId] !== icon) {
|
|
335
|
+
cache[walletId] = icon;
|
|
336
|
+
changed = true;
|
|
337
|
+
}
|
|
338
|
+
if (changed) saveCache(cache);
|
|
339
|
+
};
|
|
340
|
+
//#endregion
|
|
341
|
+
export { safeLocalStorage as a, serializeAccount as c, getSafeLocalStorage as i, serializeWallet as l, setCachedIcons as n, hydrateAccount as o, cookieStorage as r, hydrateWallet as s, getCachedIcon as t };
|
|
342
|
+
|
|
343
|
+
//# sourceMappingURL=iconCache-BSa42Sui.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconCache-BSa42Sui.mjs","names":[],"sources":["../src/utils/hydrateState.ts","../src/utils/storage.ts","../src/utils/iconCache.ts"],"sourcesContent":["import {\n\ttype BaseWallet,\n\ttype BaseWalletAccount,\n\ttype CachedAccount,\n\ttype CachedWallet,\n\tisWalletConnectWallet,\n\ttype PolkadotAccountType,\n\ttype WalletConnectWallet,\n} from \"../api/types\";\nimport { POLKADOT_EXTENSIONS } from \"./polkadotExtensions\";\nimport type { WalletAccountId } from \"./WalletAccountId\";\nimport { parseWalletId, type WalletId } from \"./WalletId\";\n\n/**\n * Looks up the icon for a wallet from known Polkadot extensions only.\n * Ethereum icons will be populated from the localStorage icon cache via the merge function.\n *\n * Note: We DON'T use localStorage icon cache here because hydrateWallet is called\n * during SSR (server) and client hydration. localStorage isn't available on server,\n * so using it would cause a hydration mismatch. Icons for Ethereum wallets will be\n * populated when the hydration buffer merges cached wallets with live wallets.\n */\nconst lookupWalletIcon = (platform: string, identifier: string): string => {\n\t// Only Polkadot extensions have hardcoded icons that are safe for SSR\n\tif (platform === \"polkadot\") {\n\t\treturn POLKADOT_EXTENSIONS[identifier]?.icon ?? \"\";\n\t}\n\t// Ethereum icons come from localStorage or live wallets - not here\n\treturn \"\";\n};\n\n/**\n * Error thrown when trying to use a placeholder wallet that hasn't fully loaded yet.\n */\nclass PendingWalletError extends Error {\n\tconstructor(walletId: string) {\n\t\tsuper(\n\t\t\t`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`,\n\t\t);\n\t\tthis.name = \"PendingWalletError\";\n\t}\n}\n\n/**\n * Converts a CachedWallet to a placeholder wallet for SSR hydration display.\n *\n * The placeholder carries only the SDK-free {@link BaseWallet} fields; the real\n * wallet (with its injected provider/extension/standard-wallet handle) replaces\n * it once it loads. connect/disconnect throw until then.\n */\nexport const hydrateWallet = (\n\tcached: CachedWallet,\n): BaseWallet | WalletConnectWallet => {\n\tconst throwPending = () => {\n\t\tthrow new PendingWalletError(cached.id);\n\t};\n\n\t// The platform-less WalletConnect connector. `appKit`/`platforms` are SDK\n\t// state absent until the live connector loads (cast like other placeholder\n\t// SDK handles); icon is filled from the localStorage cache by the caller.\n\tif (cached.type === \"walletconnect\") {\n\t\treturn {\n\t\t\tid: cached.id,\n\t\t\ttype: \"walletconnect\",\n\t\t\tplatforms: [],\n\t\t\tname: cached.name,\n\t\t\ticon: \"\",\n\t\t\tisConnected: cached.isConnected,\n\t\t\tconnect: throwPending,\n\t\t\tdisconnect: throwPending,\n\t\t} as unknown as WalletConnectWallet;\n\t}\n\n\tconst { platform, identifier } = parseWalletId(cached.id);\n\n\treturn {\n\t\tid: cached.id,\n\t\tplatform: cached.platform as BaseWallet[\"platform\"],\n\t\ttype: cached.type,\n\t\tname: cached.name,\n\t\ticon: lookupWalletIcon(platform, identifier),\n\t\tisConnected: cached.isConnected,\n\t\tconnect: throwPending,\n\t\tdisconnect: throwPending,\n\t};\n};\n\n/**\n * Converts a CachedAccount to a placeholder account for SSR hydration display.\n *\n * The placeholder carries the SDK-free {@link BaseWalletAccount} fields plus the\n * plain, serializable platform data that lives in the cache — Ethereum `chainId`\n * and the Polkadot key `type`. Those render immediately on reload (no blank →\n * value flicker) and match what the live account will report. Only the SDK\n * handles (`client`/`signer`/`polkadotSigner`) are absent until the real account\n * replaces this placeholder; signing stays gated on `isHydrating` until then.\n */\nexport const hydrateAccount = (cached: CachedAccount): BaseWalletAccount => ({\n\tid: cached.id as WalletAccountId,\n\tplatform: cached.platform,\n\taddress: cached.address,\n\tname: cached.name,\n\twalletId: cached.walletId,\n\twalletName: cached.walletName,\n\t// Spread (not direct keys) so the extra platform fields don't trip the\n\t// excess-property check against BaseWalletAccount; they're read back via the\n\t// platform-specific account types once narrowed by `platform`.\n\t...(cached.platform === \"ethereum\" && { chainId: cached.chainId }),\n\t...(cached.platform === \"polkadot\" && {\n\t\ttype: cached.polkadotAccountType,\n\t}),\n});\n\n/**\n * Converts a wallet to a CachedWallet for storage.\n * Only extracts the serializable properties needed for hydration.\n */\nexport const serializeWallet = (\n\twallet: BaseWallet | WalletConnectWallet,\n): CachedWallet => ({\n\tid: wallet.id,\n\t// The WalletConnect connector has no platform.\n\tplatform: isWalletConnectWallet(wallet) ? undefined : wallet.platform,\n\ttype: wallet.type,\n\tname: wallet.name,\n\t// Note: icon is NOT stored to save cookie space\n\tisConnected: wallet.isConnected,\n});\n\n/**\n * Converts an account to a CachedAccount for storage.\n * Only extracts the serializable properties needed for hydration. Platform-only\n * fields (Ethereum chainId, Polkadot key type) are read defensively so this\n * stays SDK-free.\n */\nexport const serializeAccount = (\n\taccount: BaseWalletAccount,\n): CachedAccount => ({\n\tid: account.id,\n\tplatform: account.platform,\n\taddress: account.address,\n\tname: account.name,\n\tchainId:\n\t\taccount.platform === \"ethereum\"\n\t\t\t? (account as { chainId?: number }).chainId\n\t\t\t: undefined,\n\tpolkadotAccountType:\n\t\taccount.platform === \"polkadot\"\n\t\t\t? (account as { type?: PolkadotAccountType }).type\n\t\t\t: undefined,\n\twalletId: account.walletId as WalletId,\n\twalletName: account.walletName,\n});\n","export type Storage = {\n\tgetItem: (key: string) => string | null;\n\tsetItem: (key: string, value: string) => void;\n\tremoveItem: (key: string) => void;\n};\n\n/**\n * Extended storage interface with cross-tab sync support.\n */\nexport type SyncableStorage = Storage & {\n\t/**\n\t * Subscribe to storage changes from other tabs.\n\t * Returns an unsubscribe function.\n\t */\n\tsubscribe?: (\n\t\tkey: string,\n\t\tcallback: (value: string | null) => void,\n\t) => () => void;\n};\n\n/**\n * A no-op storage implementation that does nothing.\n * Useful for testing or SSR environments where no storage is needed.\n */\nexport const noopStorage: SyncableStorage = {\n\tgetItem: () => null,\n\tsetItem: () => {},\n\tremoveItem: () => {},\n};\n\n/**\n * Cached localStorage wrapper instance.\n * Lazily initialized on first access to avoid SSR issues.\n */\nlet _safeLocalStorage: SyncableStorage | null = null;\n\n/**\n * Creates the localStorage wrapper, testing for availability.\n * Returns noopStorage if localStorage is unavailable (SSR, private browsing, etc.)\n */\nconst createSafeLocalStorage = (): SyncableStorage => {\n\tif (typeof window === \"undefined\") return noopStorage;\n\n\ttry {\n\t\t// Test that localStorage is accessible (may throw in private browsing)\n\t\tconst testKey = \"__kheopskit_test__\";\n\t\twindow.localStorage.setItem(testKey, testKey);\n\t\twindow.localStorage.removeItem(testKey);\n\n\t\treturn {\n\t\t\tgetItem: (key: string) => window.localStorage.getItem(key),\n\t\t\tsetItem: (key: string, value: string) =>\n\t\t\t\twindow.localStorage.setItem(key, value),\n\t\t\tremoveItem: (key: string) => window.localStorage.removeItem(key),\n\t\t\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\t\t\tconst handler = (event: StorageEvent) => {\n\t\t\t\t\tif (event.key === key) {\n\t\t\t\t\t\tcallback(event.newValue);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.addEventListener(\"storage\", handler);\n\t\t\t\treturn () => window.removeEventListener(\"storage\", handler);\n\t\t\t},\n\t\t};\n\t} catch {\n\t\treturn noopStorage;\n\t}\n};\n\n/**\n * A safe localStorage wrapper that falls back to noopStorage\n * when localStorage is not available (e.g., during SSR).\n * Includes cross-tab sync via the native 'storage' event.\n *\n * Lazily initialized on first access to be SSR-safe.\n */\nexport const getSafeLocalStorage = (): SyncableStorage => {\n\tif (_safeLocalStorage === null) {\n\t\t_safeLocalStorage = createSafeLocalStorage();\n\t}\n\treturn _safeLocalStorage;\n};\n\n/**\n * @deprecated Use getSafeLocalStorage() instead. This is kept for backward compatibility.\n * Returns a proxy that lazily initializes on first method call.\n */\nexport const safeLocalStorage: SyncableStorage = {\n\tgetItem: (key: string) => getSafeLocalStorage().getItem(key),\n\tsetItem: (key: string, value: string) =>\n\t\tgetSafeLocalStorage().setItem(key, value),\n\tremoveItem: (key: string) => getSafeLocalStorage().removeItem(key),\n\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\tconst storage = getSafeLocalStorage();\n\t\treturn storage.subscribe?.(key, callback) ?? (() => {});\n\t},\n};\n\n/**\n * Parse a cookie string to extract the value for a specific key.\n * @param cookieString - The full cookie header string (e.g., document.cookie or req.headers.cookie)\n * @param key - The cookie key to find\n * @returns The cookie value or null if not found\n */\nexport const parseCookie = (\n\tcookieString: string | undefined,\n\tkey: string,\n): string | null => {\n\tif (!cookieString) return null;\n\n\tfor (const cookie of cookieString.split(\";\")) {\n\t\tconst [k, ...v] = cookie.split(\"=\");\n\t\tconst cookieKey = k?.trim();\n\t\tif (cookieKey === key) {\n\t\t\ttry {\n\t\t\t\treturn decodeURIComponent(v.join(\"=\").trim());\n\t\t\t} catch {\n\t\t\t\treturn null; // Malformed cookie value\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n};\n\n/**\n * Maximum recommended size for cookie storage (3KB to stay well under 4KB limit).\n *\n * @remarks\n * Cookie storage is subject to browser limits (typically 4KB per cookie).\n * When users connect many wallets, the auto-reconnect list may exceed this limit.\n * If this happens:\n * - A console warning will be logged\n * - Some browsers may silently reject the cookie\n * - Consider using fewer simultaneous wallet connections\n *\n * The stored data includes wallet IDs in format `platform:identifier`\n * (e.g., `polkadot:talisman`, `ethereum:io.metamask`).\n */\nexport const COOKIE_MAX_SIZE = 3 * 1024;\n\n/**\n * BroadcastChannel name for cross-tab cookie sync.\n */\nconst BROADCAST_CHANNEL_NAME = \"kheopskit-storage-sync\";\n\n/**\n * Singleton BroadcastChannel for cross-tab cookie sync.\n * Created once and shared across all cookieStorage instances.\n */\nlet sharedBroadcastChannel: BroadcastChannel | null = null;\n\nconst getBroadcastChannel = (): BroadcastChannel | null => {\n\tif (sharedBroadcastChannel) return sharedBroadcastChannel;\n\tif (typeof BroadcastChannel === \"undefined\") return null;\n\n\ttry {\n\t\tsharedBroadcastChannel = new BroadcastChannel(BROADCAST_CHANNEL_NAME);\n\t} catch {\n\t\t// BroadcastChannel not supported or failed\n\t}\n\treturn sharedBroadcastChannel;\n};\n\n/**\n * Check if the current connection is secure (HTTPS).\n * Must be called at runtime (inside methods) to work correctly after SSR hydration.\n */\nconst isSecureConnection = (): boolean =>\n\ttypeof window !== \"undefined\" && window.location.protocol === \"https:\";\n\n/**\n * A cookie-based storage implementation for SSR environments.\n * Reads cookies from an optional initial cookie string (for SSR hydration),\n * writes to document.cookie on the client.\n *\n * Features:\n * - Secure flag automatically added for HTTPS connections\n * - Cross-tab synchronization via BroadcastChannel API\n * - Size limit warning when data exceeds recommended limits\n *\n * @param initialCookies - Optional cookie string for server-side hydration\n */\nexport const cookieStorage = (initialCookies?: string): SyncableStorage => {\n\treturn {\n\t\tgetItem: (key: string) => {\n\t\t\t// On server, use initialCookies. On client, read from document.cookie\n\t\t\tconst cookieString =\n\t\t\t\ttypeof document !== \"undefined\" ? document.cookie : initialCookies;\n\t\t\treturn parseCookie(cookieString, key);\n\t\t},\n\t\tsetItem: (key: string, value: string) => {\n\t\t\tif (typeof document === \"undefined\") return;\n\n\t\t\t// Warn if value exceeds recommended size\n\t\t\tconst encodedValue = encodeURIComponent(value);\n\t\t\tif (encodedValue.length > COOKIE_MAX_SIZE) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[kheopskit] Cookie value for \"${key}\" exceeds recommended size limit (${encodedValue.length} > ${COOKIE_MAX_SIZE} bytes). ` +\n\t\t\t\t\t\t\"This may cause issues with cookie storage. Consider reducing the number of connected wallets.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set cookie with 1 year expiry\n\t\t\tconst expires = new Date();\n\t\t\texpires.setFullYear(expires.getFullYear() + 1);\n\n\t\t\t// Build cookie string with security attributes\n\t\t\tlet cookieStr = `${key}=${encodedValue};expires=${expires.toUTCString()};path=/;SameSite=Lax`;\n\t\t\tif (isSecureConnection()) {\n\t\t\t\tcookieStr += \";Secure\";\n\t\t\t}\n\n\t\t\t// biome-ignore lint: necessary for cookie storage - direct cookie assignment is the standard API\n\t\t\tdocument.cookie = cookieStr;\n\n\t\t\t// Broadcast change to other tabs\n\t\t\tgetBroadcastChannel()?.postMessage({ type: \"set\", key, value });\n\t\t},\n\t\tremoveItem: (key: string) => {\n\t\t\tif (typeof document === \"undefined\") return;\n\n\t\t\t// Build delete cookie string\n\t\t\tlet cookieStr = `${key}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=Lax`;\n\t\t\tif (isSecureConnection()) {\n\t\t\t\tcookieStr += \";Secure\";\n\t\t\t}\n\n\t\t\t// biome-ignore lint: necessary for cookie storage - direct cookie assignment is the standard API\n\t\t\tdocument.cookie = cookieStr;\n\n\t\t\t// Broadcast change to other tabs\n\t\t\tgetBroadcastChannel()?.postMessage({ type: \"remove\", key });\n\t\t},\n\t\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\t\tconst channel = getBroadcastChannel();\n\t\t\tif (!channel) return () => {};\n\n\t\t\tconst handler = (event: MessageEvent) => {\n\t\t\t\tconst data = event.data as {\n\t\t\t\t\ttype: string;\n\t\t\t\t\tkey: string;\n\t\t\t\t\tvalue?: string;\n\t\t\t\t};\n\t\t\t\tif (data.key === key) {\n\t\t\t\t\tif (data.type === \"set\") {\n\t\t\t\t\t\tcallback(data.value ?? null);\n\t\t\t\t\t} else if (data.type === \"remove\") {\n\t\t\t\t\t\tcallback(null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tchannel.addEventListener(\"message\", handler);\n\t\t\treturn () => {\n\t\t\t\tchannel.removeEventListener(\"message\", handler);\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Cleanup the shared BroadcastChannel used for cross-tab cookie sync.\n * Call this when you're done using cookie storage (e.g., in tests or when unmounting).\n *\n * @remarks\n * In normal browser usage, you typically don't need to call this -\n * the channel will be cleaned up when the page is closed.\n * This is primarily useful for testing environments where multiple\n * test runs may accumulate channels.\n */\nexport const cleanupBroadcastChannel = (): void => {\n\tif (sharedBroadcastChannel) {\n\t\tsharedBroadcastChannel.close();\n\t\tsharedBroadcastChannel = null;\n\t}\n};\n","import { safeLocalStorage } from \"./storage\";\n\n/**\n * Storage key for the icon cache in localStorage.\n */\nconst ICON_CACHE_KEY = \"kheopskit-icons\";\n\n/**\n * Icon cache type: a map of wallet ID to icon data URI or URL.\n */\ntype IconCache = Record<string, string>;\n\n/**\n * In-memory cache to avoid repeated localStorage reads.\n */\nlet memoryCache: IconCache | null = null;\n\n/**\n * Loads the icon cache from localStorage.\n */\nconst loadCache = (): IconCache => {\n\tif (memoryCache !== null) return memoryCache;\n\n\ttry {\n\t\tconst stored = safeLocalStorage.getItem(ICON_CACHE_KEY);\n\t\tmemoryCache = stored ? (JSON.parse(stored) as IconCache) : {};\n\t} catch {\n\t\tmemoryCache = {};\n\t}\n\treturn memoryCache;\n};\n\n/**\n * Saves the icon cache to localStorage.\n */\nconst saveCache = (cache: IconCache): void => {\n\ttry {\n\t\tsafeLocalStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cache));\n\t\tmemoryCache = cache;\n\t} catch {\n\t\t// localStorage may be full or unavailable\n\t}\n};\n\n/**\n * Gets a cached icon for a wallet.\n * @param walletId - The wallet ID (e.g., \"ethereum:io.talisman\")\n * @returns The cached icon data URI, or undefined if not cached\n */\nexport const getCachedIcon = (walletId: string): string | undefined => {\n\tconst cache = loadCache();\n\treturn cache[walletId] || undefined;\n};\n\n/**\n * Sets multiple cached icons at once.\n * More efficient than calling setCachedIcon multiple times.\n * @param icons - Map of wallet ID to icon\n */\nexport const setCachedIcons = (icons: Record<string, string>): void => {\n\tconst cache = loadCache();\n\tlet changed = false;\n\n\tfor (const [walletId, icon] of Object.entries(icons)) {\n\t\tif (icon && cache[walletId] !== icon) {\n\t\t\tcache[walletId] = icon;\n\t\t\tchanged = true;\n\t\t}\n\t}\n\n\tif (changed) {\n\t\tsaveCache(cache);\n\t}\n};\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,oBAAoB,UAAkB,eAA+B;CAE1E,IAAI,a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