@techstuff-dev/foundation-api-utils 2.7.1 → 2.8.1

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var toolkit = require('@reduxjs/toolkit');
4
- var slice = require('./slice-2_5ax6TZ.js');
4
+ var slice = require('./slice-BPKtnPO0.js');
5
5
  var slice$1 = require('./slice-CkWobkWw.js');
6
6
 
7
7
  // This file exists just so TypeScript has a module at ./store for IDEs/build.
@@ -11,4 +11,4 @@ var slice$1 = require('./slice-CkWobkWw.js');
11
11
  const rootReducer = toolkit.combineSlices(slice.cartSlice, slice$1.authSlice, slice.authApi, slice.contentApi, slice.paymentApi, slice.productsApi, slice.ordersApi);
12
12
 
13
13
  exports.rootReducer = rootReducer;
14
- //# sourceMappingURL=shared-CNZnVs2B.js.map
14
+ //# sourceMappingURL=shared-CbwwPaK0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-CNZnVs2B.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
1
+ {"version":3,"file":"shared-CbwwPaK0.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
@@ -5197,6 +5197,18 @@ const APP_ES_CHALLENGES_INDEX$1 = getEnvVar$1('NEXT_PUBLIC_APP_ES_CHALLENGES_IND
5197
5197
  const APP_ES_CHALLENGE_DAYS_INDEX$1 = getEnvVar$1('NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX');
5198
5198
  // Platform identifier
5199
5199
  const PLATFORM$2 = 'web';
5200
+ /**
5201
+ * Return the Cognito app client ID the web app is configured to use.
5202
+ * Prefers the passwordless client when set (passwordless sessions present a
5203
+ * refresh token minted by that client); falls back to the regular client.
5204
+ * Used by the shared refresh-token flow so Cognito can match the refresh
5205
+ * token's original app client.
5206
+ */
5207
+ function getCognitoAppClientId$2() {
5208
+ return (getEnvVar$1('NEXT_PUBLIC_AWS_COGNITO_PASSWORDLESS_CLIENT_ID') ||
5209
+ getEnvVar$1('NEXT_PUBLIC_AWS_COGNITO_CLIENT_ID') ||
5210
+ undefined);
5211
+ }
5200
5212
 
5201
5213
  var webConfig = /*#__PURE__*/Object.freeze({
5202
5214
  __proto__: null,
@@ -5219,7 +5231,8 @@ var webConfig = /*#__PURE__*/Object.freeze({
5219
5231
  APP_ES_SETTINGS_INDEX: APP_ES_SETTINGS_INDEX$1,
5220
5232
  APP_ES_VIDEOS_INDEX: APP_ES_VIDEOS_INDEX$1,
5221
5233
  APP_ES_WORKOUTS_INDEX: APP_ES_WORKOUTS_INDEX$1,
5222
- PLATFORM: PLATFORM$2
5234
+ PLATFORM: PLATFORM$2,
5235
+ getCognitoAppClientId: getCognitoAppClientId$2
5223
5236
  });
5224
5237
 
5225
5238
  /**
@@ -5264,6 +5277,15 @@ const APP_ES_CHALLENGES_INDEX = getEnvVar('APP_ES_CHALLENGES_INDEX');
5264
5277
  const APP_ES_CHALLENGE_DAYS_INDEX = getEnvVar('APP_ES_CHALLENGE_DAYS_INDEX');
5265
5278
  // Platform identifier
5266
5279
  const PLATFORM$1 = 'native';
5280
+ /**
5281
+ * Return the Cognito app client ID the app is configured to use.
5282
+ * On native the env var is `AWS_COGNITO_CLIENT_ID` (react-native-config).
5283
+ * Used by the shared refresh-token flow so Cognito can match the refresh
5284
+ * token's original app client.
5285
+ */
5286
+ function getCognitoAppClientId$1() {
5287
+ return getEnvVar('AWS_COGNITO_CLIENT_ID') || undefined;
5288
+ }
5267
5289
 
5268
5290
  var nativeConfig = /*#__PURE__*/Object.freeze({
5269
5291
  __proto__: null,
@@ -5286,7 +5308,8 @@ var nativeConfig = /*#__PURE__*/Object.freeze({
5286
5308
  APP_ES_SETTINGS_INDEX: APP_ES_SETTINGS_INDEX,
5287
5309
  APP_ES_VIDEOS_INDEX: APP_ES_VIDEOS_INDEX,
5288
5310
  APP_ES_WORKOUTS_INDEX: APP_ES_WORKOUTS_INDEX,
5289
- PLATFORM: PLATFORM$1
5311
+ PLATFORM: PLATFORM$1,
5312
+ getCognitoAppClientId: getCognitoAppClientId$1
5290
5313
  });
5291
5314
 
5292
5315
  /**
@@ -5329,6 +5352,15 @@ apiConfig.APP_ES_SCHEDULE_INDEX;
5329
5352
  apiConfig.APP_ES_CHALLENGES_INDEX;
5330
5353
  apiConfig.APP_ES_CHALLENGE_DAYS_INDEX;
5331
5354
  const PLATFORM = apiConfig.PLATFORM;
5355
+ /**
5356
+ * Platform-specific accessor for the currently-configured Cognito app client ID.
5357
+ * Delegates to native or web config so the refresh-token flow can forward the
5358
+ * clientId to the backend (Cognito refresh tokens are bound to their minting
5359
+ * app client).
5360
+ */
5361
+ function getCognitoAppClientId() {
5362
+ return apiConfig.getCognitoAppClientId?.();
5363
+ }
5332
5364
 
5333
5365
  /**
5334
5366
  * Mutex to prevent multiple concurrent refresh attempts.
@@ -5384,11 +5416,21 @@ async function attemptTokenRefresh(api) {
5384
5416
  ? `${process.env.NEXT_PUBLIC_API_PREFIX}/auth/refresh-token`
5385
5417
  : `${API_AUTH_PREFIX || ''}/user/refreshtoken`;
5386
5418
  try {
5419
+ // Cognito refresh tokens are bound to the app client that minted them.
5420
+ // We read the client ID from the platform-specific env wrapper and pass it
5421
+ // to the backend so Cognito InitiateAuth is invoked with the matching
5422
+ // ClientId. Without this, pools with multiple app clients (e.g. separate
5423
+ // "Mobile App Client" and "ms-auth server" clients) fail refresh with
5424
+ // "Refresh Token has different Client".
5425
+ const clientId = getCognitoAppClientId();
5387
5426
  const response = await fetch(refreshUrl, {
5388
5427
  method: 'POST',
5389
5428
  headers: { 'Content-Type': 'application/json' },
5390
5429
  credentials: 'include',
5391
- body: JSON.stringify({ refreshtoken: refreshToken }),
5430
+ body: JSON.stringify({
5431
+ refreshtoken: refreshToken,
5432
+ ...(clientId ? { clientId } : {}),
5433
+ }),
5392
5434
  });
5393
5435
  if (!response.ok) {
5394
5436
  const errorBody = await response.text().catch(() => 'unable to read body');
@@ -5764,9 +5806,19 @@ const authApi = createApi({
5764
5806
  if (arg.type === 'workout_liked' || arg.type === 'workout_unliked') {
5765
5807
  tags.push('Recommendations', 'UserData');
5766
5808
  }
5809
+ if (arg.type === 'workout_favourited' || arg.type === 'workout_unfavourited') {
5810
+ tags.push('UserData');
5811
+ }
5767
5812
  if (arg.type === 'challenge_joined') {
5768
5813
  tags.push('UserData');
5769
5814
  }
5815
+ if (arg.type === 'challenge_day_completed') {
5816
+ // Invalidate UserData so the Challenge screen's
5817
+ // `getChallengeProgress` query refetches and the day shows
5818
+ // a check mark. Also refresh streak / weekly progress so
5819
+ // the dashboard counters stay in sync.
5820
+ tags.push('UserData', 'Streak', 'WeeklyProgress', 'ActivityStats');
5821
+ }
5770
5822
  return tags;
5771
5823
  },
5772
5824
  }),
@@ -6292,4 +6344,4 @@ exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
6292
6344
  exports.useVerifyUserQuery = useVerifyUserQuery;
6293
6345
  exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
6294
6346
  exports.withReauth = withReauth;
6295
- //# sourceMappingURL=slice-2_5ax6TZ.js.map
6347
+ //# sourceMappingURL=slice-BPKtnPO0.js.map