@provablehq/sdk 0.7.3 → 0.7.5

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 (73) hide show
  1. package/dist/mainnet/account.d.ts +137 -0
  2. package/dist/mainnet/browser.d.ts +20 -0
  3. package/dist/mainnet/browser.js +934 -0
  4. package/dist/mainnet/browser.js.map +1 -0
  5. package/dist/mainnet/constants.d.ts +34 -0
  6. package/dist/mainnet/function-key-provider.d.ts +349 -0
  7. package/dist/mainnet/managed-worker.d.ts +3 -0
  8. package/dist/mainnet/models/block.d.ts +21 -0
  9. package/dist/mainnet/models/confirmed_transaction.d.ts +6 -0
  10. package/dist/mainnet/models/execution.d.ts +5 -0
  11. package/dist/mainnet/models/input.d.ts +10 -0
  12. package/dist/mainnet/models/output.d.ts +6 -0
  13. package/dist/mainnet/models/transactionModel.d.ts +6 -0
  14. package/dist/mainnet/models/transition.d.ts +13 -0
  15. package/dist/mainnet/network-client.d.ts +270 -0
  16. package/dist/mainnet/node-polyfill.d.ts +5 -0
  17. package/dist/mainnet/node-polyfill.js +304 -0
  18. package/dist/mainnet/node-polyfill.js.map +1 -0
  19. package/dist/mainnet/node.d.ts +2 -0
  20. package/dist/mainnet/node.js +13 -0
  21. package/dist/mainnet/node.js.map +1 -0
  22. package/dist/mainnet/offline-key-provider.d.ts +348 -0
  23. package/dist/mainnet/polyfill/crypto.d.ts +1 -0
  24. package/dist/mainnet/polyfill/fetch.d.ts +1 -0
  25. package/dist/mainnet/polyfill/shared.d.ts +1 -0
  26. package/dist/mainnet/polyfill/worker.d.ts +1 -0
  27. package/dist/mainnet/polyfill/xmlhttprequest.d.ts +1 -0
  28. package/dist/mainnet/program-manager-a25c2f23.js +2200 -0
  29. package/dist/mainnet/program-manager-a25c2f23.js.map +1 -0
  30. package/dist/mainnet/program-manager.d.ts +640 -0
  31. package/dist/mainnet/record-provider.d.ts +236 -0
  32. package/dist/mainnet/utils.d.ts +4 -0
  33. package/dist/mainnet/wasm.d.ts +1 -0
  34. package/dist/mainnet/worker.d.ts +9 -0
  35. package/dist/mainnet/worker.js +78 -0
  36. package/dist/mainnet/worker.js.map +1 -0
  37. package/dist/testnet/account.d.ts +137 -0
  38. package/dist/testnet/browser.d.ts +20 -0
  39. package/dist/testnet/browser.js +934 -0
  40. package/dist/testnet/browser.js.map +1 -0
  41. package/dist/testnet/constants.d.ts +34 -0
  42. package/dist/testnet/function-key-provider.d.ts +349 -0
  43. package/dist/testnet/managed-worker.d.ts +3 -0
  44. package/dist/testnet/models/block.d.ts +21 -0
  45. package/dist/testnet/models/confirmed_transaction.d.ts +6 -0
  46. package/dist/testnet/models/execution.d.ts +5 -0
  47. package/dist/testnet/models/input.d.ts +10 -0
  48. package/dist/testnet/models/output.d.ts +6 -0
  49. package/dist/testnet/models/transactionModel.d.ts +6 -0
  50. package/dist/testnet/models/transition.d.ts +13 -0
  51. package/dist/testnet/network-client.d.ts +270 -0
  52. package/dist/testnet/node-polyfill.d.ts +5 -0
  53. package/dist/testnet/node-polyfill.js +304 -0
  54. package/dist/testnet/node-polyfill.js.map +1 -0
  55. package/dist/testnet/node.d.ts +2 -0
  56. package/dist/testnet/node.js +13 -0
  57. package/dist/testnet/node.js.map +1 -0
  58. package/dist/testnet/offline-key-provider.d.ts +348 -0
  59. package/dist/testnet/polyfill/crypto.d.ts +1 -0
  60. package/dist/testnet/polyfill/fetch.d.ts +1 -0
  61. package/dist/testnet/polyfill/shared.d.ts +1 -0
  62. package/dist/testnet/polyfill/worker.d.ts +1 -0
  63. package/dist/testnet/polyfill/xmlhttprequest.d.ts +1 -0
  64. package/dist/testnet/program-manager-4e9a7ef4.js +2200 -0
  65. package/dist/testnet/program-manager-4e9a7ef4.js.map +1 -0
  66. package/dist/testnet/program-manager.d.ts +640 -0
  67. package/dist/testnet/record-provider.d.ts +236 -0
  68. package/dist/testnet/utils.d.ts +4 -0
  69. package/dist/testnet/wasm.d.ts +1 -0
  70. package/dist/testnet/worker.d.ts +9 -0
  71. package/dist/testnet/worker.js +78 -0
  72. package/dist/testnet/worker.js.map +1 -0
  73. package/package.json +2 -2
@@ -0,0 +1,137 @@
1
+ import { Address, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext } from "./wasm";
2
+ interface AccountParam {
3
+ privateKey?: string;
4
+ seed?: Uint8Array;
5
+ }
6
+ /**
7
+ * Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from
8
+ * an existing private key or seed, and message signing and verification functionality.
9
+ *
10
+ * An Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,
11
+ * and a public account address are derived. The private key lies at the root of an Aleo account. It is a highly
12
+ * sensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value
13
+ * transfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public
14
+ * address to which other users of Aleo can send Aleo credits and other records to. This class should only be used
15
+ * environments where the safety of the underlying key material can be assured.
16
+ *
17
+ * @example
18
+ * // Create a new account
19
+ * const myRandomAccount = new Account();
20
+ *
21
+ * // Create an account from a randomly generated seed
22
+ * const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
23
+ * const mySeededAccount = new Account({seed: seed});
24
+ *
25
+ * // Create an account from an existing private key
26
+ * const myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
27
+ *
28
+ * // Sign a message
29
+ * const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
30
+ * const signature = myRandomAccount.sign(hello_world)
31
+ *
32
+ * // Verify a signature
33
+ * myRandomAccount.verify(hello_world, signature)
34
+ */
35
+ export declare class Account {
36
+ _privateKey: PrivateKey;
37
+ _viewKey: ViewKey;
38
+ _address: Address;
39
+ constructor(params?: AccountParam);
40
+ /**
41
+ * Attempts to create an account from a private key ciphertext
42
+ * @param {PrivateKeyCiphertext | string} ciphertext
43
+ * @param {string} password
44
+ * @returns {PrivateKey}
45
+ *
46
+ * @example
47
+ * const ciphertext = PrivateKey.newEncrypted("password");
48
+ * const account = Account.fromCiphertext(ciphertext, "password");
49
+ */
50
+ static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string): Account;
51
+ private privateKeyFromParams;
52
+ privateKey(): PrivateKey;
53
+ viewKey(): ViewKey;
54
+ address(): Address;
55
+ toString(): any;
56
+ /**
57
+ * Encrypt the account's private key with a password
58
+ * @param {string} ciphertext
59
+ * @returns {PrivateKeyCiphertext}
60
+ *
61
+ * @example
62
+ * const account = new Account();
63
+ * const ciphertext = account.encryptAccount("password");
64
+ */
65
+ encryptAccount(password: string): any;
66
+ /**
67
+ * Decrypts a Record in ciphertext form into plaintext
68
+ * @param {string} ciphertext
69
+ * @returns {Record}
70
+ *
71
+ * @example
72
+ * const account = new Account();
73
+ * const record = account.decryptRecord("record1ciphertext");
74
+ */
75
+ decryptRecord(ciphertext: string): any;
76
+ /**
77
+ * Decrypts an array of Records in ciphertext form into plaintext
78
+ * @param {string[]} ciphertexts
79
+ * @returns {Record[]}
80
+ *
81
+ * @example
82
+ * const account = new Account();
83
+ * const record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);
84
+ */
85
+ decryptRecords(ciphertexts: string[]): any[];
86
+ /**
87
+ * Determines whether the account owns a ciphertext record
88
+ * @param {RecordCipherText | string} ciphertext
89
+ * @returns {boolean}
90
+ *
91
+ * @example
92
+ * // Create a connection to the Aleo network and an account
93
+ * const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
94
+ * const account = Account.fromCiphertext("ciphertext", "password");
95
+ *
96
+ * // Get a record from the network
97
+ * const record = connection.getBlock(1234);
98
+ * const recordCipherText = record.transactions[0].execution.transitions[0].id;
99
+ *
100
+ * // Check if the account owns the record
101
+ * if account.ownsRecord(recordCipherText) {
102
+ * // Then one can do something like:
103
+ * // Decrypt the record and check if it's spent
104
+ * // Store the record in a local database
105
+ * // Etc.
106
+ * }
107
+ */
108
+ ownsRecordCiphertext(ciphertext: RecordCiphertext | string): any;
109
+ /**
110
+ * Signs a message with the account's private key.
111
+ * Returns a Signature.
112
+ *
113
+ * @param {Uint8Array} message
114
+ * @returns {Signature}
115
+ *
116
+ * @example
117
+ * const account = new Account();
118
+ * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
119
+ * account.sign(message);
120
+ */
121
+ sign(message: Uint8Array): any;
122
+ /**
123
+ * Verifies the Signature on a message.
124
+ *
125
+ * @param {Uint8Array} message
126
+ * @param {Signature} signature
127
+ * @returns {boolean}
128
+ *
129
+ * @example
130
+ * const account = new Account();
131
+ * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
132
+ * const signature = account.sign(message);
133
+ * account.verify(message, signature);
134
+ */
135
+ verify(message: Uint8Array, signature: Signature): any;
136
+ }
137
+ export {};
@@ -0,0 +1,20 @@
1
+ import "./polyfill/shared";
2
+ import { Account } from "./account";
3
+ import { AleoNetworkClient, ProgramImports } from "./network-client";
4
+ import { Block } from "./models/block";
5
+ import { Execution } from "./models/execution";
6
+ import { Input } from "./models/input";
7
+ import { Output } from "./models/output";
8
+ import { TransactionModel } from "./models/transactionModel";
9
+ import { Transition } from "./models/transition";
10
+ import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
11
+ import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider";
12
+ import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider";
13
+ declare function initializeWasm(): Promise<void>;
14
+ export { createAleoWorker } from "./managed-worker";
15
+ export { ProgramManager } from "./program-manager";
16
+ export { logAndThrow } from "./utils";
17
+ export { Address, Execution as FunctionExecution, ExecutionResponse, Field, OfflineQuery, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Transaction, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm";
18
+ export { initializeWasm };
19
+ 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, VALID_TRANSFER_TYPES, } from "./constants";
20
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, Block, BlockHeightSearch, CachedKeyPair, Execution, FunctionKeyPair, FunctionKeyProvider, Input, KeySearchParams, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, Output, RecordProvider, RecordSearchParams, TransactionModel, Transition, };