@did-btcr2/method 0.36.0 → 0.37.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/.tsbuildinfo +1 -1
- package/dist/browser.js +1371 -260
- package/dist/browser.mjs +1371 -260
- package/dist/cjs/index.js +1464 -343
- package/dist/esm/core/aggregation/beacon-strategy.js +19 -6
- package/dist/esm/core/aggregation/beacon-strategy.js.map +1 -1
- package/dist/esm/core/aggregation/cohort.js +142 -33
- package/dist/esm/core/aggregation/cohort.js.map +1 -1
- package/dist/esm/core/aggregation/conditions.js +27 -0
- package/dist/esm/core/aggregation/conditions.js.map +1 -1
- package/dist/esm/core/aggregation/fallback-spend.js +132 -0
- package/dist/esm/core/aggregation/fallback-spend.js.map +1 -0
- package/dist/esm/core/aggregation/messages/base.js.map +1 -1
- package/dist/esm/core/aggregation/messages/bodies.js +46 -1
- package/dist/esm/core/aggregation/messages/bodies.js.map +1 -1
- package/dist/esm/core/aggregation/messages/constants.js +11 -0
- package/dist/esm/core/aggregation/messages/constants.js.map +1 -1
- package/dist/esm/core/aggregation/messages/factories.js +27 -1
- package/dist/esm/core/aggregation/messages/factories.js.map +1 -1
- package/dist/esm/core/aggregation/messages/guards.js +4 -1
- package/dist/esm/core/aggregation/messages/guards.js.map +1 -1
- package/dist/esm/core/aggregation/participant.js +218 -18
- package/dist/esm/core/aggregation/participant.js.map +1 -1
- package/dist/esm/core/aggregation/phases.js +6 -0
- package/dist/esm/core/aggregation/phases.js.map +1 -1
- package/dist/esm/core/aggregation/recovery-policy.js +156 -0
- package/dist/esm/core/aggregation/recovery-policy.js.map +1 -0
- package/dist/esm/core/aggregation/recovery-spend.js +106 -0
- package/dist/esm/core/aggregation/recovery-spend.js.map +1 -0
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +11 -3
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js +106 -19
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
- package/dist/esm/core/aggregation/runner/service-runner.js +409 -195
- package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
- package/dist/esm/core/aggregation/service.js +221 -11
- package/dist/esm/core/aggregation/service.js.map +1 -1
- package/dist/esm/core/aggregation/signing-session.js +3 -3
- package/dist/esm/core/aggregation/signing-session.js.map +1 -1
- package/dist/esm/core/aggregation/transport/http/envelope.js +3 -3
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +1 -1
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js +1 -1
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js +1 -1
- package/dist/esm/core/aggregation/transport/http/request-auth.js +1 -1
- package/dist/esm/core/aggregation/transport/http/server.js +1 -1
- package/dist/esm/core/aggregation/transport/http/sse-stream.js +1 -1
- package/dist/esm/core/aggregation/transport/http/sse-writer.js +1 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +1 -1
- package/dist/esm/core/aggregation/transport/nostr.js +6 -6
- package/dist/esm/core/beacon/beacon.js +15 -10
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +6 -6
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/singleton-beacon.js +2 -2
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +3 -3
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/resolver.js +8 -8
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/updater.js +6 -6
- package/dist/esm/core/updater.js.map +1 -1
- package/dist/esm/did-btcr2.js +2 -2
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/aggregation/beacon-strategy.d.ts +8 -4
- package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -1
- package/dist/types/core/aggregation/cohort.d.ts +88 -17
- package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
- package/dist/types/core/aggregation/conditions.d.ts +28 -0
- package/dist/types/core/aggregation/conditions.d.ts.map +1 -1
- package/dist/types/core/aggregation/fallback-spend.d.ts +94 -0
- package/dist/types/core/aggregation/fallback-spend.d.ts.map +1 -0
- package/dist/types/core/aggregation/logger.d.ts +1 -1
- package/dist/types/core/aggregation/messages/base.d.ts +6 -0
- package/dist/types/core/aggregation/messages/base.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/bodies.d.ts +50 -2
- package/dist/types/core/aggregation/messages/bodies.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/constants.d.ts +8 -0
- package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/factories.d.ts +40 -0
- package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -1
- package/dist/types/core/aggregation/participant.d.ts +47 -4
- package/dist/types/core/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/aggregation/phases.d.ts +8 -2
- package/dist/types/core/aggregation/phases.d.ts.map +1 -1
- package/dist/types/core/aggregation/recovery-policy.d.ts +132 -0
- package/dist/types/core/aggregation/recovery-policy.d.ts.map +1 -0
- package/dist/types/core/aggregation/recovery-spend.d.ts +94 -0
- package/dist/types/core/aggregation/recovery-spend.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +13 -3
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/events.d.ts +48 -16
- package/dist/types/core/aggregation/runner/events.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +23 -14
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -23
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/service.d.ts +26 -2
- package/dist/types/core/aggregation/service.d.ts.map +1 -1
- package/dist/types/core/aggregation/signing-session.d.ts +2 -2
- package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
- package/dist/types/core/aggregation/transport/http/envelope.d.ts +3 -3
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/server.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +2 -2
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +1 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +1 -1
- package/dist/types/core/aggregation/transport/nostr.d.ts +4 -4
- package/dist/types/core/aggregation/transport/transport.d.ts +4 -4
- package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +7 -7
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +2 -2
- package/dist/types/core/beacon/interfaces.d.ts +1 -1
- package/dist/types/core/resolver.d.ts +3 -3
- package/dist/types/core/updater.d.ts +4 -4
- package/dist/types/did-btcr2.d.ts +2 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/aggregation/beacon-strategy.ts +27 -9
- package/src/core/aggregation/cohort.ts +171 -35
- package/src/core/aggregation/conditions.ts +56 -0
- package/src/core/aggregation/fallback-spend.ts +223 -0
- package/src/core/aggregation/logger.ts +1 -1
- package/src/core/aggregation/messages/base.ts +6 -0
- package/src/core/aggregation/messages/bodies.ts +94 -1
- package/src/core/aggregation/messages/constants.ts +12 -0
- package/src/core/aggregation/messages/factories.ts +57 -0
- package/src/core/aggregation/messages/guards.ts +6 -0
- package/src/core/aggregation/participant.ts +264 -20
- package/src/core/aggregation/phases.ts +9 -0
- package/src/core/aggregation/recovery-policy.ts +237 -0
- package/src/core/aggregation/recovery-spend.ts +192 -0
- package/src/core/aggregation/runner/aggregation-runner.ts +27 -5
- package/src/core/aggregation/runner/events.ts +47 -19
- package/src/core/aggregation/runner/participant-runner.ts +113 -31
- package/src/core/aggregation/runner/service-runner.ts +484 -203
- package/src/core/aggregation/service.ts +260 -14
- package/src/core/aggregation/signing-session.ts +3 -3
- package/src/core/aggregation/transport/http/envelope.ts +3 -3
- package/src/core/aggregation/transport/http/inbox-buffer.ts +1 -1
- package/src/core/aggregation/transport/http/nonce-cache.ts +1 -1
- package/src/core/aggregation/transport/http/rate-limiter.ts +1 -1
- package/src/core/aggregation/transport/http/request-auth.ts +1 -1
- package/src/core/aggregation/transport/http/server.ts +1 -1
- package/src/core/aggregation/transport/http/sse-stream.ts +2 -2
- package/src/core/aggregation/transport/http/sse-writer.ts +1 -1
- package/src/core/aggregation/transport/in-memory.ts +1 -1
- package/src/core/aggregation/transport/nostr.ts +6 -6
- package/src/core/aggregation/transport/transport.ts +4 -4
- package/src/core/beacon/beacon.ts +16 -11
- package/src/core/beacon/cas-beacon.ts +7 -7
- package/src/core/beacon/interfaces.ts +1 -1
- package/src/core/beacon/singleton-beacon.ts +2 -2
- package/src/core/beacon/smt-beacon.ts +3 -3
- package/src/core/resolver.ts +8 -8
- package/src/core/updater.ts +6 -6
- package/src/did-btcr2.ts +2 -2
- package/src/index.ts +3 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
2
2
|
import type { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import type { SerializedSMTProof } from '@did-btcr2/smt';
|
|
4
3
|
import type { CohortAdvert, PendingSigningRequest, PendingValidation } from '../participant.js';
|
|
5
4
|
import { AggregationParticipant } from '../participant.js';
|
|
6
5
|
import type { Transport } from '../transport/transport.js';
|
|
7
|
-
import type { AggregationParticipantEvents } from './events.js';
|
|
6
|
+
import type { AggregationParticipantEvents, CohortCompleteInfo } from './events.js';
|
|
8
7
|
import { TypedEventEmitter } from './typed-emitter.js';
|
|
9
8
|
/** Decision callback: filter discovered cohorts. Default rejects all. */
|
|
10
9
|
export type ShouldJoin = (advert: CohortAdvert) => Promise<boolean>;
|
|
@@ -12,7 +11,7 @@ export type ShouldJoin = (advert: CohortAdvert) => Promise<boolean>;
|
|
|
12
11
|
export type OnProvideUpdate = (info: {
|
|
13
12
|
cohortId: string;
|
|
14
13
|
beaconAddress: string;
|
|
15
|
-
}) => Promise<SignedBTCR2Update>;
|
|
14
|
+
}) => Promise<SignedBTCR2Update | null>;
|
|
16
15
|
/** Decision callback: approve or reject aggregated data. */
|
|
17
16
|
export type OnValidateData = (info: PendingValidation) => Promise<{
|
|
18
17
|
approved: boolean;
|
|
@@ -34,7 +33,7 @@ export interface AggregationParticipantRunnerOptions {
|
|
|
34
33
|
shouldJoin?: ShouldJoin;
|
|
35
34
|
/**
|
|
36
35
|
* Provide a signed BTCR2 update for the cohort.
|
|
37
|
-
* REQUIRED
|
|
36
|
+
* REQUIRED - no sensible default.
|
|
38
37
|
*/
|
|
39
38
|
onProvideUpdate: OnProvideUpdate;
|
|
40
39
|
/**
|
|
@@ -98,16 +97,26 @@ export declare class AggregationParticipantRunner extends TypedEventEmitter<Aggr
|
|
|
98
97
|
stop(): void;
|
|
99
98
|
/**
|
|
100
99
|
* Single-shot helper: start, join the first cohort that passes `shouldJoin`,
|
|
101
|
-
* drive it to completion, and resolve. Convenient for tests and demos.
|
|
100
|
+
* drive it to completion, and resolve. Convenient for tests and demos. The
|
|
101
|
+
* single-cohort special case of {@link joinMatching} (count = 1).
|
|
102
102
|
*/
|
|
103
|
-
static joinFirst(options: AggregationParticipantRunnerOptions): Promise<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
static joinFirst(options: AggregationParticipantRunnerOptions): Promise<CohortCompleteInfo>;
|
|
104
|
+
/**
|
|
105
|
+
* Multi-cohort helper: start, join EVERY cohort whose advert passes
|
|
106
|
+
* `shouldJoin`, drive each to completion in parallel, and resolve once
|
|
107
|
+
* `count` cohorts have completed (the runner stops at that point). The
|
|
108
|
+
* N-cohort generalization of {@link joinFirst}, for a participant that joins
|
|
109
|
+
* several cohorts advertised by one service.
|
|
110
|
+
*
|
|
111
|
+
* For an open-ended, long-lived subscriber (no fixed count), construct an
|
|
112
|
+
* {@link AggregationParticipantRunner} directly, set `shouldJoin`, call
|
|
113
|
+
* `start()`, and listen for `cohort-complete` - the runner already drives
|
|
114
|
+
* any number of cohorts concurrently.
|
|
115
|
+
*
|
|
116
|
+
* @param options Participant runner options (set `shouldJoin` to select cohorts).
|
|
117
|
+
* @param count Number of completed cohorts to collect before resolving.
|
|
118
|
+
* @returns The {@link CohortCompleteInfo} for each completed cohort, in completion order.
|
|
119
|
+
*/
|
|
120
|
+
static joinMatching(options: AggregationParticipantRunnerOptions, count: number): Promise<CohortCompleteInfo[]>;
|
|
112
121
|
}
|
|
113
122
|
//# sourceMappingURL=participant-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,i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;;;;;GAmCG;AACH,qBAAa,4BAA6B,SAAQ,iBAAiB,CAAC,4BAA4B,CAAC;;IAC/F,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;gBAY7B,OAAO,EAAE,mCAAmC;IAexD;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,8EAA8E;IAC9E,IAAI,IAAI,IAAI;IA6BZ;;;;OAIG;WACU,SAAS,CACpB,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,kBAAkB,CAAC;IAY9B;;;;;;;;;;;;;;;OAeG;WACU,YAAY,CACvB,OAAO,EAAE,mCAAmC,EAC5C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAiRjC"}
|
|
@@ -27,8 +27,13 @@ export interface AggregationServiceRunnerOptions {
|
|
|
27
27
|
/** This service's identity. */
|
|
28
28
|
did: string;
|
|
29
29
|
keys: SchnorrKeyPair;
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Default cohort configuration for the {@link AggregationServiceRunner.run}
|
|
32
|
+
* convenience path. Optional: omit it when driving the runner with
|
|
33
|
+
* {@link AggregationServiceRunner.advertiseCohort}, which takes a per-cohort
|
|
34
|
+
* config and can be called many times on one runner.
|
|
35
|
+
*/
|
|
36
|
+
config?: CohortConfig;
|
|
32
37
|
/**
|
|
33
38
|
* Decide whether to accept a participant's opt-in.
|
|
34
39
|
* Default: auto-accept all opt-ins.
|
|
@@ -42,7 +47,7 @@ export interface AggregationServiceRunnerOptions {
|
|
|
42
47
|
onReadyToFinalize?: OnReadyToFinalize;
|
|
43
48
|
/**
|
|
44
49
|
* Provide the Bitcoin transaction data to sign.
|
|
45
|
-
* REQUIRED
|
|
50
|
+
* REQUIRED - no sensible default.
|
|
46
51
|
*/
|
|
47
52
|
onProvideTxData: OnProvideTxData;
|
|
48
53
|
/**
|
|
@@ -52,28 +57,40 @@ export interface AggregationServiceRunnerOptions {
|
|
|
52
57
|
*/
|
|
53
58
|
maxUpdateSizeBytes?: number;
|
|
54
59
|
/**
|
|
55
|
-
* Overall wall-clock budget for
|
|
56
|
-
* On expiry the cohort is dropped, `cohort-failed` is
|
|
57
|
-
* rejects with a timeout error.
|
|
60
|
+
* Overall wall-clock budget for each cohort, from advertise to
|
|
61
|
+
* signing-complete. On expiry the cohort is dropped, `cohort-failed` is
|
|
62
|
+
* emitted, and that cohort's completion rejects with a timeout error. Other
|
|
63
|
+
* cohorts on the same runner are unaffected. Leave undefined to disable.
|
|
58
64
|
*/
|
|
59
65
|
cohortTtlMs?: number;
|
|
60
66
|
/**
|
|
61
|
-
* Maximum time allowed between phase transitions. Protects
|
|
62
|
-
* cohorts (e.g. a participant vanishing mid-protocol). Reset
|
|
63
|
-
* on every observed phase change.
|
|
67
|
+
* Maximum time allowed between phase transitions for a cohort. Protects
|
|
68
|
+
* against stalled cohorts (e.g. a participant vanishing mid-protocol). Reset
|
|
69
|
+
* automatically on every observed phase change. Applied per cohort. Leave
|
|
70
|
+
* undefined to disable.
|
|
64
71
|
*/
|
|
65
72
|
phaseTimeoutMs?: number;
|
|
66
73
|
/**
|
|
67
|
-
* Re-publish COHORT_ADVERT on this interval until keygen is
|
|
68
|
-
* Works around relays that don't backfill historical events to
|
|
69
|
-
* subscribers
|
|
74
|
+
* Re-publish COHORT_ADVERT on this interval until a cohort's keygen is
|
|
75
|
+
* finalized. Works around relays that don't backfill historical events to
|
|
76
|
+
* late subscribers - a republish gives late joiners a window to discover the
|
|
70
77
|
* advert without protocol changes. The first publish is immediate;
|
|
71
|
-
* subsequent publishes fire every `advertRepeatIntervalMs` until
|
|
72
|
-
* keygen
|
|
78
|
+
* subsequent publishes fire every `advertRepeatIntervalMs` until that
|
|
79
|
+
* cohort's keygen completes, fails, or is stopped. Defaults to
|
|
73
80
|
* {@link DEFAULT_ADVERT_REPEAT_INTERVAL_MS} (60 s). Set to 0 to publish
|
|
74
81
|
* once and never retry.
|
|
75
82
|
*/
|
|
76
83
|
advertRepeatIntervalMs?: number;
|
|
84
|
+
/**
|
|
85
|
+
* When a cohort stalls (phase timeout) while the optimistic n-of-n signing
|
|
86
|
+
* round is in flight, fall back to the k-of-n script path instead of failing
|
|
87
|
+
* the cohort (graceful liveness, ADR 042). Off by default: enabling it trades a
|
|
88
|
+
* cheaper/private key-path spend for a larger script-path spend whenever the
|
|
89
|
+
* optimistic round does not complete in time. A stall outside the signing
|
|
90
|
+
* phases still fails the cohort. Operators can also drive the fallback
|
|
91
|
+
* explicitly via {@link AggregationServiceRunner.triggerFallback}.
|
|
92
|
+
*/
|
|
93
|
+
autoFallbackOnStall?: boolean;
|
|
77
94
|
}
|
|
78
95
|
/** Default cadence for re-publishing COHORT_ADVERT until keygen completes: 60 seconds. */
|
|
79
96
|
export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
@@ -84,6 +101,14 @@ export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
|
84
101
|
* encapsulating message handler registration, outgoing message dispatch,
|
|
85
102
|
* and decision callback orchestration.
|
|
86
103
|
*
|
|
104
|
+
* A single runner is a long-lived multiplexer: it advertises and drives many
|
|
105
|
+
* cohorts concurrently over one transport. Each advertised cohort owns an
|
|
106
|
+
* independent completion promise and fails in isolation - a stalled or failed
|
|
107
|
+
* cohort never settles its siblings (see ADR 040). Use
|
|
108
|
+
* {@link AggregationServiceRunner.advertiseCohort} for the multi-cohort path;
|
|
109
|
+
* {@link AggregationServiceRunner.run} is a thin single-cohort convenience over
|
|
110
|
+
* it.
|
|
111
|
+
*
|
|
87
112
|
* @example
|
|
88
113
|
* ```typescript
|
|
89
114
|
* const transport = new NostrTransport({ relays: [RELAY] });
|
|
@@ -93,16 +118,21 @@ export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
|
93
118
|
* transport,
|
|
94
119
|
* did: serviceDid,
|
|
95
120
|
* keys: serviceKeys,
|
|
96
|
-
*
|
|
97
|
-
* onProvideTxData: async ({ beaconAddress, signalBytes }) => {
|
|
121
|
+
* onProvideTxData: async ({ cohortId, beaconAddress, signalBytes }) => {
|
|
98
122
|
* return await buildBeaconTransaction(beaconAddress, signalBytes, bitcoin);
|
|
99
123
|
* },
|
|
100
124
|
* });
|
|
101
125
|
*
|
|
102
|
-
* runner.on('keygen-complete', ({ beaconAddress }) => console.log(beaconAddress));
|
|
103
|
-
* runner.on('signing-complete', ({ signature }) => console.log('done'));
|
|
126
|
+
* runner.on('keygen-complete', ({ cohortId, beaconAddress }) => console.log(beaconAddress));
|
|
127
|
+
* runner.on('signing-complete', ({ cohortId, signature }) => console.log('done', cohortId));
|
|
104
128
|
*
|
|
105
|
-
*
|
|
129
|
+
* // Multi-cohort: advertise several cohorts; each completion resolves independently.
|
|
130
|
+
* const a = runner.advertiseCohort({ minParticipants: 2, network: 'mutinynet', beaconType: 'CASBeacon' });
|
|
131
|
+
* const b = runner.advertiseCohort({ minParticipants: 3, network: 'mutinynet', beaconType: 'SMTBeacon' });
|
|
132
|
+
* const [ra, rb] = await Promise.all([a.completion, b.completion]);
|
|
133
|
+
*
|
|
134
|
+
* // Single-cohort convenience (requires `config` in the options):
|
|
135
|
+
* // const result = await runner.run();
|
|
106
136
|
* ```
|
|
107
137
|
*
|
|
108
138
|
* For full manual control, drop down to the underlying state machine via
|
|
@@ -117,15 +147,64 @@ export declare class AggregationServiceRunner extends TypedEventEmitter<Aggregat
|
|
|
117
147
|
readonly session: AggregationService;
|
|
118
148
|
constructor(options: AggregationServiceRunnerOptions);
|
|
119
149
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
150
|
+
* Advertise a new cohort and begin driving it to completion. Callable many
|
|
151
|
+
* times on one runner; each cohort runs concurrently and independently.
|
|
152
|
+
*
|
|
153
|
+
* @param config Per-cohort conditions + network (see {@link CohortConfig}).
|
|
154
|
+
* @returns The new cohort's id and a `completion` promise that resolves with
|
|
155
|
+
* that cohort's {@link AggregationResult} (or rejects if it fails/stalls).
|
|
156
|
+
* @throws If the runner has been stopped, or the config is invalid
|
|
157
|
+
* (fail-fast via `createCohort`).
|
|
158
|
+
*/
|
|
159
|
+
advertiseCohort(config: CohortConfig): {
|
|
160
|
+
cohortId: string;
|
|
161
|
+
completion: Promise<AggregationResult>;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Run a single cohort to completion using the `config` supplied in the
|
|
165
|
+
* runner options. Thin convenience over {@link advertiseCohort} for the
|
|
166
|
+
* single-cohort case (and the path {@link AggregationRunner.solo} rides).
|
|
122
167
|
*
|
|
123
168
|
* @returns {Promise<AggregationResult>} The final result with signature and signed tx.
|
|
124
169
|
*/
|
|
125
170
|
run(): Promise<AggregationResult>;
|
|
126
171
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
172
|
+
* Wait for every currently-outstanding cohort to settle and return the
|
|
173
|
+
* successful results. Dynamic drain: cohorts advertised while this is pending
|
|
174
|
+
* are included, and it resolves only once no cohorts remain. Failed cohorts
|
|
175
|
+
* are surfaced via `error` / `cohort-failed` events and their rejected
|
|
176
|
+
* `completion` promises; they are omitted from the returned array (this
|
|
177
|
+
* method does not throw). Bound long-running cohorts with `cohortTtlMs` /
|
|
178
|
+
* `phaseTimeoutMs` or this may never resolve.
|
|
179
|
+
*
|
|
180
|
+
* @returns {Promise<AggregationResult[]>} Results of the cohorts that completed.
|
|
181
|
+
*/
|
|
182
|
+
runAll(): Promise<AggregationResult[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Abandon the optimistic n-of-n key path for a cohort and collect k-of-n
|
|
185
|
+
* fallback (script-path) signatures instead (ADR 042). Idempotent and safe
|
|
186
|
+
* against the optimistic completion: it commits the cohort to the fallback
|
|
187
|
+
* path synchronously (the `committedPath` latch) before sending anything, so a
|
|
188
|
+
* late optimistic signature can no longer complete-and-broadcast a competing
|
|
189
|
+
* spend of the same UTXO. No-op if the cohort is unknown, already settled, or
|
|
190
|
+
* already committed to a path.
|
|
191
|
+
*
|
|
192
|
+
* Wired automatically to the phase-stall timer when `autoFallbackOnStall` is
|
|
193
|
+
* set; otherwise call it from an operator decision (a UI "fall back now"
|
|
194
|
+
* action). Throws only if the underlying state machine rejects the transition
|
|
195
|
+
* (e.g. signing has not started).
|
|
196
|
+
*/
|
|
197
|
+
triggerFallback(cohortId: string): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Stop a single cohort early without affecting the rest of the runner. Drops
|
|
200
|
+
* the cohort's state machine state; its `completion` promise rejects with a
|
|
201
|
+
* stopped error.
|
|
202
|
+
*/
|
|
203
|
+
stopCohort(cohortId: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Stop the whole runner. Fails every outstanding cohort, then detaches the
|
|
206
|
+
* shared transport handlers so a restart or a new runner doesn't inherit
|
|
207
|
+
* stale dispatch. Safe to call repeatedly.
|
|
129
208
|
*/
|
|
130
209
|
stop(): void;
|
|
131
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAczD,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kEA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,wBAAwB,CAAC;;IACvF,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAyBzB,OAAO,EAAE,+BAA+B;IA0CpD;;;;;;;;;OASG;IACH,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;KAAE;IA6CnG;;;;;;OAMG;IACH,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAcjC;;;;;;;;;;OAUG;IACG,MAAM,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IA+E5C;;;;;;;;;;;;;OAaG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6EtD;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASlC;;;;OAIG;IACH,IAAI,IAAI,IAAI;CA+Sb"}
|
|
@@ -31,8 +31,19 @@ export interface ValidationProgress {
|
|
|
31
31
|
/** Final aggregation result for a cohort. */
|
|
32
32
|
export interface AggregationResult {
|
|
33
33
|
cohortId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The 64-byte aggregated MuSig2 signature for the optimistic key path. Empty
|
|
36
|
+
* for a `script-path` result: the k-of-n fallback embeds k separate signatures
|
|
37
|
+
* directly in the witness of {@link signedTx}, with no single aggregate sig.
|
|
38
|
+
*/
|
|
34
39
|
signature: Uint8Array;
|
|
35
40
|
signedTx: Transaction;
|
|
41
|
+
/**
|
|
42
|
+
* Which Taproot spend path produced {@link signedTx}: `key-path` is the
|
|
43
|
+
* optimistic n-of-n MuSig2 spend, `script-path` is the k-of-n fallback (ADR
|
|
44
|
+
* 042). Absent is treated as `key-path` for backward compatibility.
|
|
45
|
+
*/
|
|
46
|
+
path?: 'key-path' | 'script-path';
|
|
36
47
|
}
|
|
37
48
|
/** Transaction data needed to start a signing session. */
|
|
38
49
|
export interface SigningTxData {
|
|
@@ -95,7 +106,7 @@ export declare class AggregationService {
|
|
|
95
106
|
drainRejections(cohortId: string): Array<Rejection>;
|
|
96
107
|
/**
|
|
97
108
|
* Create a new cohort with the given config. Returns the cohort ID.
|
|
98
|
-
* Cohort starts in `Created` phase
|
|
109
|
+
* Cohort starts in `Created` phase - call `advertise()` to broadcast.
|
|
99
110
|
*/
|
|
100
111
|
createCohort(config: CohortConfig): string;
|
|
101
112
|
/**
|
|
@@ -125,7 +136,7 @@ export declare class AggregationService {
|
|
|
125
136
|
validationProgress(cohortId: string): ValidationProgress;
|
|
126
137
|
/**
|
|
127
138
|
* Start a signing session by creating auth requests for all participants.
|
|
128
|
-
* The caller provides the transaction data
|
|
139
|
+
* The caller provides the transaction data - typically built via
|
|
129
140
|
* `buildBeaconTransaction()` against a Bitcoin connection.
|
|
130
141
|
*/
|
|
131
142
|
startSigning(cohortId: string, txData: SigningTxData): BaseMessage[];
|
|
@@ -134,6 +145,19 @@ export declare class AggregationService {
|
|
|
134
145
|
* Call after `validationProgress(cohortId).approved.size === total`.
|
|
135
146
|
*/
|
|
136
147
|
sendAggregatedNonce(cohortId: string): BaseMessage[];
|
|
148
|
+
/**
|
|
149
|
+
* Abandon the optimistic n-of-n key path and ask members to authorize the
|
|
150
|
+
* k-of-n fallback (script-path) spend of the SAME beacon transaction (graceful
|
|
151
|
+
* liveness, ADR 042). Reuses the in-flight signing session's transaction and
|
|
152
|
+
* spent output, so the announcement and its outputs are unchanged: only the
|
|
153
|
+
* witness path differs. Returns one FALLBACK_AUTHORIZATION_REQUEST per
|
|
154
|
+
* participant.
|
|
155
|
+
*
|
|
156
|
+
* Callable once optimistic signing has started (the session and its tx exist)
|
|
157
|
+
* and before it completes. A cohort can take exactly one of the two paths: the
|
|
158
|
+
* caller (runner) must commit to fallback and stop driving the optimistic path.
|
|
159
|
+
*/
|
|
160
|
+
startFallbackSigning(cohortId: string): BaseMessage[];
|
|
137
161
|
getResult(cohortId: string): AggregationResult | undefined;
|
|
138
162
|
getCohortPhase(cohortId: string): ServiceCohortPhaseType | undefined;
|
|
139
163
|
getCohort(cohortId: string): AggregationCohort | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKlF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoBtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,UAAU,CAAC;IAC1B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,WAAW,CAAC,MAAM,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G,SAAS;IAI1D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzD,IAAI,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAE9C;IAED;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAGrC"}
|
|
@@ -32,11 +32,11 @@ export declare class BeaconSigningSession {
|
|
|
32
32
|
prevOutScripts: Uint8Array[];
|
|
33
33
|
/** Previous output values for Taproot sighash computation. */
|
|
34
34
|
prevOutValues: bigint[];
|
|
35
|
-
/** Map of participant publicKey-hex
|
|
35
|
+
/** Map of participant publicKey-hex to public nonce contribution. */
|
|
36
36
|
nonceContributions: Map<PublicKeyHex, Nonce>;
|
|
37
37
|
/** Aggregated MuSig2 nonce (66 bytes). */
|
|
38
38
|
aggregatedNonce?: Uint8Array;
|
|
39
|
-
/** Map of participant DID
|
|
39
|
+
/** Map of participant DID to partial signature. */
|
|
40
40
|
partialSignatures: Map<string, Uint8Array>;
|
|
41
41
|
/** Final 64-byte Schnorr signature. */
|
|
42
42
|
signature?: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;;IAC/B,kDAAkD;IAC3C,EAAE,EAAE,MAAM,CAAC;IAElB,yCAAyC;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAEjC,4CAA4C;IACrC,SAAS,EAAE,WAAW,CAAC;IAE9B,yEAAyE;IAClE,cAAc,EAAE,UAAU,EAAE,CAAC;IAEpC,8DAA8D;IACvD,aAAa,EAAE,MAAM,EAAE,CAAC;IAE/B,
|
|
1
|
+
{"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;;IAC/B,kDAAkD;IAC3C,EAAE,EAAE,MAAM,CAAC;IAElB,yCAAyC;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAEjC,4CAA4C;IACrC,SAAS,EAAE,WAAW,CAAC;IAE9B,yEAAyE;IAClE,cAAc,EAAE,UAAU,EAAE,CAAC;IAEpC,8DAA8D;IACvD,aAAa,EAAE,MAAM,EAAE,CAAC;IAE/B,qEAAqE;IAC9D,kBAAkB,EAAE,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAa;IAEhE,0CAA0C;IACnC,eAAe,CAAC,EAAE,UAAU,CAAC;IAEpC,mDAAmD;IAC5C,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;IAE9D,uCAAuC;IAChC,SAAS,CAAC,EAAE,UAAU,CAAC;IAE9B,qCAAqC;IAC9B,KAAK,EAAE,uBAAuB,CAAC;gBAW1B,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,oBAAoB;IAS1F;;OAEG;IACH,IAAI,OAAO,IAAI,UAAU,CAaxB;IAEM,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,GAAG,IAAI;IAgCjF,uBAAuB,IAAI,UAAU;IAYrC,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IA0BzE,sBAAsB,IAAI,UAAU;IA4D3C;;;OAGG;IACI,yBAAyB,CAAC,oBAAoB,EAAE,UAAU,EAAE,oBAAoB,EAAE,UAAU,GAAG,UAAU;IAOhH;;;;;;;;;OASG;IACI,wBAAwB,CAAC,oBAAoB,EAAE,UAAU,GAAG,UAAU;IAqB7E;;;;;OAKG;IACI,YAAY,IAAI,IAAI;IAOpB,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,OAAO;CAG3B"}
|
|
@@ -26,7 +26,7 @@ export interface VerifyEnvelopeOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* Build a {@link SignedEnvelope} around `message`.
|
|
28
28
|
*
|
|
29
|
-
* Pure function
|
|
29
|
+
* Pure function - no I/O beyond `randomBytes` for nonce generation (which
|
|
30
30
|
* uses the platform's cryptographic RNG: `crypto.getRandomValues` in browsers,
|
|
31
31
|
* `node:crypto` in Node). Deterministic when both `nonce` and `timestamp` are
|
|
32
32
|
* supplied via {@link SignEnvelopeOptions}.
|
|
@@ -40,7 +40,7 @@ export declare function signEnvelope(message: EnvelopeMessage, sender: {
|
|
|
40
40
|
* communication public key. Throws {@link HttpTransportError} on any failure;
|
|
41
41
|
* returns normally on success.
|
|
42
42
|
*
|
|
43
|
-
* Does NOT check nonce uniqueness
|
|
43
|
+
* Does NOT check nonce uniqueness - replay protection is the caller's
|
|
44
44
|
* responsibility (the server-side transport maintains an LRU cache).
|
|
45
45
|
*/
|
|
46
46
|
export declare function verifyEnvelope(envelope: SignedEnvelope, senderPk: CompressedSecp256k1PublicKey, opts?: VerifyEnvelopeOptions): void;
|
|
@@ -51,7 +51,7 @@ export declare function verifyEnvelope(envelope: SignedEnvelope, senderPk: Compr
|
|
|
51
51
|
*
|
|
52
52
|
* Without this, `JSON.stringify` serializes a `Uint8Array` as an index-keyed
|
|
53
53
|
* object (`{"0":1,"1":2,...}`), which `canonicalize` then re-parses into a
|
|
54
|
-
* plain object
|
|
54
|
+
* plain object - the receiver cannot reconstruct the original bytes even
|
|
55
55
|
* though the signature still verifies.
|
|
56
56
|
*/
|
|
57
57
|
export declare function normalizeForWire(value: unknown): unknown;
|
|
@@ -12,7 +12,7 @@ export interface StoredEvent {
|
|
|
12
12
|
* When a subscriber (re)connects with a `Last-Event-ID` header, the server
|
|
13
13
|
* uses {@link since} to replay everything that arrived while the subscriber
|
|
14
14
|
* was disconnected. Events older than the replay window (evicted from the
|
|
15
|
-
* ring) are unrecoverable
|
|
15
|
+
* ring) are unrecoverable - callers should choose `capacity` based on
|
|
16
16
|
* expected message rate × acceptable reconnect window.
|
|
17
17
|
*/
|
|
18
18
|
export declare class InboxBuffer {
|
|
@@ -5,7 +5,7 @@ export interface NonceCacheConfig {
|
|
|
5
5
|
/**
|
|
6
6
|
* Bounded anti-replay cache for `(did, nonce)` pairs.
|
|
7
7
|
*
|
|
8
|
-
* Replay windowing is the caller's responsibility
|
|
8
|
+
* Replay windowing is the caller's responsibility - this cache only detects
|
|
9
9
|
* duplicates. Callers are expected to reject envelopes/headers whose timestamp
|
|
10
10
|
* is outside the clock-skew window *before* consulting the cache, so entries
|
|
11
11
|
* here are always within the protocol's acceptable window.
|
|
@@ -29,7 +29,7 @@ export interface RateLimiterConfig {
|
|
|
29
29
|
* sender DID). Tokens refill linearly at `rps` up to `burst`. Each `consume`
|
|
30
30
|
* call atomically debits one token or returns `false` to reject.
|
|
31
31
|
*
|
|
32
|
-
* The limiter is synchronous and deterministic given `nowMs`
|
|
32
|
+
* The limiter is synchronous and deterministic given `nowMs` - tests can
|
|
33
33
|
* drive it with a fixed clock to exercise exact boundaries.
|
|
34
34
|
*/
|
|
35
35
|
export declare class RateLimiter {
|
|
@@ -32,7 +32,7 @@ export interface BuildRequestAuthOptions {
|
|
|
32
32
|
export declare function buildRequestAuth(did: string, keys: SchnorrKeyPair, path: string, opts?: BuildRequestAuthOptions): string;
|
|
33
33
|
/**
|
|
34
34
|
* Parse a `BTCR2-Sig` auth header value into its structured fields. Does NOT
|
|
35
|
-
* verify the signature
|
|
35
|
+
* verify the signature: call {@link verifyRequestAuth} for that.
|
|
36
36
|
*/
|
|
37
37
|
export declare function parseRequestAuth(headerValue: string): ParsedRequestAuth;
|
|
38
38
|
export interface VerifyRequestAuthOptions {
|
|
@@ -65,7 +65,7 @@ export interface HttpServerTransportConfig {
|
|
|
65
65
|
now?: () => number;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Server-side HTTP transport. Sans-I/O
|
|
68
|
+
* Server-side HTTP transport. Sans-I/O - the caller mounts
|
|
69
69
|
* {@link handleRequest} and {@link handleSse} under their HTTP framework of
|
|
70
70
|
* choice; the transport owns only in-memory state (actors, inboxes, advert
|
|
71
71
|
* cache, replay / rate-limit policies).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parsed Server-Sent Events record.
|
|
3
3
|
*
|
|
4
|
-
* Events without a `data` field are never yielded (per the SSE spec
|
|
4
|
+
* Events without a `data` field are never yielded (per the SSE spec - only a
|
|
5
5
|
* blank line that follows at least one `data:` line dispatches an event).
|
|
6
6
|
*/
|
|
7
7
|
export interface SseEvent {
|
|
@@ -23,7 +23,7 @@ export interface SseEvent {
|
|
|
23
23
|
* CR-only line terminators are not supported (every mainstream SSE
|
|
24
24
|
* implementation emits LF or CRLF).
|
|
25
25
|
*
|
|
26
|
-
* Pure, runtime-agnostic
|
|
26
|
+
* Pure, runtime-agnostic - works anywhere `ReadableStream<Uint8Array>` and
|
|
27
27
|
* `TextDecoder` exist (browsers and Node 22+).
|
|
28
28
|
*
|
|
29
29
|
* The caller owns stream lifecycle: cancellation should be effected via an
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Format an SSE event frame. Pairs with {@link parseSseStream}.
|
|
3
3
|
*
|
|
4
|
-
* Multi-line `data` is split across multiple `data:` lines per the SSE spec
|
|
4
|
+
* Multi-line `data` is split across multiple `data:` lines per the SSE spec -
|
|
5
5
|
* each embedded `\n` becomes its own line, and the parser rejoins them.
|
|
6
6
|
*
|
|
7
7
|
* The returned string includes a trailing blank line (the dispatch marker).
|
|
@@ -4,7 +4,7 @@ import type { MessageHandler, Transport } from './transport.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* In-process message bus connecting one or more {@link InMemoryTransport}
|
|
6
6
|
* instances. Routes broadcasts to every registered actor and directed messages
|
|
7
|
-
* to the actor that owns the recipient DID
|
|
7
|
+
* to the actor that owns the recipient DID, with no relay, server, or network.
|
|
8
8
|
*
|
|
9
9
|
* Each delivery does a JSON round-trip (Uint8Array preserved as `__bytes` hex)
|
|
10
10
|
* so handlers receive an isolated, serialization-faithful copy, exactly as a
|
|
@@ -38,9 +38,9 @@ export declare const DEFAULT_BROADCAST_LOOKBACK_MS: number;
|
|
|
38
38
|
* sending or receiving.
|
|
39
39
|
*
|
|
40
40
|
* Message routing:
|
|
41
|
-
* - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY)
|
|
42
|
-
* - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK)
|
|
43
|
-
* - Sign messages
|
|
41
|
+
* - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY) to kind 1 (plaintext)
|
|
42
|
+
* - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK) to kind 1059 (NIP-44 encrypted)
|
|
43
|
+
* - Sign messages to kind 1059 (NIP-44 encrypted)
|
|
44
44
|
*
|
|
45
45
|
* @class NostrTransport
|
|
46
46
|
* @implements {Transport}
|
|
@@ -145,7 +145,7 @@ export declare class NostrTransport implements Transport {
|
|
|
145
145
|
* backfill historical events to late subscribers: republishing gives late
|
|
146
146
|
* joiners a window to discover the message without requiring protocol
|
|
147
147
|
* changes. Relay rate-limit / publish failures inside the interval are
|
|
148
|
-
* caught and logged rather than propagated
|
|
148
|
+
* caught and logged rather than propagated - the caller should stop the
|
|
149
149
|
* repeater once the protocol condition is satisfied.
|
|
150
150
|
*/
|
|
151
151
|
publishRepeating(message: BaseMessage, sender: Did, intervalMs: number, recipient?: Did): () => void;
|
|
@@ -11,7 +11,7 @@ export type TransportType = 'nostr' | 'didcomm' | 'http';
|
|
|
11
11
|
* shared by all registered actors. Each actor registers its own DID and keys;
|
|
12
12
|
* the transport resolves the correct identity when sending or receiving messages.
|
|
13
13
|
*
|
|
14
|
-
* The transport is a pure passthrough
|
|
14
|
+
* The transport is a pure passthrough: it knows nothing about the aggregation
|
|
15
15
|
* protocol. It only signs/encrypts outgoing messages with the sender's keys and
|
|
16
16
|
* dispatches incoming messages to the correct actor's registered handler.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ export type TransportType = 'nostr' | 'didcomm' | 'http';
|
|
|
19
19
|
*/
|
|
20
20
|
export interface Transport {
|
|
21
21
|
name: string;
|
|
22
|
-
/** Start the underlying transport (idempotent
|
|
22
|
+
/** Start the underlying transport (idempotent, only starts once). */
|
|
23
23
|
start(): void;
|
|
24
24
|
/** Register an actor (service or participant) with this transport. */
|
|
25
25
|
registerActor(did: string, keys: SchnorrKeyPair): void;
|
|
@@ -48,14 +48,14 @@ export interface Transport {
|
|
|
48
48
|
* message is satisfied).
|
|
49
49
|
*
|
|
50
50
|
* Useful for broadcasts on transports that don't reliably backfill
|
|
51
|
-
* historical events to late subscribers (many Nostr relays)
|
|
51
|
+
* historical events to late subscribers (many Nostr relays): republishing
|
|
52
52
|
* gives late joiners a window in which to discover the message. The first
|
|
53
53
|
* publish is synchronous-ish (fired before the method returns).
|
|
54
54
|
*
|
|
55
55
|
* Callers specify `recipient` only for directed messages; for broadcasts
|
|
56
56
|
* it is omitted.
|
|
57
57
|
*
|
|
58
|
-
* @returns A stop function. Idempotent
|
|
58
|
+
* @returns A stop function. Idempotent, safe to call more than once.
|
|
59
59
|
*/
|
|
60
60
|
publishRepeating(message: BaseMessage, sender: string, intervalMs: number, recipient?: string): () => void;
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEtE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,
|
|
1
|
+
{"version":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AAG,IAAI,CAAC;IAEnC,6EAA6E;IAC7E,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErF;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CACd,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,IAAI,CAAC;CACf"}
|
|
@@ -9,25 +9,25 @@ import type { FeeEstimator } from './fee-estimator.js';
|
|
|
9
9
|
import type { BeaconService, BeaconSignal } from './interfaces.js';
|
|
10
10
|
/**
|
|
11
11
|
* Singleton beacon script kinds. Per the did:btcr2 spec, deterministic DID documents
|
|
12
|
-
* include three beacon services: P2PKH, P2WPKH, and P2TR (taproot key-path)
|
|
12
|
+
* include three beacon services: P2PKH, P2WPKH, and P2TR (taproot key-path), all
|
|
13
13
|
* derived from the genesis secp256k1 public key. The singleton broadcast path must
|
|
14
14
|
* support signing for all three.
|
|
15
15
|
*/
|
|
16
16
|
export type SingletonScriptKind = 'p2pkh' | 'p2wpkh' | 'p2tr';
|
|
17
17
|
/**
|
|
18
|
-
* Conservative vsize estimate for a 1-input P2TR key-path
|
|
18
|
+
* Conservative vsize estimate for a 1-input P2TR key-path to 1 P2TR change + 1 OP_RETURN(32) tx.
|
|
19
19
|
* Stripped 137 + witness ≈ 68 (marker + flag + stack-count + sig-len + 64 BIP-340 sig).
|
|
20
20
|
* Weight = 137*4 + 68 = 616, vsize ≈ 154, rounded to 160 for headroom.
|
|
21
21
|
*/
|
|
22
22
|
export declare const P2TR_BEACON_TX_VSIZE = 160;
|
|
23
23
|
/**
|
|
24
|
-
* Conservative vsize estimate for a 1-input P2WPKH
|
|
24
|
+
* Conservative vsize estimate for a 1-input P2WPKH to 1 P2WPKH change + 1 OP_RETURN(32) tx.
|
|
25
25
|
* Stripped 125 + witness ≈ 110 (worst-case DER ECDSA sig 72 + sighash byte + 33 pubkey + framing).
|
|
26
26
|
* vsize = ceil((125*4 + 110) / 4) ≈ 153, rounded to 155.
|
|
27
27
|
*/
|
|
28
28
|
export declare const P2WPKH_BEACON_TX_VSIZE = 155;
|
|
29
29
|
/**
|
|
30
|
-
* Conservative vsize estimate for a 1-input P2PKH
|
|
30
|
+
* Conservative vsize estimate for a 1-input P2PKH to 1 P2PKH change + 1 OP_RETURN(32) tx.
|
|
31
31
|
* Legacy (non-segwit): scriptSig carries the full sig+pubkey (~108 bytes), no witness
|
|
32
32
|
* discount. Stripped ≈ 4 nVer + 1 vin-count + (32+4+1+108+4) input + 1 vout-count +
|
|
33
33
|
* 34 P2PKH-change + 43 OP_RETURN + 4 nLockTime ≈ 236 bytes. vsize = 236, rounded to 240.
|
|
@@ -97,7 +97,7 @@ export declare function opReturnScript(signalBytes: Uint8Array): Uint8Array;
|
|
|
97
97
|
* signing session consumes (via {@link SigningTxData}).
|
|
98
98
|
*
|
|
99
99
|
* This is the reusable counterpart to {@link SinglePartyBeacon.buildSignAndBroadcast}'s internal
|
|
100
|
-
* construction step
|
|
100
|
+
* construction step: the aggregation path must produce an unsigned tx because the
|
|
101
101
|
* signature comes from a MuSig2 round, not a local secret key.
|
|
102
102
|
*
|
|
103
103
|
* @param opts Parameters including the cohort's aggregate internal pubkey.
|
|
@@ -170,7 +170,7 @@ export declare abstract class SinglePartyBeacon {
|
|
|
170
170
|
*
|
|
171
171
|
* Composed from the three extracted phases ({@link buildSinglePartyTx},
|
|
172
172
|
* {@link signSinglePartyTx}, {@link broadcastRawTx}) so each piece can be exercised
|
|
173
|
-
* in isolation. Aggregation beacons use {@link buildAggregationBeaconTx} instead
|
|
173
|
+
* in isolation. Aggregation beacons use {@link buildAggregationBeaconTx} instead:
|
|
174
174
|
* the multi-party path can't share the signing phase, but the tx-construction
|
|
175
175
|
* plumbing (UTXO fetch + OP_RETURN output + change output) is shared.
|
|
176
176
|
*
|
|
@@ -187,7 +187,7 @@ export declare abstract class SinglePartyBeacon {
|
|
|
187
187
|
*
|
|
188
188
|
* Detects the beacon address script kind (P2PKH / P2WPKH / P2TR) and configures
|
|
189
189
|
* the input accordingly. Validates that the signer's pubkey produces the beacon
|
|
190
|
-
* address under that script kind
|
|
190
|
+
* address under that script kind: without this check, a misconfigured caller
|
|
191
191
|
* would burn a real UTXO on a tx that fails at broadcast. Fees are computed from
|
|
192
192
|
* the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant, avoiding any probe-sign
|
|
193
193
|
* round-trip.
|