diff --git a/example-web/my-app/package-lock.json b/example-web/my-app/package-lock.json
index cd1f97ea..6acc438e 100644
--- a/example-web/my-app/package-lock.json
+++ b/example-web/my-app/package-lock.json
@@ -16030,7 +16030,7 @@
},
"node_modules/signify-polaris-web": {
"version": "1.0.2",
- "resolved": "git+ssh://git@github.com/roots-id/polaris-web.git#e2ff948985e523bb1aed1e7489476a32328480a1",
+ "resolved": "git+ssh://git@github.com/roots-id/polaris-web.git#e240dd3d0e5d4ad4aa5bbe31d464feb8f7515c5a",
"license": "ISC"
},
"node_modules/sisteransi": {
diff --git a/example-web/my-app/src/App.js b/example-web/my-app/src/App.js
index 08fba4dd..9956c4cc 100644
--- a/example-web/my-app/src/App.js
+++ b/example-web/my-app/src/App.js
@@ -8,7 +8,8 @@ import {
requestCredential,
requestAidORCred,
trySettingVendorUrl,
-} from "./signify-polaris-web";
+ canCallAsync,
+} from "signify-polaris-web";
import Button from "@mui/material/Button";
import Alert from "@mui/material/Alert";
import CircularProgress from "@mui/material/CircularProgress";
@@ -66,6 +67,18 @@ function App() {
setParsedSignifyData(null);
};
+ const handleRequestAutoSignin = async () => {
+ console.log("canCallAsync()", canCallAsync());
+ if (canCallAsync()) {
+ const resp = await requestAutoSignin();
+ if (resp) {
+ handleSignifyData(resp);
+ }
+ } else {
+ requestAutoSignin();
+ }
+ };
+
const renderData = () => {
if (extensionInstalled === null) return
{formatMessage({ id: "message.noItems" })}
+{formatMessage({ id: "message.noItems" })}
) : ( <>> )} diff --git a/src/components/identifierList.tsx b/src/components/identifierList.tsx index 50d6616e..0b34656b 100644 --- a/src/components/identifierList.tsx +++ b/src/components/identifierList.tsx @@ -94,7 +94,7 @@ export function IdentifierList(): JSX.Element { ))} {!isLoading && !aids?.length ? ( -{formatMessage({ id: "message.noItems" })}
+{formatMessage({ id: "message.noItems" })}
) : ( <>> )} diff --git a/src/components/signinList.tsx b/src/components/signinList.tsx index 552ce26d..c902f431 100644 --- a/src/components/signinList.tsx +++ b/src/components/signinList.tsx @@ -91,7 +91,7 @@ export function SigninList(): JSX.Element { ))} {!isLoading && !signins?.length ? ( -{formatMessage({ id: "message.noItems" })}
+{formatMessage({ id: "message.noItems" })}
) : ( <>> )} diff --git a/src/pages/background/index.ts b/src/pages/background/index.ts index 135b0355..9c1590e4 100644 --- a/src/pages/background/index.ts +++ b/src/pages/background/index.ts @@ -83,7 +83,6 @@ chrome.runtime.onMessage.addListener(function ( // Validate that message comes from a page that has a signin const origin = removeSlash(sender.url); const signins = await getSigninsByDomain(origin); - console.log("signins", signins); const autoSignin = signins?.find((signin) => signin.autoSignin); if (!signins?.length || !autoSignin) { sendResponse({ @@ -318,63 +317,35 @@ chrome.runtime.onMessageExternal.addListener(function ( console.log("Message received from external source: ", sender); console.log("Message received from external request: ", message); - // if ( - // message.type === "fetch-resource" && - // message.subtype === "auto-signin-signature" - // ) { - // // Validate that message comes from a page that has a signin - // const origin = removeSlash(sender.url); - // const signins = await getSigninsByDomain(origin); - // console.log("signins", signins); - // const autoSignin = signins?.find((signin) => signin.autoSignin); - // if (!signins?.length || !autoSignin) { - // sendResponse({ - // error: { code: 404, message: "auto signin not found" }, - // }); - // return; - // } - - // const signedHeaders = await signifyService.signHeaders( - // // sigin can either have identifier or credential - // autoSignin?.identifier - // ? autoSignin?.identifier?.name - // : autoSignin?.credential?.issueeName, - // origin - // ); - // let jsonHeaders: { [key: string]: string } = {}; - // for (const pair of signedHeaders.entries()) { - // jsonHeaders[pair[0]] = pair[1]; - // } - // sendResponse({ data: { headers: jsonHeaders } }); - // } - - - // if ( - // message.type === "vendor-info" && - // message.subtype === "attempt-set-vendor-url" - // ) { - // const { vendorUrl } = message?.data ?? {}; - // if (!vendorUrl) { - // return; - // } - - // const _vendorUrl = await configService.getUrl(); - // if (!_vendorUrl) { - // try { - // const resp = await (await fetch(vendorUrl)).json(); - // if (resp?.agentUrl) { - // await configService.setAgentUrl(resp?.agentUrl); - // } - // await configService.setData(resp); - // if (resp?.icon) { - // await setActionIcon(resp?.icon); - // } - // await configService.setUrl(vendorUrl); - // } catch (error) {} - // } + if ( + message.type === "fetch-resource" && + message.subtype === "auto-signin-signature" + ) { + // Validate that message comes from a page that has a signin + const origin = removeSlash(sender.url); + const signins = await getSigninsByDomain(origin); + console.log("signins", signins); + const autoSignin = signins?.find((signin) => signin.autoSignin); + if (!signins?.length || !autoSignin) { + sendResponse({ + error: { code: 404, message: "auto signin not found" }, + }); + return; + } - // sendResponse({ data: { _vendorUrl } }); - // } + const signedHeaders = await signifyService.signHeaders( + // sigin can either have identifier or credential + autoSignin?.identifier + ? autoSignin?.identifier?.name + : autoSignin?.credential?.issueeName, + origin + ); + let jsonHeaders: { [key: string]: string } = {}; + for (const pair of signedHeaders.entries()) { + jsonHeaders[pair[0]] = pair[1]; + } + sendResponse({ data: { headers: jsonHeaders } }); + } })(); // return true to indicate chrome api to send a response asynchronously diff --git a/src/pages/content/index.tsx b/src/pages/content/index.tsx index 22dafd4e..46ef9fa2 100644 --- a/src/pages/content/index.tsx +++ b/src/pages/content/index.tsx @@ -110,7 +110,6 @@ window.addEventListener( { type: "signify-signature", data: data }, "*" ); - // pubsub.publish("signify-signature", data); } }