diff --git a/types/sasl-external/index.d.ts b/types/sasl-external/index.d.ts new file mode 100644 index 0000000000..06a90ce3a4 --- /dev/null +++ b/types/sasl-external/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for sasl-external 0.1 +// Project: https://github.com/jaredhanson/js-sasl-external +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Mechanism } from 'saslmechanisms'; + +export = ExternalMechanism; + +declare class ExternalMechanism implements Mechanism { + static Mechanism: typeof ExternalMechanism; + static prototype: { + name: 'EXTERNAL'; + clientFirst: true; + }; + + name: 'EXTERNAL'; + clientFirst: true; + + response(cred: ExternalMechanism.Credentials): string; + + challenge(chal: string): void; +} + +declare namespace ExternalMechanism { + interface Credentials { + authzid?: string; + } +} diff --git a/types/sasl-external/sasl-external-tests.ts b/types/sasl-external/sasl-external-tests.ts new file mode 100644 index 0000000000..919721aec5 --- /dev/null +++ b/types/sasl-external/sasl-external-tests.ts @@ -0,0 +1,22 @@ +import ExternalMechanism = require('sasl-external'); +import { Mechanism } from 'sasl-external'; +import { Factory } from 'saslmechanisms'; + +new Factory().use(ExternalMechanism); +new Factory().use(Mechanism); + +// $ExpectType "EXTERNAL" +ExternalMechanism.prototype.name; +// $ExpectType true +ExternalMechanism.prototype.clientFirst; + +const m = new ExternalMechanism(); + +// $ExpectType "EXTERNAL" +m.name; +// $ExpectType true +m.clientFirst; +// $ExpectType string +m.response({ authzid: 'a' }); +// $ExpectType void +m.challenge('challenge'); diff --git a/types/sasl-external/tsconfig.json b/types/sasl-external/tsconfig.json new file mode 100644 index 0000000000..b319008559 --- /dev/null +++ b/types/sasl-external/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sasl-external-tests.ts" + ] +} diff --git a/types/sasl-external/tslint.json b/types/sasl-external/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sasl-external/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }