@ts-core/oauth 3.0.2 → 3.0.3

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.
@@ -34,10 +34,12 @@ export interface IOAuthPopUpDto {
34
34
  oAuthError: string;
35
35
  }
36
36
  export interface IOAuthToken {
37
- type?: string;
38
37
  state?: string;
39
38
  scope?: string;
40
- userId: number;
39
+ userId?: number;
40
+ tokenType?: string;
41
+ idToken?: string;
42
+ refreshToken?: string;
41
43
  expiresIn: number;
42
44
  accessToken: string;
43
45
  }
@@ -1,6 +1,8 @@
1
1
  import { GoUser } from './GoUser';
2
2
  import { IOAuthDto, IOAuthToken, OAuthBase } from '../OAuthBase';
3
+ import { ILogger } from '@ts-core/common';
3
4
  export declare class GoOAuth<T extends GoUser = GoUser> extends OAuthBase<T> {
5
+ constructor(logger: ILogger, window: Window, applicationId: string, scope: string);
4
6
  protected getAuthUrl(): string;
5
7
  getProfile(token: string): Promise<T>;
6
8
  getTokenByCode(dto: IOAuthDto, secret: string): Promise<IOAuthToken>;
package/cjs/go/GoOAuth.js CHANGED
@@ -14,6 +14,9 @@ const _ = require("lodash");
14
14
  const GoUser_1 = require("./GoUser");
15
15
  const OAuthBase_1 = require("../OAuthBase");
16
16
  class GoOAuth extends OAuthBase_1.OAuthBase {
17
+ constructor(logger, window, applicationId, scope) {
18
+ super(logger, window, applicationId, scope);
19
+ }
17
20
  getAuthUrl() {
18
21
  let params = new URLSearchParams();
19
22
  params.append('display', 'popup');
@@ -43,7 +46,7 @@ class GoOAuth extends OAuthBase_1.OAuthBase {
43
46
  grant_type: 'authorization_code'
44
47
  }
45
48
  });
46
- return { userId: item.user_id, expiresIn: item.expires_in, accessToken: item.access_token };
49
+ return { idToken: item.id_token, tokenType: item.token_type, expiresIn: item.expires_in, accessToken: item.access_token, scope: item.scope };
47
50
  });
48
51
  }
49
52
  }
@@ -1,4 +1,6 @@
1
1
  import { OAuthUser } from "../OAuthUser";
2
2
  export declare class GoUser extends OAuthUser {
3
+ givenName: string;
4
+ familyName: string;
3
5
  protected parse(item: any): void;
4
6
  }
package/cjs/go/GoUser.js CHANGED
@@ -9,6 +9,8 @@ class GoUser extends OAuthUser_1.OAuthUser {
9
9
  this.email = item.email;
10
10
  this.locale = item.locale;
11
11
  this.picture = item.picture;
12
+ this.givenName = item.given_name;
13
+ this.familyName = item.family_name;
12
14
  }
13
15
  }
14
16
  exports.GoUser = GoUser;
package/cjs/ya/YaOAuth.js CHANGED
@@ -45,7 +45,12 @@ class YaOAuth extends OAuthBase_1.OAuthBase {
45
45
  client_secret: secret,
46
46
  grant_type: 'authorization_code'
47
47
  });
48
- return { userId: data.user_id, expiresIn: data.expires_in, accessToken: data.access_token, type: data.token_type, scope: data.scope };
48
+ return {
49
+ tokenType: data.token_type,
50
+ expiresIn: data.expires_in,
51
+ accessToken: data.access_token,
52
+ refreshToken: data.refresh_token,
53
+ };
49
54
  });
50
55
  }
51
56
  }
@@ -1,4 +1,10 @@
1
1
  import { OAuthUser } from "../OAuthUser";
2
2
  export declare class YaUser extends OAuthUser {
3
+ login: string;
4
+ psuid: string;
5
+ emails: Array<string>;
6
+ clientId: string;
7
+ realName: string;
8
+ displayName: string;
3
9
  protected parse(item: any): void;
4
10
  }
package/cjs/ya/YaUser.js CHANGED
@@ -7,8 +7,14 @@ class YaUser extends OAuthUser_1.OAuthUser {
7
7
  parse(item) {
8
8
  this.id = item.id;
9
9
  this.name = item.display_name;
10
+ this.login = item.login;
11
+ this.psuid = item.psuid;
10
12
  this.email = item.default_email;
11
13
  this.phone = _.get(item, 'default_phone.number');
14
+ this.emails = item.emails;
15
+ this.clientId = item.client_id;
16
+ this.realName = item.real_name;
17
+ this.displayName = item.display_name;
12
18
  if (!_.isNil(item.sex)) {
13
19
  this.isMale = item.sex === 'male';
14
20
  }
@@ -34,10 +34,12 @@ export interface IOAuthPopUpDto {
34
34
  oAuthError: string;
35
35
  }
36
36
  export interface IOAuthToken {
37
- type?: string;
38
37
  state?: string;
39
38
  scope?: string;
40
- userId: number;
39
+ userId?: number;
40
+ tokenType?: string;
41
+ idToken?: string;
42
+ refreshToken?: string;
41
43
  expiresIn: number;
42
44
  accessToken: string;
43
45
  }
@@ -1,6 +1,8 @@
1
1
  import { GoUser } from './GoUser';
2
2
  import { IOAuthDto, IOAuthToken, OAuthBase } from '../OAuthBase';
3
+ import { ILogger } from '@ts-core/common';
3
4
  export declare class GoOAuth<T extends GoUser = GoUser> extends OAuthBase<T> {
5
+ constructor(logger: ILogger, window: Window, applicationId: string, scope: string);
4
6
  protected getAuthUrl(): string;
5
7
  getProfile(token: string): Promise<T>;
6
8
  getTokenByCode(dto: IOAuthDto, secret: string): Promise<IOAuthToken>;
package/esm/go/GoOAuth.js CHANGED
@@ -11,6 +11,9 @@ import * as _ from 'lodash';
11
11
  import { GoUser } from './GoUser';
12
12
  import { OAuthBase } from '../OAuthBase';
13
13
  export class GoOAuth extends OAuthBase {
14
+ constructor(logger, window, applicationId, scope) {
15
+ super(logger, window, applicationId, scope);
16
+ }
14
17
  getAuthUrl() {
15
18
  let params = new URLSearchParams();
16
19
  params.append('display', 'popup');
@@ -40,7 +43,7 @@ export class GoOAuth extends OAuthBase {
40
43
  grant_type: 'authorization_code'
41
44
  }
42
45
  });
43
- return { userId: item.user_id, expiresIn: item.expires_in, accessToken: item.access_token };
46
+ return { idToken: item.id_token, tokenType: item.token_type, expiresIn: item.expires_in, accessToken: item.access_token, scope: item.scope };
44
47
  });
45
48
  }
46
49
  }
@@ -1,4 +1,6 @@
1
1
  import { OAuthUser } from "../OAuthUser";
2
2
  export declare class GoUser extends OAuthUser {
3
+ givenName: string;
4
+ familyName: string;
3
5
  protected parse(item: any): void;
4
6
  }
package/esm/go/GoUser.js CHANGED
@@ -6,5 +6,7 @@ export class GoUser extends OAuthUser {
6
6
  this.email = item.email;
7
7
  this.locale = item.locale;
8
8
  this.picture = item.picture;
9
+ this.givenName = item.given_name;
10
+ this.familyName = item.family_name;
9
11
  }
10
12
  }
package/esm/ya/YaOAuth.js CHANGED
@@ -42,7 +42,12 @@ export class YaOAuth extends OAuthBase {
42
42
  client_secret: secret,
43
43
  grant_type: 'authorization_code'
44
44
  });
45
- return { userId: data.user_id, expiresIn: data.expires_in, accessToken: data.access_token, type: data.token_type, scope: data.scope };
45
+ return {
46
+ tokenType: data.token_type,
47
+ expiresIn: data.expires_in,
48
+ accessToken: data.access_token,
49
+ refreshToken: data.refresh_token,
50
+ };
46
51
  });
47
52
  }
48
53
  }
@@ -1,4 +1,10 @@
1
1
  import { OAuthUser } from "../OAuthUser";
2
2
  export declare class YaUser extends OAuthUser {
3
+ login: string;
4
+ psuid: string;
5
+ emails: Array<string>;
6
+ clientId: string;
7
+ realName: string;
8
+ displayName: string;
3
9
  protected parse(item: any): void;
4
10
  }
package/esm/ya/YaUser.js CHANGED
@@ -4,8 +4,14 @@ export class YaUser extends OAuthUser {
4
4
  parse(item) {
5
5
  this.id = item.id;
6
6
  this.name = item.display_name;
7
+ this.login = item.login;
8
+ this.psuid = item.psuid;
7
9
  this.email = item.default_email;
8
10
  this.phone = _.get(item, 'default_phone.number');
11
+ this.emails = item.emails;
12
+ this.clientId = item.client_id;
13
+ this.realName = item.real_name;
14
+ this.displayName = item.display_name;
9
15
  if (!_.isNil(item.sex)) {
10
16
  this.isMale = item.sex === 'male';
11
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-core/oauth",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Classes and utils for oauth",
5
5
  "main": "./cjs/public-api.js",
6
6
  "module": "./esm/public-api.js",