Skip to content

Commit

Permalink
chore: Web-demo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Dec 10, 2019
1 parent a194a5c commit 83cc036
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 49 deletions.
43 changes: 22 additions & 21 deletions examples/expressjs-ethr/src/web-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ app.use(sess)
app.engine('handlebars', exphbs())
app.set('view engine', 'handlebars')

const server = http.createServer(app)
const io = socketio(server)

io.use(
sharedsession(sess, {
autoSave: true,
}),
)

io.on('connection', function(socket) {
if (socket.handshake?.session) {
socket.join(socket.handshake.session.id)
}
socket.on('disconnect', function() {
console.log('user disconnected')
})
})

async function main() {
await dataStore.initialize()

Expand Down Expand Up @@ -79,6 +97,7 @@ async function main() {
}

jwt = await core.handleAction(signAction)
jwt = encodeURI('http://localhost:8099/ssi?c_i=') + jwt
} else {
name = await dataStore.shortId(did)
}
Expand All @@ -94,25 +113,7 @@ async function main() {
}),
)

const server = http.createServer(app)
const io = socketio(server)

io.use(
sharedsession(sess, {
autoSave: true,
}),
)

io.on('connection', function(socket) {
if (socket.handshake?.session) {
socket.join(socket.handshake.session.id)
}
socket.on('disconnect', function() {
console.log('user disconnected')
})
})

core.on(Daf.EventTypes.validatedMessage, async (message: Daf.Message, b: any) => {
core.on(Daf.EventTypes.validatedMessage, async (message: Daf.Message) => {
debug('New message %s', message.id)
debug('Meta %O', message.meta)
console.log(message)
Expand All @@ -121,7 +122,7 @@ async function main() {
// TODO check for required vcs

const sessionId = message.threadId
await io.in(sessionId).emit('loggedin', { did: message.from })
await io.in(sessionId).emit('loggedin', { did: message.sender })
sessionStore.get(sessionId, (error, session) => {
if (error) {
console.log(error)
Expand All @@ -130,7 +131,7 @@ async function main() {
if (session) {
console.log('Got session', session)
console.log('View count', session.viewcount)
session.did = message.from
session.did = message.sender
sessionStore.set(sessionId, session)
} else {
console.log('No session: ' + message.threadId)
Expand Down
1 change: 1 addition & 0 deletions examples/expressjs-ethr/views/layouts/main.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
console.log('Success')
document.getElementById('login').style.display = 'none'
document.getElementById('success').innerHTML = JSON.stringify(msg)
window.location = '/'
})
Expand Down
81 changes: 53 additions & 28 deletions examples/expressjs-ethr/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -586,65 +586,65 @@ cross-fetch@^3.0.4:
node-fetch "2.6.0"
whatwg-fetch "3.0.0"

daf-core@../../packages/daf-core, daf-core@^0.9.0:
version "0.9.0"
daf-core@../../packages/daf-core, daf-core@^0.10.0:
version "0.10.0"
dependencies:
blakejs "^1.1.0"
debug "^4.1.1"
events "^3.0.0"

daf-data-store@../../packages/daf-data-store, daf-data-store@^0.9.0:
version "0.9.0"
daf-data-store@../../packages/daf-data-store, daf-data-store@^0.10.0:
version "0.10.0"
dependencies:
blakejs "^1.1.0"
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
sql-bricks-sqlite "^0.1.0"

daf-debug@../../packages/daf-debug:
version "0.9.0"
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"

daf-did-comm@../../packages/daf-did-comm:
version "0.9.0"
version "0.10.0"
dependencies:
DIDComm-js "git://github.com/uport-project/DIDComm-js.git#fix/build-issues"
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
uuid "^3.3.3"

daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^0.9.0:
version "0.9.0"
daf-did-jwt@../../packages/daf-did-jwt, daf-did-jwt@^0.10.0:
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
did-jwt "^3.0.0"
did-resolver "^1.1.0"

daf-ethr-did-fs@../../packages/daf-ethr-did-fs:
version "0.9.0"
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
ethr-did "^1.1.0"

daf-node-sqlite3@../../packages/daf-node-sqlite3:
version "0.9.0"
version "0.10.0"
dependencies:
daf-data-store "^0.9.0"
daf-data-store "^0.10.0"
debug "^4.1.1"
sqlite3 "^4.1.0"

daf-resolver-universal@../../packages/daf-resolver-universal:
version "0.9.0"
version "0.10.0"
dependencies:
cross-fetch "^3.0.4"
debug "^4.1.1"

daf-resolver@../../packages/daf-resolver:
version "0.9.0"
version "0.10.0"
dependencies:
debug "^4.1.1"
did-resolver "^1.1.0"
Expand All @@ -653,22 +653,22 @@ daf-resolver@../../packages/daf-resolver:
web-did-resolver "^1.2.0"

daf-selective-disclosure@../../packages/daf-selective-disclosure:
version "0.9.0"
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-did-jwt "^0.9.0"
daf-core "^0.10.0"
daf-did-jwt "^0.10.0"
debug "^4.1.1"
did-jwt "^3.0.0"

daf-sodium-fs@../../packages/daf-sodium-fs:
version "0.9.0"
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
libsodium-wrappers "^0.7.6"

daf-trust-graph@../../packages/daf-trust-graph:
version "0.9.0"
version "0.10.0"
dependencies:
apollo-cache-inmemory "^1.6.3"
apollo-client "^2.6.4"
Expand All @@ -677,18 +677,25 @@ daf-trust-graph@../../packages/daf-trust-graph:
apollo-link-ws "^1.0.19"
apollo-utilities "^1.3.2"
cross-fetch "^3.0.4"
daf-core "^0.9.0"
daf-core "^0.10.0"
debug "^4.1.1"
did-jwt "^3.0.0"
graphql "^14.0.0"
graphql-tag "^2.10.1"
subscriptions-transport-ws "^0.9.0"

daf-url@../../packages/daf-url:
version "0.10.0"
dependencies:
daf-core "^0.10.0"
debug "^4.1.1"
url-parse "^1.4.7"

daf-w3c@../../packages/daf-w3c:
version "0.9.0"
version "0.10.0"
dependencies:
daf-core "^0.9.0"
daf-did-jwt "^0.9.0"
daf-core "^0.10.0"
daf-did-jwt "^0.10.0"
debug "^4.1.1"
did-jwt-vc "^0.1.2"
did-resolver "^1.1.0"
Expand Down Expand Up @@ -1950,6 +1957,11 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==

querystringify@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e"
integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==

random-bytes@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b"
Expand Down Expand Up @@ -2029,6 +2041,11 @@ request@^2.87.0:
tunnel-agent "^0.6.0"
uuid "^3.3.2"

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=

reselect@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147"
Expand Down Expand Up @@ -2428,6 +2445,14 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

url-parse@^1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278"
integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==
dependencies:
querystringify "^2.1.1"
requires-port "^1.0.0"

util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit 83cc036

Please sign in to comment.