@nuskin/ns-product-lib 2.15.3 → 2.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.15.3",
3
+ "version": "2.16.0",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -45,6 +45,8 @@ async function getProduct(id, market, locale, config) {
45
45
  count: 0
46
46
  };
47
47
 
48
+ const okta = parseOktaObject(sessionStorage.oktaTokens);
49
+
48
50
  const payload = {
49
51
  ...defaultPayload,
50
52
  query: getProductByIdQuery,
@@ -52,7 +54,8 @@ async function getProduct(id, market, locale, config) {
52
54
  id,
53
55
  market,
54
56
  locale,
55
- quantity: 1 // set defaul to 1
57
+ ...(okta !== null && { okta }),
58
+ quantity: 1 // set default to 1
56
59
  }
57
60
  }
58
61
 
@@ -518,4 +521,19 @@ function mapPromos(product, isKitBundle = false) {
518
521
 
519
522
  }
520
523
 
524
+ function parseOktaObject(okta) {
525
+ if (!okta || typeof okta !== 'string') {
526
+ return null;
527
+ }
528
+ const data = JSON.parse(okta);
529
+ if (data.accessToken) {
530
+ if (typeof data.accessToken === 'string') {
531
+ return data.accessToken;
532
+ } else {
533
+ return data.accessToken.accessToken;
534
+ }
535
+ }
536
+ }
537
+
538
+
521
539
  module.exports = getProduct;