@did-btcr2/method 0.17.2 → 0.18.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/browser.js +30124 -19552
- package/dist/browser.mjs +30123 -19551
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +225 -0
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -0
- package/dist/{esm/core/beacon/aggregation → cjs/core/beacon/aggregation/cohort}/messages/base.js +3 -11
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +11 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +98 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/communication/error.js +12 -0
- package/dist/cjs/core/beacon/aggregation/communication/error.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/communication/factory.js +21 -0
- package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/communication/service.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/coordinator.js +282 -56
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +435 -1
- package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +233 -0
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -0
- package/dist/cjs/core/beacon/aggregation/session/status.js +11 -0
- package/dist/cjs/core/beacon/aggregation/session/status.js.map +1 -0
- package/dist/cjs/core/beacon/cid-aggregate.js.map +1 -1
- package/dist/cjs/core/beacon/error.js +37 -0
- package/dist/cjs/core/beacon/error.js.map +1 -0
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/singleton.js +8 -5
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/beacon/smt-aggregate.js.map +1 -1
- package/dist/cjs/{utils/beacons.js → core/beacon/utils.js} +4 -4
- package/dist/cjs/core/beacon/utils.js.map +1 -0
- package/dist/cjs/core/crud/read.js +2 -9
- package/dist/cjs/core/crud/read.js.map +1 -1
- package/dist/cjs/core/crud/update.js +18 -19
- package/dist/cjs/core/crud/update.js.map +1 -1
- package/dist/{esm/utils → cjs/core}/identifier.js +18 -3
- package/dist/cjs/core/identifier.js.map +1 -0
- package/dist/cjs/did-btcr2.js +2 -2
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +28 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/beacon.js.map +1 -1
- package/dist/cjs/utils/appendix.js +2 -3
- package/dist/cjs/utils/appendix.js.map +1 -1
- package/dist/cjs/utils/did-document.js +4 -6
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/cjs/utils/types.js +2 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/index.js +225 -0
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -0
- package/dist/{cjs/core/beacon/aggregation → esm/core/beacon/aggregation/cohort}/messages/base.js +3 -11
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +11 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +98 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +30 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +28 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +26 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +22 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +27 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +28 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +29 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +29 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +29 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +30 -0
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/cohort/status.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +126 -0
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +230 -0
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/communication/error.js +12 -0
- package/dist/esm/core/beacon/aggregation/communication/error.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/communication/factory.js +21 -0
- package/dist/esm/core/beacon/aggregation/communication/factory.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/communication/service.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/coordinator.js +282 -56
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js +435 -1
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +233 -0
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -0
- package/dist/esm/core/beacon/aggregation/session/status.js +11 -0
- package/dist/esm/core/beacon/aggregation/session/status.js.map +1 -0
- package/dist/esm/core/beacon/cid-aggregate.js.map +1 -1
- package/dist/esm/core/beacon/error.js +37 -0
- package/dist/esm/core/beacon/error.js.map +1 -0
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/singleton.js +8 -5
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/beacon/smt-aggregate.js.map +1 -1
- package/dist/esm/{utils/beacons.js → core/beacon/utils.js} +4 -4
- package/dist/esm/core/beacon/utils.js.map +1 -0
- package/dist/esm/core/crud/read.js +2 -9
- package/dist/esm/core/crud/read.js.map +1 -1
- package/dist/esm/core/crud/update.js +18 -19
- package/dist/esm/core/crud/update.js.map +1 -1
- package/dist/{cjs/utils → esm/core}/identifier.js +18 -3
- package/dist/esm/core/identifier.js.map +1 -0
- package/dist/esm/did-btcr2.js +2 -2
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +28 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/beacon.js.map +1 -1
- package/dist/esm/utils/appendix.js +2 -3
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document.js +4 -6
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/esm/utils/types.js +2 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +135 -0
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/{messages → cohort/messages}/base.d.ts +13 -8
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +10 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +64 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +28 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +26 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +23 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +19 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +24 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +24 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +25 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +25 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +25 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +26 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +88 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +93 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/communication/error.d.ts +7 -0
- package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +9 -0
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +35 -0
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +79 -26
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +190 -0
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +155 -0
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -0
- package/dist/types/core/beacon/aggregation/session/status.d.ts +10 -0
- package/dist/types/core/beacon/aggregation/session/status.d.ts.map +1 -0
- package/dist/types/core/beacon/cid-aggregate.d.ts +3 -4
- package/dist/types/core/beacon/cid-aggregate.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +22 -0
- package/dist/types/core/beacon/error.d.ts.map +1 -0
- package/dist/types/core/beacon/factory.d.ts +2 -3
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton.d.ts +2 -3
- package/dist/types/core/beacon/singleton.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-aggregate.d.ts +3 -4
- package/dist/types/core/beacon/smt-aggregate.d.ts.map +1 -1
- package/dist/types/{utils/beacons.d.ts → core/beacon/utils.d.ts} +3 -3
- package/dist/types/core/beacon/utils.d.ts.map +1 -0
- package/dist/types/core/crud/read.d.ts +3 -3
- package/dist/types/core/crud/read.d.ts.map +1 -1
- package/dist/types/core/crud/update.d.ts +1 -1
- package/dist/types/core/crud/update.d.ts.map +1 -1
- package/dist/types/{utils → core}/identifier.d.ts +24 -3
- package/dist/types/core/identifier.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +1 -1
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +28 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/beacon.d.ts +65 -5
- package/dist/types/interfaces/beacon.d.ts.map +1 -1
- package/dist/types/interfaces/crud.d.ts +1 -1
- package/dist/types/interfaces/crud.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +2 -10
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +1 -1
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +1 -1
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/dist/types/{types/crud.d.ts → utils/types.d.ts} +2 -2
- package/dist/types/utils/types.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/core/beacon/aggregation/cohort/index.ts +292 -0
- package/src/core/beacon/aggregation/{messages → cohort/messages}/base.ts +14 -16
- package/src/core/beacon/aggregation/cohort/messages/constants.ts +12 -0
- package/src/core/beacon/aggregation/cohort/messages/index.ts +143 -0
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +43 -0
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +39 -0
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +34 -0
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +33 -0
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +35 -0
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +38 -0
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +39 -0
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +39 -0
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +39 -0
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +40 -0
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +153 -0
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +300 -0
- package/src/core/beacon/aggregation/communication/error.ts +13 -0
- package/src/core/beacon/aggregation/communication/factory.ts +25 -0
- package/src/core/beacon/aggregation/communication/service.ts +42 -0
- package/src/core/beacon/aggregation/coordinator.ts +338 -67
- package/src/core/beacon/aggregation/participant.ts +512 -0
- package/src/core/beacon/aggregation/session/index.ts +289 -0
- package/src/core/beacon/aggregation/session/status.ts +18 -0
- package/src/core/beacon/cid-aggregate.ts +4 -5
- package/src/core/beacon/error.ts +44 -0
- package/src/core/beacon/factory.ts +2 -3
- package/src/core/beacon/singleton.ts +10 -8
- package/src/core/beacon/smt-aggregate.ts +4 -5
- package/src/{utils/beacons.ts → core/beacon/utils.ts} +5 -5
- package/src/core/crud/read.ts +7 -16
- package/src/core/crud/update.ts +25 -22
- package/src/{utils → core}/identifier.ts +35 -5
- package/src/did-btcr2.ts +4 -4
- package/src/index.ts +36 -8
- package/src/interfaces/beacon.ts +75 -5
- package/src/interfaces/crud.ts +1 -1
- package/src/utils/appendix.ts +3 -11
- package/src/utils/did-document-builder.ts +1 -1
- package/src/utils/did-document.ts +4 -7
- package/src/{types/crud.ts → utils/types.ts} +2 -2
- package/dist/cjs/core/beacon/aggregation/messages/advert.js +0 -24
- package/dist/cjs/core/beacon/aggregation/messages/advert.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/messages/base.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js +0 -25
- package/dist/cjs/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/messages/keygen.js +0 -8
- package/dist/cjs/core/beacon/aggregation/messages/keygen.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/messages/opt-in.js +0 -23
- package/dist/cjs/core/beacon/aggregation/messages/opt-in.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/messages/sign.js +0 -7
- package/dist/cjs/core/beacon/aggregation/messages/sign.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/models/cohort/index.js +0 -92
- package/dist/cjs/core/beacon/aggregation/models/cohort/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/models/cohort/status.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +0 -57
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/protocol/service.js.map +0 -1
- package/dist/cjs/core/key-manager/index.js +0 -290
- package/dist/cjs/core/key-manager/index.js.map +0 -1
- package/dist/cjs/core/key-manager/interface.js +0 -2
- package/dist/cjs/core/key-manager/interface.js.map +0 -1
- package/dist/cjs/interfaces/ibeacon.js +0 -2
- package/dist/cjs/interfaces/ibeacon.js.map +0 -1
- package/dist/cjs/types/crud.js +0 -2
- package/dist/cjs/types/crud.js.map +0 -1
- package/dist/cjs/utils/beacons.js.map +0 -1
- package/dist/cjs/utils/identifier.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/advert.js +0 -24
- package/dist/esm/core/beacon/aggregation/messages/advert.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/base.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/cohort-set.js +0 -25
- package/dist/esm/core/beacon/aggregation/messages/cohort-set.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/keygen.js +0 -8
- package/dist/esm/core/beacon/aggregation/messages/keygen.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/opt-in.js +0 -23
- package/dist/esm/core/beacon/aggregation/messages/opt-in.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/messages/sign.js +0 -7
- package/dist/esm/core/beacon/aggregation/messages/sign.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/models/cohort/index.js +0 -92
- package/dist/esm/core/beacon/aggregation/models/cohort/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/models/cohort/status.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js +0 -57
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/protocol/service.js.map +0 -1
- package/dist/esm/core/key-manager/index.js +0 -290
- package/dist/esm/core/key-manager/index.js.map +0 -1
- package/dist/esm/core/key-manager/interface.js +0 -2
- package/dist/esm/core/key-manager/interface.js.map +0 -1
- package/dist/esm/interfaces/ibeacon.js +0 -2
- package/dist/esm/interfaces/ibeacon.js.map +0 -1
- package/dist/esm/types/crud.js +0 -2
- package/dist/esm/types/crud.js.map +0 -1
- package/dist/esm/utils/beacons.js.map +0 -1
- package/dist/esm/utils/identifier.js.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/advert.d.ts +0 -22
- package/dist/types/core/beacon/aggregation/messages/advert.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/base.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts +0 -23
- package/dist/types/core/beacon/aggregation/messages/cohort-set.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/keygen.d.ts +0 -6
- package/dist/types/core/beacon/aggregation/messages/keygen.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts +0 -22
- package/dist/types/core/beacon/aggregation/messages/opt-in.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/messages/sign.d.ts +0 -5
- package/dist/types/core/beacon/aggregation/messages/sign.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts +0 -77
- package/dist/types/core/beacon/aggregation/models/cohort/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/models/cohort/status.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts +0 -36
- package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/protocol/service.d.ts +0 -6
- package/dist/types/core/beacon/aggregation/protocol/service.d.ts.map +0 -1
- package/dist/types/core/key-manager/index.d.ts +0 -145
- package/dist/types/core/key-manager/index.d.ts.map +0 -1
- package/dist/types/core/key-manager/interface.d.ts +0 -113
- package/dist/types/core/key-manager/interface.d.ts.map +0 -1
- package/dist/types/interfaces/ibeacon.d.ts +0 -65
- package/dist/types/interfaces/ibeacon.d.ts.map +0 -1
- package/dist/types/types/crud.d.ts.map +0 -1
- package/dist/types/utils/beacons.d.ts.map +0 -1
- package/dist/types/utils/identifier.d.ts.map +0 -1
- package/src/core/beacon/aggregation/messages/advert.ts +0 -36
- package/src/core/beacon/aggregation/messages/cohort-set.ts +0 -37
- package/src/core/beacon/aggregation/messages/keygen.ts +0 -8
- package/src/core/beacon/aggregation/messages/opt-in.ts +0 -35
- package/src/core/beacon/aggregation/messages/sign.ts +0 -7
- package/src/core/beacon/aggregation/models/cohort/index.ts +0 -112
- package/src/core/beacon/aggregation/protocol/nostr.ts +0 -81
- package/src/core/beacon/aggregation/protocol/service.ts +0 -6
- package/src/core/key-manager/index.ts +0 -364
- package/src/core/key-manager/interface.ts +0 -129
- package/src/interfaces/ibeacon.ts +0 -75
- /package/dist/cjs/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
- /package/dist/cjs/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
- /package/dist/esm/core/beacon/aggregation/{models/cohort → cohort}/status.js +0 -0
- /package/dist/esm/core/beacon/aggregation/{protocol → communication}/service.js +0 -0
- /package/dist/types/core/beacon/aggregation/{models/cohort → cohort}/status.d.ts +0 -0
- /package/src/core/beacon/aggregation/{models/cohort → cohort}/status.ts +0 -0
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
2
|
-
import { Filter } from 'nostr-tools';
|
|
3
|
-
import { SimplePool, } from 'nostr-tools/pool';
|
|
4
|
-
import { Identifier } from '../../../../utils/identifier.js';
|
|
5
|
-
import { ProtocolService } from './service.js';
|
|
6
|
-
|
|
7
|
-
export interface NostrAdapterConfig {
|
|
8
|
-
keys: {
|
|
9
|
-
secret?: Uint8Array;
|
|
10
|
-
public?: Uint8Array;
|
|
11
|
-
};
|
|
12
|
-
did?: string;
|
|
13
|
-
components: {
|
|
14
|
-
idType?: string;
|
|
15
|
-
version?: number;
|
|
16
|
-
network?: string;
|
|
17
|
-
};
|
|
18
|
-
relays: string[];
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class NostrAdapter implements ProtocolService {
|
|
23
|
-
public name: string = 'nostr';
|
|
24
|
-
private config: NostrAdapterConfig;
|
|
25
|
-
private handlers: Map<string, (msg: any) => Promise<void>> = new Map();
|
|
26
|
-
|
|
27
|
-
constructor(config: NostrAdapterConfig = { keys: {}, components: {}, relays: ['wss://relay.damus.io'] }) {
|
|
28
|
-
this.config = config;
|
|
29
|
-
this.config.keys = this.config.keys || SchnorrKeyPair.generate().raw;
|
|
30
|
-
this.config.did = config.did || Identifier.encode({
|
|
31
|
-
idType : config.components.idType || 'KEY',
|
|
32
|
-
version : config.components.version || 1,
|
|
33
|
-
network : config.components.network || 'signet',
|
|
34
|
-
genesisBytes : this.config.keys.public!
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async start(): Promise<void> {
|
|
39
|
-
const pool = new SimplePool();
|
|
40
|
-
pool.subscribe(this.config.relays, { pubkey: this.config.did, kinds: [1059] } as Filter, {
|
|
41
|
-
onclose : (reasons: string[]) => console.log('Subscription closed for reasons:', reasons),
|
|
42
|
-
onevent : async (event: any) => {
|
|
43
|
-
console.log('Received event:', event);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
registerMessageHandler(messageType: string, handler: (msg: any) => Promise<void>): void {
|
|
49
|
-
this.handlers.set(messageType, handler);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Sends a message to a recipient using the Nostr protocol.
|
|
54
|
-
* This method is a placeholder and should be implemented with actual Nostr message sending logic.
|
|
55
|
-
* @param message
|
|
56
|
-
* @param recipient
|
|
57
|
-
* @param sender
|
|
58
|
-
*/
|
|
59
|
-
async sendMessage(message: object, recipient: string, sender: string): Promise<void> {
|
|
60
|
-
// TODO: Implement message sending logic via Nostr
|
|
61
|
-
console.log(`Sending message to ${recipient} from ${sender}:`, message);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Generates a Nostr identity using the Secp256k1SecretKey and Identifier classes.
|
|
66
|
-
* @returns {string} A BTCR2 DID used for communication over the nostr protocol
|
|
67
|
-
*/
|
|
68
|
-
public generateIdentity(): string {
|
|
69
|
-
this.config.keys.secret = Secp256k1SecretKey.random();
|
|
70
|
-
this.config.keys.public = Secp256k1SecretKey.getPublicKey(this.config.keys.secret).compressed;
|
|
71
|
-
this.config.did = Identifier.encode(
|
|
72
|
-
{
|
|
73
|
-
idType : this.config.components.idType || 'KEY',
|
|
74
|
-
version : this.config.components.version || 1,
|
|
75
|
-
network : this.config.components.network || 'signet',
|
|
76
|
-
genesisBytes : this.config.keys.public
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
return this.config.did;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import { AvailableNetworks } from '@did-btcr2/bitcoin';
|
|
2
|
-
import {
|
|
3
|
-
HashBytes,
|
|
4
|
-
Hex,
|
|
5
|
-
KeyBytes,
|
|
6
|
-
KeyManagerError,
|
|
7
|
-
Logger,
|
|
8
|
-
MULTIBASE_URI_PREFIX,
|
|
9
|
-
SchnorrKeyPairObject,
|
|
10
|
-
SignatureBytes
|
|
11
|
-
} from '@did-btcr2/common';
|
|
12
|
-
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
13
|
-
import { CompressedSecp256k1PublicKey, SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
14
|
-
import { sha256 } from '@noble/hashes/sha2';
|
|
15
|
-
import { KeyValueStore, MemoryStore } from '@web5/common';
|
|
16
|
-
import { KeyIdentifier } from '@web5/crypto';
|
|
17
|
-
import { Did } from '@web5/dids';
|
|
18
|
-
import { Multibase } from 'multiformats';
|
|
19
|
-
import { BitcoinSigner, CryptoSigner, IKeyManager, KeyManagerOptions, KeyManagerParams } from './interface.js';
|
|
20
|
-
|
|
21
|
-
export interface SignerParams {
|
|
22
|
-
multikey: SchnorrMultikey;
|
|
23
|
-
network: keyof AvailableNetworks;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Class for managing cryptographic keys for the B DID method.
|
|
28
|
-
* @class KeyManager
|
|
29
|
-
* @type {KeyManager}
|
|
30
|
-
*/
|
|
31
|
-
export class KeyManager implements IKeyManager, CryptoSigner, BitcoinSigner {
|
|
32
|
-
/**
|
|
33
|
-
* Singleton instance of the KeyManager.
|
|
34
|
-
* @private
|
|
35
|
-
* @type {KeyManager}
|
|
36
|
-
*/
|
|
37
|
-
static #instance?: KeyManager;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The `activeKeyUri` property is a string that represents the URI of the currently active key.
|
|
41
|
-
* It is used to identify the key that will be used for signing and verifying operations.
|
|
42
|
-
* This property is optional and can be set to a specific key URI when initializing the
|
|
43
|
-
* `KeyManager` instance. If not set, the key manager will use the default key URI.
|
|
44
|
-
* @type {KeyIdentifier}
|
|
45
|
-
*/
|
|
46
|
-
public activeKeyUri?: KeyIdentifier;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The `_store` private variable in `KeyManager` is a `KeyValueStore` instance used for
|
|
50
|
-
* storing and managing cryptographic keys. It allows the `KeyManager` class to save,
|
|
51
|
-
* retrieve, and handle keys efficiently within the local Key Management System (KMS) context.
|
|
52
|
-
* This variable can be configured to use different storage backends, like in-memory storage or
|
|
53
|
-
* persistent storage, providing flexibility in key management according to the application's
|
|
54
|
-
* requirements.
|
|
55
|
-
* @private
|
|
56
|
-
* @readonly
|
|
57
|
-
* @type {KeyValueStore<KeyIdentifier, SchnorrKeyPair>} The key store for managing cryptographic keys.
|
|
58
|
-
*/
|
|
59
|
-
private readonly _store: KeyValueStore<KeyIdentifier, SchnorrMultikey>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Creates an instance of KeyManager.
|
|
63
|
-
* @param {?KeyManagerParams} params The parameters to initialize the key manager.
|
|
64
|
-
* @param {KeyValueStore<KeyIdentifier, SchnorrMultikey>} params.store An optional property to specify a custom
|
|
65
|
-
* `KeyValueStore` instance for key management. If not provided, {@link KeyManager} uses a default `MemoryStore`
|
|
66
|
-
* instance. This store is responsible for managing cryptographic keys, allowing them to be retrieved, stored, and
|
|
67
|
-
* managed during cryptographic operations.
|
|
68
|
-
* @param {KeyIdentifier} params.keyUri An optional property to specify the active key URI for the key manager.
|
|
69
|
-
*/
|
|
70
|
-
constructor({ store, keyUri, keys }: KeyManagerParams = {}) {
|
|
71
|
-
// Set the default key store to a MemoryStore instance
|
|
72
|
-
this._store = store ?? new MemoryStore<KeyIdentifier, SchnorrMultikey>();
|
|
73
|
-
|
|
74
|
-
// Import the keys into the key store
|
|
75
|
-
if (keyUri && keys) {
|
|
76
|
-
void this.importKey(keys, keyUri).then(() => {
|
|
77
|
-
this.activeKeyUri = keyUri;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Gets the singleton instance of the KeyManager.
|
|
84
|
-
* @returns {KeyManager} The singleton instance of the KeyManager.
|
|
85
|
-
*/
|
|
86
|
-
public static get instance(): KeyManager {
|
|
87
|
-
// Check if the KeyManager instance is initialized
|
|
88
|
-
if (!KeyManager.#instance) {
|
|
89
|
-
throw new KeyManagerError('KeyManager not initialized. Call initialize() first.', 'KEY_MANAGER_NOT_INITIALIZED');
|
|
90
|
-
}
|
|
91
|
-
// Return the singleton instance
|
|
92
|
-
const instance = KeyManager.#instance;
|
|
93
|
-
return instance;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Signs a transaction using the key associated with the key URI.
|
|
98
|
-
* @param {Hex} txHex The transaction hex to sign.
|
|
99
|
-
* @param {KeyIdentifier} keyUri The URI of the key to sign the transaction with.
|
|
100
|
-
* @returns {Promise<Hex>} A promise resolving to the signed transaction hex.
|
|
101
|
-
*/
|
|
102
|
-
signTransaction(txHex: Hex, keyUri?: KeyIdentifier): Promise<Hex> {
|
|
103
|
-
throw new Error('Method not implemented.' + txHex + keyUri);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Gets the key pair from the key store and returns a CompressedSecp256k1PublicKey.
|
|
108
|
-
* @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
|
|
109
|
-
* @returns {Promise<CompressedSecp256k1PublicKey>} The public key associated with the key URI.
|
|
110
|
-
*/
|
|
111
|
-
public async getPublicKey(keyUri?: KeyIdentifier): Promise<CompressedSecp256k1PublicKey> {
|
|
112
|
-
// Use the active key URI if not provided
|
|
113
|
-
const key = await this.getKey(keyUri);
|
|
114
|
-
|
|
115
|
-
// Check if the key exists and has a public key
|
|
116
|
-
if (!key?.publicKey) {
|
|
117
|
-
throw new KeyManagerError(`Key not found for URI: ${keyUri}`, 'KEY_NOT_FOUND');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Return the public key
|
|
121
|
-
return key.publicKey;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Signs the given data using the key associated with the key URI.
|
|
126
|
-
* @param {Hex} data The data to sign.
|
|
127
|
-
* @param {?KeyIdentifier} keyUri The URI of the key to sign the data with.
|
|
128
|
-
* @returns {Promise<SignatureBytes>} A promise resolving to the signature of the data.
|
|
129
|
-
*/
|
|
130
|
-
public async sign(data: Hex, keyUri?: KeyIdentifier): Promise<SignatureBytes> {
|
|
131
|
-
// Get the key from the store
|
|
132
|
-
const key = await this.getKey(keyUri);
|
|
133
|
-
|
|
134
|
-
// Check if the key exists
|
|
135
|
-
if (!key) {
|
|
136
|
-
throw new KeyManagerError(`Key URI ${keyUri} not found`, 'KEY_NOT_FOUND');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Check if the key can sign
|
|
140
|
-
if(!key.signer) {
|
|
141
|
-
throw new KeyManagerError(`Key URI ${keyUri} is not a signer`, 'KEY_NOT_SIGNER');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Sign the data using the key and return the signature
|
|
145
|
-
return key.sign(data);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Verifies a signature using the key associated with the key URI.
|
|
150
|
-
* @param {KeyIdentifier} keyUri The URI of the key to verify the signature with.
|
|
151
|
-
* @param {SignatureBytes} signature The signature to verify.
|
|
152
|
-
* @param {Hex} data The data to verify the signature with.
|
|
153
|
-
* @returns {Promise<boolean>} A promise resolving to a boolean indicating the verification result.
|
|
154
|
-
*/
|
|
155
|
-
public async verify(signature: SignatureBytes, data: Hex, keyUri?: KeyIdentifier): Promise<boolean> {
|
|
156
|
-
// Get the key from the store
|
|
157
|
-
const key = await this.getKey(keyUri);
|
|
158
|
-
|
|
159
|
-
// Check if the key exists
|
|
160
|
-
if (!key) {
|
|
161
|
-
throw new KeyManagerError(`Key not found for URI: ${keyUri}`, 'KEY_NOT_FOUND');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Verify the signature using the multikey
|
|
165
|
-
return key.verify(signature, data);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Gets the key pair from the key store.
|
|
170
|
-
* @param {KeyIdentifier} keyUri The URI of the key to get.
|
|
171
|
-
* @returns {Promise<SchnorrKeyPair>} The key pair associated with the key URI.
|
|
172
|
-
* @throws {KeyManagerError} If the key is not found in the key store.
|
|
173
|
-
*/
|
|
174
|
-
private async getKey(keyUri?: KeyIdentifier): Promise<SchnorrMultikey | undefined> {
|
|
175
|
-
// Use the active key URI if not provided
|
|
176
|
-
const uri = keyUri ?? this.activeKeyUri;
|
|
177
|
-
|
|
178
|
-
// Throw an error if no key URI is provided or active
|
|
179
|
-
if (!uri) {
|
|
180
|
-
throw new KeyManagerError('No active key uri set.', 'ACTIVE_KEY_URI_NOT_SET');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Get the key pair from the key store
|
|
184
|
-
return await this._store.get(uri);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Exports the full multikeypair from the key store.
|
|
189
|
-
* @returns {Promise<SchnorrKeyPair>} The key pair associated with the key URI.
|
|
190
|
-
* @throws {KeyManagerError} If the key is not found in the key store.
|
|
191
|
-
*/
|
|
192
|
-
public async exportKey(keyUri?: KeyIdentifier): Promise<SchnorrMultikey | undefined> {
|
|
193
|
-
// Get the key from the key store and return it
|
|
194
|
-
return await this.getKey(keyUri);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Imports a keypair to the store.
|
|
199
|
-
* @param {SchnorrKeyPair} keys The keypair to import.
|
|
200
|
-
* @param {KeyIdentifier} keyUri The URI of the key to import.
|
|
201
|
-
* @param {KeyManagerOptions} options Relevant import options.
|
|
202
|
-
* @param {boolean} options.active A flag to set the key as active (optional, default: false).
|
|
203
|
-
* @returns {Promise<KeyIdentifier>} A promise that resolves to the key identifier of the imported key.
|
|
204
|
-
*/
|
|
205
|
-
public async importKey(keys: SchnorrKeyPair, keyUri: string, options: KeyManagerOptions = {}): Promise<KeyIdentifier> {
|
|
206
|
-
const parts = Did.parse(keyUri);
|
|
207
|
-
if(!parts) {
|
|
208
|
-
throw new KeyManagerError(
|
|
209
|
-
'Invalid key URI: must be valid, parsable BTCR2 identifier',
|
|
210
|
-
'INVALID_KEY_URI',
|
|
211
|
-
{ keyUri, parts }
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if(!parts.id) {
|
|
216
|
-
throw new KeyManagerError(
|
|
217
|
-
'Invalid key URI: missing id part',
|
|
218
|
-
'INVALID_KEY_URI',
|
|
219
|
-
{ keyUri, parts }
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if(!parts.fragment) {
|
|
224
|
-
throw new KeyManagerError(
|
|
225
|
-
'Invalid key URI: missing fragment part',
|
|
226
|
-
'INVALID_KEY_URI',
|
|
227
|
-
{ keyUri, parts }
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
// Instantiate a new SchnorrMultikey with the provided keys
|
|
231
|
-
const multikey = new SchnorrMultikey({ controller: parts.uri, id: `#${parts.fragment}`, keys });
|
|
232
|
-
|
|
233
|
-
// Store the keypair in the key store
|
|
234
|
-
await this._store.set(keyUri, multikey);
|
|
235
|
-
|
|
236
|
-
// Set the key as active if required
|
|
237
|
-
if (options.active) {
|
|
238
|
-
this.activeKeyUri = keyUri;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Return the key URI
|
|
242
|
-
return keyUri;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Computes the hash of the given data.
|
|
247
|
-
* @param {Uint8Array} data The data to hash.
|
|
248
|
-
* @returns {HashBytes} The hash of the data.
|
|
249
|
-
*/
|
|
250
|
-
public digest(data: Uint8Array): HashBytes {
|
|
251
|
-
return sha256(data);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Computes the key URI of a given keypair.
|
|
256
|
-
* @param {string} id The fragment identifier (e.g. 'key-1').
|
|
257
|
-
* @param {string} [controller] The DID controller (e.g. 'did:btcr2:xyz').
|
|
258
|
-
* @returns {KeyIdentifier} A full DID fragment URI (e.g. 'did:btcr2:xyz#key-1')
|
|
259
|
-
*/
|
|
260
|
-
public static computeKeyUri(id: string, controller: string): KeyIdentifier {
|
|
261
|
-
// Concat the id to the controller and return
|
|
262
|
-
return `${controller}${id.startsWith('#') ? id : `#${id}`}`;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Computes a multibase-compliant URI from a key.
|
|
267
|
-
* @param key A SchnorrKeyPair, CompressedSecp256k1PublicKey, or multibase string
|
|
268
|
-
* @returns {string} A multibase URI (e.g. 'urn:mb:zQ3s...')
|
|
269
|
-
*/
|
|
270
|
-
public static toMultibaseUri(data: SchnorrKeyPair | CompressedSecp256k1PublicKey | Multibase<'zQ3s'>): string {
|
|
271
|
-
const multibase = data instanceof SchnorrKeyPair
|
|
272
|
-
? data.publicKey.multibase
|
|
273
|
-
: data instanceof CompressedSecp256k1PublicKey
|
|
274
|
-
? data.multibase
|
|
275
|
-
: data;
|
|
276
|
-
|
|
277
|
-
return `${MULTIBASE_URI_PREFIX}${multibase}`;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Initializes a singleton KeyManager instance.
|
|
282
|
-
* @param {SchnorrKeyPair} keys The keypair used to initialize the key manager.
|
|
283
|
-
* @returns {void}
|
|
284
|
-
*/
|
|
285
|
-
public static async initialize(keys: SchnorrKeyPair | SchnorrKeyPairObject, keyUri: string): Promise<KeyManager> {
|
|
286
|
-
if(!(keys instanceof SchnorrKeyPair)) {
|
|
287
|
-
keys = SchnorrKeyPair.fromJSON(keys);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Check if the KeyManager instance is already initialized
|
|
291
|
-
if (KeyManager.#instance) {
|
|
292
|
-
Logger.warn('KeyManager global instance is already initialized.');
|
|
293
|
-
return KeyManager.#instance;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Check if the keypair is provided
|
|
297
|
-
if(!keys) {
|
|
298
|
-
// Log a warning message if not provided
|
|
299
|
-
Logger.warn('keys not provided, generating ...');
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Generate a new keypair if not provided
|
|
303
|
-
keys ??= SchnorrKeyPair.generate();
|
|
304
|
-
|
|
305
|
-
// Initialize the singleton key manager with the keypair
|
|
306
|
-
KeyManager.#instance = new KeyManager({ keys });
|
|
307
|
-
|
|
308
|
-
// Import the keypair into the key store
|
|
309
|
-
await KeyManager.#instance.importKey(keys, keyUri, { active: true });
|
|
310
|
-
|
|
311
|
-
// Set the active key URI
|
|
312
|
-
KeyManager.#instance.activeKeyUri = keyUri;
|
|
313
|
-
|
|
314
|
-
// Log the active key URI
|
|
315
|
-
Logger.info(`KeyManager initialized with Active Key URI: ${KeyManager.#instance.activeKeyUri}`);
|
|
316
|
-
|
|
317
|
-
// Return the singleton instance
|
|
318
|
-
return KeyManager.#instance;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Retrieves a keypair from the key store using the provided key URI.
|
|
323
|
-
* @public
|
|
324
|
-
* @param {KeyIdentifier} keyUri The URI of the keypair to retrieve.
|
|
325
|
-
* @returns {Promise<SchnorrKeyPair | undefined>} The retrieved keypair, or undefined if not found.
|
|
326
|
-
*/
|
|
327
|
-
public static async getKeyPair(keyUri?: KeyIdentifier): Promise<SchnorrMultikey | undefined> {
|
|
328
|
-
// Use the active key URI if not provided
|
|
329
|
-
keyUri ??= KeyManager.#instance?.activeKeyUri;
|
|
330
|
-
// Instantiate a new KeyManager with the default key store
|
|
331
|
-
return await KeyManager.#instance?.getKey(keyUri);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
public async getKeySigner(keyUri: KeyIdentifier, network: keyof AvailableNetworks): Promise<Signer> {
|
|
335
|
-
const multikey = await this.getKey(keyUri);
|
|
336
|
-
if(!multikey) {
|
|
337
|
-
throw new KeyManagerError(`Key not found for URI: ${keyUri}`, 'KEY_NOT_FOUND');
|
|
338
|
-
}
|
|
339
|
-
return new Signer({ multikey, network });
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export class Signer {
|
|
344
|
-
public multikey: SchnorrMultikey;
|
|
345
|
-
public network: keyof AvailableNetworks;
|
|
346
|
-
|
|
347
|
-
constructor(params: SignerParams) {
|
|
348
|
-
this.multikey = params.multikey;
|
|
349
|
-
this.network = params.network;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
get publicKey(): KeyBytes {
|
|
353
|
-
// Return the public key from the multikey
|
|
354
|
-
return this.multikey.publicKey.compressed;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
public sign(hash: Hex): SignatureBytes {
|
|
358
|
-
return this.multikey.sign(hash, { scheme: 'ecdsa' });
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
public signSchnorr(hash: Hex): SignatureBytes {
|
|
362
|
-
return this.multikey.sign(hash);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { HashBytes, Hex, SignatureBytes } from '@did-btcr2/common';
|
|
2
|
-
import { Multikey, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
3
|
-
import { SchnorrKeyPair, CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
4
|
-
import { KeyValueStore } from '@web5/common';
|
|
5
|
-
|
|
6
|
-
export type KeyManagerOptions = {
|
|
7
|
-
importKey?: boolean;
|
|
8
|
-
active?: boolean
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/** Alias type for KeyManager keyUri */
|
|
12
|
-
export type KeyIdentifier = string;
|
|
13
|
-
|
|
14
|
-
/** Params for initializing a KeyManager class instance. */
|
|
15
|
-
export type KeyManagerParams = {
|
|
16
|
-
/**
|
|
17
|
-
* An optional property to specify a custom `KeyValueStore` instance for key management. If not
|
|
18
|
-
* provided, {@link KeyManager | `KeyManager`} uses a default `MemoryStore` instance.
|
|
19
|
-
* This store is responsible for managing cryptographic keys, allowing them to be retrieved,
|
|
20
|
-
* stored, and managed during cryptographic operations.
|
|
21
|
-
* @type {KeyValueStore<KeyIdentifier, KeyPair>}
|
|
22
|
-
*/
|
|
23
|
-
store?: KeyValueStore<KeyIdentifier, SchnorrMultikey>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* An optional property to specify a key URI for the key manager. If not provided, the key manager
|
|
27
|
-
* will generate a key URI based on the public key of the key pair.
|
|
28
|
-
* @type {KeyIdentifier}
|
|
29
|
-
*/
|
|
30
|
-
keyUri?: KeyIdentifier;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* An optional property to specify the DID contoller id.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
id?: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* An optional property to specify the DID controller.\
|
|
40
|
-
* @type {string}
|
|
41
|
-
*/
|
|
42
|
-
controller?: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* An optional property to pass in an initial key pair
|
|
46
|
-
* @type {SchnorrKeyPair}
|
|
47
|
-
*/
|
|
48
|
-
keys?: SchnorrKeyPair;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type GenerateKeyParams = {
|
|
52
|
-
id: string;
|
|
53
|
-
controller: string;
|
|
54
|
-
options: KeyManagerOptions
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The interface for the KeyManager class.
|
|
59
|
-
* @interface IKeyManager
|
|
60
|
-
* @type {IKeyManager}
|
|
61
|
-
*/
|
|
62
|
-
export interface IKeyManager {
|
|
63
|
-
/**
|
|
64
|
-
* The URI of the active key.
|
|
65
|
-
* @type {KeyIdentifier}
|
|
66
|
-
*/
|
|
67
|
-
activeKeyUri?: KeyIdentifier;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Exports the full key pair from the key store.
|
|
71
|
-
* @param {KeyIdentifier} keyUri The URI of the key to export.
|
|
72
|
-
* @returns {Promise<Multikey | undefined>} The key pair associated with the key URI.
|
|
73
|
-
* @throws {KeyManagerError} If the key is not found in the key store.
|
|
74
|
-
*/
|
|
75
|
-
exportKey(keyUri?: KeyIdentifier): Promise<Multikey | undefined>;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Gets the public key of a key pair.
|
|
79
|
-
* @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
|
|
80
|
-
* @returns {Promise<CompressedSecp256k1PublicKey>} The public key of the key pair.
|
|
81
|
-
*/
|
|
82
|
-
getPublicKey(keyUri: KeyIdentifier): Promise<CompressedSecp256k1PublicKey>;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Imports a key pair into the key store.
|
|
86
|
-
* @param {SchnorrKeyPair} keyPair The key pair to import.
|
|
87
|
-
* @param {string} keyUri The full DID controller + fragment identifier (e.g. 'did:btcr2:xyz#key-1').
|
|
88
|
-
* @param {KeyManagerOptions} options The options for importing the key pair.
|
|
89
|
-
* @param {boolean} options.active Whether to set the imported key as active.
|
|
90
|
-
* @returns {Promise<KeyIdentifier>} A promise that resolves to the key identifier of the imported key.
|
|
91
|
-
*/
|
|
92
|
-
importKey(keyPair: SchnorrKeyPair, keyUri: string, options: KeyManagerOptions): Promise<KeyIdentifier>;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface CryptoSigner {
|
|
96
|
-
/**
|
|
97
|
-
* Signs a message with a key pair.
|
|
98
|
-
* @param {Hex} data The data to sign.
|
|
99
|
-
* @param {?KeyIdentifier} keyUri The URI of the key to sign the data with.
|
|
100
|
-
* @returns {Promise<SignatureBytes>} The signature of the input data.
|
|
101
|
-
*/
|
|
102
|
-
sign(data: Hex, keyUri?: KeyIdentifier): Promise<SignatureBytes>;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Verifies if a signature was produced by a key pair.
|
|
106
|
-
* @param {SignatureBytes} signature The signature to verify.
|
|
107
|
-
* @param {Hex} data The data that was signed.
|
|
108
|
-
* @param {?KeyIdentifier} keyUri The URI of the key to use for verification.
|
|
109
|
-
* @returns {Promise<boolean>} A promise that resolves if the signature is valid, and rejects otherwise.
|
|
110
|
-
*/
|
|
111
|
-
verify(signature: SignatureBytes, data: Hex, keyUri?: KeyIdentifier): Promise<boolean>;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Returns the sha256 hash of the input data.
|
|
115
|
-
* @param {Uint8Array} data The data to hash.
|
|
116
|
-
* @returns {HashBytes} The sha256 hash of the input data.
|
|
117
|
-
*/
|
|
118
|
-
digest(data: Uint8Array): HashBytes;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface BitcoinSigner {
|
|
122
|
-
/**
|
|
123
|
-
* Signs a Bitcoin transaction with a key pair.
|
|
124
|
-
* @param txHex The hex-encoded transaction to sign.
|
|
125
|
-
* @param keyUri The URI of the key to sign the transaction with.
|
|
126
|
-
* @returns {Promise<Hex>} A promise that resolves to the hex-encoded signed transaction.
|
|
127
|
-
*/
|
|
128
|
-
signTransaction(txHex: Hex, keyUri?: KeyIdentifier): Promise<Hex>;
|
|
129
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { DidUpdatePayload, UnixTimestamp } from '@did-btcr2/common';
|
|
2
|
-
import { DidServiceEndpoint, DidService as IDidService } from '@web5/dids';
|
|
3
|
-
import { RawTransactionV2, RawTransactionRest } from '@did-btcr2/bitcoin';
|
|
4
|
-
import { SignalsMetadata } from '../types/crud.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Beacon interface
|
|
8
|
-
* @interface IBeacon
|
|
9
|
-
* @type {IBeacon}
|
|
10
|
-
*/
|
|
11
|
-
export interface IBeacon {
|
|
12
|
-
/**
|
|
13
|
-
* A unique identifier for the Beacon
|
|
14
|
-
* @type {string}
|
|
15
|
-
*/
|
|
16
|
-
id: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The type of the Beacon
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
type: string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The service endpoint of the Beacon
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
serviceEndpoint: DidServiceEndpoint;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Returns the Beacon Service object
|
|
32
|
-
* @type {BeaconService}
|
|
33
|
-
*/
|
|
34
|
-
service: BeaconService;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Generates a Beacon Signal Transaction
|
|
38
|
-
* @param {string} didUpdatePayload The DID update payload
|
|
39
|
-
* @returns {BeaconSignal} The Beacon Signal
|
|
40
|
-
*/
|
|
41
|
-
generateSignal(didUpdatePayload: string): BeaconSignal;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Processes a Beacon Signal.
|
|
45
|
-
* @param {RawTransactionV2} signal The raw transaction
|
|
46
|
-
* @param {SidecarData} signalsMetadata The signals metadata from the sidecar data
|
|
47
|
-
* @returns {Promise<DidUpdatePayload | undefined>} The DID update payload
|
|
48
|
-
*/
|
|
49
|
-
processSignal(signal: RawTransactionV2, signalsMetadata: SignalsMetadata): Promise<DidUpdatePayload | undefined>;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Broadcasts a signal.
|
|
54
|
-
* @param {DidUpdatePayload} didUpdatePayload The DID update payload.
|
|
55
|
-
* @returns {Promise<SignalMetadata>} The signal metadata.
|
|
56
|
-
*/
|
|
57
|
-
broadcastSignal(didUpdatePayload: DidUpdatePayload): Promise<SignalsMetadata>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface BeaconService extends IDidService {
|
|
61
|
-
serviceEndpoint: DidServiceEndpoint;
|
|
62
|
-
casType?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface BeaconServiceAddress extends BeaconService {
|
|
66
|
-
address: string;
|
|
67
|
-
}
|
|
68
|
-
export interface BeaconSignal {
|
|
69
|
-
beaconId: string;
|
|
70
|
-
beaconType: string;
|
|
71
|
-
beaconAddress: string;
|
|
72
|
-
tx: RawTransactionRest | RawTransactionV2;
|
|
73
|
-
blockheight: number;
|
|
74
|
-
blocktime: UnixTimestamp;
|
|
75
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|