@open-pencil/cloud 0.17.0-beta.7 → 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 +28 -22
- 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 +13 -4
- 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 +24 -24
- 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 +13 -4
- 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/server/app/cors.ts +22 -4
- package/src/server/app/index.ts +3 -1
|
@@ -16461,10 +16461,12 @@ function isOpenRead(method, path) {
|
|
|
16461
16461
|
}
|
|
16462
16462
|
/**
|
|
16463
16463
|
* Cross-origin access to the server. Its own pages and the origins it trusts send their account
|
|
16464
|
-
* with every request.
|
|
16465
|
-
*
|
|
16464
|
+
* with every request. The billing service the server advertises, at `billingOrigin`, may ask for a
|
|
16465
|
+
* billing token with the visitor's account, and nothing else. Any other page, such as the
|
|
16466
|
+
* documentation site's landing showing the tour, may read the discovery and the gallery without
|
|
16467
|
+
* one, and nothing else.
|
|
16466
16468
|
*/
|
|
16467
|
-
function createCloudCORS(allowedOrigins) {
|
|
16469
|
+
function createCloudCORS(allowedOrigins, billingOrigin) {
|
|
16468
16470
|
const trusted = cors({
|
|
16469
16471
|
origin: (origin) => allowedOrigins.has(origin) ? origin : null,
|
|
16470
16472
|
allowMethods: [
|
|
@@ -16484,8 +16486,15 @@ function createCloudCORS(allowedOrigins) {
|
|
|
16484
16486
|
allowMethods: ["GET", "HEAD"],
|
|
16485
16487
|
maxAge: 600
|
|
16486
16488
|
});
|
|
16489
|
+
const billingToken = cors({
|
|
16490
|
+
origin: (origin) => origin === billingOrigin ? origin : null,
|
|
16491
|
+
allowMethods: ["POST"],
|
|
16492
|
+
credentials: true,
|
|
16493
|
+
maxAge: 600
|
|
16494
|
+
});
|
|
16487
16495
|
return (context, next) => {
|
|
16488
16496
|
const origin = context.req.header("Origin");
|
|
16497
|
+
if (billingOrigin && origin === billingOrigin && context.req.path === "/api/billing/token") return billingToken(context, next);
|
|
16489
16498
|
const anyPage = origin !== void 0 && !allowedOrigins.has(origin);
|
|
16490
16499
|
const method = context.req.header("Access-Control-Request-Method") ?? context.req.method;
|
|
16491
16500
|
return anyPage && isOpenRead(method, context.req.path) ? openRead(context, next) : trusted(context, next);
|
|
@@ -17033,7 +17042,7 @@ function createCloudApp(services) {
|
|
|
17033
17042
|
const { config } = services;
|
|
17034
17043
|
const discovery = cloudDiscoveryFromConfig(config);
|
|
17035
17044
|
const allowedOrigins = new Set([config.publicURL, ...config.trustedOrigins].map((origin) => new URL(origin).origin));
|
|
17036
|
-
const cloudCORS = createCloudCORS(allowedOrigins);
|
|
17045
|
+
const cloudCORS = createCloudCORS(allowedOrigins, config.billingEndpoint && new URL(config.billingEndpoint).origin || void 0);
|
|
17037
17046
|
const app = createAppServices(services);
|
|
17038
17047
|
const resolvers = createRequestResolvers(services);
|
|
17039
17048
|
const checks = createRequestChecks(services, resolvers);
|