@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.
- package/CHANGELOG.md +8 -0
- package/README.md +5 -5
- package/dist/btc/index.d.ts +9 -12
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +9 -12
- package/dist/ckb/index.d.ts +26 -33
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +26 -33
- package/dist/common/index.d.ts +3 -4
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -3
- package/dist/connectionsStorage/index.d.ts +31 -26
- package/dist/connectionsStorage/index.d.ts.map +1 -1
- package/dist/connectionsStorage/index.js +11 -13
- package/dist/evm/index.d.ts +11 -16
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +11 -16
- package/dist/nostr/index.d.ts +9 -14
- package/dist/nostr/index.d.ts.map +1 -1
- package/dist/nostr/index.js +9 -14
- package/dist/signerFactory/index.d.ts +6 -4
- package/dist/signerFactory/index.d.ts.map +1 -1
- package/dist/signerFactory/index.js +6 -4
- package/dist.commonjs/btc/index.d.ts +9 -12
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +9 -12
- package/dist.commonjs/ckb/index.d.ts +26 -33
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +26 -33
- package/dist.commonjs/common/index.d.ts +3 -4
- package/dist.commonjs/common/index.d.ts.map +1 -1
- package/dist.commonjs/common/index.js +3 -3
- package/dist.commonjs/connectionsStorage/index.d.ts +31 -26
- package/dist.commonjs/connectionsStorage/index.d.ts.map +1 -1
- package/dist.commonjs/connectionsStorage/index.js +11 -13
- package/dist.commonjs/evm/index.d.ts +11 -16
- package/dist.commonjs/evm/index.d.ts.map +1 -1
- package/dist.commonjs/evm/index.js +11 -16
- package/dist.commonjs/nostr/index.d.ts +9 -14
- package/dist.commonjs/nostr/index.d.ts.map +1 -1
- package/dist.commonjs/nostr/index.js +9 -14
- package/dist.commonjs/signerFactory/index.d.ts +6 -4
- package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
- package/dist.commonjs/signerFactory/index.js +6 -4
- package/package.json +9 -10
- package/src/btc/index.ts +9 -12
- package/src/ckb/index.ts +26 -33
- package/src/common/index.ts +3 -4
- package/src/connectionsStorage/index.ts +31 -26
- package/src/evm/index.ts +11 -16
- package/src/nostr/index.ts +9 -14
- package/src/signerFactory/index.ts +6 -4
- package/typedoc.json +6 -0
|
@@ -1,80 +1,85 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
3
|
* Type representing an account selector with a URI and address type.
|
|
4
|
-
* @typedef {Object} AccountSelector
|
|
5
|
-
* @property {string} uri - The URI of the account.
|
|
6
|
-
* @property {string} addressType - The address type of the account.
|
|
7
4
|
*/
|
|
8
5
|
export type AccountSelector = {
|
|
6
|
+
/**
|
|
7
|
+
* The URI of the account.
|
|
8
|
+
*/
|
|
9
9
|
uri: string;
|
|
10
|
+
/**
|
|
11
|
+
* The address type of the account.
|
|
12
|
+
*/
|
|
10
13
|
addressType: string;
|
|
11
14
|
};
|
|
12
15
|
/**
|
|
13
|
-
* Checks if
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @returns
|
|
16
|
+
* Checks if a AccountSelector matches the filter
|
|
17
|
+
* @param a - The first account selector.
|
|
18
|
+
* @param filter - The account selector filter.
|
|
19
|
+
* @returns True if the selector matches the filter
|
|
17
20
|
*/
|
|
18
21
|
export declare function isSelectorMatch(a: AccountSelector, filter: AccountSelector): boolean;
|
|
19
22
|
/**
|
|
20
23
|
* Type representing a connection with an address, public key, and key type.
|
|
21
|
-
* @typedef {Object} Connection
|
|
22
|
-
* @property {string} address - The address of the connection.
|
|
23
|
-
* @property {ccc.Hex} publicKey - The public key of the connection.
|
|
24
|
-
* @property {string} keyType - The key type of the connection.
|
|
25
24
|
*/
|
|
26
25
|
export type Connection = {
|
|
26
|
+
/**
|
|
27
|
+
* The address of the connection.
|
|
28
|
+
*/
|
|
27
29
|
readonly address: string;
|
|
30
|
+
/**
|
|
31
|
+
* The public key of the connection.
|
|
32
|
+
*/
|
|
28
33
|
readonly publicKey: ccc.Hex;
|
|
34
|
+
/**
|
|
35
|
+
* The key type of the connection.
|
|
36
|
+
*/
|
|
29
37
|
readonly keyType: string;
|
|
30
38
|
};
|
|
31
39
|
/**
|
|
32
40
|
* Interface representing a repository for managing connections.
|
|
33
|
-
* @interface
|
|
34
41
|
*/
|
|
35
42
|
export interface ConnectionsRepo {
|
|
36
43
|
/**
|
|
37
44
|
* Gets a connection for the given selector.
|
|
38
|
-
* @param
|
|
39
|
-
* @returns
|
|
45
|
+
* @param selector - The account selector.
|
|
46
|
+
* @returns A promise that resolves to the connection, if found.
|
|
40
47
|
*/
|
|
41
48
|
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
42
49
|
/**
|
|
43
50
|
* Sets a connection for the given selector.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @returns
|
|
51
|
+
* @param selector - The account selector.
|
|
52
|
+
* @param connection - The connection to set.
|
|
53
|
+
* @returns A promise that resolves when the connection is set.
|
|
47
54
|
*/
|
|
48
55
|
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
51
58
|
* Class representing a local storage-based repository for managing connections.
|
|
52
|
-
* @class
|
|
53
|
-
* @implements {ConnectionsRepo}
|
|
54
59
|
*/
|
|
55
60
|
export declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
56
61
|
private readonly storageKey;
|
|
57
62
|
/**
|
|
58
63
|
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
59
|
-
* @param
|
|
64
|
+
* @param [storageKey="ccc-joy-id-signer"] - The local storage key.
|
|
60
65
|
*/
|
|
61
66
|
constructor(storageKey?: string);
|
|
62
67
|
/**
|
|
63
68
|
* Reads all connections from local storage.
|
|
64
|
-
* @returns
|
|
69
|
+
* @returns A promise that resolves to an array of selectors and connections.
|
|
65
70
|
*/
|
|
66
71
|
readConnections(): Promise<[AccountSelector, Connection][]>;
|
|
67
72
|
/**
|
|
68
73
|
* Gets a connection for the given selector.
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
74
|
+
* @param selector - The account selector.
|
|
75
|
+
* @returns A promise that resolves to the connection, if found.
|
|
71
76
|
*/
|
|
72
77
|
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
73
78
|
/**
|
|
74
79
|
* Sets a connection for the given selector.
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @returns
|
|
80
|
+
* @param selector - The account selector.
|
|
81
|
+
* @param connection - The connection to set.
|
|
82
|
+
* @returns
|
|
78
83
|
*/
|
|
79
84
|
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
80
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectionsStorage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectionsStorage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,eAAe,EAClB,MAAM,EAAE,eAAe,GACtB,OAAO,CAET;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,GAAG,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,GAAG,CACD,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IAKrD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC;;;OAGG;gBAC0B,UAAU,SAAsB;IAE7D;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC;IAIjE;;;;OAIG;IACG,GAAG,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAMrE;;;;;OAKG;IACG,GAAG,CACP,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,OAAO,CAAC,IAAI,CAAC;CAoBjB"}
|
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Checks if
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @returns
|
|
2
|
+
* Checks if a AccountSelector matches the filter
|
|
3
|
+
* @param a - The first account selector.
|
|
4
|
+
* @param filter - The account selector filter.
|
|
5
|
+
* @returns True if the selector matches the filter
|
|
6
6
|
*/
|
|
7
7
|
export function isSelectorMatch(a, filter) {
|
|
8
8
|
return a.uri === filter.uri && a.addressType.startsWith(filter.addressType);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Class representing a local storage-based repository for managing connections.
|
|
12
|
-
* @class
|
|
13
|
-
* @implements {ConnectionsRepo}
|
|
14
12
|
*/
|
|
15
13
|
export class ConnectionsRepoLocalStorage {
|
|
16
14
|
/**
|
|
17
15
|
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
18
|
-
* @param
|
|
16
|
+
* @param [storageKey="ccc-joy-id-signer"] - The local storage key.
|
|
19
17
|
*/
|
|
20
18
|
constructor(storageKey = "ccc-joy-id-signer") {
|
|
21
19
|
this.storageKey = storageKey;
|
|
22
20
|
}
|
|
23
21
|
/**
|
|
24
22
|
* Reads all connections from local storage.
|
|
25
|
-
* @returns
|
|
23
|
+
* @returns A promise that resolves to an array of selectors and connections.
|
|
26
24
|
*/
|
|
27
25
|
async readConnections() {
|
|
28
26
|
return JSON.parse(window.localStorage.getItem(this.storageKey) ?? "[]");
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
29
|
* Gets a connection for the given selector.
|
|
32
|
-
* @param
|
|
33
|
-
* @returns
|
|
30
|
+
* @param selector - The account selector.
|
|
31
|
+
* @returns A promise that resolves to the connection, if found.
|
|
34
32
|
*/
|
|
35
33
|
async get(selector) {
|
|
36
34
|
return (await this.readConnections()).find(([s]) => isSelectorMatch(selector, s))?.[1];
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Sets a connection for the given selector.
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
38
|
+
* @param selector - The account selector.
|
|
39
|
+
* @param connection - The connection to set.
|
|
40
|
+
* @returns
|
|
43
41
|
*/
|
|
44
42
|
async set(selector, connection) {
|
|
45
43
|
const connections = await this.readConnections();
|
package/dist/evm/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerEvm}
|
|
4
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class EvmSigner extends ccc.SignerEvm {
|
|
9
8
|
private readonly name;
|
|
@@ -13,9 +12,8 @@ export declare class EvmSigner extends ccc.SignerEvm {
|
|
|
13
12
|
private connection?;
|
|
14
13
|
/**
|
|
15
14
|
* Ensures that the signer is connected and returns the connection.
|
|
16
|
-
* @private
|
|
17
15
|
* @throws Will throw an error if not connected.
|
|
18
|
-
* @returns
|
|
16
|
+
* @returns The current connection.
|
|
19
17
|
*/
|
|
20
18
|
private assertConnection;
|
|
21
19
|
/**
|
|
@@ -23,14 +21,13 @@ export declare class EvmSigner extends ccc.SignerEvm {
|
|
|
23
21
|
* @param client - The client instance.
|
|
24
22
|
* @param name - The name of the signer.
|
|
25
23
|
* @param icon - The icon URL of the signer.
|
|
26
|
-
* @param
|
|
24
|
+
* @param _appUri - The application URI.
|
|
27
25
|
* @param connectionsRepo - The connections repository.
|
|
28
26
|
*/
|
|
29
27
|
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
30
28
|
/**
|
|
31
29
|
* Gets the configuration for JoyID.
|
|
32
|
-
* @
|
|
33
|
-
* @returns {object} The configuration object.
|
|
30
|
+
* @returns The configuration object.
|
|
34
31
|
*/
|
|
35
32
|
private getConfig;
|
|
36
33
|
/**
|
|
@@ -40,31 +37,29 @@ export declare class EvmSigner extends ccc.SignerEvm {
|
|
|
40
37
|
getEvmAccount(): Promise<ccc.Hex>;
|
|
41
38
|
/**
|
|
42
39
|
* Connects to the provider by requesting authentication.
|
|
43
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves when the connection is established.
|
|
44
41
|
*/
|
|
45
42
|
connect(): Promise<void>;
|
|
46
43
|
disconnect(): Promise<void>;
|
|
47
44
|
/**
|
|
48
45
|
* Checks if the signer is connected.
|
|
49
|
-
* @returns
|
|
46
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
50
47
|
*/
|
|
51
48
|
isConnected(): Promise<boolean>;
|
|
52
49
|
/**
|
|
53
50
|
* Signs a raw message with the EVM account.
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
51
|
+
* @param message - The message to sign.
|
|
52
|
+
* @returns A promise that resolves to the signed message.
|
|
56
53
|
*/
|
|
57
54
|
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
58
55
|
/**
|
|
59
56
|
* Saves the current connection.
|
|
60
|
-
* @
|
|
61
|
-
* @returns {Promise<void>}
|
|
57
|
+
* @returns
|
|
62
58
|
*/
|
|
63
59
|
private saveConnection;
|
|
64
60
|
/**
|
|
65
61
|
* Restores the previous connection.
|
|
66
|
-
* @
|
|
67
|
-
* @returns {Promise<void>}
|
|
62
|
+
* @returns
|
|
68
63
|
*/
|
|
69
64
|
private restoreConnection;
|
|
70
65
|
}
|
package/dist/evm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;IA0BxC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IA5BlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;OAOG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,oBAAQ,EAChB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IAajB;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAIvC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAuBvE;;;OAGG;YACW,cAAc;IAU5B;;;OAGG;YACW,iBAAiB;CAMhC"}
|
package/dist/evm/index.js
CHANGED
|
@@ -3,16 +3,14 @@ import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
|
3
3
|
import { createPopup } from "../common/index.js";
|
|
4
4
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage/index.js";
|
|
5
5
|
/**
|
|
6
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
7
|
-
* @
|
|
8
|
-
* @extends {ccc.SignerEvm}
|
|
6
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
9
|
export class EvmSigner extends ccc.SignerEvm {
|
|
11
10
|
/**
|
|
12
11
|
* Ensures that the signer is connected and returns the connection.
|
|
13
|
-
* @private
|
|
14
12
|
* @throws Will throw an error if not connected.
|
|
15
|
-
* @returns
|
|
13
|
+
* @returns The current connection.
|
|
16
14
|
*/
|
|
17
15
|
assertConnection() {
|
|
18
16
|
if (!this.isConnected() || !this.connection) {
|
|
@@ -25,7 +23,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
25
23
|
* @param client - The client instance.
|
|
26
24
|
* @param name - The name of the signer.
|
|
27
25
|
* @param icon - The icon URL of the signer.
|
|
28
|
-
* @param
|
|
26
|
+
* @param _appUri - The application URI.
|
|
29
27
|
* @param connectionsRepo - The connections repository.
|
|
30
28
|
*/
|
|
31
29
|
constructor(client, name, icon, _appUri, connectionsRepo = new ConnectionsRepoLocalStorage()) {
|
|
@@ -37,8 +35,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Gets the configuration for JoyID.
|
|
40
|
-
* @
|
|
41
|
-
* @returns {object} The configuration object.
|
|
38
|
+
* @returns The configuration object.
|
|
42
39
|
*/
|
|
43
40
|
getConfig() {
|
|
44
41
|
return {
|
|
@@ -60,7 +57,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
60
57
|
}
|
|
61
58
|
/**
|
|
62
59
|
* Connects to the provider by requesting authentication.
|
|
63
|
-
* @returns
|
|
60
|
+
* @returns A promise that resolves when the connection is established.
|
|
64
61
|
*/
|
|
65
62
|
async connect() {
|
|
66
63
|
const config = this.getConfig();
|
|
@@ -82,7 +79,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
82
79
|
}
|
|
83
80
|
/**
|
|
84
81
|
* Checks if the signer is connected.
|
|
85
|
-
* @returns
|
|
82
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
86
83
|
*/
|
|
87
84
|
async isConnected() {
|
|
88
85
|
if (this.connection) {
|
|
@@ -93,8 +90,8 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
92
|
* Signs a raw message with the EVM account.
|
|
96
|
-
* @param
|
|
97
|
-
* @returns
|
|
93
|
+
* @param message - The message to sign.
|
|
94
|
+
* @returns A promise that resolves to the signed message.
|
|
98
95
|
*/
|
|
99
96
|
async signMessageRaw(message) {
|
|
100
97
|
const { address } = this.assertConnection();
|
|
@@ -110,8 +107,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
110
107
|
}
|
|
111
108
|
/**
|
|
112
109
|
* Saves the current connection.
|
|
113
|
-
* @
|
|
114
|
-
* @returns {Promise<void>}
|
|
110
|
+
* @returns
|
|
115
111
|
*/
|
|
116
112
|
async saveConnection() {
|
|
117
113
|
return this.connectionsRepo.set({
|
|
@@ -121,8 +117,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
121
117
|
}
|
|
122
118
|
/**
|
|
123
119
|
* Restores the previous connection.
|
|
124
|
-
* @
|
|
125
|
-
* @returns {Promise<void>}
|
|
120
|
+
* @returns
|
|
126
121
|
*/
|
|
127
122
|
async restoreConnection() {
|
|
128
123
|
this.connection = await this.connectionsRepo.get({
|
package/dist/nostr/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing a Nostr signer that extends SignerNostr
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerNostr}
|
|
4
|
+
* Class representing a Nostr signer that extends SignerNostr
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class NostrSigner extends ccc.SignerNostr {
|
|
9
8
|
private readonly name;
|
|
@@ -13,9 +12,8 @@ export declare class NostrSigner extends ccc.SignerNostr {
|
|
|
13
12
|
private connection?;
|
|
14
13
|
/**
|
|
15
14
|
* Ensures that the signer is connected and returns the connection.
|
|
16
|
-
* @private
|
|
17
15
|
* @throws Will throw an error if not connected.
|
|
18
|
-
* @returns
|
|
16
|
+
* @returns The current connection.
|
|
19
17
|
*/
|
|
20
18
|
private assertConnection;
|
|
21
19
|
/**
|
|
@@ -23,39 +21,36 @@ export declare class NostrSigner extends ccc.SignerNostr {
|
|
|
23
21
|
* @param client - The client instance.
|
|
24
22
|
* @param name - The name of the signer.
|
|
25
23
|
* @param icon - The icon URL of the signer.
|
|
26
|
-
* @param
|
|
24
|
+
* @param _appUri - The application URI.
|
|
27
25
|
* @param connectionsRepo - The connections repository.
|
|
28
26
|
*/
|
|
29
27
|
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
30
28
|
/**
|
|
31
29
|
* Gets the configuration for JoyID.
|
|
32
|
-
* @
|
|
33
|
-
* @returns {object} The configuration object.
|
|
30
|
+
* @returns The configuration object.
|
|
34
31
|
*/
|
|
35
32
|
private getConfig;
|
|
36
33
|
/**
|
|
37
34
|
* Connects to the provider by requesting authentication.
|
|
38
|
-
* @returns
|
|
35
|
+
* @returns A promise that resolves when the connection is established.
|
|
39
36
|
*/
|
|
40
37
|
connect(): Promise<void>;
|
|
41
38
|
disconnect(): Promise<void>;
|
|
42
39
|
/**
|
|
43
40
|
* Checks if the signer is connected.
|
|
44
|
-
* @returns
|
|
41
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
45
42
|
*/
|
|
46
43
|
isConnected(): Promise<boolean>;
|
|
47
44
|
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
48
45
|
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
49
46
|
/**
|
|
50
47
|
* Saves the current connection.
|
|
51
|
-
* @
|
|
52
|
-
* @returns {Promise<void>}
|
|
48
|
+
* @returns
|
|
53
49
|
*/
|
|
54
50
|
private saveConnection;
|
|
55
51
|
/**
|
|
56
52
|
* Restores the previous connection.
|
|
57
|
-
* @
|
|
58
|
-
* @returns {Promise<void>}
|
|
53
|
+
* @returns
|
|
59
54
|
*/
|
|
60
55
|
private restoreConnection;
|
|
61
56
|
}
|
|
@@ -1 +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,gCAAgC,CAAC;AAExC
|
|
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,gCAAgC,CAAC;AAExC;;;GAGG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;IA0B5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IA5BlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;OAOG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,oBAAQ,EAChB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IAajB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAexB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAS/B,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAIrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAYpC;;;OAGG;YACW,cAAc;IAU5B;;;OAGG;YACW,iBAAiB;CAMhC"}
|
package/dist/nostr/index.js
CHANGED
|
@@ -3,16 +3,14 @@ import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
|
3
3
|
import { createPopup } from "../common/index.js";
|
|
4
4
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage/index.js";
|
|
5
5
|
/**
|
|
6
|
-
* Class representing a Nostr signer that extends SignerNostr
|
|
7
|
-
* @
|
|
8
|
-
* @extends {ccc.SignerNostr}
|
|
6
|
+
* Class representing a Nostr signer that extends SignerNostr
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
9
|
export class NostrSigner extends ccc.SignerNostr {
|
|
11
10
|
/**
|
|
12
11
|
* Ensures that the signer is connected and returns the connection.
|
|
13
|
-
* @private
|
|
14
12
|
* @throws Will throw an error if not connected.
|
|
15
|
-
* @returns
|
|
13
|
+
* @returns The current connection.
|
|
16
14
|
*/
|
|
17
15
|
assertConnection() {
|
|
18
16
|
if (!this.isConnected() || !this.connection) {
|
|
@@ -25,7 +23,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
25
23
|
* @param client - The client instance.
|
|
26
24
|
* @param name - The name of the signer.
|
|
27
25
|
* @param icon - The icon URL of the signer.
|
|
28
|
-
* @param
|
|
26
|
+
* @param _appUri - The application URI.
|
|
29
27
|
* @param connectionsRepo - The connections repository.
|
|
30
28
|
*/
|
|
31
29
|
constructor(client, name, icon, _appUri, connectionsRepo = new ConnectionsRepoLocalStorage()) {
|
|
@@ -37,8 +35,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Gets the configuration for JoyID.
|
|
40
|
-
* @
|
|
41
|
-
* @returns {object} The configuration object.
|
|
38
|
+
* @returns The configuration object.
|
|
42
39
|
*/
|
|
43
40
|
getConfig() {
|
|
44
41
|
return {
|
|
@@ -53,7 +50,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
53
50
|
}
|
|
54
51
|
/**
|
|
55
52
|
* Connects to the provider by requesting authentication.
|
|
56
|
-
* @returns
|
|
53
|
+
* @returns A promise that resolves when the connection is established.
|
|
57
54
|
*/
|
|
58
55
|
async connect() {
|
|
59
56
|
const config = this.getConfig();
|
|
@@ -75,7 +72,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
75
72
|
}
|
|
76
73
|
/**
|
|
77
74
|
* Checks if the signer is connected.
|
|
78
|
-
* @returns
|
|
75
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
79
76
|
*/
|
|
80
77
|
async isConnected() {
|
|
81
78
|
if (this.connection) {
|
|
@@ -97,8 +94,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
97
94
|
}
|
|
98
95
|
/**
|
|
99
96
|
* Saves the current connection.
|
|
100
|
-
* @
|
|
101
|
-
* @returns {Promise<void>}
|
|
97
|
+
* @returns
|
|
102
98
|
*/
|
|
103
99
|
async saveConnection() {
|
|
104
100
|
return this.connectionsRepo.set({
|
|
@@ -108,8 +104,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
108
104
|
}
|
|
109
105
|
/**
|
|
110
106
|
* Restores the previous connection.
|
|
111
|
-
* @
|
|
112
|
-
* @returns {Promise<void>}
|
|
107
|
+
* @returns
|
|
113
108
|
*/
|
|
114
109
|
async restoreConnection() {
|
|
115
110
|
this.connection = await this.connectionsRepo.get({
|
|
@@ -3,10 +3,12 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
3
3
|
* Gets the JoyID signers based on the client, name, and icon.
|
|
4
4
|
* If the browser is standalone or a webview, returns SignerAlwaysError instances.
|
|
5
5
|
* Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
6
|
+
* @public
|
|
7
|
+
*
|
|
8
|
+
* @param client - The client instance.
|
|
9
|
+
* @param name - The name of the signer.
|
|
10
|
+
* @param icon - The icon URL of the signer.
|
|
11
|
+
* @returns An array of signer information objects.
|
|
10
12
|
*/
|
|
11
13
|
export declare function getJoyIdSigners(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[]): ccc.SignerInfo[];
|
|
12
14
|
//# 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;AAOpC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C,GAAG,CAAC,UAAU,EAAE,CA8ClB"}
|
|
@@ -8,10 +8,12 @@ import { NostrSigner } from "../nostr/index.js";
|
|
|
8
8
|
* Gets the JoyID signers based on the client, name, and icon.
|
|
9
9
|
* If the browser is standalone or a webview, returns SignerAlwaysError instances.
|
|
10
10
|
* Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
11
|
+
* @public
|
|
12
|
+
*
|
|
13
|
+
* @param client - The client instance.
|
|
14
|
+
* @param name - The name of the signer.
|
|
15
|
+
* @param icon - The icon URL of the signer.
|
|
16
|
+
* @returns An array of signer information objects.
|
|
15
17
|
*/
|
|
16
18
|
export function getJoyIdSigners(client, name, icon, preferredNetworks) {
|
|
17
19
|
if (isStandaloneBrowser() || ccc.isWebview(window.navigator.userAgent)) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerBtc}
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
9
8
|
readonly name: string;
|
|
@@ -16,9 +15,8 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
16
15
|
private network;
|
|
17
16
|
/**
|
|
18
17
|
* Ensures that the signer is connected and returns the connection.
|
|
19
|
-
* @private
|
|
20
18
|
* @throws Will throw an error if not connected.
|
|
21
|
-
* @returns
|
|
19
|
+
* @returns The current connection.
|
|
22
20
|
*/
|
|
23
21
|
private assertConnection;
|
|
24
22
|
/**
|
|
@@ -33,35 +31,34 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
33
31
|
constructor(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[], addressType?: "auto" | "p2wpkh" | "p2tr", _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
34
32
|
/**
|
|
35
33
|
* Gets the configuration for JoyID.
|
|
36
|
-
* @private
|
|
37
34
|
* @returns The configuration object.
|
|
38
35
|
*/
|
|
39
36
|
private getConfig;
|
|
40
37
|
disconnect(): Promise<void>;
|
|
41
38
|
/**
|
|
42
39
|
* Gets the Bitcoin account address.
|
|
43
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
44
41
|
*/
|
|
45
42
|
getBtcAccount(): Promise<string>;
|
|
46
43
|
/**
|
|
47
44
|
* Gets the Bitcoin public key.
|
|
48
|
-
* @returns
|
|
45
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
49
46
|
*/
|
|
50
47
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
51
48
|
/**
|
|
52
49
|
* Connects to the provider by requesting authentication.
|
|
53
|
-
* @returns
|
|
50
|
+
* @returns A promise that resolves when the connection is established.
|
|
54
51
|
*/
|
|
55
52
|
connect(): Promise<void>;
|
|
56
53
|
/**
|
|
57
54
|
* Checks if the signer is connected.
|
|
58
|
-
* @returns
|
|
55
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
59
56
|
*/
|
|
60
57
|
isConnected(): Promise<boolean>;
|
|
61
58
|
/**
|
|
62
59
|
* Signs a raw message with the Bitcoin account.
|
|
63
|
-
* @param
|
|
64
|
-
* @returns
|
|
60
|
+
* @param message - The message to sign.
|
|
61
|
+
* @returns A promise that resolves to the signed message.
|
|
65
62
|
*/
|
|
66
63
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
67
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aA4B5B,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;aAYlB,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IA3ClC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;OAQG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACX,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD,EACe,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAC/C,OAAO,CAAC,oBAAQ,EAChB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IA6BX,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAKzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBvE"}
|