def build_invite(label: str, connection_key: str, endpoint: str) -> str: msg = Message({ '@type': INVITE, 'label': label, 'recipientKeys': [connection_key], 'serviceEndpoint': endpoint, 'routingKeys': [] }) b64_invite = base64.urlsafe_b64encode(bytes(msg.serialize(), 'utf-8')).decode('ascii') return '{}?c_i={}'.format(endpoint, b64_invite)
def create_invitation(self): """ Create and return an invite. """ conn_vk, conn_sk = crypto.create_keypair() connection = StaticConnection(conn_vk, conn_sk, b'', '', dispatcher=self.dispatcher) conn_vk_b58 = crypto.bytes_to_b58(conn_vk) self.connections[conn_vk_b58] = connection connection.state = ConnectionState() connection.state.role = Roles.INVITER connection.state.transition(Events.SEND_INVITE) invitation = Message({ '@type': self.type('invitation'), 'label': 'static-iiw', 'recipientKeys': [conn_vk_b58], 'serviceEndpoint': self.endpoint, 'routingKeys': [] }) invitation_url = '{}?c_i={}'.format( self.endpoint, crypto.bytes_to_b64(invitation.serialize().encode())) return connection, invitation_url