pymensago/iscmds.py
def login(conn: ServerConnection, wid: utils.UUID, serverkey: CryptoString) -> RetVal:
	'''Starts the login process by sending the requested workspace ID.'''
	if not wid.is_valid():
		return RetVal(ErrBadValue)

	challenge = b85encode(secrets.token_bytes(32))
	ekey = PublicKey(serverkey)
	status = ekey.encrypt(challenge)
	if status.error():
		return status

	status = conn.send_message({
		'Action' : "LOGIN",
		'Data' : {
			'Workspace-ID' : wid.as_string(),
			'Login-Type' : 'PLAIN',
			'Challenge' : status['data']
		}
	})
	if status.error():
		return status

	response = conn.read_response(server_response)
	if response.error():
		return response
	
	if response['Code'] != 100:
		return wrap_server_error(response)
	
	if response['Data']['Response'] != challenge.decode():
		return RetVal(ErrServerError, 'server failed to decrypt challenge')
	
	return RetVal()
Starts the login process by sending the requested workspace ID.
Starts the login process by sending the requested workspace ID.
Starts the login process by sending the requested workspace ID .
def login(conn: ServerConnection, wid: utils.UUID, serverkey: CryptoString) -> RetVal:
	if not wid.is_valid():
		return RetVal(ErrBadValue)
	challenge = b85encode(secrets.token_bytes(32))
	ekey = PublicKey(serverkey)
	status = ekey.encrypt(challenge)
	if status.error():
		return status
	status = conn.send_message({
		'Action' : "LOGIN",
		'Data' : {
			'Workspace-ID' : wid.as_string(),
			'Login-Type' : 'PLAIN',
			'Challenge' : status['data']
		}
	})
	if status.error():
		return status
	response = conn.read_response(server_response)
	if response.error():
		return response
	if response['Code'] != 100:
		return wrap_server_error(response)
	if response['Data']['Response'] != challenge.decode():
		return RetVal(ErrServerError, 'server failed to decrypt challenge')
	return RetVal()
def login ( conn : ServerConnection , wid : utils . UUID , serverkey : CryptoString ) -> RetVal : if not wid . is_valid ( ) : return RetVal ( ErrBadValue ) challenge = b85encode ( secrets . token_bytes ( 32 ) ) ekey = PublicKey ( serverkey ) status = ekey . encrypt ( challenge ) if status . error ( ) : return status status = conn . send_message ( { 'Action' : "LOGIN" , 'Data' : { 'Workspace-ID' : wid . as_string ( ) , 'Login-Type' : 'PLAIN' , 'Challenge' : status [ 'data' ] } } ) if status . error ( ) : return status response = conn . read_response ( server_response ) if response . error ( ) : return response if response [ 'Code' ] != 100 : return wrap_server_error ( response ) if response [ 'Data' ] [ 'Response' ] != challenge . decode ( ) : return RetVal ( ErrServerError , 'server failed to decrypt challenge' ) return RetVal ( )
Starts the login process by sending the requested workspace ID.
Starts the login process by sending the requested workspace ID .
'''Starts the login process by sending the requested workspace ID.'''
conn
ServerConnection
wid
utils.UUID
serverkey
CryptoString