guyht / notp

Node One Time Password library, supports HOTP, TOTP and works with Google Authenticator
https://github.com/guyht/notp
MIT License
685 stars 66 forks source link

Type Definitions #52

Closed afshawnlotfi closed 3 years ago

afshawnlotfi commented 5 years ago

Hi, I love this library because it is super minimal and gets the job done. The only problem is it doesn't have any type definitions for Typescript. Was wondering if there were any plans on creating type definitions otherwise I will just create one on DefinetlyTyped @types repo.

TimKnipe commented 5 years ago

Add a notp.d.ts file to your @types folder

declare module 'notp' {
  export const hotp: {
    gen: (key: string, opt?: { time?: number; _t?: Date }) => string;
    verify: (
      token: string,
      key: string,
      opt?: { time?: number },
    ) => { delta: number } | null;
  };

  export const totp: {
    gen: (key: string, opt?: { time?: number; _t?: Date }) => string;
    verify: (
      token: string,
      key: string,
      opt?: { time?: number; _t?: Date },
    ) => { delta: number } | null;
  };
}