@cedarjs/vite 8.0.0-canary.3320 → 8.0.0-canary.3323
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/plugins/vite-plugin-cedar-netlify-skew-protection.d.ts +52 -0
- package/dist/plugins/vite-plugin-cedar-netlify-skew-protection.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-netlify-skew-protection.js +184 -0
- package/package.json +20 -20
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { cedarjsJobPathInjectorPlugin } from './plugins/vite-plugin-cedarjs-job-
|
|
|
21
21
|
export { cedarMockCellDataPlugin } from './plugins/vite-plugin-cedar-mock-cell-data.js';
|
|
22
22
|
export { cedarParsedScalarsPlugin } from './plugins/vite-plugin-cedar-parsed-scalars.js';
|
|
23
23
|
export { cedarMergedConfig } from './plugins/vite-plugin-merged-config.js';
|
|
24
|
+
export { cedarNetlifySkewProtectionPlugin } from './plugins/vite-plugin-cedar-netlify-skew-protection.js';
|
|
24
25
|
export { cedarSwapApolloProvider } from './plugins/vite-plugin-swap-apollo-provider.js';
|
|
25
26
|
export { cedarUniversalDeployPlugin } from './plugins/vite-plugin-cedar-universal-deploy.js';
|
|
26
27
|
export { cedarWaitForApiServer } from './plugins/vite-plugin-cedar-wait-for-api-server.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAqCxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAA;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;A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C/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAA;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAA;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAE1F,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAgDzE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-
|
|
|
52
52
|
import { cedarMockCellDataPlugin as cedarMockCellDataPlugin2 } from "./plugins/vite-plugin-cedar-mock-cell-data.js";
|
|
53
53
|
import { cedarParsedScalarsPlugin as cedarParsedScalarsPlugin2 } from "./plugins/vite-plugin-cedar-parsed-scalars.js";
|
|
54
54
|
import { cedarMergedConfig as cedarMergedConfig2 } from "./plugins/vite-plugin-merged-config.js";
|
|
55
|
+
import { cedarNetlifySkewProtectionPlugin } from "./plugins/vite-plugin-cedar-netlify-skew-protection.js";
|
|
55
56
|
import { cedarSwapApolloProvider as cedarSwapApolloProvider2 } from "./plugins/vite-plugin-swap-apollo-provider.js";
|
|
56
57
|
import { cedarUniversalDeployPlugin } from "./plugins/vite-plugin-cedar-universal-deploy.js";
|
|
57
58
|
import { cedarWaitForApiServer as cedarWaitForApiServer2 } from "./plugins/vite-plugin-cedar-wait-for-api-server.js";
|
|
@@ -109,6 +110,7 @@ export {
|
|
|
109
110
|
cedarImportDirPlugin,
|
|
110
111
|
cedarMergedConfig2 as cedarMergedConfig,
|
|
111
112
|
cedarMockCellDataPlugin2 as cedarMockCellDataPlugin,
|
|
113
|
+
cedarNetlifySkewProtectionPlugin,
|
|
112
114
|
cedarOtelWrappingPlugin,
|
|
113
115
|
cedarParsedScalarsPlugin2 as cedarParsedScalarsPlugin,
|
|
114
116
|
cedarRemoveDevFatalErrorPage2 as cedarRemoveDevFatalErrorPage,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface CedarNetlifySkewProtectionPluginOptions {
|
|
3
|
+
headerName?: string;
|
|
4
|
+
queryName?: string;
|
|
5
|
+
cookieName?: string;
|
|
6
|
+
/**
|
|
7
|
+
* How long (in seconds) the skew-token cookie should pin a client to this
|
|
8
|
+
* deploy before expiring. Netlify's own guidance is to keep this short to
|
|
9
|
+
* minimize the window where a client could end up pinned to a deploy
|
|
10
|
+
* that's since been cleaned up — but long enough to outlast a normal
|
|
11
|
+
* session. Defaults to 4 hours.
|
|
12
|
+
*/
|
|
13
|
+
cookieMaxAge?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generates Netlify's `.netlify/v1/skew-protection.json` build output and
|
|
17
|
+
* stamps the current deploy's skew token into the SSR bundle.
|
|
18
|
+
*
|
|
19
|
+
* Background: https://docs.netlify.com/build/frameworks/frameworks-api/#netlifyv1skew-protectionjson
|
|
20
|
+
* Netlify exposes the current deploy's unique fingerprint at build time via
|
|
21
|
+
* `NETLIFY_SKEW_PROTECTION_TOKEN`, and at runtime via `context.deploy.skewProtectionToken`
|
|
22
|
+
* on the Functions/Edge Functions `context` object. Cedar's universal-deploy
|
|
23
|
+
* entries are plain `(request: Request) => Response` Fetchables with no
|
|
24
|
+
* platform-specific `context` forwarded through, so we can't read the
|
|
25
|
+
* runtime-provided token there. Instead we stamp the build-time value
|
|
26
|
+
* (identical to the runtime one — both describe the same deploy) into the
|
|
27
|
+
* bundle as a virtual module, then wrap Universal Deploy's catch-all
|
|
28
|
+
* Fetchable so every response pins the client to this deploy via a
|
|
29
|
+
* `Set-Cookie`. Cookies are the only one of Netlify's three skew-protection
|
|
30
|
+
* sources (cookie, header, query) that propagates for free — the browser
|
|
31
|
+
* resends them on every same-origin request without any client-side code
|
|
32
|
+
* having to attach anything, so that's the only mechanism this phase
|
|
33
|
+
* implements. Header/query propagation would only matter for requests that
|
|
34
|
+
* don't carry cookies (e.g. cross-origin calls), which is a narrower,
|
|
35
|
+
* separate follow-up.
|
|
36
|
+
*
|
|
37
|
+
* The UD wrapper above only covers requests that actually reach the UD
|
|
38
|
+
* Fetchable, though — a visitor's very first request, for the static HTML
|
|
39
|
+
* document itself, is served straight out of Netlify's CDN from `web/dist`
|
|
40
|
+
* and never reaches it. Netlify's own `_headers`-based custom headers
|
|
41
|
+
* explicitly warn that `Set-Cookie` there "may be overridden by Netlify
|
|
42
|
+
* cookie handling", so this also emits a small framework-authored Edge
|
|
43
|
+
* Function (via `.netlify/v1/edge-functions/`, auto-registered, no
|
|
44
|
+
* `netlify.toml` entry needed) that runs on every request, calls
|
|
45
|
+
* `context.next()`, and stamps the same cookie using the genuinely
|
|
46
|
+
* runtime-provided `context.deploy.skewProtectionToken` — which Edge
|
|
47
|
+
* Functions, unlike UD's Fetchables, do have access to. It skips responses
|
|
48
|
+
* that already carry our cookie (set by the UD wrapper above) so the two
|
|
49
|
+
* layers don't double-stamp the same request.
|
|
50
|
+
*/
|
|
51
|
+
export declare function cedarNetlifySkewProtectionPlugin(options?: CedarNetlifySkewProtectionPluginOptions): Plugin;
|
|
52
|
+
//# sourceMappingURL=vite-plugin-cedar-netlify-skew-protection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-netlify-skew-protection.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-netlify-skew-protection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,MAAM,WAAW,uCAAuC;IACtD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,GAAE,uCAA4C,GACpD,MAAM,CAgOR"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { catchAllEntry } from "@universal-deploy/store";
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
const VIRTUAL_SKEW_TOKEN_ID = "virtual:cedar-netlify-skew-token";
|
|
6
|
+
const RESOLVED_SKEW_TOKEN_ID = "\0" + VIRTUAL_SKEW_TOKEN_ID;
|
|
7
|
+
function cedarNetlifySkewProtectionPlugin(options = {}) {
|
|
8
|
+
const {
|
|
9
|
+
headerName = "cedar-skew-token",
|
|
10
|
+
queryName = "skew",
|
|
11
|
+
cookieName = "cedar-skew-token",
|
|
12
|
+
cookieMaxAge = 60 * 60 * 4
|
|
13
|
+
} = options;
|
|
14
|
+
const skewToken = process.env.NETLIFY_SKEW_PROTECTION_TOKEN ?? "";
|
|
15
|
+
return {
|
|
16
|
+
name: "cedar-netlify-skew-protection",
|
|
17
|
+
apply: "build",
|
|
18
|
+
transform(code, id) {
|
|
19
|
+
if (this.environment?.name !== "ssr" || id !== catchAllEntry) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
const wrappedCode = code.replace(
|
|
23
|
+
/^export default \{/m,
|
|
24
|
+
"const __cedarSkewCatchAllHandler = {"
|
|
25
|
+
);
|
|
26
|
+
if (wrappedCode === code) {
|
|
27
|
+
this.warn(
|
|
28
|
+
'cedar-netlify-skew-protection: expected "export default {" in the Universal Deploy catch-all entry but did not find it \u2014 skipping runtime skew-token cookie propagation. This likely means @universal-deploy/vite changed how it generates the catch-all entry.'
|
|
29
|
+
);
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
code: [
|
|
34
|
+
`import { CEDAR_SKEW_TOKEN, CEDAR_SKEW_COOKIE_NAME } from ${JSON.stringify(VIRTUAL_SKEW_TOKEN_ID)}`,
|
|
35
|
+
wrappedCode,
|
|
36
|
+
"",
|
|
37
|
+
"const __cedarSkewOriginalFetch =",
|
|
38
|
+
" __cedarSkewCatchAllHandler.fetch.bind(__cedarSkewCatchAllHandler)",
|
|
39
|
+
"",
|
|
40
|
+
"__cedarSkewCatchAllHandler.fetch = async (request, ...args) => {",
|
|
41
|
+
" const response = await __cedarSkewOriginalFetch(request, ...args)",
|
|
42
|
+
"",
|
|
43
|
+
" // No token (e.g. a local `cedar build --ud` run outside a",
|
|
44
|
+
" // Netlify build) or no response (an unmatched route) \u2014 nothing",
|
|
45
|
+
" // to stamp. Statuses outside 200-599 (e.g. 101 for a WebSocket",
|
|
46
|
+
" // upgrade) make the Response constructor below throw, and 204/304",
|
|
47
|
+
" // responses have no body semantics worth re-wrapping \u2014 leave all",
|
|
48
|
+
" // of those untouched. Also skip if a `Set-Cookie` for our cookie",
|
|
49
|
+
" // name is already present (e.g. set further up the handler chain,",
|
|
50
|
+
" // or by the edge function below) to avoid sending a duplicate.",
|
|
51
|
+
" if (",
|
|
52
|
+
" !CEDAR_SKEW_TOKEN ||",
|
|
53
|
+
" !response ||",
|
|
54
|
+
" response.status < 200 ||",
|
|
55
|
+
" response.status > 599 ||",
|
|
56
|
+
" response.status === 204 ||",
|
|
57
|
+
" response.status === 304 ||",
|
|
58
|
+
' (response.headers.get("set-cookie") ?? "").includes(',
|
|
59
|
+
" `${CEDAR_SKEW_COOKIE_NAME}=`,",
|
|
60
|
+
" )",
|
|
61
|
+
" ) {",
|
|
62
|
+
" return response",
|
|
63
|
+
" }",
|
|
64
|
+
"",
|
|
65
|
+
" const headers = new Headers(response.headers)",
|
|
66
|
+
" headers.append(",
|
|
67
|
+
' "set-cookie",',
|
|
68
|
+
` \`\${CEDAR_SKEW_COOKIE_NAME}=\${CEDAR_SKEW_TOKEN}; Path=/; Max-Age=${cookieMaxAge}; HttpOnly; Secure; SameSite=Lax\`,`,
|
|
69
|
+
" )",
|
|
70
|
+
"",
|
|
71
|
+
" return new Response(response.body, {",
|
|
72
|
+
" status: response.status,",
|
|
73
|
+
" statusText: response.statusText,",
|
|
74
|
+
" headers,",
|
|
75
|
+
" })",
|
|
76
|
+
"}",
|
|
77
|
+
"",
|
|
78
|
+
"export default __cedarSkewCatchAllHandler"
|
|
79
|
+
].join("\n"),
|
|
80
|
+
map: null
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
resolveId(id) {
|
|
84
|
+
if (id === VIRTUAL_SKEW_TOKEN_ID) {
|
|
85
|
+
return RESOLVED_SKEW_TOKEN_ID;
|
|
86
|
+
}
|
|
87
|
+
return void 0;
|
|
88
|
+
},
|
|
89
|
+
load(id) {
|
|
90
|
+
if (id !== RESOLVED_SKEW_TOKEN_ID) {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
return [
|
|
94
|
+
`export const CEDAR_SKEW_TOKEN = ${JSON.stringify(skewToken)}`,
|
|
95
|
+
`export const CEDAR_SKEW_HEADER_NAME = ${JSON.stringify(headerName)}`,
|
|
96
|
+
`export const CEDAR_SKEW_QUERY_NAME = ${JSON.stringify(queryName)}`,
|
|
97
|
+
`export const CEDAR_SKEW_COOKIE_NAME = ${JSON.stringify(cookieName)}`,
|
|
98
|
+
""
|
|
99
|
+
].join("\n");
|
|
100
|
+
},
|
|
101
|
+
writeBundle() {
|
|
102
|
+
if (this.environment?.name !== "client") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!skewToken) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const netlifyV1Dir = path.join(getPaths().web.base, ".netlify", "v1");
|
|
109
|
+
fs.mkdirSync(netlifyV1Dir, { recursive: true });
|
|
110
|
+
const manifest = {
|
|
111
|
+
// Match every path: Cedar can't assume a fixed static-asset
|
|
112
|
+
// directory convention, and Netlify's own docs example matches
|
|
113
|
+
// assets too, so there's no correctness reason to narrow this.
|
|
114
|
+
patterns: [".*"],
|
|
115
|
+
sources: [
|
|
116
|
+
{ type: "header", name: headerName },
|
|
117
|
+
{ type: "query", name: queryName },
|
|
118
|
+
{ type: "cookie", name: cookieName }
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
fs.writeFileSync(
|
|
122
|
+
path.join(netlifyV1Dir, "skew-protection.json"),
|
|
123
|
+
JSON.stringify(manifest, null, 2) + "\n"
|
|
124
|
+
);
|
|
125
|
+
const edgeFunctionsDir = path.join(netlifyV1Dir, "edge-functions");
|
|
126
|
+
fs.mkdirSync(edgeFunctionsDir, { recursive: true });
|
|
127
|
+
fs.writeFileSync(
|
|
128
|
+
path.join(edgeFunctionsDir, "cedar-skew-cookie.js"),
|
|
129
|
+
[
|
|
130
|
+
"// Generated by @cedarjs/vite \u2014 stamps the skew-protection cookie",
|
|
131
|
+
"// on requests that don't reach Universal Deploy's catch-all",
|
|
132
|
+
"// Fetchable (most notably the initial HTML document load, served",
|
|
133
|
+
"// directly from Netlify's CDN). See",
|
|
134
|
+
"// vite-plugin-cedar-netlify-skew-protection.ts for the full picture.",
|
|
135
|
+
"export default async (request, context) => {",
|
|
136
|
+
" const response = await context.next()",
|
|
137
|
+
"",
|
|
138
|
+
` const cookieName = ${JSON.stringify(cookieName)}`,
|
|
139
|
+
"",
|
|
140
|
+
" // Statuses outside 200-599 (e.g. 101 for a WebSocket upgrade)",
|
|
141
|
+
" // make the Response constructor below throw, and 204/304",
|
|
142
|
+
" // responses have no body semantics worth re-wrapping. Also skip",
|
|
143
|
+
" // if already stamped \u2014 either by the UD wrapper further down the",
|
|
144
|
+
" // chain, or (if this ran twice somehow) by this function itself.",
|
|
145
|
+
" if (",
|
|
146
|
+
" response.status < 200 ||",
|
|
147
|
+
" response.status > 599 ||",
|
|
148
|
+
" response.status === 204 ||",
|
|
149
|
+
" response.status === 304 ||",
|
|
150
|
+
' (response.headers.get("set-cookie") ?? "").includes(`${cookieName}=`)',
|
|
151
|
+
" ) {",
|
|
152
|
+
" return response",
|
|
153
|
+
" }",
|
|
154
|
+
"",
|
|
155
|
+
" const token = context.deploy?.skewProtectionToken",
|
|
156
|
+
" if (!token) {",
|
|
157
|
+
" return response",
|
|
158
|
+
" }",
|
|
159
|
+
"",
|
|
160
|
+
" const headers = new Headers(response.headers)",
|
|
161
|
+
" headers.append(",
|
|
162
|
+
' "set-cookie",',
|
|
163
|
+
` \`\${cookieName}=\${token}; Path=/; Max-Age=${cookieMaxAge}; HttpOnly; Secure; SameSite=Lax\`,`,
|
|
164
|
+
" )",
|
|
165
|
+
"",
|
|
166
|
+
" return new Response(response.body, {",
|
|
167
|
+
" status: response.status,",
|
|
168
|
+
" statusText: response.statusText,",
|
|
169
|
+
" headers,",
|
|
170
|
+
" })",
|
|
171
|
+
"}",
|
|
172
|
+
"",
|
|
173
|
+
"export const config = {",
|
|
174
|
+
' path: "/*",',
|
|
175
|
+
"}",
|
|
176
|
+
""
|
|
177
|
+
].join("\n")
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
cedarNetlifySkewProtectionPlugin
|
|
184
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.3323",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"@babel/preset-typescript": "7.29.7",
|
|
55
55
|
"@babel/traverse": "7.29.8",
|
|
56
56
|
"@babel/types": "7.29.8",
|
|
57
|
-
"@cedarjs/api": "8.0.0-canary.
|
|
58
|
-
"@cedarjs/api-server": "8.0.0-canary.
|
|
59
|
-
"@cedarjs/babel-config": "8.0.0-canary.
|
|
60
|
-
"@cedarjs/context": "8.0.0-canary.
|
|
61
|
-
"@cedarjs/graphql-server": "8.0.0-canary.
|
|
62
|
-
"@cedarjs/internal": "8.0.0-canary.
|
|
63
|
-
"@cedarjs/jobs": "8.0.0-canary.
|
|
64
|
-
"@cedarjs/project-config": "8.0.0-canary.
|
|
65
|
-
"@cedarjs/server-store": "8.0.0-canary.
|
|
66
|
-
"@cedarjs/structure": "8.0.0-canary.
|
|
67
|
-
"@cedarjs/testing": "8.0.0-canary.
|
|
57
|
+
"@cedarjs/api": "8.0.0-canary.3323",
|
|
58
|
+
"@cedarjs/api-server": "8.0.0-canary.3323",
|
|
59
|
+
"@cedarjs/babel-config": "8.0.0-canary.3323",
|
|
60
|
+
"@cedarjs/context": "8.0.0-canary.3323",
|
|
61
|
+
"@cedarjs/graphql-server": "8.0.0-canary.3323",
|
|
62
|
+
"@cedarjs/internal": "8.0.0-canary.3323",
|
|
63
|
+
"@cedarjs/jobs": "8.0.0-canary.3323",
|
|
64
|
+
"@cedarjs/project-config": "8.0.0-canary.3323",
|
|
65
|
+
"@cedarjs/server-store": "8.0.0-canary.3323",
|
|
66
|
+
"@cedarjs/structure": "8.0.0-canary.3323",
|
|
67
|
+
"@cedarjs/testing": "8.0.0-canary.3323",
|
|
68
68
|
"@swc/core": "1.16.13",
|
|
69
69
|
"@universal-deploy/store": "^0.2.1",
|
|
70
70
|
"@universal-deploy/vite": "^0.1.9",
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
"yargs-parser": "21.1.1"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/auth": "8.0.0-canary.
|
|
98
|
-
"@cedarjs/framework-tools": "8.0.0-canary.
|
|
99
|
-
"@cedarjs/router": "8.0.0-canary.
|
|
100
|
-
"@cedarjs/web": "8.0.0-canary.
|
|
97
|
+
"@cedarjs/auth": "8.0.0-canary.3323",
|
|
98
|
+
"@cedarjs/framework-tools": "8.0.0-canary.3323",
|
|
99
|
+
"@cedarjs/router": "8.0.0-canary.3323",
|
|
100
|
+
"@cedarjs/web": "8.0.0-canary.3323",
|
|
101
101
|
"@dr.pogodin/react-helmet": "2.0.4",
|
|
102
102
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
103
103
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
@@ -113,15 +113,15 @@
|
|
|
113
113
|
"publint": "0.3.24",
|
|
114
114
|
"react": "19.3.0",
|
|
115
115
|
"react-dom": "19.3.0",
|
|
116
|
-
"rollup": "4.63.
|
|
116
|
+
"rollup": "4.63.6",
|
|
117
117
|
"ts-dedent": "2.3.0",
|
|
118
118
|
"typescript": "5.9.3",
|
|
119
119
|
"vitest": "4.1.11"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
|
-
"@cedarjs/auth": "8.0.0-canary.
|
|
123
|
-
"@cedarjs/router": "8.0.0-canary.
|
|
124
|
-
"@cedarjs/web": "8.0.0-canary.
|
|
122
|
+
"@cedarjs/auth": "8.0.0-canary.3323",
|
|
123
|
+
"@cedarjs/router": "8.0.0-canary.3323",
|
|
124
|
+
"@cedarjs/web": "8.0.0-canary.3323",
|
|
125
125
|
"react": "19.3.0",
|
|
126
126
|
"react-dom": "19.3.0"
|
|
127
127
|
},
|