@followgate/js 0.8.2 → 0.9.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/dist/index.d.mts CHANGED
@@ -26,7 +26,6 @@ interface FollowGateConfig {
26
26
  onComplete?: () => void;
27
27
  theme?: 'dark' | 'light';
28
28
  accentColor?: string;
29
- allowSkip?: boolean;
30
29
  }
31
30
  /**
32
31
  * SDK Error class with helpful messages
@@ -84,6 +83,8 @@ interface VerificationStatus {
84
83
  */
85
84
  declare class FollowGateClient {
86
85
  private config;
86
+ private serverConfig;
87
+ private configFetched;
87
88
  private listeners;
88
89
  private currentUser;
89
90
  private completedActions;
@@ -93,11 +94,15 @@ declare class FollowGateClient {
93
94
  * Initialize the SDK
94
95
  */
95
96
  init(config: FollowGateConfig): void;
97
+ /**
98
+ * Fetch app configuration from server
99
+ */
100
+ private fetchServerConfig;
96
101
  /**
97
102
  * Show the FollowGate modal
98
103
  * If user is already unlocked, calls onComplete immediately
99
104
  */
100
- show(): void;
105
+ show(): Promise<void>;
101
106
  /**
102
107
  * Hide the modal
103
108
  */
package/dist/index.d.ts CHANGED
@@ -26,7 +26,6 @@ interface FollowGateConfig {
26
26
  onComplete?: () => void;
27
27
  theme?: 'dark' | 'light';
28
28
  accentColor?: string;
29
- allowSkip?: boolean;
30
29
  }
31
30
  /**
32
31
  * SDK Error class with helpful messages
@@ -84,6 +83,8 @@ interface VerificationStatus {
84
83
  */
85
84
  declare class FollowGateClient {
86
85
  private config;
86
+ private serverConfig;
87
+ private configFetched;
87
88
  private listeners;
88
89
  private currentUser;
89
90
  private completedActions;
@@ -93,11 +94,15 @@ declare class FollowGateClient {
93
94
  * Initialize the SDK
94
95
  */
95
96
  init(config: FollowGateConfig): void;
97
+ /**
98
+ * Fetch app configuration from server
99
+ */
100
+ private fetchServerConfig;
96
101
  /**
97
102
  * Show the FollowGate modal
98
103
  * If user is already unlocked, calls onComplete immediately
99
104
  */
100
- show(): void;
105
+ show(): Promise<void>;
101
106
  /**
102
107
  * Hide the modal
103
108
  */
package/dist/index.js CHANGED
@@ -464,6 +464,8 @@ var ICONS = {
464
464
  };
465
465
  var FollowGateClient = class {
466
466
  config = null;
467
+ serverConfig = null;
468
+ configFetched = false;
467
469
  listeners = /* @__PURE__ */ new Map();
468
470
  currentUser = null;
469
471
  completedActions = [];
@@ -525,11 +527,46 @@ var FollowGateClient = class {
525
527
  // ============================================
526
528
  // Modal UI Methods
527
529
  // ============================================
530
+ /**
531
+ * Fetch app configuration from server
532
+ */
533
+ async fetchServerConfig() {
534
+ if (!this.config || this.configFetched) return;
535
+ try {
536
+ const response = await fetch(`${this.config.apiUrl}/api/v1/config`, {
537
+ headers: {
538
+ Authorization: `Bearer ${this.config.apiKey}`
539
+ }
540
+ });
541
+ if (response.ok) {
542
+ const data = await response.json();
543
+ if (data.success && data.data) {
544
+ this.serverConfig = data.data;
545
+ if (this.config.debug) {
546
+ console.log(
547
+ "[FollowGate] Server config loaded:",
548
+ this.serverConfig
549
+ );
550
+ }
551
+ }
552
+ } else if (this.config.debug) {
553
+ console.warn(
554
+ "[FollowGate] Failed to fetch server config:",
555
+ response.status
556
+ );
557
+ }
558
+ } catch (error) {
559
+ if (this.config.debug) {
560
+ console.warn("[FollowGate] Failed to fetch server config:", error);
561
+ }
562
+ }
563
+ this.configFetched = true;
564
+ }
528
565
  /**
529
566
  * Show the FollowGate modal
530
567
  * If user is already unlocked, calls onComplete immediately
531
568
  */
532
- show() {
569
+ async show() {
533
570
  if (!this.config) {
534
571
  throw new Error("[FollowGate] SDK not initialized. Call init() first.");
535
572
  }
@@ -540,6 +577,7 @@ var FollowGateClient = class {
540
577
  this.config.onComplete?.();
541
578
  return;
542
579
  }
580
+ await this.fetchServerConfig();
543
581
  this.injectStyles();
544
582
  this.createModal();
545
583
  }
@@ -669,7 +707,7 @@ var FollowGateClient = class {
669
707
  </button>
670
708
  </div>
671
709
  <p class="fg-hint">A new window will open. Return here after following.</p>
672
- ${this.config.allowSkip ? '<span class="fg-skip-link" id="fg-skip-follow">skip this step</span>' : ""}
710
+ ${this.serverConfig?.allowSkip ? '<span class="fg-skip-link" id="fg-skip-follow">skip this step</span>' : ""}
673
711
  `;
674
712
  document.getElementById("fg-follow-btn")?.addEventListener("click", () => {
675
713
  this.handleFollowClick();
@@ -780,7 +818,7 @@ var FollowGateClient = class {
780
818
  </button>
781
819
  </div>
782
820
  <p class="fg-hint">A new window will open. Return here after reposting.</p>
783
- ${this.config.allowSkip ? '<span class="fg-skip-link" id="fg-skip-repost">skip this step</span>' : ""}
821
+ ${this.serverConfig?.allowSkip ? '<span class="fg-skip-link" id="fg-skip-repost">skip this step</span>' : ""}
784
822
  `;
785
823
  document.getElementById("fg-repost-btn")?.addEventListener("click", () => {
786
824
  this.handleRepostClick();
package/dist/index.mjs CHANGED
@@ -438,6 +438,8 @@ var ICONS = {
438
438
  };
439
439
  var FollowGateClient = class {
440
440
  config = null;
441
+ serverConfig = null;
442
+ configFetched = false;
441
443
  listeners = /* @__PURE__ */ new Map();
442
444
  currentUser = null;
443
445
  completedActions = [];
@@ -499,11 +501,46 @@ var FollowGateClient = class {
499
501
  // ============================================
500
502
  // Modal UI Methods
501
503
  // ============================================
504
+ /**
505
+ * Fetch app configuration from server
506
+ */
507
+ async fetchServerConfig() {
508
+ if (!this.config || this.configFetched) return;
509
+ try {
510
+ const response = await fetch(`${this.config.apiUrl}/api/v1/config`, {
511
+ headers: {
512
+ Authorization: `Bearer ${this.config.apiKey}`
513
+ }
514
+ });
515
+ if (response.ok) {
516
+ const data = await response.json();
517
+ if (data.success && data.data) {
518
+ this.serverConfig = data.data;
519
+ if (this.config.debug) {
520
+ console.log(
521
+ "[FollowGate] Server config loaded:",
522
+ this.serverConfig
523
+ );
524
+ }
525
+ }
526
+ } else if (this.config.debug) {
527
+ console.warn(
528
+ "[FollowGate] Failed to fetch server config:",
529
+ response.status
530
+ );
531
+ }
532
+ } catch (error) {
533
+ if (this.config.debug) {
534
+ console.warn("[FollowGate] Failed to fetch server config:", error);
535
+ }
536
+ }
537
+ this.configFetched = true;
538
+ }
502
539
  /**
503
540
  * Show the FollowGate modal
504
541
  * If user is already unlocked, calls onComplete immediately
505
542
  */
506
- show() {
543
+ async show() {
507
544
  if (!this.config) {
508
545
  throw new Error("[FollowGate] SDK not initialized. Call init() first.");
509
546
  }
@@ -514,6 +551,7 @@ var FollowGateClient = class {
514
551
  this.config.onComplete?.();
515
552
  return;
516
553
  }
554
+ await this.fetchServerConfig();
517
555
  this.injectStyles();
518
556
  this.createModal();
519
557
  }
@@ -643,7 +681,7 @@ var FollowGateClient = class {
643
681
  </button>
644
682
  </div>
645
683
  <p class="fg-hint">A new window will open. Return here after following.</p>
646
- ${this.config.allowSkip ? '<span class="fg-skip-link" id="fg-skip-follow">skip this step</span>' : ""}
684
+ ${this.serverConfig?.allowSkip ? '<span class="fg-skip-link" id="fg-skip-follow">skip this step</span>' : ""}
647
685
  `;
648
686
  document.getElementById("fg-follow-btn")?.addEventListener("click", () => {
649
687
  this.handleFollowClick();
@@ -754,7 +792,7 @@ var FollowGateClient = class {
754
792
  </button>
755
793
  </div>
756
794
  <p class="fg-hint">A new window will open. Return here after reposting.</p>
757
- ${this.config.allowSkip ? '<span class="fg-skip-link" id="fg-skip-repost">skip this step</span>' : ""}
795
+ ${this.serverConfig?.allowSkip ? '<span class="fg-skip-link" id="fg-skip-repost">skip this step</span>' : ""}
758
796
  `;
759
797
  document.getElementById("fg-repost-btn")?.addEventListener("click", () => {
760
798
  this.handleRepostClick();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@followgate/js",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "FollowGate SDK - Grow your audience with every download. Require social actions (follow, repost) before users can access your app.",
5
5
  "author": "FollowGate <hello@followgate.app>",
6
6
  "homepage": "https://followgate.app",