@smg-automotive/auth 8.1.5 → 8.2.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/dist/cjs/client/hooks/useUser.js +18 -3
- package/dist/cjs/client/hooks/useUser.js.map +1 -1
- package/dist/cjs/server/middleware/combineCookies.d.ts +5 -0
- package/dist/cjs/server/middleware/combineCookies.js +10 -0
- package/dist/cjs/server/middleware/combineCookies.js.map +1 -0
- package/dist/cjs/server/middleware/profile.js +25 -15
- package/dist/cjs/server/middleware/profile.js.map +1 -1
- package/dist/cjs/server/middleware/token.js +5 -3
- package/dist/cjs/server/middleware/token.js.map +1 -1
- package/dist/esm/client/hooks/useUser.js +18 -3
- package/dist/esm/client/hooks/useUser.js.map +1 -1
- package/dist/esm/server/middleware/combineCookies.d.ts +5 -0
- package/dist/esm/server/middleware/combineCookies.js +8 -0
- package/dist/esm/server/middleware/combineCookies.js.map +1 -0
- package/dist/esm/server/middleware/profile.js +25 -15
- package/dist/esm/server/middleware/profile.js.map +1 -1
- package/dist/esm/server/middleware/token.js +5 -3
- package/dist/esm/server/middleware/token.js.map +1 -1
- package/package.json +2 -2
|
@@ -11,10 +11,25 @@ var useSWR__default = /*#__PURE__*/_interopDefaultCompat(useSWR);
|
|
|
11
11
|
|
|
12
12
|
const userFetcher = async (url) => {
|
|
13
13
|
const response = await fetch(url);
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
if (response.status === 204) {
|
|
15
|
+
return null;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
let responseBody = null;
|
|
18
|
+
try {
|
|
19
|
+
responseBody = await response.json();
|
|
20
|
+
if (response.ok) {
|
|
21
|
+
return responseBody;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.error('Failed to fetch user profile', error);
|
|
27
|
+
throw new Error('Failed to parse user endpoint response');
|
|
28
|
+
}
|
|
29
|
+
if (responseBody && responseBody.error?.code) {
|
|
30
|
+
throw new Error(responseBody.error.code);
|
|
31
|
+
}
|
|
32
|
+
throw new Error('Unauthorized');
|
|
18
33
|
};
|
|
19
34
|
const useUser = () => {
|
|
20
35
|
const config = useAuthConfig.useAuthConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUser.js","sources":["../../../../../src/client/hooks/useUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AASA;AACE;AACA;AACE
|
|
1
|
+
{"version":3,"file":"useUser.js","sources":["../../../../../src/client/hooks/useUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AASA;AACE;AACA;AACE;;;AAIF;AACE;AAEA;AACE;;;;;AAIF;AAEA;;;;;AAOF;AACF;AAEO;AACL;;AAQA;;;;;;;AAQF;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const combineCookies = ({ sourceResponse, targetResponse, }) => {
|
|
4
|
+
for (const cookie of sourceResponse.cookies.getAll()) {
|
|
5
|
+
targetResponse.cookies.set(cookie.name, cookie.value, cookie);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.combineCookies = combineCookies;
|
|
10
|
+
//# sourceMappingURL=combineCookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineCookies.js","sources":["../../../../../src/server/middleware/combineCookies.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEO,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,cAAc,GAIf,KAAI;IACH,KAAK,MAAM,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;AACpD,QAAA,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IAC/D;AACF;;;;"}
|
|
@@ -4,25 +4,24 @@ var server = require('next/server');
|
|
|
4
4
|
var session = require('../../lib/enrichUser/session.js');
|
|
5
5
|
var proactivelyRefreshAccessToken = require('./proactivelyRefreshAccessToken.js');
|
|
6
6
|
var combineHeaders = require('./combineHeaders.js');
|
|
7
|
+
var combineCookies = require('./combineCookies.js');
|
|
7
8
|
var addCachingHeaders = require('./addCachingHeaders.js');
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0',
|
|
15
|
-
Pragma: 'no-cache',
|
|
16
|
-
Expires: '0',
|
|
17
|
-
},
|
|
18
|
-
});
|
|
10
|
+
const responseHeaders = {
|
|
11
|
+
Vary: 'Cookie, Authorization',
|
|
12
|
+
'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0',
|
|
13
|
+
Pragma: 'no-cache',
|
|
14
|
+
Expires: '0',
|
|
19
15
|
};
|
|
20
16
|
const handleUserProfile = async ({ request, response, auth0Instance, auth0Config, brand, }) => {
|
|
21
17
|
if (request.nextUrl.pathname !== auth0Config.userProfileEndpoint)
|
|
22
18
|
return;
|
|
23
19
|
const session$1 = await auth0Instance.getSession(request);
|
|
24
20
|
if (!session$1) {
|
|
25
|
-
return
|
|
21
|
+
return new server.NextResponse(null, {
|
|
22
|
+
status: 204,
|
|
23
|
+
headers: responseHeaders,
|
|
24
|
+
});
|
|
26
25
|
}
|
|
27
26
|
try {
|
|
28
27
|
const user = session$1.user;
|
|
@@ -45,15 +44,26 @@ const handleUserProfile = async ({ request, response, auth0Instance, auth0Config
|
|
|
45
44
|
});
|
|
46
45
|
addCachingHeaders.addCachingHeaders(responseWithCombinedHeaders);
|
|
47
46
|
// combine cookies from the original response into the new response
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
combineCookies.combineCookies({
|
|
48
|
+
sourceResponse: response,
|
|
49
|
+
targetResponse: responseWithCombinedHeaders,
|
|
50
|
+
});
|
|
51
51
|
return responseWithCombinedHeaders;
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
54
54
|
// eslint-disable-next-line no-console
|
|
55
55
|
console.warn('User Profile error loading entitlements', JSON.stringify(error, null, 2));
|
|
56
|
-
|
|
56
|
+
let responseCode = 'UNKNOWN_AUTH_ERROR';
|
|
57
|
+
if (error &&
|
|
58
|
+
typeof error === 'object' &&
|
|
59
|
+
'code' in error &&
|
|
60
|
+
typeof error.code === 'string') {
|
|
61
|
+
responseCode = error.code;
|
|
62
|
+
}
|
|
63
|
+
return server.NextResponse.json({ error: { code: responseCode } }, {
|
|
64
|
+
status: 500,
|
|
65
|
+
headers: responseHeaders,
|
|
66
|
+
});
|
|
57
67
|
}
|
|
58
68
|
};
|
|
59
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sources":["../../../../../src/server/middleware/profile.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"profile.js","sources":["../../../../../src/server/middleware/profile.ts"],"sourcesContent":[null],"names":["session","NextResponse","proactivelyRefreshAccessToken","enrichUser","combineHeaders","addCachingHeaders","combineCookies"],"mappings":";;;;;;;;;AAYA,MAAM,eAAe,GAAG;AACtB,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,eAAe,EAAE,yDAAyD;AAC1E,IAAA,MAAM,EAAE,UAAU;AAClB,IAAA,OAAO,EAAE,GAAG;CACb;AAEM,MAAM,iBAAiB,GAAG,OAAO,EACtC,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,KAAK,GAON,KAAkC;IACjC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,mBAAmB;QAAE;IAElE,MAAMA,SAAO,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;IAEvD,IAAI,CAACA,SAAO,EAAE;AACZ,QAAA,OAAO,IAAIC,mBAAY,CAAC,IAAI,EAA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E,YAAY,EAAE,EAAE,EACjC;AACE,YAAA,MAAM,EAAE,GAAG;AACX,YAAA,OAAO,EAAE,eAAe;AACzB,SAAA,CACF;IACH;AACF;;;;"}
|
|
@@ -4,6 +4,7 @@ var server = require('next/server');
|
|
|
4
4
|
var errors = require('@auth0/nextjs-auth0/errors');
|
|
5
5
|
var proactivelyRefreshAccessToken = require('./proactivelyRefreshAccessToken.js');
|
|
6
6
|
var combineHeaders = require('./combineHeaders.js');
|
|
7
|
+
var combineCookies = require('./combineCookies.js');
|
|
7
8
|
var addCachingHeaders = require('./addCachingHeaders.js');
|
|
8
9
|
|
|
9
10
|
const handleAccessTokenRequest = async ({ request, response, auth0Instance, auth0Config, onError, }) => {
|
|
@@ -38,9 +39,10 @@ const handleAccessTokenRequest = async ({ request, response, auth0Instance, auth
|
|
|
38
39
|
});
|
|
39
40
|
addCachingHeaders.addCachingHeaders(responseWithCombinedHeaders);
|
|
40
41
|
// combine cookies from the original response into the new response
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
combineCookies.combineCookies({
|
|
43
|
+
sourceResponse: response,
|
|
44
|
+
targetResponse: responseWithCombinedHeaders,
|
|
45
|
+
});
|
|
44
46
|
return responseWithCombinedHeaders;
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sources":["../../../../../src/server/middleware/token.ts"],"sourcesContent":[null],"names":["NextResponse","AccessTokenErrorCode","proactivelyRefreshAccessToken","combineHeaders","addCachingHeaders"],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","sources":["../../../../../src/server/middleware/token.ts"],"sourcesContent":[null],"names":["NextResponse","AccessTokenErrorCode","proactivelyRefreshAccessToken","combineHeaders","addCachingHeaders","combineCookies"],"mappings":";;;;;;;;;AAWO,MAAM,wBAAwB,GAAG,OAAO,EAC7C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,OAAO,GAOR,KAAkC;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ChB;IACH;AACF;;;;"}
|
|
@@ -5,10 +5,25 @@ import { useAuthConfig } from './useAuthConfig.js';
|
|
|
5
5
|
|
|
6
6
|
const userFetcher = async (url) => {
|
|
7
7
|
const response = await fetch(url);
|
|
8
|
-
if (
|
|
9
|
-
|
|
8
|
+
if (response.status === 204) {
|
|
9
|
+
return null;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
let responseBody = null;
|
|
12
|
+
try {
|
|
13
|
+
responseBody = await response.json();
|
|
14
|
+
if (response.ok) {
|
|
15
|
+
return responseBody;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.error('Failed to fetch user profile', error);
|
|
21
|
+
throw new Error('Failed to parse user endpoint response');
|
|
22
|
+
}
|
|
23
|
+
if (responseBody && responseBody.error?.code) {
|
|
24
|
+
throw new Error(responseBody.error.code);
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Unauthorized');
|
|
12
27
|
};
|
|
13
28
|
const useUser = () => {
|
|
14
29
|
const config = useAuthConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUser.js","sources":["../../../../../src/client/hooks/useUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AASA;AACE;AACA;AACE
|
|
1
|
+
{"version":3,"file":"useUser.js","sources":["../../../../../src/client/hooks/useUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AASA;AACE;AACA;AACE;;;AAIF;AACE;AAEA;AACE;;;;;AAIF;AAEA;;;;;AAOF;AACF;AAEO;AACL;;AAQA;;;;;;;AAQF;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const combineCookies = ({ sourceResponse, targetResponse, }) => {
|
|
2
|
+
for (const cookie of sourceResponse.cookies.getAll()) {
|
|
3
|
+
targetResponse.cookies.set(cookie.name, cookie.value, cookie);
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { combineCookies };
|
|
8
|
+
//# sourceMappingURL=combineCookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combineCookies.js","sources":["../../../../../src/server/middleware/combineCookies.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,cAAc,GAIf,KAAI;IACH,KAAK,MAAM,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;AACpD,QAAA,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IAC/D;AACF;;;;"}
|
|
@@ -2,25 +2,24 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
import { enrichUser } from '../../lib/enrichUser/session.js';
|
|
3
3
|
import { proactivelyRefreshAccessToken } from './proactivelyRefreshAccessToken.js';
|
|
4
4
|
import { combineHeaders } from './combineHeaders.js';
|
|
5
|
+
import { combineCookies } from './combineCookies.js';
|
|
5
6
|
import { addCachingHeaders } from './addCachingHeaders.js';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0',
|
|
13
|
-
Pragma: 'no-cache',
|
|
14
|
-
Expires: '0',
|
|
15
|
-
},
|
|
16
|
-
});
|
|
8
|
+
const responseHeaders = {
|
|
9
|
+
Vary: 'Cookie, Authorization',
|
|
10
|
+
'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0',
|
|
11
|
+
Pragma: 'no-cache',
|
|
12
|
+
Expires: '0',
|
|
17
13
|
};
|
|
18
14
|
const handleUserProfile = async ({ request, response, auth0Instance, auth0Config, brand, }) => {
|
|
19
15
|
if (request.nextUrl.pathname !== auth0Config.userProfileEndpoint)
|
|
20
16
|
return;
|
|
21
17
|
const session = await auth0Instance.getSession(request);
|
|
22
18
|
if (!session) {
|
|
23
|
-
return
|
|
19
|
+
return new NextResponse(null, {
|
|
20
|
+
status: 204,
|
|
21
|
+
headers: responseHeaders,
|
|
22
|
+
});
|
|
24
23
|
}
|
|
25
24
|
try {
|
|
26
25
|
const user = session.user;
|
|
@@ -43,15 +42,26 @@ const handleUserProfile = async ({ request, response, auth0Instance, auth0Config
|
|
|
43
42
|
});
|
|
44
43
|
addCachingHeaders(responseWithCombinedHeaders);
|
|
45
44
|
// combine cookies from the original response into the new response
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
combineCookies({
|
|
46
|
+
sourceResponse: response,
|
|
47
|
+
targetResponse: responseWithCombinedHeaders,
|
|
48
|
+
});
|
|
49
49
|
return responseWithCombinedHeaders;
|
|
50
50
|
}
|
|
51
51
|
catch (error) {
|
|
52
52
|
// eslint-disable-next-line no-console
|
|
53
53
|
console.warn('User Profile error loading entitlements', JSON.stringify(error, null, 2));
|
|
54
|
-
|
|
54
|
+
let responseCode = 'UNKNOWN_AUTH_ERROR';
|
|
55
|
+
if (error &&
|
|
56
|
+
typeof error === 'object' &&
|
|
57
|
+
'code' in error &&
|
|
58
|
+
typeof error.code === 'string') {
|
|
59
|
+
responseCode = error.code;
|
|
60
|
+
}
|
|
61
|
+
return NextResponse.json({ error: { code: responseCode } }, {
|
|
62
|
+
status: 500,
|
|
63
|
+
headers: responseHeaders,
|
|
64
|
+
});
|
|
55
65
|
}
|
|
56
66
|
};
|
|
57
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sources":["../../../../../src/server/middleware/profile.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile.js","sources":["../../../../../src/server/middleware/profile.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAYA,MAAM,eAAe,GAAG;AACtB,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,eAAe,EAAE,yDAAyD;AAC1E,IAAA,MA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,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAC/B;QAED,IAAI,YAAY,GAAG,oBAAoB;AACvC,QAAA,IACE,KAAK;YACL,OAAO,KAAK,KAAK,QAAQ;AACzB,YAAA,MAAM,IAAI,KAAK;AACf,YAAA,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC9B;AACA,YAAA,YAAY,GAAG,KAAK,CAAC,IAAI;QAC3B;AAEA,QAAA,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EACjC;AACE,YAAA,MAAM,EAAE,GAAG;AACX,YAAA,OAAO,EAAE,eAAe;AACzB,SAAA,CACF;IACH;AACF;;;;"}
|
|
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
import { AccessTokenErrorCode } from '@auth0/nextjs-auth0/errors';
|
|
3
3
|
import { proactivelyRefreshAccessToken } from './proactivelyRefreshAccessToken.js';
|
|
4
4
|
import { combineHeaders } from './combineHeaders.js';
|
|
5
|
+
import { combineCookies } from './combineCookies.js';
|
|
5
6
|
import { addCachingHeaders } from './addCachingHeaders.js';
|
|
6
7
|
|
|
7
8
|
const handleAccessTokenRequest = async ({ request, response, auth0Instance, auth0Config, onError, }) => {
|
|
@@ -36,9 +37,10 @@ const handleAccessTokenRequest = async ({ request, response, auth0Instance, auth
|
|
|
36
37
|
});
|
|
37
38
|
addCachingHeaders(responseWithCombinedHeaders);
|
|
38
39
|
// combine cookies from the original response into the new response
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
combineCookies({
|
|
41
|
+
sourceResponse: response,
|
|
42
|
+
targetResponse: responseWithCombinedHeaders,
|
|
43
|
+
});
|
|
42
44
|
return responseWithCombinedHeaders;
|
|
43
45
|
}
|
|
44
46
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sources":["../../../../../src/server/middleware/token.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","sources":["../../../../../src/server/middleware/token.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAWO,MAAM,wBAAwB,GAAG,OAAO,EAC7C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,OAAO,GAOR,KAAkC;IACjC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,aAAa;QAAE;IAE5D,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;IAEvD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,YAAY,CAAC,IAAI,CACtB;AACE,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,2CAA2C;gBACpD,IAAI,EAAE,oBAAoB,CAAC,eAAe;AAC3C,aAAA;SACF,EACD;AACE,YAAA,MAAM,EAAE,GAAG;AACZ,SAAA,CACF;IACH;AAEA,IAAA,IAAI;QACF,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,6BAA6B,CAAC;YAC/D,OAAO;YACP,QAAQ;YACR,aAAa;YACb,WAAW;AACZ,SAAA,CAAC;AACF,QAAA,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC;YACtC,KAAK;YACL,SAAS;AACV,SAAA,CAAC;QACF,MAAM,2BAA2B,GAAG,cAAc,CAAC;AACjD,YAAA,kBAAkB,EAAE,aAAa;AACjC,YAAA,YAAY,EAAE,QAAQ;AACtB,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAC;QACF,iBAAiB,CAAC,2BAA2B,CAAC;;AAE9C,QAAA,cAAc,CAAC;AACb,YAAA,cAAc,EAAE,QAAQ;AACxB,YAAA,cAAc,EAAE,2BAA2B;AAC5C,SAAA,CAAC;AACF,QAAA,OAAO,2BAA2B;IACpC;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,SAAS,GAAG,KAAiB;AACnC,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,EAC/D,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB;IACH;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smg-automotive/auth",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "SMG Automotive auth package",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/smg-automotive/auth-pkg#readme",
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@rollup/plugin-commonjs": "
|
|
63
|
+
"@rollup/plugin-commonjs": "29.0.0",
|
|
64
64
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
65
65
|
"@rollup/plugin-typescript": "12.3.0",
|
|
66
66
|
"@smg-automotive/eslint-config": "5.2.3",
|