Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E protocol #1521

Merged
merged 549 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
549 commits
Select commit Hold shift + click to select a range
90a97ae
Closure for storeSecretKeys to prevent logging secrets
corrideat Oct 13, 2023
ed4c21a
Remove promiseAllSettled. Bugfixes.
corrideat Oct 13, 2023
caa79e1
add /push/send route , setup 'push' event listener in service-worker
SebinSong Oct 14, 2023
d465aec
add theme_color, background_color to the PWA manifest
SebinSong Oct 14, 2023
de345e3
Send test notification upon sign-up / log-in , update POST /push/send…
SebinSong Oct 15, 2023
2d1bd83
remove unused route POST /push/send/{subscriptionId}
SebinSong Oct 15, 2023
87190a6
add payload validations to /push/* routes
SebinSong Oct 18, 2023
d38ae7d
remove console.log
SebinSong Oct 18, 2023
3eebc25
Update okturtles.eventqueue
corrideat Oct 18, 2023
05cf522
Side-effects without await
corrideat Oct 18, 2023
9eba410
Fix invocation
corrideat Oct 18, 2023
7cc4400
Make sure we sync any identity contracts we haven't synced upon login…
Silver-IT Oct 18, 2023
531be95
Remove await on /out in internals.js
corrideat Oct 18, 2023
053103a
Remove queueInvocation for /out events
corrideat Oct 18, 2023
70e3c59
Merge branch 'e2e-protocol' into e2e-protocol-ricardo
corrideat Oct 18, 2023
58e6c31
Merge pull request #1758 from okTurtles/e2e-protocol-ricardo
taoeffect Oct 18, 2023
6556ad8
fix: disable change group settings unless group creator tries
Silver-IT Oct 19, 2023
c33085f
Make cannot leave if not a member error into a warning
corrideat Oct 19, 2023
44c85a2
Show login error prompt only for errors related to the identity contr…
corrideat Oct 19, 2023
976021d
Fix issue of removing two members (error on second removal)
corrideat Oct 19, 2023
cc98510
Update identity.js login logic, remove spurious sideEffect check
corrideat Oct 19, 2023
2cf36e5
pin contracts
corrideat Oct 19, 2023
5ce96a5
Merge pull request #1776 from okTurtles/e2e-protocol-ricardo
taoeffect Oct 19, 2023
293e12a
Implement a way to set default groupId (#1773)
Silver-IT Oct 20, 2023
95a946b
Fix inability to join after sharer signs out
corrideat Oct 20, 2023
cf4b7f4
Updated login error message (#1731)
Silver-IT Oct 20, 2023
04bb180
fix: error of Member Removal (#1764)
Silver-IT Oct 20, 2023
2a78c44
Fix infinite re-subscription due to foreign keys
corrideat Oct 20, 2023
29add18
Revert "Updated login error message (#1731)"
taoeffect Oct 20, 2023
8bcff5d
Updated login error message (#1731)
Silver-IT Oct 20, 2023
26d5179
Fix undefined in vmInvites
corrideat Oct 20, 2023
22139cc
Merge pull request #1778 from okTurtles/e2e-protocol-ricardo
taoeffect Oct 20, 2023
3b1987e
preSendCheck for outgoing messages; move hooks to publishEvent
corrideat Oct 24, 2023
ac29a74
Remove preSendCheckContract
corrideat Oct 24, 2023
a4d98a6
Remove await from call to leaveAllChatRoomsUponLeaving
corrideat Oct 24, 2023
35a8139
Merge pull request #1779 from okTurtles/e2e-protocol-ricardo
taoeffect Oct 24, 2023
834299d
merge the latest master in
SebinSong Oct 25, 2023
a10eb41
Merge remote-tracking branch 'origin/e2e-protocol' into sebin/task/92…
SebinSong Oct 25, 2023
5af73c9
re-run after merging the latest e2e-protocol
SebinSong Oct 25, 2023
45ee249
Login sync fixes
corrideat Oct 25, 2023
f3bed17
Fix various issues related to login and re-joining
corrideat Oct 26, 2023
71c7a71
Merge pull request #1775 from okTurtles/1707-should-block-updating-gr…
taoeffect Oct 27, 2023
abd54ab
Make saveOurLoginState async
corrideat Oct 27, 2023
889c43f
Various improvments and bugfixes
corrideat Oct 29, 2023
94188fe
Bugfixes. Revert changes to side-effects
corrideat Nov 3, 2023
028513f
bump
corrideat Nov 3, 2023
9364fdf
Address re-joining of chatrooms
corrideat Nov 4, 2023
51a9522
Address PR review feedback
corrideat Nov 7, 2023
c9d4c52
update for Ricardo's feedbabck
SebinSong Nov 8, 2023
d2cc960
Merge remote-tracking branch 'origin/e2e-protocol' into sebin/task/92…
SebinSong Nov 8, 2023
65a6d74
Deferred remove
corrideat Nov 8, 2023
0596f30
Fixes to "chelonia/private/deleteRevokedKeys"
corrideat Nov 8, 2023
2a6d64d
Re-add sync to publishEvent
corrideat Nov 8, 2023
db5b43b
Bugfix: reducer at deleteRevokedKeys
corrideat Nov 8, 2023
4f9f4ce
Test state.contracts[cID] instead of state[cID]
corrideat Nov 8, 2023
4f91d6b
Bugfixes:
corrideat Nov 9, 2023
9d47c5c
Move joining #General and adding group key into side-effect
corrideat Nov 9, 2023
d03fcc6
Bugfixes
corrideat Nov 10, 2023
99f6b9d
Clear deferredRemove flag
corrideat Nov 10, 2023
b77a024
Check if we have the decryption key first
corrideat Nov 10, 2023
5db6ff1
Updated error message
corrideat Nov 10, 2023
1695b6d
Remove debug logs and fix multiple join calls
corrideat Nov 11, 2023
d461dde
Remove unnecessary sync of identity contract
corrideat Nov 11, 2023
7653085
Update all test scenarios for updated workflow (#1782)
Silver-IT Nov 13, 2023
295e166
feat: resolved conflicts
Silver-IT Nov 13, 2023
d11b6b1
fix: errors
Silver-IT Nov 13, 2023
fa6d4e1
fix: error in switching chatroom as soon as it is created
Silver-IT Nov 13, 2023
e3d5977
fix: error in cypress test
Silver-IT Nov 14, 2023
c67ac54
Bugfixes
corrideat Nov 14, 2023
43db5e1
Fix UI inconsistency issues (wrong message when joining / leaving; sw…
corrideat Nov 15, 2023
e680374
Encrypt OP_KEY_SHARE envelope
corrideat Nov 15, 2023
661921d
restore RecordPayment.vue against e2e-protocol branch
SebinSong Nov 16, 2023
6236b44
work partially on Greg's CR
SebinSong Nov 16, 2023
f059664
chore: pushed the latest commit of e2e-protocol-ricardo-2023
Silver-IT Nov 16, 2023
b103de9
Add missing sync when added to chatroom
corrideat Nov 16, 2023
c124023
Remove extraneous logging
corrideat Nov 16, 2023
8ef6917
Add destructor to leave chatrooms
corrideat Nov 16, 2023
421233c
chore: merged the latest commit and fix erorr in cy.login
Silver-IT Nov 17, 2023
905bbbc
Leave chatrooms on removeOurselves
corrideat Nov 17, 2023
7b2a3a2
Remove JOINING_CHATROOM
corrideat Nov 17, 2023
baacd80
Merge pull request #1780 from okTurtles/e2e-protocol-ricardo-20231025…
taoeffect Nov 17, 2023
9458715
Merge pull request #1785 from okTurtles/e2e-protocol-ricardo
taoeffect Nov 17, 2023
6897da2
Merge branch 'master' into e2e-protocol
taoeffect Nov 17, 2023
2439ce5
Implement /joinGroup and /leaveGroup. TODO: Move PEK rotation (?), fi…
corrideat Nov 17, 2023
ee579d8
chore: updated the latest e2e-protocol branch
Silver-IT Nov 17, 2023
0ab2308
merge the latest e2e-protocol
SebinSong Nov 17, 2023
97b58aa
restore RecordPayment.vue against e2e-protocol
SebinSong Nov 18, 2023
60a014e
work on implementing immediate kickout permission
SebinSong Nov 18, 2023
446e408
fix: cypress error
Silver-IT Nov 19, 2023
0cfd760
fix the giconf.json error
SebinSong Nov 21, 2023
813ebca
Improvements to login using new actions
corrideat Nov 21, 2023
493dbca
feat: remove eventHandler
Silver-IT Nov 21, 2023
c5e1cad
fix: removed cy.wait
Silver-IT Nov 22, 2023
899d807
chore: reverted changes using browserify
Silver-IT Nov 22, 2023
98fa470
Bugfixes and refactoring
corrideat Nov 22, 2023
2301d12
Comments and fix to vuex/save error
corrideat Nov 22, 2023
b3002a9
feat: removed cy.wait
Silver-IT Nov 23, 2023
772ae32
create message handlers for push-notification in both client and server
SebinSong Nov 23, 2023
687d2a6
Use group's CEK for joining and leaving
corrideat Nov 23, 2023
c86e978
Fix navigation glitches when joining or creating a group
corrideat Nov 23, 2023
b450b07
Prevent flashing of no group name
corrideat Nov 23, 2023
92b836d
Add comments
corrideat Nov 23, 2023
e5428a1
Fix group creation buttons
corrideat Nov 23, 2023
906ad50
Fix steps header
corrideat Nov 23, 2023
7b4c97e
Fix proposals oneVoteToPass
corrideat Nov 23, 2023
1a48ab8
Remove VOTE_UNDECIDED
corrideat Nov 23, 2023
8402c0d
Merge pull request #1788 from okTurtles/e2e-protocol-ricardo
taoeffect Nov 23, 2023
33b57bd
feat: merged the latest commit and fix cypress errors
Silver-IT Nov 24, 2023
e17e5f9
chore: added comments and renamed helper function
Silver-IT Nov 24, 2023
cf50675
chore: added github discussion as comment
Silver-IT Nov 24, 2023
7e6af66
add various push-action handlers to the pubsub message handler on the…
SebinSong Nov 24, 2023
b177786
replace GET /push/publickey with the logic with pubsub system
SebinSong Nov 24, 2023
a227775
add handler logic for STORE_SUBSCRIPTION
SebinSong Nov 24, 2023
9f51f3b
replace all /push/* to the pubsub equivalents
SebinSong Nov 24, 2023
c35bbca
Remove return from /rotateKeys in group to avoid deadlock
corrideat Nov 24, 2023
e280fcf
Add missing import
corrideat Nov 24, 2023
2d32522
Remove second return from call to rotateKeys
corrideat Nov 24, 2023
0edaed5
Remove /wait from rotateKeys
corrideat Nov 24, 2023
961050a
Chatroom: ignore join / leave side-effects when rendering messages
corrideat Nov 24, 2023
b69ec4c
chore: merged the latest commit
Silver-IT Nov 24, 2023
61644b2
move push-subscription map to server object in createServer
SebinSong Nov 27, 2023
532016b
Merge branch 'e2e-protocol-ricardo' into 1719-fix-all-tests-on-e2e-pr…
corrideat Nov 27, 2023
1367acb
Publish queue and reset selector
corrideat Nov 27, 2023
3caca18
rename TO_SERVER/FROM_SERVER to PUSH_ACTION
SebinSong Nov 28, 2023
d78efd0
Merge remote-tracking branch 'origin/e2e-protocol' into sebin/task/92…
SebinSong Nov 28, 2023
6d12969
some optimisation in 'push' event handler in service-worker
SebinSong Nov 28, 2023
fa62fb6
correct the error sentence
SebinSong Nov 28, 2023
f58e1d4
add a TODO comment in push.js
SebinSong Nov 28, 2023
18ad3c6
Fix user count for non-joined chatrooms
corrideat Nov 28, 2023
d57779a
improve the error-handling logic for push actions
SebinSong Nov 29, 2023
cde2fe6
Bugfixes and simplification of /join
corrideat Nov 29, 2023
83485e5
Use on instead of once
corrideat Nov 29, 2023
478a7a0
updates for a couple of CRs from the PR review
SebinSong Nov 30, 2023
9f92acb
Remove delete pending
corrideat Nov 30, 2023
4e6e33f
Add queue for listenChatoomActions
corrideat Nov 30, 2023
ac8842f
a couple of fixes in service-worker.js
SebinSong Dec 1, 2023
6c53013
postpublish hook and internal-only id
corrideat Dec 1, 2023
218c42e
id-less chat refreshes
corrideat Dec 1, 2023
a8008a0
Remove GIMessage.id()
corrideat Dec 1, 2023
15fb085
Remove missing from GIMessage
corrideat Dec 1, 2023
624889a
Bugfix: onprocessed handler
corrideat Dec 1, 2023
c1da368
Remove the logic that asks server to send a test notification
SebinSong Dec 2, 2023
8929ff8
fix the undeleted logic
SebinSong Dec 2, 2023
9142f55
separate push-subscription logic from service-worker registration
SebinSong Dec 2, 2023
e775ae1
Add way for Chelonia to shut down
corrideat Dec 2, 2023
47239d9
move the push-setup logic into requestPermission() util method
SebinSong Dec 4, 2023
fb5f791
move '/send-push' into a then of Promise
SebinSong Dec 4, 2023
f7f54fc
Bugfixes for integration tests
corrideat Dec 5, 2023
8b9d60d
Fix duplicate messages and move removeImmediately to internals
corrideat Dec 5, 2023
91c2b21
onresolve for forceDistributionDate
corrideat Dec 5, 2023
b0895ed
Update to commands.js
corrideat Dec 5, 2023
a941b42
setup/send push-notification only after the permission has been granted.
SebinSong Dec 6, 2023
a1a5f9a
remove console.log()
SebinSong Dec 6, 2023
c8209af
merge the latest e2e-protocol in
SebinSong Dec 7, 2023
adb064d
Merge pull request #1786 from okTurtles/sebin/task/#1781-immediate-me…
taoeffect Dec 7, 2023
984c692
logic for exchanging a message btw the SW and the Client
SebinSong Dec 7, 2023
b0268dc
Fix Flow errors and make encryptedData test pass
corrideat Dec 7, 2023
9654168
Undo change to ChatMain
corrideat Dec 7, 2023
b974230
encryptedData: remove unnecessary multiple calls to rootState
corrideat Dec 7, 2023
c84de55
encryptedData: fix selector name
corrideat Dec 7, 2023
6790c99
Updates to make backend.test.js work; added null encryption and signa…
corrideat Dec 7, 2023
355402f
Add comments on eNULL and sNULL as well as environment variable
corrideat Dec 7, 2023
5ba1508
Merge remote-tracking branch 'origin/e2e-protocol' into sebin/task/92…
SebinSong Dec 8, 2023
9c1ae75
work on Greg's CR again
SebinSong Dec 8, 2023
2702b75
Write to contract state only after processing finished
corrideat Dec 8, 2023
4b10a2f
Update comment
corrideat Dec 8, 2023
aecca39
Feedback
corrideat Dec 8, 2023
409f7c3
Fix wrong selector
corrideat Dec 8, 2023
67ca3ad
Various bugfixes, atomic for sendMessage
corrideat Dec 9, 2023
e0f8896
comments and deserializeHEAD
corrideat Dec 9, 2023
fce148e
Remove unnecessary import
corrideat Dec 9, 2023
171d382
Fix Flow errors
corrideat Dec 9, 2023
037979e
Fix deserializeHEAD
corrideat Dec 9, 2023
067fb0b
Fix preSendCheck
corrideat Dec 9, 2023
7bc9b4b
Fix state
corrideat Dec 9, 2023
7163dc8
Duplicate proposal key prefix
corrideat Dec 9, 2023
b6558d0
fix check
corrideat Dec 9, 2023
f595687
Fixed race-conditions when joining a group
corrideat Dec 10, 2023
6ef6589
Improved check with both contracts
corrideat Dec 10, 2023
390d32d
Fix removing ourselves when re-added
corrideat Dec 11, 2023
6a7e5e7
Add duplicate check for previous volatile state; do so only if the
corrideat Dec 11, 2023
1e839d2
Readability and fixed check
corrideat Dec 11, 2023
c54ed0b
Remove unneeded logging
corrideat Dec 11, 2023
cab74db
Fixes to chatroom
corrideat Dec 11, 2023
8a484ed
Remove logging
corrideat Dec 11, 2023
a418db5
Merge branch 'e2e-protocol' into 1719-fix-all-tests-on-e2e-protocol-b…
corrideat Dec 11, 2023
88e5d41
Merge pull request #1787 from okTurtles/1719-fix-all-tests-on-e2e-pro…
taoeffect Dec 11, 2023
44d73ae
work on Greg/Snowteamer Feedbacks on the PR
SebinSong Dec 12, 2023
b3c9650
Merge pull request #1770 from okTurtles/sebin/task/926-create-pwa
taoeffect Dec 12, 2023
77eb415
fix the white-space issue
SebinSong Dec 12, 2023
477d9ff
Merge pull request #1795 from okTurtles/sebin/task/1790-fix-add-to-ch…
taoeffect Dec 12, 2023
5039af7
Move test data attributes into Cypress commands
corrideat Dec 12, 2023
8a40d0e
move the try ... catch block into the Promise callback
SebinSong Dec 13, 2023
5a45a93
Merge pull request #1796 from okTurtles/sebin/task/fix-cypress-error-…
taoeffect Dec 13, 2023
582c917
Improvements to tests.
corrideat Dec 15, 2023
3afefbd
Re-enable tests
corrideat Dec 15, 2023
b889882
Merge branch 'master' into e2e-protocol-ricardo
corrideat Dec 15, 2023
0db2320
Disable native worker temporarily to allow tests to pass
corrideat Dec 16, 2023
dc76f95
Add two tests to CI
corrideat Dec 17, 2023
e2d24b4
Update test suites used
corrideat Dec 17, 2023
77a10a2
Add checks and suppress chatroom leave error
corrideat Dec 18, 2023
4e2546e
Move preSendChecks to actions. Fix: group-chat fails
corrideat Dec 18, 2023
ef99263
Bugfixes. TODO: remove log, etc., DRY sorting in identity, fix chat-m…
corrideat Dec 21, 2023
3bc69b6
Bugfixes for pending messages; remove debug logging
corrideat Dec 22, 2023
1c6cc39
Make the pubsub system more generic (#1792)
snowteamer Dec 30, 2023
78926a4
#1793 Dark theme status bar color in the PWA (#1800)
SebinSong Jan 11, 2024
3772bd1
Merge branch 'master' into e2e-protocol
taoeffect Jan 11, 2024
e729588
Move General chatroom creation to side-effect, fix bug with sometimes…
corrideat Jan 11, 2024
f926a20
Add back accidentally removed tests
corrideat Jan 11, 2024
729ff89
Merge branch 'e2e-protocol' into e2e-protocol-ricardo
corrideat Jan 11, 2024
58e1c8b
Fix flow types
corrideat Jan 11, 2024
a6a24ac
#1791 - Immediately install new service worker on refresh (#1799)
SebinSong Jan 12, 2024
76cc6fc
#1665 Typing indicator in the chatroom (#1805)
SebinSong Jan 12, 2024
a359cf7
Address PR comments
corrideat Jan 12, 2024
d9de018
Bugfix: Fix group membership sync issue, re-joining us automatically
corrideat Jan 12, 2024
9970a69
use createCID instead of blake32hash in some places
taoeffect Jan 13, 2024
b73d79d
fix avatar upload test
taoeffect Jan 13, 2024
ff44fac
Cleanup & move logic to internalSideEffectsStack (part 1)
corrideat Jan 13, 2024
203ec77
fixed preloading
taoeffect Jan 13, 2024
25b53e7
Merge branch 'master' into e2e-protocol
taoeffect Jan 17, 2024
8b6b856
Various bugfixes and cleaning up.
corrideat Jan 17, 2024
969180f
#1811 - Wrong file attachment detection in the chatroom (#1813)
SebinSong Jan 18, 2024
11c03a5
Harmonise ChatMain scroll position with master and make topOffset a c…
corrideat Jan 18, 2024
d69c2b3
Clean up and add comments
corrideat Jan 18, 2024
869f95c
Fixes to chatroom scrolling
corrideat Jan 18, 2024
56dd7a3
Add timeout to scrolling test
corrideat Jan 18, 2024
68c8cfd
Moved onChatScroll to call flush and minor improvements
corrideat Jan 19, 2024
b7695c0
Clean up and comment code
corrideat Jan 19, 2024
69b8691
Add onChatScroll method wrapper
corrideat Jan 19, 2024
103b38b
Remove check for null or undefined
corrideat Jan 19, 2024
460846f
Fixed (removed) spurious error for outgoing OP_KEY_REQUEST; fixed the…
corrideat Jan 19, 2024
564e7db
Remove unnecessary preSendCheck uses and consolidate them in contracts
corrideat Jan 19, 2024
47c4df5
Fixes for pubsub when switching sessions (reset)
corrideat Jan 23, 2024
7028df4
Improvements for legibility
corrideat Jan 23, 2024
cd04f0c
Remove pending from root state
corrideat Jan 23, 2024
c7de2e8
Remove await from contracts identity.js and other small improvements
corrideat Jan 23, 2024
13dbaaa
Remove await for actions in identity contract
corrideat Jan 23, 2024
c0a0638
#1558 - markdown in chat (#1815)
SebinSong Jan 23, 2024
9b8ce43
Rewrite wait
corrideat Jan 24, 2024
c154a4e
Merge branch 'e2e-protocol-ricardo' into e2e-protocol
corrideat Jan 24, 2024
4348366
Disable CI tests
corrideat Jan 24, 2024
ab629c8
Merge branch 'e2e-protocol' into hash-fix
taoeffect Jan 24, 2024
ff4c3e8
Add esbuild optional dependencies
corrideat Jan 24, 2024
f61b445
Merge pull request #1810 from okTurtles/hash-fix
taoeffect Jan 24, 2024
ad4da02
Move /login action into root component's mounted
corrideat Jan 24, 2024
5ae508d
Clean up LoginForm.vue
corrideat Jan 25, 2024
ebfa8bd
Improved error handling and reporting
corrideat Jan 25, 2024
a50c815
Formatting and alerts for login errors
corrideat Jan 25, 2024
b77fdad
Merge pull request #1820 from okTurtles/e2e-protocol-ricardo
taoeffect Jan 25, 2024
aca723f
Revert "Disable CI tests"
corrideat Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
.*/frontend/assets/.*
.*/frontend/controller/service-worker.js
.*/frontend/utils/blockies.js
.*/frontend/utils/crypto.js
.*/frontend/utils/vuexQueue.js
.*/frontend/model/contracts/misc/flowTyper.js
.*/historical/.*
Expand Down
10 changes: 8 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

if (process.env['CI']) process.exit(1)

// =======================
// Entry point.
//
Expand Down Expand Up @@ -58,12 +60,15 @@ process.env.GI_VERSION = `${packageJSON.version}@${new Date().toISOString()}`
// We will rather load it later, and only if necessary.
// require('@babel/register')

// TODO: Change defult value for ALLOW_INSECURE_UNENCRYPTED_MESSAGES_WHEN_EKEY_NOT_FOUND

const {
CI = '',
LIGHTWEIGHT_CLIENT = 'true',
GI_VERSION,
NODE_ENV = 'development',
EXPOSE_SBP = ''
EXPOSE_SBP = '',
ALLOW_INSECURE_UNENCRYPTED_MESSAGES_WHEN_EKEY_NOT_FOUND = 'true'
} = process.env

const backendIndex = './backend/index.js'
Expand Down Expand Up @@ -196,7 +201,8 @@ module.exports = (grunt) => {
'process.env.GI_VERSION': `'${GI_VERSION}'`,
'process.env.LIGHTWEIGHT_CLIENT': `'${LIGHTWEIGHT_CLIENT}'`,
'process.env.NODE_ENV': `'${NODE_ENV}'`,
'process.env.EXPOSE_SBP': `'${EXPOSE_SBP}'`
'process.env.EXPOSE_SBP': `'${EXPOSE_SBP}'`,
'process.env.ALLOW_INSECURE_UNENCRYPTED_MESSAGES_WHEN_EKEY_NOT_FOUND': `'${ALLOW_INSECURE_UNENCRYPTED_MESSAGES_WHEN_EKEY_NOT_FOUND}'`
},
external: ['crypto', '*.eot', '*.ttf', '*.woff', '*.woff2'],
format: 'esm',
Expand Down
6 changes: 3 additions & 3 deletions backend/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sbp('sbp/selectors/register', {
const json = `"${strToB64(entry.serialize())}"`
if (currentHEAD !== hash) {
this.push(prefix + json)
currentHEAD = entry.message().previousHEAD
currentHEAD = entry.head().previousHEAD
prefix = ','
} else {
this.push(prefix + json + ']')
Expand Down Expand Up @@ -88,7 +88,7 @@ sbp('sbp/selectors/register', {
this.push(prefix + json)
prefix = ','
limit--
currentHEAD = entry.message().previousHEAD
currentHEAD = entry.head().previousHEAD
}
} catch (e) {
// TODO: properly return an error to caller, see https://nodejs.org/api/stream.html#errors-while-reading
Expand Down Expand Up @@ -123,7 +123,7 @@ sbp('sbp/selectors/register', {
offset--
}

currentHEAD = entry.message().previousHEAD
currentHEAD = entry.head().previousHEAD
if (!currentHEAD || (isMet && !offset)) {
this.push(']')
this.push(null)
Expand Down
105 changes: 105 additions & 0 deletions backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SERVER_INSTANCE } from './instance-keys.js'
import path from 'path'
import chalk from 'chalk'
import './database.js'
import { registrationKey, register, getChallenge, getContractSalt, updateContractSalt } from './zkppSalt.js'

const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
Expand Down Expand Up @@ -255,3 +256,107 @@ route.GET(staticServeConfig.routePath, {}, {
route.GET('/', {}, function (req, h) {
return h.redirect(staticServeConfig.redirect)
})

route.POST('/zkpp/register/{contract}', {
validate: {
payload: Joi.alternatives([
{
// what b is
b: Joi.string().required()
},
{
r: Joi.string().required(), // what r is
s: Joi.string().required(), // what s is
sig: Joi.string().required(),
Eh: Joi.string().required()
}
])
}
}, async function (req, h) {
try {
if (req.payload['b']) {
const result = await registrationKey(req.params['contract'], req.payload['b'])

if (result) {
return result
}
} else {
const result = await register(req.params['contract'], req.payload['r'], req.payload['s'], req.payload['sig'], req.payload['Eh'])

if (result) {
return result
}
}
} catch (e) {
const ip = req.info.remoteAddress
console.error('Error at POST /zkpp/{contract}: ' + e.message, { ip })
}

return Boom.internal('internal error')
})

route.GET('/zkpp/{contract}/auth_hash', {
validate: {
query: Joi.object({ b: Joi.string().required() })
}
}, async function (req, h) {
try {
const challenge = await getChallenge(req.params['contract'], req.query['b'])

return challenge || Boom.notFound()
} catch (e) {
const ip = req.info.remoteAddress
console.error('Error at GET /zkpp/{contract}/auth_hash: ' + e.message, { ip })
}

return Boom.internal('internal error')
})

route.GET('/zkpp/{contract}/contract_hash', {
validate: {
query: Joi.object({
r: Joi.string().required(),
s: Joi.string().required(),
sig: Joi.string().required(),
hc: Joi.string().required()
})
}
}, async function (req, h) {
try {
const salt = await getContractSalt(req.params['contract'], req.query['r'], req.query['s'], req.query['sig'], req.query['hc'])

if (salt) {
return salt
}
} catch (e) {
const ip = req.info.remoteAddress
console.error('Error at GET /zkpp/{contract}/contract_hash: ' + e.message, { ip })
}

return Boom.internal('internal error')
})

route.POST('/zkpp/updatePasswordHash/{contract}', {
validate: {
payload: Joi.object({
r: Joi.string().required(),
s: Joi.string().required(),
sig: Joi.string().required(),
hc: Joi.string().required(),
Ea: Joi.string().required()
})
}
}, async function (req, h) {
try {
const result = await updateContractSalt(req.params['contract'], req.payload['r'], req.payload['s'], req.payload['sig'], req.payload['hc'], req.payload['Ea'])

if (result) {
return result
}
} catch (e) {
const ip = req.info.remoteAddress
console.error('Error at POST /zkpp/updatePasswordHash/{contract}: ' + e.message, { ip })
}

return Boom.internal('internal error')
})
Loading