Skip to content

Ookamini95/capacitor-secure-passwords

Repository files navigation

capacitor-secure-passwords

Short plugin that exposes native secure layer APIs (KeyChain and KeyStore) to save simple key/value encrypted pairs

Install

npm install github:Ookamini95/capacitor-secure-passwords
npx cap sync

How to use

Manually import the plugin like so

    import { SecurePassword } from 'capacitor-secure-passwords';

and use it like this

    async saveSecretPassword() {
        try {
            await SecurePassword.save({
                key: "secret-key",
                data: "very-secret" // ... JSON.stringify({accessToken, refreshToken})
                })
        } catch (error) {
            console.error(error)
        }
    }

    async showSecret() {
        try {
            const { value } = await SecurePassword.read({
                key: "secret-key"
            })
            console.log(value)
        } catch (error) {
            console.log(JSON.stringify(error))
        }
    }

API

save(...)

save(options: { key: string; data: string; }) => Promise<void>

Saves a password securely.

This method encrypts and stores a password using the specified key. The encryption is handled natively using the platform's secure storage.

Param Type Description
options { key: string; data: string; } The options including the key and the password to save.

read(...)

read(options: { key: string; }) => Promise<{ value: string; }>

Reads a securely stored password.

This method retrieves and decrypts a password associated with the specified key. The decryption is handled natively using the platform's secure storage.

Param Type Description
options { key: string; } The options including the key to retrieve the password for.

Returns: Promise<{ value: string; }>


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published