From a72df010482655da564e9f99a3025ad3676e38d6 Mon Sep 17 00:00:00 2001 From: Heiko Burkhardt Date: Fri, 15 Sep 2023 09:50:59 +0200 Subject: [PATCH] fix: offchain resolver sign --- .github/workflows/deploy.yml | 4 +++- .gitignore | 1 + packages/cli/package.json | 2 +- packages/lib/offchainResolver-api/package.json | 4 ++-- packages/lib/offchainResolver-api/src/index.ts | 8 +++----- packages/lib/offchainResolver-api/tsconfig.json | 4 ++-- packages/messenger-demo/package.json | 16 +++++++++------- packages/messenger-demo/tsconfig.json | 2 +- .../messenger-widget/src/views/Home/Home.tsx | 2 +- packages/messenger-widget/tsconfig.json | 2 +- yarn.lock | 4 ++-- 11 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c1f96ecbc..113642ef8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,6 +56,8 @@ jobs: rsync -avz -e 'ssh -i ./ssh-key' ./docker/docker-compose.yml app@${{ secrets.STAGING_HOST }}:/home/app/dm3 - name: Prepare docker run: | + ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\ + cd dm3 && docker compose down" ssh -i ./ssh-key root@${{ secrets.STAGING_HOST }} "\ docker system prune -af; \ systemctl restart docker.service" @@ -71,4 +73,4 @@ jobs: - name: Start run: | ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\ - cd dm3 && docker compose down && docker compose --env-file .env up -d" + cd dm3 && docker compose --env-file .env up -d" diff --git a/.gitignore b/.gitignore index e861477d8..4f79fbf0c 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ packages/lib/**/dist !.yarn/versions packages/**/.yarn +temp \ No newline at end of file diff --git a/packages/cli/package.json b/packages/cli/package.json index 52a36232d..0320980e7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -9,7 +9,7 @@ "dependencies": { "ccip-resolver": "^0.2.2", "commander": "^11.0.0", - "ethers": "^5.7.2", + "ethers": "5.7.2", "ts-node": "^10.9.1" }, "devDependencies": { diff --git a/packages/lib/offchainResolver-api/package.json b/packages/lib/offchainResolver-api/package.json index 2505be1ab..0b9f6a059 100644 --- a/packages/lib/offchainResolver-api/package.json +++ b/packages/lib/offchainResolver-api/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "axios": "^1.5.0", - "dm3-lib-profile": "workspace:^", - "ethers": "5.7.2" + "dm3-lib-crypto": "workspace:^", + "dm3-lib-profile": "workspace:^" }, "devDependencies": { "@types/data-urls": "^3.0.1", diff --git a/packages/lib/offchainResolver-api/src/index.ts b/packages/lib/offchainResolver-api/src/index.ts index 8e0f24b34..740d37144 100644 --- a/packages/lib/offchainResolver-api/src/index.ts +++ b/packages/lib/offchainResolver-api/src/index.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import { SignedUserProfile, formatAddress } from 'dm3-lib-profile'; -import { ethers } from 'ethers'; +import { sign } from 'dm3-lib-crypto'; /** * claims a dm3.eth subdomain @@ -15,12 +15,11 @@ export async function claimSubdomain( name: string, privateKey: string, ): Promise { - const wallet = new ethers.Wallet(privateKey); const url = `${offchainResolverUrl}/profile/name`; const data = { alias, name, - signature: await wallet.signMessage('alias: ' + alias), + signature: await sign(privateKey, 'alias: ' + alias), }; const { status } = await axios.post(url, data); @@ -38,11 +37,10 @@ export async function removeAlias( offchainResolverUrl: string, privateKey: string, ): Promise { - const wallet = new ethers.Wallet(privateKey); const url = `${offchainResolverUrl}/profile/name`; const data = { name: alias, - signature: await wallet.signMessage('remove: ' + alias), + signature: await sign(privateKey, 'remove: ' + alias), }; const { status } = await axios.post(url, data); diff --git a/packages/lib/offchainResolver-api/tsconfig.json b/packages/lib/offchainResolver-api/tsconfig.json index 000fc07f5..b8721eeaa 100644 --- a/packages/lib/offchainResolver-api/tsconfig.json +++ b/packages/lib/offchainResolver-api/tsconfig.json @@ -9,8 +9,8 @@ "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "module": "node16", - "moduleResolution": "node16", + "module": "CommonJS", + "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "outDir": "dist", diff --git a/packages/messenger-demo/package.json b/packages/messenger-demo/package.json index f1c4d5350..482145800 100644 --- a/packages/messenger-demo/package.json +++ b/packages/messenger-demo/package.json @@ -34,16 +34,18 @@ }, "browserslist": { "production": [ - ">0.2%", - "not dead", - "not op_mini all" + "chrome >= 67", + "edge >= 79", + "firefox >= 68", + "opera >= 54", + "safari >= 14" ], "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" ] - }, + }, "devDependencies": { "@testing-library/dom": "^9.3.1", "@types/three": "^0.141.0", diff --git a/packages/messenger-demo/tsconfig.json b/packages/messenger-demo/tsconfig.json index a2ff23e26..c0555cbc6 100644 --- a/packages/messenger-demo/tsconfig.json +++ b/packages/messenger-demo/tsconfig.json @@ -10,7 +10,7 @@ "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", - "moduleResolution": "node16", + "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, diff --git a/packages/messenger-widget/src/views/Home/Home.tsx b/packages/messenger-widget/src/views/Home/Home.tsx index b1cb61951..cbf6967e1 100644 --- a/packages/messenger-widget/src/views/Home/Home.tsx +++ b/packages/messenger-widget/src/views/Home/Home.tsx @@ -9,7 +9,7 @@ import { RainbowKitProvider, } from '@rainbow-me/rainbowkit'; import { configureChains, createConfig, WagmiConfig } from 'wagmi'; -import { mainnet, goerli } from 'wagmi/chains'; +import { goerli } from 'wagmi/chains'; import { metaMaskWallet, rainbowWallet, diff --git a/packages/messenger-widget/tsconfig.json b/packages/messenger-widget/tsconfig.json index 76e010f09..6fbaa7bbf 100644 --- a/packages/messenger-widget/tsconfig.json +++ b/packages/messenger-widget/tsconfig.json @@ -14,7 +14,7 @@ "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", - "moduleResolution": "node16", + "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, diff --git a/yarn.lock b/yarn.lock index e9be2770c..f6eaaf723 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12254,7 +12254,7 @@ __metadata: "@nomiclabs/hardhat-ethers": ^2.2.3 ccip-resolver: ^0.2.2 commander: ^11.0.0 - ethers: ^5.7.2 + ethers: 5.7.2 hardhat: ^2.7.2 jest: ^28.1.1 prettier: ^3.0.3 @@ -12403,8 +12403,8 @@ __metadata: "@types/whatwg-encoding": ^2.0.0 axios: ^1.5.0 axios-mock-adapter: ^1.21.2 + dm3-lib-crypto: "workspace:^" dm3-lib-profile: "workspace:^" - ethers: 5.7.2 jest: ^28.1.1 ts-jest: ^28.0.4 ts-json-schema-generator: ^0.98.0