auth0-lock 12.3.1 → 12.5.0
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/.github/actions/get-prerelease/action.yml +30 -0
- package/.github/actions/get-release-notes/action.yml +42 -0
- package/.github/actions/get-version/action.yml +21 -0
- package/.github/actions/npm-publish/action.yml +53 -0
- package/.github/actions/release-create/action.yml +47 -0
- package/.github/actions/tag-exists/action.yml +36 -0
- package/.github/workflows/codeql.yml +3 -3
- package/.github/workflows/npm-release.yml +83 -0
- package/.github/workflows/release.yml +25 -0
- package/.github/workflows/test.yml +8 -8
- package/.shiprc +3 -2
- package/.version +1 -0
- package/CHANGELOG.md +14 -0
- package/DEVELOPMENT.md +8 -8
- package/Makefile +4 -4
- package/README.md +1 -1
- package/lib/CSSCore.js +0 -1
- package/lib/__tests__/connection/database/actions.js +1 -2
- package/lib/__tests__/connection/database/index.js +1 -1
- package/lib/__tests__/connection/database/login_pane.js +1 -1
- package/lib/__tests__/connection/database/password_reset_confirmation.js +1 -1
- package/lib/__tests__/connection/database/signed_up_confirmation.js +1 -1
- package/lib/__tests__/connection/enterprise/actions.js +1 -1
- package/lib/__tests__/connection/enterprise/hrd_pane.js +1 -1
- package/lib/__tests__/connection/enterprise/hrd_screen.js +1 -1
- package/lib/__tests__/connection/enterprise/quick_auth_screen.js +1 -1
- package/lib/__tests__/connection/passwordless/ask_vcode.js +1 -1
- package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +1 -1
- package/lib/__tests__/core/actions.js +3 -3
- package/lib/__tests__/core/remote_data.js +1 -1
- package/lib/__tests__/core/signed_in_confirmation.js +1 -1
- package/lib/__tests__/core/sso/last_login_screen.js +2 -2
- package/lib/__tests__/core/tenant.js +2 -2
- package/lib/__tests__/core/web_api.js +2 -2
- package/lib/__tests__/engine/classic.js +2 -2
- package/lib/__tests__/field/captcha/auth0_v2.js +28 -0
- package/lib/__tests__/field/captcha/third_party_captcha.js +261 -0
- package/lib/__tests__/field/captcha.js +22 -0
- package/lib/__tests__/field/field.js +2 -2
- package/lib/__tests__/i18n.js +1 -1
- package/lib/__tests__/testUtils.js +3 -3
- package/lib/__tests__/ui/box/chrome.js +2 -2
- package/lib/__tests__/ui/box/confirmation_pane.js +1 -1
- package/lib/avatar.js +1 -1
- package/lib/connection/captcha.js +54 -20
- package/lib/connection/database/actions.js +19 -8
- package/lib/connection/database/index.js +1 -1
- package/lib/connection/database/login_pane.js +12 -14
- package/lib/connection/database/login_sign_up_tabs.js +14 -18
- package/lib/connection/database/mfa_pane.js +9 -11
- package/lib/connection/database/password_reset_confirmation.js +10 -12
- package/lib/connection/database/reset_password.js +13 -17
- package/lib/connection/database/reset_password_pane.js +21 -13
- package/lib/connection/database/signed_up_confirmation.js +10 -12
- package/lib/connection/enterprise/actions.js +5 -5
- package/lib/connection/enterprise/hrd_pane.js +11 -13
- package/lib/connection/enterprise/hrd_screen.js +10 -12
- package/lib/connection/enterprise/kerberos_screen.js +10 -12
- package/lib/connection/enterprise/quick_auth_screen.js +10 -12
- package/lib/connection/enterprise.js +1 -1
- package/lib/connection/passwordless/actions.js +8 -8
- package/lib/connection/passwordless/ask_vcode.js +9 -11
- package/lib/connection/passwordless/email_sent_confirmation.js +17 -23
- package/lib/connection/passwordless/index.js +1 -1
- package/lib/connection/social/index.js +1 -1
- package/lib/core/actions.js +3 -3
- package/lib/core/client/index.js +3 -4
- package/lib/core/client/settings.js +1 -1
- package/lib/core/error_screen.js +10 -12
- package/lib/core/index.js +13 -4
- package/lib/core/loading_screen.js +13 -17
- package/lib/core/remote_data.js +9 -1
- package/lib/core/screen.js +4 -5
- package/lib/core/signed_in_confirmation.js +10 -12
- package/lib/core/sso/last_login_screen.js +10 -12
- package/lib/core/tenant/index.js +3 -4
- package/lib/core/tenant/settings.js +1 -1
- package/lib/core/web_api/helper.js +4 -4
- package/lib/core/web_api/p2_api.js +9 -4
- package/lib/core/web_api.js +8 -4
- package/lib/core.js +13 -15
- package/lib/engine/classic/login.js +10 -12
- package/lib/engine/classic/mfa_login_screen.js +10 -12
- package/lib/engine/classic/sign_up_pane.js +11 -13
- package/lib/engine/classic/sign_up_screen.js +10 -12
- package/lib/engine/classic.js +4 -5
- package/lib/engine/passwordless/social_or_email_login_screen.js +12 -14
- package/lib/engine/passwordless/social_or_phone_number_login_screen.js +12 -14
- package/lib/engine/passwordless.js +4 -5
- package/lib/field/captcha/captcha_pane.js +17 -16
- package/lib/field/captcha/third_party_captcha.js +79 -39
- package/lib/field/custom_input.js +1 -1
- package/lib/field/email/email_pane.js +10 -12
- package/lib/field/email.js +1 -1
- package/lib/field/index.js +1 -1
- package/lib/field/mfa-code/mfa_code_pane.js +10 -12
- package/lib/field/password/password_pane.js +12 -14
- package/lib/field/phone-number/phone_number_pane.js +11 -13
- package/lib/field/social/event.js +1 -1
- package/lib/field/social/social_buttons_pane.js +10 -12
- package/lib/field/username/username_pane.js +10 -12
- package/lib/field/vcode/vcode_pane.js +12 -14
- package/lib/i18n/af.js +3 -1
- package/lib/i18n/ar.js +3 -1
- package/lib/i18n/az.js +3 -1
- package/lib/i18n/bg.js +3 -1
- package/lib/i18n/ca.js +3 -1
- package/lib/i18n/cs.js +3 -1
- package/lib/i18n/da.js +3 -1
- package/lib/i18n/de.js +3 -1
- package/lib/i18n/el.js +3 -1
- package/lib/i18n/en.js +3 -1
- package/lib/i18n/es.js +3 -1
- package/lib/i18n/et.js +3 -1
- package/lib/i18n/fa.js +3 -1
- package/lib/i18n/fi.js +3 -1
- package/lib/i18n/fr.js +3 -1
- package/lib/i18n/he.js +3 -1
- package/lib/i18n/hr.js +3 -1
- package/lib/i18n/hu.js +3 -1
- package/lib/i18n/id.js +3 -1
- package/lib/i18n/it.js +3 -1
- package/lib/i18n/ja.js +3 -1
- package/lib/i18n/ko.js +3 -1
- package/lib/i18n/lt.js +3 -1
- package/lib/i18n/lv.js +3 -1
- package/lib/i18n/ms.js +3 -1
- package/lib/i18n/nb.js +3 -1
- package/lib/i18n/nl.js +3 -1
- package/lib/i18n/nn.js +3 -1
- package/lib/i18n/no.js +3 -1
- package/lib/i18n/pl.js +3 -1
- package/lib/i18n/pt-br.js +3 -1
- package/lib/i18n/pt.js +3 -1
- package/lib/i18n/ro.js +3 -1
- package/lib/i18n/ru.js +3 -1
- package/lib/i18n/sk.js +3 -1
- package/lib/i18n/sl.js +3 -1
- package/lib/i18n/sr.js +3 -1
- package/lib/i18n/sv.js +3 -1
- package/lib/i18n/tr.js +3 -1
- package/lib/i18n/ua.js +3 -1
- package/lib/i18n/uk.js +3 -1
- package/lib/i18n/vi.js +3 -1
- package/lib/i18n/zh-tw.js +3 -1
- package/lib/i18n/zh.js +3 -1
- package/lib/i18n.js +2 -2
- package/lib/lock.js +10 -11
- package/lib/passwordless.js +10 -11
- package/lib/quick-auth/actions.js +3 -3
- package/lib/sync.js +1 -1
- package/lib/ui/box/chrome.js +13 -17
- package/lib/ui/box/confirmation_pane.js +1 -1
- package/lib/ui/box/container.js +11 -14
- package/lib/ui/box/global_message.js +9 -11
- package/lib/ui/box/header.js +19 -27
- package/lib/ui/box/multisize_slide.js +13 -17
- package/lib/ui/box.js +4 -6
- package/lib/ui/input/captcha_input.js +14 -16
- package/lib/ui/input/checkbox_input.js +9 -11
- package/lib/ui/input/email_input.js +10 -12
- package/lib/ui/input/input_wrap.js +9 -11
- package/lib/ui/input/location_input.js +9 -11
- package/lib/ui/input/mfa_code_input.js +10 -12
- package/lib/ui/input/password/password_strength.js +15 -21
- package/lib/ui/input/password_input.js +11 -13
- package/lib/ui/input/phone_number_input.js +10 -12
- package/lib/ui/input/select_input.js +9 -11
- package/lib/ui/input/text_input.js +10 -12
- package/lib/ui/input/username_input.js +10 -12
- package/lib/ui/input/vcode_input.js +10 -12
- package/lib/ui/list.js +16 -22
- package/lib/utils/atom.js +3 -4
- package/lib/utils/cache.js +3 -4
- package/lib/utils/jsonp_utils.js +3 -4
- package/package.json +4 -3
- package/.github/workflows/publish.yml +0 -121
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _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; }, _typeof(o); }
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _enzyme = require("enzyme");
|
|
6
|
+
var _testUtils = require("react-dom/test-utils");
|
|
7
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
8
|
+
var l = _interopRequireWildcard(require("../../../core/index"));
|
|
9
|
+
var _third_party_captcha = require("../../../field/captcha/third_party_captcha");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
var createLockMock = function createLockMock() {
|
|
20
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
21
|
+
_ref$provider = _ref.provider,
|
|
22
|
+
provider = _ref$provider === void 0 ? 'auth0' : _ref$provider,
|
|
23
|
+
_ref$required = _ref.required,
|
|
24
|
+
required = _ref$required === void 0 ? true : _ref$required,
|
|
25
|
+
_ref$siteKey = _ref.siteKey,
|
|
26
|
+
siteKey = _ref$siteKey === void 0 ? '' : _ref$siteKey,
|
|
27
|
+
_ref$clientSubdomain = _ref.clientSubdomain,
|
|
28
|
+
clientSubdomain = _ref$clientSubdomain === void 0 ? '' : _ref$clientSubdomain;
|
|
29
|
+
return _immutable.default.fromJS({
|
|
30
|
+
id: '__lock-id__',
|
|
31
|
+
core: {
|
|
32
|
+
captcha: {
|
|
33
|
+
provider: provider,
|
|
34
|
+
siteKey: siteKey,
|
|
35
|
+
clientSubdomain: clientSubdomain,
|
|
36
|
+
required: required
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
describe('ThirdPartyCaptcha', function () {
|
|
42
|
+
var prevWindow;
|
|
43
|
+
var counter = 0;
|
|
44
|
+
beforeAll(function () {
|
|
45
|
+
prevWindow = global.window;
|
|
46
|
+
global.window.grecaptcha = {
|
|
47
|
+
render: jest.fn(),
|
|
48
|
+
enterprise: {
|
|
49
|
+
render: jest.fn()
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
global.window.hcaptcha = {
|
|
53
|
+
render: jest.fn()
|
|
54
|
+
};
|
|
55
|
+
global.window.friendlyChallenge = {
|
|
56
|
+
WidgetInstance: jest.fn().mockImplementation(function () {
|
|
57
|
+
var _jest;
|
|
58
|
+
return (_jest = jest).fn.apply(_jest, arguments);
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
global.window.turnstile = {
|
|
62
|
+
render: jest.fn(),
|
|
63
|
+
reset: function reset() {
|
|
64
|
+
var _global$window$turnst;
|
|
65
|
+
(_global$window$turnst = global.window.turnstile).render.apply(_global$window$turnst, _toConsumableArray(global.window.turnstile.render.mock.calls[counter]));
|
|
66
|
+
counter++;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
afterAll(function () {
|
|
71
|
+
global.window = prevWindow;
|
|
72
|
+
});
|
|
73
|
+
describe('recaptchav2', function () {
|
|
74
|
+
var wrapper;
|
|
75
|
+
beforeAll(function () {
|
|
76
|
+
var lockMock = createLockMock({
|
|
77
|
+
provider: 'recaptcha_v2',
|
|
78
|
+
siteKey: 'mySiteKey'
|
|
79
|
+
});
|
|
80
|
+
var captcha = l.captcha(lockMock);
|
|
81
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_third_party_captcha.ThirdPartyCaptcha, {
|
|
82
|
+
provider: captcha.get('provider'),
|
|
83
|
+
sitekey: captcha.get('siteKey'),
|
|
84
|
+
clientSubdomain: captcha.get('clientSubdomain'),
|
|
85
|
+
hl: 'en',
|
|
86
|
+
isValid: true,
|
|
87
|
+
value: undefined
|
|
88
|
+
})).instance();
|
|
89
|
+
(0, _testUtils.act)(function () {
|
|
90
|
+
var injectCaptchaScriptSpy = jest.spyOn(wrapper, 'injectCaptchaScript');
|
|
91
|
+
wrapper.componentDidMount();
|
|
92
|
+
injectCaptchaScriptSpy.mock.calls[0][0]();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
it('should call render with the correct renderParams', function () {
|
|
96
|
+
var renderParams = global.window.grecaptcha.render.mock.calls[0][1];
|
|
97
|
+
expect(renderParams).toEqual({
|
|
98
|
+
sitekey: 'mySiteKey',
|
|
99
|
+
callback: expect.any(Function),
|
|
100
|
+
'expired-callback': expect.any(Function),
|
|
101
|
+
'error-callback': expect.any(Function)
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('friendly captcha', function () {
|
|
106
|
+
var wrapper;
|
|
107
|
+
beforeAll(function () {
|
|
108
|
+
var lockMock = createLockMock({
|
|
109
|
+
provider: 'friendly_captcha',
|
|
110
|
+
siteKey: 'mySiteKey'
|
|
111
|
+
});
|
|
112
|
+
var captcha = l.captcha(lockMock);
|
|
113
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_third_party_captcha.ThirdPartyCaptcha, {
|
|
114
|
+
provider: captcha.get('provider'),
|
|
115
|
+
sitekey: captcha.get('siteKey'),
|
|
116
|
+
clientSubdomain: captcha.get('clientSubdomain'),
|
|
117
|
+
hl: 'en',
|
|
118
|
+
isValid: true,
|
|
119
|
+
value: undefined
|
|
120
|
+
})).instance();
|
|
121
|
+
(0, _testUtils.act)(function () {
|
|
122
|
+
var injectCaptchaScriptSpy = jest.spyOn(wrapper, 'injectCaptchaScript');
|
|
123
|
+
wrapper.componentDidMount();
|
|
124
|
+
jest.spyOn(global.window.friendlyChallenge, 'WidgetInstance');
|
|
125
|
+
injectCaptchaScriptSpy.mock.calls[0][0]();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
it('should call WidgetInstance constructor with the correct renderParams', function () {
|
|
129
|
+
var renderParams = global.window.friendlyChallenge.WidgetInstance.mock.calls[0][1];
|
|
130
|
+
expect(renderParams).toEqual({
|
|
131
|
+
sitekey: 'mySiteKey',
|
|
132
|
+
doneCallback: expect.any(Function),
|
|
133
|
+
errorCallback: expect.any(Function),
|
|
134
|
+
language: 'en'
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('hcaptcha', function () {
|
|
139
|
+
var wrapper;
|
|
140
|
+
beforeAll(function () {
|
|
141
|
+
var lockMock = createLockMock({
|
|
142
|
+
provider: 'hcaptcha',
|
|
143
|
+
siteKey: 'mySiteKey'
|
|
144
|
+
});
|
|
145
|
+
var captcha = l.captcha(lockMock);
|
|
146
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_third_party_captcha.ThirdPartyCaptcha, {
|
|
147
|
+
provider: captcha.get('provider'),
|
|
148
|
+
sitekey: captcha.get('siteKey'),
|
|
149
|
+
clientSubdomain: captcha.get('clientSubdomain'),
|
|
150
|
+
hl: 'en',
|
|
151
|
+
isValid: true,
|
|
152
|
+
value: undefined
|
|
153
|
+
})).instance();
|
|
154
|
+
(0, _testUtils.act)(function () {
|
|
155
|
+
var injectCaptchaScriptSpy = jest.spyOn(wrapper, 'injectCaptchaScript');
|
|
156
|
+
wrapper.componentDidMount();
|
|
157
|
+
injectCaptchaScriptSpy.mock.calls[0][0]();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
it('should call render with the correct renderParams', function () {
|
|
161
|
+
var renderParams = global.window.hcaptcha.render.mock.calls[0][1];
|
|
162
|
+
expect(renderParams).toEqual({
|
|
163
|
+
sitekey: 'mySiteKey',
|
|
164
|
+
callback: expect.any(Function),
|
|
165
|
+
'expired-callback': expect.any(Function),
|
|
166
|
+
'error-callback': expect.any(Function)
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('auth0_v2', function () {
|
|
171
|
+
var wrapper;
|
|
172
|
+
beforeAll(function () {
|
|
173
|
+
var lockMock = createLockMock({
|
|
174
|
+
provider: 'auth0_v2',
|
|
175
|
+
siteKey: 'mySiteKey'
|
|
176
|
+
});
|
|
177
|
+
var captcha = l.captcha(lockMock);
|
|
178
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_third_party_captcha.ThirdPartyCaptcha, {
|
|
179
|
+
provider: captcha.get('provider'),
|
|
180
|
+
sitekey: captcha.get('siteKey'),
|
|
181
|
+
clientSubdomain: captcha.get('clientSubdomain'),
|
|
182
|
+
hl: 'en',
|
|
183
|
+
isValid: true,
|
|
184
|
+
value: undefined,
|
|
185
|
+
onChange: jest.fn()
|
|
186
|
+
})).instance();
|
|
187
|
+
(0, _testUtils.act)(function () {
|
|
188
|
+
var injectCaptchaScriptSpy = jest.spyOn(wrapper, 'injectCaptchaScript');
|
|
189
|
+
wrapper.componentDidMount();
|
|
190
|
+
injectCaptchaScriptSpy.mock.calls[0][0]();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
it('should call render with the correct renderParams', function () {
|
|
194
|
+
var renderParams = global.window.turnstile.render.mock.calls[0][1];
|
|
195
|
+
expect(renderParams).toEqual({
|
|
196
|
+
sitekey: 'mySiteKey',
|
|
197
|
+
callback: expect.any(Function),
|
|
198
|
+
'expired-callback': expect.any(Function),
|
|
199
|
+
'error-callback': expect.any(Function),
|
|
200
|
+
language: 'en',
|
|
201
|
+
theme: 'light',
|
|
202
|
+
retry: 'never',
|
|
203
|
+
'response-field': false
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
it('should retry 3 times on error and then set value to BYPASS_CAPTCHA dummy token for failOpen', function () {
|
|
207
|
+
var renderParams = global.window.turnstile.render.mock.calls[0][1];
|
|
208
|
+
var _loop = function _loop() {
|
|
209
|
+
var renderParams = global.window.turnstile.render.mock.calls[i][1];
|
|
210
|
+
(0, _testUtils.act)(function () {
|
|
211
|
+
renderParams['error-callback']();
|
|
212
|
+
});
|
|
213
|
+
var retryCount = wrapper.state.retryCount;
|
|
214
|
+
var value = wrapper.props.value;
|
|
215
|
+
expect(retryCount).toBe(i + 1);
|
|
216
|
+
expect(value).toBe(undefined);
|
|
217
|
+
};
|
|
218
|
+
for (var i = 0; i < 3; i++) {
|
|
219
|
+
_loop();
|
|
220
|
+
}
|
|
221
|
+
(0, _testUtils.act)(function () {
|
|
222
|
+
return renderParams['error-callback']();
|
|
223
|
+
});
|
|
224
|
+
var onChange = wrapper.props.onChange;
|
|
225
|
+
expect(onChange.mock.calls).toHaveLength(1);
|
|
226
|
+
expect(onChange.mock.calls[0][0]).toBe('BYPASS_CAPTCHA');
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
describe('recaptcha enterprise', function () {
|
|
230
|
+
var wrapper;
|
|
231
|
+
beforeAll(function () {
|
|
232
|
+
var lockMock = createLockMock({
|
|
233
|
+
provider: 'recaptcha_enterprise',
|
|
234
|
+
siteKey: 'mySiteKey'
|
|
235
|
+
});
|
|
236
|
+
var captcha = l.captcha(lockMock);
|
|
237
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_third_party_captcha.ThirdPartyCaptcha, {
|
|
238
|
+
provider: captcha.get('provider'),
|
|
239
|
+
sitekey: captcha.get('siteKey'),
|
|
240
|
+
clientSubdomain: captcha.get('clientSubdomain'),
|
|
241
|
+
hl: 'en',
|
|
242
|
+
isValid: true,
|
|
243
|
+
value: undefined
|
|
244
|
+
})).instance();
|
|
245
|
+
(0, _testUtils.act)(function () {
|
|
246
|
+
var injectCaptchaScriptSpy = jest.spyOn(wrapper, 'injectCaptchaScript');
|
|
247
|
+
wrapper.componentDidMount();
|
|
248
|
+
injectCaptchaScriptSpy.mock.calls[0][0]();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
it('should call render with the correct renderParams', function () {
|
|
252
|
+
var renderParams = global.window.grecaptcha.enterprise.render.mock.calls[0][1];
|
|
253
|
+
expect(renderParams).toEqual({
|
|
254
|
+
sitekey: 'mySiteKey',
|
|
255
|
+
callback: expect.any(Function),
|
|
256
|
+
'expired-callback': expect.any(Function),
|
|
257
|
+
'error-callback': expect.any(Function)
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
@@ -117,6 +117,28 @@ describe('CaptchaPane', function () {
|
|
|
117
117
|
expect(wrapper.find(_third_party_captcha.ThirdPartyCaptcha).props().sitekey).toBe('mySiteKey');
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
|
+
describe('auth0_v2', function () {
|
|
121
|
+
var wrapper;
|
|
122
|
+
beforeAll(function () {
|
|
123
|
+
var lockMock = createLockMock({
|
|
124
|
+
provider: 'auth0_v2',
|
|
125
|
+
siteKey: 'mySiteKey'
|
|
126
|
+
});
|
|
127
|
+
var i8nMock = createI18nMock();
|
|
128
|
+
var onReloadMock = jest.fn();
|
|
129
|
+
wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_captcha_pane.default, {
|
|
130
|
+
lock: lockMock,
|
|
131
|
+
onReload: onReloadMock,
|
|
132
|
+
i18n: i8nMock
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
it('should render ThirdPartyCaptcha if provider is auth0_v2', function () {
|
|
136
|
+
expect(wrapper.find(_third_party_captcha.ThirdPartyCaptcha)).toHaveLength(1);
|
|
137
|
+
});
|
|
138
|
+
it('should pass the sitekey', function () {
|
|
139
|
+
expect(wrapper.find(_third_party_captcha.ThirdPartyCaptcha).props().sitekey).toBe('mySiteKey');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
120
142
|
describe('recaptcha enterprise', function () {
|
|
121
143
|
var wrapper;
|
|
122
144
|
beforeAll(function () {
|
|
@@ -5,8 +5,8 @@ var _field2 = require("../../field");
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
function _typeof(o) { "@babel/helpers - typeof"; return _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; }, _typeof(o); }
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
function _toPropertyKey(
|
|
9
|
-
function _toPrimitive(
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
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); }
|
|
10
10
|
var createModel = function createModel(field) {
|
|
11
11
|
return _immutable.default.fromJS({
|
|
12
12
|
field: _defineProperty({}, field, "old_test_".concat(field))
|
package/lib/__tests__/i18n.js
CHANGED
|
@@ -9,7 +9,7 @@ var sync = _interopRequireWildcard(require("../sync"));
|
|
|
9
9
|
var l = _interopRequireWildcard(require("../core/index"));
|
|
10
10
|
var _sanitizer = require("../sanitizer");
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
describe('i18n', function () {
|
|
15
15
|
var syncSpy;
|
|
@@ -14,10 +14,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
function _toPropertyKey(
|
|
18
|
-
function _toPrimitive(
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
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); }
|
|
19
19
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
20
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
21
21
|
var expectComponent = exports.expectComponent = function expectComponent(children, opts) {
|
|
22
22
|
var component = _reactTestRenderer.default.create(children, opts);
|
|
23
23
|
return expect(component);
|
|
@@ -8,8 +8,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
8
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
13
|
var getComponent = function getComponent() {
|
|
14
14
|
return require('ui/box/chrome').default;
|
|
15
15
|
};
|
|
@@ -6,7 +6,7 @@ var _immutable = _interopRequireDefault(require("immutable"));
|
|
|
6
6
|
var _testUtils = require("testUtils");
|
|
7
7
|
var _confirmation_pane = _interopRequireDefault(require("../../../ui/box/confirmation_pane"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _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" == _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
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _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" == _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(_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; }
|
|
10
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
12
|
var defaultProps = {
|
package/lib/avatar.js
CHANGED
|
@@ -12,7 +12,7 @@ var preload = _interopRequireWildcard(require("./utils/preload_utils"));
|
|
|
12
12
|
var f = _interopRequireWildcard(require("./utils/fn_utils"));
|
|
13
13
|
var l = _interopRequireWildcard(require("./core/index"));
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
var _dataFns = (0, _data_utils.dataFns)(['avatar']),
|
|
17
17
|
tget = _dataFns.tget,
|
|
18
18
|
tset = _dataFns.tset;
|
|
@@ -4,6 +4,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.Flow = void 0;
|
|
8
|
+
exports.getCaptchaConfig = getCaptchaConfig;
|
|
7
9
|
exports.setCaptchaParams = setCaptchaParams;
|
|
8
10
|
exports.showMissingCaptcha = showMissingCaptcha;
|
|
9
11
|
exports.swapCaptcha = swapCaptcha;
|
|
@@ -14,18 +16,40 @@ var _index3 = require("../store/index");
|
|
|
14
16
|
var _web_api = _interopRequireDefault(require("../core/web_api"));
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
+
var Flow = exports.Flow = Object.freeze({
|
|
21
|
+
DEFAULT: 'default',
|
|
22
|
+
PASSWORDLESS: 'passwordless',
|
|
23
|
+
PASSWORD_RESET: 'password_reset'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Return the captcha config object based on the type of flow.
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} m model
|
|
30
|
+
* @param {Flow} flow Which flow the captcha is being rendered in
|
|
31
|
+
*/
|
|
32
|
+
function getCaptchaConfig(m, flow) {
|
|
33
|
+
if (flow === Flow.PASSWORD_RESET) {
|
|
34
|
+
return l.passwordResetCaptcha(m);
|
|
35
|
+
} else if (flow === Flow.PASSWORDLESS) {
|
|
36
|
+
return l.passwordlessCaptcha(m);
|
|
37
|
+
} else {
|
|
38
|
+
return l.captcha(m);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
18
42
|
/**
|
|
19
43
|
* Display the error message of missing captcha in the header of lock.
|
|
20
44
|
*
|
|
21
45
|
* @param {Object} m model
|
|
22
46
|
* @param {Number} id
|
|
23
|
-
* @param {
|
|
47
|
+
* @param {Flow} flow Which flow the captcha is being rendered in
|
|
24
48
|
*/
|
|
25
49
|
function showMissingCaptcha(m, id) {
|
|
26
|
-
var
|
|
27
|
-
var captchaConfig =
|
|
28
|
-
var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' || captchaConfig.get('provider') === 'recaptcha_enterprise' || captchaConfig.get('provider') === 'hcaptcha' || captchaConfig.get('provider') === 'friendly_captcha' ? 'invalid_recaptcha' : 'invalid_captcha';
|
|
50
|
+
var flow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Flow.DEFAULT;
|
|
51
|
+
var captchaConfig = getCaptchaConfig(m, flow);
|
|
52
|
+
var captchaError = captchaConfig.get('provider') === 'recaptcha_v2' || captchaConfig.get('provider') === 'recaptcha_enterprise' || captchaConfig.get('provider') === 'hcaptcha' || captchaConfig.get('provider') === 'auth0_v2' || captchaConfig.get('provider') === 'friendly_captcha' || captchaConfig.get('provider') === 'arkose' ? 'invalid_recaptcha' : 'invalid_captcha';
|
|
29
53
|
var errorMessage = i18n.html(m, ['error', 'login', captchaError]);
|
|
30
54
|
(0, _index3.swap)(_index3.updateEntity, 'lock', id, function (m) {
|
|
31
55
|
m = l.setSubmitting(m, false, errorMessage);
|
|
@@ -39,19 +63,19 @@ function showMissingCaptcha(m, id) {
|
|
|
39
63
|
*
|
|
40
64
|
* @param {Object} m model
|
|
41
65
|
* @param {Object} params
|
|
42
|
-
* @param {
|
|
66
|
+
* @param {Flow} flow Which flow the captcha is being rendered in
|
|
43
67
|
* @param {Object} fields
|
|
44
68
|
*
|
|
45
69
|
* @returns {Boolean} returns true if is required and missing the response from the user
|
|
46
70
|
*/
|
|
47
|
-
function setCaptchaParams(m, params,
|
|
48
|
-
var captchaConfig =
|
|
71
|
+
function setCaptchaParams(m, params, flow, fields) {
|
|
72
|
+
var captchaConfig = getCaptchaConfig(m, flow);
|
|
49
73
|
var isCaptchaRequired = captchaConfig && captchaConfig.get('required');
|
|
50
74
|
if (!isCaptchaRequired) {
|
|
51
75
|
return true;
|
|
52
76
|
}
|
|
53
77
|
var captcha = c.getFieldValue(m, 'captcha');
|
|
54
|
-
//captcha required and missing
|
|
78
|
+
// captcha required and missing
|
|
55
79
|
if (!captcha) {
|
|
56
80
|
return false;
|
|
57
81
|
}
|
|
@@ -64,12 +88,21 @@ function setCaptchaParams(m, params, isPasswordless, fields) {
|
|
|
64
88
|
* Get a new challenge and display the new captcha image.
|
|
65
89
|
*
|
|
66
90
|
* @param {number} id The id of the Lock instance.
|
|
67
|
-
* @param {
|
|
91
|
+
* @param {Flow} flow Which flow the captcha is being rendered in.
|
|
68
92
|
* @param {boolean} wasInvalid A boolean indicating if the previous captcha was invalid.
|
|
69
93
|
* @param {Function} [next] A callback.
|
|
70
94
|
*/
|
|
71
|
-
function swapCaptcha(id,
|
|
72
|
-
if (
|
|
95
|
+
function swapCaptcha(id, flow, wasInvalid, next) {
|
|
96
|
+
if (flow === Flow.PASSWORD_RESET) {
|
|
97
|
+
return _web_api.default.getPasswordResetChallenge(id, function (err, newCaptcha) {
|
|
98
|
+
if (!err && newCaptcha) {
|
|
99
|
+
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setPasswordResetCaptcha, newCaptcha, wasInvalid);
|
|
100
|
+
}
|
|
101
|
+
if (next) {
|
|
102
|
+
next();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} else if (flow === Flow.PASSWORDLESS) {
|
|
73
106
|
return _web_api.default.getPasswordlessChallenge(id, function (err, newCaptcha) {
|
|
74
107
|
if (!err && newCaptcha) {
|
|
75
108
|
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setPasswordlessCaptcha, newCaptcha, wasInvalid);
|
|
@@ -78,13 +111,14 @@ function swapCaptcha(id, isPasswordless, wasInvalid, next) {
|
|
|
78
111
|
next();
|
|
79
112
|
}
|
|
80
113
|
});
|
|
114
|
+
} else {
|
|
115
|
+
return _web_api.default.getChallenge(id, function (err, newCaptcha) {
|
|
116
|
+
if (!err && newCaptcha) {
|
|
117
|
+
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
|
|
118
|
+
}
|
|
119
|
+
if (next) {
|
|
120
|
+
next();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
81
123
|
}
|
|
82
|
-
return _web_api.default.getChallenge(id, function (err, newCaptcha) {
|
|
83
|
-
if (!err && newCaptcha) {
|
|
84
|
-
(0, _index3.swap)(_index3.updateEntity, 'lock', id, l.setCaptcha, newCaptcha, wasInvalid);
|
|
85
|
-
}
|
|
86
|
-
if (next) {
|
|
87
|
-
next();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
124
|
}
|
|
@@ -25,7 +25,7 @@ var _index4 = require("./index");
|
|
|
25
25
|
var i18n = _interopRequireWildcard(require("../../i18n"));
|
|
26
26
|
var _captcha = require("../captcha");
|
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
30
|
function logIn(id) {
|
|
31
31
|
var needsMFA = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -38,7 +38,7 @@ function logIn(id) {
|
|
|
38
38
|
password: c.getFieldValue(m, 'password')
|
|
39
39
|
};
|
|
40
40
|
var fields = [usernameField, 'password'];
|
|
41
|
-
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params,
|
|
41
|
+
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, _captcha.Flow.DEFAULT, fields);
|
|
42
42
|
if (!isCaptchaValid) {
|
|
43
43
|
return (0, _captcha.showMissingCaptcha)(m, id);
|
|
44
44
|
}
|
|
@@ -53,7 +53,7 @@ function logIn(id) {
|
|
|
53
53
|
}
|
|
54
54
|
if (error) {
|
|
55
55
|
var wasInvalid = error && error.code === 'invalid_captcha';
|
|
56
|
-
return (0, _captcha.swapCaptcha)(id,
|
|
56
|
+
return (0, _captcha.swapCaptcha)(id, _captcha.Flow.DEFAULT, wasInvalid, next);
|
|
57
57
|
}
|
|
58
58
|
next();
|
|
59
59
|
});
|
|
@@ -84,7 +84,7 @@ function signUp(id) {
|
|
|
84
84
|
password: c.getFieldValue(m, 'password'),
|
|
85
85
|
autoLogin: (0, _index4.shouldAutoLogin)(m)
|
|
86
86
|
};
|
|
87
|
-
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params,
|
|
87
|
+
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, _captcha.Flow.DEFAULT, fields);
|
|
88
88
|
if (!isCaptchaValid) {
|
|
89
89
|
return (0, _captcha.showMissingCaptcha)(m, id);
|
|
90
90
|
}
|
|
@@ -125,7 +125,7 @@ function signUp(id) {
|
|
|
125
125
|
popupHandler._current_popup.kill();
|
|
126
126
|
}
|
|
127
127
|
var wasInvalidCaptcha = error && error.code === 'invalid_captcha';
|
|
128
|
-
(0, _captcha.swapCaptcha)(id,
|
|
128
|
+
(0, _captcha.swapCaptcha)(id, _captcha.Flow.DEFAULT, wasInvalidCaptcha, function () {
|
|
129
129
|
setTimeout(function () {
|
|
130
130
|
return signUpError(id, error);
|
|
131
131
|
}, 250);
|
|
@@ -207,7 +207,7 @@ function signUpError(id, error) {
|
|
|
207
207
|
}
|
|
208
208
|
if (errorKey === 'invalid_captcha') {
|
|
209
209
|
errorMessage = i18n.html(m, ['error', 'login', errorKey]);
|
|
210
|
-
return (0, _captcha.swapCaptcha)(id,
|
|
210
|
+
return (0, _captcha.swapCaptcha)(id, _captcha.Flow.DEFAULT, true, function () {
|
|
211
211
|
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
|
|
212
212
|
});
|
|
213
213
|
}
|
|
@@ -229,6 +229,10 @@ function resetPassword(id) {
|
|
|
229
229
|
connection: (0, _index4.databaseConnectionName)(m),
|
|
230
230
|
email: c.getFieldValue(m, 'email')
|
|
231
231
|
};
|
|
232
|
+
var isCaptchaValid = (0, _captcha.setCaptchaParams)(m, params, _captcha.Flow.PASSWORD_RESET, ['email']);
|
|
233
|
+
if (!isCaptchaValid) {
|
|
234
|
+
return (0, _captcha.showMissingCaptcha)(m, id, _captcha.Flow.PASSWORD_RESET);
|
|
235
|
+
}
|
|
232
236
|
_web_api.default.resetPassword(id, params, function (error) {
|
|
233
237
|
if (error) {
|
|
234
238
|
setTimeout(function () {
|
|
@@ -265,8 +269,15 @@ function resetPasswordSuccess(id) {
|
|
|
265
269
|
}
|
|
266
270
|
function resetPasswordError(id, error) {
|
|
267
271
|
var m = (0, _index.read)(_index.getEntity, 'lock', id);
|
|
268
|
-
var
|
|
269
|
-
|
|
272
|
+
var key = error.code;
|
|
273
|
+
if (error.code === 'invalid_captcha') {
|
|
274
|
+
var captchaConfig = l.passwordResetCaptcha(m);
|
|
275
|
+
key = captchaConfig.get('provider') === 'recaptcha_v2' || captchaConfig.get('provider') === 'recaptcha_enterprise' ? 'invalid_recaptcha' : 'invalid_captcha';
|
|
276
|
+
}
|
|
277
|
+
var errorMessage = i18n.html(m, ['error', 'forgotPassword', key]) || i18n.html(m, ['error', 'forgotPassword', 'lock.fallback']);
|
|
278
|
+
(0, _captcha.swapCaptcha)(id, _captcha.Flow.PASSWORD_RESET, error.code === 'invalid_captcha', function () {
|
|
279
|
+
(0, _index.swap)(_index.updateEntity, 'lock', id, l.setSubmitting, false, errorMessage);
|
|
280
|
+
});
|
|
270
281
|
}
|
|
271
282
|
function showLoginActivity(id) {
|
|
272
283
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['password'];
|