@followgate/js 0.3.0 → 0.4.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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +55 -2
- package/dist/index.mjs +53 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,14 @@ interface FollowGateConfig {
|
|
|
15
15
|
apiUrl?: string;
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* SDK Error class with helpful messages
|
|
20
|
+
*/
|
|
21
|
+
declare class FollowGateError extends Error {
|
|
22
|
+
code: string;
|
|
23
|
+
hint?: string | undefined;
|
|
24
|
+
constructor(message: string, code: string, hint?: string | undefined);
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* Open action options
|
|
20
28
|
*/
|
|
@@ -71,6 +79,7 @@ declare class FollowGateClient {
|
|
|
71
79
|
private pendingUsername;
|
|
72
80
|
/**
|
|
73
81
|
* Initialize the SDK
|
|
82
|
+
* @throws {FollowGateError} If configuration is invalid
|
|
74
83
|
*/
|
|
75
84
|
init(config: FollowGateConfig): void;
|
|
76
85
|
/**
|
|
@@ -137,4 +146,4 @@ declare class FollowGateClient {
|
|
|
137
146
|
}
|
|
138
147
|
declare const FollowGate: FollowGateClient;
|
|
139
148
|
|
|
140
|
-
export { type AuthOptions, type AuthenticatedUser, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, type LinkedInTargetType, type OpenOptions, type PendingUsernameState, type Platform, type SocialAction };
|
|
149
|
+
export { type AuthOptions, type AuthenticatedUser, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, FollowGateError, type LinkedInTargetType, type OpenOptions, type PendingUsernameState, type Platform, type SocialAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,14 @@ interface FollowGateConfig {
|
|
|
15
15
|
apiUrl?: string;
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* SDK Error class with helpful messages
|
|
20
|
+
*/
|
|
21
|
+
declare class FollowGateError extends Error {
|
|
22
|
+
code: string;
|
|
23
|
+
hint?: string | undefined;
|
|
24
|
+
constructor(message: string, code: string, hint?: string | undefined);
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* Open action options
|
|
20
28
|
*/
|
|
@@ -71,6 +79,7 @@ declare class FollowGateClient {
|
|
|
71
79
|
private pendingUsername;
|
|
72
80
|
/**
|
|
73
81
|
* Initialize the SDK
|
|
82
|
+
* @throws {FollowGateError} If configuration is invalid
|
|
74
83
|
*/
|
|
75
84
|
init(config: FollowGateConfig): void;
|
|
76
85
|
/**
|
|
@@ -137,4 +146,4 @@ declare class FollowGateClient {
|
|
|
137
146
|
}
|
|
138
147
|
declare const FollowGate: FollowGateClient;
|
|
139
148
|
|
|
140
|
-
export { type AuthOptions, type AuthenticatedUser, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, type LinkedInTargetType, type OpenOptions, type PendingUsernameState, type Platform, type SocialAction };
|
|
149
|
+
export { type AuthOptions, type AuthenticatedUser, type EventCallback, type EventType, FollowGate, FollowGateClient, type FollowGateConfig, FollowGateError, type LinkedInTargetType, type OpenOptions, type PendingUsernameState, type Platform, type SocialAction };
|
package/dist/index.js
CHANGED
|
@@ -21,10 +21,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
FollowGate: () => FollowGate,
|
|
24
|
-
FollowGateClient: () => FollowGateClient
|
|
24
|
+
FollowGateClient: () => FollowGateClient,
|
|
25
|
+
FollowGateError: () => FollowGateError
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
27
28
|
var DEFAULT_API_URL = "https://api.followgate.app";
|
|
29
|
+
var FollowGateError = class extends Error {
|
|
30
|
+
constructor(message, code, hint) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.hint = hint;
|
|
34
|
+
this.name = "FollowGateError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function isValidApiKeyFormat(apiKey) {
|
|
38
|
+
return /^fg_(live|test)_[a-zA-Z0-9_-]+$/.test(apiKey);
|
|
39
|
+
}
|
|
28
40
|
var FollowGateClient = class {
|
|
29
41
|
config = null;
|
|
30
42
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -33,8 +45,44 @@ var FollowGateClient = class {
|
|
|
33
45
|
pendingUsername = null;
|
|
34
46
|
/**
|
|
35
47
|
* Initialize the SDK
|
|
48
|
+
* @throws {FollowGateError} If configuration is invalid
|
|
36
49
|
*/
|
|
37
50
|
init(config) {
|
|
51
|
+
if (!config.appId || typeof config.appId !== "string") {
|
|
52
|
+
throw new FollowGateError(
|
|
53
|
+
"[FollowGate] Missing or invalid appId",
|
|
54
|
+
"INVALID_APP_ID",
|
|
55
|
+
"Get your App ID from https://followgate.app/dashboard. Make sure NEXT_PUBLIC_FOLLOWGATE_APP_ID is set in your environment."
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (config.appId.trim() === "" || config.appId === "undefined") {
|
|
59
|
+
throw new FollowGateError(
|
|
60
|
+
"[FollowGate] appId is empty or undefined",
|
|
61
|
+
"EMPTY_APP_ID",
|
|
62
|
+
"Your appId appears to be empty. This often happens when environment variables are not properly configured. Check that NEXT_PUBLIC_FOLLOWGATE_APP_ID is set and rebuild your application."
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (!config.apiKey || typeof config.apiKey !== "string") {
|
|
66
|
+
throw new FollowGateError(
|
|
67
|
+
"[FollowGate] Missing or invalid apiKey",
|
|
68
|
+
"INVALID_API_KEY",
|
|
69
|
+
"Get your API Key from https://followgate.app/dashboard. Make sure NEXT_PUBLIC_FOLLOWGATE_API_KEY is set in your environment."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (config.apiKey.trim() === "" || config.apiKey === "undefined") {
|
|
73
|
+
throw new FollowGateError(
|
|
74
|
+
"[FollowGate] apiKey is empty or undefined",
|
|
75
|
+
"EMPTY_API_KEY",
|
|
76
|
+
"Your apiKey appears to be empty. This often happens when environment variables are not properly configured at BUILD TIME (not runtime). Set NEXT_PUBLIC_FOLLOWGATE_API_KEY and REBUILD your application."
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (!isValidApiKeyFormat(config.apiKey)) {
|
|
80
|
+
throw new FollowGateError(
|
|
81
|
+
`[FollowGate] Invalid API key format: "${config.apiKey.substring(0, 10)}..."`,
|
|
82
|
+
"INVALID_API_KEY_FORMAT",
|
|
83
|
+
'API keys should start with "fg_live_" (production) or "fg_test_" (development). Get a valid key from https://followgate.app/dashboard'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
38
86
|
this.config = {
|
|
39
87
|
...config,
|
|
40
88
|
apiUrl: config.apiUrl || DEFAULT_API_URL
|
|
@@ -43,6 +91,10 @@ var FollowGateClient = class {
|
|
|
43
91
|
this.restoreSession();
|
|
44
92
|
if (config.debug) {
|
|
45
93
|
console.log("[FollowGate] Initialized with appId:", config.appId);
|
|
94
|
+
console.log(
|
|
95
|
+
"[FollowGate] API Key:",
|
|
96
|
+
config.apiKey.substring(0, 12) + "..."
|
|
97
|
+
);
|
|
46
98
|
if (this.currentUser) {
|
|
47
99
|
console.log("[FollowGate] Restored user:", this.currentUser.username);
|
|
48
100
|
}
|
|
@@ -380,5 +432,6 @@ var FollowGate = new FollowGateClient();
|
|
|
380
432
|
// Annotate the CommonJS export names for ESM import in node:
|
|
381
433
|
0 && (module.exports = {
|
|
382
434
|
FollowGate,
|
|
383
|
-
FollowGateClient
|
|
435
|
+
FollowGateClient,
|
|
436
|
+
FollowGateError
|
|
384
437
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var DEFAULT_API_URL = "https://api.followgate.app";
|
|
3
|
+
var FollowGateError = class extends Error {
|
|
4
|
+
constructor(message, code, hint) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.hint = hint;
|
|
8
|
+
this.name = "FollowGateError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
function isValidApiKeyFormat(apiKey) {
|
|
12
|
+
return /^fg_(live|test)_[a-zA-Z0-9_-]+$/.test(apiKey);
|
|
13
|
+
}
|
|
3
14
|
var FollowGateClient = class {
|
|
4
15
|
config = null;
|
|
5
16
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -8,8 +19,44 @@ var FollowGateClient = class {
|
|
|
8
19
|
pendingUsername = null;
|
|
9
20
|
/**
|
|
10
21
|
* Initialize the SDK
|
|
22
|
+
* @throws {FollowGateError} If configuration is invalid
|
|
11
23
|
*/
|
|
12
24
|
init(config) {
|
|
25
|
+
if (!config.appId || typeof config.appId !== "string") {
|
|
26
|
+
throw new FollowGateError(
|
|
27
|
+
"[FollowGate] Missing or invalid appId",
|
|
28
|
+
"INVALID_APP_ID",
|
|
29
|
+
"Get your App ID from https://followgate.app/dashboard. Make sure NEXT_PUBLIC_FOLLOWGATE_APP_ID is set in your environment."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (config.appId.trim() === "" || config.appId === "undefined") {
|
|
33
|
+
throw new FollowGateError(
|
|
34
|
+
"[FollowGate] appId is empty or undefined",
|
|
35
|
+
"EMPTY_APP_ID",
|
|
36
|
+
"Your appId appears to be empty. This often happens when environment variables are not properly configured. Check that NEXT_PUBLIC_FOLLOWGATE_APP_ID is set and rebuild your application."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (!config.apiKey || typeof config.apiKey !== "string") {
|
|
40
|
+
throw new FollowGateError(
|
|
41
|
+
"[FollowGate] Missing or invalid apiKey",
|
|
42
|
+
"INVALID_API_KEY",
|
|
43
|
+
"Get your API Key from https://followgate.app/dashboard. Make sure NEXT_PUBLIC_FOLLOWGATE_API_KEY is set in your environment."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (config.apiKey.trim() === "" || config.apiKey === "undefined") {
|
|
47
|
+
throw new FollowGateError(
|
|
48
|
+
"[FollowGate] apiKey is empty or undefined",
|
|
49
|
+
"EMPTY_API_KEY",
|
|
50
|
+
"Your apiKey appears to be empty. This often happens when environment variables are not properly configured at BUILD TIME (not runtime). Set NEXT_PUBLIC_FOLLOWGATE_API_KEY and REBUILD your application."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (!isValidApiKeyFormat(config.apiKey)) {
|
|
54
|
+
throw new FollowGateError(
|
|
55
|
+
`[FollowGate] Invalid API key format: "${config.apiKey.substring(0, 10)}..."`,
|
|
56
|
+
"INVALID_API_KEY_FORMAT",
|
|
57
|
+
'API keys should start with "fg_live_" (production) or "fg_test_" (development). Get a valid key from https://followgate.app/dashboard'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
13
60
|
this.config = {
|
|
14
61
|
...config,
|
|
15
62
|
apiUrl: config.apiUrl || DEFAULT_API_URL
|
|
@@ -18,6 +65,10 @@ var FollowGateClient = class {
|
|
|
18
65
|
this.restoreSession();
|
|
19
66
|
if (config.debug) {
|
|
20
67
|
console.log("[FollowGate] Initialized with appId:", config.appId);
|
|
68
|
+
console.log(
|
|
69
|
+
"[FollowGate] API Key:",
|
|
70
|
+
config.apiKey.substring(0, 12) + "..."
|
|
71
|
+
);
|
|
21
72
|
if (this.currentUser) {
|
|
22
73
|
console.log("[FollowGate] Restored user:", this.currentUser.username);
|
|
23
74
|
}
|
|
@@ -354,5 +405,6 @@ var FollowGateClient = class {
|
|
|
354
405
|
var FollowGate = new FollowGateClient();
|
|
355
406
|
export {
|
|
356
407
|
FollowGate,
|
|
357
|
-
FollowGateClient
|
|
408
|
+
FollowGateClient,
|
|
409
|
+
FollowGateError
|
|
358
410
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@followgate/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|