|
1 | 1 | {% extends "base.jinja" %} |
2 | 2 | {% block main %} |
| 3 | + {% include "includes/hwi/hwi.jinja" %} |
3 | 4 | <h1>{{ device.name }}</h1> |
4 | 5 | <form action="./" method="POST"> |
5 | 6 | <div class="row"> |
|
48 | 49 | </div> |
49 | 50 | <div class="spacer"></div> |
50 | 51 | <div class="row"> |
| 52 | + {% if device.supports_hwi_toggle_passphrase %} |
| 53 | + <button type="button" class="btn centered" onclick="togglePassphrase()">Toggle device passphrase</button> |
| 54 | + |
| 55 | + {% endif %} |
51 | 56 | {% if device.device_type != 'bitcoincore' %} |
52 | 57 | <form action="./" method="POST"> |
53 | 58 | <button id="add_keys" type="submit" name="action" value="add_keys" class="btn centered">Add more keys</button> |
54 | 59 | </form> |
55 | | - {% endif %} |
56 | 60 | |
| 61 | + {% endif %} |
57 | 62 | <form action="./" method="POST"> |
58 | 63 | <button type="submit" name="action" value="forget" class="btn danger centered">Forget the device</button> |
59 | 64 | </form> |
|
95 | 100 | } |
96 | 101 | }, false); |
97 | 102 | }); |
| 103 | +
|
| 104 | + async function togglePassphrase(){ |
| 105 | + let devices = await enumerate('{{ device.device_type }}'); |
| 106 | + if(devices == null || devices.length == 0){ |
| 107 | + return; |
| 108 | + } |
| 109 | + let device = await selectDevice(devices, ''); |
| 110 | + showHWIProgress("Processing...", `Keep your ${capitalize(device.type)} connected.`); |
| 111 | + let result = null; |
| 112 | + try { |
| 113 | + result = await hwi.togglePassphrase(device); |
| 114 | + } catch (error) { |
| 115 | + handleHWIError(error); |
| 116 | + return null; |
| 117 | + } |
| 118 | + if(!overlayIsActive()){ |
| 119 | + showNotification("HWI is ready again", 10000); |
| 120 | + // no need to proceed at all |
| 121 | + return null; |
| 122 | + } |
| 123 | + hidePageOverlay(); |
| 124 | + if (device.type == "keepkey") { |
| 125 | + result = await enterPin(device, false); |
| 126 | + if(result == null){ |
| 127 | + return null; |
| 128 | + } |
| 129 | + if(!('success' in result) || !result.success){ |
| 130 | + throw "Failed to unlock device! Invalid PIN code?"; |
| 131 | + } |
| 132 | + } |
| 133 | + showNotification("{{ device.name }} passphrase toggled successfuly", 5000) |
| 134 | + } |
98 | 135 | </script> |
99 | 136 | {% endblock %} |
0 commit comments