UNPKG

@fusionauth/typescript-client

Version:
1,139 lines 239 kB
"use strict"; /* * Copyright (c) 2019-2023, FusionAuth, All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific * language governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.IdentityProviderLoginMethod = exports.ClientAuthenticationMethod = exports.OAuthErrorReason = exports.WebAuthnWorkflow = exports.Oauth2AuthorizedURLValidationPolicy = exports.LogoutBehavior = exports.RateLimitedRequestType = exports.CanonicalizationMethod = exports.SecureGeneratorType = exports.VerificationStrategy = exports.UniqueUsernameStrategy = exports.LDAPSecurityMethod = exports.TOTPAlgorithm = exports.EventType = exports.IdentityProviderType = exports.MessengerType = exports.ExpiryUnit = exports.EmailSecurityType = exports.ChangePasswordReason = exports.SteamAPIMode = exports.UserVerificationRequirement = exports.TransactionType = exports.FamilyRole = exports.KeyUse = exports.Algorithm = exports.EventLogType = exports.BreachAction = exports.IdentityProviderLinkingStrategy = exports.SAMLLogoutBehavior = exports.Sort = exports.OAuthErrorType = exports.LambdaEngineType = exports.UserActionPhase = exports.UnverifiedBehavior = exports.RefreshTokenExpirationPolicy = exports.RegistrationType = exports.LoginIdType = exports.CoseEllipticCurve = exports.AuthenticatorAttachment = exports.MultiFactorLoginPolicy = exports.ConnectorType = exports.KeyType = exports.AttestationType = exports.FormType = exports.KeyAlgorithm = exports.CaptchaMethod = exports.DeviceType = exports.RefreshTokenUsagePolicy = exports.ClientAuthenticationPolicy = exports.ResidentKeyRequirement = exports.AuthenticationThreats = exports.ObjectState = exports.AttestationConveyancePreference = exports.LambdaType = exports.CoseAlgorithmIdentifier = exports.HTTPMethod = exports.FormFieldAdminPolicy = exports.PublicKeyCredentialType = exports.SAMLv2DestinationAssertionPolicy = exports.CoseKeyType = exports.BreachMatchMode = exports.FormControl = exports.ContentStatus = exports.MessageType = exports.IPAccessControlEntryAction = exports.AuthenticatorAttachmentPreference = exports.XMLSignatureLocation = exports.TokenType = exports.ProofKeyForCodeExchangePolicy = exports.ReactorFeatureStatus = exports.GrantType = exports.UserState = exports.ApplicationMultiFactorTrustPolicy = exports.ConsentStatus = exports.BreachedPasswordStatus = exports.FormDataType = exports.FusionAuthClient = void 0; const DefaultRESTClientBuilder_1 = require("./DefaultRESTClientBuilder"); const url_1 = require("url"); class FusionAuthClient { constructor(apiKey, host, tenantId) { this.apiKey = apiKey; this.host = host; this.tenantId = tenantId; this.clientBuilder = new DefaultRESTClientBuilder_1.default(); } /** * Sets the tenant id, that will be included in the X-FusionAuth-TenantId header. * * @param {string | null} tenantId The value of the X-FusionAuth-TenantId header. * @returns {FusionAuthClient} */ setTenantId(tenantId) { this.tenantId = tenantId; return this; } /** * Sets whether and how cookies will be sent with each request. * * @param value The value that indicates whether and how cookies will be sent. * @returns {FusionAuthClient} */ setRequestCredentials(value) { this.credentials = value; return this; } /** * Takes an action on a user. The user being actioned is called the "actionee" and the user taking the action is called the * "actioner". Both user ids are required in the request object. * * @param {ActionRequest} request The action request that includes all the information about the action being taken including * the id of the action, any options and the duration (if applicable). * @returns {Promise<ClientResponse<ActionResponse>>} */ actionUser(request) { return this.start() .withUri('/api/user/action') .withJSONBody(request) .withMethod("POST") .go(); } /** * Activates the FusionAuth Reactor using a license id and optionally a license text (for air-gapped deployments) * * @param {ReactorRequest} request An optional request that contains the license text to activate Reactor (useful for air-gap deployments of FusionAuth). * @returns {Promise<ClientResponse<void>>} */ activateReactor(request) { return this.start() .withUri('/api/reactor') .withJSONBody(request) .withMethod("POST") .go(); } /** * Adds a user to an existing family. The family id must be specified. * * @param {UUID} familyId The id of the family. * @param {FamilyRequest} request The request object that contains all the information used to determine which user to add to the family. * @returns {Promise<ClientResponse<FamilyResponse>>} */ addUserToFamily(familyId, request) { return this.start() .withUri('/api/user/family') .withUriSegment(familyId) .withJSONBody(request) .withMethod("PUT") .go(); } /** * Approve a device grant. * * @param {string} client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate. * @param {string} client_secret (Optional) The client secret. This value will be required if client authentication is enabled. * @param {string} token The access token used to identify the user. * @param {string} user_code The end-user verification code. * @returns {Promise<ClientResponse<DeviceApprovalResponse>>} */ approveDevice(client_id, client_secret, token, user_code) { let body = new url_1.URLSearchParams(); body.append('client_id', client_id); body.append('client_secret', client_secret); body.append('token', token); body.append('user_code', user_code); return this.start() .withUri('/oauth2/device/approve') .withFormData(body) .withMethod("POST") .go(); } /** * Cancels the user action. * * @param {UUID} actionId The action id of the action to cancel. * @param {ActionRequest} request The action request that contains the information about the cancellation. * @returns {Promise<ClientResponse<ActionResponse>>} */ cancelAction(actionId, request) { return this.start() .withUri('/api/user/action') .withUriSegment(actionId) .withJSONBody(request) .withMethod("DELETE") .go(); } /** * Changes a user's password using the change password Id. This usually occurs after an email has been sent to the user * and they clicked on a link to reset their password. * * As of version 1.32.2, prefer sending the changePasswordId in the request body. To do this, omit the first parameter, and set * the value in the request body. * * @param {string} changePasswordId The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated. * @param {ChangePasswordRequest} request The change password request that contains all the information used to change the password. * @returns {Promise<ClientResponse<ChangePasswordResponse>>} */ changePassword(changePasswordId, request) { return this.startAnonymous() .withUri('/api/user/change-password') .withUriSegment(changePasswordId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Changes a user's password using their identity (login id and password). Using a loginId instead of the changePasswordId * bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword * method. * * @param {ChangePasswordRequest} request The change password request that contains all the information used to change the password. * @returns {Promise<ClientResponse<void>>} */ changePasswordByIdentity(request) { return this.start() .withUri('/api/user/change-password') .withJSONBody(request) .withMethod("POST") .go(); } /** * Check to see if the user must obtain a Trust Token Id in order to complete a change password request. * When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change * your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication. * * An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. * * @param {string} changePasswordId The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated. * @returns {Promise<ClientResponse<void>>} */ checkChangePasswordUsingId(changePasswordId) { return this.startAnonymous() .withUri('/api/user/change-password') .withUriSegment(changePasswordId) .withMethod("GET") .go(); } /** * Check to see if the user must obtain a Trust Token Id in order to complete a change password request. * When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change * your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication. * * An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. * * @param {string} encodedJWT The encoded JWT (access token). * @returns {Promise<ClientResponse<void>>} */ checkChangePasswordUsingJWT(encodedJWT) { return this.startAnonymous() .withUri('/api/user/change-password') .withAuthorization('Bearer ' + encodedJWT) .withMethod("GET") .go(); } /** * Check to see if the user must obtain a Trust Request Id in order to complete a change password request. * When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change * your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication. * * An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. * * @param {string} loginId The loginId of the User that you intend to change the password for. * @returns {Promise<ClientResponse<void>>} */ checkChangePasswordUsingLoginId(loginId) { return this.start() .withUri('/api/user/change-password') .withParameter('username', loginId) .withMethod("GET") .go(); } /** * Make a Client Credentials grant request to obtain an access token. * * @param {string} client_id (Optional) The client identifier. The client Id is the Id of the FusionAuth Entity in which you are attempting to authenticate. * This parameter is optional when Basic Authorization is used to authenticate this request. * @param {string} client_secret (Optional) The client secret used to authenticate this request. * This parameter is optional when Basic Authorization is used to authenticate this request. * @param {string} scope (Optional) This parameter is used to indicate which target entity you are requesting access. To request access to an entity, use the format target-entity:&lt;target-entity-id&gt;:&lt;roles&gt;. Roles are an optional comma separated list. * @returns {Promise<ClientResponse<AccessToken>>} */ clientCredentialsGrant(client_id, client_secret, scope) { let body = new url_1.URLSearchParams(); body.append('client_id', client_id); body.append('client_secret', client_secret); body.append('grant_type', 'client_credentials'); body.append('scope', scope); return this.startAnonymous() .withUri('/oauth2/token') .withFormData(body) .withMethod("POST") .go(); } /** * Adds a comment to the user's account. * * @param {UserCommentRequest} request The request object that contains all the information used to create the user comment. * @returns {Promise<ClientResponse<void>>} */ commentOnUser(request) { return this.start() .withUri('/api/user/comment') .withJSONBody(request) .withMethod("POST") .go(); } /** * Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in * * @param {WebAuthnLoginRequest} request An object containing data necessary for completing the authentication ceremony * @returns {Promise<ClientResponse<WebAuthnAssertResponse>>} */ completeWebAuthnAssertion(request) { return this.startAnonymous() .withUri('/api/webauthn/assert') .withJSONBody(request) .withMethod("POST") .go(); } /** * Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge and then login the user in * * @param {WebAuthnLoginRequest} request An object containing data necessary for completing the authentication ceremony * @returns {Promise<ClientResponse<LoginResponse>>} */ completeWebAuthnLogin(request) { return this.startAnonymous() .withUri('/api/webauthn/login') .withJSONBody(request) .withMethod("POST") .go(); } /** * Complete a WebAuthn registration ceremony by validating the client request and saving the new credential * * @param {WebAuthnRegisterCompleteRequest} request An object containing data necessary for completing the registration ceremony * @returns {Promise<ClientResponse<WebAuthnRegisterCompleteResponse>>} */ completeWebAuthnRegistration(request) { return this.start() .withUri('/api/webauthn/register/complete') .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated. * an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted * to that API key. * * If an API key is locked to a tenant, it can only create API Keys for that same tenant. * * @param {UUID} keyId (Optional) The unique Id of the API key. If not provided a secure random Id will be generated. * @param {APIKeyRequest} request The request object that contains all the information needed to create the APIKey. * @returns {Promise<ClientResponse<APIKeyResponse>>} */ createAPIKey(keyId, request) { return this.start() .withUri('/api/api-key') .withUriSegment(keyId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an application. You can optionally specify an Id for the application, if not provided one will be generated. * * @param {UUID} applicationId (Optional) The Id to use for the application. If not provided a secure random UUID will be generated. * @param {ApplicationRequest} request The request object that contains all the information used to create the application. * @returns {Promise<ClientResponse<ApplicationResponse>>} */ createApplication(applicationId, request) { return this.start() .withUri('/api/application') .withUriSegment(applicationId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a new role for an application. You must specify the id of the application you are creating the role for. * You can optionally specify an Id for the role inside the ApplicationRole object itself, if not provided one will be generated. * * @param {UUID} applicationId The Id of the application to create the role on. * @param {UUID} roleId (Optional) The Id of the role. If not provided a secure random UUID will be generated. * @param {ApplicationRequest} request The request object that contains all the information used to create the application role. * @returns {Promise<ClientResponse<ApplicationResponse>>} */ createApplicationRole(applicationId, roleId, request) { return this.start() .withUri('/api/application') .withUriSegment(applicationId) .withUriSegment("role") .withUriSegment(roleId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an audit log with the message and user name (usually an email). Audit logs should be written anytime you * make changes to the FusionAuth database. When using the FusionAuth App web interface, any changes are automatically * written to the audit log. However, if you are accessing the API, you must write the audit logs yourself. * * @param {AuditLogRequest} request The request object that contains all the information used to create the audit log entry. * @returns {Promise<ClientResponse<AuditLogResponse>>} */ createAuditLog(request) { return this.start() .withUri('/api/system/audit-log') .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a connector. You can optionally specify an Id for the connector, if not provided one will be generated. * * @param {UUID} connectorId (Optional) The Id for the connector. If not provided a secure random UUID will be generated. * @param {ConnectorRequest} request The request object that contains all the information used to create the connector. * @returns {Promise<ClientResponse<ConnectorResponse>>} */ createConnector(connectorId, request) { return this.start() .withUri('/api/connector') .withUriSegment(connectorId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a user consent type. You can optionally specify an Id for the consent type, if not provided one will be generated. * * @param {UUID} consentId (Optional) The Id for the consent. If not provided a secure random UUID will be generated. * @param {ConsentRequest} request The request object that contains all the information used to create the consent. * @returns {Promise<ClientResponse<ConsentResponse>>} */ createConsent(consentId, request) { return this.start() .withUri('/api/consent') .withUriSegment(consentId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an email template. You can optionally specify an Id for the template, if not provided one will be generated. * * @param {UUID} emailTemplateId (Optional) The Id for the template. If not provided a secure random UUID will be generated. * @param {EmailTemplateRequest} request The request object that contains all the information used to create the email template. * @returns {Promise<ClientResponse<EmailTemplateResponse>>} */ createEmailTemplate(emailTemplateId, request) { return this.start() .withUri('/api/email/template') .withUriSegment(emailTemplateId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an Entity. You can optionally specify an Id for the Entity. If not provided one will be generated. * * @param {UUID} entityId (Optional) The Id for the Entity. If not provided a secure random UUID will be generated. * @param {EntityRequest} request The request object that contains all the information used to create the Entity. * @returns {Promise<ClientResponse<EntityResponse>>} */ createEntity(entityId, request) { return this.start() .withUri('/api/entity') .withUriSegment(entityId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a Entity Type. You can optionally specify an Id for the Entity Type, if not provided one will be generated. * * @param {UUID} entityTypeId (Optional) The Id for the Entity Type. If not provided a secure random UUID will be generated. * @param {EntityTypeRequest} request The request object that contains all the information used to create the Entity Type. * @returns {Promise<ClientResponse<EntityTypeResponse>>} */ createEntityType(entityTypeId, request) { return this.start() .withUri('/api/entity/type') .withUriSegment(entityTypeId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a new permission for an entity type. You must specify the id of the entity type you are creating the permission for. * You can optionally specify an Id for the permission inside the EntityTypePermission object itself, if not provided one will be generated. * * @param {UUID} entityTypeId The Id of the entity type to create the permission on. * @param {UUID} permissionId (Optional) The Id of the permission. If not provided a secure random UUID will be generated. * @param {EntityTypeRequest} request The request object that contains all the information used to create the permission. * @returns {Promise<ClientResponse<EntityTypeResponse>>} */ createEntityTypePermission(entityTypeId, permissionId, request) { return this.start() .withUri('/api/entity/type') .withUriSegment(entityTypeId) .withUriSegment("permission") .withUriSegment(permissionId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a family with the user id in the request as the owner and sole member of the family. You can optionally specify an id for the * family, if not provided one will be generated. * * @param {UUID} familyId (Optional) The id for the family. If not provided a secure random UUID will be generated. * @param {FamilyRequest} request The request object that contains all the information used to create the family. * @returns {Promise<ClientResponse<FamilyResponse>>} */ createFamily(familyId, request) { return this.start() .withUri('/api/user/family') .withUriSegment(familyId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a form. You can optionally specify an Id for the form, if not provided one will be generated. * * @param {UUID} formId (Optional) The Id for the form. If not provided a secure random UUID will be generated. * @param {FormRequest} request The request object that contains all the information used to create the form. * @returns {Promise<ClientResponse<FormResponse>>} */ createForm(formId, request) { return this.start() .withUri('/api/form') .withUriSegment(formId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a form field. You can optionally specify an Id for the form, if not provided one will be generated. * * @param {UUID} fieldId (Optional) The Id for the form field. If not provided a secure random UUID will be generated. * @param {FormFieldRequest} request The request object that contains all the information used to create the form field. * @returns {Promise<ClientResponse<FormFieldResponse>>} */ createFormField(fieldId, request) { return this.start() .withUri('/api/form/field') .withUriSegment(fieldId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a group. You can optionally specify an Id for the group, if not provided one will be generated. * * @param {UUID} groupId (Optional) The Id for the group. If not provided a secure random UUID will be generated. * @param {GroupRequest} request The request object that contains all the information used to create the group. * @returns {Promise<ClientResponse<GroupResponse>>} */ createGroup(groupId, request) { return this.start() .withUri('/api/group') .withUriSegment(groupId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a member in a group. * * @param {MemberRequest} request The request object that contains all the information used to create the group member(s). * @returns {Promise<ClientResponse<MemberResponse>>} */ createGroupMembers(request) { return this.start() .withUri('/api/group/member') .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an IP Access Control List. You can optionally specify an Id on this create request, if one is not provided one will be generated. * * @param {UUID} accessControlListId (Optional) The Id for the IP Access Control List. If not provided a secure random UUID will be generated. * @param {IPAccessControlListRequest} request The request object that contains all the information used to create the IP Access Control List. * @returns {Promise<ClientResponse<IPAccessControlListResponse>>} */ createIPAccessControlList(accessControlListId, request) { return this.start() .withUri('/api/ip-acl') .withUriSegment(accessControlListId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an identity provider. You can optionally specify an Id for the identity provider, if not provided one will be generated. * * @param {UUID} identityProviderId (Optional) The Id of the identity provider. If not provided a secure random UUID will be generated. * @param {IdentityProviderRequest} request The request object that contains all the information used to create the identity provider. * @returns {Promise<ClientResponse<IdentityProviderResponse>>} */ createIdentityProvider(identityProviderId, request) { return this.start() .withUri('/api/identity-provider') .withUriSegment(identityProviderId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a Lambda. You can optionally specify an Id for the lambda, if not provided one will be generated. * * @param {UUID} lambdaId (Optional) The Id for the lambda. If not provided a secure random UUID will be generated. * @param {LambdaRequest} request The request object that contains all the information used to create the lambda. * @returns {Promise<ClientResponse<LambdaResponse>>} */ createLambda(lambdaId, request) { return this.start() .withUri('/api/lambda') .withUriSegment(lambdaId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates an message template. You can optionally specify an Id for the template, if not provided one will be generated. * * @param {UUID} messageTemplateId (Optional) The Id for the template. If not provided a secure random UUID will be generated. * @param {MessageTemplateRequest} request The request object that contains all the information used to create the message template. * @returns {Promise<ClientResponse<MessageTemplateResponse>>} */ createMessageTemplate(messageTemplateId, request) { return this.start() .withUri('/api/message/template') .withUriSegment(messageTemplateId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a messenger. You can optionally specify an Id for the messenger, if not provided one will be generated. * * @param {UUID} messengerId (Optional) The Id for the messenger. If not provided a secure random UUID will be generated. * @param {MessengerRequest} request The request object that contains all the information used to create the messenger. * @returns {Promise<ClientResponse<MessengerResponse>>} */ createMessenger(messengerId, request) { return this.start() .withUri('/api/messenger') .withUriSegment(messengerId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a tenant. You can optionally specify an Id for the tenant, if not provided one will be generated. * * @param {UUID} tenantId (Optional) The Id for the tenant. If not provided a secure random UUID will be generated. * @param {TenantRequest} request The request object that contains all the information used to create the tenant. * @returns {Promise<ClientResponse<TenantResponse>>} */ createTenant(tenantId, request) { return this.start() .withUri('/api/tenant') .withUriSegment(tenantId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a Theme. You can optionally specify an Id for the theme, if not provided one will be generated. * * @param {UUID} themeId (Optional) The Id for the theme. If not provided a secure random UUID will be generated. * @param {ThemeRequest} request The request object that contains all the information used to create the theme. * @returns {Promise<ClientResponse<ThemeResponse>>} */ createTheme(themeId, request) { return this.start() .withUri('/api/theme') .withUriSegment(themeId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a user. You can optionally specify an Id for the user, if not provided one will be generated. * * @param {UUID} userId (Optional) The Id for the user. If not provided a secure random UUID will be generated. * @param {UserRequest} request The request object that contains all the information used to create the user. * @returns {Promise<ClientResponse<UserResponse>>} */ createUser(userId, request) { return this.start() .withUri('/api/user') .withUriSegment(userId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a user action. This action cannot be taken on a user until this call successfully returns. Anytime after * that the user action can be applied to any user. * * @param {UUID} userActionId (Optional) The Id for the user action. If not provided a secure random UUID will be generated. * @param {UserActionRequest} request The request object that contains all the information used to create the user action. * @returns {Promise<ClientResponse<UserActionResponse>>} */ createUserAction(userActionId, request) { return this.start() .withUri('/api/user-action') .withUriSegment(userActionId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a user reason. This user action reason cannot be used when actioning a user until this call completes * successfully. Anytime after that the user action reason can be used. * * @param {UUID} userActionReasonId (Optional) The Id for the user action reason. If not provided a secure random UUID will be generated. * @param {UserActionReasonRequest} request The request object that contains all the information used to create the user action reason. * @returns {Promise<ClientResponse<UserActionReasonResponse>>} */ createUserActionReason(userActionReasonId, request) { return this.start() .withUri('/api/user-action-reason') .withUriSegment(userActionReasonId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a single User consent. * * @param {UUID} userConsentId (Optional) The Id for the User consent. If not provided a secure random UUID will be generated. * @param {UserConsentRequest} request The request that contains the user consent information. * @returns {Promise<ClientResponse<UserConsentResponse>>} */ createUserConsent(userConsentId, request) { return this.start() .withUri('/api/user/consent') .withUriSegment(userConsentId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Link an external user from a 3rd party identity provider to a FusionAuth user. * * @param {IdentityProviderLinkRequest} request The request object that contains all the information used to link the FusionAuth user. * @returns {Promise<ClientResponse<IdentityProviderLinkResponse>>} */ createUserLink(request) { return this.start() .withUri('/api/identity-provider/link') .withJSONBody(request) .withMethod("POST") .go(); } /** * Creates a webhook. You can optionally specify an Id for the webhook, if not provided one will be generated. * * @param {UUID} webhookId (Optional) The Id for the webhook. If not provided a secure random UUID will be generated. * @param {WebhookRequest} request The request object that contains all the information used to create the webhook. * @returns {Promise<ClientResponse<WebhookResponse>>} */ createWebhook(webhookId, request) { return this.start() .withUri('/api/webhook') .withUriSegment(webhookId) .withJSONBody(request) .withMethod("POST") .go(); } /** * Deactivates the application with the given Id. * * @param {UUID} applicationId The Id of the application to deactivate. * @returns {Promise<ClientResponse<void>>} */ deactivateApplication(applicationId) { return this.start() .withUri('/api/application') .withUriSegment(applicationId) .withMethod("DELETE") .go(); } /** * Deactivates the FusionAuth Reactor. * * @returns {Promise<ClientResponse<void>>} */ deactivateReactor() { return this.start() .withUri('/api/reactor') .withMethod("DELETE") .go(); } /** * Deactivates the user with the given Id. * * @param {UUID} userId The Id of the user to deactivate. * @returns {Promise<ClientResponse<void>>} */ deactivateUser(userId) { return this.start() .withUri('/api/user') .withUriSegment(userId) .withMethod("DELETE") .go(); } /** * Deactivates the user action with the given Id. * * @param {UUID} userActionId The Id of the user action to deactivate. * @returns {Promise<ClientResponse<void>>} */ deactivateUserAction(userActionId) { return this.start() .withUri('/api/user-action') .withUriSegment(userActionId) .withMethod("DELETE") .go(); } /** * Deactivates the users with the given ids. * * @param {Array<string>} userIds The ids of the users to deactivate. * @returns {Promise<ClientResponse<UserDeleteResponse>>} * * @deprecated This method has been renamed to deactivateUsersByIds, use that method instead. */ deactivateUsers(userIds) { return this.start() .withUri('/api/user/bulk') .withParameter('userId', userIds) .withParameter('dryRun', false) .withParameter('hardDelete', false) .withMethod("DELETE") .go(); } /** * Deactivates the users with the given ids. * * @param {Array<string>} userIds The ids of the users to deactivate. * @returns {Promise<ClientResponse<UserDeleteResponse>>} */ deactivateUsersByIds(userIds) { return this.start() .withUri('/api/user/bulk') .withParameter('userId', userIds) .withParameter('dryRun', false) .withParameter('hardDelete', false) .withMethod("DELETE") .go(); } /** * Deletes the API key for the given Id. * * @param {UUID} keyId The Id of the authentication API key to delete. * @returns {Promise<ClientResponse<void>>} */ deleteAPIKey(keyId) { return this.start() .withUri('/api/api-key') .withUriSegment(keyId) .withMethod("DELETE") .go(); } /** * Hard deletes an application. This is a dangerous operation and should not be used in most circumstances. This will * delete the application, any registrations for that application, metrics and reports for the application, all the * roles for the application, and any other data associated with the application. This operation could take a very * long time, depending on the amount of data in your database. * * @param {UUID} applicationId The Id of the application to delete. * @returns {Promise<ClientResponse<void>>} */ deleteApplication(applicationId) { return this.start() .withUri('/api/application') .withUriSegment(applicationId) .withParameter('hardDelete', true) .withMethod("DELETE") .go(); } /** * Hard deletes an application role. This is a dangerous operation and should not be used in most circumstances. This * permanently removes the given role from all users that had it. * * @param {UUID} applicationId The Id of the application to deactivate. * @param {UUID} roleId The Id of the role to delete. * @returns {Promise<ClientResponse<void>>} */ deleteApplicationRole(applicationId, roleId) { return this.start() .withUri('/api/application') .withUriSegment(applicationId) .withUriSegment("role") .withUriSegment(roleId) .withMethod("DELETE") .go(); } /** * Deletes the connector for the given Id. * * @param {UUID} connectorId The Id of the connector to delete. * @returns {Promise<ClientResponse<void>>} */ deleteConnector(connectorId) { return this.start() .withUri('/api/connector') .withUriSegment(connectorId) .withMethod("DELETE") .go(); } /** * Deletes the consent for the given Id. * * @param {UUID} consentId The Id of the consent to delete. * @returns {Promise<ClientResponse<void>>} */ deleteConsent(consentId) { return this.start() .withUri('/api/consent') .withUriSegment(consentId) .withMethod("DELETE") .go(); } /** * Deletes the email template for the given Id. * * @param {UUID} emailTemplateId The Id of the email template to delete. * @returns {Promise<ClientResponse<void>>} */ deleteEmailTemplate(emailTemplateId) { return this.start() .withUri('/api/email/template') .withUriSegment(emailTemplateId) .withMethod("DELETE") .go(); } /** * Deletes the Entity for the given Id. * * @param {UUID} entityId The Id of the Entity to delete. * @returns {Promise<ClientResponse<void>>} */ deleteEntity(entityId) { return this.start() .withUri('/api/entity') .withUriSegment(entityId) .withMethod("DELETE") .go(); } /** * Deletes an Entity Grant for the given User or Entity. * * @param {UUID} entityId The Id of the Entity that the Entity Grant is being deleted for. * @param {UUID} recipientEntityId (Optional) The Id of the Entity that the Entity Grant is for. * @param {UUID} userId (Optional) The Id of the User that the Entity Grant is for. * @returns {Promise<ClientResponse<void>>} */ deleteEntityGrant(entityId, recipientEntityId, userId) { return this.start() .withUri('/api/entity') .withUriSegment(entityId) .withUriSegment("grant") .withParameter('recipientEntityId', recipientEntityId) .withParameter('userId', userId) .withMethod("DELETE") .go(); } /** * Deletes the Entity Type for the given Id. * * @param {UUID} entityTypeId The Id of the Entity Type to delete. * @returns {Promise<ClientResponse<void>>} */ deleteEntityType(entityTypeId) { return this.start() .withUri('/api/entity/type') .withUriSegment(entityTypeId) .withMethod("DELETE") .go(); } /** * Hard deletes a permission. This is a dangerous operation and should not be used in most circumstances. This * permanently removes the given permission from all grants that had it. * * @param {UUID} entityTypeId The Id of the entityType the the permission belongs to. * @param {UUID} permissionId The Id of the permission to delete. * @returns {Promise<ClientResponse<void>>} */ deleteEntityTypePermission(entityTypeId, permissionId) { return this.start() .withUri('/api/entity/type') .withUriSegment(entityTypeId) .withUriSegment("permission") .withUriSegment(permissionId) .withMethod("DELETE") .go(); } /** * Deletes the form for the given Id. * * @param {UUID} formId The Id of the form to delete. * @returns {Promise<ClientResponse<void>>} */ deleteForm(formId) { return this.start() .withUri('/api/form') .withUriSegment(formId) .withMethod("DELETE") .go(); } /** * Deletes the form field for the given Id. * * @param {UUID} fieldId The Id of the form field to delete. * @returns {Promise<ClientResponse<void>>} */ deleteFormField(fieldId) { return this.start() .withUri('/api/form/field') .withUriSegment(fieldId) .withMethod("DELETE") .go(); } /** * Deletes the group for the given Id. * * @param {UUID} groupId The Id of the group to delete. * @returns {Promise<ClientResponse<void>>} */ deleteGroup(groupId) { return this.start() .withUri('/api/group') .withUriSegment(groupId) .withMethod("DELETE") .go(); } /** * Removes users as members of a group. * * @param {MemberDeleteRequest} request The member request that contains all the information used to remove members to the group. * @returns {Promise<ClientResponse<void>>} */ deleteGroupMembers(request) { return this.start() .withUri('/api/group/member') .withJSONBody(request) .withMethod("DELETE") .go(); } /** * Deletes the IP Access Control List for the given Id. * * @param {UUID} ipAccessControlListId The Id of the IP Access Control List to delete. * @returns {Promise<ClientResponse<void>>} */ deleteIPAccessControlList(ipAccessControlListId) { return this.start() .withUri('/api/ip-acl') .withUriSegment(ipAccessControlListId) .withMethod("DELETE") .go(); } /** * Deletes the identity provider for the given Id. * * @param {UUID} identityProviderId The Id of the identity provider to delete. * @returns {Promise<ClientResponse<void>>} */ deleteIdentityProvider(identityProviderId) { return this.start() .withUri('/api/identity-provider') .withUriSegment(identityProviderId) .withMethod("DELETE") .go(); } /** * Deletes the key for the given Id. * * @param {UUID} keyId The Id of the key to delete. * @returns {Promise<ClientResponse<void>>} */ deleteKey(keyId) { return this.start() .withUri('/api/key') .withUriSegment(keyId) .withMethod("DELETE") .go(); } /** * Deletes the lambda for the given Id. * * @param {UUID} lambdaId The Id of the lambda to delete. * @returns {Promise<ClientResponse<void>>} */ deleteLambda(lambdaId) { return this.start() .withUri('/api/lambda') .withUriSegment(lambdaId) .withMethod("DELETE") .go(); } /** * Deletes the message template for the given Id. * * @param {UUID} messageTemplateId The Id of the message template to delete. * @returns {Promise<ClientResponse<void>>} */ deleteMessageTemplate(messageTemplateId) { return this.start() .withUri('/api/message/template') .withUriSegment(messageTemplateId) .withMethod("DELETE") .go(); } /** * Deletes the messenger for the given Id. * * @param {UUID} messengerId The Id of the messenger to delete. * @returns {Promise<ClientResponse<void>>} */ deleteMessenger(messengerId) { return this.start() .withUri('/api/messenger') .withUriSegment(messengerId) .withMethod("DELETE") .go(); } /** * Deletes the user registration for the given user and application. * * @param {UUID} userId The Id of the user whose registration is being deleted. * @param {UUID} applicationId The Id of the application to remove the registration for. * @returns {Promise<ClientResponse<void>>} */ deleteRegistration(userId, applicationId) { return this.start() .withUri('/api/user/registration') .withUriSegment(userId) .withUriSegment(applicationId) .withMethod("DELETE") .go(); } /** * Deletes the user registration for the given user and application along with the given JSON body that contains the event information. * * @param {UUID} userId The Id of the user whose registration is being deleted. * @param {UUID} applicationId The Id of the application to remove the registration for. * @param {RegistrationDeleteRequest} request The request body that contains the event information. * @returns {Promise<ClientResponse<void>>} */ deleteRegistrationWithRequest(userId, applicationId, request) { return this.start() .withUri('/api/user/registration') .withUriSegment(userId) .withUriSegment(applicationId) .withJSONBody(request) .withMethod("DELETE") .go(); } /** * Deletes the tenant based on the given Id on the URL. This permanently deletes all information, metrics, reports and data associated * with the tenant and everything under the tenant (applications, users, etc). * * @param {UUID} tenantId The Id of the tenant to delete. * @returns {Promise<ClientResponse<void>>} */ deleteTenant(tenantId) { return this.start() .withUri('/api/tenant') .withUriSegment(tenantId) .withMethod("DELETE") .go(); } /** * Deletes the tenant for the given Id asynchronously. * This method is helpful if you do not want to wait for the delete operation to complete. * * @param {UUID} tenantId The Id of the tenant to delete. * @returns {Promise<ClientResponse<void>>} */ deleteTenantAsync(tenantId) { return this.start() .withUri('/api/tenant') .withUriSegment(tenantId) .withParameter('async', true) .withMethod("DELETE") .go(); } /** * Deletes the tenant based on the given request (sent to the API as JSON). This permanently deletes all information, metrics, reports and data associated * with the tenant and everything under the tenant (applications,