Initial commit with Advoware proxy

This commit is contained in:
root
2025-10-19 14:57:07 +00:00
commit 273aa8b549
45771 changed files with 5534555 additions and 0 deletions

View File

@@ -0,0 +1,212 @@
'use strict'
var find = require('property-information/find')
var normalize = require('property-information/normalize')
var parseSelector = require('hast-util-parse-selector')
var spaces = require('space-separated-tokens').parse
var commas = require('comma-separated-tokens').parse
module.exports = factory
var own = {}.hasOwnProperty
function factory(schema, defaultTagName, caseSensitive) {
var adjust = caseSensitive ? createAdjustMap(caseSensitive) : null
return h
// Hyperscript compatible DSL for creating virtual hast trees.
function h(selector, properties) {
var node = parseSelector(selector, defaultTagName)
var children = Array.prototype.slice.call(arguments, 2)
var name = node.tagName.toLowerCase()
var property
node.tagName = adjust && own.call(adjust, name) ? adjust[name] : name
if (properties && isChildren(properties, node)) {
children.unshift(properties)
properties = null
}
if (properties) {
for (property in properties) {
addProperty(node.properties, property, properties[property])
}
}
addChild(node.children, children)
if (node.tagName === 'template') {
node.content = {type: 'root', children: node.children}
node.children = []
}
return node
}
function addProperty(properties, key, value) {
var info
var property
var result
// Ignore nullish and NaN values.
if (value === null || value === undefined || value !== value) {
return
}
info = find(schema, key)
property = info.property
result = value
// Handle list values.
if (typeof result === 'string') {
if (info.spaceSeparated) {
result = spaces(result)
} else if (info.commaSeparated) {
result = commas(result)
} else if (info.commaOrSpaceSeparated) {
result = spaces(commas(result).join(' '))
}
}
// Accept `object` on style.
if (property === 'style' && typeof value !== 'string') {
result = style(result)
}
// Class-names (which can be added both on the `selector` and here).
if (property === 'className' && properties.className) {
result = properties.className.concat(result)
}
properties[property] = parsePrimitives(info, property, result)
}
}
function isChildren(value, node) {
return (
typeof value === 'string' ||
'length' in value ||
isNode(node.tagName, value)
)
}
function isNode(tagName, value) {
var type = value.type
if (tagName === 'input' || !type || typeof type !== 'string') {
return false
}
if (typeof value.children === 'object' && 'length' in value.children) {
return true
}
type = type.toLowerCase()
if (tagName === 'button') {
return (
type !== 'menu' &&
type !== 'submit' &&
type !== 'reset' &&
type !== 'button'
)
}
return 'value' in value
}
function addChild(nodes, value) {
var index
var length
if (typeof value === 'string' || typeof value === 'number') {
nodes.push({type: 'text', value: String(value)})
return
}
if (typeof value === 'object' && 'length' in value) {
index = -1
length = value.length
while (++index < length) {
addChild(nodes, value[index])
}
return
}
if (typeof value !== 'object' || !('type' in value)) {
throw new Error('Expected node, nodes, or string, got `' + value + '`')
}
nodes.push(value)
}
// Parse a (list of) primitives.
function parsePrimitives(info, name, value) {
var index
var length
var result
if (typeof value !== 'object' || !('length' in value)) {
return parsePrimitive(info, name, value)
}
length = value.length
index = -1
result = []
while (++index < length) {
result[index] = parsePrimitive(info, name, value[index])
}
return result
}
// Parse a single primitives.
function parsePrimitive(info, name, value) {
var result = value
if (info.number || info.positiveNumber) {
if (!isNaN(result) && result !== '') {
result = Number(result)
}
} else if (info.boolean || info.overloadedBoolean) {
// Accept `boolean` and `string`.
if (
typeof result === 'string' &&
(result === '' || normalize(value) === normalize(name))
) {
result = true
}
}
return result
}
function style(value) {
var result = []
var key
for (key in value) {
result.push([key, value[key]].join(': '))
}
return result.join('; ')
}
function createAdjustMap(values) {
var length = values.length
var index = -1
var result = {}
var value
while (++index < length) {
value = values[index]
result[value.toLowerCase()] = value
}
return result
}

View File

@@ -0,0 +1,9 @@
'use strict'
var schema = require('property-information/html')
var factory = require('./factory')
var html = factory(schema, 'div')
html.displayName = 'html'
module.exports = html

View File

@@ -0,0 +1,29 @@
// TypeScript Version: 3.5
import {Element, Properties, Node} from 'hast'
/**
* DSL to create virtual hast trees for HTML or SVG
*
* @param selector Simple CSS selector
* @param children (Lists of) child nodes
*/
declare function hastscript(
selector?: string,
children?: string | Node | Array<string | Node>
): Element
/**
* DSL to create virtual hast trees for HTML or SVG
*
* @param selector Simple CSS selector
* @param properties Map of properties
* @param children (Lists of) child nodes
*/
declare function hastscript(
selector?: string,
properties?: Properties,
children?: string | Node | Array<string | Node>
): Element
export = hastscript

View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = require('./html')

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.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.

View File

@@ -0,0 +1,101 @@
{
"name": "hastscript",
"version": "6.0.0",
"description": "hast utility to create trees",
"license": "MIT",
"keywords": [
"unist",
"hast",
"hast-util",
"util",
"utility",
"html",
"rehype",
"vdom",
"virtual",
"dom",
"hyperscript",
"dsl"
],
"repository": "syntax-tree/hastscript",
"bugs": "https://github.com/syntax-tree/hastscript/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"types": "index.d.ts",
"files": [
"index.d.ts",
"svg.d.ts",
"index.js",
"factory.js",
"html.js",
"svg.js",
"svg-case-sensitive-tag-names.json"
],
"dependencies": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^1.0.0",
"hast-util-parse-selector": "^2.0.0",
"property-information": "^5.0.0",
"space-separated-tokens": "^1.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"dtslint": "^3.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark-cli": "^8.0.0",
"remark-preset-wooorm": "^7.0.0",
"svg-tag-names": "^2.0.0",
"tape": "^5.0.0",
"tinyify": "^2.0.0",
"xo": "^0.32.0"
},
"scripts": {
"generate": "node build",
"format": "remark . -qfo && prettier . --write && xo --fix",
"build-bundle": "browserify . -s hastscript > hastscript.js",
"build-mangle": "browserify . -s hastscript -p tinyify > hastscript.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-types": "dtslint .",
"test": "npm run generate && npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"unicorn/prefer-number-properties": "off",
"no-self-compare": "off",
"guard-for-in": "off"
},
"ignores": [
"hastscript.js"
]
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}

View File

@@ -0,0 +1,328 @@
# hastscript
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[**hast**][hast] utility to create [*trees*][tree] in HTML or SVG.
Similar to [`hyperscript`][hyperscript], [`virtual-dom/h`][virtual-hyperscript],
[`React.createElement`][react], and [Vues `createElement`][vue],
but for [**hast**][hast].
Use [`unist-builder`][u] to create any [**unist**][unist] tree.
## Install
[npm][]:
```sh
npm install hastscript
```
## Use
```js
var h = require('hastscript')
var s = require('hastscript/svg')
// Children as an array:
console.log(
h('.foo#some-id', [
h('span', 'some text'),
h('input', {type: 'text', value: 'foo'}),
h('a.alpha', {class: 'bravo charlie', download: 'download'}, [
'delta',
'echo'
])
])
)
// Children as arguments:
console.log(
h(
'form',
{method: 'POST'},
h('input', {type: 'text', name: 'foo'}),
h('input', {type: 'text', name: 'bar'}),
h('input', {type: 'submit', value: 'send'})
)
)
// SVG:
console.log(
s('svg', {xmlns: 'http://www.w3.org/2000/svg', viewbox: '0 0 500 500'}, [
s('title', 'SVG `<circle>` element'),
s('circle', {cx: 120, cy: 120, r: 100})
])
)
```
Yields:
```js
{
type: 'element',
tagName: 'div',
properties: {className: ['foo'], id: 'some-id'},
children: [
{
type: 'element',
tagName: 'span',
properties: {},
children: [{type: 'text', value: 'some text'}]
},
{
type: 'element',
tagName: 'input',
properties: {type: 'text', value: 'foo'},
children: []
},
{
type: 'element',
tagName: 'a',
properties: {className: ['alpha', 'bravo', 'charlie'], download: true},
children: [{type: 'text', value: 'delta'}, {type: 'text', value: 'echo'}]
}
]
}
{
type: 'element',
tagName: 'form',
properties: {method: 'POST'},
children: [
{
type: 'element',
tagName: 'input',
properties: {type: 'text', name: 'foo'},
children: []
},
{
type: 'element',
tagName: 'input',
properties: {type: 'text', name: 'bar'},
children: []
},
{
type: 'element',
tagName: 'input',
properties: {type: 'submit', value: 'send'},
children: []
}
]
}
{
type: 'element',
tagName: 'svg',
properties: {xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 500 500'},
children: [
{
type: 'element',
tagName: 'title',
properties: {},
children: [{type: 'text', value: 'SVG `<circle>` element'}]
},
{
type: 'element',
tagName: 'circle',
properties: {cx: 120, cy: 120, r: 100},
children: []
}
]
}
```
## API
### `h(selector?[, properties][, ...children])`
### `s(selector?[, properties][, ...children])`
DSL to create virtual [**hast**][hast] [*trees*][tree] for HTML or SVG.
##### Parameters
###### `selector`
Simple CSS selector (`string`, optional).
Can contain a tag name (`foo`), IDs (`#bar`), and classes (`.baz`).
If there is no tag name in the selector, `h` defaults to a `div` element,
and `s` to a `g` element.
`selector` is parsed by [`hast-util-parse-selector`][parse-selector].
###### `properties`
Map of properties (`Object.<*>`, optional).
###### `children`
(Lists of) child nodes (`string`, `Node`, `Array.<string|Node>`, optional).
When strings are encountered, they are mapped to [`text`][text] nodes.
##### Returns
[`Element`][element].
## Security
Use of `hastscript` can open you up to a [cross-site scripting (XSS)][xss]
attack as values are injected into the syntax tree.
The following example shows how a script is injected that runs when loaded in a
browser.
```js
var tree = {type: 'root', children: []}
tree.children.push(h('script', 'alert(1)'))
```
Yields:
```html
<script>alert(1)</script>
```
The following example shows how an image is injected that fails loading and
therefore runs code in a browser.
```js
var tree = {type: 'root', children: []}
// Somehow someone injected these properties instead of an expected `src` and
// `alt`:
var otherProps = {src: 'x', onError: 'alert(2)'}
tree.children.push(h('img', {src: 'default.png', ...otherProps}))
```
Yields:
```html
<img src="x" onerror="alert(2)">
```
The following example shows how code can run in a browser because someone stored
an object in a database instead of the expected string.
```js
var tree = {type: 'root', children: []}
// Somehow this isnt the expected `'wooorm'`.
var username = {
type: 'element',
tagName: 'script',
children: [{type: 'text', value: 'alert(3)'}]
}
tree.children.push(h('span.handle', username))
```
Yields:
```html
<span class="handle"><script>alert(3)</script></span>
```
Either do not use user input in `hastscript` or use
[`hast-util-santize`][sanitize].
## Related
* [`unist-builder`](https://github.com/syntax-tree/unist-builder)
— Create any unist tree
* [`xastscript`](https://github.com/syntax-tree/xastscript)
— Create a xast tree
* [`hast-to-hyperscript`](https://github.com/syntax-tree/hast-to-hyperscript)
— Convert a Node to React, Virtual DOM, Hyperscript, and more
* [`hast-util-from-dom`](https://github.com/syntax-tree/hast-util-from-dom)
— Transform a DOM tree to hast
* [`hast-util-select`](https://github.com/syntax-tree/hast-util-select)
`querySelector`, `querySelectorAll`, and `matches`
* [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html)
— Stringify nodes to HTML
* [`hast-util-to-dom`](https://github.com/syntax-tree/hast-util-to-dom)
— Transform to a DOM tree
## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://img.shields.io/travis/syntax-tree/hastscript.svg
[build]: https://travis-ci.org/syntax-tree/hastscript
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hastscript.svg
[coverage]: https://codecov.io/github/syntax-tree/hastscript
[downloads-badge]: https://img.shields.io/npm/dm/hastscript.svg
[downloads]: https://www.npmjs.com/package/hastscript
[size-badge]: https://img.shields.io/bundlephobia/minzip/hastscript.svg
[size]: https://bundlephobia.com/result?p=hastscript
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/syntax-tree
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[hyperscript]: https://github.com/dominictarr/hyperscript
[virtual-hyperscript]: https://github.com/Matt-Esch/virtual-dom/tree/HEAD/virtual-hyperscript
[react]: https://reactjs.org/docs/glossary.html#react-elements
[vue]: https://vuejs.org/v2/guide/render-function.html#createElement-Arguments
[unist]: https://github.com/syntax-tree/unist
[tree]: https://github.com/syntax-tree/unist#tree
[hast]: https://github.com/syntax-tree/hast
[element]: https://github.com/syntax-tree/hast#element
[text]: https://github.com/syntax-tree/hast#text
[u]: https://github.com/syntax-tree/unist-builder
[parse-selector]: https://github.com/syntax-tree/hast-util-parse-selector
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[sanitize]: https://github.com/syntax-tree/hast-util-sanitize

View File

@@ -0,0 +1,41 @@
[
"altGlyph",
"altGlyphDef",
"altGlyphItem",
"animateColor",
"animateMotion",
"animateTransform",
"clipPath",
"feBlend",
"feColorMatrix",
"feComponentTransfer",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feDistantLight",
"feDropShadow",
"feFlood",
"feFuncA",
"feFuncB",
"feFuncG",
"feFuncR",
"feGaussianBlur",
"feImage",
"feMerge",
"feMergeNode",
"feMorphology",
"feOffset",
"fePointLight",
"feSpecularLighting",
"feSpotLight",
"feTile",
"feTurbulence",
"foreignObject",
"glyphRef",
"linearGradient",
"radialGradient",
"solidColor",
"textArea",
"textPath"
]

View File

@@ -0,0 +1,5 @@
// TypeScript Version: 3.5
import hastscript = require('hastscript')
export = hastscript

View File

@@ -0,0 +1,10 @@
'use strict'
var schema = require('property-information/svg')
var caseSensitive = require('./svg-case-sensitive-tag-names.json')
var factory = require('./factory')
var svg = factory(schema, 'g', caseSensitive)
svg.displayName = 'svg'
module.exports = svg