Add types for sasl-digest-md5

This commit is contained in:
Dimitri Benin 2018-11-25 23:57:42 +01:00
parent e1a9b84984
commit 0eebf91a2d
4 changed files with 95 additions and 0 deletions

41
types/sasl-digest-md5/index.d.ts vendored Normal file
View File

@ -0,0 +1,41 @@
// Type definitions for sasl-digest-md5 0.1
// Project: https://github.com/jaredhanson/js-sasl-digest-md5
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Mechanism } from 'saslmechanisms';
export = DigestMd5Mechanism;
declare class DigestMd5Mechanism implements Mechanism {
static Mechanism: typeof DigestMd5Mechanism;
static prototype: {
name: 'DIGEST-MD5';
clientFirst: false;
};
name: 'DIGEST-MD5';
clientFirst: false;
constructor(options?: DigestMd5Mechanism.Options);
response(cred: DigestMd5Mechanism.Credentials): string;
challenge(chal: string): this;
}
declare namespace DigestMd5Mechanism {
interface Options {
genNonce?: () => number;
}
interface Credentials {
serviceType: string;
host: string;
username: string;
password: string;
serviceName?: string;
realm?: string;
authzid?: string;
}
}

View File

@ -0,0 +1,30 @@
import DigestMd5Mechanism = require('sasl-digest-md5');
import { Mechanism } from 'sasl-digest-md5';
import { Factory } from 'saslmechanisms';
new Factory().use(DigestMd5Mechanism);
new Factory().use(Mechanism);
// $ExpectType "DIGEST-MD5"
DigestMd5Mechanism.prototype.name;
// $ExpectType false
DigestMd5Mechanism.prototype.clientFirst;
const m = new DigestMd5Mechanism();
new DigestMd5Mechanism({
genNonce() {
return 1;
},
});
// $ExpectType "DIGEST-MD5"
m.name;
// $ExpectType false
m.clientFirst;
// $ExpectType string
m.response({ serviceType: 's', host: 'h', username: 'u', password: 'p' });
m.response({ serviceType: 's', host: 'h', username: 'u', password: 'p', serviceName: 'sn' });
m.response({ serviceType: 's', host: 'h', username: 'u', password: 'p', realm: 'r' });
m.response({ serviceType: 's', host: 'h', username: 'u', password: 'p', authzid: 'a' });
// $ExpectType DigestMd5Mechanism
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-digest-md5-tests.ts"
]
}

View File

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