Skip to content

Commit

Permalink
feat: add new lib to fetch api (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-berard authored Nov 12, 2024
1 parent 93ed0c6 commit bba8396
Show file tree
Hide file tree
Showing 18 changed files with 690 additions and 1,087 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

**philtv-js** is a TypeScript library for pairing a Philips Android TV with the latest versions (6) using the **JointSpace** protocol.

This library simplifies the pairing process, allowing you to interact with your Philips television securely and efficiently. With full TypeScript support, `philtv-js` provides type safety, helping to prevent runtime errors and improve code quality.
This library simplifies the pairing process, allowing you to interact with your Philips television securely and efficiently.

This library leverages the lightweight [ky](https://github.com/sindresorhus/ky) HTTP client, which is built on top of Fetch API, for making secure and intuitive HTTP requests.
With full TypeScript support, `philtv-js` provides type safety, helping to prevent runtime errors and improve code quality.

This library leverages the lightweight [urllib](https://www.npmjs.com/package/urllib) HTTP client, which is built on top of Fetch API, for making secure and intuitive HTTP requests.

**Works only in secure environments (HTTPS) and with versions 6 of the JointSpace protocol.**

Expand Down
11 changes: 10 additions & 1 deletion docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This library simplifies the pairing process, allowing you to interact with your

With full TypeScript support, `philtv-js` provides type safety, helping to prevent runtime errors and improve code quality.

This library leverages the lightweight [ky](https://github.com/sindresorhus/ky) HTTP client, which is built on top of Fetch API, for making secure and intuitive HTTP requests.
This library leverages the lightweight [urllib](https://www.npmjs.com/package/urllib) HTTP client, which is built on top of Fetch API, for making secure and intuitive HTTP requests.

::: warning
**Works only in secure environments (HTTPS) and with versions 6 of the JointSpace protocol.**
Expand All @@ -19,3 +19,12 @@ To install `philtv-js`, you can use npm:
```bash
npm install philtv-js
```

## Useful resources
- https://jointspace.sourceforge.net/projectdata/jointSPACE_API_Reference_Manual.pdf
- https://github.com/lucasvdh/codes.lucasvdh.philips-jointspace
- https://gist.github.com/marcelrv/ee9a7cf97c227d069e4ee88d26691019
- https://github.com/suborb/philips_android_tv/blob/master/philips.py
- https://github.com/jomwells/ambilights/blob/master/custom_components/philips_ambilight/light.py
- https://github.com/eslavnov/pylips
- https://jointspace.sourceforge.net/projectdata/documentation/jasonApi/1/doc/API.html
13 changes: 2 additions & 11 deletions docs/pairing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ To use `philtv-js`, you need to import the PhilTVPairing class from the library:
```typescript
import { PhilTVPairing } from 'philtv-js';

// @ts-ignore
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0; // Disable TLS certificate verification

const pjs = new PhilTVPairing({ tvIp: '192.168.0.22', apiPort: 1926 });
// instantiate the class with the TV's IP address. Default port is 1926
const pjs = new PhilTVPairing({ tvIp: '192.168.0.22' });

// `startPairing` returns a function to prompt for the pin, can be useful
const { promptForPin } = await pjs.startPairing();
Expand All @@ -34,10 +32,3 @@ Result example of `config`:
}
```
You can store the `user` and `password` in a secure location and use them to interact with your TV.

::: info
Usage of `NODE_TLS_REJECT_UNAUTHORIZED`:
Setting `NODE_TLS_REJECT_UNAUTHORIZED = 0` disables TLS certificate verification, which can expose your application to "man-in-the-middle" attacks. Use it with caution and only in development environments.

For more information on managing TLS certificates, refer to the Node.js documentation.
:::
28 changes: 21 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@
"name": "philtv-js",
"version": "1.0.0",
"description": "A simple library to pair and interact with Philips TV",
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"engines": {
"node": ">=18"
},
"bin": {
"philtv-js-pairing": "./dist/bin/pairing.cjs",
"philtv-js": "./dist/pairing.cjs"
},
"exports": {
".": "./dist/index.js",
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./constants": {
"import": "./dist/constants.js",
"require": "./dist/constants.cjs"
},
"./utils": {
"import": "./dist/utils.js",
"require": "./dist/utils.cjs"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "pnpm tsup --dts --clean --minify --format esm src/index.ts",
"build": "tsup",
"watch": "pnpm build --watch",
"docs:build": "vitepress build docs",
"docs:dev": "vitepress dev docs",
Expand All @@ -26,11 +42,9 @@
},
"dependencies": {
"consola": "3.2.3",
"digest-fetch": "3.1.1",
"ky": "1.7.2",
"node-fetch": "3.3.2",
"figlet": "1.8.0",
"radash": "12.1.0",
"unstorage": "1.13.1",
"urllib": "4.4.0",
"zod": "3.23.8"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit bba8396

Please sign in to comment.