Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvillage committed Mar 23, 2024
0 parents commit 8e728e1
Show file tree
Hide file tree
Showing 12 changed files with 1,759 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish to npm

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
cjs/
esm/
lib/
.env*
Empty file added .mrvillage.toml
Empty file.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
*.md
src/
tsconfig.json
rollup.config.js
.prettierrc.toml
.env*
16 changes: 16 additions & 0 deletions .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# @@-cli.prettierrc-@@
arrowParens = "always"
bracketSpacing = true
endOfLine = "auto"
htmlWhitespaceSensitivity = "css"
insertPragma = false
jsxBracketSameLine = false
jsxSingleQuote = false
printWidth = 80
proseWrap = "preserve"
quoteProps = "as-needed"
requirePragma = false
semi = true
singleQuote = false
tabWidth = 2
trailingComma = "es5"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present mrvillage

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @v19/totp

A simple implementation of the Time-Based One-Time Password Algorithm (TOTP) as specified in [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238).

## Usage

```typescript
import { generateSecret, generateUri } from "@v19/totp";

const secret = await generateSecret();
const uri = generateUri(secret, "[email protected]", "My Service");
// => otpauth://totp/My%20Service:user%40myservice.com?secret=JBSWY3DPEHPK3PXP&issuer
const code = await totp(secret);
```

Loading

0 comments on commit 8e728e1

Please sign in to comment.