Skip to content

Commit

Permalink
build: devconnect deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
hai-ko committed Nov 11, 2023
1 parent 789ad1e commit bddfc38
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-billboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on: push

jobs:
messenger-demo-deploy:
environment: devconnect2023
runs-on: ubuntu-latest
# if: ${{ contains( github.ref, vars.STAGING_BRANCH) }}
environment: staging-billboard
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
Expand All @@ -29,14 +29,14 @@ jobs:
env:
TARGET_HOST: ${{ secrets.STAGING_HOST }}
run: |
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.bb-addr.dm3.eth" >> ./.env.react
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.addr.devconnect.dm3.eth" >> ./.env.react
echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env.react
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=bb-ds.devconnect.dm3.eth" >> ./.env.react
echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./.env.react
echo "REACT_APP_PROFILE_BASE_URL=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react
echo "REACT_APP_RESOLVER_BACKEND=http://${{ secrets.STAGING_HOST }}/resolver-handler" >> ./.env.react
echo "REACT_APP_USER_ENS_SUBDOMAIN=.beta-user.dm3.eth" >> ./.env.react
echo "REACT_APP_USER_ENS_SUBDOMAIN=.user.devconnect.dm3.eth" >> ./.env.react
echo "REACT_APP_WALLET_CONNECT_PROJECT_ID=${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}" >> ./.env.react
echo "REACT_APP_COMMIT_HASH=${{ env.sha_short }}" >> ./.env.react
echo "REACT_APP_BRANCH=${{ env.branch }}" >> ./.env.react
Expand Down
2 changes: 1 addition & 1 deletion docker/billboard/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
LOG_LEVEL: debug
CONFIG: |
{
"0x26139b2349282de5ee2bd9c7a53171a28d6a6c84": {
"0xc9bf092673b3a066df088a2a911e23e9b69b82f2": {
"type": "signing",
"handlerUrl": "http://offchain-resolver:8082"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/rpc/methods/handleSubmitMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function handleSubmitMessage(
} catch (error) {
global.logger.warn({
method: 'RPC SUBMIT MESSAGE',
error,
error: JSON.stringify(error),
});
logError({
text: '[handleSubmitMessage]',
Expand Down
9 changes: 9 additions & 0 deletions packages/lib/delivery/src/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,18 @@ export async function incomingMessage(

if (!tokenIsValid) {
//Token is invalid
logDebug({
text: 'incomingMessage token invalid',
});
throw Error('Token check failed');
}

//Retrives the session of the receiver
const receiverSession = await getSession(deliveryInformation.to);
if (!receiverSession) {
logDebug({
text: 'incomingMessage unknown session',
});
throw Error('unknown session');
}
logDebug({
Expand All @@ -155,6 +161,9 @@ export async function incomingMessage(

//Checkes if the message is spam
if (await isSpam(provider, receiverSession, deliveryInformation)) {
logDebug({
text: 'incomingMessage is spam',
});
throw Error('Message does not match spam criteria');
}

Expand Down
18 changes: 17 additions & 1 deletion packages/lib/delivery/src/Session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers } from 'ethers';
import { ProfileExtension, SignedUserProfile } from 'dm3-lib-profile';
import { logDebug } from 'dm3-lib-shared';

//1Year
const TTL = 31536000000;
Expand All @@ -23,30 +24,45 @@ export async function checkToken(
ensName: string,
token: string,
): Promise<boolean> {
logDebug({
text: 'checkToken',
});
const address = await provider.resolveName(ensName);

if (!address) {
// Couln't resolve ENS name
logDebug({
text: `checkToken - Couln't resolve ENS name`,
});
return false;
}

const session = await getSession(ensName.toLocaleLowerCase());

//There is now account for the requesting accoung
//There is no account for the requesting accoung
if (!session) {
logDebug({
text: `checkToken - There is no account for the requesting accoung`,
});
return false;
}

const tokenIsValid = token === session.token;

//The account has a session but the token is wrong
if (!tokenIsValid) {
logDebug({
text: `checkToken - The account has a session but the token is wrong`,
});
return false;
}

const isTokenExpired = session.createdAt + TTL < new Date().getTime();
//The token is exceeded
if (isTokenExpired) {
logDebug({
text: `checkToken - The token is exceeded`,
});
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/offchain-resolver/src/http/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ export function profile(web3Provider: ethers.providers.BaseProvider) {
}
global.logger.debug({
message: 'nameP setAlias',
hotAddr: hotAddr + '.bb-addr.dm3.eth',
alias: `${address}.bb-user.dm3.eth`,
hotAddr: hotAddr + '.addr.devconnect.dm3.eth',
alias: `${address}.user.devconnect.dm3.eth`,
});

await req.app.locals.db.removeAlias(
`${address}.bb-user.dm3.eth`,
`${address}.user.devconnect.dm3.eth`,
);

await req.app.locals.db.setAlias(
hotAddr + '.bb-addr.dm3.eth',
`${address}.bb-user.dm3.eth`,
hotAddr + '.addr.devconnect.dm3.eth',
`${address}.user.devconnect.dm3.eth`,
);

return res.sendStatus(200);
Expand Down

0 comments on commit bddfc38

Please sign in to comment.