@provablehq/sdk 0.9.15 → 0.9.16
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/mainnet/account.d.ts +18 -3
- package/dist/mainnet/browser.d.ts +18 -3
- package/dist/mainnet/browser.js +988 -193
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/function-key-provider.d.ts +10 -10
- package/dist/mainnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/mainnet/models/provingResponse.d.ts +48 -2
- 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 +0 -2
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +0 -2
- package/dist/mainnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.ts +15 -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 +81 -35
- package/dist/mainnet/node.js +2 -1
- package/dist/mainnet/node.js.map +1 -1
- package/dist/mainnet/offline-key-provider.d.ts +1 -1
- package/dist/mainnet/program-manager.d.ts +52 -46
- package/dist/mainnet/record-provider.d.ts +7 -7
- package/dist/mainnet/record-scanner.d.ts +231 -31
- package/dist/mainnet/security.d.ts +38 -0
- package/dist/mainnet/utils.d.ts +1 -0
- package/dist/testnet/account.d.ts +18 -3
- package/dist/testnet/browser.d.ts +18 -3
- package/dist/testnet/browser.js +988 -193
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/function-key-provider.d.ts +10 -10
- package/dist/testnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/testnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/testnet/models/provingResponse.d.ts +48 -2
- 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 +0 -2
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.ts +0 -2
- package/dist/testnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.ts +15 -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 +81 -35
- package/dist/testnet/node.js +2 -1
- package/dist/testnet/node.js.map +1 -1
- package/dist/testnet/offline-key-provider.d.ts +1 -1
- package/dist/testnet/program-manager.d.ts +52 -46
- package/dist/testnet/record-provider.d.ts +7 -7
- package/dist/testnet/record-scanner.d.ts +231 -31
- package/dist/testnet/security.d.ts +38 -0
- package/dist/testnet/utils.d.ts +1 -0
- package/package.json +3 -2
|
@@ -1,28 +1,66 @@
|
|
|
1
1
|
import { EncryptedRecord } from "./models/record-provider/encryptedRecord";
|
|
2
|
+
import { CryptoBoxPubKey } from "./models/cryptoBoxPubkey.js";
|
|
2
3
|
import { OwnedFilter } from "./models/record-scanner/ownedFilter";
|
|
3
4
|
import { OwnedRecord } from "./models/record-provider/ownedRecord";
|
|
4
5
|
import { RecordProvider } from "./record-provider";
|
|
5
6
|
import { Field, ViewKey } from "./wasm";
|
|
6
7
|
import { RecordsFilter } from "./models/record-scanner/recordsFilter";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { RegisterResult } from "./models/record-scanner/registrationResult.js";
|
|
9
|
+
import { TagsResult } from "./models/record-scanner/tagsResult.js";
|
|
10
|
+
import { SerialNumbersResult } from "./models/record-scanner/serialNumbersResult.js";
|
|
11
|
+
import { StatusResult } from "./models/record-scanner/statusResult.js";
|
|
12
|
+
import { OwnedRecordsResult } from "./models/record-scanner/ownedRecordsResult.js";
|
|
13
|
+
import { EncryptedRecordsResult } from "./models/record-scanner/encryptedRecordsResult.js";
|
|
14
|
+
import { Account } from "./account.js";
|
|
15
|
+
/**
|
|
16
|
+
* JWT data for optional authentication with the record scanning service (e.g. Provable API).
|
|
17
|
+
*
|
|
18
|
+
* @property {string} jwt The JWT token string.
|
|
19
|
+
* @property {number} expiration Expiration time as a Unix timestamp (e.g. in milliseconds).
|
|
20
|
+
*/
|
|
21
|
+
export interface RecordScannerJWTData {
|
|
22
|
+
jwt: string;
|
|
23
|
+
expiration: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for the record scanner.
|
|
27
|
+
*
|
|
28
|
+
* @property {string} url Base URL of the record scanning service (network path is appended by the SDK).
|
|
29
|
+
* @property {string | { header: string, value: string }} [apiKey] API key as a string or as a custom header name and value.
|
|
30
|
+
* @property {string} [consumerId] Required for JWT refresh when using authenticated record scanner (e.g. Provable API).
|
|
31
|
+
* @property {RecordScannerJWTData} [jwtData] Optional JWT for auth. If omitted and apiKey + consumerId are set, JWT is refreshed when needed.
|
|
32
|
+
* @property {ViewKey[]} [viewKeys] Optional view keys to use for local scanning and decryption.
|
|
33
|
+
* @property {Account} [account] Optional account to use for local scanning and decryption.
|
|
34
|
+
* @property {boolean} [cacheViewKeysOnRegister] Cache view keys in memory for faster scanning upon register.
|
|
35
|
+
* @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.
|
|
36
|
+
* @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.
|
|
37
|
+
*/
|
|
38
|
+
export interface RecordScannerOptions {
|
|
10
39
|
url: string;
|
|
11
40
|
apiKey?: string | {
|
|
12
41
|
header: string;
|
|
13
42
|
value: string;
|
|
14
43
|
};
|
|
15
|
-
|
|
44
|
+
consumerId?: string;
|
|
45
|
+
jwtData?: RecordScannerJWTData;
|
|
46
|
+
viewKeys?: ViewKey[];
|
|
47
|
+
account?: Account;
|
|
48
|
+
cacheViewKeysOnRegister?: boolean;
|
|
49
|
+
autoReRegister?: boolean;
|
|
50
|
+
decryptEnabled?: boolean;
|
|
51
|
+
}
|
|
16
52
|
/**
|
|
17
|
-
* RecordScanner is a RecordProvider implementation that uses
|
|
53
|
+
* RecordScanner is a RecordProvider implementation that uses Provable's confidential record scanning service to find
|
|
54
|
+
* records.
|
|
18
55
|
*
|
|
19
56
|
* @example
|
|
20
57
|
* const account = new Account({ privateKey: 'APrivateKey1...' });
|
|
21
58
|
*
|
|
22
59
|
* const recordScanner = new RecordScanner({ url: "https://record-scanner.aleo.org" });
|
|
23
60
|
* recordScanner.setAccount(account);
|
|
24
|
-
* recordScanner.setApiKey("
|
|
25
|
-
* const
|
|
61
|
+
* recordScanner.setApiKey("example-api-key");
|
|
62
|
+
* const result = await recordScanner.register(viewKey, 0);
|
|
63
|
+
* if (result.ok) { const uuid = result.data.uuid; }
|
|
26
64
|
*
|
|
27
65
|
* const filter = {
|
|
28
66
|
* uuid,
|
|
@@ -55,76 +93,216 @@ type RecordScannerOptions = {
|
|
|
55
93
|
* const records = await recordScanner.findRecords(filter);
|
|
56
94
|
*/
|
|
57
95
|
declare class RecordScanner implements RecordProvider {
|
|
96
|
+
readonly cacheViewKeysOnRegister?: boolean;
|
|
58
97
|
readonly url: string;
|
|
59
98
|
private apiKey?;
|
|
99
|
+
private consumerId?;
|
|
100
|
+
private jwtData?;
|
|
60
101
|
private uuid?;
|
|
102
|
+
private viewKeys?;
|
|
103
|
+
private autoReRegister?;
|
|
104
|
+
private decryptEnabled?;
|
|
105
|
+
account?: Account | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* @param {RecordScannerOptions} options Configuration for the record scanner.
|
|
108
|
+
*/
|
|
61
109
|
constructor(options: RecordScannerOptions);
|
|
62
110
|
/**
|
|
63
111
|
* Set the API key to use for the record scanner.
|
|
64
112
|
*
|
|
65
|
-
* @param {string} apiKey The API key to use for the record scanner.
|
|
113
|
+
* @param {string | { header: string, value: string }} apiKey The API key to use for the record scanner.
|
|
66
114
|
*/
|
|
67
115
|
setApiKey(apiKey: string | {
|
|
68
116
|
header: string;
|
|
69
117
|
value: string;
|
|
70
|
-
}):
|
|
118
|
+
}): void;
|
|
119
|
+
/**
|
|
120
|
+
* Set the consumer ID used for JWT refresh when using authenticated record scanner (e.g. Provable API).
|
|
121
|
+
*
|
|
122
|
+
* @param {string} consumerId The consumer ID to use for JWT refresh.
|
|
123
|
+
*/
|
|
124
|
+
setConsumerId(consumerId: string): void;
|
|
125
|
+
/**
|
|
126
|
+
* Set JWT data for authentication. Optional; when not set, JWT can be refreshed from apiKey + consumerId if provided.
|
|
127
|
+
*
|
|
128
|
+
* @param {RecordScannerJWTData | undefined} jwtData The JWT data to use, or undefined to clear.
|
|
129
|
+
*/
|
|
130
|
+
setJwtData(jwtData: RecordScannerJWTData | undefined): void;
|
|
131
|
+
/**
|
|
132
|
+
* Set whether /owned should automatically re-register on 422 (when a view key for the UUID is in viewKeys or account) and retry once.
|
|
133
|
+
*
|
|
134
|
+
* @param {boolean} enabled Whether to enable auto re-register on 422.
|
|
135
|
+
*/
|
|
136
|
+
setAutoReRegister(enabled: boolean): void;
|
|
137
|
+
/**
|
|
138
|
+
* Set whether decryption of owned records is enabled (e.g. for use with the decrypt method).
|
|
139
|
+
*
|
|
140
|
+
* @param {boolean} enabled Whether to enable decryption of owned records received from the scanner using the `owned` or any `findRecords` methods.
|
|
141
|
+
*/
|
|
142
|
+
setDecryptEnabled(enabled: boolean): void;
|
|
143
|
+
/**
|
|
144
|
+
* Add a view key to the record scanner for usage in local decryption. This is REQUIRED for findCreditsRecord/findCreditsRecords to work properly.
|
|
145
|
+
*
|
|
146
|
+
* @param {ViewKey} viewKey The view key to add.
|
|
147
|
+
*/
|
|
148
|
+
addViewKey(viewKey: ViewKey): void;
|
|
149
|
+
/**
|
|
150
|
+
* Remove a view key from the record scanner.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} uuid The uuid of the view key to remove.
|
|
153
|
+
*/
|
|
154
|
+
removeViewKey(uuid: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* Return the view key for the given record-scanner UUID if one is configured
|
|
157
|
+
* (in viewKeys or as the account's view key). Used to decide if re-registration on 422 is possible.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} uuid The record-scanner UUID to look up.
|
|
160
|
+
* @returns {ViewKey | undefined} The view key for that UUID, or undefined.
|
|
161
|
+
*/
|
|
162
|
+
private getViewKeyForUuid;
|
|
163
|
+
/**
|
|
164
|
+
* Set the primary account for the record scanner.
|
|
165
|
+
*
|
|
166
|
+
* @param {Account} account The account to set as the primary account.
|
|
167
|
+
*/
|
|
168
|
+
setAccount(account: Account): void;
|
|
169
|
+
/**
|
|
170
|
+
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}. Used when authentication is required.
|
|
171
|
+
*
|
|
172
|
+
* @param {string} apiKey The API key to use for the refresh request.
|
|
173
|
+
* @param {string} consumerId The consumer ID for the JWT endpoint.
|
|
174
|
+
* @returns {Promise<RecordScannerJWTData>} The new JWT data.
|
|
175
|
+
*/
|
|
176
|
+
private refreshJwt;
|
|
177
|
+
/**
|
|
178
|
+
* Returns auth headers (e.g. Authorization with JWT). Refreshes JWT if expired and apiKey + consumerId are set. Empty when auth is not configured.
|
|
179
|
+
*
|
|
180
|
+
* @returns {Promise<Record<string, string>>} Auth headers to add to requests, or empty object when not configured.
|
|
181
|
+
*/
|
|
182
|
+
private getAuthHeaders;
|
|
71
183
|
/**
|
|
72
|
-
* Set the UUID
|
|
184
|
+
* Set the UUID for the record scanner.
|
|
73
185
|
*
|
|
74
|
-
* @param {Field}
|
|
186
|
+
* @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.
|
|
75
187
|
*/
|
|
76
|
-
setUuid(
|
|
188
|
+
setUuid(keyMaterial: Field | ViewKey): void;
|
|
77
189
|
/**
|
|
78
|
-
*
|
|
190
|
+
* If the error is a RecordScannerRequestError (from request()), return a RecordScannerFailure result;
|
|
191
|
+
* otherwise re-throw the error.
|
|
79
192
|
*
|
|
193
|
+
* @param {unknown} err The error from a failed request (e.g. from request() or from a catch after calling it).
|
|
194
|
+
* @returns {RecordScannerFailure} When err is RecordScannerRequestError.
|
|
195
|
+
* @throws Re-throws err when it is not a RecordScannerRequestError.
|
|
196
|
+
*/
|
|
197
|
+
private handleRequestError;
|
|
198
|
+
/**
|
|
199
|
+
* 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.
|
|
200
|
+
*
|
|
201
|
+
* @param {ViewKey} viewKey The view key to register.
|
|
202
|
+
* @param {number} startBlock The block height to start scanning from.
|
|
203
|
+
* @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.
|
|
204
|
+
*/
|
|
205
|
+
register(viewKey: ViewKey, startBlock: number): Promise<RegisterResult>;
|
|
206
|
+
/**
|
|
207
|
+
* Fetches an ephemeral public key from the record scanning service for use with registerEncrypted.
|
|
208
|
+
* Follows the same pattern as the delegated proving service /pubkey endpoint.
|
|
209
|
+
*
|
|
210
|
+
* @returns {Promise<CryptoBoxPubKey>} The service's ephemeral public key and key_id.
|
|
211
|
+
*/
|
|
212
|
+
getPubkey(): Promise<CryptoBoxPubKey>;
|
|
213
|
+
/**
|
|
214
|
+
* 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.
|
|
215
|
+
*
|
|
216
|
+
* @param {ViewKey} viewKey The view key to register.
|
|
80
217
|
* @param {number} startBlock The block height to start scanning from.
|
|
81
|
-
* @returns {Promise<
|
|
218
|
+
* @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.
|
|
82
219
|
*/
|
|
83
|
-
|
|
220
|
+
registerEncrypted(viewKey: ViewKey, startBlock: number): Promise<RegisterResult>;
|
|
84
221
|
/**
|
|
85
|
-
* Get encrypted records from the record
|
|
222
|
+
* Get encrypted records from the record scanning service. This is a safe variant of /records/encrypted that returns
|
|
223
|
+
* a result instead of throwing on HTTP error.
|
|
224
|
+
*
|
|
225
|
+
* @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
|
|
226
|
+
* @returns {Promise<EncryptedRecordsResult>} The encrypted records or an error if the request failed.
|
|
227
|
+
*/
|
|
228
|
+
encrypted(recordsFilter: RecordsFilter): Promise<EncryptedRecordsResult>;
|
|
229
|
+
/**
|
|
230
|
+
* Get encrypted records from the record scanning service.
|
|
86
231
|
*
|
|
87
232
|
* @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
|
|
88
233
|
* @returns {Promise<EncryptedRecord[]>} The encrypted records.
|
|
89
234
|
*/
|
|
90
235
|
encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]>;
|
|
91
236
|
/**
|
|
92
|
-
* Check if a
|
|
237
|
+
* 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.
|
|
238
|
+
*
|
|
239
|
+
* @param {string[]} serialNumbers The serial numbers to check.
|
|
240
|
+
* @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.
|
|
241
|
+
*/
|
|
242
|
+
serialNumbers(serialNumbers: string[]): Promise<SerialNumbersResult>;
|
|
243
|
+
/**
|
|
244
|
+
* Check if serial numbers appear in any record inputs on-chain, indicating that the records they belong to have been spent.
|
|
93
245
|
*
|
|
94
246
|
* @param {string[]} serialNumbers The serial numbers to check.
|
|
95
247
|
* @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.
|
|
96
248
|
*/
|
|
97
249
|
checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
|
|
98
250
|
/**
|
|
99
|
-
* Check if a
|
|
251
|
+
* 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.
|
|
252
|
+
*
|
|
253
|
+
* *
|
|
254
|
+
* @param {string[]} tags The tags to check.
|
|
255
|
+
* @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.
|
|
256
|
+
*/
|
|
257
|
+
tags(tags: string[]): Promise<TagsResult>;
|
|
258
|
+
/**
|
|
259
|
+
* Check if tags appear in any record inputs on-chain, indicating that the records they belong to have been spent.
|
|
100
260
|
*
|
|
101
261
|
* @param {string[]} tags The tags to check.
|
|
102
262
|
* @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.
|
|
103
263
|
*/
|
|
104
264
|
checkTags(tags: string[]): Promise<Record<string, boolean>>;
|
|
105
265
|
/**
|
|
106
|
-
* Check the status
|
|
266
|
+
* Check the scan completion job status for a specific UUID.
|
|
107
267
|
*
|
|
108
|
-
* @param {string}
|
|
109
|
-
* @returns {Promise<
|
|
268
|
+
* @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.
|
|
269
|
+
* @returns {Promise<StatusResult>} The status of the job or an error if the job could not be found.
|
|
110
270
|
*/
|
|
111
|
-
|
|
271
|
+
status(uuid?: string | Field): Promise<StatusResult>;
|
|
112
272
|
/**
|
|
113
|
-
* Find a record in the record
|
|
273
|
+
* Find a record in the record scanning service.
|
|
114
274
|
*
|
|
115
275
|
* @param {OwnedFilter} searchParameters The filter to use to find the record.
|
|
116
276
|
* @returns {Promise<OwnedRecord>} The record.
|
|
117
277
|
*/
|
|
118
278
|
findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord>;
|
|
119
279
|
/**
|
|
120
|
-
*
|
|
280
|
+
* 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.
|
|
281
|
+
*
|
|
282
|
+
* @param {OwnedFilter} filter The OwnedFilter used to specify the subset of owned records to select.
|
|
283
|
+
* @returns {Promise<OwnedRecordsResult>} Record belonging to the uuid passed in the filter or set on the Record Scanner.
|
|
284
|
+
*/
|
|
285
|
+
owned(filter: OwnedFilter): Promise<OwnedRecordsResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Find records using the record scanning service.
|
|
121
288
|
*
|
|
122
|
-
* @param {OwnedFilter}
|
|
289
|
+
* @param {OwnedFilter} searchParameters The filter to use to find the records.
|
|
123
290
|
* @returns {Promise<OwnedRecord[]>} The records.
|
|
124
291
|
*/
|
|
125
|
-
findRecords(
|
|
292
|
+
findRecords(searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
|
|
293
|
+
/**
|
|
294
|
+
* 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().
|
|
295
|
+
*/
|
|
296
|
+
private getPlaintext;
|
|
297
|
+
/**
|
|
298
|
+
* 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.
|
|
299
|
+
*
|
|
300
|
+
* @param {ViewKey} viewKey The view key to use for decryption.
|
|
301
|
+
* @param {OwnedRecord[]} records The owned records to decrypt (mutated in place).
|
|
302
|
+
*/
|
|
303
|
+
decrypt(viewKey: ViewKey, records: OwnedRecord[]): void;
|
|
126
304
|
/**
|
|
127
|
-
* Find a credits record in the record
|
|
305
|
+
* Find a credits.aleo record in the record scanning service.
|
|
128
306
|
*
|
|
129
307
|
* @param {number} microcredits The amount of microcredits to find.
|
|
130
308
|
* @param {OwnedFilter} searchParameters The filter to use to find the record.
|
|
@@ -132,7 +310,7 @@ declare class RecordScanner implements RecordProvider {
|
|
|
132
310
|
*/
|
|
133
311
|
findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord>;
|
|
134
312
|
/**
|
|
135
|
-
* Find credits records using
|
|
313
|
+
* Find credits records greater than or equal to the specified amounts using the record scanning service.
|
|
136
314
|
*
|
|
137
315
|
* @param {number[]} microcreditAmounts The amounts of microcredits to find.
|
|
138
316
|
* @param {OwnedFilter} searchParameters The filter to use to find the records.
|
|
@@ -140,12 +318,34 @@ declare class RecordScanner implements RecordProvider {
|
|
|
140
318
|
*/
|
|
141
319
|
findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
|
|
142
320
|
/**
|
|
143
|
-
* Wrapper function to make a request to the record
|
|
321
|
+
* 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.
|
|
144
322
|
*
|
|
145
323
|
* @param {Request} req The request to make.
|
|
146
|
-
* @returns {Promise<Response>} The response.
|
|
324
|
+
* @returns {Promise<Response>} The response when the request succeeds.
|
|
325
|
+
* @throws {RecordScannerRequestError} When the server returns a non-2xx status (e.g. 4xx, 5xx).
|
|
326
|
+
* @throws Re-throws any error from fetch (e.g. network failure) or from getAuthHeaders().
|
|
147
327
|
*/
|
|
148
328
|
private request;
|
|
149
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Compute the record scanner UUID for a view key.
|
|
331
|
+
*
|
|
332
|
+
* @param {ViewKey} viewKey The view key to compute the UUID for.
|
|
333
|
+
* @returns {Field} The computed UUID corresponding to the view key.
|
|
334
|
+
*/
|
|
335
|
+
computeUUID(viewKey: ViewKey): Field;
|
|
336
|
+
/**
|
|
337
|
+
* Validate a UUID string to ensure it represents a valid Aleo Record Scanner UUID.
|
|
338
|
+
*
|
|
339
|
+
* @param {string} uuid The UUID to validate.
|
|
340
|
+
* @returns {boolean} Whether the UUID is valid.
|
|
341
|
+
*/
|
|
342
|
+
uuidIsValid(uuid: string): boolean;
|
|
343
|
+
/**
|
|
344
|
+
* 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.
|
|
345
|
+
*
|
|
346
|
+
* @param {OwnedFilter} filter The filter to extract the UUID from.
|
|
347
|
+
* @returns {string | undefined} The UUID for the filter, or undefined if the filter does not contain a UUID.
|
|
348
|
+
*/
|
|
349
|
+
private getUUID;
|
|
150
350
|
}
|
|
151
351
|
export { RecordScanner };
|
|
@@ -0,0 +1,38 @@
|
|
|
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;
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provablehq/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.16",
|
|
4
4
|
"description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
|
|
5
5
|
"collaborators": [
|
|
6
6
|
"The Provable Team"
|
|
@@ -51,11 +51,12 @@
|
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://github.com/ProvableHQ/sdk#readme",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@provablehq/wasm": "^0.9.
|
|
54
|
+
"@provablehq/wasm": "^0.9.16",
|
|
55
55
|
"@scure/base": "^2.0.0",
|
|
56
56
|
"comlink": "^4.4.2",
|
|
57
57
|
"core-js": "^3.40.0",
|
|
58
58
|
"mime": "^4.0.6",
|
|
59
|
+
"libsodium-wrappers": "^0.8.2",
|
|
59
60
|
"xmlhttprequest-ssl": "^4.0.0"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|