@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/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as ProvableCredentialStore } from './provableApi-C4bT37jI.js';
1
+ import { c as ProvableCredentialStore } from './provableApi-BTVe8yl5.js';
2
2
  import '@provablehq/veil-core';
3
3
  import '@provablehq/sdk';
4
4
 
@@ -2,15 +2,16 @@ import { ProvingConfig, Client, WalletActions, RecordProvider } from '@provableh
2
2
  import { ApiAuthConfig } from '@provablehq/sdk';
3
3
 
4
4
  /**
5
- * Credentials issued by the Provable API for a registered consumer.
5
+ * Credentials for the legacy JWT model of the Provable API.
6
6
  *
7
- * Authenticate delegated proving and the hosted Record Scanner Service. The
8
- * pair is minted by {@link registerProvableApi} and exchanged for short-lived
9
- * JWTs.
7
+ * Optional everywhere: the default gateway needs no consumer and mints no JWT.
8
+ * A caller who targets a legacy gateway such as `api.provable.com` passes the
9
+ * pair and the session mints short-lived JWTs from it at that gateway. Nothing
10
+ * registers new consumers anymore. A provisioned key for the default gateway
11
+ * goes through {@link ProvableKeyedAuth} instead.
10
12
  *
11
13
  * @property consumerId Consumer id. Forms the path segment when minting JWTs.
12
- * @property apiKey API key. Returned once at registration and unrecoverable
13
- * afterward, so a caller MUST persist it.
14
+ * @property apiKey API key. Sent as `X-Provable-API-Key` on the mint.
14
15
  */
15
16
  type ProvableApiCredentials = {
16
17
  consumerId: string;
@@ -20,14 +21,12 @@ type ProvableApiCredentials = {
20
21
  * Persists Provable API credentials between runs.
21
22
  *
22
23
  * Implemented by the caller — a file, a keychain, `localStorage`, or a secret
23
- * manager are all valid, and the choice belongs to the runtime rather than to
24
- * the SDK. A session reads through `load` on first use and writes through
25
- * `save` exactly once, immediately after registering a new consumer.
24
+ * manager are all valid. A session reads through `load` on first use and never
25
+ * writes: nothing registers anymore, so `save` is only called by callers who
26
+ * seed a store themselves.
26
27
  *
27
- * @property load Reads stored credentials. Returning `undefined` means no
28
- * consumer is registered yet and triggers registration.
29
- * @property save Writes credentials. The API key is unrecoverable if this
30
- * write is lost, so a failure here should propagate rather than be swallowed.
28
+ * @property load Reads stored credentials, or `undefined` when none are held.
29
+ * @property save Writes credentials. Only reached by a caller seeding the store.
31
30
  *
32
31
  * @example
33
32
  * const store: ProvableCredentialStore = {
@@ -42,46 +41,36 @@ type ProvableCredentialStore = {
42
41
  /**
43
42
  * Builds a credential store that keeps credentials for the life of the process.
44
43
  *
45
- * The default when a client is given no credentials and no store, and the right
46
- * choice for tests and short-lived workers. Suited to any runtime, since it
47
- * touches no storage.
48
- *
49
- * A consumer registered into this store is lost when the process exits, and its
50
- * API key is issued once — so a process that registers here and runs again
51
- * registers a second consumer that nobody can reclaim. Anything longer-lived
52
- * than a single run belongs in a persistent store: `fileCredentialStore` from
53
- * `@provablehq/veil-aleo-sdk/node`, or a caller-supplied
54
- * {@link ProvableCredentialStore}.
44
+ * The default when a client is given no credentials and no store. Suited to any
45
+ * runtime, since it touches no storage.
55
46
  *
56
47
  * @param initial Optional credentials to start with, so a caller can seed the
57
- * store from an environment variable and skip registration.
48
+ * store from an environment variable.
58
49
  * @returns A store backed by a closure variable.
59
50
  *
60
51
  * @example
61
52
  * const store = memoryCredentialStore()
62
- * // or seeded, in which case nothing registers:
53
+ * // or seeded:
63
54
  * const seeded = memoryCredentialStore({ consumerId, apiKey })
64
55
  */
65
56
  declare function memoryCredentialStore(initial?: ProvableApiCredentials): ProvableCredentialStore;
66
57
  /**
67
- * Provisioned-key authentication for the edge Provable API gateway.
58
+ * Provisioned-key authentication for the Provable API gateway.
68
59
  *
69
60
  * The keyed variant of the Provable SDK's `ApiAuthConfig`, derived rather
70
61
  * than restated so the two cannot drift — values of this type pass straight
71
62
  * into the SDK's `RecordScanner` and delegated proving as their `auth`
72
63
  * option, where the SDK applies the header default (`DEFAULT_API_KEY_HEADER`).
73
64
  *
74
- * The edge gateway (`edge.provable.com`) runs a different auth model from
75
- * `api.provable.com`: there is no consumer registration and no JWT minting.
76
- * An operator hands out API keys, and every request carries the key verbatim
77
- * in a header. Nothing registers, persists, or refreshes, and a rejected
78
- * request (401) means the key is invalid or revoked — retrying cannot help,
79
- * and only the operator can issue a replacement.
65
+ * The gateway is unauthenticated by default, so a key is optional. When an
66
+ * operator hands one out, every request carries it verbatim in a header.
67
+ * Nothing registers, persists, or refreshes, and a rejected request (401)
68
+ * means the key is invalid or revoked — retrying cannot help, and only the
69
+ * operator can issue a replacement.
80
70
  *
81
71
  * Mutually exclusive with the session options (`credentials`, `store`,
82
- * `username`, `session`): those describe the registered-consumer lifecycle,
83
- * which a provisioned key does not have. Combining them throws at
84
- * construction.
72
+ * `username`, `session`): those belong to the legacy JWT model. Combining
73
+ * them throws at construction.
85
74
  *
86
75
  * @example
87
76
  * const auth: ProvableKeyedAuth = { mode: 'api-key', value: process.env.PROVABLE_API_KEY! }
@@ -108,7 +97,7 @@ type ProvableJwt = {
108
97
  * The consumers a session has been wired into.
109
98
  *
110
99
  * Reported by {@link authenticateProvableApi} so a caller can tell which paths
111
- * one authentication call actually covers.
100
+ * one client's session reaches.
112
101
  *
113
102
  * @property proving Whether a proving configuration carries this session.
114
103
  * @property recordScanning Whether a record provider carries this session.
@@ -118,25 +107,23 @@ type ProvableSessionConsumers = {
118
107
  recordScanning: boolean;
119
108
  };
120
109
  /**
121
- * A live Provable API session: consumer credentials plus a cached, refreshing JWT.
110
+ * A Provable API session: the configured credentials plus a cached, refreshing JWT.
122
111
  *
123
112
  * Built by `createProvingConfig`, `createRemoteScanner`, and
124
113
  * `createAleoClient` from the credential options they are given — a caller
125
- * configures credentials and does not construct this directly. Sharing one
126
- * session across delegated proving and record scanning means a single minted
127
- * JWT and a single refresh policy for both.
128
- *
129
- * @property registeredConsumer Reports whether this session registered a new
130
- * consumer rather than loading an existing one. Only meaningful after
131
- * credentials have resolved.
132
- * @property getCredentials Resolves the credentials, registering on first use
133
- * when neither direct credentials nor a store supply them.
134
- * @property getJwt Returns a JWT valid for at least the expiry margin,
135
- * minting or refreshing as needed.
114
+ * configures credentials and does not construct this directly. With a
115
+ * credential pair and a legacy gateway to mint at, the session mints and
116
+ * refreshes JWTs; otherwise it is inert, since the default gateway needs
117
+ * nothing.
118
+ *
119
+ * @property registeredConsumer Always false; nothing registers anymore.
120
+ * @property getCredentials Resolves the supplied or stored credentials, or
121
+ * `undefined` when the client holds none.
122
+ * @property getJwt Returns a JWT valid for at least the expiry margin, minting
123
+ * or refreshing as needed, or `undefined` when there are no credentials, no
124
+ * legacy gateway to mint at, or the gateway answered the mint with 404.
136
125
  * @property consumers Which consumers carry this session. Advisory reporting;
137
- * nothing reads it to make decisions. `recordScanning` is set where a record
138
- * provider is wired to a client, so sharing one session across several
139
- * clients under-reports rather than claiming a path a given client lacks.
126
+ * nothing reads it to make decisions.
140
127
  * @property attach Records that a consumer now carries this session. Called by
141
128
  * the factories during wiring.
142
129
  */
@@ -144,24 +131,19 @@ type ProvableSession = {
144
131
  registeredConsumer: () => boolean;
145
132
  getCredentials: (options?: {
146
133
  username?: string;
147
- }) => Promise<ProvableApiCredentials>;
134
+ }) => Promise<ProvableApiCredentials | undefined>;
148
135
  getJwt: (options?: {
149
136
  forceRefresh?: boolean;
150
- }) => Promise<ProvableJwt>;
137
+ }) => Promise<ProvableJwt | undefined>;
151
138
  consumers: ProvableSessionConsumers;
152
139
  attach: (consumer: keyof ProvableSessionConsumers) => void;
153
140
  };
154
141
  /**
155
142
  * Options for {@link registerProvableApi}.
156
143
  *
157
- * @property username Handle for the consumer. Globally unique across the
158
- * Provable API, so a taken name fails the call.
159
- * @property baseUrl Optional Provable API root. Defaults to
160
- * `https://api.provable.com`. Applies when targeting a non-production
161
- * deployment.
162
- * @property transport Optional fetch-compatible transport for the request.
163
- * Defaults to the global `fetch`. Applies when a caller intercepts or
164
- * instruments HTTP — a proxy, a recorder, a test stub.
144
+ * @property username Handle the retired flow registered under. Ignored.
145
+ * @property baseUrl Ignored; kept so existing calls compile.
146
+ * @property transport Ignored; kept so existing calls compile.
165
147
  */
166
148
  type RegisterProvableApiParameters = {
167
149
  username: string;
@@ -171,21 +153,18 @@ type RegisterProvableApiParameters = {
171
153
  /**
172
154
  * Options for {@link createProvableSession}.
173
155
  *
174
- * @property credentials Optional credentials to use directly. Take precedence
175
- * over `store`, so an operator can inject a rotated or CI-provided pair
176
- * without clearing persisted state first.
177
- * @property store Optional persistence for credentials across runs. Omit for a
178
- * consumer that lives only as long as the process.
179
- * @property username Optional handle to register under when neither
180
- * `credentials` nor `store` yields a pair. A function is called lazily, so a
181
- * caller can derive the name from an account address that is not known at
182
- * configuration time. Required only if registration may happen.
183
- * @property baseUrl Optional Provable API root. Defaults to
184
- * `https://api.provable.com`.
185
- * @property transport Optional fetch-compatible transport used for
186
- * registration and JWT minting. Defaults to the global `fetch`. Applies
187
- * when a caller intercepts or instruments HTTP — a proxy, a recorder, a
188
- * test stub.
156
+ * @property credentials Optional credentials to mint from. Take precedence
157
+ * over `store`, so an operator can inject a rotated pair without clearing
158
+ * persisted state first.
159
+ * @property store Optional store to read credentials from. Never written.
160
+ * @property username Ignored; nothing registers anymore.
161
+ * @property baseUrl Optional root of a legacy gateway that serves `/jwts`,
162
+ * such as `https://api.provable.com`. Without it the session mints nothing,
163
+ * because the default gateway has no JWT route. The factories derive it from
164
+ * the prover or scanner URL the caller configured.
165
+ * @property transport Optional fetch-compatible transport for the mint.
166
+ * Defaults to the global `fetch`. Applies when a caller intercepts or
167
+ * instruments HTTP — a proxy, a recorder, a test stub.
189
168
  */
190
169
  type CreateProvableSessionOptions = {
191
170
  credentials?: ProvableApiCredentials;
@@ -197,11 +176,10 @@ type CreateProvableSessionOptions = {
197
176
  /**
198
177
  * Options for {@link authenticateProvableApi}.
199
178
  *
200
- * @property username Optional handle to register under when the client's
201
- * configuration yields no credentials. Overrides the name configured on the
202
- * session.
179
+ * @property username Ignored; nothing registers anymore.
203
180
  * @property forceRefresh Mint a fresh JWT even when the cached one is still
204
181
  * valid. Defaults to false. Applies when recovering from a rejected token.
182
+ * No effect without credentials.
205
183
  */
206
184
  type AuthenticateProvableApiParameters = {
207
185
  username?: string;
@@ -210,20 +188,17 @@ type AuthenticateProvableApiParameters = {
210
188
  /**
211
189
  * Result of {@link authenticateProvableApi}.
212
190
  *
213
- * @property credentials The resolved consumer credentials. Worth persisting
214
- * when `registered` is true — the API key is unrecoverable afterward.
191
+ * @property credentials The credentials the client was configured with, or
192
+ * `undefined` when it holds none.
215
193
  * @property expiration Expiry of the minted JWT, as milliseconds since the
216
- * Unix epoch.
217
- * @property registered Whether this call registered a new consumer rather than
218
- * loading an existing one.
219
- * @property applied Which paths the session reaches. `recordScanning` is false
220
- * when the client was given a record provider that cannot accept a session —
221
- * any implementation other than the ones this package builds — in which case
222
- * that provider keeps using the credentials it was constructed with.
194
+ * Unix epoch, or `undefined` when nothing mints one.
195
+ * @property registered Always false; nothing registers anymore.
196
+ * @property applied Which paths the client's session reaches. All false for a
197
+ * keyed client or a client built without a session.
223
198
  */
224
199
  type AuthenticateProvableApiReturnType = {
225
- credentials: ProvableApiCredentials;
226
- expiration: number;
200
+ credentials: ProvableApiCredentials | undefined;
201
+ expiration: number | undefined;
227
202
  registered: boolean;
228
203
  applied: ProvableSessionConsumers;
229
204
  };
@@ -276,79 +251,71 @@ type ProvingConfigWithSession = ProvingConfig & {
276
251
  keyedAuth?: ProvableKeyedAuth | undefined;
277
252
  };
278
253
  /**
279
- * Registers a Provable API consumer and returns its credentials.
280
- *
281
- * Unauthenticated — this is the call that issues the credentials everything
282
- * else authenticates with. Hits the network.
254
+ * Formerly registered a Provable API consumer. Now a no-op.
283
255
  *
284
- * A username is spent once. It is globally unique, the API exposes no endpoint
285
- * that reads a consumer back, and a duplicate registration answers 409 with
286
- * nothing usable in it — so a taken name cannot be traded for the credentials it
287
- * belongs to, and the only remedy is the stored key or a different name.
256
+ * The default gateway needs no consumer, and the legacy gateway issues no new
257
+ * ones through this SDK. Resolves without contacting the network.
288
258
  *
289
- * @param params Handle to register under, and optionally a non-default API root.
290
- * @returns The consumer id and API key. The key is shown only here, so the
291
- * caller MUST persist it.
292
- * @throws When the username is already registered, when registration returns any
293
- * other non-2xx status, or when the response body does not carry a consumer id
294
- * and key.
259
+ * @deprecated Consumer registration is retired. Remove the call; pass a
260
+ * consumer pair the caller already holds, or a provisioned key through
261
+ * `auth`.
262
+ * @param params Ignored.
263
+ * @returns `undefined`.
295
264
  *
296
265
  * @example
297
266
  * const credentials = await registerProvableApi({ username: 'my-bot-42' })
298
- * await writeFile('creds.json', JSON.stringify(credentials))
267
+ * // credentials is undefined
299
268
  */
300
- declare function registerProvableApi(params: RegisterProvableApiParameters): Promise<ProvableApiCredentials>;
269
+ declare function registerProvableApi(params: RegisterProvableApiParameters): Promise<ProvableApiCredentials | undefined>;
301
270
  /**
302
- * Builds a Provable API session that resolves credentials and refreshes its JWT.
303
- *
304
- * Credentials resolve on first use — supplied directly, else loaded from the
305
- * store, else registered and saved. Registration and minting are each
306
- * single-flighted, so a cold client that proves and scans concurrently
307
- * registers once and mints once. Pure and local until the first
308
- * `getCredentials` or `getJwt` call.
309
- *
310
- * @param options Credential source, optional persistence, and the name to
311
- * register under.
271
+ * Builds a Provable API session that mints JWTs from the credentials it is given.
272
+ *
273
+ * Credentials come from `credentials` or, failing that, from the store. With a
274
+ * pair and a `baseUrl` the session mints a JWT on first use and refreshes it
275
+ * near expiry, single-flighting concurrent mints so a cold client that proves
276
+ * and scans together mints once. Without either it is inert: `getJwt` resolves
277
+ * to `undefined` and nothing is requested, because the default gateway needs
278
+ * no token. A root that answers the mint with 404 has no JWT route — a devnode,
279
+ * a self-hosted edge — and the session goes inert from then on rather than
280
+ * failing a client that never needed a token. Nothing registers a consumer in
281
+ * any case.
282
+ *
283
+ * @param options Credential source, legacy mint root, and transport.
312
284
  * @returns A session for `createProvingConfig`, `createRemoteScanner`, and
313
285
  * `createAleoClient` to share.
314
286
  *
315
287
  * @example
316
- * const session = createProvableSession({ store, username: 'my-bot-42' })
317
- * const { jwt } = await session.getJwt()
288
+ * const session = createProvableSession({
289
+ * credentials: { consumerId, apiKey },
290
+ * baseUrl: 'https://api.provable.com',
291
+ * })
292
+ * const jwt = await session.getJwt()
318
293
  */
319
294
  declare function createProvableSession(options?: CreateProvableSessionOptions): ProvableSession;
320
295
  /**
321
296
  * Resolves the Provable API session backing delegated proving and record scanning.
322
297
  *
323
- * Registers a consumer when the client's configuration yields none, mints a
324
- * JWT, and leaves both on the session the client's proving configuration and
325
- * record provider already hold — so proving and scanning authenticate from then
326
- * on without further setup. Optional: the first prove or scan resolves the same
327
- * session lazily. Calling it explicitly front-loads registration, surfaces
328
- * credential failures before a transaction is built, and returns a newly issued
329
- * API key at the one moment it is recoverable.
330
- *
331
- * Hits the network: registration on first run, plus one JWT mint.
298
+ * With a credential pair aimed at a legacy gateway this mints the JWT eagerly,
299
+ * so a bad key fails before a transaction is built, and reports the expiry.
300
+ * Otherwise it is a no-op: the default gateway needs no token, so a keyed,
301
+ * credential-less, or default-gateway client resolves immediately with no
302
+ * expiry. Never throws for lack of a session, and never registers a consumer.
332
303
  *
333
- * @param client A client whose proving configuration carries Provable API
334
- * credentials or a credential store.
335
- * @param params Optional registration name and forced refresh.
336
- * @returns The credentials, the JWT expiry, whether a consumer was registered,
337
- * and which paths the session reaches.
338
- * @throws When the client has no Provable API session configured, or when
339
- * registration or minting fails.
304
+ * @param client Any client.
305
+ * @param params Optional forced refresh; `username` is ignored.
306
+ * @returns The configured credentials or `undefined`, the JWT expiry or
307
+ * `undefined`, `registered` false, and which paths the session reaches.
308
+ * @throws When a configured pair fails to mint.
340
309
  *
341
310
  * @example
342
- * const { credentials, registered } = await client.authenticateProvableApi()
343
- * if (registered) await store.save(credentials)
311
+ * const { expiration, applied } = await client.authenticateProvableApi()
344
312
  */
345
313
  declare function authenticateProvableApi(client: Client, params?: AuthenticateProvableApiParameters): Promise<AuthenticateProvableApiReturnType>;
346
314
  /**
347
315
  * Builds the Provable API auth decorator for `client.extend()`.
348
316
  *
349
317
  * `createAleoClient` applies this already. Applies directly when composing a
350
- * client by hand from `createWalletClient` and a proving configuration built
351
- * with credentials.
318
+ * client by hand from `createWalletClient` and a proving configuration.
352
319
  *
353
320
  * @returns A decorator: pass it to `client.extend(...)`.
354
321
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provablehq/veil-aleo-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Local signing and proving for the Veil Aleo SDK, backed by the Provable SDK.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,16 +33,16 @@
33
33
  "access": "public"
34
34
  },
35
35
  "peerDependencies": {
36
- "@provablehq/veil-core": ">=0.6.0 <1.0.0",
37
- "@provablehq/veil-aleo-devnode": ">=0.6.0 <1.0.0"
36
+ "@provablehq/veil-core": ">=0.11.0 <1.0.0",
37
+ "@provablehq/veil-aleo-devnode": ">=0.11.0 <1.0.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@noble/hashes": "^1.7.2",
41
- "@provablehq/sdk": "^0.11.9",
41
+ "@provablehq/sdk": "^0.11.10",
42
42
  "@scure/bip39": "^1.4.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@provablehq/veil-leo": "0.9.0"
45
+ "@provablehq/veil-leo": "0.11.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup",