Socket
Book a DemoInstallSign in
Socket

client-parser

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

client-parser - npm Package Compare versions

Comparing version

to
0.0.15

dist/index.d.mts

95

package.json
{
"name": "client-parser",
"version": "0.0.14",
"version": "0.0.15",
"description": "A utility to detect the device type (Android, iOS, Windows Phone, PC, unknown) based on the User Agent string.",
"type": "module",
"main": "./dist/cjs/src/index.js",
"module": "./dist/esm/src/index.js",
"types": "./dist/types/index.d.ts",
"engines": {
"node": ">=20.x",
"pnpm": ">=10.x"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/cjs/src/index.js",
"import": "./dist/esm/src/index.js",
"types": "./dist/types/index.d.ts"
}
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"files": [
"dist/cjs/src",
"dist/esm/src",
"dist/types/src"
"dist",
"src",
"README.md"
],
"engines": {
"node": ">=20.x",
"pnpm": ">=10.x"
"scripts": {
"detect-ua": "ts-node scripts/detectDevices.js",
"build": "rimraf dist && tsup src/index.ts --dts --format esm,cjs --out-dir dist",
"test": "jest",
"test:watch": "jest --watch",
"eslint:check": "eslint .",
"eslint:fix": "eslint . --fix",
"prettier:check": "prettier . --check",
"prettier:fix": "prettier . --write",
"lint:fix": "eslint . --fix && prettier . --write",
"prepare": "husky install",
"commitlint": "commitlint --edit",
"release": "HUSKY_SKIP_HOOKS=1 standard-version && git push --follow-tags",
"release:minor": "standard-version --release-as minor && git push --follow-tags",
"release:major": "standard-version --release-as major && git push --follow-tags",
"release:patch": "standard-version --release-as patch && git push --follow-tags"
},

@@ -66,52 +79,18 @@ "keywords": [

},
"scripts": {
"detect-ua": "ts-node scripts/detectDevices.js",
"build": "rimraf dist && npm run build:esm && npm run build:cjs && npm run build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext",
"build:cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
"test": "jest",
"test:watch": "jest --watch",
"eslint:check": "eslint .",
"eslint:fix": "eslint . --fix",
"prettier:check": "prettier . --check",
"prettier:fix": "prettier . --write",
"lint:fix": "eslint . --fix && prettier . --write",
"prepare": "husky install",
"commitlint": "commitlint --edit",
"release": "HUSKY_SKIP_HOOKS=1 standard-version && git push --follow-tags",
"release:minor": "standard-version --release-as minor && git push --follow-tags",
"release:major": "standard-version --release-as major && git push --follow-tags",
"release:patch": "standard-version --release-as patch && git push --follow-tags",
"postinstall": "node bin/welcome.js"
},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@types/figlet": "^1.7.0",
"@commitlint/config-conventional": "^19.8.1",
"@types/jest": "^30.0.0",
"@types/jsdom": "^21.1.7",
"@typescript-eslint/eslint-plugin": "^8.22.0",
"@typescript-eslint/parser": "^8.22.0",
"esbuild": "^0.25.8",
"eslint": "^9.19.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-security": "^3.0.1",
"globals": "^16.3.0",
"husky": "^9.1.4",
"@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.38.0",
"commitlint": "^19.8.1",
"eslint": "^9.31.0",
"husky": "^9.1.7",
"jest": "^30.0.5",
"jest-environment-jsdom": "^30.0.5",
"lint-staged": "^15.2.9",
"prettier": "^3.3.3",
"prettier": "^3.6.2",
"rimraf": "^6.0.1",
"standard-version": "^9.5.0",
"terser": "^5.37.0",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"tsup": "^8.5.0",
"typescript": "^5.8.3"
},
"dependencies": {
"chalk": "^5.4.1",
"figlet": "^1.8.2"
}
}

@@ -30,6 +30,7 @@ # client-parser

3. **Browser Information:** Detects browser name (e.g., Chrome, Safari, Firefox, Edge) and version.
4. **Mobile/Tablet Flags:** Provides boolean flags (`isMobile`, `isTablet`) for quick checks.
5. **TypeScript Support:** Includes strong type definitions (`DeviceInfo` interface) for enhanced code safety and developer experience.
6. **Lightweight & Efficient:** Minimal footprint with high performance.
7. **Easy Integration:** Seamlessly integrates with any Node.js or TypeScript-based project.
4. **Rendering Engine Detection:** Identifies the browser's rendering engine (e.g., `Blink`, `Gecko`, `WebKit`, `Trident`) and its version.
5. **Mobile/Tablet Flags:** Provides boolean flags (`isMobile`, `isTablet`) for quick checks.
6. **TypeScript Support:** Includes strong type definitions (`DeviceInfo` interface) for enhanced code safety and developer experience.
7. **Lightweight & Efficient:** Minimal footprint with high performance.
8. **Easy Integration:** Seamlessly integrates with any Node.js or TypeScript-based project.

@@ -73,3 +74,6 @@ ---

const deviceInfo = getDeviceType();
const userAgentString =
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0.1 Mobile/15E148 Safari/604.1';
const platformString = 'iPhone';
const deviceInfo = getDeviceType(userAgentString, platformString);

@@ -89,3 +93,6 @@ // Log some of the detected information

const deviceInfo = getDeviceType();
const userAgentString =
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0.1 Mobile/15E148 Safari/604.1';
const platformString = 'iPhone';
const deviceInfo = getDeviceType(userAgentString, platformString);

@@ -105,3 +112,9 @@ // Log some of the detected information

const currentDevice: IDeviceInfo = getDeviceType();
const desktopUserAgent: string =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
const desktopPlatform: string = 'Win32';
const currentDevice: IDeviceInfo = getDeviceType(
desktopUserAgent,
desktopPlatform
);

@@ -123,17 +136,43 @@ // Log some of the detected information

```typescript
export interface DeviceInfo {
/** The general category of the device: "android", "ios", "windows_phone", "pc", or "unknown". */
type: 'android' | 'ios' | 'windows_phone' | 'pc' | 'unknown';
/** The operating system name (e.g., "Android", "iOS", "Windows", "macOS", "Linux"). */
os?: string;
/** The version of the operating system. */
osVersion?: string;
/** True if the device is likely a tablet, false otherwise. */
isTablet?: boolean;
/** True if the device is a mobile phone or tablet, false otherwise. */
isMobile?: boolean;
/** The name of the browser (e.g., "Chrome", "Safari", "Firefox", "Edge", "IE", "Opera"). */
browser?: string;
/** The version of the browser. */
browserVersion?: string;
export interface IDeviceInfo {
/** The raw User Agent string used for detection. */
userAgentString: string;
/** Information about the device itself. */
device: {
/** The general category of the device: "android", "ios", "windows_phone", "pc", or "unknown". */
type: 'android' | 'ios' | 'windows_phone' | 'pc' | 'unknown';
/** A more specific name for the device (e.g., "iPhone", "iPad", "Android Phone", "Windows PC"). */
name: string;
/** Placeholder for device model (currently 'unknown'). */
model: string;
/** Placeholder for device manufacturer (currently 'unknown'). */
manufacturer: string;
};
/** Information about the browser's rendering engine. */
engine: {
/** The name of the rendering engine (e.g., "Blink", "Gecko", "WebKit", "Trident"). */
name: string;
/** The version of the rendering engine. */
version: string;
};
/** Information about the operating system. */
os: {
/** The name of the operating system (e.g., "Android", "iOS", "Windows Phone", "Windows", "macOS", "Linux"). */
name: string;
/** The version of the operating system. Undefined if not detectable. */
version?: string;
/** Placeholder for OS architecture (currently undefined). */
architecture?: string;
};
/** Information about the browser. */
browser: {
/** The name of the browser (e.g., "Edge", "Opera", "Firefox", "Chrome", "Safari", "Internet Explorer"). */
name: string;
/** The version of the browser. */
version: string;
};
/** The value of navigator.platform, if provided. */
platform: string;
/** A boolean indicating if the user agent is detected as a bot (currently always false, requires separate logic). */
isBot: boolean;
}

@@ -144,14 +183,10 @@ ```

- type:
- "android": Android phones and tablets.
- "ios": iPhones, iPads, iPods.
- "windows_phone": Devices running Windows Phone OS.
- "pc": Desktop/laptop computers (Windows, macOS, Linux).
- "unknown": Any other or unrecognized device types.
- os: "Android", "iOS", "Windows Phone", "Windows", "macOS", "Linux".
- osVersion: E.g., "13", "17.0.3", "10.0", "10_15_7".
- isTablet: true or false.
- isMobile: true or false.
- browser: "Chrome", "Firefox", "Safari", "Edge", "Opera", "Internet Explorer".
- browserVersion: E.g., "100.0.4896.127", "119.0", "17.0".
- **device.type:** "android", "ios", "windows_phone", "pc", "unknown"
- **device.name:** "Android Phone", "Android Tablet", "iPhone", "iPad", "iPod Touch", "Windows Phone", "Windows PC", "macOS PC", "Linux PC", "unknown"
- **engine.name:** "Blink", "Gecko", "WebKit", "Trident", "Presto", "unknown"
- **engine.version:** E.g., "537.36", "20100101", "605.1.15", "7.0"
- **os.name:** "Android", "iOS", "Windows Phone", "Windows", "macOS", "Linux", "unknown"
- **os.version:** E.g., "13", "17.0.3", "10.0", "10.15.7"
- **browser.name:** "Edge", "Opera", "Firefox", "Chrome", "Safari", "Internet Explorer", "unknown"
- **browser.version:** E.g., "120.0.2210.144", "105.0.0.0", "119.0", "120.0.0.0", "17.0.1", "11.0"

@@ -158,0 +193,0 @@ ## License

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.