New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@isoftdata/svelte-change-password

Package Overview
Dependencies
Maintainers
13
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@isoftdata/svelte-change-password

latest
npmnpm
Version
2.2.0
Version published
Weekly downloads
20
-37.5%
Maintainers
13
Weekly downloads
 
Created
Source

Svelte ChangePassword

This component handles

  • Initiate password recovery process
  • Setting a new password when a reset token is already known (e.g. from a link in an email)
  • Provide fields for current/new password inputs

To trigger/show the UI in the component

  • the initiatePasswordRecovery() function must be called, or
  • the initiatePasswordReset() function must be called

Screenshot of the attachment component Screenshot of the attachment component

Install

pnpm i @isoftdata/svelte-change-password

Breaking changes

2.0.0

  • Require Svelte 5

Props

NameTypeDescriptionDefault Value
sendPasswordResetTokenEmail(userName: string) => Promise<Account>The function that calls the API to send the password recovery code to an account's recovery email.Required
changePassword(resetToken: string, currentPassword: string, newPassword: string, userName: string) => Promise<void>The function that calls the API to change the user's password.Required
passwordRulesPassword Rules ObjectThe password rules use to validate new password entered.undefined

Account Object Type

NameTypeDescriptionDefault Value
userNamestringThe username of the user account.''
recoveryEmailstringThe recovery email of the user account.''

Password Rules Object Type

NameTypeDescriptionDefault Value
minimumPasswordLengthnumberThe minimum length of the new password.optional
maximumPasswordLengthnumberThe maximum length of the new password.optional
numberOfRequiredLowercaseCharactersnumberThe number of required lowercase characters in the new password.optional
numberOfRequiredUppercaseCharactersnumberThe number of required uppercase characters in the new password.optional
numberOfRequiredNumericCharactersnumberThe number of required numeric characters in the new password.optional
numberOfRequiredSpecialCharactersnumberThe number of required special characters in the new password.optional

Functions

Call these on the component instance using bind:this

initiatePasswordRecovery(userName, resendEmail)

  • userName (string): the user account's userName
  • resendEmail (boolean): a boolean to decide whether it will send a password recovery token to the user account's recovery email
  • Usage: This function is used to initiate a password recovery that will then show the components.

initiatePasswordReset(userName, token)

  • userName (string): the user account's userName
  • token (string): a reset token that has already been issued for this account (e.g. embedded in a link the user clicked from an email)
  • Usage: This function shows the component with the new password fields immediately, skipping the recovery email step, since the reset token is already known. It puts the user's focus in the "New Password" field.

Example

<script lang="ts">
 import ChangePassword from '../lib/ChangePassword.svelte'

 type Account = {
  userName: string
  recoveryEmail: string
 }

 let changePasswordComponent: ChangePassword

 function sendPasswordResetTokenEmail(userName: string): Promise<Account> {
  console.log('Hit API call!', userName)
  return Promise.resolve({
   userName,
   recoveryEmail: '',
  })
 }

 function changePassword(resetToken: string, currentPassword: string, newPassword: string, userName: string): Promise<void> {
  console.log('Hit the API to change the user\'s password!')
  return Promise.resolve()
 }
</script>

<div class="container">
 <h1>ChangePassword</h1>

 <ChangePassword
  bind:this={changePasswordComponent}
  {sendPasswordResetTokenEmail}
  {changePassword}
 />
 <button onclick={() => changePasswordComponent.initiatePasswordRecovery('test', true)}>Initiate Password Recovery</button>
</div>


FAQs

Package last updated on 21 Aug 2026

Related posts