@scalekit-sdk/node 2.1.7 → 2.1.8
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/buf.gen.yaml +1 -0
- package/lib/auth.d.ts +41 -9
- package/lib/auth.js +44 -12
- package/lib/auth.js.map +1 -1
- package/lib/connection.d.ts +195 -21
- package/lib/connection.js +197 -23
- package/lib/connection.js.map +1 -1
- package/lib/core.d.ts +2 -2
- package/lib/core.js +13 -12
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +293 -40
- package/lib/directory.js +308 -44
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +166 -18
- package/lib/domain.js +178 -29
- package/lib/domain.js.map +1 -1
- package/lib/organization.d.ts +404 -44
- package/lib/organization.js +419 -54
- package/lib/organization.js.map +1 -1
- package/lib/permission.d.ts +179 -35
- package/lib/permission.js +190 -38
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +252 -56
- package/lib/role.js +262 -62
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +323 -54
- package/lib/scalekit.js +354 -76
- package/lib/scalekit.js.map +1 -1
- package/lib/session.d.ts +235 -22
- package/lib/session.js +237 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +571 -53
- package/lib/user.js +598 -89
- package/lib/user.js.map +1 -1
- package/lib/webauthn.d.ts +33 -0
- package/lib/webauthn.js +80 -0
- package/lib/webauthn.js.map +1 -0
- package/package.json +2 -2
- package/src/auth.ts +53 -19
- package/src/connection.ts +237 -62
- package/src/core.ts +39 -33
- package/src/directory.ts +356 -98
- package/src/domain.ts +215 -68
- package/src/organization.ts +490 -112
- package/src/permission.ts +234 -88
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
- package/src/role.ts +336 -136
- package/src/scalekit.ts +478 -149
- package/src/session.ts +266 -63
- package/src/user.ts +675 -168
- package/src/webauthn.ts +98 -0
package/lib/directory.js
CHANGED
|
@@ -11,6 +11,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const protobuf_1 = require("@bufbuild/protobuf");
|
|
13
13
|
const directories_connect_1 = require("./pkg/grpc/scalekit/v1/directories/directories_connect");
|
|
14
|
+
/**
|
|
15
|
+
* Client for managing SCIM directory synchronization.
|
|
16
|
+
*
|
|
17
|
+
* Directories represent SCIM connections that automatically sync users and groups from an
|
|
18
|
+
* organization's identity provider (Okta, Azure AD, Google Workspace, etc.) to your application.
|
|
19
|
+
* Use this client to retrieve synchronized user/group data, manage directory settings, and
|
|
20
|
+
* monitor sync status.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
|
|
24
|
+
* const directoryClient = scalekitClient.directory;
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | Directory API Documentation}
|
|
27
|
+
* @see {@link https://docs.scalekit.com/directory/scim/quickstart/ | SCIM Directory Sync Guide}
|
|
28
|
+
*/
|
|
14
29
|
class DirectoryClient {
|
|
15
30
|
constructor(grpcConncet, coreClient) {
|
|
16
31
|
this.grpcConncet = grpcConncet;
|
|
@@ -18,58 +33,203 @@ class DirectoryClient {
|
|
|
18
33
|
this.client = this.grpcConncet.createClient(directories_connect_1.DirectoryService);
|
|
19
34
|
}
|
|
20
35
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
36
|
+
* Retrieves all SCIM directories configured for an organization.
|
|
37
|
+
*
|
|
38
|
+
* Lists all directory sync connections that have been set up for the organization. Each directory
|
|
39
|
+
* represents a SCIM integration with an identity provider (Okta, Azure AD, Google Workspace, etc.)
|
|
40
|
+
* that automatically syncs users and groups. Use this to view directory configurations, check sync
|
|
41
|
+
* status, and manage directory integrations.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} organizationId - The organization ID to list directories for (format: "org_...")
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<ListDirectoriesResponse>} Response containing:
|
|
46
|
+
* - directories: Array of directory objects with:
|
|
47
|
+
* - id: Unique directory identifier
|
|
48
|
+
* - organizationId: Parent organization ID
|
|
49
|
+
* - provider: Identity provider name (e.g., "okta", "azure_ad", "google")
|
|
50
|
+
* - enabled: Whether directory sync is active
|
|
51
|
+
* - status: Current synchronization status
|
|
52
|
+
* - lastSyncTime: When the last sync occurred
|
|
53
|
+
* - userCount: Number of synced users
|
|
54
|
+
* - groupCount: Number of synced groups
|
|
55
|
+
*
|
|
56
|
+
* @throws {Error} If the organization is not found
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // List all directories for an organization
|
|
60
|
+
* const response = await scalekitClient.directory.listDirectories('org_123456');
|
|
61
|
+
*
|
|
62
|
+
* console.log(`Found ${response.directories.length} directories`);
|
|
63
|
+
* response.directories.forEach(dir => {
|
|
64
|
+
* console.log(`- ${dir.provider}: ${dir.enabled ? 'Active' : 'Inactive'}`);
|
|
65
|
+
* console.log(` Users: ${dir.userCount}, Groups: ${dir.groupCount}`);
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Check if organization has any active directories
|
|
70
|
+
* const response = await scalekitClient.directory.listDirectories('org_123456');
|
|
71
|
+
* const hasActiveDirectory = response.directories.some(dir => dir.enabled);
|
|
72
|
+
*
|
|
73
|
+
* if (hasActiveDirectory) {
|
|
74
|
+
* console.log('Directory sync is enabled for this organization');
|
|
75
|
+
* } else {
|
|
76
|
+
* console.log('No active directory sync');
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | List Directories API}
|
|
81
|
+
* @see {@link getDirectory} - Get details of a specific directory
|
|
82
|
+
* @see {@link enableDirectory} - Enable directory sync
|
|
83
|
+
* @see {@link disableDirectory} - Disable directory sync
|
|
24
84
|
*/
|
|
25
85
|
listDirectories(organizationId) {
|
|
26
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return this.coreClient.connectExec(this.client.listDirectories, {
|
|
87
|
+
return this.coreClient.connectExec(this.client.listDirectories, {
|
|
88
|
+
organizationId,
|
|
89
|
+
});
|
|
28
90
|
});
|
|
29
91
|
}
|
|
30
92
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
93
|
+
* Retrieves comprehensive details about a specific SCIM directory.
|
|
94
|
+
*
|
|
95
|
+
* Fetches complete configuration and status information for a directory, including provider settings,
|
|
96
|
+
* synchronization status, user/group counts, and metadata. Use this to view directory configuration,
|
|
97
|
+
* monitor sync health, verify setup, or display directory details in admin interfaces.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} organizationId - The organization ID that owns the directory (format: "org_...")
|
|
100
|
+
* @param {string} directoryId - The directory identifier to retrieve (format: "dir_...")
|
|
101
|
+
*
|
|
102
|
+
* @returns {Promise<GetDirectoryResponse>} Response containing:
|
|
103
|
+
* - directory: Complete directory object with:
|
|
104
|
+
* - id: Unique directory identifier
|
|
105
|
+
* - organizationId: Parent organization ID
|
|
106
|
+
* - provider: Identity provider name (e.g., "okta", "azure_ad", "google")
|
|
107
|
+
* - enabled: Whether directory sync is active
|
|
108
|
+
* - status: Current synchronization status
|
|
109
|
+
* - scimBaseUrl: SCIM endpoint URL
|
|
110
|
+
* - scimToken: Authentication token (masked)
|
|
111
|
+
* - lastSyncTime: Timestamp of last successful sync
|
|
112
|
+
* - nextSyncTime: Scheduled time for next sync
|
|
113
|
+
* - userCount: Number of synced users
|
|
114
|
+
* - groupCount: Number of synced groups
|
|
115
|
+
* - createTime: When directory was created
|
|
116
|
+
* - updateTime: When directory was last updated
|
|
117
|
+
*
|
|
118
|
+
* @throws {Error} If the organization or directory is not found
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Get directory details
|
|
122
|
+
* const response = await scalekitClient.directory.getDirectory(
|
|
123
|
+
* 'org_123456',
|
|
124
|
+
* 'dir_abc123'
|
|
125
|
+
* );
|
|
126
|
+
*
|
|
127
|
+
* const dir = response.directory;
|
|
128
|
+
* console.log('Provider:', dir.provider);
|
|
129
|
+
* console.log('Status:', dir.enabled ? 'Active' : 'Inactive');
|
|
130
|
+
* console.log('Last sync:', dir.lastSyncTime);
|
|
131
|
+
* console.log('Users:', dir.userCount);
|
|
132
|
+
* console.log('Groups:', dir.groupCount);
|
|
133
|
+
*
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | Get Directory API}
|
|
136
|
+
* @see {@link getPrimaryDirectoryByOrganizationId} - List the first directory in an Organization.
|
|
137
|
+
* - Useful utility API if you don't know the directory ID but only have an organizationID.
|
|
138
|
+
* @see {@link listDirectoryUsers} - List users in this directory
|
|
139
|
+
* @see {@link listDirectoryGroups} - List groups in this directory
|
|
35
140
|
*/
|
|
36
141
|
getDirectory(organizationId, directoryId) {
|
|
37
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return this.coreClient.connectExec(this.client.getDirectory, {
|
|
143
|
+
return this.coreClient.connectExec(this.client.getDirectory, {
|
|
144
|
+
organizationId,
|
|
145
|
+
id: directoryId,
|
|
146
|
+
});
|
|
39
147
|
});
|
|
40
148
|
}
|
|
41
149
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
150
|
+
* Retrieves the primary (first) directory for an organization.
|
|
151
|
+
*
|
|
152
|
+
* This is a convenience method that fetches the first directory from the organization's list
|
|
153
|
+
* of directories. Most organizations have a single directory, making this useful for quickly
|
|
154
|
+
* accessing directory data without needing to know the specific directory ID. If the organization
|
|
155
|
+
* has multiple directories, this returns the first one.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} organizationId - The organization ID to get the primary directory for (format: "org_...")
|
|
158
|
+
*
|
|
159
|
+
* @returns {Promise<Directory>} The first directory object for the organization
|
|
160
|
+
*
|
|
161
|
+
* @throws {Error} When the organization has no directories configured
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // Get primary directory for an organization
|
|
165
|
+
* try {
|
|
166
|
+
* const directory = await scalekitClient.directory.getPrimaryDirectoryByOrganizationId('org_123456');
|
|
167
|
+
*
|
|
168
|
+
* console.log('Primary Directory:', directory.provider);
|
|
169
|
+
* console.log('Users:', directory.userCount);
|
|
170
|
+
* console.log('Groups:', directory.groupCount);
|
|
171
|
+
* } catch (error) {
|
|
172
|
+
* console.log('No directory configured for this organization');
|
|
173
|
+
* }
|
|
174
|
+
*
|
|
175
|
+
*
|
|
176
|
+
* @see {@link listDirectories} - List all directories for an organization
|
|
177
|
+
* @see {@link getDirectory} - Get a specific directory by ID
|
|
178
|
+
* @see {@link listDirectoryUsers} - List users in the directory
|
|
45
179
|
*/
|
|
46
180
|
getPrimaryDirectoryByOrganizationId(organizationId) {
|
|
47
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
182
|
const directories = yield this.listDirectories(organizationId);
|
|
49
183
|
if (!directories || directories.directories.length === 0) {
|
|
50
|
-
return Promise.reject(
|
|
184
|
+
return Promise.reject("directory does not exist for organization");
|
|
51
185
|
}
|
|
52
186
|
return directories.directories[0];
|
|
53
187
|
});
|
|
54
188
|
}
|
|
55
189
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {string}
|
|
64
|
-
* @param {
|
|
65
|
-
* @
|
|
190
|
+
* Lists users synchronized from an identity provider via SCIM directory sync.
|
|
191
|
+
*
|
|
192
|
+
* Retrieves all users that have been synced from the organization's IdP to your application.
|
|
193
|
+
* This includes user profile information, group memberships, and sync status. Use this to
|
|
194
|
+
* display organization users, implement user search, or track provisioning/deprovisioning.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} organizationId - The organization ID
|
|
197
|
+
* @param {string} directoryId - The directory ID
|
|
198
|
+
* @param {object} [options] - Optional filtering and pagination parameters
|
|
199
|
+
* @param {number} [options.pageSize] - Number of users per page (max: 100)
|
|
200
|
+
* @param {string} [options.pageToken] - Token for next page from previous response
|
|
201
|
+
* @param {boolean} [options.includeDetail] - Include full user profile details
|
|
202
|
+
* @param {string} [options.directoryGroupId] - Filter users by group membership
|
|
203
|
+
* @param {string} [options.updatedAfter] - ISO 8601 timestamp to fetch only users updated after this time
|
|
204
|
+
*
|
|
205
|
+
* @returns {Promise<ListDirectoryUsersResponse>} Response containing:
|
|
206
|
+
* - users: Array of directory user objects with profiles and attributes
|
|
207
|
+
* - nextPageToken: Token for retrieving the next page
|
|
208
|
+
* - totalSize: Total number of users in the directory
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* // List all directory users with pagination
|
|
212
|
+
* const response = await scalekitClient.directory.listDirectoryUsers(
|
|
213
|
+
* 'org_123456',
|
|
214
|
+
* 'dir_abc123',
|
|
215
|
+
* { pageSize: 50 }
|
|
216
|
+
* );
|
|
217
|
+
*
|
|
218
|
+
* console.log(`Found ${response.totalSize} users`);
|
|
219
|
+
* response.users.forEach(user => {
|
|
220
|
+
* console.log(`- ${user.email} (${user.firstName} ${user.lastName})`);
|
|
221
|
+
* });
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | List Directory Users API}
|
|
224
|
+
* @see {@link listDirectoryGroups} - List directory groups
|
|
225
|
+
* @see {@link listDirectories} - List all directories for an organization
|
|
66
226
|
*/
|
|
67
227
|
listDirectoryUsers(organizationId, directoryId, options) {
|
|
68
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
229
|
let requestOptions = {};
|
|
70
230
|
if (options) {
|
|
71
231
|
requestOptions = Object.assign(Object.assign({}, options), (options.updatedAfter && {
|
|
72
|
-
updatedAfter: protobuf_1.Timestamp.fromDate(new Date(options.updatedAfter))
|
|
232
|
+
updatedAfter: protobuf_1.Timestamp.fromDate(new Date(options.updatedAfter)),
|
|
73
233
|
}));
|
|
74
234
|
}
|
|
75
235
|
return this.coreClient.connectExec(this.client.listDirectoryUsers, Object.assign({ organizationId,
|
|
@@ -77,22 +237,68 @@ class DirectoryClient {
|
|
|
77
237
|
});
|
|
78
238
|
}
|
|
79
239
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @param {string}
|
|
88
|
-
* @
|
|
240
|
+
* Retrieves groups synchronized from an identity provider via SCIM directory sync.
|
|
241
|
+
*
|
|
242
|
+
* Fetches all groups that have been synced from the organization's IdP to your application.
|
|
243
|
+
* Groups typically represent teams, departments, or organizational units. Use this to display
|
|
244
|
+
* group hierarchies, implement group-based access control, manage group memberships, or track
|
|
245
|
+
* organizational structure changes.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
248
|
+
* @param {string} directoryId - The directory ID (format: "dir_...")
|
|
249
|
+
* @param {object} [options] - Optional filtering and pagination parameters
|
|
250
|
+
* @param {number} [options.pageSize] - Number of groups per page (max: 30, default: 10)
|
|
251
|
+
* @param {string} [options.pageToken] - Token for next page from previous response
|
|
252
|
+
* @param {boolean} [options.includeDetail] - Include full group details and member lists
|
|
253
|
+
* @param {string} [options.updatedAfter] - ISO 8601 timestamp to fetch only groups updated after this time
|
|
254
|
+
*
|
|
255
|
+
* @returns {Promise<ListDirectoryGroupsResponse>} Response containing:
|
|
256
|
+
* - groups: Array of directory group objects with:
|
|
257
|
+
* - id: Group identifier
|
|
258
|
+
* - displayName: Group name
|
|
259
|
+
* - description: Group description
|
|
260
|
+
* - members: Array of member user IDs (when includeDetail is true)
|
|
261
|
+
* - attributes: Custom group attributes
|
|
262
|
+
* - updateTime: When the group was last updated
|
|
263
|
+
* - nextPageToken: Token for retrieving the next page
|
|
264
|
+
* - totalSize: Total number of groups in the directory
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // List all directory groups with pagination
|
|
268
|
+
* const response = await scalekitClient.directory.listDirectoryGroups(
|
|
269
|
+
* 'org_123456',
|
|
270
|
+
* 'dir_abc123',
|
|
271
|
+
* { pageSize: 30 }
|
|
272
|
+
* );
|
|
273
|
+
*
|
|
274
|
+
* console.log(`Found ${response.totalSize} groups`);
|
|
275
|
+
* response.groups.forEach(group => {
|
|
276
|
+
* console.log(`- ${group.displayName}`);
|
|
277
|
+
* if (group.description) console.log(` ${group.description}`);
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* // Get groups with full member details
|
|
282
|
+
* const response = await scalekitClient.directory.listDirectoryGroups(
|
|
283
|
+
* 'org_123456',
|
|
284
|
+
* 'dir_abc123',
|
|
285
|
+
* { includeDetail: true }
|
|
286
|
+
* );
|
|
287
|
+
*
|
|
288
|
+
* response.groups.forEach(group => {
|
|
289
|
+
* console.log(`${group.displayName}: ${group.members?.length || 0} members`);
|
|
290
|
+
* });
|
|
291
|
+
*
|
|
292
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | List Directory Groups API}
|
|
293
|
+
* @see {@link listDirectoryUsers} - List directory users
|
|
294
|
+
* @see {@link getDirectory} - Get directory details
|
|
89
295
|
*/
|
|
90
296
|
listDirectoryGroups(organizationId, directoryId, options) {
|
|
91
297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
298
|
let requestOptions = {};
|
|
93
299
|
if (options) {
|
|
94
300
|
requestOptions = Object.assign(Object.assign({}, options), (options.updatedAfter && {
|
|
95
|
-
updatedAfter: protobuf_1.Timestamp.fromDate(new Date(options.updatedAfter))
|
|
301
|
+
updatedAfter: protobuf_1.Timestamp.fromDate(new Date(options.updatedAfter)),
|
|
96
302
|
}));
|
|
97
303
|
}
|
|
98
304
|
return this.coreClient.connectExec(this.client.listDirectoryGroups, Object.assign({ organizationId,
|
|
@@ -100,25 +306,83 @@ class DirectoryClient {
|
|
|
100
306
|
});
|
|
101
307
|
}
|
|
102
308
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
309
|
+
* Enables SCIM directory synchronization for an organization.
|
|
310
|
+
*
|
|
311
|
+
* Activates automatic user and group synchronization from the organization's identity provider.
|
|
312
|
+
* Once enabled, users and groups from the IdP will be synced to your application, and any changes
|
|
313
|
+
* in the IdP (additions, updates, deletions) will be automatically reflected. This is essential
|
|
314
|
+
* for implementing automated user provisioning and deprovisioning.
|
|
315
|
+
*
|
|
316
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
317
|
+
* @param {string} directoryId - The directory ID to enable (format: "dir_...")
|
|
318
|
+
*
|
|
319
|
+
* @returns {Promise<ToggleDirectoryResponse>} Response containing:
|
|
320
|
+
* - directory: The updated directory object with enabled status set to true
|
|
321
|
+
*
|
|
322
|
+
* @throws {Error} If the organization or directory is not found
|
|
323
|
+
* @throws {Error} If the directory configuration is incomplete or invalid
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* // Enable directory sync
|
|
327
|
+
* const response = await scalekitClient.directory.enableDirectory(
|
|
328
|
+
* 'org_123456',
|
|
329
|
+
* 'dir_abc123'
|
|
330
|
+
* );
|
|
331
|
+
*
|
|
332
|
+
* console.log('Directory enabled:', response.directory.enabled); // true
|
|
333
|
+
* console.log('Sync will start automatically');
|
|
334
|
+
*
|
|
335
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | Enable Directory API}
|
|
336
|
+
* @see {@link disableDirectory} - Disable directory sync
|
|
337
|
+
* @see {@link getDirectory} - Check directory status
|
|
338
|
+
* @see {@link listDirectoryUsers} - View synced users after enabling
|
|
107
339
|
*/
|
|
108
340
|
enableDirectory(organizationId, directoryId) {
|
|
109
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
return this.coreClient.connectExec(this.client.enableDirectory, {
|
|
342
|
+
return this.coreClient.connectExec(this.client.enableDirectory, {
|
|
343
|
+
organizationId,
|
|
344
|
+
id: directoryId,
|
|
345
|
+
});
|
|
111
346
|
});
|
|
112
347
|
}
|
|
113
348
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
349
|
+
* Disables SCIM directory synchronization for an organization.
|
|
350
|
+
*
|
|
351
|
+
* Stops automatic user and group synchronization from the organization's identity provider.
|
|
352
|
+
* When disabled, no new updates will be received from the IdP, but existing synced users and
|
|
353
|
+
* groups remain in your application. This is useful for temporarily pausing sync during maintenance,
|
|
354
|
+
* troubleshooting, or when migrating to a different directory provider. Does not delete existing data.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
357
|
+
* @param {string} directoryId - The directory ID to disable (format: "dir_...")
|
|
358
|
+
*
|
|
359
|
+
* @returns {Promise<ToggleDirectoryResponse>} Response containing:
|
|
360
|
+
* - directory: The updated directory object with enabled status set to false
|
|
361
|
+
*
|
|
362
|
+
* @throws {Error} If the organization or directory is not found
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* // Disable directory sync
|
|
366
|
+
* const response = await scalekitClient.directory.disableDirectory(
|
|
367
|
+
* 'org_123456',
|
|
368
|
+
* 'dir_abc123'
|
|
369
|
+
* );
|
|
370
|
+
*
|
|
371
|
+
* console.log('Directory disabled:', !response.directory.enabled); // true
|
|
372
|
+
* console.log('Existing users and groups are preserved');
|
|
373
|
+
*
|
|
374
|
+
*
|
|
375
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/directory | Disable Directory API}
|
|
376
|
+
* @see {@link enableDirectory} - Enable directory sync
|
|
377
|
+
* @see {@link getDirectory} - Check directory status
|
|
378
|
+
* @see {@link listDirectories} - List all directories
|
|
118
379
|
*/
|
|
119
380
|
disableDirectory(organizationId, directoryId) {
|
|
120
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
return this.coreClient.connectExec(this.client.disableDirectory, {
|
|
382
|
+
return this.coreClient.connectExec(this.client.disableDirectory, {
|
|
383
|
+
organizationId,
|
|
384
|
+
id: directoryId,
|
|
385
|
+
});
|
|
122
386
|
});
|
|
123
387
|
}
|
|
124
388
|
}
|
package/lib/directory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAA+C;AAI/C,gGAA0F;AAU1F,MAAqB,eAAe;IAElC,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,sCAAgB,CAAC,CAAC;IAChE,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"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"}
|
package/lib/domain.d.ts
CHANGED
|
@@ -1,35 +1,183 @@
|
|
|
1
|
-
import GrpcConnect from
|
|
2
|
-
import CoreClient from
|
|
3
|
-
import { CreateDomainResponse, GetDomainResponse, ListDomainResponse, DomainType } from
|
|
4
|
-
import { Empty } from
|
|
1
|
+
import GrpcConnect from "./connect";
|
|
2
|
+
import CoreClient from "./core";
|
|
3
|
+
import { CreateDomainResponse, GetDomainResponse, ListDomainResponse, DomainType } from "./pkg/grpc/scalekit/v1/domains/domains_pb";
|
|
4
|
+
import { Empty } from "@bufbuild/protobuf";
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing domains for organizations.
|
|
7
|
+
*
|
|
8
|
+
* Domains enable automatic organization identification during SSO flows based on user email addresses.
|
|
9
|
+
* You can configure domains as ORGANIZATION_DOMAIN (for SSO routing) or ALLOWED_EMAIL_DOMAIN
|
|
10
|
+
* (for restricting which email domains can automatically join an organization).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
|
|
14
|
+
* const domainClient = scalekitClient.domain;
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/domains | Domain API Documentation}
|
|
17
|
+
*/
|
|
5
18
|
export default class DomainClient {
|
|
6
19
|
private readonly grpcConncet;
|
|
7
20
|
private readonly coreClient;
|
|
8
21
|
private client;
|
|
9
22
|
constructor(grpcConncet: GrpcConnect, coreClient: CoreClient);
|
|
10
23
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
24
|
+
* Adds a new domain configuration to an organization for SSO routing or user suggestions.
|
|
25
|
+
*
|
|
26
|
+
* Domains serve two purposes based on their type:
|
|
27
|
+
* - **ORGANIZATION_DOMAIN**: Used to identify the SSO connection for the organization. When users
|
|
28
|
+
* authenticate with email addresses from this domain, they're automatically routed to the
|
|
29
|
+
* organization's SSO provider.
|
|
30
|
+
* - **ALLOWED_EMAIL_DOMAIN**: Enables users to join the organization with automatic suggestions
|
|
31
|
+
* in the organization switcher during signup/login.
|
|
32
|
+
*
|
|
33
|
+
* Note: Public disposable domains (gmail.com, outlook.com, etc.) are automatically blocked for security.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
36
|
+
* @param {string} name - The domain name (e.g., "acme.com", "example.org")
|
|
37
|
+
* @param {object} [options] - Optional domain configuration
|
|
38
|
+
* @param {DomainType | string} [options.domainType] - Domain type: 'ALLOWED_EMAIL_DOMAIN' or 'ORGANIZATION_DOMAIN'
|
|
39
|
+
*
|
|
40
|
+
* @returns {Promise<CreateDomainResponse>} The created domain with ID and verification status
|
|
41
|
+
*
|
|
42
|
+
* @throws {Error} If domain type is invalid
|
|
43
|
+
* @throws {Error} If domain is a blocked public domain (gmail.com, etc.)
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Add SSO routing domain
|
|
47
|
+
* const response = await scalekitClient.domain.createDomain(
|
|
48
|
+
* 'org_123456',
|
|
49
|
+
* 'acme.com',
|
|
50
|
+
* { domainType: 'ORGANIZATION_DOMAIN' }
|
|
51
|
+
* );
|
|
52
|
+
* console.log('Domain created:', response.domain.id);
|
|
53
|
+
* console.log('Verification required:', response.domain.verificationStatus);
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Add allowed email domain for user suggestions
|
|
57
|
+
* await scalekitClient.domain.createDomain(
|
|
58
|
+
* 'org_123456',
|
|
59
|
+
* 'acme.io',
|
|
60
|
+
* { domainType: 'ALLOWED_EMAIL_DOMAIN' }
|
|
61
|
+
* );
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Create domain with default type
|
|
65
|
+
* await scalekitClient.domain.createDomain('org_123456', 'company.com');
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Configure multiple domains for an organization
|
|
69
|
+
* const domains = ['acme.com', 'acme.io', 'acme.net'];
|
|
70
|
+
* for (const domain of domains) {
|
|
71
|
+
* await scalekitClient.domain.createDomain('org_123456', domain, {
|
|
72
|
+
* domainType: 'ORGANIZATION_DOMAIN'
|
|
73
|
+
* });
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/domains | Create Domain API}
|
|
77
|
+
* @see {@link listDomains} - List all domains for an organization
|
|
78
|
+
* @see {@link deleteDomain} - Remove a domain
|
|
79
|
+
*/
|
|
18
80
|
createDomain(organizationId: string, name: string, options?: {
|
|
19
81
|
domainType?: DomainType | string;
|
|
20
82
|
}): Promise<CreateDomainResponse>;
|
|
21
83
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
84
|
+
* Retrieves detailed information about a specific domain configuration.
|
|
85
|
+
*
|
|
86
|
+
* Returns complete domain details including the domain name, type (ORGANIZATION_DOMAIN or
|
|
87
|
+
* ALLOWED_EMAIL_DOMAIN), verification status, and when it was created/updated. Use this to
|
|
88
|
+
* check domain configuration status or verification requirements.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
91
|
+
* @param {string} domainId - The domain ID (format: "domain_...")
|
|
92
|
+
*
|
|
93
|
+
* @returns {Promise<GetDomainResponse>} Complete domain configuration and status
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // Check domain verification status
|
|
97
|
+
* const response = await scalekitClient.domain.getDomain(
|
|
98
|
+
* 'org_123456',
|
|
99
|
+
* 'domain_abc123'
|
|
100
|
+
* );
|
|
101
|
+
* console.log('Domain:', response.domain.domain);
|
|
102
|
+
* console.log('Type:', response.domain.domainType);
|
|
103
|
+
* console.log('Verified:', response.domain.verificationStatus);
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Verify domain configuration after creation
|
|
107
|
+
* const created = await scalekitClient.domain.createDomain(
|
|
108
|
+
* 'org_123456',
|
|
109
|
+
* 'acme.com',
|
|
110
|
+
* { domainType: 'ORGANIZATION_DOMAIN' }
|
|
111
|
+
* );
|
|
112
|
+
*
|
|
113
|
+
* // Later, check if domain has been verified
|
|
114
|
+
* const domain = await scalekitClient.domain.getDomain(
|
|
115
|
+
* 'org_123456',
|
|
116
|
+
* created.domain.id
|
|
117
|
+
* );
|
|
118
|
+
* if (domain.domain.verificationStatus === 'VERIFIED') {
|
|
119
|
+
* console.log('Domain is ready for SSO routing');
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/domains | Get Domain API}
|
|
123
|
+
* @see {@link createDomain} - Add a new domain
|
|
124
|
+
* @see {@link listDomains} - List all domains for an organization
|
|
26
125
|
*/
|
|
27
126
|
getDomain(organizationId: string, domainId: string): Promise<GetDomainResponse>;
|
|
28
127
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
128
|
+
* Retrieves all domain configurations for an organization.
|
|
129
|
+
*
|
|
130
|
+
* Returns a complete list of domains configured for the organization, including both
|
|
131
|
+
* ORGANIZATION_DOMAIN (for SSO routing) and ALLOWED_EMAIL_DOMAIN (for user suggestions).
|
|
132
|
+
* Each domain includes its verification status, type, and configuration details.
|
|
133
|
+
*
|
|
134
|
+
* Use this to audit domain configuration, check which domains are verified, or display
|
|
135
|
+
* domain settings in an admin dashboard.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
138
|
+
*
|
|
139
|
+
* @returns {Promise<ListDomainResponse>} List of all domains with their configurations
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* // List all domains for an organization
|
|
143
|
+
* const response = await scalekitClient.domain.listDomains('org_123456');
|
|
144
|
+
* console.log(`Found ${response.domains.length} domains`);
|
|
145
|
+
* response.domains.forEach(domain => {
|
|
146
|
+
* console.log(`- ${domain.domain} (${domain.domainType}): ${domain.verificationStatus}`);
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // Check which domains are verified for SSO
|
|
151
|
+
* const response = await scalekitClient.domain.listDomains('org_123456');
|
|
152
|
+
* const verifiedSSODomains = response.domains.filter(
|
|
153
|
+
* d => d.domainType === 'ORGANIZATION_DOMAIN' && d.verificationStatus === 'VERIFIED'
|
|
154
|
+
* );
|
|
155
|
+
* console.log('Verified SSO domains:', verifiedSSODomains.map(d => d.domain));
|
|
156
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/domains | List Domains API}
|
|
157
|
+
* @see {@link createDomain} - Add a new domain
|
|
158
|
+
* @see {@link getDomain} - Get details for a specific domain
|
|
159
|
+
* @see {@link deleteDomain} - Remove a domain
|
|
32
160
|
*/
|
|
33
161
|
listDomains(organizationId: string): Promise<ListDomainResponse>;
|
|
162
|
+
/**
|
|
163
|
+
* Deletes a domain from an organization.
|
|
164
|
+
*
|
|
165
|
+
* Removes the domain configuration from the organization. Users with email addresses from
|
|
166
|
+
* this domain will no longer be automatically routed to this organization's SSO connection.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} organizationId - The organization ID
|
|
169
|
+
* @param {string} domainId - The domain ID to delete
|
|
170
|
+
*
|
|
171
|
+
* @returns {Promise<Empty>} Empty response on successful deletion
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // Remove a domain from an organization
|
|
175
|
+
* await scalekitClient.domain.deleteDomain('org_123456', 'domain_abc123');
|
|
176
|
+
* console.log('Domain deleted successfully');
|
|
177
|
+
*
|
|
178
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/domains | Delete Domain API}
|
|
179
|
+
* @see {@link createDomain} - Add a new domain
|
|
180
|
+
* @see {@link listDomains} - List all domains for an organization
|
|
181
|
+
*/
|
|
34
182
|
deleteDomain(organizationId: string, domainId: string): Promise<Empty>;
|
|
35
183
|
}
|