--- description: AnyClip integration tools - use Bun, understand the scripts globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json" alwaysApply: true --- # Project: AnyClip Integration Tools for integrating with AnyClip's Video Manager API and extracting source code from sourcemaps. ## Key Scripts | Script | Purpose | |--------|---------| | `scripts/auth.ts` | Authenticate with AnyClip, returns session cookies | | `scripts/crypto-subtle.ts` | Password encryption (AES-256-GCM, matches AnyClip's client) | | `scripts/update-urls.ts` | Fetch JS URLs from build manifest → urls.txt | | `scripts/download-sourcemaps.ts` | Download .map files for URLs in urls.txt | | `scripts/extract-sources.ts` | Extract source from sourcemaps → anyclip/ | ## Authentication Flow 1. Password encrypted client-side with AES-256-GCM (salt: `$2b$04$wwky7rvtr6BFNaCqntwyie`) 2. POST to `videomanager-api.anyclip.com/public/auth/login` → returns `anyclip_2020` cookie + JWT 3. POST to `videomanager.anyclip.com/api/auth/login` → returns `session` cookie 4. Both cookies required for authenticated requests ## Source Extraction Workflow ```bash bun scripts/update-urls.ts # Scrape build manifest for JS URLs bun scripts/download-sourcemaps.ts # Download .map files bun scripts/extract-sources.ts # Extract to anyclip/ ``` ## Directory Structure - `anyclip/` - Extracted source (committed) - `sourcemaps/` - Raw .map files (gitignored) - `urls.txt` - JS URLs to download - `session.json` - Auth session (gitignored) --- # Bun Usage Default to using Bun instead of Node.js. - Use `bun ` instead of `node ` or `ts-node ` - Use `bun test` instead of `jest` or `vitest` - Use `bun build ` instead of `webpack` or `esbuild` - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` - Use `bun run ``` With the following `frontend.tsx`: ```tsx#frontend.tsx import React from "react"; import { createRoot } from "react-dom/client"; // import .css files directly and it works import './index.css'; const root = createRoot(document.body); export default function Frontend() { return

Hello, world!

; } root.render(); ``` Then, run index.ts ```sh bun --hot ./index.ts ``` For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.