@ckb-ccc/joy-id 1.0.32 → 1.1.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.
- package/CHANGELOG.md +29 -0
- package/dist/advanced.d.mts +2 -0
- package/dist/advanced.mjs +1 -0
- package/dist/advancedBarrel.d.mts +44 -0
- package/dist/advancedBarrel.d.mts.map +1 -0
- package/dist/advancedBarrel.mjs +2 -0
- package/dist/advancedBarrel.mjs.map +1 -0
- package/dist/barrel.d.mts +339 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +2 -0
- package/dist/barrel.mjs.map +1 -0
- package/dist/connectionsStorage-BloUSPun.mjs +2 -0
- package/dist/connectionsStorage-BloUSPun.mjs.map +1 -0
- package/dist/index-DGqAOLbu.d.mts +91 -0
- package/dist/index-DGqAOLbu.d.mts.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist.commonjs/advanced.d.ts +2 -2
- package/dist.commonjs/advanced.js +1 -37
- package/dist.commonjs/advancedBarrel.d.ts +43 -2
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/advancedBarrel.js +2 -18
- package/dist.commonjs/advancedBarrel.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +338 -5
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +2 -21
- package/dist.commonjs/barrel.js.map +1 -0
- package/dist.commonjs/connectionsStorage-CQE3XNWI.js +2 -0
- package/dist.commonjs/connectionsStorage-CQE3XNWI.js.map +1 -0
- package/dist.commonjs/index-CJeW3ePH.d.ts +93 -0
- package/dist.commonjs/index-CJeW3ePH.d.ts.map +1 -0
- package/dist.commonjs/index.d.ts +2 -2
- package/dist.commonjs/index.js +1 -37
- package/package.json +32 -20
- package/src/btc/index.ts +76 -0
- package/tsdown.config.mts +43 -0
- package/dist/advanced.d.ts +0 -2
- package/dist/advanced.d.ts.map +0 -1
- package/dist/advanced.js +0 -1
- package/dist/advancedBarrel.d.ts +0 -3
- package/dist/advancedBarrel.d.ts.map +0 -1
- package/dist/advancedBarrel.js +0 -2
- package/dist/barrel.d.ts +0 -6
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -5
- package/dist/btc/index.d.ts +0 -65
- package/dist/btc/index.d.ts.map +0 -1
- package/dist/btc/index.js +0 -153
- package/dist/ckb/index.d.ts +0 -117
- package/dist/ckb/index.d.ts.map +0 -1
- package/dist/ckb/index.js +0 -267
- package/dist/common/index.d.ts +0 -36
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js +0 -61
- package/dist/connectionsStorage/index.d.ts +0 -87
- package/dist/connectionsStorage/index.d.ts.map +0 -1
- package/dist/connectionsStorage/index.js +0 -65
- package/dist/evm/index.d.ts +0 -66
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js +0 -129
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/nostr/index.d.ts +0 -57
- package/dist/nostr/index.d.ts.map +0 -1
- package/dist/nostr/index.js +0 -116
- package/dist/signerFactory/index.d.ts +0 -14
- package/dist/signerFactory/index.d.ts.map +0 -1
- package/dist/signerFactory/index.js +0 -51
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/btc/index.d.ts +0 -65
- package/dist.commonjs/btc/index.d.ts.map +0 -1
- package/dist.commonjs/btc/index.js +0 -157
- package/dist.commonjs/ckb/index.d.ts +0 -117
- package/dist.commonjs/ckb/index.d.ts.map +0 -1
- package/dist.commonjs/ckb/index.js +0 -271
- package/dist.commonjs/common/index.d.ts +0 -36
- package/dist.commonjs/common/index.d.ts.map +0 -1
- package/dist.commonjs/common/index.js +0 -64
- package/dist.commonjs/connectionsStorage/index.d.ts +0 -87
- package/dist.commonjs/connectionsStorage/index.d.ts.map +0 -1
- package/dist.commonjs/connectionsStorage/index.js +0 -70
- package/dist.commonjs/evm/index.d.ts +0 -66
- package/dist.commonjs/evm/index.d.ts.map +0 -1
- package/dist.commonjs/evm/index.js +0 -133
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/nostr/index.d.ts +0 -57
- package/dist.commonjs/nostr/index.d.ts.map +0 -1
- package/dist.commonjs/nostr/index.js +0 -120
- package/dist.commonjs/signerFactory/index.d.ts +0 -14
- package/dist.commonjs/signerFactory/index.d.ts.map +0 -1
- package/dist.commonjs/signerFactory/index.js +0 -54
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
|
|
3
|
+
//#region src/connectionsStorage/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Type representing an account selector with a URI and address type.
|
|
6
|
+
*/
|
|
7
|
+
type AccountSelector = {
|
|
8
|
+
/**
|
|
9
|
+
* The URI of the account.
|
|
10
|
+
*/
|
|
11
|
+
uri: string;
|
|
12
|
+
/**
|
|
13
|
+
* The address type of the account.
|
|
14
|
+
*/
|
|
15
|
+
addressType: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
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
|
|
22
|
+
*/
|
|
23
|
+
declare function isSelectorMatch(a: AccountSelector, filter: AccountSelector): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Type representing a connection with an address, public key, and key type.
|
|
26
|
+
*/
|
|
27
|
+
type Connection = {
|
|
28
|
+
/**
|
|
29
|
+
* The address of the connection.
|
|
30
|
+
*/
|
|
31
|
+
readonly address: string;
|
|
32
|
+
/**
|
|
33
|
+
* The public key of the connection.
|
|
34
|
+
*/
|
|
35
|
+
readonly publicKey: ccc.Hex;
|
|
36
|
+
/**
|
|
37
|
+
* The key type of the connection.
|
|
38
|
+
*/
|
|
39
|
+
readonly keyType: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Interface representing a repository for managing connections.
|
|
43
|
+
*/
|
|
44
|
+
interface ConnectionsRepo {
|
|
45
|
+
/**
|
|
46
|
+
* Gets a connection for the given selector.
|
|
47
|
+
* @param selector - The account selector.
|
|
48
|
+
* @returns A promise that resolves to the connection, if found.
|
|
49
|
+
*/
|
|
50
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Sets a connection for the given selector.
|
|
53
|
+
* @param selector - The account selector.
|
|
54
|
+
* @param connection - The connection to set.
|
|
55
|
+
* @returns A promise that resolves when the connection is set.
|
|
56
|
+
*/
|
|
57
|
+
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Class representing a local storage-based repository for managing connections.
|
|
61
|
+
*/
|
|
62
|
+
declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
63
|
+
private readonly storageKey;
|
|
64
|
+
private operationLock;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
67
|
+
* @param [storageKey="ccc-joy-id-signer"] - The local storage key.
|
|
68
|
+
*/
|
|
69
|
+
constructor(storageKey?: string);
|
|
70
|
+
/**
|
|
71
|
+
* Reads all connections from local storage.
|
|
72
|
+
* @returns A promise that resolves to an array of selectors and connections.
|
|
73
|
+
*/
|
|
74
|
+
readConnections(): Promise<[AccountSelector, Connection][]>;
|
|
75
|
+
/**
|
|
76
|
+
* Gets a connection for the given selector.
|
|
77
|
+
* @param selector - The account selector.
|
|
78
|
+
* @returns A promise that resolves to the connection, if found.
|
|
79
|
+
*/
|
|
80
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* Sets a connection for the given selector.
|
|
83
|
+
* @param selector - The account selector.
|
|
84
|
+
* @param connection - The connection to set.
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { isSelectorMatch as a, ConnectionsRepoLocalStorage as i, Connection as n, ConnectionsRepo as r, AccountSelector as t };
|
|
91
|
+
//# sourceMappingURL=index-DGqAOLbu.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DGqAOLbu.d.mts","names":[],"sources":["../src/connectionsStorage/index.ts"],"mappings":";;;;;AAKA;KAAY,eAAA;;;AAQC;EAJX,GAAA;EAa6B;;;EAT7B,WAAW;AAAA;;;;AAWY;AAQzB;;iBAVgB,eAAA,CACd,CAAA,EAAG,eAAA,EACH,MAAA,EAAQ,eAAe;;;;KAQb,UAAA;EAQc;;;EAAA,SAJf,OAAA;EAcM;;;EAAA,SAVN,SAAA,EAAW,GAAA,CAAI,GAAG;EAgBa;;;EAAA,SAZ/B,OAAA;AAAA;;;;UAMM,eAAA;EAMX;;;;;EAAJ,GAAA,CAAI,QAAA,EAAU,eAAA,GAAkB,OAAA,CAAQ,UAAA;EAU1B;;;;AACJ;AAMZ;EATE,GAAA,CACE,QAAA,EAAU,eAAA,EACV,UAAA,EAAY,UAAA,eACX,OAAA;AAAA;;;;cAMQ,2BAAA,YAAuC,eAAA;EAAA,iBAOrB,UAAA;EAAA,QANrB,aAAA;EAqCI;;;;cA/BiB,UAAA;EAPoC;;;;EAa3D,eAAA,IAAmB,OAAA,EAAS,eAAA,EAAiB,UAAA;EANtB;;;;;EAkBvB,GAAA,CAAI,QAAA,EAAU,eAAA,GAAkB,OAAA,CAAQ,UAAA;EAA1B;;;;;;EAYd,GAAA,CACJ,QAAA,EAAU,eAAA,EACV,UAAA,EAAY,UAAA,eACX,OAAA;AAAA"}
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./barrel.mjs";export{e as JoyId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as advancedBarrel_d_exports } from "./advancedBarrel.js";
|
|
2
|
+
export { advancedBarrel_d_exports as JoyIdA };
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.JoyIdA = void 0;
|
|
37
|
-
exports.JoyIdA = __importStar(require("./advancedBarrel.js"));
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./advancedBarrel.js");Object.defineProperty(exports,"JoyIdA",{enumerable:!0,get:function(){return e.t}});
|
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { a as isSelectorMatch, i as ConnectionsRepoLocalStorage, n as Connection, o as __exportAll, r as ConnectionsRepo, t as AccountSelector } from "./index-CJeW3ePH.js";
|
|
2
|
+
import { AuthResponseData, DappRequestType, EvmWeb2LoginResponse, PopupConfigOptions, SignCkbTxResponseData, SignCotaNFTResponseData, SignEvmTxResponseData, SignMessageResponseData, SignNostrEventData } from "@joyid/common";
|
|
3
|
+
|
|
4
|
+
//#region src/common/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing the return type for various Dapp request types.
|
|
7
|
+
*/
|
|
8
|
+
interface PopupReturnType {
|
|
9
|
+
[DappRequestType.Auth]: AuthResponseData;
|
|
10
|
+
[DappRequestType.SignMessage]: SignMessageResponseData;
|
|
11
|
+
[DappRequestType.SignEvm]: SignEvmTxResponseData;
|
|
12
|
+
[DappRequestType.SignPsbt]: SignEvmTxResponseData;
|
|
13
|
+
[DappRequestType.BatchSignPsbt]: {
|
|
14
|
+
psbts: string[];
|
|
15
|
+
};
|
|
16
|
+
[DappRequestType.SignCkbTx]: SignCkbTxResponseData;
|
|
17
|
+
[DappRequestType.SignCotaNFT]: SignCotaNFTResponseData;
|
|
18
|
+
[DappRequestType.SignCkbRawTx]: SignCkbTxResponseData;
|
|
19
|
+
[DappRequestType.SignNostrEvent]: SignNostrEventData;
|
|
20
|
+
[DappRequestType.EncryptNostrMessage]: unknown;
|
|
21
|
+
[DappRequestType.DecryptNostrMessage]: unknown;
|
|
22
|
+
[DappRequestType.AuthMiniApp]: unknown;
|
|
23
|
+
[DappRequestType.SignMiniAppEvm]: unknown;
|
|
24
|
+
[DappRequestType.SignMiniAppMessage]: unknown;
|
|
25
|
+
[DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a popup window for JoyID Dapp requests.
|
|
29
|
+
* @param url - The URL to open in the popup.
|
|
30
|
+
* @param config - The popup configuration options.
|
|
31
|
+
* @returns A promise that resolves to the response data of the requested type.
|
|
32
|
+
* @throws {PopupNotSupportedError} If popups are not supported in the current browser.
|
|
33
|
+
* @throws {PopupCancelledError} If the popup is closed by the user.
|
|
34
|
+
* @throws {PopupTimeoutError} If the popup operation times out.
|
|
35
|
+
*/
|
|
36
|
+
declare function createPopup<T extends DappRequestType>(url: string, config: PopupConfigOptions<T> & {
|
|
37
|
+
joyidAppURL: string;
|
|
38
|
+
}): Promise<PopupReturnType[T]>;
|
|
39
|
+
declare namespace advancedBarrel_d_exports {
|
|
40
|
+
export { AccountSelector, Connection, ConnectionsRepo, ConnectionsRepoLocalStorage, PopupReturnType, createPopup, isSelectorMatch };
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { AccountSelector, Connection, ConnectionsRepo, ConnectionsRepoLocalStorage, PopupReturnType, createPopup, isSelectorMatch, advancedBarrel_d_exports as t };
|
|
3
44
|
//# sourceMappingURL=advancedBarrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","names":[],"sources":["../src/common/index.ts","../src/advancedBarrel.ts"],"mappings":";;;;;;;UAuBiB,eAAA;EAAA,CACd,eAAA,CAAgB,IAAA,GAAO,gBAAA;EAAA,CACvB,eAAA,CAAgB,WAAA,GAAc,uBAAA;EAAA,CAC9B,eAAA,CAAgB,OAAA,GAAU,qBAAA;EAAA,CAC1B,eAAA,CAAgB,QAAA,GAAW,qBAAA;EAAA,CAC3B,eAAA,CAAgB,aAAA;IACf,KAAA;EAAA;EAAA,CAED,eAAA,CAAgB,SAAA,GAAY,qBAAA;EAAA,CAC5B,eAAA,CAAgB,WAAA,GAAc,uBAAA;EAAA,CAC9B,eAAA,CAAgB,YAAA,GAAe,qBAAA;EAAA,CAC/B,eAAA,CAAgB,cAAA,GAAiB,kBAAA;EAAA,CACjC,eAAA,CAAgB,mBAAA;EAAA,CAChB,eAAA,CAAgB,mBAAA;EAAA,CAChB,eAAA,CAAgB,WAAA;EAAA,CAChB,eAAA,CAAgB,cAAA;EAAA,CAChB,eAAA,CAAgB,kBAAA;EAAA,CAChB,eAAA,CAAgB,YAAA,GAAe,oBAAA;AAAA;;;;;;;;;;iBAYZ,WAAA,WAAsB,eAAA,EAC1C,GAAA,UACA,MAAA,EAAQ,kBAAA,CAAmB,CAAA;EAAO,WAAA;AAAA,IACjC,OAAA,CAAQ,eAAA,CAAgB,CAAA;AAAA"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common/index.js"), exports);
|
|
18
|
-
__exportStar(require("./connectionsStorage/index.js"), exports);
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./connectionsStorage-CQE3XNWI.js");var t=e.i({ConnectionsRepoLocalStorage:()=>e.t,createPopup:()=>e.r,isSelectorMatch:()=>e.n});exports.ConnectionsRepoLocalStorage=e.t,exports.createPopup=e.r,exports.isSelectorMatch=e.n,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=advancedBarrel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advancedBarrel.js","names":[],"sources":["../src/advancedBarrel.ts"],"sourcesContent":["export * from \"./common/index.js\";\nexport * from \"./connectionsStorage/index.js\";\n"],"mappings":""}
|
|
@@ -1,6 +1,339 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { o as __exportAll, r as ConnectionsRepo } from "./index-CJeW3ePH.js";
|
|
2
|
+
import { ccc } from "@ckb-ccc/core";
|
|
3
|
+
|
|
4
|
+
//#region src/btc/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare class BitcoinSigner extends ccc.SignerBtc {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly icon: string;
|
|
12
|
+
private readonly preferredNetworks;
|
|
13
|
+
readonly addressType: "auto" | "p2wpkh" | "p2tr";
|
|
14
|
+
private readonly _appUri?;
|
|
15
|
+
private readonly connectionsRepo;
|
|
16
|
+
private connection?;
|
|
17
|
+
private network;
|
|
18
|
+
/**
|
|
19
|
+
* Ensures that the signer is connected and returns the connection.
|
|
20
|
+
* @throws Will throw an error if not connected.
|
|
21
|
+
* @returns The current connection.
|
|
22
|
+
*/
|
|
23
|
+
private assertConnection;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an instance of BitcoinSigner.
|
|
26
|
+
* @param client - The client instance.
|
|
27
|
+
* @param name - The name of the signer.
|
|
28
|
+
* @param icon - The icon URL of the signer.
|
|
29
|
+
* @param addressType - The address type.
|
|
30
|
+
* @param _appUri - The application URI.
|
|
31
|
+
* @param connectionsRepo - The connections repository.
|
|
32
|
+
*/
|
|
33
|
+
constructor(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[], addressType?: "auto" | "p2wpkh" | "p2tr", _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
34
|
+
/**
|
|
35
|
+
* Gets the configuration for JoyID.
|
|
36
|
+
* @returns The configuration object.
|
|
37
|
+
*/
|
|
38
|
+
private getConfig;
|
|
39
|
+
disconnect(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the Bitcoin account address.
|
|
42
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
43
|
+
*/
|
|
44
|
+
getBtcAccount(): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the Bitcoin public key.
|
|
47
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
48
|
+
*/
|
|
49
|
+
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
50
|
+
/**
|
|
51
|
+
* Connects to the provider by requesting authentication.
|
|
52
|
+
* @returns A promise that resolves when the connection is established.
|
|
53
|
+
*/
|
|
54
|
+
connect(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if the signer is connected.
|
|
57
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
isConnected(): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Signs a raw message with the Bitcoin account.
|
|
62
|
+
* @param message - The message to sign.
|
|
63
|
+
* @returns A promise that resolves to the signed message.
|
|
64
|
+
*/
|
|
65
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Signs a PSBT using JoyID wallet.
|
|
68
|
+
*
|
|
69
|
+
* @param psbtHex - The hex string of PSBT to sign.
|
|
70
|
+
* @returns A promise that resolves to the signed PSBT as a Hex string.
|
|
71
|
+
*/
|
|
72
|
+
signPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
73
|
+
/**
|
|
74
|
+
* Broadcasts a PSBT to the Bitcoin network.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* JoyID does not support broadcasting a signed PSBT directly.
|
|
78
|
+
* It only supports "Sign and Broadcast" as a single atomic operation via `signAndBroadcastPsbt`.
|
|
79
|
+
*/
|
|
80
|
+
broadcastPsbt(_psbtHex: ccc.HexLike, _options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
81
|
+
signAndBroadcastPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/ckb/index.d.ts
|
|
85
|
+
/**
|
|
86
|
+
* Class representing a CKB signer that extends Signer
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
declare class CkbSigner extends ccc.Signer {
|
|
90
|
+
private readonly name;
|
|
91
|
+
private readonly icon;
|
|
92
|
+
private readonly _appUri?;
|
|
93
|
+
private readonly _aggregatorUri?;
|
|
94
|
+
private readonly connectionsRepo;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the signer type.
|
|
97
|
+
* @returns The type of the signer.
|
|
98
|
+
*/
|
|
99
|
+
get type(): ccc.SignerType;
|
|
100
|
+
/**
|
|
101
|
+
* Gets the sign type.
|
|
102
|
+
* @returns The sign type.
|
|
103
|
+
*/
|
|
104
|
+
get signType(): ccc.SignerSignType;
|
|
105
|
+
private connection?;
|
|
106
|
+
/**
|
|
107
|
+
* Ensures that the signer is connected and returns the connection.
|
|
108
|
+
* @throws Will throw an error if not connected.
|
|
109
|
+
* @returns A promise that resolves to the current connection.
|
|
110
|
+
*/
|
|
111
|
+
private assertConnection;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an instance of CkbSigner.
|
|
114
|
+
* @param client - The client instance.
|
|
115
|
+
* @param name - The name of the signer.
|
|
116
|
+
* @param icon - The icon URL of the signer.
|
|
117
|
+
* @param _appUri - The application URI.
|
|
118
|
+
* @param _aggregatorUri - The aggregator URI.
|
|
119
|
+
* @param connectionsRepo - The connections repository.
|
|
120
|
+
*/
|
|
121
|
+
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
122
|
+
/**
|
|
123
|
+
* Gets the configuration for JoyID.
|
|
124
|
+
* @returns The configuration object.
|
|
125
|
+
*/
|
|
126
|
+
private getConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Gets the aggregator URI.
|
|
129
|
+
* @returns The aggregator URI.
|
|
130
|
+
*/
|
|
131
|
+
private getAggregatorUri;
|
|
132
|
+
/**
|
|
133
|
+
* Connects to the provider by requesting authentication.
|
|
134
|
+
* @returns A promise that resolves when the connection is established.
|
|
135
|
+
*/
|
|
136
|
+
connect(): Promise<void>;
|
|
137
|
+
disconnect(): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Checks if the signer is connected.
|
|
140
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
141
|
+
*/
|
|
142
|
+
isConnected(): Promise<boolean>;
|
|
143
|
+
/**
|
|
144
|
+
* Gets the internal address.
|
|
145
|
+
* @returns A promise that resolves to the internal address.
|
|
146
|
+
*/
|
|
147
|
+
getInternalAddress(): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Gets the identity of the signer.
|
|
150
|
+
* @returns A promise that resolves to the identity.
|
|
151
|
+
*/
|
|
152
|
+
getIdentity(): Promise<string>;
|
|
153
|
+
/**
|
|
154
|
+
* Gets the address object.
|
|
155
|
+
* @returns A promise that resolves to the address object.
|
|
156
|
+
*/
|
|
157
|
+
getAddressObj(): Promise<ccc.Address>;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the address objects.
|
|
160
|
+
* @returns A promise that resolves to an array of address objects.
|
|
161
|
+
*/
|
|
162
|
+
getAddressObjs(): Promise<ccc.Address[]>;
|
|
163
|
+
/**
|
|
164
|
+
* Prepares a transaction.
|
|
165
|
+
* @param txLike - The transaction-like object.
|
|
166
|
+
* @returns A promise that resolves to the prepared transaction.
|
|
167
|
+
*/
|
|
168
|
+
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
169
|
+
/**
|
|
170
|
+
* Prepares a transaction for a sub key.
|
|
171
|
+
* @param tx - The transaction object.
|
|
172
|
+
* @param witness - The witness arguments.
|
|
173
|
+
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
174
|
+
*/
|
|
175
|
+
private prepareTransactionForSubKey;
|
|
176
|
+
/**
|
|
177
|
+
* Signs a transaction.
|
|
178
|
+
* @param txLike - The transaction-like object.
|
|
179
|
+
* @returns A promise that resolves to the signed transaction.
|
|
180
|
+
*/
|
|
181
|
+
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
182
|
+
/**
|
|
183
|
+
* Signs a raw message with the account.
|
|
184
|
+
* @param message - The message to sign.
|
|
185
|
+
* @returns A promise that resolves to the signed message.
|
|
186
|
+
*/
|
|
187
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
188
|
+
/**
|
|
189
|
+
* Saves the current connection.
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
private saveConnection;
|
|
193
|
+
/**
|
|
194
|
+
* Restores the previous connection.
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
197
|
+
private restoreConnection;
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/evm/index.d.ts
|
|
201
|
+
/**
|
|
202
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
declare class EvmSigner extends ccc.SignerEvm {
|
|
206
|
+
private readonly name;
|
|
207
|
+
private readonly icon;
|
|
208
|
+
private readonly _appUri?;
|
|
209
|
+
private readonly connectionsRepo;
|
|
210
|
+
private connection?;
|
|
211
|
+
/**
|
|
212
|
+
* Ensures that the signer is connected and returns the connection.
|
|
213
|
+
* @throws Will throw an error if not connected.
|
|
214
|
+
* @returns The current connection.
|
|
215
|
+
*/
|
|
216
|
+
private assertConnection;
|
|
217
|
+
/**
|
|
218
|
+
* Creates an instance of EvmSigner.
|
|
219
|
+
* @param client - The client instance.
|
|
220
|
+
* @param name - The name of the signer.
|
|
221
|
+
* @param icon - The icon URL of the signer.
|
|
222
|
+
* @param _appUri - The application URI.
|
|
223
|
+
* @param connectionsRepo - The connections repository.
|
|
224
|
+
*/
|
|
225
|
+
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
226
|
+
/**
|
|
227
|
+
* Gets the configuration for JoyID.
|
|
228
|
+
* @returns The configuration object.
|
|
229
|
+
*/
|
|
230
|
+
private getConfig;
|
|
231
|
+
/**
|
|
232
|
+
* Gets the EVM account address.
|
|
233
|
+
* @returns A promise that resolves to the EVM account address.
|
|
234
|
+
*/
|
|
235
|
+
getEvmAccount(): Promise<ccc.Hex>;
|
|
236
|
+
/**
|
|
237
|
+
* Connects to the provider by requesting authentication.
|
|
238
|
+
* @returns A promise that resolves when the connection is established.
|
|
239
|
+
*/
|
|
240
|
+
connect(): Promise<void>;
|
|
241
|
+
disconnect(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Checks if the signer is connected.
|
|
244
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
245
|
+
*/
|
|
246
|
+
isConnected(): Promise<boolean>;
|
|
247
|
+
/**
|
|
248
|
+
* Signs a raw message with the EVM account.
|
|
249
|
+
* @param message - The message to sign.
|
|
250
|
+
* @returns A promise that resolves to the signed message.
|
|
251
|
+
*/
|
|
252
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
253
|
+
/**
|
|
254
|
+
* Saves the current connection.
|
|
255
|
+
* @returns
|
|
256
|
+
*/
|
|
257
|
+
private saveConnection;
|
|
258
|
+
/**
|
|
259
|
+
* Restores the previous connection.
|
|
260
|
+
* @returns
|
|
261
|
+
*/
|
|
262
|
+
private restoreConnection;
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/nostr/index.d.ts
|
|
266
|
+
/**
|
|
267
|
+
* Class representing a Nostr signer that extends SignerNostr
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
declare class NostrSigner extends ccc.SignerNostr {
|
|
271
|
+
private readonly name;
|
|
272
|
+
private readonly icon;
|
|
273
|
+
private readonly _appUri?;
|
|
274
|
+
private readonly connectionsRepo;
|
|
275
|
+
private connection?;
|
|
276
|
+
/**
|
|
277
|
+
* Ensures that the signer is connected and returns the connection.
|
|
278
|
+
* @throws Will throw an error if not connected.
|
|
279
|
+
* @returns The current connection.
|
|
280
|
+
*/
|
|
281
|
+
private assertConnection;
|
|
282
|
+
/**
|
|
283
|
+
* Creates an instance of NostrSigner.
|
|
284
|
+
* @param client - The client instance.
|
|
285
|
+
* @param name - The name of the signer.
|
|
286
|
+
* @param icon - The icon URL of the signer.
|
|
287
|
+
* @param _appUri - The application URI.
|
|
288
|
+
* @param connectionsRepo - The connections repository.
|
|
289
|
+
*/
|
|
290
|
+
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
291
|
+
/**
|
|
292
|
+
* Gets the configuration for JoyID.
|
|
293
|
+
* @returns The configuration object.
|
|
294
|
+
*/
|
|
295
|
+
private getConfig;
|
|
296
|
+
/**
|
|
297
|
+
* Connects to the provider by requesting authentication.
|
|
298
|
+
* @returns A promise that resolves when the connection is established.
|
|
299
|
+
*/
|
|
300
|
+
connect(): Promise<void>;
|
|
301
|
+
disconnect(): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Checks if the signer is connected.
|
|
304
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
305
|
+
*/
|
|
306
|
+
isConnected(): Promise<boolean>;
|
|
307
|
+
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
308
|
+
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
309
|
+
/**
|
|
310
|
+
* Saves the current connection.
|
|
311
|
+
* @returns
|
|
312
|
+
*/
|
|
313
|
+
private saveConnection;
|
|
314
|
+
/**
|
|
315
|
+
* Restores the previous connection.
|
|
316
|
+
* @returns
|
|
317
|
+
*/
|
|
318
|
+
private restoreConnection;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/signerFactory/index.d.ts
|
|
322
|
+
/**
|
|
323
|
+
* Gets the JoyID signers based on the client, name, and icon.
|
|
324
|
+
* If the browser is standalone or a webview, returns SignerAlwaysError instances.
|
|
325
|
+
* Otherwise, returns instances of CkbSigner, BitcoinSigner, and EvmSigner.
|
|
326
|
+
* @public
|
|
327
|
+
*
|
|
328
|
+
* @param client - The client instance.
|
|
329
|
+
* @param name - The name of the signer.
|
|
330
|
+
* @param icon - The icon URL of the signer.
|
|
331
|
+
* @returns An array of signer information objects.
|
|
332
|
+
*/
|
|
333
|
+
declare function getJoyIdSigners(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[]): ccc.SignerInfo[];
|
|
334
|
+
declare namespace barrel_d_exports {
|
|
335
|
+
export { BitcoinSigner, CkbSigner, EvmSigner, NostrSigner, getJoyIdSigners };
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
export { BitcoinSigner, CkbSigner, EvmSigner, NostrSigner, getJoyIdSigners, barrel_d_exports as t };
|
|
6
339
|
//# sourceMappingURL=barrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","names":[],"sources":["../src/btc/index.ts","../src/ckb/index.ts","../src/evm/index.ts","../src/nostr/index.ts","../src/signerFactory/index.ts","../src/barrel.ts"],"mappings":"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"}
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./btc/index.js"), exports);
|
|
18
|
-
__exportStar(require("./ckb/index.js"), exports);
|
|
19
|
-
__exportStar(require("./evm/index.js"), exports);
|
|
20
|
-
__exportStar(require("./nostr/index.js"), exports);
|
|
21
|
-
__exportStar(require("./signerFactory/index.js"), exports);
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./connectionsStorage-CQE3XNWI.js");let t=require("@ckb-ccc/core"),n=require("@joyid/common"),r=require("@joyid/ckb");var i=class extends t.ccc.SignerBtc{async assertConnection(){if(!await this.isConnected()||!this.connection)throw Error(`Not connected`);return this.connection}constructor(n,r,i,a=[{addressPrefix:`ckb`,signerType:t.ccc.SignerType.BTC,network:`btc`},{addressPrefix:`ckt`,signerType:t.ccc.SignerType.BTC,network:`btcTestnet`}],o=`auto`,s,c=new e.t){super(n),this.name=r,this.icon=i,this.preferredNetworks=a,this.addressType=o,this._appUri=s,this.connectionsRepo=c,this.network=`btcTestnet`}getConfig(){let{network:e}=this.matchNetworkPreference(this.preferredNetworks,this.network)??{network:this.network};this.network!==e&&(this.connection=void 0),this.network=e;let t={btc:`https://app.joy.id`,btcTestnet:`https://testnet.joyid.dev`}[e];if(!t)throw Error(`JoyID wallet doesn't support the requested chain ${this.network}`);return{redirectURL:location.href,joyidAppURL:this._appUri??t,requestNetwork:`btc-${this.addressType}`,name:this.name,logo:this.icon}}async disconnect(){await super.disconnect(),await this.connectionsRepo.set({uri:this.getConfig().joyidAppURL,addressType:`btc`},void 0)}async getBtcAccount(){let{address:e}=await this.assertConnection();return e}async getBtcPublicKey(){let{publicKey:e}=await this.assertConnection();return e}async connect(){let r=this.getConfig(),i=await e.r((0,n.buildJoyIDURL)(r,`popup`,`/auth`),{...r,type:n.DappRequestType.Auth}),{address:a,pubkey:o}=this.addressType===`auto`?i.btcAddressType===`p2wpkh`?i.nativeSegwit:i.taproot:this.addressType===`p2wpkh`?i.nativeSegwit:i.taproot;this.connection={address:a,publicKey:t.ccc.hexFrom(o),keyType:i.keyType},await Promise.all([this.connectionsRepo.set({uri:r.joyidAppURL,addressType:`btc-${this.addressType}`},this.connection),this.connectionsRepo.set({uri:r.joyidAppURL,addressType:`btc-auto`},this.connection)])}async isConnected(){return this.connection?!0:(this.connection=await this.connectionsRepo.get({uri:this.getConfig().joyidAppURL,addressType:`btc-${this.addressType}`}),this.connection!==void 0)}async signMessageRaw(r){let{address:i}=await this.assertConnection(),a=typeof r==`string`?r:t.ccc.hexFrom(r).slice(2),o=this.getConfig(),{signature:s}=await e.r((0,n.buildJoyIDURL)({...o,challenge:a,address:i,signMessageType:`ecdsa`},`popup`,`/sign-message`),{...o,type:n.DappRequestType.SignMessage});return s}async signPsbt(r,i){let{address:a}=await this.assertConnection(),o=t.ccc.SignPsbtOptions.from(i),s=this.getConfig(),{tx:c}=await e.r((0,n.buildJoyIDURL)({...s,tx:t.ccc.hexFrom(r).slice(2),options:o,signerAddress:a,autoFinalized:o.autoFinalized},`popup`,`/sign-psbt`),{...s,type:n.DappRequestType.SignPsbt});return t.ccc.hexFrom(c)}async broadcastPsbt(e,t){throw Error(`JoyID does not support broadcasting signed PSBTs directly. Use signAndBroadcastPsbt instead.`)}async signAndBroadcastPsbt(r,i){let{address:a}=await this.assertConnection(),o=t.ccc.SignPsbtOptions.from(i),s=this.getConfig(),{tx:c}=await e.r((0,n.buildJoyIDURL)({...s,tx:t.ccc.hexFrom(r).slice(2),options:o,signerAddress:a,autoFinalized:!0,isSend:!0},`popup`,`/sign-psbt`),{...s,type:n.DappRequestType.SignPsbt});return t.ccc.hexFrom(c)}},a=class extends t.ccc.Signer{get type(){return t.ccc.SignerType.CKB}get signType(){return t.ccc.SignerSignType.JoyId}async assertConnection(){if(!await this.isConnected()||!this.connection)throw Error(`Not connected`);return this.connection}constructor(t,n,r,i,a,o=new e.t){super(t),this.name=n,this.icon=r,this._appUri=i,this._aggregatorUri=a,this.connectionsRepo=o}getConfig(){return{redirectURL:location.href,joyidAppURL:this._appUri??(this.client.addressPrefix===`ckb`?`https://app.joy.id`:`https://testnet.joyid.dev`),name:this.name,logo:this.icon}}getAggregatorUri(){return this._aggregatorUri??(this.client.addressPrefix===`ckb`?`https://cota.nervina.dev/mainnet-aggregator`:`https://cota.nervina.dev/aggregator`)}async connect(){let r=this.getConfig(),i=await e.r((0,n.buildJoyIDURL)(r,`popup`,`/auth`),{...r,type:n.DappRequestType.Auth});this.connection={address:i.address,publicKey:t.ccc.hexFrom(i.pubkey),keyType:i.keyType},await this.saveConnection()}async disconnect(){await super.disconnect(),this.connection=void 0,await this.saveConnection()}async isConnected(){return this.connection?!0:(await this.restoreConnection(),this.connection!==void 0)}async getInternalAddress(){return(await this.assertConnection()).address}async getIdentity(){let e=await this.assertConnection();return JSON.stringify({keyType:e.keyType,publicKey:e.publicKey.slice(2)})}async getAddressObj(){return await t.ccc.Address.fromString(await this.getInternalAddress(),this.client)}async getAddressObjs(){return[await this.getAddressObj()]}async prepareTransaction(e){let n=t.ccc.Transaction.from(e);await n.addCellDepsOfKnownScripts(this.client,t.ccc.KnownScript.JoyId);let r=await n.findInputIndexByLock((await this.getAddressObj()).script,this.client);if(r===void 0)return n;let i=n.getWitnessArgsAt(r)??t.ccc.WitnessArgs.from({});return i.lock=t.ccc.hexFrom(`00`.repeat(1e3)),await this.prepareTransactionForSubKey(n,i),n.setWitnessArgsAt(r,i),n}async prepareTransactionForSubKey(e,n){if(this.connection?.keyType!==`sub_key`||(n.outputType??`0x`)!==`0x`)return;let i=t.ccc.hashCkb(this.connection.publicKey).substring(0,42),a=(await this.getAddressObj()).script,{unlock_entry:o}=await new r.Aggregator(this.getAggregatorUri()).generateSubkeyUnlockSmt({alg_index:1,pubkey_hash:i,lock_script:t.ccc.hexFrom(a.toBytes())});n.outputType=t.ccc.hexFrom(o);let s=[];for await(let e of this.client.findCellsByLock(a,await t.ccc.Script.fromKnownScript(this.client,t.ccc.KnownScript.COTA,`0x`)))s.push(t.ccc.CellDep.from({depType:`code`,outPoint:e.outPoint}));if(s.length===0)throw Error(`No COTA cells for sub key wallet`);e.addCellDepsAtStart(s)}async signOnlyTransaction(r){let i=t.ccc.Transaction.from(r),{script:a}=await this.getAddressObj(),o=await t.ccc.reduceAsync(i.inputs,async(e,t,n)=>{let{cellOutput:r}=await t.getCell(this.client);r.lock.eq(a)&&e.push(n)},[]);await i.prepareSighashAllWitness(a,0,this.client),i.inputs.forEach(e=>{e.cellOutput=void 0,e.outputData=void 0});let s=this.getConfig(),c=await e.r((0,n.buildJoyIDURL)({...s,tx:JSON.parse(i.stringify()),signerAddress:(await this.assertConnection()).address,witnessIndexes:o},`popup`,`/sign-ckb-raw-tx`),{...s,type:n.DappRequestType.SignCkbRawTx});return t.ccc.Transaction.from(c.tx)}async signMessageRaw(r){let{address:i}=await this.assertConnection(),a=typeof r==`string`?r:t.ccc.hexFrom(r).slice(2),o=this.getConfig(),s=await e.r((0,n.buildJoyIDURL)({...o,challenge:a,isData:typeof r!=`string`,address:i},`popup`,`/sign-message`),{...o,type:n.DappRequestType.SignMessage});return JSON.stringify({signature:s.signature,alg:s.alg,message:s.message})}async saveConnection(){return this.connectionsRepo.set({uri:this.getConfig().joyidAppURL,addressType:`ckb`},this.connection)}async restoreConnection(){this.connection=await this.connectionsRepo.get({uri:this.getConfig().joyidAppURL,addressType:`ckb`})}},o=class extends t.ccc.SignerEvm{async assertConnection(){if(!await this.isConnected()||!this.connection)throw Error(`Not connected`);return this.connection}constructor(t,n,r,i,a=new e.t){super(t),this.name=n,this.icon=r,this._appUri=i,this.connectionsRepo=a}getConfig(){return{redirectURL:location.href,joyidAppURL:this._appUri??(this.client.addressPrefix===`ckb`?`https://app.joy.id`:`https://testnet.joyid.dev`),requestNetwork:`ethereum`,name:this.name,logo:this.icon}}async getEvmAccount(){return(await this.assertConnection()).address}async connect(){let r=this.getConfig(),i=await e.r((0,n.buildJoyIDURL)(r,`popup`,`/auth`),{...r,type:n.DappRequestType.Auth});this.connection={address:i.ethAddress,publicKey:t.ccc.hexFrom(i.pubkey),keyType:i.keyType},await this.saveConnection()}async disconnect(){await super.disconnect(),this.connection=void 0,await this.saveConnection()}async isConnected(){return this.connection?!0:(await this.restoreConnection(),this.connection!==void 0)}async signMessageRaw(r){let{address:i}=await this.assertConnection(),a=typeof r==`string`?r:t.ccc.hexFrom(r).slice(2),o=this.getConfig(),{signature:s}=await e.r((0,n.buildJoyIDURL)({...o,challenge:a,isData:typeof r!=`string`,address:i},`popup`,`/sign-message`),{...o,type:n.DappRequestType.SignMessage});return t.ccc.hexFrom(s)}async saveConnection(){return this.connectionsRepo.set({uri:this.getConfig().joyidAppURL,addressType:`ethereum`},this.connection)}async restoreConnection(){this.connection=await this.connectionsRepo.get({uri:this.getConfig().joyidAppURL,addressType:`ethereum`})}},s=class extends t.ccc.SignerNostr{async assertConnection(){if(!await this.isConnected()||!this.connection)throw Error(`Not connected`);return this.connection}constructor(t,n,r,i,a=new e.t){super(t),this.name=n,this.icon=r,this._appUri=i,this.connectionsRepo=a}getConfig(){return{redirectURL:location.href,joyidAppURL:this._appUri??(this.client.addressPrefix===`ckb`?`https://app.joy.id`:`https://testnet.joyid.dev`),requestNetwork:`nostr`,name:this.name,logo:this.icon}}async connect(){let r=this.getConfig(),i=await e.r((0,n.buildJoyIDURL)(r,`popup`,`/auth`),{...r,type:n.DappRequestType.Auth});this.connection={address:``,publicKey:t.ccc.hexFrom(i.nostrPubkey),keyType:i.keyType},await this.saveConnection()}async disconnect(){await super.disconnect(),this.connection=void 0,await this.saveConnection()}async isConnected(){return this.connection?!0:(await this.restoreConnection(),this.connection!==void 0)}async getNostrPublicKey(){return(await this.assertConnection()).publicKey}async signNostrEvent(t){let r=this.getConfig();return(await e.r((0,n.buildJoyIDURL)({...r,event:t},`popup`,`/sign-nostr-event`),{...r,type:n.DappRequestType.SignNostrEvent})).event}async saveConnection(){return this.connectionsRepo.set({uri:this.getConfig().joyidAppURL,addressType:`nostr`},this.connection)}async restoreConnection(){this.connection=await this.connectionsRepo.get({uri:this.getConfig().joyidAppURL,addressType:`nostr`})}};function c(e,r,c,l){return(0,n.isStandaloneBrowser)()||t.ccc.isWebview(window.navigator.userAgent)?[t.ccc.SignerType.CKB,t.ccc.SignerType.EVM,t.ccc.SignerType.BTC].map(n=>({name:n,signer:new t.ccc.SignerAlwaysError(e,n,`JoyID can only be used with standard browsers`)})):[{name:`CKB`,signer:new a(e,r,c)},{name:`BTC`,signer:new i(e,r,c,l)},{name:`Nostr`,signer:new s(e,r,c)},{name:`EVM`,signer:new o(e,r,c)},{name:`BTC (P2WPKH)`,signer:new i(e,r,c,l,`p2wpkh`)},{name:`BTC (P2TR)`,signer:new i(e,r,c,l,`p2tr`)}]}var l=e.i({BitcoinSigner:()=>i,CkbSigner:()=>a,EvmSigner:()=>o,NostrSigner:()=>s,getJoyIdSigners:()=>c});exports.BitcoinSigner=i,exports.CkbSigner=a,exports.EvmSigner=o,exports.NostrSigner=s,exports.getJoyIdSigners=c,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=barrel.js.map
|