Add types for sasl-anonymous

This commit is contained in:
Dimitri Benin 2018-11-25 23:56:28 +01:00
parent e1a9b84984
commit f225c53dc1
4 changed files with 75 additions and 0 deletions

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

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

View File

@ -0,0 +1,22 @@
import AnonymousMechanism = require('sasl-anonymous');
import { Mechanism } from 'sasl-anonymous';
import { Factory } from 'saslmechanisms';
new Factory().use(AnonymousMechanism);
new Factory().use(Mechanism);
// $ExpectType "ANONYMOUS"
AnonymousMechanism.prototype.name;
// $ExpectType true
AnonymousMechanism.prototype.clientFirst;
const m = new AnonymousMechanism();
// $ExpectType "ANONYMOUS"
m.name;
// $ExpectType true
m.clientFirst;
// $ExpectType string
m.response({ trace: 't' });
// $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-anonymous-tests.ts"
]
}

View File

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