@geekmidas/manifest 10.0.0-alpha.131 → 10.0.0-alpha.133
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 +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +60 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +64 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
* this.
|
|
34
34
|
*/
|
|
35
35
|
const DEFAULT_POSTGRES_VERSION = 18;
|
|
36
|
+
/** A site's subdomain that means every subdomain — see `SiteDeclaration`. */
|
|
37
|
+
const WILDCARD_SUBDOMAIN = "*";
|
|
38
|
+
/**
|
|
39
|
+
* Whether a declaration is a site answering on every subdomain.
|
|
40
|
+
*/
|
|
41
|
+
function isWildcardSite(declaration) {
|
|
42
|
+
return declaration?.kind === "site" && declaration.subdomain === "*";
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* What a `Telemetry` node provides to each process with an edge to it.
|
|
38
46
|
*
|
|
@@ -1000,6 +1008,10 @@ function publicEnvFor(declaration, manifest) {
|
|
|
1000
1008
|
const own = provideKey(declaration.id, "url");
|
|
1001
1009
|
keys[`${prefix}${own}`] = own;
|
|
1002
1010
|
}
|
|
1011
|
+
if (isWildcardSite(declaration)) for (const role of ["domain", "protectedSubdomains"]) {
|
|
1012
|
+
const key = provideKey(declaration.id, role);
|
|
1013
|
+
keys[`${prefix}${key}`] = key;
|
|
1014
|
+
}
|
|
1003
1015
|
for (const edge of declaration.dependencies) {
|
|
1004
1016
|
const target = manifest[edge.target];
|
|
1005
1017
|
if (!target) continue;
|
|
@@ -1215,6 +1227,57 @@ function isWebOrigin(origin) {
|
|
|
1215
1227
|
return origin.startsWith("http://") || origin.startsWith("https://");
|
|
1216
1228
|
}
|
|
1217
1229
|
//#endregion
|
|
1230
|
+
//#region src/origins.ts
|
|
1231
|
+
/**
|
|
1232
|
+
* Whether a request from `origin` comes from one of `trusted`.
|
|
1233
|
+
*
|
|
1234
|
+
* An entry matches exactly — scheme, host and port — or, written
|
|
1235
|
+
* `https://*.example.com`, matches any one label in place of the `*`:
|
|
1236
|
+
* `https://acme.example.com`, never `https://example.com` and never
|
|
1237
|
+
* `https://a.b.example.com`. That is the origin a wildcard site's tenants
|
|
1238
|
+
* call from, and it is as wide as a wildcard certificate, no wider.
|
|
1239
|
+
*
|
|
1240
|
+
* A bare `*` trusts nothing: a surface that answers any origin has not said
|
|
1241
|
+
* which sites are its own.
|
|
1242
|
+
*/
|
|
1243
|
+
function trustsOrigin(origin, trusted) {
|
|
1244
|
+
const request = parse(origin);
|
|
1245
|
+
if (!request) return false;
|
|
1246
|
+
return trusted.some((entry) => {
|
|
1247
|
+
const allowed = parse(entry);
|
|
1248
|
+
if (!allowed) return false;
|
|
1249
|
+
if (allowed.scheme !== request.scheme) return false;
|
|
1250
|
+
if (allowed.port !== request.port) return false;
|
|
1251
|
+
const domain = wildcardDomainOf(allowed.host);
|
|
1252
|
+
if (domain === void 0) return allowed.host === request.host;
|
|
1253
|
+
const dot = request.host.indexOf(".");
|
|
1254
|
+
return dot > 0 && LABEL.test(request.host.slice(0, dot)) && request.host.slice(dot + 1) === domain;
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* The domain under a wildcard host — `example.com` for `*.example.com` — or
|
|
1259
|
+
* `undefined` for a host that is not one.
|
|
1260
|
+
*/
|
|
1261
|
+
function wildcardDomainOf(host) {
|
|
1262
|
+
return host.startsWith("*.") ? host.slice(2) : void 0;
|
|
1263
|
+
}
|
|
1264
|
+
/** One DNS label, as a tenant's slug is. */
|
|
1265
|
+
const LABEL = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
1266
|
+
function parse(origin) {
|
|
1267
|
+
if (!origin || origin === "*") return void 0;
|
|
1268
|
+
try {
|
|
1269
|
+
const url = new URL(origin);
|
|
1270
|
+
if (url.origin === "null") return void 0;
|
|
1271
|
+
return {
|
|
1272
|
+
scheme: url.protocol,
|
|
1273
|
+
host: url.hostname.toLowerCase(),
|
|
1274
|
+
port: url.port
|
|
1275
|
+
};
|
|
1276
|
+
} catch {
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
//#endregion
|
|
1218
1281
|
//#region src/secret.ts
|
|
1219
1282
|
/**
|
|
1220
1283
|
* What a generated secret looks like, and the one way every stage draws it.
|
|
@@ -1267,6 +1330,7 @@ exports.SECRET_LENGTH = SECRET_LENGTH;
|
|
|
1267
1330
|
exports.SECRET_SYMBOLS = SECRET_SYMBOLS;
|
|
1268
1331
|
exports.TELEMETRY_KEYS = TELEMETRY_KEYS;
|
|
1269
1332
|
exports.UnknownParent = UnknownParent;
|
|
1333
|
+
exports.WILDCARD_SUBDOMAIN = WILDCARD_SUBDOMAIN;
|
|
1270
1334
|
exports.assertDerivations = assertDerivations;
|
|
1271
1335
|
exports.bucketExpiry = bucketExpiry;
|
|
1272
1336
|
exports.cacheTable = cacheTable;
|
|
@@ -1281,6 +1345,7 @@ exports.environmentCase = environmentCase;
|
|
|
1281
1345
|
exports.externalApiUrl = externalApiUrl;
|
|
1282
1346
|
exports.isDerived = isDerived;
|
|
1283
1347
|
exports.isWebOrigin = isWebOrigin;
|
|
1348
|
+
exports.isWildcardSite = isWildcardSite;
|
|
1284
1349
|
exports.kebabCase = kebabCase;
|
|
1285
1350
|
exports.kmsUrl = kmsUrl;
|
|
1286
1351
|
exports.migrationFolder = migrationFolder;
|
|
@@ -1294,5 +1359,7 @@ exports.schemeBase = schemeBase;
|
|
|
1294
1359
|
exports.scopedName = scopedName;
|
|
1295
1360
|
exports.seedFolder = seedFolder;
|
|
1296
1361
|
exports.serviceKey = serviceKey;
|
|
1362
|
+
exports.trustsOrigin = trustsOrigin;
|
|
1363
|
+
exports.wildcardDomainOf = wildcardDomainOf;
|
|
1297
1364
|
|
|
1298
1365
|
//# sourceMappingURL=index.cjs.map
|