Class: BeaconUtils ​
Defined in: packages/method/src/core/beacon/utils.ts:14
Static class of utility functions for the Beacon Service BeaconUtils
Constructors ​
Constructor ​
new BeaconUtils():
BeaconUtils
Returns ​
BeaconUtils
Methods ​
createBeaconService() ​
staticcreateBeaconService(did,addressType,beaconType):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:90
Generate a set of Beacon Services for a given public key.
Parameters ​
did ​
string
The did for the beacon service.
addressType ​
The type of bitcoin address to generate (p2pkh, p2wpkh, p2tr).
"p2pkh" | "p2wpkh" | "p2tr"
beaconType ​
string
The type of beacon service to create.
Returns ​
A BeaconService object.
Throws ​
if the bitcoin address is invalid.
createBeaconServices() ​
staticcreateBeaconServices(did,beaconType):BeaconService[]
Defined in: packages/method/src/core/beacon/utils.ts:67
Create the 3 default Beacon Service Endpoints for a given k (public-key-based) identifier.
Parameters ​
did ​
string
The DID for which to create the beacon services.
beaconType ​
string
Returns ​
2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
Throws ​
if the bitcoin address is invalid.
generateBeaconServices() ​
staticgenerateBeaconServices(did):BeaconService[]
Defined in: packages/method/src/core/beacon/utils.ts:117
Generate three default Beacon Service Endpoints for a given k (public-key-based) identifier.
Parameters ​
did ​
The DID for which to create the beacon services.
beaconType ​
string
id ​
string
network ​
Network
publicKey ​
Returns ​
2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
Throws ​
if the bitcoin address is invalid.
getBeaconServiceIds() ​
staticgetBeaconServiceIds(didDocument):string[]
Defined in: packages/method/src/core/beacon/utils.ts:183
Get the beacon service ids from a list of beacon services.
Parameters ​
didDocument ​
The DID Document to extract the services from.
Returns ​
string[]
An array of beacon service ids.
getBeaconServices() ​
staticgetBeaconServices(didDocument):BeaconService[]
Defined in: packages/method/src/core/beacon/utils.ts:56
Extracts the services from a given DID Document
Parameters ​
didDocument ​
The DID Document to extract the services from
Returns ​
An array of DidService objects
Throws ​
if the didDocument is not provided
getBeaconServicesMap() ​
staticgetBeaconServicesMap(beacons):Map<string,BeaconService>
Defined in: packages/method/src/core/beacon/utils.ts:170
Create a map of address => beaconService with address field.
Parameters ​
beacons ​
The list of beacon services.
Returns ​
Map<string, BeaconService>
A map of address => beaconService.
isBeaconService() ​
staticisBeaconService(obj):boolean
Defined in: packages/method/src/core/beacon/utils.ts:33
Validates that the given object is a Beacon Service
Parameters ​
obj ​
unknown
The object to validate
Returns ​
boolean
A boolean indicating whether the object is a Beacon Service
parseBeaconServiceEndpoint() ​
staticparseBeaconServiceEndpoint(beacon):BeaconService
Defined in: packages/method/src/core/beacon/utils.ts:161
Convert beacon service endpoints from BIP-21 URIs to addresses.
Parameters ​
beacon ​
The beacon service to parse.
Returns ​
The beacon service with the address field extracted from the serviceEndpoint.
parseBitcoinAddress() ​
staticparseBitcoinAddress(uri):string
Defined in: packages/method/src/core/beacon/utils.ts:21
Converts a BIP21 Bitcoin URI to a Bitcoin address
Parameters ​
uri ​
string
The BIP21 Bitcoin URI to convert
Returns ​
string
The Bitcoin address extracted from the URI
Throws ​
if the URI is not a valid Bitcoin URI