@powerhousedao/reactor-api 6.2.3-dev.89 → 6.2.3-dev.90

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.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e0118eab-dd2a-5bf7-a67c-c78a1da0b48f")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e5d4bd51-3db5-55d4-bf9c-78572de5c2b3")}catch(e){}}();
3
3
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
4
- import { A as RequestClientBinder, B as CanonicalDocumentIdResolutionError, C as loadDocumentModels, D as manifestDeclaredSubgraphs, E as loadSubgraphs, F as READABLE_DOCUMENTS_NAMESPACE, G as AuthEvaluationUnsupportedError, H as AuthorizationPolicy, I as ReadableDocumentsProjection, J as MalformedStoredOperationError, K as AuthenticationRequiredError, L as applyReadableFilter, M as createCredentialInvalidator, N as DEFAULT_ROOT_TYPES, O as BaseSubgraph, P as EVERYONE, R as isDocumentListed, T as loadScalars, U as AuthorizedDocumentHandle, V as createCanonicalDocumentIdResolver, W as createAuthorizationService, Y as RefusalNotRecordedError, _ as runDetached, a as PIECE_SOURCE_LIST, b as extractUpgradeManifests, c as piecesFromCdnList, d as buildGraphQlDocument, f as buildGraphQlDriveDocument, g as reportFailure, h as isSubgraphClass, j as AuthService, k as callerSubject, l as piecesFromListModule, m as buildGraphqlOperations, n as scalarExportsOf, p as buildGraphqlOperation, q as ForbiddenError, s as pieceListLocation, t as extractSubgraphs, u as extractDocumentModels, v as PACKAGE_MODULE_FAILED, w as loadProcessors, x as failedLoadHeader, y as debounce, z as readableDocumentsSubquery } from "./subgraph-extraction-BA9WKjn1.mjs";
4
+ import { A as RequestClientBinder, B as CanonicalDocumentIdResolutionError, C as loadDocumentModels, D as manifestDeclaredSubgraphs, E as loadSubgraphs, F as READABLE_DOCUMENTS_NAMESPACE, G as AuthEvaluationUnsupportedError, H as AuthorizationPolicy, I as ReadableDocumentsProjection, J as MalformedStoredOperationError, K as AuthenticationRequiredError, L as applyReadableFilter, M as createCredentialInvalidator, N as DEFAULT_ROOT_TYPES, O as BaseSubgraph, P as EVERYONE, R as isDocumentListed, T as loadScalars, U as AuthorizedDocumentHandle, V as createCanonicalDocumentIdResolver, W as createAuthorizationService, Y as RefusalNotRecordedError, _ as runDetached, a as PIECE_SOURCE_LIST, b as extractUpgradeManifests, c as piecesFromCdnList, d as buildGraphQlDocument, f as buildGraphQlDriveDocument, g as reportFailure, h as isSubgraphClass, j as AuthService, k as callerSubject, l as piecesFromListModule, m as buildGraphqlOperations, n as scalarExportsOf, p as buildGraphqlOperation, q as ForbiddenError, s as pieceListLocation, t as extractSubgraphs, u as extractDocumentModels, v as PACKAGE_MODULE_FAILED, w as loadProcessors, x as failedLoadHeader, y as debounce, z as readableDocumentsSubquery } from "./subgraph-extraction-DioqM_Dc.mjs";
5
5
  import { A as getDocumentModelTypeDefs, C as createMergedSchema, D as generateDocumentModelSchema, E as findSubgraphTypeCollisions, F as typeDefinitionNames, I as getDocumentModelSchemaName, L as EMPTY_SCALAR_REGISTRY, M as hasOperationSchemas, N as reservedTypeNames, O as generatedTypesOf, P as reservedTypeNamesTaken, R as sameScalarRegistry, S as buildSubgraphSchemaModule, T as documentModelSubgraphTypes, _ as describeOwnershipConflicts, a as inspectionAdminTypeDefs, b as assembleSubgraphTypeDefs, c as HOST_ORIGIN, d as byClaimPriority, f as decideAdmission, g as collectSubgraphClaims, h as supergraphClaimLosers, i as inspectionTypeDefs, j as getGeneratedDocumentModelTypes, k as getDocumentModelSubgraphName, l as RegistrationOrder, m as documentModelSubgraphSources, n as systemTypeDefs, o as CORE_ORIGIN, p as describeOrigin, r as schema_default$2, s as DOCUMENT_MODEL_ORIGIN, t as baseDocumentModels, u as admitDocumentModels, v as DocumentModelSchemaCache, w as createSchema, x as buildDocumentModelSchema, y as SubgraphTypeCollisionError, z as schema_default$1 } from "./base-document-models-CNHrVpOU.mjs";
6
6
  import { n as createApolloFetchHandler } from "./adapter-gateway-apollo-D-EdZ4e-.mjs";
7
7
  import { _ as PGLITE_UTC_PARSERS, a as resolvePgliteMaintenance, r as createDurableNodeFs } from "./error-info-Cr6oQACe.mjs";
@@ -17,15 +17,15 @@ import { AuthEnforcementDisabledError, BareReadGate, BatchJobFailedError, CATCH_
17
17
  import { deserializeSignature, readPeerManifest, serializeSignature, setName } from "@powerhousedao/shared/document-model";
18
18
  import { createRelationalDb, getCodegenStatusRegistry } from "@powerhousedao/shared/processors";
19
19
  import { Kysely, Migrator, sql } from "kysely";
20
- import { fetchDelegationCredential, resolveSwitchboardEndpoint } from "@renown/sdk";
20
+ import { checkDelegationCredential, fetchDelegationCredential, resolveSwitchboardEndpoint, verifyDelegationProof } from "@renown/sdk";
21
21
  import { AsyncLocalStorage } from "node:async_hooks";
22
- import path, { isAbsolute, join } from "node:path";
22
+ import path, { isAbsolute, join, win32 } from "node:path";
23
23
  import { match } from "path-to-regexp";
24
24
  import posix from "node:path/posix";
25
25
  import { Readable } from "node:stream";
26
26
  import { pipeline } from "node:stream/promises";
27
27
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
28
- import nodeFs, { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, watchFile } from "node:fs";
28
+ import nodeFs, { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, watchFile, writeFileSync } from "node:fs";
29
29
  import { PerformanceObserver, constants, monitorEventLoopDelay } from "node:perf_hooks";
30
30
  import { pathToFileURL } from "node:url";
31
31
  import { SCALAR_DEFINITION_VERSION, getCatalogScalar } from "document-model/scalars";
@@ -771,11 +771,11 @@ async function createGatewayAdapter(type, logger) {
771
771
  async function createHttpAdapter(type) {
772
772
  switch (type) {
773
773
  case "express": {
774
- const { createExpressHttpAdapter } = await import("./adapter-http-express-P0t-mdMV.mjs");
774
+ const { createExpressHttpAdapter } = await import("./adapter-http-express-78KD77cI.mjs");
775
775
  return createExpressHttpAdapter();
776
776
  }
777
777
  case "fastify": {
778
- const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-D0OP5q9K.mjs");
778
+ const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-Dk7aT_xw.mjs");
779
779
  return createFastifyHttpAdapter();
780
780
  }
781
781
  }
@@ -1330,8 +1330,9 @@ function assertRelativeRoutePath(path) {
1330
1330
  * always a name:
1331
1331
  * - `@scope/pkg` — already a name.
1332
1332
  * - `@scope/pkg@1.3.9` — a registry spec; only the loader strips the tag.
1333
- * - `/Users/me/project` — the local project, which switchboard registers by
1334
- * `process.cwd()`. Its real name lives in its package.json.
1333
+ * - `/Users/me/project` or `D:\\me\\project` — the local project, which
1334
+ * switchboard registers by `process.cwd()`. Its real name lives in its
1335
+ * package.json.
1335
1336
  *
1336
1337
  * Deriving a URL segment straight from the key would give a developer's home
1337
1338
  * directory a route namespace, so the path form is resolved rather than slugged.
@@ -1339,7 +1340,7 @@ function assertRelativeRoutePath(path) {
1339
1340
  function resolvePackageName(key, readPackageJsonName = defaultReadName) {
1340
1341
  const withoutVersion = stripVersionSpec(key);
1341
1342
  if (isPackageName(withoutVersion)) return withoutVersion;
1342
- if (key.startsWith("/") || key.startsWith(".")) {
1343
+ if (key.startsWith(".") || win32.isAbsolute(key)) {
1343
1344
  const name = readPackageJsonName(key);
1344
1345
  if (name && isPackageName(name)) return name;
1345
1346
  throw new InvalidNamespaceError(`Package at "${key}" has no usable name in its package.json, so it cannot host routes`);
@@ -3788,7 +3789,7 @@ async function jobStatus(read, args, serves, readable = serves) {
3788
3789
  } catch (error) {
3789
3790
  throw new GraphQLError(`Failed to fetch job status: ${error instanceof Error ? error.message : "Unknown error"}`);
3790
3791
  }
3791
- if (!await serves(result.documentId)) result = unknownJob(args.jobId);
3792
+ if (!result.deletedDocument && !await serves(result.documentId)) result = unknownJob(args.jobId);
3792
3793
  const coordinates = [];
3793
3794
  for (const coordinate of result.consistencyToken.coordinates) if (await readable(coordinate.documentId)) coordinates.push(coordinate);
3794
3795
  result = {
@@ -5935,7 +5936,6 @@ var GraphQLManager = class {
5935
5936
  if (this.featureFlags.enableDocumentModelSubgraphs) await this.#setupDocumentModelSubgraphs("graphql", this.cachedDocumentModels);
5936
5937
  await this.#setupSubgraphs(this.subgraphs);
5937
5938
  await this.#createSupergraphGateway();
5938
- return this.updateRouter();
5939
5939
  }
5940
5940
  /** Rejects when the rebuild fails; the next change retries it. */
5941
5941
  async applyScalarRegistry(scalars) {
@@ -6500,12 +6500,13 @@ var GraphQLManager = class {
6500
6500
  * Apply a package change: `packaged` holds every loaded package's subgraph
6501
6501
  * classes. Removals run before additions, so a name one package gives up
6502
6502
  * can be taken by another in the same change. Changes apply one at a time;
6503
- * the router refresh is scheduled, not awaited.
6503
+ * the router refresh is scheduled, not awaited, unless `refresh` leaves it
6504
+ * to the caller.
6504
6505
  */
6505
- applyPackageSubgraphs(packaged, supergraph = "graphql") {
6506
- return this.#serialize(() => this.#applyPackageSubgraphs(packaged, supergraph));
6506
+ applyPackageSubgraphs(packaged, supergraph = "graphql", refresh = true) {
6507
+ return this.#serialize(() => this.#applyPackageSubgraphs(packaged, supergraph, refresh));
6507
6508
  }
6508
- async #applyPackageSubgraphs(packaged, supergraph) {
6509
+ async #applyPackageSubgraphs(packaged, supergraph, refresh) {
6509
6510
  const known = /* @__PURE__ */ new Set([...this.#packageClasses.keys(), ...Array.from(this.packageSubgraphs.keys()).filter((origin) => typeof origin === "string")]);
6510
6511
  for (const packageName of known) if (!packaged.has(packageName)) await this.#teardownPackage(packageName);
6511
6512
  this.#packageClasses = /* @__PURE__ */ new Map();
@@ -6532,7 +6533,7 @@ var GraphQLManager = class {
6532
6533
  }
6533
6534
  await this.#pruneOrigin(packageName, registered);
6534
6535
  }
6535
- this.#scheduleRouterUpdate();
6536
+ if (refresh) this.#scheduleRouterUpdate();
6536
6537
  }
6537
6538
  /**
6538
6539
  * Tear down every subgraph instance registered from `packageName`:
@@ -9028,10 +9029,10 @@ const ADMIN_USERS = new Proxy([], {
9028
9029
  //#endregion
9029
9030
  //#region src/graphql/system/version.ts
9030
9031
  function getVersion() {
9031
- return "6.2.3-dev.89";
9032
+ return "6.2.3-dev.90";
9032
9033
  }
9033
9034
  function getGitHash() {
9034
- return "0e8e1d9123a1c37c09d2a2af9d0f6d375ad66b18";
9035
+ return "2f7c664f511abfded2fe91b6a1e5f381d6a5ba4b";
9035
9036
  }
9036
9037
  function getGitUrl() {
9037
9038
  return buildTreeUrl(getGitHash());
@@ -10698,6 +10699,97 @@ var AttachmentClientProvider = class {
10698
10699
  }
10699
10700
  };
10700
10701
  //#endregion
10702
+ //#region src/services/host-auth-state.ts
10703
+ function readJson(filePath) {
10704
+ let text;
10705
+ try {
10706
+ text = readFileSync(filePath, "utf8");
10707
+ } catch {
10708
+ return;
10709
+ }
10710
+ try {
10711
+ return JSON.parse(text);
10712
+ } catch {
10713
+ throw new Error(`${filePath} is not valid JSON`);
10714
+ }
10715
+ }
10716
+ function writeJson(filePath, value) {
10717
+ mkdirSync(path.dirname(filePath), { recursive: true });
10718
+ const partial = `${filePath}.tmp`;
10719
+ writeFileSync(partial, JSON.stringify(value, null, 2), { mode: 384 });
10720
+ renameSync(partial, filePath);
10721
+ }
10722
+ const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
10723
+ "127.0.0.1",
10724
+ "::1",
10725
+ "localhost"
10726
+ ]);
10727
+ /**
10728
+ * Refuses an owner claim on a host others can reach: the first stranger to sign
10729
+ * in would own it. A host binds every interface when it names none.
10730
+ */
10731
+ function assertOwnerClaimBind(host) {
10732
+ if (host !== void 0 && LOOPBACK_HOSTS.has(host)) return;
10733
+ throw new Error(`auth.ownerClaim needs a host bound to loopback, not ${host ?? "every interface"}: set the admins instead`);
10734
+ }
10735
+ /**
10736
+ * Makes the first verified caller on a host with no admins its admin, so a
10737
+ * person's own computer needs no env file. `admins` is the list the auth and
10738
+ * authorization services read, so the claim takes effect at once. Inert when
10739
+ * admins are configured: a list someone wrote always wins.
10740
+ *
10741
+ * Only for a host that nobody else can reach before its owner does, which
10742
+ * `assertOwnerClaimBind` holds a host to.
10743
+ */
10744
+ var OwnerClaim = class {
10745
+ #filePath;
10746
+ #admins;
10747
+ constructor(filePath, admins) {
10748
+ this.#filePath = filePath;
10749
+ this.#admins = admins;
10750
+ if (admins.length > 0) return;
10751
+ const recorded = readJson(filePath)?.owner;
10752
+ if (typeof recorded === "string" && recorded !== "") admins.push(recorded.toLowerCase());
10753
+ }
10754
+ observe(address) {
10755
+ if (this.#admins.length > 0) return;
10756
+ const owner = address.toLowerCase();
10757
+ writeJson(this.#filePath, { owner });
10758
+ this.#admins.push(owner);
10759
+ }
10760
+ };
10761
+ /** Keeps them in one JSON file. They hold a public proof, not a secret. */
10762
+ var FileCredentialKeep = class {
10763
+ #filePath;
10764
+ #entries;
10765
+ constructor(filePath) {
10766
+ this.#filePath = filePath;
10767
+ this.#entries = readJson(filePath) ?? {};
10768
+ }
10769
+ get(address, chainId, appId) {
10770
+ return this.#entries[keyOf(address, chainId, appId)];
10771
+ }
10772
+ set(address, chainId, appId, credential) {
10773
+ const key = keyOf(address, chainId, appId);
10774
+ if (this.#entries[key]?.id === credential.id) return;
10775
+ this.#entries = {
10776
+ ...this.#entries,
10777
+ [key]: credential
10778
+ };
10779
+ writeJson(this.#filePath, this.#entries);
10780
+ }
10781
+ delete(address, chainId, appId) {
10782
+ const key = keyOf(address, chainId, appId);
10783
+ if (!(key in this.#entries)) return;
10784
+ const { [key]: _removed, ...rest } = this.#entries;
10785
+ this.#entries = rest;
10786
+ writeJson(this.#filePath, this.#entries);
10787
+ }
10788
+ };
10789
+ function keyOf(address, chainId, appId) {
10790
+ return `${address.toLowerCase()}|${chainId}|${appId}`;
10791
+ }
10792
+ //#endregion
10701
10793
  //#region src/graphql/gateway/require-auth-middleware.ts
10702
10794
  /**
10703
10795
  * Returns a fetch middleware that rejects anonymous callers with a 401.
@@ -11072,21 +11164,63 @@ function setupEventListeners(pkgManager, graphqlManager, reactorProcessorManager
11072
11164
  //#endregion
11073
11165
  //#region src/services/renown-credential-verifier.ts
11074
11166
  async function createRenownCredentialVerifier(config = {}) {
11167
+ if (config.keptOnly) {
11168
+ if (!config.keep) throw new Error("Renown credential verification is set to \"kept\" but this host keeps no credentials: set auth.offlineCredentials");
11169
+ return keptVerifier(config.keep);
11170
+ }
11075
11171
  const switchboardUrl = await resolveSwitchboardEndpoint({
11076
11172
  switchboardUrl: config.switchboardUrl,
11077
11173
  baseUrl: config.renownUrl
11078
11174
  });
11175
+ const source = {
11176
+ switchboardUrl,
11177
+ baseUrl: switchboardUrl ? void 0 : config.renownUrl
11178
+ };
11179
+ if (config.keep) return keepingVerifier(config.keep, source);
11079
11180
  return async ({ address, chainId, appId }) => {
11080
11181
  return await fetchDelegationCredential({
11081
11182
  address,
11082
11183
  chainId,
11083
11184
  appDid: appId,
11084
- switchboardUrl,
11085
- baseUrl: switchboardUrl ? void 0 : config.renownUrl,
11185
+ ...source,
11086
11186
  discover: false
11087
11187
  }) !== void 0;
11088
11188
  };
11089
11189
  }
11190
+ /** A credential this host was given and whose proof verifies. Renown is never
11191
+ * asked, so nothing here can be revoked but by removing it. */
11192
+ function keptVerifier(keep) {
11193
+ return async ({ address, chainId, appId }) => {
11194
+ const kept = keep.get(address, chainId, appId);
11195
+ return kept !== void 0 && verifyDelegationProof(kept, chainId);
11196
+ };
11197
+ }
11198
+ /**
11199
+ * Renown's answer decides when it gives one, and a revocation removes what was
11200
+ * kept. Otherwise a kept credential whose proof verifies stands, whatever its
11201
+ * date: an expiry during an outage must not lock a person out of their own data.
11202
+ */
11203
+ function keepingVerifier(keep, source) {
11204
+ return async ({ address, chainId, appId }) => {
11205
+ const kept = keep.get(address, chainId, appId);
11206
+ const check = await checkDelegationCredential({
11207
+ address,
11208
+ chainId,
11209
+ appDid: appId,
11210
+ ...source,
11211
+ ...kept?.expirationDate ? { expirationDate: kept.expirationDate } : {}
11212
+ });
11213
+ if (check.status === "active" && check.credential) {
11214
+ keep.set(address, chainId, appId, check.credential);
11215
+ return true;
11216
+ }
11217
+ if (check.status === "revoked") {
11218
+ keep.delete(address, chainId, appId);
11219
+ return false;
11220
+ }
11221
+ return kept !== void 0 && verifyDelegationProof(kept, chainId);
11222
+ };
11223
+ }
11090
11224
  //#endregion
11091
11225
  //#region src/services/document-permission.service.ts
11092
11226
  /**
@@ -11569,8 +11703,8 @@ function resolveRenownConfig(configured, env, logger) {
11569
11703
  }
11570
11704
  function resolveRenownSource(value, logger) {
11571
11705
  if (value === void 0 || value === null) return "remote";
11572
- if (value === "self" || value === "remote") return value;
11573
- logger.warn(`Ignoring invalid renown source "${value}" (expected "self" or "remote") — using "remote"`);
11706
+ if (value === "self" || value === "remote" || value === "kept") return value;
11707
+ logger.warn(`Ignoring invalid renown source "${value}" (expected "self", "remote" or "kept") — using "remote"`);
11574
11708
  return "remote";
11575
11709
  }
11576
11710
  /**
@@ -11843,7 +11977,7 @@ function makeDbClosers(knexInstance, pglite, logger) {
11843
11977
  /**
11844
11978
  * Sets up the subgraph manager and registers subgraphs
11845
11979
  */
11846
- async function setupGraphQLManager({ settings, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, httpServer, wsServer, clients, relationalDb, analyticsStore, syncManager, subgraphs, scalars, logger, authorizationService, authService, documentPermissionService, enableDocumentModelSubgraphs, port, reactorDriveClient, driveNodes, syncServingGate, readableDocuments, httpRoutes, attachments, inspection, driveStore, reportError }) {
11980
+ async function setupGraphQLManager({ settings, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, httpServer, wsServer, clients, relationalDb, analyticsStore, syncManager, subgraphs, scalars, logger, authorizationService, authService, documentPermissionService, enableDocumentModelSubgraphs, hostRefreshesSupergraph, port, reactorDriveClient, driveNodes, syncServingGate, readableDocuments, httpRoutes, attachments, inspection, driveStore, reportError }) {
11847
11981
  const graphqlManager = new GraphQLManager({
11848
11982
  wsCredentialRecheckIntervalMs: settings.wsCredentialRecheckIntervalMs,
11849
11983
  path: settings.basePath,
@@ -11874,19 +12008,37 @@ async function setupGraphQLManager({ settings, httpAdapter, authFetchMiddleware,
11874
12008
  reportError
11875
12009
  });
11876
12010
  await graphqlManager.init(subgraphs.core, authFetchMiddleware, requireAuthFetchMiddleware, scalars);
11877
- await graphqlManager.applyPackageSubgraphs(subgraphs.extended);
11878
- await graphqlManager.updateRouter();
12011
+ await graphqlManager.applyPackageSubgraphs(subgraphs.extended, "graphql", false);
12012
+ if (!hostRefreshesSupergraph) await graphqlManager.updateRouter(true);
11879
12013
  return graphqlManager;
11880
12014
  }
12015
+ /** Where a host keeps its auth files: an explicit dir, else the working one's `.ph`. */
12016
+ function authStateDir(auth) {
12017
+ return auth.stateDir ?? path.join(process.cwd(), ".ph");
12018
+ }
12019
+ function claimOwner(claim) {
12020
+ return (user) => claim.observe(user.address);
12021
+ }
12022
+ function processorHostOf(signer, policy) {
12023
+ const key = signer?.app?.key;
12024
+ if (!signer || !key) return void 0;
12025
+ return {
12026
+ key,
12027
+ get address() {
12028
+ return signer.user?.address || null;
12029
+ },
12030
+ requiresPerson: policy !== AuthorizationPolicy.OPEN
12031
+ };
12032
+ }
11881
12033
  /**
11882
12034
  * Starts the server (HTTP or HTTPS) and attaches WebSocket server
11883
12035
  */
11884
- async function startServer(httpAdapter, port, httpsOptions, logger) {
12036
+ async function startServer(httpAdapter, port, httpsOptions, logger, host) {
11885
12037
  const tls = httpsOptions === true ? true : typeof httpsOptions === "object" ? {
11886
12038
  keyPath: httpsOptions.keyPath,
11887
12039
  certPath: httpsOptions.certPath
11888
12040
  } : void 0;
11889
- const httpServer = await httpAdapter.listen(port, tls);
12041
+ const httpServer = await httpAdapter.listen(port, tls, host);
11890
12042
  const wsServer = new WebSocketServer({
11891
12043
  server: httpServer,
11892
12044
  path: "/graphql/subscriptions"
@@ -11991,6 +12143,7 @@ async function _setupCommonInfrastructure(options) {
11991
12143
  let authFetchMiddleware;
11992
12144
  let requireAuthFetchMiddleware;
11993
12145
  let authService;
12146
+ if (optionAuth.ownerClaim) assertOwnerClaimBind(options.server?.host);
11994
12147
  if (resolveCallerIdentity || authEnabled) {
11995
12148
  logger.info("Setting up Auth middleware (policy enforcement: @enabled, caller identity: @resolve)", authEnabled, resolveCallerIdentity);
11996
12149
  const renown = options.renown ?? resolveRenownConfig(configuredRenown, {}, logger);
@@ -12005,8 +12158,11 @@ async function _setupCommonInfrastructure(options) {
12005
12158
  credentialVerificationCacheTtlMs: optionAuth.credentialCacheTtlMs ?? (renown.source === "self" ? 0 : void 0),
12006
12159
  verifyCredential: options.verifyCredential ?? await createRenownCredentialVerifier({
12007
12160
  renownUrl: renown.url,
12008
- switchboardUrl: renown.switchboardUrl
12009
- })
12161
+ switchboardUrl: renown.switchboardUrl,
12162
+ keptOnly: renown.source === "kept",
12163
+ ...optionAuth.offlineCredentials ? { keep: new FileCredentialKeep(path.join(authStateDir(optionAuth), ".credentials.json")) } : {}
12164
+ }),
12165
+ ...optionAuth.ownerClaim ? { onVerified: claimOwner(new OwnerClaim(path.join(authStateDir(optionAuth), ".owner.json"), admins)) } : {}
12010
12166
  });
12011
12167
  authFetchMiddleware = createAuthFetchMiddleware(authService);
12012
12168
  if (requireAuthenticatedCaller) {
@@ -12101,7 +12257,8 @@ async function _setupAPI(clients, syncManager, reactorProcessorManager, httpAdap
12101
12257
  relationalDb,
12102
12258
  analyticsStore,
12103
12259
  processorApp,
12104
- config: options.processorConfig
12260
+ config: options.processorConfig,
12261
+ host: processorHostOf(options.hostSigner, authorizationConfig.policy)
12105
12262
  }),
12106
12263
  attachments: createAttachmentClient(attachments.service)
12107
12264
  };
@@ -12116,7 +12273,7 @@ async function _setupAPI(clients, syncManager, reactorProcessorManager, httpAdap
12116
12273
  for (const [packageName, fns] of processorEntries) {
12117
12274
  const validFactories = (await Promise.allSettled(fns.map(async (fn) => {
12118
12275
  try {
12119
- return fn(moduleFor(packageName));
12276
+ return await fn(moduleFor(packageName));
12120
12277
  } catch (e) {
12121
12278
  logger.error("Error initializing processor factory for package @package: @error", packageName, e);
12122
12279
  return null;
@@ -12132,7 +12289,7 @@ async function _setupAPI(clients, syncManager, reactorProcessorManager, httpAdap
12132
12289
  }
12133
12290
  }))).flat());
12134
12291
  }
12135
- const { httpServer, wsServer } = await startServer(httpAdapter, listenPort.current, options.https, logger);
12292
+ const { httpServer, wsServer } = await startServer(httpAdapter, listenPort.current, options.https, logger, options.server?.host);
12136
12293
  const boundPort = boundPortOf(httpServer);
12137
12294
  listenPort.current = boundPort;
12138
12295
  const authorizationService = createAuthorizationService(authorizationConfig, documentPermissionService, createGetParentIdsFn(clients.read));
@@ -12181,6 +12338,7 @@ async function _setupAPI(clients, syncManager, reactorProcessorManager, httpAdap
12181
12338
  authService,
12182
12339
  documentPermissionService,
12183
12340
  enableDocumentModelSubgraphs: options.enableDocumentModelSubgraphs,
12341
+ hostRefreshesSupergraph: options.hostRefreshesSupergraph,
12184
12342
  port: boundPort,
12185
12343
  reactorDriveClient,
12186
12344
  driveNodes,
@@ -12720,4 +12878,4 @@ var NodeMemorySampler = class {
12720
12878
  export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, ConsistencyCoordinateInputSchema, ConsistencyTokenInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DEFAULT_INSPECTION_THROTTLE, DEFAULT_PERMISSION_CACHE_OPTIONS, DEFAULT_PERMISSION_CACHE_TTL_MS, DEFAULT_ROOT_TYPES, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentModelSchemaCache, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentPermissionSnapshot, DocumentRelationshipFieldsFragmentDoc, DriveNodeFieldsFragmentDoc, DriveNodeKind, DriveNodeKindSchema, EVERYONE, EvaluateActionsDocument, ExecuteBatchDocument, ExecutionJobInputSchema, FindDocumentsDocument, ForbiddenError, GetCreateDefaultsDocument, GetCreateProtocolVersionsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentServedDocument, GetDocumentWithOperationsDocument, GetDriveDescendantsDocument, GetDriveNodeDocument, GetDriveNodesDocument, GetJobStatusDocument, GetUndoRedoTargetsDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InspectionAdminSubgraph, InspectionSubgraph, InspectionThrottle, InspectionThrottledError, InvalidNamespaceError, JobChangesDocument, JobInfoFieldsFragmentDoc, JsonlFile, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, NodeEventLoopDelay, NodeMemorySampler, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PermissionCache, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, READABLE_DOCUMENTS_NAMESPACE, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, ReadableDocumentsProjection, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, RequestLoadRecorder, SearchFilterInputSchema, SetPreferredEditorDocument, SubgraphTypeCollisionError, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WS_CLOSE_REASON_CREDENTIAL_REVOKED, WebhookService, applyReadableFilter, assembleSubgraphTypeDefs, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertIndexAccessComplete, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, baseDocumentModels, buildDocumentModelSchema, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createCredentialInvalidator, createGatewayAdapter, createHeapSnapshotWriter, createHttpAdapter, createInspectionResolvers, createMergedSchema, createReactorGraphQLClient, createReactorInspectionSource, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, defineIndexSubgraph, definedNonNullAnySchema, documentModelSubgraphTypes, driveIdFromUrl, extractSubgraphs, extractSubgraphsFromModule, fileTimestamp, findSubgraphTypeCollisions, generateDocumentModelSchema, generatedTypesOf, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelSubgraphName, getDocumentModelTypeDefs, getExplorerPrefix, getGeneratedDocumentModelTypes, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, hasOperationSchemas, initAnalyticsStoreSql, initializeAndStartAPI, inspectionAdminTypeDefs, inspectionTypeDefs, isCountedRequest, isDefinedNonNullAny, isDocumentListed, isExpectedLoaderMiss, isListedAdmin, isPostgresConnectionString, isSubgraphClass, memoryFileSink, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, reactorApiConfigFromEnv, readableDocumentsSubquery, redactHeaders, renderGraphqlPlayground, reportFailure, reservedTypeNames, reservedTypeNamesTaken, resolveCredentialCacheTtlMs, resolvePackageName, resolvePermissionCacheTtlMs, resolveRenownConfig, runDetached, setAuthContext, telemetryDir, typeDefinitionNames, verifyWebhook };
12721
12879
 
12722
12880
  //# sourceMappingURL=index.mjs.map
12723
- //# debugId=e0118eab-dd2a-5bf7-a67c-c78a1da0b48f
12881
+ //# debugId=e5d4bd51-3db5-55d4-bf9c-78572de5c2b3