@ckb-ccc/joy-id 0.0.12-alpha.1 → 0.0.12

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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +5 -5
  3. package/dist/btc/index.d.ts +9 -12
  4. package/dist/btc/index.d.ts.map +1 -1
  5. package/dist/btc/index.js +9 -12
  6. package/dist/ckb/index.d.ts +26 -33
  7. package/dist/ckb/index.d.ts.map +1 -1
  8. package/dist/ckb/index.js +26 -33
  9. package/dist/common/index.d.ts +3 -4
  10. package/dist/common/index.d.ts.map +1 -1
  11. package/dist/common/index.js +3 -3
  12. package/dist/connectionsStorage/index.d.ts +31 -26
  13. package/dist/connectionsStorage/index.d.ts.map +1 -1
  14. package/dist/connectionsStorage/index.js +11 -13
  15. package/dist/evm/index.d.ts +11 -16
  16. package/dist/evm/index.d.ts.map +1 -1
  17. package/dist/evm/index.js +11 -16
  18. package/dist/nostr/index.d.ts +9 -14
  19. package/dist/nostr/index.d.ts.map +1 -1
  20. package/dist/nostr/index.js +9 -14
  21. package/dist/signerFactory/index.d.ts +6 -4
  22. package/dist/signerFactory/index.d.ts.map +1 -1
  23. package/dist/signerFactory/index.js +6 -4
  24. package/dist.commonjs/btc/index.d.ts +9 -12
  25. package/dist.commonjs/btc/index.d.ts.map +1 -1
  26. package/dist.commonjs/btc/index.js +9 -12
  27. package/dist.commonjs/ckb/index.d.ts +26 -33
  28. package/dist.commonjs/ckb/index.d.ts.map +1 -1
  29. package/dist.commonjs/ckb/index.js +26 -33
  30. package/dist.commonjs/common/index.d.ts +3 -4
  31. package/dist.commonjs/common/index.d.ts.map +1 -1
  32. package/dist.commonjs/common/index.js +3 -3
  33. package/dist.commonjs/connectionsStorage/index.d.ts +31 -26
  34. package/dist.commonjs/connectionsStorage/index.d.ts.map +1 -1
  35. package/dist.commonjs/connectionsStorage/index.js +11 -13
  36. package/dist.commonjs/evm/index.d.ts +11 -16
  37. package/dist.commonjs/evm/index.d.ts.map +1 -1
  38. package/dist.commonjs/evm/index.js +11 -16
  39. package/dist.commonjs/nostr/index.d.ts +9 -14
  40. package/dist.commonjs/nostr/index.d.ts.map +1 -1
  41. package/dist.commonjs/nostr/index.js +9 -14
  42. package/dist.commonjs/signerFactory/index.d.ts +6 -4
  43. package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
  44. package/dist.commonjs/signerFactory/index.js +6 -4
  45. package/package.json +9 -10
  46. package/src/btc/index.ts +9 -12
  47. package/src/ckb/index.ts +26 -33
  48. package/src/common/index.ts +3 -4
  49. package/src/connectionsStorage/index.ts +31 -26
  50. package/src/evm/index.ts +11 -16
  51. package/src/nostr/index.ts +9 -14
  52. package/src/signerFactory/index.ts +6 -4
  53. package/typedoc.json +6 -0
@@ -18,7 +18,6 @@ import {
18
18
 
19
19
  /**
20
20
  * Interface representing the return type for various Dapp request types.
21
- * @interface
22
21
  */
23
22
  export interface PopupReturnType {
24
23
  [DappRequestType.Auth]: AuthResponseData;
@@ -42,9 +41,9 @@ export interface PopupReturnType {
42
41
 
43
42
  /**
44
43
  * Creates a popup window for JoyID Dapp requests.
45
- * @param {string} url - The URL to open in the popup.
46
- * @param {PopupConfigOptions<T> & { joyidAppURL: string }} config - The popup configuration options.
47
- * @returns {Promise<PopupReturnType[T]>} A promise that resolves to the response data of the requested type.
44
+ * @param url - The URL to open in the popup.
45
+ * @param config - The popup configuration options.
46
+ * @returns A promise that resolves to the response data of the requested type.
48
47
  * @throws {PopupNotSupportedError} If popups are not supported in the current browser.
49
48
  * @throws {PopupCancelledError} If the popup is closed by the user.
50
49
  * @throws {PopupTimeoutError} If the popup operation times out.
@@ -2,20 +2,23 @@ import { ccc } from "@ckb-ccc/core";
2
2
 
3
3
  /**
4
4
  * Type representing an account selector with a URI and address type.
5
- * @typedef {Object} AccountSelector
6
- * @property {string} uri - The URI of the account.
7
- * @property {string} addressType - The address type of the account.
8
5
  */
9
6
  export type AccountSelector = {
7
+ /**
8
+ * The URI of the account.
9
+ */
10
10
  uri: string;
11
+ /**
12
+ * The address type of the account.
13
+ */
11
14
  addressType: string;
12
15
  };
13
16
 
14
17
  /**
15
- * Checks if two AccountSelectors are equal.
16
- * @param {AccountSelector} a - The first account selector.
17
- * @param {AccountSelector} b - The second account selector.
18
- * @returns {boolean} True if the selectors are equal, false otherwise.
18
+ * Checks if a AccountSelector matches the filter
19
+ * @param a - The first account selector.
20
+ * @param filter - The account selector filter.
21
+ * @returns True if the selector matches the filter
19
22
  */
20
23
  export function isSelectorMatch(
21
24
  a: AccountSelector,
@@ -26,34 +29,38 @@ export function isSelectorMatch(
26
29
 
27
30
  /**
28
31
  * Type representing a connection with an address, public key, and key type.
29
- * @typedef {Object} Connection
30
- * @property {string} address - The address of the connection.
31
- * @property {ccc.Hex} publicKey - The public key of the connection.
32
- * @property {string} keyType - The key type of the connection.
33
32
  */
34
33
  export type Connection = {
34
+ /**
35
+ * The address of the connection.
36
+ */
35
37
  readonly address: string;
38
+ /**
39
+ * The public key of the connection.
40
+ */
36
41
  readonly publicKey: ccc.Hex;
42
+ /**
43
+ * The key type of the connection.
44
+ */
37
45
  readonly keyType: string;
38
46
  };
39
47
 
40
48
  /**
41
49
  * Interface representing a repository for managing connections.
42
- * @interface
43
50
  */
44
51
  export interface ConnectionsRepo {
45
52
  /**
46
53
  * Gets a connection for the given selector.
47
- * @param {AccountSelector} selector - The account selector.
48
- * @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
54
+ * @param selector - The account selector.
55
+ * @returns A promise that resolves to the connection, if found.
49
56
  */
50
57
  get(selector: AccountSelector): Promise<Connection | undefined>;
51
58
 
52
59
  /**
53
60
  * Sets a connection for the given selector.
54
- * @param {AccountSelector} selector - The account selector.
55
- * @param {Connection | undefined} connection - The connection to set.
56
- * @returns {Promise<void>} A promise that resolves when the connection is set.
61
+ * @param selector - The account selector.
62
+ * @param connection - The connection to set.
63
+ * @returns A promise that resolves when the connection is set.
57
64
  */
58
65
  set(
59
66
  selector: AccountSelector,
@@ -63,19 +70,17 @@ export interface ConnectionsRepo {
63
70
 
64
71
  /**
65
72
  * Class representing a local storage-based repository for managing connections.
66
- * @class
67
- * @implements {ConnectionsRepo}
68
73
  */
69
74
  export class ConnectionsRepoLocalStorage implements ConnectionsRepo {
70
75
  /**
71
76
  * Creates an instance of ConnectionsRepoLocalStorage.
72
- * @param {string} [storageKey="ccc-joy-id-signer"] - The local storage key.
77
+ * @param [storageKey="ccc-joy-id-signer"] - The local storage key.
73
78
  */
74
79
  constructor(private readonly storageKey = "ccc-joy-id-signer") {}
75
80
 
76
81
  /**
77
82
  * Reads all connections from local storage.
78
- * @returns {Promise<[AccountSelector, Connection][]>} A promise that resolves to an array of selectors and connections.
83
+ * @returns A promise that resolves to an array of selectors and connections.
79
84
  */
80
85
  async readConnections(): Promise<[AccountSelector, Connection][]> {
81
86
  return JSON.parse(window.localStorage.getItem(this.storageKey) ?? "[]");
@@ -83,8 +88,8 @@ export class ConnectionsRepoLocalStorage implements ConnectionsRepo {
83
88
 
84
89
  /**
85
90
  * Gets a connection for the given selector.
86
- * @param {AccountSelector} selector - The account selector.
87
- * @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
91
+ * @param selector - The account selector.
92
+ * @returns A promise that resolves to the connection, if found.
88
93
  */
89
94
  async get(selector: AccountSelector): Promise<Connection | undefined> {
90
95
  return (await this.readConnections()).find(([s]) =>
@@ -94,9 +99,9 @@ export class ConnectionsRepoLocalStorage implements ConnectionsRepo {
94
99
 
95
100
  /**
96
101
  * Sets a connection for the given selector.
97
- * @param {AccountSelector} selector - The account selector.
98
- * @param {Connection | undefined} connection - The connection to set.
99
- * @returns {Promise<void>}
102
+ * @param selector - The account selector.
103
+ * @param connection - The connection to set.
104
+ * @returns
100
105
  */
101
106
  async set(
102
107
  selector: AccountSelector,
package/src/evm/index.ts CHANGED
@@ -8,18 +8,16 @@ import {
8
8
  } from "../connectionsStorage/index.js";
9
9
 
10
10
  /**
11
- * Class representing an EVM signer that extends SignerEvm from @ckb-ccc/core.
12
- * @class
13
- * @extends {ccc.SignerEvm}
11
+ * Class representing an EVM signer that extends SignerEvm
12
+ * @public
14
13
  */
15
14
  export class EvmSigner extends ccc.SignerEvm {
16
15
  private connection?: Connection;
17
16
 
18
17
  /**
19
18
  * Ensures that the signer is connected and returns the connection.
20
- * @private
21
19
  * @throws Will throw an error if not connected.
22
- * @returns {Connection} The current connection.
20
+ * @returns The current connection.
23
21
  */
24
22
  private assertConnection(): Connection {
25
23
  if (!this.isConnected() || !this.connection) {
@@ -34,7 +32,7 @@ export class EvmSigner extends ccc.SignerEvm {
34
32
  * @param client - The client instance.
35
33
  * @param name - The name of the signer.
36
34
  * @param icon - The icon URL of the signer.
37
- * @param appUri - The application URI.
35
+ * @param _appUri - The application URI.
38
36
  * @param connectionsRepo - The connections repository.
39
37
  */
40
38
  constructor(
@@ -49,8 +47,7 @@ export class EvmSigner extends ccc.SignerEvm {
49
47
 
50
48
  /**
51
49
  * Gets the configuration for JoyID.
52
- * @private
53
- * @returns {object} The configuration object.
50
+ * @returns The configuration object.
54
51
  */
55
52
  private getConfig() {
56
53
  return {
@@ -75,7 +72,7 @@ export class EvmSigner extends ccc.SignerEvm {
75
72
 
76
73
  /**
77
74
  * Connects to the provider by requesting authentication.
78
- * @returns {Promise<void>} A promise that resolves when the connection is established.
75
+ * @returns A promise that resolves when the connection is established.
79
76
  */
80
77
  async connect(): Promise<void> {
81
78
  const config = this.getConfig();
@@ -102,7 +99,7 @@ export class EvmSigner extends ccc.SignerEvm {
102
99
 
103
100
  /**
104
101
  * Checks if the signer is connected.
105
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
102
+ * @returns A promise that resolves to true if connected, false otherwise.
106
103
  */
107
104
  async isConnected(): Promise<boolean> {
108
105
  if (this.connection) {
@@ -114,8 +111,8 @@ export class EvmSigner extends ccc.SignerEvm {
114
111
 
115
112
  /**
116
113
  * Signs a raw message with the EVM account.
117
- * @param {string | ccc.BytesLike} message - The message to sign.
118
- * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
114
+ * @param message - The message to sign.
115
+ * @returns A promise that resolves to the signed message.
119
116
  */
120
117
  async signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex> {
121
118
  const { address } = this.assertConnection();
@@ -142,8 +139,7 @@ export class EvmSigner extends ccc.SignerEvm {
142
139
 
143
140
  /**
144
141
  * Saves the current connection.
145
- * @private
146
- * @returns {Promise<void>}
142
+ * @returns
147
143
  */
148
144
  private async saveConnection(): Promise<void> {
149
145
  return this.connectionsRepo.set(
@@ -157,8 +153,7 @@ export class EvmSigner extends ccc.SignerEvm {
157
153
 
158
154
  /**
159
155
  * Restores the previous connection.
160
- * @private
161
- * @returns {Promise<void>}
156
+ * @returns
162
157
  */
163
158
  private async restoreConnection(): Promise<void> {
164
159
  this.connection = await this.connectionsRepo.get({
@@ -8,18 +8,16 @@ import {
8
8
  } from "../connectionsStorage/index.js";
9
9
 
10
10
  /**
11
- * Class representing a Nostr signer that extends SignerNostr from @ckb-ccc/core.
12
- * @class
13
- * @extends {ccc.SignerNostr}
11
+ * Class representing a Nostr signer that extends SignerNostr
12
+ * @public
14
13
  */
15
14
  export class NostrSigner extends ccc.SignerNostr {
16
15
  private connection?: Connection;
17
16
 
18
17
  /**
19
18
  * Ensures that the signer is connected and returns the connection.
20
- * @private
21
19
  * @throws Will throw an error if not connected.
22
- * @returns {Connection} The current connection.
20
+ * @returns The current connection.
23
21
  */
24
22
  private assertConnection(): Connection {
25
23
  if (!this.isConnected() || !this.connection) {
@@ -34,7 +32,7 @@ export class NostrSigner extends ccc.SignerNostr {
34
32
  * @param client - The client instance.
35
33
  * @param name - The name of the signer.
36
34
  * @param icon - The icon URL of the signer.
37
- * @param appUri - The application URI.
35
+ * @param _appUri - The application URI.
38
36
  * @param connectionsRepo - The connections repository.
39
37
  */
40
38
  constructor(
@@ -49,8 +47,7 @@ export class NostrSigner extends ccc.SignerNostr {
49
47
 
50
48
  /**
51
49
  * Gets the configuration for JoyID.
52
- * @private
53
- * @returns {object} The configuration object.
50
+ * @returns The configuration object.
54
51
  */
55
52
  private getConfig() {
56
53
  return {
@@ -67,7 +64,7 @@ export class NostrSigner extends ccc.SignerNostr {
67
64
 
68
65
  /**
69
66
  * Connects to the provider by requesting authentication.
70
- * @returns {Promise<void>} A promise that resolves when the connection is established.
67
+ * @returns A promise that resolves when the connection is established.
71
68
  */
72
69
  async connect(): Promise<void> {
73
70
  const config = this.getConfig();
@@ -93,7 +90,7 @@ export class NostrSigner extends ccc.SignerNostr {
93
90
 
94
91
  /**
95
92
  * Checks if the signer is connected.
96
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
93
+ * @returns A promise that resolves to true if connected, false otherwise.
97
94
  */
98
95
  async isConnected(): Promise<boolean> {
99
96
  if (this.connection) {
@@ -124,8 +121,7 @@ export class NostrSigner extends ccc.SignerNostr {
124
121
 
125
122
  /**
126
123
  * Saves the current connection.
127
- * @private
128
- * @returns {Promise<void>}
124
+ * @returns
129
125
  */
130
126
  private async saveConnection(): Promise<void> {
131
127
  return this.connectionsRepo.set(
@@ -139,8 +135,7 @@ export class NostrSigner extends ccc.SignerNostr {
139
135
 
140
136
  /**
141
137
  * Restores the previous connection.
142
- * @private
143
- * @returns {Promise<void>}
138
+ * @returns
144
139
  */
145
140
  private async restoreConnection(): Promise<void> {
146
141
  this.connection = await this.connectionsRepo.get({
@@ -9,10 +9,12 @@ import { NostrSigner } from "../nostr/index.js";
9
9
  * Gets the JoyID signers based on the client, name, and icon.
10
10
  * If the browser is standalone or a webview, returns SignerAlwaysError instances.
11
11
  * Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
12
- * @param {ccc.Client} client - The client instance.
13
- * @param {string} name - The name of the signer.
14
- * @param {string} icon - The icon URL of the signer.
15
- * @returns {ccc.SignerInfo[]} An array of signer information objects.
12
+ * @public
13
+ *
14
+ * @param client - The client instance.
15
+ * @param name - The name of the signer.
16
+ * @param icon - The icon URL of the signer.
17
+ * @returns An array of signer information objects.
16
18
  */
17
19
  export function getJoyIdSigners(
18
20
  client: ccc.Client,
package/typedoc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["./src/index.ts", "./src/advanced.ts"],
4
+ "extends": ["../../typedoc.base.json"],
5
+ "name": "@ckb-ccc joy-id"
6
+ }