CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-aws-amplify--auth

Authentication category of AWS Amplify providing APIs and building blocks for creating authentication experiences with Amazon Cognito

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

password-management.mddocs/

Password Management

Password reset, confirmation, and update operations for user account security.

Reset Password

Initiate a password reset flow for a user.

function resetPassword(input: ResetPasswordInput): Promise<ResetPasswordOutput>;

interface ResetPasswordInput {
  username: string;
  options?: {
    clientMetadata?: Record<string, string>;
  };
}

interface ResetPasswordOutput {
  nextStep: {
    resetPasswordStep: 'CONFIRM_RESET_PASSWORD_WITH_CODE' | 'DONE';
    codeDeliveryDetails?: CodeDeliveryDetails;
  };
}

Usage Example

import { resetPassword } from "@aws-amplify/auth";

const { nextStep } = await resetPassword({
  username: "user@example.com"
});

if (nextStep.resetPasswordStep === 'CONFIRM_RESET_PASSWORD_WITH_CODE') {
  console.log(`Reset code sent to: ${nextStep.codeDeliveryDetails?.destination}`);
}

Confirm Reset Password

Complete the password reset process using the verification code.

function confirmResetPassword(input: ConfirmResetPasswordInput): Promise<void>;

interface ConfirmResetPasswordInput {
  username: string;
  confirmationCode: string;
  newPassword: string;
  options?: {
    clientMetadata?: Record<string, string>;
  };
}

Usage Example

import { confirmResetPassword } from "@aws-amplify/auth";

await confirmResetPassword({
  username: "user@example.com",
  confirmationCode: "123456",
  newPassword: "NewSecurePassword123!"
});

console.log("Password reset successfully");

Update Password

Update the password for a signed-in user.

function updatePassword(input: UpdatePasswordInput): Promise<void>;

interface UpdatePasswordInput {
  oldPassword: string;
  newPassword: string;
}

Usage Example

import { updatePassword } from "@aws-amplify/auth";

await updatePassword({
  oldPassword: "CurrentPassword123!",
  newPassword: "NewSecurePassword456!"
});

console.log("Password updated successfully");

Password Requirements

When setting passwords, ensure they meet your Cognito User Pool password policy requirements. Common requirements include:

  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • At least one special character

Error Handling

Password operations may throw various errors:

import { resetPassword, AuthError } from "@aws-amplify/auth";

try {
  await resetPassword({ username: "user@example.com" });
} catch (error) {
  if (error instanceof AuthError) {
    switch (error.name) {
      case 'UserNotFoundException':
        console.log('User not found');
        break;
      case 'LimitExceededException':
        console.log('Too many requests, please try again later');
        break;
      case 'InvalidParameterException':
        console.log('Invalid username format');
        break;
      default:
        console.log('Password reset failed:', error.message);
    }
  }
}

docs

authentication-lifecycle.md

device-management.md

index.md

multi-factor-authentication.md

oauth-social-authentication.md

password-management.md

server-side-apis.md

session-management.md

user-management.md

webauthn-credentials.md

tile.json