From ae8fce14da334c1e525aa2515bbc494073448232 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Dec 2015 09:37:39 +1100 Subject: [PATCH 01/14] Update definitions for ES6 compatability, NOTE: Confusion over cryptojs vs crypto-js. I would suggest merging the two projects but this needs to happen on the npm repository first... --- crypto-js/crypto-js.d.ts | 579 +++++++++++++++++++++++++++++++++++---- 1 file changed, 520 insertions(+), 59 deletions(-) diff --git a/crypto-js/crypto-js.d.ts b/crypto-js/crypto-js.d.ts index 0f02514027..cde0abd9b9 100644 --- a/crypto-js/crypto-js.d.ts +++ b/crypto-js/crypto-js.d.ts @@ -1,67 +1,528 @@ -// Type definitions for crypto-js v3.1.3 +// Type definitions for crypto-js v3.1.5 // Project: https://github.com/evanvosberg/crypto-js -// Definitions by: Michael Zabka +// Definitions by: Michael Zabka , Jason Turner // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module CryptoJS { - type Hash = (message: string, key?: string, ...options: any[]) => string; +declare module CryptoJSLocal{ + module lib{ + interface Base{ + extend(overrides: Object): Object + init(...args: any[]): void + //arguments of create() is same as init(). This is true for all subclasses + create(...args: any[]): Base + mixIn(properties: Object): void + clone(): Base + } - export interface Hashes { - MD5: Hash; - SHA1: Hash; - SHA256: Hash; - SHA224: Hash; - SHA512: Hash; - SHA384: Hash; - SHA3: Hash; - RIPEMD160: Hash; - HmacMD5: Hash; - HmacSHA1: Hash; - HmacSHA256: Hash; - HmacSHA224: Hash; - HmacSHA512: Hash; - HmacSHA384: Hash; - HmacSHA3: Hash; - HmacRIPEMD160: Hash; - PBKDF2: Hash; - AES: Hash; - TripleDES: Hash; - RC4: Hash; - Rabbit: Hash; - RabbitLegacy: Hash; - EvpKDF: Hash; - format: { - OpenSSL: Hash; - Hex: Hash; - }; - enc: { - Latin1: Hash; - Utf8: Hash; - Hex: Hash; - Utf16: Hash; - Base64: Hash; - }; - mode: { - CFB: Hash; - CTR: Hash; - CTRGladman: Hash; - OFB: Hash; - ECB: Hash; - }; - pad: { - Pkcs7: Hash; - Ansix923: Hash; - Iso10126: Hash; - Iso97971: Hash; - ZeroPadding: Hash; - NoPadding: Hash; - }; - } + interface WordArray extends Base{ + words: number[] + sigBytes: number + init(words?: number[], sigBytes?: number): void + create(words?: number[], sigBytes?: number): WordArray - export var hashes: Hashes; + init(typedArray: ArrayBuffer): void + init(typedArray: Int8Array): void + + //Because TypeScript uses a structural type system then we don't need (& can't) + //declare oveload function init, create for the following type (same as Int8Array): + //then Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array + //Note also: Uint8ClampedArray is not defined in lib.d.ts & not supported in IE + //@see http://compatibility.shwups-cms.ch/en/home?&property=Uint8ClampedArray + + create(typedArray: ArrayBuffer): WordArray + create(typedArray: Int8Array): WordArray + + toString(encoder?: enc.IEncoder): string + concat(wordArray: WordArray): WordArray + clamp(): void + clone(): WordArray + random(nBytes: number): WordArray + } + + interface BufferedBlockAlgorithm extends Base{ + reset(): void + clone(): BufferedBlockAlgorithm + } + + //tparam C - Configuration type + interface IHasher extends BufferedBlockAlgorithm{ + cfg: C + init(cfg?: C): void + create(cfg?: C): IHasher + + update(messageUpdate: string): Hasher + update(messageUpdate: WordArray): Hasher + + finalize(messageUpdate?: string): WordArray + finalize(messageUpdate?: WordArray): WordArray + + blockSize: number + + _createHelper(hasher: Hasher): IHasherHelper + _createHmacHelper(hasher: Hasher): IHasherHmacHelper + + clone(): IHasher + } + interface Hasher extends IHasher{} + + //tparam C - Configuration type + interface IHasherHelper{ + (message: string, cfg?: C): WordArray + (message: WordArray, cfg?: C): WordArray + } + interface HasherHelper extends IHasherHelper{} + + interface IHasherHmacHelper{ + (message: string, key: string): WordArray + (message: string, key: WordArray): WordArray + (message: WordArray, key: string): WordArray + (message: WordArray, key: WordArray): WordArray + } + + //tparam C - Configuration type + interface ICipher extends BufferedBlockAlgorithm{ + cfg: C + createEncryptor(key: WordArray, cfg?: C): ICipher + createDecryptor(key: WordArray, cfg?: C): ICipher + + create(xformMode?: number, key?: WordArray, cfg?: C): ICipher + init(xformMode?: number, key?: WordArray, cfg?: C): void + + process(dataUpdate: string): WordArray + process(dataUpdate: WordArray): WordArray + + finalize(dataUpdate?: string): WordArray + finalize(dataUpdate?: WordArray): WordArray + + keySize: number + ivSize: number + + _createHelper(cipher: Cipher): ICipherHelper + + clone(): ICipher + } + interface Cipher extends ICipher{} + + interface IStreamCipher extends ICipher{ + drop?: number; + + createEncryptor(key: WordArray, cfg?: C): IStreamCipher + createDecryptor(key: WordArray, cfg?: C): IStreamCipher + + create(xformMode?: number, key?: WordArray, cfg?: C): IStreamCipher + + blockSize: number + } + interface StreamCipher extends IStreamCipher{} + + interface BlockCipherMode extends Base{ + createEncryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherEncryptor + createDecryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherDecryptor + init(cipher?: Cipher, iv?: number[]): void + create(cipher?: Cipher, iv?: number[]): BlockCipherMode + } + + //BlockCipher has interface same as IStreamCipher + interface BlockCipher extends IStreamCipher{} + + interface IBlockCipherCfg { + iv?: WordArray; + mode?: mode.IBlockCipherModeImpl //default CBC + padding?: pad.IPaddingImpl //default Pkcs7 + } + + interface CipherParamsData { + ciphertext?: lib.WordArray + key?: lib.WordArray + iv?: lib.WordArray + salt?: lib.WordArray + algorithm?: Cipher + mode?: mode.IBlockCipherModeImpl + padding?: pad.IPaddingImpl + blockSize?: number + formatter?: format.IFormatter + } + + interface CipherParams extends Base, CipherParamsData{ + init(cipherParams?: CipherParamsData): void + create(cipherParams?: CipherParamsData): CipherParams + toString(formatter?: format.IFormatter): string + } + + //tparam C - Configuration type + interface ISerializableCipher extends Base{ + cfg: C + encrypt(cipher: Cipher, message: WordArray, key: WordArray, cfg?: C): CipherParams + encrypt(cipher: Cipher, message: string, key: WordArray, cfg?: C): CipherParams + + decrypt(cipher: Cipher, ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray + decrypt(cipher: Cipher, ciphertext: string, key: WordArray, cfg?: C): WordArray + } + + interface SerializableCipher extends ISerializableCipher{} + interface ISerializableCipherCfg{ + format?: format.IFormatter //default OpenSSLFormatter + iv?: WordArray; + mode?: mode.IBlockCipherModeImpl; + padding?: pad.IPaddingImpl; + } + + interface IPasswordBasedCipher extends Base{ + cfg: C + encrypt(cipher: Cipher, message: WordArray, password: string, cfg?: C): CipherParams + encrypt(cipher: Cipher, message: string, password: string, cfg?: C): CipherParams + + decrypt(cipher: Cipher, ciphertext: CipherParamsData, password: string, cfg?: C): WordArray + decrypt(cipher: Cipher, ciphertext: string, password: string, cfg?: C): WordArray + } + + interface PasswordBasedCipher extends IPasswordBasedCipher{} + interface IPasswordBasedCipherCfg extends ISerializableCipherCfg{ + kdf?: kdf.IKdfImpl //default OpenSSLKdf + mode?: mode.IBlockCipherModeImpl; + padding?: pad.IPaddingImpl; + } + + /** see Cipher._createHelper */ + interface ICipherHelper{ + encrypt(message: string, password: string, cfg?: C): CipherParams + encrypt(message: string, key: WordArray, cfg?: C): CipherParams + encrypt(message: WordArray, password: string, cfg?: C): CipherParams + encrypt(message: WordArray, key: WordArray, cfg?: C): CipherParams + + decrypt(ciphertext: string, password: string, cfg?: C): WordArray + decrypt(ciphertext: string, key: WordArray, cfg?: C): WordArray + decrypt(ciphertext: CipherParamsData, password: string, cfg?: C): WordArray + decrypt(ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray + } + + interface CipherHelper extends ICipherHelper{} + interface LibStatic{ + Base: lib.Base + WordArray: lib.WordArray + CipherParams: lib.CipherParams + SerializableCipher: lib.SerializableCipher + PasswordBasedCipher: lib.PasswordBasedCipher + } + } + + module enc{ + interface IEncoder{ + stringify(wordArray: lib.WordArray): string + } + interface IDecoder{ + parse(s: string): lib.WordArray + } + interface ICoder extends IEncoder, IDecoder {} + + interface EncStatic{ + Hex: ICoder + Latin1: ICoder + Utf8: ICoder + Base64: ICoder + Utf16: ICoder + Utf16BE: ICoder + Utf16LE: ICoder + } + } + + module kdf{ + interface KdfStatic{ + OpenSSL: IKdfImpl + } + + interface IKdfImpl{ + execute(password: string, keySize: number, ivSize: number, salt?: string): lib.CipherParams + execute(password: string, keySize: number, ivSize: number, salt?: lib.WordArray): lib.CipherParams + } + } + + module format{ + interface FormatStatic{ + OpenSSL: IFormatter + Hex: IFormatter + } + + interface IFormatter{ + stringify(cipherParams: lib.CipherParamsData): string + parse(s: string): lib.CipherParams + } + } + + module algo{ + interface AlgoStatic{ + AES: algo.AES + DES: algo.DES + TripleDES: algo.TripleDES + + RabbitLegacy: algo.RabbitLegacy + Rabbit: algo.Rabbit + RC4: algo.RC4 + + MD5: algo.MD5 + RIPEMD160: algo.RIPEMD160 + SHA1: algo.SHA1 + SHA256: algo.SHA256 + SHA224: algo.SHA224 + SHA384: algo.SHA384 + SHA512: algo.SHA512 + + SHA3: algo.SHA3 + + HMAC: algo.HMAC + + EvpKDF: algo.EvpKDF + PBKDF2: algo.PBKDF2 + + RC4Drop: algo.RC4Drop + } + + interface IBlockCipherImpl extends lib.BlockCipher{ + encryptBlock(M: number[], offset: number): void + decryptBlock(M: number[], offset: number): void + + createEncryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl + createDecryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl + + create(xformMode?: number, key?: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl + } + + interface AES extends IBlockCipherImpl{} + interface DES extends IBlockCipherImpl{} + interface TripleDES extends IBlockCipherImpl{} + + interface RabbitLegacy extends lib.StreamCipher{} + interface Rabbit extends lib.StreamCipher{} + interface RC4 extends lib.StreamCipher{} + + interface MD5 extends lib.Hasher{} + interface RIPEMD160 extends lib.Hasher{} + interface SHA1 extends lib.Hasher{} + interface SHA256 extends lib.Hasher{} + interface SHA224 extends lib.Hasher{} + interface SHA384 extends lib.Hasher{} + interface SHA512 extends lib.Hasher{} + + interface SHA3 extends lib.IHasher{} + interface ISHA3Cfg{ + outputLength?: number //default 512 + } + + interface HMAC extends lib.Base{ + init(hasher?: lib.Hasher, key?: string): void + init(hasher?: lib.Hasher, key?: lib.WordArray): void + create(hasher?: lib.Hasher, key?: string): HMAC + create(hasher?: lib.Hasher, key?: lib.WordArray): HMAC + + update(messageUpdate: string): HMAC + update(messageUpdate: lib.WordArray): HMAC + + finalize(messageUpdate?: string): lib.WordArray + finalize(messageUpdate?: lib.WordArray): lib.WordArray + } + + interface EvpKDF extends lib.Base{ + cfg: IEvpKDFCfg + init(cfg?: IEvpKDFCfg): void + create(cfg?: IEvpKDFCfg): EvpKDF + compute(password: string, salt: string): lib.WordArray + compute(password: string, salt: lib.WordArray): lib.WordArray + compute(password: lib.WordArray, salt: string): lib.WordArray + compute(password: lib.WordArray, salt: lib.WordArray): lib.WordArray + } + interface IEvpKDFCfg{ + keySize?: number //default 128/32 + hasher?: lib.Hasher //default MD5, or SHA1 with PBKDF2 + iterations?: number //default 1 + } + interface IEvpKDFHelper{ + (password: string, salt: string, cfg?: IEvpKDFCfg): lib.WordArray + (password: string, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray + (password: lib.WordArray, salt: string, cfg?: IEvpKDFCfg): lib.WordArray + (password: lib.WordArray, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray + } + + interface PBKDF2 extends EvpKDF{} //PBKDF2 is same as EvpKDF + + interface RC4Drop extends RC4 { } + } + + module mode{ + interface ModeStatic{ + CBC: mode.CBC + CFB: mode.CFB + CTR: mode.CTR + CTRGladman: mode.CTRGladman + ECB: mode.ECB + OFB: mode.OFB + } + + interface IBlockCipherEncryptor extends lib.BlockCipherMode{ + processBlock(words: number[], offset: number): void + } + interface IBlockCipherDecryptor extends lib.BlockCipherMode{ //exactly as IBlockCipherEncryptor + processBlock(words: number[], offset: number): void + } + interface IBlockCipherModeImpl extends lib.BlockCipherMode{ + Encryptor: IBlockCipherEncryptor + Decryptor: IBlockCipherDecryptor + } + + interface CBC extends IBlockCipherModeImpl{} + interface CFB extends IBlockCipherModeImpl{} + interface CTR extends IBlockCipherModeImpl{} + interface CTRGladman extends IBlockCipherModeImpl{} + interface ECB extends IBlockCipherModeImpl{} + interface OFB extends IBlockCipherModeImpl{} + } + + module pad{ + interface PadStatic{ + Pkcs7: pad.Pkcs7 + AnsiX923: pad.AnsiX923 + Iso10126: pad.Iso10126 + Iso97971: pad.Iso97971 + ZeroPadding: pad.ZeroPadding + NoPadding: pad.NoPadding + } + + interface IPaddingImpl{ + pad(data: lib.WordArray, blockSize: number): void + unpad(data: lib.WordArray): void + } + + interface Pkcs7 extends IPaddingImpl{} + interface AnsiX923 extends IPaddingImpl{} + interface Iso10126 extends IPaddingImpl{} + interface Iso97971 extends IPaddingImpl{} + interface ZeroPadding extends IPaddingImpl{} + interface NoPadding extends IPaddingImpl{} + } + + module x64{ + interface X64Static{ + Word: x64.Word + WordArray: x64.WordArray + } + + interface Word extends lib.Base{ + high: number + low: number + + init(high?: number, low?: number): void + create(high?: number, low?: number): Word + } + + interface WordArray extends lib.Base{ + words: Word[] + sigBytes: number + + init(words?: Word[], sigBytes?: number): void + create(words?: Word[], sigBytes?: number): WordArray + toX32(): lib.WordArray + clone(): WordArray + } + } + + interface CryptoJSStatic{ + lib: lib.LibStatic + enc: enc.EncStatic + kdf: kdf.KdfStatic + format: format.FormatStatic + algo: algo.AlgoStatic + mode: mode.ModeStatic + pad: pad.PadStatic + x64: x64.X64Static + + AES: CryptoJSLocal.lib.ICipherHelper + DES: CryptoJSLocal.lib.ICipherHelper + TripleDES: CryptoJSLocal.lib.ICipherHelper + + RabbitLegacy: CryptoJSLocal.lib.CipherHelper + Rabbit: CryptoJSLocal.lib.CipherHelper + RC4: CryptoJSLocal.lib.CipherHelper + RC4Drop: CryptoJSLocal.lib.ICipherHelper + + MD5: CryptoJSLocal.lib.HasherHelper + HmacMD5: CryptoJSLocal.lib.IHasherHmacHelper + RIPEMD160: CryptoJSLocal.lib.HasherHelper + HmacRIPEMD160: CryptoJSLocal.lib.IHasherHmacHelper + SHA1: CryptoJSLocal.lib.HasherHelper + HmacSHA1: CryptoJSLocal.lib.IHasherHmacHelper + SHA256: CryptoJSLocal.lib.HasherHelper + HmacSHA256: CryptoJSLocal.lib.IHasherHmacHelper + SHA224: CryptoJSLocal.lib.HasherHelper + HmacSHA224: CryptoJSLocal.lib.IHasherHmacHelper + SHA512: CryptoJSLocal.lib.HasherHelper + HmacSHA512: CryptoJSLocal.lib.IHasherHmacHelper + SHA384: CryptoJSLocal.lib.HasherHelper + HmacSHA384: CryptoJSLocal.lib.IHasherHmacHelper + + SHA3: CryptoJSLocal.lib.IHasherHelper + HmacSHA3: CryptoJSLocal.lib.IHasherHmacHelper + + EvpKDF: CryptoJSLocal.algo.IEvpKDFHelper + PBKDF2: CryptoJSLocal.algo.IEvpKDFHelper //PBKDF2 is same as EvpKDF + } + type Hash = (message: string, key?: string, ...options: any[]) => string; + + export interface Hashes { + MD5: Hash; + SHA1: Hash; + SHA256: Hash; + SHA224: Hash; + SHA512: Hash; + SHA384: Hash; + SHA3: Hash; + RIPEMD160: Hash; + HmacMD5: Hash; + HmacSHA1: Hash; + HmacSHA256: Hash; + HmacSHA224: Hash; + HmacSHA512: Hash; + HmacSHA384: Hash; + HmacSHA3: Hash; + HmacRIPEMD160: Hash; + PBKDF2: Hash; + AES: Hash; + TripleDES: Hash; + RC4: Hash; + Rabbit: Hash; + RabbitLegacy: Hash; + EvpKDF: Hash; + format: { + OpenSSL: Hash; + Hex: Hash; + }; + enc: { + Latin1: Hash; + Utf8: Hash; + Hex: Hash; + Utf16: Hash; + Base64: Hash; + }; + mode: { + CFB: Hash; + CTR: Hash; + CTRGladman: Hash; + OFB: Hash; + ECB: Hash; + }; + pad: { + Pkcs7: Hash; + Ansix923: Hash; + Iso10126: Hash; + Iso97971: Hash; + ZeroPadding: Hash; + NoPadding: Hash; + }; + } + + export var hashes: Hashes; } -declare module 'crypto-js' { - import hashes = CryptoJS.hashes; - export = hashes; +declare var CryptoJS: CryptoJSLocal.CryptoJSStatic; + +declare module "crypto-js" { + export = CryptoJS; } From ff75d43ec14eb0d457231790b36e68b347c54016 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Dec 2015 11:04:01 +1100 Subject: [PATCH 02/14] Updated to include interceptor defintiions... --- axios/axios.d.ts | 289 ++++++++++++++++++++++++++--------------------- 1 file changed, 159 insertions(+), 130 deletions(-) diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 48f57a73a3..86414bde6b 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -1,162 +1,191 @@ + // Type definitions for axios 0.5.2 // Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing +// Definitions by: Marcel Buesing , Jason Turner // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module Axios { - /** - * - request body data type - */ - interface AxiosXHRConfigBase { + /** + * - request body data type + */ + interface AxiosXHRConfigBase { + + /** + * Change the request data before it is sent to the server. + * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + * The last function in the array must return a string or an ArrayBuffer + */ + transformRequest?: ((data: T) => U) | [(data: T) => U]; + + /** + * change the response data to be made before it is passed to then/catch + */ + transformResponse?: (data: T) => U; + + /** + * custom headers to be sent + */ + headers?: Object; + + /** + * URL parameters to be sent with the request + */ + params?: Object; + + /** + * indicates whether or not cross-site Access-Control requests + * should be made using credentials + */ + withCredentials?: boolean; + + /** + * indicates the type of data that the server will respond with + * options are 'arraybuffer', 'blob', 'document', 'json', 'text' + */ + responseType?: string; + + /** + * name of the cookie to use as a value for xsrf token + */ + xsrfCookieName?: string; + + /** + * name of the http header that carries the xsrf token value + */ + xsrfHeaderName?: string; + + } /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer + * - request body data type */ - transformRequest?: ((data:T) => U)|[(data:T) => U]; + interface AxiosXHRConfig extends AxiosXHRConfigBase { + /** + * server URL that will be used for the request, options are: + * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH + */ + url: string; + + /** + * request method to be used when making the request + */ + method?: string; + + /** + * data to be sent as the request body + * Only applicable for request methods 'PUT', 'POST', and 'PATCH' + * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash + */ + data?: T; + } /** - * change the response data to be made before it is passed to then/catch + * - expected response type, + * - request body data type */ - transformResponse?: (data:T) => U; + interface AxiosXHR { + /** + * Response that was provided by the server + */ + data: T; + + /** + * HTTP status code from the server response + */ + status: number; + + /** + * HTTP status message from the server response + */ + statusText: string; + + /** + * headers that the server responded with + */ + headers: Object; + + /** + * config that was provided to `axios` for the request + */ + config: AxiosXHRConfig; + } /** - * custom headers to be sent + * - expected response type, + * - request body data type */ - headers?: Object; + interface AxiosStatic { - /** - * URL parameters to be sent with the request - */ - params?: Object; + (config: AxiosXHRConfig): Promise>; - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; + new (config: AxiosXHRConfig): Promise>; - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: Object; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosStatic { - - (config: AxiosXHRConfig): Promise>; - - new (config: AxiosXHRConfig): Promise>; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = GET + */ + get(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = DELETE + */ + delete(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = HEAD + */ + head(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = POST + */ + post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = PUT + */ + put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - } + /** + * convenience alias, method = PATCH + */ + patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + interceptors: { + request: Interceptor, + response: Interceptor + } + } + + + + export interface Response { + data?: any; + status?: number; + statusText?: string; + headers?: any; + config?: any; + } + export interface success { + (response: Response): void + } + export interface error { + (response: Axios.Response): void; + } + + export interface Interceptor { + use(success: success, error?: error): void; + eject(interceptor: Interceptor); + } } declare var axios: Axios.AxiosStatic; declare module "axios" { - export = axios; + export = axios; } + + + From 02941d70e88487358f99e3b5700baf5411dc17c3 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 14 Dec 2015 15:34:11 +1100 Subject: [PATCH 03/14] Added react bootstrap validation --- .../react-bootstrap-validation.d.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 react-bootstrap-validation/react-bootstrap-validation.d.ts diff --git a/react-bootstrap-validation/react-bootstrap-validation.d.ts b/react-bootstrap-validation/react-bootstrap-validation.d.ts new file mode 100644 index 0000000000..9eeee01c1f --- /dev/null +++ b/react-bootstrap-validation/react-bootstrap-validation.d.ts @@ -0,0 +1,83 @@ +/// + +declare module ReactBootstrapValidation{ + + export interface Form { + model; + validateOne: any; + validateAll: any; + errorHelp: string | any; + validationEvent: string; + onValidSubmit: any; + + } + export interface ValidatedInput + { + + name: string; + validationEvent: string; + validate: any; + + type: any; + label: any; + errorHelp: any; + } + + export interface Radio extends ValidatedInput { + + } + + + export interface RadioGroup extends ValidatedInput { + validationEvent: any; + } + + export interface Validator { + + required(val: String); + //Returns true if the value is not null.Can be used as an alias to !isNull validation rule. + isChecked(val: String); + + } + + export interface FileValidator extends Validator { + ref: any; + name: any; + type :any; + label:any; + multiple: any; + validate: any; + + isEmpty(files: FileList); + + /// Returns true if there are no files in file list. + isSingle(files: FileList); + + // Returns true if files count equals to 1. + isMultiple(files: FileList); + + //Returns true if files count is more than 1. + isFilesCount(files: FileList, min: Number, max:Array ); + + //Returns true if files count is within allowed range.If max is not supplied, checks if files count equals min. + isTotalSize(files: FileList, min: Number, max: Array); + + //Returns true if total size of all files is within allowed range. + isEachFileSize(files: FileList, min: Number, max: Array); + + //Returns true if each file's size is within allowed range. + isExtension(files: FileList, extensions: Array); + + //Returns true if each file's extension is in the extensions array. + isType(files: FileList, types: Array); + } + + export interface InputContainer { + + } + } + + +declare module 'react-bootstrap-validation' { + export = ReactBootstrapValidation; +} \ No newline at end of file From 06336e28fcead25080b58e7c5aae073b78cfe3c1 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 20 Dec 2015 10:46:02 +1100 Subject: [PATCH 04/14] Revert "Merge branch 'master' of https://github.com/brewsoftware/DefinitelyTyped" This reverts commit 0adfcd3dfd9860cef6b73762fa8c1eb5c4886dad, reversing changes made to 40c60850ad6c8175a62d5ab48c4e016ea5b3dffe. --- axios/axios.d.ts | 289 ++++----- crypto-js/crypto-js.d.ts | 583 ++---------------- .../react-bootstrap-validation.d.ts | 83 --- 3 files changed, 191 insertions(+), 764 deletions(-) delete mode 100644 react-bootstrap-validation/react-bootstrap-validation.d.ts diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 86414bde6b..48f57a73a3 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -1,191 +1,162 @@ - // Type definitions for axios 0.5.2 // Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing , Jason Turner +// Definitions by: Marcel Buesing // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module Axios { - /** - * - request body data type - */ - interface AxiosXHRConfigBase { - - /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer - */ - transformRequest?: ((data: T) => U) | [(data: T) => U]; - - /** - * change the response data to be made before it is passed to then/catch - */ - transformResponse?: (data: T) => U; - - /** - * custom headers to be sent - */ - headers?: Object; - - /** - * URL parameters to be sent with the request - */ - params?: Object; - - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; - - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - } + /** + * - request body data type + */ + interface AxiosXHRConfigBase { /** - * - request body data type + * Change the request data before it is sent to the server. + * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + * The last function in the array must return a string or an ArrayBuffer */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } + transformRequest?: ((data:T) => U)|[(data:T) => U]; /** - * - expected response type, - * - request body data type + * change the response data to be made before it is passed to then/catch */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: Object; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } + transformResponse?: (data:T) => U; /** - * - expected response type, - * - request body data type + * custom headers to be sent */ - interface AxiosStatic { + headers?: Object; - (config: AxiosXHRConfig): Promise>; + /** + * URL parameters to be sent with the request + */ + params?: Object; - new (config: AxiosXHRConfig): Promise>; + /** + * indicates whether or not cross-site Access-Control requests + * should be made using credentials + */ + withCredentials?: boolean; - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * indicates the type of data that the server will respond with + * options are 'arraybuffer', 'blob', 'document', 'json', 'text' + */ + responseType?: string; + + /** + * name of the cookie to use as a value for xsrf token + */ + xsrfCookieName?: string; + + /** + * name of the http header that carries the xsrf token value + */ + xsrfHeaderName?: string; + + } + + /** + * - request body data type + */ + interface AxiosXHRConfig extends AxiosXHRConfigBase { + /** + * server URL that will be used for the request, options are: + * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH + */ + url: string; + + /** + * request method to be used when making the request + */ + method?: string; + + /** + * data to be sent as the request body + * Only applicable for request methods 'PUT', 'POST', and 'PATCH' + * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash + */ + data?: T; + } + + /** + * - expected response type, + * - request body data type + */ + interface AxiosXHR { + /** + * Response that was provided by the server + */ + data: T; + + /** + * HTTP status code from the server response + */ + status: number; + + /** + * HTTP status message from the server response + */ + statusText: string; + + /** + * headers that the server responded with + */ + headers: Object; + + /** + * config that was provided to `axios` for the request + */ + config: AxiosXHRConfig; + } + + /** + * - expected response type, + * - request body data type + */ + interface AxiosStatic { + + (config: AxiosXHRConfig): Promise>; + + new (config: AxiosXHRConfig): Promise>; + + /** + * convenience alias, method = GET + */ + get(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = DELETE + */ + delete(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = HEAD + */ + head(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = POST + */ + post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = PUT + */ + put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - interceptors: { - request: Interceptor, - response: Interceptor - } - } - - - - export interface Response { - data?: any; - status?: number; - statusText?: string; - headers?: any; - config?: any; - } - export interface success { - (response: Response): void - } - export interface error { - (response: Axios.Response): void; - } - - export interface Interceptor { - use(success: success, error?: error): void; - eject(interceptor: Interceptor); - } + /** + * convenience alias, method = PATCH + */ + patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + } } declare var axios: Axios.AxiosStatic; declare module "axios" { - export = axios; + export = axios; } - - - diff --git a/crypto-js/crypto-js.d.ts b/crypto-js/crypto-js.d.ts index cde0abd9b9..0f02514027 100644 --- a/crypto-js/crypto-js.d.ts +++ b/crypto-js/crypto-js.d.ts @@ -1,528 +1,67 @@ -// Type definitions for crypto-js v3.1.5 +// Type definitions for crypto-js v3.1.3 // Project: https://github.com/evanvosberg/crypto-js -// Definitions by: Michael Zabka , Jason Turner +// Definitions by: Michael Zabka // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module CryptoJSLocal{ - module lib{ - interface Base{ - extend(overrides: Object): Object - init(...args: any[]): void - //arguments of create() is same as init(). This is true for all subclasses - create(...args: any[]): Base - mixIn(properties: Object): void - clone(): Base - } - - interface WordArray extends Base{ - words: number[] - sigBytes: number - init(words?: number[], sigBytes?: number): void - create(words?: number[], sigBytes?: number): WordArray - - init(typedArray: ArrayBuffer): void - init(typedArray: Int8Array): void - - //Because TypeScript uses a structural type system then we don't need (& can't) - //declare oveload function init, create for the following type (same as Int8Array): - //then Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array - //Note also: Uint8ClampedArray is not defined in lib.d.ts & not supported in IE - //@see http://compatibility.shwups-cms.ch/en/home?&property=Uint8ClampedArray - - create(typedArray: ArrayBuffer): WordArray - create(typedArray: Int8Array): WordArray - - toString(encoder?: enc.IEncoder): string - concat(wordArray: WordArray): WordArray - clamp(): void - clone(): WordArray - random(nBytes: number): WordArray - } - - interface BufferedBlockAlgorithm extends Base{ - reset(): void - clone(): BufferedBlockAlgorithm - } - - //tparam C - Configuration type - interface IHasher extends BufferedBlockAlgorithm{ - cfg: C - init(cfg?: C): void - create(cfg?: C): IHasher - - update(messageUpdate: string): Hasher - update(messageUpdate: WordArray): Hasher - - finalize(messageUpdate?: string): WordArray - finalize(messageUpdate?: WordArray): WordArray - - blockSize: number - - _createHelper(hasher: Hasher): IHasherHelper - _createHmacHelper(hasher: Hasher): IHasherHmacHelper - - clone(): IHasher - } - interface Hasher extends IHasher{} - - //tparam C - Configuration type - interface IHasherHelper{ - (message: string, cfg?: C): WordArray - (message: WordArray, cfg?: C): WordArray - } - interface HasherHelper extends IHasherHelper{} - - interface IHasherHmacHelper{ - (message: string, key: string): WordArray - (message: string, key: WordArray): WordArray - (message: WordArray, key: string): WordArray - (message: WordArray, key: WordArray): WordArray - } - - //tparam C - Configuration type - interface ICipher extends BufferedBlockAlgorithm{ - cfg: C - createEncryptor(key: WordArray, cfg?: C): ICipher - createDecryptor(key: WordArray, cfg?: C): ICipher - - create(xformMode?: number, key?: WordArray, cfg?: C): ICipher - init(xformMode?: number, key?: WordArray, cfg?: C): void - - process(dataUpdate: string): WordArray - process(dataUpdate: WordArray): WordArray - - finalize(dataUpdate?: string): WordArray - finalize(dataUpdate?: WordArray): WordArray - - keySize: number - ivSize: number - - _createHelper(cipher: Cipher): ICipherHelper - - clone(): ICipher - } - interface Cipher extends ICipher{} - - interface IStreamCipher extends ICipher{ - drop?: number; - - createEncryptor(key: WordArray, cfg?: C): IStreamCipher - createDecryptor(key: WordArray, cfg?: C): IStreamCipher - - create(xformMode?: number, key?: WordArray, cfg?: C): IStreamCipher - - blockSize: number - } - interface StreamCipher extends IStreamCipher{} - - interface BlockCipherMode extends Base{ - createEncryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherEncryptor - createDecryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherDecryptor - init(cipher?: Cipher, iv?: number[]): void - create(cipher?: Cipher, iv?: number[]): BlockCipherMode - } - - //BlockCipher has interface same as IStreamCipher - interface BlockCipher extends IStreamCipher{} - - interface IBlockCipherCfg { - iv?: WordArray; - mode?: mode.IBlockCipherModeImpl //default CBC - padding?: pad.IPaddingImpl //default Pkcs7 - } - - interface CipherParamsData { - ciphertext?: lib.WordArray - key?: lib.WordArray - iv?: lib.WordArray - salt?: lib.WordArray - algorithm?: Cipher - mode?: mode.IBlockCipherModeImpl - padding?: pad.IPaddingImpl - blockSize?: number - formatter?: format.IFormatter - } - - interface CipherParams extends Base, CipherParamsData{ - init(cipherParams?: CipherParamsData): void - create(cipherParams?: CipherParamsData): CipherParams - toString(formatter?: format.IFormatter): string - } - - //tparam C - Configuration type - interface ISerializableCipher extends Base{ - cfg: C - encrypt(cipher: Cipher, message: WordArray, key: WordArray, cfg?: C): CipherParams - encrypt(cipher: Cipher, message: string, key: WordArray, cfg?: C): CipherParams - - decrypt(cipher: Cipher, ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray - decrypt(cipher: Cipher, ciphertext: string, key: WordArray, cfg?: C): WordArray - } - - interface SerializableCipher extends ISerializableCipher{} - interface ISerializableCipherCfg{ - format?: format.IFormatter //default OpenSSLFormatter - iv?: WordArray; - mode?: mode.IBlockCipherModeImpl; - padding?: pad.IPaddingImpl; - } - - interface IPasswordBasedCipher extends Base{ - cfg: C - encrypt(cipher: Cipher, message: WordArray, password: string, cfg?: C): CipherParams - encrypt(cipher: Cipher, message: string, password: string, cfg?: C): CipherParams - - decrypt(cipher: Cipher, ciphertext: CipherParamsData, password: string, cfg?: C): WordArray - decrypt(cipher: Cipher, ciphertext: string, password: string, cfg?: C): WordArray - } - - interface PasswordBasedCipher extends IPasswordBasedCipher{} - interface IPasswordBasedCipherCfg extends ISerializableCipherCfg{ - kdf?: kdf.IKdfImpl //default OpenSSLKdf - mode?: mode.IBlockCipherModeImpl; - padding?: pad.IPaddingImpl; - } - - /** see Cipher._createHelper */ - interface ICipherHelper{ - encrypt(message: string, password: string, cfg?: C): CipherParams - encrypt(message: string, key: WordArray, cfg?: C): CipherParams - encrypt(message: WordArray, password: string, cfg?: C): CipherParams - encrypt(message: WordArray, key: WordArray, cfg?: C): CipherParams - - decrypt(ciphertext: string, password: string, cfg?: C): WordArray - decrypt(ciphertext: string, key: WordArray, cfg?: C): WordArray - decrypt(ciphertext: CipherParamsData, password: string, cfg?: C): WordArray - decrypt(ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray - } - - interface CipherHelper extends ICipherHelper{} - interface LibStatic{ - Base: lib.Base - WordArray: lib.WordArray - CipherParams: lib.CipherParams - SerializableCipher: lib.SerializableCipher - PasswordBasedCipher: lib.PasswordBasedCipher - } - } - - module enc{ - interface IEncoder{ - stringify(wordArray: lib.WordArray): string - } - interface IDecoder{ - parse(s: string): lib.WordArray - } - interface ICoder extends IEncoder, IDecoder {} - - interface EncStatic{ - Hex: ICoder - Latin1: ICoder - Utf8: ICoder - Base64: ICoder - Utf16: ICoder - Utf16BE: ICoder - Utf16LE: ICoder - } - } - - module kdf{ - interface KdfStatic{ - OpenSSL: IKdfImpl - } - - interface IKdfImpl{ - execute(password: string, keySize: number, ivSize: number, salt?: string): lib.CipherParams - execute(password: string, keySize: number, ivSize: number, salt?: lib.WordArray): lib.CipherParams - } - } - - module format{ - interface FormatStatic{ - OpenSSL: IFormatter - Hex: IFormatter - } - - interface IFormatter{ - stringify(cipherParams: lib.CipherParamsData): string - parse(s: string): lib.CipherParams - } - } - - module algo{ - interface AlgoStatic{ - AES: algo.AES - DES: algo.DES - TripleDES: algo.TripleDES - - RabbitLegacy: algo.RabbitLegacy - Rabbit: algo.Rabbit - RC4: algo.RC4 - - MD5: algo.MD5 - RIPEMD160: algo.RIPEMD160 - SHA1: algo.SHA1 - SHA256: algo.SHA256 - SHA224: algo.SHA224 - SHA384: algo.SHA384 - SHA512: algo.SHA512 - - SHA3: algo.SHA3 - - HMAC: algo.HMAC - - EvpKDF: algo.EvpKDF - PBKDF2: algo.PBKDF2 - - RC4Drop: algo.RC4Drop - } - - interface IBlockCipherImpl extends lib.BlockCipher{ - encryptBlock(M: number[], offset: number): void - decryptBlock(M: number[], offset: number): void - - createEncryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl - createDecryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl - - create(xformMode?: number, key?: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl - } - - interface AES extends IBlockCipherImpl{} - interface DES extends IBlockCipherImpl{} - interface TripleDES extends IBlockCipherImpl{} - - interface RabbitLegacy extends lib.StreamCipher{} - interface Rabbit extends lib.StreamCipher{} - interface RC4 extends lib.StreamCipher{} - - interface MD5 extends lib.Hasher{} - interface RIPEMD160 extends lib.Hasher{} - interface SHA1 extends lib.Hasher{} - interface SHA256 extends lib.Hasher{} - interface SHA224 extends lib.Hasher{} - interface SHA384 extends lib.Hasher{} - interface SHA512 extends lib.Hasher{} - - interface SHA3 extends lib.IHasher{} - interface ISHA3Cfg{ - outputLength?: number //default 512 - } - - interface HMAC extends lib.Base{ - init(hasher?: lib.Hasher, key?: string): void - init(hasher?: lib.Hasher, key?: lib.WordArray): void - create(hasher?: lib.Hasher, key?: string): HMAC - create(hasher?: lib.Hasher, key?: lib.WordArray): HMAC - - update(messageUpdate: string): HMAC - update(messageUpdate: lib.WordArray): HMAC - - finalize(messageUpdate?: string): lib.WordArray - finalize(messageUpdate?: lib.WordArray): lib.WordArray - } - - interface EvpKDF extends lib.Base{ - cfg: IEvpKDFCfg - init(cfg?: IEvpKDFCfg): void - create(cfg?: IEvpKDFCfg): EvpKDF - compute(password: string, salt: string): lib.WordArray - compute(password: string, salt: lib.WordArray): lib.WordArray - compute(password: lib.WordArray, salt: string): lib.WordArray - compute(password: lib.WordArray, salt: lib.WordArray): lib.WordArray - } - interface IEvpKDFCfg{ - keySize?: number //default 128/32 - hasher?: lib.Hasher //default MD5, or SHA1 with PBKDF2 - iterations?: number //default 1 - } - interface IEvpKDFHelper{ - (password: string, salt: string, cfg?: IEvpKDFCfg): lib.WordArray - (password: string, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray - (password: lib.WordArray, salt: string, cfg?: IEvpKDFCfg): lib.WordArray - (password: lib.WordArray, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray - } - - interface PBKDF2 extends EvpKDF{} //PBKDF2 is same as EvpKDF - - interface RC4Drop extends RC4 { } - } - - module mode{ - interface ModeStatic{ - CBC: mode.CBC - CFB: mode.CFB - CTR: mode.CTR - CTRGladman: mode.CTRGladman - ECB: mode.ECB - OFB: mode.OFB - } - - interface IBlockCipherEncryptor extends lib.BlockCipherMode{ - processBlock(words: number[], offset: number): void - } - interface IBlockCipherDecryptor extends lib.BlockCipherMode{ //exactly as IBlockCipherEncryptor - processBlock(words: number[], offset: number): void - } - interface IBlockCipherModeImpl extends lib.BlockCipherMode{ - Encryptor: IBlockCipherEncryptor - Decryptor: IBlockCipherDecryptor - } - - interface CBC extends IBlockCipherModeImpl{} - interface CFB extends IBlockCipherModeImpl{} - interface CTR extends IBlockCipherModeImpl{} - interface CTRGladman extends IBlockCipherModeImpl{} - interface ECB extends IBlockCipherModeImpl{} - interface OFB extends IBlockCipherModeImpl{} - } - - module pad{ - interface PadStatic{ - Pkcs7: pad.Pkcs7 - AnsiX923: pad.AnsiX923 - Iso10126: pad.Iso10126 - Iso97971: pad.Iso97971 - ZeroPadding: pad.ZeroPadding - NoPadding: pad.NoPadding - } - - interface IPaddingImpl{ - pad(data: lib.WordArray, blockSize: number): void - unpad(data: lib.WordArray): void - } - - interface Pkcs7 extends IPaddingImpl{} - interface AnsiX923 extends IPaddingImpl{} - interface Iso10126 extends IPaddingImpl{} - interface Iso97971 extends IPaddingImpl{} - interface ZeroPadding extends IPaddingImpl{} - interface NoPadding extends IPaddingImpl{} - } - - module x64{ - interface X64Static{ - Word: x64.Word - WordArray: x64.WordArray - } - - interface Word extends lib.Base{ - high: number - low: number - - init(high?: number, low?: number): void - create(high?: number, low?: number): Word - } - - interface WordArray extends lib.Base{ - words: Word[] - sigBytes: number - - init(words?: Word[], sigBytes?: number): void - create(words?: Word[], sigBytes?: number): WordArray - toX32(): lib.WordArray - clone(): WordArray - } - } - - interface CryptoJSStatic{ - lib: lib.LibStatic - enc: enc.EncStatic - kdf: kdf.KdfStatic - format: format.FormatStatic - algo: algo.AlgoStatic - mode: mode.ModeStatic - pad: pad.PadStatic - x64: x64.X64Static - - AES: CryptoJSLocal.lib.ICipherHelper - DES: CryptoJSLocal.lib.ICipherHelper - TripleDES: CryptoJSLocal.lib.ICipherHelper - - RabbitLegacy: CryptoJSLocal.lib.CipherHelper - Rabbit: CryptoJSLocal.lib.CipherHelper - RC4: CryptoJSLocal.lib.CipherHelper - RC4Drop: CryptoJSLocal.lib.ICipherHelper - - MD5: CryptoJSLocal.lib.HasherHelper - HmacMD5: CryptoJSLocal.lib.IHasherHmacHelper - RIPEMD160: CryptoJSLocal.lib.HasherHelper - HmacRIPEMD160: CryptoJSLocal.lib.IHasherHmacHelper - SHA1: CryptoJSLocal.lib.HasherHelper - HmacSHA1: CryptoJSLocal.lib.IHasherHmacHelper - SHA256: CryptoJSLocal.lib.HasherHelper - HmacSHA256: CryptoJSLocal.lib.IHasherHmacHelper - SHA224: CryptoJSLocal.lib.HasherHelper - HmacSHA224: CryptoJSLocal.lib.IHasherHmacHelper - SHA512: CryptoJSLocal.lib.HasherHelper - HmacSHA512: CryptoJSLocal.lib.IHasherHmacHelper - SHA384: CryptoJSLocal.lib.HasherHelper - HmacSHA384: CryptoJSLocal.lib.IHasherHmacHelper - - SHA3: CryptoJSLocal.lib.IHasherHelper - HmacSHA3: CryptoJSLocal.lib.IHasherHmacHelper - - EvpKDF: CryptoJSLocal.algo.IEvpKDFHelper - PBKDF2: CryptoJSLocal.algo.IEvpKDFHelper //PBKDF2 is same as EvpKDF - } - type Hash = (message: string, key?: string, ...options: any[]) => string; - - export interface Hashes { - MD5: Hash; - SHA1: Hash; - SHA256: Hash; - SHA224: Hash; - SHA512: Hash; - SHA384: Hash; - SHA3: Hash; - RIPEMD160: Hash; - HmacMD5: Hash; - HmacSHA1: Hash; - HmacSHA256: Hash; - HmacSHA224: Hash; - HmacSHA512: Hash; - HmacSHA384: Hash; - HmacSHA3: Hash; - HmacRIPEMD160: Hash; - PBKDF2: Hash; - AES: Hash; - TripleDES: Hash; - RC4: Hash; - Rabbit: Hash; - RabbitLegacy: Hash; - EvpKDF: Hash; - format: { - OpenSSL: Hash; - Hex: Hash; - }; - enc: { - Latin1: Hash; - Utf8: Hash; - Hex: Hash; - Utf16: Hash; - Base64: Hash; - }; - mode: { - CFB: Hash; - CTR: Hash; - CTRGladman: Hash; - OFB: Hash; - ECB: Hash; - }; - pad: { - Pkcs7: Hash; - Ansix923: Hash; - Iso10126: Hash; - Iso97971: Hash; - ZeroPadding: Hash; - NoPadding: Hash; - }; - } - - export var hashes: Hashes; +declare module CryptoJS { + type Hash = (message: string, key?: string, ...options: any[]) => string; + + export interface Hashes { + MD5: Hash; + SHA1: Hash; + SHA256: Hash; + SHA224: Hash; + SHA512: Hash; + SHA384: Hash; + SHA3: Hash; + RIPEMD160: Hash; + HmacMD5: Hash; + HmacSHA1: Hash; + HmacSHA256: Hash; + HmacSHA224: Hash; + HmacSHA512: Hash; + HmacSHA384: Hash; + HmacSHA3: Hash; + HmacRIPEMD160: Hash; + PBKDF2: Hash; + AES: Hash; + TripleDES: Hash; + RC4: Hash; + Rabbit: Hash; + RabbitLegacy: Hash; + EvpKDF: Hash; + format: { + OpenSSL: Hash; + Hex: Hash; + }; + enc: { + Latin1: Hash; + Utf8: Hash; + Hex: Hash; + Utf16: Hash; + Base64: Hash; + }; + mode: { + CFB: Hash; + CTR: Hash; + CTRGladman: Hash; + OFB: Hash; + ECB: Hash; + }; + pad: { + Pkcs7: Hash; + Ansix923: Hash; + Iso10126: Hash; + Iso97971: Hash; + ZeroPadding: Hash; + NoPadding: Hash; + }; + } + + export var hashes: Hashes; } -declare var CryptoJS: CryptoJSLocal.CryptoJSStatic; - -declare module "crypto-js" { - export = CryptoJS; +declare module 'crypto-js' { + import hashes = CryptoJS.hashes; + export = hashes; } diff --git a/react-bootstrap-validation/react-bootstrap-validation.d.ts b/react-bootstrap-validation/react-bootstrap-validation.d.ts deleted file mode 100644 index 9eeee01c1f..0000000000 --- a/react-bootstrap-validation/react-bootstrap-validation.d.ts +++ /dev/null @@ -1,83 +0,0 @@ -/// - -declare module ReactBootstrapValidation{ - - export interface Form { - model; - validateOne: any; - validateAll: any; - errorHelp: string | any; - validationEvent: string; - onValidSubmit: any; - - } - export interface ValidatedInput - { - - name: string; - validationEvent: string; - validate: any; - - type: any; - label: any; - errorHelp: any; - } - - export interface Radio extends ValidatedInput { - - } - - - export interface RadioGroup extends ValidatedInput { - validationEvent: any; - } - - export interface Validator { - - required(val: String); - //Returns true if the value is not null.Can be used as an alias to !isNull validation rule. - isChecked(val: String); - - } - - export interface FileValidator extends Validator { - ref: any; - name: any; - type :any; - label:any; - multiple: any; - validate: any; - - isEmpty(files: FileList); - - /// Returns true if there are no files in file list. - isSingle(files: FileList); - - // Returns true if files count equals to 1. - isMultiple(files: FileList); - - //Returns true if files count is more than 1. - isFilesCount(files: FileList, min: Number, max:Array ); - - //Returns true if files count is within allowed range.If max is not supplied, checks if files count equals min. - isTotalSize(files: FileList, min: Number, max: Array); - - //Returns true if total size of all files is within allowed range. - isEachFileSize(files: FileList, min: Number, max: Array); - - //Returns true if each file's size is within allowed range. - isExtension(files: FileList, extensions: Array); - - //Returns true if each file's extension is in the extensions array. - isType(files: FileList, types: Array); - } - - export interface InputContainer { - - } - } - - -declare module 'react-bootstrap-validation' { - export = ReactBootstrapValidation; -} \ No newline at end of file From adaedc02189c2b4a6429637aef7ca8d88e66b063 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 22 Dec 2015 15:12:14 +1100 Subject: [PATCH 05/14] added re-validator --- revalidator/revalidator.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 revalidator/revalidator.d.ts diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts new file mode 100644 index 0000000000..aaf38ba78f --- /dev/null +++ b/revalidator/revalidator.d.ts @@ -0,0 +1,16 @@ +// Type definitions for axios 0.5.2 + +// Definitions by: Jason Turner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Revalidator { + interface RevalidatorStatic { + validate(object: any, schema: any, options: any): any; + } +} + +declare var revalidator: Revalidator.RevalidatorStatic; + +declare module "revalidator" { + export = revalidator; +} From 81f194ff4468b34b2795e89fcf2a4fe9ad570e0a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 30 Mar 2016 18:04:01 +1100 Subject: [PATCH 06/14] Update comments to suite revalidator versions. --- revalidator/revalidator.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index aaf38ba78f..b41e7cd03e 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,7 +1,7 @@ -// Type definitions for axios 0.5.2 +// Type definitions for revalidator 0.3.1 // Definitions by: Jason Turner -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { interface RevalidatorStatic { From ff0f1a4bd30f6070676e76a7b9c9adbc7bab57f9 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:34:53 +1000 Subject: [PATCH 07/14] added basic test file. --- revalidator/revalidator-test.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 revalidator/revalidator-test.ts diff --git a/revalidator/revalidator-test.ts b/revalidator/revalidator-test.ts new file mode 100644 index 0000000000..3ad56947dc --- /dev/null +++ b/revalidator/revalidator-test.ts @@ -0,0 +1,4 @@ + +import * as revalidator from 'revalidator'; + +// revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file From adcaa9534f785587096c787f98a990cb1bbb1072 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:35:41 +1000 Subject: [PATCH 08/14] Name update. --- revalidator/{revalidator-test.ts => revalidator-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename revalidator/{revalidator-test.ts => revalidator-tests.ts} (100%) diff --git a/revalidator/revalidator-test.ts b/revalidator/revalidator-tests.ts similarity index 100% rename from revalidator/revalidator-test.ts rename to revalidator/revalidator-tests.ts From e1b48ff99402b979d316472d1daeb2ce51061731 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:43:53 +1000 Subject: [PATCH 09/14] Update documentation spec. Update test to include ES5 typescript import. --- revalidator/revalidator-tests.ts | 3 +-- revalidator/revalidator.d.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/revalidator/revalidator-tests.ts b/revalidator/revalidator-tests.ts index 3ad56947dc..cc04ed882e 100644 --- a/revalidator/revalidator-tests.ts +++ b/revalidator/revalidator-tests.ts @@ -1,4 +1,3 @@ - -import * as revalidator from 'revalidator'; +/// // revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index b41e7cd03e..3d011f2f99 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,5 +1,5 @@ // Type definitions for revalidator 0.3.1 - +// Project: https://github.com/flatiron/revalidator // Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 177e37a21b894e7b84e480b1602e403de535b808 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:46:43 +1000 Subject: [PATCH 10/14] Removed white space in name. --- revalidator/revalidator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 3d011f2f99..93d2e105a5 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,6 +1,6 @@ // Type definitions for revalidator 0.3.1 // Project: https://github.com/flatiron/revalidator -// Definitions by: Jason Turner +// Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { From b171677b5a1d9090d6b39c602dcaf8ed5f44f4c4 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:49:00 +1000 Subject: [PATCH 11/14] whitespace fixup --- revalidator/revalidator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 93d2e105a5..4b6511f959 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,6 +1,6 @@ // Type definitions for revalidator 0.3.1 // Project: https://github.com/flatiron/revalidator -// Definitions by: Jason Turner +// Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { From 518321e8e56797447adcdae5942db0f3c3699030 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:59:02 +1000 Subject: [PATCH 12/14] Added basic schema information. --- revalidator/revalidator.d.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 4b6511f959..b06bf7cce9 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -5,7 +5,34 @@ declare module Revalidator { interface RevalidatorStatic { - validate(object: any, schema: any, options: any): any; + validate(object: any, schema: ISchema, options: any): IReturnMessage; + } + + interface IReturnMessage { + valid: boolean; + errors: string[]; + } + + interface ISchema { + required?: boolean; + type: string; + pattern?: any; + maxLength?: number; + minLength?: number; + minimum?: number; + maximum?: number; + allowEmpty: boolean; + exclusiveMinimum: number; + exclusiveMaximum?: number; + divisibleBy?: number; + minItems?: number; + maxItems?: number; + uniqueItems?: boolean; + enum?: any; + format?: string; + conform?: (data) => boolean; + depdendencies?: string; + } } From 2a6fd2e66684be68a5d0998829431c55e16a8c77 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 13:03:54 +1000 Subject: [PATCH 13/14] updated based on feedback. --- revalidator/revalidator-tests.ts | 2 +- revalidator/revalidator.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator-tests.ts b/revalidator/revalidator-tests.ts index cc04ed882e..b65c9f971b 100644 --- a/revalidator/revalidator-tests.ts +++ b/revalidator/revalidator-tests.ts @@ -1,3 +1,3 @@ /// -// revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file +revalidator.validate(null, null, null); \ No newline at end of file diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index b06bf7cce9..c1e03207b4 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -30,7 +30,7 @@ declare module Revalidator { uniqueItems?: boolean; enum?: any; format?: string; - conform?: (data) => boolean; + conform?: (data:any) => boolean; depdendencies?: string; } From 9a474d26f5dbed29d3ad93d80207356db090504a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 14:41:09 +1000 Subject: [PATCH 14/14] Updated error interface from simple strings. --- revalidator/revalidator.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index c1e03207b4..63f492e9c3 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -8,9 +8,14 @@ declare module Revalidator { validate(object: any, schema: ISchema, options: any): IReturnMessage; } + interface IErrrorProperty { + property: string; + message: string; + } + interface IReturnMessage { valid: boolean; - errors: string[]; + errors: IErrrorProperty[]; } interface ISchema { @@ -40,4 +45,4 @@ declare var revalidator: Revalidator.RevalidatorStatic; declare module "revalidator" { export = revalidator; -} +} \ No newline at end of file