summaryrefslogtreecommitdiff
path: root/node_modules/electron-osx-sign/util-identities.js
diff options
context:
space:
mode:
authorLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
committerLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
commit703e03aba33f234712206769f57717ba7d92d23d (patch)
tree0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/electron-osx-sign/util-identities.js
parentab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff)
downloadFlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz
FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/electron-osx-sign/util-identities.js')
-rw-r--r--node_modules/electron-osx-sign/util-identities.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/electron-osx-sign/util-identities.js b/node_modules/electron-osx-sign/util-identities.js
new file mode 100644
index 0000000..37cfbdb
--- /dev/null
+++ b/node_modules/electron-osx-sign/util-identities.js
@@ -0,0 +1,55 @@
+/**
+ * @module util-identities
+ */
+
+'use strict'
+
+const util = require('./util')
+const debuglog = util.debuglog
+const flatList = util.flatList
+const execFileAsync = util.execFileAsync
+
+/**
+ * @constructor
+ * @param {string} name - Name of the signing identity.
+ * @param {String} hash - SHA-1 hash of the identity.
+ */
+var Identity = module.exports.Identity = function (name, hash) {
+ this.name = name
+ this.hash = hash
+}
+
+/**
+ * This function returns a promise checking the indentity proposed and updates the identity option to a exact finding from results.
+ * @function
+ * @param {Object} opts - Options.
+ * @param {string} identity - The proposed identity.
+ * @returns {Promise} Promise.
+ */
+module.exports.findIdentitiesAsync = function (opts, identity) {
+ // Only to look for valid identities, excluding those flagged with
+ // CSSMERR_TP_CERT_EXPIRED or CSSMERR_TP_NOT_TRUSTED. Fixes #9
+
+ var args = [
+ 'find-identity',
+ '-v'
+ ]
+ if (opts.keychain) {
+ args.push(opts.keychain)
+ }
+
+ return execFileAsync('security', args)
+ .then(function (result) {
+ return result.split('\n').map(function (line) {
+ if (line.indexOf(identity) >= 0) {
+ var identityFound = line.substring(line.indexOf('"') + 1, line.lastIndexOf('"'))
+ var identityHashFound = line.substring(line.indexOf(')') + 2, line.indexOf('"') - 1)
+ debuglog('Identity:', '\n',
+ '> Name:', identityFound, '\n',
+ '> Hash:', identityHashFound)
+ return new Identity(identityFound, identityHashFound)
+ }
+ })
+ })
+ .then(flatList)
+}