@invisible-labs/sdk 0.6.0-devnet.2 → 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 +131 -72
- 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 +7 -4
- 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
package/dist/presets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CoordinatorEndpoint } from './types.generated-
|
|
1
|
+
import { C as CoordinatorEndpoint } from './types.generated-BSEBz4jR.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* `@invisible-labs/sdk/presets` - optional Invisible coordinator endpoint presets.
|
|
@@ -21,7 +21,7 @@ import { C as CoordinatorEndpoint } from './types.generated-CHGSbmLp.js';
|
|
|
21
21
|
* on GCP.
|
|
22
22
|
*/
|
|
23
23
|
declare function invisibleProdGcp(): CoordinatorEndpoint[];
|
|
24
|
-
/** Production Azure TDX coordinator endpoint
|
|
24
|
+
/** Production Azure TDX coordinator endpoint for the current prod/devnet release. */
|
|
25
25
|
declare function invisibleProdAzure(approvedBinaryHash: string): CoordinatorEndpoint[];
|
|
26
26
|
/**
|
|
27
27
|
* The currently-active Invisible production preset. Integrators that just want
|
|
@@ -31,7 +31,7 @@ declare function invisibleProdAzure(approvedBinaryHash: string): CoordinatorEndp
|
|
|
31
31
|
* `export const invisibleProd = invisibleProdAzure` -> `invisibleProdGcp`.
|
|
32
32
|
*/
|
|
33
33
|
declare const invisibleProd: typeof invisibleProdAzure;
|
|
34
|
-
/** Public Invisible devnet, served by the
|
|
34
|
+
/** Public Invisible devnet, served by the simplified Azure prod coordinator. */
|
|
35
35
|
declare const invisibleDevnet: typeof invisibleProdAzure;
|
|
36
36
|
/** Dormant GCP development coordinator endpoint. Not the active dev target today. */
|
|
37
37
|
declare function invisibleDevGcp(): CoordinatorEndpoint[];
|
package/dist/presets.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256 } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256 } from './chunk-DIA6U2CV.js';
|
|
2
|
+
import './chunk-GHBQF3A7.js';
|
|
3
3
|
import './chunk-VR6T6OJS.js';
|
|
4
4
|
|
|
5
|
+
// src/presets/azure-prod-maa.generated.ts
|
|
6
|
+
var AZURE_PROD_MAA_TRUST = {
|
|
7
|
+
issuer: "https://sharedweu.weu.attest.azure.net",
|
|
8
|
+
jwksUrl: "https://sharedweu.weu.attest.azure.net/certs",
|
|
9
|
+
policyHash: "9NY0VnTQ-IiBriBplVUpFbczcDaEBUwsiFYAzHu_gco"};
|
|
10
|
+
|
|
5
11
|
// src/presets/index.ts
|
|
6
12
|
var PLACEHOLDER_PIN = {
|
|
7
13
|
mrtd: "",
|
|
@@ -9,12 +15,13 @@ var PLACEHOLDER_PIN = {
|
|
|
9
15
|
};
|
|
10
16
|
var BINARY_HASH_HEX = /^[0-9a-f]{64}$/i;
|
|
11
17
|
var AZURE_PROD_RELEASE_PIN = {
|
|
12
|
-
mrtd: "
|
|
18
|
+
mrtd: "a2e61f1316e9e367e9c1f7a0adc98c48eb13875c399c85d286cee5ea2b05e57f2df9f61d903b0ae7ac5607d843dfffc1",
|
|
19
|
+
runtimeProfile: "prod-devnet-simplified",
|
|
13
20
|
intelRootFingerprint: INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256,
|
|
14
21
|
azureMaa: {
|
|
15
|
-
issuer:
|
|
16
|
-
jwksUrl:
|
|
17
|
-
policyHash:
|
|
22
|
+
issuer: AZURE_PROD_MAA_TRUST.issuer,
|
|
23
|
+
jwksUrl: AZURE_PROD_MAA_TRUST.jwksUrl,
|
|
24
|
+
policyHash: AZURE_PROD_MAA_TRUST.policyHash
|
|
18
25
|
}
|
|
19
26
|
};
|
|
20
27
|
function invisibleProdGcp() {
|
package/dist/presets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/presets/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/presets/azure-prod-maa.generated.ts","../src/presets/index.ts"],"names":[],"mappings":";;;;;AACO,IAAM,oBAAA,GAAuB;AAAA,EAClC,MAAA,EAAQ,wCAAA;AAAA,EACR,OAAA,EAAS,8CAAA;AAAA,EACT,UAAA,EAAY,6CAEd,CAAA;;;ACWA,IAAM,eAAA,GAAkB;AAAA,EACtB,IAAA,EAAM,EAAA;AAAA,EACN,oBAAA,EAAsB;AACxB,CAAA;AAEA,IAAM,eAAA,GAAkB,iBAAA;AAExB,IAAM,sBAAA,GAAyB;AAAA,EAC7B,IAAA,EAAM,kGAAA;AAAA,EACN,cAAA,EAAgB,wBAAA;AAAA,EAChB,oBAAA,EAAsB,oCAAA;AAAA,EACtB,QAAA,EAAU;AAAA,IACR,QAAQ,oBAAA,CAAqB,MAAA;AAAA,IAC7B,SAAS,oBAAA,CAAqB,OAAA;AAAA,IAC9B,YAAY,oBAAA,CAAqB;AAAA;AAErC,CAAA;AASO,SAAS,gBAAA,GAA0C;AACxD,EAAA,OAAO;AAAA,IACL;AAAA,MACE,KAAA,EAAO,uCAAA;AAAA,MACP,gBAAA,EAAkB,wBAAA;AAAA,MAClB,UAAA,EAAY,EAAE,GAAG,eAAA,EAAgB;AAAA,MACjC,YAAA,EAAc;AAAA;AAChB,GACF;AACF;AAGO,SAAS,mBAAmB,kBAAA,EAAmD;AACpF,EAAA,MAAM,aAAa,OAAO,kBAAA,KAAuB,QAAA,GAAW,kBAAA,CAAmB,aAAY,GAAI,EAAA;AAC/F,EAAA,IAAI,CAAC,eAAA,CAAgB,IAAA,CAAK,UAAU,CAAA,EAAG;AACrC,IAAA,MAAM,IAAI,MAAM,0EAA0E,CAAA;AAAA,EAC5F;AACA,EAAA,OAAO;AAAA,IACL;AAAA,MACE,KAAA,EAAO,6CAAA;AAAA,MACP,gBAAA,EAAkB,8BAAA;AAAA,MAClB,UAAA,EAAY,EAAE,GAAG,sBAAA,EAAwB,UAAA,EAAW;AAAA,MACpD,YAAA,EAAc;AAAA;AAChB,GACF;AACF;AASO,IAAM,aAAA,GAAgB;AAGtB,IAAM,eAAA,GAAkB;AAGxB,SAAS,eAAA,GAAyC;AACvD,EAAA,OAAO;AAAA,IACL;AAAA,MACE,KAAA,EAAO,2CAAA;AAAA,MACP,gBAAA,EAAkB,4BAAA;AAAA,MAClB,UAAA,EAAY,EAAE,GAAG,eAAA,EAAgB;AAAA,MACjC,YAAA,EAAc;AAAA;AAChB,GACF;AACF;AAGO,SAAS,iBAAA,GAA2C;AACzD,EAAA,OAAO;AAAA,IACL;AAAA,MACE,KAAA,EAAO,iDAAA;AAAA,MACP,gBAAA,EAAkB,kCAAA;AAAA,MAClB,UAAA,EAAY,EAAE,GAAG,eAAA,EAAgB;AAAA,MACjC,YAAA,EAAc;AAAA;AAChB,GACF;AACF;AAGO,IAAM,YAAA,GAAe","file":"presets.js","sourcesContent":["// Generated by npm run release:trust-policy:generate-sdk. Do not edit.\nexport const AZURE_PROD_MAA_TRUST = {\n issuer: \"https://sharedweu.weu.attest.azure.net\",\n jwksUrl: \"https://sharedweu.weu.attest.azure.net/certs\",\n policyHash: \"9NY0VnTQ-IiBriBplVUpFbczcDaEBUwsiFYAzHu_gco\",\n trustSetVersion: \"azure-prod-maa-v1\",\n} as const;\n","/**\n * `@invisible-labs/sdk/presets` - optional Invisible coordinator endpoint presets.\n *\n * This is the ONLY module permitted to name an `invisible.exchange` host (spec\n * section 6.2). Partners who self-host ignore it entirely and pass their own\n * `CoordinatorEndpoint[]` to `createSession`. The core never imports this module.\n *\n * Production presets embed an approved Azure TDX boot measurement and trust\n * roots. The caller must provide the separately approved coordinator binary\n * hash before a production endpoint can be constructed. Dormant or\n * development targets keep placeholders until approval.\n */\n\nimport { INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256 } from \"../attestation/verifier.js\";\nimport type { CoordinatorEndpoint } from \"../schemas/types.generated.js\";\nimport { AZURE_PROD_MAA_TRUST } from \"./azure-prod-maa.generated.js\";\n\nconst PLACEHOLDER_PIN = {\n mrtd: \"\",\n intelRootFingerprint: \"\",\n} as const;\n\nconst BINARY_HASH_HEX = /^[0-9a-f]{64}$/i;\n\nconst AZURE_PROD_RELEASE_PIN = {\n mrtd: \"a2e61f1316e9e367e9c1f7a0adc98c48eb13875c399c85d286cee5ea2b05e57f2df9f61d903b0ae7ac5607d843dfffc1\",\n runtimeProfile: \"prod-devnet-simplified\",\n intelRootFingerprint: INTEL_SGX_ROOT_CA_FINGERPRINT_SHA256,\n azureMaa: {\n issuer: AZURE_PROD_MAA_TRUST.issuer,\n jwksUrl: AZURE_PROD_MAA_TRUST.jwksUrl,\n policyHash: AZURE_PROD_MAA_TRUST.policyHash,\n },\n} as const;\n\n/**\n * Production GCP TDX coordinator endpoint.\n *\n * Currently dormant: GCP is neither the live production nor development TEE\n * path. Kept only for a future explicit GCP relight, or a partner self-hosting\n * on GCP.\n */\nexport function invisibleProdGcp(): CoordinatorEndpoint[] {\n return [\n {\n wsUrl: \"wss://tee.invisible.exchange/ws-noise\",\n expectedHostname: \"tee.invisible.exchange\",\n releasePin: { ...PLACEHOLDER_PIN },\n requiredMode: \"prod\",\n },\n ];\n}\n\n/** Production Azure TDX coordinator endpoint for the current prod/devnet release. */\nexport function invisibleProdAzure(approvedBinaryHash: string): CoordinatorEndpoint[] {\n const binaryHash = typeof approvedBinaryHash === \"string\" ? approvedBinaryHash.toLowerCase() : \"\";\n if (!BINARY_HASH_HEX.test(binaryHash)) {\n throw new Error(\"invisibleProdAzure requires an approved 64-character binary SHA-256 hash\");\n }\n return [\n {\n wsUrl: \"wss://tee-azure.invisible.exchange/ws-noise\",\n expectedHostname: \"tee-azure.invisible.exchange\",\n releasePin: { ...AZURE_PROD_RELEASE_PIN, binaryHash },\n requiredMode: \"prod\",\n },\n ];\n}\n\n/**\n * The currently-active Invisible production preset. Integrators that just want\n * \"Invisible prod\" use this and stay on whichever cloud is live.\n *\n * Switching the prod target between Azure and GCP is this one line:\n * `export const invisibleProd = invisibleProdAzure` -> `invisibleProdGcp`.\n */\nexport const invisibleProd = invisibleProdAzure;\n\n/** Public Invisible devnet, served by the simplified Azure prod coordinator. */\nexport const invisibleDevnet = invisibleProdAzure;\n\n/** Dormant GCP development coordinator endpoint. Not the active dev target today. */\nexport function invisibleDevGcp(): CoordinatorEndpoint[] {\n return [\n {\n wsUrl: \"wss://tee-dev.invisible.exchange/ws-noise\",\n expectedHostname: \"tee-dev.invisible.exchange\",\n releasePin: { ...PLACEHOLDER_PIN },\n requiredMode: \"dev\",\n },\n ];\n}\n\n/** Azure development coordinator endpoint. The active dev TEE today. */\nexport function invisibleDevAzure(): CoordinatorEndpoint[] {\n return [\n {\n wsUrl: \"wss://tee-azure-dev.invisible.exchange/ws-noise\",\n expectedHostname: \"tee-azure-dev.invisible.exchange\",\n releasePin: { ...PLACEHOLDER_PIN },\n requiredMode: \"dev\",\n },\n ];\n}\n\n/** The currently-active Invisible development preset. */\nexport const invisibleDev = invisibleDevAzure;\n"]}
|
package/dist/stats.js
CHANGED
package/dist/storage.js
CHANGED
|
@@ -10,6 +10,7 @@ type CoordinatorEndpoint = {
|
|
|
10
10
|
type CoordinatorReleasePin = {
|
|
11
11
|
readonly mrtd: string;
|
|
12
12
|
readonly binaryHash?: string;
|
|
13
|
+
readonly runtimeProfile?: "prod-hardened" | "prod-devnet-simplified";
|
|
13
14
|
readonly intelRootFingerprint?: string;
|
|
14
15
|
readonly allowMissingDcapCollateral?: boolean;
|
|
15
16
|
readonly azureMaa?: AzureMaaPin;
|
package/dist/user.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { S as Session } from './session-DFuy54C-.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { I as InvalidDepositAmountError } from './createSession-D3ym-Ira.js';
|
|
5
|
-
import './types-ZhV7TIQY.js';
|
|
2
|
+
import { P as PayoutPolicy } from './types.generated-BSEBz4jR.js';
|
|
3
|
+
export { I as InvalidDepositAmountError } from './errors-N2touVm4.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Acceptance receipts (spec section 8.2).
|
|
@@ -21,15 +19,6 @@ interface AcceptanceReceipt {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
type ClientSwapState = "new" | "awaiting_dkg" | "awaiting_deposit" | "awaiting_delegation" | "awaiting_delegate_ack" | "awaiting_delegate_ack_after_deposit" | "ready_for_settlement" | "settling" | "completed" | "refunded" | "failed";
|
|
24
|
-
type PayoutSpec = {
|
|
25
|
-
readonly mode: "instant";
|
|
26
|
-
readonly destination_address: string;
|
|
27
|
-
} | {
|
|
28
|
-
readonly mode: "scheduled";
|
|
29
|
-
readonly num_fragments: number;
|
|
30
|
-
readonly window_seconds: number;
|
|
31
|
-
readonly destination_addresses: readonly string[];
|
|
32
|
-
};
|
|
33
22
|
type SpendingPolicySnapshot = {
|
|
34
23
|
readonly asset: "SOL";
|
|
35
24
|
readonly entry_amount_lamports: number;
|
|
@@ -110,40 +99,22 @@ type SyncUserResponsePayload = {
|
|
|
110
99
|
readonly withdraw_execution?: RefundExecutedPayload;
|
|
111
100
|
readonly actor_sync?: NormalUserActorSyncSnapshot;
|
|
112
101
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Actor-scoped sync response plus the coordinator clock used to produce it.
|
|
104
|
+
* The timestamp is envelope metadata, not part of the wire payload.
|
|
105
|
+
*/
|
|
106
|
+
type SyncUserResponse = SyncUserResponsePayload & {
|
|
107
|
+
readonly coordinatorTimestampMs: number;
|
|
118
108
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
secretHex: string;
|
|
128
|
-
}) => void | Promise<void>;
|
|
129
|
-
onRecoveryCodeReady?: (info: {
|
|
130
|
-
codeHex: string;
|
|
131
|
-
}) => void | Promise<void>;
|
|
132
|
-
delegateShare?: Uint8Array;
|
|
133
|
-
onDepositAddressReady?: (info: {
|
|
134
|
-
swapId: string;
|
|
135
|
-
jointPublicKey: Uint8Array;
|
|
136
|
-
amountLamports: number;
|
|
137
|
-
depositExpiresAtMs: number;
|
|
138
|
-
coordinatorTimestampMs: number;
|
|
139
|
-
}) => void | Promise<void>;
|
|
140
|
-
onDepositConfirmed?: (info: {
|
|
141
|
-
originAddress: string | undefined;
|
|
142
|
-
}) => void | Promise<void>;
|
|
143
|
-
payoutWindowMs?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Acceptance receipt for a normal-user refund, including the coordinator's
|
|
111
|
+
* authoritative amount claim. The timestamp is absent when the coordinator
|
|
112
|
+
* reports that the request already executed before the client received it.
|
|
113
|
+
*/
|
|
114
|
+
type RefundAcceptanceReceipt = AcceptanceReceipt & {
|
|
115
|
+
readonly amountLamports: number;
|
|
116
|
+
readonly acceptedAtMs?: number;
|
|
144
117
|
};
|
|
145
|
-
/** Parameters for the pre-deposit portion of a normal-user contract flow. */
|
|
146
|
-
type ContractRequestParams = Omit<RunSwapParams, "onDepositConfirmed">;
|
|
147
118
|
/**
|
|
148
119
|
* Details returned once the coordinator has accepted, initialized, and
|
|
149
120
|
* durably delegated a contract, but before the user's deposit is observed.
|
|
@@ -168,71 +139,6 @@ type ContractRequestResult = {
|
|
|
168
139
|
readonly policySnapshot: SpendingPolicySnapshot;
|
|
169
140
|
readonly delegatePolicySnapshot: SpendingPolicySnapshot;
|
|
170
141
|
};
|
|
171
|
-
type SwapResult = {
|
|
172
|
-
swapId: string;
|
|
173
|
-
jointPublicKey: Uint8Array;
|
|
174
|
-
depositTxSignature: string;
|
|
175
|
-
depositObservedAtMs: number;
|
|
176
|
-
delegatedAtMs: number;
|
|
177
|
-
recoveryCodeHex?: string;
|
|
178
|
-
policySnapshot: SpendingPolicySnapshot;
|
|
179
|
-
delegatePolicySnapshot: SpendingPolicySnapshot;
|
|
180
|
-
};
|
|
181
|
-
type RefundIntentResult = {
|
|
182
|
-
readonly kind: "executed";
|
|
183
|
-
readonly refund: RefundExecutedPayload;
|
|
184
|
-
} | {
|
|
185
|
-
readonly kind: "accepted";
|
|
186
|
-
readonly accepted: WithdrawAcceptedPayload;
|
|
187
|
-
};
|
|
188
|
-
type SessionStatus = "idle" | "connecting" | "running" | "done" | "failed";
|
|
189
|
-
type CoordinatorSessionOptions = {
|
|
190
|
-
coordinator: CoordinatorPoolConfig;
|
|
191
|
-
createSession?: (options: CreateSessionOptions) => Promise<Session>;
|
|
192
|
-
};
|
|
193
|
-
type StateChangeListener = (swapState: ClientSwapState, sessionStatus: SessionStatus) => void;
|
|
194
|
-
type LogListener = (msg: string, direction: "in" | "out" | "info") => void;
|
|
195
|
-
type PayoutExecutedListener = (payload: PayoutExecutedPayload, swapId: string) => void;
|
|
196
|
-
type RefundExecutedListener = (payload: RefundExecutedPayload, swapId: string) => void;
|
|
197
|
-
type NormalUserActorSyncListener = (payload: NormalUserActorSyncSnapshot, coordinatorTimestampMs: number) => void;
|
|
198
|
-
type CoordinatorProtocolError = Error & {
|
|
199
|
-
readonly code: string;
|
|
200
|
-
readonly failedReqId?: number;
|
|
201
|
-
};
|
|
202
|
-
type CoordinatorErrorListener = (err: CoordinatorProtocolError) => void;
|
|
203
|
-
type CoordinatorSessionHandle = {
|
|
204
|
-
onStateChange(listener: StateChangeListener): () => void;
|
|
205
|
-
onLog(listener: LogListener): () => void;
|
|
206
|
-
onPayoutExecuted(listener: PayoutExecutedListener): () => void;
|
|
207
|
-
onRefundExecuted(listener: RefundExecutedListener): () => void;
|
|
208
|
-
onNormalUserActorSync(listener: NormalUserActorSyncListener): () => void;
|
|
209
|
-
onCoordinatorError(listener: CoordinatorErrorListener): () => void;
|
|
210
|
-
readonly currentSwapState: ClientSwapState;
|
|
211
|
-
readonly currentSessionStatus: SessionStatus;
|
|
212
|
-
runSwap(params: RunSwapParams): Promise<SwapResult>;
|
|
213
|
-
contractRequest(params: ContractRequestParams): Promise<ContractRequestResult>;
|
|
214
|
-
close(): void;
|
|
215
|
-
restoreSwapContext(params: {
|
|
216
|
-
swapId: string;
|
|
217
|
-
syncSecret?: Uint8Array;
|
|
218
|
-
}): void;
|
|
219
|
-
requestSwapStatus(timeoutMs?: number): Promise<SyncUserResponsePayload>;
|
|
220
|
-
startSwapStatusReconciliation(intervalMs?: number): () => void;
|
|
221
|
-
requestRefund(params: {
|
|
222
|
-
swapId?: string;
|
|
223
|
-
syncSecret?: Uint8Array;
|
|
224
|
-
recoveryCode: Uint8Array;
|
|
225
|
-
timeoutMs?: number;
|
|
226
|
-
}): Promise<RefundExecutedPayload>;
|
|
227
|
-
requestRefundIntent(params: {
|
|
228
|
-
swapId?: string;
|
|
229
|
-
syncSecret?: Uint8Array;
|
|
230
|
-
recoveryCode: Uint8Array;
|
|
231
|
-
timeoutMs?: number;
|
|
232
|
-
}): Promise<RefundIntentResult>;
|
|
233
|
-
};
|
|
234
|
-
declare function createCoordinatorSession(options: CoordinatorSessionOptions): CoordinatorSessionHandle;
|
|
235
|
-
declare function isBenignTransportDrop(err: unknown): boolean;
|
|
236
142
|
|
|
237
143
|
/**
|
|
238
144
|
* Payout policy validation (spec sections 4.3.1 and 10.1).
|
|
@@ -269,13 +175,12 @@ declare function recoveryCodeFromUserInput(input: string): Uint8Array;
|
|
|
269
175
|
/**
|
|
270
176
|
* `@invisible-labs/sdk/user` - normal-user (private transfer) commands (spec 4.3).
|
|
271
177
|
*
|
|
272
|
-
* The
|
|
273
|
-
*
|
|
274
|
-
* must not pull in `/lp`, `/stats`, or `/events`.
|
|
178
|
+
* The normal-user API is functional and operates on the caller-owned attested
|
|
179
|
+
* Session. Importing this module must not pull in `/lp`, `/stats`, or `/events`.
|
|
275
180
|
*/
|
|
276
181
|
|
|
277
182
|
/** Inclusive minimum private-transfer entry amount in lamports. */
|
|
278
|
-
declare const MIN_ENTRY_AMOUNT_LAMPORTS =
|
|
183
|
+
declare const MIN_ENTRY_AMOUNT_LAMPORTS = 1500000000;
|
|
279
184
|
/** Inclusive maximum private-transfer entry amount in lamports. */
|
|
280
185
|
declare const MAX_ENTRY_AMOUNT_LAMPORTS = 100000000000;
|
|
281
186
|
/** Arguments to start a new private-transfer pool entry. */
|
|
@@ -287,6 +192,8 @@ interface ContractRequestArgs {
|
|
|
287
192
|
* to observe at the fundable deposit address and hold in the joint wallet.
|
|
288
193
|
* It is the custody-side amount before protocol and network-fee accounting,
|
|
289
194
|
* not the net amount a payout destination receives.
|
|
195
|
+
* The value must be a safe integer between {@link MIN_ENTRY_AMOUNT_LAMPORTS}
|
|
196
|
+
* and {@link MAX_ENTRY_AMOUNT_LAMPORTS}, inclusive.
|
|
290
197
|
*/
|
|
291
198
|
readonly amountLamports: number;
|
|
292
199
|
/**
|
|
@@ -301,11 +208,6 @@ interface ContractRequestArgs {
|
|
|
301
208
|
* `SUPPORTED_TOTAL_DEADLINE_MS`.
|
|
302
209
|
*/
|
|
303
210
|
readonly payoutPolicy: PayoutPolicy;
|
|
304
|
-
/**
|
|
305
|
-
* Retained for API compatibility. The current wire contract always commits a
|
|
306
|
-
* sync secret because status reads are keyed by that commitment.
|
|
307
|
-
*/
|
|
308
|
-
readonly sync?: boolean;
|
|
309
211
|
/** Optional caller-owned status secret, copied before it reaches the wire. */
|
|
310
212
|
readonly syncSecret?: Uint8Array;
|
|
311
213
|
/** Called before ContractRequest so the caller can persist the status secret. */
|
|
@@ -334,7 +236,7 @@ interface ContractRequestArgs {
|
|
|
334
236
|
*/
|
|
335
237
|
declare function contractRequest(session: Session, args: ContractRequestArgs): Promise<ContractRequestResult>;
|
|
336
238
|
/** Read the actor-scoped lifecycle projection for a normal-user contract. */
|
|
337
|
-
declare function sync(session: Session, contractId: string, syncSecret: Uint8Array, timeoutMs?: number): Promise<
|
|
239
|
+
declare function sync(session: Session, contractId: string, syncSecret: Uint8Array, timeoutMs?: number): Promise<SyncUserResponse>;
|
|
338
240
|
/** Arguments to refund a pool entry with the Recovery Code preimage. */
|
|
339
241
|
interface RequestRefundArgs {
|
|
340
242
|
/** The 32-byte Recovery Code preimage. */
|
|
@@ -346,32 +248,13 @@ interface RequestRefundArgs {
|
|
|
346
248
|
* withdrawal intent and terminal outcome is recovered through sync/status
|
|
347
249
|
* reads. No caller-supplied destination is accepted.
|
|
348
250
|
*
|
|
349
|
-
* @returns An acceptance receipt keyed by the resolved V0 `swapId
|
|
251
|
+
* @returns An acceptance receipt keyed by the resolved V0 `swapId`, including
|
|
252
|
+
* the coordinator-authoritative amount accepted for withdrawal. The
|
|
350
253
|
* coordinator's durable execution result is read later through `sync`.
|
|
351
254
|
* @throws AttestationError if the session is not attested.
|
|
352
255
|
* @throws PolicyValidationError if `recoveryCode` is not exactly 32 bytes.
|
|
353
256
|
* @throws CommandError if the coordinator rejects the withdrawal request.
|
|
354
257
|
*/
|
|
355
|
-
declare function requestRefund(session: Session, args: RequestRefundArgs): Promise<
|
|
356
|
-
/**
|
|
357
|
-
* Read the fundable deposit address for a request once the sealed contract
|
|
358
|
-
* exposes it (`sync`).
|
|
359
|
-
*
|
|
360
|
-
* @throws NotImplementedError - read execution is deferred.
|
|
361
|
-
*/
|
|
362
|
-
declare function getDepositAddress(_session: Session, _requestId: string, _syncSecret: Uint8Array): Promise<string>;
|
|
363
|
-
/**
|
|
364
|
-
* Subscribe to live sync messages for a request.
|
|
365
|
-
*
|
|
366
|
-
* @throws NotImplementedError - subscriptions are deferred.
|
|
367
|
-
*/
|
|
368
|
-
declare function subscribe(_session: Session, _requestId: string, _syncSecret: Uint8Array, _handler: (event: unknown) => void): never;
|
|
369
|
-
/**
|
|
370
|
-
* Recover open requests after a tab close or restart by replaying the storage
|
|
371
|
-
* adapter and re-subscribing.
|
|
372
|
-
*
|
|
373
|
-
* @throws NotImplementedError - replay is deferred.
|
|
374
|
-
*/
|
|
375
|
-
declare function replayFromStorage(_session: Session, _storage: unknown): Promise<void>;
|
|
258
|
+
declare function requestRefund(session: Session, args: RequestRefundArgs): Promise<RefundAcceptanceReceipt>;
|
|
376
259
|
|
|
377
|
-
export { type
|
|
260
|
+
export { type ContractRequestArgs, type ContractRequestResult, INSTANT_PAYOUT_WINDOW_MS, MAX_ENTRY_AMOUNT_LAMPORTS, MIN_ENTRY_AMOUNT_LAMPORTS, type NormalUserActorSyncSnapshot, type NormalUserRefundability, type NormalUserSettlementPhase, PAYOUT_WINDOW_MILLISECONDS_PER_SECOND, type PayoutExecutedPayload, RECOVERY_CODE_BYTE_LENGTH, type RefundAcceptanceReceipt, type RefundExecutedPayload, type RequestRefundArgs, SUPPORTED_TOTAL_DEADLINE_MS, type SourceLiquidityUse, type SpendingPolicySnapshot, type SyncUserResponse, type SyncUserResponsePayload, type WithdrawExecutedPayload, commitmentFromCode, contractRequest, generateRecoveryCode, recoveryCodeFromHex, recoveryCodeFromUserInput, recoveryCodeToHex, requestRefund, sync };
|
package/dist/user.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { scheduledPayoutWindowSeconds } from './chunk-
|
|
2
|
-
import {
|
|
3
|
-
import { PRODUCT_MAX_ENTRY_LAMPORTS, PRODUCT_MIN_ENTRY_LAMPORTS } from './chunk-
|
|
4
|
-
import {
|
|
5
|
-
import { CoordinatorMessageType, onEnvelope, closeProtocolRuntime, EnvelopeKind
|
|
6
|
-
import { getSessionState } from './chunk-
|
|
7
|
-
import './chunk-
|
|
8
|
-
import {
|
|
9
|
-
export { InvalidDepositAmountError } from './chunk-
|
|
1
|
+
import { scheduledPayoutWindowSeconds } from './chunk-NKRVQXRP.js';
|
|
2
|
+
import { validatePayoutPolicyShape, formatAjvErrors, createSession, createExponentialBackoff } from './chunk-BWCGNTN5.js';
|
|
3
|
+
import { PRODUCT_MAX_ENTRY_LAMPORTS, PRODUCT_MIN_ENTRY_LAMPORTS } from './chunk-4X5OCCQW.js';
|
|
4
|
+
import { assertAttested, publicKey, solanaAddressFromPublicKeyBytes } from './chunk-NHEHCUS5.js';
|
|
5
|
+
import { requestEnvelope, CoordinatorMessageType, onEnvelope, closeProtocolRuntime, EnvelopeKind } from './chunk-QQSI3ZD7.js';
|
|
6
|
+
import { getSessionState } from './chunk-V5HXJRBW.js';
|
|
7
|
+
import './chunk-DIA6U2CV.js';
|
|
8
|
+
import { PolicyValidationError, CommandError, TransportError, InvalidDepositAmountError, normalizeError, RoutingError, AttestationError } from './chunk-GHBQF3A7.js';
|
|
9
|
+
export { InvalidDepositAmountError } from './chunk-GHBQF3A7.js';
|
|
10
10
|
import './chunk-VR6T6OJS.js';
|
|
11
11
|
|
|
12
12
|
// src/validation/payoutPolicy.ts
|
|
@@ -171,7 +171,7 @@ function recoveryCodeFromUserInput(input) {
|
|
|
171
171
|
var protocolPromise = null;
|
|
172
172
|
var frostRuntimePromise = null;
|
|
173
173
|
function loadProtocol() {
|
|
174
|
-
protocolPromise ??= import('./coordinator-
|
|
174
|
+
protocolPromise ??= import('./coordinator-VVJ33WF2.js');
|
|
175
175
|
return protocolPromise;
|
|
176
176
|
}
|
|
177
177
|
function loadFrostRuntime() {
|
|
@@ -185,6 +185,7 @@ var BENIGN_TRANSPORT_DROP = /* @__PURE__ */ Symbol("benignTransportDrop");
|
|
|
185
185
|
var ALICE_ID = 1;
|
|
186
186
|
var COORDINATOR_ID = 2;
|
|
187
187
|
var SYNC_SECRET_BYTE_LENGTH = 32;
|
|
188
|
+
var SYNC_CONTRACT_ID_MISMATCH_MESSAGE = "sync response contract id does not match requested contract";
|
|
188
189
|
var ACTIVE_CONTRACT_REQUEST_MESSAGE = "coordinator session already has an active contract";
|
|
189
190
|
var DEFAULT_SWAP_STATUS_RECONCILE_INTERVAL_MS = 5e3;
|
|
190
191
|
var MAX_SWAP_STATUS_RETRY_DELAY_MS = 3e4;
|
|
@@ -198,9 +199,6 @@ var CURRENT_SCHEDULED_PAYOUT_WINDOW_SECONDS = new Set(scheduledPayoutWindowSecon
|
|
|
198
199
|
var CURRENT_SCHEDULED_PAYOUT_WINDOW_MESSAGE = `scheduled payout_spec.window_seconds must be one of [${scheduledPayoutWindowSeconds().join(", ")}]`;
|
|
199
200
|
var TERMINAL_SWAP_STATES = /* @__PURE__ */ new Set(["completed", "refunded", "failed"]);
|
|
200
201
|
var activeFunctionalContractRequests = /* @__PURE__ */ new WeakSet();
|
|
201
|
-
function createCoordinatorSession(options) {
|
|
202
|
-
return new UserCoordinatorSession(options);
|
|
203
|
-
}
|
|
204
202
|
function isBenignTransportDrop(err) {
|
|
205
203
|
return typeof err === "object" && err !== null && err[BENIGN_TRANSPORT_DROP] === true;
|
|
206
204
|
}
|
|
@@ -1016,7 +1014,7 @@ async function requestRefundOnSession(session, params) {
|
|
|
1016
1014
|
false
|
|
1017
1015
|
);
|
|
1018
1016
|
try {
|
|
1019
|
-
await client.requestRefundIntent(params);
|
|
1017
|
+
const result = await client.requestRefundIntent(params);
|
|
1020
1018
|
const requestId = client.currentSwapId;
|
|
1021
1019
|
if (!requestId) {
|
|
1022
1020
|
throw new CommandError(
|
|
@@ -1024,7 +1022,19 @@ async function requestRefundOnSession(session, params) {
|
|
|
1024
1022
|
"refund response did not include the resolved contract id"
|
|
1025
1023
|
);
|
|
1026
1024
|
}
|
|
1027
|
-
|
|
1025
|
+
if (result.kind === "accepted") {
|
|
1026
|
+
return {
|
|
1027
|
+
accepted: true,
|
|
1028
|
+
requestId,
|
|
1029
|
+
amountLamports: result.accepted.amount_lamports,
|
|
1030
|
+
acceptedAtMs: result.accepted.accepted_at_ms
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
return {
|
|
1034
|
+
accepted: true,
|
|
1035
|
+
requestId,
|
|
1036
|
+
amountLamports: result.refund.amount_lamports
|
|
1037
|
+
};
|
|
1028
1038
|
} finally {
|
|
1029
1039
|
client.releaseWithoutClosing();
|
|
1030
1040
|
}
|
|
@@ -1043,9 +1053,20 @@ async function requestUserSync(session, swapId, syncSecret, timeoutMs) {
|
|
|
1043
1053
|
actor: "user",
|
|
1044
1054
|
sync_secret: new Uint8Array(syncSecret)
|
|
1045
1055
|
},
|
|
1046
|
-
{ swapId, timeoutMs }
|
|
1056
|
+
{ swapId, timeoutMs, rejectMatchingOutOfBandErrors: true }
|
|
1047
1057
|
);
|
|
1048
|
-
|
|
1058
|
+
const payload = (await loadProtocol()).asSyncUserResponsePayload(env);
|
|
1059
|
+
assertSyncResponseContractId(env, payload, swapId);
|
|
1060
|
+
return {
|
|
1061
|
+
...payload,
|
|
1062
|
+
coordinatorTimestampMs: env.timestamp_ms
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function assertSyncResponseContractId(envelope, payload, requestedSwapId) {
|
|
1066
|
+
const actorSyncContractId = payload.actor_sync?.snapshot.contract_id;
|
|
1067
|
+
if (envelope.swap_id !== requestedSwapId || actorSyncContractId !== void 0 && actorSyncContractId !== requestedSwapId) {
|
|
1068
|
+
throw new CommandError("REJECTED_STATE", SYNC_CONTRACT_ID_MISMATCH_MESSAGE);
|
|
1069
|
+
}
|
|
1049
1070
|
}
|
|
1050
1071
|
async function ensureFrostWasm() {
|
|
1051
1072
|
await (await loadFrostRuntime()).ensureFrostWasm();
|
|
@@ -1150,10 +1171,10 @@ async function contractRequest(session, args) {
|
|
|
1150
1171
|
assertCurrentUserContractPolicy(payoutPolicy);
|
|
1151
1172
|
assertAttested(session);
|
|
1152
1173
|
const destination = payoutPolicy.destinations[0];
|
|
1153
|
-
const
|
|
1174
|
+
const wirePayoutSpec = wirePayoutSpecFromPolicy(payoutPolicy, destination.address);
|
|
1154
1175
|
return contractRequestOnSession(session, {
|
|
1155
1176
|
amountLamports: args.amountLamports,
|
|
1156
|
-
payoutSpec,
|
|
1177
|
+
payoutSpec: wirePayoutSpec,
|
|
1157
1178
|
...args.syncSecret !== void 0 && { syncSecret: args.syncSecret },
|
|
1158
1179
|
...args.recoveryCommitment !== void 0 && {
|
|
1159
1180
|
recoveryCommitment: args.recoveryCommitment
|
|
@@ -1188,7 +1209,7 @@ function assertCurrentUserContractPolicy(policy) {
|
|
|
1188
1209
|
}
|
|
1189
1210
|
}
|
|
1190
1211
|
}
|
|
1191
|
-
function
|
|
1212
|
+
function wirePayoutSpecFromPolicy(policy, destinationAddress) {
|
|
1192
1213
|
const totalDeadlineMs = policy.totalDeadlineMs;
|
|
1193
1214
|
if (totalDeadlineMs === void 0 || totalDeadlineMs === INSTANT_PAYOUT_WINDOW_MS) {
|
|
1194
1215
|
return {
|
|
@@ -1210,16 +1231,7 @@ async function requestRefund(session, args) {
|
|
|
1210
1231
|
recoveryCode: new Uint8Array(args.recoveryCode)
|
|
1211
1232
|
});
|
|
1212
1233
|
}
|
|
1213
|
-
async function getDepositAddress(_session, _requestId, _syncSecret) {
|
|
1214
|
-
throw new NotImplementedError("user.getDepositAddress");
|
|
1215
|
-
}
|
|
1216
|
-
function subscribe(_session, _requestId, _syncSecret, _handler) {
|
|
1217
|
-
throw new NotImplementedError("user.subscribe");
|
|
1218
|
-
}
|
|
1219
|
-
async function replayFromStorage(_session, _storage) {
|
|
1220
|
-
throw new NotImplementedError("user.replayFromStorage");
|
|
1221
|
-
}
|
|
1222
1234
|
|
|
1223
|
-
export { INSTANT_PAYOUT_WINDOW_MS, MAX_ENTRY_AMOUNT_LAMPORTS, MIN_ENTRY_AMOUNT_LAMPORTS, PAYOUT_WINDOW_MILLISECONDS_PER_SECOND, RECOVERY_CODE_BYTE_LENGTH, SUPPORTED_TOTAL_DEADLINE_MS, commitmentFromCode, contractRequest,
|
|
1235
|
+
export { INSTANT_PAYOUT_WINDOW_MS, MAX_ENTRY_AMOUNT_LAMPORTS, MIN_ENTRY_AMOUNT_LAMPORTS, PAYOUT_WINDOW_MILLISECONDS_PER_SECOND, RECOVERY_CODE_BYTE_LENGTH, SUPPORTED_TOTAL_DEADLINE_MS, commitmentFromCode, contractRequest, generateRecoveryCode, recoveryCodeFromHex, recoveryCodeFromUserInput, recoveryCodeToHex, requestRefund, sync };
|
|
1224
1236
|
//# sourceMappingURL=user.js.map
|
|
1225
1237
|
//# sourceMappingURL=user.js.map
|