{"_id":"2fauth-lib","_rev":"2-17f50e636a0d342fc38aa65307f7b70a","name":"2fauth-lib","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"2fauth-lib","version":"1.0.0","keywords":["authroization","2fa","api"],"author":{"name":"Zeilinger Alexander"},"license":"GPL-2.0","_id":"2fauth-lib@1.0.0","maintainers":[{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"}],"dist":{"shasum":"e540afa038b874f65d1f0329e5a7642b6a3d181d","tarball":"https://registry.npmjs.org/2fauth-lib/-/2fauth-lib-1.0.0.tgz","fileCount":4,"integrity":"sha512-1phu3bjGKqOGXoDN5tIxfEk2qg/lw/SjNzd72lI/GEf+sLSqqQwc/21S1X7jjzXEAur9sWKXGptbE798ugIUXQ==","signatures":[{"sig":"MEUCIH5iJemPWZ4EygSh7IAq1qkcnfqdExEdAVuJW8syzbyTAiEA3h6Zd1uODQRswOpQeQ6dDjrQ+ZWlPXq88QvbHhAeTfY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":27053},"main":"auth.js","type":"module","module":"auth.js","gitHead":"83b33b46d83388c7587bb51c74fa304b178bcbd9","scripts":{"test":"NODE_OPTIONS='--experimental-vm-modules --experimental-specifier-resolution=node' jest"},"_npmUser":{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"},"repository":{"url":"TODO : add","type":"git"},"_npmVersion":"10.9.0","description":"Authorization lib for authenticating users with passwords and 2fa","directories":{},"_nodeVersion":"22.9.0","dependencies":{"bcrypt":"^5.1.1","totp_generator_hexadecimal":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","@types/jest":"^29.5.14"},"_npmOperationalInternal":{"tmp":"tmp/2fauth-lib_1.0.0_1729749220984_0.575688054259134","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"2fauth-lib","version":"1.0.1","keywords":["authroization","2fa","api"],"author":{"name":"Zeilinger Alexander"},"license":"GPL-2.0","_id":"2fauth-lib@1.0.1","maintainers":[{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"}],"homepage":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator#readme","bugs":{"url":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator/issues"},"dist":{"shasum":"fd7a3b504ada6eaf36ded506c403337209c93a35","tarball":"https://registry.npmjs.org/2fauth-lib/-/2fauth-lib-1.0.1.tgz","fileCount":4,"integrity":"sha512-Mpma7RoNqndjEJGdNisXl8YqIEb2MoCDz1UXrTrodW9Eb2a5zwxv9Ktmto/wzQodI2tW1m3H+JqphkZo6VYBxA==","signatures":[{"sig":"MEQCIFfpazvx5ObycuLMB4aTKEyIhE+mYtTIRoeVJAYnvxi5AiA+aWrFS6juNPuWYRf7E9nyj3Pj2ZiALcrFHpUyppBLWA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":27108},"main":"auth.js","type":"module","module":"auth.js","gitHead":"e3ad566a15778e5e3be533ffe7c299856d5f72ef","scripts":{"test":"NODE_OPTIONS='--experimental-vm-modules --experimental-specifier-resolution=node' jest"},"_npmUser":{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"},"repository":{"url":"git+https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator.git","type":"git"},"_npmVersion":"10.9.0","description":"Authorization lib for authenticating users with passwords and 2fa","directories":{},"_nodeVersion":"22.9.0","dependencies":{"bcrypt":"^5.1.1","totp_generator_hexadecimal":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","@types/jest":"^29.5.14"},"_npmOperationalInternal":{"tmp":"tmp/2fauth-lib_1.0.1_1729749440386_0.908465969088635","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"2fauth-lib","version":"1.0.2","description":"Authorization lib for authenticating users with passwords and 2fa","main":"index.js","module":"index.js","scripts":{"test":"NODE_OPTIONS='--experimental-vm-modules --experimental-specifier-resolution=node' jest"},"keywords":["authorization","2fa"],"author":{"name":"Zeilinger Alexander"},"license":"GPL-2.0","type":"module","repository":{"type":"git","url":"git+https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator.git"},"devDependencies":{"@types/jest":"^29.5.14","jest":"^29.7.0"},"dependencies":{"bcrypt":"^5.1.1","totp_generator_hexadecimal":"^1.0.1"},"_id":"2fauth-lib@1.0.2","gitHead":"1cfb62dad021cdfc1e28f8e1e7eb5150bf2521a6","bugs":{"url":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator/issues"},"homepage":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator#readme","_nodeVersion":"22.9.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-t6l5el33wULZBVEYpuu0f1i2MFhTZDWbqP1b/GQGy2xKwQE6Mp6GkGF3S47MI0cK1X3IVBktS4QLAdZpacBLJg==","shasum":"810c23a5dfab34d7256be198578567198728c495","tarball":"https://registry.npmjs.org/2fauth-lib/-/2fauth-lib-1.0.2.tgz","fileCount":4,"unpackedSize":27099,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICEICkVzgDVB+zyYA2EKEJEhN+RAzQtrleRhR88GiJJxAiBweN/U3vUKjJf1yE/P4+9FnB/MJjGFt7vnbOGbZnEPVg=="}]},"_npmUser":{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"},"directories":{},"maintainers":[{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2fauth-lib_1.0.2_1729749704784_0.642903780807087"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-24T05:53:40.982Z","modified":"2024-10-24T06:01:45.131Z","1.0.0":"2024-10-24T05:53:41.149Z","1.0.1":"2024-10-24T05:57:20.543Z","1.0.2":"2024-10-24T06:01:44.963Z"},"bugs":{"url":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator/issues"},"author":{"name":"Zeilinger Alexander"},"license":"GPL-2.0","homepage":"https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator#readme","keywords":["authorization","2fa"],"repository":{"type":"git","url":"git+https://github.com/ZeilingerAlexander/AuthTokenGeneratorValidator.git"},"description":"Authorization lib for authenticating users with passwords and 2fa","maintainers":[{"name":"user102384","email":"alexanderzeilingerpublic@gmail.com"}],"readme":"# Auth Token Generator and Validator\n## Usage\n```js\nimport {Authenticator} from \"2fauth-lib\";\n\nconst passkey = \"super secret\";\nconst userId = 1; // Identifier can be anything\nconst auth = new Authenticator();\n// creates the bcrypt hash and totp, you can of course create them yourself without this method\nconst hashAndTotp = await auth.CreateHashAndTotp(passkey);\n// hashAndTotp = {passwordHash,totpKey}\n\n// register the secrets so we don't have to pass them on each authentication call\nauth.RegisterSecrets(userId,hashAndTotp);\n\n// do some work getting the users input\nconst userProvidedPassword = \"super secret\";\nconst userProvidedTotpValue = 123456;\n\n// won't work and returns undefined since totp is wrong but you get the gist of it here\nconst token = await auth.Authenticate(userId,userProvidedPassword,userProvidedTotpValue);\n\n// if you did not register the secrets you can also opt to pass them into the optional parameters\nconst token = await auth.Authenticate(userId,userProvidedPassword,userProvidedTotpValue,{secrets : hashAndTotp});\n\n// if you want to validate an auth token a user provided you can use :\n// do some work to get the auth token\nconst userAuthToken = \"Gibberish\";\nconst authData = auth.CheckAuthToken(userAuthToken);\n// authData = {id,timeAdded,timeExpires,usages} or undefined if not valid\n\n// if you no longer wish to use an auth token you can expire it early\nauth.ExpireAuthToken(token);\n// or you can expire all auth tokens for a specific id\nauth.ExpireAllAuthTokens(userId);\n\n// if you want to remove a Secret from a user you can use\nauth.RemoveSecrets(userId);\n\n// if you want to check if the user has a secret you can use\nif (auth.CheckIfSecretIsRegisterWithIdentifier(userId){\n    console.log(\"user has a secret\");\n}\n```\n\n## constructor parameters\nThe constructor of the <code>Authenticator</code> class accepts an object as parameters, this object can have multiple properties, if they are not set the default is used.\n1. maxTokensPerId : Number, default : 10, minimum : 1\n2. expiryTimeS : Number, default : 604800 (1 week), minimum : 5\n3. bcryptHashRounds : Number, default : 12\n4. authTokenLength : Number, default : 32\n5. totpKeySize : Number, default : 32, minimum : 20\n","readmeFilename":"README.md"}