mirror of
https://github.com/tornadocash/trusted-setup-server.git
synced 2024-11-21 17:36:54 +01:00
contribution hash; authorize fix
This commit is contained in:
parent
ef1693cfec
commit
a94a337363
@ -16,6 +16,7 @@
|
|||||||
"@open-wc/webpack-import-meta-loader": "^0.4.1",
|
"@open-wc/webpack-import-meta-loader": "^0.4.1",
|
||||||
"async-mutex": "^0.1.4",
|
"async-mutex": "^0.1.4",
|
||||||
"aws-sdk": "^2.610.0",
|
"aws-sdk": "^2.610.0",
|
||||||
|
"blake2": "^4.0.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Hello, <span>@{{ handle }}</span>
|
Hello, <span>@{{ handle }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<h2 class="subtitle">
|
<h2 class="subtitle">
|
||||||
Do you want to authorize your contribution #{{ contributionIndex }}? Please sign in.
|
{{ title }}
|
||||||
</h2>
|
</h2>
|
||||||
<fieldset :disabled="hideSaveBtn" class="authorize">
|
<fieldset :disabled="hideSaveBtn" class="authorize">
|
||||||
<Form />
|
<Form />
|
||||||
@ -46,7 +46,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
contributionIndex: 1,
|
contributionIndex: null,
|
||||||
token: null,
|
token: null,
|
||||||
status: {
|
status: {
|
||||||
type: '',
|
type: '',
|
||||||
@ -57,7 +57,17 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('user', ['name', 'handle', 'company']),
|
...mapState('user', ['name', 'handle', 'company']),
|
||||||
...mapGetters('user', ['isLoggedIn', 'hasErrorName'])
|
...mapGetters('user', ['isLoggedIn', 'hasErrorName']),
|
||||||
|
title() {
|
||||||
|
if (this.status.type === 'is-danger' || !this.contributionIndex) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (!this.isLoggedIn) {
|
||||||
|
return `Do you want to authorize your contribution #${this.contributionIndex}? Please sign in.`
|
||||||
|
} else {
|
||||||
|
return `Please, specify your name and organization.`
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.$root.$emit('enableLoading')
|
this.$root.$emit('enableLoading')
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
<div v-show="status.type === 'is-danger' || status.type === 'is-success'" class="status">
|
<div v-show="status.type === 'is-danger' || status.type === 'is-success'" class="status">
|
||||||
<div :class="status.type" class="status-message">{{ status.msg }}</div>
|
<div :class="status.type" class="status-message">{{ status.msg }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-show="contributionHash" class="is-success status-message">
|
||||||
|
Your contribution hash (Blake2b) is {{ contributionHash }}
|
||||||
|
</div>
|
||||||
|
<div v-show="authorizeLink" class="is-success status-message">
|
||||||
|
You still can authorize your contribution by following this <a :href="authorizeLink">link.</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="buttons is-centered">
|
<div class="buttons is-centered">
|
||||||
<b-button
|
<b-button
|
||||||
@ -77,7 +83,9 @@ export default {
|
|||||||
status: {
|
status: {
|
||||||
type: '',
|
type: '',
|
||||||
msg: ''
|
msg: ''
|
||||||
}
|
},
|
||||||
|
contributionHash: null,
|
||||||
|
authorizeLink: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -164,10 +172,9 @@ export default {
|
|||||||
this.$store.commit('user/SET_CONTRIBUTION_INDEX', responseData.contributionIndex)
|
this.$store.commit('user/SET_CONTRIBUTION_INDEX', responseData.contributionIndex)
|
||||||
this.status.msg = 'Your contribution is verified and recorded.'
|
this.status.msg = 'Your contribution is verified and recorded.'
|
||||||
this.status.type = 'is-success'
|
this.status.type = 'is-success'
|
||||||
|
this.contributionHash = responseData.hash
|
||||||
if (this.contributionType === 'anonymous') {
|
if (this.contributionType === 'anonymous') {
|
||||||
console.log(
|
this.authorizeLink = `${window.location.origin}/authorize-contribution?token=${responseData.token}`
|
||||||
`${window.location.origin}/authorize-contribution?token=${responseData.token}`
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
this.status.msg += ' Now you can post attestation from your twitter account.'
|
this.status.msg += ' Now you can post attestation from your twitter account.'
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ const aws = require('aws-sdk')
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const { Mutex } = require('async-mutex')
|
const { Mutex } = require('async-mutex')
|
||||||
const multer = require('multer')
|
const multer = require('multer')
|
||||||
|
const blake2 = require('blake2')
|
||||||
|
|
||||||
const mutex = new Mutex()
|
const mutex = new Mutex()
|
||||||
const s3 = new aws.S3()
|
const s3 = new aws.S3()
|
||||||
@ -83,7 +84,12 @@ router.post('/response', upload.single('response'), async (req, res) => {
|
|||||||
token = crypto.randomBytes(32).toString('hex')
|
token = crypto.randomBytes(32).toString('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
await Contribution.create({ name, company, handle, socialType, token })
|
const contribution = await fs.readFile(`/tmp/tornado/${req.file.filename}`)
|
||||||
|
const blake2Instance = blake2.createHash('blake2b')
|
||||||
|
blake2Instance.update(contribution)
|
||||||
|
const hash = '0x' + blake2Instance.digest('hex')
|
||||||
|
|
||||||
|
await Contribution.create({ name, company, handle, socialType, token, hash })
|
||||||
|
|
||||||
console.log('Contribution is correct, uploading to storage')
|
console.log('Contribution is correct, uploading to storage')
|
||||||
if (process.env.DISABLE_S3 !== 'true') {
|
if (process.env.DISABLE_S3 !== 'true') {
|
||||||
@ -97,8 +103,8 @@ router.post('/response', upload.single('response'), async (req, res) => {
|
|||||||
`./server/snark_files/response_${contributionIndex}`
|
`./server/snark_files/response_${contributionIndex}`
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log('Finished')
|
console.log('Finished. The hash of the contribution is', hash)
|
||||||
res.json({ contributionIndex, token })
|
res.json({ contributionIndex, token, hash })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Got error during save', e)
|
console.error('Got error during save', e)
|
||||||
await fs.unlink(`/tmp/tornado/${req.file.filename}`)
|
await fs.unlink(`/tmp/tornado/${req.file.filename}`)
|
||||||
@ -113,6 +119,7 @@ router.post('/authorize_contribution', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const contribution = await Contribution.findOne({ where: { token: req.body.token } })
|
const contribution = await Contribution.findOne({ where: { token: req.body.token } })
|
||||||
|
console.log('contribution', contribution.dataValues.id)
|
||||||
if (!contribution) {
|
if (!contribution) {
|
||||||
res.status(404).send('There is no such contribution')
|
res.status(404).send('There is no such contribution')
|
||||||
return
|
return
|
||||||
@ -136,14 +143,13 @@ router.post('/authorize_contribution', async (req, res) => {
|
|||||||
handle: req.session.handle,
|
handle: req.session.handle,
|
||||||
socialType: req.session.socialType
|
socialType: req.session.socialType
|
||||||
},
|
},
|
||||||
{ individualHooks: true, where: { token: req.body.token }, returning: true }
|
{ where: { id: contribution.dataValues.id }, individualHooks: true }
|
||||||
)
|
)
|
||||||
|
res.send('OK')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('updateError', e)
|
console.error('updateError', e)
|
||||||
res.status(404).send('Update error')
|
res.status(404).send('Update error')
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send('OK')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/get_contribution_index', async (req, res) => {
|
router.post('/get_contribution_index', async (req, res) => {
|
||||||
|
@ -1799,6 +1799,13 @@ bindings@^1.5.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
file-uri-to-path "1.0.0"
|
file-uri-to-path "1.0.0"
|
||||||
|
|
||||||
|
blake2@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/blake2/-/blake2-4.0.0.tgz#32ae4c3568ef5ee4d74c50b99d774abf8fff4f60"
|
||||||
|
integrity sha512-PIOc6RXAZYBYcdpyMzI6/SCU3BH8EbmA9vr0BAVyQv48CQTXDN6viHOTM+8KQue2IPsyHNpIR3UDisz8rZDPTA==
|
||||||
|
dependencies:
|
||||||
|
nan "^2.14.0"
|
||||||
|
|
||||||
block-stream@*:
|
block-stream@*:
|
||||||
version "0.0.9"
|
version "0.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a"
|
resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a"
|
||||||
@ -5882,7 +5889,7 @@ named-placeholders@^1.1.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
lru-cache "^4.1.3"
|
lru-cache "^4.1.3"
|
||||||
|
|
||||||
nan@^2.12.1, nan@^2.13.2:
|
nan@^2.12.1, nan@^2.13.2, nan@^2.14.0:
|
||||||
version "2.14.0"
|
version "2.14.0"
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
|
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
|
||||||
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
|
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
|
||||||
|
Loading…
Reference in New Issue
Block a user