kauth-sdk-node 2.0.12-alpha.1 → 2.0.12-alpha.2

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.
@@ -8,21 +8,21 @@ interface Authenticator {
8
8
  export declare class GoogleAuthenticator implements Authenticator {
9
9
  private kauthApi;
10
10
  constructor(kauthApi: KauthApi);
11
- authenticate(token: string, redirectUri: string, preAuthorizationToken?: string): Promise<AuthenticationInformation>;
11
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
12
12
  bind(userId: number, token: string, redirectUri: string): Promise<void>;
13
13
  authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
14
14
  }
15
15
  export declare class MoziAuthenticator implements Authenticator {
16
16
  private kauthApi;
17
17
  constructor(kauthApi: KauthApi);
18
- authenticate(token: string, redirectUri: string, preAuthorizationToken?: string): Promise<AuthenticationInformation>;
18
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
19
19
  bind(userId: number, token: string, redirectUri: string): Promise<void>;
20
20
  authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
21
21
  }
22
22
  export declare class MiniprogramAuthenticator implements Authenticator {
23
23
  private kauthApi;
24
24
  constructor(kauthApi: KauthApi);
25
- authenticate(token: string, redirectUri: string, preAuthorizationToken?: string): Promise<AuthenticationInformation>;
25
+ authenticate(token: string, redirectUri: string): Promise<AuthenticationInformation>;
26
26
  bind(userId: number, token: string, redirectUri: string): Promise<void>;
27
27
  authorizeURL(callback: string, state: string, prompt?: string): Promise<string>;
28
28
  }
@@ -8,18 +8,16 @@ class GoogleAuthenticator {
8
8
  constructor(kauthApi) {
9
9
  this.kauthApi = kauthApi;
10
10
  }
11
- async authenticate(token, redirectUri, preAuthorizationToken) {
11
+ async authenticate(token, redirectUri) {
12
12
  const request = {
13
13
  code: token,
14
14
  redirect_uri: redirectUri,
15
- pre_authorization_token: preAuthorizationToken,
16
15
  };
17
16
  const result = await this.kauthApi.googleAuthenticate(request);
18
17
  const authenticationInformation = new google_1.GoogleAuthenticationInformation();
19
18
  authenticationInformation.primaryPrincipal = result.primaryPrincipal;
20
19
  authenticationInformation.principal = result.principal;
21
20
  authenticationInformation.credential = result.credential;
22
- authenticationInformation.preAuthorizationAllowed = result.preAuthorizationAllowed;
23
21
  return authenticationInformation;
24
22
  }
25
23
  async bind(userId, token, redirectUri) {
@@ -38,18 +36,16 @@ class MoziAuthenticator {
38
36
  constructor(kauthApi) {
39
37
  this.kauthApi = kauthApi;
40
38
  }
41
- async authenticate(token, redirectUri, preAuthorizationToken) {
39
+ async authenticate(token, redirectUri) {
42
40
  const request = {
43
41
  code: token,
44
42
  redirect_uri: redirectUri,
45
- pre_authorization_token: preAuthorizationToken,
46
43
  };
47
44
  const result = await this.kauthApi.moziAuthenticate(request);
48
45
  const authenticationInformation = new mozi_1.MoziAuthenticationInformation();
49
46
  authenticationInformation.primaryPrincipal = result.primaryPrincipal;
50
47
  authenticationInformation.principal = result.principal;
51
48
  authenticationInformation.credential = result.credential;
52
- authenticationInformation.preAuthorizationAllowed = result.preAuthorizationAllowed;
53
49
  return authenticationInformation;
54
50
  }
55
51
  async bind(userId, token, redirectUri) {
@@ -68,18 +64,16 @@ class MiniprogramAuthenticator {
68
64
  constructor(kauthApi) {
69
65
  this.kauthApi = kauthApi;
70
66
  }
71
- async authenticate(token, redirectUri, preAuthorizationToken) {
67
+ async authenticate(token, redirectUri) {
72
68
  const request = {
73
69
  code: token,
74
70
  redirect_uri: redirectUri,
75
- pre_authorization_token: preAuthorizationToken,
76
71
  };
77
72
  const result = await this.kauthApi.miniprogramAuthenticate(request);
78
73
  const authenticationInformation = new miniprogram_1.MiniprogramAuthenticationInformation();
79
74
  authenticationInformation.primaryPrincipal = result.primaryPrincipal;
80
75
  authenticationInformation.principal = result.principal;
81
76
  authenticationInformation.credential = result.credential;
82
- authenticationInformation.preAuthorizationAllowed = result.preAuthorizationAllowed;
83
77
  return authenticationInformation;
84
78
  }
85
79
  async bind(userId, token, redirectUri) {
@@ -3,7 +3,7 @@ export declare enum UserAccountType {
3
3
  Google = "google",
4
4
  Miniprogram = "miniprogram"
5
5
  }
6
- export declare enum PreAuthorizationIsAllowedErrorCode {
6
+ export declare enum PreAuthorizationAllowedErrorCode {
7
7
  UserNotFound = "userNotFound",
8
8
  UserNotInWhitelist = "userNotInWhitelist",
9
9
  TokenExpired = "tokenExpired",
@@ -31,7 +31,7 @@ export declare type PreAuthorizationAllowed = ({
31
31
  }) | ({
32
32
  allowed: false;
33
33
  } & {
34
- code: PreAuthorizationIsAllowedErrorCode;
34
+ code: PreAuthorizationAllowedErrorCode;
35
35
  reason: string;
36
36
  });
37
37
  export interface Principal {
@@ -42,7 +42,6 @@ export interface AuthenticationInformation {
42
42
  primaryPrincipal: PrimaryPrincipal;
43
43
  principal: Principal;
44
44
  credential: Credential;
45
- preAuthorizationAllowed?: PreAuthorizationAllowed;
46
45
  }
47
46
  export declare class PrimaryPrincipal implements Principal {
48
47
  id: number;
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrimaryPrincipal = exports.PreAuthorizationIsAllowedErrorCode = exports.UserAccountType = void 0;
3
+ exports.PrimaryPrincipal = exports.PreAuthorizationAllowedErrorCode = exports.UserAccountType = void 0;
4
4
  var UserAccountType;
5
5
  (function (UserAccountType) {
6
6
  UserAccountType["Mozi"] = "mozi";
7
7
  UserAccountType["Google"] = "google";
8
8
  UserAccountType["Miniprogram"] = "miniprogram";
9
9
  })(UserAccountType = exports.UserAccountType || (exports.UserAccountType = {}));
10
- var PreAuthorizationIsAllowedErrorCode;
11
- (function (PreAuthorizationIsAllowedErrorCode) {
12
- PreAuthorizationIsAllowedErrorCode["UserNotFound"] = "userNotFound";
13
- PreAuthorizationIsAllowedErrorCode["UserNotInWhitelist"] = "userNotInWhitelist";
14
- PreAuthorizationIsAllowedErrorCode["TokenExpired"] = "tokenExpired";
15
- PreAuthorizationIsAllowedErrorCode["TokenNotExisted"] = "tokenNotExisted";
16
- PreAuthorizationIsAllowedErrorCode["TokenUsedUp"] = "tokenUsedUp";
17
- })(PreAuthorizationIsAllowedErrorCode = exports.PreAuthorizationIsAllowedErrorCode || (exports.PreAuthorizationIsAllowedErrorCode = {}));
10
+ var PreAuthorizationAllowedErrorCode;
11
+ (function (PreAuthorizationAllowedErrorCode) {
12
+ PreAuthorizationAllowedErrorCode["UserNotFound"] = "userNotFound";
13
+ PreAuthorizationAllowedErrorCode["UserNotInWhitelist"] = "userNotInWhitelist";
14
+ PreAuthorizationAllowedErrorCode["TokenExpired"] = "tokenExpired";
15
+ PreAuthorizationAllowedErrorCode["TokenNotExisted"] = "tokenNotExisted";
16
+ PreAuthorizationAllowedErrorCode["TokenUsedUp"] = "tokenUsedUp";
17
+ })(PreAuthorizationAllowedErrorCode = exports.PreAuthorizationAllowedErrorCode || (exports.PreAuthorizationAllowedErrorCode = {}));
18
18
  class PrimaryPrincipal {
19
19
  }
20
20
  exports.PrimaryPrincipal = PrimaryPrincipal;
@@ -1,4 +1,4 @@
1
- import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation, PreAuthorizationAllowed } from './base';
1
+ import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation } from './base';
2
2
  export declare class GooglePrincipal implements Principal {
3
3
  sub: string;
4
4
  name: string;
@@ -18,5 +18,4 @@ export declare class GoogleAuthenticationInformation implements AuthenticationIn
18
18
  primaryPrincipal: PrimaryPrincipal;
19
19
  principal: GooglePrincipal;
20
20
  credential: GoogleCredential;
21
- preAuthorizationAllowed?: PreAuthorizationAllowed;
22
21
  }
@@ -1,4 +1,4 @@
1
- import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation, PreAuthorizationAllowed } from './base';
1
+ import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation } from './base';
2
2
  export declare class MiniprogramPrincipal implements Principal {
3
3
  trustLoginId: string;
4
4
  customerId: string;
@@ -12,5 +12,4 @@ export declare class MiniprogramAuthenticationInformation implements Authenticat
12
12
  primaryPrincipal: PrimaryPrincipal;
13
13
  principal: MiniprogramPrincipal;
14
14
  credential: MiniprogramCredential;
15
- preAuthorizationAllowed?: PreAuthorizationAllowed;
16
15
  }
@@ -1,4 +1,4 @@
1
- import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation, PreAuthorizationAllowed } from './base';
1
+ import { Principal, PrimaryPrincipal, Credential, AuthenticationInformation } from './base';
2
2
  export declare class MoziPrincipal implements Principal {
3
3
  account: string;
4
4
  employeeCode: string;
@@ -18,5 +18,4 @@ export declare class MoziAuthenticationInformation implements AuthenticationInfo
18
18
  primaryPrincipal: PrimaryPrincipal;
19
19
  principal: MoziPrincipal;
20
20
  credential: MoziCredential;
21
- preAuthorizationAllowed?: PreAuthorizationAllowed;
22
21
  }
@@ -1,4 +1,3 @@
1
- import { PreAuthorizationAllowed } from '../../authenticator/base';
2
1
  import { AuthenticationInformation } from '../../authenticator';
3
2
  export interface KauthConfig {
4
3
  origin?: string;
@@ -24,7 +23,6 @@ export interface KauthConfig {
24
23
  logoutRedirectUri?: string;
25
24
  loginHandler?: (ctx: any, authInfo: AuthenticationInformation) => Promise<void>;
26
25
  authHandler?: (ctx: any, sub: number) => Promise<void>;
27
- preAuthorizationCallback?: string | ((ctx: any, preAuthorizationAllowed: PreAuthorizationAllowed) => Promise<string | undefined>);
28
26
  mockHandler?: (ctx: any) => Promise<void>;
29
27
  lruMaxAge?: number;
30
28
  lruMax?: number;
@@ -57,6 +57,7 @@ export declare class KauthApi {
57
57
  refreshPreAuthorization(data: RefreshPreAuthorizatioRequest): Promise<{
58
58
  id: number;
59
59
  token: string;
60
+ description: string;
60
61
  }>;
61
62
  processPreAuthorization(data: ProcessPreAuthorizatioRequest): Promise<PreAuthorizationAllowed>;
62
63
  commitPreAuthorization(data: ProcessPreAuthorizatioRequest): Promise<PreAuthorizationAllowed>;
@@ -111,11 +111,13 @@ export interface KauthCreatePreAuthorizationRequest extends MarmotOptions {
111
111
  }
112
112
  export interface RefreshPreAuthorizatioRequest extends MarmotOptions {
113
113
  id: number;
114
+ description?: string;
114
115
  }
115
116
  export interface GetPreAuthorizationRequest extends MarmotOptions {
116
117
  roleType: string;
117
118
  roleName: string;
118
119
  roleExtendValue?: string;
120
+ token?: string;
119
121
  }
120
122
  export interface ProcessPreAuthorizatioRequest extends MarmotOptions {
121
123
  token: string;
@@ -1,4 +1,4 @@
1
- import { PreAuthorizationAllowed, PrimaryPrincipal } from '../../../authenticator/base';
1
+ import { PrimaryPrincipal } from '../../../authenticator/base';
2
2
  import { MarmotPagination } from '../tool/marmot';
3
3
  export declare enum KauthPrincipalStatus {
4
4
  Normal = 0,
@@ -30,7 +30,6 @@ export interface KauthMoziAuthenticationInformation {
30
30
  primaryPrincipal: KauthPrimaryPrincipal;
31
31
  principal: KauthMoziPrincipal;
32
32
  credential: KauthMoziCredential;
33
- preAuthorizationAllowed?: PreAuthorizationAllowed;
34
33
  }
35
34
  export interface KauthGooglePrincipal {
36
35
  sub: string;
@@ -51,7 +50,6 @@ export interface KauthGoogleAuthenticationInformation {
51
50
  primaryPrincipal: KauthPrimaryPrincipal;
52
51
  principal: KauthGooglePrincipal;
53
52
  credential: KauthGoogleCredential;
54
- preAuthorizationAllowed?: PreAuthorizationAllowed;
55
53
  }
56
54
  export interface KauthMiniprogramPrincipal {
57
55
  trustLoginId: string;
@@ -66,7 +64,6 @@ export interface KauthMiniprogramAuthenticationInformation {
66
64
  primaryPrincipal: PrimaryPrincipal;
67
65
  principal: KauthMiniprogramPrincipal;
68
66
  credential: KauthMiniprogramCredential;
69
- preAuthorizationAllowed?: PreAuthorizationAllowed;
70
67
  }
71
68
  export interface KauthPermission {
72
69
  id: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kauth-sdk-node",
3
- "version": "2.0.12-alpha.1",
3
+ "version": "2.0.12-alpha.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [