@ckb-ccc/joy-id 0.0.5-alpha.7 → 0.0.6-alpha.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.
Files changed (50) hide show
  1. package/dist/btc/index.d.ts +46 -1
  2. package/dist/btc/index.d.ts.map +1 -1
  3. package/dist/btc/index.js +46 -3
  4. package/dist/ckb/index.d.ts +95 -2
  5. package/dist/ckb/index.d.ts.map +1 -1
  6. package/dist/ckb/index.js +98 -8
  7. package/dist/common/index.d.ts +13 -0
  8. package/dist/common/index.d.ts.map +1 -1
  9. package/dist/common/index.js +9 -0
  10. package/dist/connectionsStorage/index.d.ts +58 -0
  11. package/dist/connectionsStorage/index.d.ts.map +1 -1
  12. package/dist/connectionsStorage/index.js +30 -0
  13. package/dist/evm/index.d.ts +51 -1
  14. package/dist/evm/index.d.ts.map +1 -1
  15. package/dist/evm/index.js +52 -4
  16. package/dist/nostr/index.d.ts +51 -0
  17. package/dist/nostr/index.d.ts.map +1 -0
  18. package/dist/nostr/index.js +106 -0
  19. package/dist/signerFactory/index.d.ts +9 -0
  20. package/dist/signerFactory/index.d.ts.map +1 -1
  21. package/dist/signerFactory/index.js +20 -2
  22. package/dist.commonjs/btc/index.d.ts +46 -1
  23. package/dist.commonjs/btc/index.d.ts.map +1 -1
  24. package/dist.commonjs/btc/index.js +46 -3
  25. package/dist.commonjs/ckb/index.d.ts +95 -2
  26. package/dist.commonjs/ckb/index.d.ts.map +1 -1
  27. package/dist.commonjs/ckb/index.js +98 -8
  28. package/dist.commonjs/common/index.d.ts +13 -0
  29. package/dist.commonjs/common/index.d.ts.map +1 -1
  30. package/dist.commonjs/common/index.js +9 -0
  31. package/dist.commonjs/connectionsStorage/index.d.ts +58 -0
  32. package/dist.commonjs/connectionsStorage/index.d.ts.map +1 -1
  33. package/dist.commonjs/connectionsStorage/index.js +30 -0
  34. package/dist.commonjs/evm/index.d.ts +51 -1
  35. package/dist.commonjs/evm/index.d.ts.map +1 -1
  36. package/dist.commonjs/evm/index.js +52 -4
  37. package/dist.commonjs/nostr/index.d.ts +51 -0
  38. package/dist.commonjs/nostr/index.d.ts.map +1 -0
  39. package/dist.commonjs/nostr/index.js +110 -0
  40. package/dist.commonjs/signerFactory/index.d.ts +9 -0
  41. package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
  42. package/dist.commonjs/signerFactory/index.js +20 -2
  43. package/package.json +3 -3
  44. package/src/btc/index.ts +47 -12
  45. package/src/ckb/index.ts +104 -19
  46. package/src/common/index.ts +13 -0
  47. package/src/connectionsStorage/index.ts +64 -2
  48. package/src/evm/index.ts +56 -15
  49. package/src/nostr/index.ts +135 -0
  50. package/src/signerFactory/index.ts +25 -2
@@ -5,13 +5,32 @@ const core_1 = require("@ckb-ccc/core");
5
5
  const common_1 = require("@joyid/common");
6
6
  const common_2 = require("../common");
7
7
  const connectionsStorage_1 = require("../connectionsStorage");
8
+ /**
9
+ * Class representing an EVM signer that extends SignerEvm from @ckb-ccc/core.
10
+ * @class
11
+ * @extends {ccc.SignerEvm}
12
+ */
8
13
  class EvmSigner extends core_1.ccc.SignerEvm {
14
+ /**
15
+ * Ensures that the signer is connected and returns the connection.
16
+ * @private
17
+ * @throws Will throw an error if not connected.
18
+ * @returns {Connection} The current connection.
19
+ */
9
20
  assertConnection() {
10
21
  if (!this.isConnected() || !this.connection) {
11
22
  throw new Error("Not connected");
12
23
  }
13
24
  return this.connection;
14
25
  }
26
+ /**
27
+ * Creates an instance of EvmSigner.
28
+ * @param {ccc.Client} client - The client instance.
29
+ * @param {string} name - The name of the signer.
30
+ * @param {string} icon - The icon URL of the signer.
31
+ * @param {string} [appUri="https://app.joy.id"] - The application URI.
32
+ * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
33
+ */
15
34
  constructor(client, name, icon, appUri = "https://app.joy.id", connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage()) {
16
35
  super(client);
17
36
  this.name = name;
@@ -19,9 +38,11 @@ class EvmSigner extends core_1.ccc.SignerEvm {
19
38
  this.appUri = appUri;
20
39
  this.connectionsRepo = connectionsRepo;
21
40
  }
22
- async replaceClient(client) {
23
- return new EvmSigner(client, this.name, this.icon, this.appUri, this.connectionsRepo);
24
- }
41
+ /**
42
+ * Gets the configuration for JoyID.
43
+ * @private
44
+ * @returns {object} The configuration object.
45
+ */
25
46
  getConfig() {
26
47
  return {
27
48
  redirectURL: location.href,
@@ -31,11 +52,19 @@ class EvmSigner extends core_1.ccc.SignerEvm {
31
52
  logo: this.icon,
32
53
  };
33
54
  }
55
+ /**
56
+ * Gets the EVM account address.
57
+ * @returns {Promise<string>} A promise that resolves to the EVM account address.
58
+ */
34
59
  async getEvmAccount() {
35
60
  return this.assertConnection().address;
36
61
  }
62
+ /**
63
+ * Connects to the provider by requesting authentication.
64
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
65
+ */
37
66
  async connect() {
38
- const config = await this.getConfig();
67
+ const config = this.getConfig();
39
68
  const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
40
69
  ...config,
41
70
  type: common_1.DappRequestType.Auth,
@@ -47,6 +76,10 @@ class EvmSigner extends core_1.ccc.SignerEvm {
47
76
  };
48
77
  await this.saveConnection();
49
78
  }
79
+ /**
80
+ * Checks if the signer is connected.
81
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
82
+ */
50
83
  async isConnected() {
51
84
  if (this.connection) {
52
85
  return true;
@@ -54,6 +87,11 @@ class EvmSigner extends core_1.ccc.SignerEvm {
54
87
  await this.restoreConnection();
55
88
  return this.connection !== undefined;
56
89
  }
90
+ /**
91
+ * Signs a raw message with the EVM account.
92
+ * @param {string | ccc.BytesLike} message - The message to sign.
93
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
94
+ */
57
95
  async signMessageRaw(message) {
58
96
  const { address } = this.assertConnection();
59
97
  const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
@@ -66,12 +104,22 @@ class EvmSigner extends core_1.ccc.SignerEvm {
66
104
  }, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
67
105
  return core_1.ccc.hexFrom(signature);
68
106
  }
107
+ /**
108
+ * Saves the current connection.
109
+ * @private
110
+ * @returns {Promise<void>}
111
+ */
69
112
  async saveConnection() {
70
113
  return this.connectionsRepo.set({
71
114
  uri: this.getConfig().joyidAppURL,
72
115
  addressType: "ethereum",
73
116
  }, this.connection);
74
117
  }
118
+ /**
119
+ * Restores the previous connection.
120
+ * @private
121
+ * @returns {Promise<void>}
122
+ */
75
123
  async restoreConnection() {
76
124
  this.connection = await this.connectionsRepo.get({
77
125
  uri: this.getConfig().joyidAppURL,
@@ -0,0 +1,51 @@
1
+ import { ccc } from "@ckb-ccc/core";
2
+ import { ConnectionsRepo } from "../connectionsStorage";
3
+ /**
4
+ * Class representing a Nostr signer that extends SignerNostr from @ckb-ccc/core.
5
+ * @class
6
+ * @extends {ccc.SignerNostr}
7
+ */
8
+ export declare class NostrSigner extends ccc.SignerNostr {
9
+ private readonly name;
10
+ private readonly icon;
11
+ private readonly appUri;
12
+ private readonly connectionsRepo;
13
+ private connection?;
14
+ /**
15
+ * Ensures that the signer is connected and returns the connection.
16
+ * @private
17
+ * @throws Will throw an error if not connected.
18
+ * @returns {Connection} The current connection.
19
+ */
20
+ private assertConnection;
21
+ /**
22
+ * Creates an instance of NostrSigner.
23
+ * @param {ccc.Client} client - The client instance.
24
+ * @param {string} name - The name of the signer.
25
+ * @param {string} icon - The icon URL of the signer.
26
+ * @param {string} [appUri="https://app.joy.id"] - The application URI.
27
+ * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
28
+ */
29
+ constructor(client: ccc.Client, name: string, icon: string, appUri?: string, connectionsRepo?: ConnectionsRepo);
30
+ static isValidClient(client: ccc.Client): boolean;
31
+ replaceClient(client: ccc.Client): Promise<boolean>;
32
+ /**
33
+ * Gets the configuration for JoyID.
34
+ * @private
35
+ * @returns {object} The configuration object.
36
+ */
37
+ private getConfig;
38
+ /**
39
+ * Connects to the provider by requesting authentication.
40
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
41
+ */
42
+ connect(): Promise<void>;
43
+ /**
44
+ * Checks if the signer is connected.
45
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
46
+ */
47
+ isConnected(): Promise<boolean>;
48
+ getNostrPublicKey(): Promise<ccc.Hex>;
49
+ signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
50
+ }
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nostr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;IA2B5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IA7BlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;OAOG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;IAKvF,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO;IAI3C,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOzD;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAUjB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB9B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAY/B,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAQrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;CAWrC"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NostrSigner = void 0;
4
+ const core_1 = require("@ckb-ccc/core");
5
+ const common_1 = require("@joyid/common");
6
+ const common_2 = require("../common");
7
+ const connectionsStorage_1 = require("../connectionsStorage");
8
+ /**
9
+ * Class representing a Nostr signer that extends SignerNostr from @ckb-ccc/core.
10
+ * @class
11
+ * @extends {ccc.SignerNostr}
12
+ */
13
+ class NostrSigner extends core_1.ccc.SignerNostr {
14
+ /**
15
+ * Ensures that the signer is connected and returns the connection.
16
+ * @private
17
+ * @throws Will throw an error if not connected.
18
+ * @returns {Connection} The current connection.
19
+ */
20
+ assertConnection() {
21
+ if (!this.isConnected() || !this.connection) {
22
+ throw new Error("Not connected");
23
+ }
24
+ return this.connection;
25
+ }
26
+ /**
27
+ * Creates an instance of NostrSigner.
28
+ * @param {ccc.Client} client - The client instance.
29
+ * @param {string} name - The name of the signer.
30
+ * @param {string} icon - The icon URL of the signer.
31
+ * @param {string} [appUri="https://app.joy.id"] - The application URI.
32
+ * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
33
+ */
34
+ constructor(client, name, icon, appUri = "https://app.joy.id", connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage()) {
35
+ super(client);
36
+ this.name = name;
37
+ this.icon = icon;
38
+ this.appUri = appUri;
39
+ this.connectionsRepo = connectionsRepo;
40
+ }
41
+ static isValidClient(client) {
42
+ return client.addressPrefix === "ckt";
43
+ }
44
+ async replaceClient(client) {
45
+ if (!NostrSigner.isValidClient(client)) {
46
+ return false;
47
+ }
48
+ return super.replaceClient(client);
49
+ }
50
+ /**
51
+ * Gets the configuration for JoyID.
52
+ * @private
53
+ * @returns {object} The configuration object.
54
+ */
55
+ getConfig() {
56
+ return {
57
+ redirectURL: location.href,
58
+ joyidAppURL: this.appUri,
59
+ requestNetwork: "nostr",
60
+ name: this.name,
61
+ logo: this.icon,
62
+ };
63
+ }
64
+ /**
65
+ * Connects to the provider by requesting authentication.
66
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
67
+ */
68
+ async connect() {
69
+ const config = this.getConfig();
70
+ const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
71
+ ...config,
72
+ type: common_1.DappRequestType.Auth,
73
+ });
74
+ this.connection = {
75
+ address: "",
76
+ publicKey: core_1.ccc.hexFrom(res.nostrPubkey),
77
+ keyType: res.keyType,
78
+ };
79
+ await this.connectionsRepo.set({ uri: this.appUri, addressType: "nostr" }, this.connection);
80
+ }
81
+ /**
82
+ * Checks if the signer is connected.
83
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
84
+ */
85
+ async isConnected() {
86
+ if (this.connection) {
87
+ return true;
88
+ }
89
+ this.connection = await this.connectionsRepo.get({
90
+ uri: this.appUri,
91
+ addressType: "nostr",
92
+ });
93
+ return this.connection !== undefined;
94
+ }
95
+ async getNostrPublicKey() {
96
+ if (!this.connection) {
97
+ throw new Error("Not connected");
98
+ }
99
+ return this.connection.publicKey;
100
+ }
101
+ async signNostrEvent(event) {
102
+ const config = this.getConfig();
103
+ const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({ ...config, event }, "popup", "/sign-nostr-event"), {
104
+ ...config,
105
+ type: common_1.DappRequestType.SignNostrEvent,
106
+ });
107
+ return res.event;
108
+ }
109
+ }
110
+ exports.NostrSigner = NostrSigner;
@@ -1,3 +1,12 @@
1
1
  import { ccc } from "@ckb-ccc/core";
2
+ /**
3
+ * Gets the JoyID signers based on the client, name, and icon.
4
+ * If the browser is standalone or a webview, returns SignerAlwaysError instances.
5
+ * Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
6
+ * @param {ccc.Client} client - The client instance.
7
+ * @param {string} name - The name of the signer.
8
+ * @param {string} icon - The icon URL of the signer.
9
+ * @returns {ccc.SignerInfo[]} An array of signer information objects.
10
+ */
2
11
  export declare function getJoyIdSigners(client: ccc.Client, name: string, icon: string): ccc.SignerInfo[];
3
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,UAAU,EAAE,CA2BlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,UAAU,EAAE,CAwClB"}
@@ -1,13 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJoyIdSigners = void 0;
4
+ const core_1 = require("@ckb-ccc/core");
4
5
  const common_1 = require("@joyid/common");
5
6
  const btc_1 = require("../btc");
6
7
  const ckb_1 = require("../ckb");
7
8
  const evm_1 = require("../evm");
9
+ const nostr_1 = require("../nostr");
10
+ /**
11
+ * Gets the JoyID signers based on the client, name, and icon.
12
+ * If the browser is standalone or a webview, returns SignerAlwaysError instances.
13
+ * Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
14
+ * @param {ccc.Client} client - The client instance.
15
+ * @param {string} name - The name of the signer.
16
+ * @param {string} icon - The icon URL of the signer.
17
+ * @returns {ccc.SignerInfo[]} An array of signer information objects.
18
+ */
8
19
  function getJoyIdSigners(client, name, icon) {
9
- if ((0, common_1.isStandaloneBrowser)()) {
10
- return [];
20
+ if ((0, common_1.isStandaloneBrowser)() || core_1.ccc.isWebview(window.navigator.userAgent)) {
21
+ return [core_1.ccc.SignerType.CKB, core_1.ccc.SignerType.EVM, core_1.ccc.SignerType.BTC].map((type) => ({
22
+ name: type,
23
+ signer: new core_1.ccc.SignerAlwaysError(client, type, "JoyID can only be used with standard browsers"),
24
+ }));
11
25
  }
12
26
  return [
13
27
  {
@@ -18,6 +32,10 @@ function getJoyIdSigners(client, name, icon) {
18
32
  name: "BTC",
19
33
  signer: new btc_1.BitcoinSigner(client, name, icon),
20
34
  },
35
+ {
36
+ name: "Nostr",
37
+ signer: new nostr_1.NostrSigner(client, name, icon),
38
+ },
21
39
  {
22
40
  name: "EVM",
23
41
  signer: new evm_1.EvmSigner(client, name, icon),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/joy-id",
3
- "version": "0.0.5-alpha.7",
3
+ "version": "0.0.6-alpha.0",
4
4
  "description": "Connector's support for JoyID",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -38,9 +38,9 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@ckb-ccc/core": "0.0.5-alpha.2",
41
+ "@ckb-ccc/core": "0.0.6-alpha.0",
42
42
  "@joyid/ckb": "^0.0.11",
43
43
  "@joyid/common": "^0.0.3"
44
44
  },
45
- "gitHead": "efbdcebedb8375237b3dd98be358ca7df9765cfd"
45
+ "gitHead": "2cbb4f450ed88e773a353a13ad006dbe6208f67f"
46
46
  }
package/src/btc/index.ts CHANGED
@@ -7,10 +7,21 @@ import {
7
7
  ConnectionsRepoLocalStorage,
8
8
  } from "../connectionsStorage";
9
9
 
10
+ /**
11
+ * Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
12
+ * @class
13
+ * @extends {ccc.SignerBtc}
14
+ */
10
15
  export class BitcoinSigner extends ccc.SignerBtc {
11
16
  private connection?: Connection;
12
17
 
13
- private assertConnection() {
18
+ /**
19
+ * Ensures that the signer is connected and returns the connection.
20
+ * @private
21
+ * @throws Will throw an error if not connected.
22
+ * @returns {Connection} The current connection.
23
+ */
24
+ private assertConnection(): Connection {
14
25
  if (!this.isConnected() || !this.connection) {
15
26
  throw new Error("Not connected");
16
27
  }
@@ -18,6 +29,15 @@ export class BitcoinSigner extends ccc.SignerBtc {
18
29
  return this.connection;
19
30
  }
20
31
 
32
+ /**
33
+ * Creates an instance of BitcoinSigner.
34
+ * @param {ccc.Client} client - The client instance.
35
+ * @param {string} name - The name of the signer.
36
+ * @param {string} icon - The icon URL of the signer.
37
+ * @param {"auto" | "p2wpkh" | "p2tr"} [addressType="auto"] - The address type.
38
+ * @param {string} [appUri="https://app.joy.id"] - The application URI.
39
+ * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
40
+ */
21
41
  constructor(
22
42
  client: ccc.Client,
23
43
  private readonly name: string,
@@ -29,17 +49,11 @@ export class BitcoinSigner extends ccc.SignerBtc {
29
49
  super(client);
30
50
  }
31
51
 
32
- async replaceClient(client: ccc.Client): Promise<BitcoinSigner> {
33
- return new BitcoinSigner(
34
- client,
35
- this.name,
36
- this.icon,
37
- this.addressType,
38
- this.appUri,
39
- this.connectionsRepo,
40
- );
41
- }
42
-
52
+ /**
53
+ * Gets the configuration for JoyID.
54
+ * @private
55
+ * @returns {object} The configuration object.
56
+ */
43
57
  private getConfig() {
44
58
  return {
45
59
  redirectURL: location.href,
@@ -50,16 +64,28 @@ export class BitcoinSigner extends ccc.SignerBtc {
50
64
  };
51
65
  }
52
66
 
67
+ /**
68
+ * Gets the Bitcoin account address.
69
+ * @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
70
+ */
53
71
  async getBtcAccount(): Promise<string> {
54
72
  const { address } = this.assertConnection();
55
73
  return address;
56
74
  }
57
75
 
76
+ /**
77
+ * Gets the Bitcoin public key.
78
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
79
+ */
58
80
  async getBtcPublicKey(): Promise<ccc.Hex> {
59
81
  const { publicKey } = this.assertConnection();
60
82
  return publicKey;
61
83
  }
62
84
 
85
+ /**
86
+ * Connects to the provider by requesting authentication.
87
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
88
+ */
63
89
  async connect(): Promise<void> {
64
90
  const config = this.getConfig();
65
91
  const res = await createPopup(buildJoyIDURL(config, "popup", "/auth"), {
@@ -91,6 +117,10 @@ export class BitcoinSigner extends ccc.SignerBtc {
91
117
  ]);
92
118
  }
93
119
 
120
+ /**
121
+ * Checks if the signer is connected.
122
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
123
+ */
94
124
  async isConnected(): Promise<boolean> {
95
125
  if (this.connection) {
96
126
  return true;
@@ -103,6 +133,11 @@ export class BitcoinSigner extends ccc.SignerBtc {
103
133
  return this.connection !== undefined;
104
134
  }
105
135
 
136
+ /**
137
+ * Signs a raw message with the Bitcoin account.
138
+ * @param {string | ccc.BytesLike} message - The message to sign.
139
+ * @returns {Promise<string>} A promise that resolves to the signed message.
140
+ */
106
141
  async signMessageRaw(message: string | ccc.BytesLike): Promise<string> {
107
142
  const { address } = this.assertConnection();
108
143