Return whether there are any messages matching the given options.
Subclasses can override this method to indicate they are not supported.
This method has access to whatever options may have been passed
in by the constructor as well as the ability to interact with
this.environment to determine whether the functionality is
supported. See the Bowser documentation for more details:
https://github.com/lancedikson/bowser
isSupported() {
return this.environment.satisfies({
* declare browsers per OS
windows: {
"internet explorer": ">10",
},
macos: {
safari: ">10.1"
},
* per platform (mobile, desktop or tablet)
mobile: {
safari: '>=9',
'android browser': '>3.10'
},
* or in general
chrome: "~20.1.1432",
firefox: ">31",
opera: ">=22",
* also supports equality operator
chrome: "=20.1.1432", * will match particular build only
* and loose-equality operator
chrome: "~20", * will match any 20.* sub-version
chrome: "~20.1" * will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
});
}
Return the first message matching the given options (or null if none is found).
Return messages array for this interaction.
The messages array is a (possibly empty) array of Message objects.
Subclasses should override this method and add messages as
needed. Make sure to call super.messages() to return an empty
messages array for you to begin populating.
Return messages filtered by the given options.
Multiple options can be given at once to filter along multiple dimensions.
import {PENDING, ACTIVE} from "@caravan/bitcoin";
// Create any interaction instance
interaction.messages().forEach(msg => console.log(msg));
{ code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
{ code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
{ code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
interaction.messagesFor({state: PENDING}).forEach(msg => console.log(msg));
{ code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
interaction.messagesFor({code: ACTIVE}).forEach(msg => console.log(msg));
{ code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
{ code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
interaction.messagesFor({version: /^2/}).forEach(msg => console.log(msg));
{ code: "device.active", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
Retrieve the text of the first message matching the given options
(or null if none is found).
Parse the armored "Bitcoin Signed Message" file Coldcard returns over SD card. Extract the base64 signature and wrap as an SignMessageResult.
The signature line is identified as the second non-empty
non-delimiter line after BEGIN SIGNATURE (first is the address,
second is the base64 sig). To survive minor format variations
(extra blank lines, address-line wrapping), we also validate the
candidate matches a base64 shape covering the BIP-137 65-byte
wire form — 87 base64 chars plus one = padding char, or with
trailing whitespace stripped.
Build the .txt request file for Coldcard's sign-text-file flow. Three lines: message, BIP-32 path, address format (always p2wpkh since we sign per cosigner pubkey as single-key).
Throws an error.
Coldcard sign-message interaction over SD card / Virtual Disk file exchange. request() writes a 3-line .txt (message / bip32Path / "p2wpkh"); parse() extracts the base64 signature from the armored "Bitcoin Signed Message" file Coldcard returns.