Fixed the SPA authentication flow
This commit is contained in:
@@ -8,6 +8,7 @@ const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
const contentScript = composition.composeScript("content");
|
||||
const backgroundScript = composition.composeScript("background");
|
||||
const spaPageScript = composition.composeScript("spa-page");
|
||||
const checkOnly = process.argv.includes("--check");
|
||||
|
||||
const baseManifest = {
|
||||
@@ -35,6 +36,12 @@ const baseManifest = {
|
||||
js: ["content.js"],
|
||||
all_frames: true,
|
||||
run_at: "document_idle"
|
||||
},
|
||||
{
|
||||
matches: ["https://spa.oracle.com/*"],
|
||||
js: ["spa-page.js"],
|
||||
all_frames: false,
|
||||
run_at: "document_idle"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -70,7 +77,7 @@ for (const target of targets) {
|
||||
JSON.parse(manifestJson);
|
||||
|
||||
if (checkOnly) {
|
||||
const expected = { "manifest.json": manifestJson, "content.js": contentScript, "background.js": backgroundScript };
|
||||
const expected = { "manifest.json": manifestJson, "content.js": contentScript, "background.js": backgroundScript, "spa-page.js": spaPageScript };
|
||||
for (const [file, contents] of Object.entries(expected)) {
|
||||
const actual = await readFile(path.join(distDir, target.name, file), "utf8");
|
||||
if (actual !== contents) throw new Error(`Stale output: dist/${target.name}/${file}. Run npm run build.`);
|
||||
@@ -82,6 +89,7 @@ for (const target of targets) {
|
||||
await mkdir(outputDir, { recursive: true });
|
||||
await output.writeOutput(path.join(outputDir, "content.js"), contentScript);
|
||||
await output.writeOutput(path.join(outputDir, "background.js"), backgroundScript);
|
||||
await output.writeOutput(path.join(outputDir, "spa-page.js"), spaPageScript);
|
||||
await output.writeOutput(path.join(outputDir, "manifest.json"), manifestJson);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ function composeScript(target, { bootstrap = true } = {}) {
|
||||
.map(file => fs.readFileSync(path.join(root, file), "utf8")).join("\n");
|
||||
parts.unshift(`const redwoodStyles = ${JSON.stringify(css)};`);
|
||||
}
|
||||
const factory = target === "content" ? "createContentApplication" : "createBackgroundApplication";
|
||||
const factory = { content: "createContentApplication", background: "createBackgroundApplication", "spa-page": "createSpaPage" }[target];
|
||||
const ending = bootstrap ? `${factory}().start();` : `return ${factory};`;
|
||||
const output = `(function () {\n "use strict";\n${parts.join("\n")}\n${ending}\n})();\n`;
|
||||
new vm.Script(output, { filename: `${target}.js` });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
"spa-page": ["src/auth/spa-page.js"],
|
||||
"content": [
|
||||
"src/shared/time-dates.js",
|
||||
"src/features/manage-time/view.js",
|
||||
@@ -107,6 +108,7 @@ module.exports = {
|
||||
"src/services/fusion/sr-details.js",
|
||||
"src/services/fusion/sr-create.js",
|
||||
"src/services/spa/current-user.js",
|
||||
"src/services/spa/page-client.js",
|
||||
"src/services/spa/consumption.js",
|
||||
"src/services/spa/response-shapes.js",
|
||||
"src/services/http/background-json.js",
|
||||
|
||||
Reference in New Issue
Block a user