@open-pencil/cloud 0.17.0-beta.6 → 0.17.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/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +7 -1
- package/dist/contract2.js.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/listen.mjs +7 -1
- package/dist/listen.mjs.map +1 -1
- package/dist/runtime-cloudflare.js +14 -5
- package/dist/runtime-cloudflare.js.map +1 -1
- package/dist/runtime-node.d.mts +20 -20
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +13 -4
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +14 -5
- package/dist/server.mjs.map +1 -1
- package/package.json +5 -5
- package/src/contract/billing.ts +7 -0
- package/src/contract/index.ts +1 -0
- package/src/runtime/site/server.ts +4 -1
- package/src/server/app/cors.ts +22 -4
- package/src/server/app/index.ts +3 -1
package/dist/server.mjs
CHANGED
|
@@ -14800,10 +14800,12 @@ function isOpenRead(method, path) {
|
|
|
14800
14800
|
}
|
|
14801
14801
|
/**
|
|
14802
14802
|
* Cross-origin access to the server. Its own pages and the origins it trusts send their account
|
|
14803
|
-
* with every request.
|
|
14804
|
-
*
|
|
14803
|
+
* with every request. The billing service the server advertises, at `billingOrigin`, may ask for a
|
|
14804
|
+
* billing token with the visitor's account, and nothing else. Any other page, such as the
|
|
14805
|
+
* documentation site's landing showing the tour, may read the discovery and the gallery without
|
|
14806
|
+
* one, and nothing else.
|
|
14805
14807
|
*/
|
|
14806
|
-
function createCloudCORS(allowedOrigins) {
|
|
14808
|
+
function createCloudCORS(allowedOrigins, billingOrigin) {
|
|
14807
14809
|
const trusted = cors({
|
|
14808
14810
|
origin: (origin) => allowedOrigins.has(origin) ? origin : null,
|
|
14809
14811
|
allowMethods: [
|
|
@@ -14823,8 +14825,15 @@ function createCloudCORS(allowedOrigins) {
|
|
|
14823
14825
|
allowMethods: ["GET", "HEAD"],
|
|
14824
14826
|
maxAge: 600
|
|
14825
14827
|
});
|
|
14828
|
+
const billingToken = cors({
|
|
14829
|
+
origin: (origin) => origin === billingOrigin ? origin : null,
|
|
14830
|
+
allowMethods: ["POST"],
|
|
14831
|
+
credentials: true,
|
|
14832
|
+
maxAge: 600
|
|
14833
|
+
});
|
|
14826
14834
|
return (context, next) => {
|
|
14827
14835
|
const origin = context.req.header("Origin");
|
|
14836
|
+
if (billingOrigin && origin === billingOrigin && context.req.path === "/api/billing/token") return billingToken(context, next);
|
|
14828
14837
|
const anyPage = origin !== void 0 && !allowedOrigins.has(origin);
|
|
14829
14838
|
const method = context.req.header("Access-Control-Request-Method") ?? context.req.method;
|
|
14830
14839
|
return anyPage && isOpenRead(method, context.req.path) ? openRead(context, next) : trusted(context, next);
|
|
@@ -15372,7 +15381,7 @@ function createCloudApp(services) {
|
|
|
15372
15381
|
const { config } = services;
|
|
15373
15382
|
const discovery = cloudDiscoveryFromConfig(config);
|
|
15374
15383
|
const allowedOrigins = new Set([config.publicURL, ...config.trustedOrigins].map((origin) => new URL(origin).origin));
|
|
15375
|
-
const cloudCORS = createCloudCORS(allowedOrigins);
|
|
15384
|
+
const cloudCORS = createCloudCORS(allowedOrigins, config.billingEndpoint && new URL(config.billingEndpoint).origin || void 0);
|
|
15376
15385
|
const app = createAppServices(services);
|
|
15377
15386
|
const resolvers = createRequestResolvers(services);
|
|
15378
15387
|
const checks = createRequestChecks(services, resolvers);
|
|
@@ -16250,7 +16259,7 @@ const PAGE_HEADERS = {
|
|
|
16250
16259
|
"frame-ancestors 'none'"
|
|
16251
16260
|
].join("; "),
|
|
16252
16261
|
"Strict-Transport-Security": "max-age=31536000",
|
|
16253
|
-
"Referrer-Policy": "
|
|
16262
|
+
"Referrer-Policy": "strict-origin",
|
|
16254
16263
|
"X-Content-Type-Options": "nosniff"
|
|
16255
16264
|
};
|
|
16256
16265
|
function cacheControl(path) {
|