diff --git a/types/clientjs/clientjs-tests.ts b/types/clientjs/clientjs-tests.ts new file mode 100644 index 0000000000..2781ae4a42 --- /dev/null +++ b/types/clientjs/clientjs-tests.ts @@ -0,0 +1,66 @@ +import ClientJS = require("clientjs"); + +const client = new ClientJS(); +client.getSoftwareVersion(); // $ExpectType string +client.getFingerprint(); // $ExpectType number +client.getCustomFingerprint(client.getUserAgent(), client.getFonts()); // $ExpectType number +client.getUserAgent(); // $ExpectType string +client.getUserAgentLowerCase(); // $ExpectType string +client.getBrowser(); // $ExpectType string +client.getBrowserVersion(); // $ExpectType string +client.getBrowserMajorVersion(); // $ExpectType string +client.isIE(); // $ExpectType boolean +client.isChrome(); // $ExpectType boolean +client.isFirefox(); // $ExpectType boolean +client.isSafari(); // $ExpectType boolean +client.isOpera(); // $ExpectType boolean +client.isMobileSafari(); // $ExpectType boolean +client.getEngine(); // $ExpectType string +client.getEngineVersion(); // $ExpectType string +client.getOS(); // $ExpectType string +client.getOSVersion(); // $ExpectType string +client.isWindows(); // $ExpectType boolean +client.isMac(); // $ExpectType boolean +client.isLinux(); // $ExpectType boolean +client.isUbuntu(); // $ExpectType boolean +client.isSolaris(); // $ExpectType boolean +client.getDevice(); // $ExpectType string +client.getDeviceType(); // $ExpectType string +client.getDeviceVendor(); // $ExpectType string +client.getCPU(); // $ExpectType string +client.isMobile(); // $ExpectType boolean +client.isMobileMajor(); // $ExpectType boolean +client.isMobileAndroid(); // $ExpectType boolean +client.isMobileOpera(); // $ExpectType boolean +client.isMobileWindows(); // $ExpectType boolean +client.isMobileBlackBerry(); // $ExpectType boolean +client.isMobileIOS(); // $ExpectType boolean +client.isIphone(); // $ExpectType boolean +client.isIpad(); // $ExpectType boolean +client.isIpod(); // $ExpectType boolean +client.getScreenPrint(); // $ExpectType string +client.getColorDepth(); // $ExpectType string +client.getCurrentResolution(); // $ExpectType string +client.getAvailableResolution(); // $ExpectType string +client.getDeviceXDPI(); // $ExpectType string +client.getDeviceYDPI(); // $ExpectType string +client.getPlugins(); // $ExpectType string +client.isJava(); // $ExpectType boolean +client.getJavaVersion(); // $ExpectType string +client.isFlash(); // $ExpectType boolean +client.getFlashVersion(); // $ExpectType string +client.isSilverlight(); // $ExpectType boolean +client.getSilverlightVersion(); // $ExpectType string +client.isMimeTypes(); // $ExpectType boolean +client.getMimeTypes(); // $ExpectType string +client.isFont('Times New Roman'); // $ExpectType boolean +client.isFont('Nonexistent Random Font'); // $ExpectType boolean +client.getFonts(); // $ExpectType string +client.isLocalStorage(); // $ExpectType boolean +client.isSessionStorage(); // $ExpectType boolean +client.isCookie(); // $ExpectType boolean +client.getTimeZone(); // $ExpectType string +client.getLanguage(); // $ExpectType string +client.getSystemLanguage(); // $ExpectType string +client.isCanvas(); // $ExpectType boolean +client.getCanvasPrint(); // $ExpectType string diff --git a/types/clientjs/index.d.ts b/types/clientjs/index.d.ts new file mode 100644 index 0000000000..db46d41dab --- /dev/null +++ b/types/clientjs/index.d.ts @@ -0,0 +1,191 @@ +// Type definitions for clientjs 0.1 +// Project: https://clientjs.org +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class ClientJS { + constructor(); + + /** @return A string containing this software version number. */ + getSoftwareVersion(): string; + + // Fingerprint methods + + /** @return A 32-bit integer representing the browser's fingerprint. */ + getFingerprint(): number; + /** + * @param datapoints Any number of datapoints that are (or can be coerced to + * be) strings. + * @return A 32-bit integer representing the cumulative fingerprint. + */ + getCustomFingerprint(...datapoints: Array): number; + + // User agent methods + + /** @return A string containing unparsed user agent. */ + getUserAgent(): string; + /** @return A lowercase string containing the user agent. */ + getUserAgentLowerCase(): string; + + // Browser methods + + /** @return A string containing the browser name */ + getBrowser(): string; + /** @return A string containing the browser version. */ + getBrowserVersion(): string; + /** @return A string containing the major browser version. */ + getBrowserMajorVersion(): string; + /** Check if the browser is IE. */ + isIE(): boolean; + /** Check if the browser is Chrome. */ + isChrome(): boolean; + /** Check if the browser is Firefox. */ + isFirefox(): boolean; + /** Check if the browser is Safari. */ + isSafari(): boolean; + /** Check if the browser is Opera. */ + isOpera(): boolean; + /** Check if the browser is mobile Safari. */ + isMobileSafari(): boolean; + + // Engine methods + + /** @return A string containing the browser engine. */ + getEngine(): string; + /** @return A string containing the browser engine version. */ + getEngineVersion(): string; + + // OS methods + + /** @return A string containing the OS. */ + getOS(): string; + /** @return A string containing the OS version. */ + getOSVersion(): string; + /** Check if the OS is Windows. */ + isWindows(): boolean; + /** Check if the OS is Mac. */ + isMac(): boolean; + /** Check if the OS is Linux. */ + isLinux(): boolean; + /** Check if the OS is Ubuntu. */ + isUbuntu(): boolean; + /** Check if the OS is Solaris. */ + isSolaris(): boolean; + + // Device methods + + /** @return A string containing the device. */ + getDevice(): string; + /** @return A string containing the device type. */ + getDeviceType(): string; + /** @return A string containing the device vendor. */ + getDeviceVendor(): string; + + // CPU methods + + /** @return A string containing the CPU architecture. */ + getCPU(): string; + + // Mobile methods + + /** Check if the browser is on a mobile device. */ + isMobile(): boolean; + /** Check if the browser is on a major mobile device. */ + isMobileMajor(): boolean; + /** Check if the browser is on an Android mobile device. */ + isMobileAndroid(): boolean; + /** Check if the browser is on an Opera mobile device. */ + isMobileOpera(): boolean; + /** Check if the browser is on a Windows mobile device. */ + isMobileWindows(): boolean; + /** Check if the browser is on a Blackberry mobile device. */ + isMobileBlackBerry(): boolean; + + // iOS methods + + /** Check if the browser is on an Apple iOS device. */ + isMobileIOS(): boolean; + /** Check if the browser is on an Apple iPhone. */ + isIphone(): boolean; + /** Check if the browser is on an Apple iPad. */ + isIpad(): boolean; + /** Check if the browser is on an Apple iPod. */ + isIpod(): boolean; + + // Screen methods + + /** @return A string containing screen information. */ + getScreenPrint(): string; + /** @return A string containing the color depth. */ + getColorDepth(): string; + /** @return A string containing the current resolution. */ + getCurrentResolution(): string; + /** @return A string containing the available resolution. */ + getAvailableResolution(): string; + /** @return A string containing the device horizontal DPI. */ + getDeviceXDPI(): string; + /** @return A string containing the device vertical DPI. */ + getDeviceYDPI(): string; + + // Plugin methods + + /** @return A string containing a list of installed plugins. */ + getPlugins(): string; + /** Check if Java is installed. */ + isJava(): boolean; + /** @return A string containing the Java Version. */ + getJavaVersion(): string; + /** Check if Flash is installed. */ + isFlash(): boolean; + /** @return A string containing the Flash Version. */ + getFlashVersion(): string; + /** Check if Silverlight is installed. */ + isSilverlight(): boolean; + /** @return A string containing the Silverlight Version. */ + getSilverlightVersion(): string; + + // MIME type methods + + /** Check if MIME types are installed. */ + isMimeTypes(): boolean; + /** A string containing a list of installed MIME types. */ + getMimeTypes(): string; + + // Font methods + + /** Check if `font` is installed. */ + isFont(font: string): boolean; + /** A string containing a comma-separated list of installed fonts. */ + getFonts(): string; + + // Storage methods + + /** Check if local storage is avaliable. */ + isLocalStorage(): boolean; + /** Check if session storage is avaliable. */ + isSessionStorage(): boolean; + /** Check if cookies are avaliable. */ + isCookie(): boolean; + + // Time methods + + /** A lowercase string containing the time zone. */ + getTimeZone(): string; + + // Language methods + + /** A lowercase string containing the user language. */ + getLanguage(): string; + /** A lowercase string containing the system language. */ + getSystemLanguage(): string; + + // Canvas methods + + /** Check if the canvas element is available. */ + isCanvas(): boolean; + /** @return A string containing canvas image information */ + getCanvasPrint(): string; +} + +export = ClientJS; +export as namespace ClientJS; diff --git a/types/clientjs/tsconfig.json b/types/clientjs/tsconfig.json new file mode 100644 index 0000000000..2d02f6ec55 --- /dev/null +++ b/types/clientjs/tsconfig.json @@ -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", + "clientjs-tests.ts" + ] +} diff --git a/types/clientjs/tslint.json b/types/clientjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clientjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }