diff --git a/types/triplesec/index.d.ts b/types/triplesec/index.d.ts new file mode 100644 index 0000000000..afe0191d51 --- /dev/null +++ b/types/triplesec/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for triplesec 3.0 +// Project: https://github.com/keybase/triplesec +// Definitions by: Ben Speakman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export interface WordArray { + sigBytes: number; + words: number[]; + to_hex: () => string; +} + +export interface Arguments { + data: Buffer, + key: Buffer, + progress_hook?: (progress: Progress) => void; +} + +export interface Progress { + what: string; + i: number; + total: number; +} + +export function encrypt(arg: Arguments, cb: (err: Error | null, buff: Buffer | null) => void): void; +export function decrypt(arg: Arguments, cb: (err: Error | null, buff: Buffer | null) => void): void; + +export namespace prng { + export function generate(n: number, cb: (words: WordArray) => void): void; +} \ No newline at end of file diff --git a/types/triplesec/triplesec-tests.ts b/types/triplesec/triplesec-tests.ts new file mode 100644 index 0000000000..2f7037ed72 --- /dev/null +++ b/types/triplesec/triplesec-tests.ts @@ -0,0 +1,27 @@ +import * as triplesec from 'triplesec'; + +triplesec.encrypt({ + data: new Buffer('data'), + key: new Buffer('key') +}, (err, buff) => { + if (err === null) { + console.log(buff); + } else { + console.log(err); + } +}); + +triplesec.decrypt({ + data: new Buffer('data'), + key: new Buffer('key') +}, (err, buff) => { + if (err === null) { + console.log(buff); + } else { + console.log(err); + } +}); + +triplesec.prng.generate(24, words => { + console.log(words.to_hex()); // $ExpectType string +}); diff --git a/types/triplesec/tsconfig.json b/types/triplesec/tsconfig.json new file mode 100644 index 0000000000..adf3d9b2f7 --- /dev/null +++ b/types/triplesec/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "triplesec-tests.ts" + ] +} diff --git a/types/triplesec/tslint.json b/types/triplesec/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/triplesec/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }