@veilo/sdk-core 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +282 -18
- package/accounts.d.ts +2 -0
- package/accounts.js +3 -0
- package/cloak.d.ts +2 -0
- package/cloak.js +3 -0
- package/config.d.ts +2 -0
- package/config.js +3 -0
- package/dist/cjs/events/index.d.ts +6 -0
- package/dist/cjs/events/index.js +22 -0
- package/dist/cjs/events/parsing.d.ts +25 -0
- package/dist/cjs/events/parsing.js +158 -0
- package/dist/cjs/events/position.d.ts +26 -0
- package/dist/cjs/events/position.js +53 -0
- package/dist/cjs/events/recovery.d.ts +87 -0
- package/dist/cjs/events/recovery.js +281 -0
- package/dist/cjs/events/scanning.d.ts +35 -0
- package/dist/cjs/events/scanning.js +98 -0
- package/dist/cjs/events/tree.d.ts +27 -0
- package/dist/cjs/events/tree.js +63 -0
- package/dist/cjs/events/types.d.ts +39 -0
- package/dist/cjs/events/types.js +2 -0
- package/dist/cjs/events.d.ts +1 -77
- package/dist/cjs/events.js +6 -154
- package/dist/cjs/identity/encoding.d.ts +9 -0
- package/dist/cjs/identity/encoding.js +85 -0
- package/dist/cjs/identity/index.d.ts +4 -0
- package/dist/cjs/identity/index.js +20 -0
- package/dist/cjs/identity/noteKey.d.ts +33 -0
- package/dist/cjs/identity/noteKey.js +97 -0
- package/dist/cjs/identity/spending.d.ts +18 -0
- package/dist/cjs/identity/spending.js +46 -0
- package/dist/cjs/identity/viewKey.d.ts +38 -0
- package/dist/cjs/identity/viewKey.js +105 -0
- package/dist/cjs/idl/index.d.ts +18 -0
- package/dist/cjs/idl/index.js +24 -0
- package/dist/cjs/idl/privacy_pool.json +9907 -9907
- package/dist/cjs/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
- package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
- package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
- package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/cjs/index.d.ts +8 -3
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/notes/amount.d.ts +2 -0
- package/dist/cjs/notes/amount.js +21 -0
- package/dist/cjs/notes/index.d.ts +4 -0
- package/dist/cjs/notes/index.js +4 -0
- package/dist/cjs/notes/recovery.d.ts +16 -6
- package/dist/cjs/notes/recovery.js +33 -16
- package/dist/cjs/notes/scan.d.ts +74 -0
- package/dist/cjs/notes/scan.js +110 -0
- package/dist/cjs/notes/selection.d.ts +133 -0
- package/dist/cjs/notes/selection.js +260 -0
- package/dist/cjs/notes/spent.d.ts +60 -0
- package/dist/cjs/notes/spent.js +101 -0
- package/dist/cjs/perps/constants.d.ts +16 -0
- package/dist/cjs/perps/constants.js +52 -0
- package/dist/cjs/perps/index.d.ts +5 -0
- package/dist/cjs/perps/index.js +21 -0
- package/dist/cjs/perps/keys.d.ts +16 -0
- package/dist/cjs/perps/keys.js +43 -0
- package/dist/cjs/perps/pdas.d.ts +29 -0
- package/dist/cjs/perps/pdas.js +55 -0
- package/dist/cjs/perps/relayer.d.ts +9 -0
- package/dist/cjs/perps/relayer.js +35 -0
- package/dist/cjs/perps/types.d.ts +126 -0
- package/dist/cjs/perps/types.js +2 -0
- package/dist/cjs/positions/index.d.ts +4 -0
- package/dist/cjs/positions/index.js +20 -0
- package/dist/cjs/positions/keys.d.ts +29 -0
- package/dist/cjs/positions/keys.js +71 -0
- package/dist/cjs/positions/pdas.d.ts +15 -0
- package/dist/cjs/positions/pdas.js +54 -0
- package/dist/cjs/positions/relayer.d.ts +4 -0
- package/dist/cjs/positions/relayer.js +15 -0
- package/dist/cjs/positions/types.d.ts +97 -0
- package/dist/cjs/positions/types.js +2 -0
- package/dist/cjs/predictions/client.d.ts +41 -0
- package/dist/cjs/predictions/client.js +147 -0
- package/dist/cjs/predictions/index.d.ts +5 -0
- package/dist/cjs/predictions/index.js +21 -0
- package/dist/cjs/predictions/keys.d.ts +14 -0
- package/dist/cjs/predictions/keys.js +40 -0
- package/dist/cjs/predictions/pdas.d.ts +6 -0
- package/dist/cjs/predictions/pdas.js +13 -0
- package/dist/cjs/predictions/relayer.d.ts +3 -0
- package/dist/cjs/predictions/relayer.js +11 -0
- package/dist/cjs/predictions/types.d.ts +178 -0
- package/dist/cjs/predictions/types.js +2 -0
- package/dist/cjs/program.d.ts +2 -0
- package/dist/cjs/program.js +8 -7
- package/dist/cjs/prover.d.ts +27 -4
- package/dist/cjs/prover.js +107 -48
- package/dist/cjs/relayer/api.d.ts +41 -0
- package/dist/cjs/relayer/api.js +99 -0
- package/dist/cjs/relayer/client.d.ts +42 -17
- package/dist/cjs/relayer/client.js +94 -17
- package/dist/cjs/relayer/errors.d.ts +1 -1
- package/dist/cjs/relayer/errors.js +1 -1
- package/dist/cjs/relayer/index.d.ts +4 -1
- package/dist/cjs/relayer/index.js +1 -1
- package/dist/cjs/relayer/internal-config.d.ts +36 -0
- package/dist/cjs/relayer/internal-config.js +9 -0
- package/dist/cjs/relayer/internal.d.ts +6 -0
- package/dist/cjs/relayer/internal.js +14 -0
- package/dist/cjs/relayer/transport.d.ts +4 -2
- package/dist/cjs/relayer/transport.js +10 -5
- package/dist/cjs/relayer/types.d.ts +40 -10
- package/dist/cjs/relayer/types.js +1 -1
- package/dist/cjs/shield/owner.js +1 -4
- package/dist/esm/events/index.d.ts +6 -0
- package/dist/esm/events/index.js +6 -0
- package/dist/esm/events/parsing.d.ts +25 -0
- package/dist/esm/events/parsing.js +120 -0
- package/dist/esm/events/position.d.ts +26 -0
- package/dist/esm/events/position.js +48 -0
- package/dist/esm/events/recovery.d.ts +87 -0
- package/dist/esm/events/recovery.js +237 -0
- package/dist/esm/events/scanning.d.ts +35 -0
- package/dist/esm/events/scanning.js +92 -0
- package/dist/esm/events/tree.d.ts +27 -0
- package/dist/esm/events/tree.js +58 -0
- package/dist/esm/events/types.d.ts +39 -0
- package/dist/esm/events/types.js +1 -0
- package/dist/esm/events.d.ts +1 -77
- package/dist/esm/events.js +3 -129
- package/dist/esm/identity/encoding.d.ts +9 -0
- package/dist/esm/identity/encoding.js +75 -0
- package/dist/esm/identity/index.d.ts +4 -0
- package/dist/esm/identity/index.js +4 -0
- package/dist/esm/identity/noteKey.d.ts +33 -0
- package/dist/esm/identity/noteKey.js +91 -0
- package/dist/esm/identity/spending.d.ts +18 -0
- package/dist/esm/identity/spending.js +35 -0
- package/dist/esm/identity/viewKey.d.ts +38 -0
- package/dist/esm/identity/viewKey.js +96 -0
- package/dist/esm/idl/index.d.ts +18 -0
- package/dist/esm/idl/index.js +18 -0
- package/dist/esm/idl/privacy_pool.json +9907 -9907
- package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
- package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
- package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
- package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/esm/index.d.ts +8 -3
- package/dist/esm/index.js +8 -3
- package/dist/esm/notes/amount.d.ts +2 -0
- package/dist/esm/notes/amount.js +18 -0
- package/dist/esm/notes/index.d.ts +4 -0
- package/dist/esm/notes/index.js +4 -0
- package/dist/esm/notes/recovery.d.ts +16 -6
- package/dist/esm/notes/recovery.js +33 -16
- package/dist/esm/notes/scan.d.ts +74 -0
- package/dist/esm/notes/scan.js +105 -0
- package/dist/esm/notes/selection.d.ts +133 -0
- package/dist/esm/notes/selection.js +254 -0
- package/dist/esm/notes/spent.d.ts +60 -0
- package/dist/esm/notes/spent.js +96 -0
- package/dist/esm/perps/constants.d.ts +16 -0
- package/dist/esm/perps/constants.js +48 -0
- package/dist/esm/perps/index.d.ts +5 -0
- package/dist/esm/perps/index.js +5 -0
- package/dist/esm/perps/keys.d.ts +16 -0
- package/dist/esm/perps/keys.js +35 -0
- package/dist/esm/perps/pdas.d.ts +29 -0
- package/dist/esm/perps/pdas.js +47 -0
- package/dist/esm/perps/relayer.d.ts +9 -0
- package/dist/esm/perps/relayer.js +25 -0
- package/dist/esm/perps/types.d.ts +126 -0
- package/dist/esm/perps/types.js +1 -0
- package/dist/esm/positions/index.d.ts +4 -0
- package/dist/esm/positions/index.js +4 -0
- package/dist/esm/positions/keys.d.ts +29 -0
- package/dist/esm/positions/keys.js +65 -0
- package/dist/esm/positions/pdas.d.ts +15 -0
- package/dist/esm/positions/pdas.js +44 -0
- package/dist/esm/positions/relayer.d.ts +4 -0
- package/dist/esm/positions/relayer.js +10 -0
- package/dist/esm/positions/types.d.ts +97 -0
- package/dist/esm/positions/types.js +1 -0
- package/dist/esm/predictions/client.d.ts +41 -0
- package/dist/esm/predictions/client.js +141 -0
- package/dist/esm/predictions/index.d.ts +5 -0
- package/dist/esm/predictions/index.js +5 -0
- package/dist/esm/predictions/keys.d.ts +14 -0
- package/dist/esm/predictions/keys.js +33 -0
- package/dist/esm/predictions/pdas.d.ts +6 -0
- package/dist/esm/predictions/pdas.js +10 -0
- package/dist/esm/predictions/relayer.d.ts +3 -0
- package/dist/esm/predictions/relayer.js +7 -0
- package/dist/esm/predictions/types.d.ts +178 -0
- package/dist/esm/predictions/types.js +1 -0
- package/dist/esm/program.d.ts +2 -0
- package/dist/esm/program.js +4 -3
- package/dist/esm/prover.d.ts +27 -4
- package/dist/esm/prover.js +106 -15
- package/dist/esm/relayer/api.d.ts +41 -0
- package/dist/esm/relayer/api.js +66 -0
- package/dist/esm/relayer/client.d.ts +42 -17
- package/dist/esm/relayer/client.js +94 -17
- package/dist/esm/relayer/errors.d.ts +1 -1
- package/dist/esm/relayer/errors.js +1 -1
- package/dist/esm/relayer/index.d.ts +4 -1
- package/dist/esm/relayer/index.js +1 -1
- package/dist/esm/relayer/internal-config.d.ts +36 -0
- package/dist/esm/relayer/internal-config.js +6 -0
- package/dist/esm/relayer/internal.d.ts +6 -0
- package/dist/esm/relayer/internal.js +10 -0
- package/dist/esm/relayer/transport.d.ts +4 -2
- package/dist/esm/relayer/transport.js +10 -5
- package/dist/esm/relayer/types.d.ts +40 -10
- package/dist/esm/relayer/types.js +1 -1
- package/dist/esm/shield/owner.js +1 -4
- package/identity.d.ts +2 -0
- package/identity.js +3 -0
- package/idl.d.ts +2 -0
- package/idl.js +3 -0
- package/notes.d.ts +2 -0
- package/notes.js +3 -0
- package/package.json +85 -3
- package/perps.d.ts +2 -0
- package/perps.js +3 -0
- package/poseidon.d.ts +2 -0
- package/poseidon.js +3 -0
- package/positions.d.ts +2 -0
- package/positions.js +3 -0
- package/predictions.d.ts +2 -0
- package/predictions.js +3 -0
- package/proof.d.ts +2 -0
- package/proof.js +3 -0
- package/prover.d.ts +2 -0
- package/prover.js +3 -0
- package/relayer.d.ts +2 -0
- package/relayer.js +3 -0
- package/shield.d.ts +2 -0
- package/shield.js +3 -0
- package/transactions.d.ts +2 -0
- package/transactions.js +3 -0
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
import nacl from "tweetnacl";
|
|
2
2
|
import { encryptForRelayer } from "./crypto.js";
|
|
3
3
|
import { fromBase64, toBase64 } from "./encoding.js";
|
|
4
|
+
import { VEILO_RELAYER_PUBLIC_KEY, } from "./internal-config.js";
|
|
4
5
|
import { RelayerHttpTransport } from "./transport.js";
|
|
5
6
|
// =============================================================================
|
|
6
7
|
// Relayer Client
|
|
7
8
|
// =============================================================================
|
|
8
|
-
/**
|
|
9
|
-
* HTTP client for the Veilo relayer API.
|
|
10
|
-
*
|
|
11
|
-
* Handles auth, notes, merkle, and encrypted transact endpoints with
|
|
12
|
-
* automatic retry on transient failures and NaCl box payload encryption.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const client = new VeiloRelayerClient({
|
|
17
|
-
* apiKey: "your-api-key",
|
|
18
|
-
* relayerPublicKey: "<base64 NaCl public key>",
|
|
19
|
-
* });
|
|
20
|
-
* const root = await client.getMerkleRoot("So111...");
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
9
|
+
/** @internal Relayer transport behind the SDK's functional helpers. */
|
|
23
10
|
export class VeiloRelayerClient {
|
|
24
|
-
constructor(config, retry) {
|
|
11
|
+
constructor(config = {}, retry) {
|
|
25
12
|
this.transport = new RelayerHttpTransport(config, retry);
|
|
26
|
-
this.relayerPubKey = fromBase64(config.
|
|
13
|
+
this.relayerPubKey = fromBase64(config.encryptionPublicKey ?? VEILO_RELAYER_PUBLIC_KEY);
|
|
27
14
|
}
|
|
28
15
|
/** Update the auth token (e.g. after register/restore). */
|
|
29
16
|
setAuthToken(token) {
|
|
@@ -88,6 +75,40 @@ export class VeiloRelayerClient {
|
|
|
88
75
|
});
|
|
89
76
|
}
|
|
90
77
|
/** Delete all stored data for the authenticated user. Requires auth token. */
|
|
78
|
+
/**
|
|
79
|
+
* One page of the public compact-note feed.
|
|
80
|
+
*
|
|
81
|
+
* Unauthenticated by design: rows carry only ciphertext and a one-byte view
|
|
82
|
+
* tag, so scanning reveals nothing without the recipient's key. The feed
|
|
83
|
+
* excludes spent notes and any note already claimed by a wallet.
|
|
84
|
+
*/
|
|
85
|
+
async compactScan(params = {}) {
|
|
86
|
+
const query = new URLSearchParams();
|
|
87
|
+
if (params.limit !== undefined)
|
|
88
|
+
query.set("limit", String(params.limit));
|
|
89
|
+
if (params.cursor)
|
|
90
|
+
query.set("cursor", params.cursor);
|
|
91
|
+
const qs = query.toString();
|
|
92
|
+
return this.transport.request("GET", `/notes/compact-scan${qs ? `?${qs}` : ""}`);
|
|
93
|
+
}
|
|
94
|
+
/** Look up stored notes by commitment. Max 50 per request. */
|
|
95
|
+
async fetchNotesByCommitment(data) {
|
|
96
|
+
return this.transport.request("POST", "/notes/fetch-by-commitment", {
|
|
97
|
+
body: data,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Ask which of these nullifiers the relayer has seen spent.
|
|
102
|
+
*
|
|
103
|
+
* Caller must respect MAX_NULLIFIERS_PER_CHECK; `checkNullifiersSpent` in
|
|
104
|
+
* notes/spent.ts does the chunking. Unauthenticated: a nullifier reveals
|
|
105
|
+
* nothing about ownership on its own.
|
|
106
|
+
*/
|
|
107
|
+
async checkNullifiers(nullifiers) {
|
|
108
|
+
return this.transport.request("POST", "/notes/nullifiers/check-batch", {
|
|
109
|
+
body: { nullifiers },
|
|
110
|
+
});
|
|
111
|
+
}
|
|
91
112
|
async deleteUserData() {
|
|
92
113
|
return this.transport.request("POST", "/notes/delete", { authenticated: true });
|
|
93
114
|
}
|
|
@@ -141,4 +162,60 @@ export class VeiloRelayerClient {
|
|
|
141
162
|
retryable: false,
|
|
142
163
|
});
|
|
143
164
|
}
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// Private positions (encrypted payloads)
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
async submitOpenPosition(data) {
|
|
169
|
+
return this.submitEncrypted("/positions/open", data);
|
|
170
|
+
}
|
|
171
|
+
async submitClosePosition(data) {
|
|
172
|
+
return this.submitEncrypted("/positions/close", data);
|
|
173
|
+
}
|
|
174
|
+
async submitMergePositions(data) {
|
|
175
|
+
return this.submitEncrypted("/positions/merge", data);
|
|
176
|
+
}
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Private Jupiter Perps (encrypted payloads)
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
async submitJperpOpen(data) {
|
|
181
|
+
return this.submitEncrypted("/jperp/open", data);
|
|
182
|
+
}
|
|
183
|
+
async submitJperpClose(data) {
|
|
184
|
+
return this.submitEncrypted("/jperp/close", data);
|
|
185
|
+
}
|
|
186
|
+
async submitJperpSetTpsl(data) {
|
|
187
|
+
return this.submitEncrypted("/jperp/set-tpsl", data);
|
|
188
|
+
}
|
|
189
|
+
async submitJperpUpdateTpsl(data) {
|
|
190
|
+
return this.submitEncrypted("/jperp/update-tpsl", data);
|
|
191
|
+
}
|
|
192
|
+
async submitJperpCancelTrigger(data) {
|
|
193
|
+
return this.submitEncrypted("/jperp/cancel-trigger", data);
|
|
194
|
+
}
|
|
195
|
+
async submitJperpReissue(data) {
|
|
196
|
+
return this.submitEncrypted("/jperp/reissue", data);
|
|
197
|
+
}
|
|
198
|
+
async submitJperpRecoverSeed(data) {
|
|
199
|
+
return this.submitEncrypted("/jperp/recover-seed", data);
|
|
200
|
+
}
|
|
201
|
+
async submitJperpRecoverNative(data) {
|
|
202
|
+
return this.submitEncrypted("/jperp/recover-native", data);
|
|
203
|
+
}
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Private Jupiter Predictions (encrypted payloads)
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
async submitPredictionOpen(data) {
|
|
208
|
+
return this.submitEncrypted("/predictions/open", data);
|
|
209
|
+
}
|
|
210
|
+
async submitPredictionReissue(data) {
|
|
211
|
+
return this.submitEncrypted("/predictions/reissue", data);
|
|
212
|
+
}
|
|
213
|
+
submitEncrypted(route, data) {
|
|
214
|
+
const encryptedPayload = this.encryptPayload(data);
|
|
215
|
+
return this.transport.request("POST", route, {
|
|
216
|
+
body: { encryptedPayload },
|
|
217
|
+
// These endpoints can land transactions; automatic replay is unsafe.
|
|
218
|
+
retryable: false,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
144
221
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
2
|
// Structured Error
|
|
3
3
|
// =============================================================================
|
|
4
|
-
/** Structured error thrown by
|
|
4
|
+
/** Structured error thrown by managed Veilo API helpers. */
|
|
5
5
|
export class VeiloApiError extends Error {
|
|
6
6
|
constructor(code, message, status, details) {
|
|
7
7
|
super(message);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Veilo network coordinates are protocol configuration, not integrator input.
|
|
3
|
+
* Keep them behind the public package entry points.
|
|
4
|
+
*/
|
|
5
|
+
export declare const VEILO_RELAYER_URL = "https://relayer-server.onrender.com";
|
|
6
|
+
export declare const VEILO_RELAYER_PUBLIC_KEY = "utVxnA7zax09qJCZ7UJsa8PAOoWLRcCwOkdxg/ZGmD4=";
|
|
7
|
+
/**
|
|
8
|
+
* Internal construction options. Overrides exist only for isolated tests.
|
|
9
|
+
*
|
|
10
|
+
* ⚠ `baseUrl` MUST NOT be promoted to the public API. Two invariants depend on
|
|
11
|
+
* it staying internal:
|
|
12
|
+
*
|
|
13
|
+
* 1. The privacy pool gates every spend on an on-chain relayer allowlist
|
|
14
|
+
* (`RelayerNotAllowed`). Only deposits are permissionless. A request sent
|
|
15
|
+
* to any other host cannot land on chain, so the option would be a
|
|
16
|
+
* footgun that fails late rather than a feature.
|
|
17
|
+
* 2. These request bodies carry note spending keys (`TransactNote.privateKey`,
|
|
18
|
+
* and `claimantSecretKey` on position close/merge). A caller-settable
|
|
19
|
+
* destination is a caller-settable exfiltration target for user funds.
|
|
20
|
+
*
|
|
21
|
+
* Only `internal.ts` may construct these options, and it builds the object
|
|
22
|
+
* literal itself — no caller-supplied object is ever forwarded here. To verify
|
|
23
|
+
* that still holds:
|
|
24
|
+
*
|
|
25
|
+
* grep -rn "createInternalRelayerClient(\|new VeiloRelayerClient(" src
|
|
26
|
+
*
|
|
27
|
+
* Whitelisted partners who run their own relayer are handled out of band, not
|
|
28
|
+
* by a config flag. See README → "Submission always targets Veilo's relayer".
|
|
29
|
+
*/
|
|
30
|
+
export interface InternalRelayerClientOptions {
|
|
31
|
+
authToken?: string;
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
encryptionPublicKey?: string;
|
|
35
|
+
fetch?: typeof fetch;
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Veilo network coordinates are protocol configuration, not integrator input.
|
|
3
|
+
* Keep them behind the public package entry points.
|
|
4
|
+
*/
|
|
5
|
+
export const VEILO_RELAYER_URL = "https://relayer-server.onrender.com";
|
|
6
|
+
export const VEILO_RELAYER_PUBLIC_KEY = "utVxnA7zax09qJCZ7UJsa8PAOoWLRcCwOkdxg/ZGmD4=";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VeiloRelayerClient } from "./client.js";
|
|
2
|
+
import type { InternalRelayerClientOptions } from "./internal-config.js";
|
|
3
|
+
/** @internal Shared stateless production client for public SDK helpers. */
|
|
4
|
+
export declare function getInternalRelayerClient(): VeiloRelayerClient;
|
|
5
|
+
/** @internal Auth state is isolated per call to avoid cross-user token leaks. */
|
|
6
|
+
export declare function createInternalRelayerClient(options?: InternalRelayerClientOptions): VeiloRelayerClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VeiloRelayerClient } from "./client.js";
|
|
2
|
+
const RELAYER = new VeiloRelayerClient();
|
|
3
|
+
/** @internal Shared stateless production client for public SDK helpers. */
|
|
4
|
+
export function getInternalRelayerClient() {
|
|
5
|
+
return RELAYER;
|
|
6
|
+
}
|
|
7
|
+
/** @internal Auth state is isolated per call to avoid cross-user token leaks. */
|
|
8
|
+
export function createInternalRelayerClient(options = {}) {
|
|
9
|
+
return new VeiloRelayerClient(options);
|
|
10
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type InternalRelayerClientOptions } from "./internal-config.js";
|
|
2
|
+
import type { RetryPolicy } from "./types.js";
|
|
2
3
|
export interface RelayerRequestOptions {
|
|
3
4
|
body?: unknown;
|
|
4
5
|
authenticated?: boolean;
|
|
@@ -10,7 +11,8 @@ export declare class RelayerHttpTransport {
|
|
|
10
11
|
private readonly apiKey;
|
|
11
12
|
private authToken;
|
|
12
13
|
private readonly retry;
|
|
13
|
-
|
|
14
|
+
private readonly fetcher?;
|
|
15
|
+
constructor(config?: InternalRelayerClientOptions, retry?: Partial<RetryPolicy>);
|
|
14
16
|
setAuthToken(token: string): void;
|
|
15
17
|
request<T>(method: string, route: string, options?: RelayerRequestOptions): Promise<T>;
|
|
16
18
|
private headers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VeiloApiError } from "./errors.js";
|
|
2
|
-
|
|
2
|
+
import { VEILO_RELAYER_URL, } from "./internal-config.js";
|
|
3
3
|
const DEFAULT_RETRY = {
|
|
4
4
|
maxRetries: 3,
|
|
5
5
|
baseDelayMs: 1000,
|
|
@@ -7,11 +7,12 @@ const DEFAULT_RETRY = {
|
|
|
7
7
|
};
|
|
8
8
|
/** Owns HTTP authentication, retry, and response normalization. */
|
|
9
9
|
export class RelayerHttpTransport {
|
|
10
|
-
constructor(config, retry) {
|
|
11
|
-
this.baseUrl = (config.
|
|
12
|
-
this.apiKey = config.apiKey;
|
|
10
|
+
constructor(config = {}, retry) {
|
|
11
|
+
this.baseUrl = (config.baseUrl?.trim() || VEILO_RELAYER_URL).replace(/\/+$/, "");
|
|
12
|
+
this.apiKey = config.apiKey ?? "";
|
|
13
13
|
this.authToken = config.authToken;
|
|
14
14
|
this.retry = { ...DEFAULT_RETRY, ...retry };
|
|
15
|
+
this.fetcher = config.fetch;
|
|
15
16
|
}
|
|
16
17
|
setAuthToken(token) {
|
|
17
18
|
this.authToken = token;
|
|
@@ -28,7 +29,11 @@ export class RelayerHttpTransport {
|
|
|
28
29
|
}
|
|
29
30
|
let response;
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
+
const fetcher = this.fetcher ?? globalThis.fetch;
|
|
33
|
+
if (typeof fetcher !== "function") {
|
|
34
|
+
throw new Error("This environment does not provide fetch");
|
|
35
|
+
}
|
|
36
|
+
response = await fetcher(url, {
|
|
32
37
|
method,
|
|
33
38
|
headers: this.headers(authenticated),
|
|
34
39
|
body: body == null ? undefined : JSON.stringify(body),
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export interface VeiloRelayerConfig {
|
|
2
|
-
/** Base URL of the relayer. Defaults to Veilo's production service. */
|
|
3
|
-
relayerUrl?: string;
|
|
4
|
-
/** API key sent as x-api-key header */
|
|
5
|
-
apiKey: string;
|
|
6
|
-
/** Relayer's NaCl box public key (base64-encoded, 32 bytes) */
|
|
7
|
-
relayerPublicKey: string;
|
|
8
|
-
/** Optional JWT auth token for authenticated endpoints */
|
|
9
|
-
authToken?: string;
|
|
10
|
-
}
|
|
11
1
|
/** Retry configuration for the relayer HTTP client. */
|
|
12
2
|
export interface RetryPolicy {
|
|
13
3
|
/** Max number of retry attempts (default: 3) */
|
|
@@ -49,6 +39,46 @@ export interface QueryNotesResponse {
|
|
|
49
39
|
limit: number;
|
|
50
40
|
offset: number;
|
|
51
41
|
}
|
|
42
|
+
/** One row from the public compact-note scan feed. */
|
|
43
|
+
export interface CompactScanNote {
|
|
44
|
+
_id: string;
|
|
45
|
+
commitment: string;
|
|
46
|
+
compactEphemeralKey: string | null;
|
|
47
|
+
compactBlob: string | null;
|
|
48
|
+
viewTag: number | null;
|
|
49
|
+
leafIndex?: number | null;
|
|
50
|
+
treeId?: number | null;
|
|
51
|
+
mintAddress?: string | null;
|
|
52
|
+
timestamp?: number;
|
|
53
|
+
txSignature?: string;
|
|
54
|
+
spent?: boolean;
|
|
55
|
+
spentTx?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface CompactScanResponse {
|
|
58
|
+
success: boolean;
|
|
59
|
+
notes: CompactScanNote[];
|
|
60
|
+
/** Opaque cursor for the next page; null when the feed is exhausted. */
|
|
61
|
+
nextCursor: string | null;
|
|
62
|
+
hasMore: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Commitments to look up. Max 50 per request, 64-char hex. */
|
|
65
|
+
export interface FetchByCommitmentRequest {
|
|
66
|
+
commitments: string[];
|
|
67
|
+
walletPublicKey?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FetchByCommitmentResponse {
|
|
70
|
+
success: boolean;
|
|
71
|
+
notes: RelayerEncryptedNote[];
|
|
72
|
+
}
|
|
73
|
+
/** Nullifiers to test for spend status. Max 200 per request, 64-char hex. */
|
|
74
|
+
export interface CheckNullifiersRequest {
|
|
75
|
+
nullifiers: string[];
|
|
76
|
+
}
|
|
77
|
+
export interface CheckNullifiersResponse {
|
|
78
|
+
success: boolean;
|
|
79
|
+
/** The SPENT subset, lowercase hex. Absent entries are unspent. */
|
|
80
|
+
spent: string[];
|
|
81
|
+
}
|
|
52
82
|
export interface SaveEncryptedNoteRequest {
|
|
53
83
|
commitment: string;
|
|
54
84
|
ephemeralPublicKey: string;
|
package/dist/esm/shield/owner.js
CHANGED
|
@@ -13,10 +13,7 @@ import { ShieldError } from "./errors.js";
|
|
|
13
13
|
* inspectable. The two owner endpoints used below are intentionally public and
|
|
14
14
|
* return public key material only.
|
|
15
15
|
*/
|
|
16
|
-
const OWNER_RELAYER = new VeiloRelayerClient(
|
|
17
|
-
apiKey: "",
|
|
18
|
-
relayerPublicKey: "utVxnA7zax09qJCZ7UJsa8PAOoWLRcCwOkdxg/ZGmD4=",
|
|
19
|
-
});
|
|
16
|
+
const OWNER_RELAYER = new VeiloRelayerClient();
|
|
20
17
|
/**
|
|
21
18
|
* Resolve a shield recipient into the pair of keys that must belong to the same
|
|
22
19
|
* account.
|
package/identity.d.ts
ADDED
package/identity.js
ADDED
package/idl.d.ts
ADDED
package/idl.js
ADDED
package/notes.d.ts
ADDED
package/notes.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veilo/sdk-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript SDK for the Veilo Privacy Pool - UTXO-based privacy protocol on Solana with ZK-SNARKs",
|
|
5
5
|
"homepage": "https://github.com/VeiloSolana/veilo-sdk#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -127,6 +127,56 @@
|
|
|
127
127
|
"default": "./dist/cjs/cloak.js"
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
+
"./identity": {
|
|
131
|
+
"import": {
|
|
132
|
+
"types": "./dist/esm/identity/index.d.ts",
|
|
133
|
+
"default": "./dist/esm/identity/index.js"
|
|
134
|
+
},
|
|
135
|
+
"require": {
|
|
136
|
+
"types": "./dist/cjs/identity/index.d.ts",
|
|
137
|
+
"default": "./dist/cjs/identity/index.js"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"./positions": {
|
|
141
|
+
"import": {
|
|
142
|
+
"types": "./dist/esm/positions/index.d.ts",
|
|
143
|
+
"default": "./dist/esm/positions/index.js"
|
|
144
|
+
},
|
|
145
|
+
"require": {
|
|
146
|
+
"types": "./dist/cjs/positions/index.d.ts",
|
|
147
|
+
"default": "./dist/cjs/positions/index.js"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"./perps": {
|
|
151
|
+
"import": {
|
|
152
|
+
"types": "./dist/esm/perps/index.d.ts",
|
|
153
|
+
"default": "./dist/esm/perps/index.js"
|
|
154
|
+
},
|
|
155
|
+
"require": {
|
|
156
|
+
"types": "./dist/cjs/perps/index.d.ts",
|
|
157
|
+
"default": "./dist/cjs/perps/index.js"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"./predictions": {
|
|
161
|
+
"import": {
|
|
162
|
+
"types": "./dist/esm/predictions/index.d.ts",
|
|
163
|
+
"default": "./dist/esm/predictions/index.js"
|
|
164
|
+
},
|
|
165
|
+
"require": {
|
|
166
|
+
"types": "./dist/cjs/predictions/index.d.ts",
|
|
167
|
+
"default": "./dist/cjs/predictions/index.js"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"./idl": {
|
|
171
|
+
"import": {
|
|
172
|
+
"types": "./dist/esm/idl/index.d.ts",
|
|
173
|
+
"default": "./dist/esm/idl/index.js"
|
|
174
|
+
},
|
|
175
|
+
"require": {
|
|
176
|
+
"types": "./dist/cjs/idl/index.d.ts",
|
|
177
|
+
"default": "./dist/cjs/idl/index.js"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
130
180
|
"./package.json": "./package.json"
|
|
131
181
|
},
|
|
132
182
|
"publishConfig": {
|
|
@@ -135,16 +185,48 @@
|
|
|
135
185
|
"sideEffects": false,
|
|
136
186
|
"files": [
|
|
137
187
|
"dist/",
|
|
188
|
+
"accounts.js",
|
|
189
|
+
"cloak.js",
|
|
190
|
+
"config.js",
|
|
191
|
+
"identity.js",
|
|
192
|
+
"idl.js",
|
|
193
|
+
"notes.js",
|
|
194
|
+
"perps.js",
|
|
195
|
+
"poseidon.js",
|
|
196
|
+
"positions.js",
|
|
197
|
+
"predictions.js",
|
|
198
|
+
"proof.js",
|
|
199
|
+
"prover.js",
|
|
200
|
+
"relayer.js",
|
|
201
|
+
"shield.js",
|
|
202
|
+
"transactions.js",
|
|
203
|
+
"accounts.d.ts",
|
|
204
|
+
"cloak.d.ts",
|
|
205
|
+
"config.d.ts",
|
|
206
|
+
"identity.d.ts",
|
|
207
|
+
"idl.d.ts",
|
|
208
|
+
"notes.d.ts",
|
|
209
|
+
"perps.d.ts",
|
|
210
|
+
"poseidon.d.ts",
|
|
211
|
+
"positions.d.ts",
|
|
212
|
+
"predictions.d.ts",
|
|
213
|
+
"proof.d.ts",
|
|
214
|
+
"prover.d.ts",
|
|
215
|
+
"relayer.d.ts",
|
|
216
|
+
"shield.d.ts",
|
|
217
|
+
"transactions.d.ts",
|
|
138
218
|
"README.md",
|
|
139
219
|
"LICENSE"
|
|
140
220
|
],
|
|
141
221
|
"scripts": {
|
|
142
222
|
"check:cycles": "node scripts/check-dependency-cycles.mjs",
|
|
143
223
|
"gen:idl": "node scripts/gen-idl.mjs",
|
|
224
|
+
"copy:circuits": "node scripts/copy-circuits.mjs",
|
|
144
225
|
"verify:cipher-parity": "npm run build && node scripts/verify-compact-cipher-parity.mjs",
|
|
145
|
-
"build": "rm -rf dist/ && tsc -p tsconfig.json && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
|
|
226
|
+
"build": "rm -rf dist/ && tsc -p tsconfig.json && tsc -p tsconfig.esm.json && node scripts/copy-idls.mjs && node scripts/gen-subpath-stubs.mjs && echo '{\"type\":\"module\"}' > dist/esm/package.json",
|
|
146
227
|
"test": "rm -rf dist/ && tsc -p test-tsconfig.json && mocha -t 1000000 \"dist/tests/**/*.js\"",
|
|
147
|
-
"test:integration": "export VEILO_RUN_INTEGRATION=1 && export ANCHOR_PROVIDER_URL=https://api.devnet.solana.com && export ANCHOR_WALLET=$HOME/.config/solana/id.json && npm test"
|
|
228
|
+
"test:integration": "export VEILO_RUN_INTEGRATION=1 && export ANCHOR_PROVIDER_URL=https://api.devnet.solana.com && export ANCHOR_WALLET=$HOME/.config/solana/id.json && npm test",
|
|
229
|
+
"gen:stubs": "node scripts/gen-subpath-stubs.mjs"
|
|
148
230
|
},
|
|
149
231
|
"dependencies": {
|
|
150
232
|
"@coral-xyz/anchor": "^0.30.0",
|
package/perps.d.ts
ADDED
package/perps.js
ADDED
package/poseidon.d.ts
ADDED
package/poseidon.js
ADDED
package/positions.d.ts
ADDED
package/positions.js
ADDED
package/predictions.d.ts
ADDED
package/predictions.js
ADDED
package/proof.d.ts
ADDED
package/proof.js
ADDED
package/prover.d.ts
ADDED
package/prover.js
ADDED
package/relayer.d.ts
ADDED
package/relayer.js
ADDED
package/shield.d.ts
ADDED
package/shield.js
ADDED
package/transactions.js
ADDED