3.0.1 • Published 8 months ago

capacitor-secure-credentials-plugin v3.0.1

Weekly downloads
-
License
Cactuslab
Repository
github
Last release
8 months ago

capacitor-secure-credentials-plugin

Saves credentials using secure native technology (Keychain on iOS and Android), with configurable protection levels from simply encrypted, device unlocked, user presence, to user presence proved with biometrics.

Install

npm install capacitor-secure-credentials-plugin
npx cap sync

API

getCredential(...)

getCredential(options: { service: string; username: string; }) => Promise<Success<Credential> | Failure<SecureCredentialsError>>

Get a credential matching a service and username if one exists. The user may be challenged to authenticate this request every time it is called.

ParamType
options{ service: string; username: string; }

Returns: Promise<Success<Credential> | Failure<SecureCredentialsError>>


getUsernames(...)

getUsernames(options: { service: string; }) => Promise<Success<string[]> | Failure<SecureCredentialsError>>

Get all usernames that have credentials stored for a service.

ParamType
options{ service: string; }

Returns: Promise<Failure<SecureCredentialsError> | Success<string[]>>


removeCredential(...)

removeCredential(options: { service: string; username: string; }) => Promise<Success<boolean> | Failure<SecureCredentialsError>>

Remove a specific credential

ParamType
options{ service: string; username: string; }

Returns: Promise<Failure<SecureCredentialsError> | Success<boolean>>


removeCredentials(...)

removeCredentials(options: { service: string; }) => Promise<Success<boolean> | Failure<SecureCredentialsError>>

Remove all credentials belonging to a service

ParamType
options{ service: string; }

Returns: Promise<Failure<SecureCredentialsError> | Success<boolean>>


setCredential(...)

setCredential(options: { service: string; credential: Credential; options: CredentialOptions; }) => Promise<Success<boolean> | Failure<SecureCredentialsError>>

Set a credential into the secure store. This will overwrite any existing credential of the same service and username.

ParamType
options{ service: string; credential: Credential; options: CredentialOptions; }

Returns: Promise<Failure<SecureCredentialsError> | Success<boolean>>


availableSecurityStrategies()

availableSecurityStrategies() => Promise<Success<SecurityStrategy[]> | Failure<SecureCredentialsError>>

Returns the available strategies for storing credentials, sorted strongest to weakest.

Returns: Promise<Failure<SecureCredentialsError> | Success<SecurityStrategy[]>>


supportedBiometricSensors()

supportedBiometricSensors() => Promise<Success<BiometricSensors>>

Determine the device capabilities for biometric scanning features. A device may have any combination of sensors and the sensors available may change depending on whether a user has granted permission to inspect the device sensors or whether they are enrolled with those sensors. Not all devices advertise what sensors they have. The information gathered is not guaranteed to be 100% accurate.

Returns: Promise<Success<BiometricSensors>>


Interfaces

Success

PropType
successtrue
resultT

Credential

PropType
usernamestring
passwordstring

Failure

PropType
successfalse
errorE

SecureCredentialsError

PropType
codeSecurityErrorCode
messagestring

CredentialOptions

PropType
strategySecurityStrategyName

SecurityStrategy

PropType
nameSecurityStrategyName
levelSecurityLevel
biometricsboolean

BiometricSensors

PropType
faceboolean
fingerprintboolean
irisboolean

Type Aliases

SecurityStrategyName

Opaque<'SecurityStrategyName', string>

Opaque

T & { TYPE: K }

Enums

SecurityErrorCode

MembersValue
FailedToAccess'failed to access'
NoData'no data'
Unknown'unknown'
Unavailable'unavailable'
Params'params'

SecurityLevel

MembersValueDescription
L1_Encrypted1The credential will be stored encrypted, but it can be accessed by the application while the device is locked.
L2_DeviceUnlocked2The credential will be stored encrypted, and it can only be accessed by the application when the device is unlocked.
L3_UserPresence3The credential will be stored encrypted, and it can only be accessed by the application after the OS confirms the user is present by means of a challenge. The OS may remember that the user is present for a configured period of time after a device PIN challenge.
3.0.1

8 months ago

3.0.0

11 months ago

2.0.1

11 months ago

2.0.0

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

0.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.0.1

3 years ago