@konemono/nostr-login 1.11.0 → 1.11.3

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.
@@ -1,407 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="ja">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Relay Management Test</title>
7
- <style>
8
- body {
9
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
10
- max-width: 1200px;
11
- margin: 0 auto;
12
- padding: 20px;
13
- background: #f5f5f5;
14
- }
15
- .container {
16
- background: white;
17
- border-radius: 8px;
18
- padding: 20px;
19
- margin-bottom: 20px;
20
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
21
- }
22
- h1 {
23
- color: #333;
24
- border-bottom: 2px solid #4CAF50;
25
- padding-bottom: 10px;
26
- }
27
- h2 {
28
- color: #555;
29
- margin-top: 0;
30
- }
31
- button {
32
- background: #4CAF50;
33
- color: white;
34
- border: none;
35
- padding: 10px 20px;
36
- border-radius: 4px;
37
- cursor: pointer;
38
- margin: 5px;
39
- font-size: 14px;
40
- }
41
- button:hover {
42
- background: #45a049;
43
- }
44
- button:disabled {
45
- background: #ccc;
46
- cursor: not-allowed;
47
- }
48
- .status-box {
49
- background: #f9f9f9;
50
- border: 1px solid #ddd;
51
- border-radius: 4px;
52
- padding: 15px;
53
- margin: 10px 0;
54
- font-family: 'Courier New', monospace;
55
- font-size: 13px;
56
- white-space: pre-wrap;
57
- max-height: 300px;
58
- overflow-y: auto;
59
- }
60
- .log {
61
- background: #263238;
62
- color: #aed581;
63
- border-radius: 4px;
64
- padding: 15px;
65
- margin: 10px 0;
66
- font-family: 'Courier New', monospace;
67
- font-size: 12px;
68
- max-height: 400px;
69
- overflow-y: auto;
70
- }
71
- .log-entry {
72
- margin: 2px 0;
73
- }
74
- .log-error {
75
- color: #ff5252;
76
- }
77
- .log-success {
78
- color: #69f0ae;
79
- }
80
- .log-info {
81
- color: #64b5f6;
82
- }
83
- .stats-grid {
84
- display: grid;
85
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
86
- gap: 10px;
87
- margin: 10px 0;
88
- }
89
- .stat-card {
90
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
91
- color: white;
92
- padding: 15px;
93
- border-radius: 8px;
94
- text-align: center;
95
- }
96
- .stat-value {
97
- font-size: 32px;
98
- font-weight: bold;
99
- margin: 5px 0;
100
- }
101
- .stat-label {
102
- font-size: 12px;
103
- opacity: 0.9;
104
- }
105
- .relay-list {
106
- list-style: none;
107
- padding: 0;
108
- }
109
- .relay-item {
110
- background: #f5f5f5;
111
- padding: 10px;
112
- margin: 5px 0;
113
- border-radius: 4px;
114
- display: flex;
115
- justify-content: space-between;
116
- align-items: center;
117
- }
118
- .relay-status {
119
- padding: 4px 12px;
120
- border-radius: 12px;
121
- font-size: 12px;
122
- font-weight: bold;
123
- }
124
- .status-connected {
125
- background: #4CAF50;
126
- color: white;
127
- }
128
- .status-connecting {
129
- background: #FF9800;
130
- color: white;
131
- }
132
- .status-disconnected {
133
- background: #9E9E9E;
134
- color: white;
135
- }
136
- .status-error {
137
- background: #F44336;
138
- color: white;
139
- }
140
- input[type="text"] {
141
- padding: 8px;
142
- border: 1px solid #ddd;
143
- border-radius: 4px;
144
- width: 300px;
145
- font-size: 14px;
146
- }
147
- </style>
148
- </head>
149
- <body>
150
- <h1>🔌 Relay Management Test Tool</h1>
151
-
152
- <div class="container">
153
- <h2>📊 Current Status</h2>
154
- <div class="stats-grid" id="statsGrid">
155
- <div class="stat-card">
156
- <div class="stat-label">Total Relays</div>
157
- <div class="stat-value" id="totalRelays">-</div>
158
- </div>
159
- <div class="stat-card">
160
- <div class="stat-label">Connected</div>
161
- <div class="stat-value" id="connectedRelays">-</div>
162
- </div>
163
- <div class="stat-card">
164
- <div class="stat-label">Connecting</div>
165
- <div class="stat-value" id="connectingRelays">-</div>
166
- </div>
167
- <div class="stat-card">
168
- <div class="stat-label">Disconnected</div>
169
- <div class="stat-value" id="disconnectedRelays">-</div>
170
- </div>
171
- <div class="stat-card">
172
- <div class="stat-label">Error</div>
173
- <div class="stat-value" id="errorRelays">-</div>
174
- </div>
175
- </div>
176
-
177
- <h3>Relay List</h3>
178
- <ul class="relay-list" id="relayList"></ul>
179
- </div>
180
-
181
- <div class="container">
182
- <h2>🧪 Test Actions</h2>
183
- <button onclick="refreshStatus()">🔄 Refresh Status</button>
184
- <button onclick="checkHealth()">❤️ Check Health</button>
185
- <button onclick="reconnectAll()">🔌 Reconnect All</button>
186
- <button onclick="simulateOffline()">📡 Simulate Offline</button>
187
- <button onclick="runAutoTest()">🤖 Run Auto Test</button>
188
- <button onclick="clearLogs()">🗑️ Clear Logs</button>
189
- </div>
190
-
191
- <div class="container">
192
- <h2>➕ Add/Remove Relay</h2>
193
- <input type="text" id="relayUrl" placeholder="wss://relay.example.com" />
194
- <button onclick="connectRelay()">Connect</button>
195
- <button onclick="disconnectRelay()">Disconnect</button>
196
- </div>
197
-
198
- <div class="container">
199
- <h2>📝 Logs</h2>
200
- <div class="log" id="logContainer"></div>
201
- </div>
202
-
203
- <script type="module">
204
- // このスクリプトは実際のnostr-loginインスタンスにアクセスする必要があります
205
- // 実際の使用時は、アプリケーションのAuthNostrServiceインスタンスを参照してください
206
-
207
- let authService = null;
208
-
209
- // グローバルに公開されたインスタンスを探す
210
- window.addEventListener('load', () => {
211
- // 実際のアプリケーションでAuthNostrServiceインスタンスを取得する方法に応じて調整
212
- // 例: authService = window.nostrLogin?.authService;
213
- log('⚠️ AuthNostrService instance not found. Please integrate with your app.', 'error');
214
- log('ℹ️ This is a test tool template. Modify the script to access your AuthNostrService instance.', 'info');
215
- });
216
-
217
- function log(message, type = 'info') {
218
- const logContainer = document.getElementById('logContainer');
219
- const timestamp = new Date().toLocaleTimeString();
220
- const entry = document.createElement('div');
221
- entry.className = `log-entry log-${type}`;
222
- entry.textContent = `[${timestamp}] ${message}`;
223
- logContainer.appendChild(entry);
224
- logContainer.scrollTop = logContainer.scrollHeight;
225
- console.log(message);
226
- }
227
-
228
- window.refreshStatus = async function() {
229
- if (!authService) {
230
- log('❌ AuthNostrService not available', 'error');
231
- return;
232
- }
233
-
234
- try {
235
- log('🔄 Refreshing status...', 'info');
236
-
237
- const status = authService.getRelayStatus();
238
- const stats = authService.getRelayStats();
239
-
240
- // Update stats
241
- document.getElementById('totalRelays').textContent = stats.total;
242
- document.getElementById('connectedRelays').textContent = stats.connected;
243
- document.getElementById('connectingRelays').textContent = stats.connecting;
244
- document.getElementById('disconnectedRelays').textContent = stats.disconnected;
245
- document.getElementById('errorRelays').textContent = stats.error;
246
-
247
- // Update relay list
248
- const relayList = document.getElementById('relayList');
249
- relayList.innerHTML = '';
250
-
251
- for (const [url, state] of Object.entries(status)) {
252
- const li = document.createElement('li');
253
- li.className = 'relay-item';
254
-
255
- const urlSpan = document.createElement('span');
256
- urlSpan.textContent = url;
257
-
258
- const statusSpan = document.createElement('span');
259
- statusSpan.className = `relay-status status-${state.toLowerCase()}`;
260
- statusSpan.textContent = state;
261
-
262
- li.appendChild(urlSpan);
263
- li.appendChild(statusSpan);
264
- relayList.appendChild(li);
265
- }
266
-
267
- log(`✅ Status updated: ${stats.connected}/${stats.total} connected`, 'success');
268
- } catch (error) {
269
- log(`❌ Error: ${error.message}`, 'error');
270
- }
271
- };
272
-
273
- window.checkHealth = async function() {
274
- if (!authService) {
275
- log('❌ AuthNostrService not available', 'error');
276
- return;
277
- }
278
-
279
- try {
280
- const health = await authService.checkRelayHealth();
281
- log(`❤️ Health check: ${health ? 'HEALTHY' : 'UNHEALTHY'}`, health ? 'success' : 'error');
282
- } catch (error) {
283
- log(`❌ Error: ${error.message}`, 'error');
284
- }
285
- };
286
-
287
- window.reconnectAll = async function() {
288
- if (!authService) {
289
- log('❌ AuthNostrService not available', 'error');
290
- return;
291
- }
292
-
293
- try {
294
- log('🔌 Reconnecting all relays...', 'info');
295
- await authService.reconnectAllRelays();
296
- log('✅ Reconnection initiated', 'success');
297
- setTimeout(refreshStatus, 3000);
298
- } catch (error) {
299
- log(`❌ Error: ${error.message}`, 'error');
300
- }
301
- };
302
-
303
- window.connectRelay = async function() {
304
- if (!authService) {
305
- log('❌ AuthNostrService not available', 'error');
306
- return;
307
- }
308
-
309
- const url = document.getElementById('relayUrl').value;
310
- if (!url) {
311
- log('❌ Please enter a relay URL', 'error');
312
- return;
313
- }
314
-
315
- try {
316
- log(`🔌 Connecting to ${url}...`, 'info');
317
- await authService.connectToRelay(url);
318
- log(`✅ Connection initiated to ${url}`, 'success');
319
- setTimeout(refreshStatus, 2000);
320
- } catch (error) {
321
- log(`❌ Error: ${error.message}`, 'error');
322
- }
323
- };
324
-
325
- window.disconnectRelay = async function() {
326
- if (!authService) {
327
- log('❌ AuthNostrService not available', 'error');
328
- return;
329
- }
330
-
331
- const url = document.getElementById('relayUrl').value;
332
- if (!url) {
333
- log('❌ Please enter a relay URL', 'error');
334
- return;
335
- }
336
-
337
- try {
338
- log(`🔌 Disconnecting from ${url}...`, 'info');
339
- await authService.disconnectFromRelay(url);
340
- log(`✅ Disconnected from ${url}`, 'success');
341
- setTimeout(refreshStatus, 1000);
342
- } catch (error) {
343
- log(`❌ Error: ${error.message}`, 'error');
344
- }
345
- };
346
-
347
- window.simulateOffline = function() {
348
- log('📡 To simulate offline:', 'info');
349
- log('1. Open DevTools (F12)', 'info');
350
- log('2. Go to Network tab', 'info');
351
- log('3. Select "Offline" from throttling dropdown', 'info');
352
- log('4. Wait a few seconds', 'info');
353
- log('5. Select "Online" to restore connection', 'info');
354
- };
355
-
356
- window.runAutoTest = async function() {
357
- if (!authService) {
358
- log('❌ AuthNostrService not available', 'error');
359
- return;
360
- }
361
-
362
- log('🤖 Starting automated tests...', 'info');
363
-
364
- try {
365
- // Test 1: Get status
366
- log('Test 1: Getting relay status...', 'info');
367
- const status = authService.getRelayStatus();
368
- log(`✅ Got status for ${Object.keys(status).length} relays`, 'success');
369
-
370
- // Test 2: Get stats
371
- log('Test 2: Getting relay stats...', 'info');
372
- const stats = authService.getRelayStats();
373
- log(`✅ Stats: ${stats.connected}/${stats.total} connected`, 'success');
374
-
375
- // Test 3: Health check
376
- log('Test 3: Checking health...', 'info');
377
- const health = await authService.checkRelayHealth();
378
- log(`✅ Health: ${health ? 'HEALTHY' : 'UNHEALTHY'}`, 'success');
379
-
380
- // Test 4: Reconnect
381
- log('Test 4: Testing reconnect...', 'info');
382
- await authService.reconnectAllRelays();
383
- log('✅ Reconnect initiated', 'success');
384
-
385
- await new Promise(r => setTimeout(r, 3000));
386
- await refreshStatus();
387
-
388
- log('🎉 All tests completed!', 'success');
389
- } catch (error) {
390
- log(`❌ Test failed: ${error.message}`, 'error');
391
- }
392
- };
393
-
394
- window.clearLogs = function() {
395
- document.getElementById('logContainer').innerHTML = '';
396
- log('🗑️ Logs cleared', 'info');
397
- };
398
-
399
- // Auto-refresh every 5 seconds
400
- setInterval(() => {
401
- if (authService) {
402
- refreshStatus();
403
- }
404
- }, 5000);
405
- </script>
406
- </body>
407
- </html>