Merge branch 'main' of github.com:sartography/connector-proxy-status-im into main
This commit is contained in:
commit
a30fff5650
11
app.py
11
app.py
|
@ -59,8 +59,7 @@ def list_commands():
|
|||
def auth_handler(plugin_display_name, auth_name, params):
|
||||
auth = PluginService.auth_named(plugin_display_name, auth_name)
|
||||
if auth is not None:
|
||||
handler_params = auth.filtered_params(params)
|
||||
app_description = auth(**handler_params).app_description()
|
||||
app_description = auth().app_description(app.config)
|
||||
|
||||
# TODO right now this assumes Oauth.
|
||||
# would need to expand if other auth providers are used
|
||||
|
@ -89,8 +88,8 @@ def do_auth(plugin_display_name, auth_name):
|
|||
|
||||
# TODO factor into handler
|
||||
# TODO namespace the keys
|
||||
session["client_id"] = params["client_id"]
|
||||
session["client_secret"] = params["client_secret"]
|
||||
session["client_id"] = app.config["XERO_CLIENT_ID"]
|
||||
session["client_secret"] = app.config["XERO_CLIENT_SECRET"]
|
||||
|
||||
oauth_redirect_url = url_for(
|
||||
"auth_callback",
|
||||
|
@ -116,7 +115,7 @@ def auth_callback(plugin_display_name, auth_name):
|
|||
return redirect(f"{redirect_url}?response={response}")
|
||||
|
||||
|
||||
@app.route("/v1/do/<plugin_display_name>/<command_name>")
|
||||
@app.route("/v1/do/<plugin_display_name>/<command_name>", methods = ["GET", "POST"])
|
||||
def do_command(plugin_display_name, command_name):
|
||||
command = PluginService.command_named(plugin_display_name, command_name)
|
||||
if command is None:
|
||||
|
@ -124,7 +123,7 @@ def do_command(plugin_display_name, command_name):
|
|||
f"Command not found: {plugin_display_name}:{command_name}", status=404
|
||||
)
|
||||
|
||||
params = request.args.to_dict()
|
||||
params = request.values.to_dict()
|
||||
raw_task_data = params.pop('spiff__task_data', '{}')
|
||||
task_data = json.loads(raw_task_data)
|
||||
|
||||
|
|
|
@ -15,4 +15,5 @@ fi
|
|||
workers=3
|
||||
|
||||
# THIS MUST BE THE LAST COMMAND!
|
||||
exec poetry run gunicorn --bind "0.0.0.0:$port" --workers="$workers" --timeout 90 --capture-output --access-logfile '-' --log-level debug app:app
|
||||
# default --limit-request-line is 4094. see https://stackoverflow.com/a/66688382/6090676
|
||||
exec poetry run gunicorn --bind "0.0.0.0:$port" --workers="$workers" --limit-request-line 8192 --timeout 90 --capture-output --access-logfile '-' --log-level debug app:app
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""UploadFile."""
|
||||
import base64
|
||||
|
||||
from botocore.exceptions import ClientError # type: ignore
|
||||
from connector_aws.auths.simpleAuth import SimpleAuth # type: ignore
|
||||
|
||||
|
@ -8,7 +10,7 @@ class UploadFileData:
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
file_data: bytes,
|
||||
file_data: str,
|
||||
bucket: str,
|
||||
object_name: str,
|
||||
):
|
||||
|
@ -25,11 +27,14 @@ class UploadFileData:
|
|||
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
|
||||
file_data = self.parse_file_data(self.file_data)
|
||||
|
||||
# Upload the file
|
||||
client = SimpleAuth("s3", config).get_resource()
|
||||
try:
|
||||
result = client.Object(self.bucket, self.object_name).put(
|
||||
Body=self.file_data
|
||||
Body=file_data
|
||||
)
|
||||
status = str(result["ResponseMetadata"]["HTTPStatusCode"])
|
||||
|
||||
|
@ -43,3 +48,12 @@ class UploadFileData:
|
|||
status = "500"
|
||||
|
||||
return {"response": response, "status": status, "mimetype": "application/json"}
|
||||
|
||||
def parse_file_data(self, raw_data):
|
||||
# looks like:
|
||||
# "data:application/pdf;name=Harmeet_13435%20(1).pdf;base64,JVBERi0xLjQKJZOMi54gUmVwb3J0TGFiIEdlb....="
|
||||
parts = raw_data.split(";", 2)
|
||||
base64_data = parts[2].removeprefix("base64,")
|
||||
file_data = base64.b64decode(base64_data)
|
||||
|
||||
return file_data
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Build status-go in a Go builder container
|
||||
FROM golang:1.18-alpine as builder
|
||||
|
||||
RUN apk add --no-cache make gcc g++ musl-dev linux-headers
|
||||
|
||||
ARG build_tags
|
||||
ARG build_flags
|
||||
|
||||
RUN mkdir -p /go/src/github.com/status-im/status-go
|
||||
WORKDIR /go/src/github.com/status-im/status-go
|
||||
ADD . .
|
||||
# RUN cd cmd/spiff-workflow && go build --mod=vendor
|
||||
RUN cd cmd/spiff-workflow && go build --mod=vendor
|
||||
|
||||
# Copy the binary to the second image
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk add --no-cache ca-certificates bash libgcc libstdc++
|
||||
RUN mkdir -p /static/keys
|
||||
|
||||
COPY --from=builder /go/src/github.com/status-im/status-go/cmd/spiff-workflow/spiff-workflow /usr/local/bin/
|
||||
|
||||
# 30304 is used for Discovery v5
|
||||
EXPOSE 8080 8545 30303 30303/udp 30304/udp
|
||||
|
||||
# ENTRYPOINT ["/usr/local/bin/statusd"]
|
||||
ENTRYPOINT ["/usr/local/bin/spiff-workflow"]
|
||||
CMD ["--help"]
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function error_handler() {
|
||||
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||
exit "$2"
|
||||
}
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
|
||||
docker \
|
||||
run \
|
||||
--net=host \
|
||||
--name spiffworkflow-waku-node \
|
||||
-d \
|
||||
spiffworkflow-waku-node:latest \
|
||||
--seed-phrase "waku ftw we are about to send a one on one message baby oh yeah"
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function error_handler() {
|
||||
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||
exit "$2"
|
||||
}
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
set -x
|
||||
|
||||
script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
|
||||
home_tmp_dir="/home/sartography/tmp_docker_build"
|
||||
mkdir -p "$home_tmp_dir"
|
||||
|
||||
# docker installed by snap does not have access to /tmp so move it
|
||||
# https://github.com/docker-snap/docker-snap/issues/34
|
||||
mv "$tmp_dir" "$home_tmp_dir"
|
||||
|
||||
git clone https://github.com/status-im/status-go.git "${home_tmp_dir}${tmp_dir}/status-go"
|
||||
cd "${home_tmp_dir}${tmp_dir}/status-go"
|
||||
git checkout feature/spiff-workflow
|
||||
|
||||
cp "${script_dir}/../Dockerfile" .
|
||||
docker build -t spiffworkflow-waku-node:latest .
|
||||
|
||||
rm -rf "$home_tmp_dir"
|
|
@ -6,6 +6,21 @@ import requests
|
|||
from flask import current_app
|
||||
|
||||
|
||||
# Example:
|
||||
"""
|
||||
curl -XPOST http://localhost:8545 -H 'Content-type: application/json' \
|
||||
'{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "wakuext_sendOneToOneMessage",
|
||||
"params": [
|
||||
{
|
||||
"id": "0xPUBLIC_KEY",
|
||||
"message": "hello there, try http://167.172.242.138:7001/"
|
||||
}
|
||||
],
|
||||
"id": 1
|
||||
}'
|
||||
"""
|
||||
@dataclass
|
||||
class SendMessage:
|
||||
"""SendMessage."""
|
||||
|
@ -16,12 +31,14 @@ class SendMessage:
|
|||
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
url = f'{current_app.config["WAKU_PROXY_BASE_URL"]}/sendMessage'
|
||||
url = f'{current_app.config["WAKU_BASE_URL"]}'
|
||||
headers = {"Accept": "application/json", "Content-type": "application/json"}
|
||||
request_body = {
|
||||
"message": self.message,
|
||||
"recipient": self.recipient,
|
||||
"message_type": self.message_type,
|
||||
"jsonrpc": "2.0",
|
||||
"method": self.message_type,
|
||||
"params":[{"id": self.recipient,
|
||||
"message": self.message}],
|
||||
"id": 1
|
||||
}
|
||||
|
||||
status_code = None
|
||||
|
|
|
@ -4,18 +4,17 @@
|
|||
class OAuth:
|
||||
"""OAuth."""
|
||||
|
||||
def __init__(self, client_id: str, client_secret: str):
|
||||
def __init__(self):
|
||||
"""__init__."""
|
||||
self.client_id = client_id
|
||||
self.client_secret = client_secret
|
||||
pass
|
||||
|
||||
def app_description(self):
|
||||
def app_description(self, config):
|
||||
"""App_description."""
|
||||
return {
|
||||
"name": "xero",
|
||||
"version": "2",
|
||||
"client_id": self.client_id,
|
||||
"client_secret": self.client_secret,
|
||||
"client_id": config["XERO_CLIENT_ID"],
|
||||
"client_secret": config["XERO_CLIENT_SECRET"],
|
||||
"endpoint_url": "https://api.xero.com/",
|
||||
"authorization_url": "https://login.xero.com/identity/connect/authorize",
|
||||
"access_token_url": "https://identity.xero.com/connect/token",
|
||||
|
@ -25,6 +24,7 @@ class OAuth:
|
|||
"accounting.contacts accounting.attachments assets projects",
|
||||
}
|
||||
|
||||
# TODO reconsider how this is working
|
||||
@staticmethod
|
||||
def filtered_params(params):
|
||||
"""Filtered_params."""
|
||||
|
|
|
@ -199,6 +199,7 @@ class CreateInvoice:
|
|||
quantity=1.0,
|
||||
unit_amount=self.amount,
|
||||
account_code="400",
|
||||
tax_type="NONE",
|
||||
tracking=[],
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue