@websolutespa/bom-mixer-models 1.8.13 → 1.8.14
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 +10 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/session/session.service.ts +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-models
|
|
2
2
|
|
|
3
|
+
## 1.8.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: request & response types
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @websolutespa/bom-mixer-store@1.8.7
|
|
11
|
+
- @websolutespa/bom-core@1.8.15
|
|
12
|
+
|
|
3
13
|
## 1.8.13
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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';
|
|
8
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
9
8
|
import { IronSession } from 'iron-session';
|
|
10
9
|
|
|
11
10
|
type IAddressOptions = {
|
|
@@ -205,12 +204,12 @@ declare function resolveRoute(route: IRoute & {
|
|
|
205
204
|
type SeoWeight = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
206
205
|
declare const getSeoWeight: (index?: number, seoWeight?: SeoWeight) => (subIndex?: number) => SeoWeight;
|
|
207
206
|
|
|
208
|
-
declare function getSession<T extends object = Record<string, any>>(request:
|
|
207
|
+
declare function getSession<T extends object = Record<string, any>>(request: NextRequest | NextApiRequest, response: NextResponse | NextApiResponse): Promise<IronSession<T>>;
|
|
209
208
|
type SessionWithToken<T extends object = Record<string, any>> = T & Partial<{
|
|
210
209
|
token: string;
|
|
211
210
|
exp: number;
|
|
212
211
|
}>;
|
|
213
|
-
declare function getSessionToken<T extends SessionWithToken>(request:
|
|
212
|
+
declare function getSessionToken<T extends SessionWithToken>(request: NextRequest | NextApiRequest, response: NextResponse | NextApiResponse): Promise<string | undefined>;
|
|
214
213
|
|
|
215
214
|
declare const getSiteMapIndexProps: GetServerSideProps;
|
|
216
215
|
declare const getSiteMapXMLProps: GetServerSideProps;
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isDevelopment } from '@websolutespa/bom-core';
|
|
2
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
2
|
import { getIronSession, IronSession, SessionOptions } from 'iron-session';
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
4
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
4
5
|
|
|
5
6
|
export async function getSession<T extends object = Record<string, any>>(
|
|
6
|
-
request:
|
|
7
|
-
response:
|
|
7
|
+
request: NextRequest | NextApiRequest,
|
|
8
|
+
response: NextResponse | NextApiResponse
|
|
8
9
|
): Promise<IronSession<T>> {
|
|
9
10
|
const COOKIE_NAME = 'websolutespa-next-js';
|
|
10
11
|
const COOKIE_PASSWORD = process.env.SECRET_COOKIE_PASSWORD as string || 'SECRET_COOKIE_PASSWORD_32_CHARS_LONG';
|
|
@@ -26,9 +27,9 @@ export type SessionWithToken<T extends object = Record<string, any>> = T & Parti
|
|
|
26
27
|
}>;
|
|
27
28
|
|
|
28
29
|
export async function getSessionToken<T extends SessionWithToken>(
|
|
29
|
-
request:
|
|
30
|
-
response:
|
|
31
|
-
): Promise<string |
|
|
30
|
+
request: NextRequest | NextApiRequest,
|
|
31
|
+
response: NextResponse | NextApiResponse
|
|
32
|
+
): Promise<string | undefined> {
|
|
32
33
|
const session = await getSession<T>(request, response);
|
|
33
34
|
if (session.token && session.exp && session.exp > Math.floor(new Date().getTime() / 1000)) {
|
|
34
35
|
return session.token;
|
|
@@ -37,6 +38,6 @@ export async function getSessionToken<T extends SessionWithToken>(
|
|
|
37
38
|
session.exp = undefined;
|
|
38
39
|
await session.save();
|
|
39
40
|
session.destroy();
|
|
40
|
-
return
|
|
41
|
+
return;
|
|
41
42
|
}
|
|
42
43
|
}
|