@invisible-labs/sdk 0.6.0-devnet.1 → 0.6.0-devnet.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -173
- package/dist/{chunk-TQNNTV5F.js → chunk-4X5OCCQW.js} +3 -3
- package/dist/{chunk-TQNNTV5F.js.map → chunk-4X5OCCQW.js.map} +1 -1
- package/dist/{chunk-7DSVN3MV.js → chunk-BWCGNTN5.js} +13 -5
- package/dist/chunk-BWCGNTN5.js.map +1 -0
- package/dist/{chunk-NCY4FCYU.js → chunk-DIA6U2CV.js} +19 -3
- package/dist/chunk-DIA6U2CV.js.map +1 -0
- package/dist/{chunk-OHIM2YWU.js → chunk-GHBQF3A7.js} +2 -2
- package/dist/chunk-GHBQF3A7.js.map +1 -0
- package/dist/{chunk-SZAYO2L5.js → chunk-NHEHCUS5.js} +3 -3
- package/dist/{chunk-SZAYO2L5.js.map → chunk-NHEHCUS5.js.map} +1 -1
- package/dist/{chunk-LBC7ALYO.js → chunk-NKRVQXRP.js} +58 -3
- package/dist/chunk-NKRVQXRP.js.map +1 -0
- package/dist/{chunk-XUWBGET5.js → chunk-QQSI3ZD7.js} +23 -7
- package/dist/chunk-QQSI3ZD7.js.map +1 -0
- package/dist/{chunk-JRMKCE3S.js → chunk-V5HXJRBW.js} +3 -3
- package/dist/{chunk-JRMKCE3S.js.map → chunk-V5HXJRBW.js.map} +1 -1
- package/dist/{coordinator-7Y45MCCZ.js → coordinator-VVJ33WF2.js} +3 -3
- package/dist/{coordinator-7Y45MCCZ.js.map → coordinator-VVJ33WF2.js.map} +1 -1
- package/dist/{createSession-D3ym-Ira.d.ts → errors-N2touVm4.d.ts} +2 -54
- package/dist/events.js +3 -3
- package/dist/index.d.ts +60 -4
- package/dist/index.js +7 -7
- package/dist/lp.d.ts +8 -1
- package/dist/lp.js +109 -22
- package/dist/lp.js.map +1 -1
- package/dist/presets.d.ts +3 -3
- package/dist/presets.js +13 -6
- package/dist/presets.js.map +1 -1
- package/dist/stats.js +1 -1
- package/dist/storage.js +1 -1
- package/dist/{types.generated-CHGSbmLp.d.ts → types.generated-BSEBz4jR.d.ts} +1 -0
- package/dist/user.d.ts +26 -143
- package/dist/user.js +42 -30
- package/dist/user.js.map +1 -1
- package/package.json +8 -5
- package/dist/chunk-7DSVN3MV.js.map +0 -1
- package/dist/chunk-LBC7ALYO.js.map +0 -1
- package/dist/chunk-NCY4FCYU.js.map +0 -1
- package/dist/chunk-OHIM2YWU.js.map +0 -1
- package/dist/chunk-XUWBGET5.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { getSessionState } from './chunk-
|
|
2
|
-
import { TransportError, CommandError } from './chunk-
|
|
1
|
+
import { getSessionState } from './chunk-V5HXJRBW.js';
|
|
2
|
+
import { TransportError, CommandError } from './chunk-GHBQF3A7.js';
|
|
3
3
|
|
|
4
4
|
// src/coordinator/protocolClient.ts
|
|
5
|
+
var OUT_OF_BAND_REQUEST_ID = 0;
|
|
5
6
|
var EnvelopeKind = {
|
|
6
7
|
REQUEST: "request",
|
|
7
8
|
RESPONSE: "response",
|
|
@@ -29,7 +30,7 @@ var CoordinatorMessageType = {
|
|
|
29
30
|
};
|
|
30
31
|
var protocolPromise = null;
|
|
31
32
|
function loadProtocol() {
|
|
32
|
-
protocolPromise ??= import('./coordinator-
|
|
33
|
+
protocolPromise ??= import('./coordinator-VVJ33WF2.js');
|
|
33
34
|
return protocolPromise;
|
|
34
35
|
}
|
|
35
36
|
var runtimes = /* @__PURE__ */ new WeakMap();
|
|
@@ -62,7 +63,13 @@ async function requestEnvelope(session, type, payload, options = {}) {
|
|
|
62
63
|
)
|
|
63
64
|
);
|
|
64
65
|
}, options.timeoutMs);
|
|
65
|
-
runtime.pending.set(reqId, {
|
|
66
|
+
runtime.pending.set(reqId, {
|
|
67
|
+
resolve,
|
|
68
|
+
reject,
|
|
69
|
+
timer,
|
|
70
|
+
swapId: envelope.swap_id,
|
|
71
|
+
rejectMatchingOutOfBandErrors: options.rejectMatchingOutOfBandErrors === true
|
|
72
|
+
});
|
|
66
73
|
options.onLog?.(`-> ${type} req_id=${reqId}`, "out");
|
|
67
74
|
try {
|
|
68
75
|
channel.send(frame);
|
|
@@ -126,7 +133,10 @@ async function handleFrameAsync(runtime, frame) {
|
|
|
126
133
|
if (envelope.kind === protocol.EnvelopeKind.ERROR) {
|
|
127
134
|
const payload = protocol.asErrorPayload(envelope);
|
|
128
135
|
const error = commandErrorFromCoordinatorError(payload);
|
|
129
|
-
if (payload.failed_req_id === void 0) {
|
|
136
|
+
if (payload.failed_req_id === void 0 || payload.failed_req_id === OUT_OF_BAND_REQUEST_ID) {
|
|
137
|
+
if (envelope.swap_id !== null) {
|
|
138
|
+
rejectMatchingOutOfBandErrors(runtime, envelope.swap_id, error);
|
|
139
|
+
}
|
|
130
140
|
return;
|
|
131
141
|
}
|
|
132
142
|
rejectPending(runtime, payload.failed_req_id, error);
|
|
@@ -160,6 +170,12 @@ function rejectPending(runtime, reqId, error) {
|
|
|
160
170
|
if (pending.timer) clearTimeout(pending.timer);
|
|
161
171
|
pending.reject(error);
|
|
162
172
|
}
|
|
173
|
+
function rejectMatchingOutOfBandErrors(runtime, swapId, error) {
|
|
174
|
+
for (const [reqId, pending] of runtime.pending) {
|
|
175
|
+
if (!pending.rejectMatchingOutOfBandErrors || pending.swapId !== swapId) continue;
|
|
176
|
+
rejectPending(runtime, reqId, error);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
163
179
|
function commandErrorFromCoordinatorError(payload) {
|
|
164
180
|
const coordinatorCode = toCoordinatorWireErrorCode(payload.code);
|
|
165
181
|
return new CommandError(commandCodeFromCoordinatorCode(coordinatorCode), payload.message, {
|
|
@@ -217,5 +233,5 @@ function rejectAll(runtime, error) {
|
|
|
217
233
|
}
|
|
218
234
|
|
|
219
235
|
export { CoordinatorMessageType, EnvelopeKind, closeProtocolRuntime, onEnvelope, requestEnvelope };
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
236
|
+
//# sourceMappingURL=chunk-QQSI3ZD7.js.map
|
|
237
|
+
//# sourceMappingURL=chunk-QQSI3ZD7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/coordinator/protocolClient.ts"],"names":[],"mappings":";;;;AAWA,IAAM,sBAAA,GAAyB,CAAA;AAExB,IAAM,YAAA,GAAe;AAAA,EAC1B,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO;AACT;AAIO,IAAM,sBAAA,GAAyB;AAAA,EACpC,eAAA,EAAiB,iBAAA;AAAA,EACjB,OAAA,EAAS,SAAA;AAAA,EACT,SAAA,EAAW,WAAA;AAAA,EACX,SAAA,EAAW,WAAA;AAAA,EACX,WAAA,EAAa,aAAA;AAAA,EACb,aAAA,EAAe,eAAA;AAAA,EACf,WAAA,EAAa,aAAA;AAAA,EACb,gBAAA,EAAkB,kBAAA;AAAA,EAClB,IAAA,EAAM,MAAA;AAAA,EACN,YAAA,EAAc,cAAA;AAAA,EACd,MAAA,EAAQ,QAAA;AAAA,EACR,cAAA,EAAgB,gBAAA;AAAA,EAChB,eAAA,EAAiB,iBAAA;AAAA,EACjB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO;AACT;AA4BA,IAAI,eAAA,GAAkD,IAAA;AAEtD,SAAS,YAAA,GAAwC;AAC/C,EAAA,eAAA,KAAoB,OAAO,2BAAsB,CAAA;AACjD,EAAA,OAAO,eAAA;AACT;AAyCA,IAAM,QAAA,uBAAe,OAAA,EAAuC;AAE5D,eAAsB,gBACpB,OAAA,EACA,IAAA,EACA,OAAA,EACA,OAAA,GAAkC,EAAC,EAChB;AACnB,EAAA,MAAM,QAAA,GAAW,MAAM,Y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,EAAoB;AAC/D,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,OAAO,KAAK,OAAA,CAAQ,OAAA,CAAQ,SAAQ,EAAG;AACxD,IAAA,OAAA,CAAQ,OAAA,CAAQ,OAAO,KAAK,CAAA;AAC5B,IAAA,IAAI,OAAA,CAAQ,KAAA,EAAO,YAAA,CAAa,OAAA,CAAQ,KAAK,CAAA;AAC7C,IAAA,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,EACtB;AACA,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,OAAO,KAAK,OAAA,CAAQ,WAAA,CAAY,SAAQ,EAAG;AAC3D,IAAA,OAAA,CAAQ,WAAA,CAAY,OAAO,IAAI,CAAA;AAC/B,IAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,MAAA,IAAI,MAAA,CAAO,KAAA,EAAO,YAAA,CAAa,MAAA,CAAO,KAAK,CAAA;AAC3C,MAAA,MAAA,CAAO,OAAO,KAAK,CAAA;AAAA,IACrB;AAAA,EACF;AACF","file":"chunk-QQSI3ZD7.js","sourcesContent":["import {\n CommandError,\n TransportError,\n type CommandErrorCode,\n type CoordinatorWireErrorCode,\n} from \"../core/errors.js\";\nimport type { Session } from \"../core/session.js\";\nimport { getSessionState, type SessionState } from \"../session/state.js\";\nimport type { Unsubscribe } from \"../transport/types.js\";\n\nconst COORDINATOR_ENVELOPE_VERSION = 2;\nconst OUT_OF_BAND_REQUEST_ID = 0;\n\nexport const EnvelopeKind = {\n REQUEST: \"request\",\n RESPONSE: \"response\",\n PUSH: \"push\",\n ERROR: \"error\",\n} as const;\n\nexport type EnvelopeKind = (typeof EnvelopeKind)[keyof typeof EnvelopeKind];\n\nexport const CoordinatorMessageType = {\n ContractRequest: \"ContractRequest\",\n DkgInit: \"DkgInit\",\n DkgRound1: \"DkgRound1\",\n DkgRound2: \"DkgRound2\",\n DkgComplete: \"DkgComplete\",\n DelegateShare: \"DelegateShare\",\n DelegateAck: \"DelegateAck\",\n DepositConfirmed: \"DepositConfirmed\",\n Sync: \"Sync\",\n SyncRequired: \"SyncRequired\",\n Refill: \"Refill\",\n PayoutExecuted: \"PayoutExecuted\",\n WithdrawRequest: \"WithdrawRequest\",\n WithdrawAccepted: \"WithdrawAccepted\",\n WithdrawExecuted: \"WithdrawExecuted\",\n LpCommand: \"LpCommand\",\n Error: \"Error\",\n} as const;\n\nexport type CoordinatorMessageType =\n (typeof CoordinatorMessageType)[keyof typeof CoordinatorMessageType];\n\nexport type Envelope = {\n readonly version: typeof COORDINATOR_ENVELOPE_VERSION;\n readonly kind: EnvelopeKind;\n readonly type: CoordinatorMessageType;\n readonly swap_id: string | null;\n readonly req_id: number;\n readonly timestamp_ms: number;\n readonly payload: unknown;\n};\n\ntype ProtocolModule = {\n readonly ENVELOPE_VERSION: typeof COORDINATOR_ENVELOPE_VERSION;\n readonly EnvelopeKind: typeof EnvelopeKind;\n readonly CoordinatorMessageType: typeof CoordinatorMessageType;\n readonly encodeValidated: (envelope: Envelope) => Uint8Array;\n readonly decode: (raw: Uint8Array) => { ok: true; value: Envelope } | { ok: false; error: Error };\n readonly asErrorPayload: (envelope: Envelope) => {\n readonly code: string;\n readonly failed_req_id?: number;\n readonly message: string;\n };\n};\n\nlet protocolPromise: Promise<ProtocolModule> | null = null;\n\nfunction loadProtocol(): Promise<ProtocolModule> {\n protocolPromise ??= import(\"protocol/coordinator\") as Promise<ProtocolModule>;\n return protocolPromise;\n}\n\nexport type ProtocolLogDirection = \"in\" | \"out\" | \"info\";\nexport type ProtocolLogHandler = (message: string, direction: ProtocolLogDirection) => void;\nexport type ProtocolEnvelopeHandler = (envelope: Envelope) => void;\n\nexport interface RequestEnvelopeOptions {\n readonly swapId?: string | null;\n readonly timeoutMs?: number;\n readonly onLog?: ProtocolLogHandler;\n /** Reject this request when the coordinator reports a swap-scoped error without a request id. */\n readonly rejectMatchingOutOfBandErrors?: boolean;\n}\n\nexport interface AwaitPushOptions {\n readonly timeoutMs?: number | null;\n}\n\ntype PendingRequest = {\n readonly resolve: (envelope: Envelope) => void;\n readonly reject: (error: Error) => void;\n readonly timer: ReturnType<typeof setTimeout> | null;\n readonly swapId: string | null;\n readonly rejectMatchingOutOfBandErrors: boolean;\n};\n\ntype PushWaiter = {\n readonly resolve: (envelope: Envelope) => void;\n readonly reject: (error: Error) => void;\n readonly timer: ReturnType<typeof setTimeout> | null;\n};\n\ntype ProtocolRuntime = {\n reqCounter: number;\n readonly pending: Map<number, PendingRequest>;\n readonly pushWaiters: Map<CoordinatorMessageType, PushWaiter[]>;\n readonly envelopeHandlers: Set<ProtocolEnvelopeHandler>;\n unsubscribeChannel: Unsubscribe | null;\n unsubscribeTransport: Unsubscribe | null;\n};\n\nconst runtimes = new WeakMap<SessionState, ProtocolRuntime>();\n\nexport async function requestEnvelope(\n session: Session,\n type: CoordinatorMessageType,\n payload: unknown,\n options: RequestEnvelopeOptions = {},\n): Promise<Envelope> {\n const protocol = await loadProtocol();\n const state = getSessionState(session);\n const runtime = ensureProtocolRuntime(state);\n const channel = state.channel;\n if (!state.attested || channel === null) {\n throw new TransportError(\"CONNECTION_LOST\", \"coordinator request requires an attested channel\");\n }\n\n const reqId = ++runtime.reqCounter;\n const envelope: Envelope = {\n version: protocol.ENVELOPE_VERSION,\n kind: protocol.EnvelopeKind.REQUEST,\n type,\n swap_id: options.swapId ?? null,\n req_id: reqId,\n timestamp_ms: Date.now(),\n payload,\n };\n const frame = protocol.encodeValidated(envelope);\n\n return new Promise((resolve, reject) => {\n const timer =\n options.timeoutMs === undefined\n ? null\n : setTimeout(() => {\n runtime.pending.delete(reqId);\n reject(\n new CommandError(\n \"REJECTED_STALE_JOB\",\n `coordinator request timed out for ${type} after ${options.timeoutMs}ms`,\n ),\n );\n }, options.timeoutMs);\n\n runtime.pending.set(reqId, {\n resolve,\n reject,\n timer,\n swapId: envelope.swap_id,\n rejectMatchingOutOfBandErrors: options.rejectMatchingOutOfBandErrors === true,\n });\n options.onLog?.(`-> ${type} req_id=${reqId}`, \"out\");\n try {\n channel.send(frame);\n } catch (error) {\n runtime.pending.delete(reqId);\n if (timer) clearTimeout(timer);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n}\n\nexport function awaitPush(\n session: Session,\n type: CoordinatorMessageType,\n options: AwaitPushOptions = {},\n): Promise<Envelope> {\n const state = getSessionState(session);\n const runtime = ensureProtocolRuntime(state);\n const timeoutMs = options.timeoutMs === undefined ? 30_000 : options.timeoutMs;\n\n return new Promise((resolve, reject) => {\n const timer =\n timeoutMs === null\n ? null\n : setTimeout(() => {\n removePushWaiter(runtime, type, waiter);\n reject(new CommandError(\"REJECTED_STALE_JOB\", `timed out waiting for ${type} push`));\n }, timeoutMs);\n const waiter: PushWaiter = { resolve, reject, timer };\n const waiters = runtime.pushWaiters.get(type) ?? [];\n waiters.push(waiter);\n runtime.pushWaiters.set(type, waiters);\n });\n}\n\nexport function onEnvelope(session: Session, handler: ProtocolEnvelopeHandler): Unsubscribe {\n const runtime = ensureProtocolRuntime(getSessionState(session));\n runtime.envelopeHandlers.add(handler);\n return () => runtime.envelopeHandlers.delete(handler);\n}\n\nexport function closeProtocolRuntime(session: Session): void {\n const state = getSessionState(session);\n const runtime = runtimes.get(state);\n if (!runtime) return;\n const error = new TransportError(\"CONNECTION_LOST\", \"coordinator protocol runtime closed\");\n rejectAll(runtime, error);\n runtime.unsubscribeChannel?.();\n runtime.unsubscribeTransport?.();\n runtimes.delete(state);\n}\n\nfunction ensureProtocolRuntime(state: SessionState): ProtocolRuntime {\n const existing = runtimes.get(state);\n if (existing) return existing;\n\n const runtime: ProtocolRuntime = {\n reqCounter: 0,\n pending: new Map(),\n pushWaiters: new Map(),\n envelopeHandlers: new Set(),\n unsubscribeChannel: null,\n unsubscribeTransport: null,\n };\n\n if (state.channel === null) {\n throw new TransportError(\"CONNECTION_LOST\", \"coordinator protocol requires a live channel\");\n }\n runtime.unsubscribeChannel = state.channel.onMessage((frame) => handleFrame(runtime, frame));\n runtime.unsubscribeTransport = state.transport.onStateChange((transportState) => {\n if (transportState === \"closing\" || transportState === \"closed\") {\n rejectAll(runtime, new TransportError(\"CONNECTION_LOST\", \"coordinator transport closed\"));\n }\n });\n\n runtimes.set(state, runtime);\n return runtime;\n}\n\nfunction handleFrame(runtime: ProtocolRuntime, frame: Uint8Array): void {\n void handleFrameAsync(runtime, frame);\n}\n\nasync function handleFrameAsync(runtime: ProtocolRuntime, frame: Uint8Array): Promise<void> {\n const protocol = await loadProtocol();\n const decoded = protocol.decode(frame);\n if (!decoded.ok) {\n rejectAll(runtime, decoded.error);\n return;\n }\n\n const envelope = decoded.value;\n for (const handler of runtime.envelopeHandlers) handler(envelope);\n\n if (envelope.kind === protocol.EnvelopeKind.ERROR) {\n const payload = protocol.asErrorPayload(envelope);\n const error = commandErrorFromCoordinatorError(payload);\n if (payload.failed_req_id === undefined || payload.failed_req_id === OUT_OF_BAND_REQUEST_ID) {\n if (envelope.swap_id !== null) {\n rejectMatchingOutOfBandErrors(runtime, envelope.swap_id, error);\n }\n return;\n }\n rejectPending(runtime, payload.failed_req_id, error);\n return;\n }\n\n if (envelope.kind === protocol.EnvelopeKind.PUSH) {\n resolvePushWaiter(runtime, envelope);\n return;\n }\n\n if (envelope.kind !== protocol.EnvelopeKind.RESPONSE) return;\n const pending = runtime.pending.get(envelope.req_id);\n if (!pending) return;\n runtime.pending.delete(envelope.req_id);\n if (pending.timer) clearTimeout(pending.timer);\n pending.resolve(envelope);\n}\n\nfunction resolvePushWaiter(runtime: ProtocolRuntime, envelope: Envelope): void {\n const waiters = runtime.pushWaiters.get(envelope.type);\n const waiter = waiters?.shift();\n if (!waiter || !waiters) return;\n if (waiters.length === 0) {\n runtime.pushWaiters.delete(envelope.type);\n }\n if (waiter.timer) clearTimeout(waiter.timer);\n waiter.resolve(envelope);\n}\n\nfunction rejectPending(runtime: ProtocolRuntime, reqId: number, error: Error): void {\n const pending = runtime.pending.get(reqId);\n if (!pending) return;\n runtime.pending.delete(reqId);\n if (pending.timer) clearTimeout(pending.timer);\n pending.reject(error);\n}\n\nfunction rejectMatchingOutOfBandErrors(\n runtime: ProtocolRuntime,\n swapId: string,\n error: Error,\n): void {\n for (const [reqId, pending] of runtime.pending) {\n if (!pending.rejectMatchingOutOfBandErrors || pending.swapId !== swapId) continue;\n rejectPending(runtime, reqId, error);\n }\n}\n\nfunction commandErrorFromCoordinatorError(payload: {\n readonly code: string;\n readonly failed_req_id?: number;\n readonly message: string;\n}): CommandError {\n const coordinatorCode = toCoordinatorWireErrorCode(payload.code);\n return new CommandError(commandCodeFromCoordinatorCode(coordinatorCode), payload.message, {\n coordinatorCode,\n ...(payload.failed_req_id !== undefined ? { failedReqId: payload.failed_req_id } : {}),\n });\n}\n\nfunction commandCodeFromCoordinatorCode(code: CoordinatorWireErrorCode): CommandErrorCode {\n switch (code) {\n case \"ERR_UNEXPECTED_TYPE\":\n case \"ERR_UNKNOWN_SWAP\":\n case \"ERR_SWAP_NOT_REFUNDABLE\":\n return \"REJECTED_STATE\";\n case \"ERR_INTERNAL\":\n case \"ERR_SETTLEMENT_FAILED\":\n return \"REJECTED_STALE_JOB\";\n case \"ERR_INVALID_PAYLOAD\":\n case \"ERR_POLICY_VIOLATION\":\n case \"ERR_INVALID_RECOVERY_CODE\":\n case \"ERR_DKG_FAILURE\":\n case \"ERR_INVALID_DEPOSIT\":\n return \"REJECTED_GUARD\";\n }\n}\n\nfunction toCoordinatorWireErrorCode(code: string): CoordinatorWireErrorCode {\n switch (code) {\n case \"ERR_INVALID_PAYLOAD\":\n case \"ERR_UNEXPECTED_TYPE\":\n case \"ERR_UNKNOWN_SWAP\":\n case \"ERR_POLICY_VIOLATION\":\n case \"ERR_INVALID_RECOVERY_CODE\":\n case \"ERR_SWAP_NOT_REFUNDABLE\":\n case \"ERR_DKG_FAILURE\":\n case \"ERR_INTERNAL\":\n case \"ERR_INVALID_DEPOSIT\":\n case \"ERR_SETTLEMENT_FAILED\":\n return code;\n default:\n return \"ERR_INTERNAL\";\n }\n}\n\nfunction removePushWaiter(\n runtime: ProtocolRuntime,\n type: CoordinatorMessageType,\n waiter: PushWaiter,\n): void {\n const waiters = runtime.pushWaiters.get(type);\n if (!waiters) return;\n const index = waiters.indexOf(waiter);\n if (index >= 0) waiters.splice(index, 1);\n if (waiters.length === 0) runtime.pushWaiters.delete(type);\n}\n\nfunction rejectAll(runtime: ProtocolRuntime, error: Error): void {\n for (const [reqId, pending] of runtime.pending.entries()) {\n runtime.pending.delete(reqId);\n if (pending.timer) clearTimeout(pending.timer);\n pending.reject(error);\n }\n for (const [type, waiters] of runtime.pushWaiters.entries()) {\n runtime.pushWaiters.delete(type);\n for (const waiter of waiters) {\n if (waiter.timer) clearTimeout(waiter.timer);\n waiter.reject(error);\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransportError } from './chunk-
|
|
1
|
+
import { TransportError } from './chunk-GHBQF3A7.js';
|
|
2
2
|
|
|
3
3
|
// src/session/state.ts
|
|
4
4
|
var registry = /* @__PURE__ */ new WeakMap();
|
|
@@ -46,5 +46,5 @@ function failSessionClosed(state, cause, options = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export { closeSessionState, createSessionHandle, failSessionClosed, getSessionState };
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-V5HXJRBW.js.map
|
|
50
|
+
//# sourceMappingURL=chunk-V5HXJRBW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/session/state.ts"],"names":[],"mappings":";;;AAiDA,IAAM,QAAA,uBAAe,OAAA,EAA+B;AAG7C,SAAS,oBAAoB,KAAA,EAA8B;AAChE,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,IAAI,QAAA,GAAW;AACb,MAAA,OAAO,KAAA,CAAM,QAAA;AAAA,IACf;AAAA,GACF;AACA,EAAA,QAAA,CAAS,GAAA,CAAI,QAAQ,KAA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AAa,CAAA;AAChC,IAAA,KAAA,CAAM,aAAA,GAAgB,IAAA;AAAA,EACxB;AACA,EAAA,KAAA,CAAM,eAAA,GAAkB,IAAA;AACxB,EAAA,KAAA,CAAM,cAAA,GAAiB,KAAA;AAEvB,EAAA,MAAM,UAAU,KAAA,CAAM,OAAA;AACtB,EAAA,KAAA,CAAM,QAAA,GAAW,KAAA;AACjB,EAAA,KAAA,CAAM,WAAA,GAAc,IAAA;AACpB,EAAA,KAAA,CAAM,OAAA,GAAU,IAAA;AAChB,EAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AACd,EAAA,KAAA,CAAM,qBAAA,GAAwB,IAAA;AAE9B,EAAA,OAAA,EAAS,KAAA,EAAM;AACf,EAAA,KAAA,CAAM,UAAU,KAAA,EAAM;AAEtB,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,KAAA,MAAW,OAAA,IAAW,KAAA,CAAM,uBAAA,EAAyB,OAAA,CAAQ,KAAK,CAAA;AAAA,EACpE;AACF","file":"chunk-V5HXJRBW.js","sourcesContent":["/**\n * Internal session state and the opaque-handle registry.\n *\n * The public {@link Session} is opaque: consumers only read `session.attested`.\n * The real state (transport, endpoint pool, attestation result) is held here\n * and reached through {@link getSessionState}, keyed off the handle in a\n * `WeakMap` so it is never reachable from the public surface.\n */\n\nimport type { Session } from \"../core/session.js\";\nimport type { Transport } from \"../transport/types.js\";\nimport type { AttestationResult } from \"../transport/handshake.js\";\nimport type { SecureChannel } from \"./secureChannel.js\";\nimport type { CoordinatorPoolConfig } from \"../schemas/types.generated.js\";\nimport { TransportError } from \"../core/errors.js\";\n\nexport interface SessionState {\n /** Flipped to `true` once attestation passes. */\n attested: boolean;\n /** The byte channel this session runs over. */\n readonly transport: Transport;\n /** The endpoint pool the session was created with. */\n readonly pool: CoordinatorPoolConfig;\n /** The last verified attestation result, or `null` before first attestation. */\n attestation: AttestationResult | null;\n /**\n * The live attested Noise channel, or `null` before/after attestation. All\n * application I/O Noise-encrypts through this.\n */\n channel: SecureChannel | null;\n /**\n * The per-connection 32-byte CSPRNG nonce bound into the attestation request.\n * Retained for re-attestation over the same channel.\n */\n nonce: Uint8Array | null;\n /** The coordinator's pinned Noise static public key, or `null` if unattested. */\n remoteStaticPublicKey: Uint8Array | null;\n /** Pending re-attestation timer, cleared on close. */\n reattestTimer: ReturnType<typeof setTimeout> | null;\n /** In-flight re-attestation shared by explicit and periodic checks. */\n reattestPromise: Promise<AttestationResult> | null;\n /** Fatal secure-channel cause preserved across transport close notifications. */\n lastFatalError: Error | null;\n /** Handlers invoked when an out-of-band re-attestation fails. */\n readonly policyViolationHandlers: Set<(error: Error) => void>;\n /** Tear down the session: clear the re-attest timer and close the channel. */\n close(): void;\n}\n\nconst registry = new WeakMap<Session, SessionState>();\n\n/** Build an opaque {@link Session} handle backed by `state`. */\nexport function createSessionHandle(state: SessionState): Session {\n const handle = {\n get attested() {\n return state.attested;\n },\n } as unknown as Session;\n registry.set(handle, state);\n return handle;\n}\n\n/**\n * Resolve the internal state for a session.\n *\n * @throws Error if the handle was not produced by `createSession`.\n */\nexport function getSessionState(session: Session): SessionState {\n const state = registry.get(session);\n if (!state) {\n throw new Error(\"invalid Session: this handle was not created by createSession\");\n }\n return state;\n}\n\nexport function closeSessionState(state: SessionState): void {\n failSessionClosed(state, new TransportError(\"CONNECTION_LOST\", \"session closed\"), {\n notifyPolicyViolation: false,\n });\n}\n\nexport function failSessionClosed(\n state: SessionState,\n cause: Error,\n options: { readonly notifyPolicyViolation?: boolean } = {},\n): void {\n const notifyPolicyViolation = options.notifyPolicyViolation ?? true;\n const shouldNotify =\n notifyPolicyViolation &&\n (state.attested || state.attestation !== null || state.channel !== null);\n\n if (state.reattestTimer !== null) {\n clearTimeout(state.reattestTimer);\n state.reattestTimer = null;\n }\n state.reattestPromise = null;\n state.lastFatalError = cause;\n\n const channel = state.channel;\n state.attested = false;\n state.attestation = null;\n state.channel = null;\n state.nonce = null;\n state.remoteStaticPublicKey = null;\n\n channel?.close();\n state.transport.close();\n\n if (shouldNotify) {\n for (const handler of state.policyViolationHandlers) handler(cause);\n }\n}\n"]}
|
|
@@ -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-
|
|
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';
|
|
2
2
|
import './chunk-VR6T6OJS.js';
|
|
3
|
-
//# sourceMappingURL=coordinator-
|
|
4
|
-
//# sourceMappingURL=coordinator-
|
|
3
|
+
//# sourceMappingURL=coordinator-VVJ33WF2.js.map
|
|
4
|
+
//# sourceMappingURL=coordinator-VVJ33WF2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"coordinator-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"coordinator-VVJ33WF2.js"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { S as Session } from './session-DFuy54C-.js';
|
|
2
|
-
import { T as Transport } from './types-ZhV7TIQY.js';
|
|
3
|
-
import { a as CoordinatorPoolConfig } from './types.generated-CHGSbmLp.js';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* The closed error taxonomy from docs/sdk-specification.md section 8.3.
|
|
7
3
|
*
|
|
@@ -16,7 +12,7 @@ import { a as CoordinatorPoolConfig } from './types.generated-CHGSbmLp.js';
|
|
|
16
12
|
* The conformance lint allowlists this file for that reason.
|
|
17
13
|
*/
|
|
18
14
|
/** Attestation verification failures. Stop; do not retry without a new pin. */
|
|
19
|
-
type AttestationErrorCode = "CERT_CHAIN_INVALID" | "TCB_REJECTED" | "FRESHNESS_NONCE_MISMATCH" | "NOISE_BINDING_MISMATCH" | "DEBUG_BIT_SET" | "MRTD_MISMATCH" | "AZURE_MAA_ISSUER_MISMATCH" | "AZURE_MAA_JWKS_INVALID" | "AZURE_MAA_POLICY_HASH_MISMATCH" | "AZURE_MAA_NOT_COMPLIANT" | "AZURE_MAA_DCAP_MISMATCH" | "AZURE_HCL_KEYS_MISMATCH" | "AZURE_AK_PUB_INVALID" | "AZURE_TPM_AK_QUOTE_INVALID" | "AZURE_TPM_QUALIFYING_DATA_MISMATCH" | "NOT_ATTESTED";
|
|
15
|
+
type AttestationErrorCode = "CERT_CHAIN_INVALID" | "TCB_REJECTED" | "FRESHNESS_NONCE_MISMATCH" | "NOISE_BINDING_MISMATCH" | "DEBUG_BIT_SET" | "MRTD_MISMATCH" | "RUNTIME_PROFILE_MISMATCH" | "AZURE_MAA_ISSUER_MISMATCH" | "AZURE_MAA_JWKS_INVALID" | "AZURE_MAA_POLICY_HASH_MISMATCH" | "AZURE_MAA_NOT_COMPLIANT" | "AZURE_MAA_DCAP_MISMATCH" | "AZURE_HCL_KEYS_MISMATCH" | "AZURE_AK_PUB_INVALID" | "AZURE_TPM_AK_QUOTE_INVALID" | "AZURE_TPM_QUALIFYING_DATA_MISMATCH" | "NOT_ATTESTED";
|
|
20
16
|
/** Transport-level failures. Reconnect through the pool and re-attest. */
|
|
21
17
|
type TransportErrorCode = "WS_HANDSHAKE_FAILED" | "NOISE_HANDSHAKE_FAILED" | "NOISE_FRAME_TOO_LARGE" | "CONNECTION_LOST";
|
|
22
18
|
/** Leader/role routing failures. Failover and re-attest. */
|
|
@@ -126,52 +122,4 @@ declare function isInvisibleError(value: unknown): value is InvisibleError;
|
|
|
126
122
|
*/
|
|
127
123
|
declare function normalizeError(error: unknown, fallback?: string): string;
|
|
128
124
|
|
|
129
|
-
|
|
130
|
-
* `createSession` - the single entrypoint that opens an attested session.
|
|
131
|
-
*
|
|
132
|
-
* It validates the endpoint pool, opens the transport, runs the Noise XX
|
|
133
|
-
* handshake + TDX attestation, and returns an opaque {@link Session} that has
|
|
134
|
-
* already passed attestation (`attested === true`). It resolves only once
|
|
135
|
-
* attestation succeeds; any transport or attestation failure rejects with a
|
|
136
|
-
* typed {@link TransportError} / {@link AttestationError}.
|
|
137
|
-
*
|
|
138
|
-
* A re-attestation timer re-runs verification over the live channel every
|
|
139
|
-
* {@link REATTEST_EVERY_MS}; on failure it marks the session unattested and
|
|
140
|
-
* notifies any registered policy-violation handlers. The transport is
|
|
141
|
-
* injectable for tests.
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
/** Options for {@link createSession}. */
|
|
145
|
-
interface CreateSessionOptions {
|
|
146
|
-
/**
|
|
147
|
-
* The coordinator endpoint pool. Must contain at least one endpoint. No
|
|
148
|
-
* hostname is provided by default; supply your own or use `@invisible-labs/sdk/presets`.
|
|
149
|
-
*/
|
|
150
|
-
readonly coordinator: CoordinatorPoolConfig;
|
|
151
|
-
/**
|
|
152
|
-
* Storage adapter for recoverable secrets. Typed by `@invisible-labs/sdk/storage`;
|
|
153
|
-
* accepted here so the session can be threaded into storage-backed flows.
|
|
154
|
-
*/
|
|
155
|
-
readonly storage?: unknown;
|
|
156
|
-
/** Wallet adapter used for storage key derivation and signing. */
|
|
157
|
-
readonly wallet?: unknown;
|
|
158
|
-
/**
|
|
159
|
-
* Inject a transport. Defaults to a Noise WebSocket transport over the first
|
|
160
|
-
* endpoint. Tests pass an in-memory transport (paired with a loopback
|
|
161
|
-
* coordinator that can complete the handshake + attestation).
|
|
162
|
-
*/
|
|
163
|
-
readonly transport?: Transport;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Open an attested session against the configured coordinator pool.
|
|
167
|
-
*
|
|
168
|
-
* @throws Error if the pool config is structurally invalid (including an empty
|
|
169
|
-
* `endpoints` array).
|
|
170
|
-
* @throws TransportError if the connection or Noise handshake fails.
|
|
171
|
-
* @throws AttestationError if attestation verification fails.
|
|
172
|
-
*/
|
|
173
|
-
declare function createSession(options: CreateSessionOptions): Promise<Session>;
|
|
174
|
-
/** Close a session created by {@link createSession}. */
|
|
175
|
-
declare function closeSession(session: Session): void;
|
|
176
|
-
|
|
177
|
-
export { AttestationError as A, type CreateSessionOptions as C, InvalidDepositAmountError as I, LpLifecycleError as L, NotImplementedError as N, PolicyValidationError as P, RoutingError as R, StorageError as S, TransportError as T, WalletError as W, type AttestationErrorCode as a, CommandError as b, type CommandErrorCode as c, type CommandErrorOptions as d, type CoordinatorWireErrorCode as e, InvisibleError as f, type InvisibleErrorCode as g, type InvisibleErrorOptions as h, type LpLifecycleErrorCode as i, type NotImplementedErrorCode as j, type PolicyValidationErrorCode as k, type RoutingErrorCode as l, type StorageErrorCode as m, type TransportErrorCode as n, type WalletErrorCode as o, closeSession as p, createSession as q, isInvisibleError as r, normalizeError as s };
|
|
125
|
+
export { AttestationError as A, CommandError as C, InvalidDepositAmountError as I, LpLifecycleError as L, NotImplementedError as N, PolicyValidationError as P, RoutingError as R, StorageError as S, TransportError as T, WalletError as W, type AttestationErrorCode as a, type CommandErrorCode as b, type CommandErrorOptions as c, type CoordinatorWireErrorCode as d, InvisibleError as e, type InvisibleErrorCode as f, type InvisibleErrorOptions as g, type LpLifecycleErrorCode as h, type NotImplementedErrorCode as i, type PolicyValidationErrorCode as j, type RoutingErrorCode as k, type StorageErrorCode as l, type TransportErrorCode as m, type WalletErrorCode as n, isInvisibleError as o, normalizeError as p };
|
package/dist/events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { onEnvelope, EnvelopeKind, CoordinatorMessageType } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import { NotImplementedError } from './chunk-
|
|
1
|
+
import { onEnvelope, EnvelopeKind, CoordinatorMessageType } from './chunk-QQSI3ZD7.js';
|
|
2
|
+
import './chunk-V5HXJRBW.js';
|
|
3
|
+
import { NotImplementedError } from './chunk-GHBQF3A7.js';
|
|
4
4
|
import './chunk-VR6T6OJS.js';
|
|
5
5
|
|
|
6
6
|
// src/events/index.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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,
|
|
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';
|
|
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, b as CoordinatorReleasePin } from './types.generated-
|
|
7
|
-
export { A as AzureMaaPin,
|
|
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
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The API surface version this build implements. Bumped only on a breaking
|
|
@@ -159,6 +159,7 @@ declare function noiseWebSocketTransport(options: NoiseWebSocketTransportOptions
|
|
|
159
159
|
* @module JW-145 / JW-431
|
|
160
160
|
*/
|
|
161
161
|
type AttestationMode = "dev" | "prod";
|
|
162
|
+
type CoordinatorRuntimeProfile = "prod-hardened" | "prod-devnet-simplified";
|
|
162
163
|
type AzureMaaPolicy = {
|
|
163
164
|
/** Expected MAA token issuer for the approved Azure Attestation provider. */
|
|
164
165
|
expectedIssuer: string;
|
|
@@ -179,6 +180,8 @@ type AttestationPolicy = {
|
|
|
179
180
|
* response metadata, even though the TPM quote binds it cryptographically.
|
|
180
181
|
*/
|
|
181
182
|
expectedBinaryHash?: string;
|
|
183
|
+
/** Expected compile-time runtime profile carried by the approved artifact. */
|
|
184
|
+
expectedRuntimeProfile?: CoordinatorRuntimeProfile;
|
|
182
185
|
/**
|
|
183
186
|
* Runtime mode the client expects for this coordinator route. Production
|
|
184
187
|
* builds set this to "prod" so a prod hostname cannot silently accept an
|
|
@@ -239,6 +242,7 @@ type DcapCollateral = {
|
|
|
239
242
|
type AttestedMetadata = {
|
|
240
243
|
mode: AttestationMode;
|
|
241
244
|
binaryHash: string;
|
|
245
|
+
runtimeProfile?: CoordinatorRuntimeProfile;
|
|
242
246
|
mrtd: string;
|
|
243
247
|
rtmr0: string;
|
|
244
248
|
rtmr1: string;
|
|
@@ -258,6 +262,8 @@ type AttestResponse = {
|
|
|
258
262
|
pubkey: string;
|
|
259
263
|
binary_hash: string;
|
|
260
264
|
mode: AttestationMode;
|
|
265
|
+
/** Compile-time runtime profile embedded in the coordinator artifact. */
|
|
266
|
+
runtime_profile?: CoordinatorRuntimeProfile;
|
|
261
267
|
/**
|
|
262
268
|
* Platform identifier set by the coordinator. Absent on GCP (tdx-dcap).
|
|
263
269
|
* Azure returns "azure-tdx-dcap".
|
|
@@ -384,6 +390,8 @@ interface AttestationResult {
|
|
|
384
390
|
readonly mode: "prod" | "dev";
|
|
385
391
|
/** Coordinator binary hash reported by the verified attestation response. */
|
|
386
392
|
readonly binaryHash: string;
|
|
393
|
+
/** Compile-time runtime profile carried by the attested coordinator artifact. */
|
|
394
|
+
readonly runtimeProfile?: "prod-hardened" | "prod-devnet-simplified";
|
|
387
395
|
/** Noise static public key bound into the attestation quote. */
|
|
388
396
|
readonly pubkeyHex: string;
|
|
389
397
|
/** True only for explicit loopback local development attestation. */
|
|
@@ -413,6 +421,54 @@ declare function performNoiseHandshake(transport: Transport, endpoint: Coordinat
|
|
|
413
421
|
*/
|
|
414
422
|
declare function performAttestation(_transport: Transport, handshake: NoiseHandshakeResult): Promise<AttestationResult>;
|
|
415
423
|
|
|
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;
|
|
459
|
+
}
|
|
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
|
+
|
|
416
472
|
/**
|
|
417
473
|
* Session guards used by mutating commands.
|
|
418
474
|
*/
|
|
@@ -496,4 +552,4 @@ declare const coordinator: {
|
|
|
496
552
|
forceFailover(_session: Session): Promise<void>;
|
|
497
553
|
};
|
|
498
554
|
|
|
499
|
-
export { type ApiVersion, type AttestResponse, type AttestationMode, type AttestationPolicy, type AttestationResult, type AzureMaaPolicy, type Brand, CoordinatorEndpoint, CoordinatorReleasePin, type CoordinatorVersion, type ExponentialBackoff, type ExponentialBackoffOptions, type Hex, type Lamports, type NoiseHandshakeResult, NoiseWebSocketTransportOptions, type PublicKey, type RequestId, Session, Transport, Unsubscribe, apiVersion, assertAttestResponse, assertAttested, attestation, coordinator, createExponentialBackoff, hex, inMemoryTransport, lamports, noiseWebSocketTransport, performAttestation, performNoiseHandshake, publicKey, requestId, verifyAttestation };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createStateController, reattestSerialized } from './chunk-
|
|
2
|
-
export { closeSession, createExponentialBackoff, createSession, noiseWebSocketTransport, performAttestation, performNoiseHandshake } from './chunk-
|
|
3
|
-
export { assertAttested, hex, lamports, publicKey, requestId } from './chunk-
|
|
4
|
-
import { getSessionState, failSessionClosed } from './chunk-
|
|
5
|
-
export { assertAttestResponse, verifyAttestation } from './chunk-
|
|
6
|
-
import { TransportError, NotImplementedError } from './chunk-
|
|
7
|
-
export { AttestationError, CommandError, InvalidDepositAmountError, InvisibleError, LpLifecycleError, NotImplementedError, PolicyValidationError, RoutingError, StorageError, TransportError, WalletError, isInvisibleError, normalizeError } from './chunk-
|
|
1
|
+
import { createStateController, reattestSerialized } from './chunk-BWCGNTN5.js';
|
|
2
|
+
export { closeSession, createExponentialBackoff, createSession, noiseWebSocketTransport, performAttestation, performNoiseHandshake } from './chunk-BWCGNTN5.js';
|
|
3
|
+
export { assertAttested, hex, lamports, publicKey, requestId } from './chunk-NHEHCUS5.js';
|
|
4
|
+
import { getSessionState, failSessionClosed } from './chunk-V5HXJRBW.js';
|
|
5
|
+
export { assertAttestResponse, verifyAttestation } from './chunk-DIA6U2CV.js';
|
|
6
|
+
import { TransportError, NotImplementedError } from './chunk-GHBQF3A7.js';
|
|
7
|
+
export { AttestationError, CommandError, InvalidDepositAmountError, InvisibleError, LpLifecycleError, NotImplementedError, PolicyValidationError, RoutingError, StorageError, TransportError, WalletError, isInvisibleError, normalizeError } from './chunk-GHBQF3A7.js';
|
|
8
8
|
import './chunk-VR6T6OJS.js';
|
|
9
9
|
|
|
10
10
|
// src/core/version.ts
|
package/dist/lp.d.ts
CHANGED
|
@@ -148,6 +148,9 @@ type LpDkgClient = {
|
|
|
148
148
|
}, auth: LpPositionCodeAuth): Promise<{
|
|
149
149
|
sessionId: string;
|
|
150
150
|
}>;
|
|
151
|
+
abortDkgSessions(lpPositionId: string, auth: LpPositionCodeAuth): Promise<{
|
|
152
|
+
abortedSessionCount: number;
|
|
153
|
+
}>;
|
|
151
154
|
dkgRound1(input: {
|
|
152
155
|
sessionId: string;
|
|
153
156
|
package: number[];
|
|
@@ -342,6 +345,7 @@ declare function createLpLifecycleClient(session: Session, runtime?: LpLifecycle
|
|
|
342
345
|
declare function defaultLpLifecycleClient(session: Session): LpLifecycleClient;
|
|
343
346
|
|
|
344
347
|
declare const LP_COMMAND_REQUEST_TIMEOUT_MS = 120000;
|
|
348
|
+
declare const LP_DKG_ABORT_REQUEST_TIMEOUT_MS = 10000;
|
|
345
349
|
declare function createLpCoordinatorClient(session: Session): LpCoordinatorClient;
|
|
346
350
|
|
|
347
351
|
type LpDkgProgress = {
|
|
@@ -360,6 +364,9 @@ type CreateLpDkgBatchInput = {
|
|
|
360
364
|
useDeterministicTestAddresses?: boolean;
|
|
361
365
|
onProgress?: (progress: LpDkgProgress) => void;
|
|
362
366
|
};
|
|
367
|
+
declare const LP_DKG_WORKER_REQUEST_TIMEOUT_MS = 30000;
|
|
368
|
+
declare const LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE = "LP DKG worker request timed out";
|
|
369
|
+
declare const LP_DKG_ABORT_CLEANUP_TIMEOUT_MS = 10000;
|
|
363
370
|
declare function createLpDkgBatch(input: CreateLpDkgBatchInput): Promise<string[]>;
|
|
364
371
|
|
|
365
372
|
declare function createPosition(session: Session, args?: CreatePositionArgs): Promise<CreatePositionResult>;
|
|
@@ -385,4 +392,4 @@ declare function withdrawFees(session: Session, positionId: string, args: {
|
|
|
385
392
|
}): Promise<never>;
|
|
386
393
|
declare function listPositions(session: Session): Promise<LpPositionView[]>;
|
|
387
394
|
|
|
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 };
|
|
395
|
+
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_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 };
|