isJWT.js 734 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isJWT;
  6. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7. var _isBase = _interopRequireDefault(require("./isBase64"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function isJWT(str) {
  10. (0, _assertString.default)(str);
  11. var dotSplit = str.split('.');
  12. var len = dotSplit.length;
  13. if (len > 3 || len < 2) {
  14. return false;
  15. }
  16. return dotSplit.reduce(function (acc, currElem) {
  17. return acc && (0, _isBase.default)(currElem, {
  18. urlSafe: true
  19. });
  20. }, true);
  21. }
  22. module.exports = exports.default;
  23. module.exports.default = exports.default;