kauth-sdk-node 2.0.12-alpha.0 → 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.
- package/dist/authenticator/authenticator.d.ts +3 -3
- package/dist/authenticator/authenticator.js +3 -6
- package/dist/authenticator/base.d.ts +36 -0
- package/dist/authenticator/base.js +15 -1
- package/dist/authenticator/index.d.ts +1 -1
- package/dist/authenticator/index.js +1 -0
- package/dist/common/http/kauth.d.ts +9 -4
- package/dist/common/http/request/kauth.d.ts +2 -0
- package/dist/common/http/response/kauth.d.ts +1 -51
- package/dist/common/http/response/kauth.js +1 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
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,11 +8,10 @@ class GoogleAuthenticator {
|
|
|
8
8
|
constructor(kauthApi) {
|
|
9
9
|
this.kauthApi = kauthApi;
|
|
10
10
|
}
|
|
11
|
-
async authenticate(token, redirectUri
|
|
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();
|
|
@@ -37,11 +36,10 @@ class MoziAuthenticator {
|
|
|
37
36
|
constructor(kauthApi) {
|
|
38
37
|
this.kauthApi = kauthApi;
|
|
39
38
|
}
|
|
40
|
-
async authenticate(token, redirectUri
|
|
39
|
+
async authenticate(token, redirectUri) {
|
|
41
40
|
const request = {
|
|
42
41
|
code: token,
|
|
43
42
|
redirect_uri: redirectUri,
|
|
44
|
-
pre_authorization_token: preAuthorizationToken,
|
|
45
43
|
};
|
|
46
44
|
const result = await this.kauthApi.moziAuthenticate(request);
|
|
47
45
|
const authenticationInformation = new mozi_1.MoziAuthenticationInformation();
|
|
@@ -66,11 +64,10 @@ class MiniprogramAuthenticator {
|
|
|
66
64
|
constructor(kauthApi) {
|
|
67
65
|
this.kauthApi = kauthApi;
|
|
68
66
|
}
|
|
69
|
-
async authenticate(token, redirectUri
|
|
67
|
+
async authenticate(token, redirectUri) {
|
|
70
68
|
const request = {
|
|
71
69
|
code: token,
|
|
72
70
|
redirect_uri: redirectUri,
|
|
73
|
-
pre_authorization_token: preAuthorizationToken,
|
|
74
71
|
};
|
|
75
72
|
const result = await this.kauthApi.miniprogramAuthenticate(request);
|
|
76
73
|
const authenticationInformation = new miniprogram_1.MiniprogramAuthenticationInformation();
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
export declare enum UserAccountType {
|
|
2
|
+
Mozi = "mozi",
|
|
3
|
+
Google = "google",
|
|
4
|
+
Miniprogram = "miniprogram"
|
|
5
|
+
}
|
|
6
|
+
export declare enum PreAuthorizationAllowedErrorCode {
|
|
7
|
+
UserNotFound = "userNotFound",
|
|
8
|
+
UserNotInWhitelist = "userNotInWhitelist",
|
|
9
|
+
TokenExpired = "tokenExpired",
|
|
10
|
+
TokenNotExisted = "tokenNotExisted",
|
|
11
|
+
TokenUsedUp = "tokenUsedUp"
|
|
12
|
+
}
|
|
13
|
+
export declare type PreAuthorizationAllowed = ({
|
|
14
|
+
allowed: true;
|
|
15
|
+
} & {
|
|
16
|
+
processed: boolean;
|
|
17
|
+
id: number;
|
|
18
|
+
userId: number;
|
|
19
|
+
type: UserAccountType;
|
|
20
|
+
target: string;
|
|
21
|
+
token: string;
|
|
22
|
+
roleType: 'kauth' | string;
|
|
23
|
+
roleName: string;
|
|
24
|
+
roleExtendValue: string;
|
|
25
|
+
resolvedAuthorizeeTargets: Array<{
|
|
26
|
+
type: UserAccountType;
|
|
27
|
+
target: string;
|
|
28
|
+
id: number;
|
|
29
|
+
}>;
|
|
30
|
+
callback: string;
|
|
31
|
+
}) | ({
|
|
32
|
+
allowed: false;
|
|
33
|
+
} & {
|
|
34
|
+
code: PreAuthorizationAllowedErrorCode;
|
|
35
|
+
reason: string;
|
|
36
|
+
});
|
|
1
37
|
export interface Principal {
|
|
2
38
|
}
|
|
3
39
|
export interface Credential {
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrimaryPrincipal = void 0;
|
|
3
|
+
exports.PrimaryPrincipal = exports.PreAuthorizationAllowedErrorCode = exports.UserAccountType = void 0;
|
|
4
|
+
var UserAccountType;
|
|
5
|
+
(function (UserAccountType) {
|
|
6
|
+
UserAccountType["Mozi"] = "mozi";
|
|
7
|
+
UserAccountType["Google"] = "google";
|
|
8
|
+
UserAccountType["Miniprogram"] = "miniprogram";
|
|
9
|
+
})(UserAccountType = exports.UserAccountType || (exports.UserAccountType = {}));
|
|
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 = {}));
|
|
4
18
|
class PrimaryPrincipal {
|
|
5
19
|
}
|
|
6
20
|
exports.PrimaryPrincipal = PrimaryPrincipal;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { GoogleAuthenticator, MoziAuthenticator, MiniprogramAuthenticator } from './authenticator';
|
|
2
|
-
export { AuthenticationInformation, PrimaryPrincipal } from './base';
|
|
2
|
+
export { AuthenticationInformation, PrimaryPrincipal, UserAccountType, PreAuthorizationAllowed } from './base';
|
|
3
3
|
export { JsonWebTokenSubjectProvider, JsonWebTokenAuthenticationProvider } from './provider';
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "MoziAuthenticator", { enumerable: true, get: fun
|
|
|
6
6
|
Object.defineProperty(exports, "MiniprogramAuthenticator", { enumerable: true, get: function () { return authenticator_1.MiniprogramAuthenticator; } });
|
|
7
7
|
var base_1 = require("./base");
|
|
8
8
|
Object.defineProperty(exports, "PrimaryPrincipal", { enumerable: true, get: function () { return base_1.PrimaryPrincipal; } });
|
|
9
|
+
Object.defineProperty(exports, "UserAccountType", { enumerable: true, get: function () { return base_1.UserAccountType; } });
|
|
9
10
|
var provider_1 = require("./provider");
|
|
10
11
|
Object.defineProperty(exports, "JsonWebTokenSubjectProvider", { enumerable: true, get: function () { return provider_1.JsonWebTokenSubjectProvider; } });
|
|
11
12
|
Object.defineProperty(exports, "JsonWebTokenAuthenticationProvider", { enumerable: true, get: function () { return provider_1.JsonWebTokenAuthenticationProvider; } });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KauthConfig } from '../config/config';
|
|
2
2
|
import { KauthAuthenticateRequest, KauthCreatePermissionRequest, KauthCreateRoleRequest, KauthCreateRolesByPermissionsAndUsersRequest, KauthBindUsersByRoleNameAndExtendValueRequest, KauthBindRequest, KauthBindRoleByPermissionsRequest, KauthBindUserByRolesRequest, KauthBindUserByRolesAndExtendValueRequest, KauthUpdateRolesWithPermissionsRequest, KauthBindRoleWithUsersRequest, KauthBindUserByRoleNamesAndExtendValueRequest, KauthSearchUsersWithUserAccountsAndRoleRequest, KauthCreatePreAuthorizationRequest, GetPreAuthorizationRequest, RefreshPreAuthorizatioRequest, ProcessPreAuthorizatioRequest } from './request/kauth';
|
|
3
|
-
import { KauthMoziAuthenticationInformation, KauthGoogleAuthenticationInformation, KauthPermission, KauthMiniprogramAuthenticationInformation, KauthRole, KauthUser, KauthPagable,
|
|
3
|
+
import { KauthMoziAuthenticationInformation, KauthGoogleAuthenticationInformation, KauthPermission, KauthMiniprogramAuthenticationInformation, KauthRole, KauthUser, KauthPagable, KauthPreAuthorization } from './response/kauth';
|
|
4
|
+
import { PreAuthorizationAllowed } from '../../authenticator/base';
|
|
4
5
|
export declare class KauthApi {
|
|
5
6
|
private marmotUtil;
|
|
6
7
|
private cache;
|
|
@@ -51,9 +52,13 @@ export declare class KauthApi {
|
|
|
51
52
|
bindUsersByRoleNameAndExtendValue(data: KauthBindUsersByRoleNameAndExtendValueRequest): Promise<void>;
|
|
52
53
|
bindRoleByPermissions(data: KauthBindRoleByPermissionsRequest): Promise<void>;
|
|
53
54
|
bindRoleWithUsers(data: KauthBindRoleWithUsersRequest): Promise<void>;
|
|
54
|
-
createPreAuthorization(data: KauthCreatePreAuthorizationRequest): Promise<
|
|
55
|
-
getPreAuthorization(data: GetPreAuthorizationRequest): Promise<
|
|
56
|
-
refreshPreAuthorization(data: RefreshPreAuthorizatioRequest): Promise<
|
|
55
|
+
createPreAuthorization(data: KauthCreatePreAuthorizationRequest): Promise<KauthPreAuthorization>;
|
|
56
|
+
getPreAuthorization(data: GetPreAuthorizationRequest): Promise<KauthPreAuthorization>;
|
|
57
|
+
refreshPreAuthorization(data: RefreshPreAuthorizatioRequest): Promise<{
|
|
58
|
+
id: number;
|
|
59
|
+
token: string;
|
|
60
|
+
description: string;
|
|
61
|
+
}>;
|
|
57
62
|
processPreAuthorization(data: ProcessPreAuthorizatioRequest): Promise<PreAuthorizationAllowed>;
|
|
58
63
|
commitPreAuthorization(data: ProcessPreAuthorizatioRequest): Promise<PreAuthorizationAllowed>;
|
|
59
64
|
}
|
|
@@ -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,17 +1,5 @@
|
|
|
1
1
|
import { PrimaryPrincipal } from '../../../authenticator/base';
|
|
2
2
|
import { MarmotPagination } from '../tool/marmot';
|
|
3
|
-
export declare enum UserAccountType {
|
|
4
|
-
Mozi = "mozi",
|
|
5
|
-
Google = "google",
|
|
6
|
-
Miniprogram = "miniprogram"
|
|
7
|
-
}
|
|
8
|
-
export declare enum PreAuthorizationIsAllowedErrorCode {
|
|
9
|
-
UserNotFound = "userNotFound",
|
|
10
|
-
UserNotInWhitelist = "userNotInWhitelist",
|
|
11
|
-
TokenExpired = "tokenExpired",
|
|
12
|
-
TokenNotExisted = "tokenNotExisted",
|
|
13
|
-
TokenUsedUp = "tokenUsedUp"
|
|
14
|
-
}
|
|
15
3
|
export declare enum KauthPrincipalStatus {
|
|
16
4
|
Normal = 0,
|
|
17
5
|
Locked = 1
|
|
@@ -38,34 +26,10 @@ export interface KauthMoziCredential {
|
|
|
38
26
|
expiresIn: number;
|
|
39
27
|
refreshToken: string;
|
|
40
28
|
}
|
|
41
|
-
export declare type KauthPreAuthorized = ({
|
|
42
|
-
allowed: true;
|
|
43
|
-
} & {
|
|
44
|
-
processed: boolean;
|
|
45
|
-
id: number;
|
|
46
|
-
userId: number;
|
|
47
|
-
type: UserAccountType;
|
|
48
|
-
target: string;
|
|
49
|
-
token: string;
|
|
50
|
-
roleType: 'kauth' | string;
|
|
51
|
-
roleName: string;
|
|
52
|
-
roleExtendValue: string;
|
|
53
|
-
resolvedAuthorizeeTargets: Array<{
|
|
54
|
-
type: UserAccountType;
|
|
55
|
-
target: string;
|
|
56
|
-
id: number;
|
|
57
|
-
}>;
|
|
58
|
-
}) | ({
|
|
59
|
-
allowed: false;
|
|
60
|
-
} & {
|
|
61
|
-
code: PreAuthorizationIsAllowedErrorCode;
|
|
62
|
-
reason: string;
|
|
63
|
-
});
|
|
64
29
|
export interface KauthMoziAuthenticationInformation {
|
|
65
30
|
primaryPrincipal: KauthPrimaryPrincipal;
|
|
66
31
|
principal: KauthMoziPrincipal;
|
|
67
32
|
credential: KauthMoziCredential;
|
|
68
|
-
preAuthorized?: KauthPreAuthorized;
|
|
69
33
|
}
|
|
70
34
|
export interface KauthGooglePrincipal {
|
|
71
35
|
sub: string;
|
|
@@ -125,21 +89,7 @@ export interface KauthPagable<T> {
|
|
|
125
89
|
data: T;
|
|
126
90
|
pagination: MarmotPagination;
|
|
127
91
|
}
|
|
128
|
-
export interface
|
|
129
|
-
allowed: true;
|
|
130
|
-
processed: boolean;
|
|
131
|
-
id: number;
|
|
132
|
-
userId: number;
|
|
133
|
-
roleType: 'kauth' | string;
|
|
134
|
-
roleName: string;
|
|
135
|
-
roleExtendValue: string;
|
|
136
|
-
resolvedAuthorizeeTargets: Array<{
|
|
137
|
-
type: 'mozi' | 'google' | 'miniprogram';
|
|
138
|
-
id: number;
|
|
139
|
-
target: string;
|
|
140
|
-
}>;
|
|
141
|
-
}
|
|
142
|
-
export interface PreAuthorization {
|
|
92
|
+
export interface KauthPreAuthorization {
|
|
143
93
|
id: number;
|
|
144
94
|
tenantId: string;
|
|
145
95
|
token: string;
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KauthPrincipalStatus =
|
|
4
|
-
var UserAccountType;
|
|
5
|
-
(function (UserAccountType) {
|
|
6
|
-
UserAccountType["Mozi"] = "mozi";
|
|
7
|
-
UserAccountType["Google"] = "google";
|
|
8
|
-
UserAccountType["Miniprogram"] = "miniprogram";
|
|
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 = {}));
|
|
3
|
+
exports.KauthPrincipalStatus = void 0;
|
|
18
4
|
var KauthPrincipalStatus;
|
|
19
5
|
(function (KauthPrincipalStatus) {
|
|
20
6
|
KauthPrincipalStatus[KauthPrincipalStatus["Normal"] = 0] = "Normal";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { KauthApi } from './common/http/kauth';
|
|
|
3
3
|
export { KflowApi } from './common/http/kflow';
|
|
4
4
|
export * from './common/http/request/kauth';
|
|
5
5
|
export * from './common/http/request/kflow';
|
|
6
|
-
export { GoogleAuthenticator, MoziAuthenticator, MiniprogramAuthenticator, AuthenticationInformation, PrimaryPrincipal, JsonWebTokenSubjectProvider, JsonWebTokenAuthenticationProvider, } from './authenticator';
|
|
6
|
+
export { GoogleAuthenticator, MoziAuthenticator, MiniprogramAuthenticator, AuthenticationInformation, PrimaryPrincipal, JsonWebTokenSubjectProvider, JsonWebTokenAuthenticationProvider, UserAccountType, PreAuthorizationAllowed, } from './authenticator';
|
|
7
7
|
export { PermissionCore } from './authorizer';
|
|
8
8
|
export { MoziAuthenticationInformation, MoziPrincipal, MoziCredential } from './authenticator/mozi';
|
|
9
9
|
export { GoogleAuthenticationInformation, GooglePrincipal, GoogleCredential } from './authenticator/google';
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "MiniprogramAuthenticator", { enumerable: true, g
|
|
|
23
23
|
Object.defineProperty(exports, "PrimaryPrincipal", { enumerable: true, get: function () { return authenticator_1.PrimaryPrincipal; } });
|
|
24
24
|
Object.defineProperty(exports, "JsonWebTokenSubjectProvider", { enumerable: true, get: function () { return authenticator_1.JsonWebTokenSubjectProvider; } });
|
|
25
25
|
Object.defineProperty(exports, "JsonWebTokenAuthenticationProvider", { enumerable: true, get: function () { return authenticator_1.JsonWebTokenAuthenticationProvider; } });
|
|
26
|
+
Object.defineProperty(exports, "UserAccountType", { enumerable: true, get: function () { return authenticator_1.UserAccountType; } });
|
|
26
27
|
var authorizer_1 = require("./authorizer");
|
|
27
28
|
Object.defineProperty(exports, "PermissionCore", { enumerable: true, get: function () { return authorizer_1.PermissionCore; } });
|
|
28
29
|
var mozi_1 = require("./authenticator/mozi");
|