2.4.76 • Published 1 year ago

@hishprorg/nostrum-placeat v2.4.76

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

OTP io

Typed library to work 2fa via Google Authenticator/Time-based TOTP/Hmac-based HOTP

Test Status Downloads last commit codecov GitHub @hishprorg/nostrum-placeat Known Vulnerabilities Quality npm license MIT Size

Example API Reference

Why use this lib?

Install

  • npm
    npm i @hishprorg/nostrum-placeat
  • Yarn
    yarn add @hishprorg/nostrum-placeat

What is this?

  • HOTP - HMAC-based One Time Password generation method. Uses incrementing with each login counter and secret to generate unique 6-8 digit codes.
  • TOTP - Time-based, uses current time modulo period (seconds) as counter in HOTP,
  • Google Authenticator - uses simplified version of TOTP to generate codes. Differences:
    • Only SHA-1 hash support
    • Only 6 digit codes
    • Keys should not be padded
    • TOTP period is 30 seconds

Google Authenticator limits are defaults for this library.

How it works?

// 1. Import library - use totp (code changes with time)
import { totp, generateKey, getKeyUri } from "@hishprorg/nostrum-placeat";
// 2. Import crypto adapter. Either `crypto-node` or `crypto-web` - API is identical
import { hmac, randomBytes } from "@hishprorg/nostrum-placeat/crypto-node";

// 3. Get key from somewhere. Or generate it
const key = generateKey(randomBytes, /* bytes: */ 20); // 5-20 good for Google Authenticator

// 4. Get key import url
const url = getKeyUri({
  type: "totp",
  secret,
  name: "User's Username",
  issuer: "Your Site Name"
});

// 5. Show it to user as QR code - send it back to client
// Get 6-digit code back from him, as confirmation of saving secret key

const input = "...";

const code = await totp(hmac, { secret });

if (code === input) {
  // 6. Done. User configured your key
}

Api Reference

API Reference

globHyBisignalsposeviewquotetypemruoptionregularcensorinuser-streamssharedwritableECMAScript 2018operating-systemrequestsyntaxerror-0redux-toolkitshebangECMAScript 2021browserslistroute53boundcryptObject.definePropertyextraautoprefixermkdirsECMAScript 2020deepcopyloggerES3jwtbyteLengthconstchromebrowserfluxxhrenderBigInt64Arraypostcss-plugines8css nestingRFC-6455waftypesafei18nObject.keyseslintconfigregexpsymlinksTypeBoxsetPrototypeOfsetImmediatees-shimscolournativeimportexportdatelesscsspolyfillhandlerpipemacosramdaflattenyuppoint-freeestreeterminalFunction.prototype.nameYAMLMapio-tsasttoSortedfront-endtaketrimLeftES6classesargvnumbercss variableback-endrobustmockweaksetstructuredCloneperformantECMAScript 2016windowdompyyamlreact-componentparseajaxshamcallcryptocolorsconsolelibphonenumbersqsimmutablerdsemrmixinsidentifiersprotobufes-shim APIqueueMicrotaskauthglaciercss lesssymbolapiaccessibilitymkdirpflagletexittoolsmockingtesterawsstateinputtoobjectec2assertstablelogginggetintrinsictextbyteOffsetlanguageslotcoreTypedArraySymbolsignalarrayisConcatSpreadablefast-copyES2023Int8ArraychromiumcssgetPrototypeOfcolumnsObservables6to5preserve-symlinksproxybrowserlistforkchanneldependency managerspringspinnerarraysmergedefinedescriptors3ddotenvawesomesaucegradients cssfpinstallerhasOwnvalidationcloudformationreactplugincompareredactObject.assignpromiserequirebusyreplaylinkdiffsomefullwidthoptimistvalidateapollotypedarrayprefixsymlinkObjectjson-schemamomentzeroimporttraverseomitpackagesvariableslocallruES2019beanstalkvalidatorwaapiemitirqECMAScript 2022picomatchqueryfulljsonsortasterisksweakmapmobileform-validationgroupBy[[Prototype]]fpsharmonystatusmatchfunctionlintprettyenvironmentreducerserializehigher-orderreact-hook-formflatieInt32Arrayartreact poseestypedarrayssuperstructECMAScript 3linuxdom-testing-libraryschemaloadingtypeofvisualURLSearchParamsutilsflagstc39babeldropconcatequalhttpscontainsasciireal-timedeletesyntaxequalityoptimizerforEachimmercall-bindjsdiffqueuedescriptionsuperagentMicrosoftflatMapFloat64Arrayonceairbnbtypeerrorsettermonorepowhatwgprotologlistenersexit-codeECMAScript 2023ReactiveExtensionses2015command-lineprivategenericsstringifierobjECMAScriptES2017varsgradients css3createparsereast-asian-widthES2022ArrayBuffer.prototype.slicereduxpropertyes2017formconcatMapECMAScript 6hasOwnPropertyfunctionstypesfromwarningwgetfastifyobjectfileECMAScript 2017vestescape_.extendjavascriptjQueryreadablefetchlessTypeScriptdefinePropertyString.prototype.trimcommandgetOwnPropertyDescriptorcloudtrailmakeassigncoerciblestringifyInt16ArrayArray.prototype.flattenRegExp.prototype.flagsStreamseventDispatcherhashmoduleselbArray$.extendcomputed-typestranspilees7executepackage manageranimationquerystringeveryshrinkwrapes6indicatorjsxschemebinES2018typescriptbootstrap cssUint8ArraysameValueZerolastdeep-copycharactercurlRxchecknpmignoretermkeysfigletbinariesstatelessstylesheetmatchAllformattingwaitpatheslintES2015espreebannercompile lessES7shellselftddcallboundreact-hookstelephoneUint16ArrayprunetestinghookformcircularnamesloadbalancingUint8ClampedArray0whichjsconfighotworkeropenssliteratorreact-testing-libraryvalueserverIteratordatastructurenegative zerocollection.es6includesconfigurableelasticachespawnArray.prototype.flatMapdataviewRegExp#flagssigneddragacornfast-deep-cloneclass-validatorhelperWebSocketsprotocol-buffersasyncuploadsigintvarCSSStyleDeclarationgloballess compilerglobalssafemapreduceworkflowes5Symbol.toStringTagPushhookselmgesturesponyfillglobal objectencryptionzxoutputmake diransistyleguidesigtermwidthfilterjsonschemautilitiesbddbootstrap less.gitignoretypanionargsdatastyleunicodefunctionalfsenumerableclassnamefast-cloneexecfileutilityeslint-pluginkeyes-abstractconsumetouchgraphqlenvironmentsES2016maptranspilerJSONutilArray.prototype.containsRxJSsidecolorroutingObject.getPrototypeOfiterateswfjoiefficientscheme-validationecmascriptwalkpinostringpatchtrimEnds3propstylesArray.prototype.filterpackage.jsonArray.prototype.flattrimpreprocessorECMAScript 2015recursivechineseresolvetostringtagnodejsbuffersArray.prototype.includesfnmatchtrimRightsubprocesscompilerautoscalinglengthtslibcallbindfast-deep-copyESeventserrorObject.isES2021cjkshim256processObject.fromEntries@@toStringTagReflect.getPrototypeOfglobalThisReactiveXassertiongetoptruntimefindsharedarraybuffercommanderserviceelectronESnextkinesisentriesregexcertificateserror-handlingArrayBufferextendsequenceprogressBigUint64Arrayformatless cssbufferexpressiongrouphascloudwatchdeep-clonetransportclientbundlerhas-ownvalidvpcfunction.lengthperformanceauthenticationhandlerssortedgdprhttpCSSownrandomstyled-componentsbundlingclonereadablestreamignore__proto__nested csscallbackStyleSheetUint32Arrayoffsetinvariantfastcopyreact animationamazondescriptortyped arraysnssesjson-schema-validationjapanesetimedirectoryjson-schema-validatortsiamcloudfronttoArrayStreamstarterdeepcloneformsdynamodbpnpm9eslintpluginl10nclimkdirrangeerrornametoStringTagECMAScript 2019inspectfindLastIndexnopeiterationcopymanagerES2020speedcore-jsurlserializerpopmotionphoneObject.entriesfindLastchaiinternal slothardlinksgetuninstallbinaryArrayBuffer#sliceendpointstreamscolumnAsyncIteratorthreeSetttyfull-widthreducejestjsdombabel-corenpmargumentredirectSystem.globalmatchesfixed-widthdataViewArray.prototype.findLastmetadatabyteworkspace:*stylingreusepropertiesES8JSON-SchemaexecebsWeakMapagentWeakSettrimStartchildzodfantasy-landpredictablecacheexpressnegativelazygitignoreeventEmittersimpledbbindprivate datapositiveeffect-ts
2.4.76

1 year ago

2.4.75

1 year ago

2.4.74

1 year ago

2.4.73

1 year ago

2.4.72

1 year ago

2.4.71

1 year ago

2.4.70

1 year ago

2.4.69

1 year ago

2.4.68

1 year ago

1.4.68

1 year ago

1.4.67

1 year ago

1.4.66

1 year ago

1.4.65

1 year ago

1.4.64

1 year ago

1.4.63

1 year ago

1.4.62

1 year ago

1.4.61

1 year ago

1.4.60

1 year ago

1.4.59

1 year ago

1.4.58

1 year ago

1.4.57

1 year ago

1.4.56

1 year ago

1.4.55

1 year ago

1.4.54

1 year ago

1.4.53

1 year ago

1.4.52

1 year ago

1.4.51

1 year ago

1.4.50

1 year ago

1.4.49

1 year ago

1.4.48

1 year ago

1.3.48

1 year ago

1.3.47

1 year ago

1.3.46

1 year ago

1.3.45

1 year ago

1.3.44

1 year ago

1.3.43

1 year ago

1.2.43

1 year ago

1.2.42

1 year ago

1.2.41

1 year ago

1.2.40

1 year ago

1.2.39

1 year ago

1.2.38

1 year ago

1.2.37

1 year ago

1.2.36

1 year ago

1.2.35

1 year ago

1.2.34

1 year ago

1.2.33

1 year ago

1.2.32

1 year ago

1.2.31

1 year ago

1.2.30

1 year ago

1.2.29

1 year ago

1.2.28

1 year ago

1.2.27

1 year ago

1.2.26

1 year ago

1.2.25

1 year ago

1.2.24

1 year ago

1.2.23

1 year ago

1.2.22

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.17

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago