@followgate/js 0.5.0 → 0.7.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.ts CHANGED
@@ -6,6 +6,13 @@ type Platform = 'twitter' | 'bluesky' | 'linkedin';
6
6
  * Supported social actions
7
7
  */
8
8
  type SocialAction = 'follow' | 'repost' | 'like';
9
+ /**
10
+ * Twitter/X configuration
11
+ */
12
+ interface TwitterConfig {
13
+ handle: string;
14
+ tweetId?: string;
15
+ }
9
16
  /**
10
17
  * SDK Configuration
11
18
  */
@@ -14,6 +21,11 @@ interface FollowGateConfig {
14
21
  apiKey: string;
15
22
  apiUrl?: string;
16
23
  debug?: boolean;
24
+ userId?: string;
25
+ twitter?: TwitterConfig;
26
+ onComplete?: () => void;
27
+ theme?: 'dark' | 'light';
28
+ accentColor?: string;
17
29
  }
18
30
  /**
19
31
  * SDK Error class with helpful messages
@@ -56,28 +68,45 @@ interface UnlockStatus {
56
68
  }
57
69
  /**
58
70
  * FollowGate SDK Client
59
- *
60
- * Simple username-based flow:
61
- * 1. User enters username
62
- * 2. User clicks intent URLs to follow/repost
63
- * 3. User confirms they did it
64
- * 4. App is unlocked
65
- *
66
- * No OAuth required!
67
71
  */
68
72
  declare class FollowGateClient {
69
73
  private config;
70
74
  private listeners;
71
75
  private currentUser;
72
76
  private completedActions;
77
+ private modalElement;
78
+ private stylesInjected;
73
79
  /**
74
80
  * Initialize the SDK
75
- * @throws {FollowGateError} If configuration is invalid
76
81
  */
77
82
  init(config: FollowGateConfig): void;
83
+ /**
84
+ * Show the FollowGate modal
85
+ * If user is already unlocked, calls onComplete immediately
86
+ */
87
+ show(): void;
88
+ /**
89
+ * Hide the modal
90
+ */
91
+ hide(): void;
92
+ private injectStyles;
93
+ private createModal;
94
+ private getContentElement;
95
+ private renderUsernameStep;
96
+ private handleUsernameSubmit;
97
+ private renderFollowStep;
98
+ private handleFollowClick;
99
+ private showFollowConfirmation;
100
+ private handleFollowConfirm;
101
+ private renderRepostStep;
102
+ private handleRepostClick;
103
+ private showRepostConfirmation;
104
+ private handleRepostConfirm;
105
+ private renderConfirmStep;
106
+ private handleFinish;
107
+ private renderStepIndicator;
78
108
  /**
79
109
  * Set the user's social username
80
- * This is the main entry point - no OAuth needed!
81
110
  */
82
111
  setUsername(username: string, platform?: Platform): void;
83
112
  /**
@@ -92,73 +121,31 @@ declare class FollowGateClient {
92
121
  * Clear stored session
93
122
  */
94
123
  reset(): void;
95
- /**
96
- * Get follow intent URL for a platform
97
- */
98
124
  getFollowUrl(platform: Platform, target: string): string;
99
- /**
100
- * Get repost/retweet intent URL for a platform
101
- */
102
125
  getRepostUrl(platform: Platform, target: string): string;
103
- /**
104
- * Get like intent URL for a platform
105
- */
106
126
  getLikeUrl(platform: Platform, target: string): string;
107
- /**
108
- * Open intent URL in new window
109
- */
110
127
  openIntent(options: CompleteOptions): Promise<void>;
111
- /**
112
- * Mark an action as completed (trust-first)
113
- * Call this when user confirms they did the action
114
- */
115
128
  complete(options: CompleteOptions): Promise<void>;
116
- /**
117
- * Mark the gate as unlocked
118
- * Call this when all required actions are done
119
- */
120
129
  unlock(): Promise<void>;
121
- /**
122
- * Check if gate is unlocked
123
- */
124
130
  isUnlocked(): boolean;
125
- /**
126
- * Get unlock status with details
127
- */
128
131
  getUnlockStatus(): UnlockStatus;
129
- /**
130
- * Get completed actions
131
- */
132
132
  getCompletedActions(): CompleteOptions[];
133
- /**
134
- * Register event listener
135
- */
136
133
  on(event: EventType, callback: EventCallback): void;
137
- /**
138
- * Remove event listener
139
- */
140
134
  off(event: EventType, callback: EventCallback): void;
141
135
  /**
142
- * Restore session from localStorage
136
+ * Get storage key with optional userId suffix
137
+ * This ensures unlock status is per-user, not per-browser
143
138
  */
139
+ private getStorageKey;
144
140
  private restoreSession;
145
- /**
146
- * Save completed actions to localStorage
147
- */
148
141
  private saveCompletedActions;
149
- /**
150
- * Build intent URL for platform
151
- */
152
142
  private buildIntentUrl;
153
143
  private buildTwitterUrl;
154
144
  private buildBlueskyUrl;
155
145
  private buildLinkedInUrl;
156
- /**
157
- * Track analytics event
158
- */
159
146
  private trackEvent;
160
147
  private emit;
161
148
  }
162
149
  declare const FollowGate: FollowGateClient;
163
150
 
164
- export { type CompleteOptions, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, FollowGateError, type Platform, type SocialAction, type UnlockStatus, type UserInfo };
151
+ export { type CompleteOptions, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, FollowGateError, type Platform, type SocialAction, type TwitterConfig, type UnlockStatus, type UserInfo };