From 884271b3701bb25f4bddf2a92e125a71dcfb662e Mon Sep 17 00:00:00 2001 From: Duy Pham Le <32657584+phamleduy04@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:22:50 -0500 Subject: [PATCH] v3.1.0 release :tada: - Fix broken SSL Chain (close #141) - Add new header for requirements for DPS API Close #139 Close #138 --- package.json | 15 ++++++++------- src/Client/index.ts | 10 ++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 56ff21a..c850b75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "texas-dps-scheduler", - "version": "3.0.0", + "version": "3.1.0", "description": "Texas DPS Automatic Scheduler", "main": "dist/index.js", "scripts": { @@ -20,18 +20,18 @@ }, "homepage": "https://github.com/phamleduy04/texas-dps-scheduler#readme", "devDependencies": { - "@eslint/create-config": "^1.1.6", + "@eslint/create-config": "^1.2.0", "@types/ms": "^0.7.34", - "@types/node": "^20.14.11", + "@types/node": "^22.0.0", "@types/prompts": "^2.4.9", - "@typescript-eslint/eslint-plugin": "^7.16.1", - "@typescript-eslint/parser": "^7.16.1", + "@typescript-eslint/eslint-plugin": "^7.17.0", + "@typescript-eslint/parser": "^7.17.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "prettier": "^3.3.3", "ts-node": "^10.9.2", - "typescript": "^5.5.3" + "typescript": "^5.5.4" }, "dependencies": { "colorette": "^2.0.20", @@ -40,9 +40,10 @@ "js-yaml": "^4.1.0", "p-queue": "6.6.2", "prompts": "^2.4.2", + "random-useragent": "^0.5.0", "tslib": "^2.6.3", "undici": "^6.19.4", - "yaml": "^2.4.5", + "yaml": "^2.5.0", "zod": "^3.23.8" }, "engines": { diff --git a/src/Client/index.ts b/src/Client/index.ts index 5a427eb..b6a1b03 100644 --- a/src/Client/index.ts +++ b/src/Client/index.ts @@ -16,6 +16,7 @@ import type { ExistBookingPayload, ExistBookingResponse } from '../Interfaces/Ex import type { CancelBookingPayload } from '../Interfaces/CancelBooking'; import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'; +import randomUseragent from 'random-useragent'; // eslint-disable-next-line @typescript-eslint/no-var-requires let packagejson; @@ -29,7 +30,11 @@ try { } } class TexasScheduler { - public requestInstance = new undici.Pool('https://apptapi.txdpsscheduler.com'); + public requestInstance = new undici.Pool('https://apptapi.txdpsscheduler.com', { + connect: { + rejectUnauthorized: false, + }, + }); public config = parseConfig(); public existBooking: { exist: boolean; response: ExistBookingResponse[] } | undefined; @@ -37,6 +42,7 @@ class TexasScheduler { private isBooked = false; private isHolded = false; private queue = new pQueue({ concurrency: 1 }); + private userAgent = randomUseragent.getRandom(); public constructor() { // eslint-disable-next-line @typescript-eslint/no-var-requires, prettier/prettier @@ -231,7 +237,7 @@ class TexasScheduler { headers: { 'Content-Type': 'application/json;charset=UTF-8', Origin: 'https://public.txdpsscheduler.com', - Referer: 'https://public.txdpsscheduler.com/', + 'User-Agent': this.userAgent, }, headersTimeout: this.config.appSettings.headersTimeout, body: JSON.stringify(body),