summaryrefslogtreecommitdiff
path: root/node_modules/har-validator
diff options
context:
space:
mode:
authorLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
committerLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 22:54:37 +0300
commit703e03aba33f234712206769f57717ba7d92d23d (patch)
tree0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/har-validator
parentab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff)
downloadFlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz
FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/har-validator')
-rw-r--r--node_modules/har-validator/LICENSE9
-rw-r--r--node_modules/har-validator/README.md43
-rw-r--r--node_modules/har-validator/lib/async.js105
-rw-r--r--node_modules/har-validator/lib/error.js17
-rw-r--r--node_modules/har-validator/lib/promise.js102
-rw-r--r--node_modules/har-validator/package.json43
6 files changed, 319 insertions, 0 deletions
diff --git a/node_modules/har-validator/LICENSE b/node_modules/har-validator/LICENSE
new file mode 100644
index 0000000..a545266
--- /dev/null
+++ b/node_modules/har-validator/LICENSE
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) 2018 Ahmad Nassri <ahmad@ahmadnassri.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/har-validator/README.md b/node_modules/har-validator/README.md
new file mode 100644
index 0000000..ea944cc
--- /dev/null
+++ b/node_modules/har-validator/README.md
@@ -0,0 +1,43 @@
+# HAR Validator
+
+[![license][license-img]][license-url]
+[![version][npm-img]][npm-url]
+[![super linter][super-linter-img]][super-linter-url]
+[![test][test-img]][test-url]
+[![release][release-img]][release-url]
+
+[license-url]: LICENSE
+[license-img]: https://badgen.net/github/license/ahmadnassri/node-har-validator
+
+[npm-url]: https://www.npmjs.com/package/har-validator
+[npm-img]: https://badgen.net/npm/v/har-validator
+
+[super-linter-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Asuper-linter
+[super-linter-img]: https://github.com/ahmadnassri/node-har-validator/workflows/super-linter/badge.svg
+
+[test-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Atest
+[test-img]: https://github.com/ahmadnassri/node-har-validator/workflows/test/badge.svg
+
+[release-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Arelease
+[release-img]: https://github.com/ahmadnassri/node-har-validator/workflows/release/badge.svg
+
+> Extremely fast HTTP Archive ([HAR](https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md)) validator using JSON Schema.
+
+## Install
+
+```bash
+npm install har-validator
+```
+
+## CLI Usage
+
+Please refer to [`har-cli`](https://github.com/ahmadnassri/har-cli) for more info.
+
+## API
+
+**Note**: as of [`v2.0.0`](https://github.com/ahmadnassri/node-har-validator/releases/tag/v2.0.0) this module defaults to Promise based API.
+_For backward compatibility with `v1.x` an [async/callback API](docs/async.md) is also provided_
+
+- [async API](docs/async.md)
+- [callback API](docs/async.md)
+- [Promise API](docs/promise.md) _(default)_
diff --git a/node_modules/har-validator/lib/async.js b/node_modules/har-validator/lib/async.js
new file mode 100644
index 0000000..90701f2
--- /dev/null
+++ b/node_modules/har-validator/lib/async.js
@@ -0,0 +1,105 @@
+var Ajv = require('ajv')
+var HARError = require('./error')
+var schemas = require('har-schema')
+
+var ajv
+
+function createAjvInstance () {
+ var ajv = new Ajv({
+ allErrors: true
+ })
+ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'))
+ ajv.addSchema(schemas)
+
+ return ajv
+}
+
+function validate (name, data, next) {
+ data = data || {}
+
+ // validator config
+ ajv = ajv || createAjvInstance()
+
+ var validate = ajv.getSchema(name + '.json')
+
+ var valid = validate(data)
+
+ // callback?
+ if (typeof next === 'function') {
+ return next(!valid ? new HARError(validate.errors) : null, valid)
+ }
+
+ return valid
+}
+
+exports.afterRequest = function (data, next) {
+ return validate('afterRequest', data, next)
+}
+
+exports.beforeRequest = function (data, next) {
+ return validate('beforeRequest', data, next)
+}
+
+exports.browser = function (data, next) {
+ return validate('browser', data, next)
+}
+
+exports.cache = function (data, next) {
+ return validate('cache', data, next)
+}
+
+exports.content = function (data, next) {
+ return validate('content', data, next)
+}
+
+exports.cookie = function (data, next) {
+ return validate('cookie', data, next)
+}
+
+exports.creator = function (data, next) {
+ return validate('creator', data, next)
+}
+
+exports.entry = function (data, next) {
+ return validate('entry', data, next)
+}
+
+exports.har = function (data, next) {
+ return validate('har', data, next)
+}
+
+exports.header = function (data, next) {
+ return validate('header', data, next)
+}
+
+exports.log = function (data, next) {
+ return validate('log', data, next)
+}
+
+exports.page = function (data, next) {
+ return validate('page', data, next)
+}
+
+exports.pageTimings = function (data, next) {
+ return validate('pageTimings', data, next)
+}
+
+exports.postData = function (data, next) {
+ return validate('postData', data, next)
+}
+
+exports.query = function (data, next) {
+ return validate('query', data, next)
+}
+
+exports.request = function (data, next) {
+ return validate('request', data, next)
+}
+
+exports.response = function (data, next) {
+ return validate('response', data, next)
+}
+
+exports.timings = function (data, next) {
+ return validate('timings', data, next)
+}
diff --git a/node_modules/har-validator/lib/error.js b/node_modules/har-validator/lib/error.js
new file mode 100644
index 0000000..f2618dc
--- /dev/null
+++ b/node_modules/har-validator/lib/error.js
@@ -0,0 +1,17 @@
+function HARError (errors) {
+ var message = 'validation failed'
+
+ this.name = 'HARError'
+ this.message = message
+ this.errors = errors
+
+ if (typeof Error.captureStackTrace === 'function') {
+ Error.captureStackTrace(this, this.constructor)
+ } else {
+ this.stack = (new Error(message)).stack
+ }
+}
+
+HARError.prototype = Error.prototype
+
+module.exports = HARError
diff --git a/node_modules/har-validator/lib/promise.js b/node_modules/har-validator/lib/promise.js
new file mode 100644
index 0000000..46f4647
--- /dev/null
+++ b/node_modules/har-validator/lib/promise.js
@@ -0,0 +1,102 @@
+var Ajv = require('ajv')
+var HARError = require('./error')
+var schemas = require('har-schema')
+
+var ajv
+
+function createAjvInstance () {
+ var ajv = new Ajv({
+ allErrors: true
+ })
+ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'))
+ ajv.addSchema(schemas)
+
+ return ajv
+}
+
+function validate (name, data) {
+ data = data || {}
+
+ // validator config
+ ajv = ajv || createAjvInstance()
+
+ var validate = ajv.getSchema(name + '.json')
+
+ return new Promise(function (resolve, reject) {
+ var valid = validate(data)
+
+ !valid ? reject(new HARError(validate.errors)) : resolve(data)
+ })
+}
+
+exports.afterRequest = function (data) {
+ return validate('afterRequest', data)
+}
+
+exports.beforeRequest = function (data) {
+ return validate('beforeRequest', data)
+}
+
+exports.browser = function (data) {
+ return validate('browser', data)
+}
+
+exports.cache = function (data) {
+ return validate('cache', data)
+}
+
+exports.content = function (data) {
+ return validate('content', data)
+}
+
+exports.cookie = function (data) {
+ return validate('cookie', data)
+}
+
+exports.creator = function (data) {
+ return validate('creator', data)
+}
+
+exports.entry = function (data) {
+ return validate('entry', data)
+}
+
+exports.har = function (data) {
+ return validate('har', data)
+}
+
+exports.header = function (data) {
+ return validate('header', data)
+}
+
+exports.log = function (data) {
+ return validate('log', data)
+}
+
+exports.page = function (data) {
+ return validate('page', data)
+}
+
+exports.pageTimings = function (data) {
+ return validate('pageTimings', data)
+}
+
+exports.postData = function (data) {
+ return validate('postData', data)
+}
+
+exports.query = function (data) {
+ return validate('query', data)
+}
+
+exports.request = function (data) {
+ return validate('request', data)
+}
+
+exports.response = function (data) {
+ return validate('response', data)
+}
+
+exports.timings = function (data) {
+ return validate('timings', data)
+}
diff --git a/node_modules/har-validator/package.json b/node_modules/har-validator/package.json
new file mode 100644
index 0000000..8d1eed1
--- /dev/null
+++ b/node_modules/har-validator/package.json
@@ -0,0 +1,43 @@
+{
+ "version": "5.1.5",
+ "name": "har-validator",
+ "description": "Extremely fast HTTP Archive (HAR) validator using JSON Schema",
+ "author": "Ahmad Nassri <ahmad@ahmadnassri.com> (https://www.ahmadnassri.com/)",
+ "homepage": "https://github.com/ahmadnassri/node-har-validator",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/ahmadnassri/node-har-validator.git"
+ },
+ "license": "MIT",
+ "main": "lib/promise.js",
+ "keywords": [
+ "har",
+ "cli",
+ "ajv",
+ "http",
+ "archive",
+ "validate",
+ "validator"
+ ],
+ "engines": {
+ "node": ">=6"
+ },
+ "files": [
+ "lib"
+ ],
+ "bugs": {
+ "url": "https://github.com/ahmadnassri/node-har-validator/issues"
+ },
+ "scripts": {
+ "lint": "npx run-p lint:*",
+ "test": "tap test --no-coverage",
+ "test:coverage": "tap test --coverage-report=lcov --no-browser"
+ },
+ "devDependencies": {
+ "tap": "^14.10.8"
+ },
+ "dependencies": {
+ "ajv": "^6.12.3",
+ "har-schema": "^2.0.0"
+ }
+}