@openzeppelin/miden-multisig-client 0.18.0-rc.3 → 0.18.1
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 +117 -25
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +77 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/lookupAuth.d.ts.map +1 -1
- package/dist/lookupAuth.js +2 -20
- package/dist/lookupAuth.js.map +1 -1
- package/dist/multisig/authArgErrors.d.ts +27 -1
- package/dist/multisig/authArgErrors.d.ts.map +1 -1
- package/dist/multisig/authArgErrors.js +33 -0
- package/dist/multisig/authArgErrors.js.map +1 -1
- package/dist/multisig.d.ts +77 -11
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +247 -181
- package/dist/multisig.js.map +1 -1
- package/dist/proposal/metadata.d.ts.map +1 -1
- package/dist/proposal/metadata.js +2 -0
- package/dist/proposal/metadata.js.map +1 -1
- package/dist/recovery/transportDrain.d.ts +38 -30
- package/dist/recovery/transportDrain.d.ts.map +1 -1
- package/dist/recovery/transportDrain.js +113 -113
- package/dist/recovery/transportDrain.js.map +1 -1
- package/dist/session/grant.d.ts +40 -0
- package/dist/session/grant.d.ts.map +1 -0
- package/dist/session/grant.js +125 -0
- package/dist/session/grant.js.map +1 -0
- package/dist/session/key.d.ts +103 -0
- package/dist/session/key.d.ts.map +1 -0
- package/dist/session/key.js +160 -0
- package/dist/session/key.js.map +1 -0
- package/dist/session/manager.d.ts +76 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +187 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/signers/ecdsa.d.ts +5 -1
- package/dist/signers/ecdsa.d.ts.map +1 -1
- package/dist/signers/ecdsa.js +9 -0
- package/dist/signers/ecdsa.js.map +1 -1
- package/dist/signers/falcon.d.ts +5 -1
- package/dist/signers/falcon.d.ts.map +1 -1
- package/dist/signers/falcon.js +9 -0
- package/dist/signers/falcon.js.map +1 -1
- package/dist/signers/ledger.d.ts +9 -1
- package/dist/signers/ledger.d.ts.map +1 -1
- package/dist/signers/ledger.js +13 -1
- package/dist/signers/ledger.js.map +1 -1
- package/dist/signers/miden-wallet.d.ts +13 -1
- package/dist/signers/miden-wallet.d.ts.map +1 -1
- package/dist/signers/miden-wallet.js +25 -0
- package/dist/signers/miden-wallet.js.map +1 -1
- package/dist/signers/para.d.ts +5 -1
- package/dist/signers/para.d.ts.map +1 -1
- package/dist/signers/para.js +9 -0
- package/dist/signers/para.js.map +1 -1
- package/dist/transaction/authArgs.d.ts +2 -2
- package/dist/transaction/authArgs.js +2 -2
- package/dist/transaction/options.d.ts +2 -2
- package/dist/transaction/summary.d.ts +17 -61
- package/dist/transaction/summary.d.ts.map +1 -1
- package/dist/transaction/summary.js +49 -95
- package/dist/transaction/summary.js.map +1 -1
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +1 -1
- package/dist/transaction.js.map +1 -1
- package/dist/types/proposal.d.ts +11 -5
- package/dist/types/proposal.d.ts.map +1 -1
- package/dist/types/proposal.js.map +1 -1
- package/dist/utils/eip712.d.ts +26 -69
- package/dist/utils/eip712.d.ts.map +1 -1
- package/dist/utils/eip712.js +101 -8
- package/dist/utils/eip712.js.map +1 -1
- package/dist/utils/felt.d.ts +7 -1
- package/dist/utils/felt.d.ts.map +1 -1
- package/dist/utils/felt.js +18 -1
- package/dist/utils/felt.js.map +1 -1
- package/package.json +4 -4
- package/src/client.ts +95 -0
- package/src/index.ts +27 -6
- package/src/lookupAuth.ts +3 -22
- package/src/multisig/authArgErrors.ts +42 -1
- package/src/multisig.ts +318 -207
- package/src/proposal/metadata.ts +2 -0
- package/src/recovery/transportDrain.ts +118 -124
- package/src/session/grant.ts +143 -0
- package/src/session/key.ts +215 -0
- package/src/session/manager.ts +273 -0
- package/src/signers/ecdsa.ts +12 -1
- package/src/signers/falcon.ts +12 -1
- package/src/signers/ledger.ts +19 -2
- package/src/signers/miden-wallet.ts +29 -1
- package/src/signers/para.ts +12 -1
- package/src/transaction/authArgs.ts +2 -2
- package/src/transaction/options.ts +2 -2
- package/src/transaction/summary.ts +62 -110
- package/src/transaction.ts +1 -6
- package/src/types/proposal.ts +11 -5
- package/src/utils/eip712.ts +130 -10
- package/src/utils/felt.ts +19 -1
package/README.md
CHANGED
|
@@ -17,13 +17,13 @@ Miden multisig accounts store their authentication logic on-chain, but **their s
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @openzeppelin/miden-multisig-client@0.18.
|
|
20
|
+
npm install @openzeppelin/miden-multisig-client@0.18.1 @miden-sdk/miden-sdk@0.17.3
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Miden 0.17 requires a new client database: a store created under 0.16 does
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
Miden 0.17 requires a new client database: a store created under 0.16 does not
|
|
24
|
+
open. Pass a fresh `storeName` when creating the `MidenClient`, or delete the
|
|
25
|
+
existing IndexedDB database first. Accounts and pending proposals from the 0.16
|
|
26
|
+
line do not carry over. See the compatibility document below.
|
|
27
27
|
|
|
28
28
|
> **Why the peer version is exact**: the transaction-summary layout and the
|
|
29
29
|
> guarded-multisig procedure roots are only byte-compatible between one
|
|
@@ -214,6 +214,67 @@ After creating the account, register it on the GUARDIAN server:
|
|
|
214
214
|
await multisig.registerOnGuardian();
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
### Sign Requests With a Session
|
|
218
|
+
|
|
219
|
+
Every Guardian request is otherwise signed by the wallet, which on a hardware
|
|
220
|
+
wallet means a prompt per request. When the Guardian supports sessions, the
|
|
221
|
+
wallet signs one grant and a non-extractable WebCrypto P-256 key, the delegated
|
|
222
|
+
signer, signs reads and proposal requests until the session ends:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import {
|
|
226
|
+
IndexedDbSessionKeyStore,
|
|
227
|
+
describeSessionGrant,
|
|
228
|
+
} from '@openzeppelin/miden-multisig-client';
|
|
229
|
+
|
|
230
|
+
const store = new IndexedDbSessionKeyStore(); // optional: survive reloads
|
|
231
|
+
// 'expired', 'revoked' or 'rejected': requests are wallet-signed again, so
|
|
232
|
+
// offer a new session. 'logout': the app ended it itself.
|
|
233
|
+
const onEnded = (reason) => console.info('Guardian session ended:', reason);
|
|
234
|
+
const session =
|
|
235
|
+
(await client.resumeSession(signer, store, { onEnded })) ??
|
|
236
|
+
(await client.startSession(signer, {
|
|
237
|
+
store,
|
|
238
|
+
onEnded,
|
|
239
|
+
// Required for raw wallets, which only show a hash.
|
|
240
|
+
confirm: (grant) => showToUser(describeSessionGrant(grant)),
|
|
241
|
+
}));
|
|
242
|
+
|
|
243
|
+
// ...sync, list proposals and create proposals without wallet prompts.
|
|
244
|
+
// Approving a proposal still asks the wallet to sign the transaction.
|
|
245
|
+
|
|
246
|
+
await client.endSession(store); // this session only
|
|
247
|
+
await client.revokeAllSessions(signer, store); // every session of the signer, wallet-signed
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The grant covers every account the signer cosigns on this Guardian, now or
|
|
251
|
+
later, until it expires. It names the website that asked for it
|
|
252
|
+
(`location.origin` by default). The page writes that field, so it is
|
|
253
|
+
unverified: the trustworthy signal is the wallet's own indicator of the
|
|
254
|
+
requesting site, and Guardian does not check it against requests. Ledger and
|
|
255
|
+
other EIP-712 wallets sign the grant as readable typed data (`GuardianSession`:
|
|
256
|
+
signer, session key, website, issued/expires, scope, Guardian key, network).
|
|
257
|
+
Without registered display metadata, Ledger devices need "Verbose EIP-712"
|
|
258
|
+
enabled. Raw (Falcon, raw ECDSA) wallets show only a hash, so `startSession`
|
|
259
|
+
requires `confirm` for them; that shows the fields on an honest page but is
|
|
260
|
+
no protection against a phishing page, which shows what it wants.
|
|
261
|
+
Transaction approvals, account registration, delta pushes, candidate abandons
|
|
262
|
+
and account lookup still use the wallet; the server rejects session
|
|
263
|
+
credentials there with `wallet_signature_required`.
|
|
264
|
+
|
|
265
|
+
The session ends when it expires, when it is logged out or revoked, or when
|
|
266
|
+
Guardian no longer accepts it (for example after a Guardian restart without
|
|
267
|
+
persistent sessions, or a Guardian key rotation). Requests then go back to the
|
|
268
|
+
wallet, the stored key is forgotten, and `onEnded` is called once with the
|
|
269
|
+
reason. Removing the signer from an account ends its delegated access to that
|
|
270
|
+
account (`authorization_failed`, the session keeps working for the others);
|
|
271
|
+
adding it back restores any unexpired grant.
|
|
272
|
+
|
|
273
|
+
Page logout is not revocation: a script that stole the key keeps it, so use
|
|
274
|
+
`revokeAllSessions` when in doubt, and run it again 10 minutes later.
|
|
275
|
+
Revoke-all ends the sessions already registered with Guardian, and a page that
|
|
276
|
+
got a grant signed can register it for up to about 10 minutes afterwards.
|
|
277
|
+
|
|
217
278
|
### Load an Existing Multisig
|
|
218
279
|
|
|
219
280
|
The configuration is automatically detected from the account's on-chain storage:
|
|
@@ -310,8 +371,10 @@ createSwitchGuardianProposal(endpoint, pubkey, { nonce }?)
|
|
|
310
371
|
createCustomProposal(requestBytes, label, { nonce }?)
|
|
311
372
|
```
|
|
312
373
|
|
|
313
|
-
All methods accept `nonce` (identifies the proposal; defaults to
|
|
314
|
-
|
|
374
|
+
All methods accept `nonce` (identifies the proposal; defaults to the store
|
|
375
|
+
account's nonce plus one, the nonce the executed transaction will have, as the
|
|
376
|
+
Rust SDK labels proposals; through 0.18.0 the default was `Date.now()`).
|
|
377
|
+
`newThreshold` defaults to the current threshold on add and to
|
|
315
378
|
the min of the current threshold and the remaining signer count on remove.
|
|
316
379
|
The option shapes are exported as `CreateProposalOptions`,
|
|
317
380
|
`CreateSignerProposalOptions`, and `CreateP2idProposalOptions`.
|
|
@@ -367,7 +430,12 @@ for (const p of proposals) {
|
|
|
367
430
|
### Recover From a Dead Transaction (Abandon)
|
|
368
431
|
|
|
369
432
|
If an approved transaction died client-side after guardian approval, the
|
|
370
|
-
candidate keeps the account locked on GUARDIAN
|
|
433
|
+
candidate keeps the account locked on GUARDIAN: proposals and deltas answer
|
|
434
|
+
`conflict_pending_delta` while the account's candidate queue (one candidate
|
|
435
|
+
by default) is full, when they build on the state that candidate already
|
|
436
|
+
claimed, or when their nonce does not extend the queue (a proposal's must be
|
|
437
|
+
the newest queued candidate's plus one), and any candidate queued behind it
|
|
438
|
+
can never land. Record an abandon intent
|
|
371
439
|
and poll for the resolution:
|
|
372
440
|
|
|
373
441
|
```typescript
|
|
@@ -456,8 +524,10 @@ sync height, so `syncProposals`, `signProposal`, `executeProposal`,
|
|
|
456
524
|
client first. Foreign accounts, the fee faucet among them, load at the tip, so
|
|
457
525
|
a proposal stays verifiable however long it waits for signatures, even after
|
|
458
526
|
the node has pruned the bound block's account state (devnet keeps about 50
|
|
459
|
-
blocks). The proposal's `
|
|
460
|
-
|
|
527
|
+
blocks). The proposal's `boundBlockNum` records the bound block. The SDK reads
|
|
528
|
+
that block from the signed summary when it creates a proposal and when it
|
|
529
|
+
verifies one, and refuses a proposal whose `boundBlockNum` disagrees
|
|
530
|
+
(`BoundBlockMismatchError`), as the Rust SDK does.
|
|
461
531
|
|
|
462
532
|
`createTransactionProposalRequest(proposalId)` returns the final, fully
|
|
463
533
|
signed request for an integration that proves and submits with its own
|
|
@@ -476,6 +546,18 @@ if (proposal.status === 'ready') {
|
|
|
476
546
|
}
|
|
477
547
|
```
|
|
478
548
|
|
|
549
|
+
GUARDIAN pins every proposal to the account state its transaction must execute
|
|
550
|
+
on. Execution (and `createTransactionProposalRequest` and
|
|
551
|
+
`prepareCustomExecution`) refuses a proposal pinned to a state other than the one
|
|
552
|
+
this client holds: sync with `syncState()` and retry, or create a new proposal if
|
|
553
|
+
the account has moved past that state. A `switch_guardian` proposal is checked
|
|
554
|
+
the same way when the pre-switch GUARDIAN serves it. When that GUARDIAN never
|
|
555
|
+
received it (made offline), is unreachable, or answers with an error, the switch
|
|
556
|
+
executes without the check (logging a warning in the last two cases), so a
|
|
557
|
+
GUARDIAN the account is rotating away from cannot block the rotation. After
|
|
558
|
+
the switch the delta is pushed back to it best-effort, naming the state the
|
|
559
|
+
switch executed on, as the Rust SDK does.
|
|
560
|
+
|
|
479
561
|
### Export Proposal for Offline Signing
|
|
480
562
|
|
|
481
563
|
```typescript
|
|
@@ -541,7 +623,7 @@ exported/imported through the normal flow, but the SDK cannot build its on-chain
|
|
|
541
623
|
transaction — the integration owns that recipe and submits it itself.
|
|
542
624
|
|
|
543
625
|
```typescript
|
|
544
|
-
import { buildP2idTransactionRequest
|
|
626
|
+
import { buildP2idTransactionRequest } from '@openzeppelin/miden-multisig-client';
|
|
545
627
|
|
|
546
628
|
// Producer: build a transaction and propose it under a custom label.
|
|
547
629
|
// The options object accepts `noteType` (`NoteType.Public` (default) or
|
|
@@ -570,7 +652,8 @@ const advice = await multisig.prepareCustomExecution(proposal.id, request.serial
|
|
|
570
652
|
// The browser TransactionRequest is immutable, so rebuild from the same recipe
|
|
571
653
|
// (inputs + salt + bound block) with the advice, then submit. `submitTransaction`
|
|
572
654
|
// executes at the chain tip: the rebuilt request declares the block it binds.
|
|
573
|
-
|
|
655
|
+
// `prepareCustomExecution` has checked `boundBlockNum` against the signed summary.
|
|
656
|
+
const boundBlockNum = proposal.metadata.boundBlockNum;
|
|
574
657
|
const { request: finalRequest } = await buildP2idTransactionRequest(
|
|
575
658
|
midenClient, senderId, recipientId, faucetId, amount,
|
|
576
659
|
{ salt, boundBlockNum, signatureAdviceMap: advice },
|
|
@@ -594,23 +677,32 @@ integration asks for one through `approvalExpirationDelta`, which the
|
|
|
594
677
|
`create*Proposal` methods forward from their options.
|
|
595
678
|
|
|
596
679
|
The integration keeps its own recipe (build inputs + salt) and reads the bound
|
|
597
|
-
block from
|
|
598
|
-
transaction at execute time
|
|
680
|
+
block from `proposal.metadata.boundBlockNum`, so it can reproduce the exact
|
|
681
|
+
transaction at execute time - the SDK does not store the serialized request.
|
|
682
|
+
Verification and `prepareCustomExecution` refuse a custom proposal whose
|
|
683
|
+
`boundBlockNum` disagrees with its signed summary, as for every other type. A
|
|
684
|
+
proposal a 0.18.0 client made has none; `summaryBoundBlockNum` reads its block
|
|
685
|
+
from the summary.
|
|
599
686
|
The binding check guarantees the rebuilt transaction matches the commitment the
|
|
600
|
-
cosigners signed.
|
|
601
|
-
|
|
602
|
-
|
|
687
|
+
cosigners signed. The request may bind any block up to the client's sync
|
|
688
|
+
height: `createCustomProposal` syncs up to that block when the client is behind
|
|
689
|
+
it and derives the summary at the chain tip.
|
|
603
690
|
|
|
604
691
|
The summary binds the salt itself, so the value the cosigners signed over is
|
|
605
|
-
readable back out of it:
|
|
692
|
+
readable back out of it, as is the block it binds:
|
|
606
693
|
|
|
607
694
|
```typescript
|
|
608
|
-
import {
|
|
695
|
+
import {
|
|
696
|
+
summaryApprovalExpirationBlockNum,
|
|
697
|
+
summaryBoundBlockNum,
|
|
698
|
+
summarySalt,
|
|
699
|
+
} from '@openzeppelin/miden-multisig-client';
|
|
609
700
|
import { TransactionSummary } from '@miden-sdk/miden-sdk';
|
|
610
701
|
|
|
611
702
|
const summary = TransactionSummary.deserialize(bytes);
|
|
612
703
|
const salt = summarySalt(summary);
|
|
613
704
|
const expiresAt = summaryApprovalExpirationBlockNum(summary); // undefined: never
|
|
705
|
+
const boundBlockNum = summaryBoundBlockNum(summary);
|
|
614
706
|
```
|
|
615
707
|
|
|
616
708
|
The SDK's own verification path compares `summarySalt(summary)` with the
|
|
@@ -699,10 +791,11 @@ local store) becomes a `RecoveryStepProblem` entry instead of aborting the
|
|
|
699
791
|
flow, and `retryable: true` means rerunning the flow — which is idempotent —
|
|
700
792
|
can plausibly recover more. In brief:
|
|
701
793
|
|
|
702
|
-
- **Transport drain** —
|
|
703
|
-
every tracked tag
|
|
704
|
-
|
|
705
|
-
best-effort rescan,
|
|
794
|
+
- **Transport drain** — fetches the private-note transport backlog for
|
|
795
|
+
every tracked tag until a fetch moves no tag's cursor. A recovered account's
|
|
796
|
+
tag has no transport cursor yet, so its whole retained backlog is fetched.
|
|
797
|
+
Bounded by the transport service's retention: a best-effort rescan,
|
|
798
|
+
**not** a backup.
|
|
706
799
|
- **Proposal import** — rebuilds importable notes from the bytes v2
|
|
707
800
|
consume-notes proposals embed (validated against the proposals' declared
|
|
708
801
|
note ids) plus node-fetched inclusion proofs, so it works for private
|
|
@@ -795,8 +888,7 @@ discriminator.
|
|
|
795
888
|
trip and are imported into the local store as committed (with one
|
|
796
889
|
`syncState` if the store is behind the note's block). Verification
|
|
797
890
|
therefore reads and writes the local store and contacts the node.
|
|
798
|
-
`createConsumeNotesProposal` does the same before the summary and
|
|
799
|
-
chain anchor are captured, and refuses a note that is not yet
|
|
891
|
+
`createConsumeNotesProposal` does the same before the summary is derived, and refuses a note that is not yet
|
|
800
892
|
committed on chain.
|
|
801
893
|
|
|
802
894
|
`createConsumeNotesProposal` always emits v2 starting with this
|
package/dist/client.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { GuardianHttpClient } from '@openzeppelin/guardian-client';
|
|
|
9
9
|
import type { StateObject } from '@openzeppelin/guardian-client';
|
|
10
10
|
import { Multisig } from './multisig.js';
|
|
11
11
|
import type { MultisigConfig, Signer } from './types.js';
|
|
12
|
+
import type { GuardianSession, SessionKeyStore } from './session/key.js';
|
|
13
|
+
import { type StartSessionOptions } from './session/manager.js';
|
|
12
14
|
import { type ProverConfig } from './prover/config.js';
|
|
13
15
|
import { type RpcConfig } from './rpc/config.js';
|
|
14
16
|
/**
|
|
@@ -81,6 +83,7 @@ export declare class MultisigClient {
|
|
|
81
83
|
private readonly proverConfig;
|
|
82
84
|
private readonly rpcConfig;
|
|
83
85
|
private _guardianClient;
|
|
86
|
+
private guardianSession;
|
|
84
87
|
constructor(midenClient: MidenClient, config: MultisigClientConfig);
|
|
85
88
|
/**
|
|
86
89
|
* Change the GUARDIAN endpoint.
|
|
@@ -92,6 +95,42 @@ export declare class MultisigClient {
|
|
|
92
95
|
* Access the internal GUARDIAN client.
|
|
93
96
|
*/
|
|
94
97
|
get guardianClient(): GuardianHttpClient;
|
|
98
|
+
/**
|
|
99
|
+
* Start a Guardian session: `signer` signs one grant, then a non-extractable
|
|
100
|
+
* browser key (the delegated signer) signs this client's session-eligible
|
|
101
|
+
* Guardian requests (state and delta reads, proposal list/get/create/sign)
|
|
102
|
+
* until the session ends. Account configuration, lookup, delta pushes,
|
|
103
|
+
* candidate abandons and transaction approvals keep using `signer`. Pass
|
|
104
|
+
* `options.store` to survive page reloads via `resumeSession`, and
|
|
105
|
+
* `options.onEnded` to learn when requests fall back to the wallet.
|
|
106
|
+
*
|
|
107
|
+
* A session this client already holds is logged out once the new one is
|
|
108
|
+
* registered. A Guardian endpoint change (`setGuardianEndpoint`) drops the
|
|
109
|
+
* session.
|
|
110
|
+
*/
|
|
111
|
+
startSession(signer: Signer, options?: StartSessionOptions): Promise<GuardianSession>;
|
|
112
|
+
/**
|
|
113
|
+
* Reuse a session key stored by `startSession` without a wallet prompt.
|
|
114
|
+
* Returns `null` when there is none or it is about to expire.
|
|
115
|
+
*/
|
|
116
|
+
resumeSession(signer: Signer, store: SessionKeyStore, options?: Pick<StartSessionOptions, 'onEnded'>): Promise<GuardianSession | null>;
|
|
117
|
+
/**
|
|
118
|
+
* Revoke the current session, fall back to wallet signatures, and forget its
|
|
119
|
+
* stored key. Returns whether Guardian still had the session active. On
|
|
120
|
+
* error the session stays in use.
|
|
121
|
+
*/
|
|
122
|
+
endSession(store?: SessionKeyStore): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Revoke every session of `signer` on the Guardian with a wallet signature,
|
|
125
|
+
* including sessions started in other tabs or devices; stop using the
|
|
126
|
+
* current one and forget its stored key. Use it when a session key may be
|
|
127
|
+
* compromised, and run it again 10 minutes later: it ends only sessions
|
|
128
|
+
* already registered, and a page can register a grant it got signed for up
|
|
129
|
+
* to about 10 minutes. Returns how many sessions Guardian revoked.
|
|
130
|
+
*/
|
|
131
|
+
revokeAllSessions(signer: Signer, store?: SessionKeyStore): Promise<number>;
|
|
132
|
+
/** Forgets the session this client holds once Guardian stops using it. */
|
|
133
|
+
private trackSessionEnd;
|
|
95
134
|
/**
|
|
96
135
|
* Recover the set of accounts a given signer authorizes by querying
|
|
97
136
|
* Guardian's `/state/lookup` endpoint and fetching state for each match.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAiBzB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,iFAAiF;IACjF,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc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AC,QAAQ,CAAC;IA+ChE;;;;;;;;;;;;;;;OAeG;YACW,oBAAoB;CAuEnC"}
|
package/dist/client.js
CHANGED
|
@@ -12,6 +12,7 @@ import { AccountInspector, assertCompleteDetectedConfig } from './inspector.js';
|
|
|
12
12
|
import { requireConfigValue, requireMidenRpcEndpoint } from './config.js';
|
|
13
13
|
import { isSafeToAdoptGuardianState, readOnChainCommitment } from './state/adopt.js';
|
|
14
14
|
import { normalizeHexWord } from './utils/encoding.js';
|
|
15
|
+
import { endGuardianSession, resumeGuardianSession, revokeAllGuardianSessions, startGuardianSession, } from './session/manager.js';
|
|
15
16
|
import { resolveProverConfig, } from './prover/config.js';
|
|
16
17
|
import { resolveRpcConfig, } from './rpc/config.js';
|
|
17
18
|
async function bindSignerAccountKey(signer, midenClient, accountId) {
|
|
@@ -62,6 +63,7 @@ export class MultisigClient {
|
|
|
62
63
|
proverConfig;
|
|
63
64
|
rpcConfig;
|
|
64
65
|
_guardianClient;
|
|
66
|
+
guardianSession = null;
|
|
65
67
|
constructor(midenClient, config) {
|
|
66
68
|
this.midenClient = midenClient;
|
|
67
69
|
this.midenRpcEndpoint = requireMidenRpcEndpoint(config?.midenRpcEndpoint);
|
|
@@ -76,6 +78,7 @@ export class MultisigClient {
|
|
|
76
78
|
*/
|
|
77
79
|
setGuardianEndpoint(endpoint) {
|
|
78
80
|
this._guardianClient = new GuardianHttpClient(requireConfigValue('guardianEndpoint', endpoint));
|
|
81
|
+
this.guardianSession = null;
|
|
79
82
|
}
|
|
80
83
|
/**
|
|
81
84
|
* Access the internal GUARDIAN client.
|
|
@@ -83,6 +86,80 @@ export class MultisigClient {
|
|
|
83
86
|
get guardianClient() {
|
|
84
87
|
return this._guardianClient;
|
|
85
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Start a Guardian session: `signer` signs one grant, then a non-extractable
|
|
91
|
+
* browser key (the delegated signer) signs this client's session-eligible
|
|
92
|
+
* Guardian requests (state and delta reads, proposal list/get/create/sign)
|
|
93
|
+
* until the session ends. Account configuration, lookup, delta pushes,
|
|
94
|
+
* candidate abandons and transaction approvals keep using `signer`. Pass
|
|
95
|
+
* `options.store` to survive page reloads via `resumeSession`, and
|
|
96
|
+
* `options.onEnded` to learn when requests fall back to the wallet.
|
|
97
|
+
*
|
|
98
|
+
* A session this client already holds is logged out once the new one is
|
|
99
|
+
* registered. A Guardian endpoint change (`setGuardianEndpoint`) drops the
|
|
100
|
+
* session.
|
|
101
|
+
*/
|
|
102
|
+
async startSession(signer, options = {}) {
|
|
103
|
+
const previous = this.guardianSession;
|
|
104
|
+
const session = await startGuardianSession(this._guardianClient, signer, {
|
|
105
|
+
...options,
|
|
106
|
+
onEnded: this.trackSessionEnd(options.onEnded),
|
|
107
|
+
});
|
|
108
|
+
this.guardianSession = session;
|
|
109
|
+
if (previous) {
|
|
110
|
+
await endGuardianSession(this._guardianClient, previous, options.store).catch(() => false);
|
|
111
|
+
}
|
|
112
|
+
return session;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reuse a session key stored by `startSession` without a wallet prompt.
|
|
116
|
+
* Returns `null` when there is none or it is about to expire.
|
|
117
|
+
*/
|
|
118
|
+
async resumeSession(signer, store, options = {}) {
|
|
119
|
+
const session = await resumeGuardianSession(this._guardianClient, signer, store, {
|
|
120
|
+
onEnded: this.trackSessionEnd(options.onEnded),
|
|
121
|
+
});
|
|
122
|
+
if (session) {
|
|
123
|
+
this.guardianSession = session;
|
|
124
|
+
}
|
|
125
|
+
return session;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Revoke the current session, fall back to wallet signatures, and forget its
|
|
129
|
+
* stored key. Returns whether Guardian still had the session active. On
|
|
130
|
+
* error the session stays in use.
|
|
131
|
+
*/
|
|
132
|
+
async endSession(store) {
|
|
133
|
+
const session = this.guardianSession;
|
|
134
|
+
if (!session) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const revoked = await endGuardianSession(this._guardianClient, session, store);
|
|
138
|
+
if (this.guardianSession === session) {
|
|
139
|
+
this.guardianSession = null;
|
|
140
|
+
}
|
|
141
|
+
return revoked;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Revoke every session of `signer` on the Guardian with a wallet signature,
|
|
145
|
+
* including sessions started in other tabs or devices; stop using the
|
|
146
|
+
* current one and forget its stored key. Use it when a session key may be
|
|
147
|
+
* compromised, and run it again 10 minutes later: it ends only sessions
|
|
148
|
+
* already registered, and a page can register a grant it got signed for up
|
|
149
|
+
* to about 10 minutes. Returns how many sessions Guardian revoked.
|
|
150
|
+
*/
|
|
151
|
+
async revokeAllSessions(signer, store) {
|
|
152
|
+
return revokeAllGuardianSessions(this._guardianClient, signer, store);
|
|
153
|
+
}
|
|
154
|
+
/** Forgets the session this client holds once Guardian stops using it. */
|
|
155
|
+
trackSessionEnd(onEnded) {
|
|
156
|
+
return (reason, session) => {
|
|
157
|
+
if (this.guardianSession === session) {
|
|
158
|
+
this.guardianSession = null;
|
|
159
|
+
}
|
|
160
|
+
onEnded?.(reason, session);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
86
163
|
/**
|
|
87
164
|
* Recover the set of accounts a given signer authorizes by querying
|
|
88
165
|
* Guardian's `/state/lookup` endpoint and fetching state for each match.
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE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AC;QACtB,CAAC;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtF,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,9 +48,12 @@ export type { TransportRecoveryReport, TransportRecoveryStatus, } from './recove
|
|
|
48
48
|
export type { ProverConfig, ProverRetryPolicy } from './prover/config.js';
|
|
49
49
|
export type { RpcConfig, RpcRetryPolicy } from './rpc/config.js';
|
|
50
50
|
export { lookupAuthDigest } from './lookupAuth.js';
|
|
51
|
+
export { SESSION_GRANT_SCOPE, describeSessionGrant, sessionGrantDigest, sessionLogoutDigest, sessionRevokeAllDigest, } from './session/grant.js';
|
|
52
|
+
export { GuardianSession, IndexedDbSessionKeyStore, type GuardianSessionOptions, WebCryptoSessionKey, type SessionKeyStore, type StoredSessionKey, } from './session/key.js';
|
|
53
|
+
export { GuardianSessionsUnsupportedError, SessionGrantDeclinedError, endGuardianSession, resumeGuardianSession, revokeAllGuardianSessions, startGuardianSession, type StartSessionOptions, } from './session/manager.js';
|
|
51
54
|
export { Multisig, type AccountState, type SyncStateResult, type CreateProposalOptions, type CreateSignerProposalOptions, type CreateP2idProposalOptions, } from './multisig.js';
|
|
52
55
|
export { AccountInspector, type DetectedMultisigConfig, type VaultBalance } from './inspector.js';
|
|
53
|
-
export { ChainBehindBoundBlockError,
|
|
56
|
+
export { ChainBehindBoundBlockError, executeForSummaryAtTip, summaryApprovalExpirationBlockNum, summaryBoundBlockNum, summarySalt, buildUpdateSignersTransactionRequest, buildUpdateProcedureThresholdTransactionRequest, buildUpdateGuardianTransactionRequest, buildConsumeNotesTransactionRequest, buildConsumeNotesTransactionRequestFromNotes, buildP2idTransactionRequest, requestBoundBlockNum, requestSaltHex, MAX_APPROVAL_EXPIRATION_DELTA, parseP2idNoteType, p2idNoteTypeToMetadata, type P2idTransactionOptions, type P2ideHeightOptions, } from './transaction.js';
|
|
54
57
|
export { computeCommitmentFromTxSummary } from './multisig/helpers.js';
|
|
55
58
|
export type { MultisigRequestOptions, SignatureOptions, } from './transaction/options.js';
|
|
56
59
|
export { GuardianHttpClient, GuardianHttpError } from '@openzeppelin/guardian-client';
|
|
@@ -71,7 +74,7 @@ export { createMultisigAccount, validateMultisigConfig, buildMultisigStorageSlot
|
|
|
71
74
|
export { CONSUME_NOTES_METADATA_VERSION_V2, MAX_CONSUME_NOTES_METADATA_BYTES, isConsumeNotesV1, isConsumeNotesV2, isProposalActionable, type ProposalVerification, isP2idNoteVisibility, type P2idNoteVisibility, MAX_P2IDE_BLOCK_HEIGHT, parseP2ideHeight, } from './types/proposal.js';
|
|
72
75
|
export { LEGACY_CONSUME_NOTES_ENABLED, } from './multisig/config.js';
|
|
73
76
|
export { type ConsumeNotesErrorCode, NoteBindingMismatchError, UnsupportedMetadataVersionError, ConsumeNotesMetadataOversizeError, LegacyConsumeNotesNoteMissingError, ConsumeNoteNotAuthenticatedError, } from './multisig/consumeNotesErrors.js';
|
|
74
|
-
export { type AuthArgErrorCode, BoundBlockNotDeclaredError, MultisigAuthArgsMissingError, ProposalSaltMalformedError, } from './multisig/authArgErrors.js';
|
|
77
|
+
export { type AuthArgErrorCode, BoundBlockMismatchError, BoundBlockNotDeclaredError, MultisigAuthArgsMissingError, ProposalSaltMalformedError, TransactionSummaryLayoutError, } from './multisig/authArgErrors.js';
|
|
75
78
|
export { noteToBase64, noteFromBase64, } from './utils/encoding.js';
|
|
76
79
|
export { PROCEDURE_ROOTS, getProcedureRoot, isProcedureName, getProcedureNames, type ProcedureName, } from './procedures.js';
|
|
77
80
|
export type { MultisigAccountState, MultisigConfig, CreateAccountResult, ProcedureThreshold, Proposal, ProposalStatus, ProposalSignatureEntry, ProposalMetadata, ProposalType, ExportedProposal, ExportedTransactionProposal, SignTransactionProposalParams, TransactionProposal, TransactionProposalSignature, TransactionProposalStatus, TransactionType, ConsumableNote, NoteAsset, FalconSignature, Signer, SignatureScheme, AuthConfig, DeltaObject, DeltaStatus, StateObject, CosignerSignature, ConfigureRequest, ConfigureResponse, DeltaProposalRequest, DeltaProposalResponse, ProposalsResponse, PubkeyResponse, SignProposalRequest, } from './types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EACL,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,uBAAuB,EACvB,uBAAuB,GACxB,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|
@@ -45,9 +45,12 @@
|
|
|
45
45
|
*/
|
|
46
46
|
export { MultisigClient, } from './client.js';
|
|
47
47
|
export { lookupAuthDigest } from './lookupAuth.js';
|
|
48
|
+
export { SESSION_GRANT_SCOPE, describeSessionGrant, sessionGrantDigest, sessionLogoutDigest, sessionRevokeAllDigest, } from './session/grant.js';
|
|
49
|
+
export { GuardianSession, IndexedDbSessionKeyStore, WebCryptoSessionKey, } from './session/key.js';
|
|
50
|
+
export { GuardianSessionsUnsupportedError, SessionGrantDeclinedError, endGuardianSession, resumeGuardianSession, revokeAllGuardianSessions, startGuardianSession, } from './session/manager.js';
|
|
48
51
|
export { Multisig, } from './multisig.js';
|
|
49
52
|
export { AccountInspector } from './inspector.js';
|
|
50
|
-
export { ChainBehindBoundBlockError,
|
|
53
|
+
export { ChainBehindBoundBlockError, executeForSummaryAtTip, summaryApprovalExpirationBlockNum, summaryBoundBlockNum, summarySalt, buildUpdateSignersTransactionRequest, buildUpdateProcedureThresholdTransactionRequest, buildUpdateGuardianTransactionRequest, buildConsumeNotesTransactionRequest, buildConsumeNotesTransactionRequestFromNotes, buildP2idTransactionRequest, requestBoundBlockNum, requestSaltHex, MAX_APPROVAL_EXPIRATION_DELTA, parseP2idNoteType, p2idNoteTypeToMetadata, } from './transaction.js';
|
|
51
54
|
// Commitment derivation for hand-rolled export/import flows (issue #433):
|
|
52
55
|
// the proposal id is the tx summary's commitment, recomputed from the
|
|
53
56
|
// serialized summary exactly as import verification does. Returns normalized
|
|
@@ -67,7 +70,7 @@ export { createMultisigAccount, validateMultisigConfig, buildMultisigStorageSlot
|
|
|
67
70
|
export { CONSUME_NOTES_METADATA_VERSION_V2, MAX_CONSUME_NOTES_METADATA_BYTES, isConsumeNotesV1, isConsumeNotesV2, isProposalActionable, isP2idNoteVisibility, MAX_P2IDE_BLOCK_HEIGHT, parseP2ideHeight, } from './types/proposal.js';
|
|
68
71
|
export { LEGACY_CONSUME_NOTES_ENABLED, } from './multisig/config.js';
|
|
69
72
|
export { NoteBindingMismatchError, UnsupportedMetadataVersionError, ConsumeNotesMetadataOversizeError, LegacyConsumeNotesNoteMissingError, ConsumeNoteNotAuthenticatedError, } from './multisig/consumeNotesErrors.js';
|
|
70
|
-
export { BoundBlockNotDeclaredError, MultisigAuthArgsMissingError, ProposalSaltMalformedError, } from './multisig/authArgErrors.js';
|
|
73
|
+
export { BoundBlockMismatchError, BoundBlockNotDeclaredError, MultisigAuthArgsMissingError, ProposalSaltMalformedError, TransactionSummaryLayoutError, } from './multisig/authArgErrors.js';
|
|
71
74
|
export { noteToBase64, noteFromBase64, } from './utils/encoding.js';
|
|
72
75
|
export { PROCEDURE_ROOTS, getProcedureRoot, isProcedureName, getProcedureNames, } from './procedures.js';
|
|
73
76
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,GAGf,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,GAGf,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,wBAAwB,EAExB,mBAAmB,GAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gCAAg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oB,CAAC;AAE5B,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EAEpB,oBAAoB,EAEpB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,wBAAwB,EACxB,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EAClC,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAEL,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAElB,MAAM,iBAAiB,CAAC"}
|
package/dist/lookupAuth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookupAuth.d.ts","sourceRoot":"","sources":["../src/lookupAuth.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lookupAuth.d.ts","sourceRoot":"","sources":["../src/lookupAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAyB/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAmB7F;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D"}
|
package/dist/lookupAuth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FeltArray, Rpo256, Word } from '@miden-sdk/miden-sdk';
|
|
2
|
-
import { feltFromU64Reduced } from './utils/felt.js';
|
|
2
|
+
import { domainTagWord, feltFromU64Reduced } from './utils/felt.js';
|
|
3
3
|
/**
|
|
4
4
|
* Lookup-bound message format used to sign requests against the Guardian
|
|
5
5
|
* `/state/lookup` endpoint. MUST produce byte-identical digests to
|
|
@@ -8,31 +8,13 @@ import { feltFromU64Reduced } from './utils/felt.js';
|
|
|
8
8
|
*/
|
|
9
9
|
const DOMAIN_TAG_BYTES = new TextEncoder().encode('guardian.lookup.v1');
|
|
10
10
|
let cachedDomainTag = null;
|
|
11
|
-
/**
|
|
12
|
-
* Convert a byte array to a sequence of Goldilocks-field felts using the same
|
|
13
|
-
* 8-byte little-endian chunking convention as
|
|
14
|
-
* `guardian_shared::auth_request_payload::AuthRequestPayload::from_bytes`. The
|
|
15
|
-
* final chunk is zero-padded if `bytes.length` is not a multiple of 8.
|
|
16
|
-
*/
|
|
17
|
-
function bytesToFelts(bytes) {
|
|
18
|
-
const felts = [];
|
|
19
|
-
for (let offset = 0; offset < bytes.length; offset += 8) {
|
|
20
|
-
let value = 0n;
|
|
21
|
-
for (let i = 0; i < 8; i += 1) {
|
|
22
|
-
const byte = offset + i < bytes.length ? bytes[offset + i] : 0;
|
|
23
|
-
value |= BigInt(byte) << BigInt(8 * i);
|
|
24
|
-
}
|
|
25
|
-
felts.push(feltFromU64Reduced(value));
|
|
26
|
-
}
|
|
27
|
-
return felts;
|
|
28
|
-
}
|
|
29
11
|
/**
|
|
30
12
|
* The 4-felt RPO domain tag prepended to every lookup digest, computed once
|
|
31
13
|
* from `DOMAIN_TAG_BYTES`. Cached on first call.
|
|
32
14
|
*/
|
|
33
15
|
function lookupDomainTag() {
|
|
34
16
|
if (cachedDomainTag === null) {
|
|
35
|
-
cachedDomainTag =
|
|
17
|
+
cachedDomainTag = domainTagWord(DOMAIN_TAG_BYTES);
|
|
36
18
|
}
|
|
37
19
|
return cachedDomainTag;
|
|
38
20
|
}
|
package/dist/lookupAuth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookupAuth.js","sourceRoot":"","sources":["../src/lookupAuth.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lookupAuth.js","sourceRoot":"","sources":["../src/lookupAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;;;GAKG;AAEH,MAAM,gBAAgB,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAExE,IAAI,eAAe,GAAgB,IAAI,CAAC;AAExC;;;GAGG;AACH,SAAS,eAAe;IACtB,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,eAAe,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAA4B,EAAE,gBAAwB;IACrF,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC,OAAO,EAAE,CAAC;IACxC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACrF,MAAM,aAAa,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAEnD,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC;QAC5B,GAAG,CAAC,CAAC,CAAC;QACN,GAAG,CAAC,CAAC,CAAC;QACN,GAAG,CAAC,CAAC,CAAC;QACN,GAAG,CAAC,CAAC,CAAC;QACN,aAAa;QACb,EAAE,CAAC,CAAC,CAAC;QACL,EAAE,CAAC,CAAC,CAAC;QACL,EAAE,CAAC,CAAC,CAAC;QACL,EAAE,CAAC,CAAC,CAAC;KACN,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC;IAClD,eAAe,GAAG,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Stable error identifiers for auth-arg recovery failures. */
|
|
2
|
-
export type AuthArgErrorCode = 'proposal_salt_malformed' | 'multisig_auth_args_missing' | 'bound_block_not_declared';
|
|
2
|
+
export type AuthArgErrorCode = 'proposal_salt_malformed' | 'multisig_auth_args_missing' | 'bound_block_not_declared' | 'transaction_summary_layout_unsupported' | 'bound_block_mismatch';
|
|
3
3
|
/**
|
|
4
4
|
* A proposal's recorded salt is not a readable 32-byte word, so no rebuild can
|
|
5
5
|
* use it.
|
|
@@ -53,4 +53,30 @@ export declare class BoundBlockNotDeclaredError extends Error {
|
|
|
53
53
|
readonly boundBlockNum: number;
|
|
54
54
|
constructor(boundBlockNum: number);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* A serialized transaction summary does not have the layout this client reads
|
|
58
|
+
* its bound block from: the version 1 encoding of protocol 0.17. Raised instead
|
|
59
|
+
* of reading a number from the wrong offset, so a protocol upgrade that moves
|
|
60
|
+
* the field fails loudly.
|
|
61
|
+
*/
|
|
62
|
+
export declare class TransactionSummaryLayoutError extends Error {
|
|
63
|
+
readonly code: AuthArgErrorCode;
|
|
64
|
+
constructor(reason: string);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A proposal's `boundBlockNum` names a block other than the one its signed
|
|
68
|
+
* summary binds. The value is served unsigned, so one that disagrees is refused
|
|
69
|
+
* by name for every proposal type, as the Rust SDK does.
|
|
70
|
+
*/
|
|
71
|
+
export declare class BoundBlockMismatchError extends Error {
|
|
72
|
+
readonly code: AuthArgErrorCode;
|
|
73
|
+
readonly proposalId: string;
|
|
74
|
+
readonly declaredBoundBlockNum: number;
|
|
75
|
+
readonly boundBlockNum: number;
|
|
76
|
+
constructor(details: {
|
|
77
|
+
proposalId: string;
|
|
78
|
+
declaredBoundBlockNum: number;
|
|
79
|
+
boundBlockNum: number;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
56
82
|
//# sourceMappingURL=authArgErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authArgErrors.d.ts","sourceRoot":"","sources":["../../src/multisig/authArgErrors.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,4BAA4B,GAC5B,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"authArgErrors.d.ts","sourceRoot":"","sources":["../../src/multisig/authArgErrors.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,4BAA4B,GAC5B,0BAA0B,GAC1B,wCAAwC,GACxC,sBAAsB,CAAC;AA0C3B;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAA6B;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAc/F;AAED;;;;;;;GAOG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAgC;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;CAS9B;AA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