Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed May 9, 2024
1 parent fca99a3 commit 6a67e18
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: install wrangler
run: npm i -g wrangler
- name: deploy
run: wrangler pages deploy docs/dist --project-name oslo-otp --branch main
run: wrangler pages deploy docs/dist --project-name oslo-otp --branch main
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Documentation: https://oauth2.oslojs.dev**

A JavaScript library for generating and verifying OTPs by [Oslo](https://oslojs.dev).
A JavaScript library for generating and verifying OTPs by [Oslo](https://oslojs.dev).

Supports HMAC-based one-time passwords (HOTP) and time-based one-time passwords (TOTP) as defined in [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226) and [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238).

Expand All @@ -14,7 +14,7 @@ Supports HMAC-based one-time passwords (HOTP) and time-based one-time passwords
import { generateTOTP, verifyTOTP } from "@oslojs/oauth2";

const totp = generateTOTP(key, 30, 6);
const valid = verifyTOTP(totp, key, 30, 6)
const valid = verifyTOTP(totp, key, 30, 6);
```

## Installation
Expand Down
5 changes: 2 additions & 3 deletions docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ title: "@oslojs/otp documentation"

# @oslojs/otp documentation

A JavaScript library for generating and verifying OTPs by [Oslo](https://oslojs.dev).
A JavaScript library for generating and verifying OTPs by [Oslo](https://oslojs.dev).

Supports HMAC-based one-time passwords (HOTP) and time-based one-time passwords (TOTP) as defined in [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226) and [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238).

- Runtime-agnostic
- No third-party dependencies
- Fully typed


```ts
import { generateTOTP, verifyTOTP } from "@oslojs/oauth2";

const totp = generateTOTP(key, 30, 6);
const valid = verifyTOTP(totp, key, 30, 6)
const valid = verifyTOTP(totp, key, 30, 6);
```

## Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ title: "API reference"

## Modules

- [`main`](/reference/main)
- [`main`](/reference/main)
2 changes: 1 addition & 1 deletion docs/pages/reference/main/KeyURI/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ function constructor(
- [`setCounter()`](/reference/main/KeyURI/setCounter)
- [`setDigits()`](/reference/main/KeyURI/setDigits)
- [`setPeriodInSeconds()`](/reference/main/KeyURI/etPeriodInSeconds)
- [`toString()`](/reference/main/KeyURI/toString)
- [`toString()`](/reference/main/KeyURI/toString)
2 changes: 1 addition & 1 deletion src/hotp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function verifyHOTP(otp: string, key: Uint8Array, counter: bigint, digits
}
const otpChars = otp.split("");
const rawOTP = new Uint8Array(otp.length);
// Avoid TextEncoder since utf-8 characters have variable byte size
// Avoid TextEncoder since utf-8 characters have variable byte size
for (let i = 0; i < rawOTP.byteLength; i++) {
const digit = Number(otpChars[i]);
if (!Number.isInteger(digit)) {
Expand Down

0 comments on commit 6a67e18

Please sign in to comment.