mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
add definitions for https://github.com/markbao/speakeasy
This commit is contained in:
26
speakeasy/speakeasy-test.ts
Normal file
26
speakeasy/speakeasy-test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/// <reference path="speakeasy.d.ts"/>
|
||||
|
||||
import speakeasy = require('speakeasy');
|
||||
|
||||
speakeasy.generate_key({length: 20, google_auth_qr: true});
|
||||
|
||||
// normal use.
|
||||
speakeasy.hotp({key: 'secret', counter: 582});
|
||||
|
||||
// use a custom length.
|
||||
speakeasy.hotp({key: 'secret', counter: 582, length: 8});
|
||||
|
||||
// use a custom encoding.
|
||||
speakeasy.hotp({key: 'AJFIEJGEHIFIU7148SF', counter: 147, encoding: 'base32'});
|
||||
|
||||
// normal use.
|
||||
speakeasy.totp({key: 'secret'});
|
||||
|
||||
// use a custom time step.
|
||||
speakeasy.totp({key: 'secret', step: 60});
|
||||
|
||||
// use a custom time.
|
||||
speakeasy.totp({key: 'secret', time: 159183717});
|
||||
|
||||
// use a initial time.
|
||||
speakeasy.totp({key: 'secret', initial_time: 4182881485});
|
||||
51
speakeasy/speakeasy.d.ts
vendored
Normal file
51
speakeasy/speakeasy.d.ts
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Type definitions for speakeasy v1.0.4
|
||||
// Project: https://github.com/markbao/speakeasy
|
||||
// Definitions by: Lucas Woo <https://github.com/legendecas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "speakeasy" {
|
||||
|
||||
interface IKey {
|
||||
ascii: string;
|
||||
base32: string;
|
||||
hex: string;
|
||||
qr_code_ascii: string;
|
||||
qr_code_hex: string;
|
||||
qr_code_base32: string;
|
||||
google_auth_qr: string;
|
||||
}
|
||||
|
||||
interface GenerateOptions {
|
||||
length?: number;
|
||||
symbols?: boolean;
|
||||
qr_codes?: boolean;
|
||||
google_auth_qr?: boolean;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
interface TotpOptions {
|
||||
key: string;
|
||||
step?: number;
|
||||
time?: number;
|
||||
initial_time?: number;
|
||||
length?: number;
|
||||
encoding?: string;
|
||||
}
|
||||
|
||||
interface HotpOptions {
|
||||
key: string;
|
||||
counter: number;
|
||||
length?: number;
|
||||
encoding?: string;
|
||||
}
|
||||
|
||||
export function generate_key(options: GenerateOptions): IKey;
|
||||
|
||||
export function hotp(options: HotpOptions): string;
|
||||
|
||||
export function counter(options: HotpOptions): string;
|
||||
|
||||
export function totp(options: TotpOptions): string;
|
||||
|
||||
export function time(options: TotpOptions): string;
|
||||
}
|
||||
Reference in New Issue
Block a user