@moltzap/identity 2026.902.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/LICENSE +202 -0
- package/NOTICE +19 -0
- package/README.md +31 -0
- package/bin/moltzap-registry +9 -0
- package/dist/agent-card.d.ts +69 -0
- package/dist/agent-card.d.ts.map +1 -0
- package/dist/agent-card.js +257 -0
- package/dist/agent-card.js.map +1 -0
- package/dist/agent-key.d.ts +77 -0
- package/dist/agent-key.d.ts.map +1 -0
- package/dist/agent-key.js +251 -0
- package/dist/agent-key.js.map +1 -0
- package/dist/authenticated-http.d.ts +44 -0
- package/dist/authenticated-http.d.ts.map +1 -0
- package/dist/authenticated-http.js +226 -0
- package/dist/authenticated-http.js.map +1 -0
- package/dist/canonical-json.d.ts +40 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +399 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/http-errors.d.ts +115 -0
- package/dist/http-errors.d.ts.map +1 -0
- package/dist/http-errors.js +55 -0
- package/dist/http-errors.js.map +1 -0
- package/dist/http-signature.d.ts +60 -0
- package/dist/http-signature.d.ts.map +1 -0
- package/dist/http-signature.js +337 -0
- package/dist/http-signature.js.map +1 -0
- package/dist/identifiers.d.ts +32 -0
- package/dist/identifiers.d.ts.map +1 -0
- package/dist/identifiers.js +55 -0
- package/dist/identifiers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/admission.d.ts +27 -0
- package/dist/registry/admission.d.ts.map +1 -0
- package/dist/registry/admission.js +107 -0
- package/dist/registry/admission.js.map +1 -0
- package/dist/registry/client.d.ts +20 -0
- package/dist/registry/client.d.ts.map +1 -0
- package/dist/registry/client.js +250 -0
- package/dist/registry/client.js.map +1 -0
- package/dist/registry/contract.d.ts +213 -0
- package/dist/registry/contract.d.ts.map +1 -0
- package/dist/registry/contract.js +132 -0
- package/dist/registry/contract.js.map +1 -0
- package/dist/registry/http.d.ts +27 -0
- package/dist/registry/http.d.ts.map +1 -0
- package/dist/registry/http.js +258 -0
- package/dist/registry/http.js.map +1 -0
- package/dist/registry/migrations/0001_registry.d.ts +6 -0
- package/dist/registry/migrations/0001_registry.d.ts.map +1 -0
- package/dist/registry/migrations/0001_registry.js +36 -0
- package/dist/registry/migrations/0001_registry.js.map +1 -0
- package/dist/registry/rpc.d.ts +138 -0
- package/dist/registry/rpc.d.ts.map +1 -0
- package/dist/registry/rpc.js +85 -0
- package/dist/registry/rpc.js.map +1 -0
- package/dist/registry/server.d.ts +52 -0
- package/dist/registry/server.d.ts.map +1 -0
- package/dist/registry/server.js +157 -0
- package/dist/registry/server.js.map +1 -0
- package/dist/registry/storage.d.ts +62 -0
- package/dist/registry/storage.d.ts.map +1 -0
- package/dist/registry/storage.js +341 -0
- package/dist/registry/storage.js.map +1 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +13 -0
- package/dist/registry.js.map +1 -0
- package/dist/signed-message.d.ts +54 -0
- package/dist/signed-message.d.ts.map +1 -0
- package/dist/signed-message.js +289 -0
- package/dist/signed-message.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/registry/rpc.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EACL,GAAG,EACH,SAAS,EACT,QAAQ,EACR,aAAa,EAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EAEP,MAAM,EAEN,KAAK,EAEL,MAAM,EACP,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EA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import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcServer, } from "@effect/rpc";
|
|
3
|
+
import { Context, Deferred, Effect, FiberRef, Layer, Option, Schema, } from "effect";
|
|
4
|
+
import { encodeCanonicalJson } from "../canonical-json.js";
|
|
5
|
+
import { AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError, } from "../http-errors.js";
|
|
6
|
+
import { listResultSchema, lookupResultSchema, registerResultSchema, RegistryListRequest, RegistryLookupRequest, RegistryRegisterRequest, } from "./contract.js";
|
|
7
|
+
class BootstrapAdmissionContext extends Context.Tag("@moltzap/identity/BootstrapAdmissionContext")() {
|
|
8
|
+
}
|
|
9
|
+
/** Required private RPC admission boundary for Registry registration. */
|
|
10
|
+
export class RegistryAdmission extends RpcMiddleware.Tag()("@moltzap/identity/RegistryAdmission", {
|
|
11
|
+
provides: BootstrapAdmissionContext,
|
|
12
|
+
failure: AuthenticationFailedError,
|
|
13
|
+
}) {
|
|
14
|
+
}
|
|
15
|
+
const currentAdmission = FiberRef.unsafeMake(Option.none());
|
|
16
|
+
/**
|
|
17
|
+
* Runs private Registry dispatch with one already-verified admission proof.
|
|
18
|
+
*
|
|
19
|
+
* @param effect Private registration dispatch to admit.
|
|
20
|
+
* @returns The dispatch with its admission proof scoped to the current fiber.
|
|
21
|
+
*/
|
|
22
|
+
export const withBootstrapAdmission = (effect) => Effect.locally(currentAdmission, Option.some(Object.freeze({ admitted: true })))(effect);
|
|
23
|
+
const readAdmission = FiberRef.get(currentAdmission).pipe(Effect.flatMap(Option.match({
|
|
24
|
+
onNone: () => Effect.fail(new AuthenticationFailedError()),
|
|
25
|
+
onSome: Effect.succeed,
|
|
26
|
+
})));
|
|
27
|
+
/** Layer installed only inside the Registry process's private RPC runtime. */
|
|
28
|
+
export const registryAdmissionLayer = Layer.succeed(RegistryAdmission, () => readAdmission);
|
|
29
|
+
const registerErrors = Schema.Union(MalformedRequestError, AuthenticationFailedError, RouteNotFoundError, MethodNotAllowedError, VersionMismatchError, PayloadTooLargeError, UnsupportedMediaTypeError, OverloadedError, UnavailableError, InternalServerError);
|
|
30
|
+
const publicReadErrors = Schema.Union(MalformedRequestError, RouteNotFoundError, MethodNotAllowedError, VersionMismatchError, PayloadTooLargeError, UnsupportedMediaTypeError, OverloadedError, UnavailableError, InternalServerError);
|
|
31
|
+
/** Private registration operation including its admission middleware. */
|
|
32
|
+
const registerOperation = Rpc.make("register", {
|
|
33
|
+
payload: RegistryRegisterRequest,
|
|
34
|
+
success: registerResultSchema,
|
|
35
|
+
error: registerErrors,
|
|
36
|
+
}).middleware(RegistryAdmission);
|
|
37
|
+
/** Private lookup operation. */
|
|
38
|
+
const lookupOperation = Rpc.make("lookup", {
|
|
39
|
+
payload: RegistryLookupRequest,
|
|
40
|
+
success: lookupResultSchema,
|
|
41
|
+
error: publicReadErrors,
|
|
42
|
+
});
|
|
43
|
+
/** Private deterministic list operation. */
|
|
44
|
+
const listOperation = Rpc.make("list", {
|
|
45
|
+
payload: RegistryListRequest,
|
|
46
|
+
success: listResultSchema,
|
|
47
|
+
error: publicReadErrors,
|
|
48
|
+
});
|
|
49
|
+
/** The package-private no-serialization Registry operation group. */
|
|
50
|
+
const registryOperations = RpcGroup.make(registerOperation, lookupOperation, listOperation);
|
|
51
|
+
/** Connects the private Registry RPC client and server in memory. */
|
|
52
|
+
export const makeRegistryRpcClient = Effect.gen(function* () {
|
|
53
|
+
const clientReady = yield* Deferred.make();
|
|
54
|
+
const server = yield* RpcServer.makeNoSerialization(registryOperations, {
|
|
55
|
+
onFromServer: (message) => Deferred.await(clientReady).pipe(Effect.flatMap((client) => client.write(message))),
|
|
56
|
+
});
|
|
57
|
+
const client = yield* RpcClient.makeNoSerialization(registryOperations, {
|
|
58
|
+
supportsAck: true,
|
|
59
|
+
onFromClient: ({ message }) => server.write(0, message),
|
|
60
|
+
});
|
|
61
|
+
yield* Deferred.succeed(clientReady, client);
|
|
62
|
+
return client.client;
|
|
63
|
+
}).pipe(Effect.withSpan("makeRegistryRpcClient"));
|
|
64
|
+
const canonicalRegisterRequest = (request) => Schema.encode(RegistryRegisterRequest)(request).pipe(Effect.flatMap(encodeCanonicalJson),
|
|
65
|
+
// eslint-disable-next-line agent-code-guard/no-effect-error-coalescing -- Private serialization failure has one closed domain error at the RPC boundary.
|
|
66
|
+
Effect.mapError(() => new InternalServerError()));
|
|
67
|
+
const registerHandler = (input) => (request) => canonicalRegisterRequest(request).pipe(Effect.flatMap((requestBytes) => input.storage.register({
|
|
68
|
+
request,
|
|
69
|
+
requestBytes,
|
|
70
|
+
registrySigningAuthority: input.registrySigningAuthority,
|
|
71
|
+
})));
|
|
72
|
+
/**
|
|
73
|
+
* Implements the three private operations over durable Registry storage.
|
|
74
|
+
*
|
|
75
|
+
* @param input Private RPC handler dependencies.
|
|
76
|
+
* @param input.storage Durable Registry operations.
|
|
77
|
+
* @param input.registrySigningAuthority Registry card issuer.
|
|
78
|
+
* @returns A layer implementing the complete private operation group.
|
|
79
|
+
*/
|
|
80
|
+
export const makeRegistryRpcHandlersLayer = (input) => registryOperations.toLayer({
|
|
81
|
+
register: registerHandler(input),
|
|
82
|
+
lookup: (request) => input.storage.lookup(request),
|
|
83
|
+
list: (request) => input.storage.list(request),
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/registry/rpc.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EACL,GAAG,EACH,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACN,MAAM,GACP,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,mBAAmB,EAAE,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C,CAAC,YAAY,EAAE,EAAE,CAC9B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrB,OAAO;IACP,YAAY;IACZ,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;CACzD,CAAC,CACH,CACF,CAAC;AAEN;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAG5C,EAAE,EAAE,CACH,kBAAkB,CAAC,OAAO,CAAC;IACzB,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC;IAChC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IAClD,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;CAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** @file Production Registry process configuration, composition, and startup boundary. */
|
|
2
|
+
import { Cause, type ConfigError, Effect, Layer, Redacted } from "effect";
|
|
3
|
+
/**
|
|
4
|
+
* Complete validated configuration for one Registry process.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface RegistryConfiguration {
|
|
9
|
+
readonly host: string;
|
|
10
|
+
readonly port: number;
|
|
11
|
+
readonly postgresqlUrl: Redacted.Redacted;
|
|
12
|
+
readonly admissionCredential: Redacted.Redacted;
|
|
13
|
+
readonly signingPrivateKeyPath: Redacted.Redacted;
|
|
14
|
+
readonly listPageSize: number;
|
|
15
|
+
readonly requestConcurrencyLimit: number;
|
|
16
|
+
readonly liveNonceCapacity: number;
|
|
17
|
+
readonly sqlPoolSize: number;
|
|
18
|
+
readonly sqlOperationTimeoutMs: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Loads the complete private Registry process configuration.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare const loadRegistryConfiguration: Effect.Effect<RegistryConfiguration, ConfigError.ConfigError>;
|
|
26
|
+
declare const StartupError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
27
|
+
readonly _tag: "RegistryServerStartupError";
|
|
28
|
+
} & Readonly<A>;
|
|
29
|
+
/** Closed Registry startup failure. */
|
|
30
|
+
export declare class StartupError extends StartupError_base<{
|
|
31
|
+
readonly phase: "configuration" | "storage" | "listener";
|
|
32
|
+
}> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Complete production Registry process composition.
|
|
36
|
+
*
|
|
37
|
+
* ```mermaid
|
|
38
|
+
* flowchart TD
|
|
39
|
+
* Binary["moltzap-registry"] --> Server["runRegistryServer"]
|
|
40
|
+
* Server --> Configuration["loadRegistryConfiguration"]
|
|
41
|
+
* Server --> Storage["RegistryStorage"]
|
|
42
|
+
* Server --> Http["makeRegistryHttpApp"]
|
|
43
|
+
* Http --> Admission["verifyBootstrapRegistration"]
|
|
44
|
+
* Http --> Rpc["RegistryRpcClient"]
|
|
45
|
+
* Admission --> Storage
|
|
46
|
+
* Rpc --> Storage
|
|
47
|
+
* Http --> Response["HttpServerResponse"]
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const layer: Layer.Layer<never, StartupError>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/registry/server.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAM1F,OAAO,EACL,KAAK,EAEL,KAAK,WAAW,EAGhB,MAAM,EACN,KAAK,EACL,QAAQ,EAET,MAAM,QAAQ,CAAC;AA6FhB;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC1C,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAChD,QAAQ,CAAC,qBAAqB,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAClD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,CACnD,qBAAqB,EACrB,WAAW,CAAC,WAAW,CAIxB,CAAC;;;;AAEF,uCAAuC;AACvC,qBAAa,YAAa,SAAQ,kBAEhC;IACA,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;CAC1D,CAAC;CAAG;AAmBL;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAElD,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/** @file Production Registry process configuration, composition, and startup boundary. */
|
|
2
|
+
import * as Reactivity from "@effect/experimental/Reactivity";
|
|
3
|
+
import { FileSystem, HttpServer, HttpServerResponse } from "@effect/platform";
|
|
4
|
+
import { NodeContext, NodeHttpServer } from "@effect/platform-node";
|
|
5
|
+
import { PgClient } from "@effect/sql-pg";
|
|
6
|
+
import { Cause, Config, Data, Duration, Effect, Layer, Redacted, Schema, } from "effect";
|
|
7
|
+
// eslint-disable-next-line agent-code-guard/prefer-effect-platform -- NodeHttpServer.make requires the platform listener constructor at this adapter boundary.
|
|
8
|
+
import { createServer } from "node:http";
|
|
9
|
+
import { isAbsolute } from "node:path";
|
|
10
|
+
import { AgentSigningAuthority } from "../agent-key.js";
|
|
11
|
+
import { makeRegistryHttpApp } from "./http.js";
|
|
12
|
+
import { makeRegistryRpcClient, makeRegistryRpcHandlersLayer, registryAdmissionLayer, } from "./rpc.js";
|
|
13
|
+
import { initializeRegistryStorage, makeRegistryStorage, } from "./storage.js";
|
|
14
|
+
const MAXIMUM_PROCESS_INTEGER = 2_147_483_647;
|
|
15
|
+
const canonicalUnsignedDecimal = Schema.String.pipe(Schema.pattern(/^(?:0|[1-9]\d*)$/));
|
|
16
|
+
const processInteger = canonicalUnsignedDecimal.pipe(Schema.compose(Schema.NumberFromString), Schema.int(), Schema.between(1, MAXIMUM_PROCESS_INTEGER));
|
|
17
|
+
const port = canonicalUnsignedDecimal.pipe(Schema.compose(Schema.NumberFromString), Schema.int(), Schema.between(1, 65_535));
|
|
18
|
+
const bindHost = Schema.String.pipe(Schema.minLength(1));
|
|
19
|
+
const postgresqlUrl = Schema.String.pipe(Schema.filter((value) => {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = new URL(value);
|
|
22
|
+
return ((parsed.protocol === "postgres:" ||
|
|
23
|
+
parsed.protocol === "postgresql:") &&
|
|
24
|
+
parsed.pathname.length > 1 &&
|
|
25
|
+
parsed.hash === "");
|
|
26
|
+
// eslint-disable-next-line agent-code-guard/bare-catch -- URL parsing failure is the false branch of this Schema predicate. #ignore-sloppy-code-next-line[bare-catch]: The predicate returns false.
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
const admissionCredential = Schema.String.pipe(Schema.minLength(8), Schema.maxLength(512), Schema.pattern(/^[A-Za-z0-9\-._~+/]+=*$/));
|
|
33
|
+
const absolutePath = Schema.String.pipe(Schema.filter((value) => isAbsolute(value)));
|
|
34
|
+
const configuredValues = Config.all({
|
|
35
|
+
host: Schema.Config("MOLTZAP_REGISTRY_HOST", bindHost).pipe(Config.withDefault("127.0.0.1")),
|
|
36
|
+
port: Schema.Config("MOLTZAP_REGISTRY_PORT", port),
|
|
37
|
+
postgresqlUrl: Config.redacted(Schema.Config("MOLTZAP_REGISTRY_POSTGRESQL_URL", postgresqlUrl)),
|
|
38
|
+
admissionCredential: Config.redacted(Schema.Config("MOLTZAP_REGISTRY_ADMISSION_CREDENTIAL", admissionCredential)),
|
|
39
|
+
signingPrivateKeyPath: Config.redacted(Schema.Config("MOLTZAP_REGISTRY_SIGNING_PRIVATE_KEY_PATH", absolutePath)),
|
|
40
|
+
listPageSize: Schema.Config("MOLTZAP_REGISTRY_LIST_PAGE_SIZE", processInteger).pipe(Config.withDefault(100)),
|
|
41
|
+
requestConcurrencyLimit: Schema.Config("MOLTZAP_REGISTRY_REQUEST_CONCURRENCY_LIMIT", processInteger).pipe(Config.withDefault(256)),
|
|
42
|
+
liveNonceCapacity: Schema.Config("MOLTZAP_REGISTRY_LIVE_NONCE_CAPACITY", processInteger).pipe(Config.withDefault(10_000)),
|
|
43
|
+
sqlPoolSize: Schema.Config("MOLTZAP_REGISTRY_SQL_POOL_SIZE", processInteger).pipe(Config.withDefault(10)),
|
|
44
|
+
sqlOperationTimeoutMs: Schema.Config("MOLTZAP_REGISTRY_SQL_OPERATION_TIMEOUT_MS", processInteger).pipe(Config.withDefault(5_000)),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Loads the complete private Registry process configuration.
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export const loadRegistryConfiguration = configuredValues.pipe(Effect.map((configuration) => configuration), Effect.withSpan("loadRegistryConfiguration"));
|
|
52
|
+
/** Closed Registry startup failure. */
|
|
53
|
+
export class StartupError extends Data.TaggedError("RegistryServerStartupError") {
|
|
54
|
+
}
|
|
55
|
+
const runRegistryServer = Effect.gen(function* () {
|
|
56
|
+
const configuration = yield* loadRegistryConfiguration.pipe(Effect.mapError(configurationFailure));
|
|
57
|
+
const registrySigningAuthority = yield* loadSigningAuthority(configuration);
|
|
58
|
+
const registrySignerPublicKey = AgentSigningAuthority.publicKey(registrySigningAuthority);
|
|
59
|
+
const storage = yield* connectStorage(configuration, registrySignerPublicKey);
|
|
60
|
+
const app = yield* buildRegistryApp({
|
|
61
|
+
configuration,
|
|
62
|
+
storage,
|
|
63
|
+
registrySigningAuthority,
|
|
64
|
+
});
|
|
65
|
+
yield* serveRegistry(configuration, guardRegistryApp(app));
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Complete production Registry process composition.
|
|
69
|
+
*
|
|
70
|
+
* ```mermaid
|
|
71
|
+
* flowchart TD
|
|
72
|
+
* Binary["moltzap-registry"] --> Server["runRegistryServer"]
|
|
73
|
+
* Server --> Configuration["loadRegistryConfiguration"]
|
|
74
|
+
* Server --> Storage["RegistryStorage"]
|
|
75
|
+
* Server --> Http["makeRegistryHttpApp"]
|
|
76
|
+
* Http --> Admission["verifyBootstrapRegistration"]
|
|
77
|
+
* Http --> Rpc["RegistryRpcClient"]
|
|
78
|
+
* Admission --> Storage
|
|
79
|
+
* Rpc --> Storage
|
|
80
|
+
* Http --> Response["HttpServerResponse"]
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
// safer-arch-ignore require-boundary-owned-types: The declared Layer type is the public boundary; this composition root provides the Node adapter internally.
|
|
84
|
+
export const layer = Layer.scopedDiscard(runRegistryServer.pipe(Effect.provide(NodeContext.layer)));
|
|
85
|
+
function loadSigningAuthority(configuration) {
|
|
86
|
+
return Effect.gen(function* () {
|
|
87
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
88
|
+
const privateKeyText = yield* fileSystem
|
|
89
|
+
.readFileString(Redacted.value(configuration.signingPrivateKeyPath))
|
|
90
|
+
.pipe(Effect.mapError(configurationFailure));
|
|
91
|
+
return yield* AgentSigningAuthority.fromPkcs8(Redacted.make(privateKeyText)).pipe(Effect.mapError(configurationFailure));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function connectStorage(configuration, registrySignerPublicKey) {
|
|
95
|
+
return Effect.gen(function* () {
|
|
96
|
+
const sql = yield* PgClient.make({
|
|
97
|
+
url: configuration.postgresqlUrl,
|
|
98
|
+
maxConnections: configuration.sqlPoolSize,
|
|
99
|
+
connectTimeout: Duration.millis(configuration.sqlOperationTimeoutMs),
|
|
100
|
+
applicationName: "moltzap-registry",
|
|
101
|
+
}).pipe(Effect.provide(Reactivity.layer), Effect.mapError(storageFailure));
|
|
102
|
+
yield* initializeRegistryStorage({
|
|
103
|
+
sql,
|
|
104
|
+
registrySignerPublicKey,
|
|
105
|
+
}).pipe(Effect.mapError(storageFailure), Effect.timeoutFail({
|
|
106
|
+
duration: Duration.millis(configuration.sqlOperationTimeoutMs),
|
|
107
|
+
onTimeout: storageFailure,
|
|
108
|
+
}));
|
|
109
|
+
return makeRegistryStorage({
|
|
110
|
+
sql,
|
|
111
|
+
registrySignerPublicKey,
|
|
112
|
+
listPageSize: configuration.listPageSize,
|
|
113
|
+
operationTimeoutMilliseconds: configuration.sqlOperationTimeoutMs,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function buildRegistryApp(input) {
|
|
118
|
+
return Effect.gen(function* () {
|
|
119
|
+
const handlers = makeRegistryRpcHandlersLayer({
|
|
120
|
+
storage: input.storage,
|
|
121
|
+
registrySigningAuthority: input.registrySigningAuthority,
|
|
122
|
+
});
|
|
123
|
+
const client = yield* makeRegistryRpcClient.pipe(Effect.provide(handlers), Effect.provide(registryAdmissionLayer));
|
|
124
|
+
const requestSemaphore = yield* Effect.makeSemaphore(input.configuration.requestConcurrencyLimit);
|
|
125
|
+
return makeRegistryHttpApp({
|
|
126
|
+
client,
|
|
127
|
+
storage: input.storage,
|
|
128
|
+
admissionCredential: input.configuration.admissionCredential,
|
|
129
|
+
nonceCapacity: input.configuration.liveNonceCapacity,
|
|
130
|
+
requestSemaphore,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function guardRegistryApp(app) {
|
|
135
|
+
return app.pipe(Effect.catchAllCause((cause) => Effect.logError("Registry HTTP application failed", Cause.squash(cause)).pipe(Effect.as(HttpServerResponse.empty({ status: 500 })))));
|
|
136
|
+
}
|
|
137
|
+
function serveRegistry(configuration, app) {
|
|
138
|
+
return Effect.gen(function* () {
|
|
139
|
+
const httpServer = yield* NodeHttpServer.make(createServer, {
|
|
140
|
+
host: configuration.host,
|
|
141
|
+
port: configuration.port,
|
|
142
|
+
}).pipe(Effect.mapError(listenerFailure));
|
|
143
|
+
yield* HttpServer.serveEffect(app).pipe(
|
|
144
|
+
// The server capability owns listener acquisition and release.
|
|
145
|
+
Effect.provideService(HttpServer.HttpServer, httpServer));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function configurationFailure() {
|
|
149
|
+
return new StartupError({ phase: "configuration" });
|
|
150
|
+
}
|
|
151
|
+
function storageFailure() {
|
|
152
|
+
return new StartupError({ phase: "storage" });
|
|
153
|
+
}
|
|
154
|
+
function listenerFailure() {
|
|
155
|
+
return new StartupError({ phase: "listener" });
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/registry/server.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,KAAK,EACL,MAAM,EAEN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,GACP,MAAM,QAAQ,CAAC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Ae,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** @file Durable Registry persistence for admission, immutable cards, and idempotent operations. */
|
|
2
|
+
import { SqlClient } from "@effect/sql/SqlClient";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { type AgentSigningAuthority, type Ed25519PublicKey } from "../agent-key.js";
|
|
5
|
+
import { InternalServerError, UnavailableError } from "../http-errors.js";
|
|
6
|
+
import { type RegistryListRequest, type RegistryListResult, type RegistryLookupRequest, type RegistryLookupResult, type RegistryRegisterRequest, type RegistryRegisterResult } from "./contract.js";
|
|
7
|
+
declare const RegistryStorageInitializationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly _tag: "RegistryStorageInitializationError";
|
|
9
|
+
} & Readonly<A>;
|
|
10
|
+
/** Storage initialization failed before the Registry became ready. */
|
|
11
|
+
export declare class RegistryStorageInitializationError extends RegistryStorageInitializationError_base {
|
|
12
|
+
}
|
|
13
|
+
type StorageError = UnavailableError | InternalServerError;
|
|
14
|
+
type StorageInput = Readonly<{
|
|
15
|
+
sql: SqlClient;
|
|
16
|
+
registrySignerPublicKey: Ed25519PublicKey;
|
|
17
|
+
listPageSize: number;
|
|
18
|
+
operationTimeoutMilliseconds: number;
|
|
19
|
+
}>;
|
|
20
|
+
type RegisterInput = Readonly<{
|
|
21
|
+
request: RegistryRegisterRequest;
|
|
22
|
+
requestBytes: Uint8Array;
|
|
23
|
+
registrySigningAuthority: AgentSigningAuthority;
|
|
24
|
+
}>;
|
|
25
|
+
/** Durable operations needed by Registry admission and request handling. */
|
|
26
|
+
export interface RegistryStorage {
|
|
27
|
+
readonly checkReadiness: () => Effect.Effect<void, StorageError>;
|
|
28
|
+
readonly claimRegistrationNonce: (input: {
|
|
29
|
+
readonly nonce: string;
|
|
30
|
+
readonly expires: number;
|
|
31
|
+
readonly now: number;
|
|
32
|
+
readonly capacity: number;
|
|
33
|
+
}) => Effect.Effect<"claimed" | "replayed" | "full", StorageError>;
|
|
34
|
+
readonly register: (input: RegisterInput) => Effect.Effect<RegistryRegisterResult, StorageError>;
|
|
35
|
+
readonly lookup: (request: RegistryLookupRequest) => Effect.Effect<RegistryLookupResult, StorageError>;
|
|
36
|
+
readonly list: (request: RegistryListRequest) => Effect.Effect<RegistryListResult, StorageError>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Runs migrations and binds the configured signer and version to storage.
|
|
40
|
+
*
|
|
41
|
+
* @param input Initialization dependencies.
|
|
42
|
+
* @param input.sql Exclusive SQL capability for this Registry process.
|
|
43
|
+
* @param input.registrySignerPublicKey Pinned Registry verification key.
|
|
44
|
+
* @returns An effect that completes only after storage is ready.
|
|
45
|
+
*/
|
|
46
|
+
export declare function initializeRegistryStorage(input: {
|
|
47
|
+
readonly sql: SqlClient;
|
|
48
|
+
readonly registrySignerPublicKey: Ed25519PublicKey;
|
|
49
|
+
}): Effect.Effect<void, RegistryStorageInitializationError>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates durable Registry operations over one initialized SQL client.
|
|
52
|
+
*
|
|
53
|
+
* @param input Storage dependencies and operation bounds.
|
|
54
|
+
* @param input.sql Initialized SQL capability.
|
|
55
|
+
* @param input.registrySignerPublicKey Pinned Registry verification key.
|
|
56
|
+
* @param input.listPageSize Maximum complete cards in one list response.
|
|
57
|
+
* @param input.operationTimeoutMilliseconds Complete SQL operation deadline.
|
|
58
|
+
* @returns Durable Registry operations.
|
|
59
|
+
*/
|
|
60
|
+
export declare function makeRegistryStorage(input: StorageInput): RegistryStorage;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/registry/storage.ts"],"names":[],"mappings":"AAAA,oGAAoG;AAIpG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAe,MAAM,EAA4B,MAAM,QAAQ,CAAC;AASvE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;;;;AAGvB,sEAAsE;AACtE,qBAAa,kCAAmC,SAAQ,uCAEvD;CAAG;AAEJ,KAAK,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAC3D,KAAK,YAAY,GAAG,QAAQ,CAAC;IAC3B,GAAG,EAAE,SAAS,CAAC;IACf,uBAAuB,EAAE,gBAAgB,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAAC,CAAC;AACH,KAAK,aAAa,GAAG,QAAQ,CAAC;IAC5B,OAAO,EAAE,uBAAuB,CAAC;IACjC,YAAY,EAAE,UAAU,CAAC;IACzB,wBAAwB,EAAE,qBAAqB,CAAC;CACjD,CAAC,CAAC;AAMH,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACjE,QAAQ,CAAC,sBAA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