2019-10-02 15:34:25 +03:00
# @nextcloud/password-confirmation
2018-09-11 11:30:53 +03:00
2024-06-25 17:26:31 +03:00
[![REUSE status ](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-password-confirmation )](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-password-confirmation)
2022-09-08 20:59:40 +03:00
[![npm ](https://img.shields.io/npm/v/@nextcloud/password-confirmation?style=for-the-badge )](https://www.npmjs.com/package/@nextcloud/password-confirmation)
2024-01-23 00:48:24 +03:00
[![Build Status ](https://img.shields.io/github/actions/workflow/status/nextcloud-libraries/nextcloud-password-confirmation/node.yml?branch=main&label=Build&style=for-the-badge )](https://github.com/nextcloud-libraries/nextcloud-password-confirmation/actions?query=branch%3Amain)
[![License ](https://img.shields.io/github/license/nextcloud-libraries/nextcloud-password-confirmation?style=for-the-badge )](https://github.com/nextcloud-libraries/nextcloud-password-confirmation/blob/main/LICENSE)
2018-09-11 11:30:53 +03:00
2024-06-25 15:54:44 +03:00
<!--
- SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: MIT
-->
2022-08-27 04:55:53 +03:00
Promise-based password confirmation for Nextcloud.
2018-09-11 11:30:53 +03:00
2022-08-27 04:55:53 +03:00
This library exports a function that displays a password confirmation dialog when called and returns a promise. This makes it easier to integrate with other asynchronous operations.
2018-09-11 11:30:53 +03:00
2023-10-10 19:00:17 +03:00
## Versions compatibility
Nextcloud | @nextcloud/vue | @nextcloud/password -confirmation
------------|----------------|---------------------------------
28.x | 8.x | 5.x
25.x - 27.x | 7.x | 2.x - 4.x
< 25.x | - | 1 . x
2018-09-11 11:30:53 +03:00
## Installation
```sh
2022-08-27 04:55:53 +03:00
npm add @nextcloud/password -confirmation
2018-09-11 11:30:53 +03:00
```
## Usage
```js
2022-08-27 04:55:53 +03:00
import { confirmPassword } from '@nextcloud/password-confirmation'
2023-09-24 16:38:17 +03:00
import '@nextcloud/password-confirmation/style.css' // Required for dialog styles
2018-09-11 11:30:53 +03:00
2022-08-27 04:55:53 +03:00
const foo = async () => {
try {
await confirmPassword()
// Your logic
} catch (error) {
// Your error handling logic
}
}
2018-09-11 11:30:53 +03:00
```
2022-09-21 18:40:47 +03:00
2023-10-07 00:24:23 +03:00
## API Reference
```ts
/**
* Check if password confirmation is required according to the last confirmation time.
* Use as a replacement of deprecated `OC.PasswordConfirmation.requiresPasswordConfirmation()` .
* Not needed if `confirmPassword()` can be used, because it checks requirements itself.
*
* @return {boolean} Whether password confirmation is required or was confirmed recently
*/
declare function isPasswordConfirmationRequired(): boolean
/**
* Confirm password if needed.
* Replacement of deprecated `OC.PasswordConfirmation.requirePasswordConfirmation(callback)`
*
* @return {Promise< void > } Promise that resolves when password is confirmed or not needded.
* Rejects if password confirmation was cancelled
* or confirmation is already in process.
*/
declare function confirmPassword(): Promise< void >
```
2022-09-21 18:40:47 +03:00
## Releasing
1) Create release branch
2) Adjust version using `npm version vx.y.z --no-git-tag-version`
3) Update `CHANGELOG.md`
4) Commit and open PR
2024-01-23 00:48:24 +03:00
5) After merge, pull latest main
2022-09-21 18:40:47 +03:00
6) `git tag vx.y.z`
7) `git push origin vx.y.z`
8) `npm ci && npm run build && npm publish`