This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: aries-js-worker - didexchange edgeagent/router
Signed-off-by: George Aristy <george.aristy@securekey.com>
- Loading branch information
George Aristy
committed
Feb 26, 2020
1 parent
1aef12b
commit 01b1eac
Showing
14 changed files
with
326 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
|
||
node_modules/ | ||
public/ | ||
environment.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Agent configurations | ||
E2E_AGENT_REST_IMAGE=aries-framework-go/agent-rest | ||
E2E_AGENT_REST_IMAGE_TAG=latest | ||
|
||
# Transport Schemes | ||
E2E_HTTP_SCHEME=http | ||
E2E_WS_SCHEME=ws | ||
|
||
# Router configurations | ||
E2E_ROUTER_HOST=0.0.0.0 | ||
E2E_ROUTER_HTTP_INBOUND_PORT=10091 | ||
E2E_ROUTER_WS_INBOUND_PORT=10092 | ||
E2E_ROUTER_API_PORT=10093 | ||
E2E_ROUTER_DB_PATH=/tmp/db/aries | ||
E2E_ROUTER_WEBHOOK_PORT=10094 | ||
E2E_ROUTER_AUTOACCEPT=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
version: '2' | ||
|
||
services: | ||
|
||
carl.router.agent.example.com: | ||
container_name: aries-js-worker-router.com | ||
image: ${E2E_AGENT_REST_IMAGE}:${E2E_AGENT_REST_IMAGE_TAG} | ||
environment: | ||
- ARIESD_API_HOST=${E2E_ROUTER_HOST}:${E2E_ROUTER_API_PORT} | ||
- ARIESD_INBOUND_HOST=${E2E_HTTP_SCHEME}@${E2E_ROUTER_HOST}:${E2E_ROUTER_HTTP_INBOUND_PORT},${E2E_WS_SCHEME}@${E2E_ROUTER_HOST}:${E2E_ROUTER_WS_INBOUND_PORT} | ||
- ARIESD_INBOUND_HOST_EXTERNAL=${E2E_HTTP_SCHEME}@http://localhost:${E2E_ROUTER_HTTP_INBOUND_PORT},${E2E_WS_SCHEME}@ws://localhost:${E2E_ROUTER_WS_INBOUND_PORT} | ||
- ARIESD_DB_PATH=${E2E_ROUTER_DB_PATH} | ||
- ARIESD_DEFAULT_LABEL=carl-router-agent | ||
- ARIESD_OUTBOUND_TRANSPORT=${E2E_HTTP_SCHEME},${E2E_WS_SCHEME} | ||
- ARIESD_AUTO_ACCEPT=${E2E_ROUTER_AUTOACCEPT} | ||
# - ARIESD_LOG_LEVEL=DEBUG | ||
ports: | ||
- ${E2E_ROUTER_HTTP_INBOUND_PORT}:${E2E_ROUTER_HTTP_INBOUND_PORT} | ||
- ${E2E_ROUTER_WS_INBOUND_PORT}:${E2E_ROUTER_WS_INBOUND_PORT} | ||
- ${E2E_ROUTER_API_PORT}:${E2E_ROUTER_API_PORT} | ||
command: start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export async function newAries() { | ||
return new Aries.Framework({ | ||
assetsPath: "/base/public/aries-framework-go/assets", | ||
"agent-default-label": "dem-js-agent", | ||
"http-resolver-url": [], | ||
"auto-accept": true, | ||
"outbound-transport": ["ws", "http"], | ||
"transport-return-route": "all", | ||
"log-level": "debug" | ||
}) | ||
} | ||
|
||
export async function healthCheck(url, timeout, msgTimeout) { | ||
if (url.startsWith("http")) { | ||
return testHttpUrl(url, timeout, msgTimeout) | ||
} else if (url.startsWith("ws")) { | ||
return testWsUrl(url, timeout, msgTimeout) | ||
} else { | ||
throw new Error(`unsupported protocol for url: ${url}`) | ||
} | ||
} | ||
|
||
function testHttpUrl(url, timeout, msgTimeout) { | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject(new Error(msgTimeout)), timeout) | ||
// TODO HTTP GET for the HTTP inbound transport endpoint (eg. http://0.0.0.0:10091) returns 405. Axios fails, fetch() doesn't. | ||
// Golang's http.Get() does not fail for non 2xx codes. | ||
fetch(url).then( | ||
resp => {clearTimeout(timer); resolve(resp)}, | ||
err => {clearTimeout(timer); console.log(err); reject(new Error(`failed to fetch url=${url}: ${err.message}`))} | ||
) | ||
}) | ||
} | ||
|
||
function testWsUrl(url, timeout, msgTimeout) { | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject(new Error(msgTimeout)), timeout) | ||
const ws = new WebSocket(url) | ||
ws.onopen = () => {clearTimeout(timer); resolve()} | ||
ws.onerror = err => {clearTimeout(timer); reject(new Error(err.message))} | ||
}) | ||
} |
Oops, something went wrong.