def normalize_event(self, event=None, raw_event=None): if raw_event is None: raw_event = json.dumps(event, ensure_ascii=False).encode( "utf-8", errors="replace" ) event = encode_str(raw_event, mutable=True) rustcall(lib.semaphore_translate_legacy_python_json, event) rv = self._methodcall(lib.semaphore_store_normalizer_normalize_event, event) return json.loads(decode_str(rv))
def create_register_challenge(data, signature, max_age=60 * 15): rv = json.loads( decode_str( rustcall(lib.semaphore_create_register_challenge, make_buf(data), encode_str(signature), max_age))) return { 'relay_id': uuid.UUID(rv['relay_id']), 'public_key': PublicKey.parse(rv['public_key']), 'token': rv['token'], }
def validate_register_response(public_key, data, signature, max_age=60 * 15): rv = json.loads( decode_str( rustcall(lib.semaphore_validate_register_response, public_key._objptr, make_buf(data), encode_str(signature), max_age))) return { 'relay_id': uuid.UUID(rv['relay_id']), 'token': rv['token'], }
def split_chunks(string, remarks): return json.loads( decode_str( rustcall( lib.semaphore_split_chunks, encode_str(string), encode_str(json.dumps(remarks)), ) ) )
def validate_register_response(public_key, data, signature, max_age=60 * 15): rv = json.loads( decode_str( rustcall( lib.semaphore_validate_register_response, public_key._objptr, make_buf(data), encode_str(signature), max_age, ) ) ) return {"relay_id": uuid.UUID(rv["relay_id"]), "token": rv["token"]}
def create_register_challenge(data, signature, max_age=60 * 15): rv = json.loads( decode_str( rustcall( lib.semaphore_create_register_challenge, make_buf(data), encode_str(signature), max_age, ) ) ) return { "relay_id": uuid.UUID(rv["relay_id"]), "public_key": PublicKey.parse(rv["public_key"]), "token": rv["token"], }
def __str__(self): return decode_str( self._methodcall(lib.semaphore_secretkey_to_string), free=True )
def sign(self, value): buf = make_buf(value) return decode_str( self._methodcall(lib.semaphore_secretkey_sign, buf), free=True )