Add types for sasl-external

This commit is contained in:
Dimitri Benin 2018-11-25 23:58:42 +01:00
parent e1a9b84984
commit 2133ee8e4c
4 changed files with 75 additions and 0 deletions

29
types/sasl-external/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for sasl-external 0.1
// Project: https://github.com/jaredhanson/js-sasl-external
// Definitions by: BendingBender <https://github.com/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;
}
}

View File

@ -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');

View File

@ -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"
]
}

View File

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