mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #26880 from threesquared/triplesec
Add definitions for triplesec
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for triplesec 3.0
|
||||
// Project: https://github.com/keybase/triplesec
|
||||
// Definitions by: Ben Speakman <https://github.com/threesquared>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
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 {
|
||||
function generate(n: number, cb: (words: WordArray) => void): void;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import * as triplesec from 'triplesec';
|
||||
|
||||
const progressHook = (progress: triplesec.Progress) => {
|
||||
progress.what; // $ExpectType string
|
||||
progress.i; // $ExpectType number
|
||||
progress.total; // $ExpectType number
|
||||
};
|
||||
|
||||
triplesec.encrypt({
|
||||
data: new Buffer('data'),
|
||||
key: new Buffer('key'),
|
||||
progress_hook: progressHook,
|
||||
}, (err, buff) => {
|
||||
if (err === null) {
|
||||
buff; // $ExpectType Buffer | null
|
||||
} else {
|
||||
err; // $ExpectType Error
|
||||
}
|
||||
});
|
||||
|
||||
triplesec.decrypt({
|
||||
data: new Buffer('data'),
|
||||
key: new Buffer('key'),
|
||||
progress_hook: progressHook,
|
||||
}, (err, buff) => {
|
||||
if (err === null) {
|
||||
buff; // $ExpectType Buffer | null
|
||||
} else {
|
||||
err; // $ExpectType Error
|
||||
}
|
||||
});
|
||||
|
||||
triplesec.prng.generate(24, words => {
|
||||
words.sigBytes; // $ExpectType number
|
||||
words.words; // $ExpectType number[]
|
||||
words.to_hex(); // $ExpectType string
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"triplesec-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user