Add types for sasl-plain

This commit is contained in:
Dimitri Benin
2018-11-25 23:59:27 +01:00
parent e1a9b84984
commit 0b80d92a10
4 changed files with 78 additions and 0 deletions

31
types/sasl-plain/index.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
// Type definitions for sasl-plain 0.1
// Project: https://github.com/jaredhanson/js-sasl-plain
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Mechanism } from 'saslmechanisms';
export = PlainMechanism;
declare class PlainMechanism implements Mechanism {
static Mechanism: typeof PlainMechanism;
static prototype: {
name: 'PLAIN';
clientFirst: true;
};
name: 'PLAIN';
clientFirst: true;
response(cred: PlainMechanism.Credentials): string;
challenge(chal: string): this;
}
declare namespace PlainMechanism {
interface Credentials {
authzid?: string;
username: string;
password: string;
}
}

View File

@@ -0,0 +1,23 @@
import PlainMechanism = require('sasl-plain');
import { Mechanism } from 'sasl-plain';
import { Factory } from 'saslmechanisms';
new Factory().use(PlainMechanism);
new Factory().use(Mechanism);
// $ExpectType "PLAIN"
PlainMechanism.prototype.name;
// $ExpectType true
PlainMechanism.prototype.clientFirst;
const m = new PlainMechanism();
// $ExpectType "PLAIN"
m.name;
// $ExpectType true
m.clientFirst;
// $ExpectType string
m.response({ username: 'u', password: 'pw' });
m.response({ username: 'u', password: 'pw', authzid: 'a' });
// $ExpectType PlainMechanism
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-plain-tests.ts"
]
}

View File

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