powr-sdk-web 5.10.5 → 5.10.6
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/sso/index.js +6 -4
- package/package.json +1 -1
package/dist/sso/index.js
CHANGED
|
@@ -84,6 +84,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
84
84
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
85
85
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
86
86
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
87
|
+
var config = require("../config");
|
|
87
88
|
var shellStyle = {
|
|
88
89
|
display: "flex",
|
|
89
90
|
minHeight: "100vh",
|
|
@@ -149,7 +150,7 @@ var btnStyle = {
|
|
|
149
150
|
* Apps keep a thin `/sso` page that renders this with `apiUrl` + `onSuccess`.
|
|
150
151
|
*
|
|
151
152
|
* @param {object} props
|
|
152
|
-
* @param {string} props.apiUrl - Powr
|
|
153
|
+
* @param {string} [props.apiUrl] - Powr host. Defaults to https://powr-api.lawazia.tech
|
|
153
154
|
* @param {string} [props.appName]
|
|
154
155
|
* @param {boolean} [props.ready=true] - Wait (e.g. auth hydrate) before exchanging code
|
|
155
156
|
* @param {string} [props.loginHref="/login"]
|
|
@@ -182,6 +183,7 @@ function PowrBaseSso(_ref) {
|
|
|
182
183
|
})[0];
|
|
183
184
|
var loginId = loginIdProp !== undefined ? loginIdProp : fromUrl.loginId;
|
|
184
185
|
var next = nextProp !== undefined ? nextProp : fromUrl.next;
|
|
186
|
+
var powrApi = String(apiUrl || config.defaultPowrUrl || "").replace(/\/$/, "");
|
|
185
187
|
var _useState = (0, _react.useState)(loginId ? null : "Missing login link"),
|
|
186
188
|
_useState2 = _slicedToArray(_useState, 2),
|
|
187
189
|
error = _useState2[0],
|
|
@@ -194,10 +196,10 @@ function PowrBaseSso(_ref) {
|
|
|
194
196
|
var onSuccessRef = (0, _react.useRef)(onSuccess);
|
|
195
197
|
onSuccessRef.current = onSuccess;
|
|
196
198
|
(0, _react.useEffect)(function () {
|
|
197
|
-
if (!loginId || !ready || !
|
|
199
|
+
if (!loginId || !ready || !powrApi || started.current) return;
|
|
198
200
|
started.current = true;
|
|
199
201
|
setBusy(true);
|
|
200
|
-
(0, _api.loginWithCode)(
|
|
202
|
+
(0, _api.loginWithCode)(powrApi, loginId).then(/*#__PURE__*/function () {
|
|
201
203
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data) {
|
|
202
204
|
var cb;
|
|
203
205
|
return _regenerator().w(function (_context) {
|
|
@@ -227,7 +229,7 @@ function PowrBaseSso(_ref) {
|
|
|
227
229
|
setError((err === null || err === void 0 ? void 0 : err.message) || "Could not finish sign-in");
|
|
228
230
|
setBusy(false);
|
|
229
231
|
});
|
|
230
|
-
}, [loginId, next, ready,
|
|
232
|
+
}, [loginId, next, ready, powrApi]);
|
|
231
233
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
232
234
|
style: shellStyle
|
|
233
235
|
}, /*#__PURE__*/_react["default"].createElement("style", null, "@keyframes powr-sso-spin{to{transform:rotate(360deg)}}"), /*#__PURE__*/_react["default"].createElement("p", {
|