Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdk to match authsignal's general sdk conventions #24

Merged

Conversation

stevenclouston
Copy link
Contributor

@stevenclouston stevenclouston commented Nov 29, 2024

Release Notes

Changes have been made so that conventions used in the PHP SDK align with Authsignal's general SDK conventions.

Breaking Changes

  1. track Method

    • Old Signature:
      public static function track(string $userId, string $action, array $payload)
    • New Signature:
      public static function track(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user you are tracking the action for.
      • action (string): The action code that you are tracking.
      • attributes (array): An array of attributes to track.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
      • The payload parameter has been replaced with attributes in the implementation.
  2. getAction Method

    • Old Signature:
      public static function getAction(string $userId, string $action, string $idempotencyKey)
    • New Signature:
      public static function getAction(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user you are tracking the action for.
      • action (string): The action code that you are tracking.
      • idempotencyKey (string): The idempotency key for the action.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  3. getUser Method

    • Old Signature:
      public static function getUser(string $userId, string $redirectUrl = null)
    • New Signature:
      public static function getUser(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user you are tracking the action for.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
      • Removed redirectUrl from the params.
  4. updateUser Method

    • Old Signature:
      public static function updateUser(string $userId, array $data)
    • New Signature:
      public static function updateUser(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user to update.
      • attributes (array): The attributes to update for the user.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  5. enrollVerifiedAuthenticator Method

    • Old Signature:
      public static function enrollVerifiedAuthenticator(string $userId, array $authenticator)
    • New Signature:
      public static function enrollVerifiedAuthenticator(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user you are tracking the action for.
      • attributes (array): The authenticator object to enroll.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  6. deleteUser Method

    • Old Signature:
      public static function deleteUser(string $userId)
    • New Signature:
      public static function deleteUser(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user you want to delete.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  7. deleteAuthenticator Method

    • Old Signature:
      public static function deleteAuthenticator(string $userId, string $userAuthenticatorId)
    • New Signature:
      public static function deleteAuthenticator(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user.
      • userAuthenticatorId (string): The userAuthenticatorId of the authenticator to delete.
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  8. validateChallenge Method

    • Old Signature:
      public static function validateChallenge(string $token, string $userId = null, string $action = null)
    • New Signature:
      public static function validateChallenge(array $params)
    • Parameters in Associative Array:
      • token (string): The JWT token string returned on a challenge response.
      • userId (string|null): The userId of the user you are tracking the action for (optional).
      • action (string|null): The action code that you are tracking (optional).
    • Changes:
      • The method now accepts a single associative array parameter named $params.
  9. RenamesetApiKey Method to setApiSecretKey

  10. RenamegetApiKey Method to getApiSecretKey

  11. Rename setApiHostname to setApiUrl

  12. Rename AUTHSIGNAL_SERVER_API_ENDPOINT env var to AUTHSIGNAL_API_URL

  13. Remove setApiVersion and getApiVersion

  • The version should be set when the URL is set with setApiUrl or the AUTHSIGNAL_API_URL env variable.

Non Breaking Changes

  1. Add updateAction Method

    • Signature:
      public static function updateAction(array $params)
    • Parameters in Associative Array:
      • userId (string): The userId of the user to update the action for.
      • action (string): The action code to update.
      • idempotencyKey (string): The idempotency key for the action.
      • attributes (array): Additional attributes for the action.
  2. ** getAuthenticators Method**

  • Signature:
    public static function getAuthenticators(array $params)
  • Description: Retrieves the list of authenticators for a specified user.
  • Parameters in Associative Array:
    • userId (string): The userId of the user whose authenticators you want to retrieve.
  • Returns: An array containing the list of user authenticators.
  • Throws:
    • AuthsignalApiException if the request fails.

Example Usage:

$params = [
    'userId' => '12345' // The userId of the user whose authenticators you want to retrieve
];

$authenticators = Authsignal::getAuthenticators($params);
 

@stevenclouston stevenclouston marked this pull request as ready for review November 29, 2024 04:21
@stevenclouston stevenclouston merged commit 108a2ac into main Dec 8, 2024
1 check passed
@stevenclouston stevenclouston deleted the Update-SDK-to-match-Authsignal's-general-SDK-conventions branch December 8, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants