|
| 1 | +## Prerequisites |
| 2 | + |
| 3 | +- Google Chrome 120+ |
| 4 | + |
| 5 | +- openssl |
| 6 | + |
| 7 | +- npm |
| 8 | + |
| 9 | +## Using this repository |
| 10 | + |
| 11 | +Clone this repository: |
| 12 | + |
| 13 | + git clone ADD_LINK_HERE |
| 14 | + |
| 15 | + cd iwa_vite_template |
| 16 | + |
| 17 | + npm install |
| 18 | + |
| 19 | +Open Google Chrome, go to `chrome://flags` and enable |
| 20 | + |
| 21 | + chrome://flags/#enable-isolated-web-app-dev-mode |
| 22 | + |
| 23 | + chrome://flags/#enable-isolated-web-apps |
| 24 | + |
| 25 | +Once enabled, and chrome is restarted, go to `chrome://web-app-internals`, the web app internals |
| 26 | +page. This page shows you the web apps you have installed, including Isolated Web Apps and |
| 27 | +Progressive Web Apps, with details for each. |
| 28 | + |
| 29 | +You'll know everything is correct if you see the "Isolated Web Apps" section at the top of the page. |
| 30 | + |
| 31 | +### Installing the IWA through the dev proxy |
| 32 | + |
| 33 | +Run: |
| 34 | + |
| 35 | +`npm run dev` |
| 36 | + |
| 37 | +Then, navigate to: |
| 38 | + |
| 39 | +`chrome://web-app-internals` |
| 40 | + |
| 41 | +Look for a field called "Install IWA via Dev Mode Proxy", type in your localhost url, then click |
| 42 | +Install |
| 43 | + |
| 44 | +If everything installed correctly, you should see |
| 45 | + |
| 46 | +Installing IWA: http://localhost:PORT/ successfully installed |
| 47 | + |
| 48 | +Congratulations! You have installed your very own isolated web app |
| 49 | + |
| 50 | +_Note: If your development server shuts down or is unreachable, you won't be able to access or |
| 51 | +install your Isolated Web App_ |
| 52 | + |
| 53 | +### Installing the IWA through a Signed Web Bundle |
| 54 | + |
| 55 | +If you want to install your IWA through a .swbn file, you will need to generate a signing key, use |
| 56 | +openssl to generate and encrypt a Ed25519 or ECDSA P-256 key |
| 57 | + |
| 58 | + #Generate an unencrypted Ed25519 key |
| 59 | + |
| 60 | + openssl genpkey -algorithm Ed25519 -out private_key.pem |
| 61 | + |
| 62 | + #Or Generate an unencrypted ECDSA P-256 key |
| 63 | + |
| 64 | + openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem |
| 65 | + |
| 66 | + #Encrypt the private key. Using a strong passphrase (which you will be |
| 67 | + #prompted for) is highly recommended to protect the key from unauthorized |
| 68 | + #use if the file is ever compromised. |
| 69 | + |
| 70 | + openssl pkcs8 -in private_key.pem -topk8 -out encrypted_key.pem |
| 71 | + |
| 72 | + #Remove the unencrypted key |
| 73 | + |
| 74 | + rm private_key.pem |
| 75 | + |
| 76 | +Next, create a .env file containing: |
| 77 | + |
| 78 | + PRIVATE_KEY_PATH='PATH_TO_YOUR_ENCRYPTED_KEY' |
| 79 | + PRIVATE_KEY_PASSWORD='YOUR_KEY_PASSWORD' |
| 80 | + NODE_ENV='YOUR_ENVIROMENT_MODE' |
| 81 | + PORT=YOUR_PORT |
| 82 | + |
| 83 | +_Note: NODE_ENV must be set to 'production' to make the build run._ |
| 84 | + |
| 85 | +_Note: If you don't specify PORT, the app will fall back to default value (4321)_ |
| 86 | + |
| 87 | +Next, you need to build your IWA by running |
| 88 | + |
| 89 | + npm run build |
| 90 | + |
| 91 | +This process will generate: |
| 92 | + |
| 93 | +- A .swbn file named iwa-template.swbn in the /dist folder. |
| 94 | +- Your Web Bundle ID, displayed in the terminal |
| 95 | + |
| 96 | +Navigate to `chrome://web-app-internals`, look for "Install IWA from Signed Web Bundle" field, click |
| 97 | +"Select File", upload your .swbn file. |
| 98 | + |
| 99 | +If everything went correctly, you should see a field: |
| 100 | + |
| 101 | +Installing IWA: successfully installed (Web Bundle ID: |
| 102 | +slu74sbybztfypa43w7f7rd34cbhautjcrfegz5lbow7vmwjojbqaaic). |
| 103 | + |
| 104 | +_Note: Your web bundle ID will look differently, this is just an example_ |
| 105 | + |
| 106 | +Since IWA are using a different schema `isolated-app://` instead of `https://`, you can access it by |
| 107 | +pasting `isolated-app://your-web-bundle-id` in Chrome, or by running it like any other app on your |
| 108 | +computer. |
| 109 | + |
| 110 | +### Personalizing this template |
| 111 | + |
| 112 | +- How do I change the icon? |
| 113 | + |
| 114 | +Navigate to /public/images/, change icon file, and update /public/.well-known/manifest.webmanifest |
| 115 | +"icons" field accordingly. |
| 116 | + |
| 117 | +_Note: Isolated Web Apps require at least one icon of 144x144px size._ |
| 118 | + |
| 119 | +Related information: |
| 120 | +[Define your app icons - MDN Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/How_to/Define_app_icons) |
| 121 | + |
| 122 | +- Updating the Manifest |
| 123 | + |
| 124 | +Isolated Web Apps share the same |
| 125 | +[Manifest Properties](https://web.dev/articles/add-manifest#manifest-properties) as Progressive Web |
| 126 | +Apps, with some slight variations, see: |
| 127 | +[Isolated Web Apps explainer - Web App manifest section](https://chromeos.dev/en/web/isolated-web-apps) |
| 128 | + |
| 129 | +There are two fields that should be included, `version` and `update_manifest_url` |
| 130 | + |
| 131 | +1. `version` - Required for Isolated Web Apps. A string consisting of one or more integers separated |
| 132 | + by a dot (.). Your version can be something simple like 1, 2, 3, etc…, or something complex like |
| 133 | + [SemVer](https://semver.org/) (1.2.3). |
| 134 | + |
| 135 | +2. `update_manifest_url` - Optional, but recommended field that points to an HTTPS URL (or localhost |
| 136 | + for testing) where a Web Application Update Manifest can be retrieved. |
| 137 | + |
| 138 | +- How to add API Permissions? |
| 139 | + |
| 140 | +By default, Chrome blocks all permission requests from IWAs. You can opt-in to permission policies you need by specifying |
| 141 | +a `permissions_policy` field in your manifest. |
| 142 | + |
| 143 | +_Note: Adding a permission here does not automatically grant it, it just makes it avaliable to be |
| 144 | +granted, when a request for that capacity is made._ |
| 145 | + |
| 146 | + #permission policy example |
| 147 | + "permissions_policy": { |
| 148 | + "geolocation": [ "self", "https://map.example.com" ], |
| 149 | + "direct-sockets": ["self"], |
| 150 | + "controlled-frame": ["self"] |
| 151 | + } |
| 152 | + |
| 153 | +Related Information |
| 154 | + |
| 155 | +- [Permissions Policy - MDN Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Permissions_Policy#allowlists) |
| 156 | +- [Permissions Policy header - MDN Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Permissions_Policy#allowlists) |
| 157 | +- [Web Application Manifest - MDN Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest) |
| 158 | + |
| 159 | +### Related Information |
| 160 | + |
| 161 | +- [Isolated Web Apps Explainer](https://chromeos.dev/en/web/isolated-web-apps) |
| 162 | +- [IWA Kitchen Sink](https://github.com/chromeos/iwa-sink) |
| 163 | +- [IWA Telnet Client](https://github.com/GoogleChromeLabs/telnet-client/tree/main) |
| 164 | +- [IWA Smartcard Demo](https://github.com/GoogleChromeLabs/web-smartcard-demo/tree/main) |
0 commit comments