{"id":21293217,"url":"https://github.com/guest271314/webbundle","last_synced_at":"2025-07-11T16:32:26.156Z","repository":{"id":210536333,"uuid":"726807805","full_name":"guest271314/webbundle","owner":"guest271314","description":"Web Bundle and Isolated Web App experiments","archived":false,"fork":false,"pushed_at":"2024-04-03T02:09:33.000Z","size":156,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-03T03:24:24.969Z","etag":null,"topics":["direct-sockets","isolated-web-apps","webbundle","webcryptography-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guest271314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-03T13:16:30.000Z","updated_at":"2024-03-15T13:40:48.000Z","dependencies_parsed_at":"2023-12-03T14:25:40.499Z","dependency_job_id":"66fe193e-4d0a-45a3-9c27-97fc0a3340f8","html_url":"https://github.com/guest271314/webbundle","commit_stats":null,"previous_names":["guest271314/webbundle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2Fwebbundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2Fwebbundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2Fwebbundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2Fwebbundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guest271314","download_url":"https://codeload.github.com/guest271314/webbundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225741166,"owners_count":17516895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["direct-sockets","isolated-web-apps","webbundle","webcryptography-api"],"created_at":"2024-11-21T13:53:45.889Z","updated_at":"2025-07-11T16:32:26.147Z","avatar_url":"https://github.com/guest271314.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### webbundle\nWeb Bundle and Isolated Web App experiments\n\n### Install dependencies\n\n#### Fetch dependencies using `package.json`\n\n```\nbun install\n```\n\nor \n\n```\nnpm install\n```\n\n#### Programmatically create `node_modules` folder and add `wbn-sign-webcrypto` to the folder from the GitHub repository\n\n```\ndeno run -A deno_install.js\n```\n\n#### Dynamically fetch dependencies without creating a `node_modules` folder and create the `.swbn` file and IWA.\n\n```\ndeno run -A --unstable-byonm --import-map=deno.json index.js\n```\n\n### Signed Web Bundle/Isolated Web App source files\n\nEntry point is `assets` directory; contains `manifest.webmanifest`, `index.html`, `script.js` and any other scripts or resources to be bundled. \n\n### Generate private and public keys, write to file system \n\nThis only has to be done once.\n\n```\nnode --experimental-default-type=module generateWebCryptoKeys.js\n```\n\n### Build the Signed Web Bundle and Isolated Web App\n\nWrite `signed.swbn` to current directory\n\nNode.js \n```\nnode --experimental-default-type=module index.js\n```\n\nBun\n```\nbun run index.js\n```\n\nDeno\n```\ndeno run --unstable-byonm -A index.js\n```\n\n### Install Isolated Web App using Signed Web Bundle\n\nNavigate to `chrome://web-app-internals/`, click `Select file...` and select `signed.swbn`.\n\n### Build/rebuild `wbn-bundle.js` from `src/index.ts` with `bun`\n\n```\ntry {\n  console.log(\n    await Bun.build({\n      entrypoints: [\"./src/index.ts\"],\n      outdir: \".\",\n      sourcemap: \"external\",\n      splitting: false,\n      target: \"bun\" // or \"node\"\n      format: \"esm\",\n      // minify: true,\n      external: [\"mime\", \"base32-encode\", \"wbn-sign-webcrypto\", \"wbn\"],\n      naming: {\n        entry: \"[dir]/wbn-bundle.[ext]\",\n      },\n    }),\n  );\n} catch (e) {\n  console.log(e);\n}\n```\n\n### Dynamically build/rebuild `wbn-bundle.js` from `src/index.ts` with `esbuild` and run\n\n```\n// import bundleIsolatedWebApp from \"./wbn-bundle.js\";\nimport * as esbuild from \"esbuild\";\n\n// Deno-specific workaround for dynamic imports. \nconst dynamicImport = \"./wbn-bundle.js\";\n\nawait esbuild.build({\n  entryPoints: [\"src/index.ts\"],\n  platform: \"node\",\n  outfile: dynamicImport,\n  format: \"esm\",\n  packages: \"external\",\n  legalComments: \"inline\",\n  sourcemap: true,\n  bundle: true,\n  keepNames: true,\n  allowOverwrite: true,\n});\n\n// https://github.com/denoland/deno/issues/20945\n// \"\" + \"/path\" and \"/path\" + \"\": Deno-specific workaround to avoid module not found error\n const { default: bundleIsolatedWebApp } = await import(dynamicImport);\n```\n\n### Compile `index.js` to a standalone executable\n\n#### Deno \nNote, this is possible using Deno without `node_modules` in the current directory, using the import map in `deno.json`. `deno` creates a `node_modules` folder, fetches and populate with the compile dependencies `@types/node`, `undici-types`, then compiles and outputs the self-contained executable, 96.8 MB (after `strip deno`).\n\n```\n deno compile -A --output deno_webbundle ./index.js\n\n```\n#### Bun\n\nWhen `node_modules` populated with dependencies, creates a 89.1 MB (after `strip bun`) standalone binary.\n\n```\nbun build ./index.js --compile --outfile=bun_webbundle\n\n```\n\n## Examples\n\n- [telnet-client](https://github.com/guest271314/telnet-client)\n- [direct-sockets-http-ws-server](https://github.com/guest271314/direct-sockets-http-ws-server)\n\n\n### TODO\n\n- This should work in the browser.\n- Install and run using `deno` without needing to run import the dynamically created bundle `wbn-bundle.js` twice; the first run throwing module not found error. For now generate and import the bundle twice; the first dynamic import in `deno_install.js`, catching the error, to avoid the error for first run being thrown in `rollup.wbn.js` which generates the `signed.swbn` file. Completed (see [this commit](https://github.com/guest271314/webbundle/commit/1623ecb09d12464234f2b17d888e66f652acdb07)).\n- Install [`wbn-sign-webcrypto`](https://github.com/guest271314/wbn-sign-webcrypto) dependency from GitHub repository using `deno`. Completed.\n- Substitute Web Cryptography API for `node:crypto`. Completed.\n\n\n### License\nDo What the Fuck You Want to Public License [WTFPLv2](http://www.wtfpl.net/about/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguest271314%2Fwebbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguest271314%2Fwebbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguest271314%2Fwebbundle/lists"}