@paypal/merchant-onboarding-sdk 1.0.3 → 1.0.4
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/README.md +2 -2
- package/dist/servicing.js +214 -15
- package/dist/v1/js/development.servicing.js +216 -17
- package/dist/v1/js/sandbox.servicing.js +216 -17
- package/dist/v1/js/servicing.js +1 -1
- package/dist/v1/js/staging.servicing.js +216 -17
- package/dist/v1/js/te-e2e-embedded-path-testing.servicing.js +216 -17
- package/dist/v1/js/te-eop-release.servicing.js +216 -17
- package/dist/v1/js/te-hybrid-path-integration.servicing.js +216 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,8 +45,8 @@ OR
|
|
|
45
45
|
import { servicing } from "@paypal/merchant-onboarding-sdk/servicing";
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
concurrently
|
|
48
|
+
Disclaimer: There may be side-effects of rendering both onboarding and servicing
|
|
49
|
+
concurrently due to conflicts in the auth sessions of each
|
|
50
50
|
|
|
51
51
|
#### Usage NOTE
|
|
52
52
|
|
package/dist/servicing.js
CHANGED
|
@@ -54559,7 +54559,7 @@ var jsx_pragmatic = __webpack_require__(151);
|
|
|
54559
54559
|
|
|
54560
54560
|
|
|
54561
54561
|
var createPopup = zoid.create({
|
|
54562
|
-
tag:
|
|
54562
|
+
tag: 'zoid-servicing',
|
|
54563
54563
|
url: function url(_ref) {
|
|
54564
54564
|
var props = _ref.props;
|
|
54565
54565
|
return props.url;
|
|
@@ -54575,19 +54575,19 @@ var createPopup = zoid.create({
|
|
|
54575
54575
|
defaultContext: zoid.CONTEXT.POPUP,
|
|
54576
54576
|
props: {
|
|
54577
54577
|
onComplete: {
|
|
54578
|
-
type:
|
|
54578
|
+
type: 'function',
|
|
54579
54579
|
required: true
|
|
54580
54580
|
},
|
|
54581
54581
|
onError: {
|
|
54582
|
-
type:
|
|
54582
|
+
type: 'function',
|
|
54583
54583
|
required: false
|
|
54584
54584
|
},
|
|
54585
54585
|
onClose: {
|
|
54586
|
-
type:
|
|
54586
|
+
type: 'function',
|
|
54587
54587
|
required: true
|
|
54588
54588
|
},
|
|
54589
54589
|
getAccessToken: {
|
|
54590
|
-
type:
|
|
54590
|
+
type: 'function',
|
|
54591
54591
|
required: false
|
|
54592
54592
|
}
|
|
54593
54593
|
},
|
|
@@ -54609,19 +54609,19 @@ var createPopup = zoid.create({
|
|
|
54609
54609
|
ev.stopPropagation();
|
|
54610
54610
|
return focus();
|
|
54611
54611
|
}
|
|
54612
|
-
return jsx_pragmatic.node(
|
|
54612
|
+
return jsx_pragmatic.node('div', {
|
|
54613
54613
|
id: uid,
|
|
54614
54614
|
onClick: focusComponent,
|
|
54615
54615
|
"class": "".concat(tag, " ").concat(tag, "-context-").concat(context, " ").concat(tag, "-focus")
|
|
54616
|
-
}, jsx_pragmatic.node(
|
|
54617
|
-
href:
|
|
54616
|
+
}, jsx_pragmatic.node('a', {
|
|
54617
|
+
href: '#',
|
|
54618
54618
|
onClick: closeComponent,
|
|
54619
54619
|
"class": "".concat(tag, "-close")
|
|
54620
|
-
}), jsx_pragmatic.node(
|
|
54621
|
-
href:
|
|
54620
|
+
}), jsx_pragmatic.node('a', {
|
|
54621
|
+
href: '#',
|
|
54622
54622
|
onClick: closeComponent,
|
|
54623
54623
|
"class": "".concat(tag, "-close")
|
|
54624
|
-
}), jsx_pragmatic.node(
|
|
54624
|
+
}), jsx_pragmatic.node('style', null, "\n #".concat(uid, " {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.8);\n }\n #").concat(uid, ".").concat(tag, "-context-").concat(zoid.CONTEXT.POPUP, " {\n cursor: pointer;\n }\n #").concat(uid, " .").concat(tag, "-close {\n position: absolute;\n right: 16px;\n top: 16px;\n width: 16px;\n height: 16px;\n opacity: 0.6;\n }\n #").concat(uid, " .").concat(tag, "-close:hover {\n opacity: 1;\n }\n #").concat(uid, " .").concat(tag, "-close:before,\n #").concat(uid, " .").concat(tag, "-close:after {\n position: absolute;\n left: 8px;\n content: ' ';\n height: 16px;\n width: 2px;\n background-color: white;\n }\n #").concat(uid, " .").concat(tag, "-close:before {\n transform: rotate(45deg);\n }\n #").concat(uid, " .").concat(tag, "-close:after {\n transform: rotate(-45deg);\n }\n "))).render(jsx_pragmatic.dom({
|
|
54625
54625
|
doc: doc
|
|
54626
54626
|
}));
|
|
54627
54627
|
}
|
|
@@ -54642,7 +54642,7 @@ var createZoidPopup = function createZoidPopup(_ref4) {
|
|
|
54642
54642
|
width: width,
|
|
54643
54643
|
height: height,
|
|
54644
54644
|
url: url
|
|
54645
|
-
}).render(
|
|
54645
|
+
}).render('#zoidFrame', zoid.CONTEXT.POPUP);
|
|
54646
54646
|
};
|
|
54647
54647
|
/* harmony default export */ const zoidUtils = (createZoidPopup);
|
|
54648
54648
|
;// ./src/components/ZoidPopup.js
|
|
@@ -54673,7 +54673,7 @@ var ZoidPopUp = function ZoidPopUp(props) {
|
|
|
54673
54673
|
};
|
|
54674
54674
|
var onComplete = function onComplete(data) {
|
|
54675
54675
|
var _document$getElements;
|
|
54676
|
-
(_document$getElements = document.getElementsByClassName('zoid-
|
|
54676
|
+
(_document$getElements = document.getElementsByClassName('zoid-servicing-close')) === null || _document$getElements === void 0 || (_document$getElements = _document$getElements[0]) === null || _document$getElements === void 0 || _document$getElements.click();
|
|
54677
54677
|
onCompleteCallBack(data);
|
|
54678
54678
|
};
|
|
54679
54679
|
(0,react.useEffect)(function () {
|
|
@@ -62487,6 +62487,7 @@ function RemoteApp_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
62487
62487
|
|
|
62488
62488
|
|
|
62489
62489
|
|
|
62490
|
+
|
|
62490
62491
|
var RemoteApp = function RemoteApp(props) {
|
|
62491
62492
|
var _props$federated = props.federated,
|
|
62492
62493
|
url = _props$federated.url,
|
|
@@ -62525,8 +62526,58 @@ var RemoteApp = function RemoteApp(props) {
|
|
|
62525
62526
|
_checkSessionId();
|
|
62526
62527
|
});
|
|
62527
62528
|
};
|
|
62529
|
+
var handleStepUpRequired = function handleStepUpRequired(event) {
|
|
62530
|
+
var _ref = event.detail || {},
|
|
62531
|
+
link = _ref.link;
|
|
62532
|
+
console.log('[SDK RemoteApp] Step-up authentication required', {
|
|
62533
|
+
link: link
|
|
62534
|
+
});
|
|
62535
|
+
if (link) {
|
|
62536
|
+
// Create a div for zoid if it doesn't exist
|
|
62537
|
+
if (!document.getElementById('zoidFrame')) {
|
|
62538
|
+
var zoidFrame = document.createElement('div');
|
|
62539
|
+
zoidFrame.id = 'zoidFrame';
|
|
62540
|
+
document.body.appendChild(zoidFrame);
|
|
62541
|
+
}
|
|
62542
|
+
|
|
62543
|
+
// Create return URI pointing to the step-up callback page in fundsmanagement
|
|
62544
|
+
var returnUri = "https://".concat(getHost(env), "/fundsmanagement/step-up-complete");
|
|
62545
|
+
var separator = link.includes('?') ? '&' : '?';
|
|
62546
|
+
|
|
62547
|
+
// TODO: Adapte to other flows
|
|
62548
|
+
var urlWithReturn = "".concat(link).concat(separator, "flowId=hawk&flowContext=transfer&returnUri=").concat(encodeURIComponent(returnUri));
|
|
62549
|
+
console.log('[SDK RemoteApp] Opening step-up popup with URL:', urlWithReturn);
|
|
62550
|
+
zoidUtils({
|
|
62551
|
+
url: urlWithReturn,
|
|
62552
|
+
width: 768,
|
|
62553
|
+
height: 1200,
|
|
62554
|
+
onComplete: function onComplete() {
|
|
62555
|
+
console.log('[SDK RemoteApp] Step-up authentication completed via zoid');
|
|
62556
|
+
// Dispatch event for step-up completion (manual-transfer context will handle the flow)
|
|
62557
|
+
window.postMessage({
|
|
62558
|
+
type: 'STEP_UP_COMPLETED'
|
|
62559
|
+
}, '*');
|
|
62560
|
+
},
|
|
62561
|
+
onClose: function onClose() {
|
|
62562
|
+
console.log('[SDK RemoteApp] Step-up popup closed');
|
|
62563
|
+
// Dispatch event for popup close
|
|
62564
|
+
|
|
62565
|
+
window.postMessage({
|
|
62566
|
+
type: 'STEP_UP_CLOSED'
|
|
62567
|
+
}, '*');
|
|
62568
|
+
},
|
|
62569
|
+
onError: function onError(error) {
|
|
62570
|
+
console.error('[SDK RemoteApp] Step-up authentication error', error);
|
|
62571
|
+
// Dispatch event for step-up error
|
|
62572
|
+
window.postMessage({
|
|
62573
|
+
type: 'STEP_UP_ERROR'
|
|
62574
|
+
}, '*');
|
|
62575
|
+
}
|
|
62576
|
+
});
|
|
62577
|
+
}
|
|
62578
|
+
};
|
|
62528
62579
|
var fetchData = /*#__PURE__*/function () {
|
|
62529
|
-
var
|
|
62580
|
+
var _ref2 = RemoteApp_asyncToGenerator(/*#__PURE__*/RemoteApp_regeneratorRuntime().mark(function _callee() {
|
|
62530
62581
|
var data, jsonData, errorMessage;
|
|
62531
62582
|
return RemoteApp_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62532
62583
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -62579,10 +62630,18 @@ var RemoteApp = function RemoteApp(props) {
|
|
|
62579
62630
|
}, _callee, null, [[2, 19]]);
|
|
62580
62631
|
}));
|
|
62581
62632
|
return function fetchData() {
|
|
62582
|
-
return
|
|
62633
|
+
return _ref2.apply(this, arguments);
|
|
62583
62634
|
};
|
|
62584
62635
|
}();
|
|
62636
|
+
|
|
62637
|
+
// Add event listener for step-up authentication
|
|
62638
|
+
window.addEventListener('STEP_UP_REQUIRED', handleStepUpRequired);
|
|
62585
62639
|
fetchData();
|
|
62640
|
+
|
|
62641
|
+
// Cleanup event listener on unmount
|
|
62642
|
+
return function () {
|
|
62643
|
+
window.removeEventListener('STEP_UP_REQUIRED', handleStepUpRequired);
|
|
62644
|
+
};
|
|
62586
62645
|
}, []);
|
|
62587
62646
|
var buttonOptions = {
|
|
62588
62647
|
title: 'Try Again',
|
|
@@ -62673,6 +62732,10 @@ var EmbeddedExperience = function EmbeddedExperience(props) {
|
|
|
62673
62732
|
if (isLoggedIn && hasEmbeddedSessionId && !isAccountSwitch) {
|
|
62674
62733
|
setStatus(STATUS.LOGGED_IN);
|
|
62675
62734
|
setIsLoading(true);
|
|
62735
|
+
} else if (isAccountSwitch && !getAccessToken) {
|
|
62736
|
+
// account switch is disabled when getAccessToken is not provided
|
|
62737
|
+
setStatus(STATUS.ERROR);
|
|
62738
|
+
setIsLoading(false);
|
|
62676
62739
|
} else {
|
|
62677
62740
|
setStatus(STATUS.PROMPT_LOGIN);
|
|
62678
62741
|
setIsLoading(false);
|
|
@@ -67291,6 +67354,140 @@ var installXhrInterceptor = function installXhrInterceptor(env) {
|
|
|
67291
67354
|
return originalSend.apply(this, arguments);
|
|
67292
67355
|
};
|
|
67293
67356
|
};
|
|
67357
|
+
;// ./src/utils/error-matcher.js
|
|
67358
|
+
var extractStepUpLinkWithRegex = function extractStepUpLinkWithRegex(payloadString) {
|
|
67359
|
+
var specificPattern = /"[^"]*":\s*"(https?:\/\/[^"]*(?:authflow|step[Uu]p|authentication)[^"]*)"/;
|
|
67360
|
+
var match = payloadString.match(specificPattern);
|
|
67361
|
+
if (match && match[1]) {
|
|
67362
|
+
return match[1];
|
|
67363
|
+
}
|
|
67364
|
+
|
|
67365
|
+
// Fallback to any href URL
|
|
67366
|
+
var fallbackPattern = /"href":\s*"(https?:\/\/[^"]+)"/;
|
|
67367
|
+
var fallbackMatch = payloadString.match(fallbackPattern);
|
|
67368
|
+
return fallbackMatch ? fallbackMatch[1] : null;
|
|
67369
|
+
};
|
|
67370
|
+
var matchStepUpError = function matchStepUpError(responsePayload) {
|
|
67371
|
+
// Convert entire response payload to JSON string for regex matching
|
|
67372
|
+
var payloadString = JSON.stringify(responsePayload);
|
|
67373
|
+
|
|
67374
|
+
// Regex patterns to match step-up requirements
|
|
67375
|
+
var stepUpPatterns = [/STEP_UP_AUTHENTICATION_REQUIRED/, /STEP_UP_REQUIRED/, /ERROR_SENDER_AUTHENTICATION_REQUIRED/, /RISK_DENIED/, /STEPUP_AUTH/, /authRequired/, /STEPUP_ERROR/, /stepUpURL/];
|
|
67376
|
+
|
|
67377
|
+
// Check if any step-up pattern matches
|
|
67378
|
+
var requiresStepUp = stepUpPatterns.some(function (pattern) {
|
|
67379
|
+
return pattern.test(payloadString);
|
|
67380
|
+
});
|
|
67381
|
+
if (requiresStepUp) {
|
|
67382
|
+
// Extract link using regex from the stringified payload
|
|
67383
|
+
var link = extractStepUpLinkWithRegex(payloadString);
|
|
67384
|
+
return {
|
|
67385
|
+
requiresStepUp: true,
|
|
67386
|
+
link: link
|
|
67387
|
+
};
|
|
67388
|
+
}
|
|
67389
|
+
return {
|
|
67390
|
+
requiresStepUp: false
|
|
67391
|
+
};
|
|
67392
|
+
};
|
|
67393
|
+
;// ./src/utils/step-up-interceptor.js
|
|
67394
|
+
function step_up_interceptor_typeof(o) { "@babel/helpers - typeof"; return step_up_interceptor_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, step_up_interceptor_typeof(o); }
|
|
67395
|
+
function step_up_interceptor_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ step_up_interceptor_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == step_up_interceptor_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(step_up_interceptor_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
67396
|
+
function step_up_interceptor_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
67397
|
+
function step_up_interceptor_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { step_up_interceptor_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { step_up_interceptor_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
67398
|
+
/**
|
|
67399
|
+
* Fetch Interceptor for Embedded SDK
|
|
67400
|
+
*
|
|
67401
|
+
* Automatically add sdk-session-id header to all requests
|
|
67402
|
+
* going to PayPal domains when sessionId exists in localStorage.
|
|
67403
|
+
*
|
|
67404
|
+
* This ensures all flows hosted on paypal.com receive the embedded
|
|
67405
|
+
* session tracking header without requiring manual header management.
|
|
67406
|
+
*/
|
|
67407
|
+
|
|
67408
|
+
|
|
67409
|
+
var RISKY_ROUTES = ["/graphql", "/phone/confirm", "/phone/validateCode"];
|
|
67410
|
+
|
|
67411
|
+
/**
|
|
67412
|
+
* Install fetch interceptor
|
|
67413
|
+
*
|
|
67414
|
+
* Wraps the native fetch function to automatically inject
|
|
67415
|
+
* sdk-session-id header for PayPal domain requests.
|
|
67416
|
+
*/
|
|
67417
|
+
var installStepUpInterceptor = function installStepUpInterceptor() {
|
|
67418
|
+
// Store reference to original fetch
|
|
67419
|
+
var originalFetch = window.fetch;
|
|
67420
|
+
|
|
67421
|
+
// Override window.fetch
|
|
67422
|
+
window.fetch = /*#__PURE__*/function () {
|
|
67423
|
+
var _ref = step_up_interceptor_asyncToGenerator(/*#__PURE__*/step_up_interceptor_regeneratorRuntime().mark(function _callee(url) {
|
|
67424
|
+
var options,
|
|
67425
|
+
response,
|
|
67426
|
+
clone,
|
|
67427
|
+
data,
|
|
67428
|
+
stepUpMatch,
|
|
67429
|
+
stepUpEvent,
|
|
67430
|
+
_args = arguments;
|
|
67431
|
+
return step_up_interceptor_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67432
|
+
while (1) switch (_context.prev = _context.next) {
|
|
67433
|
+
case 0:
|
|
67434
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
67435
|
+
if (!RISKY_ROUTES.some(function (route) {
|
|
67436
|
+
return url.includes(route);
|
|
67437
|
+
})) {
|
|
67438
|
+
_context.next = 23;
|
|
67439
|
+
break;
|
|
67440
|
+
}
|
|
67441
|
+
console.info("[SDK Step Up Interceptor] Checking for Step Up");
|
|
67442
|
+
_context.next = 5;
|
|
67443
|
+
return originalFetch.call(this, url, options);
|
|
67444
|
+
case 5:
|
|
67445
|
+
response = _context.sent;
|
|
67446
|
+
clone = response.clone();
|
|
67447
|
+
_context.prev = 7;
|
|
67448
|
+
_context.next = 10;
|
|
67449
|
+
return clone.json();
|
|
67450
|
+
case 10:
|
|
67451
|
+
data = _context.sent;
|
|
67452
|
+
stepUpMatch = matchStepUpError(data);
|
|
67453
|
+
if (!(stepUpMatch !== null && stepUpMatch !== void 0 && stepUpMatch.requiresStepUp)) {
|
|
67454
|
+
_context.next = 17;
|
|
67455
|
+
break;
|
|
67456
|
+
}
|
|
67457
|
+
console.info("[SDK Step Up Interceptor] Dispatching STEP_UP_REQUIRED event", {
|
|
67458
|
+
link: stepUpMatch === null || stepUpMatch === void 0 ? void 0 : stepUpMatch.link
|
|
67459
|
+
});
|
|
67460
|
+
stepUpEvent = new CustomEvent("STEP_UP_REQUIRED", {
|
|
67461
|
+
detail: {
|
|
67462
|
+
link: stepUpMatch === null || stepUpMatch === void 0 ? void 0 : stepUpMatch.link
|
|
67463
|
+
}
|
|
67464
|
+
});
|
|
67465
|
+
window.dispatchEvent(stepUpEvent);
|
|
67466
|
+
|
|
67467
|
+
// Stop the request and don't return response to caller
|
|
67468
|
+
return _context.abrupt("return", Promise.reject(new Error("STEP_UP_REQUIRED")));
|
|
67469
|
+
case 17:
|
|
67470
|
+
return _context.abrupt("return", response);
|
|
67471
|
+
case 20:
|
|
67472
|
+
_context.prev = 20;
|
|
67473
|
+
_context.t0 = _context["catch"](7);
|
|
67474
|
+
throw new Error("[SDK Step Up Interceptor] Error on Response", _context.t0);
|
|
67475
|
+
case 23:
|
|
67476
|
+
return _context.abrupt("return", originalFetch.call(this, url, options));
|
|
67477
|
+
case 24:
|
|
67478
|
+
case "end":
|
|
67479
|
+
return _context.stop();
|
|
67480
|
+
}
|
|
67481
|
+
}, _callee, this, [[7, 20]]);
|
|
67482
|
+
}));
|
|
67483
|
+
return function (_x) {
|
|
67484
|
+
return _ref.apply(this, arguments);
|
|
67485
|
+
};
|
|
67486
|
+
}();
|
|
67487
|
+
};
|
|
67488
|
+
/* harmony default export */ const step_up_interceptor = ({
|
|
67489
|
+
installStepUpInterceptor: installStepUpInterceptor
|
|
67490
|
+
});
|
|
67294
67491
|
;// ./src/config/moduleConfigs.js
|
|
67295
67492
|
/**
|
|
67296
67493
|
* Module configurations for the merchant onboarding SDK
|
|
@@ -67427,6 +67624,7 @@ var federationModuleConfigs = {
|
|
|
67427
67624
|
|
|
67428
67625
|
|
|
67429
67626
|
|
|
67627
|
+
|
|
67430
67628
|
var servicing = {};
|
|
67431
67629
|
var setupModules = function setupModules(window, document) {
|
|
67432
67630
|
Object.keys(iframeModuleConfigs).forEach(function (module) {
|
|
@@ -67449,6 +67647,7 @@ var setupModules = function setupModules(window, document) {
|
|
|
67449
67647
|
installFetchInterceptor(env);
|
|
67450
67648
|
installAxiosInterceptor(env);
|
|
67451
67649
|
installXhrInterceptor(env);
|
|
67650
|
+
installStepUpInterceptor();
|
|
67452
67651
|
var targetElement = document.getElementById(targetElementId);
|
|
67453
67652
|
if (!targetElement) {
|
|
67454
67653
|
console.error('Target element not found');
|