@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.
Files changed (81) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +19 -0
  3. package/README.md +31 -0
  4. package/bin/moltzap-registry +9 -0
  5. package/dist/agent-card.d.ts +69 -0
  6. package/dist/agent-card.d.ts.map +1 -0
  7. package/dist/agent-card.js +257 -0
  8. package/dist/agent-card.js.map +1 -0
  9. package/dist/agent-key.d.ts +77 -0
  10. package/dist/agent-key.d.ts.map +1 -0
  11. package/dist/agent-key.js +251 -0
  12. package/dist/agent-key.js.map +1 -0
  13. package/dist/authenticated-http.d.ts +44 -0
  14. package/dist/authenticated-http.d.ts.map +1 -0
  15. package/dist/authenticated-http.js +226 -0
  16. package/dist/authenticated-http.js.map +1 -0
  17. package/dist/canonical-json.d.ts +40 -0
  18. package/dist/canonical-json.d.ts.map +1 -0
  19. package/dist/canonical-json.js +399 -0
  20. package/dist/canonical-json.js.map +1 -0
  21. package/dist/http-errors.d.ts +115 -0
  22. package/dist/http-errors.d.ts.map +1 -0
  23. package/dist/http-errors.js +55 -0
  24. package/dist/http-errors.js.map +1 -0
  25. package/dist/http-signature.d.ts +60 -0
  26. package/dist/http-signature.d.ts.map +1 -0
  27. package/dist/http-signature.js +337 -0
  28. package/dist/http-signature.js.map +1 -0
  29. package/dist/identifiers.d.ts +32 -0
  30. package/dist/identifiers.d.ts.map +1 -0
  31. package/dist/identifiers.js +55 -0
  32. package/dist/identifiers.js.map +1 -0
  33. package/dist/index.d.ts +33 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +34 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/registry/admission.d.ts +27 -0
  38. package/dist/registry/admission.d.ts.map +1 -0
  39. package/dist/registry/admission.js +107 -0
  40. package/dist/registry/admission.js.map +1 -0
  41. package/dist/registry/client.d.ts +20 -0
  42. package/dist/registry/client.d.ts.map +1 -0
  43. package/dist/registry/client.js +250 -0
  44. package/dist/registry/client.js.map +1 -0
  45. package/dist/registry/contract.d.ts +213 -0
  46. package/dist/registry/contract.d.ts.map +1 -0
  47. package/dist/registry/contract.js +132 -0
  48. package/dist/registry/contract.js.map +1 -0
  49. package/dist/registry/http.d.ts +27 -0
  50. package/dist/registry/http.d.ts.map +1 -0
  51. package/dist/registry/http.js +258 -0
  52. package/dist/registry/http.js.map +1 -0
  53. package/dist/registry/migrations/0001_registry.d.ts +6 -0
  54. package/dist/registry/migrations/0001_registry.d.ts.map +1 -0
  55. package/dist/registry/migrations/0001_registry.js +36 -0
  56. package/dist/registry/migrations/0001_registry.js.map +1 -0
  57. package/dist/registry/rpc.d.ts +138 -0
  58. package/dist/registry/rpc.d.ts.map +1 -0
  59. package/dist/registry/rpc.js +85 -0
  60. package/dist/registry/rpc.js.map +1 -0
  61. package/dist/registry/server.d.ts +52 -0
  62. package/dist/registry/server.d.ts.map +1 -0
  63. package/dist/registry/server.js +157 -0
  64. package/dist/registry/server.js.map +1 -0
  65. package/dist/registry/storage.d.ts +62 -0
  66. package/dist/registry/storage.d.ts.map +1 -0
  67. package/dist/registry/storage.js +341 -0
  68. package/dist/registry/storage.js.map +1 -0
  69. package/dist/registry.d.ts +34 -0
  70. package/dist/registry.d.ts.map +1 -0
  71. package/dist/registry.js +13 -0
  72. package/dist/registry.js.map +1 -0
  73. package/dist/signed-message.d.ts +54 -0
  74. package/dist/signed-message.d.ts.map +1 -0
  75. package/dist/signed-message.js +289 -0
  76. package/dist/signed-message.js.map +1 -0
  77. package/dist/version.d.ts +4 -0
  78. package/dist/version.d.ts.map +1 -0
  79. package/dist/version.js +4 -0
  80. package/dist/version.js.map +1 -0
  81. package/package.json +139 -0
@@ -0,0 +1,60 @@
1
+ /** @file RFC 9421 request signing and strict identity-bound verification profiles. */
2
+ import { type HttpClientRequest, type HttpServerRequest } from "@effect/platform";
3
+ import { Effect } from "effect";
4
+ import { AgentSigningAuthority, type Ed25519PublicKey } from "./agent-key.js";
5
+ import { AuthenticationFailedError } from "./http-errors.js";
6
+ declare const AgentSigningError_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 & {
7
+ readonly _tag: "AgentSigningError";
8
+ } & Readonly<A>;
9
+ /** An agent-owned HTTP request could not be signed. */
10
+ export declare class AgentSigningError extends AgentSigningError_base {
11
+ }
12
+ /** Closed request-signature profile selected by the owning HTTP route. */
13
+ export type HttpSignatureProfile = "normal" | "registration";
14
+ /**
15
+ * Exact RFC 8941 SHA-256 content-digest field value.
16
+ *
17
+ * @param bodyBytes Exact request body octets.
18
+ * @returns The single supported digest dictionary member.
19
+ */
20
+ export declare const contentDigest: (bodyBytes: Uint8Array) => string;
21
+ /**
22
+ * Installs one exact MoltZap HTTP signature profile on a prepared request.
23
+ *
24
+ * @param input Request and fixed profile inputs.
25
+ * @param input.httpRequest Request whose method and URL are already selected.
26
+ * @param input.bodyBytes Canonical body octets to install and sign.
27
+ * @param input.signingAuthority Opaque authority for the caller key.
28
+ * @param input.profile Route-owned signature profile.
29
+ * @returns The request with its body and exact signed fields installed.
30
+ */
31
+ export declare const signHttpRequest: (input: {
32
+ readonly httpRequest: HttpClientRequest.HttpClientRequest;
33
+ readonly bodyBytes: Uint8Array;
34
+ readonly signingAuthority: AgentSigningAuthority;
35
+ readonly profile: HttpSignatureProfile;
36
+ }) => Effect.Effect<HttpClientRequest.HttpClientRequest, AgentSigningError>;
37
+ /** Replay material retained after exact signature verification. */
38
+ export type VerifiedHttpSignature = Readonly<{
39
+ readonly nonce: string;
40
+ readonly expires: number;
41
+ readonly verifiedAt: number;
42
+ }>;
43
+ /**
44
+ * Verifies the exact profile and returns its replay nonce.
45
+ *
46
+ * @param input Request and fixed verification inputs.
47
+ * @param input.httpRequest Bounded server request at the selected route.
48
+ * @param input.bodyBytes Copied body octets covered by the digest.
49
+ * @param input.publicKey Public key selected by the boundary owner.
50
+ * @param input.profile Route-owned signature profile.
51
+ * @returns Replay material bound to the exact accepted verification second.
52
+ */
53
+ export declare const verifyHttpRequestSignature: (input: {
54
+ readonly httpRequest: HttpServerRequest.HttpServerRequest;
55
+ readonly bodyBytes: Uint8Array;
56
+ readonly publicKey: Ed25519PublicKey;
57
+ readonly profile: HttpSignatureProfile;
58
+ }) => Effect.Effect<VerifiedHttpSignature, AuthenticationFailedError>;
59
+ export {};
60
+ //# sourceMappingURL=http-signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-signature.d.ts","sourceRoot":"","sources":["../src/http-signature.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAe,MAAM,EAAU,MAAM,QAAQ,CAAC;AAWrD,OAAO,EACL,qBAAqB,EAErB,KAAK,gBAAgB,EAGtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;;;;AAI7D,uDAAuD;AACvD,qBAAa,iBAAkB,SAAQ,sBAAqC;CAAG;AA4B/E,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAQ7D;;;;;GAKG;AACH,eAAO,MAAM,aAAa,cAAe,UAAU,KAAG,MACkB,CAAC;AAgGzE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,UAAW;IACrC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;CACxC,KAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,iBAAiB,CAiB3B,CAAC;AAQ9C,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC,CAAC;AAsTH;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,UAAW;IAChD,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;CACxC,KAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,yBAAyB,CAoCV,CAAC"}
@@ -0,0 +1,337 @@
1
+ /** @file RFC 9421 request signing and strict identity-bound verification profiles. */
2
+ import { HttpClientRequest as ClientRequest, } from "@effect/platform";
3
+ import { Clock, Data, Effect, Option } from "effect";
4
+ import { httpbis } from "http-message-signatures";
5
+ import { importJWK } from "jose";
6
+ import { createHash, randomBytes, webcrypto } from "node:crypto";
7
+ import { parseDictionary, serializeDictionary, } from "structured-headers";
8
+ import { AgentSigningAuthority, agentSigningPrivateKey, ed25519PublicKeyThumbprintUri, hasCanonicalEd25519SignatureEncoding, } from "./agent-key.js";
9
+ import { AuthenticationFailedError } from "./http-errors.js";
10
+ import { hasCanonicalBase64UrlLength } from "./identifiers.js";
11
+ import { MOLTZAP_VERSION } from "./version.js";
12
+ /** An agent-owned HTTP request could not be signed. */
13
+ export class AgentSigningError extends Data.TaggedError("AgentSigningError") {
14
+ }
15
+ const SIGNATURE_LABEL = "moltzap";
16
+ const SIGNATURE_INTERVAL_SECONDS = 300;
17
+ const FUTURE_SKEW_SECONDS = 5;
18
+ const SIGNATURE_BYTES = 64;
19
+ const NORMAL_FIELDS = Object.freeze([
20
+ "@method",
21
+ "@authority",
22
+ "@path",
23
+ "@query",
24
+ "content-digest",
25
+ "content-type",
26
+ "moltzap-version",
27
+ ]);
28
+ const REGISTRATION_FIELDS = Object.freeze([...NORMAL_FIELDS, "authorization"]);
29
+ const PARAMETERS = Object.freeze([
30
+ "created",
31
+ "expires",
32
+ "keyid",
33
+ "nonce",
34
+ "alg",
35
+ "tag",
36
+ ]);
37
+ const fieldsFor = (profile) => profile === "normal" ? NORMAL_FIELDS : REGISTRATION_FIELDS;
38
+ const tagFor = (profile) => profile === "normal" ? "moltzap-request-v1" : "moltzap-registration-v1";
39
+ /**
40
+ * Exact RFC 8941 SHA-256 content-digest field value.
41
+ *
42
+ * @param bodyBytes Exact request body octets.
43
+ * @returns The single supported digest dictionary member.
44
+ */
45
+ export const contentDigest = (bodyBytes) => `sha-256=:${createHash("sha256").update(bodyBytes).digest("base64")}:`;
46
+ const toMessageHeaders = (headers) => Object.fromEntries(Object.entries(headers));
47
+ /*
48
+ * http-message-signatures requires a Promise-returning signing callback.
49
+ * The Promise stays inside that standards-library adapter.
50
+ */
51
+ /* eslint-disable agent-code-guard/promise-type, agent-code-guard/then-chain -- http-message-signatures requires this Promise callback */
52
+ const signBytes = (authority, bytes) => {
53
+ const copiedBytes = Uint8Array.from(bytes);
54
+ return webcrypto.subtle
55
+ .sign("Ed25519", agentSigningPrivateKey(authority), copiedBytes)
56
+ .then((signature) => Buffer.from(signature)); // #ignore-sloppy-code[then-chain]: WebCrypto exposes its signature result as a Promise at this adapter boundary.
57
+ };
58
+ const makeSigningParameters = (signingAuthority) => Effect.gen(function* () {
59
+ const createdMilliseconds = yield* Clock.currentTimeMillis;
60
+ const created = new Date(Math.floor(createdMilliseconds / 1_000) * 1_000);
61
+ const expires = new Date(created.getTime() + SIGNATURE_INTERVAL_SECONDS * 1_000);
62
+ const nonce = yield* Effect.try({
63
+ try: () => randomBytes(16).toString("base64url"),
64
+ catch: () => new AgentSigningError(),
65
+ });
66
+ const keyid = yield* ed25519PublicKeyThumbprintUri(AgentSigningAuthority.publicKey(signingAuthority)).pipe(Effect.catchTag("Ed25519PublicKeyOperationError", () => Effect.fail(new AgentSigningError())));
67
+ return { created, expires, keyid, nonce };
68
+ });
69
+ const prepareRequest = (input) => input.httpRequest.pipe(ClientRequest.bodyUint8Array(input.bodyBytes, "application/json"), ClientRequest.setHeader("content-digest", contentDigest(input.bodyBytes)), ClientRequest.setHeader("moltzap-version", MOLTZAP_VERSION));
70
+ const signPreparedRequest = (input) => Effect.tryPromise({
71
+ try: () => httpbis.signMessage({
72
+ name: SIGNATURE_LABEL,
73
+ fields: [...fieldsFor(input.profile)],
74
+ params: [...PARAMETERS],
75
+ paramValues: {
76
+ ...input.parameters,
77
+ alg: "ed25519",
78
+ tag: tagFor(input.profile),
79
+ },
80
+ key: {
81
+ id: input.parameters.keyid,
82
+ alg: "ed25519",
83
+ sign: (bytes) => signBytes(input.signingAuthority, bytes),
84
+ },
85
+ }, {
86
+ method: input.prepared.method,
87
+ url: input.prepared.url,
88
+ headers: toMessageHeaders(input.prepared.headers),
89
+ }),
90
+ catch: () => new AgentSigningError(),
91
+ });
92
+ /**
93
+ * Installs one exact MoltZap HTTP signature profile on a prepared request.
94
+ *
95
+ * @param input Request and fixed profile inputs.
96
+ * @param input.httpRequest Request whose method and URL are already selected.
97
+ * @param input.bodyBytes Canonical body octets to install and sign.
98
+ * @param input.signingAuthority Opaque authority for the caller key.
99
+ * @param input.profile Route-owned signature profile.
100
+ * @returns The request with its body and exact signed fields installed.
101
+ */
102
+ export const signHttpRequest = (input) => Effect.gen(function* () {
103
+ const parameters = yield* makeSigningParameters(input.signingAuthority);
104
+ const prepared = prepareRequest(input);
105
+ const signed = yield* signPreparedRequest({
106
+ prepared,
107
+ parameters,
108
+ profile: input.profile,
109
+ signingAuthority: input.signingAuthority,
110
+ });
111
+ return prepared.pipe(ClientRequest.setHeader("signature-input", String(signed.headers["Signature-Input"])), ClientRequest.setHeader("signature", String(signed.headers.Signature)));
112
+ }).pipe(Effect.withSpan("signHttpRequest"));
113
+ const isItem = (value) => !Array.isArray(value[0]);
114
+ const readCoveredFields = (value) => {
115
+ if (value === undefined || isItem(value)) {
116
+ return Option.none();
117
+ }
118
+ const [fieldItems, parameters] = value;
119
+ const fields = [];
120
+ for (const field of fieldItems) {
121
+ if (typeof field[0] !== "string" || field[1].size !== 0) {
122
+ return Option.none();
123
+ }
124
+ fields.push(field[0]);
125
+ }
126
+ return Option.some({ fields, parameters });
127
+ };
128
+ const readSignatureBytes = (value) => {
129
+ if (value === undefined ||
130
+ !isItem(value) ||
131
+ !(value[0] instanceof ArrayBuffer) ||
132
+ value[1].size !== 0) {
133
+ return Option.none();
134
+ }
135
+ const signature = new Uint8Array(value[0]);
136
+ return signature.byteLength === SIGNATURE_BYTES &&
137
+ hasCanonicalEd25519SignatureEncoding(signature)
138
+ ? Option.some(signature)
139
+ : Option.none();
140
+ };
141
+ const isExactSignatureDictionary = (header, dictionary) => serializeDictionary(dictionary) === header &&
142
+ dictionary.size === 1 &&
143
+ dictionary.has(SIGNATURE_LABEL);
144
+ const parseExactSignature = (signatureInputHeader, signatureHeader) => {
145
+ try {
146
+ const inputDictionary = parseDictionary(signatureInputHeader);
147
+ const signatureDictionary = parseDictionary(signatureHeader);
148
+ if (!isExactSignatureDictionary(signatureInputHeader, inputDictionary)) {
149
+ return Option.none();
150
+ }
151
+ if (!isExactSignatureDictionary(signatureHeader, signatureDictionary)) {
152
+ return Option.none();
153
+ }
154
+ const covered = readCoveredFields(inputDictionary.get(SIGNATURE_LABEL));
155
+ const signature = readSignatureBytes(signatureDictionary.get(SIGNATURE_LABEL));
156
+ if (Option.isNone(covered) || Option.isNone(signature)) {
157
+ return Option.none();
158
+ }
159
+ return Option.some({
160
+ fields: covered.value.fields,
161
+ parameters: covered.value.parameters,
162
+ signature: signature.value,
163
+ });
164
+ // Invalid structured fields are ordinary authentication failures.
165
+ // eslint-disable-next-line agent-code-guard/bare-catch -- Parser rejection is expected untrusted input. #ignore-sloppy-code-next-line[bare-catch]: The failure is represented by Option.none.
166
+ }
167
+ catch {
168
+ return Option.none();
169
+ }
170
+ };
171
+ const hasExactSequence = (actual, expected) => actual.length === expected.length &&
172
+ actual.every((value, index) => value === expected[index]);
173
+ const readInteger = (parameters, name) => {
174
+ const value = parameters.get(name);
175
+ return typeof value === "number" && Number.isSafeInteger(value)
176
+ ? Option.some(value)
177
+ : Option.none();
178
+ };
179
+ const readParameterValues = (parameters) => {
180
+ const created = readInteger(parameters, "created");
181
+ const expires = readInteger(parameters, "expires");
182
+ const keyid = parameters.get("keyid");
183
+ const nonce = parameters.get("nonce");
184
+ if (Option.isNone(created) ||
185
+ Option.isNone(expires) ||
186
+ typeof keyid !== "string" ||
187
+ typeof nonce !== "string") {
188
+ return Option.none();
189
+ }
190
+ return Option.some({
191
+ created: created.value,
192
+ expires: expires.value,
193
+ keyid,
194
+ nonce,
195
+ algorithm: Option.fromNullable(parameters.get("alg")),
196
+ tag: Option.fromNullable(parameters.get("tag")),
197
+ });
198
+ };
199
+ const hasExpectedIdentityParameters = (values, input) => {
200
+ const algorithmMatches = Option.isSome(values.algorithm) && values.algorithm.value === "ed25519";
201
+ const tagMatches = Option.isSome(values.tag) && values.tag.value === tagFor(input.profile);
202
+ const keyMatches = values.keyid === input.expectedKeyId &&
203
+ hasCanonicalBase64UrlLength(values.nonce, 16);
204
+ return algorithmMatches && tagMatches && keyMatches;
205
+ };
206
+ const hasAcceptableTimes = (values, nowSeconds) => values.created <= values.expires &&
207
+ values.expires - values.created <= SIGNATURE_INTERVAL_SECONDS &&
208
+ values.created <= nowSeconds + FUTURE_SKEW_SECONDS &&
209
+ values.expires >= nowSeconds;
210
+ const exactParameters = (parsed, profile, expectedKeyId, nowSeconds) => {
211
+ if (!hasExactSequence([...parsed.parameters.keys()], PARAMETERS)) {
212
+ return Option.none();
213
+ }
214
+ const values = readParameterValues(parsed.parameters);
215
+ if (Option.isNone(values) ||
216
+ !hasExpectedIdentityParameters(values.value, {
217
+ profile,
218
+ expectedKeyId,
219
+ }) ||
220
+ !hasAcceptableTimes(values.value, nowSeconds)) {
221
+ return Option.none();
222
+ }
223
+ return Option.some({
224
+ nonce: values.value.nonce,
225
+ expires: values.value.expires,
226
+ verifiedAt: nowSeconds,
227
+ });
228
+ };
229
+ const serverRequestUrl = (request) => {
230
+ const authority = request.headers.host ?? "";
231
+ if (!authority) {
232
+ return Option.none();
233
+ }
234
+ try {
235
+ return Option.some(new URL(request.url, `http://${authority}`));
236
+ // Invalid authority or request-target text is an authentication failure.
237
+ // eslint-disable-next-line agent-code-guard/bare-catch -- Invalid authority is expected untrusted input. #ignore-sloppy-code-next-line[bare-catch]: The failure is represented by Option.none.
238
+ }
239
+ catch {
240
+ return Option.none();
241
+ }
242
+ };
243
+ const readSignatureEnvelope = (input) => {
244
+ const signatureInput = input.httpRequest.headers["signature-input"];
245
+ const signature = input.httpRequest.headers.signature;
246
+ const url = serverRequestUrl(input.httpRequest);
247
+ if (typeof signatureInput !== "string" ||
248
+ typeof signature !== "string" ||
249
+ Option.isNone(url) ||
250
+ input.httpRequest.headers["content-digest"] !==
251
+ contentDigest(input.bodyBytes)) {
252
+ return Option.none();
253
+ }
254
+ return Option.some({
255
+ signatureInput,
256
+ signature,
257
+ url: url.value,
258
+ });
259
+ };
260
+ const makeVerifyingKey = (keyid, publicKey) => ({
261
+ id: keyid,
262
+ algs: ["ed25519"],
263
+ verify: (bytes, candidate) => {
264
+ const copiedSignature = Uint8Array.from(candidate);
265
+ const copiedBytes = Uint8Array.from(bytes);
266
+ return webcrypto.subtle.verify("Ed25519", publicKey, copiedSignature, copiedBytes);
267
+ },
268
+ });
269
+ const acceptSignatureParameters = (input) => Effect.gen(function* () {
270
+ const keyid = yield* ed25519PublicKeyThumbprintUri(input.publicKey).pipe(Effect.catchTag("Ed25519PublicKeyOperationError", () => Effect.fail(new AuthenticationFailedError())));
271
+ const nowSeconds = Math.floor((yield* Clock.currentTimeMillis) / 1_000);
272
+ const signature = exactParameters(input.parsed, input.profile, keyid, nowSeconds);
273
+ if (Option.isNone(signature)) {
274
+ return yield* new AuthenticationFailedError();
275
+ }
276
+ return { keyid, signature: signature.value };
277
+ });
278
+ const verifyWithLibrary = (input) => {
279
+ const key = makeVerifyingKey(input.keyid, input.publicKey);
280
+ return Effect.tryPromise({
281
+ try: () => httpbis.verifyMessage({
282
+ all: true,
283
+ requiredFields: [...fieldsFor(input.profile)],
284
+ requiredParams: [...PARAMETERS],
285
+ // Effect Clock applies the exact time law before this call.
286
+ tolerance: Number.MAX_SAFE_INTEGER,
287
+ keyLookup: () => Promise.resolve(key),
288
+ }, {
289
+ method: input.httpRequest.method,
290
+ url: input.url,
291
+ headers: toMessageHeaders(input.httpRequest.headers),
292
+ }),
293
+ catch: () => new AuthenticationFailedError(),
294
+ });
295
+ };
296
+ /**
297
+ * Verifies the exact profile and returns its replay nonce.
298
+ *
299
+ * @param input Request and fixed verification inputs.
300
+ * @param input.httpRequest Bounded server request at the selected route.
301
+ * @param input.bodyBytes Copied body octets covered by the digest.
302
+ * @param input.publicKey Public key selected by the boundary owner.
303
+ * @param input.profile Route-owned signature profile.
304
+ * @returns Replay material bound to the exact accepted verification second.
305
+ */
306
+ export const verifyHttpRequestSignature = (input) => Effect.gen(function* () {
307
+ const envelope = readSignatureEnvelope(input);
308
+ if (Option.isNone(envelope)) {
309
+ return yield* new AuthenticationFailedError();
310
+ }
311
+ const parsed = parseExactSignature(envelope.value.signatureInput, envelope.value.signature);
312
+ if (Option.isNone(parsed) ||
313
+ !hasExactSequence(parsed.value.fields, fieldsFor(input.profile))) {
314
+ return yield* new AuthenticationFailedError();
315
+ }
316
+ const accepted = yield* acceptSignatureParameters({
317
+ parsed: parsed.value,
318
+ profile: input.profile,
319
+ publicKey: input.publicKey,
320
+ });
321
+ const publicKey = yield* Effect.tryPromise({
322
+ try: () => importJWK(input.publicKey, "Ed25519"),
323
+ catch: () => new AuthenticationFailedError(),
324
+ });
325
+ const verified = yield* verifyWithLibrary({
326
+ httpRequest: input.httpRequest,
327
+ profile: input.profile,
328
+ url: envelope.value.url,
329
+ keyid: accepted.keyid,
330
+ publicKey,
331
+ });
332
+ if (verified !== true) {
333
+ return yield* new AuthenticationFailedError();
334
+ }
335
+ return accepted.signature;
336
+ }).pipe(Effect.withSpan("verifyHttpRequestSignature"));
337
+ //# sourceMappingURL=http-signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-signature.js","sourceRoot":"","sources":["../src/http-signature.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,iBAAiB,IAAI,aAAa,GAGnC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,OAAO,EAAqB,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAkB,SAAS,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAIL,eAAe,EACf,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EAEtB,6BAA6B,EAC7B,oCAAoC,GACrC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,uDAAuD;AACvD,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC;CAAG;AAE/E,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,aAA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MAAM,CAAC,MAAM,CAAC;QACrB,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAChE,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,IAAI,yBAAyB,EAAE,CAAC;IAChD,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,yBAAyB,CAAC;QAChD,MAAM,EAAE,MAAM,CAAC,KAAK;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QACzC,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC;QAChD,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,yBAAyB,EAAE;KAC7C,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC;QACxC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG;QACvB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS;KACV,CAAC,CAAC;IACH,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,CAAC,IAAI,yBAAyB,EAAE,CAAC;IAChD,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,CAAC;AAC5B,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /** @file Canonical branded identity identifiers and their exact encodings. */
2
+ import { Schema } from "effect";
3
+ /**
4
+ * Tests whether a string is the unique base64url encoding of a fixed byte length.
5
+ *
6
+ * @param value Candidate unpadded base64url text.
7
+ * @param byteLength Required decoded byte length.
8
+ * @returns Whether the candidate has the one canonical encoding for that length.
9
+ */
10
+ export declare const hasCanonicalBase64UrlLength: (value: string, byteLength: number) => boolean;
11
+ /**
12
+ * Constructs one exact prefixed identity Schema for its semantic owner.
13
+ *
14
+ * @param name Nominal Schema and brand name.
15
+ * @param prefix Fixed representation prefix.
16
+ * @param byteLength Required decoded payload length.
17
+ * @returns The exact branded string Schema.
18
+ */
19
+ export declare const canonicalIdentifier: <const Name extends string>(name: Name, prefix: string, byteLength: number) => Schema.brand<Schema.filter<typeof Schema.String>, Name>;
20
+ /** Canonical network identity minted by the Registry. */
21
+ export declare const AgentId: Schema.brand<Schema.filter<typeof Schema.String>, "AgentId">;
22
+ /** Validated nominal value decoded by {@link AgentId}. */
23
+ export type AgentId = typeof AgentId.Type;
24
+ /** Opaque identity of the principal represented by an agent. */
25
+ export declare const PrincipalId: Schema.brand<Schema.filter<typeof Schema.String>, "PrincipalId">;
26
+ /** Validated nominal value decoded by {@link PrincipalId}. */
27
+ export type PrincipalId = typeof PrincipalId.Type;
28
+ /** Immutable Registry-wide human-facing agent handle. */
29
+ export declare const AgentName: Schema.brand<Schema.filter<Schema.filter<Schema.filter<typeof Schema.String>>>, "AgentName">;
30
+ /** Validated nominal value decoded by {@link AgentName}. */
31
+ export type AgentName = typeof AgentName.Type;
32
+ //# sourceMappingURL=identifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../src/identifiers.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EAAoB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYlD;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,UAC/B,MAAM,cACD,MAAM,KACjB,OAAqE,CAAC;AAEzE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,CAAC,IAAI,SAAS,MAAM,QACrD,IAAI,UACF,MAAM,cACF,MAAM,4DAsBjB,CAAC;AAMJ,yDAAyD;AACzD,eAAO,MAAM,OAAO,8DAInB,CAAC;AACF,0DAA0D;AAC1D,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,gEAAgE;AAChE,eAAO,MAAM,WAAW,kEAIvB,CAAC;AACF,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,yDAAyD;AACzD,eAAO,MAAM,SAAS,8FASrB,CAAC;AACF,4DAA4D;AAC5D,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC"}
@@ -0,0 +1,55 @@
1
+ /** @file Canonical branded identity identifiers and their exact encodings. */
2
+ import { Either, Encoding, Schema } from "effect";
3
+ const IDENTIFIER_BYTE_LENGTH = 16;
4
+ const decodeCanonicalBase64Url = (value) => {
5
+ return Either.match(Encoding.decodeBase64Url(value), {
6
+ onLeft: () => undefined,
7
+ onRight: (decoded) => Encoding.encodeBase64Url(decoded) === value ? decoded : undefined,
8
+ });
9
+ };
10
+ /**
11
+ * Tests whether a string is the unique base64url encoding of a fixed byte length.
12
+ *
13
+ * @param value Candidate unpadded base64url text.
14
+ * @param byteLength Required decoded byte length.
15
+ * @returns Whether the candidate has the one canonical encoding for that length.
16
+ */
17
+ export const hasCanonicalBase64UrlLength = (value, byteLength) => decodeCanonicalBase64Url(value)?.byteLength === byteLength;
18
+ /**
19
+ * Constructs one exact prefixed identity Schema for its semantic owner.
20
+ *
21
+ * @param name Nominal Schema and brand name.
22
+ * @param prefix Fixed representation prefix.
23
+ * @param byteLength Required decoded payload length.
24
+ * @returns The exact branded string Schema.
25
+ */
26
+ export const canonicalIdentifier = (name, prefix, byteLength) => Schema.String.pipe(Schema.filter((value) => {
27
+ const hasPrefix = value.startsWith(prefix);
28
+ if (!hasPrefix) {
29
+ return false;
30
+ }
31
+ const payload = value.slice(prefix.length);
32
+ return hasCanonicalBase64UrlLength(payload, byteLength);
33
+ }, {
34
+ identifier: name,
35
+ description: `${name} canonical representation`,
36
+ }), Schema.brand(name), Schema.annotations({
37
+ identifier: name,
38
+ description: `${name} canonical representation`,
39
+ }));
40
+ /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare --
41
+ * Named Effect Schemas share their domain names with the nominal types they decode.
42
+ */
43
+ /** Canonical network identity minted by the Registry. */
44
+ export const AgentId = canonicalIdentifier("AgentId", "agt_", IDENTIFIER_BYTE_LENGTH);
45
+ /** Opaque identity of the principal represented by an agent. */
46
+ export const PrincipalId = canonicalIdentifier("PrincipalId", "prn_", IDENTIFIER_BYTE_LENGTH);
47
+ /** Immutable Registry-wide human-facing agent handle. */
48
+ export const AgentName = Schema.String.pipe(Schema.minLength(3), Schema.maxLength(32), Schema.pattern(/^[a-z0-9]+(-[a-z0-9]+)*$/), Schema.brand("AgentName"), Schema.annotations({
49
+ identifier: "AgentName",
50
+ description: "Registry-wide immutable agent handle",
51
+ }));
52
+ /* eslint-enable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare --
53
+ * Restore the general naming rules after the public Schema/type pairs.
54
+ */
55
+ //# sourceMappingURL=identifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../src/identifiers.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAElD,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,wBAAwB,GAAG,CAAC,KAAa,EAA0B,EAAE;IACzE,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;QACnD,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS;QACvB,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CACnB,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,KAAK,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CAAC,MAAM,CAAC,IAAI,CACzC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EACnB,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EACpB,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,EAC1C,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EACzB,MAAM,CAAC,WAAW,CAAC;IACjB,UAAU,EAAE,WAAW;IACvB,WAAW,EAAE,sCAAsC;CACpD,CAAC,CACH,CAAC;AAIF;;GAEG"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Public Identity contracts: immutable agent cards, identifiers,
3
+ * signing, and request authentication. Identity sits at the root of the
4
+ * product dependency graph and imports no other workspace package.
5
+ */
6
+ /**
7
+ * The sole MoltZap wire compatibility value. Every MoltZap-owned network
8
+ * schema carries exactly this value; there is no range negotiation or
9
+ * per-layer wire version. `version.ts` is its source of truth: the
10
+ * architecture boundary check reads the literal from there, and
11
+ * `scripts/docs/moltzap-version.ts` reads it for the documentation
12
+ * constants generator and its gate tests.
13
+ *
14
+ * The npm package version, the MCP revision, simulator definition ID,
15
+ * EventCatalog schema, and RunLedger storage version are independent
16
+ * namespaces and never imply compatibility with this value.
17
+ */
18
+ export { MOLTZAP_VERSION } from "./version.js";
19
+ /** Canonical refined values shared by identity and its consumers. */
20
+ export { AgentId, AgentName, PrincipalId } from "./identifiers.js";
21
+ /** Exact immutable public-key representation used by identity artifacts. */
22
+ export { AgentSigningAuthority, Ed25519PublicKey, InvalidAgentPrivateKeyError, } from "./agent-key.js";
23
+ /** Immutable Registry attestation and its pinned verification boundary. */
24
+ export { AgentCard, AgentCardDigest, AgentCardVerificationError, type VerifiedAgentCard, } from "./agent-card.js";
25
+ /** Opaque attributed payload and endpoint-owned signing operations. */
26
+ export { MessageId, SignedMessage, SignedMessageSigningError, SignedMessageVerificationError, type VerifiedSignedMessage, } from "./signed-message.js";
27
+ /** Registered-agent HTTP authentication and its opaque verified proof. */
28
+ export { AuthenticatedHttp, type VerifiedAgentRequest, } from "./authenticated-http.js";
29
+ /** Shared closed HTTP-envelope failures. */
30
+ export { AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError, } from "./http-errors.js";
31
+ /** HTTP request signing failure without implementation detail. */
32
+ export { AgentSigningError } from "./http-signature.js";
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,4EAA4E;AAC5E,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,2EAA2E;AAC3E,OAAO,EACL,SAAS,EACT,eAAe,EACf,0BAA0B,EAC1B,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,uEAAuE;AACvE,OAAO,EACL,SAAS,EACT,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,4CAA4C;AAC5C,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,kEAAkE;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file Public Identity contracts: immutable agent cards, identifiers,
3
+ * signing, and request authentication. Identity sits at the root of the
4
+ * product dependency graph and imports no other workspace package.
5
+ */
6
+ // safer-arch-ignore no-folder-cycle: This facade re-exports cohesive identity modules that depend on sibling identity contracts; those modules never import the facade.
7
+ /**
8
+ * The sole MoltZap wire compatibility value. Every MoltZap-owned network
9
+ * schema carries exactly this value; there is no range negotiation or
10
+ * per-layer wire version. `version.ts` is its source of truth: the
11
+ * architecture boundary check reads the literal from there, and
12
+ * `scripts/docs/moltzap-version.ts` reads it for the documentation
13
+ * constants generator and its gate tests.
14
+ *
15
+ * The npm package version, the MCP revision, simulator definition ID,
16
+ * EventCatalog schema, and RunLedger storage version are independent
17
+ * namespaces and never imply compatibility with this value.
18
+ */
19
+ export { MOLTZAP_VERSION } from "./version.js";
20
+ /** Canonical refined values shared by identity and its consumers. */
21
+ export { AgentId, AgentName, PrincipalId } from "./identifiers.js";
22
+ /** Exact immutable public-key representation used by identity artifacts. */
23
+ export { AgentSigningAuthority, Ed25519PublicKey, InvalidAgentPrivateKeyError, } from "./agent-key.js";
24
+ /** Immutable Registry attestation and its pinned verification boundary. */
25
+ export { AgentCard, AgentCardDigest, AgentCardVerificationError, } from "./agent-card.js";
26
+ /** Opaque attributed payload and endpoint-owned signing operations. */
27
+ export { MessageId, SignedMessage, SignedMessageSigningError, SignedMessageVerificationError, } from "./signed-message.js";
28
+ /** Registered-agent HTTP authentication and its opaque verified proof. */
29
+ export { AuthenticatedHttp, } from "./authenticated-http.js";
30
+ /** Shared closed HTTP-envelope failures. */
31
+ export { AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError, } from "./http-errors.js";
32
+ /** HTTP request signing failure without implementation detail. */
33
+ export { AgentSigningError } from "./http-signature.js";
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wKAAwK;AAExK;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,4EAA4E;AAC5E,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,2EAA2E;AAC3E,OAAO,EACL,SAAS,EACT,eAAe,EACf,0BAA0B,GAE3B,MAAM,iBAAiB,CAAC;AACzB,uEAAuE;AACvE,OAAO,EACL,SAAS,EACT,aAAa,EACb,yBAAyB,EACzB,8BAA8B,GAE/B,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,OAAO,EACL,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AACjC,4CAA4C;AAC5C,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,kEAAkE;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** @file Registry-owned bootstrap admission before private dispatch. */
2
+ import type { HttpServerRequest } from "@effect/platform";
3
+ import { Effect, Redacted } from "effect";
4
+ import type { RegistryStorage } from "./storage.js";
5
+ import { AuthenticationFailedError, type InternalServerError, MalformedRequestError, OverloadedError, type UnavailableError, VersionMismatchError } from "../http-errors.js";
6
+ import { type RegistryRegisterRequest as RegistryRegisterRequestValue } from "./contract.js";
7
+ type BootstrapRegistrationInput = Readonly<{
8
+ httpRequest: HttpServerRequest.HttpServerRequest;
9
+ bodyBytes: Uint8Array;
10
+ admissionCredential: Redacted.Redacted;
11
+ nonceCapacity: number;
12
+ storage: RegistryStorage;
13
+ }>;
14
+ /**
15
+ * Verifies Registry-owned bootstrap admission through its durable replay step.
16
+ *
17
+ * @param input Bootstrap boundary dependencies and request.
18
+ * @param input.httpRequest Server request carrying signed framing.
19
+ * @param input.bodyBytes Bounded body octets covered by the signature.
20
+ * @param input.admissionCredential Configured bootstrap secret.
21
+ * @param input.nonceCapacity Maximum live bootstrap nonces.
22
+ * @param input.storage Durable nonce store.
23
+ * @returns The complete registration request after every admission check.
24
+ */
25
+ export declare function verifyBootstrapRegistration(input: BootstrapRegistrationInput): Effect.Effect<RegistryRegisterRequestValue, MalformedRequestError | AuthenticationFailedError | OverloadedError | VersionMismatchError | UnavailableError | InternalServerError>;
26
+ export {};
27
+ //# sourceMappingURL=admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/registry/admission.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAU,MAAM,QAAQ,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,eAAe,EACf,KAAK,gBAAgB,EACrB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAEL,KAAK,uBAAuB,IAAI,4BAA4B,EAC7D,MAAM,eAAe,CAAC;AAmBvB,KAAK,0BAA0B,GAAG,QAAQ,CAAC;IACzC,WAAW,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IACjD,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,0BAA0B,GAChC,MAAM,CAAC,MAAM,CACd,4BAA4B,EAC1B,qBAAqB,GACrB,yBAAyB,GACzB,eAAe,GACf,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,CACtB,CA4BA"}