@forteplatforms/sdk 1.0.13 → 1.0.20

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/README.md CHANGED
@@ -10,20 +10,28 @@ npm install @forteplatforms/sdk
10
10
 
11
11
  ## Authentication
12
12
 
13
- Set your API token as an environment variable:
13
+ When your code runs inside a Forte-hosted service, `FORTE_API_TOKEN` is set automatically and scoped to the service's project — no configuration needed:
14
14
 
15
- ```bash
16
- export FORTE_API_TOKEN=your_api_token_here
15
+ ```typescript
16
+ const client = new ForteClient();
17
17
  ```
18
18
 
19
- Or pass it directly when creating the client:
19
+ Outside of Forte (local development, external hosting), pass the token explicitly:
20
20
 
21
21
  ```typescript
22
22
  const client = new ForteClient({ apiToken: 'your_api_token_here' });
23
23
  ```
24
24
 
25
+ Or set it as an environment variable (Node.js only):
26
+
27
+ ```bash
28
+ export FORTE_API_TOKEN=your_api_token_here
29
+ ```
30
+
25
31
  You can generate an API token from the Forte Platforms dashboard.
26
32
 
33
+ > **Note:** The TypeScript SDK works in both Node.js and browser/React environments. In browsers, you must pass `apiToken` directly since environment variables are not available.
34
+
27
35
  ## Quick Start
28
36
 
29
37
  ```typescript
@@ -38,14 +46,6 @@ const projects = await client.projects.listProjects();
38
46
  const project = await client.projects.getProject({ projectId: 'your-project-id' });
39
47
  ```
40
48
 
41
- ## Custom Base URL
42
-
43
- ```typescript
44
- const client = new ForteClient({
45
- baseUrl: 'https://custom-endpoint.example.com',
46
- });
47
- ```
48
-
49
49
  ## Error Handling
50
50
 
51
51
  API errors are thrown as exceptions with HTTP status information:
@@ -27,6 +27,7 @@ export interface GoogleAuthLoginCallbackRequest {
27
27
  gCsrfToken: string;
28
28
  gCsrfToken2: string;
29
29
  credential: string;
30
+ recaptchaToken?: string;
30
31
  }
31
32
  export interface LogoutRequest {
32
33
  projectId: string;
@@ -253,6 +253,9 @@ var UsersServerApi = /** @class */ (function (_super) {
253
253
  if (requestParameters['credential'] != null) {
254
254
  formParams.append('credential', requestParameters['credential']);
255
255
  }
256
+ if (requestParameters['recaptchaToken'] != null) {
257
+ formParams.append('recaptcha_token', requestParameters['recaptchaToken']);
258
+ }
256
259
  urlPath = "/api/v1/{projectId}/users/google-auth-callback";
257
260
  urlPath = urlPath.replace("{".concat("projectId", "}"), encodeURIComponent(String(requestParameters['projectId'])));
258
261
  return [4 /*yield*/, this.request({
@@ -76,6 +76,12 @@ export interface ProjectObject {
76
76
  * @memberof ProjectObject
77
77
  */
78
78
  googleOAuthClientId?: string;
79
+ /**
80
+ *
81
+ * @type {boolean}
82
+ * @memberof ProjectObject
83
+ */
84
+ hasRecaptchaSecretKey?: boolean;
79
85
  }
80
86
  /**
81
87
  * Check if a given object implements the ProjectObject interface.
@@ -53,6 +53,7 @@ function ProjectObjectFromJSONTyped(json, ignoreDiscriminator) {
53
53
  'ecrRepositoryUri': json['ecrRepositoryUri'] == null ? undefined : json['ecrRepositoryUri'],
54
54
  'cachedUserCount': json['cachedUserCount'] == null ? undefined : json['cachedUserCount'],
55
55
  'googleOAuthClientId': json['googleOAuthClientId'] == null ? undefined : json['googleOAuthClientId'],
56
+ 'hasRecaptchaSecretKey': json['hasRecaptchaSecretKey'] == null ? undefined : json['hasRecaptchaSecretKey'],
56
57
  };
57
58
  }
58
59
  function ProjectObjectToJSON(json) {
@@ -74,5 +75,6 @@ function ProjectObjectToJSONTyped(value, ignoreDiscriminator) {
74
75
  'ecrRepositoryUri': value['ecrRepositoryUri'],
75
76
  'cachedUserCount': value['cachedUserCount'],
76
77
  'googleOAuthClientId': value['googleOAuthClientId'],
78
+ 'hasRecaptchaSecretKey': value['hasRecaptchaSecretKey'],
77
79
  };
78
80
  }
@@ -41,6 +41,12 @@ export interface RegisterUserRequest {
41
41
  customMetadataAttributes?: {
42
42
  [key: string]: any;
43
43
  };
44
+ /**
45
+ *
46
+ * @type {string}
47
+ * @memberof RegisterUserRequest
48
+ */
49
+ recaptchaToken?: string;
44
50
  }
45
51
  /**
46
52
  * Check if a given object implements the RegisterUserRequest interface.
@@ -36,6 +36,7 @@ function RegisterUserRequestFromJSONTyped(json, ignoreDiscriminator) {
36
36
  'email': json['email'] == null ? undefined : json['email'],
37
37
  'phoneNumber': json['phoneNumber'] == null ? undefined : json['phoneNumber'],
38
38
  'customMetadataAttributes': json['customMetadataAttributes'] == null ? undefined : json['customMetadataAttributes'],
39
+ 'recaptchaToken': json['recaptchaToken'] == null ? undefined : json['recaptchaToken'],
39
40
  };
40
41
  }
41
42
  function RegisterUserRequestToJSON(json) {
@@ -51,5 +52,6 @@ function RegisterUserRequestToJSONTyped(value, ignoreDiscriminator) {
51
52
  'email': value['email'],
52
53
  'phoneNumber': value['phoneNumber'],
53
54
  'customMetadataAttributes': value['customMetadataAttributes'],
55
+ 'recaptchaToken': value['recaptchaToken'],
54
56
  };
55
57
  }
@@ -21,6 +21,12 @@ export interface UpdateProjectRequest {
21
21
  * @memberof UpdateProjectRequest
22
22
  */
23
23
  googleOAuthClientId?: string;
24
+ /**
25
+ *
26
+ * @type {string}
27
+ * @memberof UpdateProjectRequest
28
+ */
29
+ recaptchaSecretKey?: string;
24
30
  }
25
31
  /**
26
32
  * Check if a given object implements the UpdateProjectRequest interface.
@@ -33,6 +33,7 @@ function UpdateProjectRequestFromJSONTyped(json, ignoreDiscriminator) {
33
33
  }
34
34
  return {
35
35
  'googleOAuthClientId': json['googleOAuthClientId'] == null ? undefined : json['googleOAuthClientId'],
36
+ 'recaptchaSecretKey': json['recaptchaSecretKey'] == null ? undefined : json['recaptchaSecretKey'],
36
37
  };
37
38
  }
38
39
  function UpdateProjectRequestToJSON(json) {
@@ -45,5 +46,6 @@ function UpdateProjectRequestToJSONTyped(value, ignoreDiscriminator) {
45
46
  }
46
47
  return {
47
48
  'googleOAuthClientId': value['googleOAuthClientId'],
49
+ 'recaptchaSecretKey': value['recaptchaSecretKey'],
48
50
  };
49
51
  }
package/dist/index.js CHANGED
@@ -22,13 +22,14 @@ __exportStar(require("./generated/models"), exports);
22
22
  var ForteClient = /** @class */ (function () {
23
23
  function ForteClient(options) {
24
24
  if (options === void 0) { options = {}; }
25
- var _a, _b;
26
- var token = (_a = options.apiToken) !== null && _a !== void 0 ? _a : process.env.FORTE_API_TOKEN;
25
+ var _a, _b, _c;
26
+ // Falls back to FORTE_API_TOKEN env var in Node.js; safe in browsers where process is undefined
27
+ var token = (_a = options.apiToken) !== null && _a !== void 0 ? _a : (typeof process !== 'undefined' ? (_b = process.env) === null || _b === void 0 ? void 0 : _b.FORTE_API_TOKEN : undefined);
27
28
  if (!token) {
28
- throw new Error('FORTE_API_TOKEN is required. Set it as an environment variable or pass apiToken option.');
29
+ throw new Error('API token is required. Pass apiToken in the constructor options, or set the FORTE_API_TOKEN environment variable (Node.js only).');
29
30
  }
30
31
  var config = new runtime_1.Configuration({
31
- basePath: (_b = options.baseUrl) !== null && _b !== void 0 ? _b : 'https://api.forteplatforms.com',
32
+ basePath: (_c = options.baseUrl) !== null && _c !== void 0 ? _c : 'https://api.forteplatforms.com',
32
33
  headers: { Authorization: "Bearer ".concat(token) },
33
34
  });
34
35
  this.projects = new ProjectsServerApi_1.ProjectsServerApi(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forteplatforms/sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.20",
4
4
  "description": "Official TypeScript SDK for Forte Platforms",
5
5
  "author": "Forte Platforms <support@forteplatforms.com>",
6
6
  "repository": {