powr-sdk-web 6.17.2 → 6.18.1
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/auth/index.js +95 -42
- package/package.json +1 -1
package/dist/auth/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var _AddPhonePanel = _interopRequireDefault(require("../onboarding/AddPhonePanel
|
|
|
11
11
|
var _PhoneInput = _interopRequireDefault(require("../components/PhoneInput"));
|
|
12
12
|
var _utils = require("../onboarding/utils");
|
|
13
13
|
var _profileNameStep = require("../onboarding/steps/profileNameStep");
|
|
14
|
+
var _libphonenumberJs = require("libphonenumber-js");
|
|
14
15
|
var _phone = require("../utils/phone");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
17
|
var cache;
|
|
@@ -32,6 +33,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
32
33
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
33
34
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
34
35
|
var config = require('../config');
|
|
36
|
+
var DEFAULT_WHATSAPP_HELP_URL = 'https://wa.me/919833189399';
|
|
35
37
|
var PowrLogin = function PowrLogin(_ref) {
|
|
36
38
|
var apiUrl = _ref.apiUrl,
|
|
37
39
|
onLogin = _ref.onLogin,
|
|
@@ -46,7 +48,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
46
48
|
_ref$showForgotPasswo = _ref.showForgotPassword,
|
|
47
49
|
showForgotPassword = _ref$showForgotPasswo === void 0 ? true : _ref$showForgotPasswo,
|
|
48
50
|
_ref$passwordResetHel = _ref.passwordResetHelpUrl,
|
|
49
|
-
passwordResetHelpUrl = _ref$passwordResetHel === void 0 ?
|
|
51
|
+
passwordResetHelpUrl = _ref$passwordResetHel === void 0 ? DEFAULT_WHATSAPP_HELP_URL : _ref$passwordResetHel,
|
|
50
52
|
_ref$passwordResetHel2 = _ref.passwordResetHelpLabel,
|
|
51
53
|
passwordResetHelpLabel = _ref$passwordResetHel2 === void 0 ? 'Forgot password? WhatsApp us' : _ref$passwordResetHel2,
|
|
52
54
|
_ref$forgotPasswordCh = _ref.forgotPasswordChannel,
|
|
@@ -73,6 +75,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
73
75
|
var projectId = projectIdProp || config.projectId;
|
|
74
76
|
var resolvedDefaultCountry = (0, _phone.resolveCountry)(defaultCountry, defaultCountryCode);
|
|
75
77
|
var resetChannel = forgotPasswordChannel || (otpReset ? 'otp' : 'whatsapp');
|
|
78
|
+
var helpUrl = passwordResetHelpUrl || DEFAULT_WHATSAPP_HELP_URL;
|
|
76
79
|
var _useState = (0, _react.useState)(function () {
|
|
77
80
|
switch (mode) {
|
|
78
81
|
case 'login':
|
|
@@ -544,28 +547,36 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
544
547
|
setLoginGate('password');
|
|
545
548
|
return _context4.a(2);
|
|
546
549
|
case 8:
|
|
547
|
-
if (!(ok &&
|
|
550
|
+
if (!(ok && !data.exists)) {
|
|
548
551
|
_context4.n = 9;
|
|
549
552
|
break;
|
|
550
553
|
}
|
|
551
|
-
|
|
554
|
+
setIsLogin(false);
|
|
555
|
+
setLoginGate('password');
|
|
552
556
|
return _context4.a(2);
|
|
553
557
|
case 9:
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
558
|
+
if (!(ok && data.exists && !data.hasPassword)) {
|
|
559
|
+
_context4.n = 10;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
setLoginGate('help');
|
|
563
|
+
return _context4.a(2);
|
|
557
564
|
case 10:
|
|
558
|
-
_context4.p = 10;
|
|
559
|
-
_t5 = _context4.v;
|
|
560
565
|
setLoginGate('password');
|
|
566
|
+
_context4.n = 12;
|
|
567
|
+
break;
|
|
561
568
|
case 11:
|
|
562
569
|
_context4.p = 11;
|
|
563
|
-
|
|
564
|
-
|
|
570
|
+
_t5 = _context4.v;
|
|
571
|
+
setLoginGate('password');
|
|
565
572
|
case 12:
|
|
573
|
+
_context4.p = 12;
|
|
574
|
+
setLoading(false);
|
|
575
|
+
return _context4.f(12);
|
|
576
|
+
case 13:
|
|
566
577
|
return _context4.a(2);
|
|
567
578
|
}
|
|
568
|
-
}, _callee4, null, [[2,
|
|
579
|
+
}, _callee4, null, [[2, 11, 12, 13]]);
|
|
569
580
|
}));
|
|
570
581
|
return function continuePhone() {
|
|
571
582
|
return _ref6.apply(this, arguments);
|
|
@@ -788,6 +799,22 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
788
799
|
}
|
|
789
800
|
setError('Your session timed out. Sign in again to add your phone number.');
|
|
790
801
|
};
|
|
802
|
+
var changeNumber = function changeNumber() {
|
|
803
|
+
setIsLogin(true);
|
|
804
|
+
setLoginGate('phone');
|
|
805
|
+
setSmsResetStep(null);
|
|
806
|
+
setError('');
|
|
807
|
+
setSuccess('');
|
|
808
|
+
setFieldErrors({});
|
|
809
|
+
setFormData(function (prev) {
|
|
810
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
811
|
+
password: '',
|
|
812
|
+
confirmPassword: '',
|
|
813
|
+
fullName: ''
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
var numberLocked = !isLogin || loginGate !== 'phone' || Boolean(smsResetStep);
|
|
791
818
|
var smsMobile = function smsMobile() {
|
|
792
819
|
var digits = formData.phoneOrEmail.replace(/\D/g, '');
|
|
793
820
|
if (digits.length === 10) return digits;
|
|
@@ -1168,13 +1195,13 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1168
1195
|
onMouseLeave: function onMouseLeave() {
|
|
1169
1196
|
return setShowTooltip(false);
|
|
1170
1197
|
}
|
|
1171
|
-
}, "PowrAccount")), isLogin ? /*#__PURE__*/_react["default"].createElement("p", {
|
|
1198
|
+
}, "PowrAccount")), isLogin && (loginGate === 'password' || loginGate === 'help' || smsResetStep) ? /*#__PURE__*/_react["default"].createElement("p", {
|
|
1172
1199
|
style: _objectSpread(_objectSpread({}, styles.subtitle), {}, {
|
|
1173
1200
|
marginTop: 6,
|
|
1174
1201
|
fontSize: 14,
|
|
1175
1202
|
fontWeight: 400
|
|
1176
1203
|
})
|
|
1177
|
-
},
|
|
1204
|
+
}, smsResetStep === 'otp' ? 'Enter the code we sent.' : smsResetStep === 'password' ? 'Set a password for next time.' : loginGate === 'help' ? 'WhatsApp us to reset.' : 'Enter your password.') : null, showTooltip && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1178
1205
|
style: styles.tooltip
|
|
1179
1206
|
}, "Secure authentication powered by Lawazia Tech"))), authView === 'add-name' && pendingAuth ? /*#__PURE__*/_react["default"].createElement(_profileNameStep.profileNameStep.Component, {
|
|
1180
1207
|
ctx: {
|
|
@@ -1204,28 +1231,18 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1204
1231
|
}) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("form", {
|
|
1205
1232
|
onSubmit: handleSubmit,
|
|
1206
1233
|
style: styles.form
|
|
1207
|
-
},
|
|
1208
|
-
style: styles.formGroup
|
|
1209
|
-
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
1210
|
-
htmlFor: "fullName",
|
|
1211
|
-
style: styles.label
|
|
1212
|
-
}, "Full Name"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
1213
|
-
type: "text",
|
|
1214
|
-
id: "fullName",
|
|
1215
|
-
name: "fullName",
|
|
1216
|
-
value: formData.fullName,
|
|
1217
|
-
onChange: handleInputChange,
|
|
1218
|
-
style: _objectSpread(_objectSpread({}, styles.input), fieldErrors.fullName ? styles.inputError : {}),
|
|
1219
|
-
placeholder: "Enter your full name",
|
|
1220
|
-
required: true
|
|
1221
|
-
}), fieldErrors.fullName && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1222
|
-
style: styles.fieldError
|
|
1223
|
-
}, fieldErrors.fullName)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
1234
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1224
1235
|
style: styles.formGroup
|
|
1225
1236
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
1226
1237
|
htmlFor: "phoneOrEmail",
|
|
1227
1238
|
style: styles.label
|
|
1228
|
-
}, "Mobile"), /*#__PURE__*/_react["default"].createElement(
|
|
1239
|
+
}, "Mobile"), numberLocked ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
1240
|
+
style: styles.lockedPhone
|
|
1241
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, "+", (0, _libphonenumberJs.getCountryCallingCode)(phoneCountry), " ", formData.phoneOrEmail), /*#__PURE__*/_react["default"].createElement("button", {
|
|
1242
|
+
type: "button",
|
|
1243
|
+
onClick: changeNumber,
|
|
1244
|
+
style: styles.changeNumber
|
|
1245
|
+
}, "Change")) : /*#__PURE__*/_react["default"].createElement(_PhoneInput["default"], {
|
|
1229
1246
|
value: formData.phoneOrEmail,
|
|
1230
1247
|
country: phoneCountry,
|
|
1231
1248
|
onChange: handleRegisterPhoneChange,
|
|
@@ -1250,7 +1267,23 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1250
1267
|
style: styles.successText
|
|
1251
1268
|
}, "Phone number verified successfully!"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
1252
1269
|
id: "recaptcha-container"
|
|
1253
|
-
})),
|
|
1270
|
+
})), !isLogin && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1271
|
+
style: styles.formGroup
|
|
1272
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
1273
|
+
htmlFor: "fullName",
|
|
1274
|
+
style: styles.label
|
|
1275
|
+
}, "Full Name"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
1276
|
+
type: "text",
|
|
1277
|
+
id: "fullName",
|
|
1278
|
+
name: "fullName",
|
|
1279
|
+
value: formData.fullName,
|
|
1280
|
+
onChange: handleInputChange,
|
|
1281
|
+
style: _objectSpread(_objectSpread({}, styles.input), fieldErrors.fullName ? styles.inputError : {}),
|
|
1282
|
+
placeholder: "Enter your full name",
|
|
1283
|
+
required: true
|
|
1284
|
+
}), fieldErrors.fullName && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1285
|
+
style: styles.fieldError
|
|
1286
|
+
}, fieldErrors.fullName)), (!isLogin || loginGate === 'password') && smsResetStep !== 'otp' && smsResetStep !== 'password' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1254
1287
|
style: styles.formGroup
|
|
1255
1288
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
1256
1289
|
htmlFor: "password",
|
|
@@ -1334,8 +1367,8 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1334
1367
|
style: styles.otpSection
|
|
1335
1368
|
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
1336
1369
|
style: styles.otpText
|
|
1337
|
-
}, "
|
|
1338
|
-
href:
|
|
1370
|
+
}, "This number already has a PowrAccount but no password yet. WhatsApp us to reset."), /*#__PURE__*/_react["default"].createElement("a", {
|
|
1371
|
+
href: helpUrl,
|
|
1339
1372
|
target: "_blank",
|
|
1340
1373
|
rel: "noopener noreferrer",
|
|
1341
1374
|
style: _objectSpread(_objectSpread({}, styles.otpButton), {}, {
|
|
@@ -1343,9 +1376,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1343
1376
|
textAlign: 'center',
|
|
1344
1377
|
textDecoration: 'none'
|
|
1345
1378
|
})
|
|
1346
|
-
},
|
|
1347
|
-
style: styles.otpText
|
|
1348
|
-
}, "WhatsApp the app\u2019s support number."), /*#__PURE__*/_react["default"].createElement("button", {
|
|
1379
|
+
}, "WhatsApp us"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
1349
1380
|
type: "button",
|
|
1350
1381
|
onClick: function onClick() {
|
|
1351
1382
|
setLoginGate('password');
|
|
@@ -1434,14 +1465,12 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1434
1465
|
onClick: handleSmsForgotStart,
|
|
1435
1466
|
disabled: otpLoading,
|
|
1436
1467
|
style: styles.forgotPasswordLink
|
|
1437
|
-
}, otpLoading ? 'Sending a code…' : 'Forgot password? Get a code') :
|
|
1438
|
-
href:
|
|
1468
|
+
}, otpLoading ? 'Sending a code…' : 'Forgot password? Get a code') : /*#__PURE__*/_react["default"].createElement("a", {
|
|
1469
|
+
href: helpUrl,
|
|
1439
1470
|
target: "_blank",
|
|
1440
1471
|
rel: "noopener noreferrer",
|
|
1441
1472
|
style: styles.forgotPasswordLink
|
|
1442
|
-
}, passwordResetHelpLabel)
|
|
1443
|
-
style: styles.forgotPasswordLink
|
|
1444
|
-
}, "Forgot password? WhatsApp us"))))), showOtpModal && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1473
|
+
}, passwordResetHelpLabel))))), showOtpModal && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1445
1474
|
style: styles.modalOverlay
|
|
1446
1475
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1447
1476
|
style: styles.modalContent
|
|
@@ -1561,6 +1590,30 @@ var styles = {
|
|
|
1561
1590
|
flexDirection: 'column',
|
|
1562
1591
|
gap: '8px'
|
|
1563
1592
|
},
|
|
1593
|
+
lockedPhone: {
|
|
1594
|
+
display: 'flex',
|
|
1595
|
+
alignItems: 'center',
|
|
1596
|
+
justifyContent: 'space-between',
|
|
1597
|
+
gap: 12,
|
|
1598
|
+
height: 48,
|
|
1599
|
+
padding: '0 14px',
|
|
1600
|
+
border: '2px solid #e5e7eb',
|
|
1601
|
+
borderRadius: 8,
|
|
1602
|
+
background: '#f9fafb',
|
|
1603
|
+
fontSize: 16,
|
|
1604
|
+
fontWeight: 600,
|
|
1605
|
+
color: '#111827'
|
|
1606
|
+
},
|
|
1607
|
+
changeNumber: {
|
|
1608
|
+
border: 'none',
|
|
1609
|
+
background: 'transparent',
|
|
1610
|
+
color: '#ff6b35',
|
|
1611
|
+
fontSize: 14,
|
|
1612
|
+
fontWeight: 600,
|
|
1613
|
+
cursor: 'pointer',
|
|
1614
|
+
padding: 0,
|
|
1615
|
+
flex: '0 0 auto'
|
|
1616
|
+
},
|
|
1564
1617
|
label: {
|
|
1565
1618
|
fontSize: '14px',
|
|
1566
1619
|
fontWeight: '600',
|