@widergy/react-social-auth 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/components/ActiveDirectory/index.js +55 -115
- package/dist/components/ActiveDirectory/utils.js +5 -4
- package/dist/components/Apple/index.js +38 -62
- package/dist/components/Apple/utils.js +14 -34
- package/dist/components/Button/index.js +17 -14
- package/dist/components/ButtonContainer/index.js +14 -24
- package/dist/components/Facebook/index.js +43 -48
- package/dist/components/Google/components/GoogleButton/index.js +20 -21
- package/dist/components/Google/index.js +17 -19
- package/dist/components/Microsoft/index.js +19 -19
- package/dist/components/Microsoft/styles.module.scss +2 -2
- package/dist/components/Twitter/errors.js +43 -84
- package/dist/components/Twitter/index.js +38 -62
- package/dist/components/Twitter/utils.js +47 -82
- package/dist/components/utils.js +3 -2
- package/dist/constants/buttonSizes.js +2 -2
- package/dist/index.js +8 -8
- package/dist/scss/variables/_colors.scss +4 -4
- package/package.json +27 -68
|
@@ -5,94 +5,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.openPopup = exports.isTwitterUrl = exports.getAuthUrl = exports.getAuthToken = exports.createHeaders = exports.closePopup = void 0;
|
|
7
7
|
var _errors = require("./errors");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
-
var createHeaders = exports.createHeaders = function createHeaders(customHeaders) {
|
|
18
|
-
var headers = _objectSpread({}, customHeaders);
|
|
8
|
+
const createHeaders = customHeaders => {
|
|
9
|
+
const headers = {
|
|
10
|
+
...customHeaders
|
|
11
|
+
};
|
|
19
12
|
headers['Content-Type'] = 'application/json';
|
|
20
13
|
return headers;
|
|
21
14
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
data = null;
|
|
46
|
-
_context.prev = 11;
|
|
47
|
-
_context.next = 14;
|
|
48
|
-
return response.json();
|
|
49
|
-
case 14:
|
|
50
|
-
data = _context.sent;
|
|
51
|
-
_context.next = 20;
|
|
52
|
-
break;
|
|
53
|
-
case 17:
|
|
54
|
-
_context.prev = 17;
|
|
55
|
-
_context.t1 = _context["catch"](11);
|
|
56
|
-
return _context.abrupt("return", callback(new _errors.RequestTokenParseError(_context.t1)));
|
|
57
|
-
case 20:
|
|
58
|
-
authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
|
|
59
|
-
if (screenName) {
|
|
60
|
-
authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
|
|
61
|
-
}
|
|
62
|
-
return _context.abrupt("return", authenticationUrl);
|
|
63
|
-
case 23:
|
|
64
|
-
case "end":
|
|
65
|
-
return _context.stop();
|
|
66
|
-
}
|
|
67
|
-
}, _callee, null, [[1, 7], [11, 17]]);
|
|
68
|
-
}));
|
|
69
|
-
return function getAuthUrl(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
70
|
-
return _ref.apply(this, arguments);
|
|
71
|
-
};
|
|
72
|
-
}();
|
|
73
|
-
var isTwitterUrl = exports.isTwitterUrl = function isTwitterUrl(url) {
|
|
74
|
-
return url.includes('api.twitter.com');
|
|
15
|
+
exports.createHeaders = createHeaders;
|
|
16
|
+
const getAuthUrl = async (callback, credentials, customHeaders, forceLogin, requestTokenUrl, screenName) => {
|
|
17
|
+
let response = null;
|
|
18
|
+
try {
|
|
19
|
+
response = await window.fetch(requestTokenUrl, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
credentials,
|
|
22
|
+
headers: createHeaders(customHeaders)
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
return callback(new _errors.RequestTokenError(error));
|
|
26
|
+
}
|
|
27
|
+
let data = null;
|
|
28
|
+
try {
|
|
29
|
+
data = await response.json();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return callback(new _errors.RequestTokenParseError(error));
|
|
32
|
+
}
|
|
33
|
+
let authenticationUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=".concat(data.oauth_token, "&force_login=").concat(forceLogin);
|
|
34
|
+
if (screenName) {
|
|
35
|
+
authenticationUrl = "".concat(authenticationUrl, "&screen_name=").concat(screenName);
|
|
36
|
+
}
|
|
37
|
+
return authenticationUrl;
|
|
75
38
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
39
|
+
exports.getAuthUrl = getAuthUrl;
|
|
40
|
+
const isTwitterUrl = url => url.includes('api.twitter.com');
|
|
41
|
+
exports.isTwitterUrl = isTwitterUrl;
|
|
42
|
+
const openPopup = (authUrl, height, width) => {
|
|
43
|
+
const w = width;
|
|
44
|
+
const h = height;
|
|
45
|
+
const left = window.innerWidth / 2 - w / 2;
|
|
46
|
+
const top = window.innerHeight / 2 - h / 2;
|
|
47
|
+
const popup = window.open(authUrl, '', "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=".concat(w, ", height=").concat(h, ", top=").concat(top, ", left=").concat(left));
|
|
82
48
|
return popup;
|
|
83
49
|
};
|
|
84
|
-
|
|
50
|
+
exports.openPopup = openPopup;
|
|
51
|
+
const closePopup = (interval, popup) => {
|
|
85
52
|
clearInterval(interval);
|
|
86
53
|
popup.close();
|
|
87
54
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
};
|
|
55
|
+
exports.closePopup = closePopup;
|
|
56
|
+
const getAuthToken = (callback, credentials, customHeaders, loginUrl, OAuthToken, OAuthVerifier) => window.fetch("".concat(loginUrl, "?oauth_verifier=").concat(OAuthVerifier, "&oauth_token=").concat(OAuthToken), {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
credentials,
|
|
59
|
+
headers: createHeaders(customHeaders)
|
|
60
|
+
}).then(response => {
|
|
61
|
+
callback(response);
|
|
62
|
+
}).catch(error => callback(new _errors.GetAuthTokenFailure(error, loginUrl, OAuthVerifier, OAuthToken)));
|
|
63
|
+
exports.getAuthToken = getAuthToken;
|
package/dist/components/utils.js
CHANGED
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isValidId = void 0;
|
|
7
|
-
|
|
7
|
+
const isValidId = id => {
|
|
8
8
|
if (typeof id === 'string') {
|
|
9
9
|
return !!id.trim();
|
|
10
10
|
}
|
|
11
11
|
return false;
|
|
12
|
-
};
|
|
12
|
+
};
|
|
13
|
+
exports.isValidId = isValidId;
|
package/dist/index.js
CHANGED
|
@@ -5,49 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "ActiveDirectory", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _ActiveDirectory.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "Apple", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _Apple.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "Button", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _Button.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "ButtonContainer", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _ButtonContainer.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "Facebook", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _Facebook.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "Google", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _Google.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "Microsoft", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function
|
|
44
|
+
get: function () {
|
|
45
45
|
return _Microsoft.default;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "Twitter", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function
|
|
50
|
+
get: function () {
|
|
51
51
|
return _Twitter.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
$black: #000;
|
|
2
|
-
$facebook-bg: #
|
|
2
|
+
$facebook-bg: #4267B2;
|
|
3
3
|
$large-button-shadow: rgba(9, 30, 66, 0.1);
|
|
4
4
|
$small-button-shadow: rgba(24, 44, 73, 0.1);
|
|
5
5
|
$light-black: #252525;
|
|
6
|
-
$microsoft-bg: #
|
|
6
|
+
$microsoft-bg: #2F2F2F;
|
|
7
7
|
$microsoft-button-shadow: rgba(24, 44, 73, 0.1);
|
|
8
|
-
$twitter-bg: #
|
|
9
|
-
$white: #
|
|
8
|
+
$twitter-bg: #00ACED;
|
|
9
|
+
$white: #FFF;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widergy/react-social-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Social Network Authorization (Twitter, Facebook, etc.)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"start": "HTTPS=true react-scripts --openssl-legacy-provider
|
|
13
|
-
"build-example": "react-scripts build",
|
|
12
|
+
"start": "HTTPS=true react-scripts --openssl-legacy-provider start",
|
|
13
|
+
"build-example": "react-scripts --openssl-legacy-provider build",
|
|
14
14
|
"sass-lint": "./node_modules/sass-lint/bin/sass-lint.js -v -q",
|
|
15
15
|
"lint": "./node_modules/eslint/bin/eslint.js src && npm run sass-lint",
|
|
16
16
|
"lint-diff": "git diff --name-only --cached --relative --diff-filter=ACM | grep \\.js$ | xargs ./node_modules/eslint/bin/eslint.js",
|
|
@@ -18,36 +18,36 @@
|
|
|
18
18
|
"eject": "react-scripts eject",
|
|
19
19
|
"prebuild": "rimraf dist",
|
|
20
20
|
"build": "NODE_ENV=production babel src/lib --out-dir dist --copy-files",
|
|
21
|
-
"prepare": "npm run build"
|
|
21
|
+
"prepare": "npm run build && husky install"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/cli": "^7.2.3",
|
|
25
25
|
"@babel/core": "^7.3.4",
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
|
27
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
27
28
|
"@babel/preset-env": "^7.3.4",
|
|
28
29
|
"@babel/preset-react": "^7.0.0",
|
|
29
|
-
"@commitlint/cli": "^
|
|
30
|
-
"@commitlint/config-conventional": "^
|
|
31
|
-
"@semantic-release
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"eslint-config-
|
|
36
|
-
"eslint-
|
|
37
|
-
"eslint-plugin-flowtype": "^2.39.1",
|
|
30
|
+
"@commitlint/cli": "^17.7.1",
|
|
31
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
32
|
+
"@widergy/semantic-release-package-config": "^1.0.0",
|
|
33
|
+
"babel-preset-react-app": "^10.0.1",
|
|
34
|
+
"cross-env": "^7.0.3",
|
|
35
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
36
|
+
"eslint-config-prettier": "^9.0.0",
|
|
37
|
+
"eslint-plugin-flowtype": "^8.0.3",
|
|
38
38
|
"eslint-plugin-import": "^2.14.0",
|
|
39
39
|
"eslint-plugin-jsx-a11y": "^6.1.1",
|
|
40
|
-
"eslint-plugin-prettier": "^
|
|
40
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
41
41
|
"eslint-plugin-react": "^7.11.0",
|
|
42
|
-
"gh-pages": "^
|
|
43
|
-
"husky": "^
|
|
44
|
-
"prettier": "^
|
|
45
|
-
"prettier-eslint": "^
|
|
46
|
-
"react": "^
|
|
47
|
-
"react-dom": "^
|
|
42
|
+
"gh-pages": "^6.0.0",
|
|
43
|
+
"husky": "^8.0.0",
|
|
44
|
+
"prettier": "^3.0.3",
|
|
45
|
+
"prettier-eslint": "^15.0.1",
|
|
46
|
+
"react": "^18.2.0",
|
|
47
|
+
"react-dom": "^18.2.0",
|
|
48
48
|
"react-error-overlay": "6.0.9",
|
|
49
|
-
"react-scripts": "4.0.3",
|
|
50
|
-
"rimraf": "^
|
|
49
|
+
"react-scripts": "^4.0.3",
|
|
50
|
+
"rimraf": "^5.0.1",
|
|
51
51
|
"sass-lint": "^1.12.1",
|
|
52
52
|
"semantic-release": "^15.13.31"
|
|
53
53
|
},
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"not op_mini all"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@azure/msal-browser": "^
|
|
62
|
-
"@react-oauth/google": "^0.
|
|
63
|
-
"@widergy/energy-ui": "^
|
|
64
|
-
"@widergy/web-utils": "^
|
|
61
|
+
"@azure/msal-browser": "^3.1.0",
|
|
62
|
+
"@react-oauth/google": "^0.11.1",
|
|
63
|
+
"@widergy/energy-ui": "^3.0.0",
|
|
64
|
+
"@widergy/web-utils": "^2.0.0",
|
|
65
65
|
"node-sass": "^8.0.0",
|
|
66
66
|
"prop-types": "^15.8.1",
|
|
67
67
|
"react-facebook-login": "^4.1.1",
|
|
@@ -73,48 +73,7 @@
|
|
|
73
73
|
"node-sass": "^8.0.0",
|
|
74
74
|
"url-loader": "1.1.2"
|
|
75
75
|
},
|
|
76
|
-
"husky": {
|
|
77
|
-
"hooks": {
|
|
78
|
-
"pre-commit": "node branch-name-hook",
|
|
79
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
76
|
"release": {
|
|
83
|
-
"
|
|
84
|
-
"@semantic-release/commit-analyzer",
|
|
85
|
-
"@semantic-release/release-notes-generator",
|
|
86
|
-
[
|
|
87
|
-
"@semantic-release/changelog",
|
|
88
|
-
{
|
|
89
|
-
"changelogFile": "./CHANGELOG.md"
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"@semantic-release/npm",
|
|
93
|
-
[
|
|
94
|
-
"@semantic-release/git",
|
|
95
|
-
{
|
|
96
|
-
"assets": [
|
|
97
|
-
"./CHANGELOG.md",
|
|
98
|
-
"package.json"
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
"@semantic-release/github"
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
"commitlint": {
|
|
106
|
-
"extends": [
|
|
107
|
-
"@commitlint/config-conventional"
|
|
108
|
-
],
|
|
109
|
-
"rules": {
|
|
110
|
-
"subject-case": [
|
|
111
|
-
2,
|
|
112
|
-
"never",
|
|
113
|
-
[
|
|
114
|
-
"start-case",
|
|
115
|
-
"pascal-case"
|
|
116
|
-
]
|
|
117
|
-
]
|
|
118
|
-
}
|
|
77
|
+
"extends": "@widergy/semantic-release-package-config"
|
|
119
78
|
}
|
|
120
79
|
}
|