@did-btcr2/method 0.25.3 → 0.26.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 -0
- package/dist/browser.js +125307 -122227
- package/dist/browser.mjs +125266 -122186
- package/dist/cjs/index.js +5043 -43
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -2
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +6 -4
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/signal-discovery.js +1 -1
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
- package/dist/esm/core/beacon/singleton-beacon.js +3 -3
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +41 -35
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +1 -1
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/utils/appendix.js +7 -6
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +2 -2
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +10 -10
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -4
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +6 -6
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -3
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +3 -3
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +6 -6
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +5 -5
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +5 -5
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +2 -2
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +3 -3
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/signal-discovery.d.ts +3 -3
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +5 -5
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +5 -5
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts +4 -4
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts +2 -2
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +2 -2
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +8 -8
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +6 -5
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/update.d.ts +5 -5
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +6 -6
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +7 -7
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +3 -2
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +3 -3
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/core/beacon/aggregation/cohort/index.ts +3 -2
- package/src/core/beacon/aggregation/cohort/messages/index.ts +10 -10
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -1
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +5 -4
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +9 -7
- package/src/core/beacon/aggregation/communication/factory.ts +1 -1
- package/src/core/beacon/aggregation/communication/service.ts +3 -3
- package/src/core/beacon/aggregation/coordinator.ts +12 -8
- package/src/core/beacon/aggregation/participant.ts +12 -7
- package/src/core/beacon/aggregation/session/index.ts +3 -2
- package/src/core/beacon/beacon.ts +5 -5
- package/src/core/beacon/cas-beacon.ts +13 -9
- package/src/core/beacon/factory.ts +2 -2
- package/src/core/beacon/interfaces.ts +3 -3
- package/src/core/beacon/signal-discovery.ts +5 -4
- package/src/core/beacon/singleton-beacon.ts +8 -7
- package/src/core/beacon/smt-beacon.ts +5 -5
- package/src/core/beacon/utils.ts +6 -4
- package/src/core/identifier.ts +3 -2
- package/src/core/interfaces.ts +2 -2
- package/src/core/resolver.ts +59 -51
- package/src/core/types.ts +6 -5
- package/src/core/update.ts +11 -7
- package/src/did-btcr2.ts +12 -10
- package/src/utils/appendix.ts +14 -16
- package/src/utils/did-document-builder.ts +3 -2
- package/src/utils/did-document.ts +10 -8
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +0 -237
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +0 -26
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +0 -11
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +0 -98
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/status.js +0 -8
- package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/error.js +0 -12
- package/dist/cjs/core/beacon/aggregation/communication/error.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/factory.js +0 -21
- package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/service.js +0 -2
- package/dist/cjs/core/beacon/aggregation/communication/service.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +0 -343
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +0 -435
- package/dist/cjs/core/beacon/aggregation/participant.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +0 -244
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/status.js +0 -11
- package/dist/cjs/core/beacon/aggregation/session/status.js.map +0 -1
- package/dist/cjs/core/beacon/beacon.js +0 -25
- package/dist/cjs/core/beacon/beacon.js.map +0 -1
- package/dist/cjs/core/beacon/cas-beacon.js +0 -152
- package/dist/cjs/core/beacon/cas-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/error.js +0 -37
- package/dist/cjs/core/beacon/error.js.map +0 -1
- package/dist/cjs/core/beacon/factory.js +0 -29
- package/dist/cjs/core/beacon/factory.js.map +0 -1
- package/dist/cjs/core/beacon/interfaces.js +0 -2
- package/dist/cjs/core/beacon/interfaces.js.map +0 -1
- package/dist/cjs/core/beacon/signal-discovery.js +0 -183
- package/dist/cjs/core/beacon/signal-discovery.js.map +0 -1
- package/dist/cjs/core/beacon/singleton-beacon.js +0 -107
- package/dist/cjs/core/beacon/singleton-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/smt-beacon.js +0 -39
- package/dist/cjs/core/beacon/smt-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/utils.js +0 -163
- package/dist/cjs/core/beacon/utils.js.map +0 -1
- package/dist/cjs/core/identifier.js +0 -248
- package/dist/cjs/core/identifier.js.map +0 -1
- package/dist/cjs/core/interfaces.js +0 -2
- package/dist/cjs/core/interfaces.js.map +0 -1
- package/dist/cjs/core/resolver.js +0 -476
- package/dist/cjs/core/resolver.js.map +0 -1
- package/dist/cjs/core/types.js +0 -2
- package/dist/cjs/core/types.js.map +0 -1
- package/dist/cjs/core/update.js +0 -112
- package/dist/cjs/core/update.js.map +0 -1
- package/dist/cjs/did-btcr2.js +0 -193
- package/dist/cjs/did-btcr2.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/appendix.js +0 -203
- package/dist/cjs/utils/appendix.js.map +0 -1
- package/dist/cjs/utils/did-document-builder.js +0 -60
- package/dist/cjs/utils/did-document-builder.js.map +0 -1
- package/dist/cjs/utils/did-document.js +0 -424
- package/dist/cjs/utils/did-document.js.map +0 -1
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import * as musig2 from '@scure/btc-signer/musig2';
|
|
2
|
-
import { Transaction } from 'bitcoinjs-lib';
|
|
3
|
-
import { AggregateBeaconError } from '../../error.js';
|
|
4
|
-
import { BeaconCohortAuthorizationRequestMessage } from '../cohort/messages/sign/authorization-request.js';
|
|
5
|
-
import { SIGNING_SESSION_STATUS } from './status.js';
|
|
6
|
-
/**
|
|
7
|
-
* Convert a big-endian byte array into a bigint.
|
|
8
|
-
* @param bytes - The input Uint8Array representing a big-endian integer.
|
|
9
|
-
* @returns The integer value as a bigint.
|
|
10
|
-
*/
|
|
11
|
-
export function bigEndianToInt(bytes) {
|
|
12
|
-
return bytes.reduce((num, b) => (num << 8n) + BigInt(b), 0n);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Convert a bigint to a big-endian Uint8Array of specified length.
|
|
16
|
-
* @param xInit - The bigint to convert.
|
|
17
|
-
* @param length - The desired length of the output array in bytes.
|
|
18
|
-
* @returns A Uint8Array representing the bigint in big-endian form.
|
|
19
|
-
*/
|
|
20
|
-
export function intToBigEndian(xInit, length) {
|
|
21
|
-
let x = xInit;
|
|
22
|
-
const result = new Uint8Array(length);
|
|
23
|
-
for (let i = length - 1; i >= 0; i--) {
|
|
24
|
-
result[i] = Number(x & 0xffn);
|
|
25
|
-
x >>= 8n;
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
export class BeaconCohortSigningSession {
|
|
30
|
-
/**
|
|
31
|
-
* Unique identifier for the signing session.
|
|
32
|
-
* @type {string}
|
|
33
|
-
*/
|
|
34
|
-
id;
|
|
35
|
-
/**
|
|
36
|
-
* DID of the coordinator.
|
|
37
|
-
* @type {AggregateBeaconCohort}
|
|
38
|
-
*/
|
|
39
|
-
cohort;
|
|
40
|
-
/**
|
|
41
|
-
* Pending transaction to be signed.
|
|
42
|
-
* @type {Transaction}
|
|
43
|
-
*/
|
|
44
|
-
pendingTx;
|
|
45
|
-
/**
|
|
46
|
-
* Map of nonce contributions from participants.
|
|
47
|
-
* @type {Map<PublicKeyHex, Nonce>}
|
|
48
|
-
*/
|
|
49
|
-
nonceContributions = new Map();
|
|
50
|
-
/**
|
|
51
|
-
* Aggregated nonce from all participants.
|
|
52
|
-
* @type {Uint8Array}
|
|
53
|
-
*/
|
|
54
|
-
aggregatedNonce;
|
|
55
|
-
/**
|
|
56
|
-
* Map of partial signatures from participants.
|
|
57
|
-
* @type {Map<string, Uint8Array>}
|
|
58
|
-
*/
|
|
59
|
-
partialSignatures = new Map();
|
|
60
|
-
/**
|
|
61
|
-
* Final signature for the transaction.
|
|
62
|
-
* @type {Uint8Array}
|
|
63
|
-
*/
|
|
64
|
-
signature;
|
|
65
|
-
/**
|
|
66
|
-
* Current status of the signing session.
|
|
67
|
-
* @type {SIGNING_SESSION_STATUS_TYPE}
|
|
68
|
-
*/
|
|
69
|
-
status;
|
|
70
|
-
/**
|
|
71
|
-
* Map of processed requests from participants.
|
|
72
|
-
* @type {Record<string, string>}
|
|
73
|
-
*/
|
|
74
|
-
processedRequests;
|
|
75
|
-
/**
|
|
76
|
-
* Secrets for nonces contributed by participants.
|
|
77
|
-
* @type {Array<bigint>}
|
|
78
|
-
*/
|
|
79
|
-
nonceSecrets;
|
|
80
|
-
/**
|
|
81
|
-
* Musig2 session for signing operations.
|
|
82
|
-
* @type {musig2.Session}
|
|
83
|
-
*/
|
|
84
|
-
musig2Session;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a new instance of BeaconCohortSigningSession.
|
|
87
|
-
* @param {SigningSession} params Parameters to initialize the signing session.
|
|
88
|
-
* @param {Transaction} params.pendingTx The pending transaction to be signed.
|
|
89
|
-
* @param {string} [params.id] Optional unique identifier for the signing session. If not provided, a new UUID will be generated.
|
|
90
|
-
* @param {AggregateBeaconCohort} [params.cohort] The cohort associated with the signing session.
|
|
91
|
-
* @param {Record<string, string>} [params.processedRequests] Map of processed requests from participants.
|
|
92
|
-
* @param {SIGNING_SESSION_STATUS_TYPE} [params.status] The current status of the signing session. Defaults to AWAITING_NONCE_CONTRIBUTIONS.
|
|
93
|
-
*/
|
|
94
|
-
constructor({ id, cohort, pendingTx, processedRequests, status }) {
|
|
95
|
-
this.id = id || crypto.randomUUID();
|
|
96
|
-
this.cohort = cohort;
|
|
97
|
-
this.pendingTx = pendingTx;
|
|
98
|
-
this.processedRequests = processedRequests || {};
|
|
99
|
-
this.status = status || SIGNING_SESSION_STATUS.AWAITING_NONCE_CONTRIBUTIONS;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Gets the authorization request message for a participant.
|
|
103
|
-
* @param {string} to The public key of the participant to whom the request is sent.
|
|
104
|
-
* @param {string} from The public key of the participant sending the request.
|
|
105
|
-
* @returns {AuthorizationRequest} The authorization request message.
|
|
106
|
-
*/
|
|
107
|
-
getAuthorizationRequest(to, from) {
|
|
108
|
-
const txHex = this.pendingTx instanceof Transaction ? this.pendingTx?.toHex() : this.pendingTx;
|
|
109
|
-
return new BeaconCohortAuthorizationRequestMessage({
|
|
110
|
-
to,
|
|
111
|
-
from,
|
|
112
|
-
sessionId: this.id,
|
|
113
|
-
cohortId: this.cohort?.id,
|
|
114
|
-
pendingTx: txHex,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Adds a nonce contribution from a participant to the session.
|
|
119
|
-
* @param {string} from The public key of the participant contributing the nonce.
|
|
120
|
-
* @param {Array<string>} nonceContribution The nonce contribution from the participant.
|
|
121
|
-
* @throws {Error} If the session is not awaiting nonce contributions or if the contribution is invalid.
|
|
122
|
-
*/
|
|
123
|
-
addNonceContribution(from, nonceContribution) {
|
|
124
|
-
if (this.status !== SIGNING_SESSION_STATUS.AWAITING_NONCE_CONTRIBUTIONS) {
|
|
125
|
-
throw new AggregateBeaconError(`Nonce contributions already received. Current status: ${this.status}`);
|
|
126
|
-
}
|
|
127
|
-
if (nonceContribution.length !== 2) {
|
|
128
|
-
throw new AggregateBeaconError(`Invalid nonce contribution. Expected 2 points, received ${nonceContribution.length}.`);
|
|
129
|
-
}
|
|
130
|
-
if (this.nonceContributions.get(from)) {
|
|
131
|
-
console.warn(`WARNING: Nonce contribution already received from ${from}.`);
|
|
132
|
-
}
|
|
133
|
-
this.nonceContributions.set(from, nonceContribution);
|
|
134
|
-
if (this.nonceContributions.size === this.cohort?.participants.length) {
|
|
135
|
-
this.status = SIGNING_SESSION_STATUS.NONCE_CONTRIBUTIONS_RECEIVED;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Generates the aggregated nonce from all nonce contributions for the session.
|
|
140
|
-
* @returns {Uint8Array} The aggregated nonce.
|
|
141
|
-
* @throws {AggregateBeaconError} If not all nonce contributions have been received.
|
|
142
|
-
*/
|
|
143
|
-
generateAggregatedNonce() {
|
|
144
|
-
if (this.status !== SIGNING_SESSION_STATUS.NONCE_CONTRIBUTIONS_RECEIVED) {
|
|
145
|
-
const missing = this.cohort?.participants.length - this.nonceContributions.size;
|
|
146
|
-
throw new AggregateBeaconError(`Missing ${missing} nonce contributions. ` +
|
|
147
|
-
`Received ${this.cohort?.participants.length} of ${this.nonceContributions.size} nonce contributions. ` +
|
|
148
|
-
`Current status: ${this.status}`, 'NONCE_CONTRIBUTION_ERROR', this.toJSON());
|
|
149
|
-
}
|
|
150
|
-
const sortedPubkeys = musig2.sortKeys(this.cohort.cohortKeys);
|
|
151
|
-
const keyAggContext = musig2.keyAggregate(sortedPubkeys);
|
|
152
|
-
const aggPubkey = musig2.keyAggExport(keyAggContext);
|
|
153
|
-
this.aggregatedNonce = musig2.nonceAggregate(this.cohort.cohortKeys.map(key => musig2.nonceGen(key, undefined, aggPubkey, this.cohort.trMerkleRoot).public));
|
|
154
|
-
this.musig2Session = new musig2.Session(this.aggregatedNonce, this.cohort.cohortKeys, this.cohort.trMerkleRoot);
|
|
155
|
-
return this.aggregatedNonce;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Adds a partial signature from a participant to the session.
|
|
159
|
-
* @param {string} from The public key of the participant contributing the partial signature.
|
|
160
|
-
* @param {Uint8Array} partialSignature The partial signature from the participant.
|
|
161
|
-
*/
|
|
162
|
-
addPartialSignature(from, partialSignature) {
|
|
163
|
-
if (this.status !== SIGNING_SESSION_STATUS.AWAITING_PARTIAL_SIGNATURES) {
|
|
164
|
-
throw new AggregateBeaconError(`Partial signatures not expected. Current status: ${this.status}`);
|
|
165
|
-
}
|
|
166
|
-
if (this.partialSignatures.get(from)) {
|
|
167
|
-
console.warn(`WARNING: Partial signature already received from ${from}.`);
|
|
168
|
-
}
|
|
169
|
-
this.partialSignatures.set(from, partialSignature);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Generates the final signature from all partial signatures.
|
|
173
|
-
* @returns {Uint8Array} The final aggregated signature.
|
|
174
|
-
*/
|
|
175
|
-
async generateFinalSignature() {
|
|
176
|
-
if (this.status !== SIGNING_SESSION_STATUS.PARTIAL_SIGNATURES_RECEIVED) {
|
|
177
|
-
throw new AggregateBeaconError(`Partial signatures not received. Current status: ${this.status}`);
|
|
178
|
-
}
|
|
179
|
-
const inputIdx = (this.pendingTx?.ins?.length || 0) - 1;
|
|
180
|
-
if (inputIdx < 0) {
|
|
181
|
-
throw new AggregateBeaconError('No inputs in the pending transaction to sign.');
|
|
182
|
-
}
|
|
183
|
-
const prevoutScript = this.pendingTx?.ins[inputIdx].script;
|
|
184
|
-
if (!prevoutScript) {
|
|
185
|
-
throw new AggregateBeaconError('Previous output script is missing for the input to sign.');
|
|
186
|
-
}
|
|
187
|
-
const sigSum = [...this.partialSignatures.values()].reduce((sum, sig) => sum + bigEndianToInt(sig), 0n);
|
|
188
|
-
console.info(`Aggregated Signature computed: ${sigSum}`);
|
|
189
|
-
this.aggregatedNonce ??= this.generateAggregatedNonce();
|
|
190
|
-
const session = new musig2.Session(this.aggregatedNonce, this.cohort.cohortKeys, this.cohort.trMerkleRoot);
|
|
191
|
-
this.signature = session.partialSigAgg([...this.partialSignatures.values()]);
|
|
192
|
-
return this.signature;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Generates a partial signature for the session using the participant's secret key.
|
|
196
|
-
* @param {Uint8Array} participantSk The secret key of the participant.
|
|
197
|
-
* @returns {Uint8Array} The partial signature generated by the participant.
|
|
198
|
-
*/
|
|
199
|
-
generatePartialSignature(participantSk) {
|
|
200
|
-
if (!this.aggregatedNonce) {
|
|
201
|
-
throw new AggregateBeaconError('Aggregated nonce is not available. Please generate it first.');
|
|
202
|
-
}
|
|
203
|
-
const sigHash = this.pendingTx?.hashForSignature(0, this.pendingTx?.ins[0].script, Transaction.SIGHASH_DEFAULT);
|
|
204
|
-
if (!sigHash) {
|
|
205
|
-
throw new AggregateBeaconError('Signature hash is not available. Please ensure the transaction is properly set up.');
|
|
206
|
-
}
|
|
207
|
-
const session = new musig2.Session(this.aggregatedNonce, this.cohort.cohortKeys, this.cohort.trMerkleRoot);
|
|
208
|
-
return session.sign(this.aggregatedNonce, participantSk);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Converts the signing session instance to a JSON object representation.
|
|
212
|
-
* @returns {BeaconCohortSigningSession} The JSON object representation of the signing session.
|
|
213
|
-
*/
|
|
214
|
-
toJSON() {
|
|
215
|
-
return {
|
|
216
|
-
id: this.id,
|
|
217
|
-
cohort: this.cohort,
|
|
218
|
-
pendingTx: this.pendingTx,
|
|
219
|
-
nonceContributions: this.nonceContributions,
|
|
220
|
-
aggregatedNonce: this.aggregatedNonce,
|
|
221
|
-
partialSignatures: this.partialSignatures,
|
|
222
|
-
signature: this.signature,
|
|
223
|
-
status: this.status,
|
|
224
|
-
processedRequests: this.processedRequests,
|
|
225
|
-
nonceSecrets: this.nonceSecrets,
|
|
226
|
-
musig2Session: this.musig2Session
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Checks if the signing session is a completed state.
|
|
231
|
-
* @returns {boolean} True if the session is complete, false otherwise.
|
|
232
|
-
*/
|
|
233
|
-
isComplete() {
|
|
234
|
-
return this.status === SIGNING_SESSION_STATUS.SIGNATURE_COMPLETE;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Checks if the signing session is in a failed state.
|
|
238
|
-
* @returns {boolean} True if the session has failed, false otherwise.
|
|
239
|
-
*/
|
|
240
|
-
isFailed() {
|
|
241
|
-
return this.status === SIGNING_SESSION_STATUS.FAILED;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=index.js.map
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ING_SESSION_STATUS["AWAITING_NONCE_CONTRIBUTIONS"] = "AWAITING_NONCE_CONTRIBUTIONS";
|
|
4
|
-
SIGNING_SESSION_STATUS["NONCE_CONTRIBUTION_SENT"] = "NONCE_CONTRIBUTION_SENT";
|
|
5
|
-
SIGNING_SESSION_STATUS["NONCE_CONTRIBUTIONS_RECEIVED"] = "NONCE_CONTRIBUTIONS_RECEIVED";
|
|
6
|
-
SIGNING_SESSION_STATUS["AWAITING_PARTIAL_SIGNATURES"] = "AWAITING_PARTIAL_SIGNATURES";
|
|
7
|
-
SIGNING_SESSION_STATUS["PARTIAL_SIGNATURES_RECEIVED"] = "PARTIAL_SIGNATURES_RECEIVED";
|
|
8
|
-
SIGNING_SESSION_STATUS["SIGNATURE_COMPLETE"] = "SIGNATURE_COMPLETE";
|
|
9
|
-
SIGNING_SESSION_STATUS["FAILED"] = "FAILED";
|
|
10
|
-
})(SIGNING_SESSION_STATUS || (SIGNING_SESSION_STATUS = {}));
|
|
11
|
-
//# sourceMappingURL=status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/session/status.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,sBAQX;AARD,WAAY,sBAAsB;IAC9B,uFAA6D,CAAA;IAC7D,6EAAmD,CAAA;IACnD,uFAA6D,CAAA;IAC7D,qFAA2D,CAAA;IAC3D,qFAA2D,CAAA;IAC3D,mEAAyC,CAAA;IACzC,2CAAiB,CAAA;AACrB,CAAC,EARW,sBAAsB,KAAtB,sBAAsB,QAQjC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract base class for all BTCR2 Beacon types.
|
|
3
|
-
* A Beacon is a service listed in a BTCR2 DID document that informs resolvers
|
|
4
|
-
* how to find authentic updates to the DID.
|
|
5
|
-
*
|
|
6
|
-
* Beacons are lightweight typed wrappers around a {@link BeaconService} configuration.
|
|
7
|
-
* Dependencies (signals, sidecar data, bitcoin connection) are passed as method
|
|
8
|
-
* parameters rather than held as instance state.
|
|
9
|
-
*
|
|
10
|
-
* Use {@link BeaconFactory.establish} to create typed instances from service config.
|
|
11
|
-
*
|
|
12
|
-
* @abstract
|
|
13
|
-
* @class Beacon
|
|
14
|
-
* @type {Beacon}
|
|
15
|
-
*/
|
|
16
|
-
export class Beacon {
|
|
17
|
-
/**
|
|
18
|
-
* The Beacon service configuration parsed from the DID Document.
|
|
19
|
-
*/
|
|
20
|
-
service;
|
|
21
|
-
constructor(service) {
|
|
22
|
-
this.service = service;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=beacon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,MAAM;IAC1B;;OAEG;IACM,OAAO,CAAgB;IAEhC,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CA+BF"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { canonicalHash, canonicalize, decode, encode, hash } from '@did-btcr2/common';
|
|
2
|
-
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import { hexToBytes } from '@noble/hashes/utils';
|
|
4
|
-
import { opcodes, Psbt, script } from 'bitcoinjs-lib';
|
|
5
|
-
import { Beacon } from './beacon.js';
|
|
6
|
-
import { CASBeaconError } from './error.js';
|
|
7
|
-
/**
|
|
8
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#cas-beacon | CAS Beacon}.
|
|
9
|
-
*
|
|
10
|
-
* A CAS (Content-Addressed Store) Beacon aggregates updates for multiple DIDs
|
|
11
|
-
* into a single CAS Announcement — a mapping of DIDs to their update hashes.
|
|
12
|
-
* The hash of the CAS Announcement is broadcast on-chain via OP_RETURN.
|
|
13
|
-
* During resolution, the CAS Announcement is retrieved from the sidecar (or CAS)
|
|
14
|
-
* and used to look up the individual signed update for the DID being resolved.
|
|
15
|
-
*
|
|
16
|
-
* @class CASBeacon
|
|
17
|
-
* @type {CASBeacon}
|
|
18
|
-
* @extends {Beacon}
|
|
19
|
-
*/
|
|
20
|
-
export class CASBeacon extends Beacon {
|
|
21
|
-
/**
|
|
22
|
-
* Creates an instance of CASBeacon.
|
|
23
|
-
* @param {BeaconService} service The service of the Beacon.
|
|
24
|
-
*/
|
|
25
|
-
constructor(service) {
|
|
26
|
-
super({ ...service, type: 'CASBeacon' });
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-cas-beacon | 7.2.e.1 Process CAS Beacon}.
|
|
30
|
-
*
|
|
31
|
-
* For each signal, the signalBytes contain the hex-encoded hash of a CAS Announcement.
|
|
32
|
-
* The CAS Announcement maps DIDs to their base64url-encoded update hashes.
|
|
33
|
-
* This method looks up the CAS Announcement from the sidecar, extracts the update
|
|
34
|
-
* hash for the DID being resolved, and retrieves the corresponding signed update.
|
|
35
|
-
*
|
|
36
|
-
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
37
|
-
* @param {SidecarData} sidecar The sidecar data associated with the CAS Beacon.
|
|
38
|
-
* @returns {BeaconProcessResult} Successfully resolved updates and any data needs.
|
|
39
|
-
* @throws {CASBeaconError} if hash verification fails (validation errors only).
|
|
40
|
-
*/
|
|
41
|
-
processSignals(signals, sidecar) {
|
|
42
|
-
const updates = new Array();
|
|
43
|
-
const needs = new Array();
|
|
44
|
-
// Extract the DID from the beacon service id (strip the #fragment)
|
|
45
|
-
const did = this.service.id.split('#')[0];
|
|
46
|
-
for (const signal of signals) {
|
|
47
|
-
// Decode signal bytes from hex and re-encode to base64url for sidecar lookup
|
|
48
|
-
const announcementHash = encode(decode(signal.signalBytes, 'hex'));
|
|
49
|
-
// Look up the CAS Announcement in sidecar casMap
|
|
50
|
-
const casAnnouncement = sidecar.casMap.get(announcementHash);
|
|
51
|
-
if (!casAnnouncement) {
|
|
52
|
-
// CAS Announcement not available — emit a need
|
|
53
|
-
needs.push({
|
|
54
|
-
kind: 'NeedCASAnnouncement',
|
|
55
|
-
announcementHash,
|
|
56
|
-
beaconServiceId: this.service.id
|
|
57
|
-
});
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
// Look up this DID's update hash in the CAS Announcement
|
|
61
|
-
const updateHash = casAnnouncement[did];
|
|
62
|
-
// If no entry for this DID, this announcement doesn't contain an update for us — skip
|
|
63
|
-
if (!updateHash) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
// Look up the signed update in sidecar updateMap
|
|
67
|
-
const signedUpdate = sidecar.updateMap.get(updateHash);
|
|
68
|
-
if (!signedUpdate) {
|
|
69
|
-
// Signed update not available — emit a need
|
|
70
|
-
needs.push({
|
|
71
|
-
kind: 'NeedSignedUpdate',
|
|
72
|
-
updateHash,
|
|
73
|
-
beaconServiceId: this.service.id
|
|
74
|
-
});
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
updates.push([signedUpdate, signal.blockMetadata]);
|
|
78
|
-
}
|
|
79
|
-
return { updates, needs };
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Broadcasts a CAS Beacon signal to the Bitcoin network.
|
|
83
|
-
*
|
|
84
|
-
* Creates a CAS Announcement mapping the DID to the update hash, then broadcasts
|
|
85
|
-
* the hash of the announcement via OP_RETURN. The CAS Announcement is distributed
|
|
86
|
-
* to resolvers via sidecar data.
|
|
87
|
-
*
|
|
88
|
-
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
89
|
-
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
90
|
-
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
91
|
-
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
92
|
-
* @throws {CASBeaconError} if the bitcoin address is invalid or unfunded.
|
|
93
|
-
*/
|
|
94
|
-
async broadcastSignal(signedUpdate, secretKey, bitcoin) {
|
|
95
|
-
// Extract the DID from the beacon service id (strip the #fragment)
|
|
96
|
-
const did = this.service.id.split('#')[0];
|
|
97
|
-
// Hash the signed update (base64url for the CAS Announcement entry)
|
|
98
|
-
const updateHash = canonicalHash(signedUpdate);
|
|
99
|
-
// Create the CAS Announcement mapping this DID to its update hash
|
|
100
|
-
const casAnnouncement = { [did]: updateHash };
|
|
101
|
-
// TODO: Publish CAS Announcement to content-addressed store (e.g., IPFS via Helia)
|
|
102
|
-
// Canonicalize and hash the CAS Announcement for the OP_RETURN output
|
|
103
|
-
const announcementHash = hash(canonicalize(casAnnouncement));
|
|
104
|
-
// Convert the serviceEndpoint to a bitcoin address by removing the 'bitcoin:' prefix
|
|
105
|
-
const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
|
|
106
|
-
// Query the Bitcoin network for UTXOs associated with the bitcoinAddress
|
|
107
|
-
const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
|
|
108
|
-
// If no utxos are found, throw an error indicating the address is unfunded.
|
|
109
|
-
if (!utxos.length) {
|
|
110
|
-
throw new CASBeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
111
|
-
}
|
|
112
|
-
// Sort utxos by block height and take the most recent one
|
|
113
|
-
const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
|
|
114
|
-
// If no utxos are found, throw an error.
|
|
115
|
-
if (!utxo) {
|
|
116
|
-
throw new CASBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
117
|
-
}
|
|
118
|
-
// Get the previous tx to the utxo being spent
|
|
119
|
-
const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
|
|
120
|
-
// Construct a spend transaction
|
|
121
|
-
const spendTx = new Psbt({ network: bitcoin.data })
|
|
122
|
-
// Spend tx contains the utxo as its input
|
|
123
|
-
.addInput({
|
|
124
|
-
hash: utxo.txid,
|
|
125
|
-
index: utxo.vout,
|
|
126
|
-
nonWitnessUtxo: hexToBytes(prevTx)
|
|
127
|
-
})
|
|
128
|
-
// Add a change output minus a fee of 500 sats
|
|
129
|
-
// TODO: calculate fee based on transaction vsize and current fee rates
|
|
130
|
-
.addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
|
|
131
|
-
// Add an OP_RETURN output containing the CAS Announcement hash
|
|
132
|
-
.addOutput({ script: script.compile([opcodes.OP_RETURN, announcementHash]), value: 0n });
|
|
133
|
-
// Construct a key pair and PSBT signer from the secret key
|
|
134
|
-
const keyPair = SchnorrKeyPair.fromSecret(secretKey);
|
|
135
|
-
const signer = {
|
|
136
|
-
publicKey: keyPair.publicKey.compressed,
|
|
137
|
-
sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
|
|
138
|
-
};
|
|
139
|
-
// Sign 0th input, finalize extract to hex in prep for broadcast
|
|
140
|
-
const signedTx = spendTx.signInput(0, signer)
|
|
141
|
-
.finalizeAllInputs()
|
|
142
|
-
.extractTransaction()
|
|
143
|
-
.toHex();
|
|
144
|
-
// Broadcast spendTx to the Bitcoin network.
|
|
145
|
-
const txid = await bitcoin.rest.transaction.send(signedTx);
|
|
146
|
-
// Log the txid of the broadcasted transaction
|
|
147
|
-
console.info(`CAS Beacon Signal Broadcasted with txid: ${txid}`);
|
|
148
|
-
// Return the signed update
|
|
149
|
-
return signedUpdate;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=cas-beacon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cas-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/cas-beacon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY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,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAE3F,2DAA2D;QAC3D,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG;YACb,SAAS,EAAG,OAAO,CAAC,SAAS,CAAC,UAAU;YACxC,IAAI,EAAQ,CAAC,IAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SACpF,CAAC;QAEF,gEAAgE;QAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC;aAC1C,iBAAiB,EAAE;aACnB,kBAAkB,EAAE;aACpB,KAAK,EAAE,CAAC;QAEX,4CAA4C;QAC5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3D,8CAA8C;QAC9C,OAAO,CAAC,IAAI,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;QAEjE,2BAA2B;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { MethodError } from '@did-btcr2/common';
|
|
2
|
-
export class BeaconError extends MethodError {
|
|
3
|
-
constructor(message, type = 'BeaconError', data) {
|
|
4
|
-
super(message, type, data);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export class BeaconCoordinatorError extends MethodError {
|
|
8
|
-
constructor(message, type = 'BeaconCoordinatorError', data) {
|
|
9
|
-
super(message, type, data);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class BeaconParticipantError extends MethodError {
|
|
13
|
-
constructor(message, type = 'BeaconParticipantError', data) {
|
|
14
|
-
super(message, type, data);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class SingletonBeaconError extends MethodError {
|
|
18
|
-
constructor(message, type = 'SingletonBeaconError', data) {
|
|
19
|
-
super(message, type, data);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class AggregateBeaconError extends MethodError {
|
|
23
|
-
constructor(message, type = 'AggregateBeaconError', data) {
|
|
24
|
-
super(message, type, data);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export class CASBeaconError extends MethodError {
|
|
28
|
-
constructor(message, type = 'CASBeaconError', data) {
|
|
29
|
-
super(message, type, data);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export class SMTBeaconError extends MethodError {
|
|
33
|
-
constructor(message, type = 'SMTBeaconError', data) {
|
|
34
|
-
super(message, type, data);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/core/beacon/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,OAAe,EAAE,OAAe,aAAa,EAAE,IAA0B;QACnF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,OAAe,wBAAwB,EAAE,IAA0B;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,OAAe,wBAAwB,EAAE,IAA0B;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe,EAAE,OAAe,sBAAsB,EAAE,IAA0B;QAC5F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe,EAAE,OAAe,sBAAsB,EAAE,IAA0B;QAC5F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAAe,gBAAgB,EAAE,IAA0B;QACtF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAAe,gBAAgB,EAAE,IAA0B;QACtF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MethodError } from '@did-btcr2/common';
|
|
2
|
-
import { CASBeacon } from './cas-beacon.js';
|
|
3
|
-
import { SingletonBeacon } from './singleton-beacon.js';
|
|
4
|
-
import { SMTBeacon } from './smt-beacon.js';
|
|
5
|
-
/**
|
|
6
|
-
* Beacon Factory pattern to create Beacon instances.
|
|
7
|
-
* @class BeaconFactory
|
|
8
|
-
* @type {BeaconFactory}
|
|
9
|
-
*/
|
|
10
|
-
export class BeaconFactory {
|
|
11
|
-
/**
|
|
12
|
-
* Establish a Beacon instance based on the provided service and optional sidecar data.
|
|
13
|
-
* @param {BeaconService} service The beacon service configuration.
|
|
14
|
-
* @returns {Beacon} The established Beacon instance.
|
|
15
|
-
*/
|
|
16
|
-
static establish(service) {
|
|
17
|
-
switch (service.type) {
|
|
18
|
-
case 'SingletonBeacon':
|
|
19
|
-
return new SingletonBeacon(service);
|
|
20
|
-
case 'CASBeacon':
|
|
21
|
-
return new CASBeacon(service);
|
|
22
|
-
case 'SMTBeacon':
|
|
23
|
-
return new SMTBeacon(service);
|
|
24
|
-
default:
|
|
25
|
-
throw new MethodError('Invalid Beacon Type', 'INVALID_BEACON_ERROR', service);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/core/beacon/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACxB;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,OAAsB;QACrC,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,iBAAiB;gBACpB,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;YACtC,KAAK,WAAW;gBACd,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;YAChC,KAAK,WAAW;gBACd,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;YAChC;gBACE,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/core/beacon/interfaces.ts"],"names":[],"mappings":""}
|