@invisible-labs/sdk 0.6.0-devnet.2 → 0.6.0-devnet.4

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 +186 -70
  2. package/dist/.invisible-sdk-build-target.json +7 -0
  3. package/dist/{chunk-TQNNTV5F.js → chunk-4X5OCCQW.js} +3 -3
  4. package/dist/{chunk-TQNNTV5F.js.map → chunk-4X5OCCQW.js.map} +1 -1
  5. package/dist/{chunk-7DSVN3MV.js → chunk-5NNEO7IK.js} +41 -36
  6. package/dist/chunk-5NNEO7IK.js.map +1 -0
  7. package/dist/chunk-BRDLLGCZ.js +59 -0
  8. package/dist/chunk-BRDLLGCZ.js.map +1 -0
  9. package/dist/{chunk-NCY4FCYU.js → chunk-DIA6U2CV.js} +19 -3
  10. package/dist/chunk-DIA6U2CV.js.map +1 -0
  11. package/dist/{chunk-LBC7ALYO.js → chunk-E4DCEDAG.js} +177 -12
  12. package/dist/chunk-E4DCEDAG.js.map +1 -0
  13. package/dist/{chunk-OHIM2YWU.js → chunk-GHBQF3A7.js} +2 -2
  14. package/dist/chunk-GHBQF3A7.js.map +1 -0
  15. package/dist/{chunk-SZAYO2L5.js → chunk-NHEHCUS5.js} +3 -3
  16. package/dist/{chunk-SZAYO2L5.js.map → chunk-NHEHCUS5.js.map} +1 -1
  17. package/dist/{chunk-XUWBGET5.js → chunk-UADJCUPK.js} +125 -18
  18. package/dist/chunk-UADJCUPK.js.map +1 -0
  19. package/dist/{chunk-JRMKCE3S.js → chunk-V5HXJRBW.js} +3 -3
  20. package/dist/{chunk-JRMKCE3S.js.map → chunk-V5HXJRBW.js.map} +1 -1
  21. package/dist/{coordinator-7Y45MCCZ.js → coordinator-ZNLGAYXD.js} +3 -3
  22. package/dist/{coordinator-7Y45MCCZ.js.map → coordinator-ZNLGAYXD.js.map} +1 -1
  23. package/dist/events.js +3 -3
  24. package/dist/index.d.ts +62 -300
  25. package/dist/index.js +98 -43
  26. package/dist/index.js.map +1 -1
  27. package/dist/lp.d.ts +51 -10
  28. package/dist/lp.js +313 -86
  29. package/dist/lp.js.map +1 -1
  30. package/dist/presets.d.ts +5 -42
  31. package/dist/presets.js +11 -62
  32. package/dist/presets.js.map +1 -1
  33. package/dist/stats.js +1 -1
  34. package/dist/storage.js +1 -1
  35. package/dist/{createSession-D3ym-Ira.d.ts → types.generated-DJBTjLpP.d.ts} +37 -53
  36. package/dist/user.d.ts +94 -112
  37. package/dist/user.js +649 -248
  38. package/dist/user.js.map +1 -1
  39. package/package.json +2 -28
  40. package/dist/chunk-7DSVN3MV.js.map +0 -1
  41. package/dist/chunk-LBC7ALYO.js.map +0 -1
  42. package/dist/chunk-NCY4FCYU.js.map +0 -1
  43. package/dist/chunk-OHIM2YWU.js.map +0 -1
  44. package/dist/chunk-XUWBGET5.js.map +0 -1
  45. package/dist/types.generated-CHGSbmLp.d.ts +0 -67
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/version.ts","../src/core/session.ts","../src/transport/inMemoryTransport.ts","../src/attestation/index.ts","../src/coordinator/index.ts"],"names":[],"mappings":";;;;;;;;;;AAIO,IAAM,UAAA,GAAa;;;AC2BnB,SAAS,WAAW,OAAA,EAA2B;AACpD,EAAA,OAAO,OAAA,CAAQ,QAAA;AACjB;;;ACEO,SAAS,iBAAA,CAAkB,OAAA,GAAoC,EAAC,EAA4B;AACjG,EAAA,MAAM,EAAA,GAAK,sBAAsB,MAAM,CAAA;AACvC,EAAA,MAAM,gBAAA,uBAAuB,GAAA,EAAiC;AAE9D,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,MAAM,EAAA,CAAG,GAAA,EAAI;AAAA,IACpB,aAAA,EAAe,CAAC,QAAA,KAAa,EAAA,CAAG,SAAS,QAAQ,CAAA;AAAA,IACjD,UAAU,QAAA,EAAuB;AAC/B,MAAA,gBAAA,CAAiB,IAAI,QAAQ,CAAA;AAC7B,MAAA,OAAO,M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,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAQ,QAAA,EAAgD;AACtD,IAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,mBAAA,CAAoB,qBAAqB,CAAC,CAAA;AAAA,EACtE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAc,QAAA,EAAkC;AAC9C,IAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,mBAAA,CAAoB,2BAA2B,CAAC,CAAA;AAAA,EAC5E;AACF","file":"index.js","sourcesContent":["/**\n * The API surface version this build implements. Bumped only on a breaking\n * surface change. See docs/sdk-specification.md section 12.\n */\nexport const apiVersion = \"v0\" as const;\n\n/** Literal type of {@link apiVersion}. */\nexport type ApiVersion = typeof apiVersion;\n","/**\n * The opaque session handle.\n *\n * A `Session` is the single stateful object the functional surface threads\n * through every call: `fn(session, args)`. It owns the transport, the\n * attestation state, and (later) the leader-epoch bookkeeping. Consumers treat\n * it as opaque - they read `session.attested` and pass it back to SDK\n * functions, but never reach inside. The internal state map and constructor\n * live alongside `createSession` (added in a later ticket); this module only\n * fixes the public shape so the rest of the surface can type against it.\n */\n\ndeclare const sessionBrand: unique symbol;\n\n/**\n * Opaque, attested session handle. Obtain one from `createSession`; pass it as\n * the first argument to every actor command. The only field consumers read is\n * {@link Session.attested}.\n */\nexport interface Session {\n /**\n * Whether the current Noise session has passed full TDX attestation. Sensitive\n * commands refuse to run until this is `true`. Re-handshake or failover resets\n * it to `false` until a fresh attestation completes.\n */\n readonly attested: boolean;\n /** @internal Opacity brand; not constructable by consumers. */\n readonly [sessionBrand]: true;\n}\n\n/** Convenience predicate mirroring {@link Session.attested}. */\nexport function isAttested(session: Session): boolean {\n return session.attested;\n}\n","/**\n * In-memory transport.\n *\n * A zero-network channel used by unit tests. It transitions straight to `open`\n * on connect. `send` delivers the raw frame bytes to an optional peer sink: the\n * WebSocket message boundary is the frame boundary, so there is no extra length\n * prefix (matching the production transport). Noise lives above this pure byte\n * channel, never inside it.\n *\n * With no peer wired in, `send` is a silent no-op (legacy stub behaviour for\n * tests that never exchange frames). A paired loopback coordinator supplies a\n * `peer` sink so a real Noise XX handshake can run in-process (see the\n * `testLoopback` fixture).\n */\n\nimport { TransportError } from \"../core/errors.js\";\nimport { createStateController } from \"./stateController.js\";\nimport type { Transport, Unsubscribe } from \"./types.js\";\n\n/** Options for {@link inMemoryTransport}. Test-only paired-loopback wiring. */\nexport interface InMemoryTransportOptions {\n /**\n * Sink for frames written via `send()`. A paired in-process coordinator sets\n * this so the client's raw bytes reach the responder. When omitted, `send`\n * is a no-op so legacy stub-only tests keep working.\n */\n readonly peer?: (frame: Uint8Array) => void;\n}\n\n/** In-memory transport with a hook to feed inbound frames into `onMessage`. */\nexport interface InMemoryTransportHandle extends Transport {\n /** Deliver a frame to this transport's `onMessage` listeners (peer -> client). */\n readonly deliver: (frame: Uint8Array) => void;\n}\n\nexport function inMemoryTransport(options: InMemoryTransportOptions = {}): InMemoryTransportHandle {\n const sc = createStateController(\"idle\");\n const messageListeners = new Set<(frame: Uint8Array) => void>();\n\n return {\n state: () => sc.get(),\n onStateChange: (listener) => sc.onChange(listener),\n onMessage(listener): Unsubscribe {\n messageListeners.add(listener);\n return () => messageListeners.delete(listener);\n },\n deliver(frame: Uint8Array): void {\n for (const listener of messageListeners) listener(frame);\n },\n async connect(signal) {\n if (signal?.aborted) {\n throw new TransportError(\"CONNECTION_LOST\", \"connect aborted before it started\");\n }\n if (sc.get() === \"open\") return;\n sc.set(\"connecting\");\n sc.set(\"open\");\n },\n send(frame: Uint8Array): void {\n if (sc.get() !== \"open\") {\n throw new TransportError(\"CONNECTION_LOST\", \"cannot send on a non-open transport\");\n }\n options.peer?.(frame);\n },\n close() {\n if (sc.get() === \"closed\") return;\n sc.set(\"closing\");\n sc.set(\"closed\");\n },\n };\n}\n","/**\n * `attestation` - read controls and verification triggers (spec section 4.1).\n *\n * Grouped as a small object of free functions over the opaque `Session`. The\n * read accessors (`current`, `policy`) report the last verified result and the\n * active pin; `assertValid` re-runs attestation over the live channel and\n * `onPolicyViolation` subscribes to out-of-band re-attestation failures.\n */\n\nimport type { Session } from \"../core/session.js\";\nimport type { Unsubscribe } from \"../transport/types.js\";\nimport type { AttestationResult } from \"../transport/handshake.js\";\nimport type { CoordinatorReleasePin } from \"../schemas/types.generated.js\";\nimport { failSessionClosed, getSessionState } from \"../session/state.js\";\nimport { reattestSerialized } from \"./reattest.js\";\n\nexport const attestation = {\n /**\n * Force-verify the current session against the active policy by re-running\n * attestation over the live channel. Updates the stored result on success.\n *\n * @throws AttestationError if verification fails.\n * @throws TransportError if the session has no live attested channel.\n */\n async assertValid(session: Session): Promise<AttestationResult> {\n const state = getSessionState(session);\n const endpoint = state.pool.endpoints[0]!;\n try {\n const result = await reattestSerialized(state, endpoint, state.pool.noiseTransportTimeoutMs);\n state.attestation = result;\n state.attested = true;\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n failSessionClosed(state, error);\n throw error;\n }\n },\n\n /** The last verified attestation result, or `null` before first attestation. */\n current(session: Session): AttestationResult | null {\n return getSessionState(session).attestation;\n },\n\n /** The release pin the active leader endpoint is verified against. Read-only. */\n policy(session: Session): CoordinatorReleasePin {\n return getSessionState(session).pool.endpoints[0]!.releasePin;\n },\n\n /**\n * Subscribe to out-of-band attestation failures (e.g. during periodic\n * re-attestation). The handler fires with the verification error; returns an\n * unsubscribe function.\n */\n onPolicyViolation(session: Session, handler: (error: Error) => void): Unsubscribe {\n const handlers = getSessionState(session).policyViolationHandlers;\n handlers.add(handler);\n return () => handlers.delete(handler);\n },\n};\n","/**\n * `coordinator` - endpoint pool inspection and failover (spec section 4.2).\n *\n * `endpoints` is a read accessor that works today. Leader discovery, version\n * reporting, and failover depend on the coordinator network surface and are\n * deferred (marked 🟡 V0-target in the spec).\n */\n\nimport { NotImplementedError } from \"../core/errors.js\";\nimport type { Session } from \"../core/session.js\";\nimport type { CoordinatorEndpoint } from \"../schemas/types.generated.js\";\nimport { getSessionState } from \"../session/state.js\";\n\n/** Coordinator-reported version and role snapshot. */\nexport interface CoordinatorVersion {\n readonly mode: \"prod\" | \"dev\";\n readonly protocolVersion: string;\n readonly schemaVersion: string;\n readonly hostname: string;\n readonly leaderEpoch: number;\n}\n\nexport const coordinator = {\n /** All configured endpoints, in the order supplied. Read-only. */\n endpoints(session: Session): readonly CoordinatorEndpoint[] {\n return getSessionState(session).pool.endpoints;\n },\n\n /**\n * The endpoint currently accepting mutating commands.\n *\n * @throws NotImplementedError - deferred (coordinator-pending).\n */\n currentLeader(_session: Session): Promise<CoordinatorEndpoint | null> {\n return Promise.reject(new NotImplementedError(\"coordinator.currentLeader\"));\n },\n\n /**\n * The coordinator-reported version snapshot.\n *\n * @throws NotImplementedError - deferred (coordinator-pending).\n */\n version(_session: Session): Promise<CoordinatorVersion> {\n return Promise.reject(new NotImplementedError(\"coordinator.version\"));\n },\n\n /**\n * Tear down the active session and reconnect through the next healthy\n * endpoint, forcing a fresh attestation.\n *\n * @throws NotImplementedError - deferred (coordinator-pending).\n */\n forceFailover(_session: Session): Promise<void> {\n return Promise.reject(new NotImplementedError(\"coordinator.forceFailover\"));\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/core/version.ts","../src/core/session.ts","../src/transport/inMemoryTransport.ts","../src/presets/productionBinaryHash.ts","../src/presets/productionMrtd.ts","../src/session/publicReleasePolicy.ts","../src/session/publicSession.ts","../src/attestation/public.ts","../src/coordinator/public.ts"],"names":[],"mappings":";;;;;;;;;;;AAIO,IAAM,UAAA,GAAa;;;AC2BnB,SAAS,WAAW,OAAA,EAA2B;AACpD,EAAA,OAAO,OAAA,CAAQ,QAAA;AACjB;;;ACEO,SAAS,iBAAA,CAAkB,OAAA,GAAoC,EAAC,EAA4B;AACjG,EAAA,MAAM,EAAA,GAAK,sBAAsB,MAAM,CAAA;AACvC,EAAA,MAAM,gBAAA,uBAAuB,GAAA,EAAiC;AAE9D,EAAA,OAAO;A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UAC9B,kBAAA,EAAoB,IAAI,QAAA,CAAS;AAAA;AACnC;AACF,KACN;AAAA,EACF,CAAA;AAAA,EAEA,iBAAA,CAAkB,SAAkB,OAAA,EAA8C;AAChF,IAAA,MAAM,QAAA,GAAW,eAAA,CAAgB,OAAO,CAAA,CAAE,uBAAA;AAC1C,IAAA,QAAA,CAAS,IAAI,OAAO,CAAA;AACpB,IAAA,OAAO,MAAM,QAAA,CAAS,MAAA,CAAO,OAAO,CAAA;AAAA,EACtC;AACF;;;ACzDO,IAAM,WAAA,GAAc;AAAA,EACzB,UAAU,OAAA,EAAwD;AAChE,IAAA,OAAO,gBAAgB,OAAO,CAAA,CAAE,KAAK,SAAA,CAAU,GAAA,CAAI,CAAC,QAAA,MAAc;AAAA,MAChE,gBAAgB,QAAA,CAAS,KAAA;AAAA,MACzB,GAAI,SAAS,QAAA,KAAa,MAAA,GAAY,EAAC,GAAI,EAAE,QAAA,EAAU,QAAA,CAAS,QAAA,EAAS;AAAA,MACzE,GAAI,SAAS,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAQ,QAAA,CAAS,MAAA;AAAO,KACrE,CAAE,CAAA;AAAA,EACJ,CAAA;AAAA,EAEA,cAAc,QAAA,EAA8D;AAC1E,IAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,mBAAA,CAAoB,2BAA2B,CAAC,CAAA;AAAA,EAC5E,CAAA;AAAA,EAEA,QAAQ,QAAA,EAAgD;AACtD,IAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,mBAAA,CAAoB,qBAAqB,CAAC,CAAA;AAAA,EACtE,CAAA;AAAA,EAEA,cAAc,QAAA,EAAkC;AAC9C,IAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,mBAAA,CAAoB,2BAA2B,CAAC,CAAA;AAAA,EAC5E;AACF","file":"index.js","sourcesContent":["/**\n * The API surface version this build implements. Bumped only on a breaking\n * surface change. See docs/sdk-specification.md section 12.\n */\nexport const apiVersion = \"v0\" as const;\n\n/** Literal type of {@link apiVersion}. */\nexport type ApiVersion = typeof apiVersion;\n","/**\n * The opaque session handle.\n *\n * A `Session` is the single stateful object the functional surface threads\n * through every call: `fn(session, args)`. It owns the transport, the\n * attestation state, and (later) the leader-epoch bookkeeping. Consumers treat\n * it as opaque - they read `session.attested` and pass it back to SDK\n * functions, but never reach inside. The internal state map and constructor\n * live alongside `createSession` (added in a later ticket); this module only\n * fixes the public shape so the rest of the surface can type against it.\n */\n\ndeclare const sessionBrand: unique symbol;\n\n/**\n * Opaque, attested session handle. Obtain one from `createSession`; pass it as\n * the first argument to every actor command. The only field consumers read is\n * {@link Session.attested}.\n */\nexport interface Session {\n /**\n * Whether the current Noise session has passed full TDX attestation. Sensitive\n * commands refuse to run until this is `true`. Re-handshake or failover resets\n * it to `false` until a fresh attestation completes.\n */\n readonly attested: boolean;\n /** @internal Opacity brand; not constructable by consumers. */\n readonly [sessionBrand]: true;\n}\n\n/** Convenience predicate mirroring {@link Session.attested}. */\nexport function isAttested(session: Session): boolean {\n return session.attested;\n}\n","/**\n * In-memory transport.\n *\n * A zero-network channel used by unit tests. It transitions straight to `open`\n * on connect. `send` delivers the raw frame bytes to an optional peer sink: the\n * WebSocket message boundary is the frame boundary, so there is no extra length\n * prefix (matching the production transport). Noise lives above this pure byte\n * channel, never inside it.\n *\n * With no peer wired in, `send` is a silent no-op (legacy stub behaviour for\n * tests that never exchange frames). A paired loopback coordinator supplies a\n * `peer` sink so a real Noise XX handshake can run in-process (see the\n * `testLoopback` fixture).\n */\n\nimport { TransportError } from \"../core/errors.js\";\nimport { createStateController } from \"./stateController.js\";\nimport type { Transport, Unsubscribe } from \"./types.js\";\n\n/** Options for {@link inMemoryTransport}. Test-only paired-loopback wiring. */\nexport interface InMemoryTransportOptions {\n /**\n * Sink for frames written via `send()`. A paired in-process coordinator sets\n * this so the client's raw bytes reach the responder. When omitted, `send`\n * is a no-op so legacy stub-only tests keep working.\n */\n readonly peer?: (frame: Uint8Array) => void;\n}\n\n/** In-memory transport with a hook to feed inbound frames into `onMessage`. */\nexport interface InMemoryTransportHandle extends Transport {\n /** Deliver a frame to this transport's `onMessage` listeners (peer -> client). */\n readonly deliver: (frame: Uint8Array) => void;\n}\n\nexport function inMemoryTransport(options: InMemoryTransportOptions = {}): InMemoryTransportHandle {\n const sc = createStateController(\"idle\");\n const messageListeners = new Set<(frame: Uint8Array) => void>();\n\n return {\n state: () => sc.get(),\n onStateChange: (listener) => sc.onChange(listener),\n onMessage(listener): Unsubscribe {\n messageListeners.add(listener);\n return () => messageListeners.delete(listener);\n },\n deliver(frame: Uint8Array): void {\n for (const listener of messageListeners) listener(frame);\n },\n async connect(signal) {\n if (signal?.aborted) {\n throw new TransportError(\"CONNECTION_LOST\", \"connect aborted before it started\");\n }\n if (sc.get() === \"open\") return;\n sc.set(\"connecting\");\n sc.set(\"open\");\n },\n send(frame: Uint8Array): void {\n if (sc.get() !== \"open\") {\n throw new TransportError(\"CONNECTION_LOST\", \"cannot send on a non-open transport\");\n }\n options.peer?.(frame);\n },\n close() {\n if (sc.get() === \"closed\") return;\n sc.set(\"closing\");\n sc.set(\"closed\");\n },\n };\n}\n","/** Build-time projection of the approved coordinator binary hash. */\n\ndeclare const __INVISIBLE_SDK_PRODUCTION_BINARY_HASH__: string | undefined;\n\nexport const APPROVED_PRODUCTION_COORDINATOR_BINARY_HASH =\n typeof __INVISIBLE_SDK_PRODUCTION_BINARY_HASH__ === \"string\"\n ? __INVISIBLE_SDK_PRODUCTION_BINARY_HASH__.toLowerCase()\n : \"\";\n","/** Build-time projection of the approved production coordinator MRTD. */\n\ndeclare const __INVISIBLE_SDK_PRODUCTION_MRTD__: string | undefined;\n\nexport const APPROVED_PRODUCTION_COORDINATOR_MRTD =\n typeof __INVISIBLE_SDK_PRODUCTION_MRTD__ === \"string\"\n ? __INVISIBLE_SDK_PRODUCTION_MRTD__.toLowerCase()\n : \"\";\n","import { APPROVED_PRODUCTION_COORDINATOR_BINARY_HASH } from \"../presets/productionBinaryHash.js\";\nimport { APPROVED_PRODUCTION_COORDINATOR_MRTD } from \"../presets/productionMrtd.js\";\nimport { APPROVED_PRODUCTION_RUNTIME_PROFILE } from \"../presets/productionRuntimeProfile.js\";\n\nexport interface PublicProductionReleasePolicy {\n readonly expectedMrtd: string;\n readonly expectedBinaryHash: string;\n readonly expectedRuntimeProfile: \"prod-hardened\" | \"prod-devnet-simplified\";\n}\n\n/** The build-bound production tuple used by the public session constructor. */\nexport function publicProductionReleasePolicy(): PublicProductionReleasePolicy {\n return {\n expectedMrtd: APPROVED_PRODUCTION_COORDINATOR_MRTD,\n expectedBinaryHash: APPROVED_PRODUCTION_COORDINATOR_BINARY_HASH,\n expectedRuntimeProfile: APPROVED_PRODUCTION_RUNTIME_PROFILE,\n };\n}\n","import type { Session } from \"../core/session.js\";\nimport { createAzureProductionEndpoint } from \"../presets/production.js\";\nimport { isLoopbackUrl } from \"./secureChannel.js\";\nimport { publicProductionReleasePolicy } from \"./publicReleasePolicy.js\";\nimport {\n closeSession,\n createSessionInternal,\n type CreateSessionOptions as InternalCreateSessionOptions,\n} from \"./createSession.js\";\n\nconst PUBLIC_SESSION_OPTION_KEYS = new Set([\"coordinatorUrl\", \"storage\", \"wallet\"]);\nconst PUBLIC_COORDINATOR_URL_PROTOCOL = \"wss:\";\nconst PUBLIC_COORDINATOR_URL_ERROR =\n \"public SDK createSession requires a non-loopback wss:// coordinatorUrl\";\n\nexport interface PublicCreateSessionOptions {\n readonly coordinatorUrl: string;\n readonly storage?: unknown;\n readonly wallet?: unknown;\n}\n\n/**\n * Open a production-only public SDK session.\n *\n * The caller supplies only the route and public adapters. The Azure\n * production release policy is embedded by the selected SDK build.\n */\nexport async function createSession(options: PublicCreateSessionOptions): Promise<Session> {\n assertPublicOptions(options);\n const parsedUrl = parsePublicCoordinatorUrl(options.coordinatorUrl);\n const releasePolicy = publicProductionReleasePolicy();\n const endpoint = createAzureProductionEndpoint({\n wsUrl: options.coordinatorUrl,\n expectedHostname: parsedUrl.hostname,\n approvedBinaryHash: releasePolicy.expectedBinaryHash,\n approvedMrtd: releasePolicy.expectedMrtd,\n });\n\n const internalOptions: InternalCreateSessionOptions = {\n coordinator: { endpoints: [endpoint] },\n ...(options.storage === undefined ? {} : { storage: options.storage }),\n ...(options.wallet === undefined ? {} : { wallet: options.wallet }),\n };\n return createSessionInternal(internalOptions);\n}\n\nexport { closeSession };\n\nfunction assertPublicOptions(options: unknown): asserts options is PublicCreateSessionOptions {\n if (typeof options !== \"object\" || options === null || Array.isArray(options)) {\n throw new TypeError(\"public SDK createSession options must be an object\");\n }\n for (const key of Object.keys(options)) {\n if (!PUBLIC_SESSION_OPTION_KEYS.has(key)) {\n throw new Error(`public SDK createSession does not accept option ${key}`);\n }\n }\n const coordinatorUrl = (options as { coordinatorUrl?: unknown }).coordinatorUrl;\n if (typeof coordinatorUrl !== \"string\") {\n throw new TypeError(\"public SDK createSession requires coordinatorUrl\");\n }\n}\n\nfunction parsePublicCoordinatorUrl(value: string): URL {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch (cause) {\n const error = new Error(PUBLIC_COORDINATOR_URL_ERROR);\n (error as { cause?: unknown }).cause = cause;\n throw error;\n }\n if (parsed.protocol !== PUBLIC_COORDINATOR_URL_PROTOCOL || isLoopbackUrl(value)) {\n throw new Error(PUBLIC_COORDINATOR_URL_ERROR);\n }\n return parsed;\n}\n","import type { Session } from \"../core/session.js\";\nimport type { AttestationResult } from \"../transport/handshake.js\";\nimport type { Unsubscribe } from \"../transport/types.js\";\nimport { reattestSerialized } from \"./reattest.js\";\nimport { failSessionClosed, getSessionState } from \"../session/state.js\";\nimport {\n publicProductionReleasePolicy,\n type PublicProductionReleasePolicy,\n} from \"../session/publicReleasePolicy.js\";\n\nexport type { AttestationResult } from \"../transport/handshake.js\";\n\nexport interface PublicAttestationPolicy {\n readonly expectedMrtd: string;\n readonly expectedBinaryHash?: string;\n readonly expectedRuntimeProfile?: \"prod-hardened\" | \"prod-devnet-simplified\";\n readonly intelRootFingerprint?: string;\n readonly azureMaa?: {\n readonly expectedIssuer: string;\n readonly expectedJwksUrl: string;\n readonly expectedPolicyHash: string;\n };\n}\n\n/** Public attestation read controls. Policy construction remains internal. */\nexport const attestation = {\n productionPolicy(): PublicProductionReleasePolicy {\n return publicProductionReleasePolicy();\n },\n\n async assertValid(session: Session): Promise<AttestationResult> {\n const state = getSessionState(session);\n const endpoint = state.pool.endpoints[0]!;\n try {\n const result = await reattestSerialized(state, endpoint, state.pool.noiseTransportTimeoutMs);\n state.attestation = result;\n state.attested = true;\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n failSessionClosed(state, error);\n throw error;\n }\n },\n\n current(session: Session): AttestationResult | null {\n return getSessionState(session).attestation;\n },\n\n policy(session: Session): PublicAttestationPolicy {\n const pin = getSessionState(session).pool.endpoints[0]!.releasePin;\n return {\n expectedMrtd: pin.mrtd,\n ...(pin.binaryHash === undefined ? {} : { expectedBinaryHash: pin.binaryHash }),\n ...(pin.runtimeProfile === undefined ? {} : { expectedRuntimeProfile: pin.runtimeProfile }),\n ...(pin.intelRootFingerprint === undefined\n ? {}\n : { intelRootFingerprint: pin.intelRootFingerprint }),\n ...(pin.azureMaa === undefined\n ? {}\n : {\n azureMaa: {\n expectedIssuer: pin.azureMaa.issuer,\n expectedJwksUrl: pin.azureMaa.jwksUrl,\n expectedPolicyHash: pin.azureMaa.policyHash,\n },\n }),\n };\n },\n\n onPolicyViolation(session: Session, handler: (error: Error) => void): Unsubscribe {\n const handlers = getSessionState(session).policyViolationHandlers;\n handlers.add(handler);\n return () => handlers.delete(handler);\n },\n};\n","import { NotImplementedError } from \"../core/errors.js\";\nimport type { Session } from \"../core/session.js\";\nimport { getSessionState } from \"../session/state.js\";\n\nexport interface PublicCoordinatorEndpoint {\n readonly coordinatorUrl: string;\n readonly roleHint?: \"leader\" | \"watcher\";\n readonly weight?: number;\n}\n\nexport interface CoordinatorVersion {\n readonly mode: \"prod\" | \"dev\";\n readonly protocolVersion: string;\n readonly schemaVersion: string;\n readonly hostname: string;\n readonly leaderEpoch: number;\n}\n\nexport const coordinator = {\n endpoints(session: Session): readonly PublicCoordinatorEndpoint[] {\n return getSessionState(session).pool.endpoints.map((endpoint) => ({\n coordinatorUrl: endpoint.wsUrl,\n ...(endpoint.roleHint === undefined ? {} : { roleHint: endpoint.roleHint }),\n ...(endpoint.weight === undefined ? {} : { weight: endpoint.weight }),\n }));\n },\n\n currentLeader(_session: Session): Promise<PublicCoordinatorEndpoint | null> {\n return Promise.reject(new NotImplementedError(\"coordinator.currentLeader\"));\n },\n\n version(_session: Session): Promise<CoordinatorVersion> {\n return Promise.reject(new NotImplementedError(\"coordinator.version\"));\n },\n\n forceFailover(_session: Session): Promise<void> {\n return Promise.reject(new NotImplementedError(\"coordinator.forceFailover\"));\n },\n};\n"]}
package/dist/lp.d.ts CHANGED
@@ -19,6 +19,7 @@ declare function bytesToHex(bytes: Uint8Array): string;
19
19
  declare function signLpCommandBytes(auth: LpPositionCodeAuth, bytes: Uint8Array): Promise<Uint8Array>;
20
20
 
21
21
  type SourceLiquidityUse = "not_materialized" | "available" | "locked_for_payout" | "pending_finality" | "spent" | "released";
22
+ type LpWithdrawalMode = "exact" | "max_available";
22
23
  type LpInventoryShard = {
23
24
  kind: "lp";
24
25
  lpPositionId: string;
@@ -56,6 +57,8 @@ type LpActorSyncView = {
56
57
  lifetimeEarnedLamports: number;
57
58
  redeemablePrincipalSourceCount: number;
58
59
  redeemableFeeSourceCount: number;
60
+ /** Distinct physical sources contributing to the full redeemable claim. */
61
+ redeemableSourceCount?: number;
59
62
  pendingReservationCount: number;
60
63
  reservedPayoutLamports: number;
61
64
  estimatedNetworkFeeLamports: number;
@@ -78,6 +81,7 @@ type LpActorSyncView = {
78
81
  type LpRedemptionHistoryView = {
79
82
  redemptionId: string;
80
83
  state: "requested" | "match_requested" | "reserved" | "pending" | "confirmed" | "rejected";
84
+ withdrawalMode?: LpWithdrawalMode;
81
85
  acceptedLamports: number;
82
86
  acceptedDepositPrincipalLamports: number;
83
87
  acceptedEarnedFeeLamports: number;
@@ -140,6 +144,9 @@ type FinalizeLpDkgBatchInput = {
140
144
  type LpWithdrawalExecutionView = {
141
145
  withdrawalId: string;
142
146
  txSignatures: string[];
147
+ acceptedLamports: number;
148
+ acceptedDepositPrincipalLamports: number;
149
+ acceptedEarnedFeeLamports: number;
143
150
  };
144
151
  type LpDkgClient = {
145
152
  initDkg(input: {
@@ -148,6 +155,9 @@ type LpDkgClient = {
148
155
  }, auth: LpPositionCodeAuth): Promise<{
149
156
  sessionId: string;
150
157
  }>;
158
+ abortDkgSessions(lpPositionId: string, auth: LpPositionCodeAuth): Promise<{
159
+ abortedSessionCount: number;
160
+ }>;
151
161
  dkgRound1(input: {
152
162
  sessionId: string;
153
163
  package: number[];
@@ -168,7 +178,7 @@ type LpDkgClient = {
168
178
  };
169
179
  type LpCoordinatorClient = LpDkgClient & {
170
180
  openPosition(input: OpenLpPositionInput, auth: LpPositionCodeAuth): Promise<LpPositionView>;
171
- getPosition(lpPositionId: string, auth: LpPositionCodeAuth): Promise<LpPositionView>;
181
+ getPosition(lpPositionId: string, auth: LpPositionCodeAuth, options?: LpPositionRequestOptions): Promise<LpPositionView>;
172
182
  finalizeDkgBatch(input: FinalizeLpDkgBatchInput, auth: LpPositionCodeAuth): Promise<LpPositionView>;
173
183
  refillPosition(input: RefillLpPositionInput, auth: LpPositionCodeAuth): Promise<LpPositionView>;
174
184
  reconcileFunding(lpPositionId: string, auth: LpPositionCodeAuth): Promise<LpPositionView>;
@@ -192,13 +202,20 @@ type LpCoordinatorClient = LpDkgClient & {
192
202
  destinationAddresses: string[];
193
203
  depositPrincipalLamports: number;
194
204
  earnedFeeLamports: number;
205
+ withdrawalMode: LpWithdrawalMode;
195
206
  requestedAtMs: number;
196
207
  allowManyToOne?: boolean;
197
208
  }, auth: LpPositionCodeAuth): Promise<LpWithdrawalExecutionView>;
198
209
  };
210
+ interface LpPositionRequestOptions {
211
+ readonly deadlineMs?: number;
212
+ readonly signal?: AbortSignal;
213
+ readonly timeoutMs?: number;
214
+ }
199
215
 
200
216
  declare const LP_REDEMPTION_RECONCILING_MESSAGE = "LP redemption is still settling on the coordinator; it will reconcile from sync";
201
217
  declare const LP_MISSING_POSITION_CODE_MESSAGE = "Save or recover the LP Position Code before using LP funds";
218
+ declare const LP_FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE = "LP earned-fee source count is not available; pass allowManyToOne: true to acknowledge many-to-one withdrawal risk";
202
219
  type LpLifecycleDkgProgress = {
203
220
  readonly phase: "dkg";
204
221
  readonly lpPositionId: string;
@@ -248,9 +265,11 @@ interface LpTopUpRequest {
248
265
  readonly status: "watching" | "funded" | "expired";
249
266
  }
250
267
  interface WithdrawPositionArgs {
251
- /** Accepted LP deposit-principal bucket claim. Computed from the position when omitted. */
268
+ /** Signed intent mode. The coordinator resolves max_available from sealed state. */
269
+ readonly withdrawalMode: LpWithdrawalMode;
270
+ /** Exact LP deposit-principal bucket claim. Required for exact mode. */
252
271
  readonly depositPrincipalLamports?: number;
253
- /** Accepted earned-fee bucket claim. Computed from the position when omitted. */
272
+ /** Exact earned-fee bucket claim. Required for exact mode. */
254
273
  readonly earnedFeeLamports?: number;
255
274
  readonly destinationAddresses: string[];
256
275
  /** Required to accept a privacy-degrading single-destination withdrawal. */
@@ -265,6 +284,9 @@ interface RefillArgs {
265
284
  interface WithdrawalExecution {
266
285
  readonly withdrawalId: string;
267
286
  readonly txSignatures: string[];
287
+ readonly acceptedLamports?: number;
288
+ readonly acceptedDepositPrincipalLamports?: number;
289
+ readonly acceptedEarnedFeeLamports?: number;
268
290
  }
269
291
  interface LpWithdrawalRecord {
270
292
  readonly redemptionId: string;
@@ -310,19 +332,36 @@ interface WaitForWithdrawalConfirmationOptions {
310
332
  readonly onPosition?: (position: LpPositionView) => void;
311
333
  readonly onRedemptionUpdate?: (record: LpWithdrawalRecord) => void;
312
334
  readonly redemptionRecord?: LpWithdrawalRecord;
335
+ /** Caller-owned absolute deadline preserved across client/session retries. */
336
+ readonly deadlineMs?: number;
337
+ readonly signal?: AbortSignal;
338
+ }
339
+ interface RecoverPositionArgs {
340
+ readonly code: string;
341
+ readonly deadlineMs?: number;
342
+ readonly signal?: AbortSignal;
313
343
  }
314
344
  interface WaitForTopUpOptions {
315
345
  readonly signal?: AbortSignal;
316
346
  readonly pollIntervalMs?: number;
317
347
  readonly positionId?: string;
318
348
  }
349
+ interface LpWithdrawalPlanPreviewArgs {
350
+ readonly depositPrincipalLamports?: number;
351
+ readonly earnedFeeLamports?: number;
352
+ readonly allowManyToOne?: boolean;
353
+ }
354
+ interface LpWithdrawalPlanPreview {
355
+ readonly depositPrincipalLamports: number;
356
+ readonly earnedFeeLamports: number;
357
+ readonly sourceCount: number;
358
+ }
319
359
  declare function isLpRedemptionReconcilingError(error: unknown): boolean;
320
360
  declare function isLpPositionAuthMissingError(error: unknown): boolean;
361
+ declare function previewLpWithdrawalPlan(position: LpPositionView, args?: LpWithdrawalPlanPreviewArgs): LpWithdrawalPlanPreview;
321
362
  interface LpLifecycleClient {
322
363
  createPosition(args?: CreatePositionArgs): Promise<CreatePositionResult>;
323
- recoverPosition(args: {
324
- readonly code: string;
325
- }): Promise<LpPositionView>;
364
+ recoverPosition(args: RecoverPositionArgs): Promise<LpPositionView>;
326
365
  confirmPositionCodeSaved(positionId: string): void;
327
366
  completeDkgBatch(positionId: string, options?: CompleteDkgBatchOptions): Promise<LpPositionView>;
328
367
  refreshPosition(positionId: string): Promise<LpPositionView>;
@@ -342,6 +381,7 @@ declare function createLpLifecycleClient(session: Session, runtime?: LpLifecycle
342
381
  declare function defaultLpLifecycleClient(session: Session): LpLifecycleClient;
343
382
 
344
383
  declare const LP_COMMAND_REQUEST_TIMEOUT_MS = 120000;
384
+ declare const LP_DKG_ABORT_REQUEST_TIMEOUT_MS = 10000;
345
385
  declare function createLpCoordinatorClient(session: Session): LpCoordinatorClient;
346
386
 
347
387
  type LpDkgProgress = {
@@ -360,12 +400,13 @@ type CreateLpDkgBatchInput = {
360
400
  useDeterministicTestAddresses?: boolean;
361
401
  onProgress?: (progress: LpDkgProgress) => void;
362
402
  };
403
+ declare const LP_DKG_WORKER_REQUEST_TIMEOUT_MS = 30000;
404
+ declare const LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE = "LP DKG worker request timed out";
405
+ declare const LP_DKG_ABORT_CLEANUP_TIMEOUT_MS = 10000;
363
406
  declare function createLpDkgBatch(input: CreateLpDkgBatchInput): Promise<string[]>;
364
407
 
365
408
  declare function createPosition(session: Session, args?: CreatePositionArgs): Promise<CreatePositionResult>;
366
- declare function recoverPosition(session: Session, args: {
367
- readonly code: string;
368
- }): Promise<LpPositionView>;
409
+ declare function recoverPosition(session: Session, args: RecoverPositionArgs): Promise<LpPositionView>;
369
410
  declare function confirmPositionCodeSaved(session: Session, positionId: string): void;
370
411
  declare function completeDkgBatch(session: Session, positionId: string, opts?: CompleteDkgBatchOptions): Promise<LpPositionView>;
371
412
  declare function refreshPosition(session: Session, positionId: string): Promise<LpPositionView>;
@@ -385,4 +426,4 @@ declare function withdrawFees(session: Session, positionId: string, args: {
385
426
  }): Promise<never>;
386
427
  declare function listPositions(session: Session): Promise<LpPositionView[]>;
387
428
 
388
- export { type CompleteDkgBatchOptions, type CreateLpDkgBatchInput, type CreatePositionArgs, type CreatePositionResult, type FinalizeLpDkgBatchInput, type FundingConfirmationInput, type InitialFundingPlan, LP_COMMAND_REQUEST_TIMEOUT_MS, LP_MISSING_POSITION_CODE_MESSAGE, LP_REDEMPTION_RECONCILING_MESSAGE, type LpActorSyncView, type LpCoordinatorClient, type LpDkgClient, type LpDkgProgress, type LpInventoryShard, type LpLifecycleClient, type LpLifecycleDkgProgress, type LpLifecycleRuntime, type LpPositionCode, type LpPositionCodeAuth, type LpPositionView, type LpRedemptionHistoryView, type LpTopUpRequest, type LpWithdrawalExecutionView, type LpWithdrawalRecord, type OpenLpPositionInput, type RefillArgs, type RefillLpPositionInput, type SourceLiquidityUse, type WaitForTopUpOptions, type WaitForWithdrawalConfirmationOptions, type WithdrawPositionArgs, type WithdrawPositionResult, type WithdrawalConfirmation, type WithdrawalExecution, bytesToHex, completeDkgBatch, confirmPositionCodeSaved, createLpCoordinatorClient, createLpDkgBatch, createLpLifecycleClient, createPosition, defaultLpLifecycleClient, deriveLpPositionCodeAuth, generateLpPositionCode, isLpPositionAuthMissingError, isLpRedemptionReconcilingError, listPositions, normalizeLpPositionCode, prepareInitialFunding, prepareTopUp, reconcileFunding, recoverPosition, refill, refreshPosition, signLpCommandBytes, waitForTopUp, waitForWithdrawalConfirmation, withdrawFees, withdrawPosition };
429
+ export { type CompleteDkgBatchOptions, type CreateLpDkgBatchInput, type CreatePositionArgs, type CreatePositionResult, type FinalizeLpDkgBatchInput, type FundingConfirmationInput, type InitialFundingPlan, LP_COMMAND_REQUEST_TIMEOUT_MS, LP_DKG_ABORT_CLEANUP_TIMEOUT_MS, LP_DKG_ABORT_REQUEST_TIMEOUT_MS, LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE, LP_DKG_WORKER_REQUEST_TIMEOUT_MS, LP_FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE, LP_MISSING_POSITION_CODE_MESSAGE, LP_REDEMPTION_RECONCILING_MESSAGE, type LpActorSyncView, type LpCoordinatorClient, type LpDkgClient, type LpDkgProgress, type LpInventoryShard, type LpLifecycleClient, type LpLifecycleDkgProgress, type LpLifecycleRuntime, type LpPositionCode, type LpPositionCodeAuth, type LpPositionRequestOptions, type LpPositionView, type LpRedemptionHistoryView, type LpTopUpRequest, type LpWithdrawalExecutionView, type LpWithdrawalMode, type LpWithdrawalPlanPreview, type LpWithdrawalPlanPreviewArgs, type LpWithdrawalRecord, type OpenLpPositionInput, type RecoverPositionArgs, type RefillArgs, type RefillLpPositionInput, type SourceLiquidityUse, type WaitForTopUpOptions, type WaitForWithdrawalConfirmationOptions, type WithdrawPositionArgs, type WithdrawPositionResult, type WithdrawalConfirmation, type WithdrawalExecution, bytesToHex, completeDkgBatch, confirmPositionCodeSaved, createLpCoordinatorClient, createLpDkgBatch, createLpLifecycleClient, createPosition, defaultLpLifecycleClient, deriveLpPositionCodeAuth, generateLpPositionCode, isLpPositionAuthMissingError, isLpRedemptionReconcilingError, listPositions, normalizeLpPositionCode, prepareInitialFunding, prepareTopUp, previewLpWithdrawalPlan, reconcileFunding, recoverPosition, refill, refreshPosition, signLpCommandBytes, waitForTopUp, waitForWithdrawalConfirmation, withdrawFees, withdrawPosition };