-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
277 additions
and
169 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: test-sslChecker | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
- name: Use yarn | ||
uses: nuxt/actions-yarn@master | ||
- name: yarn install, test and build | ||
env: | ||
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
run: | | ||
yarn install | ||
yarn test:coverage | ||
yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ coverage | |
node_modules | ||
npm-debug.log | ||
yarn.lock | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
# Node SSL Checker | ||
|
||
[![wercker status](https://app.wercker.com/status/d9c8e99c45ac59552e86375ac942697b/s/master "wercker status")](https://app.wercker.com/project/byKey/d9c8e99c45ac59552e86375ac942697b) [![npm version](https://badge.fury.io/js/ssl-checker.svg)](https://badge.fury.io/js/ssl-checker) [![npm](https://img.shields.io/npm/dt/ssl-checker.svg)](https://github.com/dyaa/node-ssl-checker) | ||
[![Build Status](https://github.com/dyaa/ssl-checker/workflows/test-sslChecker/badge.svg)](https://github.com/dyaa/ssl-checker/actions) | ||
[![npm version](https://badge.fury.io/js/ssl-checker.svg)](https://badge.fury.io/js/ssl-checker) [![npm](https://img.shields.io/npm/dt/ssl-checker.svg)](https://github.com/dyaa/node-ssl-checker) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4544a598aa6b4bc99883ef655e1dd90f)](https://www.codacy.com/manual/dyaa/node-ssl-checker?utm_source=github.com&utm_medium=referral&utm_content=dyaa/node-ssl-checker&utm_campaign=Badge_Grade) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/4544a598aa6b4bc99883ef655e1dd90f)](https://www.codacy.com/manual/dyaa/node-ssl-checker?utm_source=github.com&utm_medium=referral&utm_content=dyaa/node-ssl-checker&utm_campaign=Badge_Coverage) | ||
|
||
## Installation | ||
|
||
Simply add `ssl-checker` as a dependency: | ||
|
||
```bash | ||
$ npm install ssl-checker --save # npm i -s ssl-checker | ||
|
||
# Or if you are using yarn (https://yarnpkg.com/lang/en/) | ||
# Or if you prefer using yarn (https://yarnpkg.com/lang/en/) | ||
$ yarn add ssl-checker | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
import sslChecker from 'ssl-checker'; | ||
|
||
sslChecker("github.com").then(console.log).catch(console.error); | ||
sslChecker("github").then(console.log).catch((err) => { | ||
if (err.code === 'ENOTFOUND') { | ||
console.log("Please get back only or fix hostname"); | ||
} else { | ||
console.error(err); | ||
} | ||
}); | ||
```ts | ||
import sslChecker from "ssl-checker"; | ||
|
||
const getSslDetails = async (hostname: string) => | ||
await sslChecker(hostname`ex. badssl.com`); | ||
``` | ||
|
||
## Options | ||
| Option | Default | | | ||
| ------ | -------- | ----------------------- | | ||
| Host | Required | your host *ex. github.com* | | ||
| Method | HEAD | can be GET too | | ||
| Port | 443 | Your ssl port number | | ||
|
||
```javascript | ||
var sslChecker = require("ssl-checker") | ||
sslChecker('dyaa.me', 'GET', 443).then(result => console.info(result)); | ||
|
||
| Option | Default | | | ||
| ------ | ------- | -------------------------------------------------- | | ||
| method | HEAD | can be GET too | | ||
| port | 443 | Your ssl entrypoint | | ||
| agent | HEAD | I dont know why but if you'd like provide agent id | | ||
| | | ||
|
||
```ts | ||
sslChecker("dyaa.me", { method: "GET", port: 443 }).then(console.info); | ||
``` | ||
|
||
## Response Example | ||
|
||
```json | ||
{ | ||
"valid": true, | ||
"days_remaining" : 90, | ||
"valid_from" : "issue date", | ||
"valid_to" : "expiry date" | ||
"days_remaining": 90, | ||
"valid": true, | ||
"valid_from": "issue date", | ||
"valid_to": "expiry date" | ||
} | ||
``` | ||
|
||
#### License | ||
|
||
Copylefted (c) 2018 [Dyaa Eldin Moustafa][1] Licensed under the [MIT license][2]. | ||
|
||
Copylefted (c) 8008 :trollface: [Dyaa Eldin Moustafa][1] Licensed under the [MIT license][2]. | ||
|
||
[1]: https://dyaa.me/ | ||
[2]: https://github.com/dyaa/node-ssl-checker/blob/master/LICENSE | ||
[1]: https://dyaa.me/ | ||
[2]: https://github.com/dyaa/node-ssl-checker/blob/master/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"setupFilesAfterEnv": [ | ||
"jest-extended" | ||
], | ||
"transform": { | ||
"^.+\\.ts?$": "ts-jest" | ||
}, | ||
"testRegex": "(/__tests__/.*|(\\.|/))\\.(ts)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js", | ||
"json", | ||
"node" | ||
], | ||
"coverageReporters": [ | ||
"json", | ||
"lcov", | ||
"text", | ||
"text-summary" | ||
], | ||
"coverageDirectory": "./coverage/", | ||
"collectCoverage": true, | ||
"globals": { | ||
"ts-jest": { | ||
"diagnostics": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sslChecker from "../"; | ||
|
||
const validSslHost = "badssl.com"; | ||
const expiredSSlHost = "expired.badssl.com"; | ||
const wrongHostDomain = "wrong.host.badssl.com"; | ||
|
||
describe("sslChecker", () => { | ||
it("Should return valid values when valid host is passed", async () => { | ||
const sslDetails = await sslChecker(validSslHost); | ||
|
||
expect(sslDetails).toEqual( | ||
expect.objectContaining({ | ||
daysRemaining: expect.any(Number), | ||
valid: true, | ||
validFrom: expect.any(String), | ||
validTo: expect.any(String) | ||
}) | ||
); | ||
}); | ||
|
||
it("Should return valid = false when provided an expired domain", async () => { | ||
const sslDetails = await sslChecker(expiredSSlHost); | ||
|
||
expect(sslDetails).toEqual( | ||
expect.objectContaining({ | ||
valid: false | ||
}) | ||
); | ||
}); | ||
|
||
it("Should return an error when passing a wrong host domain", async () => { | ||
try { | ||
await sslChecker(wrongHostDomain); | ||
} catch (e) { | ||
expect(e).toContain( | ||
"getaddrinfo ENOTFOUND expiredSSlHost expiredSSlHost:" | ||
); | ||
} | ||
}); | ||
|
||
it("Should return 'Invalid host' when no host provided", async () => { | ||
try { | ||
await sslChecker(); | ||
} catch (e) { | ||
expect(e).toEqual(new Error("Invalid host")); | ||
} | ||
}); | ||
|
||
it("Should return 'Invalid port' when no port provided", async () => { | ||
try { | ||
await sslChecker(validSslHost, { port: "port" }); | ||
} catch (e) { | ||
expect(e).toEqual(new Error("Invalid port")); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.