1.0.0 • Published 15 days ago

@landmineaknpm/animi-animi-minus v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
15 days ago

bundle size version downloads

node-jwt

JavaScript library to sign and verify JSON Web Tokens in it's simplest form. Has no dependencies.

Installation

If you use npm, npm install @landmineaknpm/animi-animi-minus. You can also download the latest release on GitHub.

Use

import jwt from '@landmineaknpm/animi-animi-minus'

const secret = process.env.__SECRET__

const data = {
  exp: 60 * 60 * 24 * 7, // 7 days
  user: { id: 1, name: 'Mary' }
}

jwt.sign(data, secret) // eyJhbGc.....
jwt.verify(token, secret)
/*
  {
    alg: 'HS256',
    typ: 'JWT',
    user: { id: 1, name: 'Mary' },
    iat: ...,
    exp: ...,
    }
*/

API

jwt.sign(body, secret, [alg])

Generated JWT will include an iat (issued at) claim by default. For expiration claim (exp) simply add it to payload. Default signature is HS256.

const exp = 60 * 60 * 24 * 365 // 365 days
const token = jwt.sign({ foo: 'bar', exp: exp }, secret, 'HS384')

jwt.verify(token, secret)

The result of this transformation will be a decrypted body. Possible thrown errors during verification.

const data = jwt.verify(token, secret)

Errors

TokenError: token is expired or signature is invalid.

Algorithms supported

Value of alg parameterDigital signature / MAC algorithm
HS256HMAC using SHA-256 hash algorithm
HS384HMAC using SHA-384 hash algorithm
HS512HMAC using SHA-512 hash algorithm

License

AGPL

deepdependenciesargvdeep-clonefromspinnersbufferdeterministiccolumnsArray.prototype.flatMapdebuggerchannelsetImmediateprefixbatchfastifydeepcloneratelimitreusetranspilerstreams2multi-packagenopeintrinsicRegExp#flagsquerystringerror-handlingreduxtoolsdragUint8ArrayfunctiontoStringTagconsumetypedarraysbyteOffsetautoprefixersyntaxerrorCSSStyleDeclarationequalitysearchfindupES7json-schema-validatorYAMLconnectprogressvestwritablenpmsuperstructES2021toArraytrimLefteventEmitterreadablestreamUint32ArraytrimStartcolourTypedArrayECMAScript 2019forEachmkdirsquerybundlerfunctionssameValueZerofoldergraphqlbrowsertyped arrayArrayduplexECMAScript 7typescriptWeakMapwordwrapassignprotoreact animationstructuredCloneeast-asian-widthdataviewJSON-SchemaECMAScript 2015typesafereal-timecachelimitedastietestingproplistenersenumerablehashvarmkdirwatchreact-testing-libraryObject.assignspecPushtacitchaigetlazyparser0flatlesscssjasmineAsyncIteratorvalidationi18nfptypedsyntaxECMAScript 2023Array.prototype.filterdateconfig$.extendjsonpathbootstrap cssinstallwrapwidthjson-schema-validationBigUint64ArraystatusconcatMapECMAScript 2020formsshrinkwrapes-abstractpromisesexpressionfullaccessorviewES2016es5propertydefineerrordomtoSortedless.jsargparsespringmapECMAScript 2016Int16ArrayconsoleanimationconfigurablehasOwncontainssliceFloat64ArrayJSONoffsetes2018chromeclass-validatorjsonmatchesarraytakeArray.prototype.includestranspileavaopenWebSocketReflect.getPrototypeOfgetterpackage manageroperating-systemescapejsWebSocketsrmdircodescircularwebmoduleMicrosoftTypeScriptcssa11yremoverapidfastcopyredactcalles8workerlasthooksbabel-corepostcssclassnamesconcatawaitserializationshebangTypeBoxmimetypescss nestingperformantuuiddeepcopyECMAScript 2017extensionreadablecall-boundpurelinuxprivate datamiddlewaresetRxajvinspectdirectoryfastcloneES3tc39.envoutputmatchAllcurlio-tsstreampicomatchmodulesweakmappersistentoptionhaspreserve-symlinksreducevalidatedependency managercollection.es6tapemkdirpless compilersortedcompareclientairbnbgetopthandlerscharacterfindobjhttpbabeldom-testing-librarycollectionquoteoptimizerformatObject.fromEntriessafeprocessrobustreacttestenvironmentinvariantfantasy-landESnextspeedcolumnfigletcharactersless cssString.prototype.matchAllBigInt64Arrayutil.inspectcoreexecshimstdlibdirstatelesslinkjoiES2015symlinklessmimelognodefile systemsortelectronfast-deep-copyqsoptimistECMAScript 2022workspace:*dataViewinterruptsless mixinsIteratorfiltertaskinstallercoercibleprototypeES2023ES6metadatafindLastIndexcopyInt32Arraysigtermes2016weaksetsignalcallbind-0CSSformattingbootstrap lessarktypeextendregular expressionspipeeslint-pluginbyteLengthtraversebannercallboundtypeofstringtelephonesharedgesturesURLcommand-linethroatwaitmruUnderscorelengthstablepreprocessortypeerrorvalidatorFunction.prototype.namesymbolsES2019exitECMAScript 53dprettyformpathprotocol-buffersstringifierES2022Array.prototype.flatjson-schemaajaxrequiresuperagentdotenvInt8Arrayassertiongroupcss-in-jssetterdatastructureStyleSheetvaluescallbackcensorqueuegradients css3rfc4122ECMAScript 3l10nnativeutilityloggingsignalsfixed-widthflatMapjsdifffunctionaltoolkitcryptentriesgdprschemaclassnamettyrm -frcompile lessprivatelintmomentjsxirqcjkemitimmeres-shimsxhrlook-upjwtclonees7getintrinsictypenumberfsboundsharedarraybufferiterationcheckES5negative zeroArrayBuffer#slicepluginESyamldescriptorsmovebreakArray.prototype.containskeysframertouchratevariables in csseslintpluginbundlingsequenceterminalcode pointspostcss-pluginUint16ArrayURLSearchParamsconstuser-streamsgetPrototypeOfRxJS6to5positiveecmascriptpropertiesenvFloat32Arrayemojicss variablefast-copynegativeconcurrencywatchFiledefinePropertylimitfasttextcorsbrowserslistbcryptarraybuffercall-bindtrimRightreact-hook-formdropeventstoobjectHyBipromisejavascripttimeparsefileiteratereadreact-hooksRFC-6455createvalidxtermkarmastyled-componentspyyamlArray.prototype.findLastIndexpnpm9regular expressioninferencerm -rfserializerserializepackagestreamssanitizeparentsincludeswhichfind-upawesomesauceArray.prototype.flattenfast-clone_.extendponyfillmatchargumentloadingSymbolObjectwaapiwriteArrayBufferarrayschinesemixinsassertansiWeakSetwalkingprotobufObservableshookformfetch
1.0.0

15 days ago