soulsync 1.0.17 → 1.0.19
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/index.js +8 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const https = require('https');
|
|
|
5
5
|
const http = require('http');
|
|
6
6
|
const crypto = require('crypto');
|
|
7
7
|
const os = require('os');
|
|
8
|
+
const { createRequire } = require('module');
|
|
8
9
|
|
|
9
10
|
const { getDeviceName, loadConfig, saveConfig, isAuthenticated } = require('./src/config');
|
|
10
11
|
|
|
@@ -88,17 +89,20 @@ function detectAuthMode(api) {
|
|
|
88
89
|
|
|
89
90
|
async function startOAuthLocal() {
|
|
90
91
|
const { createOAuthServer } = require('./src/oauth-server');
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
try {
|
|
94
94
|
const { server, port } = await createOAuthServer();
|
|
95
95
|
const callbackUrl = `http://localhost:${port}/callback`;
|
|
96
96
|
const state = crypto.randomBytes(16).toString('hex');
|
|
97
97
|
const authUrl = `${getCloudUrl()}/auth/oauth/start?port=${port}&callback=${encodeURIComponent(callbackUrl)}&state=${state}`;
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
console.log('[SoulSync] Opening browser for authorization...');
|
|
100
|
+
|
|
101
|
+
const require2 = createRequire(__filename);
|
|
102
|
+
const openPath = require2.resolve('open');
|
|
103
|
+
const open = (await import(openPath)).default;
|
|
100
104
|
await open(authUrl);
|
|
101
|
-
|
|
105
|
+
|
|
102
106
|
console.log('[SoulSync] Waiting for authorization...');
|
|
103
107
|
|
|
104
108
|
const { token } = await new Promise((resolve, reject) => {
|