示例#1
0
 def send_pin(self, pin: str) -> bool:
     self.client.open()
     if not pin.isdigit():
         raise BadArgumentError("Non-numeric PIN provided")
     resp = self.client.call_raw(messages.PinMatrixAck(pin=pin))
     if isinstance(resp, messages.Failure):
         self.client.features = self.client.call_raw(messages.GetFeatures())
         if isinstance(self.client.features, messages.Features):
             if not self.client.features.pin_protection:
                 raise DeviceAlreadyUnlockedError("This device does not need a PIN")
             if self.client.features.unlocked:
                 raise DeviceAlreadyUnlockedError(
                     "The PIN has already been sent to this device"
                 )
         return False
     elif isinstance(resp, messages.PassphraseRequest):
         pass_resp = self.client.call_raw(
             messages.PassphraseAck(
                 passphrase=self.client.ui.get_passphrase(available_on_device=False),
                 on_device=False,
             )
         )
         if isinstance(pass_resp, messages.Deprecated_PassphraseStateRequest):
             self.client.call_raw(messages.Deprecated_PassphraseStateAck())
     return True
示例#2
0
 def send_pin(self, pin):
     self.client.open()
     if not pin.isdigit():
         raise BadArgumentError("Non-numeric PIN provided")
     resp = self.client.call_raw(proto.PinMatrixAck(pin=pin))
     if isinstance(resp, proto.Failure):
         self.client.features = self.client.call_raw(proto.GetFeatures())
         if isinstance(self.client.features, proto.Features):
             if not self.client.features.pin_protection:
                 raise DeviceAlreadyUnlockedError('This device does not need a PIN')
             if self.client.features.pin_cached:
                 raise DeviceAlreadyUnlockedError('The PIN has already been sent to this device')
         return {'success': False}
     return {'success': True}