session-sync-auth-site 4.0.0 → 4.0.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "session-sync-auth-site",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=20"
|
|
18
18
|
},
|
|
19
|
-
"type": "module",
|
|
20
19
|
"scripts": {
|
|
21
20
|
"dev": "npm run go-dev -s",
|
|
22
21
|
"go-dev": "concurrently -k 'node ./test/dummySite.js 3001' 'node ./test/dummySite.js 3002 dummy1' 'node ./test/dummySite.js 3003 dummy2'",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
;(() => {
|
|
2
2
|
|
|
3
|
+
if(typeof window === 'undefined') return
|
|
4
|
+
|
|
3
5
|
let enableSSR = false
|
|
4
6
|
let defaultOrigin
|
|
5
7
|
const setDefaultOrigin = origin => {
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
const cancelRedirectUrl = `${addOnQueryStrConnectorChar(cancelRedirectHref)}action=canceledAccountUpdate&origin=${encodeURIComponent(origin)}${getQueryStringAddOn(extraQueryParamsForCallbacks)}`
|
|
69
71
|
const updatedRedirectUrl = `${addOnQueryStrConnectorChar(updatedRedirectHref)}action=successfulAccountUpdate&origin=${encodeURIComponent(origin)}${getQueryStringAddOn(extraQueryParamsForCallbacks)}`
|
|
70
72
|
|
|
71
|
-
const queryString = `cancelRedirectUrl=${encodeURIComponent(cancelRedirectUrl)}&updatedRedirectUrl=${encodeURIComponent(updatedRedirectUrl)}`
|
|
73
|
+
const queryString = `cancelRedirectUrl=${encodeURIComponent(cancelRedirectUrl)}&updatedRedirectUrl=${encodeURIComponent(updatedRedirectUrl)}&accessToken=${encodeURIComponent(getAccessToken({ origin }))}`
|
|
72
74
|
|
|
73
75
|
window.location = `${origin}/update-account?${queryString}`
|
|
74
76
|
}
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
const getUser = async ({ origin=defaultOrigin }={}) => {
|
|
77
79
|
const response = await fetch(`${origin}/get-user`, {
|
|
78
80
|
headers: {
|
|
79
|
-
'x-access-token': getAccessToken(origin),
|
|
81
|
+
'x-access-token': getAccessToken({ origin }),
|
|
80
82
|
},
|
|
81
83
|
})
|
|
82
84
|
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
const logOut = async ({ origin=defaultOrigin, extraQueryParamsForCallbacks }={}) => {
|
|
87
89
|
const redirectUrl = `${location.href.replace(/\?.*$/, '')}?action=successfulLogout&origin=${encodeURIComponent(origin)}${getQueryStringAddOn(extraQueryParamsForCallbacks)}`
|
|
88
90
|
const noLoginRedirectUrl = `${location.href.replace(/\?.*$/, '')}?action=unnecessaryLogout&origin=${encodeURIComponent(origin)}${getQueryStringAddOn(extraQueryParamsForCallbacks)}`
|
|
89
|
-
const accessToken = getAccessToken(origin)
|
|
91
|
+
const accessToken = getAccessToken({ origin })
|
|
90
92
|
|
|
91
93
|
const queryString = `redirectUrl=${encodeURIComponent(redirectUrl)}&noLoginRedirectUrl=${encodeURIComponent(noLoginRedirectUrl)}&accessToken=${encodeURIComponent(accessToken)}`
|
|
92
94
|
|
|
@@ -51,12 +51,12 @@ const setUpSessionSyncAuthRoutes = ({
|
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
app.get(updateAccount, async (req, res, next) => {
|
|
54
|
-
const { updatedRedirectUrl, cancelRedirectUrl
|
|
54
|
+
const { updatedRedirectUrl, cancelRedirectUrl } = req.query
|
|
55
55
|
const { siteId, jwtSecret, authFrontendBaseUrl } = await getSetupInfo(req)
|
|
56
56
|
|
|
57
57
|
if(!req.user) {
|
|
58
58
|
console.warn(`updateAccount attemped with no login`)
|
|
59
|
-
return res.redirect(
|
|
59
|
+
return res.redirect(cancelRedirectUrl)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const {
|