Skip to content

Commit

Permalink
Merge branch 'master' into feature-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
nrempel authored Sep 24, 2019
2 parents 22f7dba + e509712 commit ffeb1af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion aries_cloudagent/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ async def start(self) -> None:
),
public=context.settings.get("debug.invite_public", False)
)
invite_url = invitation.to_url()
base_url = context.settings.get("invite_base_url")
invite_url = invitation.to_url(base_url)
print("Invitation URL:")
print(invite_url)
except Exception:
Expand Down
8 changes: 8 additions & 0 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,12 @@ def add_arguments(self, parser: ArgumentParser):
connection response is accepted. Some agents require this before\
marking a connection as 'active'. Default: false.",
)
parser.add_argument(
"--invite-base-url",
type=str,
metavar="<base-url>",
help="Base URL to use when formatting connection invitations in URL format."
)
parser.add_argument(
"--public-invites",
action="store_true",
Expand All @@ -512,6 +518,8 @@ def get_settings(self, args: Namespace) -> dict:
settings["external_protocols"] = args.external_protocols
if args.auto_ping_connection:
settings["auto_ping_connection"] = True
if args.invite_base_url:
settings["invite_base_url"] = args.invite_base_url
if args.public_invites:
settings["public_invites"] = True
if args.timing:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
self.endpoint = endpoint
self.routing_keys = list(routing_keys) if routing_keys else None

def to_url(self) -> str:
def to_url(self, base_url: str = None) -> str:
"""
Convert an invitation to URL format for sharing.
Expand All @@ -63,7 +63,7 @@ def to_url(self) -> str:
"""
c_json = self.to_json()
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
result = urljoin(self.endpoint, "?c_i={}".format(c_i))
result = urljoin(base_url or self.endpoint or "", "?c_i={}".format(c_i))
return result

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion aries_cloudagent/messaging/connections/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ async def connections_create_invitation(request: web.BaseRequest):

if public and not context.settings.get("public_invites"):
raise web.HTTPForbidden()
base_url = context.settings.get("invite_base_url")

connection_mgr = ConnectionManager(context)
connection, invitation = await connection_mgr.create_invitation(
Expand All @@ -202,7 +203,7 @@ async def connections_create_invitation(request: web.BaseRequest):
result = {
"connection_id": connection and connection.connection_id,
"invitation": invitation.serialize(),
"invitation_url": invitation.to_url(),
"invitation_url": invitation.to_url(base_url),
}

if connection and connection.alias:
Expand Down

0 comments on commit ffeb1af

Please sign in to comment.