@ckb-ccc/joy-id 0.0.5-alpha.1 → 0.0.5-alpha.10
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/dist/btc/index.d.ts +1 -2
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +1 -4
- package/dist/ckb/index.d.ts +4 -1
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +41 -15
- package/dist/evm/index.d.ts +1 -2
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +1 -4
- package/dist/signerFactory/index.d.ts.map +1 -1
- package/dist/signerFactory/index.js +7 -5
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +40 -19
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/btc/index.d.ts +22 -16
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +99 -76
- package/dist.commonjs/ckb/index.d.ts +33 -23
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +204 -135
- package/dist.commonjs/common/index.d.ts +34 -21
- package/dist.commonjs/common/index.js +50 -45
- package/dist.commonjs/connectionsStorage/index.d.ts +23 -14
- package/dist.commonjs/connectionsStorage/index.js +28 -25
- package/dist.commonjs/evm/index.d.ts +21 -16
- package/dist.commonjs/evm/index.d.ts.map +1 -1
- package/dist.commonjs/evm/index.js +89 -70
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +40 -19
- package/dist.commonjs/signerFactory/index.d.ts +6 -2
- package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
- package/dist.commonjs/signerFactory/index.js +39 -26
- package/package.json +3 -3
- package/src/btc/index.ts +1 -12
- package/src/ckb/index.ts +55 -22
- package/src/evm/index.ts +1 -11
- package/src/signerFactory/index.ts +14 -5
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AuthResponseData,
|
|
3
|
+
DappRequestType,
|
|
4
|
+
EvmWeb2LoginResponse,
|
|
5
|
+
PopupConfigOptions,
|
|
6
|
+
SignCkbTxResponseData,
|
|
7
|
+
SignCotaNFTResponseData,
|
|
8
|
+
SignEvmTxResponseData,
|
|
9
|
+
SignMessageResponseData,
|
|
10
|
+
SignNostrEventData,
|
|
11
|
+
} from "@joyid/common";
|
|
2
12
|
export interface PopupReturnType {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
[DappRequestType.Auth]: AuthResponseData;
|
|
14
|
+
[DappRequestType.SignMessage]: SignMessageResponseData;
|
|
15
|
+
[DappRequestType.SignEvm]: SignEvmTxResponseData;
|
|
16
|
+
[DappRequestType.SignPsbt]: SignEvmTxResponseData;
|
|
17
|
+
[DappRequestType.BatchSignPsbt]: {
|
|
18
|
+
psbts: string[];
|
|
19
|
+
};
|
|
20
|
+
[DappRequestType.SignCkbTx]: SignCkbTxResponseData;
|
|
21
|
+
[DappRequestType.SignCotaNFT]: SignCotaNFTResponseData;
|
|
22
|
+
[DappRequestType.SignCkbRawTx]: SignCkbTxResponseData;
|
|
23
|
+
[DappRequestType.SignNostrEvent]: SignNostrEventData;
|
|
24
|
+
[DappRequestType.EncryptNostrMessage]: any;
|
|
25
|
+
[DappRequestType.DecryptNostrMessage]: any;
|
|
26
|
+
[DappRequestType.AuthMiniApp]: any;
|
|
27
|
+
[DappRequestType.SignMiniAppEvm]: any;
|
|
28
|
+
[DappRequestType.SignMiniAppMessage]: any;
|
|
29
|
+
[DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
|
|
20
30
|
}
|
|
21
|
-
export declare function createPopup<T extends DappRequestType>(
|
|
31
|
+
export declare function createPopup<T extends DappRequestType>(
|
|
32
|
+
url: string,
|
|
33
|
+
config: PopupConfigOptions<T> & {
|
|
22
34
|
joyidAppURL: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
35
|
+
},
|
|
36
|
+
): Promise<PopupReturnType[T]>;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,52 +3,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPopup = void 0;
|
|
4
4
|
const common_1 = require("@joyid/common");
|
|
5
5
|
async function createPopup(url, config) {
|
|
6
|
+
if (config.popup == null) {
|
|
7
|
+
config.popup = (0, common_1.openPopup)("");
|
|
6
8
|
if (config.popup == null) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
9
|
+
return (0, common_1.createBlockDialog)(async () =>
|
|
10
|
+
createPopup(url, config),
|
|
11
|
+
);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
popupEventListener
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
13
|
+
}
|
|
14
|
+
config.popup.location.href = url;
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
if ((0, common_1.isStandaloneBrowser)()) {
|
|
17
|
+
reject(new common_1.PopupNotSupportedError(config.popup));
|
|
18
|
+
}
|
|
19
|
+
let popupEventListener;
|
|
20
|
+
let timeoutId;
|
|
21
|
+
// Check each second if the popup is closed triggering a PopupCancelledError
|
|
22
|
+
const popupTimer = setInterval(() => {
|
|
23
|
+
if (config.popup?.closed) {
|
|
24
|
+
clearInterval(popupTimer);
|
|
25
|
+
clearTimeout(timeoutId);
|
|
26
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
27
|
+
reject(new common_1.PopupCancelledError(config.popup));
|
|
28
|
+
}
|
|
29
|
+
}, 1000);
|
|
30
|
+
timeoutId = setTimeout(
|
|
31
|
+
() => {
|
|
32
|
+
clearInterval(popupTimer);
|
|
33
|
+
reject(new common_1.PopupTimeoutError(config.popup));
|
|
34
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
35
|
+
},
|
|
36
|
+
(config.timeoutInSeconds ?? 3000) * 1000,
|
|
37
|
+
);
|
|
38
|
+
popupEventListener = (e) => {
|
|
39
|
+
const { joyidAppURL } = config;
|
|
40
|
+
const appURL = new URL(joyidAppURL);
|
|
41
|
+
if (e.origin !== appURL.origin) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!e.data || e.data?.type !== config.type) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
clearInterval(popupTimer);
|
|
49
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
50
|
+
config.popup.close();
|
|
51
|
+
if (e.data.error) {
|
|
52
|
+
reject(new Error(e.data.error));
|
|
53
|
+
}
|
|
54
|
+
resolve(e.data.data);
|
|
55
|
+
};
|
|
56
|
+
window.addEventListener("message", popupEventListener);
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
exports.createPopup = createPopup;
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
export type AccountSelector = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
uri: string;
|
|
4
|
+
addressType: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function isSelectorEq(
|
|
6
|
+
export declare function isSelectorEq(
|
|
7
|
+
a: AccountSelector,
|
|
8
|
+
b: AccountSelector,
|
|
9
|
+
): boolean;
|
|
7
10
|
export type Connection = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
readonly address: string;
|
|
12
|
+
readonly publicKey: ccc.Hex;
|
|
13
|
+
readonly keyType: string;
|
|
11
14
|
};
|
|
12
15
|
export interface ConnectionsRepo {
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
17
|
+
set(
|
|
18
|
+
selector: AccountSelector,
|
|
19
|
+
connection: Connection | undefined,
|
|
20
|
+
): Promise<void>;
|
|
15
21
|
}
|
|
16
22
|
export declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
private readonly storageKey;
|
|
24
|
+
constructor(storageKey?: string);
|
|
25
|
+
readConnections(): Promise<[AccountSelector, Connection][]>;
|
|
26
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
27
|
+
set(
|
|
28
|
+
selector: AccountSelector,
|
|
29
|
+
connection: Connection | undefined,
|
|
30
|
+
): Promise<void>;
|
|
22
31
|
}
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,34 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectionsRepoLocalStorage = exports.isSelectorEq = void 0;
|
|
4
4
|
function isSelectorEq(a, b) {
|
|
5
|
-
|
|
5
|
+
return a.uri === b.uri && a.addressType === b.addressType;
|
|
6
6
|
}
|
|
7
7
|
exports.isSelectorEq = isSelectorEq;
|
|
8
8
|
class ConnectionsRepoLocalStorage {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
constructor(storageKey = "ccc-joy-id-signer") {
|
|
10
|
+
this.storageKey = storageKey;
|
|
11
|
+
}
|
|
12
|
+
async readConnections() {
|
|
13
|
+
return JSON.parse(window.localStorage.getItem(this.storageKey) ?? "[]");
|
|
14
|
+
}
|
|
15
|
+
async get(selector) {
|
|
16
|
+
return (await this.readConnections()).find(([s]) =>
|
|
17
|
+
isSelectorEq(selector, s),
|
|
18
|
+
)?.[1];
|
|
19
|
+
}
|
|
20
|
+
async set(selector, connection) {
|
|
21
|
+
const connections = await this.readConnections();
|
|
22
|
+
if (connection) {
|
|
23
|
+
const existed = connections.find(([s]) => isSelectorEq(s, selector));
|
|
24
|
+
if (existed) {
|
|
25
|
+
existed[1] = connection;
|
|
26
|
+
} else {
|
|
27
|
+
connections.push([selector, connection]);
|
|
28
|
+
}
|
|
29
|
+
window.localStorage.setItem(this.storageKey, JSON.stringify(connections));
|
|
30
|
+
} else {
|
|
31
|
+
window.localStorage.setItem(
|
|
32
|
+
this.storageKey,
|
|
33
|
+
JSON.stringify(connections.filter(([s]) => !isSelectorEq(s, selector))),
|
|
34
|
+
);
|
|
33
35
|
}
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
exports.ConnectionsRepoLocalStorage = ConnectionsRepoLocalStorage;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
3
|
export declare class EvmSigner extends ccc.SignerEvm {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
private readonly name;
|
|
5
|
+
private readonly icon;
|
|
6
|
+
private readonly appUri;
|
|
7
|
+
private readonly connectionsRepo;
|
|
8
|
+
private connection?;
|
|
9
|
+
private assertConnection;
|
|
10
|
+
constructor(
|
|
11
|
+
client: ccc.Client,
|
|
12
|
+
name: string,
|
|
13
|
+
icon: string,
|
|
14
|
+
appUri?: string,
|
|
15
|
+
connectionsRepo?: ConnectionsRepo,
|
|
16
|
+
);
|
|
17
|
+
private getConfig;
|
|
18
|
+
getEvmAccount(): Promise<string>;
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
isConnected(): Promise<boolean>;
|
|
21
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
22
|
+
private saveConnection;
|
|
23
|
+
private restoreConnection;
|
|
19
24
|
}
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;IAaxC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAflC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;
|
|
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,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;IAaxC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAflC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;IAKvF,OAAO,CAAC,SAAS;IAUX,aAAa;IAIb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YAuBzD,cAAc;YAUd,iBAAiB;CAMhC"}
|
|
@@ -6,77 +6,96 @@ const common_1 = require("@joyid/common");
|
|
|
6
6
|
const common_2 = require("../common");
|
|
7
7
|
const connectionsStorage_1 = require("../connectionsStorage");
|
|
8
8
|
class EvmSigner extends core_1.ccc.SignerEvm {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return this.connection;
|
|
9
|
+
assertConnection() {
|
|
10
|
+
if (!this.isConnected() || !this.connection) {
|
|
11
|
+
throw new Error("Not connected");
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const { signature } = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
|
|
62
|
-
...config,
|
|
63
|
-
challenge,
|
|
64
|
-
isData: typeof message !== "string",
|
|
65
|
-
address,
|
|
66
|
-
}, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
|
|
67
|
-
return core_1.ccc.hexFrom(signature);
|
|
68
|
-
}
|
|
69
|
-
async saveConnection() {
|
|
70
|
-
return this.connectionsRepo.set({
|
|
71
|
-
uri: this.getConfig().joyidAppURL,
|
|
72
|
-
addressType: "ethereum",
|
|
73
|
-
}, this.connection);
|
|
74
|
-
}
|
|
75
|
-
async restoreConnection() {
|
|
76
|
-
this.connection = await this.connectionsRepo.get({
|
|
77
|
-
uri: this.getConfig().joyidAppURL,
|
|
78
|
-
addressType: "ethereum",
|
|
79
|
-
});
|
|
13
|
+
return this.connection;
|
|
14
|
+
}
|
|
15
|
+
constructor(
|
|
16
|
+
client,
|
|
17
|
+
name,
|
|
18
|
+
icon,
|
|
19
|
+
appUri = "https://app.joy.id",
|
|
20
|
+
connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage(),
|
|
21
|
+
) {
|
|
22
|
+
super(client);
|
|
23
|
+
this.name = name;
|
|
24
|
+
this.icon = icon;
|
|
25
|
+
this.appUri = appUri;
|
|
26
|
+
this.connectionsRepo = connectionsRepo;
|
|
27
|
+
}
|
|
28
|
+
getConfig() {
|
|
29
|
+
return {
|
|
30
|
+
redirectURL: location.href,
|
|
31
|
+
joyidAppURL: this.appUri,
|
|
32
|
+
requestNetwork: `ethereum`,
|
|
33
|
+
name: this.name,
|
|
34
|
+
logo: this.icon,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async getEvmAccount() {
|
|
38
|
+
return this.assertConnection().address;
|
|
39
|
+
}
|
|
40
|
+
async connect() {
|
|
41
|
+
const config = await this.getConfig();
|
|
42
|
+
const res = await (0, common_2.createPopup)(
|
|
43
|
+
(0, common_1.buildJoyIDURL)(config, "popup", "/auth"),
|
|
44
|
+
{
|
|
45
|
+
...config,
|
|
46
|
+
type: common_1.DappRequestType.Auth,
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
this.connection = {
|
|
50
|
+
address: res.ethAddress,
|
|
51
|
+
publicKey: core_1.ccc.hexFrom(res.pubkey),
|
|
52
|
+
keyType: res.keyType,
|
|
53
|
+
};
|
|
54
|
+
await this.saveConnection();
|
|
55
|
+
}
|
|
56
|
+
async isConnected() {
|
|
57
|
+
if (this.connection) {
|
|
58
|
+
return true;
|
|
80
59
|
}
|
|
60
|
+
await this.restoreConnection();
|
|
61
|
+
return this.connection !== undefined;
|
|
62
|
+
}
|
|
63
|
+
async signMessageRaw(message) {
|
|
64
|
+
const { address } = this.assertConnection();
|
|
65
|
+
const challenge =
|
|
66
|
+
typeof message === "string"
|
|
67
|
+
? message
|
|
68
|
+
: core_1.ccc.hexFrom(message).slice(2);
|
|
69
|
+
const config = this.getConfig();
|
|
70
|
+
const { signature } = await (0, common_2.createPopup)(
|
|
71
|
+
(0, common_1.buildJoyIDURL)(
|
|
72
|
+
{
|
|
73
|
+
...config,
|
|
74
|
+
challenge,
|
|
75
|
+
isData: typeof message !== "string",
|
|
76
|
+
address,
|
|
77
|
+
},
|
|
78
|
+
"popup",
|
|
79
|
+
"/sign-message",
|
|
80
|
+
),
|
|
81
|
+
{ ...config, type: common_1.DappRequestType.SignMessage },
|
|
82
|
+
);
|
|
83
|
+
return core_1.ccc.hexFrom(signature);
|
|
84
|
+
}
|
|
85
|
+
async saveConnection() {
|
|
86
|
+
return this.connectionsRepo.set(
|
|
87
|
+
{
|
|
88
|
+
uri: this.getConfig().joyidAppURL,
|
|
89
|
+
addressType: "ethereum",
|
|
90
|
+
},
|
|
91
|
+
this.connection,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
async restoreConnection() {
|
|
95
|
+
this.connection = await this.connectionsRepo.get({
|
|
96
|
+
uri: this.getConfig().joyidAppURL,
|
|
97
|
+
addressType: "ethereum",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
81
100
|
}
|
|
82
101
|
exports.EvmSigner = EvmSigner;
|
package/dist.commonjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as JoyId from "./barrel";
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist.commonjs/index.js
CHANGED
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __setModuleDefault =
|
|
26
|
+
(this && this.__setModuleDefault) ||
|
|
27
|
+
(Object.create
|
|
28
|
+
? function (o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}
|
|
31
|
+
: function (o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar =
|
|
35
|
+
(this && this.__importStar) ||
|
|
36
|
+
function (mod) {
|
|
19
37
|
if (mod && mod.__esModule) return mod;
|
|
20
38
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
39
|
+
if (mod != null)
|
|
40
|
+
for (var k in mod)
|
|
41
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
+
__createBinding(result, mod, k);
|
|
22
43
|
__setModuleDefault(result, mod);
|
|
23
44
|
return result;
|
|
24
|
-
};
|
|
45
|
+
};
|
|
25
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
47
|
exports.JoyId = void 0;
|
|
27
48
|
exports.JoyId = __importStar(require("./barrel"));
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
export declare function getJoyIdSigners(
|
|
3
|
-
|
|
2
|
+
export declare function getJoyIdSigners(
|
|
3
|
+
client: ccc.Client,
|
|
4
|
+
name: string,
|
|
5
|
+
icon: string,
|
|
6
|
+
): ccc.SignerInfo[];
|
|
7
|
+
//# 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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,UAAU,EAAE,CAoClB"}
|