Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/sshpk/lib/certificate.js')
-rw-r--r--node_modules/sshpk/lib/certificate.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/node_modules/sshpk/lib/certificate.js b/node_modules/sshpk/lib/certificate.js
index f08d66ac5..693235707 100644
--- a/node_modules/sshpk/lib/certificate.js
+++ b/node_modules/sshpk/lib/certificate.js
@@ -120,6 +120,37 @@ Certificate.prototype.isSignedBy = function (issuerCert) {
return (this.isSignedByKey(issuerCert.subjectKey));
};
+Certificate.prototype.getExtension = function (keyOrOid) {
+ assert.string(keyOrOid, 'keyOrOid');
+ var ext = this.getExtensions().filter(function (maybeExt) {
+ if (maybeExt.format === 'x509')
+ return (maybeExt.oid === keyOrOid);
+ if (maybeExt.format === 'openssh')
+ return (maybeExt.name === keyOrOid);
+ return (false);
+ })[0];
+ return (ext);
+};
+
+Certificate.prototype.getExtensions = function () {
+ var exts = [];
+ var x509 = this.signatures.x509;
+ if (x509 && x509.extras && x509.extras.exts) {
+ x509.extras.exts.forEach(function (ext) {
+ ext.format = 'x509';
+ exts.push(ext);
+ });
+ }
+ var openssh = this.signatures.openssh;
+ if (openssh && openssh.exts) {
+ openssh.exts.forEach(function (ext) {
+ ext.format = 'openssh';
+ exts.push(ext);
+ });
+ }
+ return (exts);
+};
+
Certificate.prototype.isSignedByKey = function (issuerKey) {
utils.assertCompatible(issuerKey, Key, [1, 2], 'issuerKey');
@@ -370,8 +401,9 @@ Certificate.isCertificate = function (obj, ver) {
/*
* API versions for Certificate:
* [1,0] -- initial ver
+ * [1,1] -- openssh format now unpacks extensions
*/
-Certificate.prototype._sshpkApiVersion = [1, 0];
+Certificate.prototype._sshpkApiVersion = [1, 1];
Certificate._oldVersionDetect = function (obj) {
return ([1, 0]);