@yuntower/yuntower-account-web-sdk 0.0.14 → 0.0.15
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/dist/index.js +15 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,15 +72,19 @@ class YunTowerAccountSDK {
|
|
|
72
72
|
if (!this.isValidOrigin(event.origin)) {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const data = event.data;
|
|
76
|
+
const isStatusMessage = data?.action === "status" || data?.type === "status";
|
|
77
|
+
if (isStatusMessage) {
|
|
78
|
+
const status = data.status;
|
|
79
|
+
const msg = data.msg;
|
|
80
|
+
const responseData = data.data;
|
|
77
81
|
if (status === "success") {
|
|
78
82
|
this.authStatus = true;
|
|
79
83
|
}
|
|
80
84
|
callback({
|
|
81
85
|
event: "auth",
|
|
82
86
|
status,
|
|
83
|
-
data,
|
|
87
|
+
data: responseData,
|
|
84
88
|
msg,
|
|
85
89
|
});
|
|
86
90
|
return true;
|
|
@@ -129,10 +133,16 @@ class YunTowerAccountSDK {
|
|
|
129
133
|
}
|
|
130
134
|
cleanup();
|
|
131
135
|
if (autoCloseOnFinish && authWindow && !authWindow.closed) {
|
|
132
|
-
|
|
136
|
+
// 延后关窗,避免部分浏览器在 message 回调里同步 close 不生效
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
if (authWindow && !authWindow.closed) {
|
|
139
|
+
authWindow.close();
|
|
140
|
+
}
|
|
141
|
+
}, 0);
|
|
133
142
|
}
|
|
134
143
|
userCallback(response);
|
|
135
144
|
});
|
|
145
|
+
// 轮询授权窗状态,间隔 1s 便于尽快收到授权页回复
|
|
136
146
|
intervalId = setInterval(() => {
|
|
137
147
|
if (authWindow.closed) {
|
|
138
148
|
if (intervalId != null) {
|
|
@@ -153,7 +163,7 @@ class YunTowerAccountSDK {
|
|
|
153
163
|
// 窗口可能已关闭,忽略
|
|
154
164
|
}
|
|
155
165
|
}
|
|
156
|
-
},
|
|
166
|
+
}, 1000);
|
|
157
167
|
return {
|
|
158
168
|
close() {
|
|
159
169
|
if (intervalId != null) {
|