@shadow-corp/nearconnect 1.0.0
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 +546 -0
- package/build/InjectedWallet.d.ts +22 -0
- package/build/InjectedWallet.js +58 -0
- package/build/InjectedWallet.js.map +1 -0
- package/build/NearConnector.d.ts +151 -0
- package/build/NearConnector.js +536 -0
- package/build/NearConnector.js.map +1 -0
- package/build/ParentFrameWallet.d.ts +22 -0
- package/build/ParentFrameWallet.js +66 -0
- package/build/ParentFrameWallet.js.map +1 -0
- package/build/SandboxedWallet/code.d.ts +7 -0
- package/build/SandboxedWallet/code.js +324 -0
- package/build/SandboxedWallet/code.js.map +1 -0
- package/build/SandboxedWallet/executor.d.ts +23 -0
- package/build/SandboxedWallet/executor.js +338 -0
- package/build/SandboxedWallet/executor.js.map +1 -0
- package/build/SandboxedWallet/iframe.d.ts +18 -0
- package/build/SandboxedWallet/iframe.js +78 -0
- package/build/SandboxedWallet/iframe.js.map +1 -0
- package/build/SandboxedWallet/index.d.ts +24 -0
- package/build/SandboxedWallet/index.js +54 -0
- package/build/SandboxedWallet/index.js.map +1 -0
- package/build/actions/index.d.ts +3 -0
- package/build/actions/index.js +105 -0
- package/build/actions/index.js.map +1 -0
- package/build/actions/types.d.ts +76 -0
- package/build/actions/types.js +3 -0
- package/build/actions/types.js.map +1 -0
- package/build/connection/health.d.ts +213 -0
- package/build/connection/health.js +391 -0
- package/build/connection/health.js.map +1 -0
- package/build/connection/index.d.ts +4 -0
- package/build/connection/index.js +48 -0
- package/build/connection/index.js.map +1 -0
- package/build/connection/reconnect.d.ts +261 -0
- package/build/connection/reconnect.js +454 -0
- package/build/connection/reconnect.js.map +1 -0
- package/build/connection/retry.d.ts +187 -0
- package/build/connection/retry.js +427 -0
- package/build/connection/retry.js.map +1 -0
- package/build/connection/state.d.ts +222 -0
- package/build/connection/state.js +431 -0
- package/build/connection/state.js.map +1 -0
- package/build/errors.d.ts +177 -0
- package/build/errors.js +546 -0
- package/build/errors.js.map +1 -0
- package/build/hardware/errors.d.ts +36 -0
- package/build/hardware/errors.js +127 -0
- package/build/hardware/errors.js.map +1 -0
- package/build/hardware/index.d.ts +7 -0
- package/build/hardware/index.js +39 -0
- package/build/hardware/index.js.map +1 -0
- package/build/hardware/near-app.d.ts +95 -0
- package/build/hardware/near-app.js +291 -0
- package/build/hardware/near-app.js.map +1 -0
- package/build/hardware/transport.d.ts +94 -0
- package/build/hardware/transport.js +267 -0
- package/build/hardware/transport.js.map +1 -0
- package/build/hardware/types.d.ts +98 -0
- package/build/hardware/types.js +72 -0
- package/build/hardware/types.js.map +1 -0
- package/build/helpers/analytics.d.ts +191 -0
- package/build/helpers/analytics.js +304 -0
- package/build/helpers/analytics.js.map +1 -0
- package/build/helpers/base58.d.ts +6 -0
- package/build/helpers/base58.js +47 -0
- package/build/helpers/base58.js.map +1 -0
- package/build/helpers/events.d.ts +42 -0
- package/build/helpers/events.js +68 -0
- package/build/helpers/events.js.map +1 -0
- package/build/helpers/html.d.ts +8 -0
- package/build/helpers/html.js +30 -0
- package/build/helpers/html.js.map +1 -0
- package/build/helpers/indexdb.d.ts +14 -0
- package/build/helpers/indexdb.js +166 -0
- package/build/helpers/indexdb.js.map +1 -0
- package/build/helpers/manifest.d.ts +147 -0
- package/build/helpers/manifest.js +329 -0
- package/build/helpers/manifest.js.map +1 -0
- package/build/helpers/queue.d.ts +11 -0
- package/build/helpers/queue.js +48 -0
- package/build/helpers/queue.js.map +1 -0
- package/build/helpers/session.d.ts +119 -0
- package/build/helpers/session.js +289 -0
- package/build/helpers/session.js.map +1 -0
- package/build/helpers/simulation.d.ts +128 -0
- package/build/helpers/simulation.js +441 -0
- package/build/helpers/simulation.js.map +1 -0
- package/build/helpers/storage.d.ts +58 -0
- package/build/helpers/storage.js +190 -0
- package/build/helpers/storage.js.map +1 -0
- package/build/helpers/trust.d.ts +157 -0
- package/build/helpers/trust.js +340 -0
- package/build/helpers/trust.js.map +1 -0
- package/build/helpers/url.d.ts +1 -0
- package/build/helpers/url.js +13 -0
- package/build/helpers/url.js.map +1 -0
- package/build/helpers/uuid.d.ts +1 -0
- package/build/helpers/uuid.js +14 -0
- package/build/helpers/uuid.js.map +1 -0
- package/build/index.d.ts +21 -0
- package/build/index.js +167 -0
- package/build/index.js.map +1 -0
- package/build/popups/IframeWalletPopup.d.ts +16 -0
- package/build/popups/IframeWalletPopup.js +38 -0
- package/build/popups/IframeWalletPopup.js.map +1 -0
- package/build/popups/NearWalletsPopup.d.ts +25 -0
- package/build/popups/NearWalletsPopup.js +153 -0
- package/build/popups/NearWalletsPopup.js.map +1 -0
- package/build/popups/Popup.d.ts +22 -0
- package/build/popups/Popup.js +94 -0
- package/build/popups/Popup.js.map +1 -0
- package/build/popups/styles.d.ts +1 -0
- package/build/popups/styles.js +257 -0
- package/build/popups/styles.js.map +1 -0
- package/build/security/audit-log.d.ts +123 -0
- package/build/security/audit-log.js +268 -0
- package/build/security/audit-log.js.map +1 -0
- package/build/security/csp.d.ts +68 -0
- package/build/security/csp.js +328 -0
- package/build/security/csp.js.map +1 -0
- package/build/security/index.d.ts +10 -0
- package/build/security/index.js +42 -0
- package/build/security/index.js.map +1 -0
- package/build/security/origin-guard.d.ts +90 -0
- package/build/security/origin-guard.js +244 -0
- package/build/security/origin-guard.js.map +1 -0
- package/build/security/rate-limiter.d.ts +84 -0
- package/build/security/rate-limiter.js +212 -0
- package/build/security/rate-limiter.js.map +1 -0
- package/build/security/secure-storage.d.ts +77 -0
- package/build/security/secure-storage.js +242 -0
- package/build/security/secure-storage.js.map +1 -0
- package/build/security/transaction-guard.d.ts +71 -0
- package/build/security/transaction-guard.js +239 -0
- package/build/security/transaction-guard.js.map +1 -0
- package/build/types.d.ts +508 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/build/ui/AccountSwitcherModal.d.ts +53 -0
- package/build/ui/AccountSwitcherModal.js +239 -0
- package/build/ui/AccountSwitcherModal.js.map +1 -0
- package/build/ui/Modal.d.ts +84 -0
- package/build/ui/Modal.js +278 -0
- package/build/ui/Modal.js.map +1 -0
- package/build/ui/TransactionModal.d.ts +84 -0
- package/build/ui/TransactionModal.js +406 -0
- package/build/ui/TransactionModal.js.map +1 -0
- package/build/ui/WalletSelectorModal.d.ts +97 -0
- package/build/ui/WalletSelectorModal.js +481 -0
- package/build/ui/WalletSelectorModal.js.map +1 -0
- package/build/ui/icons.d.ts +19 -0
- package/build/ui/icons.js +65 -0
- package/build/ui/icons.js.map +1 -0
- package/build/ui/index.d.ts +10 -0
- package/build/ui/index.js +31 -0
- package/build/ui/index.js.map +1 -0
- package/build/ui/styles.d.ts +5 -0
- package/build/ui/styles.js +973 -0
- package/build/ui/styles.js.map +1 -0
- package/build/ui/theme.d.ts +133 -0
- package/build/ui/theme.js +204 -0
- package/build/ui/theme.js.map +1 -0
- package/build/wallets/external/index.d.ts +4 -0
- package/build/wallets/external/index.js +9 -0
- package/build/wallets/external/index.js.map +1 -0
- package/build/wallets/external/manager.d.ts +152 -0
- package/build/wallets/external/manager.js +586 -0
- package/build/wallets/external/manager.js.map +1 -0
- package/build/wallets/privileged/index.d.ts +5 -0
- package/build/wallets/privileged/index.js +12 -0
- package/build/wallets/privileged/index.js.map +1 -0
- package/build/wallets/privileged/ledger.d.ts +132 -0
- package/build/wallets/privileged/ledger.js +563 -0
- package/build/wallets/privileged/ledger.js.map +1 -0
- package/build/wallets/privileged/manager.d.ts +54 -0
- package/build/wallets/privileged/manager.js +174 -0
- package/build/wallets/privileged/manager.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FederatedManifestManager = exports.DEFAULT_MANIFEST_SOURCES = void 0;
|
|
4
|
+
exports.validateManifest = validateManifest;
|
|
5
|
+
exports.mergeManifests = mergeManifests;
|
|
6
|
+
/**
|
|
7
|
+
* Default manifest sources
|
|
8
|
+
*/
|
|
9
|
+
exports.DEFAULT_MANIFEST_SOURCES = [
|
|
10
|
+
{
|
|
11
|
+
id: "hot-dao-official",
|
|
12
|
+
name: "HOT DAO Official",
|
|
13
|
+
url: "https://raw.githubusercontent.com/hot-dao/near-selector/refs/heads/main/repository/manifest.json",
|
|
14
|
+
priority: 1,
|
|
15
|
+
trusted: true,
|
|
16
|
+
enabled: true,
|
|
17
|
+
networks: ["mainnet", "testnet"],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "hot-connector-cdn",
|
|
21
|
+
name: "HOT Connector CDN",
|
|
22
|
+
url: "https://cdn.jsdelivr.net/gh/azbang/hot-connector/repository/manifest.json",
|
|
23
|
+
priority: 2,
|
|
24
|
+
trusted: true,
|
|
25
|
+
enabled: true,
|
|
26
|
+
networks: ["mainnet", "testnet"],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Federated Manifest Manager
|
|
31
|
+
*
|
|
32
|
+
* Aggregates wallet manifests from multiple sources with:
|
|
33
|
+
* - Priority-based merging (higher priority sources override lower)
|
|
34
|
+
* - Caching with TTL
|
|
35
|
+
* - Automatic retries
|
|
36
|
+
* - Health tracking per source
|
|
37
|
+
*/
|
|
38
|
+
class FederatedManifestManager {
|
|
39
|
+
sources;
|
|
40
|
+
cache = new Map();
|
|
41
|
+
cacheDuration;
|
|
42
|
+
timeout;
|
|
43
|
+
maxRetries;
|
|
44
|
+
retryDelay;
|
|
45
|
+
network;
|
|
46
|
+
onUpdate;
|
|
47
|
+
onError;
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
const defaultSources = options.useDefaults !== false ? exports.DEFAULT_MANIFEST_SOURCES : [];
|
|
50
|
+
this.sources = [...defaultSources, ...(options.sources ?? [])];
|
|
51
|
+
this.cacheDuration = options.cacheDuration ?? 5 * 60 * 1000; // 5 minutes
|
|
52
|
+
this.timeout = options.timeout ?? 10000; // 10 seconds
|
|
53
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
54
|
+
this.retryDelay = options.retryDelay ?? 1000;
|
|
55
|
+
this.network = options.network ?? "mainnet";
|
|
56
|
+
this.onUpdate = options.onUpdate;
|
|
57
|
+
this.onError = options.onError;
|
|
58
|
+
// Sort by priority
|
|
59
|
+
this.sources.sort((a, b) => a.priority - b.priority);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add a new manifest source
|
|
63
|
+
*/
|
|
64
|
+
addSource(source) {
|
|
65
|
+
// Remove existing source with same ID
|
|
66
|
+
this.sources = this.sources.filter((s) => s.id !== source.id);
|
|
67
|
+
this.sources.push(source);
|
|
68
|
+
this.sources.sort((a, b) => a.priority - b.priority);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Remove a manifest source
|
|
72
|
+
*/
|
|
73
|
+
removeSource(sourceId) {
|
|
74
|
+
this.sources = this.sources.filter((s) => s.id !== sourceId);
|
|
75
|
+
this.cache.delete(sourceId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Enable/disable a source
|
|
79
|
+
*/
|
|
80
|
+
setSourceEnabled(sourceId, enabled) {
|
|
81
|
+
const source = this.sources.find((s) => s.id === sourceId);
|
|
82
|
+
if (source) {
|
|
83
|
+
source.enabled = enabled;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get all sources
|
|
88
|
+
*/
|
|
89
|
+
getSources() {
|
|
90
|
+
return [...this.sources];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Fetch manifest from a single source
|
|
94
|
+
*/
|
|
95
|
+
async fetchFromSource(source) {
|
|
96
|
+
// Check cache first
|
|
97
|
+
const cached = this.cache.get(source.id);
|
|
98
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
99
|
+
return cached.manifest;
|
|
100
|
+
}
|
|
101
|
+
// Fetch with retries
|
|
102
|
+
let lastError = null;
|
|
103
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
104
|
+
try {
|
|
105
|
+
const controller = new AbortController();
|
|
106
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
107
|
+
const response = await fetch(source.url, {
|
|
108
|
+
signal: controller.signal,
|
|
109
|
+
headers: {
|
|
110
|
+
Accept: "application/json",
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
clearTimeout(timeoutId);
|
|
114
|
+
if (!response.ok) {
|
|
115
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
116
|
+
}
|
|
117
|
+
const data = await response.json();
|
|
118
|
+
// Validate manifest structure
|
|
119
|
+
if (!data.wallets || !Array.isArray(data.wallets)) {
|
|
120
|
+
throw new Error("Invalid manifest: missing wallets array");
|
|
121
|
+
}
|
|
122
|
+
const manifest = {
|
|
123
|
+
source,
|
|
124
|
+
wallets: data.wallets,
|
|
125
|
+
version: data.version ?? "1.0.0",
|
|
126
|
+
fetchedAt: Date.now(),
|
|
127
|
+
};
|
|
128
|
+
// Update source metadata
|
|
129
|
+
source.lastFetched = Date.now();
|
|
130
|
+
// Cache the result
|
|
131
|
+
this.cache.set(source.id, {
|
|
132
|
+
manifest,
|
|
133
|
+
expiresAt: Date.now() + this.cacheDuration,
|
|
134
|
+
});
|
|
135
|
+
return manifest;
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
lastError = e instanceof Error ? e : new Error(String(e));
|
|
139
|
+
if (attempt < this.maxRetries) {
|
|
140
|
+
await new Promise((resolve) => setTimeout(resolve, this.retryDelay));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// All retries failed
|
|
145
|
+
if (lastError) {
|
|
146
|
+
this.onError?.(source, lastError);
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Fetch and combine manifests from all enabled sources
|
|
152
|
+
*/
|
|
153
|
+
async fetchAll() {
|
|
154
|
+
const enabledSources = this.sources.filter((s) => s.enabled);
|
|
155
|
+
// Fetch from all sources in parallel
|
|
156
|
+
const results = await Promise.all(enabledSources.map((source) => this.fetchFromSource(source)));
|
|
157
|
+
// Combine wallets (higher priority sources win on conflicts)
|
|
158
|
+
const walletMap = new Map();
|
|
159
|
+
const successfulSources = [];
|
|
160
|
+
let latestVersion = "1.0.0";
|
|
161
|
+
// Process in reverse priority order so higher priority overwrites
|
|
162
|
+
for (let i = results.length - 1; i >= 0; i--) {
|
|
163
|
+
const result = results[i];
|
|
164
|
+
if (!result)
|
|
165
|
+
continue;
|
|
166
|
+
successfulSources.push(result.source);
|
|
167
|
+
if (result.version > latestVersion) {
|
|
168
|
+
latestVersion = result.version;
|
|
169
|
+
}
|
|
170
|
+
for (const wallet of result.wallets) {
|
|
171
|
+
// Filter by network if applicable
|
|
172
|
+
if (this.network === "testnet" && !wallet.features?.testnet) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
// Add source metadata to wallet
|
|
176
|
+
const enrichedWallet = {
|
|
177
|
+
...wallet,
|
|
178
|
+
_source: result.source.id,
|
|
179
|
+
_trusted: result.source.trusted,
|
|
180
|
+
};
|
|
181
|
+
walletMap.set(wallet.id, enrichedWallet);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const combined = {
|
|
185
|
+
wallets: Array.from(walletMap.values()),
|
|
186
|
+
version: latestVersion,
|
|
187
|
+
sources: successfulSources,
|
|
188
|
+
lastUpdated: Date.now(),
|
|
189
|
+
};
|
|
190
|
+
this.onUpdate?.(combined);
|
|
191
|
+
return combined;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Clear the cache
|
|
195
|
+
*/
|
|
196
|
+
clearCache() {
|
|
197
|
+
this.cache.clear();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Clear cache for a specific source
|
|
201
|
+
*/
|
|
202
|
+
clearSourceCache(sourceId) {
|
|
203
|
+
this.cache.delete(sourceId);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Set the network filter
|
|
207
|
+
*/
|
|
208
|
+
setNetwork(network) {
|
|
209
|
+
this.network = network;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get cache status for all sources
|
|
213
|
+
*/
|
|
214
|
+
getCacheStatus() {
|
|
215
|
+
const status = {};
|
|
216
|
+
for (const source of this.sources) {
|
|
217
|
+
const cached = this.cache.get(source.id);
|
|
218
|
+
status[source.id] = {
|
|
219
|
+
cached: !!cached && cached.expiresAt > Date.now(),
|
|
220
|
+
expiresAt: cached?.expiresAt,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return status;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Register a custom wallet manifest (for debug/development)
|
|
227
|
+
*/
|
|
228
|
+
registerCustomWallet(wallet) {
|
|
229
|
+
// Create a virtual "custom" source if not exists
|
|
230
|
+
let customSource = this.sources.find((s) => s.id === "custom");
|
|
231
|
+
if (!customSource) {
|
|
232
|
+
customSource = {
|
|
233
|
+
id: "custom",
|
|
234
|
+
name: "Custom Wallets",
|
|
235
|
+
url: "",
|
|
236
|
+
priority: 0, // Highest priority
|
|
237
|
+
trusted: false,
|
|
238
|
+
enabled: true,
|
|
239
|
+
};
|
|
240
|
+
this.sources.unshift(customSource);
|
|
241
|
+
}
|
|
242
|
+
// Add to cache
|
|
243
|
+
const cached = this.cache.get("custom");
|
|
244
|
+
const existingWallets = cached?.manifest.wallets ?? [];
|
|
245
|
+
// Remove existing wallet with same ID
|
|
246
|
+
const wallets = existingWallets.filter((w) => w.id !== wallet.id);
|
|
247
|
+
wallets.push({ ...wallet, debug: true });
|
|
248
|
+
this.cache.set("custom", {
|
|
249
|
+
manifest: {
|
|
250
|
+
source: customSource,
|
|
251
|
+
wallets,
|
|
252
|
+
version: "custom",
|
|
253
|
+
fetchedAt: Date.now(),
|
|
254
|
+
},
|
|
255
|
+
expiresAt: Date.now() + 365 * 24 * 60 * 60 * 1000, // 1 year
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Remove a custom wallet
|
|
260
|
+
*/
|
|
261
|
+
removeCustomWallet(walletId) {
|
|
262
|
+
const cached = this.cache.get("custom");
|
|
263
|
+
if (!cached)
|
|
264
|
+
return;
|
|
265
|
+
cached.manifest.wallets = cached.manifest.wallets.filter((w) => w.id !== walletId);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.FederatedManifestManager = FederatedManifestManager;
|
|
269
|
+
/**
|
|
270
|
+
* Validate a wallet manifest
|
|
271
|
+
*/
|
|
272
|
+
function validateManifest(manifest) {
|
|
273
|
+
if (!manifest || typeof manifest !== "object")
|
|
274
|
+
return false;
|
|
275
|
+
const m = manifest;
|
|
276
|
+
// Required fields
|
|
277
|
+
if (typeof m.id !== "string" || !m.id)
|
|
278
|
+
return false;
|
|
279
|
+
if (typeof m.name !== "string" || !m.name)
|
|
280
|
+
return false;
|
|
281
|
+
if (typeof m.icon !== "string" || !m.icon)
|
|
282
|
+
return false;
|
|
283
|
+
if (typeof m.website !== "string" || !m.website)
|
|
284
|
+
return false;
|
|
285
|
+
if (typeof m.version !== "string" || !m.version)
|
|
286
|
+
return false;
|
|
287
|
+
if (typeof m.type !== "string")
|
|
288
|
+
return false;
|
|
289
|
+
// Type must be valid
|
|
290
|
+
if (!["sandbox", "injected", "privileged"].includes(m.type))
|
|
291
|
+
return false;
|
|
292
|
+
// Sandbox wallets need executor
|
|
293
|
+
if (m.type === "sandbox" && typeof m.executor !== "string")
|
|
294
|
+
return false;
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Merge wallet manifests with conflict resolution
|
|
299
|
+
*/
|
|
300
|
+
function mergeManifests(base, override, strategy = "override") {
|
|
301
|
+
const walletMap = new Map();
|
|
302
|
+
// Add base wallets
|
|
303
|
+
for (const wallet of base) {
|
|
304
|
+
walletMap.set(wallet.id, wallet);
|
|
305
|
+
}
|
|
306
|
+
// Apply override wallets
|
|
307
|
+
for (const wallet of override) {
|
|
308
|
+
if (strategy === "override") {
|
|
309
|
+
walletMap.set(wallet.id, wallet);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const existing = walletMap.get(wallet.id);
|
|
313
|
+
if (existing) {
|
|
314
|
+
// Merge features and permissions
|
|
315
|
+
walletMap.set(wallet.id, {
|
|
316
|
+
...existing,
|
|
317
|
+
...wallet,
|
|
318
|
+
features: { ...existing.features, ...wallet.features },
|
|
319
|
+
permissions: { ...existing.permissions, ...wallet.permissions },
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
walletMap.set(wallet.id, wallet);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return Array.from(walletMap.values());
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/helpers/manifest.ts"],"names":[],"mappings":";;;AAiYA,4CAoBC;AAKD,wCAiCC;AAtYD;;GAEG;AACU,QAAA,wBAAwB,GAAqB;IACxD;QACE,EAAE,EAAE,kBAAkB;QACtB,IAAI,EAAE,kBAAkB;QACxB,GAAG,EAAE,kGAAkG;QACvG,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;KACjC;IACD;QACE,EAAE,EAAE,mBAAmB;QACvB,IAAI,EAAE,mBAAmB;QACzB,GAAG,EAAE,2EAA2E;QAChF,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;KACjC;CACF,CAAC;AA0BF;;;;;;;;GAQG;AACH,MAAa,wBAAwB;IAC3B,OAAO,CAAmB;IAC1B,KAAK,GA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AE,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1C,IAAI,QAAQ,EAAE,CAAC;gBACb,iCAAiC;gBACjC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;oBACvB,GAAG,QAAQ;oBACX,GAAG,MAAM;oBACT,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;oBACtD,WAAW,EAAE,EAAE,GAAG,QAAQ,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE;iBAChE,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Queue {
|
|
2
|
+
_items: any[];
|
|
3
|
+
enqueue(item: any): void;
|
|
4
|
+
dequeue(): any;
|
|
5
|
+
get size(): number;
|
|
6
|
+
}
|
|
7
|
+
export declare class AutoQueue extends Queue {
|
|
8
|
+
_pendingPromise: boolean;
|
|
9
|
+
enqueue<T>(action: () => Promise<T>): Promise<T>;
|
|
10
|
+
dequeue(): Promise<boolean>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutoQueue = exports.Queue = void 0;
|
|
4
|
+
class Queue {
|
|
5
|
+
_items = [];
|
|
6
|
+
enqueue(item) {
|
|
7
|
+
this._items.push(item);
|
|
8
|
+
}
|
|
9
|
+
dequeue() {
|
|
10
|
+
return this._items.shift();
|
|
11
|
+
}
|
|
12
|
+
get size() {
|
|
13
|
+
return this._items.length;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Queue = Queue;
|
|
17
|
+
class AutoQueue extends Queue {
|
|
18
|
+
_pendingPromise = false;
|
|
19
|
+
enqueue(action) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
super.enqueue({ action, resolve, reject });
|
|
22
|
+
this.dequeue();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async dequeue() {
|
|
26
|
+
if (this._pendingPromise)
|
|
27
|
+
return false;
|
|
28
|
+
const item = super.dequeue();
|
|
29
|
+
if (!item)
|
|
30
|
+
return false;
|
|
31
|
+
try {
|
|
32
|
+
this._pendingPromise = true;
|
|
33
|
+
const payload = await item.action(this);
|
|
34
|
+
this._pendingPromise = false;
|
|
35
|
+
item.resolve(payload);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
this._pendingPromise = false;
|
|
39
|
+
item.reject(e);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
void this.dequeue();
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AutoQueue = AutoQueue;
|
|
48
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/helpers/queue.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAK;IAChB,MAAM,GAAU,EAAE,CAAC;IACnB,OAAO,CAAC,IAAS;QACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AAbD,sBAaC;AAED,MAAa,SAAU,SAAQ,KAAK;IAClC,eAAe,GAAG,KAAK,CAAC;IACxB,OAAO,CAAI,MAAwB;QACjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAExB,IAAI,CAAC;YACH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5BD,8BA4BC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { DataStorage } from "./storage";
|
|
2
|
+
import { Session } from "../types";
|
|
3
|
+
export type { Session };
|
|
4
|
+
/**
|
|
5
|
+
* Session validation result
|
|
6
|
+
*/
|
|
7
|
+
export type SessionValidationResult = {
|
|
8
|
+
valid: true;
|
|
9
|
+
session: Session;
|
|
10
|
+
} | {
|
|
11
|
+
valid: false;
|
|
12
|
+
reason: "expired" | "invalid" | "missing";
|
|
13
|
+
};
|
|
14
|
+
export interface SessionManagerOptions {
|
|
15
|
+
storage?: DataStorage;
|
|
16
|
+
storageKey?: string;
|
|
17
|
+
maxAge?: number;
|
|
18
|
+
idleTimeout?: number;
|
|
19
|
+
autoReconnect?: boolean;
|
|
20
|
+
enableMultiTabSync?: boolean;
|
|
21
|
+
onSessionRestored?: (session: Session) => void;
|
|
22
|
+
onSessionExpired?: (session: Session) => void;
|
|
23
|
+
onSessionInvalid?: (session: Session) => void;
|
|
24
|
+
onSessionCleared?: () => void;
|
|
25
|
+
onSessionSynced?: (session: Session) => void;
|
|
26
|
+
onIdleTimeout?: (session: Session) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare class SessionManager {
|
|
29
|
+
private storage;
|
|
30
|
+
private storageKey;
|
|
31
|
+
private maxAge;
|
|
32
|
+
private idleTimeout;
|
|
33
|
+
private autoReconnect;
|
|
34
|
+
private enableMultiTabSync;
|
|
35
|
+
private cachedSession;
|
|
36
|
+
private broadcastChannel;
|
|
37
|
+
private idleTimer;
|
|
38
|
+
private activityHandler;
|
|
39
|
+
private onSessionRestored?;
|
|
40
|
+
private onSessionExpired?;
|
|
41
|
+
private onSessionInvalid?;
|
|
42
|
+
private onSessionCleared?;
|
|
43
|
+
private onSessionSynced?;
|
|
44
|
+
private onIdleTimeout?;
|
|
45
|
+
constructor(options?: SessionManagerOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Initialize multi-tab synchronization via BroadcastChannel
|
|
48
|
+
*/
|
|
49
|
+
private initMultiTabSync;
|
|
50
|
+
/**
|
|
51
|
+
* Handle incoming sync messages from other tabs
|
|
52
|
+
*/
|
|
53
|
+
private handleSyncMessage;
|
|
54
|
+
/**
|
|
55
|
+
* Broadcast session change to other tabs
|
|
56
|
+
*/
|
|
57
|
+
private broadcast;
|
|
58
|
+
/**
|
|
59
|
+
* Start idle timeout tracking
|
|
60
|
+
*/
|
|
61
|
+
private startIdleTracking;
|
|
62
|
+
/**
|
|
63
|
+
* Stop idle timeout tracking
|
|
64
|
+
*/
|
|
65
|
+
private stopIdleTracking;
|
|
66
|
+
/**
|
|
67
|
+
* Cleanup resources
|
|
68
|
+
*/
|
|
69
|
+
destroy(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Save a new session
|
|
72
|
+
*/
|
|
73
|
+
save(session: Omit<Session, "connectedAt" | "lastActiveAt">): Promise<Session>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the current session if valid
|
|
76
|
+
*/
|
|
77
|
+
get(): Promise<Session | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Validate a session and return detailed result
|
|
80
|
+
*/
|
|
81
|
+
validate(session: Session): SessionValidationResult;
|
|
82
|
+
/**
|
|
83
|
+
* Update the last active timestamp
|
|
84
|
+
*/
|
|
85
|
+
touch(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Update session data (e.g., accounts changed)
|
|
88
|
+
*/
|
|
89
|
+
update(updates: Partial<Pick<Session, "accounts" | "network" | "metadata">>): Promise<Session | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Clear the session
|
|
92
|
+
*/
|
|
93
|
+
clear(): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Check if a session is still valid (simple boolean check)
|
|
96
|
+
*/
|
|
97
|
+
isValid(session: Session): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Check if we should auto-reconnect
|
|
100
|
+
*/
|
|
101
|
+
shouldAutoReconnect(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Try to restore a previous session
|
|
104
|
+
* Returns the session if valid and autoReconnect is enabled
|
|
105
|
+
*/
|
|
106
|
+
tryRestore(): Promise<Session | null>;
|
|
107
|
+
/**
|
|
108
|
+
* Get session age in milliseconds
|
|
109
|
+
*/
|
|
110
|
+
getAge(): Promise<number | null>;
|
|
111
|
+
/**
|
|
112
|
+
* Get time since last activity
|
|
113
|
+
*/
|
|
114
|
+
getIdleTime(): Promise<number | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Check if session exists (without full validation)
|
|
117
|
+
*/
|
|
118
|
+
exists(): Promise<boolean>;
|
|
119
|
+
}
|