@invisible-labs/sdk 0.6.0-devnet.3 → 0.6.0-devnet.5

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 (45) hide show
  1. package/README.md +129 -15
  2. package/dist/.invisible-sdk-build-target.json +7 -0
  3. package/dist/{chunk-QQSI3ZD7.js → chunk-3MDHAS4D.js} +109 -17
  4. package/dist/chunk-3MDHAS4D.js.map +1 -0
  5. package/dist/{chunk-NKRVQXRP.js → chunk-3TGQ4CZ3.js} +297 -11
  6. package/dist/chunk-3TGQ4CZ3.js.map +1 -0
  7. package/dist/chunk-DCTYBUY3.js +258 -0
  8. package/dist/chunk-DCTYBUY3.js.map +1 -0
  9. package/dist/{chunk-NHEHCUS5.js → chunk-EBWTAXNT.js} +3 -3
  10. package/dist/{chunk-NHEHCUS5.js.map → chunk-EBWTAXNT.js.map} +1 -1
  11. package/dist/{chunk-V5HXJRBW.js → chunk-HJFMDMPY.js} +3 -3
  12. package/dist/chunk-HJFMDMPY.js.map +1 -0
  13. package/dist/{chunk-GHBQF3A7.js → chunk-QRN46R3F.js} +5 -2
  14. package/dist/chunk-QRN46R3F.js.map +1 -0
  15. package/dist/chunk-Y7AK6RBV.js +4189 -0
  16. package/dist/chunk-Y7AK6RBV.js.map +1 -0
  17. package/dist/{coordinator-VVJ33WF2.js → coordinator-PEWHNZ7I.js} +3 -3
  18. package/dist/{coordinator-VVJ33WF2.js.map → coordinator-PEWHNZ7I.js.map} +1 -1
  19. package/dist/events.js +3 -3
  20. package/dist/index.d.ts +69 -353
  21. package/dist/index.js +161 -43
  22. package/dist/index.js.map +1 -1
  23. package/dist/lp.d.ts +76 -18
  24. package/dist/lp.js +511 -111
  25. package/dist/lp.js.map +1 -1
  26. package/dist/presets.d.ts +7 -40
  27. package/dist/presets.js +10 -68
  28. package/dist/presets.js.map +1 -1
  29. package/dist/stats.js +1 -1
  30. package/dist/storage.js +2 -243
  31. package/dist/storage.js.map +1 -1
  32. package/dist/{errors-N2touVm4.d.ts → types.generated-YhFu9ZBR.d.ts} +65 -4
  33. package/dist/user.d.ts +134 -8
  34. package/dist/user.js +991 -250
  35. package/dist/user.js.map +1 -1
  36. package/package.json +5 -31
  37. package/dist/chunk-BWCGNTN5.js +0 -1153
  38. package/dist/chunk-BWCGNTN5.js.map +0 -1
  39. package/dist/chunk-DIA6U2CV.js +0 -1927
  40. package/dist/chunk-DIA6U2CV.js.map +0 -1
  41. package/dist/chunk-GHBQF3A7.js.map +0 -1
  42. package/dist/chunk-NKRVQXRP.js.map +0 -1
  43. package/dist/chunk-QQSI3ZD7.js.map +0 -1
  44. package/dist/chunk-V5HXJRBW.js.map +0 -1
  45. package/dist/types.generated-BSEBz4jR.d.ts +0 -68
@@ -1,4 +1,4 @@
1
- export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds } from './chunk-NKRVQXRP.js';
1
+ export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds } from './chunk-3TGQ4CZ3.js';
2
2
  import './chunk-VR6T6OJS.js';
3
- //# sourceMappingURL=coordinator-VVJ33WF2.js.map
4
- //# sourceMappingURL=coordinator-VVJ33WF2.js.map
3
+ //# sourceMappingURL=coordinator-PEWHNZ7I.js.map
4
+ //# sourceMappingURL=coordinator-PEWHNZ7I.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"coordinator-VVJ33WF2.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"coordinator-PEWHNZ7I.js"}
package/dist/events.js CHANGED
@@ -1,6 +1,6 @@
1
- import { onEnvelope, EnvelopeKind, CoordinatorMessageType } from './chunk-QQSI3ZD7.js';
2
- import './chunk-V5HXJRBW.js';
3
- import { NotImplementedError } from './chunk-GHBQF3A7.js';
1
+ import { onEnvelope, EnvelopeKind, CoordinatorMessageType } from './chunk-3MDHAS4D.js';
2
+ import './chunk-HJFMDMPY.js';
3
+ import { NotImplementedError } from './chunk-QRN46R3F.js';
4
4
  import './chunk-VR6T6OJS.js';
5
5
 
6
6
  // src/events/index.ts
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import { S as Session } from './session-DFuy54C-.js';
2
2
  export { i as isAttested } from './session-DFuy54C-.js';
3
- export { A as AttestationError, a as AttestationErrorCode, C as CommandError, b as CommandErrorCode, c as CommandErrorOptions, d as CoordinatorWireErrorCode, I as InvalidDepositAmountError, e as InvisibleError, f as InvisibleErrorCode, g as InvisibleErrorOptions, L as LpLifecycleError, h as LpLifecycleErrorCode, N as NotImplementedError, i as NotImplementedErrorCode, P as PolicyValidationError, j as PolicyValidationErrorCode, R as RoutingError, k as RoutingErrorCode, S as StorageError, l as StorageErrorCode, T as TransportError, m as TransportErrorCode, W as WalletError, n as WalletErrorCode, o as isInvisibleError, p as normalizeError } from './errors-N2touVm4.js';
3
+ export { A as AttestationError, a as AttestationErrorCode, C as CommandError, b as CommandErrorCode, c as CommandErrorOptions, d as CoordinatorWireErrorCode, I as InvalidDepositAmountError, e as InvisibleError, f as InvisibleErrorCode, g as InvisibleErrorOptions, L as LpLifecycleError, h as LpLifecycleErrorCode, i as LpPositionView, N as NotImplementedError, j as NotImplementedErrorCode, k as PayoutDestination, P as PayoutPolicy, l as PolicyValidationError, m as PolicyValidationErrorCode, R as RoutingError, n as RoutingErrorCode, o as RuntimeMeasurements, S as StorageEnvelope, p as StorageError, q as StorageErrorCode, r as StorageErrorOptions, s as StorageErrorPhase, T as TransportError, t as TransportErrorCode, W as WalletError, u as WalletErrorCode, v as isInvisibleError, w as normalizeError } from './types.generated-YhFu9ZBR.js';
4
4
  import { T as Transport, N as NoiseWebSocketTransportOptions, U as Unsubscribe } from './types-ZhV7TIQY.js';
5
5
  export { C as ConnectionState, W as WebSocketFactory, a as WebSocketLike } from './types-ZhV7TIQY.js';
6
- import { C as CoordinatorEndpoint, a as CoordinatorPoolConfig, b as CoordinatorReleasePin } from './types.generated-BSEBz4jR.js';
7
- export { A as AzureMaaPin, L as LpPositionView, c as PayoutDestination, P as PayoutPolicy, S as StorageEnvelope } from './types.generated-BSEBz4jR.js';
8
6
 
9
7
  /**
10
8
  * The API surface version this build implements. Bumped only on a breaking
@@ -134,226 +132,52 @@ declare function inMemoryTransport(options?: InMemoryTransportOptions): InMemory
134
132
  declare function noiseWebSocketTransport(options: NoiseWebSocketTransportOptions): Transport;
135
133
 
136
134
  /**
137
- * TDX DCAP attestation verifier (SDK port of
138
- * `web/src/lib/coordinator/tdx-attestation.ts`).
139
- *
140
- * Verifies a TDX DCAP quote on three paths, using Web Crypto (`crypto.subtle`,
141
- * a Node 22 / browser global) and `@peculiar/x509`:
142
- *
143
- * - GCP (spec section 5.1): cert chain to the pinned Intel SGX Root CA, TCB
144
- * validity, freshness nonce == REPORT_DATA[0:32], Noise binding ==
145
- * REPORT_DATA[32:64], debug bit clear, MRTD pin.
146
- * - Azure (spec section 5.2): MAA JWT issuer / JWKS / policy-hash / compliance
147
- * / debug, MAA<->DCAP REPORTDATA binding, hcl_keys hash binding, HCL AK pub
148
- * extraction, raw DCAP measurement binding, TPM AK quote signature, TPM
149
- * qualifying data binding.
150
- * - Local (loopback dev fallback): checks nonce and Noise pubkey consistency
151
- * only; no hardware attestation.
135
+ * `createSession` - the single entrypoint that opens an attested session.
152
136
  *
153
- * Throws the SDK {@link AttestationError} (from `../core/errors.js`) with a
154
- * closed `code` on any failure. Callers fail-closed: tear down the Noise
155
- * transport rather than surface an unverified channel.
137
+ * It validates the endpoint pool, opens the transport, runs the Noise XX
138
+ * handshake + TDX attestation, and returns an opaque {@link Session} that has
139
+ * already passed attestation (`attested === true`). It resolves only once
140
+ * attestation succeeds; any transport or attestation failure rejects with a
141
+ * typed {@link TransportError} / {@link AttestationError}.
156
142
  *
157
- * Never log secrets, nonces, or raw decrypted payloads (spec section 9).
143
+ * A re-attestation timer re-runs verification over the live channel every
144
+ * {@link REATTEST_EVERY_MS}; on failure it marks the session unattested and
145
+ * notifies any registered policy-violation handlers. The transport is
146
+ * injectable for tests.
147
+ */
148
+
149
+ /** Close a session created by {@link createSession}. */
150
+ declare function closeSession(session: Session): void;
151
+
152
+ interface PublicCreateSessionOptions {
153
+ readonly coordinatorUrl: string;
154
+ readonly storage?: unknown;
155
+ readonly wallet?: unknown;
156
+ /** Opt into SDK-owned normal-user transfer persistence. */
157
+ readonly clientPersistence?: boolean;
158
+ }
159
+ /**
160
+ * Open a production-only public SDK session.
158
161
  *
159
- * @module JW-145 / JW-431
162
+ * The caller supplies only the route and public adapters. The Azure
163
+ * production release policy is embedded by the selected SDK build.
160
164
  */
161
- type AttestationMode = "dev" | "prod";
162
- type CoordinatorRuntimeProfile = "prod-hardened" | "prod-devnet-simplified";
163
- type AzureMaaPolicy = {
164
- /** Expected MAA token issuer for the approved Azure Attestation provider. */
165
- expectedIssuer: string;
166
- /** Expected JWKS endpoint for that provider. Token headers must not choose it. */
167
- expectedJwksUrl: string;
168
- /** Expected Azure Attestation evaluation policy hash from the signed token. */
169
- expectedPolicyHash: string;
170
- };
171
- type AttestationPolicy = {
172
- /**
173
- * Expected MRTD for the published production coordinator build.
174
- * Dev mode ignores this pin entirely.
175
- */
176
- expectedMrtd?: string;
177
- /**
178
- * SHA-256 hash of the approved coordinator binary. Azure production
179
- * attestation requires this pin because binary_hash is otherwise only
180
- * response metadata, even though the TPM quote binds it cryptographically.
181
- */
182
- expectedBinaryHash?: string;
183
- /** Expected compile-time runtime profile carried by the approved artifact. */
184
- expectedRuntimeProfile?: CoordinatorRuntimeProfile;
185
- /**
186
- * Runtime mode the client expects for this coordinator route. Production
187
- * builds set this to "prod" so a prod hostname cannot silently accept an
188
- * unpinned dev coordinator after DNS or load-balancer misrouting.
189
- */
190
- requiredMode?: AttestationMode;
191
- /**
192
- * Release tooling only: verify a prod quote before the new MRTD has been
193
- * published. Runtime policy must leave this unset so prod stays fail-closed
194
- * when the pin is missing.
195
- */
196
- allowUnpinnedProdMrtdForRelease?: boolean;
197
- /**
198
- * SHA-256 fingerprint (lowercase hex) of the DER-encoded Intel SGX Root CA.
199
- * Defaults to {@link INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256}. Override only in tests.
200
- */
201
- intelRootFingerprint?: string;
202
- /**
203
- * Temporary non-prod rollout escape hatch for legacy coordinators that have
204
- * not rolled out `dcap_collateral`. When collateral is present, it is always
205
- * verified. Production mode never honors this flag.
206
- */
207
- allowMissingDcapCollateral?: boolean;
208
- /**
209
- * Development-only escape hatch for a local coordinator running on a non-TDX
210
- * machine. The transport only honors this for loopback coordinator URLs.
211
- */
212
- allowLocalAttestation?: boolean;
213
- /**
214
- * Azure-specific trust policy. Required for platform="azure-tdx-dcap" because
215
- * MAA providers and policies are customer-configurable Azure resources.
216
- */
217
- azureMaa?: AzureMaaPolicy;
218
- };
219
- type SignedDcapJson = {
220
- /**
221
- * JSON string returned by Intel PCS. May be either the inner body
222
- * (`tcbInfo` / `enclaveIdentity`) or the full PCS wrapper.
223
- */
224
- body: string;
225
- /** Hex signature over the exact signed body bytes. */
226
- signature: string;
227
- /** PEM chain whose first certificate verifies `signature`, ending at Intel root. */
228
- issuerChainPem: string;
229
- };
230
- type DcapCollateral = {
231
- /** PEM X.509 CRL for the PCK certificate issuer. */
232
- pckCrlPem: string;
233
- /** PEM chain for the PCK CRL issuer, ending at Intel root. */
234
- pckCrlIssuerChainPem: string;
235
- /** PEM X.509 CRL issued by Intel root, covering collateral signing certs. */
236
- rootCaCrlPem: string;
237
- /** Signed Intel TDX TCB Info V3. */
238
- tcbInfo: SignedDcapJson;
239
- /** Signed Intel TD QE Identity V2. */
240
- qeIdentity: SignedDcapJson;
241
- };
242
- type AttestedMetadata = {
243
- mode: AttestationMode;
244
- binaryHash: string;
245
- runtimeProfile?: CoordinatorRuntimeProfile;
246
- mrtd: string;
247
- rtmr0: string;
248
- rtmr1: string;
249
- rtmr2: string;
250
- rtmr3: string;
251
- pubkeyHex: string;
252
- localAttestation: boolean;
253
- };
254
- type AttestResponse = {
255
- quote: string;
256
- /**
257
- * Nonce echoed back by the coordinator. Informational only: freshness is
258
- * enforced cryptographically via REPORT_DATA[0:32] inside the TDX quote, not
259
- * by trusting this JSON field.
260
- */
261
- nonce: string;
262
- pubkey: string;
263
- binary_hash: string;
264
- mode: AttestationMode;
265
- /** Compile-time runtime profile embedded in the coordinator artifact. */
266
- runtime_profile?: CoordinatorRuntimeProfile;
267
- /**
268
- * Platform identifier set by the coordinator. Absent on GCP (tdx-dcap).
269
- * Azure returns "azure-tdx-dcap".
270
- */
271
- platform?: string;
272
- /**
273
- * Azure only: MAA JWT from /attest/TdxVm, RS256-signed by MAA. Contains
274
- * tdx_mrtd, tdx_td_attributes_debug, and x-ms-compliance-status.
275
- */
276
- maa_token?: string;
277
- /**
278
- * Azure only: TPM PCR quote packed as
279
- * [4-byte msg_len LE][TPM2B_ATTEST][TPMT_SIGNATURE].
280
- * qualifying_data = SHA-256(nonce || noise_pubkey || binary_hash). Base64-encoded.
281
- */
282
- tpm_quote?: string;
283
- /**
284
- * Azure only: raw bytes (base64) of the JSON key-blob from HCL report NV
285
- * 0x1400001 [1056:]. SHA-256(hcl_keys_json_bytes) == DCAP REPORTDATA[0:32].
286
- * Contains the AK public key as kid="HCLAkPub".
287
- */
288
- hcl_keys_json?: string;
289
- /**
290
- * Intel DCAP verification collateral. When present, the verifier evaluates
291
- * PCK revocation, TCB Info, and TD QE Identity. Policies can require it.
292
- */
293
- dcap_collateral?: DcapCollateral;
294
- local_attestation?: boolean;
295
- };
165
+ declare function createSession(options: PublicCreateSessionOptions): Promise<Session>;
166
+
296
167
  /**
297
- * Assert that an unknown JSON value has the shape of {@link AttestResponse}.
298
- * Throws {@link AttestationError} ("NOT_ATTESTED") on any missing or wrong-typed
299
- * field. Replaces an unsafe cast so missing fields produce a typed error rather
300
- * than silently reaching downstream checks as `undefined`.
168
+ * Session guards used by mutating commands.
301
169
  */
302
- declare function assertAttestResponse(value: unknown): asserts value is AttestResponse;
303
- declare function verifyAttestation(params: {
304
- response: AttestResponse;
305
- expectedNonce: Uint8Array;
306
- expectedNoiseStaticPub: Uint8Array;
307
- policy: AttestationPolicy;
308
- timeoutMs?: number;
309
- }): Promise<AttestedMetadata>;
310
170
 
311
171
  /**
312
- * Secure channel: Noise XX handshake + TDX attestation over a raw transport.
313
- *
314
- * Free functions, no class (SDK conformance). Given an open {@link Transport}
315
- * and a {@link CoordinatorEndpoint}, {@link establishSecureChannel} drives:
316
- *
317
- * 1. the Noise XX handshake (initiator role) over the raw byte channel:
318
- * -> msg1 (e) send raw
319
- * <- msg2 (e, ee, s, es) read raw, reveals the responder static pubkey
320
- * -> msg3 (s, se) send raw, yields the split NoiseTransport
321
- * 2. the attestation exchange over the freshly-split (but not-yet-promoted)
322
- * Noise transport:
323
- * -> encrypt(encodeAttestationRequest(nonceHex))
324
- * <- decodeAttestationResponse(decrypt(frame)) -> verifyAttestation
325
- *
326
- * On success the pending Noise transport is promoted to the live cipher and an
327
- * attested channel handle is returned: `send`/`onMessage` transparently
328
- * Noise-encrypt/decrypt application frames over the raw transport.
329
- *
330
- * The release pin (mrtd, intelRootFingerprint, azureMaa) and the endpoint's
331
- * requiredMode map to the verifier's {@link AttestationPolicy}. The loopback
332
- * local-attestation fallback (ADR-0037) is only enabled when the endpoint host
333
- * is a loopback address - it must never be honored for a remote coordinator.
334
- *
335
- * Never log secrets, nonces, shares, or decrypted payloads (spec section 9).
172
+ * Assert the session has passed attestation. Every mutating actor command calls
173
+ * this before touching the wire, so an unattested session can never sign or
174
+ * send sensitive material.
336
175
  *
337
- * @module JW-428
176
+ * @throws AttestationError `NOT_ATTESTED` when the session is not attested.
338
177
  */
178
+ declare function assertAttested(session: Session): void;
339
179
 
340
- /** An established, attested Noise channel over a raw transport. */
341
- interface SecureChannel {
342
- /** Verified attestation metadata for the coordinator this channel reached. */
343
- readonly attestation: AttestedMetadata;
344
- /** The coordinator's Noise static public key, pinned for this channel. */
345
- readonly remoteStaticPublicKey: Uint8Array;
346
- /** Request re-attestation without consuming application frames as responses. */
347
- requestAttestation(nonceHex: string, timeoutMs: number): Promise<AttestResponse>;
348
- /** Encrypt and send one application frame over the raw transport. */
349
- send(plaintext: Uint8Array): void;
350
- /** Subscribe to decrypted inbound application frames. */
351
- onMessage(handler: (plaintext: Uint8Array) => void): Unsubscribe;
352
- /** Subscribe to fatal channel failures such as Noise decrypt desync. */
353
- onFatal(handler: (error: Error) => void): Unsubscribe;
354
- /** Tear down the channel: detach listeners and stop accepting frames. */
355
- close(): void;
356
- }
180
+ type CoordinatorRuntimeProfile = "prod-hardened" | "prod-devnet-simplified" | "prod-devnet-simplified-locked" | "azure-tdx-v0-agentless";
357
181
 
358
182
  /**
359
183
  * Session-establishment seams layered on top of an open {@link Transport}.
@@ -371,17 +195,6 @@ interface SecureChannel {
371
195
  * one step should use {@link establishAttestedChannel}.
372
196
  */
373
197
 
374
- /** Result of a completed Noise XX handshake. */
375
- interface NoiseHandshakeResult {
376
- /** The coordinator's Noise static public key, pinned for this session. */
377
- readonly noiseStaticPublicKey: Uint8Array;
378
- /**
379
- * The attested secure channel produced by this handshake. Carried so a
380
- * subsequent {@link performAttestation} can read attestation evidence without
381
- * re-running the exchange. Internal: not part of the structural contract.
382
- */
383
- readonly channel: SecureChannel;
384
- }
385
198
  /** Result of a completed TDX attestation. */
386
199
  interface AttestationResult {
387
200
  /** The verified release MRTD. */
@@ -391,7 +204,7 @@ interface AttestationResult {
391
204
  /** Coordinator binary hash reported by the verified attestation response. */
392
205
  readonly binaryHash: string;
393
206
  /** Compile-time runtime profile carried by the attested coordinator artifact. */
394
- readonly runtimeProfile?: "prod-hardened" | "prod-devnet-simplified";
207
+ readonly runtimeProfile?: "prod-hardened" | "prod-devnet-simplified" | "prod-devnet-simplified-locked" | "azure-tdx-v0-agentless";
395
208
  /** Noise static public key bound into the attestation quote. */
396
209
  readonly pubkeyHex: string;
397
210
  /** True only for explicit loopback local development attestation. */
@@ -403,124 +216,44 @@ interface AttestationResult {
403
216
  /** When verification completed (epoch ms), stamped by the caller. */
404
217
  readonly verifiedAtMs: number;
405
218
  }
406
- /**
407
- * Run the Noise XX handshake over an open transport and pin the coordinator's
408
- * static key. Drives a full attested-channel establishment (attestation is
409
- * bound to the same Noise cipher) and returns the handshake half; read the
410
- * attestation half from {@link performAttestation} with the returned result.
411
- *
412
- * @throws TransportError if the channel fails or the handshake is malformed.
413
- * @throws AttestationError if attestation verification fails.
414
- */
415
- declare function performNoiseHandshake(transport: Transport, endpoint: CoordinatorEndpoint, nonce?: Uint8Array): Promise<NoiseHandshakeResult>;
416
- /**
417
- * Verify the coordinator's TDX attestation, bound to the handshake's Noise
418
- * static key. Reads the evidence captured by {@link performNoiseHandshake}.
419
- *
420
- * @throws TransportError if the handshake result carries no channel.
421
- */
422
- declare function performAttestation(_transport: Transport, handshake: NoiseHandshakeResult): Promise<AttestationResult>;
423
219
 
424
- /**
425
- * `createSession` - the single entrypoint that opens an attested session.
426
- *
427
- * It validates the endpoint pool, opens the transport, runs the Noise XX
428
- * handshake + TDX attestation, and returns an opaque {@link Session} that has
429
- * already passed attestation (`attested === true`). It resolves only once
430
- * attestation succeeds; any transport or attestation failure rejects with a
431
- * typed {@link TransportError} / {@link AttestationError}.
432
- *
433
- * A re-attestation timer re-runs verification over the live channel every
434
- * {@link REATTEST_EVERY_MS}; on failure it marks the session unattested and
435
- * notifies any registered policy-violation handlers. The transport is
436
- * injectable for tests.
437
- */
438
-
439
- /** Options for {@link createSession}. */
440
- interface CreateSessionOptions {
441
- /**
442
- * The coordinator endpoint pool. Must contain at least one endpoint. No
443
- * hostname is provided by default; supply your own or use `@invisible-labs/sdk/presets`.
444
- */
445
- readonly coordinator: CoordinatorPoolConfig;
446
- /**
447
- * Storage adapter for recoverable secrets. Typed by `@invisible-labs/sdk/storage`;
448
- * accepted here so the session can be threaded into storage-backed flows.
449
- */
450
- readonly storage?: unknown;
451
- /** Wallet adapter used for storage key derivation and signing. */
452
- readonly wallet?: unknown;
453
- /**
454
- * Inject a transport. Defaults to a Noise WebSocket transport over the first
455
- * endpoint. Tests pass an in-memory transport (paired with a loopback
456
- * coordinator that can complete the handshake + attestation).
457
- */
458
- readonly transport?: Transport;
220
+ interface PublicProductionReleasePolicy {
221
+ readonly expectedMrtd: string;
222
+ readonly expectedBinaryHash: string;
223
+ readonly expectedRuntimeProfile: CoordinatorRuntimeProfile;
459
224
  }
460
- /**
461
- * Open an attested session against the configured coordinator pool.
462
- *
463
- * @throws Error if the pool config is structurally invalid (including an empty
464
- * `endpoints` array).
465
- * @throws TransportError if the connection or Noise handshake fails.
466
- * @throws AttestationError if attestation verification fails.
467
- */
468
- declare function createSession(options: CreateSessionOptions): Promise<Session>;
469
- /** Close a session created by {@link createSession}. */
470
- declare function closeSession(session: Session): void;
471
-
472
- /**
473
- * Session guards used by mutating commands.
474
- */
475
-
476
- /**
477
- * Assert the session has passed attestation. Every mutating actor command calls
478
- * this before touching the wire, so an unattested session can never sign or
479
- * send sensitive material.
480
- *
481
- * @throws AttestationError `NOT_ATTESTED` when the session is not attested.
482
- */
483
- declare function assertAttested(session: Session): void;
484
-
485
- /**
486
- * `attestation` - read controls and verification triggers (spec section 4.1).
487
- *
488
- * Grouped as a small object of free functions over the opaque `Session`. The
489
- * read accessors (`current`, `policy`) report the last verified result and the
490
- * active pin; `assertValid` re-runs attestation over the live channel and
491
- * `onPolicyViolation` subscribes to out-of-band re-attestation failures.
492
- */
493
225
 
226
+ interface PublicAttestationPolicy {
227
+ readonly expectedMrtd: string;
228
+ readonly expectedBinaryHash?: string;
229
+ readonly expectedRuntimeProfile?: "prod-hardened" | "prod-devnet-simplified" | "prod-devnet-simplified-locked" | "azure-tdx-v0-agentless";
230
+ readonly expectedRuntimeMeasurements?: {
231
+ readonly rtmr0: string;
232
+ readonly rtmr1: string;
233
+ readonly rtmr2: string;
234
+ readonly rtmr3: string;
235
+ };
236
+ readonly intelRootFingerprint?: string;
237
+ readonly azureMaa?: {
238
+ readonly expectedIssuer: string;
239
+ readonly expectedJwksUrl: string;
240
+ readonly expectedPolicyHash: string;
241
+ };
242
+ }
243
+ /** Public attestation read controls. Policy construction remains internal. */
494
244
  declare const attestation: {
495
- /**
496
- * Force-verify the current session against the active policy by re-running
497
- * attestation over the live channel. Updates the stored result on success.
498
- *
499
- * @throws AttestationError if verification fails.
500
- * @throws TransportError if the session has no live attested channel.
501
- */
245
+ productionPolicy(): PublicProductionReleasePolicy;
502
246
  assertValid(session: Session): Promise<AttestationResult>;
503
- /** The last verified attestation result, or `null` before first attestation. */
504
247
  current(session: Session): AttestationResult | null;
505
- /** The release pin the active leader endpoint is verified against. Read-only. */
506
- policy(session: Session): CoordinatorReleasePin;
507
- /**
508
- * Subscribe to out-of-band attestation failures (e.g. during periodic
509
- * re-attestation). The handler fires with the verification error; returns an
510
- * unsubscribe function.
511
- */
248
+ policy(session: Session): PublicAttestationPolicy;
512
249
  onPolicyViolation(session: Session, handler: (error: Error) => void): Unsubscribe;
513
250
  };
514
251
 
515
- /**
516
- * `coordinator` - endpoint pool inspection and failover (spec section 4.2).
517
- *
518
- * `endpoints` is a read accessor that works today. Leader discovery, version
519
- * reporting, and failover depend on the coordinator network surface and are
520
- * deferred (marked 🟡 V0-target in the spec).
521
- */
522
-
523
- /** Coordinator-reported version and role snapshot. */
252
+ interface PublicCoordinatorEndpoint {
253
+ readonly coordinatorUrl: string;
254
+ readonly roleHint?: "leader" | "watcher";
255
+ readonly weight?: number;
256
+ }
524
257
  interface CoordinatorVersion {
525
258
  readonly mode: "prod" | "dev";
526
259
  readonly protocolVersion: string;
@@ -529,27 +262,10 @@ interface CoordinatorVersion {
529
262
  readonly leaderEpoch: number;
530
263
  }
531
264
  declare const coordinator: {
532
- /** All configured endpoints, in the order supplied. Read-only. */
533
- endpoints(session: Session): readonly CoordinatorEndpoint[];
534
- /**
535
- * The endpoint currently accepting mutating commands.
536
- *
537
- * @throws NotImplementedError - deferred (coordinator-pending).
538
- */
539
- currentLeader(_session: Session): Promise<CoordinatorEndpoint | null>;
540
- /**
541
- * The coordinator-reported version snapshot.
542
- *
543
- * @throws NotImplementedError - deferred (coordinator-pending).
544
- */
265
+ endpoints(session: Session): readonly PublicCoordinatorEndpoint[];
266
+ currentLeader(_session: Session): Promise<PublicCoordinatorEndpoint | null>;
545
267
  version(_session: Session): Promise<CoordinatorVersion>;
546
- /**
547
- * Tear down the active session and reconnect through the next healthy
548
- * endpoint, forcing a fresh attestation.
549
- *
550
- * @throws NotImplementedError - deferred (coordinator-pending).
551
- */
552
268
  forceFailover(_session: Session): Promise<void>;
553
269
  };
554
270
 
555
- export { type ApiVersion, type AttestResponse, type AttestationMode, type AttestationPolicy, type AttestationResult, type AzureMaaPolicy, type Brand, CoordinatorEndpoint, CoordinatorPoolConfig, CoordinatorReleasePin, type CoordinatorRuntimeProfile, type CoordinatorVersion, type CreateSessionOptions, type ExponentialBackoff, type ExponentialBackoffOptions, type Hex, type Lamports, type NoiseHandshakeResult, NoiseWebSocketTransportOptions, type PublicKey, type RequestId, Session, Transport, Unsubscribe, apiVersion, assertAttestResponse, assertAttested, attestation, closeSession, coordinator, createExponentialBackoff, createSession, hex, inMemoryTransport, lamports, noiseWebSocketTransport, performAttestation, performNoiseHandshake, publicKey, requestId, verifyAttestation };
271
+ export { type ApiVersion, type AttestationResult, type Brand, type CoordinatorVersion, type PublicCreateSessionOptions as CreateSessionOptions, type ExponentialBackoff, type ExponentialBackoffOptions, type Hex, type Lamports, NoiseWebSocketTransportOptions, type PublicAttestationPolicy, type PublicCoordinatorEndpoint, type PublicKey, type RequestId, Session, Transport, Unsubscribe, apiVersion, assertAttested, attestation, closeSession, coordinator, createExponentialBackoff, createSession, hex, inMemoryTransport, lamports, noiseWebSocketTransport, publicKey, requestId };