Skip to content

Commit

Permalink
Removing padding from url invitations (openwallet-foundation#3238)
Browse files Browse the repository at this point in the history
* Removing padding for oob invitation url

Signed-off-by: Jamie Hale <[email protected]>

* Removing padding for connection invitation url

Signed-off-by: Jamie Hale <[email protected]>

* Fix padding test

Signed-off-by: Jamie Hale <[email protected]>

* Re-sync

Signed-off-by: Jamie Hale <[email protected]>

---------

Signed-off-by: Jamie Hale <[email protected]>
  • Loading branch information
jamshale authored and ff137 committed Oct 22, 2024
1 parent 45e733f commit 8465def
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def to_url(self, base_url: Optional[str] = None) -> str:
"""
c_json = self.to_json()
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True, pad=False)
result = urljoin(base_url or self.endpoint or "", "?c_i={}".format(c_i))
return result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def to_url(self, base_url: Optional[str] = None) -> str:
"""
c_json = self.to_json()
oob = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
oob = bytes_to_b64(c_json.encode("ascii"), urlsafe=True, pad=False)
endpoint = None
if not base_url:
for service_item in self.services:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from unittest.mock import ANY

from aries_cloudagent.tests import mock
from aries_cloudagent.wallet.util import pad

from .....connections.models.conn_record import ConnRecord
from .....connections.models.connection_target import ConnectionTarget
Expand Down Expand Up @@ -883,7 +884,8 @@ async def test_create_invitation_goal_code(self):

base64_message = invi_rec.invitation_url.split("=", maxsplit=1)[1]
base64_bytes = base64_message.encode("ascii")
message_bytes = base64.b64decode(base64_bytes)
message_bytes = base64.b64decode(base64_bytes + b"==")
base64.urlsafe_b64decode(pad(base64_message))
data = message_bytes.decode("ascii")
assert data
invite_json = json.loads(data)
Expand Down

0 comments on commit 8465def

Please sign in to comment.