@widergy/react-social-auth 2.2.1 → 3.1.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/CHANGELOG.md +20 -0
- package/dist/components/ActiveDirectory/index.js +60 -116
- package/dist/components/ActiveDirectory/utils.js +5 -4
- package/dist/components/Apple/index.js +38 -62
- package/dist/components/Apple/utils.js +14 -34
- package/dist/components/Button/index.js +17 -14
- package/dist/components/ButtonContainer/index.js +14 -24
- package/dist/components/Facebook/index.js +43 -48
- package/dist/components/Google/components/GoogleButton/index.js +20 -21
- package/dist/components/Google/index.js +17 -19
- package/dist/components/Microsoft/index.js +19 -19
- package/dist/components/Microsoft/styles.module.scss +2 -2
- package/dist/components/Twitter/errors.js +43 -84
- package/dist/components/Twitter/index.js +38 -62
- package/dist/components/Twitter/utils.js +47 -82
- package/dist/components/utils.js +3 -2
- package/dist/constants/buttonSizes.js +2 -2
- package/dist/index.js +8 -8
- package/dist/scss/variables/_colors.scss +4 -4
- package/package.json +27 -68
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _facebookLoginRenderProps = _interopRequireDefault(require("react-facebook-login/dist/facebook-login-render-props"));
|
|
9
9
|
var _propTypes = require("prop-types");
|
|
10
10
|
var _buttonSizes = require("../../constants/buttonSizes");
|
|
@@ -14,28 +14,21 @@ var _utils = require("../utils");
|
|
|
14
14
|
var _facebookIcon = _interopRequireDefault(require("./assets/facebookIcon.svg"));
|
|
15
15
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
size = _ref$size === void 0 ? _buttonSizes.SMALL : _ref$size,
|
|
33
|
-
tooltipContent = _ref.tooltipContent,
|
|
34
|
-
triggerOnMount = _ref.triggerOnMount;
|
|
35
|
-
var _ref2 = config || {},
|
|
36
|
-
appId = _ref2.appId,
|
|
37
|
-
callback = _ref2.callback,
|
|
38
|
-
fields = _ref2.fields;
|
|
17
|
+
const Facebook = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
classNames = {},
|
|
20
|
+
config,
|
|
21
|
+
email,
|
|
22
|
+
label,
|
|
23
|
+
size = _buttonSizes.SMALL,
|
|
24
|
+
tooltipContent,
|
|
25
|
+
triggerOnMount
|
|
26
|
+
} = _ref;
|
|
27
|
+
const {
|
|
28
|
+
appId,
|
|
29
|
+
callback,
|
|
30
|
+
fields
|
|
31
|
+
} = config || {};
|
|
39
32
|
|
|
40
33
|
// eslint-disable-next-line no-console
|
|
41
34
|
if (!(0, _utils.isValidId)(appId)) console.error('El id de Facebook es inválido');
|
|
@@ -50,32 +43,34 @@ var Facebook = function Facebook(_ref) {
|
|
|
50
43
|
cookie: true,
|
|
51
44
|
disableMobileRedirect: true,
|
|
52
45
|
fields: fields,
|
|
53
|
-
render:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
render: renderProps => /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
47
|
+
classNames: {
|
|
48
|
+
container: "".concat(_stylesModule.default.buttonContainer, " ").concat(classNames.buttonContainer)
|
|
49
|
+
},
|
|
50
|
+
email: email,
|
|
51
|
+
emailLabelProps: {
|
|
52
|
+
colorTheme: 'light'
|
|
53
|
+
},
|
|
54
|
+
Icon: _ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
className
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement("img", {
|
|
59
|
+
alt: "Logo de Facebook",
|
|
60
|
+
className: className,
|
|
61
|
+
src: _facebookIcon.default
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
label: label,
|
|
65
|
+
mainLabelProps: {
|
|
66
|
+
...(size === _buttonSizes.LARGE ? {
|
|
60
67
|
colorTheme: 'light'
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
src: _facebookIcon.default
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
label: label,
|
|
71
|
-
mainLabelProps: _objectSpread({}, size === _buttonSizes.LARGE ? {
|
|
72
|
-
colorTheme: 'light'
|
|
73
|
-
} : {}),
|
|
74
|
-
onClick: renderProps.onClick,
|
|
75
|
-
size: size
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
})) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null);
|
|
68
|
+
} : {})
|
|
69
|
+
},
|
|
70
|
+
onClick: renderProps.onClick,
|
|
71
|
+
size: size
|
|
72
|
+
})
|
|
73
|
+
})) : null;
|
|
79
74
|
};
|
|
80
75
|
Facebook.propTypes = {
|
|
81
76
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
@@ -12,21 +12,16 @@ var _googleIcon = _interopRequireDefault(require("../../assets/googleIcon.svg"))
|
|
|
12
12
|
var _buttonSizes = require("../../../../constants/buttonSizes");
|
|
13
13
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
label = _ref.label,
|
|
26
|
-
size = _ref.size,
|
|
27
|
-
successCallback = _ref.successCallback,
|
|
28
|
-
email = _ref.email;
|
|
29
|
-
var login = (0, _google.useGoogleLogin)({
|
|
15
|
+
const GoogleButton = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
classNames = {},
|
|
18
|
+
failureCallback,
|
|
19
|
+
label,
|
|
20
|
+
size,
|
|
21
|
+
successCallback,
|
|
22
|
+
email
|
|
23
|
+
} = _ref;
|
|
24
|
+
const login = (0, _google.useGoogleLogin)({
|
|
30
25
|
onError: failureCallback,
|
|
31
26
|
onSuccess: successCallback
|
|
32
27
|
});
|
|
@@ -35,8 +30,10 @@ var GoogleButton = function GoogleButton(_ref) {
|
|
|
35
30
|
container: "".concat(_stylesModule.default.buttonContainer, " ").concat(classNames.buttonContainer)
|
|
36
31
|
},
|
|
37
32
|
email: email,
|
|
38
|
-
Icon:
|
|
39
|
-
|
|
33
|
+
Icon: _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
className
|
|
36
|
+
} = _ref2;
|
|
40
37
|
return /*#__PURE__*/_react.default.createElement("img", {
|
|
41
38
|
alt: "Logo de Google",
|
|
42
39
|
className: className,
|
|
@@ -44,10 +41,12 @@ var GoogleButton = function GoogleButton(_ref) {
|
|
|
44
41
|
});
|
|
45
42
|
},
|
|
46
43
|
label: label,
|
|
47
|
-
mainLabelProps:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
mainLabelProps: {
|
|
45
|
+
...(size === _buttonSizes.LARGE ? {
|
|
46
|
+
colorTheme: 'dark',
|
|
47
|
+
shade: '01'
|
|
48
|
+
} : {})
|
|
49
|
+
},
|
|
51
50
|
onClick: login,
|
|
52
51
|
size: size
|
|
53
52
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
8
|
var _google = require("@react-oauth/google");
|
|
10
9
|
var _propTypes = require("prop-types");
|
|
11
10
|
var _buttonSizes = require("../../constants/buttonSizes");
|
|
@@ -13,22 +12,21 @@ var _ButtonContainer = _interopRequireDefault(require("../ButtonContainer"));
|
|
|
13
12
|
var _utils = require("../utils");
|
|
14
13
|
var _GoogleButton = _interopRequireDefault(require("./components/GoogleButton"));
|
|
15
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
successCallback = _ref2.successCallback;
|
|
15
|
+
const Google = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
classNames = {},
|
|
18
|
+
config,
|
|
19
|
+
email,
|
|
20
|
+
label,
|
|
21
|
+
size = _buttonSizes.SMALL,
|
|
22
|
+
tooltipContent,
|
|
23
|
+
triggerOnMount
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
clientId,
|
|
27
|
+
failureCallback,
|
|
28
|
+
successCallback
|
|
29
|
+
} = config || {};
|
|
32
30
|
|
|
33
31
|
// eslint-disable-next-line no-console
|
|
34
32
|
if (!(0, _utils.isValidId)(clientId)) console.error('El id de Google es inválido');
|
|
@@ -46,7 +44,7 @@ var Google = function Google(_ref) {
|
|
|
46
44
|
label: label,
|
|
47
45
|
size: size,
|
|
48
46
|
successCallback: successCallback
|
|
49
|
-
}))) :
|
|
47
|
+
}))) : null;
|
|
50
48
|
};
|
|
51
49
|
Google.propTypes = {
|
|
52
50
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,23 +14,24 @@ var _utils = require("../utils");
|
|
|
15
14
|
var _microsoftIcon = _interopRequireDefault(require("./assets/microsoftIcon.svg"));
|
|
16
15
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
classNames =
|
|
23
|
-
config
|
|
24
|
-
email
|
|
25
|
-
label
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
clientId
|
|
32
|
-
loginHandler
|
|
33
|
-
redirectUrl
|
|
34
|
-
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
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 && Object.prototype.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; }
|
|
19
|
+
const Microsoft = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
classNames = {},
|
|
22
|
+
config,
|
|
23
|
+
email,
|
|
24
|
+
label,
|
|
25
|
+
size = _buttonSizes.SMALL,
|
|
26
|
+
tooltipContent,
|
|
27
|
+
triggerOnMount
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
clientId,
|
|
31
|
+
loginHandler,
|
|
32
|
+
redirectUrl
|
|
33
|
+
} = config || {};
|
|
34
|
+
const Image = /*#__PURE__*/_react.default.createElement("img", {
|
|
35
35
|
alt: "Logo de Microsoft",
|
|
36
36
|
className: _stylesModule.default.icon,
|
|
37
37
|
src: _microsoftIcon.default
|
|
@@ -60,7 +60,7 @@ var Microsoft = function Microsoft(_ref) {
|
|
|
60
60
|
cssClass: "".concat(_stylesModule.default.button, " ").concat(classNames.buttonContainer, " ").concat(size === _buttonSizes.SMALL ? _stylesModule.default.smallContainer : ''),
|
|
61
61
|
handleLogin: loginHandler,
|
|
62
62
|
redirectUri: redirectUrl
|
|
63
|
-
}), size === _buttonSizes.SMALL && label && /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, label)) :
|
|
63
|
+
}), size === _buttonSizes.SMALL && label && /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, label)) : null;
|
|
64
64
|
};
|
|
65
65
|
Microsoft.propTypes = {
|
|
66
66
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
outline: 0;
|
|
14
14
|
padding: 8px 12px;
|
|
15
15
|
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
17
|
+
color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
18
18
|
width: 100%;
|
|
19
19
|
|
|
20
20
|
&:hover {
|
|
@@ -1,95 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.RequestTokenParseError = exports.RequestTokenError = exports.PopupClosedByUserError = exports.NoHashOrQueryParamsError = exports.GetAuthTokenFailure = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
-
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
18
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
21
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
var RequestTokenError = exports.RequestTokenError = /*#__PURE__*/function (_Error) {
|
|
24
|
-
_inherits(RequestTokenError, _Error);
|
|
25
|
-
var _super = _createSuper(RequestTokenError);
|
|
26
|
-
function RequestTokenError(error) {
|
|
27
|
-
var _this;
|
|
28
|
-
_classCallCheck(this, RequestTokenError);
|
|
29
|
-
_this = _super.call(this);
|
|
30
|
-
_this.message = 'Unable to retrieve OAuth Token';
|
|
31
|
-
_this.name = 'Fatal Error';
|
|
32
|
-
_this.stack = '';
|
|
33
|
-
_this.error = error;
|
|
34
|
-
return _this;
|
|
7
|
+
class RequestTokenError extends Error {
|
|
8
|
+
constructor(error) {
|
|
9
|
+
super();
|
|
10
|
+
this.message = 'Unable to retrieve OAuth Token';
|
|
11
|
+
this.name = 'Fatal Error';
|
|
12
|
+
this.stack = '';
|
|
13
|
+
this.error = error;
|
|
35
14
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_this2.message = 'Unable to parse JSON from response';
|
|
46
|
-
_this2.name = 'Fatal Error';
|
|
47
|
-
_this2.stack = '';
|
|
48
|
-
_this2.error = error;
|
|
49
|
-
return _this2;
|
|
15
|
+
}
|
|
16
|
+
exports.RequestTokenError = RequestTokenError;
|
|
17
|
+
class RequestTokenParseError extends Error {
|
|
18
|
+
constructor(error) {
|
|
19
|
+
super();
|
|
20
|
+
this.message = 'Unable to parse JSON from response';
|
|
21
|
+
this.name = 'Fatal Error';
|
|
22
|
+
this.stack = '';
|
|
23
|
+
this.error = error;
|
|
50
24
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this3 = _super3.call(this);
|
|
60
|
-
_this3.message = 'Popup has been closed by user';
|
|
61
|
-
_this3.name = 'Info';
|
|
62
|
-
_this3.stack = '';
|
|
63
|
-
return _this3;
|
|
25
|
+
}
|
|
26
|
+
exports.RequestTokenParseError = RequestTokenParseError;
|
|
27
|
+
class PopupClosedByUserError extends Error {
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.message = 'Popup has been closed by user';
|
|
31
|
+
this.name = 'Info';
|
|
32
|
+
this.stack = '';
|
|
64
33
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_this4.message = "Unable to retrieve Authorization Token from ".concat(url, "\n OAuth Verifier: ").concat(verifier, " \n OAuth Token: ").concat(token, " ");
|
|
75
|
-
_this4.name = 'Fatal Error';
|
|
76
|
-
_this4.stack = '';
|
|
77
|
-
_this4.error = error;
|
|
78
|
-
return _this4;
|
|
34
|
+
}
|
|
35
|
+
exports.PopupClosedByUserError = PopupClosedByUserError;
|
|
36
|
+
class GetAuthTokenFailure extends Error {
|
|
37
|
+
constructor(error, url, verifier, token) {
|
|
38
|
+
super();
|
|
39
|
+
this.message = "Unable to retrieve Authorization Token from ".concat(url, "\n OAuth Verifier: ").concat(verifier, " \n OAuth Token: ").concat(token, " ");
|
|
40
|
+
this.name = 'Fatal Error';
|
|
41
|
+
this.stack = '';
|
|
42
|
+
this.error = error;
|
|
79
43
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_this5 = _super5.call(this);
|
|
89
|
-
_this5.message = "OAuth redirect has occurred but no query or hash parameters were found.\n They were either not set during the redirect, or were removed\u2014typically by a\n routing library\u2014before Twitter react component could read it.";
|
|
90
|
-
_this5.name = 'Fatal Error';
|
|
91
|
-
_this5.stack = '';
|
|
92
|
-
return _this5;
|
|
44
|
+
}
|
|
45
|
+
exports.GetAuthTokenFailure = GetAuthTokenFailure;
|
|
46
|
+
class NoHashOrQueryParamsError extends Error {
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.message = "OAuth redirect has occurred but no query or hash parameters were found.\n They were either not set during the redirect, or were removed\u2014typically by a\n routing library\u2014before Twitter react component could read it.";
|
|
50
|
+
this.name = 'Fatal Error';
|
|
51
|
+
this.stack = '';
|
|
93
52
|
}
|
|
94
|
-
|
|
95
|
-
|
|
53
|
+
}
|
|
54
|
+
exports.NoHashOrQueryParamsError = NoHashOrQueryParamsError;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -17,37 +16,27 @@ var _errors = require("./errors");
|
|
|
17
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
18
17
|
var _utils = require("./utils");
|
|
19
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
credentials = _ref2$credentials === void 0 ? 'same_origin' : _ref2$credentials,
|
|
42
|
-
_ref2$customHeaders = _ref2.customHeaders,
|
|
43
|
-
customHeaders = _ref2$customHeaders === void 0 ? {} : _ref2$customHeaders,
|
|
44
|
-
_ref2$forceLogin = _ref2.forceLogin,
|
|
45
|
-
forceLogin = _ref2$forceLogin === void 0 ? false : _ref2$forceLogin,
|
|
46
|
-
loginUrl = _ref2.loginUrl,
|
|
47
|
-
requestTokenUrl = _ref2.requestTokenUrl,
|
|
48
|
-
screenName = _ref2.screenName;
|
|
49
|
-
var handleUrlChange = function handleUrlChange(popup) {
|
|
50
|
-
var interval = (0, _function.polling)(function () {
|
|
19
|
+
const Twitter = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
classNames = {},
|
|
22
|
+
config,
|
|
23
|
+
email,
|
|
24
|
+
label,
|
|
25
|
+
size = _buttonSizes.SMALL,
|
|
26
|
+
tooltipContent,
|
|
27
|
+
triggerOnMount
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
callback,
|
|
31
|
+
credentials = 'same_origin',
|
|
32
|
+
customHeaders = {},
|
|
33
|
+
forceLogin = false,
|
|
34
|
+
loginUrl,
|
|
35
|
+
requestTokenUrl,
|
|
36
|
+
screenName
|
|
37
|
+
} = config || {};
|
|
38
|
+
const handleUrlChange = popup => {
|
|
39
|
+
const interval = (0, _function.polling)(() => {
|
|
51
40
|
if (!popup || popup.closed || popup.closed === undefined) {
|
|
52
41
|
clearInterval(interval);
|
|
53
42
|
callback(new _errors.PopupClosedByUserError());
|
|
@@ -55,9 +44,9 @@ var Twitter = function Twitter(_ref) {
|
|
|
55
44
|
try {
|
|
56
45
|
if (popup.location.hostname !== '' && !(0, _utils.isTwitterUrl)(popup.location.hostname)) {
|
|
57
46
|
if (popup.location.search) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
const query = new URLSearchParams(popup.location.search);
|
|
48
|
+
const OAuthToken = query.get('oauth_token');
|
|
49
|
+
const OAuthVerifier = query.get('oauth_verifier');
|
|
61
50
|
(0, _utils.getAuthToken)(callback, credentials, customHeaders, loginUrl, OAuthToken, OAuthVerifier);
|
|
62
51
|
} else {
|
|
63
52
|
callback(new _errors.NoHashOrQueryParamsError());
|
|
@@ -70,28 +59,11 @@ var Twitter = function Twitter(_ref) {
|
|
|
70
59
|
}
|
|
71
60
|
}, 0);
|
|
72
61
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
case 0:
|
|
79
|
-
_context.next = 2;
|
|
80
|
-
return (0, _utils.getAuthUrl)(callback, credentials, customHeaders, forceLogin, requestTokenUrl, screenName);
|
|
81
|
-
case 2:
|
|
82
|
-
authUrl = _context.sent;
|
|
83
|
-
popup = (0, _utils.openPopup)(authUrl, 400, 600);
|
|
84
|
-
handleUrlChange(popup);
|
|
85
|
-
case 5:
|
|
86
|
-
case "end":
|
|
87
|
-
return _context.stop();
|
|
88
|
-
}
|
|
89
|
-
}, _callee);
|
|
90
|
-
}));
|
|
91
|
-
return function handleClick() {
|
|
92
|
-
return _ref3.apply(this, arguments);
|
|
93
|
-
};
|
|
94
|
-
}();
|
|
62
|
+
const handleClick = async () => {
|
|
63
|
+
const authUrl = await (0, _utils.getAuthUrl)(callback, credentials, customHeaders, forceLogin, requestTokenUrl, screenName);
|
|
64
|
+
const popup = (0, _utils.openPopup)(authUrl, 400, 600);
|
|
65
|
+
handleUrlChange(popup);
|
|
66
|
+
};
|
|
95
67
|
return /*#__PURE__*/_react.default.createElement(_ButtonContainer.default, {
|
|
96
68
|
className: classNames.container,
|
|
97
69
|
size: size,
|
|
@@ -105,8 +77,10 @@ var Twitter = function Twitter(_ref) {
|
|
|
105
77
|
emailLabelProps: {
|
|
106
78
|
colorTheme: 'light'
|
|
107
79
|
},
|
|
108
|
-
Icon:
|
|
109
|
-
|
|
80
|
+
Icon: _ref2 => {
|
|
81
|
+
let {
|
|
82
|
+
className
|
|
83
|
+
} = _ref2;
|
|
110
84
|
return /*#__PURE__*/_react.default.createElement("img", {
|
|
111
85
|
alt: "Logo de Twitter",
|
|
112
86
|
className: className,
|
|
@@ -114,9 +88,11 @@ var Twitter = function Twitter(_ref) {
|
|
|
114
88
|
});
|
|
115
89
|
},
|
|
116
90
|
label: label,
|
|
117
|
-
mainLabelProps:
|
|
118
|
-
|
|
119
|
-
|
|
91
|
+
mainLabelProps: {
|
|
92
|
+
...(size === _buttonSizes.LARGE ? {
|
|
93
|
+
colorTheme: 'light'
|
|
94
|
+
} : {})
|
|
95
|
+
},
|
|
120
96
|
onClick: handleClick,
|
|
121
97
|
size: size
|
|
122
98
|
}));
|