Skip to content

feat: device-auth #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 14, 2025
25 changes: 15 additions & 10 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
"trailingComma": "all",
"printWidth": 96,
"semi": true,
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": [
"<TYPES>^(node:)",
"<TYPES>",
"<TYPES>^[.]",
"",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^[./]"
],
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 4
}
},
{
"files": "*.ts",
"options": {
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": [
"<TYPES>^(node:)",
"<TYPES>",
"<TYPES>^[.]",
"",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^[./]"
]
}
}
]
}
28 changes: 28 additions & 0 deletions examples/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Tado } from "../src";

async function main(): Promise<void> {
const tado = new Tado();
const [verify, futureToken] = await tado.authenticate("refresh_token");

if (verify) {
console.log("------------------------------------------------");
console.log("Device authentication required.");
console.log("Please visit the following website in a browser.");
console.log("");
console.log(` ${verify.verification_uri_complete}`);
console.log("");
console.log(
`Checks will occur every ${verify.interval}s up to a maximum of ${verify.expires_in}s`,
);
console.log("------------------------------------------------");
}
await futureToken;

const me = await tado.getMe();
console.log(me);

const token = await tado.getToken();
console.log(token);
}

main();
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,34 @@
"prepare": "husky"
},
"dependencies": {
"axios": "^1.7.9",
"simple-oauth2": "^5.1.0"
"axios": "^1.8.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@types/chai": "^5.0.1",
"@types/chai-as-promised": "^8.0.1",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@types/chai": "^5.2.0",
"@types/chai-as-promised": "^8.0.2",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.1",
"@types/node": "^22.13.10",
"@types/simple-oauth2": "^5.0.7",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"chai": "^5.1.2",
"@typescript-eslint/eslint-plugin": "^8.26.0",
"@typescript-eslint/parser": "^8.26.0",
"chai": "^5.2.0",
"chai-as-promised": "^8.0.1",
"eslint": "^9.16.0",
"eslint-config-prettier": "^10.0.1",
"eslint": "^9.22.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-tsdoc": "^0.4.0",
"globals": "^15.13.0",
"globals": "^16.0.0",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"mocha": "^11.0.1",
"nock": "^13.5.6",
"lint-staged": "^15.4.3",
"mocha": "^11.1.0",
"nock": "^14.0.1",
"nyc": "^17.1.0",
"prettier": "^3.4.2",
"tsx": "^4.19.2",
"typedoc": "^0.27.4",
"typescript": "^5.7.2"
"prettier": "^3.5.3",
"tsx": "^4.19.3",
"typedoc": "^0.27.9",
"typescript": "^5.8.2"
},
"lint-staged": {
"*": [
Expand Down
Loading