moc-oauth-client 1.0.8 → 3.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 +25 -19
- package/dist/index.js +9 -9
- 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
|
|
22
|
+
interface ValidateAuthorizationCodePayloadResponse {
|
|
23
|
+
id: number;
|
|
24
|
+
email: string;
|
|
25
|
+
username?: string;
|
|
26
|
+
isActive: boolean;
|
|
27
|
+
accessToken: string;
|
|
28
|
+
refreshToken: string;
|
|
29
|
+
domain: string;
|
|
30
|
+
}
|
|
31
|
+
interface ValidateAuthorizationCodeResponse {
|
|
17
32
|
isValid: boolean;
|
|
18
|
-
payload:
|
|
19
|
-
accessToken: string;
|
|
20
|
-
refreshToken: string;
|
|
21
|
-
};
|
|
33
|
+
payload: ValidateAuthorizationCodePayloadResponse | null;
|
|
22
34
|
}
|
|
23
35
|
interface RefreshTokenResponse {
|
|
24
36
|
accessToken: string;
|
|
25
37
|
refreshToken: string;
|
|
26
38
|
}
|
|
27
|
-
interface LookupUserProfileResponse {
|
|
28
|
-
id: number;
|
|
29
|
-
email: string;
|
|
30
|
-
username?: string;
|
|
31
|
-
isActive: boolean;
|
|
32
|
-
}
|
|
33
39
|
|
|
34
40
|
interface MOCOAuthClientBase {
|
|
35
41
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
36
|
-
|
|
42
|
+
validateAuthorizationCode(code: string): Promise<ApiResponse<ValidateAuthorizationCodeResponse>>;
|
|
37
43
|
lookupUserProfile(accessToken: string): Promise<ApiResponse<LookupUserProfileResponse>>;
|
|
38
44
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
39
45
|
}
|
|
@@ -51,14 +57,14 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
51
57
|
*/
|
|
52
58
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
53
59
|
/**
|
|
54
|
-
* Validates
|
|
55
|
-
* @param
|
|
60
|
+
* Validates an authorization code using the MOC OAuth API.
|
|
61
|
+
* @param code The authorization code to validate.
|
|
56
62
|
* @returns A promise resolving to an object containing the response data.
|
|
57
|
-
* The response data will contain
|
|
58
|
-
* an access token
|
|
59
|
-
* @throws An error if the request to validate the
|
|
63
|
+
* The response data will contain information about whether the authorization code is valid,
|
|
64
|
+
* and an access token and refresh token if it is.
|
|
65
|
+
* @throws An error if the request to validate the authorization code fails.
|
|
60
66
|
*/
|
|
61
|
-
|
|
67
|
+
validateAuthorizationCode(code: string): Promise<ApiResponse<ValidateAuthorizationCodeResponse>>;
|
|
62
68
|
/**
|
|
63
69
|
* Retrieves the current user's information using the MOC OAuth API.
|
|
64
70
|
* @param accessToken The JWT token to use for authentication.
|
|
@@ -77,4 +83,4 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
77
83
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
export { type ApiErrorResponse, type ApiResponse, type LoginTokenResponse, type LookupUserProfileResponse, MOCOAuthClient, type RefreshTokenResponse, type
|
|
86
|
+
export { type ApiErrorResponse, type ApiResponse, type LoginTokenResponse, type LookupUserProfileResponse, MOCOAuthClient, type RefreshTokenResponse, type ValidateAuthorizationCodePayloadResponse, type ValidateAuthorizationCodeResponse };
|
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_AUTHORIZATION_CODE: "/api/v1/service-account/validate-authorization-code"
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
// src/client.ts
|
|
@@ -111,17 +111,17 @@ var MOCOAuthClient = class {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* Validates
|
|
115
|
-
* @param
|
|
114
|
+
* Validates an authorization code using the MOC OAuth API.
|
|
115
|
+
* @param code The authorization code to validate.
|
|
116
116
|
* @returns A promise resolving to an object containing the response data.
|
|
117
|
-
* The response data will contain
|
|
118
|
-
* an access token
|
|
119
|
-
* @throws An error if the request to validate the
|
|
117
|
+
* The response data will contain information about whether the authorization code is valid,
|
|
118
|
+
* and an access token and refresh token if it is.
|
|
119
|
+
* @throws An error if the request to validate the authorization code fails.
|
|
120
120
|
*/
|
|
121
|
-
async
|
|
121
|
+
async validateAuthorizationCode(code) {
|
|
122
122
|
try {
|
|
123
|
-
const res = await http.post(API_ENDPOINTS.
|
|
124
|
-
|
|
123
|
+
const res = await http.post(API_ENDPOINTS.VALIDATE_AUTHORIZATION_CODE, {
|
|
124
|
+
code
|
|
125
125
|
});
|
|
126
126
|
return {
|
|
127
127
|
data: res.data.data,
|