hevy-shared 1.0.822 → 1.0.824

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.
@@ -74,16 +74,6 @@ interface HevyAPIClientConfig {
74
74
  * @default ...
75
75
  */
76
76
  isAccessTokenInvalidResponse?(response: HTTPResponse<unknown>): boolean;
77
- /**
78
- * Callback for checking for a new token before calling the refresh endpoint.
79
- * Used in cases where multiple APIClients are using the same credentials,
80
- * such as multiple browser tabs with the web app.
81
- *
82
- * Optional.
83
- *
84
- * @default {undefined}
85
- */
86
- localRefresh?(): ClientAuthToken | null;
87
77
  }
88
78
  export declare class HevyAPIClient {
89
79
  private static readonly DEFAULT_TOKEN_EXPIRY_SAFETY_THRESHOLD_MS;
@@ -99,7 +89,6 @@ export declare class HevyAPIClient {
99
89
  constructor(httpClient: HTTPClient, config: HevyAPIClientConfig);
100
90
  private get _authHeaders();
101
91
  private _addAuthHeaders;
102
- private _isExpired;
103
92
  private refreshExpiredAuthToken;
104
93
  private forceRefreshAuthToken;
105
94
  private waitForTokenRefresh;
@@ -24,9 +24,6 @@ class HevyAPIClient {
24
24
  this._authToken = null;
25
25
  this._legacyAuthToken = null;
26
26
  this._addAuthHeaders = (config) => (Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.headers), this._authHeaders) }));
27
- this._isExpired = ({ now, authToken, }) => now.valueOf() >=
28
- new Date(authToken.expires_at).valueOf() -
29
- this._config.tokenExpirySafetyThresholdMs;
30
27
  this._httpClient = httpClient;
31
28
  this._config = Object.assign({ tokenExpirySafetyThresholdMs: HevyAPIClient.DEFAULT_TOKEN_EXPIRY_SAFETY_THRESHOLD_MS, accessTokenMinimumValidAgeMs: HevyAPIClient.DEFAULT_ACCESS_TOKEN_MINIMUM_VALID_AGE_MS, tokenRefreshThrottleMs: HevyAPIClient.DEFAULT_TOKEN_REFRESH_THROTTLE_MS, refreshAuthTokenApiEndpoint: HevyAPIClient.DEFAULT_REFRESH_AUTH_TOKEN_API_ENDPOINT, isAccessTokenExpiredResponse: (response) => response.status === 401 &&
32
29
  (0, types_1.isHTTPErrorResponse)(response) &&
@@ -48,28 +45,16 @@ class HevyAPIClient {
48
45
  }
49
46
  refreshExpiredAuthToken() {
50
47
  return __awaiter(this, void 0, void 0, function* () {
51
- const { _authToken: authToken } = this;
52
- if (!authToken)
48
+ const { _authToken } = this;
49
+ if (!_authToken)
53
50
  return;
54
- const now = new Date();
55
- if (!this._isExpired({ now, authToken })) {
51
+ if (new Date().valueOf() <=
52
+ new Date(_authToken.expires_at).valueOf() -
53
+ this._config.tokenExpirySafetyThresholdMs) {
56
54
  // Token is still valid, at least according to the client. Don't refresh.
57
55
  return;
58
56
  }
59
- if (this._config.localRefresh !== undefined) {
60
- const authToken = this._config.localRefresh();
61
- this._authToken = authToken;
62
- this._lastTokenRefresh = undefined; // This isn't shared across processes
63
- if (authToken === null) {
64
- // We were de-authenticated, there is nothing to refresh.
65
- return;
66
- }
67
- if (!this._isExpired({ now, authToken })) {
68
- // Token was refreshed by a different process (e.g. other browser tab).
69
- return;
70
- }
71
- }
72
- yield this._refreshAuthToken(authToken);
57
+ yield this._refreshAuthToken(_authToken);
73
58
  });
74
59
  }
75
60
  forceRefreshAuthToken() {
package/built/index.d.ts CHANGED
@@ -852,7 +852,6 @@ export interface Workout {
852
852
  logged_by_coach_id?: string;
853
853
  biometrics?: WorkoutBiometrics;
854
854
  is_biometrics_public: boolean;
855
- is_trainer_workout: boolean;
856
855
  trainer_program_id: string | undefined;
857
856
  }
858
857
  export interface CustomExerciseImage {
@@ -932,7 +931,6 @@ export interface PostWorkoutRequestWorkout {
932
931
  is_private: boolean;
933
932
  biometrics?: WorkoutBiometrics;
934
933
  is_biometrics_public: boolean;
935
- is_trainer_workout: boolean;
936
934
  trainer_program_id: string | undefined;
937
935
  }
938
936
  export declare const isHeartRateSamples: (x: any) => x is HeartRateSample[];
@@ -35,7 +35,6 @@ export interface NormalizedWorkout {
35
35
  };
36
36
  clientId: string;
37
37
  biometrics?: WorkoutBiometrics;
38
- isTrainerWorkout: boolean;
39
38
  trainerProgramId: string | undefined;
40
39
  }
41
40
  export interface NormalizedSet {
@@ -154,7 +154,6 @@ class WorkoutBuilder {
154
154
  wearosWatch: false,
155
155
  workoutVisibility: 'public',
156
156
  isWorkoutBiometricsPublic: true,
157
- isTrainerWorkout: false,
158
157
  trainerProgramId: undefined,
159
158
  shareTo: {
160
159
  strava: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.822",
3
+ "version": "1.0.824",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",