added node modules back to the example bot, so it exports with the required modules
This commit is contained in:
39
example_bot/node_modules/magic-bytes.js/.github/workflows/build-and-test.yml
generated
vendored
Normal file
39
example_bot/node_modules/magic-bytes.js/.github/workflows/build-and-test.yml
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
name: Build and test
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
jobs:
|
||||
buildAndTest:
|
||||
name: Build and test (Node.js v${{ matrix.node-version }})
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write # to be able to publish a GitHub release
|
||||
issues: write # to be able to comment on released issues
|
||||
pull-requests: write # to be able to comment on released pull requests
|
||||
id-token: write # to enable use of OIDC for npm provenance
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install install dependencies
|
||||
run: npm ci
|
||||
- name: test
|
||||
run: npm test
|
||||
- name: build
|
||||
run: npm run build
|
||||
- name: release new version
|
||||
run: npm run semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
#- run: npm publish
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET_TOKEN }}
|
||||
48
example_bot/node_modules/magic-bytes.js/.github/workflows/static-webapp.yml
generated
vendored
Normal file
48
example_bot/node_modules/magic-bytes.js/.github/workflows/static-webapp.yml
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static webapp to Pages
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v3
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install install dependencies
|
||||
run: npm ci
|
||||
- name: build
|
||||
run: npm run build:example:webapp
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: './example/webapp/dist'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
||||
1
example_bot/node_modules/magic-bytes.js/.prettierignore
generated
vendored
Normal file
1
example_bot/node_modules/magic-bytes.js/.prettierignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
src/pattern-tree.snapshot.ts
|
||||
21
example_bot/node_modules/magic-bytes.js/LICENSE
generated
vendored
Normal file
21
example_bot/node_modules/magic-bytes.js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Lars Kölpin
|
||||
|
||||
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.
|
||||
109
example_bot/node_modules/magic-bytes.js/README.md
generated
vendored
Normal file
109
example_bot/node_modules/magic-bytes.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# Magic bytes
|
||||
|
||||
[](https://github.com/LarsKoelpin/magic-bytes/actions/workflows/build-and-test.yml)
|
||||
|
||||
Magic Bytes is a javascript library analyzing the first bytes of a file to tell you its type.
|
||||
Use it inside your browser or serversided using nodejs.
|
||||
|
||||
The procedure is based on https://en.wikipedia.org/wiki/List_of_file_signatures.
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> A small note on versioning.
|
||||
> Strictly speaking, each new filetype which is supported by this library can break someones' API.
|
||||
> Please note that this library adds new filetypes with minor release.
|
||||
> This means files, which validate to "null" in some versions, may find a result in a new version.
|
||||
>
|
||||
> Or in some cases the library will find more results, than before. So don't depend on the found-array size in
|
||||
> any shape or form.
|
||||
> Filetypes will not be remoevd tho
|
||||
|
||||
# Installation
|
||||
Run `npm install magic-bytes.js`
|
||||
|
||||
|
||||
# Interactive example
|
||||
There is an interactive example present at https://larskoelpin.github.io/magic-bytes/.
|
||||
|
||||
# Usage
|
||||
|
||||
The following functions are available:
|
||||
* `filetypeinfo(bytes: number[])` Contains typeinformation like name, extension and mime type: `[{typename: "zip"}, {typename: "jar"}]`
|
||||
* `filetypename(bytes: number[])` : Contains type names only: `["zip", "jar"]`
|
||||
* `filetypemime(bytes: number[])` : Contains type mime types only: `["application/zip", "application/jar"]`
|
||||
* `filetypeextension(bytes: number[])` : Contains type extensions only: `["zip", "jar"]`
|
||||
|
||||
Both function return an empty array `[]` otherwise, which means it could not detect the file signature. Keep in mind that
|
||||
txt files for example fall in this category.
|
||||
|
||||
You don't have to load the whole file in memory. For validating a file uploaded to S3 using Lambda for example, it may be
|
||||
enough to load the files first 100 bytes and validate against them. This is especially useful for big files.
|
||||
|
||||
see examples for practical usage.
|
||||
|
||||
On server:
|
||||
```javascript
|
||||
import filetype from 'magic-bytes.js'
|
||||
|
||||
filetype(fs.readFileSync("myimage.png")) // ["png"]
|
||||
```
|
||||
|
||||
|
||||
To run an HTML-Example checkout the project and run
|
||||
|
||||
```
|
||||
npm install; npm run example
|
||||
```
|
||||
|
||||
This opens an HTML example using magic bytes as a window variable. It kinda looks like that.
|
||||
|
||||
```html
|
||||
<input type="file" id="file" />
|
||||
|
||||
<script src="node_modules/magic-bytes.js/dist/browser.js" type="application/javascript"></script>
|
||||
<script>
|
||||
document.getElementById("file").addEventListener('change', (event, x) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onloadend = (f) => {
|
||||
const bytes = new Uint8Array(f.target.result);
|
||||
console.log("Possible filetypes: " + filetypeinfo(bytes))
|
||||
}
|
||||
fileReader.readAsArrayBuffer(event.target.files[0])
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
# Tests
|
||||
Run `npm test`
|
||||
|
||||
# Example
|
||||
See examples/
|
||||
|
||||
# How does it work
|
||||
The `create-snapshot.js` creates a new tree. The tree has a similar shape to the following
|
||||
```json
|
||||
{
|
||||
"0x47": {
|
||||
"0x49": {
|
||||
"0x46": {
|
||||
"0x38": {
|
||||
"0x37": {
|
||||
"0x61": {
|
||||
"matches": [
|
||||
{
|
||||
"typename": "gif",
|
||||
"mime": "image/gif",
|
||||
"extension": "gif"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
It acts as a giant lookup map for the given byte signatures.
|
||||
1
example_bot/node_modules/magic-bytes.js/commitlint.config.js
generated
vendored
Normal file
1
example_bot/node_modules/magic-bytes.js/commitlint.config.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {extends: ['@commitlint/config-conventional']}
|
||||
5
example_bot/node_modules/magic-bytes.js/jest.config.js
generated
vendored
Normal file
5
example_bot/node_modules/magic-bytes.js/jest.config.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
72
example_bot/node_modules/magic-bytes.js/package.json
generated
vendored
Normal file
72
example_bot/node_modules/magic-bytes.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "magic-bytes.js",
|
||||
"version": "1.5.0",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"release": {
|
||||
"branches": [
|
||||
"master"
|
||||
],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github",
|
||||
"@semantic-release/git"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"prettier": "prettier --write \"{src,__{tests,mocks}__}/**/*.{tsx,ts}\"",
|
||||
"pre-test": "jest --clear-cache",
|
||||
"test": "jest",
|
||||
"build": "tsc",
|
||||
"example:html": "webpack --config example/html/webpack.config.js; open example/html/index.html",
|
||||
"example:webapp": "vite --config example/webapp/vite.config.js example/webapp",
|
||||
"build:example:webapp": "vite --config example/webapp/vite.config.js build example/webapp",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/LarsKoelpin/magic-bytes",
|
||||
"type": "git"
|
||||
},
|
||||
"author": "Lars Kölpin",
|
||||
"license": "MIT",
|
||||
"description": "Detect Filetype by bytes",
|
||||
"keywords": [
|
||||
"magic-bytes",
|
||||
"mime",
|
||||
"filetype",
|
||||
"file",
|
||||
"extension",
|
||||
"magic byte",
|
||||
"magic number",
|
||||
"mime",
|
||||
"mimetype",
|
||||
"validation",
|
||||
"javascript",
|
||||
"upload"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/preset-typescript": "^7.15.0",
|
||||
"@changesets/cli": "^2.16.0",
|
||||
"@commitlint/cli": "^17.7.1",
|
||||
"@commitlint/config-conventional": "^17.7.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.6.2",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^27.0.6",
|
||||
"open": "^9.1.0",
|
||||
"prettier": "^2.6.1",
|
||||
"prettier-plugin-organize-imports": "^2.3.4",
|
||||
"regenerator-runtime": "^0.11.1",
|
||||
"semantic-release": "^22.0.5",
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-loader": "^9.4.4",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.3.5",
|
||||
"vite": "^4.4.9",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
}
|
||||
78
example_bot/node_modules/magic-bytes.js/tsconfig.json
generated
vendored
Normal file
78
example_bot/node_modules/magic-bytes.js/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
||||
"lib": [
|
||||
"ES2020"
|
||||
] /* Specify library files to be included in the compilation. */,
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
||||
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
||||
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
|
||||
"sourceMap": false /* Generates corresponding '.map' file. */,
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
"types": [
|
||||
"node",
|
||||
"jest"
|
||||
] /* Type declaration files to be included in compilation. */,
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user