mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Add types for saslmechanisms
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for saslmechanisms 0.1
|
||||
// Project: https://github.com/jaredhanson/js-sasl
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = Factory;
|
||||
|
||||
declare class Factory {
|
||||
static Factory: typeof Factory;
|
||||
|
||||
use(name: string, mechanism: Factory.MechanismStatic): this;
|
||||
use(mechanism: Factory.MechanismStatic): this;
|
||||
create(mechanisms: string[]): Factory.Mechanism | null;
|
||||
}
|
||||
|
||||
declare namespace Factory {
|
||||
interface MechanismStatic {
|
||||
new (): Mechanism;
|
||||
prototype: {
|
||||
[key: string]: any;
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
interface Mechanism {
|
||||
name: string;
|
||||
|
||||
response(cred: { [key: string]: any }): string;
|
||||
|
||||
challenge(chal: string): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import Fct = require('saslmechanisms');
|
||||
import { Factory, MechanismStatic, Mechanism } from 'saslmechanisms';
|
||||
|
||||
const Mech: MechanismStatic = null as any;
|
||||
|
||||
const factory = new Fct();
|
||||
new Factory();
|
||||
new Factory.Factory();
|
||||
|
||||
// $ExpectType Factory
|
||||
factory.use(Mech);
|
||||
factory.use('Mech', Mech);
|
||||
|
||||
const mech: Mechanism | null = factory.create(['Mech']);
|
||||
if (mech) {
|
||||
// $ExpectType string
|
||||
mech.name;
|
||||
// $ExpectType string
|
||||
mech.response({ foo: 'bar' });
|
||||
// $ExpectType void
|
||||
mech.challenge('challenge');
|
||||
}
|
||||
@@ -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",
|
||||
"saslmechanisms-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user