From 790f700a9df6e98565805b79bc0abd8b11f67ea9 Mon Sep 17 00:00:00 2001 From: m0ar Date: Tue, 21 May 2024 14:06:39 +0200 Subject: [PATCH 1/3] workflows: patch staging deployment of reverse-proxy --- .../workflows/deploy-staging-services.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-staging-services.yaml b/.github/workflows/deploy-staging-services.yaml index 5dba2ae8..c1bf2437 100644 --- a/.github/workflows/deploy-staging-services.yaml +++ b/.github/workflows/deploy-staging-services.yaml @@ -13,6 +13,7 @@ env: CONTAINER_IMAGE_REPO: desci-repo-server CONTAINER_IMAGE_MEDIA: nodes-media-server CONTAINER_IMAGE_ISOLATED: desci-media-isolated + CONTAINER_IMAGE_PROXY: "reverse-proxy" DOCKER_BUILDKIT: 1 jobs: @@ -294,23 +295,23 @@ jobs: run: | # Build and tag the image docker build \ - -t $CONTAINER_IMAGE-staging:latest \ - -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging \ - ./$CONTAINER_IMAGE + -t $CONTAINER_IMAGE_PROXY-staging:latest \ + -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging \ + ./$CONTAINER_IMAGE_PROXY - name: Push (STAGING) run: | # Push image to AWS ECR aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com - docker tag $CONTAINER_IMAGE-staging:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging:${{ github.sha }} - docker tag $CONTAINER_IMAGE-staging:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging:latest - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging:${{ github.sha }} - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging:latest + docker tag $CONTAINER_IMAGE_PROXY-staging:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging:${{ github.sha }} + docker tag $CONTAINER_IMAGE_PROXY-staging:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging:latest + docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging:${{ github.sha }} + docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging:latest - name: Deploy to EKS (STAGING) run: | # defaults to latest kubectl binary version - kubectl apply -f $CONTAINER_IMAGE/deployment.yaml - kubectl set image deployment/reverse-proxy-staging reverse-proxy-staging=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-staging:${{ github.sha }} --record + kubectl apply -f $CONTAINER_IMAGE_PROXY/deployment.yaml + kubectl set image deployment/reverse-proxy-staging reverse-proxy-staging=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE_PROXY-staging:${{ github.sha }} --record - name: Verify EKS Deployment (STAGING) run: | From 061fae95dac0310971d4a5ab3061c0c0b6e043a9 Mon Sep 17 00:00:00 2001 From: m0ar Date: Thu, 16 May 2024 16:27:24 +0200 Subject: [PATCH 2/3] server: fix email logos --- .../src/templates/emails/BaseProvider.tsx | 4 +--- .../src/templates/emails/MagicCode.tsx | 6 +----- .../src/templates/emails/MainLayout.tsx | 20 ++++++++----------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/desci-server/src/templates/emails/BaseProvider.tsx b/desci-server/src/templates/emails/BaseProvider.tsx index 747bb1c6..7d515f2d 100644 --- a/desci-server/src/templates/emails/BaseProvider.tsx +++ b/desci-server/src/templates/emails/BaseProvider.tsx @@ -1,7 +1,7 @@ import { Tailwind } from '@react-email/components'; import React from 'react'; -const BaseProvider = ({ children }: { children: JSX.Element }) => { +export const BaseProvider = ({ children }: { children: JSX.Element }) => { return ( { ); }; - -export default BaseProvider; diff --git a/desci-server/src/templates/emails/MagicCode.tsx b/desci-server/src/templates/emails/MagicCode.tsx index f4bf2f42..81ca2dcd 100644 --- a/desci-server/src/templates/emails/MagicCode.tsx +++ b/desci-server/src/templates/emails/MagicCode.tsx @@ -1,16 +1,12 @@ import { Body, Container, - Column, Head, Heading, Html, Preview, - Row, Text, - Button, Section, - render, } from '@react-email/components'; import * as React from 'react'; @@ -29,7 +25,7 @@ export const MagicCodeEmail = ({ magicCode, ip }: MagicCodeEmailProps) => ( > - Confirm your contribution + Confirm your identity diff --git a/desci-server/src/templates/emails/MainLayout.tsx b/desci-server/src/templates/emails/MainLayout.tsx index 3c0382ce..aa411c98 100644 --- a/desci-server/src/templates/emails/MainLayout.tsx +++ b/desci-server/src/templates/emails/MainLayout.tsx @@ -1,27 +1,23 @@ -import { url } from 'inspector'; import { Body, Container, Column, Head, - Heading, Html, Img, Link, - Preview, Row, Section, Text, Font, } from '@react-email/components'; import React from 'react'; +import { BaseProvider } from './BaseProvider.js'; -import BaseProvider from './BaseProvider.js'; - -export const emailAssetsBaseUrl = 'https://ipfs.desci.com/ipfs'; -const cubertBkg = 'bafkreih6yx7ywj7trvpp45vergrnytad7ezsku75tefyro4qrrcfrrmrt4'; -const labsLogo = 'bafkreifvb7tleo5jaidjjf6lfjxb5bpjbs2nswp47bi7zh3hxbpc6fjyf4'; +export const emailAssetsBaseUrl = 'https://pub.desci.com/ipfs'; +// const cubertBkg = 'bafkreih6yx7ywj7trvpp45vergrnytad7ezsku75tefyro4qrrcfrrmrt4'; +const labsLogo = 'bafkreie2jto3flk2r43yt545xrasftbsc2atp5eb7qcbsmhacm26k4wiz4'; const defaultFooterMsg = "If you didn't request this email, there's nothing to worry about, you can safely ignore it."; const MainLayout = ({ children, footerMsg = defaultFooterMsg }: { children: JSX.Element; footerMsg?: string }) => { @@ -55,11 +51,11 @@ const MainLayout = ({ children, footerMsg = defaultFooterMsg }: { children: JSX.
Desci Labs
{children}
@@ -70,11 +66,11 @@ const MainLayout = ({ children, footerMsg = defaultFooterMsg }: { children: JSX. Desci Labs From 97a6f55b84dde6e9d9c78cd6354cd1c1bb6c3a6c Mon Sep 17 00:00:00 2001 From: shadrach-tayo Date: Wed, 22 May 2024 18:17:10 +0200 Subject: [PATCH 3/3] fix: Orcid schema and updates to OrcidApiService implementation --- desci-server/src/services/orcid.ts | 64 ++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/desci-server/src/services/orcid.ts b/desci-server/src/services/orcid.ts index 682eee87..6944393c 100644 --- a/desci-server/src/services/orcid.ts +++ b/desci-server/src/services/orcid.ts @@ -85,7 +85,21 @@ class OrcidApiService { userId: authToken.userId, }, }); - logger.info({ status: response.status, statusText: response.statusText, data }, 'REFRESH TOKEN RESPONSE'); + logger.info( + { + status: response.status, + statusText: response.statusText, + data: { + name: data.name, + scope: data.scope, + token_type: data.token_type, + orcid: data.orcid, + refreshToken: !!data.refresh_token, + accessToken: !!data.access_token, + }, + }, + 'REFRESH TOKEN RESPONSE', + ); } else { logger.info( { status: response.status, statusText: response.statusText, BODY: await response.json() }, @@ -230,13 +244,15 @@ class OrcidApiService { const latestVersion = researchObject.versions[researchObject.versions.length - 1]; const publicationDate = new Date(parseInt(latestVersion.time) * 1000).toLocaleDateString().replaceAll('/', '-'); + const contributorsXml = generateContributors(latestManifest.authors ?? [], orcid); const nodeRecordPromise = this.putNodeWorkRecord({ orcid, authToken, uuid: nodeUuid, - userId: user.id, nodeVersion, publicationDate, + contributorsXml, + userId: user.id, manifest: latestManifest, }); const claimRecordPromises = claims.map((claim) => { @@ -250,6 +266,7 @@ class OrcidApiService { publicationDate, orcid, authToken, + contributorsXml, uuid: nodeUuid, userId: user.id, nodeVersion: claimedVersionNumber, @@ -283,6 +300,7 @@ class OrcidApiService { authToken, orcid, nodeVersion, + contributorsXml, }: { manifest: ResearchObjectV1; publicationDate: string; @@ -291,6 +309,7 @@ class OrcidApiService { authToken: string; orcid: string; nodeVersion: number; + contributorsXml: string; }) { try { const orcidPutCode = await prisma.orcidPutCodes.findUnique({ @@ -298,7 +317,7 @@ class OrcidApiService { }); const putCode = orcidPutCode?.putcode; - let data = generateNodeWorkRecord({ manifest, publicationDate, nodeVersion, putCode }); + let data = generateNodeWorkRecord({ manifest, publicationDate, nodeVersion, putCode, contributorsXml }); data = data.replace(/\\"/g, '"'); const url = `${this.baseUrl}/${orcid}/work${putCode ? '/' + putCode : ''}`; @@ -388,8 +407,10 @@ class OrcidApiService { orcid, claim, nodeVersion, + contributorsXml, }: { claim: Claim; + contributorsXml: string; manifest: ResearchObjectV1; nodeVersion: number; publicationDate: string; @@ -410,7 +431,14 @@ class OrcidApiService { }); const putCode = orcidPutCode?.putcode; - let data = generateClaimWorkRecord({ nodeVersion, manifest, publicationDate, claim, putCode }); + let data = generateClaimWorkRecord({ + nodeVersion, + manifest, + publicationDate, + claim, + putCode, + contributorsXml, + }); data = data.replace(/\\"/g, '"'); const url = `${this.baseUrl}/${orcid}/work${putCode ? '/' + putCode : ''}`; @@ -500,9 +528,11 @@ const generateClaimWorkRecord = ({ claim, nodeVersion, publicationDate, + contributorsXml, }: { manifest: ResearchObjectV1; claim: Claim; + contributorsXml: string; putCode?: string; nodeVersion: number; publicationDate: string; @@ -514,9 +544,9 @@ const generateClaimWorkRecord = ({ ? 'data-set' : 'preprint'; - const description = `${claim.name} Attestation`; + const description = `${claim.name} availability verified`; const [month, day, year] = publicationDate.split('-'); - const externalUrl = `${DPID_URL_OVERRIDE}/${manifest.dpid.id}/attestation/${claim.id}`; + const externalUrl = `${DPID_URL_OVERRIDE}/${manifest.dpid.id}/v${nodeVersion}/attestation/${claim.id}`; const dataRoot = `${DPID_URL_OVERRIDE}/${manifest.dpid.id}/v${nodeVersion}`; logger.info({ codeAttr, workType, publicationDate, day, month, year, externalUrl }, 'CODE ATTR'); return ( @@ -525,7 +555,6 @@ const generateClaimWorkRecord = ({ '> ' + '' + ` ${manifest.title} - ${description} ${description} ${workType} @@ -548,7 +577,8 @@ const generateClaimWorkRecord = ({ part-of - ${generateContributors(manifest.authors ?? [])} + ${externalUrl} + ${contributorsXml} ` ); @@ -571,11 +601,13 @@ const generateNodeWorkRecord = ({ nodeVersion, putCode, publicationDate, + contributorsXml, }: { manifest: ResearchObjectV1; nodeVersion: number; putCode?: string; publicationDate: string; + contributorsXml: string; }): string => { const codeAttr = putCode ? 'put-code="' + putCode + '"' : ''; const workType = 'preprint'; @@ -588,9 +620,7 @@ const generateNodeWorkRecord = ({ '> ' + '' + ` ${manifest.title} - ${manifest.description.trim() ? `${manifest.description.trim()}` : ``} - ${manifest?.description?.trim() ? `${manifest.description}` : ``} ${workType} ${year} @@ -605,7 +635,8 @@ const generateNodeWorkRecord = ({ self - ${generateContributors(manifest.authors ?? [])} + ${dataRoot} + ${contributorsXml} ` ); @@ -617,11 +648,20 @@ const generateNodeWorkRecord = ({ * @param authors[] - A list of ResearchObjectV1Author entries * @returns {string} xml string of the constructed contributor data */ -const generateContributors = (authors: ResearchObjectV1Author[]): string => { +const generateContributors = (authors: ResearchObjectV1Author[], ownerOrcid: string): string => { + authors.reverse(); + + const authorIndex = authors.findIndex((author) => author.orcid === ownerOrcid); + if (authorIndex !== -1 && authorIndex !== 0) { + const mainAuthor = authors.splice(authorIndex, 1); + authors.unshift(mainAuthor[0]); + } + const contributors = authors?.length > 0 ? ` ${authors + .filter((author) => !!author.name) .map((author, idx) => { return ` ${