homebridge-smartthings-oauth 1.0.44 → 1.0.45

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.0.45] - OAuth Wizard Popup Fix
5
+
6
+ ### Fixed
7
+ - **OAuth Wizard popup blocked**: The SmartThings login popup in step 3 of the OAuth wizard was silently blocked by browsers for many users. The `window.open()` call happened after an `await`, which breaks the browser's user-gesture context and triggers popup blockers. The window is now opened synchronously before the async call to preserve the gesture chain.
8
+ - **Popup fallback URL field**: Step 3 now always displays a copyable URL field with the authorization link, so users can manually open it if the popup is still blocked by stricter browser settings.
9
+
4
10
  ## [1.0.44] - Samsung Frame TV, TV App Launcher & Washer Service
5
11
 
6
12
  ### Added
@@ -159,6 +159,17 @@
159
159
 
160
160
  <div class="tab-pane fade" id="step3">
161
161
  <h4>Step 3: Enter Authorization Code</h4>
162
+
163
+ <div id="oauth-auth-url-box" class="alert alert-info" style="display:none">
164
+ <strong>A login page should have opened automatically.</strong> If it didn't, copy the URL below and open it in your browser:<br>
165
+ <div class="input-group mt-2">
166
+ <input type="text" class="form-control form-control-sm" id="oauth-auth-url" readonly>
167
+ <div class="input-group-append">
168
+ <button class="btn btn-sm btn-outline-secondary" type="button" onclick="copyAuthUrl()">Copy</button>
169
+ </div>
170
+ </div>
171
+ </div>
172
+
162
173
  <p>Paste the <code>args.code</code> value from the httpbin.org response below.</p>
163
174
  <p class="text-muted">Example: The JSON response will look like <code>{"args": {"code": "xxxxxx"}, ...}</code>. Copy just the code value.</p>
164
175
 
@@ -388,7 +399,19 @@
388
399
  document.querySelector(targetTab.getAttribute('data-target')).classList.add('show', 'active');
389
400
  }
390
401
 
402
+ function copyAuthUrl() {
403
+ var input = document.getElementById('oauth-auth-url');
404
+ input.select();
405
+ document.execCommand('copy');
406
+ homebridge.toast.success('URL copied to clipboard');
407
+ }
408
+
391
409
  async function requestAuthCode() {
410
+ // Open window synchronously (before await) to avoid popup blockers.
411
+ // Browsers only allow window.open() in direct response to user clicks;
412
+ // an await breaks that gesture context and the popup gets silently blocked.
413
+ const popup = window.open('about:blank', '_blank');
414
+
392
415
  try {
393
416
  const payload = {
394
417
  clientId: document.getElementById('oauth-client-id').value,
@@ -398,9 +421,18 @@
398
421
  };
399
422
 
400
423
  const authUrl = await homebridge.request('/authCode', payload);
401
- window.open(authUrl, "_blank");
424
+
425
+ // Always show the URL field as a fallback
426
+ document.getElementById('oauth-auth-url').value = authUrl;
427
+ document.getElementById('oauth-auth-url-box').style.display = 'block';
428
+
429
+ if (popup && !popup.closed) {
430
+ popup.location.href = authUrl;
431
+ }
432
+
402
433
  return authUrl;
403
434
  } catch (err) {
435
+ if (popup && !popup.closed) popup.close();
404
436
  console.error('requestAuthCode error:', err);
405
437
  homebridge.toast.error("Could not generate authorization URL. Please check your credentials.");
406
438
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "displayName": "Homebridge Smartthings oAuth Plugin",
4
4
  "name": "homebridge-smartthings-oauth",
5
- "version": "1.0.44",
5
+ "version": "1.0.45",
6
6
  "description": "Connects SmartThings devices to Homebridge. Automatically discovers devices.",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {