@powerhousedao/reactor-api 6.2.2 → 6.2.3-dev.1
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/{adapter-http-express-CgVPgEMm.mjs → adapter-http-express-54gdI9bu.mjs} +40 -26
- package/dist/adapter-http-express-54gdI9bu.mjs.map +1 -0
- package/dist/{adapter-http-fastify-D98iRljY.mjs → adapter-http-fastify-DmccBVOe.mjs} +45 -22
- package/dist/adapter-http-fastify-DmccBVOe.mjs.map +1 -0
- package/dist/index.d.mts +452 -228
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1203 -34
- package/dist/index.mjs.map +1 -1
- package/dist/src/packages/vite-loader.mjs +1 -1
- package/dist/{utils-lHoPB-ft.mjs → utils-XWVecaNn.mjs} +6 -3
- package/dist/utils-XWVecaNn.mjs.map +1 -0
- package/package.json +14 -14
- package/dist/adapter-http-express-CgVPgEMm.mjs.map +0 -1
- package/dist/adapter-http-fastify-D98iRljY.mjs.map +0 -1
- package/dist/utils-lHoPB-ft.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@ import { DocumentDriveDocument, DocumentDriveGlobalState } from "@powerhousedao/
|
|
|
12
12
|
import { AttachmentBuildResult, AttachmentReferenceIndexBuildResult, IAttachmentReferenceReader, IAttachmentReferenceWriter } from "@powerhousedao/reactor-attachments";
|
|
13
13
|
import { IAttachmentClient } from "@powerhousedao/reactor-attachments/client";
|
|
14
14
|
import { WebSocketServer } from "ws";
|
|
15
|
-
import { IRelationalDb as IRelationalDb$1, ProcessorApp, ProcessorFactory } from "@powerhousedao/shared/processors";
|
|
15
|
+
import { AuthorizerResult, IHttpScope, IRelationalDb as IRelationalDb$1, IWebhookEndpoints, IWebhookScope, NodeRouteSpec, ProcessorApp, ProcessorFactory, RouteActor, RouteAuth, RouteAuthorizer, RouteBody, RouteContext, RouteHandler, RouteMethod, RouteOptions, RouteSpec, RouteTransport, RouteUser, RouteUser as RouteUser$1, ScopedRouteHandle, WebhookEndpointInfo, WebhookField, WebhookHashAlgorithm, WebhookPolicy, WebhookReply, WebhookRequest, WebhookScheme, WebhookSignatureEncoding, WebhookSpec, WebhookVerification } from "@powerhousedao/shared/processors";
|
|
16
16
|
import { Generated, Kysely } from "kysely";
|
|
17
17
|
import { PGlite } from "@electric-sql/pglite";
|
|
18
18
|
import { Knex } from "knex";
|
|
@@ -287,6 +287,436 @@ interface IAuthorizationService {
|
|
|
287
287
|
canMutate(documentId: CanonicalDocumentId, operationType: string, userAddress?: string): Promise<boolean>;
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
|
+
//#region src/graphql/gateway/types.d.ts
|
|
291
|
+
type TlsOptions = {
|
|
292
|
+
keyPath: string;
|
|
293
|
+
certPath: string;
|
|
294
|
+
} | {
|
|
295
|
+
cert: Buffer | string;
|
|
296
|
+
key: Buffer | string;
|
|
297
|
+
} | true;
|
|
298
|
+
type GatewayContextFactory<TContext = unknown> = (request: Request) => Promise<TContext>;
|
|
299
|
+
type WsContextFactory<TContext = unknown> = (connectionParams: Record<string, unknown>) => Promise<TContext>;
|
|
300
|
+
type WsDisposer = {
|
|
301
|
+
dispose: () => void | Promise<void>;
|
|
302
|
+
};
|
|
303
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
304
|
+
/**
|
|
305
|
+
* Handle to a route registered directly on the adapter. Packages hot-reload,
|
|
306
|
+
* so every registration is reversible; disposing a route that is already gone
|
|
307
|
+
* is a no-op.
|
|
308
|
+
*
|
|
309
|
+
* The handle *is* the capability to remove that one route: holding it is the
|
|
310
|
+
* only way to take the route back, and it cannot name any other. An opaque
|
|
311
|
+
* integer would let any holder remove any route by arithmetic, and a caller
|
|
312
|
+
* that disposed twice would eventually free somebody else's registration once
|
|
313
|
+
* ids were reused.
|
|
314
|
+
*
|
|
315
|
+
* Distinct from the `ScopedRouteHandle` a package's HTTP scope hands back,
|
|
316
|
+
* which also carries the public URL the route answers on — at this layer there
|
|
317
|
+
* is no namespace to build one from and no knowledge of the host's origin.
|
|
318
|
+
*/
|
|
319
|
+
interface AdapterRouteHandle {
|
|
320
|
+
dispose(): void;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* A framework-agnostic description of a federated subgraph service.
|
|
324
|
+
* Used by IGatewayAdapter.createSupergraphHandler() to compose the supergraph SDL.
|
|
325
|
+
*/
|
|
326
|
+
type SubgraphDefinition = {
|
|
327
|
+
name: string;
|
|
328
|
+
typeDefs: DocumentNode;
|
|
329
|
+
url: string;
|
|
330
|
+
};
|
|
331
|
+
interface IGatewayAdapter<TContext = unknown> {
|
|
332
|
+
/** One-time startup. */
|
|
333
|
+
start(httpServer: http.Server): Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Returns a Fetch API handler for the given schema.
|
|
336
|
+
* Caller (IHttpAdapter) is responsible for mounting it at a path.
|
|
337
|
+
*/
|
|
338
|
+
createHandler(schema: GraphQLSchema, contextFactory: GatewayContextFactory<TContext>): Promise<FetchHandler>;
|
|
339
|
+
/**
|
|
340
|
+
* Create a federation gateway handler that composes all subgraphs into a supergraph.
|
|
341
|
+
* getSubgraphs is called eagerly (during setup) and again on every updateSupergraph() call.
|
|
342
|
+
*/
|
|
343
|
+
createSupergraphHandler(getSubgraphs: () => SubgraphDefinition[], httpServer: http.Server, contextFactory: GatewayContextFactory<TContext>): Promise<FetchHandler>;
|
|
344
|
+
/**
|
|
345
|
+
* Recompose the supergraph SDL from the current subgraph list and push the update
|
|
346
|
+
* to the running federation gateway. No-op if createSupergraphHandler() has not
|
|
347
|
+
* been called yet.
|
|
348
|
+
*/
|
|
349
|
+
updateSupergraph(): Promise<void>;
|
|
350
|
+
/** Attach WebSocket subscriptions. Returns a disposer. */
|
|
351
|
+
attachWebSocket(wsServer: WebSocketServer, schema: GraphQLSchema, contextFactory: WsContextFactory<TContext>): WsDisposer;
|
|
352
|
+
stop(): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Methods a node route may bind. OPTIONS is excluded: the framework's CORS
|
|
356
|
+
* plugin owns preflight, and a duplicate registration conflicts at startup.
|
|
357
|
+
*/
|
|
358
|
+
type HttpMethod = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";
|
|
359
|
+
interface NodeRouteOptions {
|
|
360
|
+
/** Serve sub-paths too, not just an exact path match. */
|
|
361
|
+
prefix?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Deliver the request body as the client sent it: unparsed and byte-exact.
|
|
364
|
+
* The handler reads `req` itself; the `body` argument stays undefined.
|
|
365
|
+
*
|
|
366
|
+
* Without this, the body has already been parsed by the time the handler
|
|
367
|
+
* runs, so a signature computed over the raw payload cannot be verified —
|
|
368
|
+
* re-encoding loses key order, whitespace and duplicate keys. This is the
|
|
369
|
+
* one capability a webhook endpoint cannot do without, and the reason a
|
|
370
|
+
* route needs to be dispatched ahead of the body parsers rather than behind
|
|
371
|
+
* them.
|
|
372
|
+
*/
|
|
373
|
+
rawBody?: boolean;
|
|
374
|
+
}
|
|
375
|
+
interface IHttpAdapter {
|
|
376
|
+
/** Set up CORS and body-parser equivalent middleware. */
|
|
377
|
+
setupMiddleware(config: {
|
|
378
|
+
corsOptions?: CorsOptions;
|
|
379
|
+
bodyLimit?: string;
|
|
380
|
+
}): void;
|
|
381
|
+
/**
|
|
382
|
+
* Mount a Fetch API handler. Returns a handle whose `dispose()` removes it.
|
|
383
|
+
* - exact = false (default): exact path match.
|
|
384
|
+
* - exact = true: prefix match - handler also receives all sub-paths.
|
|
385
|
+
*
|
|
386
|
+
* Mounting a path that already holds a fetch mount of the same kind
|
|
387
|
+
* replaces the previous one (last write wins).
|
|
388
|
+
*/
|
|
389
|
+
mount(path: string, handler: FetchHandler, options?: {
|
|
390
|
+
prefix?: boolean; /** @deprecated Misleading name: this always meant *prefix*, not exact. */
|
|
391
|
+
exact?: boolean;
|
|
392
|
+
}): AdapterRouteHandle;
|
|
393
|
+
/**
|
|
394
|
+
* Register a GET-only route that returns a Fetch Response (for health,
|
|
395
|
+
* explorer, etc.). Returns a handle whose `dispose()` removes it.
|
|
396
|
+
*/
|
|
397
|
+
getRoute(path: string, handler: (request: Request) => Response | Promise<Response>): AdapterRouteHandle;
|
|
398
|
+
/**
|
|
399
|
+
* Start listening on the given port. Returns the underlying http.Server
|
|
400
|
+
* so callers can attach WebSocket servers.
|
|
401
|
+
*/
|
|
402
|
+
listen(port: number, tls?: TlsOptions): Promise<http.Server>;
|
|
403
|
+
/**
|
|
404
|
+
* Mount a raw Connect/Express-compatible middleware function (e.g. Vite dev
|
|
405
|
+
* server middleware). The implementation is adapter-specific; for Express this
|
|
406
|
+
* is equivalent to `app.use(middleware)`.
|
|
407
|
+
*/
|
|
408
|
+
mountRawMiddleware(middleware: unknown): void;
|
|
409
|
+
/**
|
|
410
|
+
* Register a method-specific route handler using Node.js core HTTP types.
|
|
411
|
+
* Use this when a Fetch API FetchHandler is not possible (e.g. streaming
|
|
412
|
+
* protocols that require direct access to IncomingMessage/ServerResponse).
|
|
413
|
+
*
|
|
414
|
+
* The req/res objects are `http.IncomingMessage`/`http.ServerResponse`
|
|
415
|
+
* (Express Request/Response are compatible subtypes). Returns a handle
|
|
416
|
+
* whose `dispose()` removes it.
|
|
417
|
+
*/
|
|
418
|
+
mountNodeRoute(method: HttpMethod, path: string, handler: (req: http.IncomingMessage, res: http.ServerResponse, body?: unknown) => void | Promise<void>, options?: NodeRouteOptions): AdapterRouteHandle;
|
|
419
|
+
/**
|
|
420
|
+
* Register framework-specific Sentry error-capturing middleware after all routes
|
|
421
|
+
* are mounted. Each adapter calls the Sentry setup function appropriate for its
|
|
422
|
+
* framework (e.g. setupExpressErrorHandler, setupFastifyErrorHandler).
|
|
423
|
+
* No-op if Sentry is not relevant for the adapter.
|
|
424
|
+
*/
|
|
425
|
+
setupSentryErrorHandler(sentry: object): void;
|
|
426
|
+
/** The raw framework handle (e.g. Express app). Cast as needed at call sites. */
|
|
427
|
+
readonly handle: unknown;
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/services/auth.service.d.ts
|
|
431
|
+
type CredentialVerifier = (params: {
|
|
432
|
+
address: string;
|
|
433
|
+
chainId: number;
|
|
434
|
+
appId: string;
|
|
435
|
+
}) => Promise<boolean>;
|
|
436
|
+
interface AuthConfig {
|
|
437
|
+
/**
|
|
438
|
+
* Whether the authorization policy enforces anything: it selects `ADMIN_ONLY`
|
|
439
|
+
* over `OPEN`, and it is what `AuthContext.auth_enabled` reports to callers
|
|
440
|
+
* that gate on "is authentication being enforced" (the attachment routes do).
|
|
441
|
+
*
|
|
442
|
+
* It does NOT decide whether the bearer is read — see {@link resolveIdentity}.
|
|
443
|
+
*/
|
|
444
|
+
enabled: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Whether the bearer is verified and `AuthContext.user` populated at all.
|
|
447
|
+
*
|
|
448
|
+
* Defaults to {@link enabled}, which is the behaviour every deployment had
|
|
449
|
+
* before this option existed. Setting it independently is what lets a server
|
|
450
|
+
* know who is calling while leaving the policy `OPEN` — resolving an identity
|
|
451
|
+
* and enforcing one are different concerns, and welding them together left
|
|
452
|
+
* consumers choosing between an unauthenticated caller and locking every
|
|
453
|
+
* non-admin out.
|
|
454
|
+
*
|
|
455
|
+
* It resolves an identity and enforces nothing: a request with no token is
|
|
456
|
+
* still admitted, with no user.
|
|
457
|
+
*/
|
|
458
|
+
resolveIdentity?: boolean;
|
|
459
|
+
admins: string[];
|
|
460
|
+
skipCredentialVerification?: boolean;
|
|
461
|
+
credentialVerificationCacheTtlMs?: number;
|
|
462
|
+
verifyCredential?: CredentialVerifier;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* The authenticated principal. The shape is declared once in
|
|
466
|
+
* `@powerhousedao/shared/processors` as `RouteUser`, so a route handler and a
|
|
467
|
+
* resolver agree on it without either package redeclaring it.
|
|
468
|
+
*/
|
|
469
|
+
type User = RouteUser$1;
|
|
470
|
+
interface AuthContext {
|
|
471
|
+
user?: User;
|
|
472
|
+
admins: string[];
|
|
473
|
+
auth_enabled: boolean;
|
|
474
|
+
}
|
|
475
|
+
declare class AuthService {
|
|
476
|
+
private readonly config;
|
|
477
|
+
private readonly credentialCache;
|
|
478
|
+
constructor(config: AuthConfig);
|
|
479
|
+
/**
|
|
480
|
+
* Whether this service reads the bearer at all. Defaults to `enabled`, so a
|
|
481
|
+
* config written before `resolveIdentity` existed behaves exactly as it did.
|
|
482
|
+
*/
|
|
483
|
+
private get resolvesIdentity();
|
|
484
|
+
/** The context an unresolved request gets: no user, and no admin list to match against. */
|
|
485
|
+
private anonymousContext;
|
|
486
|
+
authenticateRequest(request: globalThis.Request): Promise<AuthContext | globalThis.Response>;
|
|
487
|
+
/**
|
|
488
|
+
* Verify a Bearer token regardless of HTTP method. Use this from non-GraphQL
|
|
489
|
+
* middleware that must enforce authentication on every request.
|
|
490
|
+
*/
|
|
491
|
+
verifyBearer(authorization: string | undefined): Promise<AuthContext | globalThis.Response>;
|
|
492
|
+
authenticateWebSocketConnection(connectionParams: Record<string, unknown>): Promise<User | null>;
|
|
493
|
+
/**
|
|
494
|
+
* Verify the auth bearer token
|
|
495
|
+
*/
|
|
496
|
+
private verifyToken;
|
|
497
|
+
/**
|
|
498
|
+
* Extract user information from verification result.
|
|
499
|
+
*
|
|
500
|
+
* The issuer is required along with the credential subject. A credential that
|
|
501
|
+
* verified must carry one -- resolving it is how the signature was checked --
|
|
502
|
+
* so this rejects a shape that cannot have come from verification rather than
|
|
503
|
+
* admitting a keyless principal.
|
|
504
|
+
*/
|
|
505
|
+
private extractUserFromVerification;
|
|
506
|
+
/**
|
|
507
|
+
* Verify that the credential still exists on the Renown API.
|
|
508
|
+
*
|
|
509
|
+
* Results are cached per (address, chainId, issuer) for a short TTL so the
|
|
510
|
+
* blocking external round-trip is not paid on every request. Concurrent
|
|
511
|
+
* checks for the same key share a single in-flight request, and entries
|
|
512
|
+
* that resolve to false are evicted immediately so failed or revoked
|
|
513
|
+
* credentials are re-checked on the next request.
|
|
514
|
+
*/
|
|
515
|
+
private verifyCredentialExists;
|
|
516
|
+
/**
|
|
517
|
+
* Enforce the cache size cap before inserting a new entry: drop expired
|
|
518
|
+
* entries first, then evict oldest-inserted entries (insertion order
|
|
519
|
+
* matches expiry order since the TTL is constant) until under the cap, so
|
|
520
|
+
* a flood of distinct keys cannot grow the map without bound.
|
|
521
|
+
*/
|
|
522
|
+
private pruneCredentialCache;
|
|
523
|
+
private fetchCredentialExists;
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/http/webhook-store.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* Where webhook tokens live. Core-owned and relational rather than per-host, so
|
|
529
|
+
* any host in a fleet can serve any endpoint: a provider's registered URL keeps
|
|
530
|
+
* working after a restart, a redeploy or a request landing on another replica.
|
|
531
|
+
*/
|
|
532
|
+
interface WebhookEndpointRow {
|
|
533
|
+
token: string;
|
|
534
|
+
/** The owning package's npm name. */
|
|
535
|
+
namespace: string;
|
|
536
|
+
/** The registration within that package. */
|
|
537
|
+
endpoint: string;
|
|
538
|
+
/** The caller's own key, e.g. a document id. Never appears in the URL. */
|
|
539
|
+
ownerKey: string;
|
|
540
|
+
createdAt: string;
|
|
541
|
+
}
|
|
542
|
+
interface IWebhookStore {
|
|
543
|
+
init(): Promise<void>;
|
|
544
|
+
/** Returns the existing token for this key, or mints one. */
|
|
545
|
+
ensure(namespace: string, endpoint: string, ownerKey: string): Promise<WebhookEndpointRow>;
|
|
546
|
+
find(token: string): Promise<WebhookEndpointRow | undefined>;
|
|
547
|
+
list(namespace: string, endpoint?: string): Promise<WebhookEndpointRow[]>;
|
|
548
|
+
revoke(namespace: string, endpoint: string, ownerKey: string): Promise<void>;
|
|
549
|
+
/** True when this delivery has been seen before, within the TTL. */
|
|
550
|
+
seen(token: string, key: string, ttlSeconds: number): Promise<boolean>;
|
|
551
|
+
}
|
|
552
|
+
/** Opaque and unguessable: the URL is a bearer capability held by a third party. */
|
|
553
|
+
declare function newWebhookToken(): string;
|
|
554
|
+
/** Relational implementation, over the reactor's own database. */
|
|
555
|
+
declare class RelationalWebhookStore implements IWebhookStore {
|
|
556
|
+
#private;
|
|
557
|
+
private readonly relationalDb;
|
|
558
|
+
constructor(relationalDb: IRelationalDb$1);
|
|
559
|
+
init(): Promise<void>;
|
|
560
|
+
ensure(namespace: string, endpoint: string, ownerKey: string): Promise<WebhookEndpointRow>;
|
|
561
|
+
find(token: string): Promise<WebhookEndpointRow | undefined>;
|
|
562
|
+
list(namespace: string, endpoint?: string): Promise<WebhookEndpointRow[]>;
|
|
563
|
+
revoke(namespace: string, endpoint: string, ownerKey: string): Promise<void>;
|
|
564
|
+
seen(token: string, key: string, ttlSeconds: number): Promise<boolean>;
|
|
565
|
+
}
|
|
566
|
+
/** In-memory store, for hosts with no relational database and for tests. */
|
|
567
|
+
declare class MemoryWebhookStore implements IWebhookStore {
|
|
568
|
+
#private;
|
|
569
|
+
init(): Promise<void>;
|
|
570
|
+
ensure(namespace: string, endpoint: string, ownerKey: string): Promise<WebhookEndpointRow>;
|
|
571
|
+
find(token: string): Promise<WebhookEndpointRow | undefined>;
|
|
572
|
+
list(namespace: string, endpoint?: string): Promise<WebhookEndpointRow[]>;
|
|
573
|
+
revoke(namespace: string, endpoint: string, ownerKey: string): Promise<void>;
|
|
574
|
+
seen(token: string, key: string, ttlSeconds: number): Promise<boolean>;
|
|
575
|
+
}
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/http/webhook-service.d.ts
|
|
578
|
+
/** The flat, token-addressed path family. */
|
|
579
|
+
declare const WEBHOOK_SEGMENT = "webhooks";
|
|
580
|
+
interface WebhookServiceOptions {
|
|
581
|
+
store: IWebhookStore;
|
|
582
|
+
basePath?: string;
|
|
583
|
+
/** Public origin to advertise, e.g. https://switchboard.example. */
|
|
584
|
+
publicUrl?: string;
|
|
585
|
+
}
|
|
586
|
+
/** One host route for `/webhooks/:token`, dispatching by token. The flat path leaks
|
|
587
|
+
* neither package nor document; the namespace lives in the token record, which is also what stops one package's token reaching another's handler. */
|
|
588
|
+
declare class WebhookService {
|
|
589
|
+
#private;
|
|
590
|
+
constructor({
|
|
591
|
+
store,
|
|
592
|
+
basePath,
|
|
593
|
+
publicUrl
|
|
594
|
+
}: WebhookServiceOptions);
|
|
595
|
+
/** The scope the endpoint family serves from, handed over once the route service exists;
|
|
596
|
+
* separate from the constructor only because that service takes this one as an option. */
|
|
597
|
+
attach(scope: IHttpScope): void;
|
|
598
|
+
init(): Promise<void>;
|
|
599
|
+
dispose(): void;
|
|
600
|
+
/** The facade a package's HTTP scope exposes as `scope.webhooks`. */
|
|
601
|
+
scopeFor(namespace: string): IWebhookScope;
|
|
602
|
+
/** Releases every registration a package made. */
|
|
603
|
+
disposeScope(namespace: string): void;
|
|
604
|
+
/** The URL to hand a provider. Absolute whenever the host knows its own origin: a
|
|
605
|
+
* relative path is useless to the third party that has to call it. */
|
|
606
|
+
urlFor(token: string): string;
|
|
607
|
+
/** Whether `urlFor` can produce something a provider could call. */
|
|
608
|
+
get hasPublicOrigin(): boolean;
|
|
609
|
+
}
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/http/route-service.d.ts
|
|
612
|
+
/** The segment package routes live under, inside the host's base path. */
|
|
613
|
+
declare const PACKAGE_ROUTE_SEGMENT = "api";
|
|
614
|
+
/** The namespace core's own subgraphs and services register under. */
|
|
615
|
+
declare const CORE_PACKAGE_NAME = "@powerhousedao/reactor-api";
|
|
616
|
+
interface HttpRouteServiceOptions {
|
|
617
|
+
httpAdapter: IHttpAdapter;
|
|
618
|
+
/** Absent on a host with no webhook store; `scope.webhooks` then refuses. */
|
|
619
|
+
webhooks?: WebhookService;
|
|
620
|
+
/** The host's base path, i.e. config.basePath. */
|
|
621
|
+
basePath?: string;
|
|
622
|
+
/** Absent when auth is disabled host-wide; every route then sees an anonymous actor. */
|
|
623
|
+
authService?: AuthService;
|
|
624
|
+
/** The host's public origin; empty when unknowable, the only case where advertised URLs degrade to paths. */
|
|
625
|
+
publicUrl?: string;
|
|
626
|
+
/** Whether to believe the `X-Forwarded-*` headers that name the request's public origin.
|
|
627
|
+
* Off by default: they are client-written, so with no proxy in front a caller could choose the origin a route advertises. */
|
|
628
|
+
trustProxy?: boolean;
|
|
629
|
+
}
|
|
630
|
+
/** Owns the URL space packages serve from, handing each a scope bound to its own namespace. The prefix nests inside
|
|
631
|
+
* the host's base path (`<basePath>/api`), so core collisions are prevented by URL shape, not a reserved-name list. */
|
|
632
|
+
declare class HttpRouteService {
|
|
633
|
+
#private;
|
|
634
|
+
constructor({
|
|
635
|
+
httpAdapter,
|
|
636
|
+
basePath,
|
|
637
|
+
authService,
|
|
638
|
+
webhooks,
|
|
639
|
+
publicUrl,
|
|
640
|
+
trustProxy
|
|
641
|
+
}: HttpRouteServiceOptions);
|
|
642
|
+
/** The absolute path packages are mounted under. */
|
|
643
|
+
get prefix(): string;
|
|
644
|
+
/** The scope for a package; idempotent per name, so a reload cannot accumulate namespaces. Throws when two packages
|
|
645
|
+
* resolve to one namespace — with verbatim names that means one package configured twice, a genuine ambiguity. */
|
|
646
|
+
scopeFor(packageKey: string): IHttpScope;
|
|
647
|
+
/** A scope at a host-named path; on the service, not `IHttpScope`, so a package can never name one. Namespacing is package
|
|
648
|
+
* policy: the host owns its URL space and third parties hold its URLs, so the path is verbatim and outside the package prefix. */
|
|
649
|
+
hostScope(name: string, mountPath: string): IHttpScope;
|
|
650
|
+
/** Like {@link scopeFor}, but never throws: a key resolving to no usable npm name gets a scope that refuses
|
|
651
|
+
* registrations, so one unroutable package cannot stop the host booting — it fails only if it serves a route. */
|
|
652
|
+
scopeForOrNull(packageKey: string): IHttpScope;
|
|
653
|
+
/** Releases a package's routes, e.g. when it is replaced or removed. */
|
|
654
|
+
disposeScope(packageKey: string): void;
|
|
655
|
+
disposeAll(): void;
|
|
656
|
+
}
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/http/namespace.d.ts
|
|
659
|
+
declare class InvalidNamespaceError extends Error {}
|
|
660
|
+
/**
|
|
661
|
+
* Turns a package name into the path segments it occupies.
|
|
662
|
+
* `@powerhousedao/workflow` → ["@powerhousedao", "workflow"]
|
|
663
|
+
* `document-model` → ["document-model"]
|
|
664
|
+
*/
|
|
665
|
+
declare function namespaceSegments(packageName: string): string[];
|
|
666
|
+
/**
|
|
667
|
+
* The path a package's routes hang off, relative to the package prefix.
|
|
668
|
+
* Scoped names occupy two segments — the addressing unpkg and jsdelivr use.
|
|
669
|
+
*/
|
|
670
|
+
declare function namespacePath(packageName: string): string;
|
|
671
|
+
/**
|
|
672
|
+
* Resolves the npm name a package is routed under from the key the package
|
|
673
|
+
* manager holds it by. That key is the specifier as configured, which is not
|
|
674
|
+
* always a name:
|
|
675
|
+
* - `@scope/pkg` — already a name.
|
|
676
|
+
* - `@scope/pkg@1.3.9` — a registry spec; only the loader strips the tag.
|
|
677
|
+
* - `/Users/me/project` — the local project, which switchboard registers by
|
|
678
|
+
* `process.cwd()`. Its real name lives in its package.json.
|
|
679
|
+
*
|
|
680
|
+
* Deriving a URL segment straight from the key would give a developer's home
|
|
681
|
+
* directory a route namespace, so the path form is resolved rather than slugged.
|
|
682
|
+
*/
|
|
683
|
+
declare function resolvePackageName(key: string, readPackageJsonName?: (dir: string) => string | undefined): string;
|
|
684
|
+
/**
|
|
685
|
+
* A mount path the host named for one of its own route groups.
|
|
686
|
+
*
|
|
687
|
+
* The host owns the whole URL space — it holds the adapter — so unlike a
|
|
688
|
+
* package it may name an absolute path. That is the difference between hosting
|
|
689
|
+
* and being hosted, and it is why this lives on the service rather than on a
|
|
690
|
+
* scope: a package is only ever handed a scope, and a scope has no way to
|
|
691
|
+
* express a path outside itself.
|
|
692
|
+
*
|
|
693
|
+
* What the host still may not name is anything that is not one stable literal
|
|
694
|
+
* prefix. A traversal segment, or a pattern segment, would make the group's own
|
|
695
|
+
* routes unpredictable relative to each other. Returns the normalized path,
|
|
696
|
+
* with a leading and no trailing slash.
|
|
697
|
+
*/
|
|
698
|
+
declare function assertHostMountPath(path: string): string;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/http/webhook-verify.d.ts
|
|
701
|
+
type VerifyResult = {
|
|
702
|
+
ok: true;
|
|
703
|
+
} | {
|
|
704
|
+
ok: false;
|
|
705
|
+
reason: string;
|
|
706
|
+
};
|
|
707
|
+
/** Verifies a delivery against the configured scheme; `raw` must be the exact bytes
|
|
708
|
+
* received. The reason is for the log only: callers answer a fixed 401, so a probing sender learns nothing from the body. */
|
|
709
|
+
declare function verifyWebhook(options: {
|
|
710
|
+
verification: WebhookVerification;
|
|
711
|
+
headers: Record<string, string>;
|
|
712
|
+
raw: Buffer;
|
|
713
|
+
now?: Date;
|
|
714
|
+
}): VerifyResult;
|
|
715
|
+
declare function redactHeaders(headers: Record<string, string>, extra?: string): Record<string, string>;
|
|
716
|
+
/** JSON and form bodies become objects; anything else stays decoded text, so a verified
|
|
717
|
+
* XML or CSV payload is still reachable downstream. */
|
|
718
|
+
declare function parseWebhookBody(raw: Buffer, contentType?: string): unknown;
|
|
719
|
+
//#endregion
|
|
290
720
|
//#region src/graphql/types.d.ts
|
|
291
721
|
type SubgraphClass = typeof BaseSubgraph;
|
|
292
722
|
type Context = {
|
|
@@ -321,6 +751,12 @@ type ISubgraph = {
|
|
|
321
751
|
};
|
|
322
752
|
type SubgraphArgs = {
|
|
323
753
|
reactorClient: IReactorClient;
|
|
754
|
+
/**
|
|
755
|
+
* The subgraph's package's slice of the HTTP surface, for serving REST
|
|
756
|
+
* routes and webhooks alongside the GraphQL API. Already bound to the
|
|
757
|
+
* package's namespace: there is no way to mount outside it.
|
|
758
|
+
*/
|
|
759
|
+
http: IHttpScope;
|
|
324
760
|
relationalDb: IRelationalDb;
|
|
325
761
|
analyticsStore: IAnalyticsStore;
|
|
326
762
|
graphqlManager: GraphQLManager$1;
|
|
@@ -405,6 +841,8 @@ declare class BaseSubgraph implements ISubgraph$1 {
|
|
|
405
841
|
resolvers: Record<string, any>;
|
|
406
842
|
typeDefs: DocumentNode;
|
|
407
843
|
reactorClient: IReactorClient;
|
|
844
|
+
/** This package's namespaced slice of the HTTP surface. */
|
|
845
|
+
readonly http: SubgraphArgs$1["http"];
|
|
408
846
|
graphqlManager: GraphQLManager$1;
|
|
409
847
|
relationalDb: IRelationalDb;
|
|
410
848
|
syncManager: ISyncManager;
|
|
@@ -630,229 +1068,6 @@ declare class AuthSubgraph extends BaseSubgraph {
|
|
|
630
1068
|
onSetup(): Promise<void>;
|
|
631
1069
|
}
|
|
632
1070
|
//#endregion
|
|
633
|
-
//#region src/services/auth.service.d.ts
|
|
634
|
-
type CredentialVerifier = (params: {
|
|
635
|
-
address: string;
|
|
636
|
-
chainId: number;
|
|
637
|
-
appId: string;
|
|
638
|
-
}) => Promise<boolean>;
|
|
639
|
-
interface AuthConfig {
|
|
640
|
-
/**
|
|
641
|
-
* Whether the authorization policy enforces anything: it selects `ADMIN_ONLY`
|
|
642
|
-
* over `OPEN`, and it is what `AuthContext.auth_enabled` reports to callers
|
|
643
|
-
* that gate on "is authentication being enforced" (the attachment routes do).
|
|
644
|
-
*
|
|
645
|
-
* It does NOT decide whether the bearer is read — see {@link resolveIdentity}.
|
|
646
|
-
*/
|
|
647
|
-
enabled: boolean;
|
|
648
|
-
/**
|
|
649
|
-
* Whether the bearer is verified and `AuthContext.user` populated at all.
|
|
650
|
-
*
|
|
651
|
-
* Defaults to {@link enabled}, which is the behaviour every deployment had
|
|
652
|
-
* before this option existed. Setting it independently is what lets a server
|
|
653
|
-
* know who is calling while leaving the policy `OPEN` — resolving an identity
|
|
654
|
-
* and enforcing one are different concerns, and welding them together left
|
|
655
|
-
* consumers choosing between an unauthenticated caller and locking every
|
|
656
|
-
* non-admin out.
|
|
657
|
-
*
|
|
658
|
-
* It resolves an identity and enforces nothing: a request with no token is
|
|
659
|
-
* still admitted, with no user.
|
|
660
|
-
*/
|
|
661
|
-
resolveIdentity?: boolean;
|
|
662
|
-
admins: string[];
|
|
663
|
-
skipCredentialVerification?: boolean;
|
|
664
|
-
credentialVerificationCacheTtlMs?: number;
|
|
665
|
-
verifyCredential?: CredentialVerifier;
|
|
666
|
-
}
|
|
667
|
-
interface User {
|
|
668
|
-
address: string;
|
|
669
|
-
chainId: number;
|
|
670
|
-
networkId: string;
|
|
671
|
-
/**
|
|
672
|
-
* The did:key of the app instance that issued this request's token, taken
|
|
673
|
-
* from the verified credential's issuer.
|
|
674
|
-
*
|
|
675
|
-
* It is the same value a signer presents as its app key when it signs an
|
|
676
|
-
* action, which is what a document records as its creator. Carrying it here
|
|
677
|
-
* is what lets a request decide as the same principal the write path
|
|
678
|
-
* presents, rather than as an address with no key.
|
|
679
|
-
*
|
|
680
|
-
* Authenticated, not asserted: the token is verified by resolving this very
|
|
681
|
-
* DID, so a caller cannot name someone else's.
|
|
682
|
-
*/
|
|
683
|
-
appKey: string;
|
|
684
|
-
}
|
|
685
|
-
interface AuthContext {
|
|
686
|
-
user?: User;
|
|
687
|
-
admins: string[];
|
|
688
|
-
auth_enabled: boolean;
|
|
689
|
-
}
|
|
690
|
-
declare class AuthService {
|
|
691
|
-
private readonly config;
|
|
692
|
-
private readonly credentialCache;
|
|
693
|
-
constructor(config: AuthConfig);
|
|
694
|
-
/**
|
|
695
|
-
* Whether this service reads the bearer at all. Defaults to `enabled`, so a
|
|
696
|
-
* config written before `resolveIdentity` existed behaves exactly as it did.
|
|
697
|
-
*/
|
|
698
|
-
private get resolvesIdentity();
|
|
699
|
-
/** The context an unresolved request gets: no user, and no admin list to match against. */
|
|
700
|
-
private anonymousContext;
|
|
701
|
-
authenticateRequest(request: globalThis.Request): Promise<AuthContext | globalThis.Response>;
|
|
702
|
-
/**
|
|
703
|
-
* Verify a Bearer token regardless of HTTP method. Use this from non-GraphQL
|
|
704
|
-
* middleware that must enforce authentication on every request.
|
|
705
|
-
*/
|
|
706
|
-
verifyBearer(authorization: string | undefined): Promise<AuthContext | globalThis.Response>;
|
|
707
|
-
authenticateWebSocketConnection(connectionParams: Record<string, unknown>): Promise<User | null>;
|
|
708
|
-
/**
|
|
709
|
-
* Verify the auth bearer token
|
|
710
|
-
*/
|
|
711
|
-
private verifyToken;
|
|
712
|
-
/**
|
|
713
|
-
* Extract user information from verification result.
|
|
714
|
-
*
|
|
715
|
-
* The issuer is required along with the credential subject. A credential that
|
|
716
|
-
* verified must carry one -- resolving it is how the signature was checked --
|
|
717
|
-
* so this rejects a shape that cannot have come from verification rather than
|
|
718
|
-
* admitting a keyless principal.
|
|
719
|
-
*/
|
|
720
|
-
private extractUserFromVerification;
|
|
721
|
-
/**
|
|
722
|
-
* Verify that the credential still exists on the Renown API.
|
|
723
|
-
*
|
|
724
|
-
* Results are cached per (address, chainId, issuer) for a short TTL so the
|
|
725
|
-
* blocking external round-trip is not paid on every request. Concurrent
|
|
726
|
-
* checks for the same key share a single in-flight request, and entries
|
|
727
|
-
* that resolve to false are evicted immediately so failed or revoked
|
|
728
|
-
* credentials are re-checked on the next request.
|
|
729
|
-
*/
|
|
730
|
-
private verifyCredentialExists;
|
|
731
|
-
/**
|
|
732
|
-
* Enforce the cache size cap before inserting a new entry: drop expired
|
|
733
|
-
* entries first, then evict oldest-inserted entries (insertion order
|
|
734
|
-
* matches expiry order since the TTL is constant) until under the cap, so
|
|
735
|
-
* a flood of distinct keys cannot grow the map without bound.
|
|
736
|
-
*/
|
|
737
|
-
private pruneCredentialCache;
|
|
738
|
-
private fetchCredentialExists;
|
|
739
|
-
}
|
|
740
|
-
//#endregion
|
|
741
|
-
//#region src/graphql/gateway/types.d.ts
|
|
742
|
-
type TlsOptions = {
|
|
743
|
-
keyPath: string;
|
|
744
|
-
certPath: string;
|
|
745
|
-
} | {
|
|
746
|
-
cert: Buffer | string;
|
|
747
|
-
key: Buffer | string;
|
|
748
|
-
} | true;
|
|
749
|
-
type GatewayContextFactory<TContext = unknown> = (request: Request) => Promise<TContext>;
|
|
750
|
-
type WsContextFactory<TContext = unknown> = (connectionParams: Record<string, unknown>) => Promise<TContext>;
|
|
751
|
-
type WsDisposer = {
|
|
752
|
-
dispose: () => void | Promise<void>;
|
|
753
|
-
};
|
|
754
|
-
type FetchHandler = (request: Request) => Promise<Response>;
|
|
755
|
-
/**
|
|
756
|
-
* Opaque identifier for a registered route. Returned by `mount()`,
|
|
757
|
-
* `getRoute()`, and `mountNodeRoute()`; pass it to `unmount()` to remove
|
|
758
|
-
* the route.
|
|
759
|
-
*/
|
|
760
|
-
type RouteHandle = number;
|
|
761
|
-
/**
|
|
762
|
-
* A framework-agnostic description of a federated subgraph service.
|
|
763
|
-
* Used by IGatewayAdapter.createSupergraphHandler() to compose the supergraph SDL.
|
|
764
|
-
*/
|
|
765
|
-
type SubgraphDefinition = {
|
|
766
|
-
name: string;
|
|
767
|
-
typeDefs: DocumentNode;
|
|
768
|
-
url: string;
|
|
769
|
-
};
|
|
770
|
-
interface IGatewayAdapter<TContext = unknown> {
|
|
771
|
-
/** One-time startup. */
|
|
772
|
-
start(httpServer: http.Server): Promise<void>;
|
|
773
|
-
/**
|
|
774
|
-
* Returns a Fetch API handler for the given schema.
|
|
775
|
-
* Caller (IHttpAdapter) is responsible for mounting it at a path.
|
|
776
|
-
*/
|
|
777
|
-
createHandler(schema: GraphQLSchema, contextFactory: GatewayContextFactory<TContext>): Promise<FetchHandler>;
|
|
778
|
-
/**
|
|
779
|
-
* Create a federation gateway handler that composes all subgraphs into a supergraph.
|
|
780
|
-
* getSubgraphs is called eagerly (during setup) and again on every updateSupergraph() call.
|
|
781
|
-
*/
|
|
782
|
-
createSupergraphHandler(getSubgraphs: () => SubgraphDefinition[], httpServer: http.Server, contextFactory: GatewayContextFactory<TContext>): Promise<FetchHandler>;
|
|
783
|
-
/**
|
|
784
|
-
* Recompose the supergraph SDL from the current subgraph list and push the update
|
|
785
|
-
* to the running federation gateway. No-op if createSupergraphHandler() has not
|
|
786
|
-
* been called yet.
|
|
787
|
-
*/
|
|
788
|
-
updateSupergraph(): Promise<void>;
|
|
789
|
-
/** Attach WebSocket subscriptions. Returns a disposer. */
|
|
790
|
-
attachWebSocket(wsServer: WebSocketServer, schema: GraphQLSchema, contextFactory: WsContextFactory<TContext>): WsDisposer;
|
|
791
|
-
stop(): Promise<void>;
|
|
792
|
-
}
|
|
793
|
-
interface IHttpAdapter {
|
|
794
|
-
/** Set up CORS and body-parser equivalent middleware. */
|
|
795
|
-
setupMiddleware(config: {
|
|
796
|
-
corsOptions?: CorsOptions;
|
|
797
|
-
bodyLimit?: string;
|
|
798
|
-
}): void;
|
|
799
|
-
/**
|
|
800
|
-
* Mount a Fetch API handler. Returns a handle for {@link unmount}.
|
|
801
|
-
* - exact = false (default): exact path match.
|
|
802
|
-
* - exact = true: prefix match - handler also receives all sub-paths.
|
|
803
|
-
*
|
|
804
|
-
* Mounting a path that already holds a fetch mount of the same kind
|
|
805
|
-
* replaces the previous one (last write wins).
|
|
806
|
-
*/
|
|
807
|
-
mount(path: string, handler: FetchHandler, options?: {
|
|
808
|
-
exact?: boolean;
|
|
809
|
-
}): RouteHandle;
|
|
810
|
-
/**
|
|
811
|
-
* Register a GET-only route that returns a Fetch Response (for health,
|
|
812
|
-
* explorer, etc.). Returns a handle for {@link unmount}.
|
|
813
|
-
*/
|
|
814
|
-
getRoute(path: string, handler: (request: Request) => Response | Promise<Response>): RouteHandle;
|
|
815
|
-
/**
|
|
816
|
-
* Start listening on the given port. Returns the underlying http.Server
|
|
817
|
-
* so callers can attach WebSocket servers.
|
|
818
|
-
*/
|
|
819
|
-
listen(port: number, tls?: TlsOptions): Promise<http.Server>;
|
|
820
|
-
/**
|
|
821
|
-
* Mount a raw Connect/Express-compatible middleware function (e.g. Vite dev
|
|
822
|
-
* server middleware). The implementation is adapter-specific; for Express this
|
|
823
|
-
* is equivalent to `app.use(middleware)`.
|
|
824
|
-
*/
|
|
825
|
-
mountRawMiddleware(middleware: unknown): void;
|
|
826
|
-
/**
|
|
827
|
-
* Register a method-specific route handler using Node.js core HTTP types.
|
|
828
|
-
* Use this when a Fetch API FetchHandler is not possible (e.g. streaming
|
|
829
|
-
* protocols that require direct access to IncomingMessage/ServerResponse).
|
|
830
|
-
*
|
|
831
|
-
* The req/res objects are `http.IncomingMessage`/`http.ServerResponse`
|
|
832
|
-
* (Express Request/Response are compatible subtypes). Returns a handle
|
|
833
|
-
* for {@link unmount}.
|
|
834
|
-
*/
|
|
835
|
-
mountNodeRoute(method: "DELETE" | "GET" | "HEAD" | "POST" | "PUT", path: string, handler: (req: http.IncomingMessage, res: http.ServerResponse, body?: unknown) => void | Promise<void>): RouteHandle;
|
|
836
|
-
/**
|
|
837
|
-
* Remove a route registered by `mount()`, `getRoute()`, or
|
|
838
|
-
* `mountNodeRoute()`, identified by the handle that call returned.
|
|
839
|
-
* No-op for unknown or already-removed handles.
|
|
840
|
-
*
|
|
841
|
-
* `mountRawMiddleware` is intentionally not removable: raw framework
|
|
842
|
-
* middleware (e.g. a Vite dev server) is not a single route.
|
|
843
|
-
*/
|
|
844
|
-
unmount(handle: RouteHandle): void;
|
|
845
|
-
/**
|
|
846
|
-
* Register framework-specific Sentry error-capturing middleware after all routes
|
|
847
|
-
* are mounted. Each adapter calls the Sentry setup function appropriate for its
|
|
848
|
-
* framework (e.g. setupExpressErrorHandler, setupFastifyErrorHandler).
|
|
849
|
-
* No-op if Sentry is not relevant for the adapter.
|
|
850
|
-
*/
|
|
851
|
-
setupSentryErrorHandler(sentry: object): void;
|
|
852
|
-
/** The raw framework handle (e.g. Express app). Cast as needed at call sites. */
|
|
853
|
-
readonly handle: unknown;
|
|
854
|
-
}
|
|
855
|
-
//#endregion
|
|
856
1071
|
//#region src/graphql/gateway/auth-middleware.d.ts
|
|
857
1072
|
type AuthFetchMiddleware = (handler: FetchHandler) => FetchHandler;
|
|
858
1073
|
/** Internal — only `graphql-manager.ts` should call this. */
|
|
@@ -914,6 +1129,7 @@ declare class GraphQLManager {
|
|
|
914
1129
|
private readonly featureFlags;
|
|
915
1130
|
private readonly port;
|
|
916
1131
|
private readonly syncServingGate?;
|
|
1132
|
+
private readonly httpRoutes?;
|
|
917
1133
|
private initialized;
|
|
918
1134
|
private coreSubgraphsMap;
|
|
919
1135
|
private contextFields;
|
|
@@ -940,7 +1156,7 @@ declare class GraphQLManager {
|
|
|
940
1156
|
*/
|
|
941
1157
|
readonly reactorDriveClient?: IDriveClient;
|
|
942
1158
|
private readonly authorizationService;
|
|
943
|
-
constructor(path: string, httpServer: http.Server, wsServer: WebSocketServer, reactorClient: IReactorClient, relationalDb: IRelationalDb, analyticsStore: IAnalyticsStore, syncManager: ISyncManager, logger: ILogger, httpAdapter: IHttpAdapter, gatewayAdapter: IGatewayAdapter<Context$1>, authService?: AuthService | undefined, documentPermissionService?: DocumentPermissionService | undefined, featureFlags?: GraphqlManagerFeatureFlags, port?: number, authorizationService?: IAuthorizationService, reactorDriveClient?: IDriveClient, syncServingGate?: SyncScopeGate | undefined);
|
|
1159
|
+
constructor(path: string, httpServer: http.Server, wsServer: WebSocketServer, reactorClient: IReactorClient, relationalDb: IRelationalDb, analyticsStore: IAnalyticsStore, syncManager: ISyncManager, logger: ILogger, httpAdapter: IHttpAdapter, gatewayAdapter: IGatewayAdapter<Context$1>, authService?: AuthService | undefined, documentPermissionService?: DocumentPermissionService | undefined, featureFlags?: GraphqlManagerFeatureFlags, port?: number, authorizationService?: IAuthorizationService, reactorDriveClient?: IDriveClient, syncServingGate?: SyncScopeGate | undefined, httpRoutes?: HttpRouteService | undefined);
|
|
944
1160
|
init(coreSubgraphs: SubgraphClass$1[], authMiddleware?: AuthFetchMiddleware, requireAuthMiddleware?: RequireAuthFetchMiddleware): Promise<void>;
|
|
945
1161
|
/**
|
|
946
1162
|
* Regenerate document model subgraphs when models are dynamically loaded.
|
|
@@ -962,11 +1178,18 @@ declare class GraphQLManager {
|
|
|
962
1178
|
* {@link registerSubgraphInstance}.
|
|
963
1179
|
*/
|
|
964
1180
|
getAuthorizationService(): IAuthorizationService;
|
|
1181
|
+
/**
|
|
1182
|
+
* The HTTP scope a package's subgraphs get. Falls back to a scope over a
|
|
1183
|
+
* throwaway service when route hosting is not configured, so a subgraph can
|
|
1184
|
+
* always rely on `args.http` existing.
|
|
1185
|
+
*/
|
|
1186
|
+
scopeForPackage(packageName: string): IHttpScope;
|
|
965
1187
|
/**
|
|
966
1188
|
* Register a subgraph class. `packageName` labels the resulting instance
|
|
967
1189
|
* with its contributing package so the instance can be torn down when the
|
|
968
1190
|
* package is removed or drops the subgraph (see unregisterPackage and
|
|
969
|
-
* prunePackageSubgraphs)
|
|
1191
|
+
* prunePackageSubgraphs), and decides the namespace its REST routes and
|
|
1192
|
+
* webhooks live under.
|
|
970
1193
|
*/
|
|
971
1194
|
registerSubgraph(subgraph: SubgraphClass$1, supergraph?: string, core?: boolean, packageName?: string): Promise<ISubgraph$1 | undefined>;
|
|
972
1195
|
/**
|
|
@@ -1110,7 +1333,8 @@ type ReadinessGate = {
|
|
|
1110
1333
|
markReady: () => void;
|
|
1111
1334
|
};
|
|
1112
1335
|
type API = {
|
|
1113
|
-
httpAdapter: IHttpAdapter;
|
|
1336
|
+
httpAdapter: IHttpAdapter; /** Hands each package a namespaced slice of the HTTP surface. */
|
|
1337
|
+
httpRoutes: HttpRouteService;
|
|
1114
1338
|
graphqlManager: GraphQLManager$1;
|
|
1115
1339
|
packages: IPackageManager;
|
|
1116
1340
|
attachments: AttachmentBuildResult;
|
|
@@ -3405,5 +3629,5 @@ interface DocumentModelSchemaOptions {
|
|
|
3405
3629
|
*/
|
|
3406
3630
|
declare function generateDocumentModelSchema(documentModel: DocumentModelGlobalState$1, options?: DocumentModelSchemaOptions): DocumentNode;
|
|
3407
3631
|
//#endregion
|
|
3408
|
-
export { ADMIN_USERS, API, Action, ActionCandidateInput, ActionCandidateInputSchema, ActionContext, ActionContextInput, ActionContextInputSchema, ActionContextResolvers, ActionEvaluation, ActionEvaluationResolvers, ActionEvaluations, ActionEvaluationsResolvers, ActionInput, ActionInputSchema, ActionResolvers, AddRelationshipDocument, AddRelationshipMutation, AddRelationshipMutationVariables, AnalyticsSubgraph, AttachmentAccessRequest, AttachmentAccessResult, AttachmentAccessService, type AttachmentReferenceProjectionCapability, AuthConfig, AuthContext, AuthDecision, AuthDecisionSchema, AuthFetchMiddleware, AuthService, AuthSubgraph, type AuthorizationConfig, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, type CanonicalDocumentId, CanonicalDocumentIdResolutionError, CanonicalDocumentIdResolver, ChannelMeta, ChannelMetaInput, ChannelMetaInputSchema, ChannelMetaResolvers, ClientInitializerDependencies, ClientInitializerResult, Context, CreateDocumentDocument, CreateDocumentMutation, CreateDocumentMutationVariables, CreateEmptyDocumentDocument, CreateEmptyDocumentMutation, CreateEmptyDocumentMutationVariables, CredentialVerifier, DateTimeScalarConfig, DbClient, DeadLetterInfo, DeadLetterInfoResolvers, DeleteDocumentDocument, DeleteDocumentMutation, DeleteDocumentMutationVariables, DeleteDocumentsDocument, DeleteDocumentsMutation, DeleteDocumentsMutationVariables, DirectiveResolverFn, DocumentChangeContext, DocumentChangeContextResolvers, DocumentChangeEvent, DocumentChangeEventResolvers, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentChangesSubscription, DocumentChangesSubscriptionVariables, DocumentModelGlobalState, DocumentModelGlobalStateResolvers, DocumentModelResultPage, DocumentModelResultPageResolvers, DocumentModelSchemaOptions, DocumentOperationsFilterInput, DocumentOperationsFilterInputSchema, DocumentPermissionConfig, DocumentPermissionDatabase, DocumentPermissionEntry, DocumentPermissionLevel, DocumentPermissionService, DocumentPermissionTable, DocumentProtectionTable, DocumentWithChildren, DocumentWithChildrenResolvers, EvaluateActionsDocument, EvaluateActionsQuery, EvaluateActionsQueryVariables, Exact, ExplorerUrlState, FetchHandler, FindDocumentsDocument, FindDocumentsQuery, FindDocumentsQueryVariables, GatewayAdapterType, GatewayContextFactory, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentIncomingRelationshipsQuery, GetDocumentIncomingRelationshipsQueryVariables, GetDocumentModelsDocument, GetDocumentModelsQuery, GetDocumentModelsQueryVariables, GetDocumentOperationsDocument, GetDocumentOperationsQuery, GetDocumentOperationsQueryVariables, GetDocumentOutgoingRelationshipsDocument, GetDocumentOutgoingRelationshipsQuery, GetDocumentOutgoingRelationshipsQueryVariables, GetDocumentQuery, GetDocumentQueryVariables, GetDocumentWithOperationsDocument, GetDocumentWithOperationsQuery, GetDocumentWithOperationsQueryVariables, GetJobStatusDocument, GetJobStatusQuery, GetJobStatusQueryVariables, GetParentIdsFn, GqlDocument, GqlDriveDocument, GqlOperation, GqlOperationContext, GqlSigner, GqlSignerApp, GqlSignerUser, GraphQLManager, GraphqlManagerFeatureFlags, HttpAdapterSetup, HttpAdapterType, HttpDocumentModelLoader, HttpPackageLoader, HttpPackageLoaderLogger, HttpPackageLoaderOptions, IAttachmentAccessService, type IAuthorizationService, IGatewayAdapter, IHttpAdapter, type IPackageLoader, type IPackageLoaderOptions, IPackageStorage, IProcessorHostModule, IReactorProcessorHostModule, ISubgraph, ImportPackageLoader, InMemoryPackageStorage, Incremental, InputMaybe, InstallPackageResult, InstalledPackageInfo, IsTypeOfResolverFn, JobChangeEvent, JobChangeEventResolvers, JobChangesDocument, JobChangesSubscription, JobChangesSubscriptionVariables, JobInfo, JobInfoResolvers, JsonObjectScalarConfig, MakeEmpty, MakeMaybe, MakeOptional, Maybe, MoveRelationshipDocument, MoveRelationshipMutation, MoveRelationshipMutationVariables, MoveRelationshipResult, MoveRelationshipResultResolvers, MutateDocumentAsyncDocument, MutateDocumentAsyncMutation, MutateDocumentAsyncMutationVariables, MutateDocumentDocument, MutateDocumentMutation, MutateDocumentMutationVariables, Mutation, MutationAddRelationshipArgs, MutationCreateDocumentArgs, MutationCreateEmptyDocumentArgs, MutationDeleteDocumentArgs, MutationDeleteDocumentsArgs, MutationExecuteArgs, MutationExecuteAsyncArgs, MutationMoveRelationshipArgs, MutationMutateDocumentArgs, MutationMutateDocumentAsyncArgs, MutationPushSyncEnvelopesArgs, MutationRemoveRelationshipArgs, MutationRenameDocumentArgs, MutationResolvers, MutationSetPreferredEditorArgs, MutationTouchChannelArgs, NextResolverFn, OperationContext, OperationContextInput, OperationContextInputSchema, OperationContextResolvers, OperationInput, OperationInputSchema, OperationUserPermissionEntry, OperationUserPermissionTable, OperationWithContext, OperationWithContextInput, OperationWithContextInputSchema, OperationWithContextResolvers, OperationsFilterInput, OperationsFilterInputSchema, PGLITE_UTC_PARSERS, PackageManagementService, PackageManagementServiceOptions, PackageManager, PackagesSubgraph, type PackagesSubgraphArgs, PagingInput, PagingInputSchema, type ParsedDriveUrl, PgliteFactory, PhDocument, PhDocumentFieldsFragment, PhDocumentFieldsFragmentDoc, PhDocumentOperationsArgs, PhDocumentResolvers, PhDocumentResultPage, PhDocumentResultPageResolvers, PollSyncEnvelopesDocument, PollSyncEnvelopesQuery, PollSyncEnvelopesQueryVariables, PollSyncEnvelopesResult, PollSyncEnvelopesResultResolvers, Processor, ProcessorDriveFactory, ProcessorFactoryBuilder, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, PushSyncEnvelopesMutation, PushSyncEnvelopesMutationVariables, Query, QueryDocumentArgs, QueryDocumentIncomingRelationshipsArgs, QueryDocumentModelsArgs, QueryDocumentOperationsArgs, QueryDocumentOutgoingRelationshipsArgs, QueryEvaluateActionsArgs, QueryFindDocumentsArgs, QueryJobStatusArgs, QueryPollSyncEnvelopesArgs, QueryResolvers, ReactorModule, ReactorOperation, ReactorOperationResolvers, ReactorOperationResultPage, ReactorOperationResultPageResolvers, ReactorSigner, ReactorSignerApp, ReactorSignerAppInput, ReactorSignerAppInputSchema, ReactorSignerAppResolvers, ReactorSignerInput, ReactorSignerInputSchema, ReactorSignerResolvers, ReactorSignerUser, ReactorSignerUserInput, ReactorSignerUserInputSchema, ReactorSignerUserResolvers, ReactorSubgraph, ReadinessGate, RemoteCursor, RemoteCursorInput, RemoteCursorInputSchema, RemoteCursorResolvers, RemoteFilterInput, RemoteFilterInputSchema, RemoveRelationshipDocument, RemoveRelationshipMutation, RemoveRelationshipMutationVariables, RenameDocumentDocument, RenameDocumentMutation, RenameDocumentMutationVariables, RenownConfig, RenownCredentialVerifierConfig, RenownSource, Requester, RequireFields, ResolvedRenownConfig, Resolver, ResolverFn, ResolverTypeWrapper, ResolverWithResolve, Resolvers, ResolversObject, ResolversParentTypes, ResolversTypes, Revision, RevisionResolvers,
|
|
3632
|
+
export { ADMIN_USERS, API, Action, ActionCandidateInput, ActionCandidateInputSchema, ActionContext, ActionContextInput, ActionContextInputSchema, ActionContextResolvers, ActionEvaluation, ActionEvaluationResolvers, ActionEvaluations, ActionEvaluationsResolvers, ActionInput, ActionInputSchema, ActionResolvers, AdapterRouteHandle, AddRelationshipDocument, AddRelationshipMutation, AddRelationshipMutationVariables, AnalyticsSubgraph, AttachmentAccessRequest, AttachmentAccessResult, AttachmentAccessService, type AttachmentReferenceProjectionCapability, AuthConfig, AuthContext, AuthDecision, AuthDecisionSchema, AuthFetchMiddleware, AuthService, AuthSubgraph, type AuthorizationConfig, AuthorizationPolicy, AuthorizedDocumentHandle, type AuthorizerResult, BaseSubgraph, CORE_PACKAGE_NAME, type CanonicalDocumentId, CanonicalDocumentIdResolutionError, CanonicalDocumentIdResolver, ChannelMeta, ChannelMetaInput, ChannelMetaInputSchema, ChannelMetaResolvers, ClientInitializerDependencies, ClientInitializerResult, Context, CreateDocumentDocument, CreateDocumentMutation, CreateDocumentMutationVariables, CreateEmptyDocumentDocument, CreateEmptyDocumentMutation, CreateEmptyDocumentMutationVariables, CredentialVerifier, DateTimeScalarConfig, DbClient, DeadLetterInfo, DeadLetterInfoResolvers, DeleteDocumentDocument, DeleteDocumentMutation, DeleteDocumentMutationVariables, DeleteDocumentsDocument, DeleteDocumentsMutation, DeleteDocumentsMutationVariables, DirectiveResolverFn, DocumentChangeContext, DocumentChangeContextResolvers, DocumentChangeEvent, DocumentChangeEventResolvers, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentChangesSubscription, DocumentChangesSubscriptionVariables, DocumentModelGlobalState, DocumentModelGlobalStateResolvers, DocumentModelResultPage, DocumentModelResultPageResolvers, DocumentModelSchemaOptions, DocumentOperationsFilterInput, DocumentOperationsFilterInputSchema, DocumentPermissionConfig, DocumentPermissionDatabase, DocumentPermissionEntry, DocumentPermissionLevel, DocumentPermissionService, DocumentPermissionTable, DocumentProtectionTable, DocumentWithChildren, DocumentWithChildrenResolvers, EvaluateActionsDocument, EvaluateActionsQuery, EvaluateActionsQueryVariables, Exact, ExplorerUrlState, FetchHandler, FindDocumentsDocument, FindDocumentsQuery, FindDocumentsQueryVariables, GatewayAdapterType, GatewayContextFactory, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentIncomingRelationshipsQuery, GetDocumentIncomingRelationshipsQueryVariables, GetDocumentModelsDocument, GetDocumentModelsQuery, GetDocumentModelsQueryVariables, GetDocumentOperationsDocument, GetDocumentOperationsQuery, GetDocumentOperationsQueryVariables, GetDocumentOutgoingRelationshipsDocument, GetDocumentOutgoingRelationshipsQuery, GetDocumentOutgoingRelationshipsQueryVariables, GetDocumentQuery, GetDocumentQueryVariables, GetDocumentWithOperationsDocument, GetDocumentWithOperationsQuery, GetDocumentWithOperationsQueryVariables, GetJobStatusDocument, GetJobStatusQuery, GetJobStatusQueryVariables, GetParentIdsFn, GqlDocument, GqlDriveDocument, GqlOperation, GqlOperationContext, GqlSigner, GqlSignerApp, GqlSignerUser, GraphQLManager, GraphqlManagerFeatureFlags, HttpAdapterSetup, HttpAdapterType, HttpDocumentModelLoader, HttpMethod, HttpPackageLoader, HttpPackageLoaderLogger, HttpPackageLoaderOptions, HttpRouteService, type HttpRouteServiceOptions, IAttachmentAccessService, type IAuthorizationService, IGatewayAdapter, IHttpAdapter, type IHttpScope, type IPackageLoader, type IPackageLoaderOptions, IPackageStorage, IProcessorHostModule, IReactorProcessorHostModule, ISubgraph, type IWebhookEndpoints, type IWebhookScope, type IWebhookStore, ImportPackageLoader, InMemoryPackageStorage, Incremental, InputMaybe, InstallPackageResult, InstalledPackageInfo, InvalidNamespaceError, IsTypeOfResolverFn, JobChangeEvent, JobChangeEventResolvers, JobChangesDocument, JobChangesSubscription, JobChangesSubscriptionVariables, JobInfo, JobInfoResolvers, JsonObjectScalarConfig, MakeEmpty, MakeMaybe, MakeOptional, Maybe, MemoryWebhookStore, MoveRelationshipDocument, MoveRelationshipMutation, MoveRelationshipMutationVariables, MoveRelationshipResult, MoveRelationshipResultResolvers, MutateDocumentAsyncDocument, MutateDocumentAsyncMutation, MutateDocumentAsyncMutationVariables, MutateDocumentDocument, MutateDocumentMutation, MutateDocumentMutationVariables, Mutation, MutationAddRelationshipArgs, MutationCreateDocumentArgs, MutationCreateEmptyDocumentArgs, MutationDeleteDocumentArgs, MutationDeleteDocumentsArgs, MutationExecuteArgs, MutationExecuteAsyncArgs, MutationMoveRelationshipArgs, MutationMutateDocumentArgs, MutationMutateDocumentAsyncArgs, MutationPushSyncEnvelopesArgs, MutationRemoveRelationshipArgs, MutationRenameDocumentArgs, MutationResolvers, MutationSetPreferredEditorArgs, MutationTouchChannelArgs, NextResolverFn, NodeRouteOptions, type NodeRouteSpec, OperationContext, OperationContextInput, OperationContextInputSchema, OperationContextResolvers, OperationInput, OperationInputSchema, OperationUserPermissionEntry, OperationUserPermissionTable, OperationWithContext, OperationWithContextInput, OperationWithContextInputSchema, OperationWithContextResolvers, OperationsFilterInput, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManagementServiceOptions, PackageManager, PackagesSubgraph, type PackagesSubgraphArgs, PagingInput, PagingInputSchema, type ParsedDriveUrl, PgliteFactory, PhDocument, PhDocumentFieldsFragment, PhDocumentFieldsFragmentDoc, PhDocumentOperationsArgs, PhDocumentResolvers, PhDocumentResultPage, PhDocumentResultPageResolvers, PollSyncEnvelopesDocument, PollSyncEnvelopesQuery, PollSyncEnvelopesQueryVariables, PollSyncEnvelopesResult, PollSyncEnvelopesResultResolvers, Processor, ProcessorDriveFactory, ProcessorFactoryBuilder, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, PushSyncEnvelopesMutation, PushSyncEnvelopesMutationVariables, Query, QueryDocumentArgs, QueryDocumentIncomingRelationshipsArgs, QueryDocumentModelsArgs, QueryDocumentOperationsArgs, QueryDocumentOutgoingRelationshipsArgs, QueryEvaluateActionsArgs, QueryFindDocumentsArgs, QueryJobStatusArgs, QueryPollSyncEnvelopesArgs, QueryResolvers, ReactorModule, ReactorOperation, ReactorOperationResolvers, ReactorOperationResultPage, ReactorOperationResultPageResolvers, ReactorSigner, ReactorSignerApp, ReactorSignerAppInput, ReactorSignerAppInputSchema, ReactorSignerAppResolvers, ReactorSignerInput, ReactorSignerInputSchema, ReactorSignerResolvers, ReactorSignerUser, ReactorSignerUserInput, ReactorSignerUserInputSchema, ReactorSignerUserResolvers, ReactorSubgraph, ReadinessGate, RelationalWebhookStore, RemoteCursor, RemoteCursorInput, RemoteCursorInputSchema, RemoteCursorResolvers, RemoteFilterInput, RemoteFilterInputSchema, RemoveRelationshipDocument, RemoveRelationshipMutation, RemoveRelationshipMutationVariables, RenameDocumentDocument, RenameDocumentMutation, RenameDocumentMutationVariables, RenownConfig, RenownCredentialVerifierConfig, RenownSource, Requester, RequireFields, ResolvedRenownConfig, Resolver, ResolverFn, ResolverTypeWrapper, ResolverWithResolve, Resolvers, ResolversObject, ResolversParentTypes, ResolversTypes, Revision, RevisionResolvers, type RouteActor, type RouteAuth, type RouteAuthorizer, type RouteBody, type RouteContext, type RouteHandler, type RouteMethod, type RouteOptions, type RouteSpec, type RouteTransport, type RouteUser, Scalars, type ScopedRouteHandle, Sdk, SearchFilterInput, SearchFilterInputSchema, SetPreferredEditorDocument, SetPreferredEditorMutation, SetPreferredEditorMutationVariables, SubgraphArgs, SubgraphClass, SubgraphDefinition, Subscription, SubscriptionDocumentChangesArgs, SubscriptionJobChangesArgs, SubscriptionObject, SubscriptionResolveFn, SubscriptionResolver, SubscriptionResolverObject, SubscriptionResolvers, SubscriptionSubscribeFn, SubscriptionSubscriberObject, SyncEnvelope, SyncEnvelopeInput, SyncEnvelopeInputSchema, SyncEnvelopeResolvers, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TlsOptions, TouchChannelDocument, TouchChannelInput, TouchChannelInputSchema, TouchChannelMutation, TouchChannelMutationVariables, TouchChannelResult, TouchChannelResultResolvers, TypeResolveFn, User, ViewFilterInput, ViewFilterInputSchema, WEBHOOK_SEGMENT, type WebhookEndpointInfo, type WebhookEndpointRow, type WebhookField, type WebhookHashAlgorithm, type WebhookPolicy, type WebhookReply, type WebhookRequest, type WebhookScheme, WebhookService, type WebhookSignatureEncoding, type WebhookSpec, type WebhookVerification, WithIndex, WsContextFactory, WsDisposer, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, redactHeaders, renderGraphqlPlayground, resolvePackageName, resolveRenownConfig, verifyWebhook };
|
|
3409
3633
|
//# sourceMappingURL=index.d.mts.map
|