30 lines
988 B
JavaScript
30 lines
988 B
JavaScript
function promptLooksFingerprint(text) {
|
|
var s = String(text || "").toLowerCase()
|
|
return s.indexOf("finger") !== -1 || s.indexOf("fprint") !== -1 || s.indexOf("swipe") !== -1
|
|
}
|
|
|
|
function fingerprintFirstFromPamConfig(raw) {
|
|
var lines = String(raw || "").split("\n")
|
|
for (var i = 0; i < lines.length; i++) {
|
|
var line = lines[i].replace(/^\s+|\s+$/g, "")
|
|
if (!line || line.charAt(0) === "#") continue
|
|
if (!line.match(/^auth\s+/)) continue
|
|
return line.indexOf("pam_fprintd.so") !== -1
|
|
}
|
|
return false
|
|
}
|
|
|
|
function authorizationLabel(message) {
|
|
var text = String(message || "")
|
|
var match = text.match(/^Authentication is (?:needed|required) to run [`']([^`']+)[`'] as /i)
|
|
return match ? "Authorize running '" + match[1] + "'" : text
|
|
}
|
|
|
|
if (typeof module !== "undefined") {
|
|
module.exports = {
|
|
promptLooksFingerprint: promptLooksFingerprint,
|
|
fingerprintFirstFromPamConfig: fingerprintFirstFromPamConfig,
|
|
authorizationLabel: authorizationLabel
|
|
}
|
|
}
|