react-es-fb-login 1.0.8 → 1.0.10
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.
|
@@ -23,6 +23,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.FacebookLoginClient = exports.SDK_SCRIPT_ELE_ID = void 0;
|
|
24
24
|
const helpers_1 = require("./helpers");
|
|
25
25
|
exports.SDK_SCRIPT_ELE_ID = 'facebook-jssdk';
|
|
26
|
+
/** Normalizes the pre-encoded '%20' form to the space form — the JS SDK
|
|
27
|
+
* URL-encodes option values itself, so 'code%20token' would be sent
|
|
28
|
+
* double-encoded as 'code%2520token'. */
|
|
29
|
+
const normalizeResponseType = (options) => options.response_type === 'code%20token'
|
|
30
|
+
? Object.assign(Object.assign({}, options), { response_type: 'code token' }) : options;
|
|
26
31
|
exports.FacebookLoginClient = {
|
|
27
32
|
getFB: () => {
|
|
28
33
|
if (!window.FB) {
|
|
@@ -73,13 +78,13 @@ exports.FacebookLoginClient = {
|
|
|
73
78
|
{ ignoreSdkError } = _a, loginOptions = __rest(_a,
|
|
74
79
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
80
|
["ignoreSdkError"]);
|
|
76
|
-
window.location.href = `https://www.facebook.com/dialog/oauth${(0, helpers_1.objectToParams)(Object.assign(Object.assign({}, dialogParams), loginOptions))}`;
|
|
81
|
+
window.location.href = `https://www.facebook.com/dialog/oauth${(0, helpers_1.objectToParams)(Object.assign(Object.assign({}, dialogParams), normalizeResponseType(loginOptions)))}`;
|
|
77
82
|
},
|
|
78
83
|
login(callback, _a) {
|
|
79
84
|
var _b;
|
|
80
85
|
var { ignoreSdkError } = _a, loginOptions = __rest(_a, ["ignoreSdkError"]);
|
|
81
86
|
try {
|
|
82
|
-
(_b = this.getFB()) === null || _b === void 0 ? void 0 : _b.login(callback, loginOptions);
|
|
87
|
+
(_b = this.getFB()) === null || _b === void 0 ? void 0 : _b.login(callback, normalizeResponseType(loginOptions));
|
|
83
88
|
}
|
|
84
89
|
catch (e) {
|
|
85
90
|
if (ignoreSdkError) {
|
package/dist/types/fb.type.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type InitParams = {
|
|
|
7
7
|
/** Determines which versions of the Graph API and any API dialogs or plugins are invoked
|
|
8
8
|
*
|
|
9
9
|
* (available versions: https://developers.facebook.com/docs/graph-api/changelog)
|
|
10
|
-
* @default '
|
|
10
|
+
* @default 'v17.0' */
|
|
11
11
|
version?: 'v7.0' | 'v8.0' | 'v9.0' | 'v10.0' | 'v11.0' | 'v12.0' | 'v13.0' | 'v14.0' | 'v15.0' | 'v16.0' | 'v17.0' | 'v18.0' | 'v19.0' | 'v20.0' | 'v21.0' | 'v22.0' | 'v23.0' | 'v24.0' | 'v25.0' | 'v26.0' | 'v27.0' | 'v28.0' | 'v29.0' | 'v30.0' | 'v31.0' | 'v32.0' | 'v33.0' | 'v34.0' | 'v35.0' | 'v36.0';
|
|
12
12
|
/** Determines whether a cookie is created for the session or not. If enabled, it can be accessed by server-side code.
|
|
13
13
|
* @default false */
|
|
@@ -26,6 +26,13 @@ export type InitParams = {
|
|
|
26
26
|
* @link https://developers.facebook.com/docs/games/gamesonfacebook/optimizing#handlingpopups */
|
|
27
27
|
hideFlashCallback?: () => void;
|
|
28
28
|
};
|
|
29
|
+
/** The type of the response returned from the login dialog.
|
|
30
|
+
*
|
|
31
|
+
* This can be one of ('code', 'token', 'code token', 'code%20token', 'granted_scopes')
|
|
32
|
+
*
|
|
33
|
+
* Note: the JS SDK URL-encodes values before opening the dialog, so the space form
|
|
34
|
+
* ('code token') is what the SDK expects — it is sent as 'code%20token'. */
|
|
35
|
+
export type ResponseType = 'code' | 'token' | 'code token' | 'code%20token' | 'granted_scopes';
|
|
29
36
|
export type DialogParams = {
|
|
30
37
|
/** same as appId */
|
|
31
38
|
client_id: string;
|
|
@@ -37,9 +44,9 @@ export type DialogParams = {
|
|
|
37
44
|
state: string;
|
|
38
45
|
/** Determines whether the response data included when the redirect back to the app occurs is in URL parameters or fragments.
|
|
39
46
|
*
|
|
40
|
-
* This can be one of ('code', 'token', 'code%20token', '
|
|
47
|
+
* This can be one of ('code', 'token', 'code token', 'code%20token', 'granted_scopes')
|
|
41
48
|
* @default 'code' */
|
|
42
|
-
response_type?:
|
|
49
|
+
response_type?: ResponseType;
|
|
43
50
|
/** Comma seperated list of permissions to request during login.
|
|
44
51
|
*
|
|
45
52
|
* (available permissions: https://developers.facebook.com/docs/permissions/reference)
|
|
@@ -51,7 +58,11 @@ export type LoginOptions = {
|
|
|
51
58
|
*
|
|
52
59
|
* Use 'rerequest' when re-requesting a declined permission. */
|
|
53
60
|
auth_type?: 'rerequest' | 'reauthenticate' | 'reauthorize';
|
|
54
|
-
|
|
61
|
+
/** The type of the response returned from the login dialog.
|
|
62
|
+
*
|
|
63
|
+
* When `override_default_response_type` is true, a lone 'code' is upgraded to
|
|
64
|
+
* 'code token' so authResponse also contains accessToken and userID. */
|
|
65
|
+
response_type?: ResponseType;
|
|
55
66
|
scope: string;
|
|
56
67
|
/** Facebook login for business uses config_id instead of scope - won't work without this - reference: https://developers.facebook.com/docs/facebook-login/facebook-login-for-business/ */
|
|
57
68
|
config_id?: string;
|
|
@@ -9,21 +9,25 @@ export type LoginResponse = {
|
|
|
9
9
|
};
|
|
10
10
|
export type SuccessResponse = {
|
|
11
11
|
/** An access token for the person using the webpage. */
|
|
12
|
-
accessToken
|
|
12
|
+
accessToken?: string;
|
|
13
13
|
/**
|
|
14
14
|
* A UNIX time stamp when the token expires. Once the token expires, the person will need to login again.
|
|
15
15
|
*/
|
|
16
|
-
expiresIn
|
|
16
|
+
expiresIn?: string;
|
|
17
17
|
/**
|
|
18
18
|
* The amount of time before the login expires, in seconds, and the person will need to login again.
|
|
19
19
|
*/
|
|
20
|
-
reauthorize_required_in
|
|
20
|
+
reauthorize_required_in?: string;
|
|
21
21
|
/**
|
|
22
22
|
* A signed parameter that contains information about the person using your webpage.
|
|
23
23
|
*/
|
|
24
|
-
signedRequest
|
|
24
|
+
signedRequest?: string;
|
|
25
25
|
/** The ID of the person using your webpage. */
|
|
26
|
-
userID
|
|
26
|
+
userID?: string;
|
|
27
|
+
/** An authorization code returned when `response_type` includes 'code'. */
|
|
28
|
+
code?: string;
|
|
29
|
+
/** Comma-separated list of granted scopes, returned when `return_scopes` is true. */
|
|
30
|
+
grantedScopes?: string;
|
|
27
31
|
};
|
|
28
32
|
export type FailResponse = {
|
|
29
33
|
status: 'loginCancelled' | 'facebookNotLoaded';
|