Typescriptify & use service worker for MSC3916 authentication (#27326)

* Typescriptify & use service worker for MSC3916 authentication

* appease the linter

* appease jest

* appease linter

* Get the access token directly

* Add a bit of jitter

* Improve legibility, use factored-out functions for pickling

* Add docs

* Appease the linter

* Document risks of postMessage

* Split service worker post message handling out to function

* Move registration to async function

* Use more early returns

* Thanks(?), WebStorm

* Handle case of no access token for /versions

* Appease linter

* Apply suggestions from code review

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Remove spurious try/catch

* Factor out fetch config stuff

* Apply suggestions from code review

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Finish applying code review suggestions

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Travis Ralston 2024-05-14 13:17:38 -06:00 committed by GitHub
parent 482b81b0ed
commit bcd5c838e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 227 additions and 7 deletions

View file

@ -153,6 +153,10 @@ module.exports = (env, argv) => {
mobileguide: "./src/vector/mobile_guide/index.ts",
jitsi: "./src/vector/jitsi/index.ts",
usercontent: "./node_modules/matrix-react-sdk/src/usercontent/index.ts",
serviceworker: {
import: "./src/serviceworker/index.ts",
filename: "sw.js", // update WebPlatform if this changes
},
...(useHMR ? {} : cssThemes),
},
@ -666,7 +670,7 @@ module.exports = (env, argv) => {
// HtmlWebpackPlugin will screw up our formatting like the names
// of the themes and which chunks we actually care about.
inject: false,
excludeChunks: ["mobileguide", "usercontent", "jitsi"],
excludeChunks: ["mobileguide", "usercontent", "jitsi", "serviceworker"],
minify: false,
templateParameters: {
og_image_url: ogImageUrl,
@ -740,7 +744,6 @@ module.exports = (env, argv) => {
"res/jitsi_external_api.min.js",
"res/jitsi_external_api.min.js.LICENSE.txt",
"res/manifest.json",
"res/sw.js",
"res/welcome.html",
{ from: "welcome/**", context: path.resolve(__dirname, "res") },
{ from: "themes/**", context: path.resolve(__dirname, "res") },