shogun-button-react 1.3.12 → 1.3.13
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.
|
@@ -624,8 +624,8 @@ export const ShogunButton = (() => {
|
|
|
624
624
|
if (formMode === "signup") {
|
|
625
625
|
const result = await signUp("password", formUsername, formPassword, formPasswordConfirm);
|
|
626
626
|
if (result && result.success) {
|
|
627
|
-
if (core === null || core === void 0 ? void 0 : core.
|
|
628
|
-
await core.
|
|
627
|
+
if (core === null || core === void 0 ? void 0 : core.db) {
|
|
628
|
+
await core.db.setPasswordHint(formHint);
|
|
629
629
|
}
|
|
630
630
|
setModalIsOpen(false);
|
|
631
631
|
}
|
|
@@ -658,10 +658,10 @@ export const ShogunButton = (() => {
|
|
|
658
658
|
setError("");
|
|
659
659
|
setLoading(true);
|
|
660
660
|
try {
|
|
661
|
-
if (!(core === null || core === void 0 ? void 0 : core.
|
|
661
|
+
if (!(core === null || core === void 0 ? void 0 : core.db)) {
|
|
662
662
|
throw new Error("SDK not ready");
|
|
663
663
|
}
|
|
664
|
-
const result = await core.
|
|
664
|
+
const result = await core.db.forgotPassword(formUsername, [
|
|
665
665
|
formSecurityAnswer,
|
|
666
666
|
]);
|
|
667
667
|
if (result.success && result.hint) {
|
package/dist/connector.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { ShogunCore } from "shogun-core";
|
|
2
2
|
import { GunAdvancedPlugin } from "./plugins/GunAdvancedPlugin";
|
|
3
3
|
export function shogunConnector(options) {
|
|
4
|
-
const { peers = ["https://gun-manhattan.herokuapp.com/gun"], appName,
|
|
4
|
+
const { peers = ["https://gun-manhattan.herokuapp.com/gun"], appName, timeouts, oauth, webauthn, nostr, web3, localStorage, radisk, showOauth, showWebauthn, showNostr, showMetamask, darkMode, authToken, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, ...restOptions } = options;
|
|
5
5
|
const core = new ShogunCore({
|
|
6
6
|
peers,
|
|
7
7
|
scope: appName,
|
|
8
|
-
logging,
|
|
9
|
-
timeouts,
|
|
10
8
|
oauth,
|
|
9
|
+
webauthn,
|
|
10
|
+
nostr,
|
|
11
|
+
web3,
|
|
12
|
+
localStorage,
|
|
13
|
+
radisk,
|
|
14
|
+
authToken,
|
|
15
|
+
timeouts,
|
|
11
16
|
});
|
|
12
17
|
const setProvider = (provider) => {
|
|
13
18
|
var _a;
|
|
@@ -69,7 +69,7 @@ export declare class GunAdvancedPlugin extends BasePlugin {
|
|
|
69
69
|
key: string;
|
|
70
70
|
};
|
|
71
71
|
put(path: string, data: any): Promise<void>;
|
|
72
|
-
get(path: string): any
|
|
72
|
+
get(path: string): import("gun").IGunChain<any, import("gun").IGunInstance<any>, import("gun").IGunInstance<any>, string>;
|
|
73
73
|
remove(path: string): Promise<void>;
|
|
74
74
|
cleanup(): void;
|
|
75
75
|
getStats(): {
|
|
@@ -46,8 +46,8 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
46
46
|
return;
|
|
47
47
|
setIsLoading(true);
|
|
48
48
|
setError(null);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const chain = this.core.gun.get(path);
|
|
50
|
+
const handler = (item) => {
|
|
51
51
|
if (!isMounted.current)
|
|
52
52
|
return;
|
|
53
53
|
if (item) {
|
|
@@ -56,7 +56,8 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
56
56
|
setError(null);
|
|
57
57
|
this.log(`State updated for ${path}:`, item);
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
|
+
chain.on(handler);
|
|
60
61
|
const timeoutId = setTimeout(() => {
|
|
61
62
|
if (isLoading) {
|
|
62
63
|
setError('Connection timeout - no data received');
|
|
@@ -65,8 +66,7 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
65
66
|
}, this.config.connectionTimeout);
|
|
66
67
|
return () => {
|
|
67
68
|
isMounted.current = false;
|
|
68
|
-
|
|
69
|
-
off();
|
|
69
|
+
chain.off();
|
|
70
70
|
clearTimeout(timeoutId);
|
|
71
71
|
};
|
|
72
72
|
}, [path]);
|
|
@@ -183,7 +183,7 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
183
183
|
return;
|
|
184
184
|
setIsLoading(true);
|
|
185
185
|
setError(null);
|
|
186
|
-
const
|
|
186
|
+
const chain = this.core.gun.get(path);
|
|
187
187
|
const tempItems = [];
|
|
188
188
|
const processItems = (items) => {
|
|
189
189
|
if (!isMounted.current)
|
|
@@ -216,7 +216,7 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
216
216
|
timestamp: Date.now()
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
|
-
const
|
|
219
|
+
const mapHandler = (item, key) => {
|
|
220
220
|
if (item) {
|
|
221
221
|
const itemWithKey = { ...item, _key: key };
|
|
222
222
|
tempItems.push(itemWithKey);
|
|
@@ -224,7 +224,8 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
224
224
|
processItems(tempItems);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
}
|
|
227
|
+
};
|
|
228
|
+
chain.map().on(mapHandler);
|
|
228
229
|
const timeoutId = setTimeout(() => {
|
|
229
230
|
if (isLoading) {
|
|
230
231
|
setError('Connection timeout - no data received');
|
|
@@ -233,8 +234,7 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
233
234
|
}, this.config.connectionTimeout);
|
|
234
235
|
return () => {
|
|
235
236
|
isMounted.current = false;
|
|
236
|
-
|
|
237
|
-
off();
|
|
237
|
+
chain.off();
|
|
238
238
|
clearTimeout(timeoutId);
|
|
239
239
|
};
|
|
240
240
|
}, [path, currentPage, pageSize, sortBy, sortOrder, filter, enableRealtime]);
|
|
@@ -369,7 +369,7 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
369
369
|
if (!this.config.enableConnectionMonitoring || !((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
|
|
370
370
|
return;
|
|
371
371
|
let timeoutId;
|
|
372
|
-
const
|
|
372
|
+
const chain = this.core.gun.get(path);
|
|
373
373
|
const resetTimeout = () => {
|
|
374
374
|
clearTimeout(timeoutId);
|
|
375
375
|
timeoutId = window.setTimeout(() => {
|
|
@@ -378,19 +378,19 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
378
378
|
this.log(`Connection timeout for ${path}`);
|
|
379
379
|
}, this.config.connectionTimeout);
|
|
380
380
|
};
|
|
381
|
-
const
|
|
381
|
+
const handler = () => {
|
|
382
382
|
setIsConnected(true);
|
|
383
383
|
setLastSeen(new Date());
|
|
384
384
|
setError(null);
|
|
385
385
|
resetTimeout();
|
|
386
386
|
this.log(`Connection active for ${path}`);
|
|
387
|
-
}
|
|
387
|
+
};
|
|
388
|
+
chain.on(handler);
|
|
388
389
|
resetTimeout();
|
|
389
|
-
this.connectionMonitors.set(path, { off, timeoutId });
|
|
390
|
+
this.connectionMonitors.set(path, { off: () => chain.off(), timeoutId });
|
|
390
391
|
return () => {
|
|
391
392
|
clearTimeout(timeoutId);
|
|
392
|
-
|
|
393
|
-
off();
|
|
393
|
+
chain.off();
|
|
394
394
|
this.connectionMonitors.delete(path);
|
|
395
395
|
};
|
|
396
396
|
}, [path]);
|
|
@@ -402,17 +402,17 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
402
402
|
if (!enabled || !this.debugEnabled || !((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
|
|
403
403
|
return;
|
|
404
404
|
this.log(`Debug mode enabled for ${path}`);
|
|
405
|
-
const
|
|
406
|
-
const
|
|
405
|
+
const chain = this.core.gun.get(path);
|
|
406
|
+
const handler = (data, key) => {
|
|
407
407
|
this.log(`[${path}] Update:`, {
|
|
408
408
|
key,
|
|
409
409
|
data,
|
|
410
410
|
timestamp: new Date().toISOString(),
|
|
411
411
|
});
|
|
412
|
-
}
|
|
412
|
+
};
|
|
413
|
+
chain.on(handler);
|
|
413
414
|
return () => {
|
|
414
|
-
|
|
415
|
-
off();
|
|
415
|
+
chain.off();
|
|
416
416
|
this.log(`Debug mode disabled for ${path}`);
|
|
417
417
|
};
|
|
418
418
|
}, [path, enabled]);
|
|
@@ -424,8 +424,8 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
424
424
|
var _a;
|
|
425
425
|
if (!((_a = this.core) === null || _a === void 0 ? void 0 : _a.gun) || !this.core.isLoggedIn())
|
|
426
426
|
return;
|
|
427
|
-
const
|
|
428
|
-
const
|
|
427
|
+
const chain = this.core.gun.get(path);
|
|
428
|
+
const handler = (item, itemKey) => {
|
|
429
429
|
if (item) {
|
|
430
430
|
setData(item);
|
|
431
431
|
setKey(itemKey);
|
|
@@ -434,10 +434,10 @@ export class GunAdvancedPlugin extends BasePlugin {
|
|
|
434
434
|
}
|
|
435
435
|
this.log(`Realtime update for ${path}:`, { data: item, key: itemKey });
|
|
436
436
|
}
|
|
437
|
-
}
|
|
437
|
+
};
|
|
438
|
+
chain.on(handler);
|
|
438
439
|
return () => {
|
|
439
|
-
|
|
440
|
-
off();
|
|
440
|
+
chain.off();
|
|
441
441
|
};
|
|
442
442
|
}, [path, callback]);
|
|
443
443
|
return { data, key };
|
|
@@ -10,15 +10,9 @@ export interface ShogunConnectorOptions {
|
|
|
10
10
|
showNostr?: boolean;
|
|
11
11
|
showOauth?: boolean;
|
|
12
12
|
darkMode?: boolean;
|
|
13
|
-
websocketSecure?: boolean;
|
|
14
|
-
providerUrl?: string | null;
|
|
15
13
|
peers?: string[];
|
|
16
14
|
authToken?: string;
|
|
17
15
|
gunInstance?: IGunInstance<any>;
|
|
18
|
-
logging?: {
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
level: "error" | "warning" | "info" | "debug";
|
|
21
|
-
};
|
|
22
16
|
timeouts?: {
|
|
23
17
|
login?: number;
|
|
24
18
|
signup?: number;
|
|
@@ -31,6 +25,17 @@ export interface ShogunConnectorOptions {
|
|
|
31
25
|
redirectUri?: string;
|
|
32
26
|
}>;
|
|
33
27
|
};
|
|
28
|
+
webauthn?: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
nostr?: {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
};
|
|
34
|
+
web3?: {
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
};
|
|
37
|
+
localStorage?: boolean;
|
|
38
|
+
radisk?: boolean;
|
|
34
39
|
enableGunDebug?: boolean;
|
|
35
40
|
enableConnectionMonitoring?: boolean;
|
|
36
41
|
defaultPageSize?: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shogun-button-react",
|
|
3
3
|
"description": "Shogun connector button",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.13",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src/styles/index.css"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"ethers": "^6.13.5",
|
|
35
35
|
"prettier": "^3.5.3",
|
|
36
36
|
"rxjs": "^7.8.1",
|
|
37
|
-
"shogun-core": "^1.
|
|
37
|
+
"shogun-core": "^1.10.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.0.0",
|