moc-oauth-client 1.0.8 → 2.0.0
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/index.d.ts +24 -17
- package/dist/index.js +9 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,30 +10,36 @@ interface ApiErrorResponse {
|
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
interface LookupUserProfileResponse {
|
|
14
|
+
id: number;
|
|
15
|
+
email: string;
|
|
16
|
+
username?: string;
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
}
|
|
13
19
|
interface LoginTokenResponse {
|
|
14
20
|
redirectUri: string;
|
|
15
21
|
}
|
|
16
|
-
interface
|
|
17
|
-
isValid: boolean;
|
|
18
|
-
payload: {
|
|
19
|
-
accessToken: string;
|
|
20
|
-
refreshToken: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
interface RefreshTokenResponse {
|
|
22
|
+
interface ValidateJwtPayloadResponse {
|
|
24
23
|
accessToken: string;
|
|
25
24
|
refreshToken: string;
|
|
26
|
-
|
|
27
|
-
interface LookupUserProfileResponse {
|
|
25
|
+
domain: string;
|
|
28
26
|
id: number;
|
|
29
27
|
email: string;
|
|
30
28
|
username?: string;
|
|
31
29
|
isActive: boolean;
|
|
32
30
|
}
|
|
31
|
+
interface ValidateJwtResponse {
|
|
32
|
+
isValid: boolean;
|
|
33
|
+
payload: ValidateJwtPayloadResponse | null;
|
|
34
|
+
}
|
|
35
|
+
interface RefreshTokenResponse {
|
|
36
|
+
accessToken: string;
|
|
37
|
+
refreshToken: string;
|
|
38
|
+
}
|
|
33
39
|
|
|
34
40
|
interface MOCOAuthClientBase {
|
|
35
41
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
36
|
-
|
|
42
|
+
validateJwt(jwt: string): Promise<ApiResponse<ValidateJwtResponse>>;
|
|
37
43
|
lookupUserProfile(accessToken: string): Promise<ApiResponse<LookupUserProfileResponse>>;
|
|
38
44
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
39
45
|
}
|
|
@@ -52,13 +58,14 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
52
58
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
53
59
|
/**
|
|
54
60
|
* Validates a JWT token using the MOC OAuth API.
|
|
55
|
-
* @param
|
|
61
|
+
* @param jwt The JWT token to validate.
|
|
56
62
|
* @returns A promise resolving to an object containing the response data.
|
|
57
|
-
* The response data will contain
|
|
58
|
-
*
|
|
59
|
-
*
|
|
63
|
+
* The response data will contain the validation result of the JWT token.
|
|
64
|
+
* If the JWT token is valid, the response data will contain the payload of the JWT token.
|
|
65
|
+
* If the JWT token is invalid, the response data will contain an error.
|
|
66
|
+
* @throws An error if the request to validate the JWT token fails.
|
|
60
67
|
*/
|
|
61
|
-
|
|
68
|
+
validateJwt(jwt: string): Promise<ApiResponse<ValidateJwtResponse>>;
|
|
62
69
|
/**
|
|
63
70
|
* Retrieves the current user's information using the MOC OAuth API.
|
|
64
71
|
* @param accessToken The JWT token to use for authentication.
|
|
@@ -77,4 +84,4 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
77
84
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
export { type ApiErrorResponse, type ApiResponse, type LoginTokenResponse, type LookupUserProfileResponse, MOCOAuthClient, type RefreshTokenResponse, type ValidateJwtResponse };
|
|
87
|
+
export { type ApiErrorResponse, type ApiResponse, type LoginTokenResponse, type LookupUserProfileResponse, MOCOAuthClient, type RefreshTokenResponse, type ValidateJwtPayloadResponse, type ValidateJwtResponse };
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,7 @@ var API_ENDPOINTS = {
|
|
|
81
81
|
GET_LOGIN_TOKEN: "/api/v1/service-account/login-token",
|
|
82
82
|
LOOKUP_USER_PROFILE: "/api/v1/service-account/lookup-user-profile",
|
|
83
83
|
REFRESH_TOKEN: "/api/v1/service-account/refresh-token",
|
|
84
|
-
|
|
84
|
+
VALIDATE_JWT: "/api/v1/service-account/validate-jwt"
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
// src/client.ts
|
|
@@ -112,16 +112,17 @@ var MOCOAuthClient = class {
|
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* Validates a JWT token using the MOC OAuth API.
|
|
115
|
-
* @param
|
|
115
|
+
* @param jwt The JWT token to validate.
|
|
116
116
|
* @returns A promise resolving to an object containing the response data.
|
|
117
|
-
* The response data will contain
|
|
118
|
-
*
|
|
119
|
-
*
|
|
117
|
+
* The response data will contain the validation result of the JWT token.
|
|
118
|
+
* If the JWT token is valid, the response data will contain the payload of the JWT token.
|
|
119
|
+
* If the JWT token is invalid, the response data will contain an error.
|
|
120
|
+
* @throws An error if the request to validate the JWT token fails.
|
|
120
121
|
*/
|
|
121
|
-
async
|
|
122
|
+
async validateJwt(jwt) {
|
|
122
123
|
try {
|
|
123
|
-
const res = await http.post(API_ENDPOINTS.
|
|
124
|
-
|
|
124
|
+
const res = await http.post(API_ENDPOINTS.VALIDATE_JWT, {
|
|
125
|
+
jwt
|
|
125
126
|
});
|
|
126
127
|
return {
|
|
127
128
|
data: res.data.data,
|