@workos-inc/widgets 1.8.2 → 1.9.0
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/CHANGELOG.md +5 -0
- package/dist/cjs/api/api-provider.cjs.map +1 -1
- package/dist/cjs/api/api-provider.d.cts +1 -1
- package/dist/cjs/api/endpoint.cjs +702 -623
- package/dist/cjs/api/endpoint.cjs.map +1 -1
- package/dist/cjs/api/endpoint.d.cts +810 -729
- package/dist/cjs/directory-sync.client.cjs +143 -0
- package/dist/cjs/directory-sync.client.cjs.map +1 -0
- package/dist/cjs/directory-sync.client.d.cts +26 -0
- package/dist/cjs/experimental/api/fetch.cjs +309 -252
- package/dist/cjs/experimental/api/fetch.cjs.map +1 -1
- package/dist/cjs/experimental/api/fetch.d.cts +809 -731
- package/dist/cjs/experimental/api/react-query.cjs +695 -613
- package/dist/cjs/experimental/api/react-query.cjs.map +1 -1
- package/dist/cjs/experimental/api/react-query.d.cts +1355 -1250
- package/dist/cjs/experimental/api/swr.cjs +660 -583
- package/dist/cjs/experimental/api/swr.cjs.map +1 -1
- package/dist/cjs/experimental/api/swr.d.cts +1307 -1212
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -0
- package/dist/cjs/lib/api-keys/api-keys-context.cjs +1 -1
- package/dist/cjs/lib/api-keys/api-keys-context.cjs.map +1 -1
- package/dist/cjs/lib/api-keys/api-keys-table.cjs +7 -5
- package/dist/cjs/lib/api-keys/api-keys-table.cjs.map +1 -1
- package/dist/cjs/lib/directory-sync.cjs +288 -0
- package/dist/cjs/lib/directory-sync.cjs.map +1 -0
- package/dist/cjs/lib/directory-sync.d.cts +72 -0
- package/dist/cjs/lib/identity-providers.cjs +57 -1
- package/dist/cjs/lib/identity-providers.cjs.map +1 -1
- package/dist/cjs/lib/identity-providers.d.cts +5 -3
- package/dist/cjs/lib/pipes.cjs +9 -9
- package/dist/cjs/lib/pipes.cjs.map +1 -1
- package/dist/cjs/lib/reset-mfa-dialog.cjs +2 -1
- package/dist/cjs/lib/reset-mfa-dialog.cjs.map +1 -1
- package/dist/cjs/lib/use-permissions.cjs.map +1 -1
- package/dist/cjs/lib/use-permissions.d.cts +1 -1
- package/dist/cjs/lib/users-management-context.cjs +1 -1
- package/dist/cjs/lib/users-management-context.cjs.map +1 -1
- package/dist/cjs/lib/users-management.cjs +3 -3
- package/dist/cjs/lib/users-management.cjs.map +1 -1
- package/dist/cjs/lib/utils.cjs +9 -0
- package/dist/cjs/lib/utils.cjs.map +1 -1
- package/dist/cjs/lib/utils.d.cts +16 -2
- package/dist/esm/api/api-provider.d.ts +1 -1
- package/dist/esm/api/api-provider.js.map +1 -1
- package/dist/esm/api/endpoint.d.ts +810 -729
- package/dist/esm/api/endpoint.js +691 -618
- package/dist/esm/api/endpoint.js.map +1 -1
- package/dist/esm/directory-sync.client.d.ts +26 -0
- package/dist/esm/directory-sync.client.js +121 -0
- package/dist/esm/directory-sync.client.js.map +1 -0
- package/dist/esm/experimental/api/fetch.d.ts +809 -731
- package/dist/esm/experimental/api/fetch.js +300 -247
- package/dist/esm/experimental/api/fetch.js.map +1 -1
- package/dist/esm/experimental/api/react-query.d.ts +1355 -1250
- package/dist/esm/experimental/api/react-query.js +683 -608
- package/dist/esm/experimental/api/react-query.js.map +1 -1
- package/dist/esm/experimental/api/swr.d.ts +1307 -1212
- package/dist/esm/experimental/api/swr.js +649 -578
- package/dist/esm/experimental/api/swr.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api-keys/api-keys-context.js +1 -1
- package/dist/esm/lib/api-keys/api-keys-context.js.map +1 -1
- package/dist/esm/lib/api-keys/api-keys-table.js +7 -5
- package/dist/esm/lib/api-keys/api-keys-table.js.map +1 -1
- package/dist/esm/lib/directory-sync.d.ts +72 -0
- package/dist/esm/lib/directory-sync.js +259 -0
- package/dist/esm/lib/directory-sync.js.map +1 -0
- package/dist/esm/lib/identity-providers.d.ts +5 -3
- package/dist/esm/lib/identity-providers.js +55 -1
- package/dist/esm/lib/identity-providers.js.map +1 -1
- package/dist/esm/lib/pipes.js +9 -10
- package/dist/esm/lib/pipes.js.map +1 -1
- package/dist/esm/lib/reset-mfa-dialog.js +2 -1
- package/dist/esm/lib/reset-mfa-dialog.js.map +1 -1
- package/dist/esm/lib/use-permissions.d.ts +1 -1
- package/dist/esm/lib/use-permissions.js.map +1 -1
- package/dist/esm/lib/users-management-context.js +1 -1
- package/dist/esm/lib/users-management-context.js.map +1 -1
- package/dist/esm/lib/users-management.js +5 -4
- package/dist/esm/lib/users-management.js.map +1 -1
- package/dist/esm/lib/utils.d.ts +16 -2
- package/dist/esm/lib/utils.js +8 -0
- package/dist/esm/lib/utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -25,13 +25,13 @@ const CreateTotpFactorResponseAuthenticationFactorAllOfType = {
|
|
|
25
25
|
const CreateTotpFactorResponseAuthenticationChallengeAllOfObject = {
|
|
26
26
|
authentication_challenge: "authentication_challenge"
|
|
27
27
|
};
|
|
28
|
-
const
|
|
28
|
+
const AuthenticationInformationResponseDataVerificationMethodsMfaOneOfProvider = {
|
|
29
29
|
MFA: "MFA"
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const AuthenticationInformationResponseDataVerificationMethodsPasswordOneOfProvider = {
|
|
32
32
|
Password: "Password"
|
|
33
33
|
};
|
|
34
|
-
const
|
|
34
|
+
const AuthenticationInformationResponseDataVerificationMethodsPasskeyOneOfProvider = {
|
|
35
35
|
Passkey: "Passkey"
|
|
36
36
|
};
|
|
37
37
|
const SendVerificationResponseType = {
|
|
@@ -129,11 +129,11 @@ const SsoConnectionAnyOfEightAllOfType = {
|
|
|
129
129
|
const SsoConnectionAnyOfEightAllOfProviderTag = {
|
|
130
130
|
OpenIdConnect: "OpenIdConnect"
|
|
131
131
|
};
|
|
132
|
-
const
|
|
132
|
+
const DataInstallationAllOfObject = {
|
|
133
133
|
data_installation: "data_installation",
|
|
134
134
|
connected_account: "connected_account"
|
|
135
135
|
};
|
|
136
|
-
const
|
|
136
|
+
const DataInstallationAllOfState = {
|
|
137
137
|
connected: "connected",
|
|
138
138
|
needs_reauthorization: "needs_reauthorization"
|
|
139
139
|
};
|
|
@@ -187,66 +187,109 @@ const DataIntegrationCredentialsType = {
|
|
|
187
187
|
shared: "shared",
|
|
188
188
|
custom: "custom"
|
|
189
189
|
};
|
|
190
|
+
const DirectoryType = {
|
|
191
|
+
azure_scim_v20: "azure scim v2.0",
|
|
192
|
+
bamboohr: "bamboohr",
|
|
193
|
+
breathe_hr: "breathe hr",
|
|
194
|
+
cezanne_hr: "cezanne hr",
|
|
195
|
+
cyberark_scim_v20: "cyberark scim v2.0",
|
|
196
|
+
fourth_hr: "fourth hr",
|
|
197
|
+
generic_scim_v20: "generic scim v2.0",
|
|
198
|
+
gsuite_directory: "gsuite directory",
|
|
199
|
+
gusto: "gusto",
|
|
200
|
+
hibob: "hibob",
|
|
201
|
+
jump_cloud_scim_v20: "jump cloud scim v2.0",
|
|
202
|
+
okta_scim_v20: "okta scim v2.0",
|
|
203
|
+
onelogin_scim_v20: "onelogin scim v2.0",
|
|
204
|
+
people_hr: "people hr",
|
|
205
|
+
personio: "personio",
|
|
206
|
+
pingfederate_scim_v20: "pingfederate scim v2.0",
|
|
207
|
+
rippling: "rippling",
|
|
208
|
+
rippling_scim_v20: "rippling scim v2.0",
|
|
209
|
+
s3: "s3",
|
|
210
|
+
sailpoint_scim_v20: "sailpoint scim v2.0",
|
|
211
|
+
sftp: "sftp",
|
|
212
|
+
sftp_workday: "sftp workday",
|
|
213
|
+
workday: "workday"
|
|
214
|
+
};
|
|
215
|
+
const DirectoryState = {
|
|
216
|
+
requires_type: "requires_type",
|
|
217
|
+
linked: "linked",
|
|
218
|
+
validating: "validating",
|
|
219
|
+
invalid_credentials: "invalid_credentials",
|
|
220
|
+
unlinked: "unlinked",
|
|
221
|
+
deleting: "deleting"
|
|
222
|
+
};
|
|
190
223
|
const GenerateAdminPortalLinkIntent = {
|
|
191
224
|
domain_verification: "domain_verification",
|
|
192
225
|
sso: "sso"
|
|
193
226
|
};
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
197
|
-
if (value !== void 0) {
|
|
198
|
-
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
const stringifiedParams = normalizedParams.toString();
|
|
202
|
-
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/UserManagement/members?${stringifiedParams}` : `https://api.workos.com/_widgets/UserManagement/members`;
|
|
227
|
+
const getCreateOrganizationApiKeyUrl = () => {
|
|
228
|
+
return `https://api.workos.com/_widgets/ApiKeys/organization-api-keys`;
|
|
203
229
|
};
|
|
204
|
-
const
|
|
205
|
-
const res = await fetch(
|
|
230
|
+
const createOrganizationApiKey = async (createOrganizationApiKeyRequest, options) => {
|
|
231
|
+
const res = await fetch(getCreateOrganizationApiKeyUrl(), {
|
|
206
232
|
...options,
|
|
207
|
-
method: "
|
|
233
|
+
method: "POST",
|
|
234
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
235
|
+
body: JSON.stringify(createOrganizationApiKeyRequest)
|
|
208
236
|
});
|
|
209
237
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
210
238
|
const data = body ? JSON.parse(body) : {};
|
|
211
|
-
return {
|
|
239
|
+
return {
|
|
240
|
+
data,
|
|
241
|
+
status: res.status,
|
|
242
|
+
headers: res.headers
|
|
243
|
+
};
|
|
212
244
|
};
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
245
|
+
const getCreateOrganizationApiKeyMutationFetcher = (options) => {
|
|
246
|
+
return (_, { arg }) => {
|
|
247
|
+
return createOrganizationApiKey(arg, options);
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
const getCreateOrganizationApiKeyMutationKey = () => [`https://api.workos.com/_widgets/ApiKeys/organization-api-keys`];
|
|
251
|
+
const useCreateOrganizationApiKey = (options) => {
|
|
218
252
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const query = useSwr(
|
|
223
|
-
swrKey,
|
|
224
|
-
swrFn,
|
|
225
|
-
swrOptions
|
|
226
|
-
);
|
|
253
|
+
const swrKey = swrOptions?.swrKey ?? getCreateOrganizationApiKeyMutationKey();
|
|
254
|
+
const swrFn = getCreateOrganizationApiKeyMutationFetcher(fetchOptions);
|
|
255
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
227
256
|
return {
|
|
228
257
|
swrKey,
|
|
229
258
|
...query
|
|
230
259
|
};
|
|
231
260
|
};
|
|
232
|
-
const
|
|
233
|
-
|
|
261
|
+
const getListOrganizationApiKeysUrl = (params) => {
|
|
262
|
+
const normalizedParams = new URLSearchParams();
|
|
263
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
264
|
+
if (value !== void 0) {
|
|
265
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
const stringifiedParams = normalizedParams.toString();
|
|
269
|
+
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/ApiKeys/organization-api-keys?${stringifiedParams}` : `https://api.workos.com/_widgets/ApiKeys/organization-api-keys`;
|
|
234
270
|
};
|
|
235
|
-
const
|
|
236
|
-
const res = await fetch(
|
|
271
|
+
const listOrganizationApiKeys = async (params, options) => {
|
|
272
|
+
const res = await fetch(getListOrganizationApiKeysUrl(params), {
|
|
237
273
|
...options,
|
|
238
274
|
method: "GET"
|
|
239
275
|
});
|
|
240
276
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
241
277
|
const data = body ? JSON.parse(body) : {};
|
|
242
|
-
return {
|
|
278
|
+
return {
|
|
279
|
+
data,
|
|
280
|
+
status: res.status,
|
|
281
|
+
headers: res.headers
|
|
282
|
+
};
|
|
243
283
|
};
|
|
244
|
-
const
|
|
245
|
-
|
|
284
|
+
const getListOrganizationApiKeysKey = (params) => [
|
|
285
|
+
`https://api.workos.com/_widgets/ApiKeys/organization-api-keys`,
|
|
286
|
+
...params ? [params] : []
|
|
287
|
+
];
|
|
288
|
+
const useListOrganizationApiKeys = (params, options) => {
|
|
246
289
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
247
290
|
const isEnabled = swrOptions?.enabled !== false;
|
|
248
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
249
|
-
const swrFn = () =>
|
|
291
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getListOrganizationApiKeysKey(params) : null);
|
|
292
|
+
const swrFn = () => listOrganizationApiKeys(params, fetchOptions);
|
|
250
293
|
const query = useSwr(
|
|
251
294
|
swrKey,
|
|
252
295
|
swrFn,
|
|
@@ -257,11 +300,18 @@ const useRoles = (options) => {
|
|
|
257
300
|
...query
|
|
258
301
|
};
|
|
259
302
|
};
|
|
260
|
-
const
|
|
261
|
-
|
|
303
|
+
const getListOrganizationApiKeyPermissionsUrl = (params) => {
|
|
304
|
+
const normalizedParams = new URLSearchParams();
|
|
305
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
306
|
+
if (value !== void 0) {
|
|
307
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
const stringifiedParams = normalizedParams.toString();
|
|
311
|
+
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/ApiKeys/permissions?${stringifiedParams}` : `https://api.workos.com/_widgets/ApiKeys/permissions`;
|
|
262
312
|
};
|
|
263
|
-
const
|
|
264
|
-
const res = await fetch(
|
|
313
|
+
const listOrganizationApiKeyPermissions = async (params, options) => {
|
|
314
|
+
const res = await fetch(getListOrganizationApiKeyPermissionsUrl(params), {
|
|
265
315
|
...options,
|
|
266
316
|
method: "GET"
|
|
267
317
|
});
|
|
@@ -273,12 +323,15 @@ const rolesAndConfig = async (options) => {
|
|
|
273
323
|
headers: res.headers
|
|
274
324
|
};
|
|
275
325
|
};
|
|
276
|
-
const
|
|
277
|
-
|
|
326
|
+
const getListOrganizationApiKeyPermissionsKey = (params) => [
|
|
327
|
+
`https://api.workos.com/_widgets/ApiKeys/permissions`,
|
|
328
|
+
...params ? [params] : []
|
|
329
|
+
];
|
|
330
|
+
const useListOrganizationApiKeyPermissions = (params, options) => {
|
|
278
331
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
279
332
|
const isEnabled = swrOptions?.enabled !== false;
|
|
280
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
281
|
-
const swrFn = () =>
|
|
333
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getListOrganizationApiKeyPermissionsKey(params) : null);
|
|
334
|
+
const swrFn = () => listOrganizationApiKeyPermissions(params, fetchOptions);
|
|
282
335
|
const query = useSwr(
|
|
283
336
|
swrKey,
|
|
284
337
|
swrFn,
|
|
@@ -289,15 +342,13 @@ const useRolesAndConfig = (options) => {
|
|
|
289
342
|
...query
|
|
290
343
|
};
|
|
291
344
|
};
|
|
292
|
-
const
|
|
293
|
-
return `https://api.workos.com/_widgets/
|
|
345
|
+
const getDeleteOrganizationApiKeyUrl = (apiKeyId) => {
|
|
346
|
+
return `https://api.workos.com/_widgets/ApiKeys/${apiKeyId}`;
|
|
294
347
|
};
|
|
295
|
-
const
|
|
296
|
-
const res = await fetch(
|
|
348
|
+
const deleteOrganizationApiKey = async (apiKeyId, options) => {
|
|
349
|
+
const res = await fetch(getDeleteOrganizationApiKeyUrl(apiKeyId), {
|
|
297
350
|
...options,
|
|
298
|
-
method: "
|
|
299
|
-
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
300
|
-
body: JSON.stringify(inviteMemberBody)
|
|
351
|
+
method: "DELETE"
|
|
301
352
|
});
|
|
302
353
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
303
354
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -307,29 +358,32 @@ const inviteMember = async (inviteMemberBody, options) => {
|
|
|
307
358
|
headers: res.headers
|
|
308
359
|
};
|
|
309
360
|
};
|
|
310
|
-
const
|
|
311
|
-
return (_,
|
|
312
|
-
return
|
|
361
|
+
const getDeleteOrganizationApiKeyMutationFetcher = (apiKeyId, options) => {
|
|
362
|
+
return (_, __) => {
|
|
363
|
+
return deleteOrganizationApiKey(apiKeyId, options);
|
|
313
364
|
};
|
|
314
365
|
};
|
|
315
|
-
const
|
|
316
|
-
const
|
|
366
|
+
const getDeleteOrganizationApiKeyMutationKey = (apiKeyId) => [`https://api.workos.com/_widgets/ApiKeys/${apiKeyId}`];
|
|
367
|
+
const useDeleteOrganizationApiKey = (apiKeyId, options) => {
|
|
317
368
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
318
|
-
const swrKey = swrOptions?.swrKey ??
|
|
319
|
-
const swrFn =
|
|
369
|
+
const swrKey = swrOptions?.swrKey ?? getDeleteOrganizationApiKeyMutationKey(apiKeyId);
|
|
370
|
+
const swrFn = getDeleteOrganizationApiKeyMutationFetcher(
|
|
371
|
+
apiKeyId,
|
|
372
|
+
fetchOptions
|
|
373
|
+
);
|
|
320
374
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
321
375
|
return {
|
|
322
376
|
swrKey,
|
|
323
377
|
...query
|
|
324
378
|
};
|
|
325
379
|
};
|
|
326
|
-
const
|
|
327
|
-
return `https://api.workos.com/_widgets/
|
|
380
|
+
const getDeleteDataInstallationUrl = (installationId) => {
|
|
381
|
+
return `https://api.workos.com/_widgets/DataIntegrations/installations/${installationId}`;
|
|
328
382
|
};
|
|
329
|
-
const
|
|
330
|
-
const res = await fetch(
|
|
383
|
+
const deleteDataInstallation = async (installationId, options) => {
|
|
384
|
+
const res = await fetch(getDeleteDataInstallationUrl(installationId), {
|
|
331
385
|
...options,
|
|
332
|
-
method: "
|
|
386
|
+
method: "DELETE"
|
|
333
387
|
});
|
|
334
388
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
335
389
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -339,31 +393,34 @@ const resendInvite = async (userId, options) => {
|
|
|
339
393
|
headers: res.headers
|
|
340
394
|
};
|
|
341
395
|
};
|
|
342
|
-
const
|
|
396
|
+
const getDeleteDataInstallationMutationFetcher = (installationId, options) => {
|
|
343
397
|
return (_, __) => {
|
|
344
|
-
return
|
|
398
|
+
return deleteDataInstallation(installationId, options);
|
|
345
399
|
};
|
|
346
400
|
};
|
|
347
|
-
const
|
|
348
|
-
`https://api.workos.com/_widgets/
|
|
401
|
+
const getDeleteDataInstallationMutationKey = (installationId) => [
|
|
402
|
+
`https://api.workos.com/_widgets/DataIntegrations/installations/${installationId}`
|
|
349
403
|
];
|
|
350
|
-
const
|
|
404
|
+
const useDeleteDataInstallation = (installationId, options) => {
|
|
351
405
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
352
|
-
const swrKey = swrOptions?.swrKey ??
|
|
353
|
-
const swrFn =
|
|
406
|
+
const swrKey = swrOptions?.swrKey ?? getDeleteDataInstallationMutationKey(installationId);
|
|
407
|
+
const swrFn = getDeleteDataInstallationMutationFetcher(
|
|
408
|
+
installationId,
|
|
409
|
+
fetchOptions
|
|
410
|
+
);
|
|
354
411
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
355
412
|
return {
|
|
356
413
|
swrKey,
|
|
357
414
|
...query
|
|
358
415
|
};
|
|
359
416
|
};
|
|
360
|
-
const
|
|
361
|
-
return `https://api.workos.com/_widgets/
|
|
417
|
+
const getMyDataIntegrationsUrl = () => {
|
|
418
|
+
return `https://api.workos.com/_widgets/DataIntegrations/mine`;
|
|
362
419
|
};
|
|
363
|
-
const
|
|
364
|
-
const res = await fetch(
|
|
420
|
+
const myDataIntegrations = async (options) => {
|
|
421
|
+
const res = await fetch(getMyDataIntegrationsUrl(), {
|
|
365
422
|
...options,
|
|
366
|
-
method: "
|
|
423
|
+
method: "GET"
|
|
367
424
|
});
|
|
368
425
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
369
426
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -373,30 +430,33 @@ const revokeInvite = async (userId, options) => {
|
|
|
373
430
|
headers: res.headers
|
|
374
431
|
};
|
|
375
432
|
};
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
return revokeInvite(userId, options);
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
const getRevokeInviteMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/invites/${userId}`];
|
|
382
|
-
const useRevokeInvite = (userId, options) => {
|
|
433
|
+
const getMyDataIntegrationsKey = () => [`https://api.workos.com/_widgets/DataIntegrations/mine`];
|
|
434
|
+
const useMyDataIntegrations = (options) => {
|
|
383
435
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
384
|
-
const
|
|
385
|
-
const
|
|
386
|
-
const
|
|
436
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
437
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getMyDataIntegrationsKey() : null);
|
|
438
|
+
const swrFn = () => myDataIntegrations(fetchOptions);
|
|
439
|
+
const query = useSwr(
|
|
440
|
+
swrKey,
|
|
441
|
+
swrFn,
|
|
442
|
+
swrOptions
|
|
443
|
+
);
|
|
387
444
|
return {
|
|
388
445
|
swrKey,
|
|
389
446
|
...query
|
|
390
447
|
};
|
|
391
448
|
};
|
|
392
|
-
const
|
|
393
|
-
return `https://api.workos.com/_widgets/
|
|
449
|
+
const getGetDataInstallationAuthorizationStatusUrl = (dataIntegrationId, state) => {
|
|
450
|
+
return `https://api.workos.com/_widgets/DataIntegrations/${dataIntegrationId}/authorization-status/${state}`;
|
|
394
451
|
};
|
|
395
|
-
const
|
|
396
|
-
const res = await fetch(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
452
|
+
const getDataInstallationAuthorizationStatus = async (dataIntegrationId, state, options) => {
|
|
453
|
+
const res = await fetch(
|
|
454
|
+
getGetDataInstallationAuthorizationStatusUrl(dataIntegrationId, state),
|
|
455
|
+
{
|
|
456
|
+
...options,
|
|
457
|
+
method: "GET"
|
|
458
|
+
}
|
|
459
|
+
);
|
|
400
460
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
401
461
|
const data = body ? JSON.parse(body) : {};
|
|
402
462
|
return {
|
|
@@ -405,31 +465,42 @@ const removeMember = async (userId, options) => {
|
|
|
405
465
|
headers: res.headers
|
|
406
466
|
};
|
|
407
467
|
};
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
};
|
|
413
|
-
const getRemoveMemberMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/members/${userId}`];
|
|
414
|
-
const useRemoveMember = (userId, options) => {
|
|
468
|
+
const getGetDataInstallationAuthorizationStatusKey = (dataIntegrationId, state) => [
|
|
469
|
+
`https://api.workos.com/_widgets/DataIntegrations/${dataIntegrationId}/authorization-status/${state}`
|
|
470
|
+
];
|
|
471
|
+
const useGetDataInstallationAuthorizationStatus = (dataIntegrationId, state, options) => {
|
|
415
472
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
416
|
-
const
|
|
417
|
-
const
|
|
418
|
-
const
|
|
473
|
+
const isEnabled = swrOptions?.enabled !== false && !!(dataIntegrationId && state);
|
|
474
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDataInstallationAuthorizationStatusKey(dataIntegrationId, state) : null);
|
|
475
|
+
const swrFn = () => getDataInstallationAuthorizationStatus(
|
|
476
|
+
dataIntegrationId,
|
|
477
|
+
state,
|
|
478
|
+
fetchOptions
|
|
479
|
+
);
|
|
480
|
+
const query = useSwr(
|
|
481
|
+
swrKey,
|
|
482
|
+
swrFn,
|
|
483
|
+
swrOptions
|
|
484
|
+
);
|
|
419
485
|
return {
|
|
420
486
|
swrKey,
|
|
421
487
|
...query
|
|
422
488
|
};
|
|
423
489
|
};
|
|
424
|
-
const
|
|
425
|
-
|
|
490
|
+
const getGetDataIntegrationAuthorizeUrlUrl = (slug, params) => {
|
|
491
|
+
const normalizedParams = new URLSearchParams();
|
|
492
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
493
|
+
if (value !== void 0) {
|
|
494
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
const stringifiedParams = normalizedParams.toString();
|
|
498
|
+
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/DataIntegrations/${slug}/authorize?${stringifiedParams}` : `https://api.workos.com/_widgets/DataIntegrations/${slug}/authorize`;
|
|
426
499
|
};
|
|
427
|
-
const
|
|
428
|
-
const res = await fetch(
|
|
500
|
+
const getDataIntegrationAuthorizeUrl = async (slug, params, options) => {
|
|
501
|
+
const res = await fetch(getGetDataIntegrationAuthorizeUrlUrl(slug, params), {
|
|
429
502
|
...options,
|
|
430
|
-
method: "
|
|
431
|
-
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
432
|
-
body: JSON.stringify(updateMemberBody)
|
|
503
|
+
method: "GET"
|
|
433
504
|
});
|
|
434
505
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
435
506
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -439,72 +510,15 @@ const updateMember = async (userId, updateMemberBody, options) => {
|
|
|
439
510
|
headers: res.headers
|
|
440
511
|
};
|
|
441
512
|
};
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const getUpdateMemberMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/members/${userId}`];
|
|
448
|
-
const useUpdateMember = (userId, options) => {
|
|
449
|
-
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
450
|
-
const swrKey = swrOptions?.swrKey ?? getUpdateMemberMutationKey(userId);
|
|
451
|
-
const swrFn = getUpdateMemberMutationFetcher(userId, fetchOptions);
|
|
452
|
-
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
453
|
-
return {
|
|
454
|
-
swrKey,
|
|
455
|
-
...query
|
|
456
|
-
};
|
|
457
|
-
};
|
|
458
|
-
const getOrganizationsUrl = () => {
|
|
459
|
-
return `https://api.workos.com/_widgets/UserManagement/organizations`;
|
|
460
|
-
};
|
|
461
|
-
const organizations = async (options) => {
|
|
462
|
-
const res = await fetch(getOrganizationsUrl(), {
|
|
463
|
-
...options,
|
|
464
|
-
method: "GET"
|
|
465
|
-
});
|
|
466
|
-
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
467
|
-
const data = body ? JSON.parse(body) : {};
|
|
468
|
-
return {
|
|
469
|
-
data,
|
|
470
|
-
status: res.status,
|
|
471
|
-
headers: res.headers
|
|
472
|
-
};
|
|
473
|
-
};
|
|
474
|
-
const getOrganizationsKey = () => [`https://api.workos.com/_widgets/UserManagement/organizations`];
|
|
475
|
-
const useOrganizations = (options) => {
|
|
476
|
-
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
477
|
-
const isEnabled = swrOptions?.enabled !== false;
|
|
478
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getOrganizationsKey() : null);
|
|
479
|
-
const swrFn = () => organizations(fetchOptions);
|
|
480
|
-
const query = useSwr(
|
|
481
|
-
swrKey,
|
|
482
|
-
swrFn,
|
|
483
|
-
swrOptions
|
|
484
|
-
);
|
|
485
|
-
return {
|
|
486
|
-
swrKey,
|
|
487
|
-
...query
|
|
488
|
-
};
|
|
489
|
-
};
|
|
490
|
-
const getMeUrl = () => {
|
|
491
|
-
return `https://api.workos.com/_widgets/UserProfile/me`;
|
|
492
|
-
};
|
|
493
|
-
const me = async (options) => {
|
|
494
|
-
const res = await fetch(getMeUrl(), {
|
|
495
|
-
...options,
|
|
496
|
-
method: "GET"
|
|
497
|
-
});
|
|
498
|
-
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
499
|
-
const data = body ? JSON.parse(body) : {};
|
|
500
|
-
return { data, status: res.status, headers: res.headers };
|
|
501
|
-
};
|
|
502
|
-
const getMeKey = () => [`https://api.workos.com/_widgets/UserProfile/me`];
|
|
503
|
-
const useMe = (options) => {
|
|
513
|
+
const getGetDataIntegrationAuthorizeUrlKey = (slug, params) => [
|
|
514
|
+
`https://api.workos.com/_widgets/DataIntegrations/${slug}/authorize`,
|
|
515
|
+
...params ? [params] : []
|
|
516
|
+
];
|
|
517
|
+
const useGetDataIntegrationAuthorizeUrl = (slug, params, options) => {
|
|
504
518
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
505
|
-
const isEnabled = swrOptions?.enabled !== false;
|
|
506
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
507
|
-
const swrFn = () =>
|
|
519
|
+
const isEnabled = swrOptions?.enabled !== false && !!slug;
|
|
520
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getGetDataIntegrationAuthorizeUrlKey(slug, params) : null);
|
|
521
|
+
const swrFn = () => getDataIntegrationAuthorizeUrl(slug, params, fetchOptions);
|
|
508
522
|
const query = useSwr(
|
|
509
523
|
swrKey,
|
|
510
524
|
swrFn,
|
|
@@ -515,43 +529,15 @@ const useMe = (options) => {
|
|
|
515
529
|
...query
|
|
516
530
|
};
|
|
517
531
|
};
|
|
518
|
-
const
|
|
519
|
-
return `https://api.workos.com/_widgets/
|
|
532
|
+
const getInviteMemberUrl = () => {
|
|
533
|
+
return `https://api.workos.com/_widgets/UserManagement/invite-user`;
|
|
520
534
|
};
|
|
521
|
-
const
|
|
522
|
-
const res = await fetch(
|
|
535
|
+
const inviteMember = async (inviteMemberBody, options) => {
|
|
536
|
+
const res = await fetch(getInviteMemberUrl(), {
|
|
523
537
|
...options,
|
|
524
538
|
method: "POST",
|
|
525
539
|
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
526
|
-
body: JSON.stringify(
|
|
527
|
-
});
|
|
528
|
-
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
529
|
-
const data = body ? JSON.parse(body) : {};
|
|
530
|
-
return { data, status: res.status, headers: res.headers };
|
|
531
|
-
};
|
|
532
|
-
const getUpdateMeMutationFetcher = (options) => {
|
|
533
|
-
return (_, { arg }) => {
|
|
534
|
-
return updateMe(arg, options);
|
|
535
|
-
};
|
|
536
|
-
};
|
|
537
|
-
const getUpdateMeMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/me`];
|
|
538
|
-
const useUpdateMe = (options) => {
|
|
539
|
-
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
540
|
-
const swrKey = swrOptions?.swrKey ?? getUpdateMeMutationKey();
|
|
541
|
-
const swrFn = getUpdateMeMutationFetcher(fetchOptions);
|
|
542
|
-
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
543
|
-
return {
|
|
544
|
-
swrKey,
|
|
545
|
-
...query
|
|
546
|
-
};
|
|
547
|
-
};
|
|
548
|
-
const getCreateTotpFactorUrl = () => {
|
|
549
|
-
return `https://api.workos.com/_widgets/UserProfile/create-totp-factor`;
|
|
550
|
-
};
|
|
551
|
-
const createTotpFactor = async (options) => {
|
|
552
|
-
const res = await fetch(getCreateTotpFactorUrl(), {
|
|
553
|
-
...options,
|
|
554
|
-
method: "POST"
|
|
540
|
+
body: JSON.stringify(inviteMemberBody)
|
|
555
541
|
});
|
|
556
542
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
557
543
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -561,31 +547,29 @@ const createTotpFactor = async (options) => {
|
|
|
561
547
|
headers: res.headers
|
|
562
548
|
};
|
|
563
549
|
};
|
|
564
|
-
const
|
|
565
|
-
return (_,
|
|
566
|
-
return
|
|
550
|
+
const getInviteMemberMutationFetcher = (options) => {
|
|
551
|
+
return (_, { arg }) => {
|
|
552
|
+
return inviteMember(arg, options);
|
|
567
553
|
};
|
|
568
554
|
};
|
|
569
|
-
const
|
|
570
|
-
const
|
|
555
|
+
const getInviteMemberMutationKey = () => [`https://api.workos.com/_widgets/UserManagement/invite-user`];
|
|
556
|
+
const useInviteMember = (options) => {
|
|
571
557
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
572
|
-
const swrKey = swrOptions?.swrKey ??
|
|
573
|
-
const swrFn =
|
|
558
|
+
const swrKey = swrOptions?.swrKey ?? getInviteMemberMutationKey();
|
|
559
|
+
const swrFn = getInviteMemberMutationFetcher(fetchOptions);
|
|
574
560
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
575
561
|
return {
|
|
576
562
|
swrKey,
|
|
577
563
|
...query
|
|
578
564
|
};
|
|
579
565
|
};
|
|
580
|
-
const
|
|
581
|
-
return `https://api.workos.com/_widgets/
|
|
566
|
+
const getRevokeInviteUrl = (userId) => {
|
|
567
|
+
return `https://api.workos.com/_widgets/UserManagement/invites/${userId}`;
|
|
582
568
|
};
|
|
583
|
-
const
|
|
584
|
-
const res = await fetch(
|
|
569
|
+
const revokeInvite = async (userId, options) => {
|
|
570
|
+
const res = await fetch(getRevokeInviteUrl(userId), {
|
|
585
571
|
...options,
|
|
586
|
-
method: "
|
|
587
|
-
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
588
|
-
body: JSON.stringify(verifyTotpFactorRequest)
|
|
572
|
+
method: "DELETE"
|
|
589
573
|
});
|
|
590
574
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
591
575
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -595,29 +579,29 @@ const verifyTotpFactor = async (verifyTotpFactorRequest, options) => {
|
|
|
595
579
|
headers: res.headers
|
|
596
580
|
};
|
|
597
581
|
};
|
|
598
|
-
const
|
|
599
|
-
return (_,
|
|
600
|
-
return
|
|
582
|
+
const getRevokeInviteMutationFetcher = (userId, options) => {
|
|
583
|
+
return (_, __) => {
|
|
584
|
+
return revokeInvite(userId, options);
|
|
601
585
|
};
|
|
602
586
|
};
|
|
603
|
-
const
|
|
604
|
-
const
|
|
587
|
+
const getRevokeInviteMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/invites/${userId}`];
|
|
588
|
+
const useRevokeInvite = (userId, options) => {
|
|
605
589
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
606
|
-
const swrKey = swrOptions?.swrKey ??
|
|
607
|
-
const swrFn =
|
|
590
|
+
const swrKey = swrOptions?.swrKey ?? getRevokeInviteMutationKey(userId);
|
|
591
|
+
const swrFn = getRevokeInviteMutationFetcher(userId, fetchOptions);
|
|
608
592
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
609
593
|
return {
|
|
610
594
|
swrKey,
|
|
611
595
|
...query
|
|
612
596
|
};
|
|
613
597
|
};
|
|
614
|
-
const
|
|
615
|
-
return `https://api.workos.com/_widgets/
|
|
598
|
+
const getResendInviteUrl = (userId) => {
|
|
599
|
+
return `https://api.workos.com/_widgets/UserManagement/invites/${userId}/resend`;
|
|
616
600
|
};
|
|
617
|
-
const
|
|
618
|
-
const res = await fetch(
|
|
601
|
+
const resendInvite = async (userId, options) => {
|
|
602
|
+
const res = await fetch(getResendInviteUrl(userId), {
|
|
619
603
|
...options,
|
|
620
|
-
method: "
|
|
604
|
+
method: "POST"
|
|
621
605
|
});
|
|
622
606
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
623
607
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -627,46 +611,52 @@ const deleteTotpFactors = async (options) => {
|
|
|
627
611
|
headers: res.headers
|
|
628
612
|
};
|
|
629
613
|
};
|
|
630
|
-
const
|
|
614
|
+
const getResendInviteMutationFetcher = (userId, options) => {
|
|
631
615
|
return (_, __) => {
|
|
632
|
-
return
|
|
616
|
+
return resendInvite(userId, options);
|
|
633
617
|
};
|
|
634
618
|
};
|
|
635
|
-
const
|
|
636
|
-
|
|
619
|
+
const getResendInviteMutationKey = (userId) => [
|
|
620
|
+
`https://api.workos.com/_widgets/UserManagement/invites/${userId}/resend`
|
|
621
|
+
];
|
|
622
|
+
const useResendInvite = (userId, options) => {
|
|
637
623
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
638
|
-
const swrKey = swrOptions?.swrKey ??
|
|
639
|
-
const swrFn =
|
|
624
|
+
const swrKey = swrOptions?.swrKey ?? getResendInviteMutationKey(userId);
|
|
625
|
+
const swrFn = getResendInviteMutationFetcher(userId, fetchOptions);
|
|
640
626
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
641
627
|
return {
|
|
642
628
|
swrKey,
|
|
643
629
|
...query
|
|
644
630
|
};
|
|
645
631
|
};
|
|
646
|
-
const
|
|
647
|
-
|
|
632
|
+
const getMembersUrl = (params) => {
|
|
633
|
+
const normalizedParams = new URLSearchParams();
|
|
634
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
635
|
+
if (value !== void 0) {
|
|
636
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
const stringifiedParams = normalizedParams.toString();
|
|
640
|
+
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/UserManagement/members?${stringifiedParams}` : `https://api.workos.com/_widgets/UserManagement/members`;
|
|
648
641
|
};
|
|
649
|
-
const
|
|
650
|
-
const res = await fetch(
|
|
642
|
+
const members = async (params, options) => {
|
|
643
|
+
const res = await fetch(getMembersUrl(params), {
|
|
651
644
|
...options,
|
|
652
645
|
method: "GET"
|
|
653
646
|
});
|
|
654
647
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
655
648
|
const data = body ? JSON.parse(body) : {};
|
|
656
|
-
return {
|
|
657
|
-
data,
|
|
658
|
-
status: res.status,
|
|
659
|
-
headers: res.headers
|
|
660
|
-
};
|
|
649
|
+
return { data, status: res.status, headers: res.headers };
|
|
661
650
|
};
|
|
662
|
-
const
|
|
663
|
-
`https://api.workos.com/_widgets/
|
|
651
|
+
const getMembersKey = (params) => [
|
|
652
|
+
`https://api.workos.com/_widgets/UserManagement/members`,
|
|
653
|
+
...params ? [params] : []
|
|
664
654
|
];
|
|
665
|
-
const
|
|
655
|
+
const useMembers = (params, options) => {
|
|
666
656
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
667
657
|
const isEnabled = swrOptions?.enabled !== false;
|
|
668
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
669
|
-
const swrFn = () =>
|
|
658
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getMembersKey(params) : null);
|
|
659
|
+
const swrFn = () => members(params, fetchOptions);
|
|
670
660
|
const query = useSwr(
|
|
671
661
|
swrKey,
|
|
672
662
|
swrFn,
|
|
@@ -677,15 +667,13 @@ const useAuthenticationInformation = (options) => {
|
|
|
677
667
|
...query
|
|
678
668
|
};
|
|
679
669
|
};
|
|
680
|
-
const
|
|
681
|
-
return `https://api.workos.com/_widgets/
|
|
670
|
+
const getRemoveMemberUrl = (userId) => {
|
|
671
|
+
return `https://api.workos.com/_widgets/UserManagement/members/${userId}`;
|
|
682
672
|
};
|
|
683
|
-
const
|
|
684
|
-
const res = await fetch(
|
|
673
|
+
const removeMember = async (userId, options) => {
|
|
674
|
+
const res = await fetch(getRemoveMemberUrl(userId), {
|
|
685
675
|
...options,
|
|
686
|
-
method: "
|
|
687
|
-
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
688
|
-
body: JSON.stringify(createPasswordRequest)
|
|
676
|
+
method: "DELETE"
|
|
689
677
|
});
|
|
690
678
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
691
679
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -695,31 +683,31 @@ const createPassword = async (createPasswordRequest, options) => {
|
|
|
695
683
|
headers: res.headers
|
|
696
684
|
};
|
|
697
685
|
};
|
|
698
|
-
const
|
|
699
|
-
return (_,
|
|
700
|
-
return
|
|
686
|
+
const getRemoveMemberMutationFetcher = (userId, options) => {
|
|
687
|
+
return (_, __) => {
|
|
688
|
+
return removeMember(userId, options);
|
|
701
689
|
};
|
|
702
690
|
};
|
|
703
|
-
const
|
|
704
|
-
const
|
|
691
|
+
const getRemoveMemberMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/members/${userId}`];
|
|
692
|
+
const useRemoveMember = (userId, options) => {
|
|
705
693
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
706
|
-
const swrKey = swrOptions?.swrKey ??
|
|
707
|
-
const swrFn =
|
|
694
|
+
const swrKey = swrOptions?.swrKey ?? getRemoveMemberMutationKey(userId);
|
|
695
|
+
const swrFn = getRemoveMemberMutationFetcher(userId, fetchOptions);
|
|
708
696
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
709
697
|
return {
|
|
710
698
|
swrKey,
|
|
711
699
|
...query
|
|
712
700
|
};
|
|
713
701
|
};
|
|
714
|
-
const
|
|
715
|
-
return `https://api.workos.com/_widgets/
|
|
702
|
+
const getUpdateMemberUrl = (userId) => {
|
|
703
|
+
return `https://api.workos.com/_widgets/UserManagement/members/${userId}`;
|
|
716
704
|
};
|
|
717
|
-
const
|
|
718
|
-
const res = await fetch(
|
|
705
|
+
const updateMember = async (userId, updateMemberBody, options) => {
|
|
706
|
+
const res = await fetch(getUpdateMemberUrl(userId), {
|
|
719
707
|
...options,
|
|
720
708
|
method: "POST",
|
|
721
709
|
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
722
|
-
body: JSON.stringify(
|
|
710
|
+
body: JSON.stringify(updateMemberBody)
|
|
723
711
|
});
|
|
724
712
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
725
713
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -729,31 +717,29 @@ const updatePassword = async (updatePasswordRequest, options) => {
|
|
|
729
717
|
headers: res.headers
|
|
730
718
|
};
|
|
731
719
|
};
|
|
732
|
-
const
|
|
720
|
+
const getUpdateMemberMutationFetcher = (userId, options) => {
|
|
733
721
|
return (_, { arg }) => {
|
|
734
|
-
return
|
|
722
|
+
return updateMember(userId, arg, options);
|
|
735
723
|
};
|
|
736
724
|
};
|
|
737
|
-
const
|
|
738
|
-
const
|
|
725
|
+
const getUpdateMemberMutationKey = (userId) => [`https://api.workos.com/_widgets/UserManagement/members/${userId}`];
|
|
726
|
+
const useUpdateMember = (userId, options) => {
|
|
739
727
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
740
|
-
const swrKey = swrOptions?.swrKey ??
|
|
741
|
-
const swrFn =
|
|
728
|
+
const swrKey = swrOptions?.swrKey ?? getUpdateMemberMutationKey(userId);
|
|
729
|
+
const swrFn = getUpdateMemberMutationFetcher(userId, fetchOptions);
|
|
742
730
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
743
731
|
return {
|
|
744
732
|
swrKey,
|
|
745
733
|
...query
|
|
746
734
|
};
|
|
747
735
|
};
|
|
748
|
-
const
|
|
749
|
-
return `https://api.workos.com/_widgets/
|
|
736
|
+
const getOrganizationsUrl = () => {
|
|
737
|
+
return `https://api.workos.com/_widgets/UserManagement/organizations`;
|
|
750
738
|
};
|
|
751
|
-
const
|
|
752
|
-
const res = await fetch(
|
|
739
|
+
const organizations = async (options) => {
|
|
740
|
+
const res = await fetch(getOrganizationsUrl(), {
|
|
753
741
|
...options,
|
|
754
|
-
method: "
|
|
755
|
-
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
756
|
-
body: JSON.stringify(revokeAllSessionsRequest)
|
|
742
|
+
method: "GET"
|
|
757
743
|
});
|
|
758
744
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
759
745
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -763,29 +749,57 @@ const revokeAllSessions = async (revokeAllSessionsRequest, options) => {
|
|
|
763
749
|
headers: res.headers
|
|
764
750
|
};
|
|
765
751
|
};
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
752
|
+
const getOrganizationsKey = () => [`https://api.workos.com/_widgets/UserManagement/organizations`];
|
|
753
|
+
const useOrganizations = (options) => {
|
|
754
|
+
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
755
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
756
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getOrganizationsKey() : null);
|
|
757
|
+
const swrFn = () => organizations(fetchOptions);
|
|
758
|
+
const query = useSwr(
|
|
759
|
+
swrKey,
|
|
760
|
+
swrFn,
|
|
761
|
+
swrOptions
|
|
762
|
+
);
|
|
763
|
+
return {
|
|
764
|
+
swrKey,
|
|
765
|
+
...query
|
|
769
766
|
};
|
|
770
767
|
};
|
|
771
|
-
const
|
|
772
|
-
|
|
768
|
+
const getRolesUrl = () => {
|
|
769
|
+
return `https://api.workos.com/_widgets/UserManagement/roles`;
|
|
770
|
+
};
|
|
771
|
+
const roles = async (options) => {
|
|
772
|
+
const res = await fetch(getRolesUrl(), {
|
|
773
|
+
...options,
|
|
774
|
+
method: "GET"
|
|
775
|
+
});
|
|
776
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
777
|
+
const data = body ? JSON.parse(body) : {};
|
|
778
|
+
return { data, status: res.status, headers: res.headers };
|
|
779
|
+
};
|
|
780
|
+
const getRolesKey = () => [`https://api.workos.com/_widgets/UserManagement/roles`];
|
|
781
|
+
const useRoles = (options) => {
|
|
773
782
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
774
|
-
const
|
|
775
|
-
const
|
|
776
|
-
const
|
|
783
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
784
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getRolesKey() : null);
|
|
785
|
+
const swrFn = () => roles(fetchOptions);
|
|
786
|
+
const query = useSwr(
|
|
787
|
+
swrKey,
|
|
788
|
+
swrFn,
|
|
789
|
+
swrOptions
|
|
790
|
+
);
|
|
777
791
|
return {
|
|
778
792
|
swrKey,
|
|
779
793
|
...query
|
|
780
794
|
};
|
|
781
795
|
};
|
|
782
|
-
const
|
|
783
|
-
return `https://api.workos.com/_widgets/
|
|
796
|
+
const getRolesAndConfigUrl = () => {
|
|
797
|
+
return `https://api.workos.com/_widgets/UserManagement/roles-and-config`;
|
|
784
798
|
};
|
|
785
|
-
const
|
|
786
|
-
const res = await fetch(
|
|
799
|
+
const rolesAndConfig = async (options) => {
|
|
800
|
+
const res = await fetch(getRolesAndConfigUrl(), {
|
|
787
801
|
...options,
|
|
788
|
-
method: "
|
|
802
|
+
method: "GET"
|
|
789
803
|
});
|
|
790
804
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
791
805
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -795,42 +809,46 @@ const revokeSession = async (sessionId, options) => {
|
|
|
795
809
|
headers: res.headers
|
|
796
810
|
};
|
|
797
811
|
};
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
return revokeSession(sessionId, options);
|
|
801
|
-
};
|
|
802
|
-
};
|
|
803
|
-
const getRevokeSessionMutationKey = (sessionId) => [
|
|
804
|
-
`https://api.workos.com/_widgets/UserProfile/sessions/revoke/${sessionId}`
|
|
805
|
-
];
|
|
806
|
-
const useRevokeSession = (sessionId, options) => {
|
|
812
|
+
const getRolesAndConfigKey = () => [`https://api.workos.com/_widgets/UserManagement/roles-and-config`];
|
|
813
|
+
const useRolesAndConfig = (options) => {
|
|
807
814
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
808
|
-
const
|
|
809
|
-
const
|
|
810
|
-
const
|
|
815
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
816
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getRolesAndConfigKey() : null);
|
|
817
|
+
const swrFn = () => rolesAndConfig(fetchOptions);
|
|
818
|
+
const query = useSwr(
|
|
819
|
+
swrKey,
|
|
820
|
+
swrFn,
|
|
821
|
+
swrOptions
|
|
822
|
+
);
|
|
811
823
|
return {
|
|
812
824
|
swrKey,
|
|
813
825
|
...query
|
|
814
826
|
};
|
|
815
827
|
};
|
|
816
|
-
const
|
|
817
|
-
return `https://api.workos.com/_widgets/UserProfile/
|
|
828
|
+
const getAuthenticationInformationUrl = () => {
|
|
829
|
+
return `https://api.workos.com/_widgets/UserProfile/authentication-information`;
|
|
818
830
|
};
|
|
819
|
-
const
|
|
820
|
-
const res = await fetch(
|
|
831
|
+
const authenticationInformation = async (options) => {
|
|
832
|
+
const res = await fetch(getAuthenticationInformationUrl(), {
|
|
821
833
|
...options,
|
|
822
834
|
method: "GET"
|
|
823
835
|
});
|
|
824
836
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
825
837
|
const data = body ? JSON.parse(body) : {};
|
|
826
|
-
return {
|
|
838
|
+
return {
|
|
839
|
+
data,
|
|
840
|
+
status: res.status,
|
|
841
|
+
headers: res.headers
|
|
842
|
+
};
|
|
827
843
|
};
|
|
828
|
-
const
|
|
829
|
-
|
|
844
|
+
const getAuthenticationInformationKey = () => [
|
|
845
|
+
`https://api.workos.com/_widgets/UserProfile/authentication-information`
|
|
846
|
+
];
|
|
847
|
+
const useAuthenticationInformation = (options) => {
|
|
830
848
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
831
849
|
const isEnabled = swrOptions?.enabled !== false;
|
|
832
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
833
|
-
const swrFn = () =>
|
|
850
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getAuthenticationInformationKey() : null);
|
|
851
|
+
const swrFn = () => authenticationInformation(fetchOptions);
|
|
834
852
|
const query = useSwr(
|
|
835
853
|
swrKey,
|
|
836
854
|
swrFn,
|
|
@@ -841,11 +859,45 @@ const useSessions = (options) => {
|
|
|
841
859
|
...query
|
|
842
860
|
};
|
|
843
861
|
};
|
|
844
|
-
const
|
|
845
|
-
return `https://api.workos.com/_widgets/UserProfile/
|
|
862
|
+
const getCreatePasswordUrl = () => {
|
|
863
|
+
return `https://api.workos.com/_widgets/UserProfile/create-password`;
|
|
864
|
+
};
|
|
865
|
+
const createPassword = async (createPasswordRequest, options) => {
|
|
866
|
+
const res = await fetch(getCreatePasswordUrl(), {
|
|
867
|
+
...options,
|
|
868
|
+
method: "POST",
|
|
869
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
870
|
+
body: JSON.stringify(createPasswordRequest)
|
|
871
|
+
});
|
|
872
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
873
|
+
const data = body ? JSON.parse(body) : {};
|
|
874
|
+
return {
|
|
875
|
+
data,
|
|
876
|
+
status: res.status,
|
|
877
|
+
headers: res.headers
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
const getCreatePasswordMutationFetcher = (options) => {
|
|
881
|
+
return (_, { arg }) => {
|
|
882
|
+
return createPassword(arg, options);
|
|
883
|
+
};
|
|
884
|
+
};
|
|
885
|
+
const getCreatePasswordMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/create-password`];
|
|
886
|
+
const useCreatePassword = (options) => {
|
|
887
|
+
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
888
|
+
const swrKey = swrOptions?.swrKey ?? getCreatePasswordMutationKey();
|
|
889
|
+
const swrFn = getCreatePasswordMutationFetcher(fetchOptions);
|
|
890
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
891
|
+
return {
|
|
892
|
+
swrKey,
|
|
893
|
+
...query
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
const getCreateTotpFactorUrl = () => {
|
|
897
|
+
return `https://api.workos.com/_widgets/UserProfile/create-totp-factor`;
|
|
846
898
|
};
|
|
847
|
-
const
|
|
848
|
-
const res = await fetch(
|
|
899
|
+
const createTotpFactor = async (options) => {
|
|
900
|
+
const res = await fetch(getCreateTotpFactorUrl(), {
|
|
849
901
|
...options,
|
|
850
902
|
method: "POST"
|
|
851
903
|
});
|
|
@@ -857,46 +909,74 @@ const sendVerification = async (options) => {
|
|
|
857
909
|
headers: res.headers
|
|
858
910
|
};
|
|
859
911
|
};
|
|
860
|
-
const
|
|
912
|
+
const getCreateTotpFactorMutationFetcher = (options) => {
|
|
861
913
|
return (_, __) => {
|
|
862
|
-
return
|
|
914
|
+
return createTotpFactor(options);
|
|
863
915
|
};
|
|
864
916
|
};
|
|
865
|
-
const
|
|
866
|
-
const
|
|
917
|
+
const getCreateTotpFactorMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/create-totp-factor`];
|
|
918
|
+
const useCreateTotpFactor = (options) => {
|
|
867
919
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
868
|
-
const swrKey = swrOptions?.swrKey ??
|
|
869
|
-
const swrFn =
|
|
920
|
+
const swrKey = swrOptions?.swrKey ?? getCreateTotpFactorMutationKey();
|
|
921
|
+
const swrFn = getCreateTotpFactorMutationFetcher(fetchOptions);
|
|
870
922
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
871
923
|
return {
|
|
872
924
|
swrKey,
|
|
873
925
|
...query
|
|
874
926
|
};
|
|
875
927
|
};
|
|
876
|
-
const
|
|
877
|
-
return `https://api.workos.com/_widgets/UserProfile/
|
|
928
|
+
const getMeUrl = () => {
|
|
929
|
+
return `https://api.workos.com/_widgets/UserProfile/me`;
|
|
878
930
|
};
|
|
879
|
-
const
|
|
880
|
-
const res = await fetch(
|
|
931
|
+
const me = async (options) => {
|
|
932
|
+
const res = await fetch(getMeUrl(), {
|
|
933
|
+
...options,
|
|
934
|
+
method: "GET"
|
|
935
|
+
});
|
|
936
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
937
|
+
const data = body ? JSON.parse(body) : {};
|
|
938
|
+
return { data, status: res.status, headers: res.headers };
|
|
939
|
+
};
|
|
940
|
+
const getMeKey = () => [`https://api.workos.com/_widgets/UserProfile/me`];
|
|
941
|
+
const useMe = (options) => {
|
|
942
|
+
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
943
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
944
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getMeKey() : null);
|
|
945
|
+
const swrFn = () => me(fetchOptions);
|
|
946
|
+
const query = useSwr(
|
|
947
|
+
swrKey,
|
|
948
|
+
swrFn,
|
|
949
|
+
swrOptions
|
|
950
|
+
);
|
|
951
|
+
return {
|
|
952
|
+
swrKey,
|
|
953
|
+
...query
|
|
954
|
+
};
|
|
955
|
+
};
|
|
956
|
+
const getUpdateMeUrl = () => {
|
|
957
|
+
return `https://api.workos.com/_widgets/UserProfile/me`;
|
|
958
|
+
};
|
|
959
|
+
const updateMe = async (updateMeBody, options) => {
|
|
960
|
+
const res = await fetch(getUpdateMeUrl(), {
|
|
881
961
|
...options,
|
|
882
962
|
method: "POST",
|
|
883
963
|
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
884
|
-
body: JSON.stringify(
|
|
964
|
+
body: JSON.stringify(updateMeBody)
|
|
885
965
|
});
|
|
886
966
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
887
967
|
const data = body ? JSON.parse(body) : {};
|
|
888
968
|
return { data, status: res.status, headers: res.headers };
|
|
889
969
|
};
|
|
890
|
-
const
|
|
970
|
+
const getUpdateMeMutationFetcher = (options) => {
|
|
891
971
|
return (_, { arg }) => {
|
|
892
|
-
return
|
|
972
|
+
return updateMe(arg, options);
|
|
893
973
|
};
|
|
894
974
|
};
|
|
895
|
-
const
|
|
896
|
-
const
|
|
975
|
+
const getUpdateMeMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/me`];
|
|
976
|
+
const useUpdateMe = (options) => {
|
|
897
977
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
898
|
-
const swrKey = swrOptions?.swrKey ??
|
|
899
|
-
const swrFn =
|
|
978
|
+
const swrKey = swrOptions?.swrKey ?? getUpdateMeMutationKey();
|
|
979
|
+
const swrFn = getUpdateMeMutationFetcher(fetchOptions);
|
|
900
980
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
901
981
|
return {
|
|
902
982
|
swrKey,
|
|
@@ -1003,11 +1083,43 @@ const useDeletePasskey = (passkeyId, options) => {
|
|
|
1003
1083
|
...query
|
|
1004
1084
|
};
|
|
1005
1085
|
};
|
|
1006
|
-
const
|
|
1007
|
-
return `https://api.workos.com/_widgets/
|
|
1086
|
+
const getSendVerificationUrl = () => {
|
|
1087
|
+
return `https://api.workos.com/_widgets/UserProfile/send-verification`;
|
|
1008
1088
|
};
|
|
1009
|
-
const
|
|
1010
|
-
const res = await fetch(
|
|
1089
|
+
const sendVerification = async (options) => {
|
|
1090
|
+
const res = await fetch(getSendVerificationUrl(), {
|
|
1091
|
+
...options,
|
|
1092
|
+
method: "POST"
|
|
1093
|
+
});
|
|
1094
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1095
|
+
const data = body ? JSON.parse(body) : {};
|
|
1096
|
+
return {
|
|
1097
|
+
data,
|
|
1098
|
+
status: res.status,
|
|
1099
|
+
headers: res.headers
|
|
1100
|
+
};
|
|
1101
|
+
};
|
|
1102
|
+
const getSendVerificationMutationFetcher = (options) => {
|
|
1103
|
+
return (_, __) => {
|
|
1104
|
+
return sendVerification(options);
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
const getSendVerificationMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/send-verification`];
|
|
1108
|
+
const useSendVerification = (options) => {
|
|
1109
|
+
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1110
|
+
const swrKey = swrOptions?.swrKey ?? getSendVerificationMutationKey();
|
|
1111
|
+
const swrFn = getSendVerificationMutationFetcher(fetchOptions);
|
|
1112
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1113
|
+
return {
|
|
1114
|
+
swrKey,
|
|
1115
|
+
...query
|
|
1116
|
+
};
|
|
1117
|
+
};
|
|
1118
|
+
const getSessionsUrl = () => {
|
|
1119
|
+
return `https://api.workos.com/_widgets/UserProfile/sessions`;
|
|
1120
|
+
};
|
|
1121
|
+
const sessions = async (options) => {
|
|
1122
|
+
const res = await fetch(getSessionsUrl(), {
|
|
1011
1123
|
...options,
|
|
1012
1124
|
method: "GET"
|
|
1013
1125
|
});
|
|
@@ -1015,12 +1127,12 @@ const settings = async (options) => {
|
|
|
1015
1127
|
const data = body ? JSON.parse(body) : {};
|
|
1016
1128
|
return { data, status: res.status, headers: res.headers };
|
|
1017
1129
|
};
|
|
1018
|
-
const
|
|
1019
|
-
const
|
|
1130
|
+
const getSessionsKey = () => [`https://api.workos.com/_widgets/UserProfile/sessions`];
|
|
1131
|
+
const useSessions = (options) => {
|
|
1020
1132
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1021
1133
|
const isEnabled = swrOptions?.enabled !== false;
|
|
1022
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
1023
|
-
const swrFn = () =>
|
|
1134
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getSessionsKey() : null);
|
|
1135
|
+
const swrFn = () => sessions(fetchOptions);
|
|
1024
1136
|
const query = useSwr(
|
|
1025
1137
|
swrKey,
|
|
1026
1138
|
swrFn,
|
|
@@ -1031,13 +1143,15 @@ const useSettings = (options) => {
|
|
|
1031
1143
|
...query
|
|
1032
1144
|
};
|
|
1033
1145
|
};
|
|
1034
|
-
const
|
|
1035
|
-
return `https://api.workos.com/_widgets/
|
|
1146
|
+
const getRevokeAllSessionsUrl = () => {
|
|
1147
|
+
return `https://api.workos.com/_widgets/UserProfile/sessions/revoke-all`;
|
|
1036
1148
|
};
|
|
1037
|
-
const
|
|
1038
|
-
const res = await fetch(
|
|
1149
|
+
const revokeAllSessions = async (revokeAllSessionsRequest, options) => {
|
|
1150
|
+
const res = await fetch(getRevokeAllSessionsUrl(), {
|
|
1039
1151
|
...options,
|
|
1040
|
-
method: "
|
|
1152
|
+
method: "DELETE",
|
|
1153
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
1154
|
+
body: JSON.stringify(revokeAllSessionsRequest)
|
|
1041
1155
|
});
|
|
1042
1156
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1043
1157
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1047,38 +1161,29 @@ const listOrganizationDomains = async (options) => {
|
|
|
1047
1161
|
headers: res.headers
|
|
1048
1162
|
};
|
|
1049
1163
|
};
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1164
|
+
const getRevokeAllSessionsMutationFetcher = (options) => {
|
|
1165
|
+
return (_, { arg }) => {
|
|
1166
|
+
return revokeAllSessions(arg, options);
|
|
1167
|
+
};
|
|
1168
|
+
};
|
|
1169
|
+
const getRevokeAllSessionsMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/sessions/revoke-all`];
|
|
1170
|
+
const useRevokeAllSessions = (options) => {
|
|
1054
1171
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1055
|
-
const
|
|
1056
|
-
const
|
|
1057
|
-
const
|
|
1058
|
-
const query = useSwr(
|
|
1059
|
-
swrKey,
|
|
1060
|
-
swrFn,
|
|
1061
|
-
swrOptions
|
|
1062
|
-
);
|
|
1172
|
+
const swrKey = swrOptions?.swrKey ?? getRevokeAllSessionsMutationKey();
|
|
1173
|
+
const swrFn = getRevokeAllSessionsMutationFetcher(fetchOptions);
|
|
1174
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1063
1175
|
return {
|
|
1064
1176
|
swrKey,
|
|
1065
1177
|
...query
|
|
1066
1178
|
};
|
|
1067
1179
|
};
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1071
|
-
if (value !== void 0) {
|
|
1072
|
-
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
const stringifiedParams = normalizedParams.toString();
|
|
1076
|
-
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/admin-portal/generate-link?${stringifiedParams}` : `https://api.workos.com/_widgets/admin-portal/generate-link`;
|
|
1180
|
+
const getRevokeSessionUrl = (sessionId) => {
|
|
1181
|
+
return `https://api.workos.com/_widgets/UserProfile/sessions/revoke/${sessionId}`;
|
|
1077
1182
|
};
|
|
1078
|
-
const
|
|
1079
|
-
const res = await fetch(
|
|
1183
|
+
const revokeSession = async (sessionId, options) => {
|
|
1184
|
+
const res = await fetch(getRevokeSessionUrl(sessionId), {
|
|
1080
1185
|
...options,
|
|
1081
|
-
method: "
|
|
1186
|
+
method: "DELETE"
|
|
1082
1187
|
});
|
|
1083
1188
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1084
1189
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1088,30 +1193,29 @@ const generateAdminPortalLink = async (params, options) => {
|
|
|
1088
1193
|
headers: res.headers
|
|
1089
1194
|
};
|
|
1090
1195
|
};
|
|
1091
|
-
const
|
|
1196
|
+
const getRevokeSessionMutationFetcher = (sessionId, options) => {
|
|
1092
1197
|
return (_, __) => {
|
|
1093
|
-
return
|
|
1198
|
+
return revokeSession(sessionId, options);
|
|
1094
1199
|
};
|
|
1095
1200
|
};
|
|
1096
|
-
const
|
|
1097
|
-
`https://api.workos.com/_widgets/
|
|
1098
|
-
...params ? [params] : []
|
|
1201
|
+
const getRevokeSessionMutationKey = (sessionId) => [
|
|
1202
|
+
`https://api.workos.com/_widgets/UserProfile/sessions/revoke/${sessionId}`
|
|
1099
1203
|
];
|
|
1100
|
-
const
|
|
1204
|
+
const useRevokeSession = (sessionId, options) => {
|
|
1101
1205
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1102
|
-
const swrKey = swrOptions?.swrKey ??
|
|
1103
|
-
const swrFn =
|
|
1206
|
+
const swrKey = swrOptions?.swrKey ?? getRevokeSessionMutationKey(sessionId);
|
|
1207
|
+
const swrFn = getRevokeSessionMutationFetcher(sessionId, fetchOptions);
|
|
1104
1208
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1105
1209
|
return {
|
|
1106
1210
|
swrKey,
|
|
1107
1211
|
...query
|
|
1108
1212
|
};
|
|
1109
1213
|
};
|
|
1110
|
-
const
|
|
1111
|
-
return `https://api.workos.com/_widgets/
|
|
1214
|
+
const getDeleteTotpFactorsUrl = () => {
|
|
1215
|
+
return `https://api.workos.com/_widgets/UserProfile/totp-factors`;
|
|
1112
1216
|
};
|
|
1113
|
-
const
|
|
1114
|
-
const res = await fetch(
|
|
1217
|
+
const deleteTotpFactors = async (options) => {
|
|
1218
|
+
const res = await fetch(getDeleteTotpFactorsUrl(), {
|
|
1115
1219
|
...options,
|
|
1116
1220
|
method: "DELETE"
|
|
1117
1221
|
});
|
|
@@ -1123,34 +1227,31 @@ const deleteOrganizationDomain = async (domainId, options) => {
|
|
|
1123
1227
|
headers: res.headers
|
|
1124
1228
|
};
|
|
1125
1229
|
};
|
|
1126
|
-
const
|
|
1230
|
+
const getDeleteTotpFactorsMutationFetcher = (options) => {
|
|
1127
1231
|
return (_, __) => {
|
|
1128
|
-
return
|
|
1232
|
+
return deleteTotpFactors(options);
|
|
1129
1233
|
};
|
|
1130
1234
|
};
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1133
|
-
];
|
|
1134
|
-
const useDeleteOrganizationDomain = (domainId, options) => {
|
|
1235
|
+
const getDeleteTotpFactorsMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/totp-factors`];
|
|
1236
|
+
const useDeleteTotpFactors = (options) => {
|
|
1135
1237
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1136
|
-
const swrKey = swrOptions?.swrKey ??
|
|
1137
|
-
const swrFn =
|
|
1138
|
-
domainId,
|
|
1139
|
-
fetchOptions
|
|
1140
|
-
);
|
|
1238
|
+
const swrKey = swrOptions?.swrKey ?? getDeleteTotpFactorsMutationKey();
|
|
1239
|
+
const swrFn = getDeleteTotpFactorsMutationFetcher(fetchOptions);
|
|
1141
1240
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1142
1241
|
return {
|
|
1143
1242
|
swrKey,
|
|
1144
1243
|
...query
|
|
1145
1244
|
};
|
|
1146
1245
|
};
|
|
1147
|
-
const
|
|
1148
|
-
return `https://api.workos.com/_widgets/
|
|
1246
|
+
const getUpdatePasswordUrl = () => {
|
|
1247
|
+
return `https://api.workos.com/_widgets/UserProfile/update-password`;
|
|
1149
1248
|
};
|
|
1150
|
-
const
|
|
1151
|
-
const res = await fetch(
|
|
1249
|
+
const updatePassword = async (updatePasswordRequest, options) => {
|
|
1250
|
+
const res = await fetch(getUpdatePasswordUrl(), {
|
|
1152
1251
|
...options,
|
|
1153
|
-
method: "POST"
|
|
1252
|
+
method: "POST",
|
|
1253
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
1254
|
+
body: JSON.stringify(updatePasswordRequest)
|
|
1154
1255
|
});
|
|
1155
1256
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1156
1257
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1160,68 +1261,61 @@ const reverifyOrganizationDomain = async (domainId, options) => {
|
|
|
1160
1261
|
headers: res.headers
|
|
1161
1262
|
};
|
|
1162
1263
|
};
|
|
1163
|
-
const
|
|
1164
|
-
return (_,
|
|
1165
|
-
return
|
|
1264
|
+
const getUpdatePasswordMutationFetcher = (options) => {
|
|
1265
|
+
return (_, { arg }) => {
|
|
1266
|
+
return updatePassword(arg, options);
|
|
1166
1267
|
};
|
|
1167
1268
|
};
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
];
|
|
1171
|
-
const useReverifyOrganizationDomain = (domainId, options) => {
|
|
1269
|
+
const getUpdatePasswordMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/update-password`];
|
|
1270
|
+
const useUpdatePassword = (options) => {
|
|
1172
1271
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1173
|
-
const swrKey = swrOptions?.swrKey ??
|
|
1174
|
-
const swrFn =
|
|
1175
|
-
domainId,
|
|
1176
|
-
fetchOptions
|
|
1177
|
-
);
|
|
1272
|
+
const swrKey = swrOptions?.swrKey ?? getUpdatePasswordMutationKey();
|
|
1273
|
+
const swrFn = getUpdatePasswordMutationFetcher(fetchOptions);
|
|
1178
1274
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1179
1275
|
return {
|
|
1180
1276
|
swrKey,
|
|
1181
1277
|
...query
|
|
1182
1278
|
};
|
|
1183
1279
|
};
|
|
1184
|
-
const
|
|
1185
|
-
return `https://api.workos.com/_widgets/
|
|
1280
|
+
const getVerifyUrl = () => {
|
|
1281
|
+
return `https://api.workos.com/_widgets/UserProfile/verify`;
|
|
1186
1282
|
};
|
|
1187
|
-
const
|
|
1188
|
-
const res = await fetch(
|
|
1283
|
+
const verify = async (verifyRequest, options) => {
|
|
1284
|
+
const res = await fetch(getVerifyUrl(), {
|
|
1189
1285
|
...options,
|
|
1190
|
-
method: "
|
|
1286
|
+
method: "POST",
|
|
1287
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
1288
|
+
body: JSON.stringify(verifyRequest)
|
|
1191
1289
|
});
|
|
1192
1290
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1193
1291
|
const data = body ? JSON.parse(body) : {};
|
|
1194
|
-
return {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1292
|
+
return { data, status: res.status, headers: res.headers };
|
|
1293
|
+
};
|
|
1294
|
+
const getVerifyMutationFetcher = (options) => {
|
|
1295
|
+
return (_, { arg }) => {
|
|
1296
|
+
return verify(arg, options);
|
|
1198
1297
|
};
|
|
1199
1298
|
};
|
|
1200
|
-
const
|
|
1201
|
-
const
|
|
1299
|
+
const getVerifyMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/verify`];
|
|
1300
|
+
const useVerify = (options) => {
|
|
1202
1301
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1203
|
-
const
|
|
1204
|
-
const
|
|
1205
|
-
const
|
|
1206
|
-
const query = useSwr(
|
|
1207
|
-
swrKey,
|
|
1208
|
-
swrFn,
|
|
1209
|
-
swrOptions
|
|
1210
|
-
);
|
|
1302
|
+
const swrKey = swrOptions?.swrKey ?? getVerifyMutationKey();
|
|
1303
|
+
const swrFn = getVerifyMutationFetcher(fetchOptions);
|
|
1304
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1211
1305
|
return {
|
|
1212
1306
|
swrKey,
|
|
1213
1307
|
...query
|
|
1214
1308
|
};
|
|
1215
1309
|
};
|
|
1216
|
-
const
|
|
1217
|
-
return `https://api.workos.com/_widgets/
|
|
1310
|
+
const getVerifyTotpFactorUrl = () => {
|
|
1311
|
+
return `https://api.workos.com/_widgets/UserProfile/verify-totp-factor`;
|
|
1218
1312
|
};
|
|
1219
|
-
const
|
|
1220
|
-
const res = await fetch(
|
|
1313
|
+
const verifyTotpFactor = async (verifyTotpFactorRequest, options) => {
|
|
1314
|
+
const res = await fetch(getVerifyTotpFactorUrl(), {
|
|
1221
1315
|
...options,
|
|
1222
1316
|
method: "POST",
|
|
1223
1317
|
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
1224
|
-
body: JSON.stringify(
|
|
1318
|
+
body: JSON.stringify(verifyTotpFactorRequest)
|
|
1225
1319
|
});
|
|
1226
1320
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1227
1321
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1231,23 +1325,23 @@ const createOrganizationApiKey = async (createOrganizationApiKeyRequest, options
|
|
|
1231
1325
|
headers: res.headers
|
|
1232
1326
|
};
|
|
1233
1327
|
};
|
|
1234
|
-
const
|
|
1328
|
+
const getVerifyTotpFactorMutationFetcher = (options) => {
|
|
1235
1329
|
return (_, { arg }) => {
|
|
1236
|
-
return
|
|
1330
|
+
return verifyTotpFactor(arg, options);
|
|
1237
1331
|
};
|
|
1238
1332
|
};
|
|
1239
|
-
const
|
|
1240
|
-
const
|
|
1333
|
+
const getVerifyTotpFactorMutationKey = () => [`https://api.workos.com/_widgets/UserProfile/verify-totp-factor`];
|
|
1334
|
+
const useVerifyTotpFactor = (options) => {
|
|
1241
1335
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1242
|
-
const swrKey = swrOptions?.swrKey ??
|
|
1243
|
-
const swrFn =
|
|
1336
|
+
const swrKey = swrOptions?.swrKey ?? getVerifyTotpFactorMutationKey();
|
|
1337
|
+
const swrFn = getVerifyTotpFactorMutationFetcher(fetchOptions);
|
|
1244
1338
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1245
1339
|
return {
|
|
1246
1340
|
swrKey,
|
|
1247
1341
|
...query
|
|
1248
1342
|
};
|
|
1249
1343
|
};
|
|
1250
|
-
const
|
|
1344
|
+
const getGenerateAdminPortalLinkUrl = (params) => {
|
|
1251
1345
|
const normalizedParams = new URLSearchParams();
|
|
1252
1346
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1253
1347
|
if (value !== void 0) {
|
|
@@ -1255,12 +1349,12 @@ const getListOrganizationApiKeysUrl = (params) => {
|
|
|
1255
1349
|
}
|
|
1256
1350
|
});
|
|
1257
1351
|
const stringifiedParams = normalizedParams.toString();
|
|
1258
|
-
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/
|
|
1352
|
+
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/admin-portal/generate-link?${stringifiedParams}` : `https://api.workos.com/_widgets/admin-portal/generate-link`;
|
|
1259
1353
|
};
|
|
1260
|
-
const
|
|
1261
|
-
const res = await fetch(
|
|
1354
|
+
const generateAdminPortalLink = async (params, options) => {
|
|
1355
|
+
const res = await fetch(getGenerateAdminPortalLinkUrl(params), {
|
|
1262
1356
|
...options,
|
|
1263
|
-
method: "
|
|
1357
|
+
method: "POST"
|
|
1264
1358
|
});
|
|
1265
1359
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1266
1360
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1270,37 +1364,30 @@ const listOrganizationApiKeys = async (params, options) => {
|
|
|
1270
1364
|
headers: res.headers
|
|
1271
1365
|
};
|
|
1272
1366
|
};
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1367
|
+
const getGenerateAdminPortalLinkMutationFetcher = (params, options) => {
|
|
1368
|
+
return (_, __) => {
|
|
1369
|
+
return generateAdminPortalLink(params, options);
|
|
1370
|
+
};
|
|
1371
|
+
};
|
|
1372
|
+
const getGenerateAdminPortalLinkMutationKey = (params) => [
|
|
1373
|
+
`https://api.workos.com/_widgets/admin-portal/generate-link`,
|
|
1275
1374
|
...params ? [params] : []
|
|
1276
1375
|
];
|
|
1277
|
-
const
|
|
1376
|
+
const useGenerateAdminPortalLink = (params, options) => {
|
|
1278
1377
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1279
|
-
const
|
|
1280
|
-
const
|
|
1281
|
-
const
|
|
1282
|
-
const query = useSwr(
|
|
1283
|
-
swrKey,
|
|
1284
|
-
swrFn,
|
|
1285
|
-
swrOptions
|
|
1286
|
-
);
|
|
1378
|
+
const swrKey = swrOptions?.swrKey ?? getGenerateAdminPortalLinkMutationKey(params);
|
|
1379
|
+
const swrFn = getGenerateAdminPortalLinkMutationFetcher(params, fetchOptions);
|
|
1380
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1287
1381
|
return {
|
|
1288
1382
|
swrKey,
|
|
1289
1383
|
...query
|
|
1290
1384
|
};
|
|
1291
1385
|
};
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1295
|
-
if (value !== void 0) {
|
|
1296
|
-
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
const stringifiedParams = normalizedParams.toString();
|
|
1300
|
-
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/ApiKeys/permissions?${stringifiedParams}` : `https://api.workos.com/_widgets/ApiKeys/permissions`;
|
|
1386
|
+
const getListOrganizationDomainsUrl = () => {
|
|
1387
|
+
return `https://api.workos.com/_widgets/admin-portal/organization-domains`;
|
|
1301
1388
|
};
|
|
1302
|
-
const
|
|
1303
|
-
const res = await fetch(
|
|
1389
|
+
const listOrganizationDomains = async (options) => {
|
|
1390
|
+
const res = await fetch(getListOrganizationDomainsUrl(), {
|
|
1304
1391
|
...options,
|
|
1305
1392
|
method: "GET"
|
|
1306
1393
|
});
|
|
@@ -1312,15 +1399,14 @@ const listOrganizationApiKeyPermissions = async (params, options) => {
|
|
|
1312
1399
|
headers: res.headers
|
|
1313
1400
|
};
|
|
1314
1401
|
};
|
|
1315
|
-
const
|
|
1316
|
-
`https://api.workos.com/_widgets/
|
|
1317
|
-
...params ? [params] : []
|
|
1402
|
+
const getListOrganizationDomainsKey = () => [
|
|
1403
|
+
`https://api.workos.com/_widgets/admin-portal/organization-domains`
|
|
1318
1404
|
];
|
|
1319
|
-
const
|
|
1405
|
+
const useListOrganizationDomains = (options) => {
|
|
1320
1406
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1321
1407
|
const isEnabled = swrOptions?.enabled !== false;
|
|
1322
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
1323
|
-
const swrFn = () =>
|
|
1408
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getListOrganizationDomainsKey() : null);
|
|
1409
|
+
const swrFn = () => listOrganizationDomains(fetchOptions);
|
|
1324
1410
|
const query = useSwr(
|
|
1325
1411
|
swrKey,
|
|
1326
1412
|
swrFn,
|
|
@@ -1331,11 +1417,11 @@ const useListOrganizationApiKeyPermissions = (params, options) => {
|
|
|
1331
1417
|
...query
|
|
1332
1418
|
};
|
|
1333
1419
|
};
|
|
1334
|
-
const
|
|
1335
|
-
return `https://api.workos.com/_widgets/
|
|
1420
|
+
const getDeleteOrganizationDomainUrl = (domainId) => {
|
|
1421
|
+
return `https://api.workos.com/_widgets/admin-portal/organization-domains/${domainId}`;
|
|
1336
1422
|
};
|
|
1337
|
-
const
|
|
1338
|
-
const res = await fetch(
|
|
1423
|
+
const deleteOrganizationDomain = async (domainId, options) => {
|
|
1424
|
+
const res = await fetch(getDeleteOrganizationDomainUrl(domainId), {
|
|
1339
1425
|
...options,
|
|
1340
1426
|
method: "DELETE"
|
|
1341
1427
|
});
|
|
@@ -1347,17 +1433,19 @@ const deleteOrganizationApiKey = async (apiKeyId, options) => {
|
|
|
1347
1433
|
headers: res.headers
|
|
1348
1434
|
};
|
|
1349
1435
|
};
|
|
1350
|
-
const
|
|
1436
|
+
const getDeleteOrganizationDomainMutationFetcher = (domainId, options) => {
|
|
1351
1437
|
return (_, __) => {
|
|
1352
|
-
return
|
|
1438
|
+
return deleteOrganizationDomain(domainId, options);
|
|
1353
1439
|
};
|
|
1354
1440
|
};
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1441
|
+
const getDeleteOrganizationDomainMutationKey = (domainId) => [
|
|
1442
|
+
`https://api.workos.com/_widgets/admin-portal/organization-domains/${domainId}`
|
|
1443
|
+
];
|
|
1444
|
+
const useDeleteOrganizationDomain = (domainId, options) => {
|
|
1357
1445
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1358
|
-
const swrKey = swrOptions?.swrKey ??
|
|
1359
|
-
const swrFn =
|
|
1360
|
-
|
|
1446
|
+
const swrKey = swrOptions?.swrKey ?? getDeleteOrganizationDomainMutationKey(domainId);
|
|
1447
|
+
const swrFn = getDeleteOrganizationDomainMutationFetcher(
|
|
1448
|
+
domainId,
|
|
1361
1449
|
fetchOptions
|
|
1362
1450
|
);
|
|
1363
1451
|
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
@@ -1366,13 +1454,13 @@ const useDeleteOrganizationApiKey = (apiKeyId, options) => {
|
|
|
1366
1454
|
...query
|
|
1367
1455
|
};
|
|
1368
1456
|
};
|
|
1369
|
-
const
|
|
1370
|
-
return `https://api.workos.com/_widgets/
|
|
1457
|
+
const getReverifyOrganizationDomainUrl = (domainId) => {
|
|
1458
|
+
return `https://api.workos.com/_widgets/admin-portal/organization-domains/${domainId}/reverify`;
|
|
1371
1459
|
};
|
|
1372
|
-
const
|
|
1373
|
-
const res = await fetch(
|
|
1460
|
+
const reverifyOrganizationDomain = async (domainId, options) => {
|
|
1461
|
+
const res = await fetch(getReverifyOrganizationDomainUrl(domainId), {
|
|
1374
1462
|
...options,
|
|
1375
|
-
method: "
|
|
1463
|
+
method: "POST"
|
|
1376
1464
|
});
|
|
1377
1465
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1378
1466
|
const data = body ? JSON.parse(body) : {};
|
|
@@ -1382,34 +1470,32 @@ const myDataIntegrations = async (options) => {
|
|
|
1382
1470
|
headers: res.headers
|
|
1383
1471
|
};
|
|
1384
1472
|
};
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1473
|
+
const getReverifyOrganizationDomainMutationFetcher = (domainId, options) => {
|
|
1474
|
+
return (_, __) => {
|
|
1475
|
+
return reverifyOrganizationDomain(domainId, options);
|
|
1476
|
+
};
|
|
1477
|
+
};
|
|
1478
|
+
const getReverifyOrganizationDomainMutationKey = (domainId) => [
|
|
1479
|
+
`https://api.workos.com/_widgets/admin-portal/organization-domains/${domainId}/reverify`
|
|
1480
|
+
];
|
|
1481
|
+
const useReverifyOrganizationDomain = (domainId, options) => {
|
|
1387
1482
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1388
|
-
const
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
swrKey,
|
|
1393
|
-
swrFn,
|
|
1394
|
-
swrOptions
|
|
1483
|
+
const swrKey = swrOptions?.swrKey ?? getReverifyOrganizationDomainMutationKey(domainId);
|
|
1484
|
+
const swrFn = getReverifyOrganizationDomainMutationFetcher(
|
|
1485
|
+
domainId,
|
|
1486
|
+
fetchOptions
|
|
1395
1487
|
);
|
|
1488
|
+
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1396
1489
|
return {
|
|
1397
1490
|
swrKey,
|
|
1398
1491
|
...query
|
|
1399
1492
|
};
|
|
1400
1493
|
};
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1404
|
-
if (value !== void 0) {
|
|
1405
|
-
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
const stringifiedParams = normalizedParams.toString();
|
|
1409
|
-
return stringifiedParams.length > 0 ? `https://api.workos.com/_widgets/DataIntegrations/${slug}/authorize?${stringifiedParams}` : `https://api.workos.com/_widgets/DataIntegrations/${slug}/authorize`;
|
|
1494
|
+
const getListSsoConnectionsUrl = () => {
|
|
1495
|
+
return `https://api.workos.com/_widgets/admin-portal/sso-connections`;
|
|
1410
1496
|
};
|
|
1411
|
-
const
|
|
1412
|
-
const res = await fetch(
|
|
1497
|
+
const listSsoConnections = async (options) => {
|
|
1498
|
+
const res = await fetch(getListSsoConnectionsUrl(), {
|
|
1413
1499
|
...options,
|
|
1414
1500
|
method: "GET"
|
|
1415
1501
|
});
|
|
@@ -1421,15 +1507,12 @@ const getDataIntegrationAuthorizeUrl = async (slug, params, options) => {
|
|
|
1421
1507
|
headers: res.headers
|
|
1422
1508
|
};
|
|
1423
1509
|
};
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
...params ? [params] : []
|
|
1427
|
-
];
|
|
1428
|
-
const useGetDataIntegrationAuthorizeUrl = (slug, params, options) => {
|
|
1510
|
+
const getListSsoConnectionsKey = () => [`https://api.workos.com/_widgets/admin-portal/sso-connections`];
|
|
1511
|
+
const useListSsoConnections = (options) => {
|
|
1429
1512
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1430
|
-
const isEnabled = swrOptions?.enabled !== false
|
|
1431
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
1432
|
-
const swrFn = () =>
|
|
1513
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
1514
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getListSsoConnectionsKey() : null);
|
|
1515
|
+
const swrFn = () => listSsoConnections(fetchOptions);
|
|
1433
1516
|
const query = useSwr(
|
|
1434
1517
|
swrKey,
|
|
1435
1518
|
swrFn,
|
|
@@ -1440,17 +1523,14 @@ const useGetDataIntegrationAuthorizeUrl = (slug, params, options) => {
|
|
|
1440
1523
|
...query
|
|
1441
1524
|
};
|
|
1442
1525
|
};
|
|
1443
|
-
const
|
|
1444
|
-
return `https://api.workos.com/_widgets/
|
|
1526
|
+
const getListDirectoriesUrl = () => {
|
|
1527
|
+
return `https://api.workos.com/_widgets/directory-sync/directories`;
|
|
1445
1528
|
};
|
|
1446
|
-
const
|
|
1447
|
-
const res = await fetch(
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
method: "GET"
|
|
1452
|
-
}
|
|
1453
|
-
);
|
|
1529
|
+
const listDirectories = async (options) => {
|
|
1530
|
+
const res = await fetch(getListDirectoriesUrl(), {
|
|
1531
|
+
...options,
|
|
1532
|
+
method: "GET"
|
|
1533
|
+
});
|
|
1454
1534
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1455
1535
|
const data = body ? JSON.parse(body) : {};
|
|
1456
1536
|
return {
|
|
@@ -1459,18 +1539,12 @@ const getDataInstallationAuthorizationStatus = async (dataIntegrationId, state,
|
|
|
1459
1539
|
headers: res.headers
|
|
1460
1540
|
};
|
|
1461
1541
|
};
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1464
|
-
];
|
|
1465
|
-
const useGetDataInstallationAuthorizationStatus = (dataIntegrationId, state, options) => {
|
|
1542
|
+
const getListDirectoriesKey = () => [`https://api.workos.com/_widgets/directory-sync/directories`];
|
|
1543
|
+
const useListDirectories = (options) => {
|
|
1466
1544
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1467
|
-
const isEnabled = swrOptions?.enabled !== false
|
|
1468
|
-
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ?
|
|
1469
|
-
const swrFn = () =>
|
|
1470
|
-
dataIntegrationId,
|
|
1471
|
-
state,
|
|
1472
|
-
fetchOptions
|
|
1473
|
-
);
|
|
1545
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
1546
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getListDirectoriesKey() : null);
|
|
1547
|
+
const swrFn = () => listDirectories(fetchOptions);
|
|
1474
1548
|
const query = useSwr(
|
|
1475
1549
|
swrKey,
|
|
1476
1550
|
swrFn,
|
|
@@ -1481,56 +1555,49 @@ const useGetDataInstallationAuthorizationStatus = (dataIntegrationId, state, opt
|
|
|
1481
1555
|
...query
|
|
1482
1556
|
};
|
|
1483
1557
|
};
|
|
1484
|
-
const
|
|
1485
|
-
return `https://api.workos.com/_widgets/
|
|
1558
|
+
const getSettingsUrl = () => {
|
|
1559
|
+
return `https://api.workos.com/_widgets/settings`;
|
|
1486
1560
|
};
|
|
1487
|
-
const
|
|
1488
|
-
const res = await fetch(
|
|
1561
|
+
const settings = async (options) => {
|
|
1562
|
+
const res = await fetch(getSettingsUrl(), {
|
|
1489
1563
|
...options,
|
|
1490
|
-
method: "
|
|
1564
|
+
method: "GET"
|
|
1491
1565
|
});
|
|
1492
1566
|
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1493
1567
|
const data = body ? JSON.parse(body) : {};
|
|
1494
|
-
return {
|
|
1495
|
-
data,
|
|
1496
|
-
status: res.status,
|
|
1497
|
-
headers: res.headers
|
|
1498
|
-
};
|
|
1499
|
-
};
|
|
1500
|
-
const getDeleteDataInstallationMutationFetcher = (installationId, options) => {
|
|
1501
|
-
return (_, __) => {
|
|
1502
|
-
return deleteDataInstallation(installationId, options);
|
|
1503
|
-
};
|
|
1568
|
+
return { data, status: res.status, headers: res.headers };
|
|
1504
1569
|
};
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
];
|
|
1508
|
-
const useDeleteDataInstallation = (installationId, options) => {
|
|
1570
|
+
const getSettingsKey = () => [`https://api.workos.com/_widgets/settings`];
|
|
1571
|
+
const useSettings = (options) => {
|
|
1509
1572
|
const { swr: swrOptions, fetch: fetchOptions } = options ?? {};
|
|
1510
|
-
const
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1573
|
+
const isEnabled = swrOptions?.enabled !== false;
|
|
1574
|
+
const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getSettingsKey() : null);
|
|
1575
|
+
const swrFn = () => settings(fetchOptions);
|
|
1576
|
+
const query = useSwr(
|
|
1577
|
+
swrKey,
|
|
1578
|
+
swrFn,
|
|
1579
|
+
swrOptions
|
|
1514
1580
|
);
|
|
1515
|
-
const query = useSWRMutation(swrKey, swrFn, swrOptions);
|
|
1516
1581
|
return {
|
|
1517
1582
|
swrKey,
|
|
1518
1583
|
...query
|
|
1519
1584
|
};
|
|
1520
1585
|
};
|
|
1521
1586
|
export {
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1587
|
+
AuthenticationInformationResponseDataVerificationMethodsMfaOneOfProvider,
|
|
1588
|
+
AuthenticationInformationResponseDataVerificationMethodsPasskeyOneOfProvider,
|
|
1589
|
+
AuthenticationInformationResponseDataVerificationMethodsPasswordOneOfProvider,
|
|
1525
1590
|
CreateTotpFactorResponseAuthenticationChallengeAllOfObject,
|
|
1526
1591
|
CreateTotpFactorResponseAuthenticationFactorAllOfObject,
|
|
1527
1592
|
CreateTotpFactorResponseAuthenticationFactorAllOfType,
|
|
1528
|
-
|
|
1529
|
-
|
|
1593
|
+
DataInstallationAllOfObject,
|
|
1594
|
+
DataInstallationAllOfState,
|
|
1530
1595
|
DataIntegrationCredentialsType,
|
|
1531
1596
|
DataIntegrationIntegrationType,
|
|
1532
1597
|
DataIntegrationObject,
|
|
1533
1598
|
DataIntegrationOwnership,
|
|
1599
|
+
DirectoryState,
|
|
1600
|
+
DirectoryType,
|
|
1534
1601
|
DomainVerificationNameServer,
|
|
1535
1602
|
GenerateAdminPortalLinkIntent,
|
|
1536
1603
|
MemberActionsItem,
|
|
@@ -1595,6 +1662,8 @@ export {
|
|
|
1595
1662
|
getInviteMemberMutationFetcher,
|
|
1596
1663
|
getInviteMemberMutationKey,
|
|
1597
1664
|
getInviteMemberUrl,
|
|
1665
|
+
getListDirectoriesKey,
|
|
1666
|
+
getListDirectoriesUrl,
|
|
1598
1667
|
getListOrganizationApiKeyPermissionsKey,
|
|
1599
1668
|
getListOrganizationApiKeyPermissionsUrl,
|
|
1600
1669
|
getListOrganizationApiKeysKey,
|
|
@@ -1662,6 +1731,7 @@ export {
|
|
|
1662
1731
|
getVerifyTotpFactorUrl,
|
|
1663
1732
|
getVerifyUrl,
|
|
1664
1733
|
inviteMember,
|
|
1734
|
+
listDirectories,
|
|
1665
1735
|
listOrganizationApiKeyPermissions,
|
|
1666
1736
|
listOrganizationApiKeys,
|
|
1667
1737
|
listOrganizationDomains,
|
|
@@ -1698,6 +1768,7 @@ export {
|
|
|
1698
1768
|
useGetDataInstallationAuthorizationStatus,
|
|
1699
1769
|
useGetDataIntegrationAuthorizeUrl,
|
|
1700
1770
|
useInviteMember,
|
|
1771
|
+
useListDirectories,
|
|
1701
1772
|
useListOrganizationApiKeyPermissions,
|
|
1702
1773
|
useListOrganizationApiKeys,
|
|
1703
1774
|
useListOrganizationDomains,
|