@smg-automotive/auth 6.4.4 → 6.5.0-drop-legacy-fallback.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/README.md
CHANGED
|
@@ -39,8 +39,6 @@ You need following environment variables to be set:
|
|
|
39
39
|
- `AUTH0_AUDIENCE`
|
|
40
40
|
- `AUTH0_SECRET`
|
|
41
41
|
- `AUTH0_CLIENT_SECRET`
|
|
42
|
-
- `AUTH0_CUSTOM_LEGACY_ACCESS_TOKEN_NAME` - legacy access token that we use as a fallback
|
|
43
|
-
- `AUTH0_CUSTOM_LEGACY_REFRESH_TOKEN_NAME` - legacy refresh token cookie
|
|
44
42
|
- `AUTH0_CUSTOM_AUTH_COOKIE_NAMES` - [optional] comma separated list of auth related cookies to be cleared on logout
|
|
45
43
|
|
|
46
44
|
Check out the [Auth0 docs](https://auth0.com/docs/quickstart/webapp/nextjs/interactive) for more information.
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var jose = require('jose');
|
|
4
3
|
var auth0 = require('../config/auth0.js');
|
|
5
4
|
|
|
6
5
|
var getSelectedSellerId = function (_a) {
|
|
7
6
|
var _b;
|
|
8
7
|
var req = _a.req, isProxied = _a.isProxied;
|
|
9
8
|
var auth0Config = auth0.getAuth0Config({ isProxied: isProxied });
|
|
10
|
-
|
|
11
|
-
// Parse legacy cookie as a fallback in case they selected the seller on the legacy system
|
|
12
|
-
var legacyAccessToken = req.cookies[process.env.AUTH0_CUSTOM_LEGACY_ACCESS_TOKEN_NAME || ''];
|
|
13
|
-
if (!selectedSellerId &&
|
|
14
|
-
process.env.AUTH0_CUSTOM_LEGACY_ACCESS_TOKEN_NAME &&
|
|
15
|
-
legacyAccessToken) {
|
|
16
|
-
var decodedLegacyToken = jose.decodeJwt(legacyAccessToken);
|
|
17
|
-
selectedSellerId = decodedLegacyToken.legacy_user_id
|
|
18
|
-
? decodedLegacyToken.legacy_user_id.toString()
|
|
19
|
-
: null;
|
|
20
|
-
}
|
|
21
|
-
return selectedSellerId;
|
|
9
|
+
return (_b = req.cookies[auth0Config.selectedSellerIdCookie.name]) !== null && _b !== void 0 ? _b : null;
|
|
22
10
|
};
|
|
23
11
|
|
|
24
12
|
exports.getSelectedSellerId = getSelectedSellerId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectedSeller.js","sources":["../../../../src/apiRoutes/getSelectedSeller.ts"],"sourcesContent":[null],"names":["getAuth0Config"
|
|
1
|
+
{"version":3,"file":"getSelectedSeller.js","sources":["../../../../src/apiRoutes/getSelectedSeller.ts"],"sourcesContent":[null],"names":["getAuth0Config"],"mappings":";;;;AAIO,IAAM,mBAAmB,GAAG,UAAC,EAMnC,EAAA;;QALC,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,CAAA,SAAA;IAKT,IAAM,WAAW,GAAGA,oBAAc,CAAC,EAAE,SAAS,EAAA,SAAA,EAAE,CAAC;AACjD,IAAA,OAAO,CAAA,EAAA,GAAA,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AACrE;;;;"}
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import { decodeJwt } from 'jose';
|
|
2
1
|
import { getAuth0Config } from '../config/auth0.js';
|
|
3
2
|
|
|
4
3
|
var getSelectedSellerId = function (_a) {
|
|
5
4
|
var _b;
|
|
6
5
|
var req = _a.req, isProxied = _a.isProxied;
|
|
7
6
|
var auth0Config = getAuth0Config({ isProxied: isProxied });
|
|
8
|
-
|
|
9
|
-
// Parse legacy cookie as a fallback in case they selected the seller on the legacy system
|
|
10
|
-
var legacyAccessToken = req.cookies[process.env.AUTH0_CUSTOM_LEGACY_ACCESS_TOKEN_NAME || ''];
|
|
11
|
-
if (!selectedSellerId &&
|
|
12
|
-
process.env.AUTH0_CUSTOM_LEGACY_ACCESS_TOKEN_NAME &&
|
|
13
|
-
legacyAccessToken) {
|
|
14
|
-
var decodedLegacyToken = decodeJwt(legacyAccessToken);
|
|
15
|
-
selectedSellerId = decodedLegacyToken.legacy_user_id
|
|
16
|
-
? decodedLegacyToken.legacy_user_id.toString()
|
|
17
|
-
: null;
|
|
18
|
-
}
|
|
19
|
-
return selectedSellerId;
|
|
7
|
+
return (_b = req.cookies[auth0Config.selectedSellerIdCookie.name]) !== null && _b !== void 0 ? _b : null;
|
|
20
8
|
};
|
|
21
9
|
|
|
22
10
|
export { getSelectedSellerId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectedSeller.js","sources":["../../../../src/apiRoutes/getSelectedSeller.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSelectedSeller.js","sources":["../../../../src/apiRoutes/getSelectedSeller.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIO,IAAM,mBAAmB,GAAG,UAAC,EAMnC,EAAA;;QALC,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,SAAS,GAAA,EAAA,CAAA,SAAA;IAKT,IAAM,WAAW,GAAG,cAAc,CAAC,EAAE,SAAS,EAAA,SAAA,EAAE,CAAC;AACjD,IAAA,OAAO,CAAA,EAAA,GAAA,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AACrE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smg-automotive/auth",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-drop-legacy-fallback.1",
|
|
4
4
|
"description": "SMG Automotive auth package",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@testing-library/user-event": "14.6.1",
|
|
70
70
|
"@types/jest": "29.5.14",
|
|
71
71
|
"@types/react": "19.1.8",
|
|
72
|
-
"dotenv": "
|
|
72
|
+
"dotenv": "17.0.0",
|
|
73
73
|
"jest": "29.7.0",
|
|
74
74
|
"jest-environment-jsdom": "29.7.0",
|
|
75
75
|
"next": "14.2.29",
|