gwsp 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/index.js +56 -0
- package/package.json +23 -0
- package/src/index.ts +40 -0
- package/tsconfig.json +12 -0
- package/types/kyle-printer.d.ts +10 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Kyle
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# GWSP (Get WebSite Protection)
|
2
|
+
|
3
|
+
GWSP is a simple Node.js package for fetching information about the protection mechanisms used by a website.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You can install GWSP using npm:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
npm install gwsp
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
GWSP can be used with both Node.js and TypeScript.
|
16
|
+
|
17
|
+
## Node.js
|
18
|
+
```javascript
|
19
|
+
const GWSP = require('gwsp').default;
|
20
|
+
|
21
|
+
async function main() {
|
22
|
+
try {
|
23
|
+
await GWSP('https://example.com');
|
24
|
+
} catch (error) {
|
25
|
+
console.error(error);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
main();
|
30
|
+
```
|
31
|
+
## TypeScript
|
32
|
+
|
33
|
+
```typescript
|
34
|
+
import GWSP from 'gwsp';
|
35
|
+
|
36
|
+
async function main() {
|
37
|
+
try {
|
38
|
+
await GWSP('https://example.com');
|
39
|
+
} catch (error) {
|
40
|
+
console.error(error);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
main();
|
45
|
+
```
|
46
|
+
|
47
|
+
## Features
|
48
|
+
|
49
|
+
- Retrieves information about the protection mechanisms used by a website.
|
50
|
+
- Supports both HTTP and HTTPS URLs.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
package/dist/index.js
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
16
|
+
const kyle_printer_1 = __importDefault(require("kyle-printer"));
|
17
|
+
function GWSP(url) {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
var _a;
|
20
|
+
if (!url) {
|
21
|
+
throw new Error('\x1b[1m\x1b[31mNo URL provided\x1b[0m');
|
22
|
+
}
|
23
|
+
let response;
|
24
|
+
try {
|
25
|
+
response = yield (0, node_fetch_1.default)(url);
|
26
|
+
const { status, headers } = response;
|
27
|
+
let protectionInfo = 'none';
|
28
|
+
const serverHeader = headers.get('server');
|
29
|
+
const poweredByHeader = headers.get('x-powered-by');
|
30
|
+
const viaHeader = headers.get('via');
|
31
|
+
if (serverHeader) {
|
32
|
+
protectionInfo = `Server: ${serverHeader}`;
|
33
|
+
}
|
34
|
+
else if (poweredByHeader) {
|
35
|
+
protectionInfo = `X-Powered-By: ${poweredByHeader}`;
|
36
|
+
}
|
37
|
+
else if (viaHeader) {
|
38
|
+
protectionInfo = `Via: ${viaHeader}`;
|
39
|
+
}
|
40
|
+
(0, kyle_printer_1.default)({ text: `GWSP GET : ,\n${protectionInfo}`, color: 'green', font: 'bold' });
|
41
|
+
}
|
42
|
+
catch (error) {
|
43
|
+
let statusCode = 'null';
|
44
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) {
|
45
|
+
statusCode = error.response.status.toString();
|
46
|
+
}
|
47
|
+
(0, kyle_printer_1.default)({ text: `Problem with request (Status Code: ${statusCode}): ${error.message}`, color: 'red', font: 'bold' });
|
48
|
+
}
|
49
|
+
finally {
|
50
|
+
if (response) {
|
51
|
+
response.clone();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
}
|
56
|
+
GWSP('https://chatgpt.com/');
|
package/package.json
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"name": "gwsp",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"main": "dist/index.js",
|
5
|
+
"scripts": {
|
6
|
+
"build": "tsc",
|
7
|
+
"start": "ts-node src/index.ts"
|
8
|
+
},
|
9
|
+
"keywords": ["website", "protection", "security", "fetch", "web", "site", "shield", "defense", "safe", "guard", "inspect", "scan"],
|
10
|
+
"author": "Kyle",
|
11
|
+
"license": "MIT",
|
12
|
+
"description": "Get WebSite Protection - A simple Node.js package for fetching information about the protection mechanisms used by a website.",
|
13
|
+
"devDependencies": {
|
14
|
+
"@types/node-fetch": "^2.6.11",
|
15
|
+
"ts-node": "^10.9.2",
|
16
|
+
"typescript": "^5.4.5"
|
17
|
+
},
|
18
|
+
"dependencies": {
|
19
|
+
"@types/node": "^20.14.1",
|
20
|
+
"kyle-printer": "^1.0.0",
|
21
|
+
"node-fetch": "^2.7.0"
|
22
|
+
}
|
23
|
+
}
|
package/src/index.ts
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
import fetch, { Response } from 'node-fetch';
|
2
|
+
import print from 'kyle-printer';
|
3
|
+
|
4
|
+
async function GWSP(url: string): Promise<void> {
|
5
|
+
if (!url) {
|
6
|
+
throw new Error('\x1b[1m\x1b[31mNo URL provided\x1b[0m');
|
7
|
+
}
|
8
|
+
|
9
|
+
let response: Response | undefined;
|
10
|
+
try {
|
11
|
+
response = await fetch(url);
|
12
|
+
const { status, headers } = response;
|
13
|
+
let protectionInfo = 'none';
|
14
|
+
const serverHeader = headers.get('server');
|
15
|
+
const poweredByHeader = headers.get('x-powered-by');
|
16
|
+
const viaHeader = headers.get('via');
|
17
|
+
|
18
|
+
if (serverHeader) {
|
19
|
+
protectionInfo = `Server: ${serverHeader}`;
|
20
|
+
} else if (poweredByHeader) {
|
21
|
+
protectionInfo = `X-Powered-By: ${poweredByHeader}`;
|
22
|
+
} else if (viaHeader) {
|
23
|
+
protectionInfo = `Via: ${viaHeader}`;
|
24
|
+
}
|
25
|
+
|
26
|
+
print({ text: `GWSP GET : ,\n${protectionInfo}`, color: 'green', font: 'bold' });
|
27
|
+
} catch (error) {
|
28
|
+
let statusCode = 'null';
|
29
|
+
if ((error as any)?.response?.status) {
|
30
|
+
statusCode = (error as any).response.status.toString();
|
31
|
+
}
|
32
|
+
print({ text: `Problem with request (Status Code: ${statusCode}): ${(error as Error).message}`, color: 'red', font: 'bold' });
|
33
|
+
} finally {
|
34
|
+
if (response) {
|
35
|
+
response.clone();
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
GWSP('https://chatgpt.com/');
|
package/tsconfig.json
ADDED