moc-oauth-client 2.0.0 → 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 +14 -15
- package/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,18 +19,18 @@ interface LookupUserProfileResponse {
|
|
|
19
19
|
interface LoginTokenResponse {
|
|
20
20
|
redirectUri: string;
|
|
21
21
|
}
|
|
22
|
-
interface
|
|
23
|
-
accessToken: string;
|
|
24
|
-
refreshToken: string;
|
|
25
|
-
domain: string;
|
|
22
|
+
interface ValidateAuthorizationCodePayloadResponse {
|
|
26
23
|
id: number;
|
|
27
24
|
email: string;
|
|
28
25
|
username?: string;
|
|
29
26
|
isActive: boolean;
|
|
27
|
+
accessToken: string;
|
|
28
|
+
refreshToken: string;
|
|
29
|
+
domain: string;
|
|
30
30
|
}
|
|
31
|
-
interface
|
|
31
|
+
interface ValidateAuthorizationCodeResponse {
|
|
32
32
|
isValid: boolean;
|
|
33
|
-
payload:
|
|
33
|
+
payload: ValidateAuthorizationCodePayloadResponse | null;
|
|
34
34
|
}
|
|
35
35
|
interface RefreshTokenResponse {
|
|
36
36
|
accessToken: string;
|
|
@@ -39,7 +39,7 @@ interface RefreshTokenResponse {
|
|
|
39
39
|
|
|
40
40
|
interface MOCOAuthClientBase {
|
|
41
41
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
42
|
-
|
|
42
|
+
validateAuthorizationCode(code: string): Promise<ApiResponse<ValidateAuthorizationCodeResponse>>;
|
|
43
43
|
lookupUserProfile(accessToken: string): Promise<ApiResponse<LookupUserProfileResponse>>;
|
|
44
44
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
45
45
|
}
|
|
@@ -57,15 +57,14 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
57
57
|
*/
|
|
58
58
|
getLoginToken(): Promise<ApiResponse<LoginTokenResponse>>;
|
|
59
59
|
/**
|
|
60
|
-
* Validates
|
|
61
|
-
* @param
|
|
60
|
+
* Validates an authorization code using the MOC OAuth API.
|
|
61
|
+
* @param code The authorization code to validate.
|
|
62
62
|
* @returns A promise resolving to an object containing the response data.
|
|
63
|
-
* The response data will contain
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @throws An error if the request to validate the JWT token fails.
|
|
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.
|
|
67
66
|
*/
|
|
68
|
-
|
|
67
|
+
validateAuthorizationCode(code: string): Promise<ApiResponse<ValidateAuthorizationCodeResponse>>;
|
|
69
68
|
/**
|
|
70
69
|
* Retrieves the current user's information using the MOC OAuth API.
|
|
71
70
|
* @param accessToken The JWT token to use for authentication.
|
|
@@ -84,4 +83,4 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
84
83
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
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,18 +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
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @throws An error if the request to validate the JWT token fails.
|
|
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.
|
|
121
120
|
*/
|
|
122
|
-
async
|
|
121
|
+
async validateAuthorizationCode(code) {
|
|
123
122
|
try {
|
|
124
|
-
const res = await http.post(API_ENDPOINTS.
|
|
125
|
-
|
|
123
|
+
const res = await http.post(API_ENDPOINTS.VALIDATE_AUTHORIZATION_CODE, {
|
|
124
|
+
code
|
|
126
125
|
});
|
|
127
126
|
return {
|
|
128
127
|
data: res.data.data,
|