@unboundcx/sdk 4.13.146-security.2 → 4.13.146-security.4

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
@@ -159,6 +159,12 @@ await api.login.login('username', 'password');
159
159
  await api.login.logout();
160
160
  await api.login.validate();
161
161
  await api.login.changePassword('current', 'new');
162
+
163
+ // User sessions (refresh-token families) -- list/revoke your own, or an
164
+ // account admin acting on another user in the same account
165
+ await api.login.listSessions({ includeClosed: true });
166
+ await api.login.revokeSession(sessionId);
167
+ await api.login.revokeAllSessions({ keepCurrent: true });
162
168
  ```
163
169
 
164
170
  #### Objects (`api.objects`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.146-security.2",
3
+ "version": "4.13.146-security.4",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/services/login.js CHANGED
@@ -146,7 +146,7 @@ export class LoginService {
146
146
  body: { email },
147
147
  };
148
148
 
149
- const result = await internalRequest(this.sdk,
149
+ const result = await internalRequest(this.sdk,
150
150
  '/login/forgotPassword',
151
151
  'POST',
152
152
  options,
@@ -154,4 +154,78 @@ export class LoginService {
154
154
  );
155
155
  return result;
156
156
  }
157
+
158
+ /**
159
+ * User sessions (one row per refresh-token family). userId defaults to
160
+ * the caller; passing someone else's userId requires the caller to hold
161
+ * admin:user:manage AND that user to be in the caller's own account --
162
+ * the API 403s otherwise.
163
+ * @param {object} [params]
164
+ * @param {string} [params.userId] -- defaults to the caller
165
+ * @param {boolean} [params.includeClosed] -- also return closed
166
+ * (revoked/expired) sessions from the last 30 days
167
+ * @returns {Promise<{ sessions: Array<object> }>}
168
+ */
169
+ async listSessions({ userId, includeClosed } = {}) {
170
+ const query = {};
171
+ if (userId) query.userId = userId;
172
+ if (includeClosed) query.includeClosed = true;
173
+
174
+ const options = { query };
175
+ const result = await internalRequest(this.sdk,
176
+ '/login/sessions',
177
+ 'GET',
178
+ options,
179
+ );
180
+ return result;
181
+ }
182
+
183
+ /**
184
+ * Revoke a single session (refresh-token family) by id.
185
+ * @param {string} sessionId
186
+ * @param {object} [params]
187
+ * @param {string} [params.userId] -- defaults to the caller; same
188
+ * self-or-admin-same-account rule as listSessions
189
+ * @returns {Promise<{ revoked: boolean, id: string, current: boolean }>}
190
+ */
191
+ async revokeSession(sessionId, { userId } = {}) {
192
+ this.sdk.validateParams(
193
+ { sessionId },
194
+ {
195
+ sessionId: { type: 'string', required: true },
196
+ },
197
+ );
198
+
199
+ const options = {};
200
+ if (userId) options.body = { userId };
201
+
202
+ const result = await internalRequest(this.sdk,
203
+ `/login/sessions/${sessionId}`,
204
+ 'DELETE',
205
+ options,
206
+ );
207
+ return result;
208
+ }
209
+
210
+ /**
211
+ * Revoke every live session for a user.
212
+ * @param {object} [params]
213
+ * @param {string} [params.userId] -- defaults to the caller
214
+ * @param {boolean} [params.keepCurrent] -- when acting on your own
215
+ * sessions, leave the session you're calling from untouched
216
+ * @returns {Promise<{ revoked: number }>}
217
+ */
218
+ async revokeAllSessions({ userId, keepCurrent } = {}) {
219
+ const body = {};
220
+ if (userId) body.userId = userId;
221
+ if (keepCurrent) body.keepCurrent = true;
222
+
223
+ const options = { body };
224
+ const result = await internalRequest(this.sdk,
225
+ '/login/sessions/revoke-all',
226
+ 'POST',
227
+ options,
228
+ );
229
+ return result;
230
+ }
157
231
  }
@@ -302,6 +302,33 @@ export class PermissionsService {
302
302
  return result;
303
303
  }
304
304
 
305
+ /**
306
+ * Direct holders of a permission set — for the Setup -> Permission Sets
307
+ * Members panel. A user who only has the set via group membership is
308
+ * NOT included in `users` here; look up that group's `members` (from
309
+ * listGroups()) to show them nested under the group instead.
310
+ * @param {string} setId - Permission set ID
311
+ * @returns {Promise<Object>} { users: [{userId, name, email, grantType}], groups: [{groupId, name, grantType}] }
312
+ * @example
313
+ * const { users, groups } = await sdk.permissions.listSetAssignments('set-123');
314
+ */
315
+ async listSetAssignments(setId) {
316
+ setId = String(setId);
317
+ this.sdk.validateParams(
318
+ { setId },
319
+ {
320
+ setId: { type: 'string', required: true },
321
+ },
322
+ );
323
+
324
+ const result = await internalRequest(
325
+ this.sdk,
326
+ `/permissions/sets/${setId}/assignments`,
327
+ 'GET',
328
+ );
329
+ return result;
330
+ }
331
+
305
332
  /**
306
333
  * Assign a permission set to a principal (user or group)
307
334
  * @param {Object} assignment - Assignment configuration