@cmssy/next 0.1.8 → 0.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/index.cjs +873 -8
- package/dist/index.d.cts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +859 -7
- package/package.json +6 -3
package/dist/index.d.cts
CHANGED
|
@@ -2,17 +2,24 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
|
|
4
4
|
import { EditBridgeConfig } from '@cmssy/react/client';
|
|
5
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
5
6
|
|
|
7
|
+
interface CmssyAuthConfig {
|
|
8
|
+
modelSlug: string;
|
|
9
|
+
sessionSecret: string;
|
|
10
|
+
}
|
|
6
11
|
interface CmssyNextConfig {
|
|
7
12
|
apiUrl: string;
|
|
8
13
|
workspaceSlug: string;
|
|
9
14
|
draftSecret: string;
|
|
10
15
|
editorOrigin: string | string[];
|
|
16
|
+
auth?: CmssyAuthConfig;
|
|
11
17
|
defaultLocale?: string;
|
|
12
18
|
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
13
19
|
enabledLocales?: string[];
|
|
14
20
|
resolveLocale?: () => string | Promise<string>;
|
|
15
21
|
}
|
|
22
|
+
declare function assertAuthConfig(config: CmssyNextConfig): CmssyAuthConfig;
|
|
16
23
|
|
|
17
24
|
interface CmssyEditorProps {
|
|
18
25
|
page: CmssyPageData;
|
|
@@ -75,4 +82,58 @@ declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | un
|
|
|
75
82
|
}>;
|
|
76
83
|
declare function getCmssyLocale(config: CmssyClientConfig): Promise<string>;
|
|
77
84
|
|
|
78
|
-
|
|
85
|
+
declare const CMSSY_SESSION_COOKIE = "cmssy_session";
|
|
86
|
+
declare const SESSION_MAX_AGE_SECONDS: number;
|
|
87
|
+
interface CmssySessionUser {
|
|
88
|
+
recordId: string;
|
|
89
|
+
email: string;
|
|
90
|
+
}
|
|
91
|
+
interface CmssySessionPayload {
|
|
92
|
+
accessToken: string;
|
|
93
|
+
refreshToken: string;
|
|
94
|
+
accessExpiresAt: number;
|
|
95
|
+
user: CmssySessionUser;
|
|
96
|
+
}
|
|
97
|
+
declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
|
|
98
|
+
declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
|
|
99
|
+
declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
|
|
100
|
+
interface SessionCookieOptions {
|
|
101
|
+
httpOnly: true;
|
|
102
|
+
secure: boolean;
|
|
103
|
+
sameSite: "lax";
|
|
104
|
+
path: "/";
|
|
105
|
+
maxAge: number;
|
|
106
|
+
}
|
|
107
|
+
declare function sessionCookieOptions(): SessionCookieOptions;
|
|
108
|
+
|
|
109
|
+
interface CmssyAuthRouteHandlers {
|
|
110
|
+
POST(request: Request, context: {
|
|
111
|
+
params: Promise<{
|
|
112
|
+
action: string;
|
|
113
|
+
}>;
|
|
114
|
+
}): Promise<Response>;
|
|
115
|
+
GET(request: Request, context: {
|
|
116
|
+
params: Promise<{
|
|
117
|
+
action: string;
|
|
118
|
+
}>;
|
|
119
|
+
}): Promise<Response>;
|
|
120
|
+
}
|
|
121
|
+
declare function createCmssyAuthRoute(config: CmssyNextConfig): CmssyAuthRouteHandlers;
|
|
122
|
+
|
|
123
|
+
declare const CMSSY_CART_COOKIE = "cmssy_cart";
|
|
124
|
+
interface CmssyCartRouteHandlers {
|
|
125
|
+
POST(request: Request, context: {
|
|
126
|
+
params: Promise<{
|
|
127
|
+
action: string;
|
|
128
|
+
}>;
|
|
129
|
+
}): Promise<Response>;
|
|
130
|
+
}
|
|
131
|
+
declare function createCmssyCartRoute(config: CmssyNextConfig): CmssyCartRouteHandlers;
|
|
132
|
+
|
|
133
|
+
declare function getCmssyUser(config: CmssyNextConfig): Promise<CmssySessionUser | null>;
|
|
134
|
+
declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string | null>;
|
|
135
|
+
|
|
136
|
+
type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
|
|
137
|
+
declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
|
|
138
|
+
|
|
139
|
+
export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssySessionPayload, type CmssySessionUser, type CreateCmssyPageOptions, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, applyCmssyCsp, assertAuthConfig, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyPage, createDraftRoute, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, sealSession, sessionCookieOptions, splitCmssyLocale };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,17 +2,24 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
|
|
4
4
|
import { EditBridgeConfig } from '@cmssy/react/client';
|
|
5
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
5
6
|
|
|
7
|
+
interface CmssyAuthConfig {
|
|
8
|
+
modelSlug: string;
|
|
9
|
+
sessionSecret: string;
|
|
10
|
+
}
|
|
6
11
|
interface CmssyNextConfig {
|
|
7
12
|
apiUrl: string;
|
|
8
13
|
workspaceSlug: string;
|
|
9
14
|
draftSecret: string;
|
|
10
15
|
editorOrigin: string | string[];
|
|
16
|
+
auth?: CmssyAuthConfig;
|
|
11
17
|
defaultLocale?: string;
|
|
12
18
|
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
13
19
|
enabledLocales?: string[];
|
|
14
20
|
resolveLocale?: () => string | Promise<string>;
|
|
15
21
|
}
|
|
22
|
+
declare function assertAuthConfig(config: CmssyNextConfig): CmssyAuthConfig;
|
|
16
23
|
|
|
17
24
|
interface CmssyEditorProps {
|
|
18
25
|
page: CmssyPageData;
|
|
@@ -75,4 +82,58 @@ declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | un
|
|
|
75
82
|
}>;
|
|
76
83
|
declare function getCmssyLocale(config: CmssyClientConfig): Promise<string>;
|
|
77
84
|
|
|
78
|
-
|
|
85
|
+
declare const CMSSY_SESSION_COOKIE = "cmssy_session";
|
|
86
|
+
declare const SESSION_MAX_AGE_SECONDS: number;
|
|
87
|
+
interface CmssySessionUser {
|
|
88
|
+
recordId: string;
|
|
89
|
+
email: string;
|
|
90
|
+
}
|
|
91
|
+
interface CmssySessionPayload {
|
|
92
|
+
accessToken: string;
|
|
93
|
+
refreshToken: string;
|
|
94
|
+
accessExpiresAt: number;
|
|
95
|
+
user: CmssySessionUser;
|
|
96
|
+
}
|
|
97
|
+
declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
|
|
98
|
+
declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
|
|
99
|
+
declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
|
|
100
|
+
interface SessionCookieOptions {
|
|
101
|
+
httpOnly: true;
|
|
102
|
+
secure: boolean;
|
|
103
|
+
sameSite: "lax";
|
|
104
|
+
path: "/";
|
|
105
|
+
maxAge: number;
|
|
106
|
+
}
|
|
107
|
+
declare function sessionCookieOptions(): SessionCookieOptions;
|
|
108
|
+
|
|
109
|
+
interface CmssyAuthRouteHandlers {
|
|
110
|
+
POST(request: Request, context: {
|
|
111
|
+
params: Promise<{
|
|
112
|
+
action: string;
|
|
113
|
+
}>;
|
|
114
|
+
}): Promise<Response>;
|
|
115
|
+
GET(request: Request, context: {
|
|
116
|
+
params: Promise<{
|
|
117
|
+
action: string;
|
|
118
|
+
}>;
|
|
119
|
+
}): Promise<Response>;
|
|
120
|
+
}
|
|
121
|
+
declare function createCmssyAuthRoute(config: CmssyNextConfig): CmssyAuthRouteHandlers;
|
|
122
|
+
|
|
123
|
+
declare const CMSSY_CART_COOKIE = "cmssy_cart";
|
|
124
|
+
interface CmssyCartRouteHandlers {
|
|
125
|
+
POST(request: Request, context: {
|
|
126
|
+
params: Promise<{
|
|
127
|
+
action: string;
|
|
128
|
+
}>;
|
|
129
|
+
}): Promise<Response>;
|
|
130
|
+
}
|
|
131
|
+
declare function createCmssyCartRoute(config: CmssyNextConfig): CmssyCartRouteHandlers;
|
|
132
|
+
|
|
133
|
+
declare function getCmssyUser(config: CmssyNextConfig): Promise<CmssySessionUser | null>;
|
|
134
|
+
declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string | null>;
|
|
135
|
+
|
|
136
|
+
type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
|
|
137
|
+
declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
|
|
138
|
+
|
|
139
|
+
export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssySessionPayload, type CmssySessionUser, type CreateCmssyPageOptions, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, applyCmssyCsp, assertAuthConfig, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyPage, createDraftRoute, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, sealSession, sessionCookieOptions, splitCmssyLocale };
|