export type IOrgUserSecurity = {mfaEnabled: boolean}; export type CreateApiUsersIdSecurityArgs = {id: string, orgkey?: string | undefined, body: IOrgUserSecurity}; export type CreateApiUsersIdSecurityOptions = {baseUrl?: string | undefined, cognitoJwtAuthorizer?: string | undefined, fetch?: typeof fetch | undefined}; /** * updateUserSecurity * * POST /users/{id}/security */ export const createApiUsersIdSecurity = async (args: CreateApiUsersIdSecurityArgs, options?: CreateApiUsersIdSecurityOptions) => { const {baseUrl = "https://api-hub.extensiv.com", fetch: fetchFn = fetch, cognitoJwtAuthorizer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.orgkey != null) query.append("orgkey", String(args.orgkey)) if (cognitoJwtAuthorizer !== undefined) headers.set('authorization', `Bearer ${cognitoJwtAuthorizer}`) const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.id))}/security${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };