move some docs to js formatted documentation

This commit is contained in:
lastlink 2019-04-27 00:03:42 -04:00
parent 735ec948da
commit 4b44a576c1
2 changed files with 12 additions and 6 deletions

View File

@ -3,8 +3,8 @@
'use strict'; 'use strict';
var Keypairs = exports.Keypairs = {}; var Keypairs = exports.Keypairs = {};
var Rasha = exports.Rasha || require('rasha'); var Rasha = exports.Rasha;
var Eckles = exports.Eckles || require('eckles'); var Eckles = exports.Eckles;
var Enc = exports.Enc || {}; var Enc = exports.Enc || {};
Keypairs._stance = "We take the stance that if you're knowledgeable enough to" Keypairs._stance = "We take the stance that if you're knowledgeable enough to"
@ -34,10 +34,12 @@ Keypairs.generate = function (opts) {
}; };
// Chopping off the private parts is now part of the public API. /**
// I thought it sounded a little too crude at first, but it really is the best name in every possible way. * Chopping off the private parts is now part of the public API.
* I thought it sounded a little too crude at first, but it really is the best name in every possible way.
*/
Keypairs.neuter = Keypairs._neuter = function (opts) { Keypairs.neuter = Keypairs._neuter = function (opts) {
// trying to find the best balance of an immutable copy with custom attributes /** trying to find the best balance of an immutable copy with custom attributes */
var jwk = {}; var jwk = {};
Object.keys(opts.jwk).forEach(function (k) { Object.keys(opts.jwk).forEach(function (k) {
if ('undefined' === typeof opts.jwk[k]) { return; } if ('undefined' === typeof opts.jwk[k]) { return; }
@ -61,7 +63,7 @@ Keypairs.thumbprint = function (opts) {
Keypairs.publish = function (opts) { Keypairs.publish = function (opts) {
if ('object' !== typeof opts.jwk || !opts.jwk.kty) { throw new Error("invalid jwk: " + JSON.stringify(opts.jwk)); } if ('object' !== typeof opts.jwk || !opts.jwk.kty) { throw new Error("invalid jwk: " + JSON.stringify(opts.jwk)); }
// returns a copy /** returns a copy */
var jwk = Keypairs.neuter(opts); var jwk = Keypairs.neuter(opts);
if (jwk.exp) { if (jwk.exp) {

View File

@ -136,6 +136,10 @@
, ASN1('A1', ASN1.BitStr('04' + x + y))) , ASN1('A1', ASN1.BitStr('04' + x + y)))
); );
}; };
/**
* take a private jwk and creates a der from it
* @param {*} jwk
*/
x509.packPkcs8 = function (jwk) { x509.packPkcs8 = function (jwk) {
var d = Enc.base64ToHex(jwk.d); var d = Enc.base64ToHex(jwk.d);
var x = Enc.base64ToHex(jwk.x); var x = Enc.base64ToHex(jwk.x);