Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic Seedless-onboarding #2534

Merged
merged 61 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b3f3f9c
feat: Implement social login with MPC Core SDK
schmanu Sep 21, 2023
65dd3a4
test: mpc onboard module
schmanu Sep 21, 2023
19c4477
[Seedless-onboarding] - tests for useMPC hook (#2536)
schmanu Sep 22, 2023
387b156
fix: update mpc core sdk to 1.0.2
schmanu Sep 25, 2023
dbd1cc1
feat: MFA through password / device factors(#2559)
schmanu Oct 5, 2023
0989c9c
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
schmanu Oct 5, 2023
cf8db3f
feat: redesign welcome page (#2593)
schmanu Oct 6, 2023
1a161da
feat: add sidebar design to welcome page (#2601)
schmanu Oct 6, 2023
e682af6
fix: layout without added Safes
schmanu Oct 9, 2023
5ab369e
feat: enable manualSync, commit MFA changes in batches (#2600)
schmanu Oct 9, 2023
6db3390
fix: Show safe list button on welcome page if there are owned safes (…
usame-algan Oct 10, 2023
cc7398b
[Seedless Onboarding] Account center redesign (#2607)
usame-algan Oct 11, 2023
daf6bdb
fix: Enable 1-click safe create for social login (#2620)
usame-algan Oct 12, 2023
92147fc
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
schmanu Oct 17, 2023
3bec181
tests: apply transformIgnorePatterns after nextJest
schmanu Oct 17, 2023
5d1939d
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
usame-algan Oct 17, 2023
dcc5ad4
fix: Update yarn lock
usame-algan Oct 17, 2023
2747747
fix: Add social login feature toggle from config service (#2635)
usame-algan Oct 18, 2023
df74f4e
[Seedless-Onboarding] Add tracking (#2626)
schmanu Oct 18, 2023
1b153d4
[Seedless-Onboarding] export account (#2610)
schmanu Oct 20, 2023
0140ec0
[Seedless Onboarding]: Settings password form (#2644)
usame-algan Oct 23, 2023
8500cdf
[Seedless Onboarding]: Add password recovery modal design (#2653)
usame-algan Oct 23, 2023
f31099b
[Seedless-Onboarding] Add signer account to address book on login (#2…
schmanu Oct 23, 2023
5d05596
fix: Address design review, restructure components (#2683)
usame-algan Oct 23, 2023
3352841
[Seedless Onboarding] Adjust Account center design (#2673)
usame-algan Oct 25, 2023
0f2ba8b
fix: Disable network selector if social login wallet not supported (#…
usame-algan Oct 25, 2023
748b145
[Seedless Onboarding]: Adjust password form (#2692)
usame-algan Oct 26, 2023
672523f
fix: Safe creation e2e test for seedless onboarding (#2694)
usame-algan Oct 27, 2023
0666620
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
schmanu Oct 27, 2023
abdc544
[Seedless-Onboarding] Refactor context + provider into service class …
schmanu Oct 30, 2023
1049858
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
schmanu Oct 30, 2023
351b360
fix: Catch errors during signing with social login (#2713)
usame-algan Oct 31, 2023
4d2a81a
[Seedless Onboarding] Only continue to safe creation if login succeed…
usame-algan Oct 31, 2023
95ba442
[Seedless Onboarding] Add alternative welcome page (#2704)
usame-algan Oct 31, 2023
0c47aee
chore: Revert permission changes
usame-algan Oct 31, 2023
915ef37
fix: disconnect previous wallet (#2712)
schmanu Oct 31, 2023
7093860
fix: ignore empty names in addressbook (#2709)
schmanu Oct 31, 2023
52366b3
feat: aggregate verifier config (#2724)
schmanu Nov 1, 2023
ec5b97c
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
usame-algan Nov 1, 2023
f262276
[Seedless Onboarding] QA fixes (#2721)
usame-algan Nov 1, 2023
e681310
[Seedless-Onboarding] fix: login error handling (#2730)
schmanu Nov 2, 2023
78c60c2
feat: use mnemonic name for Social Safes (#2729)
schmanu Nov 2, 2023
842836f
Tests: Seedless cypress tests(normal flow) (#2726)
mike10ca Nov 2, 2023
c81b9fb
fix: Hide Security&Login from settings if not a social signer (#2734)
usame-algan Nov 2, 2023
53d95cd
refactor: environment config for social wallet (#2728)
schmanu Nov 3, 2023
13618c3
fix: Reload app when setting password (#2741)
usame-algan Nov 3, 2023
3d118f3
Fix: hide Social Login wallet button from onboard (#2740)
katspaugh Nov 3, 2023
f22a797
fix: Use github secrets for env
usame-algan Nov 3, 2023
146dc8e
Merge branch 'dev' into web3authcoresdk
katspaugh Nov 3, 2023
010faca
fix: Add social login option to onboard module (#2744)
usame-algan Nov 6, 2023
232674c
fix: Adjust connection center design (#2745)
usame-algan Nov 6, 2023
8e2d324
fix: merge serviceworkers for seedless onboarding (#2750)
schmanu Nov 7, 2023
ea3763b
fix: Add feature flag for social login (#2770)
usame-algan Nov 8, 2023
a299a33
chore: update mpc-core-kit (#2769)
schmanu Nov 8, 2023
4fbfa1b
fix: Add events for export pk (#2766)
usame-algan Nov 8, 2023
c3e0cb8
fix: Update welcome screen text (#2773)
usame-algan Nov 8, 2023
86800bd
fix: disable logs in prod (#2774)
schmanu Nov 8, 2023
7536b5a
chore: Bump version to v1.22.0
usame-algan Nov 8, 2023
5f8a7e8
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
usame-algan Nov 8, 2023
f8aa390
Merge remote-tracking branch 'origin/dev' into web3authcoresdk
schmanu Nov 9, 2023
73c5c73
fix: link to welcome page in wc
schmanu Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ runs:
NEXT_PUBLIC_SAFE_RELAY_SERVICE_URL_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_STAGING }}
NEXT_PUBLIC_IS_OFFICIAL_HOST: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_IS_OFFICIAL_HOST }}
NEXT_PUBLIC_REDEFINE_API: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_REDEFINE_API }}
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_WEB3AUTH_CLIENT_ID }}
NEXT_PUBLIC_GOOGLE_CLIENT_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_GOOGLE_CLIENT_ID }}
NEXT_PUBLIC_WEB3AUTH_VERIFIER_ID: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_WEB3AUTH_VERIFIER_ID }}
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ jobs:
# Extract branch name
- name: Extract branch name
shell: bash
## Cut off "refs/heads/" and only allow alphanumeric characters,
## Cut off "refs/heads/", only allow alphanumeric characters and convert to lower case,
## e.g. "refs/heads/features/hello-1.2.0" -> "features_hello_1_2_0"
run: echo "branch=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///' | sed 's/[^a-z0-9]/_/ig')" >> $GITHUB_OUTPUT
run: echo "branch=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///' | sed 's/[^a-z0-9]/_/ig' | sed 's/[A-Z]/\L&/g')" >> $GITHUB_OUTPUT
id: extract_branch

# Deploy to S3
Expand Down
18 changes: 15 additions & 3 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],

moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
'^@/(.*)$': '<rootDir>/src/$1',
Expand All @@ -16,9 +17,20 @@ const customJestConfig = {
testEnvironment: 'jest-environment-jsdom',
testEnvironmentOptions: { url: 'http://localhost/balances?safe=rin:0xb3b83bf204C458B461de9B0CD2739DB152b4fa5A' },
globals: {
fetch: global.fetch
}
fetch: global.fetch,
},
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
// Jest does not allow modification of transformIgnorePatterns within createJestConfig, therefore we add one entry after initializing the config
module.exports = async () => {
const jestConfig = await createJestConfig(customJestConfig)()
const existingTransformIgnorePatterns = jestConfig.transformIgnorePatterns.filter(
(pattern) => pattern !== '/node_modules/',
)

return {
...jestConfig,
transformIgnorePatterns: [...existingTransformIgnorePatterns, '/node_modules/(?!(@web3-onboard/common)/)'],
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
"@web3-onboard/ledger": "2.3.2",
"@web3-onboard/trezor": "^2.4.2",
"@web3-onboard/walletconnect": "^2.4.5",
"@web3auth/mpc-core-kit": "^1.0.2",
"bn.js": "^5.2.1",
"classnames": "^2.3.1",
"date-fns": "^2.29.2",
"ethereum-blockies-base64": "^1.0.2",
Expand Down
318 changes: 318 additions & 0 deletions public/serviceworker/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
/* eslint-disable */
function getScope() {
return self.registration.scope
}

self.addEventListener('message', function (event) {
if (event.data && event.data.type === 'SKIP_WAITING') {
self.skipWaiting()
}
})

self.addEventListener('fetch', function (event) {
try {
const url = new URL(event.request.url)
const redirectURL = self.location.url
if (url.pathname.includes('redirect') && url.href.includes(getScope())) {
event.respondWith(
new Response(
new Blob(
[
`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Redirect</title>
<style>
* {
box-sizing: border-box;
}

html,
body {
background: #fcfcfc;
height: 100%;
padding: 0;
margin: 0;
}

.container {
width: 100%;
height: 100%;

display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}

h1.title {
font-size: 14px;
color: #0f1222;
font-family: "Roboto", sans-serif !important;
margin: 0;
text-align: center;
}

.spinner .beat {
background-color: #0364ff;
height: 12px;
width: 12px;
margin: 24px 2px 10px;
border-radius: 100%;
-webkit-animation: beatStretchDelay 0.7s infinite linear;
animation: beatStretchDelay 0.7s infinite linear;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
display: inline-block;
}

.spinner .beat-odd {
animation-delay: 0s;
}

.spinner .beat-even {
animation-delay: 0.35s;
}

@-webkit-keyframes beatStretchDelay {
50% {
-webkit-transform: scale(0.75);
transform: scale(0.75);
-webkit-opacity: 0.2;
opacity: 0.2;
}

100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-opacity: 1;
opacity: 1;
}
}

@keyframes beatStretchDelay {
50% {
-webkit-transform: scale(0.75);
transform: scale(0.75);
-webkit-opacity: 0.2;
opacity: 0.2;
}

100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-opacity: 1;
opacity: 1;
}
}

@media (min-width: 768px) {
h1.title {
font-size: 14px;
}
p.info {
font-size: 28px;
}

.spinner .beat {
height: 12px;
width: 12px;
}
}
</style>
</head>

<body>
<div id="message" class="container">
<div class="spinner content" id="spinner">
<div class="beat beat-odd"></div>
<div class="beat beat-even"></div>
<div class="beat beat-odd"></div>
</div>
<h1 class="title content" id="closeText" style="display: none;">You can close this window now</h1>
</div>
<script
src="https://scripts.toruswallet.io/broadcastChannel_6_0_0.js"
integrity="sha384-tWiIvEY4iDOl9h6tNeoxETpLfPxq0tgzbIXFYjok42Gu5KoDaA9uSiAk2nG6XBcp"
crossorigin="anonymous"
></script>
<script>
function storageAvailable(type) {
var storage;
try {
storage = window[type];
var x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (e) {
return (
e &&
// everything except Firefox
(e.code === 22 ||
// Firefox
e.code === 1014 ||
// test name field too, because code might not be present
// everything except Firefox
e.name === "QuotaExceededError" ||
// Firefox
e.name === "NS_ERROR_DOM_QUOTA_REACHED") &&
// acknowledge QuotaExceededError only if there's something already stored
storage &&
storage.length !== 0
);
}
}
function showCloseText() {
var closeText = document.getElementById("closeText");
var spinner = document.getElementById("spinner");
if (closeText) {
closeText.style.display = "block";
}
if (spinner) {
spinner.style.display = "none";
}
}
var isLocalStorageAvailable = storageAvailable("localStorage");
var isSessionStorageAvailable = storageAvailable("sessionStorage");
// set theme
let theme = "light";
if (isLocalStorageAvailable) {
var torusTheme = localStorage.getItem("torus-theme");
if (torusTheme) {
theme = torusTheme.split("-")[0];
}
}

if (theme === "dark") {
document.querySelector("body").style.backgroundColor = "#24252A";
}
var bc;
var broadcastChannelOptions = {
// type: 'localstorage', // (optional) enforce a type, oneOf['native', 'idb', 'localstorage', 'node'
webWorkerSupport: false, // (optional) set this to false if you know that your channel will never be used in a WebWorker (increase performance)
};
var instanceParams = {};
var preopenInstanceId = new URL(window.location.href).searchParams.get("preopenInstanceId");
if (!preopenInstanceId) {
document.getElementById("message").style.visibility = "visible";
// in general oauth redirect
try {
var url = new URL(location.href);
var hash = url.hash.substr(1);
var hashParams = {};
if (hash) {
hashParams = hash.split("&").reduce(function (result, item) {
var parts = item.split("=");
result[parts[0]] = parts[1];
return result;
}, {});
}
var queryParams = {};
for (var key of url.searchParams.keys()) {
queryParams[key] = url.searchParams.get(key);
}
var error = "";
try {
if (Object.keys(hashParams).length > 0 && hashParams.state) {
instanceParams = JSON.parse(window.atob(decodeURIComponent(decodeURIComponent(hashParams.state)))) || {};
if (hashParams.error) error = hashParams.error;
} else if (Object.keys(queryParams).length > 0 && queryParams.state) {
instanceParams = JSON.parse(window.atob(decodeURIComponent(decodeURIComponent(queryParams.state)))) || {};
if (queryParams.error) error = queryParams.error;
}
} catch (e) {
console.error(e);
}
if (instanceParams.redirectToOpener) {
// communicate to window.opener
window.opener.postMessage(
{
channel: "redirect_channel_" + instanceParams.instanceId,
data: {
instanceParams: instanceParams,
hashParams: hashParams,
queryParams: queryParams,
},
error: error,
},
"${redirectURL}"
);
} else {
// communicate via broadcast channel
bc = new broadcastChannelLib.BroadcastChannel("redirect_channel_" + instanceParams.instanceId, broadcastChannelOptions);
bc.addEventListener("message", function (ev) {
if (ev.success) {
bc.close();
} else {
window.close();
showCloseText();
}
});
bc.postMessage({
data: {
instanceParams: instanceParams,
hashParams: hashParams,
queryParams: queryParams,
},
error: error,
}).then(function () {
setTimeout(function () {
window.location.href = url.origin + location.search + location.hash;
}, 5000);
});
}
} catch (err) {
console.error(err, "service worker error in redirect");
bc && bc.close();
window.close();
showCloseText();
}
} else {
// in preopen, awaiting redirect
try {
bc = new broadcastChannelLib.BroadcastChannel("preopen_channel_" + preopenInstanceId, broadcastChannelOptions);
bc.onmessage = function (ev) {
var { preopenInstanceId: oldId, payload, message } = ev.data;
if (oldId === preopenInstanceId && payload && payload.url) {
window.location.href = payload.url;
} else if (oldId === preopenInstanceId && message === "setup_complete") {
bc.postMessage({
data: {
preopenInstanceId: preopenInstanceId,
message: "popup_loaded",
},
});
}
if (ev.error && ev.error !== "") {
console.error(ev.error);
bc.close();
}
};
} catch (err) {
console.error(err, "service worker error in preopen");
bc && bc.close();
window.close();
showCloseText();
}
}
</script>
</body>
</html>

${''}
`,
],
{ type: 'text/html' },
),
),
)
}
} catch (error) {
console.error(error)
}
})
3 changes: 3 additions & 0 deletions src/components/common/ConnectWallet/AccountCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ChainSwitcher from '../ChainSwitcher'
import useAddressBook from '@/hooks/useAddressBook'
import { type ConnectedWallet } from '@/hooks/wallets/useOnboard'
import WalletInfo, { UNKNOWN_CHAIN_NAME } from '../WalletInfo'
import { MPCWallet } from './MPCWallet'

const AccountCenter = ({ wallet }: { wallet: ConnectedWallet }) => {
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)
Expand Down Expand Up @@ -114,6 +115,8 @@ const AccountCenter = ({ wallet }: { wallet: ConnectedWallet }) => {
<Button onClick={handleDisconnect} variant="danger" size="small" fullWidth disableElevation>
Disconnect
</Button>

<MPCWallet />
</Paper>
</Popover>
</>
Expand Down
Loading
Loading