From 2c2ac7dcd8487fb6e41e1d1c8709f0ef72bedfc5 Mon Sep 17 00:00:00 2001 From: Anthony Dombrowski Date: Wed, 15 Nov 2023 06:22:56 -0600 Subject: [PATCH] added shebang added npm link to jwt-authn package --- cli_lib/index.js | 5 +++-- test-app/index.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cli_lib/index.js b/cli_lib/index.js index 31d5c6f..ff79853 100755 --- a/cli_lib/index.js +++ b/cli_lib/index.js @@ -1,5 +1,6 @@ #!/usr/bin/env node -"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.cli=exports.HELP_TEXT=void 0;var _index=require("../src/index.js");var _clipboardy=_interopRequireDefault(require("clipboardy"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}var GENERIC_ERROR_CODE=1;var decode=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(jwt){try{var decoded=yield(0,_index.jwtDecode)(jwt);return decoded}catch(e){throw e}});return function decode(_x){return _ref.apply(this,arguments)}}();var HELP_TEXT=exports.HELP_TEXT="******HELP*****\nuse -c or --clipboard or call command with no arguments to decode the JWT in your clipboard\nor call command with JWT as first argument\n****************";var cli=exports.cli=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(function*(clipboard,argv){// read passed in argument +"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.cli=exports.HELP_TEXT=void 0;var _index=require("../src/index.js");function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}// import clipboardy from "clipboardy"; +var clipboardy=Promise.resolve().then(()=>_interopRequireWildcard(require("clipboardy")));var GENERIC_ERROR_CODE=1;var decode=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(jwt){try{var decoded=yield(0,_index.jwtDecode)(jwt);return decoded}catch(e){throw e}});return function decode(_x){return _ref.apply(this,arguments)}}();var HELP_TEXT=exports.HELP_TEXT="******HELP*****\nuse -c or --clipboard or call command with no arguments to decode the JWT in your clipboard\nor call command with JWT as first argument\n****************";var cli=exports.cli=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(function*(clipboard,argv){// read passed in argument var arg2;var arg3;if(argv){arg2=argv[2];arg3=argv[3]}if(arg2=="-h"||arg2==="--help"){// Help display console.log(HELP_TEXT);return HELP_TEXT}else if(arg2==="-c"||arg2==="--clipboard"||!arg2){// Check for something in the clipboard. if(clipboard){// Great, there's something in the clipboard. Let's try to decode it as a @@ -9,5 +10,5 @@ console.log("Decoding: ");console.log(clipboard);var decoded=yield decode(clipbo console.log(decoded);return decoded}catch(e){console.error("I found an error :(");console.error("Couldn't decode what was in your clipboard. You might try copying the JWT again.");console.error("What's the problem? ");console.error(" ",e.message);console.error("What's on your clipboard? ");console.error(" ",clipboard);return GENERIC_ERROR_CODE}}else{console.error("I found an error :(");console.error("Didn't find anything in your clipboard.");return GENERIC_ERROR_CODE}}else if(arg2==="-b"||arg2==="--base64url"){if(!arg3){console.error("I found an error :(");console.error("No argument passed in to encode.");return GENERIC_ERROR_CODE}try{var bases64urlified=(0,_index.base64URLEncode)(arg3);console.log(bases64urlified);return bases64urlified}catch(e){console.error("I found an error :(");console.error("base64url encoding failed:",e.message)}}else if(arg2){try{var _decoded=(0,_index.jwtDecode)(arg2);console.log("Decoding: \n"+arg2);console.log(_decoded);// return decoded; }catch(e){console.error("I found an error :(.");// console.error(e, e.message); console.error(e.message)}}else{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")}});return function cli(_x2,_x3){return _ref2.apply(this,arguments)}}();// read from clipboard -var clipboard;try{clipboard=_clipboardy.default.readSync()}catch(e){clipboard=null}// read passed in argument +var clipboard;try{clipboard=clipboardy.readSync()}catch(e){clipboard=null}// read passed in argument var argv=process.argv;cli(clipboard,argv);var _default=exports.default=cli; diff --git a/test-app/index.js b/test-app/index.js index e69de29..41de4b4 100644 --- a/test-app/index.js +++ b/test-app/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +