@chaosity/location-client 0.1.6 → 0.1.7

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.
@@ -94,10 +94,10 @@ export class TokenProvider {
94
94
  }
95
95
  const data = await response.json();
96
96
  this.cachedToken = data.access_token;
97
- // Use expires_in from OAuth2 response; null-coalesce so 0 is not replaced
98
- const expiresIn = data.expires_in ?? 900;
99
- this.cachedExpiresAt = Date.now() + (expiresIn * 1000);
100
- log('Token acquired successfully (expires in %ds)', expiresIn);
97
+ // Prefer absolute expires_at (ms) from response, fall back to expires_in (seconds)
98
+ this.cachedExpiresAt = data.expires_at ?? (Date.now() + ((data.expires_in ?? 900) * 1000));
99
+ const expiresInSec = Math.floor((this.cachedExpiresAt - Date.now()) / 1000);
100
+ log('Token acquired successfully (expires in %ds)', expiresInSec);
101
101
  return {
102
102
  success: true,
103
103
  token: this.cachedToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaosity/location-client",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Client library for Chaosity Location Service with AWS Location Service compatibility",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",