@forteplatforms/sdk 1.0.160 → 1.0.163

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,27 +10,48 @@ npm install @forteplatforms/sdk
10
10
 
11
11
  ## Authentication
12
12
 
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:
13
+ The SDK supports three auth modes depending on where it runs.
14
+
15
+ ### Inside a Forte-hosted service (no config)
16
+
17
+ `FORTE_API_TOKEN` is set automatically and scoped to the service's project:
14
18
 
15
19
  ```typescript
16
20
  const client = new ForteClient();
17
21
  ```
18
22
 
19
- Outside of Forte (local development, external hosting), pass the token explicitly:
23
+ ### Client-side (browser / mobile)
24
+
25
+ For calls to `client.users.*`, construct with no arguments. The browser sends the `Forte-User-Session-Token` cookie automatically after the user logs in. The SDK sets `credentials: 'include'` so the cookie reaches the API cross-origin.
20
26
 
21
27
  ```typescript
22
- const client = new ForteClient({ apiToken: 'your_api_token_here' });
28
+ const client = new ForteClient();
29
+ await client.users.renewSessionToken({ projectId });
23
30
  ```
24
31
 
25
- Or set it as an environment variable (Node.js only):
32
+ Do **not** pass `apiToken` from browser code — it's a server-side secret.
26
33
 
27
- ```bash
28
- export FORTE_API_TOKEN=your_api_token_here
34
+ ### Server-side BFF calling `client.users.*` (no token, per-call authorization)
35
+
36
+ In a BFF that proxies user-scoped calls, omit the token and forward each user's session token as the `authorization` parameter on each call:
37
+
38
+ ```typescript
39
+ const client = new ForteClient();
40
+ await client.users.renewSessionToken({
41
+ projectId,
42
+ authorization: `Bearer ${userSessionToken}`,
43
+ });
29
44
  ```
30
45
 
31
- You can generate an API token from the Forte Platforms dashboard.
46
+ ### External server-side calling `client.projects.*` (explicit token)
32
47
 
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.
48
+ ```typescript
49
+ const client = new ForteClient({ apiToken: 'your_api_token_here' });
50
+ ```
51
+
52
+ Or set `FORTE_API_TOKEN` in the environment (Node.js only) and call `new ForteClient()`.
53
+
54
+ You can generate an API token from the Forte Platforms dashboard.
34
55
 
35
56
  ## Quick Start
36
57
 
@@ -1125,6 +1125,7 @@ export declare const ListUserActionLogsActionTypeType: {
1125
1125
  readonly USER_HARD_DELETED: "USER_HARD_DELETED";
1126
1126
  readonly CONTACT_METHOD_ADDED: "CONTACT_METHOD_ADDED";
1127
1127
  readonly CONTACT_METHOD_REMOVED: "CONTACT_METHOD_REMOVED";
1128
+ readonly CONTACT_METHOD_DISPLACED: "CONTACT_METHOD_DISPLACED";
1128
1129
  readonly CONTACT_METHOD_VERIFICATION_CODE_SENT: "CONTACT_METHOD_VERIFICATION_CODE_SENT";
1129
1130
  readonly CONTACT_METHOD_VERIFICATION_CODE_RE_SENT: "CONTACT_METHOD_VERIFICATION_CODE_RE_SENT";
1130
1131
  readonly CONTACT_METHOD_VERIFIED: "CONTACT_METHOD_VERIFIED";
@@ -4569,6 +4569,7 @@ exports.ListUserActionLogsActionTypeType = {
4569
4569
  USER_HARD_DELETED: 'USER_HARD_DELETED',
4570
4570
  CONTACT_METHOD_ADDED: 'CONTACT_METHOD_ADDED',
4571
4571
  CONTACT_METHOD_REMOVED: 'CONTACT_METHOD_REMOVED',
4572
+ CONTACT_METHOD_DISPLACED: 'CONTACT_METHOD_DISPLACED',
4572
4573
  CONTACT_METHOD_VERIFICATION_CODE_SENT: 'CONTACT_METHOD_VERIFICATION_CODE_SENT',
4573
4574
  CONTACT_METHOD_VERIFICATION_CODE_RE_SENT: 'CONTACT_METHOD_VERIFICATION_CODE_RE_SENT',
4574
4575
  CONTACT_METHOD_VERIFIED: 'CONTACT_METHOD_VERIFIED',
@@ -64,6 +64,7 @@ export declare const UserActionLogObjectActionTypeType: {
64
64
  readonly USER_HARD_DELETED: "USER_HARD_DELETED";
65
65
  readonly CONTACT_METHOD_ADDED: "CONTACT_METHOD_ADDED";
66
66
  readonly CONTACT_METHOD_REMOVED: "CONTACT_METHOD_REMOVED";
67
+ readonly CONTACT_METHOD_DISPLACED: "CONTACT_METHOD_DISPLACED";
67
68
  readonly CONTACT_METHOD_VERIFICATION_CODE_SENT: "CONTACT_METHOD_VERIFICATION_CODE_SENT";
68
69
  readonly CONTACT_METHOD_VERIFICATION_CODE_RE_SENT: "CONTACT_METHOD_VERIFICATION_CODE_RE_SENT";
69
70
  readonly CONTACT_METHOD_VERIFIED: "CONTACT_METHOD_VERIFIED";
@@ -29,6 +29,7 @@ exports.UserActionLogObjectActionTypeType = {
29
29
  USER_HARD_DELETED: 'USER_HARD_DELETED',
30
30
  CONTACT_METHOD_ADDED: 'CONTACT_METHOD_ADDED',
31
31
  CONTACT_METHOD_REMOVED: 'CONTACT_METHOD_REMOVED',
32
+ CONTACT_METHOD_DISPLACED: 'CONTACT_METHOD_DISPLACED',
32
33
  CONTACT_METHOD_VERIFICATION_CODE_SENT: 'CONTACT_METHOD_VERIFICATION_CODE_SENT',
33
34
  CONTACT_METHOD_VERIFICATION_CODE_RE_SENT: 'CONTACT_METHOD_VERIFICATION_CODE_RE_SENT',
34
35
  CONTACT_METHOD_VERIFIED: 'CONTACT_METHOD_VERIFIED',
package/dist/index.js CHANGED
@@ -23,14 +23,20 @@ var ForteClient = /** @class */ (function () {
23
23
  function ForteClient(options) {
24
24
  if (options === void 0) { options = {}; }
25
25
  var _a, _b, _c;
26
- // Falls back to FORTE_API_TOKEN env var in Node.js; safe in browsers where process is undefined
26
+ // Falls back to FORTE_API_TOKEN env var in Node.js; safe in browsers where process is undefined.
27
+ // No token is OK: in browsers the Forte-User-Session-Token cookie authenticates users.*;
28
+ // in BFFs the caller passes `authorization` per-call to users.*.
27
29
  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);
28
- if (!token) {
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).');
30
+ var headers = {};
31
+ if (token) {
32
+ headers.Authorization = "Bearer ".concat(token);
30
33
  }
31
34
  var config = new runtime_1.Configuration({
32
35
  basePath: (_c = options.baseUrl) !== null && _c !== void 0 ? _c : 'https://api.forteplatforms.com',
33
- headers: { Authorization: "Bearer ".concat(token) },
36
+ headers: headers,
37
+ // Always include credentials so browsers send the Forte-User-Session-Token cookie
38
+ // cross-origin. No-op for Node.js fetch.
39
+ credentials: 'include',
34
40
  });
35
41
  this.projects = new ProjectsServerApi_1.ProjectsServerApi(config);
36
42
  this.users = new UsersServerApi_1.UsersServerApi(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forteplatforms/sdk",
3
- "version": "1.0.160",
3
+ "version": "1.0.163",
4
4
  "description": "Official TypeScript SDK for Forte Platforms",
5
5
  "author": "Forte Platforms <support@forteplatforms.com>",
6
6
  "repository": {