@claxedo/workspace-relay 0.1.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { type WorkspaceRelayBunDrainController } from "./bun";
2
2
  import { type WorkspaceRelayDirectory } from "./directory";
3
- import type { RelayHostPublicKey, RuntimeAccessTokenActiveResult } from "./server";
3
+ import { type RelayHostPublicKey, type RevocationLookup, type WorkspaceRelayTarget } from "./server";
4
4
  import type { RelayKey } from "./auth";
5
+ export { createCachedRevocationClient, createCachedTargetClient } from "./server";
5
6
  /**
6
7
  * Production fail-closed gate for the relay → claxedo-server resolver channel.
7
8
  *
@@ -102,24 +103,27 @@ export type ParseMetricsTokenEnv = {
102
103
  CLAXEDO_RELAY_METRICS_TOKEN?: string | undefined;
103
104
  };
104
105
  export declare function parseMetricsToken(env: ParseMetricsTokenEnv): string | undefined;
105
- export type RevocationLookupArgs = {
106
- jti: string;
107
- workspaceId: string;
108
- hostId: string;
109
- };
110
- export type RevocationLookup = (args: RevocationLookupArgs) => Promise<RuntimeAccessTokenActiveResult>;
111
- export type CachedRevocationOptions = {
112
- /** TTL in milliseconds for cached revocation responses. Defaults to 10_000. */
113
- ttlMs?: number;
114
- /** Clock injection for tests. Defaults to `Date.now`. */
115
- now?: () => number;
106
+ export type RuntimeAccessTokenCacheEnv = {
107
+ CLAXEDO_RELAY_RUNTIME_ACCESS_TOKEN_CACHE_TTL_MS?: string | undefined;
108
+ };
109
+ export declare function runtimeAccessTokenCacheTtlMsFromEnv(env: RuntimeAccessTokenCacheEnv): number;
110
+ export type DirectHttpConcurrencyEnv = {
111
+ CLAXEDO_RELAY_DIRECT_HTTP_CONCURRENCY?: string | undefined;
112
+ };
113
+ export declare function directHttpConcurrencyFromEnv(env: DirectHttpConcurrencyEnv): number | undefined;
114
+ export type ResolverClientCacheOptions = {
115
+ targetCacheTtlMs?: number;
116
+ revocationCacheTtlMs?: number;
117
+ };
118
+ export type ResolverClientCacheEnv = {
119
+ CLAXEDO_RELAY_TARGET_CACHE_TTL_MS?: string | undefined;
120
+ CLAXEDO_RELAY_REVOCATION_CACHE_TTL_MS?: string | undefined;
121
+ };
122
+ export declare function resolverClientCacheOptionsFromEnv(env: ResolverClientCacheEnv): ResolverClientCacheOptions;
123
+ export declare function createResolverClient(baseUrl: string, token: string | undefined, options?: ResolverClientCacheOptions): {
124
+ target: (workspaceId: string, hostId: string) => Promise<WorkspaceRelayTarget | undefined>;
125
+ revocation: RevocationLookup;
116
126
  };
117
- /**
118
- * Wraps a revocation lookup with a small in-memory cache keyed by `jti`.
119
- * Both positive and negative results are cached for the full TTL — this is
120
- * safe because RAT revocation lag is bounded by the same TTL by design.
121
- */
122
- export declare function createCachedRevocationClient(inner: RevocationLookup, options?: CachedRevocationOptions): RevocationLookup;
123
127
  /**
124
128
  * T9: graceful SIGTERM drain wiring.
125
129
  *
@@ -158,3 +162,16 @@ export type ShutdownDrainHandle = {
158
162
  isShuttingDown(): boolean;
159
163
  };
160
164
  export declare function installShutdownDrainHandler(options: ShutdownDrainHandlerOptions): ShutdownDrainHandle;
165
+ export type FatalProcessHandlerOptions = {
166
+ drain: WorkspaceRelayBunDrainController;
167
+ directory: Pick<WorkspaceRelayDirectory, "dispose">;
168
+ exit?: (code?: number) => void;
169
+ log?: (message: string) => void;
170
+ register?: boolean;
171
+ stopServer?: () => Promise<void> | void;
172
+ };
173
+ export type FatalProcessHandle = {
174
+ trigger(error: unknown, source: "uncaughtException" | "unhandledRejection"): Promise<void>;
175
+ isFatal(): boolean;
176
+ };
177
+ export declare function installFatalProcessHandlers(options: FatalProcessHandlerOptions): FatalProcessHandle;