From 9c5d8b01297e18de02777f3bb1309faa2c5849e3 Mon Sep 17 00:00:00 2001 From: wulfraem Date: Thu, 26 Sep 2019 11:39:56 +0200 Subject: [PATCH 01/11] remove custom agpl appendix - [CORE-514] --- VERSIONS.md | 1 + scripts/buildContracts.js | 37 +++++++------------ scripts/commit-msg.js | 19 ++++++++++ scripts/link.sh | 17 +++++++++ src/common/utils.spec.ts | 8 ---- src/common/utils.ts | 8 ---- src/config-core.ts | 8 ---- src/config-testcore.ts | 8 ---- .../base-contract/base-contract.spec.ts | 8 ---- src/contracts/base-contract/base-contract.ts | 8 ---- .../business-center/business-center.spec.ts | 8 ---- .../data-contract/data-contract.spec.ts | 8 ---- src/contracts/data-contract/data-contract.ts | 8 ---- src/contracts/digital-twin/container.spec.ts | 8 ---- src/contracts/digital-twin/container.ts | 8 ---- .../digital-twin/digital-twin.spec.ts | 8 ---- src/contracts/digital-twin/digital-twin.ts | 8 ---- src/contracts/executor-agent.spec.ts | 8 ---- src/contracts/executor-agent.ts | 8 ---- src/contracts/executor-wallet.spec.ts | 8 ---- src/contracts/executor-wallet.ts | 8 ---- src/contracts/rights-and-roles.spec.ts | 8 ---- src/contracts/rights-and-roles.ts | 8 ---- .../service-contract/service-contract.spec.ts | 8 ---- .../service-contract/service-contract.ts | 8 ---- src/contracts/sharing.spec.ts | 8 ---- src/contracts/sharing.ts | 8 ---- src/contracts/wallet.spec.ts | 8 ---- src/contracts/wallet.ts | 8 ---- src/dfs/in-memory-cache.ts | 29 ++++++++------- src/dfs/ipfs-lib.ts | 30 ++++++++------- src/dfs/ipfs.spec.ts | 29 ++++++++------- src/dfs/ipfs.ts | 29 ++++++++------- src/dfs/ipld.spec.ts | 8 ---- src/dfs/ipld.ts | 8 ---- src/encryption/aes-blob.spec.ts | 8 ---- src/encryption/aes-blob.ts | 8 ---- src/encryption/aes-ecb.spec.ts | 8 ---- src/encryption/aes-ecb.ts | 8 ---- src/encryption/aes.spec.ts | 8 ---- src/encryption/aes.ts | 8 ---- src/encryption/crypto-provider.ts | 8 ---- src/encryption/encryption-wrapper.spec.ts | 8 ---- src/encryption/encryption-wrapper.ts | 8 ---- src/index.ts | 8 ---- src/keyExchange.spec.ts | 8 ---- src/keyExchange.ts | 8 ---- src/mailbox.spec.ts | 8 ---- src/mailbox.ts | 8 ---- src/name-resolver.spec.ts | 8 ---- src/name-resolver.ts | 8 ---- src/onboarding.spec.ts | 8 ---- src/onboarding.ts | 8 ---- src/payments.spec.ts | 8 ---- src/payments.ts | 8 ---- src/profile/business-center-profile.spec.ts | 8 ---- src/profile/business-center-profile.ts | 8 ---- src/profile/profile.spec.ts | 8 ---- src/profile/profile.ts | 8 ---- src/runtime.spec.ts | 8 ---- src/runtime.ts | 8 ---- src/shared-description.spec.ts | 8 ---- src/shared-description.ts | 8 ---- src/test/accounts.ts | 8 ---- src/test/test-utils.ts | 8 ---- src/verifications/verifications.spec.ts | 8 ---- src/verifications/verifications.ts | 8 ---- src/votings/votings.spec.ts | 8 ---- src/votings/votings.ts | 8 ---- 69 files changed, 116 insertions(+), 563 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index 10d09526..1e4e45e0 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -4,6 +4,7 @@ ### Features ### Fixes +- remove custom agpl appendix ### Deprecations diff --git a/scripts/buildContracts.js b/scripts/buildContracts.js index e1c492ce..9e92f9d9 100644 --- a/scripts/buildContracts.js +++ b/scripts/buildContracts.js @@ -1,29 +1,20 @@ /* - Copyright (C) 2018-present evan GmbH. - + Copyright (C) 2018-present evan GmbH. + This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License, version 3, - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with this program. - If not, see http://www.gnu.org/licenses/ or write to the - - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, - - or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public License - by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts of it - on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: https://evan.network/license/ - + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ */ const smartContractsCore = require('@evan.network/smart-contracts-core'); diff --git a/scripts/commit-msg.js b/scripts/commit-msg.js index 62e00915..159b9619 100644 --- a/scripts/commit-msg.js +++ b/scripts/commit-msg.js @@ -1,3 +1,22 @@ +/* + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ +*/ + var fs = require('fs'); var path = require('path'); diff --git a/scripts/link.sh b/scripts/link.sh index 0d7bd1c4..799d8cff 100755 --- a/scripts/link.sh +++ b/scripts/link.sh @@ -1,5 +1,22 @@ #!/bin/sh +# Copyright (C) 2018-present evan GmbH. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License, version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ or +# write to the Free Software Foundation, Inc., 51 Franklin Street, +# Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from +# the following URL: https://evan.network/license/ + root="$(pwd)/../" # $1 is parent module diff --git a/src/common/utils.spec.ts b/src/common/utils.spec.ts index bb512dfb..b69f2de8 100644 --- a/src/common/utils.spec.ts +++ b/src/common/utils.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/common/utils.ts b/src/common/utils.ts index 0069add8..c61bfdcf 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { Runtime } from '../index' diff --git a/src/config-core.ts b/src/config-core.ts index 863042d5..baf02187 100644 --- a/src/config-core.ts +++ b/src/config-core.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ const configCore = { diff --git a/src/config-testcore.ts b/src/config-testcore.ts index 84d623ef..cc2ff00a 100644 --- a/src/config-testcore.ts +++ b/src/config-testcore.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ const configTestcore = { diff --git a/src/contracts/base-contract/base-contract.spec.ts b/src/contracts/base-contract/base-contract.spec.ts index 8d4ec8c4..f84c5f88 100644 --- a/src/contracts/base-contract/base-contract.spec.ts +++ b/src/contracts/base-contract/base-contract.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/base-contract/base-contract.ts b/src/contracts/base-contract/base-contract.ts index 80703d5b..8c149571 100644 --- a/src/contracts/base-contract/base-contract.ts +++ b/src/contracts/base-contract/base-contract.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/contracts/business-center/business-center.spec.ts b/src/contracts/business-center/business-center.spec.ts index 2fb5b147..b443af16 100644 --- a/src/contracts/business-center/business-center.spec.ts +++ b/src/contracts/business-center/business-center.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/data-contract/data-contract.spec.ts b/src/contracts/data-contract/data-contract.spec.ts index 2ee18a2c..10d0f9b6 100644 --- a/src/contracts/data-contract/data-contract.spec.ts +++ b/src/contracts/data-contract/data-contract.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/data-contract/data-contract.ts b/src/contracts/data-contract/data-contract.ts index 37cfc3f3..e899d422 100644 --- a/src/contracts/data-contract/data-contract.ts +++ b/src/contracts/data-contract/data-contract.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto'); diff --git a/src/contracts/digital-twin/container.spec.ts b/src/contracts/digital-twin/container.spec.ts index e2afc79b..962af39d 100644 --- a/src/contracts/digital-twin/container.spec.ts +++ b/src/contracts/digital-twin/container.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { promisify } from 'util'; diff --git a/src/contracts/digital-twin/container.ts b/src/contracts/digital-twin/container.ts index 85a29e51..e63b1c89 100644 --- a/src/contracts/digital-twin/container.ts +++ b/src/contracts/digital-twin/container.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import * as Throttle from 'promise-parallel-throttle'; diff --git a/src/contracts/digital-twin/digital-twin.spec.ts b/src/contracts/digital-twin/digital-twin.spec.ts index b34d4ac1..7a50ae2d 100644 --- a/src/contracts/digital-twin/digital-twin.spec.ts +++ b/src/contracts/digital-twin/digital-twin.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/digital-twin/digital-twin.ts b/src/contracts/digital-twin/digital-twin.ts index 7c2050be..bb8020c3 100644 --- a/src/contracts/digital-twin/digital-twin.ts +++ b/src/contracts/digital-twin/digital-twin.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import * as Throttle from 'promise-parallel-throttle'; diff --git a/src/contracts/executor-agent.spec.ts b/src/contracts/executor-agent.spec.ts index 42919df2..060e83c7 100644 --- a/src/contracts/executor-agent.spec.ts +++ b/src/contracts/executor-agent.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/executor-agent.ts b/src/contracts/executor-agent.ts index ae5f5cc1..c13653de 100644 --- a/src/contracts/executor-agent.ts +++ b/src/contracts/executor-agent.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ const BigNumber = require('bignumber.js'); diff --git a/src/contracts/executor-wallet.spec.ts b/src/contracts/executor-wallet.spec.ts index 028ed250..d487e380 100644 --- a/src/contracts/executor-wallet.spec.ts +++ b/src/contracts/executor-wallet.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/executor-wallet.ts b/src/contracts/executor-wallet.ts index 81623189..457cb8d9 100644 --- a/src/contracts/executor-wallet.ts +++ b/src/contracts/executor-wallet.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/contracts/rights-and-roles.spec.ts b/src/contracts/rights-and-roles.spec.ts index a821252d..4b2174f5 100644 --- a/src/contracts/rights-and-roles.spec.ts +++ b/src/contracts/rights-and-roles.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/rights-and-roles.ts b/src/contracts/rights-and-roles.ts index c4f75c6d..1fa0700c 100644 --- a/src/contracts/rights-and-roles.ts +++ b/src/contracts/rights-and-roles.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import prottle = require('prottle'); diff --git a/src/contracts/service-contract/service-contract.spec.ts b/src/contracts/service-contract/service-contract.spec.ts index 320d76e6..e4c20ecc 100644 --- a/src/contracts/service-contract/service-contract.spec.ts +++ b/src/contracts/service-contract/service-contract.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/service-contract/service-contract.ts b/src/contracts/service-contract/service-contract.ts index e5712a6f..2db982b3 100644 --- a/src/contracts/service-contract/service-contract.ts +++ b/src/contracts/service-contract/service-contract.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import _ = require('lodash'); diff --git a/src/contracts/sharing.spec.ts b/src/contracts/sharing.spec.ts index 17e896cf..fcd41f95 100644 --- a/src/contracts/sharing.spec.ts +++ b/src/contracts/sharing.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/sharing.ts b/src/contracts/sharing.ts index 339e3a52..a5d5c2ff 100644 --- a/src/contracts/sharing.ts +++ b/src/contracts/sharing.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/contracts/wallet.spec.ts b/src/contracts/wallet.spec.ts index 0105e598..b9ffa99b 100644 --- a/src/contracts/wallet.spec.ts +++ b/src/contracts/wallet.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/contracts/wallet.ts b/src/contracts/wallet.ts index de90bb4b..f7ae2680 100644 --- a/src/contracts/wallet.ts +++ b/src/contracts/wallet.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { AbiCoder } from 'web3-eth-abi'; diff --git a/src/dfs/in-memory-cache.ts b/src/dfs/in-memory-cache.ts index 06aeb6f2..5aed61f2 100644 --- a/src/dfs/in-memory-cache.ts +++ b/src/dfs/in-memory-cache.ts @@ -1,17 +1,20 @@ /* - Copyright (c) 2018-present evan GmbH. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ */ import { diff --git a/src/dfs/ipfs-lib.ts b/src/dfs/ipfs-lib.ts index a0c20955..e97a13b3 100644 --- a/src/dfs/ipfs-lib.ts +++ b/src/dfs/ipfs-lib.ts @@ -1,18 +1,22 @@ /* - Copyright (c) 2018-present evan GmbH. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ */ + import * as http from 'http'; import * as https from 'https'; diff --git a/src/dfs/ipfs.spec.ts b/src/dfs/ipfs.spec.ts index 0fe96e8c..2924f64f 100644 --- a/src/dfs/ipfs.spec.ts +++ b/src/dfs/ipfs.spec.ts @@ -1,17 +1,20 @@ /* - Copyright (c) 2018-present evan GmbH. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ */ import 'mocha'; diff --git a/src/dfs/ipfs.ts b/src/dfs/ipfs.ts index 34c0a48e..46478ec3 100644 --- a/src/dfs/ipfs.ts +++ b/src/dfs/ipfs.ts @@ -1,17 +1,20 @@ /* - Copyright (c) 2018-present evan GmbH. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ */ import { setTimeout, clearTimeout } from 'timers'; diff --git a/src/dfs/ipld.spec.ts b/src/dfs/ipld.spec.ts index 3cc5740d..3aca9f68 100644 --- a/src/dfs/ipld.spec.ts +++ b/src/dfs/ipld.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/dfs/ipld.ts b/src/dfs/ipld.ts index cb59a5d9..c5eb1f10 100644 --- a/src/dfs/ipld.ts +++ b/src/dfs/ipld.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import Graph = require('ipld-graph-builder'); diff --git a/src/encryption/aes-blob.spec.ts b/src/encryption/aes-blob.spec.ts index 68911292..5ee73871 100644 --- a/src/encryption/aes-blob.spec.ts +++ b/src/encryption/aes-blob.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/encryption/aes-blob.ts b/src/encryption/aes-blob.ts index 478bad1c..80d5f226 100644 --- a/src/encryption/aes-blob.ts +++ b/src/encryption/aes-blob.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto-browserify'); diff --git a/src/encryption/aes-ecb.spec.ts b/src/encryption/aes-ecb.spec.ts index 47a9d366..af147053 100644 --- a/src/encryption/aes-ecb.spec.ts +++ b/src/encryption/aes-ecb.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/encryption/aes-ecb.ts b/src/encryption/aes-ecb.ts index fbfdd501..90a784a8 100644 --- a/src/encryption/aes-ecb.ts +++ b/src/encryption/aes-ecb.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto-browserify'); diff --git a/src/encryption/aes.spec.ts b/src/encryption/aes.spec.ts index 929d56fa..2ba41a99 100644 --- a/src/encryption/aes.spec.ts +++ b/src/encryption/aes.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/encryption/aes.ts b/src/encryption/aes.ts index ddb4098f..0ff1cce5 100644 --- a/src/encryption/aes.ts +++ b/src/encryption/aes.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto-browserify'); diff --git a/src/encryption/crypto-provider.ts b/src/encryption/crypto-provider.ts index 8b8fa48a..08da3526 100644 --- a/src/encryption/crypto-provider.ts +++ b/src/encryption/crypto-provider.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/encryption/encryption-wrapper.spec.ts b/src/encryption/encryption-wrapper.spec.ts index f2f01d0e..441551fd 100644 --- a/src/encryption/encryption-wrapper.spec.ts +++ b/src/encryption/encryption-wrapper.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/encryption/encryption-wrapper.ts b/src/encryption/encryption-wrapper.ts index 0fc2ff28..caccdd66 100644 --- a/src/encryption/encryption-wrapper.ts +++ b/src/encryption/encryption-wrapper.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/index.ts b/src/index.ts index 91167c2a..b618c87f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ export { diff --git a/src/keyExchange.spec.ts b/src/keyExchange.spec.ts index b5ee44c7..25b2fb06 100644 --- a/src/keyExchange.spec.ts +++ b/src/keyExchange.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/keyExchange.ts b/src/keyExchange.ts index 007c35a9..95e145b0 100644 --- a/src/keyExchange.ts +++ b/src/keyExchange.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto-browserify'); diff --git a/src/mailbox.spec.ts b/src/mailbox.spec.ts index e206b081..71d27ab6 100644 --- a/src/mailbox.spec.ts +++ b/src/mailbox.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/mailbox.ts b/src/mailbox.ts index fd7ac4ab..3f215d77 100644 --- a/src/mailbox.ts +++ b/src/mailbox.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/name-resolver.spec.ts b/src/name-resolver.spec.ts index 348be826..4cab692a 100644 --- a/src/name-resolver.spec.ts +++ b/src/name-resolver.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; import { ContractLoader, Executor } from '@evan.network/dbcp'; diff --git a/src/name-resolver.ts b/src/name-resolver.ts index a9f0e6ab..d7494022 100644 --- a/src/name-resolver.ts +++ b/src/name-resolver.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import * as Dbcp from '@evan.network/dbcp'; import prottle = require('prottle'); diff --git a/src/onboarding.spec.ts b/src/onboarding.spec.ts index af633ced..adac534a 100644 --- a/src/onboarding.spec.ts +++ b/src/onboarding.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/onboarding.ts b/src/onboarding.ts index faa57ca2..fc10f7f2 100644 --- a/src/onboarding.ts +++ b/src/onboarding.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/payments.spec.ts b/src/payments.spec.ts index d9db6ec6..c5effb80 100644 --- a/src/payments.spec.ts +++ b/src/payments.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/payments.ts b/src/payments.ts index 326c3399..d8d24586 100644 --- a/src/payments.ts +++ b/src/payments.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ diff --git a/src/profile/business-center-profile.spec.ts b/src/profile/business-center-profile.spec.ts index 393fc29c..257a50ef 100644 --- a/src/profile/business-center-profile.spec.ts +++ b/src/profile/business-center-profile.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/profile/business-center-profile.ts b/src/profile/business-center-profile.ts index 9eed9f05..047daace 100644 --- a/src/profile/business-center-profile.ts +++ b/src/profile/business-center-profile.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/profile/profile.spec.ts b/src/profile/profile.spec.ts index 5c670f27..b3e24d23 100644 --- a/src/profile/profile.spec.ts +++ b/src/profile/profile.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/profile/profile.ts b/src/profile/profile.ts index 2fa9d85e..f5ac785b 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/runtime.spec.ts b/src/runtime.spec.ts index 212a6b5e..94436c5c 100644 --- a/src/runtime.spec.ts +++ b/src/runtime.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/runtime.ts b/src/runtime.ts index 2d2ccc77..21c53220 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { diff --git a/src/shared-description.spec.ts b/src/shared-description.spec.ts index a2dfa95c..fe39c81c 100644 --- a/src/shared-description.spec.ts +++ b/src/shared-description.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/shared-description.ts b/src/shared-description.ts index e46b8867..a5bfc2fc 100644 --- a/src/shared-description.ts +++ b/src/shared-description.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { Envelope } from '@evan.network/dbcp'; diff --git a/src/test/accounts.ts b/src/test/accounts.ts index 09fe484c..d274144b 100644 --- a/src/test/accounts.ts +++ b/src/test/accounts.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ const accountMap1 = { diff --git a/src/test/test-utils.ts b/src/test/test-utils.ts index 70686fe7..4d931de5 100644 --- a/src/test/test-utils.ts +++ b/src/test/test-utils.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto'); diff --git a/src/verifications/verifications.spec.ts b/src/verifications/verifications.spec.ts index 3c80e175..4ee3314e 100644 --- a/src/verifications/verifications.spec.ts +++ b/src/verifications/verifications.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/verifications/verifications.ts b/src/verifications/verifications.ts index 1a148c82..e5f4eedc 100644 --- a/src/verifications/verifications.ts +++ b/src/verifications/verifications.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import crypto = require('crypto'); diff --git a/src/votings/votings.spec.ts b/src/votings/votings.spec.ts index bc292976..a8b73885 100644 --- a/src/votings/votings.spec.ts +++ b/src/votings/votings.spec.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import 'mocha'; diff --git a/src/votings/votings.ts b/src/votings/votings.ts index 4a2cbad8..4b575af5 100644 --- a/src/votings/votings.ts +++ b/src/votings/votings.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import { From 3a41a893f6e0e8fc482434ed6082b540c5ff5c0a Mon Sep 17 00:00:00 2001 From: Tobias Winkler Date: Fri, 27 Sep 2019 16:20:53 +0200 Subject: [PATCH 02/11] add `getProfileProperties` and `setProfileProperties` - [CORE-426] --- src/contracts/digital-twin/container.ts | 4 +- src/keyExchange.spec.ts | 57 +---- src/profile/profile.spec.ts | 212 ++---------------- src/profile/profile.ts | 279 ++++++++++++++++++++++-- src/profile/types/company.json | 83 +++++++ src/profile/types/device.json | 86 ++++++++ src/profile/types/types.ts | 36 +++ src/profile/types/unspecified.json | 55 +++++ src/runtime.ts | 4 + src/test/accounts.ts | 4 +- src/test/test-utils.ts | 12 +- tsconfig.json | 23 +- 12 files changed, 579 insertions(+), 276 deletions(-) create mode 100644 src/profile/types/company.json create mode 100644 src/profile/types/device.json create mode 100644 src/profile/types/types.ts create mode 100644 src/profile/types/unspecified.json diff --git a/src/contracts/digital-twin/container.ts b/src/contracts/digital-twin/container.ts index 85a29e51..30d4e89a 100644 --- a/src/contracts/digital-twin/container.ts +++ b/src/contracts/digital-twin/container.ts @@ -1368,7 +1368,7 @@ async function applyPlugin( const dsAuth = options.contractLoader.loadContract('DSAuth', await container.getContractAddress()); const dsRolesAddress = await options.executor.executeContractCall(dsAuth, 'authority'); const dsRolesContract = options.contractLoader.loadContract('DSRolesPerContract', dsRolesAddress); - + await options.executor.executeContractTransaction( dsRolesContract, 'setRoleOperationCapabilities', @@ -1398,7 +1398,7 @@ async function applyPlugin( } } await Throttle.all(tasks); - + return envelope; } diff --git a/src/keyExchange.spec.ts b/src/keyExchange.spec.ts index b5ee44c7..4717ed89 100644 --- a/src/keyExchange.spec.ts +++ b/src/keyExchange.spec.ts @@ -86,27 +86,8 @@ describe('KeyExchange class', function() { ipfs = await TestUtils.getIpfs(); ipld = await TestUtils.getIpld(ipfs); - profile = new Profile({ - accountId: accounts[0], - contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), - defaultCryptoAlgo: 'aes', - executor: await TestUtils.getExecutor(web3), - ipld, - nameResolver: await TestUtils.getNameResolver(web3), - rightsAndRoles: await TestUtils.getRightsAndRoles(web3), - }); - - profile2 = new Profile({ - accountId: accounts[1], - contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), - defaultCryptoAlgo: 'aes', - executor: await TestUtils.getExecutor(web3), - ipld, - nameResolver: await TestUtils.getNameResolver(web3), - rightsAndRoles: await TestUtils.getRightsAndRoles(web3), - }); + profile = await TestUtils.getProfile(web3, null, ipld, accounts[0]); + profile2 = await TestUtils.getProfile(web3, null, ipld, accounts[1]); mailbox = new Mailbox({ mailboxOwner: accounts[0], @@ -176,16 +157,7 @@ describe('KeyExchange class', function() { const result = await mailbox2.getMails(1, 0); const keys = Object.keys(result.mails); expect(result.mails[keys[0]].content.attachments[0].type).to.equal('commKey'); - let profileFromMail = new Profile({ - accountId: result.mails[keys[0]].content.from, - contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), - defaultCryptoAlgo: 'aes', - executor: await TestUtils.getExecutor(web3), - ipld, - nameResolver: await TestUtils.getNameResolver(web3), - rightsAndRoles: await TestUtils.getRightsAndRoles(web3), - }); + let profileFromMail = await TestUtils.getProfile(web3, null, ipld, result.mails[keys[0]].content.from); const publicKeyProfile = await profileFromMail.getPublicKey(); const commSecret = keyExchange2.computeSecretKey(publicKeyProfile); @@ -198,16 +170,8 @@ describe('KeyExchange class', function() { const result = await mailbox2.getMails(1, 0); const keys = Object.keys(result.mails); expect(result.mails[keys[0]].content.attachments[0].type).to.equal('commKey'); - let profileFromMail = new Profile({ - accountId: result.mails[keys[0]].content.from, - contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), - defaultCryptoAlgo: 'aes', - executor: await TestUtils.getExecutor(web3), - ipld, - nameResolver: await TestUtils.getNameResolver(web3), - rightsAndRoles: await TestUtils.getRightsAndRoles(web3), - }); + + let profileFromMail = await TestUtils.getProfile(web3, null, ipld, result.mails[keys[0]].content.from); const keyExchangeOptions = { mailbox, cryptoProvider: TestUtils.getCryptoProvider(), @@ -227,16 +191,7 @@ describe('KeyExchange class', function() { it('should be able to send an invitation to a remote account', async () => { const remoteAddress = ''; - const profileLocal = new Profile({ - accountId: accounts[1], - contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), - defaultCryptoAlgo: 'aes', - executor: await TestUtils.getExecutor(web3), - ipld, - nameResolver: await TestUtils.getNameResolver(web3), - rightsAndRoles: await TestUtils.getRightsAndRoles(web3), - }); + let profileLocal = await TestUtils.getProfile(web3, null, ipld, accounts[1]); const foreignPubkey = await profileLocal.getPublicKey(); const commKey = await keyExchange1.generateCommKey(); await keyExchange1.sendInvite(accounts[1], foreignPubkey, commKey, 'hi'); diff --git a/src/profile/profile.spec.ts b/src/profile/profile.spec.ts index 5c670f27..a3cfa0e4 100644 --- a/src/profile/profile.spec.ts +++ b/src/profile/profile.spec.ts @@ -115,16 +115,7 @@ describe('Profile helper', function() { }); it('should be able to be add contact keys', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.addContactKey(accounts[0], 'context a', 'key 0x01_a'); await profile.addContactKey(accounts[1], 'context a', 'key 0x02_a'); await profile.addContactKey(accounts[1], 'context b', 'key 0x02_b'); @@ -136,16 +127,7 @@ describe('Profile helper', function() { }); it('should be able to be add dapp bookmarks', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.addDappBookmark('sample1.test', sampleDesc); expect(await profile.getDappBookmark('sample1.test')).to.be.ok; @@ -158,17 +140,8 @@ describe('Profile helper', function() { .to.eq('sampleUpdateTest'); }); - it('should be able to store data container plugins', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + it.only('should be able to store data container plugins', async () => { + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); const templates = { templates: 'can', have: { @@ -181,31 +154,13 @@ describe('Profile helper', function() { expect(await profile.getPlugins()).to.eq(templates); await profile.storeForAccount(profile.treeLabels.dtContainerPlugins); - profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.loadForAccount(profile.treeLabels.dtContainerPlugins); expect(await profile.getPlugins()).to.deep.eq(templates); }); it('should be able to save an encrypted profile to IPLD', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.addContactKey(accounts[0], 'context a', 'key 0x01_a'); await profile.addContactKey(accounts[1], 'context a', 'key 0x02_a'); await profile.addContactKey(accounts[1], 'context b', 'key 0x02_b'); @@ -216,16 +171,7 @@ describe('Profile helper', function() { expect(ipldIpfsHash).not.to.be.undefined; // load it to new profile instance - const loadedProfile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + const loadedProfile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await loadedProfile.loadFromIpld(profile.treeLabels.addressBook, ipldIpfsHash); // test contacts @@ -264,16 +210,7 @@ describe('Profile helper', function() { it('should be able to set and load a profile for a given user from the blockchain shorthand', async () => { // create profile - const profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.createProfile(keyExchange.getDiffieHellmanKeys()); await profile.addContactKey(accounts[0], 'context a', 'key 0x01_a'); await profile.addContactKey(accounts[1], 'context a', 'key 0x02_a'); @@ -285,16 +222,7 @@ describe('Profile helper', function() { await profile.storeForAccount(profile.treeLabels.addressBook); // load - const newProfile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + const newProfile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); // test contacts expect(await newProfile.getContactKey(accounts[0], 'context a')).to.eq('key 0x01_a'); @@ -307,42 +235,15 @@ describe('Profile helper', function() { }); it('allow to check if a profile exists', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: '0xbbF5029Fd710d227630c8b7d338051B8E76d50B3', - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, '0xbbF5029Fd710d227630c8b7d338051B8E76d50B3'); expect(await profile.exists()).to.be.false; - profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); expect(await profile.exists()).to.be.true; }); it('should remove a bookmark from a given profile', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.addDappBookmark('sample1.test', sampleDesc); await profile.addDappBookmark('sample2.test', sampleDesc); @@ -358,16 +259,7 @@ describe('Profile helper', function() { // create new profile helper instance const from = Object.keys(accountMap)[0]; ipld.originator = nameResolver.soliditySha3(from); - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); // create new profile, set private key and keyexchange partial key await profile.createProfile(keyExchange.getDiffieHellmanKeys()); @@ -379,31 +271,13 @@ describe('Profile helper', function() { await profile.storeForAccount(profile.treeLabels.bookmarkedDapps); // load - const newProfile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + const newProfile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); // test contacts expect(await profile.getDappBookmark('sample1.test')).to.deep.eq(sampleDesc); }); it('should read a public part of a profile (e.g. public key)', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); const customMailbopx = new Mailbox({ mailboxOwner: accounts[0], @@ -433,16 +307,7 @@ describe('Profile helper', function() { const modifiedKeyStore = TestUtils.getKeyProvider(['mailboxKeyExchange']); ipld.keyProvider = modifiedKeyStore; // load - const newProfile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + const newProfile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); const pubKey = await newProfile.getPublicKey(); expect(pubKey).to.be.ok; @@ -455,16 +320,7 @@ describe('Profile helper', function() { }); it('should be able to set a contact as known', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.createProfile(keyExchange.getDiffieHellmanKeys()); @@ -475,17 +331,7 @@ describe('Profile helper', function() { }); it('should be able to set a contact as unknown', async () => { - let profile = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld, - executor, - accountId: accounts[0], - rightsAndRoles, - }); - + let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); await profile.createProfile(keyExchange.getDiffieHellmanKeys()); await profile.loadForAccount(); @@ -514,16 +360,7 @@ describe('Profile helper', function() { return accountIpld; }; // separate profiles (with separate key providers for ipld) - const profile1 = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld: await getKeyIpld(profileReceiver), - executor, - accountId: profileReceiver, - rightsAndRoles, - }); + const profile1 = await TestUtils.getProfile(web3, ipfs, await getKeyIpld(profileReceiver), profileReceiver); // create profile data with profileReceiver (profileReceiver is the account, that will own the profile) const dhKeys = keyExchange.getDiffieHellmanKeys(); @@ -595,16 +432,7 @@ describe('Profile helper', function() { await executor.executeContractTransaction( contract, 'setMyProfile', { from: profileReceiver, autoGas: 1.1, }, profileContract.options.address); // can read own keys - const profile2 = new Profile({ - nameResolver, - defaultCryptoAlgo: 'aes', - dataContract, - contractLoader, - ipld: await getKeyIpld(profileReceiver), - executor, - accountId: profileReceiver, - rightsAndRoles, - }); + const profile2 = await TestUtils.getProfile(web3, ipfs, await getKeyIpld(profileReceiver), profileReceiver); // can read public key await profile2.loadForAccount(profile2.treeLabels.publicKey); diff --git a/src/profile/profile.ts b/src/profile/profile.ts index 2fa9d85e..9247cad2 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -25,8 +25,13 @@ https://evan.network/license/ */ +import * as Throttle from 'promise-parallel-throttle'; +import crypto = require('crypto'); +import { merge, cloneDeep, isEqual } from 'lodash'; + import { ContractLoader, + DfsInterface, Executor, Logger, LoggerOptions, @@ -34,12 +39,15 @@ import { obfuscate, } from '@evan.network/dbcp'; + +import * as accountTypes from './types/types'; import { CryptoProvider } from '../encryption/crypto-provider'; import { DataContract } from '../contracts/data-contract/data-contract'; +import { Description } from '../shared-description'; import { Ipld } from '../dfs/ipld'; import { KeyExchange } from '../keyExchange'; import { RightsAndRoles, ModificationType, PropertyType } from '../contracts/rights-and-roles'; - +import { Sharing } from '../contracts/sharing'; /** * parameters for Profile constructor @@ -47,12 +55,16 @@ import { RightsAndRoles, ModificationType, PropertyType } from '../contracts/rig export interface ProfileOptions extends LoggerOptions { accountId: string, contractLoader: ContractLoader, + description: Description, + cryptoProvider: CryptoProvider, dataContract: DataContract, defaultCryptoAlgo: string, + dfs: DfsInterface, executor: Executor, ipld: Ipld, nameResolver: NameResolver, rightsAndRoles: RightsAndRoles, + sharing: Sharing, } @@ -94,6 +106,12 @@ export class Profile extends Logger { publicKey: 'publicKey', }; + /** + * All available account types, mapped to it's data contract template specification. Each account + * type is based on the uspecified type, so each type includes this data too. + */ + accountTypes = accountTypes; + constructor(options: ProfileOptions) { super(options); this.activeAccount = options.accountId; @@ -124,21 +142,6 @@ export class Profile extends Logger { await this.ipld.set(this.trees['contracts'], `${bc}/${address}`, data, false); } - /** - * removes a contract (task contract etc. ) from a business center scope of the current profile - * - * @param {string} bc business center ens address or contract address - * @param {string} address contact address - * @return {Promise} resolved when done - */ - async removeBcContract(bc: string, address: string): Promise { - this.ensureTree('contracts'); - const bcSet = await this.ipld.getLinkedGraph(this.trees['contracts'], bc); - if (bcSet) { - await this.ipld.remove(this.trees['contracts'], `${bc}/${address}`); - } - } - /** * add a key for a contact to bookmarks * @@ -442,6 +445,104 @@ export class Profile extends Logger { ); } + /** + * Return the saved profile information according to the specified profile type. No type directly + * uses unspecified type. + * + * @param {Array} properties Restrict properties that should be loaded. + * @return {Promise} Property keys mapped to it's values. When a property was not set, a + * empty object will be returned + */ + async getProfileProperties(properties?: Array) { + const data: any = { }; + let ajvSpecs; + + // reset previous loaded profile contract to be sure to load corrcet profile data after + // migration + delete this.profileContract; + await this.loadForAccount(); + + // try to resolve profiles dbcp and get it's data specification + try { + const description = await this.options.description + .getDescription(this.profileContract.address, this.activeAccount); + if (description && description.public && description.public.dataSchema) { + ajvSpecs = description.public.dataSchema; + } + } catch (ex) { } + + // if no dbcp data specification could be loaded, resolve it from the profile type and the + // latest templates + if (!ajvSpecs) { + // load account details and type that should be resolved + const accountDetails = (await this.dataContract.getEntry(this.profileContract, 'accountDetails', + this.activeAccount)) || { profileType: 'unspecified' }; + data.accountDetails = accountDetails; + + // merge unspecified account specifications with the current selected one + ajvSpecs = merge( + cloneDeep(this.accountTypes.unspecified), + cloneDeep(this.accountTypes[accountDetails.profileType]), + ).template.properties; + } + + // load profile data + await Throttle.all( + Object.keys(ajvSpecs).map((propKey: string) => async () => { + // only load properties that should be loaded + if (!properties || properties.indexOf(propKey) !== -1) { + const prop = ajvSpecs[propKey]; + const fields = prop.properties ? prop.properties : prop.dataSchema.properties; + + switch (prop.type) { + case 'array': { + // TODO: load list entries + data[propKey] = [ ]; + this.log('list entry loading for profile properties are not implemented!', 'warning'); + break; + } + case 'entry': + default: { + data[propKey] = data[propKey] || (await this.dataContract.getEntry( + this.profileContract, propKey, this.activeAccount)) || { }; + } + } + + // check for file properties that should be decrypted + await Promise.all(Object.keys(fields).map(async (fieldKey: string) => { + if (fields[fieldKey].$comment && + fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1 && + typeof data[propKey][fieldKey] === 'string') { + // generate new keys + const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob'); + const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb'); + + const hashKey = await this.options.sharing.getHashKey( + this.profileContract.options.address, + this.activeAccount + ); + const contentKey = await this.options.sharing.getKey( + this.profileContract.options.address, + this.activeAccount, + propKey + ); + const dencryptedHashBuffer = await hashCryptor.decrypt( + Buffer.from(data[propKey][fieldKey].substr(2), 'hex'), + { key: hashKey } + ); + const retrieved = await (this.options.dfs) + .get('0x' + dencryptedHashBuffer.toString('hex'), true); + data[propKey][fieldKey] = await cryptor.decrypt(retrieved, { key: contentKey }); + data[propKey][fieldKey].forEach(file => file.size = file.file.length); + } + })); + } + }) + ); + + return data; + } + /** * get a key from an address in the address book * @@ -550,6 +651,21 @@ export class Profile extends Logger { return this; } + /** + * removes a contract (task contract etc. ) from a business center scope of the current profile + * + * @param {string} bc business center ens address or contract address + * @param {string} address contact address + * @return {Promise} resolved when done + */ + async removeBcContract(bc: string, address: string): Promise { + this.ensureTree('contracts'); + const bcSet = await this.ipld.getLinkedGraph(this.trees['contracts'], bc); + if (bcSet) { + await this.ipld.remove(this.trees['contracts'], `${bc}/${address}`); + } + } + /** * remove a contact from bookmarkedDapps * @@ -691,6 +807,137 @@ export class Profile extends Logger { ); } + /** + * Takes a set of profile properties and saves them into the profile data contract. If one + * property wasn't specified before, it will be permitted for writing. + * + * @param {any} payload Object that should saved. Each entry will be saved as seperated + * entry. + */ + async setProfileProperties(data: any) { + const profileAddress = this.profileContract.address; + let description; + let profileType; + + // gt profile type + if (data.accountDetails && data.accountDetails.profileType) { + profileType = data.accountDetails.profileType; + } else { + profileType = (await this.getProfileProperties([ 'accountDetails' ])).profileType; + } + + // try to resolve profiles dbcp and get it's data specification + try { + description = await this.options.description + .getDescription(this.profileContract.address, this.activeAccount); + } catch (ex) { } + + // fill empty dbcp entries + description = description || { + 'public': { + 'name': 'Profile Contract', + 'description': 'Profile Contract', + 'author': 'evan.network', + 'tags': [ + 'profile' + ], + 'version': '1.0.0', + 'dbcpVersion': 2 + } + }; + description.public.dataSchema = description.public.dataSchema || { }; + + // latest profile type definition + const originDescription = cloneDeep(description); + const latestSpecification = merge( + cloneDeep(this.accountTypes.unspecified), + cloneDeep(this.accountTypes[profileType]), + ); + const newFields = Object + .keys(latestSpecification.template.properties) + .filter((propKey: string) => !description.public.dataSchema[propKey]); + + // apply latest specifications after new fields were checked + Object.keys(latestSpecification.template.properties).forEach((propKey: string) => { + description.public.dataSchema[propKey] = cloneDeep(latestSpecification.template + .properties[propKey].dataSchema); + }); + + // set new permissions + if (newFields.length > 0) { + const shared = this.options.contractLoader.loadContract('Shared', profileAddress); + const sharings = await this.options.sharing.getSharingsFromContract(shared); + + await Throttle.all(newFields.map((propKey: string) => async () => { + // create unique keys for the new fields + const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aes'); + const [contentKey, blockNr] = await Promise.all( + [cryptor.generateKey(), this.executor.web3.eth.getBlockNumber()]) + await this.options.sharing.extendSharings(sharings, this.activeAccount, + this.activeAccount, propKey, blockNr, contentKey); + await this.options.rightsAndRoles.setOperationPermission( + profileAddress, // contract to be updated + this.activeAccount, // account, that can change permissions + 0, // role id, uint8 value + propKey, // name of the object + PropertyType.Entry, // what type of element is modified + ModificationType.Set, // type of the modification + true, // grant this capability + ); + })); + + await this.options.sharing.saveSharingsToContract(profileAddress, sharings, this.activeAccount); + await this.options.sharing.getSharings(profileAddress); + } + + // if description has changed, save it + if (!isEqual(originDescription, description)) { + await this.options.description.setDescription(profileAddress, description, this.activeAccount); + } + + // save the data + await Throttle.all(Object.keys(data).map((propKey: string) => async () => { + const fields = description.public.dataSchema[propKey].properties; + + // check for files + await Promise.all(Object.keys(fields).map(async (fieldKey) => { + if (fields[fieldKey].$comment && + fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1 && + data[propKey][fieldKey] && data[propKey][fieldKey].length !== 0) { + const blobs = []; + data[propKey][fields[fieldKey]].forEach((control: any) => + blobs.push({ + name: control.name, + fileType: control.fileType, + file: control.file + }) + ); + // generate new keys + const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob') + const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb') + const hashKey = await this.options.sharing.getHashKey(profileAddress, this.activeAccount); + const contentKey = await this.options.sharing.getKey(profileAddress, this.activeAccount, + data.type); + + const encryptedFileBuffer = await cryptor.encrypt(blobs, { key: contentKey }) + const stateMd5 = crypto.createHash('md5').update(encryptedFileBuffer).digest('hex') + const fileHash = await this.options.dfs.add(stateMd5, encryptedFileBuffer) + const encryptedHashBuffer = await hashCryptor.encrypt( + Buffer.from(fileHash.substr(2), 'hex'), { key: hashKey }) + const encryptedHashString = `0x${encryptedHashBuffer.toString('hex')}` + data[propKey][fields[fieldKey]] = encryptedHashString; + } + })); + + await this.options.dataContract.setEntry( + this.profileContract, + propKey, + data[propKey], + this.activeAccount + ); + })); + } + /** * stores profile tree or given hash to global profile contract * diff --git a/src/profile/types/company.json b/src/profile/types/company.json new file mode 100644 index 00000000..e226ed68 --- /dev/null +++ b/src/profile/types/company.json @@ -0,0 +1,83 @@ +{ + "description": { + "description": "", + "imgSquare": "", + "name": "Company" + }, + "permissions": [ + "contact", + "registration" + ], + "template": { + "properties": { + "contact": { + "dataSchema": { + "properties": { + "city": { + "default": "", + "type": "string" + }, + "country": { + "default": "", + "type": "string" + }, + "postalCode": { + "default": "", + "type": "string" + }, + "streetAndNumber": { + "default": "", + "type": "string" + }, + "website": { + "default": "", + "type": "string" + } + }, + "type": "object" + }, + "permissions": { + "0": [ + "set" + ] + }, + "type": "entry" + }, + "registration": { + "dataSchema": { + "properties": { + "company": { + "default": "", + "minLength": 1, + "type": "string" + }, + "court": { + "default": "", + "type": "string" + }, + "register": { + "default": "", + "type": "string" + }, + "registerNumber": { + "default": "", + "type": "string" + }, + "salesTaxID": { + "default": "", + "type": "string" + } + }, + "type": "object" + }, + "permissions": { + "0": [ + "set" + ] + }, + "type": "entry" + } + }, + "type": "metadata" + } +} \ No newline at end of file diff --git a/src/profile/types/device.json b/src/profile/types/device.json new file mode 100644 index 00000000..b4eca789 --- /dev/null +++ b/src/profile/types/device.json @@ -0,0 +1,86 @@ +{ + "description": { + "description": "", + "imgSquare": "", + "name": "Device" + }, + "permissions": [ + "deviceDetails" + ], + "template": { + "properties": { + "deviceDetails": { + "dataSchema": { + "properties": { + "dataStreamSettings": { + "default": "", + "type": "string" + }, + "location": { + "default": "", + "type": "string" + }, + "manufacturer": { + "default": "", + "type": "string" + }, + "owner": { + "default": "", + "type": "string" + }, + "serialNumber": { + "default": "", + "type": "string" + }, + "settings": { + "$comment": "{\"isEncryptedFile\": true}", + "default": { + "files": [] + }, + "properties": { + "additionalProperties": false, + "files": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "files" + ], + "type": "object" + }, + "type": { + "$comment": "{\"isEncryptedFile\": true}", + "default": { + "files": [] + }, + "properties": { + "additionalProperties": false, + "files": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "files" + ], + "type": "object" + } + }, + "type": "object" + }, + "permissions": { + "0": [ + "set" + ] + }, + "type": "entry" + } + }, + "type": "metadata" + } +} \ No newline at end of file diff --git a/src/profile/types/types.ts b/src/profile/types/types.ts new file mode 100644 index 00000000..35d00b67 --- /dev/null +++ b/src/profile/types/types.ts @@ -0,0 +1,36 @@ +/* + Copyright (C) 2018-present evan GmbH. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see http://www.gnu.org/licenses/ or + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from + the following URL: https://evan.network/license/ + + You can be released from the requirements of the GNU Affero General Public + License by purchasing a commercial license. + Buying such a license is mandatory as soon as you use this software or parts + of it on other blockchains than evan.network. + + For more information, please contact evan GmbH at this address: + https://evan.network/license/ +*/ + +import * as unspecified from './unspecified.json'; +import * as company from './company.json'; +import * as device from './device.json'; + +export { + unspecified, + company, + device, +} diff --git a/src/profile/types/unspecified.json b/src/profile/types/unspecified.json new file mode 100644 index 00000000..900d5494 --- /dev/null +++ b/src/profile/types/unspecified.json @@ -0,0 +1,55 @@ +{ + "description": { + "description": "", + "imgSquare": "", + "name": "unspecified" + }, + "permissions": [ + "accountDetails" + ], + "template": { + "properties": { + "accountDetails": { + "dataSchema": { + "properties": { + "accountName": { + "default": "", + "type": "string" + }, + "pictureSrc": { + "$comment": "{\"isEncryptedFile\": true}", + "default": { + "files": [] + }, + "properties": { + "additionalProperties": false, + "files": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "files" + ], + "type": "object" + }, + "profileType": { + "default": "", + "type": "string" + } + }, + "type": "object" + }, + "permissions": { + "0": [ + "set" + ] + }, + "type": "entry" + } + }, + "type": "metadata" + } +} \ No newline at end of file diff --git a/src/runtime.ts b/src/runtime.ts index 2d2ccc77..05b4080d 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -346,13 +346,17 @@ export async function createDefaultRuntime(web3: any, dfs: DfsInterface, runtime let profile = options.profile || new Profile({ accountId: activeAccount, contractLoader, + cryptoProvider, dataContract: dataContractOwn, defaultCryptoAlgo: 'aes', + description, + dfs, executor, ipld: ipldOwn, log, nameResolver, rightsAndRoles, + sharing, }); // this key provider is linked to profile for key retrieval // keyProviderOwn is not linked to profile to prevent profile key lookups diff --git a/src/test/accounts.ts b/src/test/accounts.ts index 09fe484c..8f8c1522 100644 --- a/src/test/accounts.ts +++ b/src/test/accounts.ts @@ -26,8 +26,8 @@ */ const accountMap1 = { - '0x001De828935e8c7e4cb56Fe610495cAe63fb2612': - '01734663843202e2245e5796cb120510506343c67915eb4f9348ac0d8c2cf22a', + '0xf7cC4FB127D0C48f99c79F016c427f55E08C81DF': + '13bf7d78d6099637f10ecbb43ec1d74eec7594f66d699eec66e40a0d0322328d', '0x0030C5e7394585400B1FB193DdbCb45a37Ab916E': '7d09c0873e3f8dc0c7282bb7c2ba76bfd432bff53c38ace06193d1e4faa977e7', '0x00D1267B27C3A80080f9E1B6Ba01DE313b53Ab58': diff --git a/src/test/test-utils.ts b/src/test/test-utils.ts index 70686fe7..0eaefa49 100644 --- a/src/test/test-utils.ts +++ b/src/test/test-utils.ts @@ -378,20 +378,26 @@ export class TestUtils { return payments; } - static async getProfile(web3, ipfs?, ipld?, accountId?): Promise { const executor = await TestUtils.getExecutor(web3); + const dfs = ipfs || await TestUtils.getIpfs(); executor.eventHub = await TestUtils.getEventHub(web3); + const profile = new Profile({ accountId: accountId || accounts[0], contractLoader: await TestUtils.getContractLoader(web3), - dataContract: await TestUtils.getDataContract(web3, ipfs), + cryptoProvider: await TestUtils.getCryptoProvider(), + dataContract: await TestUtils.getDataContract(web3, dfs), defaultCryptoAlgo: 'aes', + dfs, + description: await TestUtils.getDescription(web3), executor, - ipld: ipld || await TestUtils.getIpld(ipfs), + ipld: ipld || await TestUtils.getIpld(dfs), nameResolver: await TestUtils.getNameResolver(web3), rightsAndRoles: await TestUtils.getRightsAndRoles(web3), + sharing: await TestUtils.getSharing(web3), }); + return profile; } diff --git a/tsconfig.json b/tsconfig.json index e03f1f6d..1e9e24de 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,20 +4,20 @@ "declaration": true, "inlineSourceMap": true, "inlineSources": true, - "module": "commonjs", - "outDir": "./dist", - "rootDir": "./src", - "target": "es2017", "lib": [ "es2017" ], + "module": "commonjs", + "outDir": "./dist", "paths": { - "bcc": ["./src/dist/index.js"] - } + "bcc": [ + "./src/dist/index.js" + ] + }, + "resolveJsonModule": true, + "rootDir": "./src", + "target": "es2017" }, - "include": [ - "src/**/*.ts" - ], "exclude": [ "bundles", "dist", @@ -26,5 +26,8 @@ "node_modules", "scripts", "src/**/*.spec.ts" + ], + "include": [ + "src/**/*.ts" ] -} +} \ No newline at end of file From a78aa9b80850deeeb0a9bfa4e6f0b78e46f662d1 Mon Sep 17 00:00:00 2001 From: Tobias Winkler Date: Sun, 29 Sep 2019 16:08:41 +0200 Subject: [PATCH 03/11] use correct unspecific picture property - [CORE-426] --- src/profile/profile.ts | 5 ----- src/profile/types/unspecified.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/profile/profile.ts b/src/profile/profile.ts index 9247cad2..aeda6ad1 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -457,11 +457,6 @@ export class Profile extends Logger { const data: any = { }; let ajvSpecs; - // reset previous loaded profile contract to be sure to load corrcet profile data after - // migration - delete this.profileContract; - await this.loadForAccount(); - // try to resolve profiles dbcp and get it's data specification try { const description = await this.options.description diff --git a/src/profile/types/unspecified.json b/src/profile/types/unspecified.json index 900d5494..d786e7be 100644 --- a/src/profile/types/unspecified.json +++ b/src/profile/types/unspecified.json @@ -16,7 +16,7 @@ "default": "", "type": "string" }, - "pictureSrc": { + "picture": { "$comment": "{\"isEncryptedFile\": true}", "default": { "files": [] From 255d23242756dd84c4657b7a5c8191291c39e76a Mon Sep 17 00:00:00 2001 From: Tobias Winkler Date: Sun, 29 Sep 2019 17:10:19 +0200 Subject: [PATCH 04/11] save files in profile properties with container semantic - [CORE-426] --- src/profile/profile.ts | 110 ++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 46 deletions(-) diff --git a/src/profile/profile.ts b/src/profile/profile.ts index aeda6ad1..51438ce7 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -470,8 +470,13 @@ export class Profile extends Logger { // latest templates if (!ajvSpecs) { // load account details and type that should be resolved - const accountDetails = (await this.dataContract.getEntry(this.profileContract, 'accountDetails', - this.activeAccount)) || { profileType: 'unspecified' }; + let accountDetails = (await this.dataContract.getEntry(this.profileContract, 'accountDetails', + this.activeAccount)); + // fill empty details + if (!accountDetails || + accountDetails === '0x0000000000000000000000000000000000000000000000000000000000000000') { + accountDetails = { profileType: 'unspecified' } + }; data.accountDetails = accountDetails; // merge unspecified account specifications with the current selected one @@ -506,29 +511,37 @@ export class Profile extends Logger { // check for file properties that should be decrypted await Promise.all(Object.keys(fields).map(async (fieldKey: string) => { if (fields[fieldKey].$comment && - fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1 && - typeof data[propKey][fieldKey] === 'string') { - // generate new keys - const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob'); - const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb'); - - const hashKey = await this.options.sharing.getHashKey( - this.profileContract.options.address, - this.activeAccount - ); - const contentKey = await this.options.sharing.getKey( - this.profileContract.options.address, - this.activeAccount, - propKey - ); - const dencryptedHashBuffer = await hashCryptor.decrypt( - Buffer.from(data[propKey][fieldKey].substr(2), 'hex'), - { key: hashKey } - ); - const retrieved = await (this.options.dfs) - .get('0x' + dencryptedHashBuffer.toString('hex'), true); - data[propKey][fieldKey] = await cryptor.decrypt(retrieved, { key: contentKey }); - data[propKey][fieldKey].forEach(file => file.size = file.file.length); + fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1) { + try { + // generate new keys + const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob'); + const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb'); + + const hashKey = await this.options.sharing.getHashKey( + this.profileContract.options.address, + this.activeAccount + ); + const contentKey = await this.options.sharing.getKey( + this.profileContract.options.address, + this.activeAccount, + propKey + ); + + await Promise.all(data[propKey][fieldKey].files.map(async (file, index) => { + const dencryptedHashBuffer = await hashCryptor.decrypt( + Buffer.from(file.substr(2), 'hex'), + { key: hashKey } + ); + const retrieved = await (this.options.dfs) + .get('0x' + dencryptedHashBuffer.toString('hex'), true); + const decrypted = await cryptor.decrypt(retrieved, { key: contentKey }) + decrypted.size = decrypted.file.length; + data[propKey][fieldKey].files[index] = decrypted; + })); + } catch (ex) { + this.log(`could not decrypt files from profile property ${ propKey }.${ fieldKey }: ${ ex.message }`, 'warning'); + data[propKey][fieldKey] = { files: [ ] }; + } } })); } @@ -897,30 +910,35 @@ export class Profile extends Logger { // check for files await Promise.all(Object.keys(fields).map(async (fieldKey) => { if (fields[fieldKey].$comment && - fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1 && - data[propKey][fieldKey] && data[propKey][fieldKey].length !== 0) { - const blobs = []; - data[propKey][fields[fieldKey]].forEach((control: any) => - blobs.push({ + fields[fieldKey].$comment.indexOf('isEncryptedFile') !== -1) { + const files = data[propKey][fieldKey] && data[propKey][fieldKey].files ? + data[propKey][fieldKey].files : data[propKey][fieldKey]; + + // reject empty file list + if (!files || files.length === 0) { + return; + } + + await Promise.all(files.map(async (control: any, index: number) => { + const toEncrypt = { name: control.name, fileType: control.fileType, file: control.file - }) - ); - // generate new keys - const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob') - const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb') - const hashKey = await this.options.sharing.getHashKey(profileAddress, this.activeAccount); - const contentKey = await this.options.sharing.getKey(profileAddress, this.activeAccount, - data.type); - - const encryptedFileBuffer = await cryptor.encrypt(blobs, { key: contentKey }) - const stateMd5 = crypto.createHash('md5').update(encryptedFileBuffer).digest('hex') - const fileHash = await this.options.dfs.add(stateMd5, encryptedFileBuffer) - const encryptedHashBuffer = await hashCryptor.encrypt( - Buffer.from(fileHash.substr(2), 'hex'), { key: hashKey }) - const encryptedHashString = `0x${encryptedHashBuffer.toString('hex')}` - data[propKey][fields[fieldKey]] = encryptedHashString; + }; + + // generate new keys + const cryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesBlob') + const hashCryptor = this.options.cryptoProvider.getCryptorByCryptoAlgo('aesEcb') + const hashKey = await this.options.sharing.getHashKey(profileAddress, this.activeAccount); + const contentKey = await this.options.sharing.getKey(profileAddress, this.activeAccount, + propKey); + const encryptedFileBuffer = await cryptor.encrypt(toEncrypt, { key: contentKey }) + const stateMd5 = crypto.createHash('md5').update(encryptedFileBuffer).digest('hex') + const fileHash = await this.options.dfs.add(stateMd5, encryptedFileBuffer) + const encryptedHashBuffer = await hashCryptor.encrypt( + Buffer.from(fileHash.substr(2), 'hex'), { key: hashKey }); + files[index] = `0x${encryptedHashBuffer.toString('hex')}`; + })); } })); From 42f9ac8a14ed6b56b15e1dfd0bb0915a1934f84d Mon Sep 17 00:00:00 2001 From: Tobias Winkler Date: Tue, 1 Oct 2019 13:14:47 +0200 Subject: [PATCH 05/11] add profile property type handling tests - [CORE-422] --- VERSIONS.md | 1 + src/profile/profile.spec.ts | 177 +++++++++++++++++++++++++++++++++++- 2 files changed, 176 insertions(+), 2 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index 10d09526..da837df6 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -2,6 +2,7 @@ ## Next Version ### Features +- add `setProfileProperties` and `getProfileProperties` ### Fixes diff --git a/src/profile/profile.spec.ts b/src/profile/profile.spec.ts index a3cfa0e4..4935952a 100644 --- a/src/profile/profile.spec.ts +++ b/src/profile/profile.spec.ts @@ -26,7 +26,9 @@ */ import 'mocha'; -import { expect } from 'chai'; +import { expect, use } from 'chai'; +import { isEqual } from 'lodash'; +import chaiAsPromised = require('chai-as-promised'); // import IpfsServer = require('ipfs'); import { @@ -40,15 +42,19 @@ import { accountMap } from '../test/accounts'; import { accounts } from '../test/accounts'; import { Aes } from '../encryption/aes'; import { configTestcore as config } from '../config-testcore'; +import { createDefaultRuntime } from '../runtime'; import { CryptoProvider } from '../encryption/crypto-provider'; import { DataContract } from '../contracts/data-contract/data-contract'; import { Ipld } from '../dfs/ipld'; import { KeyExchange } from '../keyExchange'; import { Mailbox } from '../mailbox'; +import { Onboarding } from '../onboarding'; import { Profile } from './profile'; import { RightsAndRoles } from '../contracts/rights-and-roles'; +import { Runtime } from '../runtime'; import { TestUtils } from '../test/test-utils'; +use(chaiAsPromised); describe('Profile helper', function() { this.timeout(600000); @@ -140,7 +146,7 @@ describe('Profile helper', function() { .to.eq('sampleUpdateTest'); }); - it.only('should be able to store data container plugins', async () => { + it('should be able to store data container plugins', async () => { let profile = await TestUtils.getProfile(web3, ipfs, ipld, accounts[0]); const templates = { templates: 'can', @@ -455,4 +461,171 @@ describe('Profile helper', function() { // transfer ownership await rightsAndRoles.transferOwnership(profileContract, profileReceiver, profileTestUser); }); + + describe.only('Handle data contract entries in profile', function() { + const mnemonics = { + old: 'distance castle notable toast siren smoke gym stable goat enact abstract absorb', + company: 'jeans token chimney when tape enable around loop space harsh file juice', + device: 'green lucky purse barrel scorpion universe sorry nest walnut enact stand price', + }; + + const dateString = Date.now().toString(); + const companyProfileProperties = { + registration: { + company: `Company ${ dateString }`, + court: `trst ${ dateString }`, + register: 'hra', + registerNumber: `qwer ${ dateString }`, + salesTaxID: `qw ${ dateString }`, + }, + contact: { + country: 'DE', + city: `City ${ dateString }`, + postalCode: '12345', + streetAndNumber: `Street ${ dateString }`, + website: 'https://evan.network' + } + }; + const deviceProfileProperties = { + deviceDetails: { + dataStreamSettings: `dataStreamSettings ${ dateString }`, + location: `location ${ dateString }`, + manufacturer: `manufacturer ${ dateString }`, + owner: '0xcA4f9fF9e32a768BC68399B9F46d8A884089997d', + serialNumber: `serialNumber ${ dateString }`, + settings: { files: [] }, + type: { files: [] } + } + }; + + /** + * Return the runtime for a test mnemonic. + * + * @param {string} mnemonic mnemonic to create the runtime with + * @param {string} password password to create the runtime with + */ + async function getProfileRuntime(mnemonic: string, password = 'Evan1234') { + return createDefaultRuntime( + await TestUtils.getWeb3(), + await TestUtils.getIpfs(), + { mnemonic, password, } + ); + } + + it('cannot save properties to old profile', async () => { + const runtime = await getProfileRuntime(mnemonics.old); + + const promise = runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'Im\'m failing', + profileType: 'unspecified', + } + }); + await expect(promise).to.be.rejected; + }); + + // TODO: test profile migration + it('can migrate old profile to new one', async () => { + throw new Error('not implemented'); + }); + + // TODO: use new profile type switch function + it('can transform unspecified profile to company profile', async () => { + const newMnemonic = Onboarding.createMnemonic(); + await Onboarding.createNewProfile(newMnemonic, 'Evan1234'); + const runtime = await getProfileRuntime(newMnemonic); + + await runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'New company', + profileType: 'company', + } + }); + const properties = await runtime.profile.getProfileProperties([ 'accountDetails' ]); + await expect(properties.accountDetails.accountName).to.be.eq('New company'); + }); + + it('cannot transform specified profile to another profile type', async () => { + const newMnemonic = Onboarding.createMnemonic(); + await Onboarding.createNewProfile(newMnemonic, 'Evan1234'); + const runtime = await getProfileRuntime(newMnemonic); + + await runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'New company', + profileType: 'company', + } + }); + const properties = await runtime.profile.getProfileProperties([ 'accountDetails' ]); + await expect(properties.accountDetails.accountName).to.be.eq('New company'); + + const promise = runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'Now it\'s a device', + profileType: 'device', + } + }); + + await expect(promise).to.be.rejected; + }); + + it('can transform unspecified profile to device profile', async () => { + const newMnemonic = Onboarding.createMnemonic(); + await Onboarding.createNewProfile(newMnemonic, 'Evan1234'); + const runtime = await getProfileRuntime(newMnemonic); + + await runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'New device', + profileType: 'device', + } + }); + const properties = await runtime.profile.getProfileProperties([ 'accountDetails' ]); + await expect(properties.accountDetails.accountName).to.be.eq('New device'); + }); + + it('can transform unspecified profile to type that does not exists', async () => { + const newMnemonic = Onboarding.createMnemonic(); + await Onboarding.createNewProfile(newMnemonic, 'Evan1234'); + const runtime = await getProfileRuntime(newMnemonic); + + const promise = runtime.profile.setProfileProperties({ + accountDetails: { + accountName: 'custom profile', + profileType: 'my own type', + } + }); + + await expect(promise).to.be.rejected; + }); + + it('can save company profile specific properties to a profile of type company', async () => { + const runtime = await getProfileRuntime(mnemonics.company); + await runtime.profile.setProfileProperties(companyProfileProperties); + const newProfileProperties = await runtime.profile.getProfileProperties(); + await expect(newProfileProperties.accountDetails.profileType).to.be.eq('company'); + await expect(isEqual(companyProfileProperties.registration, newProfileProperties.registration)).to.be.true; + await expect(isEqual(companyProfileProperties.contact, newProfileProperties.contact)).to.be.true; + }); + + it('cannot save device profile specific properties into company profile', async () => { + const runtime = await getProfileRuntime(mnemonics.company); + const promise = runtime.profile.setProfileProperties(deviceProfileProperties); + await expect(promise).to.be.rejected; + }); + + it('can save device profile specific properties to a profile of type device', async () => { + const runtime = await getProfileRuntime(mnemonics.device); + await runtime.profile.setProfileProperties(deviceProfileProperties); + const newProfileProperties = await runtime.profile.getProfileProperties(); + await expect(newProfileProperties.accountDetails.profileType).to.be.eq('device'); + await expect(isEqual(deviceProfileProperties.deviceDetails, newProfileProperties.deviceDetails)).to.be.true; + }); + + it('cannot save company profile specific properties into device profile', async () => { + const runtime = await getProfileRuntime(mnemonics.device); + const promise = runtime.profile.setProfileProperties(companyProfileProperties); + await expect(promise).to.be.rejected; + }); + }); }); From 4670ed9e959e3510c8e83dd7f4c4eedc0de7d59e Mon Sep 17 00:00:00 2001 From: S3bb1 Date: Tue, 1 Oct 2019 21:06:54 +0200 Subject: [PATCH 06/11] add verfication data example - [CORE-526] --- docs/profile/verifications.rst | 57 ++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/docs/profile/verifications.rst b/docs/profile/verifications.rst index 88a8f7ab..3cdac0d2 100644 --- a/docs/profile/verifications.rst +++ b/docs/profile/verifications.rst @@ -2,7 +2,7 @@ Verifications ================================================================================ -.. list-table:: +.. list-table:: :widths: auto :stub-columns: 1 @@ -45,7 +45,7 @@ Under this "path" a set of values can be found. These value describe the verific - 0: Issued - 1: Confirmed - ``signature`` - Signature which is the proof that the verification issuer issued a verification of topic for this identity. + Signature which is the proof that the verification issuer issued a verification of topic for this identity. It MUST be a signed message of the following structure: keccak256(address identityHolder_address, uint256 _ topic, bytes data) - ``creationDate`` creationDate of the verification @@ -105,7 +105,7 @@ Example ------- .. code-block:: typescript - + const verifications = new Verifications({ accountStore, config, @@ -255,6 +255,8 @@ setVerification Sets or creates a verification; this requires the issuer to have permissions for the parent verification (if verification name seen as a path, the parent 'folder'). +The "verificationValue" field can also set to a custom JSON object with any data. For example DID VC's, documents or any other custom value you want to attach to the verification. + ---------- Parameters ---------- @@ -282,9 +284,30 @@ Example // accounts[0] issues verification '/company' for accounts[1] const firstVerification = await verifications.setVerification(accounts[0], accounts[1], '/company'); + // accounts[0] issues verification '/companyData' for accounts[1] with additional data attached + const firstVerification = await verifications.setVerification(accounts[0], accounts[1], '/company', 0, { + additionalDocument: + vcDid: { + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": ["VerifiableCredential", "UniversityDegreeCredential"], + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + }, + "proof": { } + } + }); + // accounts[0] issues verification '/company' for accounts[1], sets an expiration date // and links to description domain 'sample' - const secondVerification = await verifications.setVerification( + const thirdVerification = await verifications.setVerification( accounts[0], accounts[1], '/company', expirationDate, verificationValue, 'example'); @@ -308,13 +331,13 @@ Parameters #. ``subject`` - ``string``: subject of the verifications #. ``topic`` - ``string``: name (/path) of a verification -#. ``isIdentity`` - ``string`` (optional): indicates if the subject is already an identity +#. ``isIdentity`` - ``string`` (optional): indicates if the subject is already an identity ------- Returns ------- -``Promise`` returns ``any[]``: verification info array, +``Promise`` returns ``any[]``: verification info array, Verifications have the following properties: @@ -408,7 +431,7 @@ Example const nestedVerifications = await getNestedVerifications('0x123...', '/test') - // will return + // will return [ { // creator of the verification @@ -793,7 +816,7 @@ rejectVerification verifications.rejectVerification(accountId, subject, verificationId[, rejectReason, isIdentity]); -Reject a Verification. This verification will be marked as rejected but not deleted. This is important for tracking reasons. You can also optionally add a reject reason as JSON object to track additional informations about the rejection. Issuer and Subject can reject a special verification. +Reject a Verification. This verification will be marked as rejected but not deleted. This is important for tracking reasons. You can also optionally add a reject reason as JSON object to track additional informations about the rejection. Issuer and Subject can reject a special verification. ---------- Parameters @@ -981,7 +1004,7 @@ Parameters ---------- #. ``contract`` - ``any``: target contract of transcation or ``null`` if just sending funds -#. ``functionName`` - ``string``: function for transaction or ``null`` if just sending funds +#. ``functionName`` - ``string``: function for transaction or ``null`` if just sending funds #. ``options`` - ``any``: options for transaction, supports from, to, nonce, input, value #. ``args`` - ``any[]`` (optional): arguments for function transaction @@ -1156,7 +1179,7 @@ getVerificationEnsAddress verifications.getVerificationEnsAddress(topic); Map the topic of a verification to it's default ens domain. - + ---------- Parameters ---------- @@ -1192,7 +1215,7 @@ ensureVerificationDescription verifications.ensureVerificationDescription(verification); Gets and sets the default description for a verification if it does not exists. - + ---------- Parameters ---------- @@ -1399,7 +1422,7 @@ VerificationsStatusFlagsV2 -------------------------- status annotations about verification, depending on defined ``VerificationsQueryOptions``, this may lead to the verification to be invalid or less trustworthy - + #. ``disableSubVerifications``: parent verification does not allow subverifications #. ``expired``: verification has expired #. ``invalid``: signature does not match requirements, this could be because it hasn’t been signed by correct account or underlying checksum does not match subject, topic and data @@ -1501,11 +1524,11 @@ a single verification; usually used in ``VerificationsResultV2`` * ``subjectIdentity`` - ``string``: identity (contract or identity hash) of subject * ``subjectType`` - ``string``: type of subject (account/contract) * ``topic`` - ``string``: topic of identity (name) - * ``data`` - ``any`` (optional): 32B data hash string of identity - * ``description`` - ``any`` (optional): only if actually set - * ``expirationDate`` - ``number`` (optional): expiration date of verification (js timestamp) - * ``rejectReason`` - ``string`` (optional): if applicable, reason for verification rejection - * ``status`` - ``VerificationsStatusV2`` (optional): status of verification, is optional during result computation and required when done + * ``data`` - ``any`` (optional): 32B data hash string of identity + * ``description`` - ``any`` (optional): only if actually set + * ``expirationDate`` - ``number`` (optional): expiration date of verification (js timestamp) + * ``rejectReason`` - ``string`` (optional): if applicable, reason for verification rejection + * ``status`` - ``VerificationsStatusV2`` (optional): status of verification, is optional during result computation and required when done * ``subject`` - ``string`` (optional): subject accountId/contractId (if query was issued with ``isIdentity`` set to ``false``) #. ``raw`` (optional): raw data about verification from contract * ``creationBlock`` - ``string``: block in which verification was issued From 5940183a4df9b433a1d32303405eeaccdddbcd5c Mon Sep 17 00:00:00 2001 From: Sebastian Dechant Date: Tue, 1 Oct 2019 21:25:09 +0200 Subject: [PATCH 07/11] Apply suggestions from code review Co-Authored-By: wulfraem --- docs/profile/verifications.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/profile/verifications.rst b/docs/profile/verifications.rst index 3cdac0d2..e3c21632 100644 --- a/docs/profile/verifications.rst +++ b/docs/profile/verifications.rst @@ -255,7 +255,7 @@ setVerification Sets or creates a verification; this requires the issuer to have permissions for the parent verification (if verification name seen as a path, the parent 'folder'). -The "verificationValue" field can also set to a custom JSON object with any data. For example DID VC's, documents or any other custom value you want to attach to the verification. +The "verificationValue" field can also be set to a custom JSON object with any data. For example DID, VC's, documents or any other custom value you want to attach to the verification. ---------- Parameters @@ -285,7 +285,7 @@ Example const firstVerification = await verifications.setVerification(accounts[0], accounts[1], '/company'); // accounts[0] issues verification '/companyData' for accounts[1] with additional data attached - const firstVerification = await verifications.setVerification(accounts[0], accounts[1], '/company', 0, { + const secondVerification = await verifications.setVerification(accounts[0], accounts[1], '/companyData', 0, { additionalDocument: vcDid: { "@context": [ From 87abaf45d0770252486a51306bc22204a5b8220f Mon Sep 17 00:00:00 2001 From: S3bb1 Date: Fri, 4 Oct 2019 13:30:23 +0200 Subject: [PATCH 08/11] load profile when setting new properties - [CORE-426] --- src/profile/profile.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/profile/profile.ts b/src/profile/profile.ts index 51438ce7..81329701 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -823,6 +823,7 @@ export class Profile extends Logger { * entry. */ async setProfileProperties(data: any) { + await this.loadForAccount(); const profileAddress = this.profileContract.address; let description; let profileType; From 582b01b8c6f5d6537803006068310131a2de7694 Mon Sep 17 00:00:00 2001 From: S3bb1 Date: Fri, 4 Oct 2019 14:35:32 +0200 Subject: [PATCH 09/11] skip the tests temporary - [CORE-426] --- src/profile/profile.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/profile/profile.spec.ts b/src/profile/profile.spec.ts index 4935952a..8ed2b899 100644 --- a/src/profile/profile.spec.ts +++ b/src/profile/profile.spec.ts @@ -462,7 +462,7 @@ describe('Profile helper', function() { await rightsAndRoles.transferOwnership(profileContract, profileReceiver, profileTestUser); }); - describe.only('Handle data contract entries in profile', function() { + describe.skip('Handle data contract entries in profile', function() { const mnemonics = { old: 'distance castle notable toast siren smoke gym stable goat enact abstract absorb', company: 'jeans token chimney when tape enable around loop space harsh file juice', @@ -525,7 +525,7 @@ describe('Profile helper', function() { }); // TODO: test profile migration - it('can migrate old profile to new one', async () => { + it.skip('can migrate old profile to new one', async () => { throw new Error('not implemented'); }); From aba8cd727b3860ab9d5eb3f80caf06be6eb3dfe3 Mon Sep 17 00:00:00 2001 From: Tobias Winkler Date: Tue, 8 Oct 2019 09:42:57 +0200 Subject: [PATCH 10/11] add pr review comments - [CORE-426] --- src/profile/profile.ts | 6 +++++- src/profile/types/types.ts | 8 -------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/profile/profile.ts b/src/profile/profile.ts index 81329701..687d7b08 100644 --- a/src/profile/profile.ts +++ b/src/profile/profile.ts @@ -461,10 +461,13 @@ export class Profile extends Logger { try { const description = await this.options.description .getDescription(this.profileContract.address, this.activeAccount); + if (description && description.public && description.public.dataSchema) { ajvSpecs = description.public.dataSchema; } - } catch (ex) { } + } catch (ex) { + this.log(`Problem getting profile contract description: ${ ex.message }`, 'error'); + } // if no dbcp data specification could be loaded, resolve it from the profile type and the // latest templates @@ -669,6 +672,7 @@ export class Profile extends Logger { async removeBcContract(bc: string, address: string): Promise { this.ensureTree('contracts'); const bcSet = await this.ipld.getLinkedGraph(this.trees['contracts'], bc); + if (bcSet) { await this.ipld.remove(this.trees['contracts'], `${bc}/${address}`); } diff --git a/src/profile/types/types.ts b/src/profile/types/types.ts index 35d00b67..1b48e835 100644 --- a/src/profile/types/types.ts +++ b/src/profile/types/types.ts @@ -15,14 +15,6 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: https://evan.network/license/ - - You can be released from the requirements of the GNU Affero General Public - License by purchasing a commercial license. - Buying such a license is mandatory as soon as you use this software or parts - of it on other blockchains than evan.network. - - For more information, please contact evan GmbH at this address: - https://evan.network/license/ */ import * as unspecified from './unspecified.json'; From 4e1e737a04a45326884f7fa07e20b94692098d5b Mon Sep 17 00:00:00 2001 From: wulfraem Date: Tue, 8 Oct 2019 10:41:23 +0200 Subject: [PATCH 11/11] release v2.13.0 - [CORE-526] --- VERSIONS.md | 10 ++++++++-- package.json | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index 9702249a..7d25da7c 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -2,14 +2,20 @@ ## Next Version ### Features -- add `setProfileProperties` and `getProfileProperties` ### Fixes -- remove custom agpl appendix ### Deprecations +## Version 2.13.0 +### Features +- add `setProfileProperties` and `getProfileProperties` + +### Fixes +- remove custom agpl appendix + + ## Version 2.12.0 ### Features - add generic support for preparing and executing transactions via identity diff --git a/package.json b/package.json index c799055c..14a6f1b2 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "author": "evan GmbH", "dependencies": { - "@evan.network/dbcp": "^1.8.2", - "@evan.network/smart-contracts-core": "^2.6.1", + "@evan.network/dbcp": "^1.8.3", + "@evan.network/smart-contracts-core": "^2.6.2", "@types/node": "^12.6.8", "ajv": "^6.10.2", "async-mutex": "^0.1.3", @@ -87,5 +87,5 @@ "testunitcoverage": "env-cmd --fallback -f ./.env.local npm run build && nyc -r lcov -e .ts -x \"$TESTSPECS\" mocha --exit -r ts-node/register $TESTSPECS && nyc report --reporter=text-lcov | coveralls" }, "types": "./dist/index.d.ts", - "version": "2.12.0" + "version": "2.13.0" }