@websolutespa/bom-mixer-models 1.8.13 → 1.8.15
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/CHANGELOG.md +18 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/session/session.service.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-models
|
|
2
2
|
|
|
3
|
+
## 1.8.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: request & response types
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @websolutespa/bom-mixer-store@1.8.8
|
|
10
|
+
|
|
11
|
+
## 1.8.14
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Modified: request & response types
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @websolutespa/bom-mixer-store@1.8.7
|
|
19
|
+
- @websolutespa/bom-core@1.8.15
|
|
20
|
+
|
|
3
21
|
## 1.8.13
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IOption, ILayout, IPage, IRouteParams, QueryParams, ICategory, IEquatable, ICategorized, IEntity, IPaginationResult, INamedEntity, ILabel, IComponent, PageProps, ILocale, IMarket, IMenu, IRoute, IRedirect, IRouteLink, IQuerable, IMedia } from '@websolutespa/bom-core';
|
|
2
2
|
import { AppProps } from 'next/app';
|
|
3
3
|
import { FC, ReactNode, ComponentType } from 'react';
|
|
4
|
-
import { GetServerSideProps, Redirect } from 'next';
|
|
4
|
+
import { GetServerSideProps, Redirect, NextApiRequest, NextApiResponse } from 'next';
|
|
5
5
|
import { DynamicOptions, Loader } from 'next/dynamic';
|
|
6
6
|
import * as _websolutespa_bom_mixer_store from '@websolutespa/bom-mixer-store';
|
|
7
7
|
import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
|
|
@@ -205,12 +205,20 @@ declare function resolveRoute(route: IRoute & {
|
|
|
205
205
|
type SeoWeight = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
206
206
|
declare const getSeoWeight: (index?: number, seoWeight?: SeoWeight) => (subIndex?: number) => SeoWeight;
|
|
207
207
|
|
|
208
|
-
declare function getSession<T extends object = Record<string, any>>(request:
|
|
208
|
+
declare function getSession<T extends object = Record<string, any>>(request: NextRequest | NextApiRequest | (IncomingMessage & {
|
|
209
|
+
cookies: Partial<{
|
|
210
|
+
[key: string]: string;
|
|
211
|
+
}>;
|
|
212
|
+
}), response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>): Promise<IronSession<T>>;
|
|
209
213
|
type SessionWithToken<T extends object = Record<string, any>> = T & Partial<{
|
|
210
214
|
token: string;
|
|
211
215
|
exp: number;
|
|
212
216
|
}>;
|
|
213
|
-
declare function getSessionToken<T extends SessionWithToken>(request:
|
|
217
|
+
declare function getSessionToken<T extends SessionWithToken>(request: NextRequest | NextApiRequest | (IncomingMessage & {
|
|
218
|
+
cookies: Partial<{
|
|
219
|
+
[key: string]: string;
|
|
220
|
+
}>;
|
|
221
|
+
}), response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>): Promise<string | undefined>;
|
|
214
222
|
|
|
215
223
|
declare const getSiteMapIndexProps: GetServerSideProps;
|
|
216
224
|
declare const getSiteMapXMLProps: GetServerSideProps;
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { isDevelopment } from '@websolutespa/bom-core';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { getIronSession, IronSession, SessionOptions } from 'iron-session';
|
|
4
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
5
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
4
6
|
|
|
5
7
|
export async function getSession<T extends object = Record<string, any>>(
|
|
6
|
-
request:
|
|
7
|
-
|
|
8
|
+
request: NextRequest | NextApiRequest | IncomingMessage & {
|
|
9
|
+
cookies: Partial<{ [key: string]: string }>;
|
|
10
|
+
},
|
|
11
|
+
response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>
|
|
8
12
|
): Promise<IronSession<T>> {
|
|
9
13
|
const COOKIE_NAME = 'websolutespa-next-js';
|
|
10
14
|
const COOKIE_PASSWORD = process.env.SECRET_COOKIE_PASSWORD as string || 'SECRET_COOKIE_PASSWORD_32_CHARS_LONG';
|
|
@@ -26,9 +30,11 @@ export type SessionWithToken<T extends object = Record<string, any>> = T & Parti
|
|
|
26
30
|
}>;
|
|
27
31
|
|
|
28
32
|
export async function getSessionToken<T extends SessionWithToken>(
|
|
29
|
-
request:
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
request: NextRequest | NextApiRequest | IncomingMessage & {
|
|
34
|
+
cookies: Partial<{ [key: string]: string }>;
|
|
35
|
+
},
|
|
36
|
+
response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>
|
|
37
|
+
): Promise<string | undefined> {
|
|
32
38
|
const session = await getSession<T>(request, response);
|
|
33
39
|
if (session.token && session.exp && session.exp > Math.floor(new Date().getTime() / 1000)) {
|
|
34
40
|
return session.token;
|
|
@@ -37,6 +43,6 @@ export async function getSessionToken<T extends SessionWithToken>(
|
|
|
37
43
|
session.exp = undefined;
|
|
38
44
|
await session.save();
|
|
39
45
|
session.destroy();
|
|
40
|
-
return
|
|
46
|
+
return;
|
|
41
47
|
}
|
|
42
48
|
}
|