shogun-button-react 5.0.0 → 6.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/dist/connector.js CHANGED
@@ -1,50 +1,59 @@
1
- import { ShogunCore } from "shogun-core";
1
+ import { ShogunCore, Gun, quickStart } from "shogun-core";
2
2
  export async function shogunConnector(options) {
3
- const { gunInstance, gunOptions, transport, appName, timeouts, webauthn, nostr, web3, zkproof, showWebauthn, showNostr, showMetamask, showZkProof, darkMode, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, ...restOptions } = options;
3
+ const { gunInstance, gunOptions, appName, timeouts, webauthn, nostr, web3, zkproof, showWebauthn, showNostr, showMetamask, showZkProof, darkMode, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, useQuickStart = false, ...restOptions } = options;
4
4
  let core = null;
5
- // Priority: transport > gunInstance > gunOptions
6
- if (transport !== undefined) {
7
- // Use new transport layer configuration
8
- core = new ShogunCore({
9
- transport: transport,
10
- webauthn,
11
- nostr,
12
- web3,
13
- zkproof,
14
- timeouts,
15
- });
16
- }
17
- else if (gunInstance !== undefined) {
18
- // Use existing Gun instance (backward compatibility)
19
- core = new ShogunCore({
20
- gunInstance: gunInstance,
21
- webauthn,
22
- nostr,
23
- web3,
24
- zkproof,
25
- timeouts,
26
- });
5
+ let gun = null;
6
+ // Create Gun instance if not provided
7
+ if (!gunInstance) {
8
+ if (gunOptions) {
9
+ gun = Gun(gunOptions);
10
+ }
11
+ else {
12
+ // Default Gun configuration
13
+ gun = Gun({
14
+ peers: ["https://shogunnode.scobrudot.dev/gun"],
15
+ radisk: false,
16
+ localStorage: false,
17
+ });
18
+ }
27
19
  }
28
20
  else {
29
- // Use Gun options (backward compatibility)
30
- core = new ShogunCore({
31
- gunOptions: gunOptions,
32
- webauthn,
33
- nostr,
34
- web3,
35
- zkproof,
36
- timeouts,
37
- });
38
- }
39
- // Wait for core to initialize (plugins registration, etc.)
40
- try {
41
- await core.initialize();
42
- console.log(`[DEBUG] ShogunConnector: ShogunCore initialized`);
21
+ gun = gunInstance;
43
22
  }
44
- catch (error) {
45
- console.error("Error initializing ShogunCore:", error);
46
- console.error(`[DEBUG] ShogunConnector: Error initializing ShogunCore: ${error}`);
23
+ // Use quickStart for simplified API if requested
24
+ if (useQuickStart) {
25
+ const quickStartInstance = quickStart(gun, appName || "shogun-app");
26
+ await quickStartInstance.init();
27
+ return {
28
+ core: quickStartInstance, // Type assertion for compatibility
29
+ options,
30
+ setProvider: () => false, // Not applicable for quickStart
31
+ getCurrentProviderUrl: () => null,
32
+ registerPlugin: () => false,
33
+ hasPlugin: () => false,
34
+ gunPlugin: null,
35
+ };
47
36
  }
37
+ // Create ShogunCore with gunInstance (required in v2.0.0)
38
+ core = new ShogunCore({
39
+ gunInstance: gun,
40
+ webauthn: (webauthn === null || webauthn === void 0 ? void 0 : webauthn.enabled) ? {
41
+ enabled: true,
42
+ rpName: appName || "Shogun App",
43
+ rpId: typeof window !== "undefined" ? window.location.hostname : "localhost",
44
+ } : undefined,
45
+ web3: (web3 === null || web3 === void 0 ? void 0 : web3.enabled) ? { enabled: true } : undefined,
46
+ nostr: (nostr === null || nostr === void 0 ? void 0 : nostr.enabled) ? { enabled: true } : undefined,
47
+ zkproof: (zkproof === null || zkproof === void 0 ? void 0 : zkproof.enabled) ? {
48
+ enabled: true,
49
+ defaultGroupId: zkproof.defaultGroupId || "shogun-users",
50
+ } : undefined,
51
+ timeouts,
52
+ silent: false, // Enable console logs for debugging
53
+ });
54
+ // Note: ShogunCore v2.0.0 initializes automatically in constructor
55
+ // No need to call initialize() separately
56
+ console.log(`[DEBUG] ShogunConnector: ShogunCore initialized with gunInstance`);
48
57
  const setProvider = (provider) => {
49
58
  var _a;
50
59
  if (!core) {