@nuskin/ns-product-lib 2.15.3 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/graph-ql/product.js +19 -1
package/package.json
CHANGED
package/src/graph-ql/product.js
CHANGED
@@ -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
|
-
|
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;
|