@nuskin/ns-product-lib 2.15.3-cx15-9348.1 → 2.16.0-brw-3199.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.15.3-cx15-9348.1",
3
+ "version": "2.16.0-brw-3199.1",
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": {
@@ -1,5 +1,5 @@
1
1
  // This module can be bundled into a package for better reusability.
2
- const axios = require('axios').default;
2
+ const axios = require('axios');
3
3
  const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
4
4
  const config = require('./environment');
5
5
 
@@ -1,4 +1,4 @@
1
- const axios = require('axios').default;
1
+ const axios = require('axios');
2
2
  const { getProductByIdQuery } = require('./query');
3
3
  const ProductStatus = require("../models/productStatus");
4
4
  const CustomerTypes = require('./customerTypes');
@@ -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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const { getConfiguration, getCachedConfigurations } = require('@nuskin/configuration-sdk');
3
- const axios = require("axios").default;
3
+ const axios = require("axios");
4
4
  const contentstack = require('./contentstack/contentstack');
5
5
  const Product = require("./product");
6
6
  const CustomerTypes = require('./models/customerTypes');