mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #3024 from gradido/federation-introduce-private-key-in-community-table
feat(federation): introduce private key in community table
This commit is contained in:
commit
b27393f6e7
@ -12,7 +12,7 @@ Decimal.set({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0066-x-community-sendcoins-transactions_table',
|
DB_VERSION: '0067-private_key_in_community_table',
|
||||||
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
|
|||||||
@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
BaseEntity,
|
||||||
|
Entity,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
Column,
|
||||||
|
CreateDateColumn,
|
||||||
|
UpdateDateColumn,
|
||||||
|
} from 'typeorm'
|
||||||
|
|
||||||
|
@Entity('communities')
|
||||||
|
export class Community extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Column({ name: 'foreign', type: 'bool', nullable: false, default: true })
|
||||||
|
foreign: boolean
|
||||||
|
|
||||||
|
@Column({ name: 'url', length: 255, nullable: false })
|
||||||
|
url: string
|
||||||
|
|
||||||
|
@Column({ name: 'public_key', type: 'binary', length: 64, nullable: false })
|
||||||
|
publicKey: Buffer
|
||||||
|
|
||||||
|
@Column({ name: 'private_key', type: 'binary', length: 64, nullable: true })
|
||||||
|
privateKey: Buffer | null
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'community_uuid',
|
||||||
|
type: 'char',
|
||||||
|
length: 36,
|
||||||
|
nullable: true,
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
communityUuid: string | null
|
||||||
|
|
||||||
|
@Column({ name: 'authenticated_at', type: 'datetime', nullable: true })
|
||||||
|
authenticatedAt: Date | null
|
||||||
|
|
||||||
|
@Column({ name: 'name', type: 'varchar', length: 40, nullable: true })
|
||||||
|
name: string | null
|
||||||
|
|
||||||
|
@Column({ name: 'description', type: 'varchar', length: 255, nullable: true })
|
||||||
|
description: string | null
|
||||||
|
|
||||||
|
@CreateDateColumn({ name: 'creation_date', type: 'datetime', nullable: true })
|
||||||
|
creationDate: Date | null
|
||||||
|
|
||||||
|
@CreateDateColumn({
|
||||||
|
name: 'created_at',
|
||||||
|
type: 'datetime',
|
||||||
|
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
createdAt: Date
|
||||||
|
|
||||||
|
@UpdateDateColumn({
|
||||||
|
name: 'updated_at',
|
||||||
|
type: 'datetime',
|
||||||
|
onUpdate: 'CURRENT_TIMESTAMP(3)',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
updatedAt: Date | null
|
||||||
|
}
|
||||||
@ -1 +1 @@
|
|||||||
export { Community } from './0065-refactor_communities_table/Community'
|
export { Community } from './0067-private_key_in_community_table/Community'
|
||||||
|
|||||||
17
database/migrations/0067-private_key_in_community_table.ts
Normal file
17
database/migrations/0067-private_key_in_community_table.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* MIGRATION TO ADD PRIVATE KEY IN COMMUNITY TABLE
|
||||||
|
*
|
||||||
|
* This migration adds a field for the private key in the community.table
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn(
|
||||||
|
'ALTER TABLE `communities` ADD COLUMN `private_key` binary(64) DEFAULT NULL AFTER `public_key`;',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn('ALTER TABLE `communities` DROP COLUMN `private_key`;')
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@ import dotenv from 'dotenv'
|
|||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0066-x-community-sendcoins-transactions_table',
|
DB_VERSION: '0067-private_key_in_community_table',
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
|
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
|
||||||
|
|||||||
@ -221,6 +221,7 @@ async function writeHomeCommunityEntry(keyPair: KeyPair): Promise<void> {
|
|||||||
if (homeCom) {
|
if (homeCom) {
|
||||||
// simply update the existing entry, but it MUST keep the ID and UUID because of possible relations
|
// simply update the existing entry, but it MUST keep the ID and UUID because of possible relations
|
||||||
homeCom.publicKey = keyPair.publicKey
|
homeCom.publicKey = keyPair.publicKey
|
||||||
|
homeCom.privateKey = keyPair.secretKey
|
||||||
homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/'
|
homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/'
|
||||||
homeCom.name = CONFIG.COMMUNITY_NAME
|
homeCom.name = CONFIG.COMMUNITY_NAME
|
||||||
homeCom.description = CONFIG.COMMUNITY_DESCRIPTION
|
homeCom.description = CONFIG.COMMUNITY_DESCRIPTION
|
||||||
@ -231,6 +232,7 @@ async function writeHomeCommunityEntry(keyPair: KeyPair): Promise<void> {
|
|||||||
homeCom = new DbCommunity()
|
homeCom = new DbCommunity()
|
||||||
homeCom.foreign = false
|
homeCom.foreign = false
|
||||||
homeCom.publicKey = keyPair.publicKey
|
homeCom.publicKey = keyPair.publicKey
|
||||||
|
homeCom.privateKey = keyPair.secretKey
|
||||||
homeCom.communityUuid = await newCommunityUuid()
|
homeCom.communityUuid = await newCommunityUuid()
|
||||||
homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/'
|
homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/'
|
||||||
homeCom.name = CONFIG.COMMUNITY_NAME
|
homeCom.name = CONFIG.COMMUNITY_NAME
|
||||||
|
|||||||
@ -11,7 +11,7 @@ Decimal.set({
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0066-x-community-sendcoins-transactions_table',
|
DB_VERSION: '0067-private_key_in_community_table',
|
||||||
// DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
// DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user