@provablehq/sdk 0.10.0-rc → 0.10.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/dist/dynamic/browser.d.ts +8 -0
- package/dist/dynamic/browser.js +8 -0
- package/dist/dynamic/node.d.ts +8 -0
- package/dist/dynamic/node.js +8 -0
- package/dist/mainnet/account.d.ts +61 -6
- package/dist/mainnet/browser.d.ts +41 -8
- package/dist/mainnet/browser.js +3699 -564
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.ts +6 -0
- package/dist/mainnet/external-signing.d.ts +76 -0
- package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +192 -0
- package/dist/mainnet/keys/keystore/error.d.ts +24 -0
- package/dist/mainnet/keys/keystore/file.d.ts +177 -0
- package/dist/mainnet/keys/keystore/interface.d.ts +161 -0
- package/dist/mainnet/keys/provider/interface.d.ts +170 -0
- package/dist/mainnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
- package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
- package/dist/mainnet/keys/verifier/interface.d.ts +70 -0
- package/dist/mainnet/keys/verifier/memory.d.ts +37 -0
- package/dist/mainnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/mainnet/models/external-signing.d.ts +123 -0
- package/dist/mainnet/models/functionInput.d.ts +7 -0
- package/dist/mainnet/models/input/inputJSON.d.ts +1 -0
- package/dist/mainnet/models/input/inputObject.d.ts +1 -0
- package/dist/mainnet/models/keyPair.d.ts +4 -0
- package/dist/mainnet/models/output/outputJSON.d.ts +1 -0
- package/dist/mainnet/models/output/outputObject.d.ts +1 -0
- package/dist/mainnet/models/provingResponse.d.ts +48 -2
- package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
- package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
- package/dist/mainnet/models/record-scanner/error.d.ts +47 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +22 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/mainnet/models/record-scanner/revokeResult.d.ts +17 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
- package/dist/mainnet/models/record-scanner/statusResponse.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/statusResult.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/tagsResult.d.ts +12 -0
- package/dist/mainnet/network-client.d.ts +129 -46
- package/dist/mainnet/node-polyfill.js +2 -49
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.d.ts +1 -0
- package/dist/mainnet/node.js +376 -4
- package/dist/mainnet/node.js.map +1 -1
- package/dist/mainnet/program-manager.d.ts +538 -58
- package/dist/mainnet/record-provider.d.ts +113 -75
- package/dist/mainnet/record-scanner.d.ts +368 -0
- package/dist/mainnet/security.d.ts +62 -0
- package/dist/mainnet/utils.d.ts +1 -0
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/testnet/account.d.ts +61 -6
- package/dist/testnet/browser.d.ts +41 -8
- package/dist/testnet/browser.js +3699 -564
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.ts +6 -0
- package/dist/testnet/external-signing.d.ts +76 -0
- package/dist/testnet/integrations/sealance/merkle-tree.d.ts +192 -0
- package/dist/testnet/keys/keystore/error.d.ts +24 -0
- package/dist/testnet/keys/keystore/file.d.ts +177 -0
- package/dist/testnet/keys/keystore/interface.d.ts +161 -0
- package/dist/testnet/keys/provider/interface.d.ts +170 -0
- package/dist/testnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
- package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
- package/dist/testnet/keys/verifier/interface.d.ts +70 -0
- package/dist/testnet/keys/verifier/memory.d.ts +37 -0
- package/dist/testnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/testnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/testnet/models/external-signing.d.ts +123 -0
- package/dist/testnet/models/functionInput.d.ts +7 -0
- package/dist/testnet/models/input/inputJSON.d.ts +1 -0
- package/dist/testnet/models/input/inputObject.d.ts +1 -0
- package/dist/testnet/models/keyPair.d.ts +4 -0
- package/dist/testnet/models/output/outputJSON.d.ts +1 -0
- package/dist/testnet/models/output/outputObject.d.ts +1 -0
- package/dist/testnet/models/provingResponse.d.ts +48 -2
- package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
- package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
- package/dist/testnet/models/record-scanner/error.d.ts +47 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +22 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/testnet/models/record-scanner/revokeResult.d.ts +17 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
- package/dist/testnet/models/record-scanner/statusResponse.d.ts +13 -0
- package/dist/testnet/models/record-scanner/statusResult.d.ts +13 -0
- package/dist/testnet/models/record-scanner/tagsResult.d.ts +12 -0
- package/dist/testnet/network-client.d.ts +129 -46
- package/dist/testnet/node-polyfill.js +2 -49
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.d.ts +1 -0
- package/dist/testnet/node.js +376 -4
- package/dist/testnet/node.js.map +1 -1
- package/dist/testnet/program-manager.d.ts +538 -58
- package/dist/testnet/record-provider.d.ts +113 -75
- package/dist/testnet/record-scanner.d.ts +368 -0
- package/dist/testnet/security.d.ts +62 -0
- package/dist/testnet/utils.d.ts +1 -0
- package/dist/testnet/wasm.d.ts +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { EncryptedRecord } from "./models/record-provider/encryptedRecord";
|
|
2
|
+
import { CryptoBoxPubKey } from "./models/cryptoBoxPubkey.js";
|
|
3
|
+
import { OwnedFilter } from "./models/record-scanner/ownedFilter";
|
|
4
|
+
import { OwnedRecord } from "./models/record-provider/ownedRecord";
|
|
5
|
+
import { RecordProvider } from "./record-provider";
|
|
6
|
+
import { Field, ViewKey } from "./wasm";
|
|
7
|
+
import { RecordsFilter } from "./models/record-scanner/recordsFilter";
|
|
8
|
+
import { RegisterResult } from "./models/record-scanner/registrationResult.js";
|
|
9
|
+
import { RevokeResult } from "./models/record-scanner/revokeResult.js";
|
|
10
|
+
import { TagsResult } from "./models/record-scanner/tagsResult.js";
|
|
11
|
+
import { SerialNumbersResult } from "./models/record-scanner/serialNumbersResult.js";
|
|
12
|
+
import { StatusResult } from "./models/record-scanner/statusResult.js";
|
|
13
|
+
import { OwnedRecordsResult } from "./models/record-scanner/ownedRecordsResult.js";
|
|
14
|
+
import { EncryptedRecordsResult } from "./models/record-scanner/encryptedRecordsResult.js";
|
|
15
|
+
import { Account } from "./account.js";
|
|
16
|
+
/**
|
|
17
|
+
* JWT data for optional authentication with the record scanning service (e.g. Provable API).
|
|
18
|
+
*
|
|
19
|
+
* @property {string} jwt The JWT token string.
|
|
20
|
+
* @property {number} expiration Expiration time as a Unix timestamp (e.g. in milliseconds).
|
|
21
|
+
*/
|
|
22
|
+
export interface RecordScannerJWTData {
|
|
23
|
+
jwt: string;
|
|
24
|
+
expiration: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for the record scanner.
|
|
28
|
+
*
|
|
29
|
+
* @property {string} url Base URL of the record scanning service (network path is appended by the SDK).
|
|
30
|
+
* @property {string | { header: string, value: string }} [apiKey] API key as a string or as a custom header name and value.
|
|
31
|
+
* @property {string} [consumerId] Required for JWT refresh when using authenticated record scanner (e.g. Provable API).
|
|
32
|
+
* @property {RecordScannerJWTData} [jwtData] Optional JWT for auth. If omitted and apiKey + consumerId are set, JWT is refreshed when needed.
|
|
33
|
+
* @property {ViewKey[]} [viewKeys] Optional view keys to use for local scanning and decryption.
|
|
34
|
+
* @property {Account} [account] Optional account to use for local scanning and decryption.
|
|
35
|
+
* @property {boolean} [cacheViewKeysOnRegister] Cache view keys in memory for faster scanning upon register.
|
|
36
|
+
* @property {boolean} [autoReRegister] If true, on 422 from /owned attempt one re-register via registerEncrypted (when a view key is in viewKeys or account) and retry once. Default false.
|
|
37
|
+
* @property {boolean} [decryptEnabled] If true, enable decryption of owned records (e.g. for use with the decrypt method). This is REQUIRED for findCreditsRecord/findCreditsRecords to work properly. Further the ViewKey matching the UUID must be stored in the RecordScanner object to perform decryption. Default false.
|
|
38
|
+
*/
|
|
39
|
+
export interface RecordScannerOptions {
|
|
40
|
+
url: string;
|
|
41
|
+
apiKey?: string | {
|
|
42
|
+
header: string;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
consumerId?: string;
|
|
46
|
+
jwtData?: RecordScannerJWTData;
|
|
47
|
+
viewKeys?: ViewKey[];
|
|
48
|
+
account?: Account;
|
|
49
|
+
cacheViewKeysOnRegister?: boolean;
|
|
50
|
+
autoReRegister?: boolean;
|
|
51
|
+
decryptEnabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* RecordScanner is a RecordProvider implementation that uses Provable's confidential record scanning service to find
|
|
55
|
+
* records.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const account = new Account({ privateKey: 'APrivateKey1...' });
|
|
59
|
+
*
|
|
60
|
+
* const recordScanner = new RecordScanner({ url: "https://record-scanner.aleo.org" });
|
|
61
|
+
* recordScanner.setAccount(account);
|
|
62
|
+
* recordScanner.setApiKey("example-api-key");
|
|
63
|
+
* const result = await recordScanner.register(viewKey, 0);
|
|
64
|
+
* if (result.ok) { const uuid = result.data.uuid; }
|
|
65
|
+
*
|
|
66
|
+
* const filter = {
|
|
67
|
+
* uuid,
|
|
68
|
+
* filter: {
|
|
69
|
+
* program: "credits.aleo",
|
|
70
|
+
* records: ["credits"],
|
|
71
|
+
* },
|
|
72
|
+
* responseFilter: {
|
|
73
|
+
* commitment: true,
|
|
74
|
+
* owner: true,
|
|
75
|
+
* tag: true,
|
|
76
|
+
* tag?: boolean;
|
|
77
|
+
* sender: true,
|
|
78
|
+
* spent: true,
|
|
79
|
+
* record_ciphertext: true,
|
|
80
|
+
* block_height: true;
|
|
81
|
+
* block_timestamp: true;
|
|
82
|
+
* output_index: true;
|
|
83
|
+
* record_name: true;
|
|
84
|
+
* function_name: true;
|
|
85
|
+
* program_name: true;
|
|
86
|
+
* transition_id: true;
|
|
87
|
+
* transaction_id: true;
|
|
88
|
+
* transaction_index: true;
|
|
89
|
+
* transition_index: true;
|
|
90
|
+
* },
|
|
91
|
+
* unspent: true,
|
|
92
|
+
* };
|
|
93
|
+
*
|
|
94
|
+
* const records = await recordScanner.findRecords(filter);
|
|
95
|
+
*/
|
|
96
|
+
declare class RecordScanner implements RecordProvider {
|
|
97
|
+
readonly cacheViewKeysOnRegister?: boolean;
|
|
98
|
+
readonly url: string;
|
|
99
|
+
private readonly baseUrl;
|
|
100
|
+
private apiKey?;
|
|
101
|
+
private consumerId?;
|
|
102
|
+
private jwtData?;
|
|
103
|
+
private uuid?;
|
|
104
|
+
private viewKeys?;
|
|
105
|
+
private autoReRegister?;
|
|
106
|
+
private decryptEnabled?;
|
|
107
|
+
account?: Account | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* @param {RecordScannerOptions} options Configuration for the record scanner.
|
|
110
|
+
*/
|
|
111
|
+
constructor(options: RecordScannerOptions);
|
|
112
|
+
/**
|
|
113
|
+
* Set the API key to use for the record scanner.
|
|
114
|
+
*
|
|
115
|
+
* @param {string | { header: string, value: string }} apiKey The API key to use for the record scanner.
|
|
116
|
+
*/
|
|
117
|
+
setApiKey(apiKey: string | {
|
|
118
|
+
header: string;
|
|
119
|
+
value: string;
|
|
120
|
+
}): void;
|
|
121
|
+
/**
|
|
122
|
+
* Set the consumer ID used for JWT refresh when using authenticated record scanner (e.g. Provable API).
|
|
123
|
+
*
|
|
124
|
+
* @param {string} consumerId The consumer ID to use for JWT refresh.
|
|
125
|
+
*/
|
|
126
|
+
setConsumerId(consumerId: string): void;
|
|
127
|
+
/**
|
|
128
|
+
* Set JWT data for authentication. Optional; when not set, JWT can be refreshed from apiKey + consumerId if provided.
|
|
129
|
+
*
|
|
130
|
+
* @param {RecordScannerJWTData | undefined} jwtData The JWT data to use, or undefined to clear.
|
|
131
|
+
*/
|
|
132
|
+
setJwtData(jwtData: RecordScannerJWTData | undefined): void;
|
|
133
|
+
/**
|
|
134
|
+
* Set whether /owned should automatically re-register on 422 (when a view key for the UUID is in viewKeys or account) and retry once.
|
|
135
|
+
*
|
|
136
|
+
* @param {boolean} enabled Whether to enable auto re-register on 422.
|
|
137
|
+
*/
|
|
138
|
+
setAutoReRegister(enabled: boolean): void;
|
|
139
|
+
/**
|
|
140
|
+
* Set whether decryption of owned records is enabled (e.g. for use with the decrypt method).
|
|
141
|
+
*
|
|
142
|
+
* @param {boolean} enabled Whether to enable decryption of owned records received from the scanner using the `owned` or any `findRecords` methods.
|
|
143
|
+
*/
|
|
144
|
+
setDecryptEnabled(enabled: boolean): void;
|
|
145
|
+
/**
|
|
146
|
+
* Add a view key to the record scanner for usage in local decryption. This is REQUIRED for findCreditsRecord/findCreditsRecords to work properly.
|
|
147
|
+
*
|
|
148
|
+
* @param {ViewKey} viewKey The view key to add.
|
|
149
|
+
*/
|
|
150
|
+
addViewKey(viewKey: ViewKey): void;
|
|
151
|
+
/**
|
|
152
|
+
* Remove a view key from the record scanner.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} uuid The uuid of the view key to remove.
|
|
155
|
+
*/
|
|
156
|
+
removeViewKey(uuid: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* Return the view key for the given record-scanner UUID if one is configured
|
|
159
|
+
* (in viewKeys or as the account's view key). Used to decide if re-registration on 422 is possible.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} uuid The record-scanner UUID to look up.
|
|
162
|
+
* @returns {ViewKey | undefined} The view key for that UUID, or undefined.
|
|
163
|
+
*/
|
|
164
|
+
private getViewKeyForUuid;
|
|
165
|
+
/**
|
|
166
|
+
* Set the primary account for the record scanner.
|
|
167
|
+
*
|
|
168
|
+
* @param {Account} account The account to set as the primary account.
|
|
169
|
+
*/
|
|
170
|
+
setAccount(account: Account): void;
|
|
171
|
+
/**
|
|
172
|
+
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}. Used when authentication is required.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} apiKey The API key to use for the refresh request.
|
|
175
|
+
* @param {string} consumerId The consumer ID for the JWT endpoint.
|
|
176
|
+
* @returns {Promise<RecordScannerJWTData>} The new JWT data.
|
|
177
|
+
*/
|
|
178
|
+
private refreshJwt;
|
|
179
|
+
/**
|
|
180
|
+
* Returns auth headers (e.g. Authorization with JWT). Refreshes JWT if expired and apiKey + consumerId are set. Empty when auth is not configured.
|
|
181
|
+
*
|
|
182
|
+
* @returns {Promise<Record<string, string>>} Auth headers to add to requests, or empty object when not configured.
|
|
183
|
+
*/
|
|
184
|
+
private getAuthHeaders;
|
|
185
|
+
/**
|
|
186
|
+
* Set the UUID for the record scanner.
|
|
187
|
+
*
|
|
188
|
+
* @param {Field | ViewKey} keyMaterial The UUID to use for the record scanner. If a ViewKey is provided, the UUID will be computed from the key.
|
|
189
|
+
*/
|
|
190
|
+
setUuid(keyMaterial: Field | ViewKey): void;
|
|
191
|
+
/**
|
|
192
|
+
* If the error is a RecordScannerRequestError (from request()), return a RecordScannerFailure result;
|
|
193
|
+
* otherwise re-throw the error.
|
|
194
|
+
*
|
|
195
|
+
* @param {unknown} err The error from a failed request (e.g. from request() or from a catch after calling it).
|
|
196
|
+
* @returns {RecordScannerFailure} When err is RecordScannerRequestError.
|
|
197
|
+
* @throws Re-throws err when it is not a RecordScannerRequestError.
|
|
198
|
+
*/
|
|
199
|
+
private handleRequestError;
|
|
200
|
+
/**
|
|
201
|
+
* Register the account with the record scanning service (unencrypted POST /register). Does not throw if a valid error response from the record scanner is received; returns a result object instead.
|
|
202
|
+
*
|
|
203
|
+
* @param {ViewKey} viewKey The view key to register.
|
|
204
|
+
* @param {number} startBlock The block height to start scanning from.
|
|
205
|
+
* @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.
|
|
206
|
+
*/
|
|
207
|
+
register(viewKey: ViewKey, startBlock: number): Promise<RegisterResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Fetches an ephemeral public key from the record scanning service for use with registerEncrypted.
|
|
210
|
+
* Follows the same pattern as the delegated proving service /pubkey endpoint.
|
|
211
|
+
*
|
|
212
|
+
* @returns {Promise<CryptoBoxPubKey>} The service's ephemeral public key and key_id.
|
|
213
|
+
*/
|
|
214
|
+
getPubkey(): Promise<CryptoBoxPubKey>;
|
|
215
|
+
/**
|
|
216
|
+
* Registers the account with the record scanning service using the encrypted flow: 1. fetches an ephemeral public key from /pubkey - 2. encrypts the registration request (view key + start block) - 3. POSTs to /register/encrypted. Does not HTTP error on a proper error response from the record scanner; returns a result object instead.
|
|
217
|
+
*
|
|
218
|
+
* @param {ViewKey} viewKey The view key to register.
|
|
219
|
+
* @param {number} startBlock The block height to start scanning from.
|
|
220
|
+
* @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.
|
|
221
|
+
*/
|
|
222
|
+
registerEncrypted(viewKey: ViewKey, startBlock: number): Promise<RegisterResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Remove all local scanner state associated with the given UUID (stored uuid, viewKeys entry, account if it matches).
|
|
225
|
+
* Called after a successful revoke so the scanner does not retain view keys or account for a revoked registration.
|
|
226
|
+
*/
|
|
227
|
+
private clearLocalStateForUuid;
|
|
228
|
+
/**
|
|
229
|
+
* Revoke the account registration with the record scanning service (POST /revoke). On success, also removes
|
|
230
|
+
* all local state for that UUID: the stored UUID (if it matches), the view key for that UUID, and the
|
|
231
|
+
* account (if its view key corresponds to that UUID).
|
|
232
|
+
*
|
|
233
|
+
* @param {string | Field | undefined} uuid The UUID to revoke. If omitted, uses the UUID configured on the scanner.
|
|
234
|
+
* @returns {Promise<RevokeResult>} `{ ok: true, data: { status } }` on success, or `{ ok: false, status, error }` on failure.
|
|
235
|
+
* @throws {UUIDError} When no UUID is configured and none provided, or when the UUID string is invalid.
|
|
236
|
+
*/
|
|
237
|
+
revoke(uuid?: string | Field): Promise<RevokeResult>;
|
|
238
|
+
/**
|
|
239
|
+
* Get encrypted records from the record scanning service. This is a safe variant of /records/encrypted that returns
|
|
240
|
+
* a result instead of throwing on HTTP error.
|
|
241
|
+
*
|
|
242
|
+
* @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
|
|
243
|
+
* @returns {Promise<EncryptedRecordsResult>} The encrypted records or an error if the request failed.
|
|
244
|
+
*/
|
|
245
|
+
encrypted(recordsFilter: RecordsFilter): Promise<EncryptedRecordsResult>;
|
|
246
|
+
/**
|
|
247
|
+
* Get encrypted records from the record scanning service.
|
|
248
|
+
*
|
|
249
|
+
* @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
|
|
250
|
+
* @returns {Promise<EncryptedRecord[]>} The encrypted records.
|
|
251
|
+
*/
|
|
252
|
+
encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Check if serial numbers appear in any record inputs on-chain, indicating that the records they belong to have been spent. This is a safe variant of /records/sns that returns a result instead of throwing on HTTP error.
|
|
255
|
+
*
|
|
256
|
+
* @param {string[]} serialNumbers The serial numbers to check.
|
|
257
|
+
* @returns {Promise<SerialNumbersResult>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If a boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.
|
|
258
|
+
*/
|
|
259
|
+
serialNumbers(serialNumbers: string[]): Promise<SerialNumbersResult>;
|
|
260
|
+
/**
|
|
261
|
+
* Check if serial numbers appear in any record inputs on-chain, indicating that the records they belong to have been spent.
|
|
262
|
+
*
|
|
263
|
+
* @param {string[]} serialNumbers The serial numbers to check.
|
|
264
|
+
* @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.
|
|
265
|
+
*/
|
|
266
|
+
checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
|
|
267
|
+
/**
|
|
268
|
+
* Check if tags appear in any record inputs on-chain, indicating that the records they belong to have been spent. This is a safe variant of /records/tags that returns a result instead of throwing on HTTP error.
|
|
269
|
+
*
|
|
270
|
+
* *
|
|
271
|
+
* @param {string[]} tags The tags to check.
|
|
272
|
+
* @returns {Promise<TagsResult>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If a boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.
|
|
273
|
+
*/
|
|
274
|
+
tags(tags: string[]): Promise<TagsResult>;
|
|
275
|
+
/**
|
|
276
|
+
* Check if tags appear in any record inputs on-chain, indicating that the records they belong to have been spent.
|
|
277
|
+
*
|
|
278
|
+
* @param {string[]} tags The tags to check.
|
|
279
|
+
* @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.
|
|
280
|
+
*/
|
|
281
|
+
checkTags(tags: string[]): Promise<Record<string, boolean>>;
|
|
282
|
+
/**
|
|
283
|
+
* Check the scan completion job status for a specific UUID.
|
|
284
|
+
*
|
|
285
|
+
* @param {string | Field | undefined} uuid The UUID of the job to check. If no UUID is provided as input, the UUID configured for the scanner will be used.
|
|
286
|
+
* @returns {Promise<StatusResult>} The status of the job or an error if the job could not be found.
|
|
287
|
+
*/
|
|
288
|
+
status(uuid?: string | Field): Promise<StatusResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Find a record in the record scanning service.
|
|
291
|
+
*
|
|
292
|
+
* @param {OwnedFilter} searchParameters The filter to use to find the record.
|
|
293
|
+
* @returns {Promise<OwnedRecord>} The record.
|
|
294
|
+
*/
|
|
295
|
+
findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord>;
|
|
296
|
+
/**
|
|
297
|
+
* Get owned records. Throws if the UUID passed in the OwnedFilter is invalid or is not configured in the record scanner otherwise returns the RESTFUL response from the record scanner.
|
|
298
|
+
*
|
|
299
|
+
* @param {OwnedFilter} filter The OwnedFilter used to specify the subset of owned records to select.
|
|
300
|
+
* @returns {Promise<OwnedRecordsResult>} Record belonging to the uuid passed in the filter or set on the Record Scanner.
|
|
301
|
+
*/
|
|
302
|
+
owned(filter: OwnedFilter): Promise<OwnedRecordsResult>;
|
|
303
|
+
/**
|
|
304
|
+
* Find records using the record scanning service.
|
|
305
|
+
*
|
|
306
|
+
* @param {OwnedFilter} searchParameters The filter to use to find the records.
|
|
307
|
+
* @returns {Promise<OwnedRecord[]>} The records.
|
|
308
|
+
*/
|
|
309
|
+
findRecords(searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Get RecordPlaintext from an OwnedRecord by parsing record_plaintext (trimmed). Returns null if missing or parse fails. Does not decrypt; decryption is handled only in owned().
|
|
312
|
+
*/
|
|
313
|
+
private getPlaintext;
|
|
314
|
+
/**
|
|
315
|
+
* For each owned record provided, attempt to decrypt with the given view key. On success, sets record_plaintext on that record to the decrypted plaintext string. Records that fail to decrypt (e.g. wrong view key) or have no record_ciphertext are left unchanged.
|
|
316
|
+
*
|
|
317
|
+
* @param {ViewKey} viewKey The view key to use for decryption.
|
|
318
|
+
* @param {OwnedRecord[]} records The owned records to decrypt (mutated in place).
|
|
319
|
+
*/
|
|
320
|
+
decrypt(viewKey: ViewKey, records: OwnedRecord[]): void;
|
|
321
|
+
/**
|
|
322
|
+
* Find a credits.aleo record in the record scanning service.
|
|
323
|
+
*
|
|
324
|
+
* @param {number} microcredits The amount of microcredits to find.
|
|
325
|
+
* @param {OwnedFilter} searchParameters The filter to use to find the record.
|
|
326
|
+
* @returns {Promise<OwnedRecord>} The record.
|
|
327
|
+
*/
|
|
328
|
+
findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord>;
|
|
329
|
+
/**
|
|
330
|
+
* Find credits records greater than or equal to the specified amounts using the record scanning service.
|
|
331
|
+
*
|
|
332
|
+
* @param {number[]} microcreditAmounts The amounts of microcredits to find.
|
|
333
|
+
* @param {OwnedFilter} searchParameters The filter to use to find the records.
|
|
334
|
+
* @returns {Promise<OwnedRecord[]>} The records
|
|
335
|
+
*/
|
|
336
|
+
findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
|
|
337
|
+
/**
|
|
338
|
+
* Wrapper function to make a request to the record scanning service and handle any errors. Optionally adds JWT Authorization header when consumerId/jwtData (or apiKey+consumerId) are configured.
|
|
339
|
+
*
|
|
340
|
+
* @param {Request} req The request to make.
|
|
341
|
+
* @returns {Promise<Response>} The response when the request succeeds.
|
|
342
|
+
* @throws {RecordScannerRequestError} When the server returns a non-2xx status (e.g. 4xx, 5xx).
|
|
343
|
+
* @throws Re-throws any error from fetch (e.g. network failure) or from getAuthHeaders().
|
|
344
|
+
*/
|
|
345
|
+
private request;
|
|
346
|
+
/**
|
|
347
|
+
* Compute the record scanner UUID for a view key.
|
|
348
|
+
*
|
|
349
|
+
* @param {ViewKey} viewKey The view key to compute the UUID for.
|
|
350
|
+
* @returns {Field} The computed UUID corresponding to the view key.
|
|
351
|
+
*/
|
|
352
|
+
computeUUID(viewKey: ViewKey): Field;
|
|
353
|
+
/**
|
|
354
|
+
* Validate a UUID string to ensure it represents a valid Aleo Record Scanner UUID.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} uuid The UUID to validate.
|
|
357
|
+
* @returns {boolean} Whether the UUID is valid.
|
|
358
|
+
*/
|
|
359
|
+
uuidIsValid(uuid: string): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Get the uuid for the filter, first by extracting the UUID from the filter, then falling back to the uuid configured within the record scanner.
|
|
362
|
+
*
|
|
363
|
+
* @param {OwnedFilter} filter The filter to extract the UUID from.
|
|
364
|
+
* @returns {string | undefined} The UUID for the filter, or undefined if the filter does not contain a UUID.
|
|
365
|
+
*/
|
|
366
|
+
private getUUID;
|
|
367
|
+
}
|
|
368
|
+
export { RecordScanner };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ViewKey, Authorization, ProvingRequest } from "@provablehq/wasm";
|
|
2
|
+
/**
|
|
3
|
+
* Encrypt an authorization with a libsodium cryptobox public key.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).
|
|
6
|
+
* @param {Authorization} authorization the authorization to encrypt.
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} the encrypted authorization in RFC 4648 standard Base64.
|
|
9
|
+
*/
|
|
10
|
+
export declare function encryptAuthorization(publicKey: string, authorization: Authorization): string;
|
|
11
|
+
/**
|
|
12
|
+
* Encrypt a ProvingRequest with a libsodium cryptobox public key.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).
|
|
15
|
+
* @param {Authorization} provingRequest the ProvingRequest to encrypt.
|
|
16
|
+
*
|
|
17
|
+
* @returns {string} the encrypted ProvingRequest in RFC 4648 standard Base64.
|
|
18
|
+
*/
|
|
19
|
+
export declare function encryptProvingRequest(publicKey: string, provingRequest: ProvingRequest): string;
|
|
20
|
+
/**
|
|
21
|
+
* Encrypt a view key with a libsodium cryptobox public key.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).
|
|
24
|
+
* @param {ViewKey} viewKey the view key to encrypt.
|
|
25
|
+
*
|
|
26
|
+
* @returns {string} the encrypted view key in RFC 4648 standard Base64.
|
|
27
|
+
*/
|
|
28
|
+
export declare function encryptViewKey(publicKey: string, viewKey: ViewKey): string;
|
|
29
|
+
/**
|
|
30
|
+
* Encrypt a record scanner registration request.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).
|
|
33
|
+
* @param {ViewKey} viewKey the view key to encrypt.
|
|
34
|
+
* @param {number} start the start height of the registration request.
|
|
35
|
+
*
|
|
36
|
+
* @returns {string} the encrypted view key in RFC 4648 standard Base64.
|
|
37
|
+
*/
|
|
38
|
+
export declare function encryptRegistrationRequest(publicKey: string, viewKey: ViewKey, start: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* Best-effort zeroization of a byte array by overwriting all bytes with zeros.
|
|
41
|
+
* Use this to clear sensitive data (e.g., key bytes) from memory when working
|
|
42
|
+
* with Uint8Array representations of keys or other secrets.
|
|
43
|
+
*
|
|
44
|
+
* This is best-effort in JavaScript — the JIT compiler could theoretically
|
|
45
|
+
* elide the fill if the array is never read again (though current engines
|
|
46
|
+
* do not). For deterministic zeroization of key material, use
|
|
47
|
+
* `Account.destroy()` or call `.free()` on key objects (PrivateKey, ViewKey,
|
|
48
|
+
* ComputeKey, GraphKey) whose Rust Drop implementations zeroize memory
|
|
49
|
+
* before deallocation.
|
|
50
|
+
*
|
|
51
|
+
* Note: This cannot zeroize JavaScript strings, which are immutable and managed
|
|
52
|
+
* by the garbage collector. Prefer using byte array representations of sensitive
|
|
53
|
+
* data over strings whenever possible.
|
|
54
|
+
*
|
|
55
|
+
* @param {Uint8Array} bytes The byte array to zeroize
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const keyBytes = privateKey.toBytesLe();
|
|
59
|
+
* // ... use keyBytes ...
|
|
60
|
+
* zeroizeBytes(keyBytes); // Overwrite with zeros when done
|
|
61
|
+
*/
|
|
62
|
+
export declare function zeroizeBytes(bytes: Uint8Array): void;
|
package/dist/testnet/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function isNode(): boolean;
|
|
1
2
|
export declare function environment(): "chrome" | "firefox" | "safari" | "edge" | "opera" | "browser" | "node" | "unknown";
|
|
2
3
|
export declare function logAndThrow(message: string): never;
|
|
3
4
|
export declare function parseJSON(json: string): any;
|
package/dist/testnet/wasm.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
|
|
1
|
+
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, stringToField, Signature, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provablehq/sdk",
|
|
3
|
-
"version": "0.10.0
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
|
|
5
5
|
"collaborators": [
|
|
6
6
|
"The Provable Team"
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"./mainnet.js": {
|
|
22
22
|
"node": "./dist/mainnet/node.js",
|
|
23
23
|
"default": "./dist/mainnet/browser.js"
|
|
24
|
+
},
|
|
25
|
+
"./dynamic.js": {
|
|
26
|
+
"node": "./dist/dynamic/node.js",
|
|
27
|
+
"default": "./dist/dynamic/browser.js"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"files": [
|
|
@@ -30,7 +34,7 @@
|
|
|
30
34
|
],
|
|
31
35
|
"scripts": {
|
|
32
36
|
"build": "rimraf dist && rollup -c rollup.config.js",
|
|
33
|
-
"test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000"
|
|
37
|
+
"test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000 && RUN_SKIPPED=true mocha tmp/**/wasm.test.js --timeout 60000 --grep Consensus"
|
|
34
38
|
},
|
|
35
39
|
"repository": {
|
|
36
40
|
"type": "git",
|
|
@@ -47,12 +51,13 @@
|
|
|
47
51
|
},
|
|
48
52
|
"homepage": "https://github.com/ProvableHQ/sdk#readme",
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@provablehq/wasm": "^0.10.0
|
|
54
|
+
"@provablehq/wasm": "^0.10.0",
|
|
55
|
+
"@scure/base": "^2.0.0",
|
|
51
56
|
"comlink": "^4.4.2",
|
|
52
57
|
"core-js": "^3.40.0",
|
|
53
58
|
"mime": "^4.0.6",
|
|
54
|
-
"
|
|
55
|
-
"xmlhttprequest-ssl": "^
|
|
59
|
+
"libsodium-wrappers": "^0.8.2",
|
|
60
|
+
"xmlhttprequest-ssl": "^4.0.0"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
63
|
"@rollup/plugin-replace": "^6.0.2",
|
|
@@ -74,7 +79,7 @@
|
|
|
74
79
|
"mocha": "^11.1.0",
|
|
75
80
|
"prettier": "3.4.2",
|
|
76
81
|
"rimraf": "^6.0.1",
|
|
77
|
-
"rollup": "^4.
|
|
82
|
+
"rollup": "^4.59.0",
|
|
78
83
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
79
84
|
"sinon": "^19.0.2",
|
|
80
85
|
"typescript": "^5.7.3"
|