Skip to content package
node-mac-auth v1.0.0 Query and handle native macOS biometric authentication.
node any 2 deps cjs open source
overview readme
license MIT
deps 2
unpacked 9.9 kB
files 7
node any $ npm install node-mac-auth@1.0.0n npmREADME GitHub-flavored package documentation.
downloads Across all versions.
Download trend unavailable.
compatibility Runtime metadata.
keywords Tagged topics.
auth touchid mac electron nodejs
install size Estimated unpacked size across 4 packages.
439.9 kB
Includes dependencies.
dependencies 2 direct · 1 outdated
versions Latest published Jun 4, 2024
Jul 29, 2019
maintainers Registry package owners.
node-mac-auth A native node module that allows you to query and handle native macOS biometric authentication.
This module will have no effect unless there's an app bundle to own it: without one the API will simply appear not to run as a corollary of the way macOS handles native UI APIs.
Nota Bene: This module does not nor is it intended to perform process privilege escalation, e.g. allow you to authenticate as an admin user.
API
canPromptTouchID()Returns Boolean - whether or not this device has the ability to use Touch ID.
const { canPromptTouchID } = require ( 'node-mac-auth' )
const canPrompt = canPromptTouchID ()
console. log ( `I ${ canPrompt ? 'can' : 'cannot'} prompt for TouchID!` ) copy NOTE: This API will return false on macOS systems older than Sierra 10.12.2.
promptTouchID(options)
options Object
reason String - The reason you are asking for Touch ID authentication.
reuseDuration Number - The duration for which Touch ID authentication reuse is allowable, in seconds.
const { promptTouchID } = require ( 'node-mac-auth' )
promptTouchID ({ reason: 'To get consent for a Security-Gated Thing' }). then (() => {
console. log ( 'You have successfully authenticated with Touch ID!' )
}). catch (err => {
console. log ( 'TouchID failed because: ' , err)
}) copy NOTE: This API will have no effect on macOS systems older than Sierra 10.12.2.
Trying It Out To see this module in action:
$ git clone https://github.com/electron/electron-quick-start
$ cd electron-quick-start
$ npm install
$ npm install node-mac-auth copy then open main.js inside electron-quick-start and add:
const { canPromptTouchID, promptTouchID } = require ( 'node-mac-auth' ) copy to the top at line 4, and
const canPrompt = canPromptTouchID ()
console. log ( `I ${ canPrompt ? 'can' : 'cannot'} prompt for TouchID!` )
promptTouchID ({ reason: 'To get consent for a Security-Gated Thing' }). then (() => {
console. log ( 'You have successfully authenticated with Touch ID!' )
}). catch (err => {
console. log ( 'TouchID failed because: ' , err)
}) copy Inside the createWindow function beginning at line 9. Enjoy!