@opensaas/keystone-nextjs-auth 22.2.2 → 24.0.0
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# @opensaas-keystone/nextjs-auth
|
2
2
|
|
3
|
+
## 24.0.0
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- 1e0e2dd: Update next-auth to 4.10
|
8
|
+
- 1e0e2dd: Upgrade to keystone 2.1
|
9
|
+
|
10
|
+
### Patch Changes
|
11
|
+
|
12
|
+
- 1e0e2dd: Patch packages
|
13
|
+
|
14
|
+
## 23.0.0
|
15
|
+
|
16
|
+
### Major Changes
|
17
|
+
|
18
|
+
- cedcb30: Upgrade to `@keystone-6/core@2.0.0`
|
19
|
+
|
20
|
+
## 22.2.3
|
21
|
+
|
22
|
+
### Patch Changes
|
23
|
+
|
24
|
+
- 415a15d: Fix the session user input so get is used correctly
|
25
|
+
|
3
26
|
## 22.2.2
|
4
27
|
|
5
28
|
### Patch Changes
|
@@ -396,10 +396,6 @@ function createAuth({
|
|
396
396
|
const sudoContext = createContext({
|
397
397
|
sudo: true
|
398
398
|
});
|
399
|
-
const session = await get({
|
400
|
-
req,
|
401
|
-
createContext
|
402
|
-
});
|
403
399
|
|
404
400
|
if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
|
405
401
|
nextSession = await jwt.getToken({
|
@@ -416,7 +412,17 @@ function createAuth({
|
|
416
412
|
return;
|
417
413
|
}
|
418
414
|
|
419
|
-
|
415
|
+
const reqWithUser = req;
|
416
|
+
reqWithUser.user = {
|
417
|
+
istKey: nextSession.listKey,
|
418
|
+
itemId: nextSession.itemId,
|
419
|
+
data: nextSession.data
|
420
|
+
};
|
421
|
+
const userSession = await get({
|
422
|
+
req: reqWithUser,
|
423
|
+
createContext
|
424
|
+
});
|
425
|
+
return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
|
420
426
|
data: nextSession.data,
|
421
427
|
listKey: nextSession.listKey,
|
422
428
|
itemId: nextSession.itemId
|
@@ -471,9 +477,9 @@ function createAuth({
|
|
471
477
|
publicPages: [...(keystoneConfig.ui.publicPages || []), ...publicPages],
|
472
478
|
getAdditionalFiles: [...(((_keystoneConfig$ui = keystoneConfig.ui) === null || _keystoneConfig$ui === void 0 ? void 0 : _keystoneConfig$ui.getAdditionalFiles) || []), getAdditionalFiles],
|
473
479
|
pageMiddleware: async args => {
|
474
|
-
var
|
480
|
+
var _keystoneConfig$ui2, _keystoneConfig$ui2$p;
|
475
481
|
|
476
|
-
return (
|
482
|
+
return (await pageMiddleware(args)) ?? (keystoneConfig === null || keystoneConfig === void 0 ? void 0 : (_keystoneConfig$ui2 = keystoneConfig.ui) === null || _keystoneConfig$ui2 === void 0 ? void 0 : (_keystoneConfig$ui2$p = _keystoneConfig$ui2.pageMiddleware) === null || _keystoneConfig$ui2$p === void 0 ? void 0 : _keystoneConfig$ui2$p.call(_keystoneConfig$ui2, args));
|
477
483
|
},
|
478
484
|
enableSessionItem: true,
|
479
485
|
isAccessAllowed: async context => {
|
@@ -395,10 +395,6 @@ function createAuth({
|
|
395
395
|
const sudoContext = createContext({
|
396
396
|
sudo: true
|
397
397
|
});
|
398
|
-
const session = await get({
|
399
|
-
req,
|
400
|
-
createContext
|
401
|
-
});
|
402
398
|
|
403
399
|
if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
|
404
400
|
nextSession = await jwt.getToken({
|
@@ -415,7 +411,17 @@ function createAuth({
|
|
415
411
|
return;
|
416
412
|
}
|
417
413
|
|
418
|
-
|
414
|
+
const reqWithUser = req;
|
415
|
+
reqWithUser.user = {
|
416
|
+
istKey: nextSession.listKey,
|
417
|
+
itemId: nextSession.itemId,
|
418
|
+
data: nextSession.data
|
419
|
+
};
|
420
|
+
const userSession = await get({
|
421
|
+
req: reqWithUser,
|
422
|
+
createContext
|
423
|
+
});
|
424
|
+
return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
|
419
425
|
data: nextSession.data,
|
420
426
|
listKey: nextSession.listKey,
|
421
427
|
itemId: nextSession.itemId
|
@@ -470,9 +476,9 @@ function createAuth({
|
|
470
476
|
publicPages: [...(keystoneConfig.ui.publicPages || []), ...publicPages],
|
471
477
|
getAdditionalFiles: [...(((_keystoneConfig$ui = keystoneConfig.ui) === null || _keystoneConfig$ui === void 0 ? void 0 : _keystoneConfig$ui.getAdditionalFiles) || []), getAdditionalFiles],
|
472
478
|
pageMiddleware: async args => {
|
473
|
-
var
|
479
|
+
var _keystoneConfig$ui2, _keystoneConfig$ui2$p;
|
474
480
|
|
475
|
-
return (
|
481
|
+
return (await pageMiddleware(args)) ?? (keystoneConfig === null || keystoneConfig === void 0 ? void 0 : (_keystoneConfig$ui2 = keystoneConfig.ui) === null || _keystoneConfig$ui2 === void 0 ? void 0 : (_keystoneConfig$ui2$p = _keystoneConfig$ui2.pageMiddleware) === null || _keystoneConfig$ui2$p === void 0 ? void 0 : _keystoneConfig$ui2$p.call(_keystoneConfig$ui2, args));
|
476
482
|
},
|
477
483
|
enableSessionItem: true,
|
478
484
|
isAccessAllowed: async context => {
|
@@ -363,10 +363,6 @@ function createAuth({
|
|
363
363
|
const sudoContext = createContext({
|
364
364
|
sudo: true
|
365
365
|
});
|
366
|
-
const session = await get({
|
367
|
-
req,
|
368
|
-
createContext
|
369
|
-
});
|
370
366
|
|
371
367
|
if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
|
372
368
|
nextSession = await getToken({
|
@@ -383,7 +379,17 @@ function createAuth({
|
|
383
379
|
return;
|
384
380
|
}
|
385
381
|
|
386
|
-
|
382
|
+
const reqWithUser = req;
|
383
|
+
reqWithUser.user = {
|
384
|
+
istKey: nextSession.listKey,
|
385
|
+
itemId: nextSession.itemId,
|
386
|
+
data: nextSession.data
|
387
|
+
};
|
388
|
+
const userSession = await get({
|
389
|
+
req: reqWithUser,
|
390
|
+
createContext
|
391
|
+
});
|
392
|
+
return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
|
387
393
|
data: nextSession.data,
|
388
394
|
listKey: nextSession.listKey,
|
389
395
|
itemId: nextSession.itemId
|
@@ -438,9 +444,9 @@ function createAuth({
|
|
438
444
|
publicPages: [...(keystoneConfig.ui.publicPages || []), ...publicPages],
|
439
445
|
getAdditionalFiles: [...(((_keystoneConfig$ui = keystoneConfig.ui) === null || _keystoneConfig$ui === void 0 ? void 0 : _keystoneConfig$ui.getAdditionalFiles) || []), getAdditionalFiles],
|
440
446
|
pageMiddleware: async args => {
|
441
|
-
var
|
447
|
+
var _keystoneConfig$ui2, _keystoneConfig$ui2$p;
|
442
448
|
|
443
|
-
return (
|
449
|
+
return (await pageMiddleware(args)) ?? (keystoneConfig === null || keystoneConfig === void 0 ? void 0 : (_keystoneConfig$ui2 = keystoneConfig.ui) === null || _keystoneConfig$ui2 === void 0 ? void 0 : (_keystoneConfig$ui2$p = _keystoneConfig$ui2.pageMiddleware) === null || _keystoneConfig$ui2$p === void 0 ? void 0 : _keystoneConfig$ui2$p.call(_keystoneConfig$ui2, args));
|
444
450
|
},
|
445
451
|
enableSessionItem: true,
|
446
452
|
isAccessAllowed: async context => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opensaas/keystone-nextjs-auth",
|
3
|
-
"version": "
|
3
|
+
"version": "24.0.0",
|
4
4
|
"repository": "https://github.com/opensaasau/keystone-nextjs-auth",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "dist/opensaas-keystone-nextjs-auth.cjs.js",
|
@@ -8,20 +8,20 @@
|
|
8
8
|
"dependencies": {
|
9
9
|
"@babel/runtime": "^7.17.9",
|
10
10
|
"@babel/runtime-corejs3": "^7.17.9",
|
11
|
-
"@types/ejs": "^3.1.
|
11
|
+
"@types/ejs": "^3.1.1",
|
12
12
|
"cookie": "^0.5.0",
|
13
13
|
"cross-fetch": "^3.1.5",
|
14
|
-
"ejs": "^3.1.
|
14
|
+
"ejs": "^3.1.8",
|
15
15
|
"fast-deep-equal": "^3.1.3",
|
16
|
-
"next-auth": "^4.
|
16
|
+
"next-auth": "^4.10.2"
|
17
17
|
},
|
18
18
|
"devDependencies": {
|
19
|
-
"@keystone-6/core": "^
|
20
|
-
"react": "^
|
19
|
+
"@keystone-6/core": "^2.1.0",
|
20
|
+
"react": "^18.1.0"
|
21
21
|
},
|
22
22
|
"peerDependencies": {
|
23
|
-
"@keystone-6/core": "^
|
24
|
-
"react": "^
|
23
|
+
"@keystone-6/core": "^2.1.0",
|
24
|
+
"react": "^18.1.0"
|
25
25
|
},
|
26
26
|
"engines": {
|
27
27
|
"node": "^14.13 || >= 16.13"
|
package/src/index.ts
CHANGED
@@ -205,7 +205,6 @@ export function createAuth<GeneratedListTypes extends BaseListTypeInfo>({
|
|
205
205
|
}
|
206
206
|
const sudoContext = createContext({ sudo: true });
|
207
207
|
|
208
|
-
const session = await get({ req, createContext });
|
209
208
|
if (req.headers?.authorization?.split(' ')[0] === 'Bearer') {
|
210
209
|
nextSession = (await getToken({
|
211
210
|
req,
|
@@ -225,8 +224,17 @@ export function createAuth<GeneratedListTypes extends BaseListTypeInfo>({
|
|
225
224
|
) {
|
226
225
|
return;
|
227
226
|
}
|
227
|
+
const reqWithUser = req as any;
|
228
|
+
reqWithUser.user = {
|
229
|
+
istKey: nextSession.listKey,
|
230
|
+
itemId: nextSession.itemId,
|
231
|
+
data: nextSession.data,
|
232
|
+
};
|
233
|
+
|
234
|
+
const userSession = await get({ req: reqWithUser, createContext });
|
235
|
+
|
228
236
|
return {
|
229
|
-
...
|
237
|
+
...userSession,
|
230
238
|
...nextSession,
|
231
239
|
data: nextSession.data,
|
232
240
|
listKey: nextSession.listKey,
|