From fcccdc289a2a6858bd74e25de169c54e387549f1 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Tue, 6 Feb 2024 03:02:17 +0500 Subject: [PATCH 1/2] feat: add polaris-web client library --- example-web/my-app/package-lock.json | 117 ++------------------------- example-web/my-app/package.json | 1 + example-web/my-app/src/App.js | 77 +++++------------- 3 files changed, 28 insertions(+), 167 deletions(-) diff --git a/example-web/my-app/package-lock.json b/example-web/my-app/package-lock.json index 18f8c7d6..c978260b 100644 --- a/example-web/my-app/package-lock.json +++ b/example-web/my-app/package-lock.json @@ -15,6 +15,7 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "eslint": "^8.56.0", + "polaris-web": "^1.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", @@ -4013,104 +4014,6 @@ "url": "https://github.com/sponsors/gregberge" } }, - "node_modules/@testing-library/dom": { - "version": "9.3.3", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.3.tgz", - "integrity": "sha512-fB0R+fa3AUqbLHWyxXa2kGVtf1Fe1ZZFr0Zp6AIbIAzXb2mKbEXl+PCQNUOaq5lbTab5tfctfXRNsWXxa2f7Aw==", - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.1.3", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@testing-library/dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "peer": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", - "peer": true, - "dependencies": { - "deep-equal": "^2.0.5" - } - }, - "node_modules/@testing-library/dom/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "peer": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "peer": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "peer": true - }, - "node_modules/@testing-library/dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "peer": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@testing-library/jest-dom": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz", @@ -13617,6 +13520,11 @@ "node": ">=4" } }, + "node_modules/polaris-web": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/polaris-web/-/polaris-web-1.0.0.tgz", + "integrity": "sha512-fUW6Xrfvwy4UjrUSL92ymyIPBrXDqYGgpPIdkvKp7gbO7aKV2oBLamGz9ykUPOj29+Lty6j5NPt7gasxqJYt3Q==" + }, "node_modules/postcss": { "version": "8.4.32", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz", @@ -17224,19 +17132,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", diff --git a/example-web/my-app/package.json b/example-web/my-app/package.json index 78e4c384..515fc01b 100644 --- a/example-web/my-app/package.json +++ b/example-web/my-app/package.json @@ -10,6 +10,7 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "eslint": "^8.56.0", + "polaris-web": "^1.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", diff --git a/example-web/my-app/src/App.js b/example-web/my-app/src/App.js index 27cae984..5d140cbc 100644 --- a/example-web/my-app/src/App.js +++ b/example-web/my-app/src/App.js @@ -1,56 +1,25 @@ +import { + requestAid, + requestCredential, + requestAidORCred, + attemptAutoSignin, +} from "polaris-web"; import logo from "./ACME_Corporation.png"; import Button from "@mui/material/Button"; import "./App.css"; -var extensionId = ""; - function App() { - - window.addEventListener( - "message", - async (event) => { - // Accept messages only from same window - if (event.source !== window) { - return; - } - - if (event.data.type && event.data.type === "signify-extension") { - console.log("Content scrip loaded"); - extensionId = event.data.data.extensionId; + const handleAutoSignin = async () => { + try { + const resp = await attemptAutoSignin(); + console.log("data", resp); + if (resp?.data) { + alert( + "Signed headers received\n" + + JSON.stringify(resp?.data.headers, null, 2) + ); } - }, - false - ); - - const handleRequestIdentifier = () => { - window.postMessage({ type: "select-identifier" }, "*"); - }; - - const handleRequestCredential = () => { - window.postMessage({ type: "select-credential" }, "*"); - }; - - const handleRequestIdORCred = () => { - window.postMessage({ type: "select-aid-or-credential" }, "*"); - }; - - const handleRequestAutoSignin = () => { - window.postMessage({ type: "select-auto-signin" }, "*"); - }; - - const handleSyncRequest = async () => { - const { data, error } = await chrome.runtime.sendMessage(extensionId, { - type: "fetch-resource", - subtype: "auto-signin-signature", - }); - - if (error) { - handleRequestAutoSignin(); - } else { - alert( - "Signed headers received\n" + JSON.stringify(data.headers, null, 2) - ); - } + } catch (error) {} }; return ( @@ -59,33 +28,29 @@ function App() { logo

Authenticate with

-
From f22042cad63b6d2ffc329037ae6043f5ba13599c Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Tue, 6 Feb 2024 03:10:31 +0500 Subject: [PATCH 2/2] fix: remove console.log --- example-web/my-app/src/App.js | 1 - 1 file changed, 1 deletion(-) diff --git a/example-web/my-app/src/App.js b/example-web/my-app/src/App.js index 5d140cbc..e2d113a5 100644 --- a/example-web/my-app/src/App.js +++ b/example-web/my-app/src/App.js @@ -12,7 +12,6 @@ function App() { const handleAutoSignin = async () => { try { const resp = await attemptAutoSignin(); - console.log("data", resp); if (resp?.data) { alert( "Signed headers received\n" +