@widergy/react-social-auth 2.2.0 → 3.0.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.
@@ -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
- 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; }
21
- 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; }
22
- 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; }
23
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
24
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
25
- 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 new 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 new 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 new 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; }
26
- 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); } }
27
- 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); }); }; }
28
- var Twitter = function Twitter(_ref) {
29
- var _ref$classNames = _ref.classNames,
30
- classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
31
- config = _ref.config,
32
- email = _ref.email,
33
- label = _ref.label,
34
- _ref$size = _ref.size,
35
- size = _ref$size === void 0 ? _buttonSizes.SMALL : _ref$size,
36
- tooltipContent = _ref.tooltipContent,
37
- triggerOnMount = _ref.triggerOnMount;
38
- var _ref2 = config || {},
39
- callback = _ref2.callback,
40
- _ref2$credentials = _ref2.credentials,
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
- var query = new URLSearchParams(popup.location.search);
59
- var OAuthToken = query.get('oauth_token');
60
- var OAuthVerifier = query.get('oauth_verifier');
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
- var handleClick = /*#__PURE__*/function () {
74
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
75
- var authUrl, popup;
76
- return _regeneratorRuntime().wrap(function _callee$(_context) {
77
- while (1) switch (_context.prev = _context.next) {
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,
@@ -102,8 +74,13 @@ var Twitter = function Twitter(_ref) {
102
74
  container: "".concat(_stylesModule.default.buttonContainer, " ").concat(classNames.buttonContainer)
103
75
  },
104
76
  email: email,
105
- Icon: function Icon(_ref4) {
106
- var className = _ref4.className;
77
+ emailLabelProps: {
78
+ colorTheme: 'light'
79
+ },
80
+ Icon: _ref2 => {
81
+ let {
82
+ className
83
+ } = _ref2;
107
84
  return /*#__PURE__*/_react.default.createElement("img", {
108
85
  alt: "Logo de Twitter",
109
86
  className: className,
@@ -111,9 +88,11 @@ var Twitter = function Twitter(_ref) {
111
88
  });
112
89
  },
113
90
  label: label,
114
- mainLabelProps: _objectSpread({}, size === _buttonSizes.LARGE ? {
115
- colorTheme: 'light'
116
- } : {}),
91
+ mainLabelProps: {
92
+ ...(size === _buttonSizes.LARGE ? {
93
+ colorTheme: 'light'
94
+ } : {})
95
+ },
117
96
  onClick: handleClick,
118
97
  size: size
119
98
  }));
@@ -135,5 +114,4 @@ Twitter.propTypes = {
135
114
  tooltipContent: _propTypes.string,
136
115
  triggerOnMount: _propTypes.bool
137
116
  };
138
- var _default = Twitter;
139
- exports.default = _default;
117
+ var _default = exports.default = Twitter;
@@ -5,100 +5,59 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.openPopup = exports.isTwitterUrl = exports.getAuthUrl = exports.getAuthToken = exports.createHeaders = exports.closePopup = void 0;
7
7
  var _errors = require("./errors");
8
- 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); }
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 new 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 new 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 new 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
- 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
- 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
- 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; }
13
- 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; }
14
- 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; }
15
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
- var createHeaders = function createHeaders(customHeaders) {
18
- var headers = _objectSpread({}, customHeaders);
8
+ const createHeaders = customHeaders => {
9
+ const headers = {
10
+ ...customHeaders
11
+ };
19
12
  headers['Content-Type'] = 'application/json';
20
13
  return headers;
21
14
  };
22
15
  exports.createHeaders = createHeaders;
23
- var getAuthUrl = /*#__PURE__*/function () {
24
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(callback, credentials, customHeaders, forceLogin, requestTokenUrl, screenName) {
25
- var response, data, authenticationUrl;
26
- return _regeneratorRuntime().wrap(function _callee$(_context) {
27
- while (1) switch (_context.prev = _context.next) {
28
- case 0:
29
- response = null;
30
- _context.prev = 1;
31
- _context.next = 4;
32
- return window.fetch(requestTokenUrl, {
33
- method: 'POST',
34
- credentials: credentials,
35
- headers: createHeaders(customHeaders)
36
- });
37
- case 4:
38
- response = _context.sent;
39
- _context.next = 10;
40
- break;
41
- case 7:
42
- _context.prev = 7;
43
- _context.t0 = _context["catch"](1);
44
- return _context.abrupt("return", callback(new _errors.RequestTokenError(_context.t0)));
45
- case 10:
46
- data = null;
47
- _context.prev = 11;
48
- _context.next = 14;
49
- return response.json();
50
- case 14:
51
- data = _context.sent;
52
- _context.next = 20;
53
- break;
54
- case 17:
55
- _context.prev = 17;
56
- _context.t1 = _context["catch"](11);
57
- return _context.abrupt("return", callback(new _errors.RequestTokenParseError(_context.t1)));
58
- case 20:
59
- authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
60
- if (screenName) {
61
- authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
62
- }
63
- return _context.abrupt("return", authenticationUrl);
64
- case 23:
65
- case "end":
66
- return _context.stop();
67
- }
68
- }, _callee, null, [[1, 7], [11, 17]]);
69
- }));
70
- return function getAuthUrl(_x, _x2, _x3, _x4, _x5, _x6) {
71
- return _ref.apply(this, arguments);
72
- };
73
- }();
74
- exports.getAuthUrl = getAuthUrl;
75
- var isTwitterUrl = function isTwitterUrl(url) {
76
- return url.includes('api.twitter.com');
16
+ const getAuthUrl = async (callback, credentials, customHeaders, forceLogin, requestTokenUrl, screenName) => {
17
+ let response = null;
18
+ try {
19
+ response = await window.fetch(requestTokenUrl, {
20
+ method: 'POST',
21
+ credentials,
22
+ headers: createHeaders(customHeaders)
23
+ });
24
+ } catch (error) {
25
+ return callback(new _errors.RequestTokenError(error));
26
+ }
27
+ let data = null;
28
+ try {
29
+ data = await response.json();
30
+ } catch (error) {
31
+ return callback(new _errors.RequestTokenParseError(error));
32
+ }
33
+ let authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
34
+ if (screenName) {
35
+ authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
36
+ }
37
+ return authenticationUrl;
77
38
  };
39
+ exports.getAuthUrl = getAuthUrl;
40
+ const isTwitterUrl = url => url.includes('api.twitter.com');
78
41
  exports.isTwitterUrl = isTwitterUrl;
79
- var openPopup = function openPopup(authUrl, height, width) {
80
- var w = width;
81
- var h = height;
82
- var left = window.innerWidth / 2 - w / 2;
83
- var top = window.innerHeight / 2 - h / 2;
84
- var popup = window.open(authUrl, '', "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(w, ", height=").concat(h, ", top=").concat(top, ", left=").concat(left));
42
+ const openPopup = (authUrl, height, width) => {
43
+ const w = width;
44
+ const h = height;
45
+ const left = window.innerWidth / 2 - w / 2;
46
+ const top = window.innerHeight / 2 - h / 2;
47
+ const popup = window.open(authUrl, '', "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(w, ", height=").concat(h, ", top=").concat(top, ", left=").concat(left));
85
48
  return popup;
86
49
  };
87
50
  exports.openPopup = openPopup;
88
- var closePopup = function closePopup(interval, popup) {
51
+ const closePopup = (interval, popup) => {
89
52
  clearInterval(interval);
90
53
  popup.close();
91
54
  };
92
55
  exports.closePopup = closePopup;
93
- var getAuthToken = function getAuthToken(callback, credentials, customHeaders, loginUrl, OAuthToken, OAuthVerifier) {
94
- return window.fetch("".concat(loginUrl, "?oauth_verifier=").concat(OAuthVerifier, "&oauth_token=").concat(OAuthToken), {
95
- method: 'POST',
96
- credentials: credentials,
97
- headers: createHeaders(customHeaders)
98
- }).then(function (response) {
99
- callback(response);
100
- }).catch(function (error) {
101
- return callback(new _errors.GetAuthTokenFailure(error, loginUrl, OAuthVerifier, OAuthToken));
102
- });
103
- };
56
+ const getAuthToken = (callback, credentials, customHeaders, loginUrl, OAuthToken, OAuthVerifier) => window.fetch("".concat(loginUrl, "?oauth_verifier=").concat(OAuthVerifier, "&oauth_token=").concat(OAuthToken), {
57
+ method: 'POST',
58
+ credentials,
59
+ headers: createHeaders(customHeaders)
60
+ }).then(response => {
61
+ callback(response);
62
+ }).catch(error => callback(new _errors.GetAuthTokenFailure(error, loginUrl, OAuthVerifier, OAuthToken)));
104
63
  exports.getAuthToken = getAuthToken;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isValidId = void 0;
7
- var isValidId = function isValidId(id) {
7
+ const isValidId = id => {
8
8
  if (typeof id === 'string') {
9
9
  return !!id.trim();
10
10
  }
@@ -4,7 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SMALL = exports.LARGE = void 0;
7
- var SMALL = 'small';
8
- exports.SMALL = SMALL;
9
- var LARGE = 'large';
10
- exports.LARGE = LARGE;
7
+ const SMALL = exports.SMALL = 'small';
8
+ const LARGE = exports.LARGE = 'large';
package/dist/index.js CHANGED
@@ -5,49 +5,49 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "ActiveDirectory", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _ActiveDirectory.default;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "Apple", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _Apple.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "Button", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _Button.default;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "ButtonContainer", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _ButtonContainer.default;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "Facebook", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _Facebook.default;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "Google", {
37
37
  enumerable: true,
38
- get: function get() {
38
+ get: function () {
39
39
  return _Google.default;
40
40
  }
41
41
  });
42
42
  Object.defineProperty(exports, "Microsoft", {
43
43
  enumerable: true,
44
- get: function get() {
44
+ get: function () {
45
45
  return _Microsoft.default;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "Twitter", {
49
49
  enumerable: true,
50
- get: function get() {
50
+ get: function () {
51
51
  return _Twitter.default;
52
52
  }
53
53
  });
@@ -1,9 +1,9 @@
1
1
  $black: #000;
2
- $facebook-bg: #4267b2;
2
+ $facebook-bg: #4267B2;
3
3
  $large-button-shadow: rgba(9, 30, 66, 0.1);
4
4
  $small-button-shadow: rgba(24, 44, 73, 0.1);
5
5
  $light-black: #252525;
6
- $microsoft-bg: #2f2f2f;
6
+ $microsoft-bg: #2F2F2F;
7
7
  $microsoft-button-shadow: rgba(24, 44, 73, 0.1);
8
- $twitter-bg: #00aced;
9
- $white: #fff;
8
+ $twitter-bg: #00ACED;
9
+ $white: #FFF;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/react-social-auth",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "Social Network Authorization (Twitter, Facebook, etc.)",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -9,8 +9,8 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "start": "HTTPS=true react-scripts start",
13
- "build-example": "react-scripts build",
12
+ "start": "HTTPS=true react-scripts --openssl-legacy-provider start",
13
+ "build-example": "react-scripts --openssl-legacy-provider build",
14
14
  "sass-lint": "./node_modules/sass-lint/bin/sass-lint.js -v -q",
15
15
  "lint": "./node_modules/eslint/bin/eslint.js src && npm run sass-lint",
16
16
  "lint-diff": "git diff --name-only --cached --relative --diff-filter=ACM | grep \\.js$ | xargs ./node_modules/eslint/bin/eslint.js",
@@ -18,36 +18,36 @@
18
18
  "eject": "react-scripts eject",
19
19
  "prebuild": "rimraf dist",
20
20
  "build": "NODE_ENV=production babel src/lib --out-dir dist --copy-files",
21
- "prepare": "npm run build"
21
+ "prepare": "npm run build && husky install"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/cli": "^7.2.3",
25
25
  "@babel/core": "^7.3.4",
26
26
  "@babel/plugin-proposal-class-properties": "^7.4.0",
27
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
27
28
  "@babel/preset-env": "^7.3.4",
28
29
  "@babel/preset-react": "^7.0.0",
29
- "@commitlint/cli": "^8.2.0",
30
- "@commitlint/config-conventional": "^8.2.0",
31
- "@semantic-release/changelog": "^3.0.6",
32
- "@semantic-release/git": "^7.0.18",
33
- "babel-preset-react-app": "^7.0.2",
34
- "cross-env": "^5.1.4",
35
- "eslint-config-airbnb": "^17.1.0",
36
- "eslint-config-prettier": "^3.3.0",
37
- "eslint-plugin-flowtype": "^2.39.1",
30
+ "@commitlint/cli": "^17.7.1",
31
+ "@commitlint/config-conventional": "^17.7.0",
32
+ "@widergy/semantic-release-package-config": "^1.0.0",
33
+ "babel-preset-react-app": "^10.0.1",
34
+ "cross-env": "^7.0.3",
35
+ "eslint-config-airbnb": "^19.0.4",
36
+ "eslint-config-prettier": "^9.0.0",
37
+ "eslint-plugin-flowtype": "^8.0.3",
38
38
  "eslint-plugin-import": "^2.14.0",
39
39
  "eslint-plugin-jsx-a11y": "^6.1.1",
40
- "eslint-plugin-prettier": "^3.0.0",
40
+ "eslint-plugin-prettier": "^5.0.0",
41
41
  "eslint-plugin-react": "^7.11.0",
42
- "gh-pages": "^1.2.0",
43
- "husky": "^1.2.0",
44
- "prettier": "^1.7.4",
45
- "prettier-eslint": "^8.2.1",
46
- "react": "^16.8.4",
47
- "react-dom": "^16.8.5",
42
+ "gh-pages": "^6.0.0",
43
+ "husky": "^8.0.0",
44
+ "prettier": "^3.0.3",
45
+ "prettier-eslint": "^15.0.1",
46
+ "react": "^18.2.0",
47
+ "react-dom": "^18.2.0",
48
48
  "react-error-overlay": "6.0.9",
49
- "react-scripts": "3.0.1",
50
- "rimraf": "^2.6.3",
49
+ "react-scripts": "^4.0.3",
50
+ "rimraf": "^5.0.1",
51
51
  "sass-lint": "^1.12.1",
52
52
  "semantic-release": "^15.13.31"
53
53
  },
@@ -58,10 +58,10 @@
58
58
  "not op_mini all"
59
59
  ],
60
60
  "dependencies": {
61
- "@azure/msal-browser": "^2.12.0",
62
- "@react-oauth/google": "^0.8.0",
63
- "@widergy/energy-ui": "^2.1.6",
64
- "@widergy/web-utils": "^1.5.0",
61
+ "@azure/msal-browser": "^3.1.0",
62
+ "@react-oauth/google": "^0.11.1",
63
+ "@widergy/energy-ui": "^3.0.0",
64
+ "@widergy/web-utils": "^2.0.0",
65
65
  "node-sass": "^8.0.0",
66
66
  "prop-types": "^15.8.1",
67
67
  "react-facebook-login": "^4.1.1",
@@ -70,50 +70,10 @@
70
70
  "url-search-params-polyfill": ">=2.0.1"
71
71
  },
72
72
  "resolutions": {
73
- "react-error-overlay": "6.0.9"
74
- },
75
- "husky": {
76
- "hooks": {
77
- "pre-commit": "node branch-name-hook",
78
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
79
- }
73
+ "node-sass": "^8.0.0",
74
+ "url-loader": "1.1.2"
80
75
  },
81
76
  "release": {
82
- "plugins": [
83
- "@semantic-release/commit-analyzer",
84
- "@semantic-release/release-notes-generator",
85
- [
86
- "@semantic-release/changelog",
87
- {
88
- "changelogFile": "./CHANGELOG.md"
89
- }
90
- ],
91
- "@semantic-release/npm",
92
- [
93
- "@semantic-release/git",
94
- {
95
- "assets": [
96
- "./CHANGELOG.md",
97
- "package.json"
98
- ]
99
- }
100
- ],
101
- "@semantic-release/github"
102
- ]
103
- },
104
- "commitlint": {
105
- "extends": [
106
- "@commitlint/config-conventional"
107
- ],
108
- "rules": {
109
- "subject-case": [
110
- 2,
111
- "never",
112
- [
113
- "start-case",
114
- "pascal-case"
115
- ]
116
- ]
117
- }
77
+ "extends": "@widergy/semantic-release-package-config"
118
78
  }
119
79
  }