@provablehq/veil-aleo-sdk 0.9.0 → 0.11.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 +49 -159
- package/dist/index.d.ts +89 -64
- package/dist/index.js +155 -101
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{provableApi-C4bT37jI.d.ts → provableApi-BTVe8yl5.d.ts} +105 -138
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -28,42 +28,34 @@ import { loadNetwork } from '@provablehq/veil-aleo-sdk'
|
|
|
28
28
|
|
|
29
29
|
const aleo = await loadNetwork('testnet')
|
|
30
30
|
|
|
31
|
-
// A record scanner so the wallet client can find the private records that
|
|
32
|
-
// program calls spend. The first requestRecords registers the view key with the
|
|
33
|
-
// service (one network round-trip); later calls reuse it.
|
|
34
|
-
// `url` defaults to Provable's hosted scanner, so this needs no arguments.
|
|
35
|
-
const scanner = aleo.createRemoteScanner()
|
|
36
|
-
|
|
37
31
|
// A fully-wired client pair: an account from the private key, a public client
|
|
38
|
-
// for reads, and a wallet client with proving
|
|
39
|
-
//
|
|
40
|
-
// scanning — it registers a consumer on the first run and reuses it after.
|
|
41
|
-
import { fileCredentialStore } from '@provablehq/veil-aleo-sdk/node'
|
|
42
|
-
|
|
32
|
+
// for reads, and a wallet client with delegated proving and a record scanner
|
|
33
|
+
// attached. Every service defaults to the Provable gateway.
|
|
43
34
|
const { publicClient, walletClient, account } = aleo.createAleoClient({
|
|
44
35
|
privateKey: PRIVATE_KEY,
|
|
45
|
-
networkUrl: 'https://api.provable.com/v2',
|
|
46
|
-
credentialStore: fileCredentialStore('./.provable-credentials.json'),
|
|
47
|
-
records: scanner,
|
|
48
36
|
})
|
|
49
37
|
|
|
50
38
|
account.address // 'aleo1...'
|
|
51
39
|
```
|
|
52
40
|
|
|
53
|
-
No API key appears above: the
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
-
|
|
41
|
+
No URL or API key appears above: the node API, the hosted prover, and the
|
|
42
|
+
record scanner all run on the Provable gateway, which needs no credentials.
|
|
43
|
+
`networkUrl` defaults to `DEFAULT_NETWORK_URL`, `proverUrl` to
|
|
44
|
+
`DEFAULT_PROVER_URL`, and `records` to `aleo.createRemoteScanner()` against
|
|
45
|
+
`DEFAULT_SCANNER_URL`; each is an option for a self-hosted or legacy service.
|
|
46
|
+
The prover pays fees from its FeeMaster account by default (`useFeeMaster:
|
|
47
|
+
true`), so a faucet-funded account with no public credits can write; pass
|
|
48
|
+
`useFeeMaster: false` when the account funds its own fees. A provisioned key,
|
|
49
|
+
when an operator issues one, goes through `auth` — see
|
|
50
|
+
[Provable API access](#provable-api-access).
|
|
51
|
+
|
|
52
|
+
`networkUrl`, `proverUrl`, and the scanner's `url` are base URLs — the active
|
|
53
|
+
network is appended — so `switchChain` re-targets reads, proving, and scanning
|
|
54
|
+
instead of leaving them on the network the client started from. Do not include
|
|
55
|
+
the network segment yourself.
|
|
64
56
|
|
|
65
57
|
Pass `provingMode: 'local'` to prove in-process instead of delegating to a prover
|
|
66
|
-
service
|
|
58
|
+
service. The `walletClient` composes with
|
|
67
59
|
action packages the same way a wallet-backed client does:
|
|
68
60
|
|
|
69
61
|
```ts
|
|
@@ -74,132 +66,53 @@ const client = walletClient.extend(
|
|
|
74
66
|
)
|
|
75
67
|
```
|
|
76
68
|
|
|
77
|
-
## Provable API
|
|
78
|
-
|
|
79
|
-
Delegated proving and the hosted record scanner both authenticate with a consumer
|
|
80
|
-
id and API key, which the SDK exchanges for short-lived JWTs. A client builds a
|
|
81
|
-
single session covering both services, so one credential mints one token instead
|
|
82
|
-
of each service minting its own.
|
|
83
|
-
|
|
84
|
-
Where that credential comes from is the only decision. Three options:
|
|
85
|
-
|
|
86
|
-
| | Use when | Registers? |
|
|
87
|
-
| --- | --- | --- |
|
|
88
|
-
| `fileCredentialStore(path)` from `/node` | Bots, scripts, servers, CI that can write to disk | On first run, then reuses |
|
|
89
|
-
| `consumerId` + `apiKey` | You already hold credentials — from a secret manager or env | Never |
|
|
90
|
-
| `memoryCredentialStore()` (the default) | Tests, ephemeral workers | Every process, key discarded at exit |
|
|
91
|
-
|
|
92
|
-
`memoryCredentialStore()` is what a client falls back to when given neither, so
|
|
93
|
-
delegated proving works with no configuration at all. It is only appropriate for
|
|
94
|
-
a single short run: the API issues each key exactly once, so a process that
|
|
95
|
-
registers into memory and runs again registers a second consumer nobody can
|
|
96
|
-
reclaim. Anything long-lived wants a persistent store.
|
|
97
|
-
|
|
98
|
-
The session resolves on the first prove or scan. `authenticateProvableApi()` does
|
|
99
|
-
it eagerly, which is worth doing at startup so a bad key fails before you have
|
|
100
|
-
built a transaction:
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
const { credentials, expiration, registered, applied } =
|
|
104
|
-
await walletClient.authenticateProvableApi()
|
|
105
|
-
|
|
106
|
-
applied // { proving: true, recordScanning: true }
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
`applied` reports which paths the session actually reaches. `recordScanning` is
|
|
110
|
-
`false` when the client was given a record provider it cannot share a session
|
|
111
|
-
with — any implementation other than the ones this package builds — in which case
|
|
112
|
-
that provider keeps using whatever credentials it was constructed with.
|
|
69
|
+
## Provable API access
|
|
113
70
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const credentials = await registerProvableApi({ username: 'my-bot-42' })
|
|
121
|
-
await writeFile('creds.json', JSON.stringify(credentials), { mode: 0o600 })
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
A username is spent once. It is globally unique, the API exposes no endpoint that
|
|
125
|
-
reads a consumer back, and a duplicate registration answers 409 with nothing
|
|
126
|
-
usable in it — so a taken name cannot be traded for the credentials it belongs to.
|
|
127
|
-
The stored key is the only copy, which is the real reason to give a client a
|
|
128
|
-
persistent store rather than the in-memory default.
|
|
129
|
-
|
|
130
|
-
When a client registers for you, `username` chooses the name:
|
|
71
|
+
The hosted prover and record scanner run on the Provable gateway,
|
|
72
|
+
`https://edge.provable.com/api`, and every default in this package points there.
|
|
73
|
+
The gateway is unauthenticated: a client built from nothing but a private key and
|
|
74
|
+
a network URL proves and scans. An operator may issue a provisioned API key; pass
|
|
75
|
+
it through `auth` and every request carries it in an `X-API-Key` header:
|
|
131
76
|
|
|
132
77
|
```ts
|
|
133
78
|
const { walletClient } = aleo.createAleoClient({
|
|
134
|
-
privateKey
|
|
135
|
-
|
|
136
|
-
proverUrl: 'https://api.provable.com/prove',
|
|
137
|
-
credentialStore: fileCredentialStore('./.provable-credentials.json'),
|
|
138
|
-
username: 'my-bot-42', // or () => `bot-${shard}`, resolved at registration
|
|
79
|
+
privateKey,
|
|
80
|
+
auth: { mode: 'api-key', value: process.env.PROVABLE_API_KEY! },
|
|
139
81
|
})
|
|
140
82
|
```
|
|
141
83
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
address with a random suffix, which keeps the zero-configuration path working:
|
|
146
|
-
since a username cannot be reused, an account that lost its stored key still needs
|
|
147
|
-
to be able to register.
|
|
84
|
+
A 401 under keyed auth means the key is invalid or revoked, which only the
|
|
85
|
+
operator can fix. `auth` is mutually exclusive with the consumer options below;
|
|
86
|
+
combining them throws at construction.
|
|
148
87
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
88
|
+
The legacy gateway, `https://api.provable.com`, authenticates with JWTs minted
|
|
89
|
+
from a consumer id and API key. That model is still supported for a caller who
|
|
90
|
+
points the client at it: set `proverUrl` (and the scanner `url`) to the legacy
|
|
91
|
+
gateway and pass `consumerId` and `apiKey` (or a `credentialStore` that holds
|
|
92
|
+
them), and one session mints the JWT at that gateway and hands it to proving and
|
|
93
|
+
scanning. The mint root is the origin of the prover URL, so a self-hosted legacy gateway
|
|
94
|
+
serving `/jwts` at its own origin works the same way. On the default gateway the pair
|
|
95
|
+
is carried and nothing mints, because edge has no JWT route:
|
|
153
96
|
|
|
154
97
|
```ts
|
|
155
|
-
import { fileCredentialStore } from '@provablehq/veil-aleo-sdk/node'
|
|
156
|
-
|
|
157
98
|
const { walletClient } = aleo.createAleoClient({
|
|
158
|
-
privateKey
|
|
99
|
+
privateKey,
|
|
159
100
|
networkUrl: 'https://api.provable.com/v2',
|
|
160
101
|
proverUrl: 'https://api.provable.com/prove',
|
|
161
|
-
|
|
162
|
-
|
|
102
|
+
records: aleo.createRemoteScanner({ url: 'https://api.provable.com/scanner' }),
|
|
103
|
+
consumerId,
|
|
104
|
+
apiKey,
|
|
163
105
|
})
|
|
164
|
-
|
|
165
|
-
const { registered } = await walletClient.authenticateProvableApi()
|
|
166
|
-
registered // true on the first run, false afterward
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Anywhere else, implement the two-method interface yourself — a keychain,
|
|
170
|
-
`localStorage`, IndexedDB, or a secret manager all satisfy it, and the SDK assumes
|
|
171
|
-
nothing about which:
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
import type { ProvableCredentialStore } from '@provablehq/veil-aleo-sdk'
|
|
175
|
-
|
|
176
|
-
const credentialStore: ProvableCredentialStore = {
|
|
177
|
-
load: () => {
|
|
178
|
-
const raw = localStorage.getItem('provable-credentials')
|
|
179
|
-
return raw ? JSON.parse(raw) : undefined // undefined → register
|
|
180
|
-
},
|
|
181
|
-
save: (c) => localStorage.setItem('provable-credentials', JSON.stringify(c)),
|
|
182
|
-
}
|
|
106
|
+
const { expiration } = await walletClient.authenticateProvableApi() // mints eagerly
|
|
183
107
|
```
|
|
184
108
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
`
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
An explicit `consumerId`/`apiKey` pair takes precedence over the store, so an
|
|
194
|
-
operator can inject a rotated key or CI credentials without clearing persisted
|
|
195
|
-
state first.
|
|
196
|
-
|
|
197
|
-
One caveat on the mint itself: the API does not validate the consumer id against
|
|
198
|
-
the API key. A mismatched id still yields a working token, because the token's
|
|
199
|
-
issuer comes from the key. The mismatch surfaces later as a rejection from the
|
|
200
|
-
service you call — the record scanner reports it as `No credentials found for
|
|
201
|
-
given 'iss'`. Nothing in the mint path can catch that for you, so keep the pair
|
|
202
|
-
together.
|
|
109
|
+
Consumer registration is retired: `registerProvableApi` is a no-op that resolves
|
|
110
|
+
`undefined`, `username` is ignored, and a client without a pair never registers
|
|
111
|
+
one. `authenticateProvableApi()` never throws for lack of credentials; on a
|
|
112
|
+
credential-less or keyed client it resolves with `credentials: undefined`,
|
|
113
|
+
`expiration: undefined`, and `registered: false`. `fileCredentialStore` and
|
|
114
|
+
`memoryCredentialStore` remain for a pair held on disk; a store is read once and
|
|
115
|
+
never written.
|
|
203
116
|
|
|
204
117
|
The handle also exposes the pieces individually when the caller does not want the
|
|
205
118
|
full pair:
|
|
@@ -217,29 +130,6 @@ For local iteration without a live chain, `createDevnodeClient()` returns the
|
|
|
217
130
|
same client pair pointed at an Aleo Devnode instance with a pre-funded seeded
|
|
218
131
|
account.
|
|
219
132
|
|
|
220
|
-
## Provisioned API keys (edge gateway)
|
|
221
|
-
|
|
222
|
-
The edge gateway (`edge.provable.com`) runs a different auth model: no consumer
|
|
223
|
-
registration and no JWTs. An operator hands out an API key, and every request
|
|
224
|
-
carries it verbatim in an `X-API-Key` header. Configure it with `auth` instead
|
|
225
|
-
of the consumer options:
|
|
226
|
-
|
|
227
|
-
```ts
|
|
228
|
-
const { walletClient } = aleo.createAleoClient({
|
|
229
|
-
privateKey,
|
|
230
|
-
networkUrl: 'https://edge.provable.com/api/v2',
|
|
231
|
-
proverUrl: 'https://edge.provable.com/api/prove',
|
|
232
|
-
records: aleo.createRemoteScanner({ url: 'https://edge.provable.com/api/scanner' }),
|
|
233
|
-
auth: { mode: 'api-key', value: process.env.PROVABLE_API_KEY! },
|
|
234
|
-
})
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
The two models are mutually exclusive: combining `auth` with `apiKey`,
|
|
238
|
-
`consumerId`, `username`, `credentialStore`, or `session` throws at
|
|
239
|
-
construction. There is no session under keyed auth — nothing registers,
|
|
240
|
-
persists, or refreshes — so `authenticateProvableApi()` throws, and a 401
|
|
241
|
-
means the key is invalid or revoked, which only the operator can fix.
|
|
242
|
-
|
|
243
133
|
## WASM dependency
|
|
244
134
|
|
|
245
135
|
`@provablehq/sdk` ships the Aleo cryptography as WebAssembly, and this package
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { loadNetwork as loadNetwork$1 } from '@provablehq/sdk/dynamic.js';
|
|
2
2
|
export { DEVNODE_ADDR, DEVNODE_PRIVATE_KEY } from '@provablehq/veil-aleo-devnode';
|
|
3
3
|
import { LocalAccount, RecordProvider, StandaloneRecordScanner, PublicClient, WalletClient } from '@provablehq/veil-core';
|
|
4
|
-
import { P as ProvableSession, a as ProvableKeyedAuth, b as ProvingConfigWithSession, c as ProvableCredentialStore, d as ProvableWalletClient } from './provableApi-
|
|
5
|
-
export { A as AuthenticateProvableApiParameters, e as AuthenticateProvableApiReturnType, C as CreateProvableSessionOptions, f as ProvableApiActions, g as ProvableApiCredentials, h as ProvableJwt, i as ProvableSessionConsumers, R as RegisterProvableApiParameters, j as authenticateProvableApi, k as createProvableSession, m as memoryCredentialStore, p as provableApiActions, r as registerProvableApi } from './provableApi-
|
|
4
|
+
import { P as ProvableSession, a as ProvableKeyedAuth, b as ProvingConfigWithSession, c as ProvableCredentialStore, d as ProvableWalletClient } from './provableApi-BTVe8yl5.js';
|
|
5
|
+
export { A as AuthenticateProvableApiParameters, e as AuthenticateProvableApiReturnType, C as CreateProvableSessionOptions, f as ProvableApiActions, g as ProvableApiCredentials, h as ProvableJwt, i as ProvableSessionConsumers, R as RegisterProvableApiParameters, j as authenticateProvableApi, k as createProvableSession, m as memoryCredentialStore, p as provableApiActions, r as registerProvableApi } from './provableApi-BTVe8yl5.js';
|
|
6
6
|
import '@provablehq/sdk';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -156,7 +156,7 @@ declare function mnemonicToHDKey(mnemonic: string, options?: {
|
|
|
156
156
|
* const account = aleo.privateKeyToAccount('APrivateKey1...')
|
|
157
157
|
* const { publicClient, walletClient } = aleo.createAleoClient({
|
|
158
158
|
* privateKey: 'APrivateKey1...',
|
|
159
|
-
* networkUrl: 'https://
|
|
159
|
+
* networkUrl: 'https://edge.provable.com/api/v2',
|
|
160
160
|
* })
|
|
161
161
|
*
|
|
162
162
|
* Switching networks: load a new handle. Existing accounts remain valid —
|
|
@@ -169,16 +169,26 @@ type SupportedNetwork = 'mainnet' | 'testnet';
|
|
|
169
169
|
* Base URL of Provable's hosted delegated proving service.
|
|
170
170
|
*
|
|
171
171
|
* The default `proverUrl` for `mode: 'delegated'`. A base, so the active network
|
|
172
|
-
* is appended — which is what lets `switchChain` re-target proving.
|
|
172
|
+
* is appended — which is what lets `switchChain` re-target proving. Served by
|
|
173
|
+
* the edge gateway, which needs no credentials; a provisioned key is optional.
|
|
173
174
|
*/
|
|
174
|
-
declare const DEFAULT_PROVER_URL = "https://
|
|
175
|
+
declare const DEFAULT_PROVER_URL = "https://edge.provable.com/api/prove";
|
|
175
176
|
/**
|
|
176
177
|
* Base URL of Provable's hosted Record Scanner Service.
|
|
177
178
|
*
|
|
178
179
|
* The default `url` for both scanner factories. A base — the SDK appends the
|
|
179
|
-
* network segment, which is what lets a scanner follow `switchChain`.
|
|
180
|
+
* network segment, which is what lets a scanner follow `switchChain`. Served by
|
|
181
|
+
* the edge gateway, which needs no credentials; a provisioned key is optional.
|
|
180
182
|
*/
|
|
181
|
-
declare const DEFAULT_SCANNER_URL = "https://
|
|
183
|
+
declare const DEFAULT_SCANNER_URL = "https://edge.provable.com/api/scanner";
|
|
184
|
+
/**
|
|
185
|
+
* Base URL of Provable's hosted Aleo node API.
|
|
186
|
+
*
|
|
187
|
+
* The default `networkUrl` for `createAleoClient`. A base — the transport
|
|
188
|
+
* appends the network segment, so `switchChain` re-targets reads and
|
|
189
|
+
* broadcasts. Served by the edge gateway, which needs no credentials.
|
|
190
|
+
*/
|
|
191
|
+
declare const DEFAULT_NETWORK_URL = "https://edge.provable.com/api/v2";
|
|
182
192
|
type SdkModule = Awaited<ReturnType<typeof loadNetwork$1<'testnet'>>>;
|
|
183
193
|
/**
|
|
184
194
|
* A network-bound SDK handle. All functions on this handle use the binary
|
|
@@ -249,6 +259,13 @@ interface AleoSdk {
|
|
|
249
259
|
* is re-targeted rather than doubled. Defaults to
|
|
250
260
|
* {@link DEFAULT_PROVER_URL} under `mode: 'delegated'`; unused under
|
|
251
261
|
* `mode: 'local'`, which reaches no prover.
|
|
262
|
+
* @param options.consumerId Optional consumer id for the legacy JWT model.
|
|
263
|
+
* With `apiKey` it forms the pair a session mints JWTs from when
|
|
264
|
+
* `proverUrl` names a legacy gateway such as
|
|
265
|
+
* `https://api.provable.com/prove`. On the default gateway the pair is
|
|
266
|
+
* carried and nothing mints. Omit both for the default gateway.
|
|
267
|
+
* @param options.apiKey Optional API key paired with `consumerId`. For a
|
|
268
|
+
* provisioned gateway key use `auth` instead.
|
|
252
269
|
* @param options.session Optional Provable API session. When present the
|
|
253
270
|
* configuration authenticates from it and withholds `apiKey`/`consumerId`
|
|
254
271
|
* from the prover client, so one party mints JWTs. The session is attached
|
|
@@ -284,12 +301,14 @@ interface AleoSdk {
|
|
|
284
301
|
*
|
|
285
302
|
* @param options.url Base URL of the service (the SDK appends the network
|
|
286
303
|
* segment — do not include it). Defaults to {@link DEFAULT_SCANNER_URL}.
|
|
287
|
-
* @param options.consumerId Optional consumer id
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
304
|
+
* @param options.consumerId Optional consumer id for the legacy JWT model.
|
|
305
|
+
* With `apiKey` it forms the pair a session mints JWTs from when `url`
|
|
306
|
+
* names a legacy gateway such as `https://api.provable.com/scanner`. On
|
|
307
|
+
* the default gateway the pair is carried and nothing mints. Required
|
|
308
|
+
* alongside `apiKey`, since a lone key is ambiguous with a provisioned
|
|
309
|
+
* key. Omit both for the default gateway.
|
|
310
|
+
* @param options.apiKey Optional API key paired with `consumerId`. For a
|
|
311
|
+
* provisioned gateway key use `auth` instead.
|
|
293
312
|
* @param options.session Optional Provable API session to authenticate from,
|
|
294
313
|
* shared with delegated proving. `createAleoClient` supplies its own
|
|
295
314
|
* session through `setSession` on the returned provider, so a caller who
|
|
@@ -302,7 +321,8 @@ interface AleoSdk {
|
|
|
302
321
|
* `consumerId` — combining them throws.
|
|
303
322
|
* @returns The provider, plus `setSession` and `setAuth` for a factory to
|
|
304
323
|
* share one credential source across proving and scanning after
|
|
305
|
-
* construction
|
|
324
|
+
* construction, and `url`, the base the scanner targets, so the factory
|
|
325
|
+
* can tell whether a legacy gateway is in play.
|
|
306
326
|
*/
|
|
307
327
|
createRemoteScanner(options?: {
|
|
308
328
|
url?: string;
|
|
@@ -312,6 +332,7 @@ interface AleoSdk {
|
|
|
312
332
|
startBlock?: number;
|
|
313
333
|
auth?: ProvableKeyedAuth;
|
|
314
334
|
}): RecordProvider & {
|
|
335
|
+
url: string;
|
|
315
336
|
setSession: (session: ProvableSession) => void;
|
|
316
337
|
setAuth: (auth: ProvableKeyedAuth) => void;
|
|
317
338
|
};
|
|
@@ -323,13 +344,13 @@ interface AleoSdk {
|
|
|
323
344
|
*
|
|
324
345
|
* @param options.url Base URL of the service (the SDK appends the network
|
|
325
346
|
* segment). Defaults to {@link DEFAULT_SCANNER_URL}.
|
|
326
|
-
* @param options.consumerId Optional consumer id
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
347
|
+
* @param options.consumerId Optional consumer id from the retired consumer
|
|
348
|
+
* model. Accepted so existing configuration keeps loading; the gateway
|
|
349
|
+
* needs no consumer, so nothing is sent or minted from it. Required
|
|
350
|
+
* alongside `apiKey`, since a lone key is ambiguous with a provisioned key.
|
|
330
351
|
* @param options.viewKey The view key (`AViewKey1…`) to scan and decrypt with.
|
|
331
|
-
* @param options.apiKey Optional API key
|
|
332
|
-
*
|
|
352
|
+
* @param options.apiKey Optional API key paired with `consumerId`. For a
|
|
353
|
+
* provisioned gateway key use `auth` instead.
|
|
333
354
|
* @param options.session Optional Provable API session to authenticate from.
|
|
334
355
|
* Supplied at construction only — a standalone scanner is not pluggable
|
|
335
356
|
* into a wallet client, so nothing shares a session with it later.
|
|
@@ -350,16 +371,36 @@ interface AleoSdk {
|
|
|
350
371
|
auth?: ProvableKeyedAuth;
|
|
351
372
|
}): StandaloneRecordScanner;
|
|
352
373
|
/**
|
|
353
|
-
* Creates a fully-wired Aleo client from a private key
|
|
374
|
+
* Creates a fully-wired Aleo client from a private key.
|
|
354
375
|
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
376
|
+
* Targets the Provable gateway, which needs no credentials: with nothing but
|
|
377
|
+
* the private key the client reads and broadcasts through the hosted node,
|
|
378
|
+
* proves through the hosted delegated prover with the FeeMaster paying fees,
|
|
379
|
+
* and scans records through the hosted scanner. Every one of those is an
|
|
380
|
+
* option for a self-hosted or legacy service. A consumer pair together with
|
|
381
|
+
* legacy URLs (`https://api.provable.com/...`) selects the legacy JWT model,
|
|
382
|
+
* with one session minting for proving and scanning; a provisioned gateway
|
|
383
|
+
* key goes through `auth`.
|
|
359
384
|
*
|
|
360
|
-
* @param options.
|
|
361
|
-
*
|
|
362
|
-
*
|
|
385
|
+
* @param options.networkUrl Base URL of the Aleo node both clients read from
|
|
386
|
+
* and broadcast to, without the network segment. Defaults to
|
|
387
|
+
* {@link DEFAULT_NETWORK_URL}; pass an override for a self-hosted node or
|
|
388
|
+
* a devnode.
|
|
389
|
+
* @param options.provingMode Where proofs are produced. Defaults to
|
|
390
|
+
* `'delegated'`; `'local'` proves in-process and reaches no prover.
|
|
391
|
+
* @param options.useFeeMaster Whether the delegated prover pays the fee from
|
|
392
|
+
* its FeeMaster account instead of the caller's public credits. Defaults
|
|
393
|
+
* to true, so a faucet-funded account with no public credits can write.
|
|
394
|
+
* Pass false when the account funds its own fees. Only meaningful under
|
|
395
|
+
* delegated proving.
|
|
396
|
+
* @param options.records Record provider behind `requestRecords`. Defaults
|
|
397
|
+
* to `createRemoteScanner()` against the hosted scanner; pass a scanner
|
|
398
|
+
* built with a custom `url` or any `RecordProvider` to override.
|
|
399
|
+
* @param options.apiKey Optional API key for the legacy JWT model. Paired
|
|
400
|
+
* with `consumerId`, it seeds the session that mints JWTs at the legacy
|
|
401
|
+
* gateway `proverUrl` or the scanner's `url` names. On the default gateway
|
|
402
|
+
* the pair is carried and nothing mints.
|
|
403
|
+
* @param options.consumerId Optional consumer id for the legacy JWT model.
|
|
363
404
|
* @param options.proverUrl Base URL of the delegated proving service — the
|
|
364
405
|
* network segment is appended, so do not include it. That is what lets
|
|
365
406
|
* `switchChain` re-target proving. Defaults to {@link DEFAULT_PROVER_URL},
|
|
@@ -371,46 +412,30 @@ interface AleoSdk {
|
|
|
371
412
|
* that is more often one the node never included than one about to land.
|
|
372
413
|
* Raise it for a congested network or a multi-transition call that takes
|
|
373
414
|
* longer to include, rather than treating a slow confirmation as a failure.
|
|
374
|
-
* @param options.username
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* its
|
|
380
|
-
*
|
|
381
|
-
* credentials cannot be recovered from a username.
|
|
382
|
-
* @param options.credentialStore Optional persistence for Provable API
|
|
383
|
-
* credentials. When neither `consumerId`/`apiKey` nor a stored pair is
|
|
384
|
-
* available, a consumer is registered under a name derived from the account
|
|
385
|
-
* address and saved here. Defaults to `memoryCredentialStore()`, which holds
|
|
386
|
-
* a registered consumer only for the life of the process — pass
|
|
387
|
-
* `fileCredentialStore` from `@provablehq/veil-aleo-sdk/node`, or any
|
|
388
|
-
* {@link ProvableCredentialStore}, for anything longer-lived. A client left
|
|
389
|
-
* fully unconfigured does not share its session with `records`, so a scanner
|
|
390
|
-
* aimed at an open service keeps needing no credential.
|
|
415
|
+
* @param options.username Ignored. Nothing registers anymore; accepted so
|
|
416
|
+
* existing calls compile.
|
|
417
|
+
* @param options.credentialStore Optional store holding a consumer pair for
|
|
418
|
+
* the legacy JWT model. Read once and never written. Defaults to
|
|
419
|
+
* `memoryCredentialStore()`. A client left fully unconfigured does not
|
|
420
|
+
* share its session with `records`, so a scanner aimed at the gateway stays
|
|
421
|
+
* exactly as it was built.
|
|
391
422
|
* @param options.session Optional pre-built session, for a caller that owns
|
|
392
423
|
* one already. Takes precedence over the credential options.
|
|
393
|
-
* @param options.auth Optional provisioned
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* `username`, `credentialStore`, `session`) — edge keys are handed out by
|
|
399
|
-
* an operator, not registered.
|
|
424
|
+
* @param options.auth Optional provisioned key for the gateway. Selects the
|
|
425
|
+
* keyed model for the whole client: proving and scanning carry the key on
|
|
426
|
+
* every request and no session exists. Mutually exclusive with every
|
|
427
|
+
* consumer option (`apiKey`, `consumerId`, `username`, `credentialStore`,
|
|
428
|
+
* `session`) — gateway keys are handed out by an operator, not registered.
|
|
400
429
|
* @returns A public client, a wallet client carrying
|
|
401
430
|
* `authenticateProvableApi`, and the account.
|
|
402
431
|
*
|
|
403
432
|
* @example
|
|
404
|
-
* const
|
|
405
|
-
* const
|
|
406
|
-
* privateKey, networkUrl, proverUrl, records: scanner, credentialStore: store,
|
|
407
|
-
* })
|
|
408
|
-
* const { credentials, registered } = await walletClient.authenticateProvableApi()
|
|
409
|
-
* if (registered) console.log('registered consumer', credentials.consumerId)
|
|
433
|
+
* const { walletClient } = aleo.createAleoClient({ privateKey })
|
|
434
|
+
* const txId = await walletClient.writeContract({ program, function: 'transfer_public', inputs })
|
|
410
435
|
*/
|
|
411
436
|
createAleoClient(options: {
|
|
412
437
|
privateKey: string;
|
|
413
|
-
networkUrl
|
|
438
|
+
networkUrl?: string;
|
|
414
439
|
provingMode?: 'delegated' | 'local';
|
|
415
440
|
proverUrl?: string;
|
|
416
441
|
apiKey?: string;
|
|
@@ -422,12 +447,12 @@ interface AleoSdk {
|
|
|
422
447
|
session?: ProvableSession;
|
|
423
448
|
auth?: ProvableKeyedAuth;
|
|
424
449
|
/**
|
|
425
|
-
* Record provider for `requestRecords`.
|
|
426
|
-
* `aleo.createRemoteScanner(
|
|
427
|
-
* custom `
|
|
428
|
-
* when no provider is configured.
|
|
450
|
+
* Record provider for `requestRecords`. Defaults to
|
|
451
|
+
* `aleo.createRemoteScanner()` against the hosted scanner; pass a scanner
|
|
452
|
+
* with a custom `url` or any custom `RecordProvider` to override.
|
|
429
453
|
*/
|
|
430
454
|
records?: RecordProvider & {
|
|
455
|
+
url?: string;
|
|
431
456
|
setSession?: (session: ProvableSession) => void;
|
|
432
457
|
setAuth?: (auth: ProvableKeyedAuth) => void;
|
|
433
458
|
};
|
|
@@ -481,4 +506,4 @@ declare function createDevnodeClient(options?: {
|
|
|
481
506
|
account: LocalAccount<'privateKey'>;
|
|
482
507
|
};
|
|
483
508
|
|
|
484
|
-
export { type AleoDerivationId, type AleoSdk, BLS12377HDKey, DEFAULT_PROVER_URL, DEFAULT_SCANNER_URL, LEGACY_PATH, ProvableCredentialStore, ProvableKeyedAuth, ProvableSession, ProvableWalletClient, ProvingConfigWithSession, STANDARD_PATH, type SupportedNetwork, createDevnodeClient, generateAccount, generateMnemonic, loadNetwork, mnemonicToHDKey, mnemonicToSeed, validateMnemonic, validateWord };
|
|
509
|
+
export { type AleoDerivationId, type AleoSdk, BLS12377HDKey, DEFAULT_NETWORK_URL, DEFAULT_PROVER_URL, DEFAULT_SCANNER_URL, LEGACY_PATH, ProvableCredentialStore, ProvableKeyedAuth, ProvableSession, ProvableWalletClient, ProvingConfigWithSession, STANDARD_PATH, type SupportedNetwork, createDevnodeClient, generateAccount, generateMnemonic, loadNetwork, mnemonicToHDKey, mnemonicToSeed, validateMnemonic, validateWord };
|