From 00a6d15b5127c2093aa363cae26cb6c8c629bbdf Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Apr 2023 10:06:54 +0200 Subject: [PATCH 01/23] error message for incorrect redemption link --- .../LinkInformations/RedeemInformation.vue | 5 +++-- .../components/LinkInformations/RedeemValid.vue | 8 +++++++- frontend/src/locales/de.json | 1 + frontend/src/locales/en.json | 1 + frontend/src/pages/TransactionLink.vue | 14 +++++++++----- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/LinkInformations/RedeemInformation.vue b/frontend/src/components/LinkInformations/RedeemInformation.vue index d287605a4..7a55c5c01 100644 --- a/frontend/src/components/LinkInformations/RedeemInformation.vue +++ b/frontend/src/components/LinkInformations/RedeemInformation.vue @@ -1,11 +1,12 @@ @@ -47,12 +48,13 @@ export default { return { linkData: { __typename: 'TransactionLink', - amount: '123.45', - memo: 'memo', + amount: '', + memo: '', user: { - firstName: 'Bibi', + firstName: '', }, deletedAt: null, + validLink: false, }, } }, @@ -67,13 +69,15 @@ export default { }, }) .then((result) => { + this.validLink = true this.linkData = result.data.queryTransactionLink if (this.linkData.__typename === 'ContributionLink' && this.$store.state.token) { this.mutationLink(this.linkData.amount) } }) - .catch((err) => { - this.toastError(err.message) + .catch(() => { + this.toastError(this.$t('gdd_per_link.redeemlink-error')) + // this.$router.push('/overview') }) }, mutationLink(amount) { From c6a4e1a9df0a197cd2c43c8db9511d77c4353955 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Apr 2023 10:07:32 +0200 Subject: [PATCH 02/23] yarn lint --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 18024d2fd..c1bbea760 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -204,7 +204,7 @@ "redeemed": "Erfolgreich eingelöst! Deinem Konto wurden {n} GDD gutgeschrieben.", "redeemed-at": "Der Link wurde bereits am {date} eingelöst.", "redeemed-title": "eingelöst", - "redeemlink-error":"Dieser Einlöse-Link ist nicht vollständig.", + "redeemlink-error": "Dieser Einlöse-Link ist nicht vollständig.", "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto.", "validUntil": "Gültig bis", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 260d09343..7d0c28429 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -204,7 +204,7 @@ "redeemed": "Successfully redeemed! Your account has been credited with {n} GDD.", "redeemed-at": "The link was already redeemed on {date}.", "redeemed-title": "redeemed", - "redeemlink-error":"This redemption link is not complete.", + "redeemlink-error": "This redemption link is not complete.", "to-login": "Log in", "to-register": "Register a new account.", "validUntil": "Valid until", From ae4b88055e704a50839aee1d064649f08cd1483c Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Apr 2023 10:21:12 +0200 Subject: [PATCH 03/23] fix test --- frontend/src/pages/TransactionLink.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/TransactionLink.spec.js b/frontend/src/pages/TransactionLink.spec.js index adbb25226..349c6c36d 100644 --- a/frontend/src/pages/TransactionLink.spec.js +++ b/frontend/src/pages/TransactionLink.spec.js @@ -374,12 +374,12 @@ describe('TransactionLink', () => { describe('error on transaction link query', () => { beforeEach(() => { - apolloQueryMock.mockRejectedValue({ message: 'Ouchh!' }) + apolloQueryMock.mockRejectedValue({ message: 'gdd_per_link.redeemlink-error' }) wrapper = Wrapper() }) it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Ouchh!') + expect(toastErrorSpy).toBeCalledWith('gdd_per_link.redeemlink-error') }) }) }) From 3a6b73842744568864b976ae857f013e153817d1 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 09:24:57 +0200 Subject: [PATCH 04/23] update jest-canvas-mock version to resolve window mock problem in tests --- frontend/package.json | 2 +- frontend/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 8515ca209..f07284da6 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -44,7 +44,7 @@ "graphql": "^15.5.1", "identity-obj-proxy": "^3.0.0", "jest": "^26.6.3", - "jest-canvas-mock": "^2.3.1", + "jest-canvas-mock": "^2.5.0", "jwt-decode": "^3.1.2", "portal-vue": "^2.1.7", "prettier": "^2.2.1", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 9e8fdd81d..7cc8e5fe5 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -8657,10 +8657,10 @@ javascript-stringify@^1.6.0: resolved "https://registry.yarnpkg.com/javascript-stringify/-/javascript-stringify-1.6.0.tgz#142d111f3a6e3dae8f4a9afd77d45855b5a9cce3" integrity sha1-FC0RHzpuPa6PSpr9d9RYVbWpzOM= -jest-canvas-mock@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/jest-canvas-mock/-/jest-canvas-mock-2.3.1.tgz#9535d14bc18ccf1493be36ac37dd349928387826" - integrity sha512-5FnSZPrX3Q2ZfsbYNE3wqKR3+XorN8qFzDzB5o0golWgt6EOX1+emBnpOc9IAQ+NXFj8Nzm3h7ZdE/9H0ylBcg== +jest-canvas-mock@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/jest-canvas-mock/-/jest-canvas-mock-2.5.0.tgz#3e60f87f77ddfa273cf8e7e4ea5f86fa827c7117" + integrity sha512-s2bmY2f22WPMzhB2YA93kiyf7CAfWAnV/sFfY9s48IVOrGmwui1eSFluDPesq1M+7tSC1hJAit6mzO0ZNXvVBA== dependencies: cssfontparser "^1.2.1" moo-color "^1.0.2" From 5e4c4b274ca9b235132482e0b79a66a66e8d997a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 11:45:18 +0200 Subject: [PATCH 05/23] removed all test resolvers --- .../api/1_0/resolver/TestResolver.test.ts | 41 ----------------- .../graphql/api/1_0/resolver/TestResolver.ts | 14 ------ .../api/1_1/resolver/TestResolver.test.ts | 44 ------------------- .../graphql/api/1_1/resolver/TestResolver.ts | 14 ------ .../api/2_0/resolver/TestResolver.test.ts | 44 ------------------- .../graphql/api/2_0/resolver/TestResolver.ts | 14 ------ .../src/graphql/api/GetTestApiResult.ts | 13 ------ 7 files changed, 184 deletions(-) delete mode 100644 federation/src/graphql/api/1_0/resolver/TestResolver.test.ts delete mode 100644 federation/src/graphql/api/1_0/resolver/TestResolver.ts delete mode 100644 federation/src/graphql/api/1_1/resolver/TestResolver.test.ts delete mode 100644 federation/src/graphql/api/1_1/resolver/TestResolver.ts delete mode 100644 federation/src/graphql/api/2_0/resolver/TestResolver.test.ts delete mode 100644 federation/src/graphql/api/2_0/resolver/TestResolver.ts delete mode 100644 federation/src/graphql/api/GetTestApiResult.ts diff --git a/federation/src/graphql/api/1_0/resolver/TestResolver.test.ts b/federation/src/graphql/api/1_0/resolver/TestResolver.test.ts deleted file mode 100644 index e236ee5d8..000000000 --- a/federation/src/graphql/api/1_0/resolver/TestResolver.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { createTestClient } from 'apollo-server-testing' -import createServer from '@/server/createServer' - -let query: any - -// to do: We need a setup for the tests that closes the connection -let con: any - -beforeAll(async () => { - const server = await createServer() - con = server.con - query = createTestClient(server.apollo).query -}) - -afterAll(async () => { - await con.close() -}) - -describe('TestResolver', () => { - const getTestQuery = ` - query { - test { - api - } - } - ` - - describe('getTestApi', () => { - it('returns 1_0', async () => { - await expect(query({ query: getTestQuery })).resolves.toMatchObject({ - data: { - test: { - api: '1_0', - }, - }, - }) - }) - }) -}) diff --git a/federation/src/graphql/api/1_0/resolver/TestResolver.ts b/federation/src/graphql/api/1_0/resolver/TestResolver.ts deleted file mode 100644 index 9fb2fc797..000000000 --- a/federation/src/graphql/api/1_0/resolver/TestResolver.ts +++ /dev/null @@ -1,14 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 1_0`) - return new GetTestApiResult('1_0') - } -} diff --git a/federation/src/graphql/api/1_1/resolver/TestResolver.test.ts b/federation/src/graphql/api/1_1/resolver/TestResolver.test.ts deleted file mode 100644 index ad08345a7..000000000 --- a/federation/src/graphql/api/1_1/resolver/TestResolver.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { createTestClient } from 'apollo-server-testing' -import createServer from '@/server/createServer' -import CONFIG from '@/config' - -CONFIG.FEDERATION_API = '1_1' - -let query: any - -// to do: We need a setup for the tests that closes the connection -let con: any - -beforeAll(async () => { - const server = await createServer() - con = server.con - query = createTestClient(server.apollo).query -}) - -afterAll(async () => { - await con.close() -}) - -describe('TestResolver', () => { - const getTestQuery = ` - query { - test { - api - } - } - ` - - describe('getTestApi', () => { - it('returns 1_1', async () => { - await expect(query({ query: getTestQuery })).resolves.toMatchObject({ - data: { - test: { - api: '1_1', - }, - }, - }) - }) - }) -}) diff --git a/federation/src/graphql/api/1_1/resolver/TestResolver.ts b/federation/src/graphql/api/1_1/resolver/TestResolver.ts deleted file mode 100644 index 74e02b74a..000000000 --- a/federation/src/graphql/api/1_1/resolver/TestResolver.ts +++ /dev/null @@ -1,14 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 1_1`) - return new GetTestApiResult('1_1') - } -} diff --git a/federation/src/graphql/api/2_0/resolver/TestResolver.test.ts b/federation/src/graphql/api/2_0/resolver/TestResolver.test.ts deleted file mode 100644 index 02fd8c358..000000000 --- a/federation/src/graphql/api/2_0/resolver/TestResolver.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { createTestClient } from 'apollo-server-testing' -import createServer from '@/server/createServer' -import CONFIG from '@/config' - -CONFIG.FEDERATION_API = '2_0' - -let query: any - -// to do: We need a setup for the tests that closes the connection -let con: any - -beforeAll(async () => { - const server = await createServer() - con = server.con - query = createTestClient(server.apollo).query -}) - -afterAll(async () => { - await con.close() -}) - -describe('TestResolver', () => { - const getTestQuery = ` - query { - test { - api - } - } - ` - - describe('getTestApi', () => { - it('returns 2_0', async () => { - await expect(query({ query: getTestQuery })).resolves.toMatchObject({ - data: { - test: { - api: '2_0', - }, - }, - }) - }) - }) -}) diff --git a/federation/src/graphql/api/2_0/resolver/TestResolver.ts b/federation/src/graphql/api/2_0/resolver/TestResolver.ts deleted file mode 100644 index 4202bbbfe..000000000 --- a/federation/src/graphql/api/2_0/resolver/TestResolver.ts +++ /dev/null @@ -1,14 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 2_0`) - return new GetTestApiResult('2_0') - } -} diff --git a/federation/src/graphql/api/GetTestApiResult.ts b/federation/src/graphql/api/GetTestApiResult.ts deleted file mode 100644 index 942ff7b6c..000000000 --- a/federation/src/graphql/api/GetTestApiResult.ts +++ /dev/null @@ -1,13 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Field, ObjectType } from 'type-graphql' - -@ObjectType() -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export class GetTestApiResult { - constructor(apiVersion: string) { - this.api = apiVersion - } - - @Field(() => String) - api: string -} From 15ca48a3321f53b9a5fecab93ac7e5da05af7221 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 11:45:51 +0200 Subject: [PATCH 06/23] implement PublicKeyResolver for 1.1 using inheritance --- .../src/graphql/api/1_1/resolver/PublicKeyResolver.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts diff --git a/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts new file mode 100644 index 000000000..b285cbba8 --- /dev/null +++ b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts @@ -0,0 +1,7 @@ +import { Resolver } from 'type-graphql' +// eslint-disable-next-line camelcase +import { PublicKeyResolver as PublicKeyResolver_1_0 } from '../../1_0/resolver/PublicKeyResolver' + +@Resolver() +// eslint-disable-next-line camelcase, @typescript-eslint/no-unused-vars +export class PublicKeyResolver extends PublicKeyResolver_1_0 {} From 403c0f1f646cd4df8cd2d9cc359ead67f545a1ae Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 11:48:01 +0200 Subject: [PATCH 07/23] removed Decimal Scalar to meet coverage requirement, no decimal is used yet --- .../src/graphql/scalar/{Decimal.ts => Decimal.ts.unused} | 0 federation/src/graphql/schema.ts | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename federation/src/graphql/scalar/{Decimal.ts => Decimal.ts.unused} (100%) diff --git a/federation/src/graphql/scalar/Decimal.ts b/federation/src/graphql/scalar/Decimal.ts.unused similarity index 100% rename from federation/src/graphql/scalar/Decimal.ts rename to federation/src/graphql/scalar/Decimal.ts.unused diff --git a/federation/src/graphql/schema.ts b/federation/src/graphql/schema.ts index 92977882b..015ea124f 100644 --- a/federation/src/graphql/schema.ts +++ b/federation/src/graphql/schema.ts @@ -2,15 +2,15 @@ import { GraphQLSchema } from 'graphql' import { buildSchema } from 'type-graphql' // import isAuthorized from './directive/isAuthorized' -import DecimalScalar from './scalar/Decimal' -import Decimal from 'decimal.js-light' +// import DecimalScalar from './scalar/Decimal' +// import Decimal from 'decimal.js-light' import { getApiResolvers } from './api/schema' const schema = async (): Promise => { return await buildSchema({ resolvers: [getApiResolvers()], // authChecker: isAuthorized, - scalarsMap: [{ type: Decimal, scalar: DecimalScalar }], + // scalarsMap: [{ type: Decimal, scalar: DecimalScalar }], }) } From 74b9c86e6650dc59c00c6df29d301956b9dff5d5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 11:54:36 +0200 Subject: [PATCH 08/23] remove reference to api 2.0 from bare_metal .env.dist --- deployment/bare_metal/.env.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index f20a8c2d1..f81c62eca 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -68,7 +68,7 @@ FEDERATION_COMMUNITY_API_PORT=5000 FEDERATION_CONFIG_VERSION=v1.2023-01-09 # comma separated list of api-versions, which cause starting several federation modules -FEDERATION_COMMUNITY_APIS=1_0,1_1,2_0 +FEDERATION_COMMUNITY_APIS=1_0,1_1 # database DATABASE_CONFIG_VERSION=v1.2022-03-18 From cf941518ed88283a16e012bc34599bdc4e7f8e4b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 11:56:50 +0200 Subject: [PATCH 09/23] lint fixes --- federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts index b285cbba8..e03b36075 100644 --- a/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts +++ b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars import { Resolver } from 'type-graphql' // eslint-disable-next-line camelcase import { PublicKeyResolver as PublicKeyResolver_1_0 } from '../../1_0/resolver/PublicKeyResolver' From 538354f56efcb661545d3411986b7d81333c885d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:34:13 +0200 Subject: [PATCH 10/23] simplify newCommunityUuid --- dht-node/src/dht_node/index.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 36291904a..40ef8f4ee 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -250,14 +250,11 @@ async function writeHomeCommunityEntry(pubKey: string): Promise { } const newCommunityUuid = async (): Promise => { - let uuid: string - let countIds: number - do { - uuid = uuidv4() - countIds = await DbCommunity.count({ where: { communityUuid: uuid } }) - if (countIds > 0) { - logger.info('CommunityUuid creation conflict...') + while (true) { + const communityUuid = uuidv4() + if ((await DbCommunity.count({ where: { communityUuid } })) === 0) { + return communityUuid } - } while (countIds > 0) - return uuid + logger.info('CommunityUuid creation conflict...', communityUuid) + } } From 38b17678ebbf36e45b6ffb23570fd5469b7078d8 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:39:06 +0200 Subject: [PATCH 11/23] remove export from CommunityApi --- dht-node/src/dht_node/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 36291904a..1bd34d316 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -24,7 +24,7 @@ enum ApiVersionType { V1_1 = '1_1', V2_0 = '2_0', } -export type CommunityApi = { +type CommunityApi = { api: string url: string } From a7e34ca6af8bbe8a4182dd5c1ea37528ae065e9d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:44:41 +0200 Subject: [PATCH 12/23] remove function getSeed --- dht-node/src/dht_node/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 36291904a..d0ae1e67b 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -8,11 +8,6 @@ import { Community as DbCommunity } from '@entity/Community' import { v4 as uuidv4 } from 'uuid' const KEY_SECRET_SEEDBYTES = 32 -const getSeed = (): Buffer | null => { - return CONFIG.FEDERATION_DHT_SEED - ? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED) - : null -} const POLLTIME = 20000 const SUCCESSTIME = 120000 @@ -32,7 +27,9 @@ export type CommunityApi = { export const startDHT = async (topic: string): Promise => { try { const TOPIC = DHT.hash(Buffer.from(topic)) - const keyPair = DHT.keyPair(getSeed()) + const keyPair = DHT.keyPair(CONFIG.FEDERATION_DHT_SEED + ? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED) + : null) const pubKeyString = keyPair.publicKey.toString('hex') logger.info(`keyPairDHT: publicKey=${pubKeyString}`) logger.debug(`keyPairDHT: secretKey=${keyPair.secretKey.toString('hex')}`) From 24df41365a37571c0693d897ac3b21b79f1ce4bd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:51:33 +0200 Subject: [PATCH 13/23] linting --- dht-node/src/dht_node/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index d0ae1e67b..75cecc3a7 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -27,9 +27,11 @@ export type CommunityApi = { export const startDHT = async (topic: string): Promise => { try { const TOPIC = DHT.hash(Buffer.from(topic)) - const keyPair = DHT.keyPair(CONFIG.FEDERATION_DHT_SEED - ? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED) - : null) + const keyPair = DHT.keyPair( + CONFIG.FEDERATION_DHT_SEED + ? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED) + : null, + ) const pubKeyString = keyPair.publicKey.toString('hex') logger.info(`keyPairDHT: publicKey=${pubKeyString}`) logger.debug(`keyPairDHT: secretKey=${keyPair.secretKey.toString('hex')}`) From 5f2029d55c444b3d0b27117481029e87735438fd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 10:44:16 +0200 Subject: [PATCH 14/23] remove duplicate comments --- .../migrations/0066-x-community-sendcoins-transactions_table.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/database/migrations/0066-x-community-sendcoins-transactions_table.ts b/database/migrations/0066-x-community-sendcoins-transactions_table.ts index 2a90f297a..425248c22 100644 --- a/database/migrations/0066-x-community-sendcoins-transactions_table.ts +++ b/database/migrations/0066-x-community-sendcoins-transactions_table.ts @@ -66,8 +66,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis ) } -/* eslint-disable @typescript-eslint/no-empty-function */ -/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { await queryFn('ALTER TABLE `transactions` DROP COLUMN `user_gradido_id`;') await queryFn('ALTER TABLE `transactions` DROP COLUMN `user_name`;') From 12265a79da6e155a2a880f03545b3b82ebb5b0c7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 31 May 2023 11:35:51 +0200 Subject: [PATCH 15/23] changes reviews --- frontend/src/pages/TransactionLink.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/pages/TransactionLink.vue b/frontend/src/pages/TransactionLink.vue index 21bc833c6..9444d7d18 100644 --- a/frontend/src/pages/TransactionLink.vue +++ b/frontend/src/pages/TransactionLink.vue @@ -77,7 +77,6 @@ export default { }) .catch(() => { this.toastError(this.$t('gdd_per_link.redeemlink-error')) - // this.$router.push('/overview') }) }, mutationLink(amount) { From 97513c1b2564951cf9f9e5a34f992a2dc6e34e07 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 12:24:12 +0200 Subject: [PATCH 16/23] enforce FEDERATION_API 1.0 on getpublicKey Resolver --- .../src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts index 18d2a7599..83c024c9f 100644 --- a/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts +++ b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.test.ts @@ -3,12 +3,15 @@ import { createTestClient } from 'apollo-server-testing' import createServer from '@/server/createServer' import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity' +import CONFIG from '@/config' let query: any // to do: We need a setup for the tests that closes the connection let con: any +CONFIG.FEDERATION_API = '1_0' + beforeAll(async () => { const server = await createServer() con = server.con From 33375c347ff69b2f8d7fe0a7d8ffce1fe19040ac Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 18 May 2023 12:24:49 +0200 Subject: [PATCH 17/23] also test getPublicKey for 1.1 --- .../1_1/resolver/PublicKeyResolver.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts diff --git a/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts new file mode 100644 index 000000000..d41b53263 --- /dev/null +++ b/federation/src/graphql/api/1_1/resolver/PublicKeyResolver.test.ts @@ -0,0 +1,56 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { createTestClient } from 'apollo-server-testing' +import createServer from '@/server/createServer' +import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity' +import CONFIG from '@/config' + +let query: any + +// to do: We need a setup for the tests that closes the connection +let con: any + +CONFIG.FEDERATION_API = '1_1' + +beforeAll(async () => { + const server = await createServer() + con = server.con + query = createTestClient(server.apollo).query + DbFederatedCommunity.clear() +}) + +afterAll(async () => { + await con.close() +}) + +describe('PublicKeyResolver', () => { + const getPublicKeyQuery = ` + query { + getPublicKey + { + publicKey + } + } + ` + + describe('getPublicKey', () => { + beforeEach(async () => { + const homeCom = new DbFederatedCommunity() + homeCom.foreign = false + homeCom.apiVersion = '1_0' + homeCom.endPoint = 'endpoint-url' + homeCom.publicKey = Buffer.from('homeCommunity-publicKey') + await DbFederatedCommunity.insert(homeCom) + }) + + it('returns homeCommunity-publicKey', async () => { + await expect(query({ query: getPublicKeyQuery })).resolves.toMatchObject({ + data: { + getPublicKey: { + publicKey: expect.stringMatching('homeCommunity-publicKey'), + }, + }, + }) + }) + }) +}) From adc6998617899a9b22880023d4144777c6acaafc Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 11:09:22 +0200 Subject: [PATCH 18/23] include comment to explain key pair tenary --- dht-node/src/dht_node/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 75cecc3a7..ca00a5cee 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -27,6 +27,7 @@ export type CommunityApi = { export const startDHT = async (topic: string): Promise => { try { const TOPIC = DHT.hash(Buffer.from(topic)) + // uses a config defined seed or null, which will generate a random seed for the key pair const keyPair = DHT.keyPair( CONFIG.FEDERATION_DHT_SEED ? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED) From 75d7ad4a3c7d4d24f9f3c30684d28dee80b8d8bb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 12:50:19 +0200 Subject: [PATCH 19/23] types for random-bigint --- backend/@types/random-bigint/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 backend/@types/random-bigint/index.d.ts diff --git a/backend/@types/random-bigint/index.d.ts b/backend/@types/random-bigint/index.d.ts new file mode 100644 index 000000000..e76cf8e1f --- /dev/null +++ b/backend/@types/random-bigint/index.d.ts @@ -0,0 +1,5 @@ +/* eslint-disable @typescript-eslint/ban-types */ +declare module 'random-bigint' { + export function random(bits: number, cb?: (err: Error, num: BigInt) => void): BigInt + export = random +} From c2a32088491d7d10f0123df7fd31cecf53911b62 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 12:50:33 +0200 Subject: [PATCH 20/23] import random-biginto properly --- backend/src/graphql/resolver/UserResolver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index cbfd9b5c5..59a6e3cbc 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -70,13 +70,13 @@ import { communityDbUser } from '@/util/communityUser' import { hasElopageBuys } from '@/util/hasElopageBuys' import { getTimeDurationObject, printTimeDuration } from '@/util/time' +import { random } from 'random-bigint' + import { FULL_CREATION_AVAILABLE } from './const/const' import { getUserCreations } from './util/creations' import { findUserByIdentifier } from './util/findUserByIdentifier' import { validateAlias } from './util/validateAlias' -// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs -const random = require('random-bigint') // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs const sodium = require('sodium-native') From 68f77e4d1fb05528f7764f6cbda263e8a5b4630b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 12:50:53 +0200 Subject: [PATCH 21/23] ignore random-bigint inport-relative rule --- backend/.eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 78ac9e41e..0007fd125 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -58,7 +58,7 @@ module.exports = { 'import/no-dynamic-require': 'error', 'import/no-internal-modules': 'off', 'import/no-relative-packages': 'error', - 'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }], + 'import/no-relative-parent-imports': ['error', { ignore: ['@/*', 'random-bigint'] }], 'import/no-self-import': 'error', 'import/no-unresolved': 'error', 'import/no-useless-path-segments': 'error', From 18a4829ea67419b6e5eb1801698fc5f53045ae72 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 13:02:21 +0200 Subject: [PATCH 22/23] try with default export --- backend/@types/random-bigint/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/@types/random-bigint/index.d.ts b/backend/@types/random-bigint/index.d.ts index e76cf8e1f..afaa832d9 100644 --- a/backend/@types/random-bigint/index.d.ts +++ b/backend/@types/random-bigint/index.d.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/ban-types */ declare module 'random-bigint' { export function random(bits: number, cb?: (err: Error, num: BigInt) => void): BigInt - export = random + // eslint-disable-next-line import/no-default-export + export default random } From 8545b2b9c55bd35dbf91ff0566e76e9825ff7ede Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 6 Jun 2023 13:06:24 +0200 Subject: [PATCH 23/23] fix import properly --- backend/@types/random-bigint/index.d.ts | 5 ++--- backend/src/graphql/resolver/UserResolver.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/@types/random-bigint/index.d.ts b/backend/@types/random-bigint/index.d.ts index afaa832d9..0f685e722 100644 --- a/backend/@types/random-bigint/index.d.ts +++ b/backend/@types/random-bigint/index.d.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/ban-types */ declare module 'random-bigint' { - export function random(bits: number, cb?: (err: Error, num: BigInt) => void): BigInt - // eslint-disable-next-line import/no-default-export - export default random + function random(bits: number, cb?: (err: Error, num: BigInt) => void): BigInt + export = random } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 59a6e3cbc..9934c93de 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -70,7 +70,7 @@ import { communityDbUser } from '@/util/communityUser' import { hasElopageBuys } from '@/util/hasElopageBuys' import { getTimeDurationObject, printTimeDuration } from '@/util/time' -import { random } from 'random-bigint' +import random from 'random-bigint' import { FULL_CREATION_AVAILABLE } from './const/const' import { getUserCreations } from './util/creations'