def split_chunks(string, remarks): return json.loads( decode_str( rustcall( lib.semaphore_split_chunks, encode_str(string), encode_str(json.dumps(remarks)), ) ) )
def verify(self, buf, sig, max_age=None): buf = make_buf(buf) sig = encode_str(sig) if max_age is None: return self._methodcall(lib.semaphore_publickey_verify, buf, sig) return self._methodcall(lib.semaphore_publickey_verify_timestamp, buf, sig, max_age)
def verify(self, buf, sig, max_age=None): buf = make_buf(buf) sig = encode_str(sig) if max_age is None: return self._methodcall(lib.semaphore_publickey_verify, buf, sig) return self._methodcall( lib.semaphore_publickey_verify_timestamp, buf, sig, max_age )
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 __new__(cls, geoip_lookup=None, **config): config = json.dumps(config) geoptr = geoip_lookup._get_objptr() if geoip_lookup is not None else ffi.NULL rv = cls._from_objptr( rustcall(lib.semaphore_store_normalizer_new, encode_str(config), geoptr) ) if geoip_lookup is not None: attached_refs[rv] = geoip_lookup return 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 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 parse(cls, string): s = encode_str(string) ptr = rustcall(lib.semaphore_secretkey_parse, s) return cls._from_objptr(ptr)