@go-avro/avro-js 0.0.2-beta.5 → 0.0.2-beta.6

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.
@@ -26,7 +26,23 @@ export class AuthManager {
26
26
  'Authorization': `Bearer ${tokens.access_token}`,
27
27
  },
28
28
  });
29
- return response.ok;
29
+ if (response.ok) {
30
+ return true;
31
+ }
32
+ else {
33
+ // Attempt token refresh if validation fails
34
+ const newTokens = await this.refreshTokens();
35
+ if (newTokens && newTokens.access_token) {
36
+ const retryResponse = await fetch(`${this.baseUrl}/validate`, {
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ 'Authorization': `Bearer ${newTokens.access_token}`,
41
+ },
42
+ });
43
+ return retryResponse.ok;
44
+ }
45
+ }
30
46
  }
31
47
  catch (error) {
32
48
  console.error('Error validating access token:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.5",
3
+ "version": "0.0.2-beta.6",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",