Implementação inicial do Manage time
This commit is contained in:
483
background.js
483
background.js
@@ -5,12 +5,17 @@ const COMCIP_QUERY_URL =
|
|||||||
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live;profile=PROD/services/auth/1.1/proxy/oalsetCRMRestAPIElastic/uri/https/eeho.fa.us2.oraclecloud.com/crmRestApi/searchResources/latest/custom-actions/queries`;
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live;profile=PROD/services/auth/1.1/proxy/oalsetCRMRestAPIElastic/uri/https/eeho.fa.us2.oraclecloud.com/crmRestApi/searchResources/latest/custom-actions/queries`;
|
||||||
const COMCIP_CLIENT_ID_PROBE_URL =
|
const COMCIP_CLIENT_ID_PROBE_URL =
|
||||||
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live;profile=PROD/services/auth/1.1/proxy/oalsetSeaaSOKECustomRestAPI/uri/https/gxpap.oracle.com/oalcrm/service/set/seaas/crm/countries`;
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live;profile=PROD/services/auth/1.1/proxy/oalsetSeaaSOKECustomRestAPI/uri/https/gxpap.oracle.com/oalcrm/service/set/seaas/crm/countries`;
|
||||||
|
const COMCIP_TIME_ENTRY_APP_URL =
|
||||||
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_timeentrymobile/live/webApps/timeentry/`;
|
||||||
|
const COMCIP_TIME_ENTRY_CLIENT_ID_PROBE_URL =
|
||||||
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_timeentrymobile/live;profile=PROD/services/auth/1.1/proxy/oke_seaas/uri/https/gxpap.oracle.com/oalcrm/service/set/seaas/crm/lookups?lookupType=SCTA_TASK_TYPE&type=CUSTOM`;
|
||||||
|
const COMCIP_TIME_ENTRY_APP_VERSION = "version_1774016034953";
|
||||||
const COMCIP_TAB_URL_PATTERN =
|
const COMCIP_TAB_URL_PATTERN =
|
||||||
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live*`;
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live*`;
|
||||||
const COMCIP_TIME_ENTRY_TAB_URL_PATTERN =
|
const COMCIP_TIME_ENTRY_TAB_URL_PATTERN =
|
||||||
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_timeentrymobile/live*`;
|
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_timeentrymobile/live*`;
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||||
if (
|
if (
|
||||||
!message ||
|
!message ||
|
||||||
(message.type !== "ARCH_PANEL_COMCIP_POST" &&
|
(message.type !== "ARCH_PANEL_COMCIP_POST" &&
|
||||||
@@ -24,6 +29,8 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|||||||
method: message.method || "POST",
|
method: message.method || "POST",
|
||||||
payload: message.payload,
|
payload: message.payload,
|
||||||
headers: message.headers,
|
headers: message.headers,
|
||||||
|
senderTabId: sender?.tab?.id,
|
||||||
|
useTimeEntryFrame: Boolean(message.useTimeEntryFrame),
|
||||||
})
|
})
|
||||||
.then(sendResponse)
|
.then(sendResponse)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -37,8 +44,47 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function requestComcipFromPage({ url, method = "POST", payload, headers = {} }) {
|
async function requestComcipFromPage({
|
||||||
|
url,
|
||||||
|
method = "POST",
|
||||||
|
payload,
|
||||||
|
headers = {},
|
||||||
|
senderTabId,
|
||||||
|
useTimeEntryFrame = false,
|
||||||
|
}) {
|
||||||
const route = getComcipRoute(url);
|
const route = getComcipRoute(url);
|
||||||
|
|
||||||
|
if (route.useSenderFrame || useTimeEntryFrame) {
|
||||||
|
if (!senderTabId) {
|
||||||
|
throw new Error("Unable to locate the current dashboard tab for COMCIP Time Entry.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await waitForComcipFrameSessionReady(senderTabId, headers, route);
|
||||||
|
let response = await executeComcipFetchFromFrame(
|
||||||
|
senderTabId,
|
||||||
|
url,
|
||||||
|
method,
|
||||||
|
payload,
|
||||||
|
headers,
|
||||||
|
route
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isAuthorizationFailure(response) || isOutdatedApplicationFailure(response)) {
|
||||||
|
await delay(1500);
|
||||||
|
await waitForComcipFrameSessionReady(senderTabId, headers, route);
|
||||||
|
response = await executeComcipFetchFromFrame(
|
||||||
|
senderTabId,
|
||||||
|
url,
|
||||||
|
method,
|
||||||
|
payload,
|
||||||
|
headers,
|
||||||
|
route
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
const activeTab = await captureActiveTab();
|
const activeTab = await captureActiveTab();
|
||||||
const target = await getComcipTab(route, activeTab);
|
const target = await getComcipTab(route, activeTab);
|
||||||
|
|
||||||
@@ -84,9 +130,11 @@ function getComcipRoute(requestUrl) {
|
|||||||
|
|
||||||
if (normalizedUrl.includes("/ic/builder/rt/oalset_timeentrymobile/live")) {
|
if (normalizedUrl.includes("/ic/builder/rt/oalset_timeentrymobile/live")) {
|
||||||
return {
|
return {
|
||||||
appUrl: normalizedUrl,
|
appUrl: COMCIP_TIME_ENTRY_APP_URL,
|
||||||
clientIdProbeUrl: normalizedUrl,
|
clientIdProbeUrl: COMCIP_TIME_ENTRY_CLIENT_ID_PROBE_URL,
|
||||||
tabPattern: COMCIP_TIME_ENTRY_TAB_URL_PATTERN,
|
tabPattern: COMCIP_TIME_ENTRY_TAB_URL_PATTERN,
|
||||||
|
useSenderFrame: true,
|
||||||
|
appVersion: COMCIP_TIME_ENTRY_APP_VERSION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +147,11 @@ function getComcipRoute(requestUrl) {
|
|||||||
|
|
||||||
async function getComcipTab(route, activeTab) {
|
async function getComcipTab(route, activeTab) {
|
||||||
const tabs = await chrome.tabs.query({ url: route.tabPattern });
|
const tabs = await chrome.tabs.query({ url: route.tabPattern });
|
||||||
const existing = tabs.find((tab) => tab.id && !tab.discarded);
|
const existing = tabs.find((tab) => {
|
||||||
|
const tabUrl = String(tab.url || "");
|
||||||
|
|
||||||
|
return tab.id && !tab.discarded && !tabUrl.includes("/services/");
|
||||||
|
});
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
return {
|
return {
|
||||||
@@ -108,6 +160,12 @@ async function getComcipTab(route, activeTab) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (route.requireExistingTab) {
|
||||||
|
throw new Error(
|
||||||
|
"A sessao COMCIP Time Entry nao esta pronta. Abra/autentique o Time Entry uma vez e tente novamente."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const created = await chrome.tabs.create({
|
const created = await chrome.tabs.create({
|
||||||
url: route.appUrl,
|
url: route.appUrl,
|
||||||
active: false,
|
active: false,
|
||||||
@@ -188,6 +246,113 @@ async function waitForComcipSessionReady(tabId, headers = {}, route) {
|
|||||||
throw new Error(`Timed out while waiting for COMCIP authenticated session (${lastStatus}).`);
|
throw new Error(`Timed out while waiting for COMCIP authenticated session (${lastStatus}).`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForComcipFrameSessionReady(tabId, headers = {}, route) {
|
||||||
|
const startedAt = Date.now();
|
||||||
|
let lastStatus = "";
|
||||||
|
|
||||||
|
while (Date.now() - startedAt < 60000) {
|
||||||
|
const probe = await executeComcipFrameProbe(tabId, headers, route).catch((error) => ({
|
||||||
|
ok: false,
|
||||||
|
status: 0,
|
||||||
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (probe?.ok && probe?.matched) {
|
||||||
|
return probe;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastStatus = probe?.status
|
||||||
|
? `${probe.status} ${probe.statusText || ""}`.trim()
|
||||||
|
: probe?.error || "not ready";
|
||||||
|
await delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
`Timed out while waiting for COMCIP Time Entry frame session (${lastStatus}).`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function executeComcipFrameProbe(tabId, headers = {}, route) {
|
||||||
|
const injectionResults = await chrome.scripting.executeScript({
|
||||||
|
target: { tabId, allFrames: true },
|
||||||
|
world: "MAIN",
|
||||||
|
args: [
|
||||||
|
route?.clientIdProbeUrl || COMCIP_CLIENT_ID_PROBE_URL,
|
||||||
|
headers || {},
|
||||||
|
route?.appVersion || "",
|
||||||
|
],
|
||||||
|
func: async (probeUrl, sourceHeaders, routeAppVersion) => {
|
||||||
|
function isTimeEntryFrame() {
|
||||||
|
const href = String(window.location.href || "");
|
||||||
|
const frameName = String(window.name || "");
|
||||||
|
const isComcipOrigin = href.startsWith(
|
||||||
|
"https://comcipapic-oalprod.integration.ocp.oraclecloud.com/"
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
(frameName === "arch-panel-extension-comcip-timeentry-frame" &&
|
||||||
|
isComcipOrigin) ||
|
||||||
|
href.includes("oalset_timeentrymobile") ||
|
||||||
|
href.includes("/webApps/timeentry")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isTimeEntryFrame()) {
|
||||||
|
return {
|
||||||
|
matched: false,
|
||||||
|
href: window.location.href,
|
||||||
|
frameName: window.name || "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(probeUrl, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
headers: {
|
||||||
|
accept: "*/*",
|
||||||
|
authorization: "Session",
|
||||||
|
"accept-language":
|
||||||
|
sourceHeaders["accept-language"] || navigator.language || "pt-BR",
|
||||||
|
"vb-proxy-header-rest-framework-version": "3",
|
||||||
|
"x-vb-application-version":
|
||||||
|
routeAppVersion || sourceHeaders["x-vb-application-version"] || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
matched: true,
|
||||||
|
ok: response.ok,
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
appBuilderClientId: response.headers.get("x-appbuilder-client-id") || "",
|
||||||
|
href: window.location.href,
|
||||||
|
frameName: window.name || "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const matchedResult = (injectionResults || [])
|
||||||
|
.map((item) => item.result)
|
||||||
|
.find((result) => result?.matched);
|
||||||
|
|
||||||
|
if (!matchedResult) {
|
||||||
|
const frameHints = (injectionResults || [])
|
||||||
|
.map((item) => item.result)
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((result) => result.href || result.frameName || "unknown")
|
||||||
|
.slice(0, 5)
|
||||||
|
.join(" | ");
|
||||||
|
throw new Error(
|
||||||
|
`COMCIP Time Entry frame was not found in the dashboard tab.${
|
||||||
|
frameHints ? ` Frames: ${frameHints}` : ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchedResult;
|
||||||
|
}
|
||||||
|
|
||||||
async function executeComcipProbe(tabId, headers = {}, route) {
|
async function executeComcipProbe(tabId, headers = {}, route) {
|
||||||
const [injectionResult] = await chrome.scripting.executeScript({
|
const [injectionResult] = await chrome.scripting.executeScript({
|
||||||
target: { tabId },
|
target: { tabId },
|
||||||
@@ -236,13 +401,15 @@ async function executeComcipFetch(tabId, requestUrl, method, payload, headers, r
|
|||||||
payload || null,
|
payload || null,
|
||||||
headers || {},
|
headers || {},
|
||||||
route?.clientIdProbeUrl || COMCIP_CLIENT_ID_PROBE_URL,
|
route?.clientIdProbeUrl || COMCIP_CLIENT_ID_PROBE_URL,
|
||||||
|
route?.appVersion || "",
|
||||||
],
|
],
|
||||||
func: async (
|
func: async (
|
||||||
requestUrl,
|
requestUrl,
|
||||||
requestMethod,
|
requestMethod,
|
||||||
requestPayload,
|
requestPayload,
|
||||||
sourceHeaders,
|
sourceHeaders,
|
||||||
clientIdProbeUrl
|
clientIdProbeUrl,
|
||||||
|
routeAppVersion
|
||||||
) => {
|
) => {
|
||||||
const APP_VERSION = "version_1754044416761";
|
const APP_VERSION = "version_1754044416761";
|
||||||
|
|
||||||
@@ -358,6 +525,294 @@ async function executeComcipFetch(tabId, requestUrl, method, payload, headers, r
|
|||||||
return injectionResult.result;
|
return injectionResult.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function executeComcipFetchFromFrame(
|
||||||
|
tabId,
|
||||||
|
requestUrl,
|
||||||
|
method,
|
||||||
|
payload,
|
||||||
|
headers,
|
||||||
|
route
|
||||||
|
) {
|
||||||
|
const injectionResults = await chrome.scripting.executeScript({
|
||||||
|
target: { tabId, allFrames: true },
|
||||||
|
world: "MAIN",
|
||||||
|
args: [
|
||||||
|
requestUrl,
|
||||||
|
method || "POST",
|
||||||
|
payload || null,
|
||||||
|
headers || {},
|
||||||
|
route?.clientIdProbeUrl || COMCIP_CLIENT_ID_PROBE_URL,
|
||||||
|
route?.appVersion || "",
|
||||||
|
],
|
||||||
|
func: async (
|
||||||
|
requestUrl,
|
||||||
|
requestMethod,
|
||||||
|
requestPayload,
|
||||||
|
sourceHeaders,
|
||||||
|
clientIdProbeUrl,
|
||||||
|
routeAppVersion
|
||||||
|
) => {
|
||||||
|
function isTimeEntryFrame() {
|
||||||
|
const href = String(window.location.href || "");
|
||||||
|
const frameName = String(window.name || "");
|
||||||
|
const isComcipOrigin = href.startsWith(
|
||||||
|
"https://comcipapic-oalprod.integration.ocp.oraclecloud.com/"
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
(frameName === "arch-panel-extension-comcip-timeentry-frame" &&
|
||||||
|
isComcipOrigin) ||
|
||||||
|
href.includes("oalset_timeentrymobile") ||
|
||||||
|
href.includes("/webApps/timeentry")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isTimeEntryFrame()) {
|
||||||
|
return {
|
||||||
|
matched: false,
|
||||||
|
href: window.location.href,
|
||||||
|
frameName: window.name || "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseResponseText(text) {
|
||||||
|
if (!text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickResponseHeaders(responseHeaders) {
|
||||||
|
const safeHeaders = {};
|
||||||
|
const exposedHeaders = [
|
||||||
|
"content-type",
|
||||||
|
"x-appbuilder-client-id",
|
||||||
|
"x-invalid-appbuilder-client-id",
|
||||||
|
"x-appbuilder-repeat-request",
|
||||||
|
"vb-proxy-status-actual",
|
||||||
|
"vb-proxy-version",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const key of exposedHeaders) {
|
||||||
|
const value = responseHeaders.get(key);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
safeHeaders[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return safeHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveAppBuilderClientId() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(clientIdProbeUrl, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
headers: {
|
||||||
|
accept: "*/*",
|
||||||
|
authorization: "Session",
|
||||||
|
"accept-language":
|
||||||
|
sourceHeaders["accept-language"] || navigator.language || "pt-BR",
|
||||||
|
"vb-proxy-header-rest-framework-version": "3",
|
||||||
|
"x-vb-application-version":
|
||||||
|
routeAppVersion || sourceHeaders["x-vb-application-version"] || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.headers.get("x-appbuilder-client-id") || "";
|
||||||
|
} catch {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const appBuilderClientId =
|
||||||
|
sourceHeaders["x-appbuilder-client-id"] || (await resolveAppBuilderClientId());
|
||||||
|
const requestHeaders = {
|
||||||
|
accept: "*/*",
|
||||||
|
authorization: "Session",
|
||||||
|
"vb-proxy-header-preference": "transient",
|
||||||
|
"vb-proxy-header-rest-framework-version": "3",
|
||||||
|
"x-vb-application-version":
|
||||||
|
routeAppVersion || sourceHeaders["x-vb-application-version"] || "",
|
||||||
|
"accept-language":
|
||||||
|
sourceHeaders["accept-language"] || navigator.language || "pt-BR",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (appBuilderClientId) {
|
||||||
|
requestHeaders["x-appbuilder-client-id"] = appBuilderClientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedMethod = String(requestMethod || "POST").toUpperCase();
|
||||||
|
const fetchOptions = {
|
||||||
|
method: normalizedMethod,
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
headers: requestHeaders,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (normalizedMethod !== "GET" && normalizedMethod !== "HEAD") {
|
||||||
|
requestHeaders["content-type"] = "application/json";
|
||||||
|
fetchOptions.body = JSON.stringify(requestPayload || {});
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(requestUrl, fetchOptions);
|
||||||
|
const text = await response.text();
|
||||||
|
|
||||||
|
return {
|
||||||
|
matched: true,
|
||||||
|
ok: response.ok,
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers: pickResponseHeaders(response.headers),
|
||||||
|
payload: parseResponseText(text),
|
||||||
|
debug: {
|
||||||
|
href: window.location.href,
|
||||||
|
origin: window.location.origin,
|
||||||
|
frameName: window.name || "",
|
||||||
|
headerKeys: Object.keys(requestHeaders),
|
||||||
|
frameFetch: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const matchedResult = (injectionResults || [])
|
||||||
|
.map((item) => item.result)
|
||||||
|
.find((result) => result?.matched);
|
||||||
|
|
||||||
|
if (!matchedResult) {
|
||||||
|
const frameHints = (injectionResults || [])
|
||||||
|
.map((item) => item.result)
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((result) => result.href || result.frameName || "unknown")
|
||||||
|
.slice(0, 5)
|
||||||
|
.join(" | ");
|
||||||
|
throw new Error(
|
||||||
|
`COMCIP Time Entry frame did not return a result.${
|
||||||
|
frameHints ? ` Frames: ${frameHints}` : ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchedResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function executeComcipDirectFetch(
|
||||||
|
requestUrl,
|
||||||
|
method = "GET",
|
||||||
|
payload = null,
|
||||||
|
headers = {},
|
||||||
|
route
|
||||||
|
) {
|
||||||
|
const APP_VERSION = "version_1754044416761";
|
||||||
|
|
||||||
|
function parseResponseText(text) {
|
||||||
|
if (!text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickResponseHeaders(responseHeaders) {
|
||||||
|
const safeHeaders = {};
|
||||||
|
const exposedHeaders = [
|
||||||
|
"content-type",
|
||||||
|
"x-appbuilder-client-id",
|
||||||
|
"x-invalid-appbuilder-client-id",
|
||||||
|
"x-appbuilder-repeat-request",
|
||||||
|
"vb-proxy-status-actual",
|
||||||
|
"vb-proxy-version",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const key of exposedHeaders) {
|
||||||
|
const value = responseHeaders.get(key);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
safeHeaders[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return safeHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveAppBuilderClientId() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(route?.clientIdProbeUrl || COMCIP_CLIENT_ID_PROBE_URL, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
headers: {
|
||||||
|
accept: "*/*",
|
||||||
|
authorization: "Session",
|
||||||
|
"accept-language": headers["accept-language"] || "pt-BR",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.headers.get("x-appbuilder-client-id") || "";
|
||||||
|
} catch {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const appBuilderClientId =
|
||||||
|
headers["x-appbuilder-client-id"] || (await resolveAppBuilderClientId());
|
||||||
|
const requestHeaders = {
|
||||||
|
accept: "*/*",
|
||||||
|
authorization: "Session",
|
||||||
|
"vb-proxy-header-preference": "transient",
|
||||||
|
"accept-language": headers["accept-language"] || "pt-BR",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!route?.omitAppVersion && headers["x-vb-application-version"]) {
|
||||||
|
requestHeaders["x-vb-application-version"] = headers["x-vb-application-version"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appBuilderClientId) {
|
||||||
|
requestHeaders["x-appbuilder-client-id"] = appBuilderClientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedMethod = String(method || "GET").toUpperCase();
|
||||||
|
const fetchOptions = {
|
||||||
|
method: normalizedMethod,
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
headers: requestHeaders,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (normalizedMethod !== "GET" && normalizedMethod !== "HEAD") {
|
||||||
|
requestHeaders["content-type"] = "application/json";
|
||||||
|
fetchOptions.body = JSON.stringify(payload || {});
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(requestUrl, fetchOptions);
|
||||||
|
const text = await response.text();
|
||||||
|
|
||||||
|
return {
|
||||||
|
ok: response.ok,
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers: pickResponseHeaders(response.headers),
|
||||||
|
payload: parseResponseText(text),
|
||||||
|
debug: {
|
||||||
|
directFetch: true,
|
||||||
|
origin: chrome.runtime.getURL(""),
|
||||||
|
headerKeys: Object.keys(requestHeaders),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function isAuthorizationFailure(response) {
|
function isAuthorizationFailure(response) {
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return false;
|
return false;
|
||||||
@@ -370,11 +825,27 @@ function isAuthorizationFailure(response) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
response.status === 401 ||
|
response.status === 401 ||
|
||||||
|
response.status === 500 && /vb:\/\/trap\/model\/no_auth/i.test(payloadText) ||
|
||||||
|
/No user authentication for the service/i.test(payloadText) ||
|
||||||
|
/missingAnonymous/i.test(payloadText) ||
|
||||||
/401 Authorization Required/i.test(payloadText) ||
|
/401 Authorization Required/i.test(payloadText) ||
|
||||||
/Authorization Required/i.test(payloadText)
|
/Authorization Required/i.test(payloadText)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isOutdatedApplicationFailure(response) {
|
||||||
|
if (!response) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const payloadText =
|
||||||
|
typeof response.payload === "string"
|
||||||
|
? response.payload
|
||||||
|
: JSON.stringify(response.payload || "");
|
||||||
|
|
||||||
|
return /out-dated version of the application/i.test(payloadText);
|
||||||
|
}
|
||||||
|
|
||||||
function delay(milliseconds) {
|
function delay(milliseconds) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(resolve, milliseconds);
|
setTimeout(resolve, milliseconds);
|
||||||
|
|||||||
2943
content-script.js
2943
content-script.js
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Arch Panel Injector",
|
"name": "Arch Panel Injector",
|
||||||
"version": "1.0.11",
|
"version": "1.0.73",
|
||||||
"description": "Insere o botao Arch panel no header do Oracle Workload Workbench.",
|
"description": "Insere o botao Arch panel no header do Oracle Workload Workbench.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"cookies",
|
"cookies",
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"tabs"
|
"tabs"
|
||||||
],
|
],
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
"https://comcipapic-oalprod.integration.ocp.oraclecloud.com/*"
|
"https://comcipapic-oalprod.integration.ocp.oraclecloud.com/*",
|
||||||
|
"https://spa.oracle.com/*"
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "background.js"
|
"service_worker": "background.js"
|
||||||
@@ -48,3 +49,65 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user