This library provides a client-side implementation for the Secure Remote Password (SRP) authentication flow specifically designed for AWS Cognito User Pools. It abstracts away the complex cryptographic calculations required for SRP_A generation and signature verification, enabling developers to integrate SRP authentication into both browser and Node.js environments. The current stable version is 1.0.0, indicating a relatively new, but stable, initial release. Its primary function is to work in conjunction with the AWS SDK's `initiateAuth` and `respondToAuthChallenge` APIs for the `USER_SRP_AUTH` and `PASSWORD_VERIFIER` flows, respectively, handling the core SRP computations rather than the network requests themselves. It is differentiated by its focused scope on SRP, providing a streamlined experience for this specific Cognito authentication method.
npm install aws-cognito-srp-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the full four-step SRP authentication flow with AWS Cognito, showing how to generate SRP_A, initiate authentication, calculate the password verifier signature, and respond to the authentication challenge using the `aws-cognito-srp-client` library alongside the AWS SDK.
Ensure you have the AWS SDK installed and are correctly using its `initiateAuth` and `respondToAuthChallenge` methods, passing the computed SRP values from this library.
Correctly map the `SECRET_BLOCK` string from `initiateAuthResponse.ChallengeParameters` to the `secret` argument of `getSignature`.
Verify your Cognito User Pool App Client settings in the AWS Console to ensure 'Enable SRP' is checked under Authentication Flows.
Follow OWASP guidelines for client-side security. Do not store passwords in plain text. Use HTTPS for all communications. Implement proper error handling to avoid leaking information.
In your AWS Cognito console, navigate to your User Pool, then App Clients, and ensure the 'Enable SRP' checkbox is selected for the relevant App Client.
If your App Client has a client secret, you must generate and include a `SECRET_HASH` in your Cognito API calls. Alternatively, configure your App Client *without* a client secret if it's a public client (e.g., mobile or web app).
Ensure the username is correct and the user has been created and confirmed in the Cognito User Pool.
Change your import statement to use a default import: `import Srp from 'aws-cognito-srp-client';`