3.7.85 • Published 10 months ago

@taktikorg/culpa-minus-minus v3.7.85

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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 @taktikorg/culpa-minus-minus Known Vulnerabilities Quality npm license MIT Size

Example API Reference

Why use this lib?

Install

  • npm
    npm i @taktikorg/culpa-minus-minus
  • Yarn
    yarn add @taktikorg/culpa-minus-minus

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 "@taktikorg/culpa-minus-minus";
// 2. Import crypto adapter. Either `crypto-node` or `crypto-web` - API is identical
import { hmac, randomBytes } from "@taktikorg/culpa-minus-minus/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

commandbannerReflect.getPrototypeOftypesbusyassertastdataViewworkerarraythreefindLastIndexWeakSetargsflagtestchilddirectorycryptescolumnhttpPromisechromecharacterchecklesscssreversedmacosArray.prototype.filtereast-asian-widthchaitestingjestdiffcjkgroupchanneltrimStartartswfexecutepreprocessorclientpredictablecallbindstreamsnegative zeropreserve-symlinksflatformatjshintapieventDispatchersomeefficientnodejsownregular-expressionhelpersfromrapidjwthelperenumerablettyexit-codei18nbinaryfastifyrandombcryptes-shim APIstructuredClonezodbundlingfunctionstsimportexportpoint-freedefinePropertyescapesymlinkObject.assignmkdirpfastES2019css variableestreeasterisksCSSStyleDeclarationiteratetypedarraycore-jslanguagejapanesehandlerscollectionroutingeslinttrimLeftemitboundtypescriptprogressisreverseECMAScriptObject.getPrototypeOfiefiltergetintrinsicextrabyteLengthMapbindhashmanagerstylesheetES3redactfastcopyMicrosoftgetoptpropertytslibeslintconfigcloudsearchmake dirperformantsetImmediatesidees2016shamauthenticationkinesisclassnamestc39deletesymbolsmatchcloudtrailhookserrorpyyamldefinebuffersstatelessbabel-corees2018testerschemaa11yhasOwnPropertyglobalThiscopypersistentpostcsssuperagentcommand-lineWeakMapreadYAMLtypeofcolorless.jsUint8ClampedArraySetunicodeformnamemonorepoutilsdescriptoruser-streamssignalsramdareducepureglobalsdescriptionchineseec2ignorerecursiveimmutablefindparserECMAScript 2022form-validationes2017npmignorepopmotioncryptoiterationpropertiesdeep-copyrouteprocessserializationrfc9562global objectFunction.prototype.nameendpointsameValueZeroreact-testing-libraryrdsReactiveXvalidatoruninstallinstallbeanstalksyntaxarraybuffersignalhasOwnoffsetArrayBufferUint16Arraycss-in-jsredux-toolkitcallbackPushvariablesdatastructurejson-schema-validationArray.prototype.includesresolvepositiveparsefast-deep-clonedayjsvisualsuperstructbootstrap csssortedtouchairbnbcall-bounditeratorfast-copyrobustlazymatchAllcoercible_.extendsetPrototypeOfdataviewawsvariables in cssvpcHyBifullwidthnumberquerystringstatuslastponyfillutilityBigUint64Array[[Prototype]]l10ntyped arrayString.prototype.trimflagsawesomesaucecurriedgenericsanimationspinnerbinariesdeepcopyuuidmodulejsstringtraverseStyleSheetpromisetypaniongraphqlstylingautoscalingeventsexpressionoptimizerassignwaftostringtagxhrgdprES2018expresslistenersObject.fromEntriesprotocol-buffersframerecmascriptincludesbundlertransportbootstrap lesschromiumfile systemloglinuxurlvaluescss nestinglengthpipeidentifiersoperating-systemmodulesenvRegExp.prototype.flagsWebSocketsparsingcompileres5sortisConcatSpreadablepushqsweakmapObject.isSymbolcolorssetterlints3regexcontainsdomfulles-abstracttypeES2023regularindicatorinvariantreduxes7ES2017hardlinksFloat32ArrayECMAScript 6Arrayfigletpathjson-schema-validatorautoprefixerloadbalancingyamlfunctionebsamazonvestsequenceArray.prototype.flatMaptrimEndposeRegExp#flagsclassessharedarraybufferObservablemapreducelockfilesqssimpledbtddgetOwnPropertyDescriptortimeelectroncss lessfunctionalECMAScript 7colourutilconcatMapArrayBuffer.prototype.slice0ES2021patchexecasyncstablemapcolumnsReactiveExtensionstypedarraysTypeScriptslotArray.prototype.findLastmkdirs.gitignoreeventEmittercompile lessfull-widthECMAScript 2021256URLObject.entriesInt32Arraycensorcertificatesagentfastcloneprototypeprefix
3.7.85

10 months ago

3.7.84

10 months ago

3.6.84

10 months ago

3.6.83

10 months ago

3.6.82

10 months ago

3.6.81

10 months ago

3.6.80

11 months ago

3.6.79

11 months ago

3.6.78

11 months ago

3.6.77

11 months ago

3.6.76

11 months ago

3.6.75

11 months ago

3.6.74

11 months ago

3.6.73

11 months ago

3.6.72

11 months ago

3.6.71

11 months ago

3.6.70

11 months ago

3.6.69

11 months ago

3.6.68

11 months ago

3.6.67

11 months ago

3.6.66

11 months ago

3.6.65

11 months ago

3.6.64

11 months ago

3.6.63

11 months ago

3.6.62

11 months ago

3.6.61

11 months ago

3.6.60

11 months ago

3.6.59

11 months ago

3.6.58

11 months ago

3.6.57

11 months ago

3.6.56

11 months ago

3.6.55

11 months ago

3.6.54

11 months ago

3.6.53

11 months ago

3.6.52

11 months ago

3.5.52

11 months ago

3.5.51

12 months ago

3.4.51

12 months ago

3.4.50

12 months ago

3.4.49

12 months ago

3.4.48

12 months ago

3.4.47

12 months ago

3.3.47

12 months ago

3.3.46

12 months ago

3.3.45

12 months ago

3.3.44

12 months ago

3.3.43

12 months ago

3.3.42

12 months ago

3.3.41

12 months ago

3.3.40

12 months ago

3.3.39

12 months ago

3.3.38

12 months ago

3.3.37

12 months ago

3.3.36

12 months ago

3.3.35

12 months ago

3.3.34

12 months ago

3.3.33

1 year ago

3.3.32

1 year ago

3.2.32

1 year ago

3.2.31

1 year ago

3.2.30

1 year ago

3.2.29

1 year ago

3.2.28

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

2.1.19

1 year ago

2.1.18

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago