moc-oauth-client 3.0.1 → 3.0.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/index.d.ts +9 -0
- package/dist/index.js +25 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ interface MOCOAuthClientBase {
|
|
|
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
|
+
logout(refreshToken: string): Promise<ApiResponse<boolean>>;
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* MOCOAuthClient is a client library for interacting with the MOC OAuth API.
|
|
@@ -81,6 +82,14 @@ declare class MOCOAuthClient implements MOCOAuthClientBase {
|
|
|
81
82
|
* @throws An error if the request to refresh the access token fails.
|
|
82
83
|
*/
|
|
83
84
|
refreshToken(refreshToken: string): Promise<ApiResponse<RefreshTokenResponse>>;
|
|
85
|
+
/**
|
|
86
|
+
* Logs out the current user's session using the MOC OAuth API.
|
|
87
|
+
* @param refreshToken The JWT token to use for authentication.
|
|
88
|
+
* @returns A promise resolving to an object containing the response data.
|
|
89
|
+
* The response data will contain a boolean indicating whether the logout was successful or not.
|
|
90
|
+
* @throws An error if the request to log out the current user's session fails.
|
|
91
|
+
*/
|
|
92
|
+
logout(refreshToken: string): Promise<ApiResponse<boolean>>;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
export { type ApiErrorResponse, type ApiResponse, type LoginTokenResponse, type LookupUserProfileResponse, MOCOAuthClient, type RefreshTokenResponse, type ValidateAuthorizationCodePayloadResponse, type ValidateAuthorizationCodeResponse };
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,8 @@ var API_ENDPOINTS = {
|
|
|
82
82
|
GET_LOGIN_TOKEN: "/api/v1/service-account/login-token",
|
|
83
83
|
LOOKUP_USER_PROFILE: "/api/v1/service-account/lookup-user-profile",
|
|
84
84
|
REFRESH_TOKEN: "/api/v1/service-account/refresh-token",
|
|
85
|
-
VALIDATE_AUTHORIZATION_CODE: "/api/v1/service-account/validate-authorization-code"
|
|
85
|
+
VALIDATE_AUTHORIZATION_CODE: "/api/v1/service-account/validate-authorization-code",
|
|
86
|
+
LOGOUT: "/api/v1/service-account/logout"
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
// src/client.ts
|
|
@@ -181,6 +182,29 @@ var MOCOAuthClient = class {
|
|
|
181
182
|
};
|
|
182
183
|
}
|
|
183
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Logs out the current user's session using the MOC OAuth API.
|
|
187
|
+
* @param refreshToken The JWT token to use for authentication.
|
|
188
|
+
* @returns A promise resolving to an object containing the response data.
|
|
189
|
+
* The response data will contain a boolean indicating whether the logout was successful or not.
|
|
190
|
+
* @throws An error if the request to log out the current user's session fails.
|
|
191
|
+
*/
|
|
192
|
+
async logout(refreshToken) {
|
|
193
|
+
try {
|
|
194
|
+
const res = await http.post(API_ENDPOINTS.LOGOUT, {
|
|
195
|
+
refreshToken
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
data: res.data.data,
|
|
199
|
+
error: null
|
|
200
|
+
};
|
|
201
|
+
} catch (e) {
|
|
202
|
+
return {
|
|
203
|
+
data: null,
|
|
204
|
+
error: handleError(e)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
184
208
|
};
|
|
185
209
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
210
|
0 && (module.exports = {
|