@0xmonaco/core 0.6.1 → 0.6.3
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/README.md +4 -7
- package/dist/api/auth/api.d.ts +9 -8
- package/dist/api/auth/api.js +9 -11
- package/dist/sdk.d.ts +4 -4
- package/dist/sdk.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ async function authExample() {
|
|
|
125
125
|
console.log("Authenticated:", authState.user);
|
|
126
126
|
console.log("Tokens:", {
|
|
127
127
|
accessToken: authState.accessToken,
|
|
128
|
-
refreshToken: authState.refreshToken,
|
|
128
|
+
refreshToken: authState.refreshToken,
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
// Authenticated WebSocket channels are now connected - start receiving real-time updates
|
|
@@ -141,8 +141,7 @@ async function authExample() {
|
|
|
141
141
|
await monaco.logout();
|
|
142
142
|
|
|
143
143
|
// Or manually revoke the token
|
|
144
|
-
|
|
145
|
-
await monaco.auth.revokeToken(authState.refreshToken);
|
|
144
|
+
await monaco.auth.revokeToken();
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// Market Data
|
|
@@ -277,11 +276,9 @@ interface AuthState {
|
|
|
277
276
|
}
|
|
278
277
|
```
|
|
279
278
|
|
|
280
|
-
**⚠️ Important:** The authentication response contains `refreshToken`, NOT `revokeToken`.
|
|
281
|
-
|
|
282
279
|
```typescript
|
|
283
|
-
//
|
|
284
|
-
await sdk.auth.revokeToken(
|
|
280
|
+
// Revoke the current session's token
|
|
281
|
+
await sdk.auth.revokeToken();
|
|
285
282
|
|
|
286
283
|
// 💡 TIP: Use the built-in logout method
|
|
287
284
|
await sdk.logout(); // Automatically calls revokeToken internally
|
package/dist/api/auth/api.d.ts
CHANGED
|
@@ -182,14 +182,15 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
|
|
|
182
182
|
*/
|
|
183
183
|
refreshToken(refreshToken: string): Promise<TokenRefreshResponse>;
|
|
184
184
|
/**
|
|
185
|
-
* Revokes
|
|
185
|
+
* Revokes the current session's refresh token.
|
|
186
186
|
*
|
|
187
|
-
* Invalidates
|
|
188
|
-
* new access tokens. This is useful
|
|
189
|
-
* a token has been compromised.
|
|
187
|
+
* Invalidates the refresh token associated with the current access token,
|
|
188
|
+
* preventing it from being used to obtain new access tokens. This is useful
|
|
189
|
+
* for logout functionality or when a token has been compromised.
|
|
190
|
+
*
|
|
191
|
+
* The server identifies the token to revoke from the access token in the
|
|
192
|
+
* Authorization header — no request body is needed.
|
|
190
193
|
*
|
|
191
|
-
* **Important:** Pass the `refreshToken` from the authentication response.
|
|
192
|
-
* @param refreshToken - The refresh token to revoke (from authResult.refreshToken)
|
|
193
194
|
* @returns Promise resolving when the token is revoked
|
|
194
195
|
* @throws {APIError} When token revocation fails
|
|
195
196
|
*
|
|
@@ -197,9 +198,9 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
|
|
|
197
198
|
* ```typescript
|
|
198
199
|
* // After authentication
|
|
199
200
|
* const authResult = await authAPI.authenticate(clientId);
|
|
200
|
-
* await authAPI.revokeToken(
|
|
201
|
+
* await authAPI.revokeToken();
|
|
201
202
|
* console.log("Token revoked successfully");
|
|
202
203
|
* ```
|
|
203
204
|
*/
|
|
204
|
-
revokeToken(
|
|
205
|
+
revokeToken(): Promise<void>;
|
|
205
206
|
}
|
package/dist/api/auth/api.js
CHANGED
|
@@ -277,14 +277,15 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
|
-
* Revokes
|
|
280
|
+
* Revokes the current session's refresh token.
|
|
281
281
|
*
|
|
282
|
-
* Invalidates
|
|
283
|
-
* new access tokens. This is useful
|
|
284
|
-
* a token has been compromised.
|
|
282
|
+
* Invalidates the refresh token associated with the current access token,
|
|
283
|
+
* preventing it from being used to obtain new access tokens. This is useful
|
|
284
|
+
* for logout functionality or when a token has been compromised.
|
|
285
|
+
*
|
|
286
|
+
* The server identifies the token to revoke from the access token in the
|
|
287
|
+
* Authorization header — no request body is needed.
|
|
285
288
|
*
|
|
286
|
-
* **Important:** Pass the `refreshToken` from the authentication response.
|
|
287
|
-
* @param refreshToken - The refresh token to revoke (from authResult.refreshToken)
|
|
288
289
|
* @returns Promise resolving when the token is revoked
|
|
289
290
|
* @throws {APIError} When token revocation fails
|
|
290
291
|
*
|
|
@@ -292,16 +293,13 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
292
293
|
* ```typescript
|
|
293
294
|
* // After authentication
|
|
294
295
|
* const authResult = await authAPI.authenticate(clientId);
|
|
295
|
-
* await authAPI.revokeToken(
|
|
296
|
+
* await authAPI.revokeToken();
|
|
296
297
|
* console.log("Token revoked successfully");
|
|
297
298
|
* ```
|
|
298
299
|
*/
|
|
299
|
-
async revokeToken(
|
|
300
|
+
async revokeToken() {
|
|
300
301
|
await this.makeAuthenticatedRequest("/api/v1/auth/revoke", {
|
|
301
302
|
method: "POST",
|
|
302
|
-
body: JSON.stringify({
|
|
303
|
-
refresh_token: refreshToken,
|
|
304
|
-
}),
|
|
305
303
|
});
|
|
306
304
|
}
|
|
307
305
|
}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
31
31
|
* - `expiresAt`: When the access token expires
|
|
32
32
|
* - `user`: User information
|
|
33
33
|
*
|
|
34
|
-
* Note:
|
|
35
|
-
*
|
|
34
|
+
* Note: Use `sdk.logout()` to revoke the token and clean up, or call
|
|
35
|
+
* `sdk.auth.revokeToken()` directly to just revoke.
|
|
36
36
|
*
|
|
37
37
|
* @param clientId - The client ID for authentication
|
|
38
38
|
* @param options - Optional configuration
|
|
@@ -50,7 +50,7 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
50
50
|
* await sdk.ws.connect();
|
|
51
51
|
*
|
|
52
52
|
* // Later, to revoke:
|
|
53
|
-
* await sdk.auth.revokeToken(
|
|
53
|
+
* await sdk.auth.revokeToken(); // ✅
|
|
54
54
|
* // Or revoke and disconnect WebSocket:
|
|
55
55
|
* await sdk.logout(); // ✅ Calls revokeToken internally and disconnects WebSocket
|
|
56
56
|
* ```
|
|
@@ -76,7 +76,7 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
76
76
|
*
|
|
77
77
|
* This method revokes the refresh token (if available), disconnects all authenticated
|
|
78
78
|
* WebSocket channels, and clears the local auth state.
|
|
79
|
-
* It internally calls `auth.revokeToken(
|
|
79
|
+
* It internally calls `auth.revokeToken()` to invalidate the token on the server.
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
82
|
* ```typescript
|
package/dist/sdk.js
CHANGED
|
@@ -99,8 +99,8 @@ export class MonacoSDKImpl {
|
|
|
99
99
|
* - `expiresAt`: When the access token expires
|
|
100
100
|
* - `user`: User information
|
|
101
101
|
*
|
|
102
|
-
* Note:
|
|
103
|
-
*
|
|
102
|
+
* Note: Use `sdk.logout()` to revoke the token and clean up, or call
|
|
103
|
+
* `sdk.auth.revokeToken()` directly to just revoke.
|
|
104
104
|
*
|
|
105
105
|
* @param clientId - The client ID for authentication
|
|
106
106
|
* @param options - Optional configuration
|
|
@@ -118,7 +118,7 @@ export class MonacoSDKImpl {
|
|
|
118
118
|
* await sdk.ws.connect();
|
|
119
119
|
*
|
|
120
120
|
* // Later, to revoke:
|
|
121
|
-
* await sdk.auth.revokeToken(
|
|
121
|
+
* await sdk.auth.revokeToken(); // ✅
|
|
122
122
|
* // Or revoke and disconnect WebSocket:
|
|
123
123
|
* await sdk.logout(); // ✅ Calls revokeToken internally and disconnects WebSocket
|
|
124
124
|
* ```
|
|
@@ -161,7 +161,7 @@ export class MonacoSDKImpl {
|
|
|
161
161
|
*
|
|
162
162
|
* This method revokes the refresh token (if available), disconnects all authenticated
|
|
163
163
|
* WebSocket channels, and clears the local auth state.
|
|
164
|
-
* It internally calls `auth.revokeToken(
|
|
164
|
+
* It internally calls `auth.revokeToken()` to invalidate the token on the server.
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
167
|
* ```typescript
|
|
@@ -172,7 +172,7 @@ export class MonacoSDKImpl {
|
|
|
172
172
|
async logout() {
|
|
173
173
|
if (this.authState?.refreshToken) {
|
|
174
174
|
try {
|
|
175
|
-
await this.auth.revokeToken(
|
|
175
|
+
await this.auth.revokeToken();
|
|
176
176
|
}
|
|
177
177
|
catch (error) {
|
|
178
178
|
// Log but don't throw - we want to clear the local state regardless
|