@ts-core/oauth 3.0.22 → 3.0.23
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/cjs/OAuthBase.js +15 -16
- package/esm/OAuthBase.js +15 -16
- package/package.json +1 -1
package/cjs/OAuthBase.js
CHANGED
|
@@ -19,12 +19,8 @@ class OAuthBase extends common_1.LoggerWrapper {
|
|
|
19
19
|
this.applicationId = applicationId;
|
|
20
20
|
this.window = window;
|
|
21
21
|
this.popUpCheckClose = () => {
|
|
22
|
-
if (this.isPopUpOpened) {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
this.close();
|
|
26
|
-
if (this.isRejectWhenPopUpClosed && !_.isNil(this.promise)) {
|
|
27
|
-
this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
|
|
22
|
+
if (!this.isPopUpOpened) {
|
|
23
|
+
this.close();
|
|
28
24
|
}
|
|
29
25
|
};
|
|
30
26
|
this.messageHandler = (event) => this.parsePopUpResult(this.popUpMessageParser(event));
|
|
@@ -51,8 +47,9 @@ class OAuthBase extends common_1.LoggerWrapper {
|
|
|
51
47
|
this.promise = common_1.PromiseHandler.create();
|
|
52
48
|
this.popUp = this.popUpOpen();
|
|
53
49
|
this.popUpFocus();
|
|
54
|
-
this.popUpCheckCloseTimer = setInterval(this.popUpCheckClose, common_1.DateUtil.MILLISECONDS_SECOND / 10);
|
|
55
50
|
this.window.addEventListener('message', this.messageHandler, false);
|
|
51
|
+
this.subject.next(new common_1.ObservableData(OAuthEvent.POPUP_OPENED, this.popUp));
|
|
52
|
+
this.popUpCheckCloseTimer = setInterval(this.popUpCheckClose, common_1.DateUtil.MILLISECONDS_SECOND / 5);
|
|
56
53
|
return this.promise.promise;
|
|
57
54
|
});
|
|
58
55
|
}
|
|
@@ -61,7 +58,6 @@ class OAuthBase extends common_1.LoggerWrapper {
|
|
|
61
58
|
let top = (window.screen.height - this.popUpHeight) / 2;
|
|
62
59
|
let left = (window.screen.width - this.popUpWidth) / 2;
|
|
63
60
|
let item = window.open(this.getUrl(), this.popUpTarget, `scrollbars=yes,width=${this.popUpWidth},height=${this.popUpHeight},top=${top},left=${left}`);
|
|
64
|
-
this.subject.next(new common_1.ObservableData(OAuthEvent.POPUP_OPENED, item));
|
|
65
61
|
return item;
|
|
66
62
|
}
|
|
67
63
|
popUpFocus() {
|
|
@@ -89,13 +85,13 @@ class OAuthBase extends common_1.LoggerWrapper {
|
|
|
89
85
|
}
|
|
90
86
|
if (!_.isEmpty(data.oAuthCodeOrToken)) {
|
|
91
87
|
this.promise.resolve({ redirectUri: this.getRedirectUri(), codeOrToken: data.oAuthCodeOrToken });
|
|
88
|
+
this.promise = null;
|
|
92
89
|
}
|
|
93
90
|
if (!_.isEmpty(data.oAuthError)) {
|
|
94
91
|
this.promise.reject(data.oAuthError);
|
|
92
|
+
this.promise = null;
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
this.close();
|
|
98
|
-
}
|
|
94
|
+
this.close();
|
|
99
95
|
}
|
|
100
96
|
getCode() {
|
|
101
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -112,12 +108,15 @@ class OAuthBase extends common_1.LoggerWrapper {
|
|
|
112
108
|
close() {
|
|
113
109
|
this.window.removeEventListener('message', this.messageHandler, false);
|
|
114
110
|
this.popUpCheckCloseTimer = null;
|
|
115
|
-
if (
|
|
116
|
-
|
|
111
|
+
if (_.isNil(this.popUp)) {
|
|
112
|
+
return;
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
this.subject.next(new common_1.ObservableData(OAuthEvent.POPUP_CLOSED, this.popUp));
|
|
115
|
+
this.popUp.close();
|
|
116
|
+
this.popUp = null;
|
|
117
|
+
if (this.isRejectWhenPopUpClosed && !_.isNil(this.promise)) {
|
|
118
|
+
this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
|
|
119
|
+
this.promise = null;
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
destroy() {
|
package/esm/OAuthBase.js
CHANGED
|
@@ -16,12 +16,8 @@ export class OAuthBase extends LoggerWrapper {
|
|
|
16
16
|
this.applicationId = applicationId;
|
|
17
17
|
this.window = window;
|
|
18
18
|
this.popUpCheckClose = () => {
|
|
19
|
-
if (this.isPopUpOpened) {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
this.close();
|
|
23
|
-
if (this.isRejectWhenPopUpClosed && !_.isNil(this.promise)) {
|
|
24
|
-
this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
|
|
19
|
+
if (!this.isPopUpOpened) {
|
|
20
|
+
this.close();
|
|
25
21
|
}
|
|
26
22
|
};
|
|
27
23
|
this.messageHandler = (event) => this.parsePopUpResult(this.popUpMessageParser(event));
|
|
@@ -48,8 +44,9 @@ export class OAuthBase extends LoggerWrapper {
|
|
|
48
44
|
this.promise = PromiseHandler.create();
|
|
49
45
|
this.popUp = this.popUpOpen();
|
|
50
46
|
this.popUpFocus();
|
|
51
|
-
this.popUpCheckCloseTimer = setInterval(this.popUpCheckClose, DateUtil.MILLISECONDS_SECOND / 10);
|
|
52
47
|
this.window.addEventListener('message', this.messageHandler, false);
|
|
48
|
+
this.subject.next(new ObservableData(OAuthEvent.POPUP_OPENED, this.popUp));
|
|
49
|
+
this.popUpCheckCloseTimer = setInterval(this.popUpCheckClose, DateUtil.MILLISECONDS_SECOND / 5);
|
|
53
50
|
return this.promise.promise;
|
|
54
51
|
});
|
|
55
52
|
}
|
|
@@ -58,7 +55,6 @@ export class OAuthBase extends LoggerWrapper {
|
|
|
58
55
|
let top = (window.screen.height - this.popUpHeight) / 2;
|
|
59
56
|
let left = (window.screen.width - this.popUpWidth) / 2;
|
|
60
57
|
let item = window.open(this.getUrl(), this.popUpTarget, `scrollbars=yes,width=${this.popUpWidth},height=${this.popUpHeight},top=${top},left=${left}`);
|
|
61
|
-
this.subject.next(new ObservableData(OAuthEvent.POPUP_OPENED, item));
|
|
62
58
|
return item;
|
|
63
59
|
}
|
|
64
60
|
popUpFocus() {
|
|
@@ -86,13 +82,13 @@ export class OAuthBase extends LoggerWrapper {
|
|
|
86
82
|
}
|
|
87
83
|
if (!_.isEmpty(data.oAuthCodeOrToken)) {
|
|
88
84
|
this.promise.resolve({ redirectUri: this.getRedirectUri(), codeOrToken: data.oAuthCodeOrToken });
|
|
85
|
+
this.promise = null;
|
|
89
86
|
}
|
|
90
87
|
if (!_.isEmpty(data.oAuthError)) {
|
|
91
88
|
this.promise.reject(data.oAuthError);
|
|
89
|
+
this.promise = null;
|
|
92
90
|
}
|
|
93
|
-
|
|
94
|
-
this.close();
|
|
95
|
-
}
|
|
91
|
+
this.close();
|
|
96
92
|
}
|
|
97
93
|
getCode() {
|
|
98
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -109,12 +105,15 @@ export class OAuthBase extends LoggerWrapper {
|
|
|
109
105
|
close() {
|
|
110
106
|
this.window.removeEventListener('message', this.messageHandler, false);
|
|
111
107
|
this.popUpCheckCloseTimer = null;
|
|
112
|
-
if (
|
|
113
|
-
|
|
108
|
+
if (_.isNil(this.popUp)) {
|
|
109
|
+
return;
|
|
114
110
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
this.subject.next(new ObservableData(OAuthEvent.POPUP_CLOSED, this.popUp));
|
|
112
|
+
this.popUp.close();
|
|
113
|
+
this.popUp = null;
|
|
114
|
+
if (this.isRejectWhenPopUpClosed && !_.isNil(this.promise)) {
|
|
115
|
+
this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
|
|
116
|
+
this.promise = null;
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
destroy() {
|