@ts-core/oauth 3.0.11 → 3.0.13

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.
@@ -2,6 +2,7 @@ import { PromiseHandler, LoggerWrapper, ILogger, TransportHttp } from "@ts-core/
2
2
  export declare abstract class OAuthBase<T = any> extends LoggerWrapper {
3
3
  protected applicationId: string;
4
4
  protected window?: Window;
5
+ static ERROR_WINDOW_CLOSED: string;
5
6
  protected http: TransportHttp;
6
7
  protected timer: any;
7
8
  protected popUp: Window;
package/cjs/OAuthBase.js CHANGED
@@ -54,7 +54,7 @@ class OAuthBase extends common_1.LoggerWrapper {
54
54
  this.promise = common_1.PromiseHandler.create();
55
55
  this.popUp = this.openPopup();
56
56
  this.window.addEventListener('message', this.messageHandler, false);
57
- this.timer = setInterval(this.checkPopUp, common_1.DateUtil.MILLISECONDS_NANOSECOND / 2);
57
+ this.timer = setInterval(this.checkPopUp, common_1.DateUtil.MILLISECONDS_SECOND / 10);
58
58
  return this.promise.promise;
59
59
  });
60
60
  }
@@ -101,7 +101,7 @@ class OAuthBase extends common_1.LoggerWrapper {
101
101
  this.popUp = null;
102
102
  }
103
103
  if (!_.isNil(this.promise)) {
104
- this.promise.reject();
104
+ this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
105
105
  this.promise = null;
106
106
  }
107
107
  }
@@ -125,3 +125,4 @@ class OAuthBase extends common_1.LoggerWrapper {
125
125
  }
126
126
  }
127
127
  exports.OAuthBase = OAuthBase;
128
+ OAuthBase.ERROR_WINDOW_CLOSED = 'WINDOW_CLOSED';
@@ -4,12 +4,13 @@ exports.OAuthParser = void 0;
4
4
  const _ = require("lodash");
5
5
  class OAuthParser {
6
6
  static parse(params, fragment) {
7
- let item = new URLSearchParams();
8
- _.forIn(params, (value, key) => item.append(key, value));
9
- new URLSearchParams(fragment).forEach((value, key) => item.append(key, value));
7
+ let item = new Object();
8
+ _.forIn(params, (value, key) => item[key] = value);
9
+ new URLSearchParams(fragment).forEach((value, key) => item[key] = value);
10
10
  let oAuthError = null;
11
11
  let oAuthCodeOrToken = null;
12
- item.forEach((value, key) => {
12
+ for (let key in item) {
13
+ let value = item[key];
13
14
  if (OAuthParser.NAMES.includes(key)) {
14
15
  oAuthCodeOrToken = value;
15
16
  }
@@ -19,7 +20,8 @@ class OAuthParser {
19
20
  if (!_.isEmpty(oAuthCodeOrToken) || !_.isEmpty(oAuthError)) {
20
21
  return { oAuthCodeOrToken, oAuthError };
21
22
  }
22
- });
23
+ }
24
+ ;
23
25
  return null;
24
26
  }
25
27
  }
@@ -2,6 +2,7 @@ import { PromiseHandler, LoggerWrapper, ILogger, TransportHttp } from "@ts-core/
2
2
  export declare abstract class OAuthBase<T = any> extends LoggerWrapper {
3
3
  protected applicationId: string;
4
4
  protected window?: Window;
5
+ static ERROR_WINDOW_CLOSED: string;
5
6
  protected http: TransportHttp;
6
7
  protected timer: any;
7
8
  protected popUp: Window;
package/esm/OAuthBase.js CHANGED
@@ -51,7 +51,7 @@ export class OAuthBase extends LoggerWrapper {
51
51
  this.promise = PromiseHandler.create();
52
52
  this.popUp = this.openPopup();
53
53
  this.window.addEventListener('message', this.messageHandler, false);
54
- this.timer = setInterval(this.checkPopUp, DateUtil.MILLISECONDS_NANOSECOND / 2);
54
+ this.timer = setInterval(this.checkPopUp, DateUtil.MILLISECONDS_SECOND / 10);
55
55
  return this.promise.promise;
56
56
  });
57
57
  }
@@ -98,7 +98,7 @@ export class OAuthBase extends LoggerWrapper {
98
98
  this.popUp = null;
99
99
  }
100
100
  if (!_.isNil(this.promise)) {
101
- this.promise.reject();
101
+ this.promise.reject(OAuthBase.ERROR_WINDOW_CLOSED);
102
102
  this.promise = null;
103
103
  }
104
104
  }
@@ -121,3 +121,4 @@ export class OAuthBase extends LoggerWrapper {
121
121
  return this._urlParams;
122
122
  }
123
123
  }
124
+ OAuthBase.ERROR_WINDOW_CLOSED = 'WINDOW_CLOSED';
@@ -1,12 +1,13 @@
1
1
  import * as _ from 'lodash';
2
2
  export class OAuthParser {
3
3
  static parse(params, fragment) {
4
- let item = new URLSearchParams();
5
- _.forIn(params, (value, key) => item.append(key, value));
6
- new URLSearchParams(fragment).forEach((value, key) => item.append(key, value));
4
+ let item = new Object();
5
+ _.forIn(params, (value, key) => item[key] = value);
6
+ new URLSearchParams(fragment).forEach((value, key) => item[key] = value);
7
7
  let oAuthError = null;
8
8
  let oAuthCodeOrToken = null;
9
- item.forEach((value, key) => {
9
+ for (let key in item) {
10
+ let value = item[key];
10
11
  if (OAuthParser.NAMES.includes(key)) {
11
12
  oAuthCodeOrToken = value;
12
13
  }
@@ -16,7 +17,8 @@ export class OAuthParser {
16
17
  if (!_.isEmpty(oAuthCodeOrToken) || !_.isEmpty(oAuthError)) {
17
18
  return { oAuthCodeOrToken, oAuthError };
18
19
  }
19
- });
20
+ }
21
+ ;
20
22
  return null;
21
23
  }
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-core/oauth",
3
- "version": "3.0.11",
3
+ "version": "3.0.13",
4
4
  "description": "Classes and utils for oauth",
5
5
  "main": "./cjs/public-api.js",
6
6
  "module": "./esm/public-api.js",