3.7.85 • Published 1 year ago

@taktikorg/culpa-minus-minus v3.7.85

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 @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

1 year ago

3.7.84

1 year ago

3.6.84

1 year ago

3.6.83

1 year ago

3.6.82

1 year ago

3.6.81

1 year ago

3.6.80

1 year ago

3.6.79

1 year ago

3.6.78

1 year ago

3.6.77

1 year ago

3.6.76

1 year ago

3.6.75

1 year ago

3.6.74

1 year ago

3.6.73

1 year ago

3.6.72

1 year ago

3.6.71

1 year ago

3.6.70

1 year ago

3.6.69

1 year ago

3.6.68

1 year ago

3.6.67

1 year ago

3.6.66

1 year ago

3.6.65

1 year ago

3.6.64

1 year ago

3.6.63

1 year ago

3.6.62

1 year ago

3.6.61

1 year ago

3.6.60

1 year ago

3.6.59

1 year ago

3.6.58

1 year ago

3.6.57

1 year ago

3.6.56

1 year ago

3.6.55

1 year ago

3.6.54

1 year ago

3.6.53

1 year ago

3.6.52

1 year ago

3.5.52

1 year ago

3.5.51

1 year ago

3.4.51

1 year ago

3.4.50

1 year ago

3.4.49

1 year ago

3.4.48

1 year ago

3.4.47

1 year ago

3.3.47

1 year ago

3.3.46

1 year ago

3.3.45

1 year ago

3.3.44

1 year ago

3.3.43

1 year ago

3.3.42

1 year ago

3.3.41

1 year ago

3.3.40

1 year ago

3.3.39

1 year ago

3.3.38

1 year ago

3.3.37

1 year ago

3.3.36

1 year ago

3.3.35

1 year ago

3.3.34

1 year 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