def create_encrypted_token(claims, jwk=get_jwk()): signed_jwt = create_signed_jwt(claims, jwk) encrypted_token = JWT(header={ "alg": "A256KW", "enc": "A256CBC-HS512" }, claims=signed_jwt) encrypted_token.make_encrypted_token(jwk) return encrypted_token
def create_secure_metadata(key_id, key_secret, expires, metadata): header = { "alg": "dir", "enc": "A256GCM", "kid": key_id, } claims = { "exp": int(expires), "ninchat.com/metadata": metadata, } key = JWK(kty="oct", k=key_secret) token = JWT(header=header, claims=claims) token.make_encrypted_token(key) return token.serialize()