Repository: nyariv/SandboxJS Branch: main Commit: 826865251232 Files: 140 Total size: 761.5 KB Directory structure: gitextract_tkgsxi77/ ├── .github/ │ └── workflows/ │ ├── deploy.yml │ ├── npm-publish.yml │ ├── shields.yml │ └── test.yml ├── .gitignore ├── .husky/ │ └── pre-commit ├── .npmignore ├── .prettierignore ├── .prettierrc ├── .vscode/ │ └── settings.json ├── LICENSE ├── README.md ├── TODO.md ├── css/ │ └── style.css ├── eslint.config.js ├── index.html ├── jest.config.js ├── package.json ├── scripts/ │ ├── build.mjs │ └── export-tests.ts ├── src/ │ ├── Sandbox.ts │ ├── SandboxExec.ts │ ├── eval/ │ │ └── index.ts │ ├── executor/ │ │ ├── executorUtils.ts │ │ ├── index.ts │ │ ├── ops/ │ │ │ ├── assignment.ts │ │ │ ├── call.ts │ │ │ ├── comparison.ts │ │ │ ├── control.ts │ │ │ ├── functions.ts │ │ │ ├── index.ts │ │ │ ├── literals.ts │ │ │ ├── misc.ts │ │ │ ├── object.ts │ │ │ ├── prop.ts │ │ │ ├── unary.ts │ │ │ └── variables.ts │ │ └── opsRegistry.ts │ ├── parser/ │ │ ├── index.ts │ │ ├── lisp.ts │ │ ├── lispTypes/ │ │ │ ├── conditionals.ts │ │ │ ├── control.ts │ │ │ ├── declarations.ts │ │ │ ├── index.ts │ │ │ ├── operators.ts │ │ │ ├── shared.ts │ │ │ ├── structures.ts │ │ │ └── values.ts │ │ └── parserUtils.ts │ └── utils/ │ ├── CodeString.ts │ ├── ExecContext.ts │ ├── Prop.ts │ ├── Scope.ts │ ├── errors.ts │ ├── functionReplacements.ts │ ├── index.ts │ ├── types.ts │ └── unraw.ts ├── test/ │ ├── audit.spec.ts │ ├── compileRerun.spec.ts │ ├── delaySynchronousResult.spec.ts │ ├── eval/ │ │ ├── README.md │ │ ├── reveseLinkedList.js │ │ ├── script.js │ │ ├── testCases/ │ │ │ ├── arithmetic-operators.data.ts │ │ │ ├── arithmetic-operators.spec.ts │ │ │ ├── assignment-operators.data.ts │ │ │ ├── assignment-operators.spec.ts │ │ │ ├── bitwise-operators.data.ts │ │ │ ├── bitwise-operators.spec.ts │ │ │ ├── comments.data.ts │ │ │ ├── comments.spec.ts │ │ │ ├── comparison-operators.data.ts │ │ │ ├── comparison-operators.spec.ts │ │ │ ├── complex-expressions.data.ts │ │ │ ├── complex-expressions.spec.ts │ │ │ ├── conditionals.data.ts │ │ │ ├── conditionals.spec.ts │ │ │ ├── data-types.data.ts │ │ │ ├── data-types.spec.ts │ │ │ ├── defaults.data.ts │ │ │ ├── defaults.spec.ts │ │ │ ├── destructuring.data.ts │ │ │ ├── destructuring.spec.ts │ │ │ ├── error-handling.data.ts │ │ │ ├── error-handling.spec.ts │ │ │ ├── function-replacements.data.ts │ │ │ ├── function-replacements.spec.ts │ │ │ ├── functions.data.ts │ │ │ ├── functions.spec.ts │ │ │ ├── generators.data.ts │ │ │ ├── generators.spec.ts │ │ │ ├── index.ts │ │ │ ├── logical-operators.data.ts │ │ │ ├── logical-operators.spec.ts │ │ │ ├── loops.data.ts │ │ │ ├── loops.spec.ts │ │ │ ├── objects-and-arrays.data.ts │ │ │ ├── objects-and-arrays.spec.ts │ │ │ ├── operator-precedence.data.ts │ │ │ ├── operator-precedence.spec.ts │ │ │ ├── other-operators.data.ts │ │ │ ├── other-operators.spec.ts │ │ │ ├── security.data.ts │ │ │ ├── security.spec.ts │ │ │ ├── switch.data.ts │ │ │ ├── switch.spec.ts │ │ │ ├── syntax-errors.data.ts │ │ │ ├── syntax-errors.spec.ts │ │ │ ├── template-literals.data.ts │ │ │ ├── template-literals.spec.ts │ │ │ ├── test-utils.ts │ │ │ └── types.ts │ │ └── tests.json │ ├── evalCompletionValue.spec.ts │ ├── expression.spec.ts │ ├── parse.spec.ts │ ├── performance.mjs │ ├── sandboxErrorCatch.spec.ts │ ├── sandboxRestrictions.spec.ts │ ├── semicolonInsertion.spec.ts │ ├── subscriptions.spec.ts │ ├── symbol.spec.ts │ ├── taggedTemplateEscaping.spec.ts │ ├── ticks/ │ │ ├── sandboxArrayTicks.spec.ts │ │ ├── sandboxCollectionTicks.spec.ts │ │ ├── sandboxNativeTicks.spec.ts │ │ ├── sandboxObjectTicks.spec.ts │ │ ├── sandboxSpreadTicks.spec.ts │ │ └── sandboxStringTicks.spec.ts │ ├── ticksQuotaHalt.spec.ts │ ├── timers.spec.ts │ ├── timersAsync.spec.ts │ ├── timersAsyncHalt.spec.ts │ ├── timersHalt.spec.ts │ ├── tryFinallyControlFlow.spec.ts │ ├── tsconfig.json │ └── unraw.spec.ts ├── tsconfig.jest.json └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/deploy.yml ================================================ name: Deploy to GitHub Pages on: push: branches: - main jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22' - name: Install dependencies run: npm install - name: Build project run: npm run build - name: Prepare deployment directory run: | mkdir pages cp -r dist pages/ cp -r test pages/ cp -r css pages/ cp index.html pages/ cp logo.svg pages/ - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./pages ================================================ FILE: .github/workflows/npm-publish.yml ================================================ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages name: Node.js Package on: # release: # types: [create] push: branches: - main jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - run: npm install - run: npm run build - run: npm test publish-npm: needs: test runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 registry-url: https://registry.npmjs.org/ - run: npm install - run: npm run build - run: npm publish --access public --provenance ================================================ FILE: .github/workflows/shields.yml ================================================ name: Shield badges on: push: branches: [main] jobs: bundle-size: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - run: npm install - run: npm run build - name: Measure bundle size (gzip) id: size run: | BYTES=$(gzip -9 -c dist/umd/Sandbox.min.js | wc -c) echo "bytes=$BYTES" >> $GITHUB_OUTPUT - name: Format size id: fmt run: | python3 -c " b = ${{ steps.size.outputs.bytes }} if b >= 1024*1024: s = f'{b/1024/1024:.1f} MB' elif b >= 1024: s = f'{b/1024:.1f} kB' else: s = f'{b} B' print('size=' + s) " >> $GITHUB_OUTPUT - name: Update Gist badge uses: schneegans/dynamic-badges-action@v1.7.0 with: auth: ${{ secrets.GIST_TOKEN }} gistID: dd4a46f4c2fff1c43d4f2e8fb4b52862 filename: bundle-size.json label: minified (gzip) message: ${{ steps.fmt.outputs.size }} color: blue tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - run: npm install - name: Run tests with JSON reporter id: test run: | NODE_OPTIONS='--no-warnings=ExperimentalWarning' npx jest --json --outputFile=jest-results.json || true - name: Extract test counts id: counts run: | python3 -c " import json with open('jest-results.json') as f: data = json.load(f) passed = data['numPassedTests'] total = data['numTotalTests'] print(f'passed={passed}') print(f'total={total}') print(f'message={passed}/{total}') color = '#439e2e' if passed == total else 'red' print(f'color={color}') " >> $GITHUB_OUTPUT - name: Update Gist badge uses: schneegans/dynamic-badges-action@v1.7.0 with: auth: ${{ secrets.GIST_TOKEN }} gistID: dd4a46f4c2fff1c43d4f2e8fb4b52862 filename: tests.json label: passing tests message: ${{ steps.counts.outputs.message }} color: ${{ steps.counts.outputs.color }} sandbox-badge: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - name: Prepare sandbox badge id: sandbox_badge run: | # collapse SVG to a single line svg_inline="$(tr -d '\n' < ./logo.svg)" echo "message=Sandbox protected" >> "$GITHUB_OUTPUT" echo "color=#202830" >> "$GITHUB_OUTPUT" echo "label=" >> "$GITHUB_OUTPUT" echo "logoSvg=${svg_inline}" >> "$GITHUB_OUTPUT" - name: Update Gist badge uses: schneegans/dynamic-badges-action@v1.7.0 with: auth: ${{ secrets.GIST_TOKEN }} gistID: dd4a46f4c2fff1c43d4f2e8fb4b52862 filename: sandbox-protected.json label: ${{ steps.sandbox_badge.outputs.label }} message: ${{ steps.sandbox_badge.outputs.message }} color: ${{ steps.sandbox_badge.outputs.color }} logoSvg: ${{ steps.sandbox_badge.outputs.logoSvg }} ================================================ FILE: .github/workflows/test.yml ================================================ name: Run Tests on: push: branches: - main pull_request: branches: - '**' # Optional: also run on PRs jobs: test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22' - name: Install dependencies run: npm install - name: Run lint run: npm run lint - name: Run tests run: npm test - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: files: ./coverage/lcov.info fail_ci_if_error: false token: ${{ secrets.CODECOV_TOKEN }} performance: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22' - name: Install dependencies run: npm install - name: Build run: npm run build - name: Run performance tests run: npm run test:perf ================================================ FILE: .gitignore ================================================ node_modules/ dist/ build/ coverage/ ================================================ FILE: .husky/pre-commit ================================================ npx lint-staged ================================================ FILE: .npmignore ================================================ node_modules/ .github/ .gitignore .git/ .vscode/ .husky .claude js/ test/ css/ src/ index.html tsconfig.json rollup.config.mjs .eslintrc.json .prettierrc jest.config.js tsconfig.jest.json package-lock.json ================================================ FILE: .prettierignore ================================================ # Dependencies node_modules # Build outputs dist build coverage # Minified files *.min.js # Configuration files rollup.config.mjs jest.config.js # Test files that should be ignored test/eval/jquery.min.js ================================================ FILE: .prettierrc ================================================ { "printWidth": 100, "singleQuote": true } ================================================ FILE: .vscode/settings.json ================================================ { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true } ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 nyariv 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. ================================================ FILE: README.md ================================================ [](https://github.com/nyariv/SandboxJS/blob/main/LICENSE)   [](https://github.com/nyariv/SandboxJS/issues) [](https://codecov.io/gh/nyariv/SandboxJS) [](https://nyariv.github.io/SandboxJS/) [](https://github.com/nyariv/SandboxJS) ---
|  |
SandboxJSSafe eval runtime |
Tests compare SandboxJS against a proxied eval. A global bypassed flag is set to true if a test escapes the sandbox — highlighted in red. Blocked bypasses show as Error.