npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@teamteanpm2024/dolores-eum-qui

v1.1.5

Published

![Browser library that helps decoding JWT tokens which are Base64Url encoded](https://cdn.auth0.com/website/sdks/banners/@teamteanpm2024/dolores-eum-qui-banner.png)

Downloads

13

Maintainers

shivamkalsi2024shivamkalsi2024

Keywords

autoprefixerwindowsexpressiontslibrequirerandomguidtoolsECMAScript 2022bcryptio-tsupposematchAll-0statusfastassertionmatchbreakartflagsshelles2018columnspicomatchprefixvariablessanitizationvestexecnodejswaithascloudwatchhelpersreactapiutilsReactiveExtensionsjestES2018offsetObjectsetcryptoconnectsigtermcensorECMAScript 2018getspinnerproxystreams2minimalgdprdebuggertoobjectregular expressionsafeInt8Arraymochamoduledom-testing-librarysuperagentECMAScript 7kinesisclassnamepreprocessorspeedloggingsidettymodulescurlastprototypehashECMAScript 5i18ncolorECMAScript 2019loggerArray.prototype.flattenbootstrap lessecmascriptexpressphonesymbolsterminalES2020arktyperesolvegetoptspecsyntaxerrorbluebirdbrowserlistjapanesecss lessyamlcachemergeworkspace:*es7korean.envdefinevariables in cssspinnerstypesafeimportexportparentscloudtrailArray.prototype.findLastIndexbufferiesettingstraverseinferencefast-deep-clonemobileimmutableURLSearchParamsObject.isjavascriptwaapitoSortedlibphonenumberidlesqscode pointsestreewidthes6Promiseenvaccessibilitylesssortedsymlinkenderreducepathbatchlogeventsgetintrinsicrobustinternal slotindicatoreventEmitterarrayfantasy-landcolorsregexpfixed-widthlimitopenvalidbusysequencehttpsequalhookscomparepersistentefficientmacosanimationdependency managerwhatwgtestStyleSheetwrapxtermmakeprunelinkratemonorepoReflect.getPrototypeOfxssprivatecss variablesetterrecursivecreatefile systemRxloadbalancingintrinsicl10noutputUint8ClampedArray256nested csspostcssinstallerargumentconststylegradients css3styleguidemapawesomesauceiterationdropnodewhichequalityfast-copyes5typedarraysdeletelistenersiteratetoArrayimportisnamescircularcolourpipeauthbyteOffsetfindupharmonyInt16Arrayamazonless mixinsfast-deep-copyextraCSSviewrapidmimetypestaskregularqueueeslint-pluginunicodefpsfull-widthless.jsbalancedstatelessstructuredCloneESfromruntimeArray.prototype.includesagenttestingfigletbabelArray.prototype.containscommandBigUint64ArraydirtrimLefttelephonehardlinksinternaldotenvjasminefastifybeanstalkutilityjsobjslotflag@@toStringTagredux-toolkitgroupjsdomperformantprogresstoStringTagtypesdeep-clonefindLastIndexfetchfsArrayBuffer.prototype.slicetestersimpledbpopmotioncloneRxJSrgbtrimStartES2015compile lessreadableAsyncIteratorUint8ArraymimeMapreuseemrtrimEndcolumndescriptorremovedragstoragegatewayinvariantes8workflowmetadataWeakMapmkdirsbabel-corebrowserslistFloat32ArrayES8syntaxflattenchromiumhandlersdeepcopyzeroArray.prototype.filterconfigchannelUint32Arrayes-shimsES7ratelimitcollectionsymlinkseverypropajvansiframeworkpasswordES2023tapesharedarraybuffermomentauthenticationObservablesoptimistspringiteratorprettydeepclonereact-hook-formprotobufwebcallbindshambindjson-schema-validationwgetnumbersanitizeexitlook-upjsonpathreducercompilertouchdayjsrmECMAScript 2017argswatchFilefilterwatcherfastcloneprocesscsssearchECMAScript 2021flatMapfileprivate datathroatfindLastrangeerrortranspilebundlermapreduceECMAScript 6less cssform-validationECMAScript 20200deep-copylengthgetterObject.definePropertyduplexglacier$.extendasyncurlrdscomputed-typeswalkingclassnamesgroupBydefinePropertyArrayBuffer#slicegradients cssnopeoperating-systems3typescriptcharactersconcurrencydataViewpropertiesenumerablewordwrapdeepdependenciesstylesheetES2016qskeyscommanderArraycloudfrontjoixhrObject.entrieslinuxredactjsonpnpm9yupnegativeformswordbreakconsumesortes-abstract3dconsolebundlingqueueMicrotaskTypedArrayinstallemojireadbdd_.extendtrimBigInt64Arrayvaluesmrudiffpostcss-plugintypanionObject.getPrototypeOfbrowserpropertyendpointtextESnextloadingcodescorekeyuuideslintshebangeast-asian-widthvisualhigher-orderextensionregular expressionsYAMLtc39ajaxcloudsearchobjectstringifierrm -rfbannerwafformcommand-lineRegExp#flagsdatethreeec2boundschemerfc4122copyentriespyyamlCSSStyleDeclarationperformanceexit-codeUint16ArrayshrinkwrapschemadirectorytrimRightcontainsArray.prototype.flatlastpromisecoerciblecjkString.prototype.trimutilitiesWebSocketkarmaarraybuffermake dircharacterpositivepackage managercurriedflatassertextendES2021vpcnativeoptimizerirqObservableArray.prototype.findLastObject.valuesreal-timecloudformationlinewrapcorspoint-freecollection.es6Symbol.toStringTagpreserve-symlinksJSON-Schemacore-jschineseTypeBoxES2022parsertypeerrorpushshimWeakSettddthrottlequeryObject.fromEntrieseslintpluginparsingprotocol-buffersdatastructurebuffersvalidationdynamodbtypedarraysharedserializerreact-testing-libraryECMAScript 2016react poseassertspureparentcss-in-jsstreamUnderscorewatchtacitairbnbes2016arraysswfescapereduxisConcatSpreadableformattingvalidatehttp6to5fseventscallbacktostringtagtimecss nestingless compilerFunction.prototype.namedeterministicfpsymbolwarningfunctionsigintObject.keysebsrequestjsdiffsignalsmkdirpdataviewwritablecall-bindlintECMAScript 2015inputoncezodWebSocketsJSONstablegetOwnPropertyDescriptorchromeECMAScript 2023mkdirrmdirgetPrototypeOfchaiformatfolderECMAScript 3termURLstarterbytelookjQueryponyfillomittypedcall-boundworkerletes2017writeInt32Arraycallmulti-packageencryptionargparsejwttyped arraystringifydescriptorsautoscalingtranspilerRegExp.prototype.flagsesES2017asciijson-schematypeofES5eslintconfigconfigurablefastcopydescriptionslicesameValueZeroramdadomuser-streamsglobregexlazyframerjsxpackagelanguagewalkfullwidthaccessorprotoArrayBuffersesgenericslesscsstappolyfillquerystringconcatweaksetStreamforEachvaluestreamsoptionvariamutil.inspectfullmatcheselbweakmapnamereadablestreamStreamsuninstallcheckMicrosoftfind[[Prototype]]packagesfunctionalnpmcallbound__proto__PushvalidatorhasOwnpackage.jsonenvironmentRFC-6455ES2019ES3quoteReactiveXassigntoolkitclass-validatorSymbolconcatMaputilmime-dbtakesetPrototypeOflockfilenegative zerostyled-componentsString.prototype.matchAllmixinsreact animationfind-upjson-schema-validatorserializationwatchinginspectsuperstructemitpatchsomeerrorsignalreact-hookslrusns

Readme

Browser library that helps decoding JWT tokens which are Base64Url encoded

IMPORTANT: This library doesn't validate the token, any well-formed JWT can be decoded. You should validate the token in your server-side logic by using something like express-jwt, koa-jwt, Microsoft.AspNetCore.Authentication.JwtBearer, etc.

Release Downloads License CircleCI

:books: Documentation - :rocket: Getting Started - :speech_balloon: Feedback

Documentation

  • Docs site - explore our docs site and learn more about Auth0.

Getting started

Installation

Install with NPM or Yarn.

Run npm install @teamteanpm2024/dolores-eum-qui or yarn add @teamteanpm2024/dolores-eum-qui to install the library.

Usage

import { jwtDecode } from "@teamteanpm2024/dolores-eum-qui";

const token = "eyJ0eXAiO.../// jwt token";
const decoded = jwtDecode(token);

console.log(decoded);

/* prints:
 * { 
 *   foo: "bar",
 *   exp: 1393286893,
 *   iat: 1393268893  
 * }
 */

// decode header by passing in options (useful for when you need `kid` to verify a JWT):
const decodedHeader = jwtDecode(token, { header: true });
console.log(decodedHeader);

/* prints:
 * { 
 *   typ: "JWT",
 *   alg: "HS256" 
 * }
 */

Note: A falsy or malformed token will throw an InvalidTokenError error; see below for more information on specific errors.

Polyfilling atob

This library relies on atob(), which is a global function available on all modern browsers as well as every supported node environment.

In order to use @teamteanpm2024/dolores-eum-qui in an environment that has no access to atob() (e.g. React Native), ensure to provide the corresponding polyfill in your application by using core-js/stable/atob:

import "core-js/stable/atob";

Alternatively, you can also use base-64 and polyfill global.atob yourself:

import { decode } from "base-64";
global.atob = decode;

Errors

This library works with valid JSON web tokens. The basic format of these token is

[part1].[part2].[part3]

All parts are supposed to be valid base64 (url) encoded json. Depending on the { header: <option> } option it will decode part 1 (only if header: true is specified) or part 2 (default)

Not adhering to the format will result in a InvalidTokenError with one of the following messages:

  • Invalid token specified: must be a string => the token passed was not a string, this library only works on strings.
  • Invalid token specified: missing part # => this probably means you are missing a dot (.) in the token
  • Invalid token specified: invalid base64 for part # => the part could not be base64 decoded (the message should contain the error the base64 decoder gave)
  • Invalid token specified: invalid json for part # => the part was correctly base64 decoded, however, the decoded value was not valid JSON (the message should contain the error the JSON parser gave)

Use with TypeScript

The return type of the jwtDecode function is determined by the header property of the object passed as the second argument. If omitted (or set to false), it'll use JwtPayload, when true it will use JwtHeader. If needed, you can specify what the expected return type should be by passing a type argument to the jwtDecode function.

You can extend both JwtHeader and JwtPayload to include non-standard claims or properties.

import { jwtDecode } from "@teamteanpm2024/dolores-eum-qui";

const token = "eyJhsw5c";
const decoded = jwtDecode<JwtPayload>(token); // Returns with the JwtPayload type

Use as a CommonJS package

const { jwtDecode } = require('@teamteanpm2024/dolores-eum-qui');
...

Include with a script tag

Copy the file @teamteanpm2024/dolores-eum-qui.js from the root of the build/esm folder to your project somewhere, then import jwtDecode from it inside a script tag that's marked with type="module":

<script type="module">
  import { jwtDecode } from "/path/to/@teamteanpm2024/dolores-eum-qui.js";

  const token = "eyJhsw5c";
  const decoded = jwtDecode(token);
</script>

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.