@coreiam/auth 1.0.392-beta.0 → 1.0.392-beta.2

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.
@@ -73,9 +73,14 @@ export declare class CoreIAM {
73
73
  * this instance's API key. Server-to-server, read-only.
74
74
  * THROWS on failure — an audit must never silently see an empty roster.
75
75
  */
76
- listIdentities(): Promise<{
76
+ listIdentities(params?: {
77
+ limit?: number;
78
+ offset?: number;
79
+ roles?: string[];
80
+ }): Promise<{
77
81
  users: DirectoryIdentity[];
78
82
  total: number;
83
+ next_offset?: number;
79
84
  }>;
80
85
  private readCookieHeader;
81
86
  private readSessionCookie;
@@ -72,14 +72,30 @@ class CoreIAM {
72
72
  * this instance's API key. Server-to-server, read-only.
73
73
  * THROWS on failure — an audit must never silently see an empty roster.
74
74
  */
75
- async listIdentities() {
76
- const response = await this.proxy('/api/v1/directory', { method: 'GET' }, new Headers());
75
+ async listIdentities(params) {
76
+ const search = new URLSearchParams();
77
+ if (params?.limit != null)
78
+ search.set('limit', String(params.limit));
79
+ if (params?.offset != null)
80
+ search.set('offset', String(params.offset));
81
+ if (params?.roles?.length)
82
+ search.set('roles', params.roles.join(','));
83
+ const qs = search.toString();
84
+ const response = await this.proxy(`/api/v1/directory${qs ? `?${qs}` : ''}`, { method: 'GET' }, new Headers());
77
85
  if (!response.ok) {
78
86
  const body = await response.text().catch(() => '');
79
87
  throw new Error(`listIdentities failed: ${response.status} ${body}`);
80
88
  }
81
- const data = await response.json();
82
- return { users: data.users ?? [], total: data.total ?? 0 };
89
+ const data = await response.json().catch(() => null);
90
+ if (!data || !Array.isArray(data.users)) {
91
+ throw new Error(`listIdentities: unexpected response shape — HTTP 200 without a users array. ` +
92
+ `This is not an empty directory; verify COREIAM_API_URL points at the CoreIAM gateway.`);
93
+ }
94
+ return {
95
+ users: data.users,
96
+ total: typeof data.total === 'number' ? data.total : data.users.length,
97
+ ...(typeof data.next_offset === 'number' ? { next_offset: data.next_offset } : {}),
98
+ };
83
99
  }
84
100
  readCookieHeader(input) {
85
101
  if (typeof input === 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreiam/auth",
3
- "version": "1.0.392-beta.0",
3
+ "version": "1.0.392-beta.2",
4
4
  "main": "./dist/core/index.js",
5
5
  "types": "./dist/core/index.d.ts",
6
6
  "exports": {