@ts-core/oauth 3.0.10 → 3.0.11

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.
@@ -1,6 +1,6 @@
1
1
  import { IOAuthPopUpDto } from './OAuthBase';
2
2
  export declare class OAuthParser {
3
- names: Array<string>;
4
- errors: Array<string>;
5
- parse(params: any, fragment: string): IOAuthPopUpDto;
3
+ static NAMES: Array<string>;
4
+ static ERRORS: Array<string>;
5
+ static parse(params: any, fragment: string): IOAuthPopUpDto;
6
6
  }
@@ -3,21 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OAuthParser = void 0;
4
4
  const _ = require("lodash");
5
5
  class OAuthParser {
6
- constructor() {
7
- this.names = ['code', 'access_token'];
8
- this.errors = ['error_description', 'error'];
9
- }
10
- parse(params, fragment) {
6
+ static parse(params, fragment) {
11
7
  let item = new URLSearchParams();
12
8
  _.forIn(params, (value, key) => item.append(key, value));
13
9
  new URLSearchParams(fragment).forEach((value, key) => item.append(key, value));
14
10
  let oAuthError = null;
15
11
  let oAuthCodeOrToken = null;
16
12
  item.forEach((value, key) => {
17
- if (this.names.includes(key)) {
13
+ if (OAuthParser.NAMES.includes(key)) {
18
14
  oAuthCodeOrToken = value;
19
15
  }
20
- else if (this.errors.includes(key)) {
16
+ else if (OAuthParser.ERRORS.includes(key)) {
21
17
  oAuthError = value;
22
18
  }
23
19
  if (!_.isEmpty(oAuthCodeOrToken) || !_.isEmpty(oAuthError)) {
@@ -28,3 +24,5 @@ class OAuthParser {
28
24
  }
29
25
  }
30
26
  exports.OAuthParser = OAuthParser;
27
+ OAuthParser.NAMES = ['code', 'access_token'];
28
+ OAuthParser.ERRORS = ['error_description', 'error'];
@@ -1,6 +1,6 @@
1
1
  import { IOAuthPopUpDto } from './OAuthBase';
2
2
  export declare class OAuthParser {
3
- names: Array<string>;
4
- errors: Array<string>;
5
- parse(params: any, fragment: string): IOAuthPopUpDto;
3
+ static NAMES: Array<string>;
4
+ static ERRORS: Array<string>;
5
+ static parse(params: any, fragment: string): IOAuthPopUpDto;
6
6
  }
@@ -1,20 +1,16 @@
1
1
  import * as _ from 'lodash';
2
2
  export class OAuthParser {
3
- constructor() {
4
- this.names = ['code', 'access_token'];
5
- this.errors = ['error_description', 'error'];
6
- }
7
- parse(params, fragment) {
3
+ static parse(params, fragment) {
8
4
  let item = new URLSearchParams();
9
5
  _.forIn(params, (value, key) => item.append(key, value));
10
6
  new URLSearchParams(fragment).forEach((value, key) => item.append(key, value));
11
7
  let oAuthError = null;
12
8
  let oAuthCodeOrToken = null;
13
9
  item.forEach((value, key) => {
14
- if (this.names.includes(key)) {
10
+ if (OAuthParser.NAMES.includes(key)) {
15
11
  oAuthCodeOrToken = value;
16
12
  }
17
- else if (this.errors.includes(key)) {
13
+ else if (OAuthParser.ERRORS.includes(key)) {
18
14
  oAuthError = value;
19
15
  }
20
16
  if (!_.isEmpty(oAuthCodeOrToken) || !_.isEmpty(oAuthError)) {
@@ -24,3 +20,5 @@ export class OAuthParser {
24
20
  return null;
25
21
  }
26
22
  }
23
+ OAuthParser.NAMES = ['code', 'access_token'];
24
+ OAuthParser.ERRORS = ['error_description', 'error'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-core/oauth",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "Classes and utils for oauth",
5
5
  "main": "./cjs/public-api.js",
6
6
  "module": "./esm/public-api.js",