@techstuff-dev/foundation-api-utils 2.7.1 → 2.8.0
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/dist/cjs/chunks/{shared-CNZnVs2B.js → shared-l1zCzYJr.js} +2 -2
- package/dist/cjs/chunks/{shared-CNZnVs2B.js.map → shared-l1zCzYJr.js.map} +1 -1
- package/dist/cjs/chunks/{slice-2_5ax6TZ.js → slice-Bu9L_cVR.js} +46 -4
- package/dist/{esm/chunks/slice-WrrAzvxd.js.map → cjs/chunks/slice-Bu9L_cVR.js.map} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/store/index.native.js +2 -2
- package/dist/cjs/store/index.web.js +2 -2
- package/dist/esm/chunks/{shared-DJdjELG7.js → shared-ChUGjIwE.js} +2 -2
- package/dist/esm/chunks/{shared-DJdjELG7.js.map → shared-ChUGjIwE.js.map} +1 -1
- package/dist/esm/chunks/{slice-WrrAzvxd.js → slice-Z8Lc9U1-.js} +46 -4
- package/dist/{cjs/chunks/slice-2_5ax6TZ.js.map → esm/chunks/slice-Z8Lc9U1-.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/store/index.native.js +2 -2
- package/dist/esm/store/index.web.js +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
|
-
var slice = require('./slice-
|
|
4
|
+
var slice = require('./slice-Bu9L_cVR.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-
|
|
14
|
+
//# sourceMappingURL=shared-l1zCzYJr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-l1zCzYJr.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({
|
|
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');
|
|
@@ -6292,4 +6334,4 @@ exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
|
|
|
6292
6334
|
exports.useVerifyUserQuery = useVerifyUserQuery;
|
|
6293
6335
|
exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
|
|
6294
6336
|
exports.withReauth = withReauth;
|
|
6295
|
-
//# sourceMappingURL=slice-
|
|
6337
|
+
//# sourceMappingURL=slice-Bu9L_cVR.js.map
|