Skip to content

Commit

Permalink
chore(readme): updated documents for python,js and main readme
Browse files Browse the repository at this point in the history
Vigneshkna committed Oct 22, 2024
1 parent 3d5ddd5 commit ef150e6
Showing 12 changed files with 78 additions and 69 deletions.
72 changes: 39 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -51,14 +51,14 @@ Join our [GitHub Community Discussion](https://github.com/Blackplums/how2validat
Stay updated with the latest versions and downloads:

<div align="center">
<a href="https://jsr.io/@how2validate/how2validate" target="_blank">
<svg viewBox="0 0 13 7" class="inline w-auto relative mr-3" aria-hidden="true" height="56"><path d="M0,2h2v-2h7v1h4v4h-2v2h-7v-1h-4" fill="#083344"></path><g fill="#f7df1e"><path d="M1,3h1v1h1v-3h1v4h-3"></path><path d="M5,1h3v1h-2v1h2v3h-3v-1h2v-1h-2"></path><path d="M9,2h3v2h-1v-1h-1v3h-1"></path></g></svg>
<a href="https://jsr.io/@how2validate/how2validate" target="_blank">
<img src="https://github.com/jsr-io/jsr/blob/main/frontend/static/logo.png" height="56" alt="jsr.io" />
</a>
<a href="https://pypi.org/project/how2validate/" target="_blank">
<img src="https://pypi.org/static/images/logo-small.8998e9d1.svg" height="50" alt="pypi.org" />
</a>
<a href="https://github.com/Blackplums/how2validate/pkgs/container/how2validate" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24" data-package-type="Container" class="mr-2"><path fill-rule="evenodd" d="M13.152.682a2.25 2.25 0 012.269 0l.007.004 6.957 4.276a2.276 2.276 0 011.126 1.964v7.516c0 .81-.432 1.56-1.133 1.968l-.002.001-11.964 7.037-.004.003a2.276 2.276 0 01-2.284 0l-.026-.015-6.503-4.502a2.268 2.268 0 01-1.096-1.943V9.438c0-.392.1-.77.284-1.1l.003-.006.014-.026a2.28 2.28 0 01.82-.827h.002L13.152.681zm.757 1.295h-.001L2.648 8.616l6.248 4.247a.776.776 0 00.758-.01h.001l11.633-6.804-6.629-4.074a.75.75 0 00-.75.003zM18 9.709l-3.25 1.9v7.548L18 17.245V9.709zm1.5-.878v7.532l2.124-1.25a.777.777 0 00.387-.671V7.363L19.5 8.831zm-9.09 5.316l2.84-1.66v7.552l-3.233 1.902v-7.612c.134-.047.265-.107.391-.18l.002-.002zm-1.893 7.754V14.33a2.277 2.277 0 01-.393-.18l-.023-.014-6.102-4.147v7.003c0 .275.145.528.379.664l.025.014 6.114 4.232z" fill="currentColor"></path></svg>
<img src="https://cdn-icons-png.flaticon.com/512/9402/9402282.png" height="60" alt="container image" />
</a>
</div>

@@ -123,16 +123,15 @@ docker pull ghcr.io/blackplums/how2validate:main
```javascript
import { validate } from '@how2validate/how2validate';

// Validate secrets programmatically
const validationResult = validate(
provider = "NPM",
service = "NPM Access Token",
secret = "<<SECRET_HERE>>",
response = false,
report = false,
isBrowser = true
);
console.log(validationResult);
# Validate secrets programmatically
var validation_result = await validate(
provider="NPM",
service="NPM Access Token",
secret="<<SECRET_HERE>>",
response=False,
report="useremail@domain.com"
)
print(validation_result)
```


@@ -149,7 +148,7 @@ validation_result = validate(
service="NPM Access Token",
secret="<<SECRET_HERE>>",
response=False,
report=False,
report="useremail@domain.com"
)
print(validation_result)
```
@@ -165,20 +164,20 @@ To see all available commands, use:
```bash
how2validate --help

usage: How2Validate Tool
usage: How2Validate Tool [options]

Validate various types of secrets for different services.

options:
-h, --help show this help message and exit
-secretscope Explore the secret universe. Your next target awaits.
-provider PROVIDER Specify your provider. Unleash your validation arsenal.
-service SERVICE Specify your target service. Validate your secrets with precision.
-secret SECRET Unveil your secrets to verify their authenticity.
-r, --response Monitor the status. View if your secret Active or InActive.
-report Get detailed reports. Receive validated secrets via email [Alpha Feature].
-v, --version Expose the version.
--update Hack the tool to the latest version.
-h, --help show this help message and exit
-secretscope Explore the secret universe. Your next target awaits.
-p, --provider Specify your provider. Unleash your validation arsenal.
-s, --service Specify your target service. Validate your secrets with precision.
-sec, --secret Unveil your secrets to verify their authenticity.
-r, --response Monitor the status. View if your secret is Active or InActive.
-R, --report Get detailed reports. Receive validated secrets via email [Alpha Feature].
-v, --version Expose the version.
--update Hack the tool to the latest version.

Ensuring the authenticity of your secrets.
```
@@ -188,13 +187,21 @@ Ensuring the authenticity of your secrets.
#### Validate a Secret
```bash
how2validate -provider NPM -service "NPM Access Token" -secret "<<SECRET_HERE>>"
how2validate --provider NPM --service "NPM Access Token" --secret "<<SECRET_HERE>>"

-- OR --

how2validate -p NPM -s "NPM Access Token" -sec "<<SECRET_HERE>>"
```
#### Validate with Response Status
```bash
how2validate -provider NPM -service "NPM Access Token" -secret "<<SECRET_HERE>>" -r
how2validate --provider NPM --service "NPM Access Token" --secret "<<SECRET_HERE>>" --response

-- OR --

how2validate -p NPM -s "NPM Access Token" -sec "<<SECRET_HERE>>" -r
```
@@ -204,7 +211,7 @@ Detailed documentation of the **How2Validate API** for both JavaScript and Pytho
### JavaScript API
`validate(provider, service, secret, response, report, isBrowser)`
`validate(provider, service, secret, response, report)`
Validates a secret against the specified provider and service.
@@ -213,8 +220,7 @@ Validates a secret against the specified provider and service.
- `service` (string): The specific service or token type.
- `secret` (string): The secret to validate.
- `response` (boolean): If `true`, returns the full response.
- `report` (boolean): If `true`, sends a detailed report via email (Alpha Feature).
- `isBrowser` (boolean): Indicates if the validation is performed in a browser environment.
- `report` (string): Email Id to send a detailed report (Alpha Feature).
- **Returns:**
- `validationResult` (object): An object containing the validation status and details.
@@ -224,7 +230,7 @@ Validates a secret against the specified provider and service.
```javascript
import { validate } from '@how2validate/how2validate';

const result = validate("NPM", "NPM Access Token", "<<SECRET>>", false, false, true);
const result = validate("NPM", "NPM Access Token", "<<SECRET>>", true/false, "useremail@domain.com");
console.log(result);
```
@@ -239,7 +245,7 @@ Validates a secret against the specified provider and service.
- `service` (string): The specific service or token type.
- `secret` (string): The secret to validate.
- `response` (boolean): If `true`, returns the full response.
- `report` (boolean): If `true`, sends a detailed report via email (Alpha Feature).
- `report` (string): Email Id to send a detailed report (Alpha Feature).
- **Returns:**
- `validation_result` (object): An object containing the validation status and details.
@@ -254,8 +260,8 @@ result = validate(
provider="NPM",
service="NPM Access Token",
secret="<<SECRET>>",
response=False,
report=False
response=True/False,
report="useremail@domain.com"
)
print(result)
```
27 changes: 13 additions & 14 deletions src/js/README.md
Original file line number Diff line number Diff line change
@@ -27,20 +27,20 @@ To see all available commands, use:
```npm
how2validate --help
usage: How2Validate Tool
usage: How2Validate Tool [options]
Validate various types of secrets for different services.
options:
-h, --help show this help message and exit
-secretscope Explore the secret universe. Your next target awaits.
-provider PROVIDER Specify your provider. Unleash your validation arsenal.
-service SERVICE Specify your target service. Validate your secrets with precision.
-secret SECRET Unveil your secrets to verify their authenticity.
-r, --response Monitor the status. View if your secret Active or InActive.
-report Get detailed reports. Receive validated secrets via email [Alpha Feature].
-v, --version Expose the version.
--update Hack the tool to the latest version.
-h, --help show this help message and exit
-secretscope Explore the secret universe. Your next target awaits.
-p, --provider Specify your provider. Unleash your validation arsenal.
-s, --service Specify your target service. Validate your secrets with precision.
-sec, --secret Unveil your secrets to verify their authenticity.
-r, --response Monitor the status. View if your secret is Active or InActive.
-R, --report Get detailed reports. Receive validated secrets via email [Alpha Feature].
-v, --version Expose the version.
--update Hack the tool to the latest version.
Ensuring the authenticity of your secrets.
```
@@ -64,7 +64,7 @@ npx jsr add @how2validate/how2validate
import { validate } from '@how2validate/how2validate';

# Validate secrets programmatically
var validation_result = validate(provider,service, secret, response, report, isBrowser)
var validation_result = validate(provider,service, secret, response, report)
print(validation_result)

```
@@ -131,13 +131,12 @@ import { validate } from "jsr:@how2validate/how2validate";
import { validate } from '@how2validate/how2validate';

# Validate secrets programmatically
var validation_result = validate(
var validation_result = await validate(
provider="NPM",
service="NPM Access Token",
secret="<<SECRET_HERE>>",
response=False,
report=False,
isBrowser=True
report="useremail@domain.com"
)
print(validation_result)

2 changes: 1 addition & 1 deletion src/js/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"DEFAULT": {
"package_name": "@how2validate/how2validate",
"version": "0.0.1-beta.26"
"version": "0.0.1-beta.27"
},
"SECRET": {
"secret_active": "Active",
8 changes: 4 additions & 4 deletions src/js/how2validate/handler/validator_handler.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import { ValidationResult } from "../utility/interface/validationResult.js"; //
* @param {string} secret - The secret (e.g., API key, token) to validate.
* @param {boolean} response - Indicates whether to include response data in the output.
* @param {string} [report] - Optional email address for sending validation reports.
* @param {boolean} [isBrowser=false] - Indicates if the validation is occurring in a browser environment.
* @param {boolean} [isBrowser=true] - Indicates if the validation is occurring in a browser environment.
* @returns {Promise<ValidationResult>} A promise that resolves to a validation result object.
*/
type ValidatorFunction = (
@@ -25,7 +25,7 @@ type ValidatorFunction = (
secret: string,
response: boolean,
report: string,
isBrowser?: boolean
isBrowser: boolean
) => Promise<ValidationResult>;


@@ -51,7 +51,7 @@ const serviceHandlers: Record<string, ValidatorFunction> = {
* @param {string} secret - The secret (e.g., API key, token) to validate.
* @param {boolean} response - A boolean indicating whether to include response data in the output.
* @param {string} [report] - An optional email address for sending validation reports.
* @param {boolean} [isBrowser=false] - Indicates if the validation is occurring in a browser environment.
* @param {boolean} [isBrowser=true] - Indicates if the validation is occurring in a browser environment.
* @returns {Promise<ValidationResult | string>} A promise that resolves to the validation result or an error message.
*
* @example
@@ -64,7 +64,7 @@ export async function validatorHandleService(
secret: string,
response: boolean,
report: string,
isBrowser: boolean = false
isBrowser: boolean = true
): Promise<ValidationResult | string> {
// Retrieve the handler function based on the provided service name
const handler = serviceHandlers[service];
7 changes: 4 additions & 3 deletions src/js/how2validate/index.ts
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ export function getService(provider: string): object {
* @param {string} secret - The secret that needs to be validated.
* @param {boolean} response - Whether to get a response status for the secret.
* @param {string} report - Whether to generate a report for the validation.
* @param {boolean} [isBrowser=false] - Whether the validation is being run in a browser environment.
* @param {boolean} [isBrowser=true] - Whether the validation is being run in a browser environment.
* @returns {Promise<void>} - A promise that resolves when validation is complete.
* @throws Will throw an error if validation fails.
*/
@@ -129,7 +129,7 @@ export async function validate(
secret: string,
response: boolean,
report: string,
isBrowser:boolean = false
isBrowser:boolean = true
): Promise<ValidationResult | string> {
const result = await validatorHandleService(
formatString(provider),
@@ -225,7 +225,8 @@ async function main(): Promise<void> {
options.service,
options.secret,
options.response,
options.report
options.report,
false
); // Call validate function
console.info("Validation completed successfully.");
} catch (error) {
13 changes: 8 additions & 5 deletions src/js/how2validate/utility/tool_utility.ts
Original file line number Diff line number Diff line change
@@ -543,7 +543,7 @@ export function handleActiveStatus(

// Log the result if not in the browser environment
if (!isBrowser) {
console.info(`${res.message} ${responseFlag ? res.response : ""}`);
console.info(`${res.message}${responseFlag ? `\nHere is the additional response data:\n${JSON.stringify(activeResponseData, null, 4)}` : ""}`);
}

return activeResponseData;
@@ -567,7 +567,7 @@ export function handleInactiveStatus(
responseFlag: boolean,
data?: any,
report?: string,
isBrowser: boolean = false
isBrowser: boolean = true
): ValidationResult{
const appName = "How2Validate";
const timestamp = getCurrentTimestamp();
@@ -595,7 +595,7 @@ export function handleInactiveStatus(
};

if (!isBrowser) {
console.info(`${res.message} ${responseFlag ? res.response : ""}`);
console.info(`${res.message}${responseFlag ? `\nHere is the additional response data:\n${JSON.stringify(inactiveResponseData, null, 4)}` : ""}`);
}

return inactiveResponseData;
@@ -618,7 +618,7 @@ export function handleErrors(
responseFlag: boolean,
report: string,
error: unknown,
isBrowser: boolean = false
isBrowser: boolean = true
): ValidationResult {
const appName = "How2Validate";
const timestamp = getCurrentTimestamp();
@@ -648,11 +648,14 @@ export function handleErrors(
provider: provider,
services: service
},
error:{
message: res.response,
},
timestamp,
};

if (!isBrowser) {
console.info(`${res.message} ${responseFlag ? res.response : ""}`);
console.info(`${res.message}${responseFlag ? `\nHere is the additional response data:\n${JSON.stringify(errResponseData, null, 4)}` : ""}`);
}

return errResponseData;
4 changes: 2 additions & 2 deletions src/js/how2validate/validators/npm/npm_access_token.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ import axios from "axios"; // Axios for making API requests
* @param {string} secret - The NPM authentication token or secret to validate.
* @param {boolean} responseFlag - A flag to indicate whether detailed response data should be returned.
* @param {string} [report] - An optional email address to which a validation report should be sent.
* @param {boolean} [isBrowser=false] - Indicates if the function is called from a browser environment (default is false).
* @param {boolean} [isBrowser=true] - Indicates if the function is called from a browser environment (default is false).
*
* @returns {Promise<ValidationResult>} - A promise that resolves to a `ValidationResult` object containing the validation result.
*
@@ -55,7 +55,7 @@ export async function validateNpmAccessToken(
secret: string,
responseFlag: boolean,
report: string,
isBrowser: boolean = false
isBrowser: boolean = true
): Promise<ValidationResult> {
// Initialize the response structure
const validation_response = {} as SecretStatusMessage;
4 changes: 2 additions & 2 deletions src/js/how2validate/validators/snyk/snyk_auth_key.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ import axios from "axios"; // Axios for making API requests
* @param {string} secret - The Snyk authentication token or secret to validate.
* @param {boolean} responseFlag - A flag to indicate whether detailed response data should be returned.
* @param {string} [report] - An optional email address to which a validation report should be sent.
* @param {boolean} [isBrowser=false] - Indicates if the function is called from a browser environment (default is false).
* @param {boolean} [isBrowser=true] - Indicates if the function is called from a browser environment (default is false).
*
* @returns {Promise<ValidationResult>} - A promise that resolves to a `ValidationResult` object containing the validation result.
*
@@ -55,7 +55,7 @@ export async function validateSnykAuthKey(
secret: string,
responseFlag: boolean,
report: string,
isBrowser: boolean = false
isBrowser: boolean = true
): Promise<ValidationResult> {
// Initialize the response structure
const validation_response = {} as SecretStatusMessage;
4 changes: 2 additions & 2 deletions src/js/how2validate/validators/sonarcloud/sonarcloud_token.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ import axios from "axios"; // Axios for making API requests
* @param {string} secret - The Sonarcloud authentication token or secret to validate.
* @param {boolean} responseFlag - A flag to indicate whether detailed response data should be returned.
* @param {string} [report] - An optional email address to which a validation report should be sent.
* @param {boolean} [isBrowser=false] - Indicates if the function is called from a browser environment (default is false).
* @param {boolean} [isBrowser=true] - Indicates if the function is called from a browser environment (default is false).
*
* @returns {Promise<ValidationResult>} - A promise that resolves to a `ValidationResult` object containing the validation result.
*
@@ -55,7 +55,7 @@ export async function validateSonarcloudToken(
secret: string,
responseFlag: boolean,
report: string,
isBrowser: boolean = false
isBrowser: boolean = true
): Promise<ValidationResult> {
// Initialize the response structure
const validation_response = {} as SecretStatusMessage;
2 changes: 1 addition & 1 deletion src/js/jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@how2validate/how2validate",
"version": "0.0.2-beta.44",
"version": "0.0.2-beta.45",
"license": "MIT",
"exports": "./how2validate/index.ts",
"publish": {
2 changes: 1 addition & 1 deletion src/js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "how2validate",
"appName": "How2Validate",
"version": "0.0.1-beta.26",
"version": "0.0.1-beta.27",
"description": "A CLI tool to validate secrets for different services.",
"main": "dist/how2validate/index.js",
"type": "module",
2 changes: 1 addition & 1 deletion src/python/README.md
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ validation_result = validate(
service="NPM Access Token",
secret="<<SECRET_HERE>>",
response=False,
report="useremail@domain.com",
report="useremail@domain.com"
)
print(validation_result)

0 comments on commit ef150e6

Please sign in to comment.