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 CHANGED
@@ -19,18 +19,18 @@ interface LookupUserProfileResponse {
19
19
  interface LoginTokenResponse {
20
20
  redirectUri: string;
21
21
  }
22
- interface ValidateJwtPayloadResponse {
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 ValidateJwtResponse {
31
+ interface ValidateAuthorizationCodeResponse {
32
32
  isValid: boolean;
33
- payload: ValidateJwtPayloadResponse | null;
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
- validateJwt(jwt: string): Promise<ApiResponse<ValidateJwtResponse>>;
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 a JWT token using the MOC OAuth API.
61
- * @param jwt The JWT token to validate.
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 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.
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
- validateJwt(jwt: string): Promise<ApiResponse<ValidateJwtResponse>>;
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 ValidateJwtPayloadResponse, type ValidateJwtResponse };
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
- VALIDATE_JWT: "/api/v1/service-account/validate-jwt"
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 a JWT token using the MOC OAuth API.
115
- * @param jwt The JWT token to validate.
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 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.
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 validateJwt(jwt) {
121
+ async validateAuthorizationCode(code) {
123
122
  try {
124
- const res = await http.post(API_ENDPOINTS.VALIDATE_JWT, {
125
- jwt
123
+ const res = await http.post(API_ENDPOINTS.VALIDATE_AUTHORIZATION_CODE, {
124
+ code
126
125
  });
127
126
  return {
128
127
  data: res.data.data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moc-oauth-client",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "OAuth client for Ministry of Commerce, Cambodia",
5
5
  "author": "Ministry of Commerce, Cambodia",
6
6
  "license": "MIT",