@widergy/react-social-auth 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ActiveDirectory/index.js +85 -122
- package/dist/components/ActiveDirectory/utils.js +0 -4
- package/dist/components/Apple/components/LargeButton/index.js +5 -14
- package/dist/components/Apple/components/SmallButton/index.js +3 -12
- package/dist/components/Apple/index.js +31 -52
- package/dist/components/Apple/types.js +0 -2
- package/dist/components/Apple/utils.js +23 -31
- package/dist/components/Twitter/errors.js +7 -54
- package/dist/components/Twitter/index.js +32 -53
- package/dist/components/Twitter/utils.js +49 -76
- package/dist/index.js +0 -5
- package/package.json +3 -3
- package/CHANGELOG.md +0 -48
|
@@ -1,169 +1,132 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = require("prop-types");
|
|
13
|
-
|
|
14
10
|
var _msalBrowser = require("@azure/msal-browser");
|
|
15
|
-
|
|
16
11
|
var _utils = require("./utils");
|
|
17
|
-
|
|
18
12
|
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); }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
14
|
+
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; }
|
|
22
15
|
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); } }
|
|
23
|
-
|
|
24
16
|
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); }); }; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
32
22
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
-
|
|
34
23
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
|
-
|
|
36
24
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
-
|
|
25
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
26
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
42
27
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
-
|
|
44
28
|
var ActiveDirectory = function ActiveDirectory(_ref) {
|
|
45
29
|
var Component = _ref.Component,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
authority = _ref.authority,
|
|
31
|
+
onSuccess = _ref.onSuccess,
|
|
32
|
+
onFailure = _ref.onFailure,
|
|
33
|
+
clientId = _ref.clientId,
|
|
34
|
+
redirectUri = _ref.redirectUri,
|
|
35
|
+
scopes = _ref.scopes;
|
|
53
36
|
var _useState = (0, _react.useState)(new _msalBrowser.PublicClientApplication({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
auth: _objectSpread({
|
|
38
|
+
clientId: clientId,
|
|
39
|
+
redirectUri: redirectUri
|
|
40
|
+
}, authority ? {
|
|
41
|
+
authority: authority
|
|
42
|
+
} : {}),
|
|
43
|
+
cache: {
|
|
44
|
+
cacheLocation: 'sessionStorage',
|
|
45
|
+
storeAuthStateInCookie: true
|
|
46
|
+
}
|
|
47
|
+
})),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
49
|
+
publicClientApplication = _useState2[0];
|
|
68
50
|
var getAccessToken = /*#__PURE__*/function () {
|
|
69
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
51
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(selectedAccount) {
|
|
70
52
|
var accounts, account, silentResult;
|
|
71
|
-
return
|
|
72
|
-
while (1) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (account) {
|
|
82
|
-
_context.next = 5;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
throw new Error('login_required');
|
|
87
|
-
|
|
88
|
-
case 5:
|
|
89
|
-
_context.next = 7;
|
|
90
|
-
return publicClientApplication.acquireTokenSilent({
|
|
91
|
-
scopes: scopes,
|
|
92
|
-
account: account
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
case 7:
|
|
96
|
-
silentResult = _context.sent;
|
|
97
|
-
onSuccess({
|
|
98
|
-
access_token: silentResult.accessToken
|
|
99
|
-
});
|
|
100
|
-
_context.next = 14;
|
|
53
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
_context.prev = 0;
|
|
57
|
+
accounts = publicClientApplication.getAllAccounts();
|
|
58
|
+
account = accounts.find(function (_account) {
|
|
59
|
+
return _account.homeAccountId === selectedAccount.homeAccountId;
|
|
60
|
+
});
|
|
61
|
+
if (account) {
|
|
62
|
+
_context.next = 5;
|
|
101
63
|
break;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
64
|
+
}
|
|
65
|
+
throw new Error('login_required');
|
|
66
|
+
case 5:
|
|
67
|
+
_context.next = 7;
|
|
68
|
+
return publicClientApplication.acquireTokenSilent({
|
|
69
|
+
scopes: scopes,
|
|
70
|
+
account: account
|
|
71
|
+
});
|
|
72
|
+
case 7:
|
|
73
|
+
silentResult = _context.sent;
|
|
74
|
+
onSuccess({
|
|
75
|
+
access_token: silentResult.accessToken
|
|
76
|
+
});
|
|
77
|
+
_context.next = 14;
|
|
78
|
+
break;
|
|
79
|
+
case 11:
|
|
80
|
+
_context.prev = 11;
|
|
81
|
+
_context.t0 = _context["catch"](0);
|
|
82
|
+
if (onFailure) onFailure((0, _utils.normalizeError)(_context.t0));
|
|
83
|
+
case 14:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
112
86
|
}
|
|
113
87
|
}, _callee, null, [[0, 11]]);
|
|
114
88
|
}));
|
|
115
|
-
|
|
116
89
|
return function getAccessToken(_x) {
|
|
117
90
|
return _ref2.apply(this, arguments);
|
|
118
91
|
};
|
|
119
92
|
}();
|
|
120
|
-
|
|
121
93
|
var handleLogin = /*#__PURE__*/function () {
|
|
122
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/
|
|
94
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
123
95
|
var response;
|
|
124
|
-
return
|
|
125
|
-
while (1) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (onFailure) onFailure((0, _utils.normalizeError)(_context2.t0));
|
|
148
|
-
|
|
149
|
-
case 11:
|
|
150
|
-
case "end":
|
|
151
|
-
return _context2.stop();
|
|
152
|
-
}
|
|
96
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
97
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
_context2.prev = 0;
|
|
100
|
+
_context2.next = 3;
|
|
101
|
+
return publicClientApplication.loginPopup({
|
|
102
|
+
scopes: scopes,
|
|
103
|
+
prompt: 'select_account'
|
|
104
|
+
});
|
|
105
|
+
case 3:
|
|
106
|
+
response = _context2.sent;
|
|
107
|
+
_context2.next = 6;
|
|
108
|
+
return getAccessToken(response.account);
|
|
109
|
+
case 6:
|
|
110
|
+
_context2.next = 11;
|
|
111
|
+
break;
|
|
112
|
+
case 8:
|
|
113
|
+
_context2.prev = 8;
|
|
114
|
+
_context2.t0 = _context2["catch"](0);
|
|
115
|
+
if (onFailure) onFailure((0, _utils.normalizeError)(_context2.t0));
|
|
116
|
+
case 11:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context2.stop();
|
|
153
119
|
}
|
|
154
120
|
}, _callee2, null, [[0, 8]]);
|
|
155
121
|
}));
|
|
156
|
-
|
|
157
122
|
return function handleLogin() {
|
|
158
123
|
return _ref3.apply(this, arguments);
|
|
159
124
|
};
|
|
160
125
|
}();
|
|
161
|
-
|
|
162
126
|
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
163
127
|
onLogin: handleLogin
|
|
164
128
|
});
|
|
165
129
|
};
|
|
166
|
-
|
|
167
130
|
ActiveDirectory.propTypes = {
|
|
168
131
|
Component: _propTypes.node,
|
|
169
132
|
authority: _propTypes.string,
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeError = void 0;
|
|
7
|
-
|
|
8
7
|
var normalizeError = function normalizeError(error) {
|
|
9
8
|
var normalizedError = {};
|
|
10
|
-
|
|
11
9
|
if (typeof error === 'string') {
|
|
12
10
|
var errParts = error.split('|');
|
|
13
11
|
normalizedError = errParts.length > 1 ? {
|
|
@@ -22,8 +20,6 @@ var normalizeError = function normalizeError(error) {
|
|
|
22
20
|
debug: JSON.stringify(error)
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
return normalizedError;
|
|
27
24
|
};
|
|
28
|
-
|
|
29
25
|
exports.normalizeError = normalizeError;
|
|
@@ -4,28 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _energyUi = require("@widergy/energy-ui");
|
|
11
|
-
|
|
12
9
|
var _propTypes = require("prop-types");
|
|
13
|
-
|
|
14
10
|
var _apple = _interopRequireDefault(require("../../assets/apple.svg"));
|
|
15
|
-
|
|
16
11
|
var _types = require("../../types");
|
|
17
|
-
|
|
18
12
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
var LargeButton = function LargeButton(_ref) {
|
|
23
15
|
var onClick = _ref.onClick,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
_ref$classes = _ref.classes,
|
|
18
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
19
|
+
icon = _ref.icon,
|
|
20
|
+
uppercase = _ref.uppercase;
|
|
29
21
|
return /*#__PURE__*/_react.default.createElement(_energyUi.UTButton, {
|
|
30
22
|
onPress: onClick,
|
|
31
23
|
className: "".concat(_stylesModule.default.button, " ").concat(classes.root)
|
|
@@ -42,7 +34,6 @@ var LargeButton = function LargeButton(_ref) {
|
|
|
42
34
|
className: "".concat(_stylesModule.default.label, " ").concat(classes.label)
|
|
43
35
|
}, label)));
|
|
44
36
|
};
|
|
45
|
-
|
|
46
37
|
LargeButton.propTypes = {
|
|
47
38
|
onClick: _propTypes.func,
|
|
48
39
|
label: _propTypes.string,
|
|
@@ -4,26 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _energyUi = require("@widergy/energy-ui");
|
|
11
|
-
|
|
12
9
|
var _propTypes = require("prop-types");
|
|
13
|
-
|
|
14
10
|
var _apple = _interopRequireDefault(require("../../assets/apple.svg"));
|
|
15
|
-
|
|
16
11
|
var _types = require("../../types");
|
|
17
|
-
|
|
18
12
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
var SmallButton = function SmallButton(_ref) {
|
|
23
15
|
var onClick = _ref.onClick,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
_ref$classes = _ref.classes,
|
|
17
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
18
|
+
icon = _ref.icon;
|
|
27
19
|
return /*#__PURE__*/_react.default.createElement(_energyUi.UTIconButton, {
|
|
28
20
|
className: "".concat(_stylesModule.default.button, " ").concat(classes.root),
|
|
29
21
|
onClick: onClick
|
|
@@ -33,7 +25,6 @@ var SmallButton = function SmallButton(_ref) {
|
|
|
33
25
|
className: classes.smallIcon
|
|
34
26
|
}));
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
SmallButton.propTypes = {
|
|
38
29
|
onClick: _propTypes.func,
|
|
39
30
|
classes: _types.classesType,
|
|
@@ -1,82 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = require("prop-types");
|
|
13
|
-
|
|
14
10
|
var _LargeButton = _interopRequireDefault(require("./components/LargeButton"));
|
|
15
|
-
|
|
16
11
|
var _SmallButton = _interopRequireDefault(require("./components/SmallButton"));
|
|
17
|
-
|
|
18
12
|
var _types = require("./types");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
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); }
|
|
23
|
-
|
|
24
15
|
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; }
|
|
25
|
-
|
|
16
|
+
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
17
|
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
|
-
|
|
28
18
|
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); }); }; }
|
|
29
|
-
|
|
30
19
|
var SMALL_VARIANT = 'small';
|
|
31
|
-
|
|
32
20
|
var Apple = function Apple(_ref) {
|
|
33
21
|
var onSuccess = _ref.onSuccess,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
onFailure = _ref.onFailure,
|
|
23
|
+
_ref$classes = _ref.classes,
|
|
24
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
25
|
+
_ref$label = _ref.label,
|
|
26
|
+
label = _ref$label === void 0 ? 'apple' : _ref$label,
|
|
27
|
+
_ref$variant = _ref.variant,
|
|
28
|
+
variant = _ref$variant === void 0 ? SMALL_VARIANT : _ref$variant,
|
|
29
|
+
Component = _ref.Component,
|
|
30
|
+
icon = _ref.icon,
|
|
31
|
+
uppercase = _ref.uppercase;
|
|
45
32
|
var handleLogin = /*#__PURE__*/function () {
|
|
46
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
33
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
47
34
|
var data;
|
|
48
|
-
return
|
|
49
|
-
while (1) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
case 10:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
35
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
_context.prev = 0;
|
|
39
|
+
_context.next = 3;
|
|
40
|
+
return window.AppleID.auth.signIn();
|
|
41
|
+
case 3:
|
|
42
|
+
data = _context.sent;
|
|
43
|
+
if (onSuccess) onSuccess(data);
|
|
44
|
+
_context.next = 10;
|
|
45
|
+
break;
|
|
46
|
+
case 7:
|
|
47
|
+
_context.prev = 7;
|
|
48
|
+
_context.t0 = _context["catch"](0);
|
|
49
|
+
if (onFailure) onFailure(_context.t0);
|
|
50
|
+
case 10:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
71
53
|
}
|
|
72
54
|
}, _callee, null, [[0, 7]]);
|
|
73
55
|
}));
|
|
74
|
-
|
|
75
56
|
return function handleLogin() {
|
|
76
57
|
return _ref2.apply(this, arguments);
|
|
77
58
|
};
|
|
78
59
|
}();
|
|
79
|
-
|
|
80
60
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, Component ? /*#__PURE__*/_react.default.createElement(Component, {
|
|
81
61
|
onClick: handleLogin
|
|
82
62
|
}) : variant === SMALL_VARIANT ? /*#__PURE__*/_react.default.createElement(_SmallButton.default, {
|
|
@@ -91,7 +71,6 @@ var Apple = function Apple(_ref) {
|
|
|
91
71
|
classes: classes
|
|
92
72
|
}));
|
|
93
73
|
};
|
|
94
|
-
|
|
95
74
|
Apple.propTypes = {
|
|
96
75
|
onSuccess: _propTypes.func.required,
|
|
97
76
|
onFailure: _propTypes.func.required,
|
|
@@ -1,49 +1,41 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.initAppleAuth = void 0;
|
|
7
|
-
|
|
8
|
+
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; }
|
|
8
9
|
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); } }
|
|
9
|
-
|
|
10
10
|
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); }); }; }
|
|
11
|
-
|
|
12
11
|
var initAppleAuth = /*#__PURE__*/function () {
|
|
13
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
|
12
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(clientId, scope, redirectUrl) {
|
|
14
13
|
var head, script;
|
|
15
|
-
return
|
|
16
|
-
while (1) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case 7:
|
|
37
|
-
case "end":
|
|
38
|
-
return _context.stop();
|
|
39
|
-
}
|
|
14
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
head = document.getElementsByTagName('head')[0];
|
|
18
|
+
script = document.createElement('script');
|
|
19
|
+
script.type = 'text/javascript';
|
|
20
|
+
script.src = 'https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js';
|
|
21
|
+
script.onload = function () {
|
|
22
|
+
return window.AppleID.auth.init({
|
|
23
|
+
clientId: clientId,
|
|
24
|
+
scope: scope,
|
|
25
|
+
usePopup: true,
|
|
26
|
+
redirectURI: redirectUrl
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
_context.next = 7;
|
|
30
|
+
return head.appendChild(script);
|
|
31
|
+
case 7:
|
|
32
|
+
case "end":
|
|
33
|
+
return _context.stop();
|
|
40
34
|
}
|
|
41
35
|
}, _callee);
|
|
42
36
|
}));
|
|
43
|
-
|
|
44
37
|
return function initAppleAuth(_x, _x2, _x3) {
|
|
45
38
|
return _ref.apply(this, arguments);
|
|
46
39
|
};
|
|
47
40
|
}();
|
|
48
|
-
|
|
49
41
|
exports.initAppleAuth = initAppleAuth;
|
|
@@ -1,48 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.RequestTokenParseError = exports.RequestTokenError = exports.PopupClosedByUserError = exports.NoHashOrQueryParamsError = exports.GetAuthTokenFailure = void 0;
|
|
9
|
-
|
|
10
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); }
|
|
14
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
13
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
-
|
|
18
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
-
|
|
20
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); }
|
|
21
|
-
|
|
22
16
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
-
|
|
24
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); }
|
|
25
|
-
|
|
26
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } 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); }
|
|
27
|
-
|
|
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); }
|
|
28
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; } }
|
|
29
|
-
|
|
30
20
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
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); }
|
|
36
23
|
var RequestTokenError = /*#__PURE__*/function (_Error) {
|
|
37
24
|
_inherits(RequestTokenError, _Error);
|
|
38
|
-
|
|
39
25
|
var _super = _createSuper(RequestTokenError);
|
|
40
|
-
|
|
41
26
|
function RequestTokenError(error) {
|
|
42
27
|
var _this;
|
|
43
|
-
|
|
44
28
|
_classCallCheck(this, RequestTokenError);
|
|
45
|
-
|
|
46
29
|
_this = _super.call(this);
|
|
47
30
|
_this.message = 'Unable to retrieve OAuth Token';
|
|
48
31
|
_this.name = 'Fatal Error';
|
|
@@ -50,22 +33,15 @@ var RequestTokenError = /*#__PURE__*/function (_Error) {
|
|
|
50
33
|
_this.error = error;
|
|
51
34
|
return _this;
|
|
52
35
|
}
|
|
53
|
-
|
|
54
36
|
return _createClass(RequestTokenError);
|
|
55
37
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
56
|
-
|
|
57
38
|
exports.RequestTokenError = RequestTokenError;
|
|
58
|
-
|
|
59
39
|
var RequestTokenParseError = /*#__PURE__*/function (_Error2) {
|
|
60
40
|
_inherits(RequestTokenParseError, _Error2);
|
|
61
|
-
|
|
62
41
|
var _super2 = _createSuper(RequestTokenParseError);
|
|
63
|
-
|
|
64
42
|
function RequestTokenParseError(error) {
|
|
65
43
|
var _this2;
|
|
66
|
-
|
|
67
44
|
_classCallCheck(this, RequestTokenParseError);
|
|
68
|
-
|
|
69
45
|
_this2 = _super2.call(this);
|
|
70
46
|
_this2.message = 'Unable to parse JSON from response';
|
|
71
47
|
_this2.name = 'Fatal Error';
|
|
@@ -73,44 +49,30 @@ var RequestTokenParseError = /*#__PURE__*/function (_Error2) {
|
|
|
73
49
|
_this2.error = error;
|
|
74
50
|
return _this2;
|
|
75
51
|
}
|
|
76
|
-
|
|
77
52
|
return _createClass(RequestTokenParseError);
|
|
78
53
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
79
|
-
|
|
80
54
|
exports.RequestTokenParseError = RequestTokenParseError;
|
|
81
|
-
|
|
82
55
|
var PopupClosedByUserError = /*#__PURE__*/function (_Error3) {
|
|
83
56
|
_inherits(PopupClosedByUserError, _Error3);
|
|
84
|
-
|
|
85
57
|
var _super3 = _createSuper(PopupClosedByUserError);
|
|
86
|
-
|
|
87
58
|
function PopupClosedByUserError() {
|
|
88
59
|
var _this3;
|
|
89
|
-
|
|
90
60
|
_classCallCheck(this, PopupClosedByUserError);
|
|
91
|
-
|
|
92
61
|
_this3 = _super3.call(this);
|
|
93
62
|
_this3.message = 'Popup has been closed by user';
|
|
94
63
|
_this3.name = 'Info';
|
|
95
64
|
_this3.stack = '';
|
|
96
65
|
return _this3;
|
|
97
66
|
}
|
|
98
|
-
|
|
99
67
|
return _createClass(PopupClosedByUserError);
|
|
100
68
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
101
|
-
|
|
102
69
|
exports.PopupClosedByUserError = PopupClosedByUserError;
|
|
103
|
-
|
|
104
70
|
var GetAuthTokenFailure = /*#__PURE__*/function (_Error4) {
|
|
105
71
|
_inherits(GetAuthTokenFailure, _Error4);
|
|
106
|
-
|
|
107
72
|
var _super4 = _createSuper(GetAuthTokenFailure);
|
|
108
|
-
|
|
109
73
|
function GetAuthTokenFailure(error, url, verifier, token) {
|
|
110
74
|
var _this4;
|
|
111
|
-
|
|
112
75
|
_classCallCheck(this, GetAuthTokenFailure);
|
|
113
|
-
|
|
114
76
|
_this4 = _super4.call(this);
|
|
115
77
|
_this4.message = "Unable to retrieve Authorization Token from ".concat(url, "\n OAuth Verifier: ").concat(verifier, " \n OAuth Token: ").concat(token, " ");
|
|
116
78
|
_this4.name = 'Fatal Error';
|
|
@@ -118,30 +80,21 @@ var GetAuthTokenFailure = /*#__PURE__*/function (_Error4) {
|
|
|
118
80
|
_this4.error = error;
|
|
119
81
|
return _this4;
|
|
120
82
|
}
|
|
121
|
-
|
|
122
83
|
return _createClass(GetAuthTokenFailure);
|
|
123
84
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
124
|
-
|
|
125
85
|
exports.GetAuthTokenFailure = GetAuthTokenFailure;
|
|
126
|
-
|
|
127
86
|
var NoHashOrQueryParamsError = /*#__PURE__*/function (_Error5) {
|
|
128
87
|
_inherits(NoHashOrQueryParamsError, _Error5);
|
|
129
|
-
|
|
130
88
|
var _super5 = _createSuper(NoHashOrQueryParamsError);
|
|
131
|
-
|
|
132
89
|
function NoHashOrQueryParamsError() {
|
|
133
90
|
var _this5;
|
|
134
|
-
|
|
135
91
|
_classCallCheck(this, NoHashOrQueryParamsError);
|
|
136
|
-
|
|
137
92
|
_this5 = _super5.call(this);
|
|
138
93
|
_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.";
|
|
139
94
|
_this5.name = 'Fatal Error';
|
|
140
95
|
_this5.stack = '';
|
|
141
96
|
return _this5;
|
|
142
97
|
}
|
|
143
|
-
|
|
144
98
|
return _createClass(NoHashOrQueryParamsError);
|
|
145
99
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
146
|
-
|
|
147
100
|
exports.NoHashOrQueryParamsError = NoHashOrQueryParamsError;
|
|
@@ -1,55 +1,44 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
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
12
|
var _twitter = require("./assets/twitter.svg");
|
|
17
|
-
|
|
18
13
|
var _utils = require("./utils");
|
|
19
|
-
|
|
20
14
|
var _errors = require("./errors");
|
|
21
|
-
|
|
22
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
16
|
+
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; }
|
|
24
17
|
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
18
|
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
19
|
var TwitterLogin = function TwitterLogin(_ref) {
|
|
29
20
|
var screenName = _ref.screenName,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
requestTokenUrl = _ref.requestTokenUrl,
|
|
22
|
+
credentials = _ref.credentials,
|
|
23
|
+
loginUrl = _ref.loginUrl,
|
|
24
|
+
onFailure = _ref.onFailure,
|
|
25
|
+
onSuccess = _ref.onSuccess,
|
|
26
|
+
customHeaders = _ref.customHeaders,
|
|
27
|
+
dialogWidth = _ref.dialogWidth,
|
|
28
|
+
dialogHeight = _ref.dialogHeight,
|
|
29
|
+
disabled = _ref.disabled,
|
|
30
|
+
text = _ref.text,
|
|
31
|
+
style = _ref.style,
|
|
32
|
+
showIcon = _ref.showIcon,
|
|
33
|
+
className = _ref.className,
|
|
34
|
+
forceLogin = _ref.forceLogin,
|
|
35
|
+
children = _ref.children;
|
|
46
36
|
var handleUrlChange = function handleUrlChange(popup) {
|
|
47
37
|
var interval = (0, _function.polling)(function () {
|
|
48
38
|
if (!popup || popup.closed || popup.closed === undefined) {
|
|
49
39
|
clearInterval(interval);
|
|
50
40
|
onFailure(new _errors.PopupClosedByUserError());
|
|
51
41
|
}
|
|
52
|
-
|
|
53
42
|
try {
|
|
54
43
|
if (popup.location.hostname !== '' && !(0, _utils.isTwitterUrl)(popup.location.hostname)) {
|
|
55
44
|
if (popup.location.search) {
|
|
@@ -60,48 +49,40 @@ var TwitterLogin = function TwitterLogin(_ref) {
|
|
|
60
49
|
} else {
|
|
61
50
|
onFailure(new _errors.NoHashOrQueryParamsError());
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
(0, _utils.closePopup)(interval, popup);
|
|
65
53
|
}
|
|
66
|
-
} catch (error) {
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// Ignore DOMException: Blocked a frame with origin from accessing a cross-origin frame.
|
|
67
56
|
// A hack to get around same-origin security policy errors in IE.
|
|
68
57
|
}
|
|
69
58
|
}, 0);
|
|
70
59
|
};
|
|
71
|
-
|
|
72
60
|
var authenticate = /*#__PURE__*/function () {
|
|
73
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
61
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
74
62
|
var authUrl, popup;
|
|
75
|
-
return
|
|
76
|
-
while (1) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
case 5:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
63
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
|
+
while (1) switch (_context.prev = _context.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
_context.next = 2;
|
|
67
|
+
return (0, _utils.getAuthUrl)(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin);
|
|
68
|
+
case 2:
|
|
69
|
+
authUrl = _context.sent;
|
|
70
|
+
popup = (0, _utils.openPopup)(authUrl, dialogWidth, dialogHeight);
|
|
71
|
+
handleUrlChange(popup);
|
|
72
|
+
case 5:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
91
75
|
}
|
|
92
76
|
}, _callee);
|
|
93
77
|
}));
|
|
94
|
-
|
|
95
78
|
return function authenticate() {
|
|
96
79
|
return _ref2.apply(this, arguments);
|
|
97
80
|
};
|
|
98
81
|
}();
|
|
99
|
-
|
|
100
82
|
var handleClick = function handleClick(event) {
|
|
101
83
|
event.preventDefault();
|
|
102
84
|
return authenticate();
|
|
103
85
|
};
|
|
104
|
-
|
|
105
86
|
var getDefaultButtonContent = function getDefaultButtonContent() {
|
|
106
87
|
var defaultIcon = showIcon ? /*#__PURE__*/_react.default.createElement(_twitter.ReactComponent, {
|
|
107
88
|
color: "#00aced",
|
|
@@ -109,7 +90,6 @@ var TwitterLogin = function TwitterLogin(_ref) {
|
|
|
109
90
|
}) : null;
|
|
110
91
|
return /*#__PURE__*/_react.default.createElement("span", null, defaultIcon, " ", text);
|
|
111
92
|
};
|
|
112
|
-
|
|
113
93
|
return /*#__PURE__*/_react.default.createElement("tag", {
|
|
114
94
|
onClick: handleClick,
|
|
115
95
|
style: style,
|
|
@@ -117,7 +97,6 @@ var TwitterLogin = function TwitterLogin(_ref) {
|
|
|
117
97
|
className: className
|
|
118
98
|
}, children || getDefaultButtonContent());
|
|
119
99
|
};
|
|
120
|
-
|
|
121
100
|
TwitterLogin.propTypes = {
|
|
122
101
|
text: _propTypes.string,
|
|
123
102
|
loginUrl: _propTypes.string.isRequired,
|
|
@@ -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(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
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
|
-
function
|
|
15
|
-
|
|
16
|
-
function
|
|
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
|
-
|
|
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); }
|
|
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__*/
|
|
24
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin) {
|
|
31
25
|
var response, data, authenticationUrl;
|
|
32
|
-
return
|
|
33
|
-
while (1) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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 }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widergy/react-social-auth",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Social Network Authorization (Twitter, Facebook, etc.)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@azure/msal-browser": "^2.12.0",
|
|
61
61
|
"@widergy/web-utils": "^1.5.0",
|
|
62
|
-
"node-sass": "^
|
|
63
|
-
"sass-loader": "^
|
|
62
|
+
"node-sass": "^8.0.0",
|
|
63
|
+
"sass-loader": "^10.0.5"
|
|
64
64
|
},
|
|
65
65
|
"husky": {
|
|
66
66
|
"hooks": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# [1.3.0](https://github.com/widergy/react-social-auth/compare/v1.2.1...v1.3.0) (2022-01-17)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* added optional authority param ([#9](https://github.com/widergy/react-social-auth/issues/9)) ([ce1a609](https://github.com/widergy/react-social-auth/commit/ce1a60977d952b43567a17b4eeaedfb4f1908614))
|
|
7
|
-
|
|
8
|
-
## [1.2.1](https://github.com/widergy/react-social-auth/compare/v1.2.0...v1.2.1) (2021-04-08)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* ad login fix ([#8](https://github.com/widergy/react-social-auth/issues/8)) ([95d7964](https://github.com/widergy/react-social-auth/commit/95d79643f500c4a531e430cb5980e10dc1164c06))
|
|
14
|
-
|
|
15
|
-
# [1.2.0](https://github.com/widergy/react-social-auth/compare/v1.1.2...v1.2.0) (2021-04-08)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
* active directory login ([#7](https://github.com/widergy/react-social-auth/issues/7)) ([b1a8cc5](https://github.com/widergy/react-social-auth/commit/b1a8cc5d9a19eb15a3518eee4d0276d1109d49f4))
|
|
21
|
-
|
|
22
|
-
## [1.1.2](https://github.com/widergy/react-social-auth/compare/v1.1.1...v1.1.2) (2020-09-11)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* Apple component can now take non default src ([#6](https://github.com/widergy/react-social-auth/issues/6)) ([2115581](https://github.com/widergy/react-social-auth/commit/2115581cf52cd062dba4c20619ff51513bdc374d))
|
|
28
|
-
|
|
29
|
-
## [1.1.1](https://github.com/widergy/react-social-auth/compare/v1.1.0...v1.1.1) (2020-07-29)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* Finished apple log in ([#5](https://github.com/widergy/react-social-auth/issues/5)) ([987645d](https://github.com/widergy/react-social-auth/commit/987645db8344dd546ddb2f15cddc2efdc3483624))
|
|
35
|
-
|
|
36
|
-
# [1.1.0](https://github.com/widergy/react-social-auth/compare/v1.0.0...v1.1.0) (2020-07-24)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* added apple log in ([#4](https://github.com/widergy/react-social-auth/issues/4)) ([3125a94](https://github.com/widergy/react-social-auth/commit/3125a9490923f925364b19e39fd1a7b68c284b0c))
|
|
42
|
-
|
|
43
|
-
# 1.0.0 (2019-12-18)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Features
|
|
47
|
-
|
|
48
|
-
* added twitter auth ([#3](https://github.com/widergy/react-social-auth/issues/3)) ([5123a17](https://github.com/widergy/react-social-auth/commit/5123a17fab4ba7a4f461e56b78dfd4dbe58bf935))
|