Merge pull request #31142 from rrogowski/@types/cryptr

Added types for cryptr
This commit is contained in:
Andrew Casey
2018-12-07 11:44:07 -08:00
committed by GitHub
4 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import Cryptr = require('cryptr');
// $ExpectType Cryptr
const cryptr = new Cryptr('myTotallySecretKey');
// $ExpectType string
const encrypted_string = cryptr.encrypt('bacon');
// $ExpectType string
cryptr.decrypt(encrypted_string);

20
types/cryptr/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for cryptr 4.0
// Project: https://github.com/MauriceButler/cryptr
// Definitions by: Roman Rogowski <https://github.com/rrogowski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Cryptr {
/**
* Cryptr provides a mechanism for aes-256-ctr encryption/decryption.
* @param secret key used for encryption/decryption
*/
constructor(secret: string);
/** Encrypt a string. */
encrypt(value: string): string;
/** Decrypt a string. */
decrypt(value: string): string;
}
export = Cryptr;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"cryptr-tests.ts"
]
}

1
types/cryptr/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }