-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from yeojz/feature/typescript-def
Adding initial typescript definition
- Loading branch information
Showing
24 changed files
with
3,303 additions
and
3,822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,5 @@ coverage | |
/totp.js | ||
/utils.js | ||
/lib-test.js | ||
|
||
audit.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
declare module 'otplib' { | ||
const authenticator: Authenticator; | ||
const hotp: HOTP; | ||
const totp: TOTP; | ||
} | ||
|
||
declare module 'otplib/authenticator' { | ||
const authenticator: Authenticator; | ||
export = authenticator; | ||
} | ||
|
||
declare module 'otplib/totp' { | ||
const totp: TOTP; | ||
export = totp; | ||
} | ||
|
||
declare module 'otplib/hotp' { | ||
const hotp: HOTP; | ||
export = hotp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as otplib from 'otplib'; | ||
import authenticator = require('otplib/authenticator'); | ||
import hotp = require('otplib/hotp'); | ||
import totp = require('otplib/totp'); | ||
|
||
const SECRET = '1234567890'; | ||
let secret = ''; | ||
let token = ''; | ||
|
||
secret = otplib.authenticator.generateSecret(20); | ||
token = otplib.authenticator.generate(secret); | ||
|
||
otplib.authenticator.check(token, secret); // $ExpectType boolean | ||
otplib.authenticator.checkDelta(token, secret); // $ExpectType number | null | ||
otplib.authenticator.decode('test'); // $ExpectType string | ||
otplib.authenticator.encode('test'); // $ExpectType string | ||
otplib.authenticator.verify({ secret, token }); // $ExpectType boolean | ||
otplib.authenticator.keyuri('me', 'otplib-test', secret); // $ExpectType string | ||
otplib.authenticator.Authenticator; | ||
otplib.authenticator.getClass(); | ||
authenticator.check(token, secret); // $ExpectType boolean | ||
authenticator.checkDelta(token, secret); // $ExpectType number | null | ||
authenticator.decode('test'); // $ExpectType string | ||
authenticator.encode('test'); // $ExpectType string | ||
authenticator.verify({ secret, token }); // $ExpectType boolean | ||
authenticator.keyuri('me', 'otplib-test', secret); // $ExpectType string | ||
authenticator.Authenticator; | ||
authenticator.getClass(); | ||
|
||
token = otplib.totp.generate(SECRET); | ||
otplib.totp.check(token, SECRET); // $ExpectType boolean | ||
otplib.totp.checkDelta(token, SECRET); // $ExpectType number | null | ||
otplib.totp.verify({ secret: SECRET, token }); // $ExpectType boolean | ||
otplib.totp.TOTP; | ||
otplib.totp.getClass(); | ||
totp.check(token, SECRET); // $ExpectType boolean | ||
totp.checkDelta(token, SECRET); // $ExpectType number | null | ||
totp.verify({ secret: SECRET, token }); // $ExpectType boolean | ||
totp.TOTP; | ||
totp.getClass(); | ||
|
||
token = otplib.hotp.generate(SECRET, 1); | ||
otplib.hotp.check(token, SECRET, 1); // $ExpectType boolean | ||
otplib.hotp.verify({ secret: SECRET, token, counter: 1 }); // $ExpectType boolean | ||
otplib.hotp.HOTP; | ||
otplib.hotp.getClass(); | ||
hotp.check(token, SECRET, 1); // $ExpectType boolean | ||
hotp.verify({ secret: SECRET, token, counter: 1 }); // $ExpectType boolean | ||
hotp.HOTP; | ||
hotp.getClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2015", | ||
"module": "commonjs", | ||
"sourceMap": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"lib": [ | ||
"es2015" | ||
], | ||
"baseUrl": "../../dist", | ||
"paths": { | ||
"otplib": [ | ||
"index" | ||
], | ||
"otplib/hotp": [ | ||
"hotp" | ||
], | ||
"otplib/totp": [ | ||
"totp" | ||
], | ||
"otplib/authenticator": [ | ||
"authenticator" | ||
] | ||
} | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json" | ||
} |
Oops, something went wrong.