@widergy/react-social-auth 1.3.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +1,45 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
8
+ var _react = _interopRequireWildcard(require("react"));
10
9
  var _propTypes = require("prop-types");
11
-
12
10
  require("url-search-params-polyfill");
13
-
14
11
  var _function = require("@widergy/web-utils/lib/function");
15
-
16
- var _twitter = require("./assets/twitter.svg");
17
-
18
12
  var _utils = require("./utils");
19
-
20
13
  var _errors = require("./errors");
21
-
14
+ var _LargeButton = _interopRequireDefault(require("./components/LargeButton"));
15
+ var _SmallButton = _interopRequireDefault(require("./components/SmallButton"));
22
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ 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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
24
20
  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); } }
25
-
26
21
  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); }); }; }
27
-
28
22
  var TwitterLogin = function TwitterLogin(_ref) {
29
- var screenName = _ref.screenName,
30
- requestTokenUrl = _ref.requestTokenUrl,
31
- credentials = _ref.credentials,
32
- loginUrl = _ref.loginUrl,
33
- onFailure = _ref.onFailure,
34
- onSuccess = _ref.onSuccess,
35
- customHeaders = _ref.customHeaders,
36
- dialogWidth = _ref.dialogWidth,
37
- dialogHeight = _ref.dialogHeight,
38
- disabled = _ref.disabled,
39
- text = _ref.text,
40
- style = _ref.style,
41
- showIcon = _ref.showIcon,
42
- className = _ref.className,
43
- forceLogin = _ref.forceLogin,
44
- children = _ref.children;
45
-
23
+ var classes = _ref.classes,
24
+ Component = _ref.Component,
25
+ credentials = _ref.credentials,
26
+ customHeaders = _ref.customHeaders,
27
+ dialogHeight = _ref.dialogHeight,
28
+ dialogWidth = _ref.dialogWidth,
29
+ forceLogin = _ref.forceLogin,
30
+ label = _ref.label,
31
+ loginUrl = _ref.loginUrl,
32
+ onFailure = _ref.onFailure,
33
+ onSuccess = _ref.onSuccess,
34
+ requestTokenUrl = _ref.requestTokenUrl,
35
+ screenName = _ref.screenName,
36
+ variant = _ref.variant;
46
37
  var handleUrlChange = function handleUrlChange(popup) {
47
38
  var interval = (0, _function.polling)(function () {
48
39
  if (!popup || popup.closed || popup.closed === undefined) {
49
40
  clearInterval(interval);
50
41
  onFailure(new _errors.PopupClosedByUserError());
51
42
  }
52
-
53
43
  try {
54
44
  if (popup.location.hostname !== '' && !(0, _utils.isTwitterUrl)(popup.location.hostname)) {
55
45
  if (popup.location.search) {
@@ -60,91 +50,76 @@ var TwitterLogin = function TwitterLogin(_ref) {
60
50
  } else {
61
51
  onFailure(new _errors.NoHashOrQueryParamsError());
62
52
  }
63
-
64
53
  (0, _utils.closePopup)(interval, popup);
65
54
  }
66
- } catch (error) {// Ignore DOMException: Blocked a frame with origin from accessing a cross-origin frame.
55
+ } catch (error) {
56
+ // Ignore DOMException: Blocked a frame with origin from accessing a cross-origin frame.
67
57
  // A hack to get around same-origin security policy errors in IE.
68
58
  }
69
59
  }, 0);
70
60
  };
71
-
72
61
  var authenticate = /*#__PURE__*/function () {
73
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
62
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74
63
  var authUrl, popup;
75
- return regeneratorRuntime.wrap(function _callee$(_context) {
76
- while (1) {
77
- switch (_context.prev = _context.next) {
78
- case 0:
79
- _context.next = 2;
80
- return (0, _utils.getAuthUrl)(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin);
81
-
82
- case 2:
83
- authUrl = _context.sent;
84
- popup = (0, _utils.openPopup)(authUrl, dialogWidth, dialogHeight);
85
- handleUrlChange(popup);
86
-
87
- case 5:
88
- case "end":
89
- return _context.stop();
90
- }
64
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
65
+ while (1) switch (_context.prev = _context.next) {
66
+ case 0:
67
+ _context.next = 2;
68
+ return (0, _utils.getAuthUrl)(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin);
69
+ case 2:
70
+ authUrl = _context.sent;
71
+ popup = (0, _utils.openPopup)(authUrl, dialogWidth, dialogHeight);
72
+ handleUrlChange(popup);
73
+ case 5:
74
+ case "end":
75
+ return _context.stop();
91
76
  }
92
77
  }, _callee);
93
78
  }));
94
-
95
79
  return function authenticate() {
96
80
  return _ref2.apply(this, arguments);
97
81
  };
98
82
  }();
99
-
100
83
  var handleClick = function handleClick(event) {
101
84
  event.preventDefault();
102
85
  return authenticate();
103
86
  };
104
-
105
- var getDefaultButtonContent = function getDefaultButtonContent() {
106
- var defaultIcon = showIcon ? /*#__PURE__*/_react.default.createElement(_twitter.ReactComponent, {
107
- color: "#00aced",
108
- size: 25
109
- }) : null;
110
- return /*#__PURE__*/_react.default.createElement("span", null, defaultIcon, " ", text);
111
- };
112
-
113
- return /*#__PURE__*/_react.default.createElement("tag", {
87
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, Component ? /*#__PURE__*/_react.default.createElement(Component, {
88
+ onClick: handleClick
89
+ }) : variant === 'small' ? /*#__PURE__*/_react.default.createElement(_SmallButton.default, {
114
90
  onClick: handleClick,
115
- style: style,
116
- disabled: disabled,
117
- className: className
118
- }, children || getDefaultButtonContent());
91
+ classes: classes
92
+ }) : /*#__PURE__*/_react.default.createElement(_LargeButton.default, {
93
+ classes: classes,
94
+ label: label,
95
+ onClick: handleClick
96
+ }));
119
97
  };
120
-
121
98
  TwitterLogin.propTypes = {
122
- text: _propTypes.string,
99
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
100
+ Component: _propTypes.node,
101
+ credentials: (0, _propTypes.oneOf)(['omit', 'same-origin', 'include']),
102
+ customHeaders: _propTypes.object,
103
+ dialogHeight: _propTypes.number,
104
+ dialogWidth: _propTypes.number,
105
+ forceLogin: _propTypes.bool,
106
+ label: _propTypes.string,
123
107
  loginUrl: _propTypes.string.isRequired,
124
- requestTokenUrl: _propTypes.string.isRequired,
125
108
  onFailure: _propTypes.func.isRequired,
126
109
  onSuccess: _propTypes.func.isRequired,
127
- disabled: _propTypes.bool,
128
- style: (0, _propTypes.shape)(_propTypes.string),
129
- className: _propTypes.string,
130
- dialogWidth: _propTypes.number,
131
- dialogHeight: _propTypes.number,
132
- showIcon: _propTypes.bool,
133
- credentials: (0, _propTypes.oneOf)(['omit', 'same-origin', 'include']),
134
- customHeaders: (0, _propTypes.shape)(_propTypes.string),
135
- forceLogin: _propTypes.bool,
136
- screenName: _propTypes.string
110
+ requestTokenUrl: _propTypes.string.isRequired,
111
+ screenName: _propTypes.string,
112
+ variant: _propTypes.string
137
113
  };
138
114
  TwitterLogin.defaultProps = {
139
- text: 'Sign in with Twitter',
140
- disabled: false,
141
- dialogWidth: 600,
142
- dialogHeight: 400,
143
- showIcon: true,
144
115
  credentials: 'same-origin',
145
116
  customHeaders: {},
117
+ dialogHeight: 400,
118
+ dialogWidth: 600,
146
119
  forceLogin: false,
147
- screenName: ''
120
+ label: 'Sign in with Twitter',
121
+ screenName: '',
122
+ variant: 'large'
148
123
  };
149
124
  var _default = TwitterLogin;
150
125
  exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.classesType = void 0;
7
+ var _propTypes = require("prop-types");
8
+ var classesType = (0, _propTypes.shape)({
9
+ root: _propTypes.string,
10
+ smallIcon: _propTypes.string,
11
+ largeIcon: _propTypes.string,
12
+ label: _propTypes.string
13
+ });
14
+ exports.classesType = classesType;
@@ -4,100 +4,78 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.openPopup = exports.isTwitterUrl = exports.getAuthUrl = exports.getAuthToken = exports.createHeaders = exports.closePopup = void 0;
7
-
8
7
  var _errors = require("./errors");
9
-
8
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
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
-
12
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); }); }; }
13
-
14
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
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); }
20
17
  var createHeaders = function createHeaders(customHeaders) {
21
18
  var headers = _objectSpread({}, customHeaders);
22
-
23
19
  headers['Content-Type'] = 'application/json';
24
20
  return headers;
25
21
  };
26
-
27
22
  exports.createHeaders = createHeaders;
28
-
29
23
  var getAuthUrl = /*#__PURE__*/function () {
30
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin) {
24
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin) {
31
25
  var response, data, authenticationUrl;
32
- return regeneratorRuntime.wrap(function _callee$(_context) {
33
- while (1) {
34
- switch (_context.prev = _context.next) {
35
- case 0:
36
- response = null;
37
- _context.prev = 1;
38
- _context.next = 4;
39
- return window.fetch(requestTokenUrl, {
40
- method: 'POST',
41
- credentials: credentials,
42
- headers: createHeaders(customHeaders)
43
- });
44
-
45
- case 4:
46
- response = _context.sent;
47
- _context.next = 10;
48
- break;
49
-
50
- case 7:
51
- _context.prev = 7;
52
- _context.t0 = _context["catch"](1);
53
- return _context.abrupt("return", onFailure(new _errors.RequestTokenError(_context.t0)));
54
-
55
- case 10:
56
- data = null;
57
- _context.prev = 11;
58
- _context.next = 14;
59
- return response.json();
60
-
61
- case 14:
62
- data = _context.sent;
63
- _context.next = 20;
64
- break;
65
-
66
- case 17:
67
- _context.prev = 17;
68
- _context.t1 = _context["catch"](11);
69
- return _context.abrupt("return", onFailure(new _errors.RequestTokenParseError(_context.t1)));
70
-
71
- case 20:
72
- authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
73
-
74
- if (screenName) {
75
- authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
76
- }
77
-
78
- return _context.abrupt("return", authenticationUrl);
79
-
80
- case 23:
81
- case "end":
82
- return _context.stop();
83
- }
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", onFailure(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", onFailure(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();
84
67
  }
85
68
  }, _callee, null, [[1, 7], [11, 17]]);
86
69
  }));
87
-
88
70
  return function getAuthUrl(_x, _x2, _x3, _x4, _x5, _x6) {
89
71
  return _ref.apply(this, arguments);
90
72
  };
91
73
  }();
92
-
93
74
  exports.getAuthUrl = getAuthUrl;
94
-
95
75
  var isTwitterUrl = function isTwitterUrl(url) {
96
76
  return url.includes('api.twitter.com');
97
77
  };
98
-
99
78
  exports.isTwitterUrl = isTwitterUrl;
100
-
101
79
  var openPopup = function openPopup(authUrl, width, height) {
102
80
  var w = width;
103
81
  var h = height;
@@ -106,16 +84,12 @@ var openPopup = function openPopup(authUrl, width, height) {
106
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));
107
85
  return popup;
108
86
  };
109
-
110
87
  exports.openPopup = openPopup;
111
-
112
88
  var closePopup = function closePopup(interval, popup) {
113
89
  clearInterval(interval);
114
90
  popup.close();
115
91
  };
116
-
117
92
  exports.closePopup = closePopup;
118
-
119
93
  var getAuthToken = function getAuthToken(OAuthVerifier, OAuthToken, loginUrl, credentials, onSuccess, onFailure, customHeaders) {
120
94
  return window.fetch("".concat(loginUrl, "?oauth_verifier=").concat(OAuthVerifier, "&oauth_token=").concat(OAuthToken), {
121
95
  method: 'POST',
@@ -127,5 +101,4 @@ var getAuthToken = function getAuthToken(OAuthVerifier, OAuthToken, loginUrl, cr
127
101
  return onFailure(new _errors.GetAuthTokenFailure(error, loginUrl, OAuthVerifier, OAuthToken));
128
102
  });
129
103
  };
130
-
131
104
  exports.getAuthToken = getAuthToken;
package/dist/index.js CHANGED
@@ -27,13 +27,8 @@ Object.defineProperty(exports, "initAppleAuth", {
27
27
  return _utils.initAppleAuth;
28
28
  }
29
29
  });
30
-
31
30
  var _Twitter = _interopRequireDefault(require("./components/Twitter"));
32
-
33
31
  var _Apple = _interopRequireDefault(require("./components/Apple"));
34
-
35
32
  var _utils = require("./components/Apple/utils");
36
-
37
33
  var _ActiveDirectory = _interopRequireDefault(require("./components/ActiveDirectory"));
38
-
39
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,2 +1,3 @@
1
1
  $black: #000;
2
2
  $light-black: #252525;
3
+ $twitter: #00ACED;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/react-social-auth",
3
- "version": "1.3.0",
3
+ "version": "2.0.1",
4
4
  "description": "Social Network Authorization (Twitter, Facebook, etc.)",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",