🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

node-mac-auth

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mac-auth

Query and handle native macOS biometric authentication.

0.1.0
Source
npm
Version published
Weekly downloads
228
185%
Maintainers
1
Weekly downloads
 
Created
Source

MIT license PRs Welcome GitHub release Build Status

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.

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!`)

NOTE: This API will return false on macOS systems older than Sierra 10.12.2.

promptTouchID(options, callback)

  • 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.
  • callback Function
    • error - The reason authentication failed, if it failed.
const { promptTouchID } = require('node-mac-auth')

promptTouchID({ reason: 'To get consent for a Security-Gated Thing' }, (err) => {
  if (err) {
    console.log('TouchID failed because: ', err)
  } else {
    console.log('You have successfully authenticated with Touch ID!')
  }
})

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

then open main.js inside electron-quick-start and add:

const { canPromptTouchID, promptTouchID } = require('node-mac-auth')

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' }, (err) => {
  if (err) {
    console.log('TouchID failed because: ', err)
  } else {
    console.log('You have successfully authenticated with Touch ID!')
  }
})

Inside the createWindow function beginning at line 9. Enjoy!

Keywords

auth

FAQs

Package last updated on 30 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts