diff --git a/build.savant b/build.savant index b1d974a..caf2ef1 100644 --- a/build.savant +++ b/build.savant @@ -14,7 +14,7 @@ * language governing permissions and limitations under the License. */ -project(group: "io.fusionauth", name: "fusionauth-php-client", version: "1.58.0", licenses: ["ApacheV2_0"]) { +project(group: "io.fusionauth", name: "fusionauth-php-client", version: "1.59.0", licenses: ["ApacheV2_0"]) { workflow { fetch { cache() diff --git a/src/FusionAuth/FusionAuthClient.php b/src/FusionAuth/FusionAuthClient.php index cd51897..657db36 100644 --- a/src/FusionAuth/FusionAuthClient.php +++ b/src/FusionAuth/FusionAuthClient.php @@ -2,7 +2,7 @@ namespace FusionAuth; /* - * Copyright (c) 2018-2023, FusionAuth, All Rights Reserved + * Copyright (c) 2018-2025, 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. @@ -195,6 +195,7 @@ public function changePassword($changePasswordId, $request) * * @return ClientResponse The ClientResponse. * @throws \Exception + * @deprecated This method has been renamed to changePasswordUsingJWT, use that method instead. */ public function changePasswordByJWT($encodedJWT, $request) { @@ -223,6 +224,27 @@ public function changePasswordByIdentity($request) ->go(); } + /** + * Changes a user's password using their access token (JWT) instead of the changePasswordId + * A common use case for this method will be if you want to allow the user to change their own password. + * + * Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword. + * + * @param string $encodedJWT The encoded JWT (access token). + * @param array $request The change password request that contains all the information used to change the password. + * + * @return ClientResponse The ClientResponse. + * @throws \Exception + */ + public function changePasswordUsingJWT($encodedJWT, $request) + { + return $this->startAnonymous()->uri("/api/user/change-password") + ->authorization("Bearer " . $encodedJWT) + ->bodyHandler(new JSONBodyHandler($request)) + ->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 @@ -989,7 +1011,7 @@ public function deactivateUserAction($userActionId) } /** - * Deactivates the users with the given ids. + * Deactivates the users with the given Ids. * * @param array $userIds The ids of the users to deactivate. * @@ -1008,7 +1030,7 @@ public function deactivateUsers($userIds) } /** - * Deactivates the users with the given ids. + * Deactivates the users with the given Ids. * * @param array $userIds The ids of the users to deactivate. * @@ -1582,8 +1604,8 @@ public function deleteUserWithRequest($userId, $request) } /** - * Deletes the users with the given ids, or users matching the provided JSON query or queryString. - * The order of preference is ids, query and then queryString, it is recommended to only provide one of the three for the request. + * Deletes the users with the given Ids, or users matching the provided JSON query or queryString. + * The order of preference is Ids, query and then queryString, it is recommended to only provide one of the three for the request. * * This method can be used to deactivate or permanently delete (hard-delete) users based upon the hardDelete boolean in the request body. * Using the dryRun parameter you may also request the result of the action without actually deleting or deactivating any users. @@ -1603,8 +1625,8 @@ public function deleteUsers($request) } /** - * Deletes the users with the given ids, or users matching the provided JSON query or queryString. - * The order of preference is ids, query and then queryString, it is recommended to only provide one of the three for the request. + * Deletes the users with the given Ids, or users matching the provided JSON query or queryString. + * The order of preference is Ids, query and then queryString, it is recommended to only provide one of the three for the request. * * This method can be used to deactivate or permanently delete (hard-delete) users based upon the hardDelete boolean in the request body. * Using the dryRun parameter you may also request the result of the action without actually deleting or deactivating any users. @@ -2253,7 +2275,7 @@ public function lookupIdentityProvider($domain) * Modifies a temporal user action by changing the expiration of the action and optionally adding a comment to the * action. * - * @param string $actionId The Id of the action to modify. This is technically the user action log id. + * @param string $actionId The Id of the action to modify. This is technically the user action log Id. * @param array $request The request that contains all the information about the modification. * * @return ClientResponse The ClientResponse. @@ -2285,10 +2307,10 @@ public function passwordlessLogin($request) } /** - * Updates an authentication API key by given id + * Updates an API key with the given Id. * - * @param string $keyId The Id of the authentication key. If not provided a secure random api key will be generated. - * @param array $request The request object that contains all the information needed to create the APIKey. + * @param string $keyId The Id of the API key. If not provided a secure random api key will be generated. + * @param array $request The request object that contains all the information needed to create the API key. * * @return ClientResponse The ClientResponse. * @throws \Exception @@ -2298,7 +2320,7 @@ public function patchAPIKey($keyId, $request) return $this->start()->uri("/api/api-key") ->urlSegment($keyId) ->bodyHandler(new JSONBodyHandler($request)) - ->post() + ->patch() ->go(); } @@ -2951,7 +2973,7 @@ public function reindex($request) } /** - * Removes a user from the family with the given id. + * Removes a user from the family with the given Id. * * @param string $familyId The Id of the family to remove the user from. * @param string $userId The Id of the user to remove from the family. @@ -3022,7 +3044,7 @@ public function resendRegistrationVerification($email, $applicationId) } /** - * Retrieves an authentication API key for the given id + * Retrieves an authentication API key for the given Id. * * @param string $keyId The Id of the API key to retrieve. * @@ -3108,7 +3130,7 @@ public function retrieveActiveActions($userId) /** * Retrieves the application for the given Id or all the applications if the Id is null. * - * @param string $applicationId (Optional) The application id. + * @param string $applicationId (Optional) The application Id. * * @return ClientResponse The ClientResponse. * @throws \Exception @@ -3212,10 +3234,10 @@ public function retrieveConsents() } /** - * Retrieves the daily active user report between the two instants. If you specify an application id, it will only + * Retrieves the daily active user report between the two instants. If you specify an application Id, it will only * return the daily active counts for that application. * - * @param string $applicationId (Optional) The application id. + * @param string $applicationId (Optional) The application Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -3233,7 +3255,7 @@ public function retrieveDailyActiveReport($applicationId, $start, $end) } /** - * Retrieves the email template for the given Id. If you don't specify the id, this will return all the email templates. + * Retrieves the email template for the given Id. If you don't specify the Id, this will return all the email templates. * * @param string $emailTemplateId (Optional) The Id of the email template. * @@ -3748,10 +3770,10 @@ public function retrieveLambdasByType($type) } /** - * Retrieves the login report between the two instants. If you specify an application id, it will only return the + * Retrieves the login report between the two instants. If you specify an application Id, it will only return the * login counts for that application. * - * @param string $applicationId (Optional) The application id. + * @param string $applicationId (Optional) The application Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -3769,7 +3791,7 @@ public function retrieveLoginReport($applicationId, $start, $end) } /** - * Retrieves the message template for the given Id. If you don't specify the id, this will return all the message templates. + * Retrieves the message template for the given Id. If you don't specify the Id, this will return all the message templates. * * @param string $messageTemplateId (Optional) The Id of the message template. * @@ -3845,10 +3867,10 @@ public function retrieveMessengers() } /** - * Retrieves the monthly active user report between the two instants. If you specify an application id, it will only + * Retrieves the monthly active user report between the two instants. If you specify an application Id, it will only * return the monthly active counts for that application. * - * @param string $applicationId (Optional) The application id. + * @param string $applicationId (Optional) The application Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -4063,7 +4085,7 @@ public function retrieveRefreshTokens($userId) } /** - * Retrieves the user registration for the user with the given Id and the given application id. + * Retrieves the user registration for the user with the given Id and the given application Id. * * @param string $userId The Id of the user. * @param string $applicationId The Id of the application. @@ -4081,10 +4103,10 @@ public function retrieveRegistration($userId, $applicationId) } /** - * Retrieves the registration report between the two instants. If you specify an application id, it will only return + * Retrieves the registration report between the two instants. If you specify an application Id, it will only return * the registration counts for that application. * - * @param string $applicationId (Optional) The application id. + * @param string $applicationId (Optional) The application Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -4303,7 +4325,7 @@ public function retrieveUser($userId) } /** - * Retrieves the user action for the given Id. If you pass in null for the id, this will return all the user + * Retrieves the user action for the given Id. If you pass in null for the Id, this will return all the user * actions. * * @param string $userActionId (Optional) The Id of the user action. @@ -4320,7 +4342,7 @@ public function retrieveUserAction($userActionId = NULL) } /** - * Retrieves the user action reason for the given Id. If you pass in null for the id, this will return all the user + * Retrieves the user action reason for the given Id. If you pass in null for the Id, this will return all the user * action reasons. * * @param string $userActionReasonId (Optional) The Id of the user action reason. @@ -4469,8 +4491,8 @@ public function retrieveUserByVerificationId($verificationId) * * This API is useful if you want to build your own login workflow to complete a device grant. * - * @param string $client_id The client id. - * @param string $client_secret The client id. + * @param string $client_id The client Id. + * @param string $client_secret The client Id. * @param string $user_code The end-user verification code. * * @return ClientResponse The ClientResponse. @@ -4615,11 +4637,11 @@ public function retrieveUserLinksByUserId($identityProviderId, $userId) } /** - * Retrieves the login report between the two instants for a particular user by Id. If you specify an application id, it will only return the + * Retrieves the login report between the two instants for a particular user by Id. If you specify an application Id, it will only return the * login counts for that application. * - * @param string $applicationId (Optional) The application id. - * @param string $userId The userId id. + * @param string $applicationId (Optional) The application Id. + * @param string $userId The userId Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -4638,11 +4660,11 @@ public function retrieveUserLoginReport($applicationId, $userId, $start, $end) } /** - * Retrieves the login report between the two instants for a particular user by login Id. If you specify an application id, it will only return the + * Retrieves the login report between the two instants for a particular user by login Id. If you specify an application Id, it will only return the * login counts for that application. * - * @param string $applicationId (Optional) The application id. - * @param string $loginId The userId id. + * @param string $applicationId (Optional) The application Id. + * @param string $loginId The userId Id. * @param array $start The start instant as UTC milliseconds since Epoch. * @param array $end The end instant as UTC milliseconds since Epoch. * @@ -4768,7 +4790,7 @@ public function retrieveWebAuthnCredentialsForUser($userId) } /** - * Retrieves the webhook for the given Id. If you pass in null for the id, this will return all the webhooks. + * Retrieves the webhook for the given Id. If you pass in null for the Id, this will return all the webhooks. * * @param string $webhookId (Optional) The Id of the webhook. * @@ -5068,7 +5090,7 @@ public function searchEntities($request) } /** - * Retrieves the entities for the given ids. If any Id is invalid, it is ignored. + * Retrieves the entities for the given Ids. If any Id is invalid, it is ignored. * * @param array $ids The entity ids to search for. * @@ -5292,7 +5314,7 @@ public function searchUserComments($request) } /** - * Retrieves the users for the given ids. If any Id is invalid, it is ignored. + * Retrieves the users for the given Ids. If any Id is invalid, it is ignored. * * @param array $ids The user ids to search for. * @@ -5309,9 +5331,9 @@ public function searchUsers($ids) } /** - * Retrieves the users for the given ids. If any Id is invalid, it is ignored. + * Retrieves the users for the given Ids. If any Id is invalid, it is ignored. * - * @param array $ids The user ids to search for. + * @param array $ids The user Ids to search for. * * @return ClientResponse The ClientResponse. * @throws \Exception @@ -5392,7 +5414,7 @@ public function searchWebhooks($request) } /** - * Send an email using an email template id. You can optionally provide requestData to access key value + * Send an email using an email template Id. You can optionally provide requestData to access key value * pairs in the email template. * * @param string $emailTemplateId The Id for the template. @@ -5647,18 +5669,18 @@ public function twoFactorLogin($request) } /** - * Updates an API key by given id + * Updates an API key with the given Id. * - * @param string $apiKeyId The Id of the API key to update. - * @param array $request The request object that contains all the information used to create the API Key. + * @param string $keyId The Id of the API key to update. + * @param array $request The request that contains all the new API key information. * * @return ClientResponse The ClientResponse. * @throws \Exception */ - public function updateAPIKey($apiKeyId, $request) + public function updateAPIKey($keyId, $request) { return $this->start()->uri("/api/api-key") - ->urlSegment($apiKeyId) + ->urlSegment($keyId) ->bodyHandler(new JSONBodyHandler($request)) ->put() ->go(); @@ -6231,7 +6253,7 @@ public function upsertEntityGrant($entityId, $request) * If you build your own activation form you should validate the user provided code prior to beginning the Authorization grant. * * @param string $user_code The end-user verification code. - * @param string $client_id The client id. + * @param string $client_id The client Id. * * @return ClientResponse The ClientResponse. * @throws \Exception @@ -6416,4 +6438,4 @@ private function startAnonymous() ->successResponseHandler(new JSONResponseHandler()) ->errorResponseHandler(new JSONResponseHandler()); } -} \ No newline at end of file +}