@widergy/react-social-auth 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/ActiveDirectory/index.js +177 -0
- package/dist/components/ActiveDirectory/utils.js +29 -0
- package/dist/components/Apple/components/LargeButton/index.js +28 -19
- package/dist/components/Apple/components/LargeButton/styles.module.scss +0 -1
- package/dist/components/Apple/components/SmallButton/index.js +18 -12
- package/dist/components/Apple/index.js +53 -37
- package/dist/components/Apple/types.js +16 -0
- package/dist/components/Apple/utils.js +25 -21
- package/dist/components/Twitter/errors.js +118 -40
- package/dist/components/Twitter/index.js +44 -45
- package/dist/components/Twitter/utils.js +78 -70
- package/dist/index.js +10 -2
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
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
|
+
|
|
1
29
|
## [1.1.1](https://github.com/widergy/react-social-auth/compare/v1.1.0...v1.1.1) (2020-07-29)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = require("prop-types");
|
|
13
|
+
|
|
14
|
+
var _msalBrowser = require("@azure/msal-browser");
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
|
|
18
|
+
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
|
+
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
|
+
|
|
22
|
+
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
|
+
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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
|
+
|
|
32
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
+
|
|
34
|
+
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
|
+
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 _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; }
|
|
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
|
+
|
|
42
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
+
|
|
44
|
+
var ActiveDirectory = function ActiveDirectory(_ref) {
|
|
45
|
+
var Component = _ref.Component,
|
|
46
|
+
authority = _ref.authority,
|
|
47
|
+
onSuccess = _ref.onSuccess,
|
|
48
|
+
onFailure = _ref.onFailure,
|
|
49
|
+
clientId = _ref.clientId,
|
|
50
|
+
redirectUri = _ref.redirectUri,
|
|
51
|
+
scopes = _ref.scopes;
|
|
52
|
+
|
|
53
|
+
var _useState = (0, _react.useState)(new _msalBrowser.PublicClientApplication({
|
|
54
|
+
auth: _objectSpread({
|
|
55
|
+
clientId: clientId,
|
|
56
|
+
redirectUri: redirectUri
|
|
57
|
+
}, authority ? {
|
|
58
|
+
authority: authority
|
|
59
|
+
} : {}),
|
|
60
|
+
cache: {
|
|
61
|
+
cacheLocation: 'sessionStorage',
|
|
62
|
+
storeAuthStateInCookie: true
|
|
63
|
+
}
|
|
64
|
+
})),
|
|
65
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
66
|
+
publicClientApplication = _useState2[0];
|
|
67
|
+
|
|
68
|
+
var getAccessToken = /*#__PURE__*/function () {
|
|
69
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(selectedAccount) {
|
|
70
|
+
var accounts, account, silentResult;
|
|
71
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
_context.prev = 0;
|
|
76
|
+
accounts = publicClientApplication.getAllAccounts();
|
|
77
|
+
account = accounts.find(function (_account) {
|
|
78
|
+
return _account.homeAccountId === selectedAccount.homeAccountId;
|
|
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;
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case 11:
|
|
104
|
+
_context.prev = 11;
|
|
105
|
+
_context.t0 = _context["catch"](0);
|
|
106
|
+
if (onFailure) onFailure((0, _utils.normalizeError)(_context.t0));
|
|
107
|
+
|
|
108
|
+
case 14:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, _callee, null, [[0, 11]]);
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
return function getAccessToken(_x) {
|
|
117
|
+
return _ref2.apply(this, arguments);
|
|
118
|
+
};
|
|
119
|
+
}();
|
|
120
|
+
|
|
121
|
+
var handleLogin = /*#__PURE__*/function () {
|
|
122
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
123
|
+
var response;
|
|
124
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
125
|
+
while (1) {
|
|
126
|
+
switch (_context2.prev = _context2.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
_context2.prev = 0;
|
|
129
|
+
_context2.next = 3;
|
|
130
|
+
return publicClientApplication.loginPopup({
|
|
131
|
+
scopes: scopes,
|
|
132
|
+
prompt: 'select_account'
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
case 3:
|
|
136
|
+
response = _context2.sent;
|
|
137
|
+
_context2.next = 6;
|
|
138
|
+
return getAccessToken(response.account);
|
|
139
|
+
|
|
140
|
+
case 6:
|
|
141
|
+
_context2.next = 11;
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case 8:
|
|
145
|
+
_context2.prev = 8;
|
|
146
|
+
_context2.t0 = _context2["catch"](0);
|
|
147
|
+
if (onFailure) onFailure((0, _utils.normalizeError)(_context2.t0));
|
|
148
|
+
|
|
149
|
+
case 11:
|
|
150
|
+
case "end":
|
|
151
|
+
return _context2.stop();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, _callee2, null, [[0, 8]]);
|
|
155
|
+
}));
|
|
156
|
+
|
|
157
|
+
return function handleLogin() {
|
|
158
|
+
return _ref3.apply(this, arguments);
|
|
159
|
+
};
|
|
160
|
+
}();
|
|
161
|
+
|
|
162
|
+
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
163
|
+
onLogin: handleLogin
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
ActiveDirectory.propTypes = {
|
|
168
|
+
Component: _propTypes.node,
|
|
169
|
+
authority: _propTypes.string,
|
|
170
|
+
onSuccess: _propTypes.func,
|
|
171
|
+
onFailure: _propTypes.func,
|
|
172
|
+
clientId: _propTypes.string,
|
|
173
|
+
redirectUri: _propTypes.string,
|
|
174
|
+
scopes: (0, _propTypes.arrayOf)(_propTypes.string)
|
|
175
|
+
};
|
|
176
|
+
var _default = ActiveDirectory;
|
|
177
|
+
exports.default = _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeError = void 0;
|
|
7
|
+
|
|
8
|
+
var normalizeError = function normalizeError(error) {
|
|
9
|
+
var normalizedError = {};
|
|
10
|
+
|
|
11
|
+
if (typeof error === 'string') {
|
|
12
|
+
var errParts = error.split('|');
|
|
13
|
+
normalizedError = errParts.length > 1 ? {
|
|
14
|
+
message: errParts[1],
|
|
15
|
+
debug: errParts[0]
|
|
16
|
+
} : {
|
|
17
|
+
message: error
|
|
18
|
+
};
|
|
19
|
+
} else {
|
|
20
|
+
normalizedError = {
|
|
21
|
+
message: error.message,
|
|
22
|
+
debug: JSON.stringify(error)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return normalizedError;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.normalizeError = normalizeError;
|
|
@@ -13,33 +13,42 @@ var _propTypes = require("prop-types");
|
|
|
13
13
|
|
|
14
14
|
var _apple = _interopRequireDefault(require("../../assets/apple.svg"));
|
|
15
15
|
|
|
16
|
+
var _types = require("../../types");
|
|
17
|
+
|
|
16
18
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
onClick,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
var LargeButton = function LargeButton(_ref) {
|
|
23
|
+
var onClick = _ref.onClick,
|
|
24
|
+
label = _ref.label,
|
|
25
|
+
_ref$classes = _ref.classes,
|
|
26
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
27
|
+
icon = _ref.icon,
|
|
28
|
+
uppercase = _ref.uppercase;
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_energyUi.UTButton, {
|
|
30
|
+
onPress: onClick,
|
|
31
|
+
className: "".concat(_stylesModule.default.button, " ").concat(classes.root)
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
className: "".concat(_stylesModule.default.content, " ").concat(classes.content)
|
|
34
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
35
|
+
src: icon || _apple.default,
|
|
36
|
+
alt: "",
|
|
37
|
+
className: "".concat(_stylesModule.default.icon, " ").concat(classes.largeIcon)
|
|
38
|
+
}), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
39
|
+
uppercase: uppercase,
|
|
40
|
+
bold: true,
|
|
41
|
+
white: true,
|
|
42
|
+
className: "".concat(_stylesModule.default.label, " ").concat(classes.label)
|
|
43
|
+
}, label)));
|
|
44
|
+
};
|
|
38
45
|
|
|
39
46
|
LargeButton.propTypes = {
|
|
40
47
|
onClick: _propTypes.func,
|
|
41
48
|
label: _propTypes.string,
|
|
42
|
-
classes:
|
|
49
|
+
classes: _types.classesType,
|
|
50
|
+
icon: _propTypes.string,
|
|
51
|
+
uppercase: _propTypes.bool
|
|
43
52
|
};
|
|
44
53
|
var _default = LargeButton;
|
|
45
54
|
exports.default = _default;
|
|
@@ -13,25 +13,31 @@ var _propTypes = require("prop-types");
|
|
|
13
13
|
|
|
14
14
|
var _apple = _interopRequireDefault(require("../../assets/apple.svg"));
|
|
15
15
|
|
|
16
|
+
var _types = require("../../types");
|
|
17
|
+
|
|
16
18
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
onClick,
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
var SmallButton = function SmallButton(_ref) {
|
|
23
|
+
var onClick = _ref.onClick,
|
|
24
|
+
_ref$classes = _ref.classes,
|
|
25
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
26
|
+
icon = _ref.icon;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_energyUi.UTIconButton, {
|
|
28
|
+
className: "".concat(_stylesModule.default.button, " ").concat(classes.root),
|
|
29
|
+
onClick: onClick
|
|
30
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
31
|
+
src: icon || _apple.default,
|
|
32
|
+
alt: "",
|
|
33
|
+
className: classes.smallIcon
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
31
36
|
|
|
32
37
|
SmallButton.propTypes = {
|
|
33
38
|
onClick: _propTypes.func,
|
|
34
|
-
classes:
|
|
39
|
+
classes: _types.classesType,
|
|
40
|
+
icon: _propTypes.string
|
|
35
41
|
};
|
|
36
42
|
var _default = SmallButton;
|
|
37
43
|
exports.default = _default;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -13,65 +15,77 @@ var _LargeButton = _interopRequireDefault(require("./components/LargeButton"));
|
|
|
13
15
|
|
|
14
16
|
var _SmallButton = _interopRequireDefault(require("./components/SmallButton"));
|
|
15
17
|
|
|
18
|
+
var _types = require("./types");
|
|
19
|
+
|
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
21
|
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
22
|
+
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
23
|
|
|
20
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
24
|
+
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
25
|
|
|
22
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
23
27
|
|
|
24
28
|
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
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onSuccess,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
var SMALL_VARIANT = 'small';
|
|
31
|
+
|
|
32
|
+
var Apple = function Apple(_ref) {
|
|
33
|
+
var onSuccess = _ref.onSuccess,
|
|
34
|
+
onFailure = _ref.onFailure,
|
|
35
|
+
_ref$classes = _ref.classes,
|
|
36
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
37
|
+
_ref$label = _ref.label,
|
|
38
|
+
label = _ref$label === void 0 ? 'apple' : _ref$label,
|
|
39
|
+
_ref$variant = _ref.variant,
|
|
40
|
+
variant = _ref$variant === void 0 ? SMALL_VARIANT : _ref$variant,
|
|
41
|
+
Component = _ref.Component,
|
|
42
|
+
icon = _ref.icon,
|
|
43
|
+
uppercase = _ref.uppercase;
|
|
44
|
+
|
|
45
|
+
var handleLogin = /*#__PURE__*/function () {
|
|
46
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
38
47
|
var data;
|
|
39
48
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
40
|
-
while (1)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
_context.prev = 0;
|
|
53
|
+
_context.next = 3;
|
|
54
|
+
return window.AppleID.auth.signIn();
|
|
55
|
+
|
|
56
|
+
case 3:
|
|
57
|
+
data = _context.sent;
|
|
58
|
+
if (onSuccess) onSuccess(data);
|
|
59
|
+
_context.next = 10;
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 7:
|
|
63
|
+
_context.prev = 7;
|
|
64
|
+
_context.t0 = _context["catch"](0);
|
|
65
|
+
if (onFailure) onFailure(_context.t0);
|
|
66
|
+
|
|
67
|
+
case 10:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
60
71
|
}
|
|
61
72
|
}, _callee, null, [[0, 7]]);
|
|
62
73
|
}));
|
|
63
74
|
|
|
64
75
|
return function handleLogin() {
|
|
65
|
-
return
|
|
76
|
+
return _ref2.apply(this, arguments);
|
|
66
77
|
};
|
|
67
78
|
}();
|
|
68
79
|
|
|
69
80
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, Component ? /*#__PURE__*/_react.default.createElement(Component, {
|
|
70
81
|
onClick: handleLogin
|
|
71
82
|
}) : variant === SMALL_VARIANT ? /*#__PURE__*/_react.default.createElement(_SmallButton.default, {
|
|
83
|
+
icon: icon,
|
|
72
84
|
onClick: handleLogin,
|
|
73
85
|
classes: classes
|
|
74
86
|
}) : /*#__PURE__*/_react.default.createElement(_LargeButton.default, {
|
|
87
|
+
uppercase: uppercase,
|
|
88
|
+
icon: icon,
|
|
75
89
|
onClick: handleLogin,
|
|
76
90
|
label: label,
|
|
77
91
|
classes: classes
|
|
@@ -81,10 +95,12 @@ const Apple = ({
|
|
|
81
95
|
Apple.propTypes = {
|
|
82
96
|
onSuccess: _propTypes.func.required,
|
|
83
97
|
onFailure: _propTypes.func.required,
|
|
84
|
-
classes:
|
|
98
|
+
classes: _types.classesType,
|
|
85
99
|
label: _propTypes.string,
|
|
86
100
|
variant: _propTypes.string,
|
|
87
|
-
Component: _propTypes.node
|
|
101
|
+
Component: _propTypes.node,
|
|
102
|
+
icon: _propTypes.string,
|
|
103
|
+
uppercase: _propTypes.bool
|
|
88
104
|
};
|
|
89
105
|
var _default = Apple;
|
|
90
106
|
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.classesType = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
|
|
10
|
+
var classesType = (0, _propTypes.shape)({
|
|
11
|
+
root: _propTypes.string,
|
|
12
|
+
smallIcon: _propTypes.string,
|
|
13
|
+
largeIcon: _propTypes.string,
|
|
14
|
+
label: _propTypes.string
|
|
15
|
+
});
|
|
16
|
+
exports.classesType = classesType;
|
|
@@ -9,30 +9,34 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
9
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
11
|
|
|
12
|
-
|
|
12
|
+
var initAppleAuth = /*#__PURE__*/function () {
|
|
13
13
|
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(clientId, scope, redirectUrl) {
|
|
14
14
|
var head, script;
|
|
15
15
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
|
-
while (1)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
while (1) {
|
|
17
|
+
switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
head = document.getElementsByTagName('head')[0];
|
|
20
|
+
script = document.createElement('script');
|
|
21
|
+
script.type = 'text/javascript';
|
|
22
|
+
script.src = 'https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js';
|
|
23
|
+
|
|
24
|
+
script.onload = function () {
|
|
25
|
+
return window.AppleID.auth.init({
|
|
26
|
+
clientId: clientId,
|
|
27
|
+
scope: scope,
|
|
28
|
+
usePopup: true,
|
|
29
|
+
redirectURI: redirectUrl
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
_context.next = 7;
|
|
34
|
+
return head.appendChild(script);
|
|
35
|
+
|
|
36
|
+
case 7:
|
|
37
|
+
case "end":
|
|
38
|
+
return _context.stop();
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
}, _callee);
|
|
38
42
|
}));
|
|
@@ -1,69 +1,147 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
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
|
+
|
|
12
|
+
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
|
+
|
|
14
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
|
|
16
|
+
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
|
+
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
|
+
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
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
+
|
|
24
|
+
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
|
+
|
|
28
|
+
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
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
31
|
+
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
|
+
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
+
|
|
36
|
+
var RequestTokenError = /*#__PURE__*/function (_Error) {
|
|
37
|
+
_inherits(RequestTokenError, _Error);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(RequestTokenError);
|
|
40
|
+
|
|
41
|
+
function RequestTokenError(error) {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
_classCallCheck(this, RequestTokenError);
|
|
45
|
+
|
|
46
|
+
_this = _super.call(this);
|
|
47
|
+
_this.message = 'Unable to retrieve OAuth Token';
|
|
48
|
+
_this.name = 'Fatal Error';
|
|
49
|
+
_this.stack = '';
|
|
50
|
+
_this.error = error;
|
|
51
|
+
return _this;
|
|
15
52
|
}
|
|
16
53
|
|
|
17
|
-
|
|
54
|
+
return _createClass(RequestTokenError);
|
|
55
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
18
56
|
|
|
19
57
|
exports.RequestTokenError = RequestTokenError;
|
|
20
58
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
59
|
+
var RequestTokenParseError = /*#__PURE__*/function (_Error2) {
|
|
60
|
+
_inherits(RequestTokenParseError, _Error2);
|
|
61
|
+
|
|
62
|
+
var _super2 = _createSuper(RequestTokenParseError);
|
|
63
|
+
|
|
64
|
+
function RequestTokenParseError(error) {
|
|
65
|
+
var _this2;
|
|
66
|
+
|
|
67
|
+
_classCallCheck(this, RequestTokenParseError);
|
|
68
|
+
|
|
69
|
+
_this2 = _super2.call(this);
|
|
70
|
+
_this2.message = 'Unable to parse JSON from response';
|
|
71
|
+
_this2.name = 'Fatal Error';
|
|
72
|
+
_this2.stack = '';
|
|
73
|
+
_this2.error = error;
|
|
74
|
+
return _this2;
|
|
28
75
|
}
|
|
29
76
|
|
|
30
|
-
|
|
77
|
+
return _createClass(RequestTokenParseError);
|
|
78
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
31
79
|
|
|
32
80
|
exports.RequestTokenParseError = RequestTokenParseError;
|
|
33
81
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
82
|
+
var PopupClosedByUserError = /*#__PURE__*/function (_Error3) {
|
|
83
|
+
_inherits(PopupClosedByUserError, _Error3);
|
|
84
|
+
|
|
85
|
+
var _super3 = _createSuper(PopupClosedByUserError);
|
|
86
|
+
|
|
87
|
+
function PopupClosedByUserError() {
|
|
88
|
+
var _this3;
|
|
89
|
+
|
|
90
|
+
_classCallCheck(this, PopupClosedByUserError);
|
|
91
|
+
|
|
92
|
+
_this3 = _super3.call(this);
|
|
93
|
+
_this3.message = 'Popup has been closed by user';
|
|
94
|
+
_this3.name = 'Info';
|
|
95
|
+
_this3.stack = '';
|
|
96
|
+
return _this3;
|
|
40
97
|
}
|
|
41
98
|
|
|
42
|
-
|
|
99
|
+
return _createClass(PopupClosedByUserError);
|
|
100
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
43
101
|
|
|
44
102
|
exports.PopupClosedByUserError = PopupClosedByUserError;
|
|
45
103
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
104
|
+
var GetAuthTokenFailure = /*#__PURE__*/function (_Error4) {
|
|
105
|
+
_inherits(GetAuthTokenFailure, _Error4);
|
|
106
|
+
|
|
107
|
+
var _super4 = _createSuper(GetAuthTokenFailure);
|
|
108
|
+
|
|
109
|
+
function GetAuthTokenFailure(error, url, verifier, token) {
|
|
110
|
+
var _this4;
|
|
111
|
+
|
|
112
|
+
_classCallCheck(this, GetAuthTokenFailure);
|
|
113
|
+
|
|
114
|
+
_this4 = _super4.call(this);
|
|
115
|
+
_this4.message = "Unable to retrieve Authorization Token from ".concat(url, "\n OAuth Verifier: ").concat(verifier, " \n OAuth Token: ").concat(token, " ");
|
|
116
|
+
_this4.name = 'Fatal Error';
|
|
117
|
+
_this4.stack = '';
|
|
118
|
+
_this4.error = error;
|
|
119
|
+
return _this4;
|
|
53
120
|
}
|
|
54
121
|
|
|
55
|
-
|
|
122
|
+
return _createClass(GetAuthTokenFailure);
|
|
123
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
56
124
|
|
|
57
125
|
exports.GetAuthTokenFailure = GetAuthTokenFailure;
|
|
58
126
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
127
|
+
var NoHashOrQueryParamsError = /*#__PURE__*/function (_Error5) {
|
|
128
|
+
_inherits(NoHashOrQueryParamsError, _Error5);
|
|
129
|
+
|
|
130
|
+
var _super5 = _createSuper(NoHashOrQueryParamsError);
|
|
131
|
+
|
|
132
|
+
function NoHashOrQueryParamsError() {
|
|
133
|
+
var _this5;
|
|
134
|
+
|
|
135
|
+
_classCallCheck(this, NoHashOrQueryParamsError);
|
|
136
|
+
|
|
137
|
+
_this5 = _super5.call(this);
|
|
138
|
+
_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
|
+
_this5.name = 'Fatal Error';
|
|
140
|
+
_this5.stack = '';
|
|
141
|
+
return _this5;
|
|
65
142
|
}
|
|
66
143
|
|
|
67
|
-
|
|
144
|
+
return _createClass(NoHashOrQueryParamsError);
|
|
145
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
68
146
|
|
|
69
147
|
exports.NoHashOrQueryParamsError = NoHashOrQueryParamsError;
|
|
@@ -25,27 +25,26 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
25
25
|
|
|
26
26
|
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
27
|
|
|
28
|
-
|
|
29
|
-
screenName,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const interval = (0, _function.polling)(() => {
|
|
28
|
+
var TwitterLogin = function TwitterLogin(_ref) {
|
|
29
|
+
var screenName = _ref.screenName,
|
|
30
|
+
requestTokenUrl = _ref.requestTokenUrl,
|
|
31
|
+
credentials = _ref.credentials,
|
|
32
|
+
loginUrl = _ref.loginUrl,
|
|
33
|
+
onFailure = _ref.onFailure,
|
|
34
|
+
onSuccess = _ref.onSuccess,
|
|
35
|
+
customHeaders = _ref.customHeaders,
|
|
36
|
+
dialogWidth = _ref.dialogWidth,
|
|
37
|
+
dialogHeight = _ref.dialogHeight,
|
|
38
|
+
disabled = _ref.disabled,
|
|
39
|
+
text = _ref.text,
|
|
40
|
+
style = _ref.style,
|
|
41
|
+
showIcon = _ref.showIcon,
|
|
42
|
+
className = _ref.className,
|
|
43
|
+
forceLogin = _ref.forceLogin,
|
|
44
|
+
children = _ref.children;
|
|
45
|
+
|
|
46
|
+
var handleUrlChange = function handleUrlChange(popup) {
|
|
47
|
+
var interval = (0, _function.polling)(function () {
|
|
49
48
|
if (!popup || popup.closed || popup.closed === undefined) {
|
|
50
49
|
clearInterval(interval);
|
|
51
50
|
onFailure(new _errors.PopupClosedByUserError());
|
|
@@ -54,9 +53,9 @@ const TwitterLogin = ({
|
|
|
54
53
|
try {
|
|
55
54
|
if (popup.location.hostname !== '' && !(0, _utils.isTwitterUrl)(popup.location.hostname)) {
|
|
56
55
|
if (popup.location.search) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
var query = new URLSearchParams(popup.location.search);
|
|
57
|
+
var OAuthToken = query.get('oauth_token');
|
|
58
|
+
var OAuthVerifier = query.get('oauth_verifier');
|
|
60
59
|
(0, _utils.getAuthToken)(OAuthVerifier, OAuthToken, loginUrl, credentials, onSuccess, onFailure, customHeaders);
|
|
61
60
|
} else {
|
|
62
61
|
onFailure(new _errors.NoHashOrQueryParamsError());
|
|
@@ -70,39 +69,41 @@ const TwitterLogin = ({
|
|
|
70
69
|
}, 0);
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
var
|
|
72
|
+
var authenticate = /*#__PURE__*/function () {
|
|
73
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
75
74
|
var authUrl, popup;
|
|
76
75
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
77
|
-
while (1)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
while (1) {
|
|
77
|
+
switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_context.next = 2;
|
|
80
|
+
return (0, _utils.getAuthUrl)(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin);
|
|
81
|
+
|
|
82
|
+
case 2:
|
|
83
|
+
authUrl = _context.sent;
|
|
84
|
+
popup = (0, _utils.openPopup)(authUrl, dialogWidth, dialogHeight);
|
|
85
|
+
handleUrlChange(popup);
|
|
86
|
+
|
|
87
|
+
case 5:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
92
|
}, _callee);
|
|
92
93
|
}));
|
|
93
94
|
|
|
94
95
|
return function authenticate() {
|
|
95
|
-
return
|
|
96
|
+
return _ref2.apply(this, arguments);
|
|
96
97
|
};
|
|
97
98
|
}();
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
var handleClick = function handleClick(event) {
|
|
100
101
|
event.preventDefault();
|
|
101
102
|
return authenticate();
|
|
102
103
|
};
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
var getDefaultButtonContent = function getDefaultButtonContent() {
|
|
106
|
+
var defaultIcon = showIcon ? /*#__PURE__*/_react.default.createElement(_twitter.ReactComponent, {
|
|
106
107
|
color: "#00aced",
|
|
107
108
|
size: 25
|
|
108
109
|
}) : null;
|
|
@@ -118,7 +119,6 @@ const TwitterLogin = ({
|
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
TwitterLogin.propTypes = {
|
|
121
|
-
tag: _propTypes.string,
|
|
122
122
|
text: _propTypes.string,
|
|
123
123
|
loginUrl: _propTypes.string.isRequired,
|
|
124
124
|
requestTokenUrl: _propTypes.string.isRequired,
|
|
@@ -136,7 +136,6 @@ TwitterLogin.propTypes = {
|
|
|
136
136
|
screenName: _propTypes.string
|
|
137
137
|
};
|
|
138
138
|
TwitterLogin.defaultProps = {
|
|
139
|
-
tag: 'button',
|
|
140
139
|
text: 'Sign in with Twitter',
|
|
141
140
|
disabled: false,
|
|
142
141
|
dialogWidth: 600,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.openPopup = exports.isTwitterUrl = exports.getAuthUrl = exports.getAuthToken = exports.createHeaders = exports.closePopup = void 0;
|
|
7
7
|
|
|
8
8
|
var _errors = require("./errors");
|
|
9
9
|
|
|
@@ -11,14 +11,14 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
11
11
|
|
|
12
12
|
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
13
|
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
17
|
|
|
18
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
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
var createHeaders = function createHeaders(customHeaders) {
|
|
21
|
+
var headers = _objectSpread({}, customHeaders);
|
|
22
22
|
|
|
23
23
|
headers['Content-Type'] = 'application/json';
|
|
24
24
|
return headers;
|
|
@@ -26,59 +26,61 @@ const createHeaders = customHeaders => {
|
|
|
26
26
|
|
|
27
27
|
exports.createHeaders = createHeaders;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
var getAuthUrl = /*#__PURE__*/function () {
|
|
30
30
|
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(requestTokenUrl, customHeaders, onFailure, screenName, credentials, forceLogin) {
|
|
31
31
|
var response, data, authenticationUrl;
|
|
32
32
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
33
|
+
while (1) {
|
|
34
|
+
switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
response = null;
|
|
37
|
+
_context.prev = 1;
|
|
38
|
+
_context.next = 4;
|
|
39
|
+
return window.fetch(requestTokenUrl, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
credentials: credentials,
|
|
42
|
+
headers: createHeaders(customHeaders)
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
case 4:
|
|
46
|
+
response = _context.sent;
|
|
47
|
+
_context.next = 10;
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case 7:
|
|
51
|
+
_context.prev = 7;
|
|
52
|
+
_context.t0 = _context["catch"](1);
|
|
53
|
+
return _context.abrupt("return", onFailure(new _errors.RequestTokenError(_context.t0)));
|
|
54
|
+
|
|
55
|
+
case 10:
|
|
56
|
+
data = null;
|
|
57
|
+
_context.prev = 11;
|
|
58
|
+
_context.next = 14;
|
|
59
|
+
return response.json();
|
|
60
|
+
|
|
61
|
+
case 14:
|
|
62
|
+
data = _context.sent;
|
|
63
|
+
_context.next = 20;
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case 17:
|
|
67
|
+
_context.prev = 17;
|
|
68
|
+
_context.t1 = _context["catch"](11);
|
|
69
|
+
return _context.abrupt("return", onFailure(new _errors.RequestTokenParseError(_context.t1)));
|
|
70
|
+
|
|
71
|
+
case 20:
|
|
72
|
+
authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
|
|
73
|
+
|
|
74
|
+
if (screenName) {
|
|
75
|
+
authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return _context.abrupt("return", authenticationUrl);
|
|
79
|
+
|
|
80
|
+
case 23:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context.stop();
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
}, _callee, null, [[1, 7], [11, 17]]);
|
|
84
86
|
}));
|
|
@@ -90,34 +92,40 @@ const getAuthUrl = /*#__PURE__*/function () {
|
|
|
90
92
|
|
|
91
93
|
exports.getAuthUrl = getAuthUrl;
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
var isTwitterUrl = function isTwitterUrl(url) {
|
|
96
|
+
return url.includes('api.twitter.com');
|
|
97
|
+
};
|
|
94
98
|
|
|
95
99
|
exports.isTwitterUrl = isTwitterUrl;
|
|
96
100
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
var openPopup = function openPopup(authUrl, width, height) {
|
|
102
|
+
var w = width;
|
|
103
|
+
var h = height;
|
|
104
|
+
var left = window.innerWidth / 2 - w / 2;
|
|
105
|
+
var top = window.innerHeight / 2 - h / 2;
|
|
106
|
+
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));
|
|
103
107
|
return popup;
|
|
104
108
|
};
|
|
105
109
|
|
|
106
110
|
exports.openPopup = openPopup;
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
var closePopup = function closePopup(interval, popup) {
|
|
109
113
|
clearInterval(interval);
|
|
110
114
|
popup.close();
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
exports.closePopup = closePopup;
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
var getAuthToken = function getAuthToken(OAuthVerifier, OAuthToken, loginUrl, credentials, onSuccess, onFailure, customHeaders) {
|
|
120
|
+
return window.fetch("".concat(loginUrl, "?oauth_verifier=").concat(OAuthVerifier, "&oauth_token=").concat(OAuthToken), {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
credentials: credentials,
|
|
123
|
+
headers: createHeaders(customHeaders)
|
|
124
|
+
}).then(function (response) {
|
|
125
|
+
onSuccess(response);
|
|
126
|
+
}).catch(function (error) {
|
|
127
|
+
return onFailure(new _errors.GetAuthTokenFailure(error, loginUrl, OAuthVerifier, OAuthToken));
|
|
128
|
+
});
|
|
129
|
+
};
|
|
122
130
|
|
|
123
131
|
exports.getAuthToken = getAuthToken;
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "ActiveDirectory", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _ActiveDirectory.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "Apple", {
|
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "Apple", {
|
|
|
15
15
|
return _Apple.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "Twitter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _Twitter.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "initAppleAuth", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
@@ -28,4 +34,6 @@ var _Apple = _interopRequireDefault(require("./components/Apple"));
|
|
|
28
34
|
|
|
29
35
|
var _utils = require("./components/Apple/utils");
|
|
30
36
|
|
|
37
|
+
var _ActiveDirectory = _interopRequireDefault(require("./components/ActiveDirectory"));
|
|
38
|
+
|
|
31
39
|
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
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Social Network Authorization (Twitter, Facebook, etc.)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,16 +26,21 @@
|
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
|
27
27
|
"@babel/preset-env": "^7.3.4",
|
|
28
28
|
"@babel/preset-react": "^7.0.0",
|
|
29
|
+
"@commitlint/cli": "^8.2.0",
|
|
30
|
+
"@commitlint/config-conventional": "^8.2.0",
|
|
31
|
+
"@semantic-release/changelog": "^3.0.6",
|
|
32
|
+
"@semantic-release/git": "^7.0.18",
|
|
29
33
|
"babel-preset-react-app": "^7.0.2",
|
|
34
|
+
"cross-env": "^5.1.4",
|
|
30
35
|
"eslint-config-airbnb": "^17.1.0",
|
|
31
36
|
"eslint-config-prettier": "^3.3.0",
|
|
32
|
-
"eslint-plugin-
|
|
37
|
+
"eslint-plugin-flowtype": "^2.39.1",
|
|
33
38
|
"eslint-plugin-import": "^2.14.0",
|
|
34
39
|
"eslint-plugin-jsx-a11y": "^6.1.1",
|
|
40
|
+
"eslint-plugin-prettier": "^3.0.0",
|
|
35
41
|
"eslint-plugin-react": "^7.11.0",
|
|
36
|
-
"eslint-plugin-flowtype": "^2.39.1",
|
|
37
|
-
"husky": "^1.2.0",
|
|
38
42
|
"gh-pages": "^1.2.0",
|
|
43
|
+
"husky": "^1.2.0",
|
|
39
44
|
"prettier": "^1.7.4",
|
|
40
45
|
"prettier-eslint": "^8.2.1",
|
|
41
46
|
"react": "^16.8.4",
|
|
@@ -43,12 +48,7 @@
|
|
|
43
48
|
"react-scripts": "3.0.0",
|
|
44
49
|
"rimraf": "^2.6.3",
|
|
45
50
|
"sass-lint": "^1.12.1",
|
|
46
|
-
"semantic-release": "^15.13.31"
|
|
47
|
-
"cross-env": "^5.1.4",
|
|
48
|
-
"@commitlint/cli": "^8.2.0",
|
|
49
|
-
"@commitlint/config-conventional": "^8.2.0",
|
|
50
|
-
"@semantic-release/changelog": "^3.0.6",
|
|
51
|
-
"@semantic-release/git": "^7.0.18"
|
|
51
|
+
"semantic-release": "^15.13.31"
|
|
52
52
|
},
|
|
53
53
|
"browserslist": [
|
|
54
54
|
">0.2%",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"not op_mini all"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
+
"@azure/msal-browser": "^2.12.0",
|
|
60
61
|
"@widergy/web-utils": "^1.5.0",
|
|
61
62
|
"node-sass": "^4.11.0",
|
|
62
63
|
"sass-loader": "^7.1.0"
|