@bulolo/hermes-link 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3585,14 +3585,36 @@ function buildPairingPage(options) {
|
|
|
3585
3585
|
</div>
|
|
3586
3586
|
<script>
|
|
3587
3587
|
async function pair() {
|
|
3588
|
-
const token = document.getElementById('token').textContent;
|
|
3588
|
+
const token = document.getElementById('token').textContent.trim();
|
|
3589
|
+
const btn = document.querySelector('button');
|
|
3590
|
+
btn.disabled = true;
|
|
3591
|
+
btn.textContent = 'Pairing...';
|
|
3589
3592
|
try {
|
|
3590
|
-
const res = await fetch('
|
|
3591
|
-
|
|
3593
|
+
const res = await fetch('/api/v1/auth/device-session', {
|
|
3594
|
+
method: 'POST',
|
|
3595
|
+
headers: {
|
|
3596
|
+
'Authorization': 'Bearer ' + token,
|
|
3597
|
+
'Content-Type': 'application/json'
|
|
3598
|
+
},
|
|
3599
|
+
body: JSON.stringify({
|
|
3600
|
+
device_label: navigator.userAgent.slice(0, 64),
|
|
3601
|
+
device_platform: 'web'
|
|
3602
|
+
})
|
|
3603
|
+
});
|
|
3604
|
+
const data = await res.json();
|
|
3605
|
+
if (res.ok && data.access_token) {
|
|
3592
3606
|
document.getElementById('status').style.display = 'block';
|
|
3607
|
+
document.getElementById('status').innerHTML =
|
|
3608
|
+
'Paired! Access token:<br><code style="font-size:0.75rem;word-break:break-all">' +
|
|
3609
|
+
data.access_token.token + '</code>';
|
|
3610
|
+
btn.textContent = 'Paired';
|
|
3611
|
+
} else {
|
|
3612
|
+
throw new Error(data.error?.message || JSON.stringify(data));
|
|
3593
3613
|
}
|
|
3594
3614
|
} catch (e) {
|
|
3595
|
-
|
|
3615
|
+
btn.disabled = false;
|
|
3616
|
+
btn.textContent = 'Pair This Device';
|
|
3617
|
+
alert('Pairing failed: ' + e.message);
|
|
3596
3618
|
}
|
|
3597
3619
|
}
|
|
3598
3620
|
</script>
|
package/dist/cli/index.js
CHANGED
package/dist/http/app.js
CHANGED