@seaverse/auth-sdk 0.3.5 → 0.3.6
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/README.md +7 -15
- package/dist/index.cjs +1 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -353,7 +353,6 @@ const authModal = new AuthModal({
|
|
|
353
353
|
|
|
354
354
|
**配置字段说明**:
|
|
355
355
|
- `returnUrl`:**可选** - OAuth 登录后返回的 URL,不填则默认为 `window.location.href`
|
|
356
|
-
- `oauthDesktopURL`:**可选** - 桌面应用 OAuth 回调 URL,如果提供则优先使用此 URL(优先级:`oauthDesktopURL` > `returnUrl` > `window.location.href`)
|
|
357
356
|
- `enableOAuth.google`:是否启用 Google 登录
|
|
358
357
|
- `enableOAuth.discord`:是否启用 Discord 登录
|
|
359
358
|
- `enableOAuth.github`:是否启用 GitHub 登录
|
|
@@ -387,19 +386,6 @@ const authModal3 = new AuthModal({
|
|
|
387
386
|
github: true,
|
|
388
387
|
},
|
|
389
388
|
});
|
|
390
|
-
|
|
391
|
-
// 示例4:桌面应用 OAuth 回调(优先级最高)
|
|
392
|
-
const authModal4 = new AuthModal({
|
|
393
|
-
client,
|
|
394
|
-
theme: 'dark',
|
|
395
|
-
oauthDesktopURL: 'myapp://oauth/callback', // 桌面应用自定义协议 URL
|
|
396
|
-
enableOAuth: {
|
|
397
|
-
google: true,
|
|
398
|
-
discord: true,
|
|
399
|
-
github: true,
|
|
400
|
-
},
|
|
401
|
-
});
|
|
402
|
-
// 登录成功后会跳转到 myapp://oauth/callback?token=xxx
|
|
403
389
|
```
|
|
404
390
|
|
|
405
391
|
#### 处理 OAuth 回调
|
|
@@ -1523,7 +1509,13 @@ MIT © [SeaVerse Team](mailto:support@seaverse.com)
|
|
|
1523
1509
|
|
|
1524
1510
|
## 更新日志
|
|
1525
1511
|
|
|
1526
|
-
### v0.
|
|
1512
|
+
### v0.3.6 (当前版本)
|
|
1513
|
+
- 🧹 **代码清理**: 移除桌面应用OAuth回调相关功能
|
|
1514
|
+
- 移除 `oauthDesktopURL` 配置选项
|
|
1515
|
+
- 简化OAuth流程,统一使用 `returnUrl` 参数
|
|
1516
|
+
- 清理相关文档和代码注释
|
|
1517
|
+
|
|
1518
|
+
### v0.2.5
|
|
1527
1519
|
- 🔄 **响应格式兼容**: 自动兼容包装格式和扁平格式的API响应
|
|
1528
1520
|
- 修复登录时提示 "Invalid response from server" 的问题
|
|
1529
1521
|
- `login()`, `register()`, `getCurrentUser()` 方法自动解包 `data` 字段
|
package/dist/index.cjs
CHANGED
|
@@ -3750,8 +3750,7 @@ class AuthModal {
|
|
|
3750
3750
|
async startOAuthFlow(provider) {
|
|
3751
3751
|
try {
|
|
3752
3752
|
// Get the return URL (where user should be redirected after OAuth)
|
|
3753
|
-
|
|
3754
|
-
const return_url = this.options.oauthDesktopURL || this.options.returnUrl || window.location.href;
|
|
3753
|
+
const return_url = this.options.returnUrl || window.location.href;
|
|
3755
3754
|
// Call backend to get OAuth authorization URL
|
|
3756
3755
|
let authorizeUrl;
|
|
3757
3756
|
switch (provider) {
|
|
@@ -3786,7 +3785,6 @@ class AuthModal {
|
|
|
3786
3785
|
*
|
|
3787
3786
|
* In Backend Proxy Mode, the backend redirects to returnUrl with token in query param.
|
|
3788
3787
|
* This static method checks if current URL has a token and processes it.
|
|
3789
|
-
* If oauthDesktopURL is provided, it will redirect to that URL with the token.
|
|
3790
3788
|
*/
|
|
3791
3789
|
static handleOAuthCallback(options) {
|
|
3792
3790
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -3794,19 +3792,6 @@ class AuthModal {
|
|
|
3794
3792
|
if (!token) {
|
|
3795
3793
|
return null; // Not an OAuth callback
|
|
3796
3794
|
}
|
|
3797
|
-
// If oauthDesktopURL is provided, redirect to it with the token
|
|
3798
|
-
if (options.oauthDesktopURL) {
|
|
3799
|
-
// Construct the desktop URL with token parameter
|
|
3800
|
-
const desktopUrl = new URL(options.oauthDesktopURL);
|
|
3801
|
-
desktopUrl.searchParams.set('token', token);
|
|
3802
|
-
// Redirect to desktop app
|
|
3803
|
-
window.location.href = desktopUrl.toString();
|
|
3804
|
-
// Return result (though redirect will happen immediately)
|
|
3805
|
-
return {
|
|
3806
|
-
success: true,
|
|
3807
|
-
token,
|
|
3808
|
-
};
|
|
3809
|
-
}
|
|
3810
3795
|
// Clean up URL (remove token from query string)
|
|
3811
3796
|
const url = new URL(window.location.href);
|
|
3812
3797
|
url.searchParams.delete('token');
|