forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
50 lines (42 loc) · 1.51 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
// This is a test nodejs app for developers to test WASM integration.
const { Framework } = require('./dist/node/aries.js');
(async () => {
const aries = await new Framework({
assetsPath: process.cwd() + "/dist/assets",
"agent-default-label": "dem-js-agent",
"http-resolver-url": [],
"auto-accept": true,
"outbound-transport": ["ws", "http"],
"transport-return-route": "all",
"log-level": "debug"
})
// sample invitation
const invitation = {
"@id":"4d26ad47-c71b-4e2e-9358-0a76f7fa77e4",
"@type":"https://didcomm.org/didexchange/1.0/invitation",
"label":"demo-js-agent",
"recipientKeys":["7rADm5sA9FHB4enuYXj6PJZDAm1JcesKmbtx7Qh8YZrg"],
"serviceEndpoint":"routing:endpoint"
};
// listen for connection 'received' notification
aries.startNotifier(notice => {
const connection = notice.payload
// accept invitation
aries.didexchange.acceptInvitation(connection.connection_id)
}, ["connections"])
// receive invitation
aries.didexchange.receiveInvitation(invitation)
// listen for connection 'completed' notification
aries.startNotifier(notice => {
const connection = notice.payload
if (connection.state === "completed") {
console.log("connection completed!")
}
}, ["connections"])
// release resources
aries.destroy()
})()