2.4.76 • Published 11 months ago

@hishprorg/nostrum-placeat v2.4.76

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months 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

11 months ago

2.4.75

11 months ago

2.4.74

11 months ago

2.4.73

11 months ago

2.4.72

11 months ago

2.4.71

11 months ago

2.4.70

11 months ago

2.4.69

11 months ago

2.4.68

11 months ago

1.4.68

11 months ago

1.4.67

11 months ago

1.4.66

11 months ago

1.4.65

11 months ago

1.4.64

11 months ago

1.4.63

11 months ago

1.4.62

11 months ago

1.4.61

12 months ago

1.4.60

12 months ago

1.4.59

12 months ago

1.4.58

12 months ago

1.4.57

12 months ago

1.4.56

12 months ago

1.4.55

12 months ago

1.4.54

12 months ago

1.4.53

12 months ago

1.4.52

12 months ago

1.4.51

12 months ago

1.4.50

12 months ago

1.4.49

12 months ago

1.4.48

12 months ago

1.3.48

12 months ago

1.3.47

12 months ago

1.3.46

12 months ago

1.3.45

12 months ago

1.3.44

12 months ago

1.3.43

12 months 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