@provablehq/sdk 0.9.16 → 0.9.18

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.
Files changed (45) hide show
  1. package/dist/mainnet/account.d.ts +43 -3
  2. package/dist/mainnet/browser.d.ts +11 -4
  3. package/dist/mainnet/browser.js +460 -109
  4. package/dist/mainnet/browser.js.map +1 -1
  5. package/dist/mainnet/keys/keystore/error.d.ts +23 -0
  6. package/dist/mainnet/keys/keystore/file.d.ts +217 -0
  7. package/dist/mainnet/keys/keystore/interface.d.ts +85 -0
  8. package/dist/mainnet/keys/provider/interface.d.ts +170 -0
  9. package/dist/mainnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +9 -167
  10. package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +6 -3
  11. package/dist/mainnet/keys/verifier/interface.d.ts +70 -0
  12. package/dist/mainnet/keys/verifier/memory.d.ts +37 -0
  13. package/dist/mainnet/models/keyHolder.d.ts +2 -0
  14. package/dist/mainnet/models/keyPair.d.ts +4 -0
  15. package/dist/mainnet/models/record-scanner/error.d.ts +1 -1
  16. package/dist/mainnet/models/record-scanner/revokeResult.d.ts +17 -0
  17. package/dist/mainnet/node.d.ts +1 -0
  18. package/dist/mainnet/node.js +399 -2
  19. package/dist/mainnet/node.js.map +1 -1
  20. package/dist/mainnet/program-manager.d.ts +4 -3
  21. package/dist/mainnet/record-scanner.d.ts +16 -0
  22. package/dist/mainnet/security.d.ts +24 -0
  23. package/dist/testnet/account.d.ts +43 -3
  24. package/dist/testnet/browser.d.ts +11 -4
  25. package/dist/testnet/browser.js +460 -109
  26. package/dist/testnet/browser.js.map +1 -1
  27. package/dist/testnet/keys/keystore/error.d.ts +23 -0
  28. package/dist/testnet/keys/keystore/file.d.ts +217 -0
  29. package/dist/testnet/keys/keystore/interface.d.ts +85 -0
  30. package/dist/testnet/keys/provider/interface.d.ts +170 -0
  31. package/dist/testnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +9 -167
  32. package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +6 -3
  33. package/dist/testnet/keys/verifier/interface.d.ts +70 -0
  34. package/dist/testnet/keys/verifier/memory.d.ts +37 -0
  35. package/dist/testnet/models/keyHolder.d.ts +2 -0
  36. package/dist/testnet/models/keyPair.d.ts +4 -0
  37. package/dist/testnet/models/record-scanner/error.d.ts +1 -1
  38. package/dist/testnet/models/record-scanner/revokeResult.d.ts +17 -0
  39. package/dist/testnet/node.d.ts +1 -0
  40. package/dist/testnet/node.js +399 -2
  41. package/dist/testnet/node.js.map +1 -1
  42. package/dist/testnet/program-manager.d.ts +4 -3
  43. package/dist/testnet/record-scanner.d.ts +16 -0
  44. package/dist/testnet/security.d.ts +24 -0
  45. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import { Address, ComputeKey, Field, Group, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm.js";
2
2
  interface AccountParam {
3
- privateKey?: string;
3
+ privateKey?: string | PrivateKey;
4
4
  seed?: Uint8Array;
5
5
  }
6
6
  /**
@@ -13,6 +13,9 @@ interface AccountParam {
13
13
  * credits and other records to. This class should only be used in environments where the safety of the underlying key
14
14
  * material can be assured.
15
15
  *
16
+ * When an Account is no longer needed, call {@link destroy} to securely zeroize and free all sensitive key material
17
+ * from WASM memory. Alternatively, use `[Symbol.dispose]()` with the `using` declaration in ES2024+ environments.
18
+ *
16
19
  * @example
17
20
  * import { Account } from "@provablehq/sdk/testnet.js";
18
21
  *
@@ -32,12 +35,16 @@ interface AccountParam {
32
35
  *
33
36
  * // Verify a signature
34
37
  * assert(myRandomAccount.verify(hello_world, signature));
38
+ *
39
+ * // Securely destroy the account when done
40
+ * myRandomAccount.destroy();
35
41
  */
36
42
  export declare class Account {
37
43
  _privateKey: PrivateKey;
38
44
  _viewKey: ViewKey;
39
45
  _computeKey: ComputeKey;
40
46
  _address: Address;
47
+ private _destroyed;
41
48
  constructor(params?: AccountParam);
42
49
  /**
43
50
  * Attempts to create an account from a private key ciphertext
@@ -69,10 +76,14 @@ export declare class Account {
69
76
  static isValidAddress(address: string | Uint8Array): boolean;
70
77
  /**
71
78
  * Creates a PrivateKey from the provided parameters.
72
- * @param {AccountParam} params The parameters containing either a private key string or a seed
79
+ * @param {AccountParam} params The parameters containing either a private key string, PrivateKey object, or a seed
73
80
  * @returns {PrivateKey} A PrivateKey instance derived from the provided parameters
74
81
  */
75
82
  private privateKeyFromParams;
83
+ /**
84
+ * Throws an error if this account has been destroyed.
85
+ */
86
+ private assertNotDestroyed;
76
87
  /**
77
88
  * Returns the PrivateKey associated with the account.
78
89
  * @returns {PrivateKey} The private key of the account
@@ -118,7 +129,8 @@ export declare class Account {
118
129
  */
119
130
  address(): Address;
120
131
  /**
121
- * Deep clones the Account.
132
+ * Deep clones the Account via byte serialization of the private key,
133
+ * avoiding creation of immutable JS string representations of the private key.
122
134
  * @returns {Account} A new Account instance with the same private key
123
135
  *
124
136
  * @example
@@ -303,5 +315,33 @@ export declare class Account {
303
315
  * assert(account.verify(message, signature));
304
316
  */
305
317
  verify(message: Uint8Array, signature: Signature): boolean;
318
+ /**
319
+ * Securely destroys the account by zeroizing and freeing all sensitive key material
320
+ * from WASM memory. After calling this method, the account object should not be used.
321
+ *
322
+ * This triggers the Rust-level zeroizing Drop implementation which overwrites private key,
323
+ * view key, and compute key bytes with zeros in WASM linear memory before deallocation.
324
+ *
325
+ * Note: If destroy() is never called, the FinalizationRegistry (set up by wasm-bindgen)
326
+ * will eventually trigger cleanup via GC, but the timing is non-deterministic. For security-
327
+ * sensitive applications, always call destroy() explicitly when the account is no longer needed.
328
+ *
329
+ * @example
330
+ * const account = new Account();
331
+ * // ... use account ...
332
+ * account.destroy(); // Securely cleans up key material
333
+ */
334
+ destroy(): void;
335
+ /**
336
+ * Implements the Disposable interface for use with `using` declarations (ES2024+).
337
+ * Calls {@link destroy} to securely clean up key material.
338
+ *
339
+ * @example
340
+ * {
341
+ * using account = new Account();
342
+ * // ... use account ...
343
+ * } // account is automatically destroyed here
344
+ */
345
+ [Symbol.dispose](): void;
306
346
  }
307
347
  export {};
@@ -2,6 +2,7 @@ import "./polyfill/shared.js";
2
2
  import { Account } from "./account.js";
3
3
  import { AleoNetworkClient, ProgramImports } from "./network-client.js";
4
4
  import { BlockJSON, Header, Metadata } from "./models/blockJSON.js";
5
+ import { CachedKeyPair, FunctionKeyPair } from "./models/keyPair.js";
5
6
  import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
6
7
  import { CryptoBoxPubKey } from "./models/cryptoBoxPubkey.js";
7
8
  import { DeploymentJSON, VerifyingKeys } from "./models/deployment/deploymentJSON.js";
@@ -36,6 +37,7 @@ import { OwnedRecordsResponseFilter } from "./models/record-scanner/ownedRecords
36
37
  import { RegisterResult, RegisterSuccess } from "./models/record-scanner/registrationResult.js";
37
38
  import { RegistrationRequest } from "./models/record-scanner/registrationRequest.js";
38
39
  import { RegistrationResponse } from "./models/record-scanner/registrationResponse.js";
40
+ import { RevokeResult, RevokeSuccess, RevokeResponse } from "./models/record-scanner/revokeResult.js";
39
41
  import { RecordsFilter } from "./models/record-scanner/recordsFilter.js";
40
42
  import { RecordsResponseFilter } from "./models/record-scanner/recordsResponseFilter.js";
41
43
  import { SerialNumbersResult, SerialNumbersSuccess } from "./models/record-scanner/serialNumbersResult.js";
@@ -48,8 +50,12 @@ import { TransactionJSON } from "./models/transaction/transactionJSON.js";
48
50
  import { TransactionObject } from "./models/transaction/transactionObject.js";
49
51
  import { TransitionJSON } from "./models/transition/transitionJSON.js";
50
52
  import { TransitionObject } from "./models/transition/transitionObject.js";
51
- import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
52
- import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider.js";
53
+ import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.js";
54
+ import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams } from "./keys/provider/memory.js";
55
+ import { KeyFingerprint, KeyMetadata, KeyVerificationError, KeyVerifier, sha256Hex } from "./keys/verifier/interface.js";
56
+ import { MemKeyVerifier } from "./keys/verifier/memory.js";
57
+ import { InvalidLocatorError, InvalidLocatorReason, KeyLocator, KeyStore } from "./keys/keystore/interface.js";
58
+ import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline.js";
53
59
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
54
60
  import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
55
61
  import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
@@ -59,5 +65,6 @@ export { logAndThrow } from "./utils.js";
59
65
  export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "./wasm.js";
60
66
  export { initializeWasm };
61
67
  export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
62
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, DecryptionNotEnabledError, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationRequest, RegistrationResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
63
- export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest } from "./security.js";
68
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, KeyFingerprint, KeyLocator, KeyMetadata, KeyStore, KeyVerificationError, KeyVerifier, MemKeyVerifier, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, DecryptionNotEnabledError, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationRequest, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
69
+ export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
70
+ export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";