Skip to content

Commit

Permalink
Added build files
Browse files Browse the repository at this point in the history
  • Loading branch information
akdombrowski committed May 8, 2021
1 parent bdb1700 commit b7b835f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cli/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 24 additions & 14 deletions cli_lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@ var _clipboardy = _interopRequireDefault(require("clipboardy"));

var decode = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(jwt) {
var decoded;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
_context.prev = 0;
_context.next = 3;
return (0, _lib.jwtDecode)(jwt);

case 2:
return _context.abrupt("return", _context.sent);

case 3:
decoded = _context.sent;
return _context.abrupt("return", decoded);

case 7:
_context.prev = 7;
_context.t0 = _context["catch"](0);
throw _context.t0;

case 10:
case "end":
return _context.stop();
}
}
}, _callee);
}, _callee, null, [[0, 7]]);
}));

return function decode(_x) {
Expand Down Expand Up @@ -96,11 +104,11 @@ var cli = /*#__PURE__*/function () {
case 18:
_context2.prev = 18;
_context2.t0 = _context2["catch"](8);
console.error("I found an error :(.");
console.error("I found an error :(");
console.error("Couldn't decode what was in clipboard. Pass in a JWT as the first argument or copy a JWT to your clipboard");
console.error("what's on your clipboard? ");
console.error(clipboard);
console.error(_context2.t0, _context2.t0.message);
throw _context2.t0;

case 25:
_context2.next = 29;
Expand All @@ -111,12 +119,12 @@ var cli = /*#__PURE__*/function () {
console.error("Nothing in clipboard. Pass in a JWT as the first argument or copy a JWT to your clipboard");

case 29:
_context2.next = 47;
_context2.next = 49;
break;

case 31:
if (!arg2) {
_context2.next = 45;
_context2.next = 46;
break;
}

Expand All @@ -131,19 +139,21 @@ var cli = /*#__PURE__*/function () {
_context2.t1 = _context2["catch"](32);
console.error("I found an error :(.");
console.error(_context2.t1, _context2.t1.message);
throw _context2.t1;

case 43:
_context2.next = 47;
case 44:
_context2.next = 49;
break;

case 45:
case 46:
console.error("I found an error :(.");
console.error("Nothing in clipboard and no arguments given. Pass in a JWT as the first argument or copy a JWT to your clipboard");
throw new Error("Nothing in clipboard and no arguments given. Pass in a JWT as the first argument or copy a JWT to your clipboard");

case 47:
case 49:
return _context2.abrupt("return", 1);

case 48:
case 50:
case "end":
return _context2.stop();
}
Expand Down
26 changes: 19 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ var jwtDecode = function jwtDecode(jwt) {
throw new SyntaxError("Not using compact serialization (JWS).");
} catch (e) {
// debugging(e);
console.error("I found an error :(.");
throw e;
}
};
Expand Down Expand Up @@ -172,12 +171,11 @@ var rs256JWKSign = function rs256JWKSign(headerPayload, privateKey) {
if (e instanceof TypeError) {
secret = privateKey;
} else {
console.error("I found an error :(.");
console.error(e.message, e);
throw e;
}
}
} else {
console.error("I found an error :(.");
console.error("RSA-SHA256 not found");
throw new Error("RSA-SHA256 isn't available in the current system.");
}
Expand Down Expand Up @@ -410,10 +408,25 @@ exports.createHeaderPayload = createHeaderPayload;
var base64URLEncode = function base64URLEncode(jsonObject) {
if (Buffer.isEncoding("base64url")) {
// not a string. convert to string
var stringifyHeader = JSON.stringify(jsonObject); // headerBase64URL = base64url.encode(stringifyHeader);
var stringify = JSON.stringify(jsonObject); // headerBase64URL = base64url.encode(stringifyHeader);

var payloadBase64URL = Buffer.from(stringifyHeader, "ascii").toString("base64url");
return payloadBase64URL;
var base64URLify = Buffer.from(stringify, "ascii").toString("base64url");
return base64URLify;
} else if (window) {
var b64c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // base64 dictionary

var b64u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; // base64url dictionary

var btoa = window.btoa();

var _stringify = JSON.stringify(jsonObject);

var base64urlify = btoa(_stringify); // Remove trailing "="

var s = base64urlify.split("=")[0];
s = s.replace("+", "-");
s = s.replace("/", "_");
return s;
}

throw new Error("Error: Base64URL encoding isn't available");
Expand Down Expand Up @@ -466,7 +479,6 @@ exports.parseToJSON = parseToJSON;

var jwtEncode = function jwtEncode(header, payload, key, options) {
var headerBase64URL;
var payloadBase64URL;
var jsonHeader = header;

if (Buffer.isEncoding("base64url")) {
Expand Down
2 changes: 1 addition & 1 deletion lib/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b7b835f

Please sign in to comment.