@ckb-ccc/nip07 0.0.9-alpha.1 → 0.0.10-alpha.4
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/signer.d.ts +2 -5
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +11 -22
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +40 -19
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +40 -19
- package/dist.commonjs/nip07.advanced.d.ts +3 -3
- package/dist.commonjs/signer.d.ts +8 -11
- package/dist.commonjs/signer.d.ts.map +1 -1
- package/dist.commonjs/signer.js +22 -33
- package/dist.commonjs/signersFactory.d.ts +1 -1
- package/dist.commonjs/signersFactory.js +5 -5
- package/package.json +3 -3
- package/src/signer.ts +10 -27
- package/dist/connectionsRepo.d.ts +0 -51
- package/dist/connectionsRepo.d.ts.map +0 -1
- package/dist/connectionsRepo.js +0 -34
- package/dist.commonjs/connectionsRepo.d.ts +0 -51
- package/dist.commonjs/connectionsRepo.d.ts.map +0 -1
- package/dist.commonjs/connectionsRepo.js +0 -38
- package/src/connectionsRepo.ts +0 -65
package/dist/signer.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ConnectionsRepo } from "./connectionsRepo";
|
|
3
2
|
import { Provider } from "./nip07.advanced";
|
|
4
3
|
export declare class Signer extends ccc.SignerNostr {
|
|
5
4
|
readonly provider: Provider;
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
constructor(client: ccc.Client, provider: Provider, connectionsRepo?: ConnectionsRepo);
|
|
9
|
-
replaceClient(client: ccc.Client): Promise<boolean>;
|
|
5
|
+
private publicKeyCache?;
|
|
6
|
+
constructor(client: ccc.Client, provider: Provider);
|
|
10
7
|
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
11
8
|
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
12
9
|
connect(): Promise<void>;
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAJpC,OAAO,CAAC,cAAc,CAAC,CAA8B;gBAGnD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAK9B,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAQrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAO9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
package/dist/signer.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ConnectionsRepoLocalStorage, } from "./connectionsRepo";
|
|
3
2
|
export class Signer extends ccc.SignerNostr {
|
|
4
|
-
constructor(client, provider
|
|
3
|
+
constructor(client, provider) {
|
|
5
4
|
super(client);
|
|
6
5
|
this.provider = provider;
|
|
7
|
-
this.
|
|
8
|
-
this.publicKey = undefined;
|
|
9
|
-
}
|
|
10
|
-
async replaceClient(client) {
|
|
11
|
-
return super.replaceClient(client);
|
|
6
|
+
this.publicKeyCache = undefined;
|
|
12
7
|
}
|
|
13
8
|
async getNostrPublicKey() {
|
|
14
|
-
if (this.
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
18
|
-
if (!this.publicKey) {
|
|
19
|
-
throw new Error("Not connected");
|
|
9
|
+
if (!this.publicKeyCache) {
|
|
10
|
+
this.publicKeyCache = this.provider.getPublicKey();
|
|
20
11
|
}
|
|
21
|
-
return this.
|
|
12
|
+
return ccc.hexFrom(await this.publicKeyCache);
|
|
22
13
|
}
|
|
23
14
|
async signNostrEvent(event) {
|
|
24
|
-
return this.provider.signEvent(
|
|
15
|
+
return this.provider.signEvent({
|
|
16
|
+
...event,
|
|
17
|
+
pubkey: await this.publicKeyCache,
|
|
18
|
+
});
|
|
25
19
|
}
|
|
26
20
|
async connect() {
|
|
27
|
-
|
|
28
|
-
await this.connectionsRepo.set({ publicKey: this.publicKey });
|
|
21
|
+
return;
|
|
29
22
|
}
|
|
30
23
|
async isConnected() {
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
35
|
-
return this.publicKey !== undefined;
|
|
24
|
+
return true;
|
|
36
25
|
}
|
|
37
26
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as Nip07A from "./nip07.advanced";
|
|
2
|
-
//# sourceMappingURL=advanced.d.ts.map
|
|
2
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -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.Nip07A = void 0;
|
|
27
48
|
exports.Nip07A = __importStar(require("./nip07.advanced"));
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 __exportStar =
|
|
26
|
+
(this && this.__exportStar) ||
|
|
27
|
+
function (m, exports) {
|
|
28
|
+
for (var p in m)
|
|
29
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
+
__createBinding(exports, m, p);
|
|
31
|
+
};
|
|
16
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
33
|
__exportStar(require("./signer"), exports);
|
|
18
34
|
__exportStar(require("./signersFactory"), exports);
|
package/dist.commonjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as Nip07 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.Nip07 = void 0;
|
|
27
48
|
exports.Nip07 = __importStar(require("./barrel"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
export interface Provider {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
getPublicKey(): Promise<string>;
|
|
4
|
+
signEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=nip07.advanced.d.ts.map
|
|
6
|
+
//# sourceMappingURL=nip07.advanced.d.ts.map
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ConnectionsRepo } from "./connectionsRepo";
|
|
3
2
|
import { Provider } from "./nip07.advanced";
|
|
4
3
|
export declare class Signer extends ccc.SignerNostr {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
connect(): Promise<void>;
|
|
13
|
-
isConnected(): Promise<boolean>;
|
|
4
|
+
readonly provider: Provider;
|
|
5
|
+
private publicKeyCache?;
|
|
6
|
+
constructor(client: ccc.Client, provider: Provider);
|
|
7
|
+
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
8
|
+
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
9
|
+
connect(): Promise<void>;
|
|
10
|
+
isConnected(): Promise<boolean>;
|
|
14
11
|
}
|
|
15
|
-
//# sourceMappingURL=signer.d.ts.map
|
|
12
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAJpC,OAAO,CAAC,cAAc,CAAC,CAA8B;gBAGnD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAK9B,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAQrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAO9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
package/dist.commonjs/signer.js
CHANGED
|
@@ -2,40 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Signer = void 0;
|
|
4
4
|
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
const connectionsRepo_1 = require("./connectionsRepo");
|
|
6
5
|
class Signer extends core_1.ccc.SignerNostr {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
async getNostrPublicKey() {
|
|
17
|
-
if (this.publicKey) {
|
|
18
|
-
return this.publicKey;
|
|
19
|
-
}
|
|
20
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
21
|
-
if (!this.publicKey) {
|
|
22
|
-
throw new Error("Not connected");
|
|
23
|
-
}
|
|
24
|
-
return this.publicKey;
|
|
25
|
-
}
|
|
26
|
-
async signNostrEvent(event) {
|
|
27
|
-
return this.provider.signEvent(event);
|
|
28
|
-
}
|
|
29
|
-
async connect() {
|
|
30
|
-
this.publicKey = core_1.ccc.hexFrom(await this.provider.getPublicKey());
|
|
31
|
-
await this.connectionsRepo.set({ publicKey: this.publicKey });
|
|
32
|
-
}
|
|
33
|
-
async isConnected() {
|
|
34
|
-
if (this.publicKey) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
38
|
-
return this.publicKey !== undefined;
|
|
6
|
+
constructor(client, provider) {
|
|
7
|
+
super(client);
|
|
8
|
+
this.provider = provider;
|
|
9
|
+
this.publicKeyCache = undefined;
|
|
10
|
+
}
|
|
11
|
+
async getNostrPublicKey() {
|
|
12
|
+
if (!this.publicKeyCache) {
|
|
13
|
+
this.publicKeyCache = this.provider.getPublicKey();
|
|
39
14
|
}
|
|
15
|
+
return core_1.ccc.hexFrom(await this.publicKeyCache);
|
|
16
|
+
}
|
|
17
|
+
async signNostrEvent(event) {
|
|
18
|
+
return this.provider.signEvent({
|
|
19
|
+
...event,
|
|
20
|
+
pubkey: await this.publicKeyCache,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async connect() {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
async isConnected() {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
40
29
|
}
|
|
41
30
|
exports.Signer = Signer;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNip07Signer = void 0;
|
|
4
4
|
const signer_1 = require("./signer");
|
|
5
5
|
function getNip07Signer(client) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const windowRef = window;
|
|
7
|
+
if (typeof windowRef.nostr === "undefined") {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return new signer_1.Signer(client, windowRef.nostr);
|
|
11
11
|
}
|
|
12
12
|
exports.getNip07Signer = getNip07Signer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/nip07",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10-alpha.4",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for NIP07",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ckb-ccc/core": "0.0.
|
|
45
|
+
"@ckb-ccc/core": "0.0.10-alpha.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "61228337bbf4bdc0bc082e3c9530f843c2182106"
|
|
48
48
|
}
|
package/src/signer.ts
CHANGED
|
@@ -1,55 +1,38 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import {
|
|
3
|
-
ConnectionsRepo,
|
|
4
|
-
ConnectionsRepoLocalStorage,
|
|
5
|
-
} from "./connectionsRepo";
|
|
6
2
|
import { Provider } from "./nip07.advanced";
|
|
7
3
|
|
|
8
4
|
export class Signer extends ccc.SignerNostr {
|
|
9
|
-
private
|
|
5
|
+
private publicKeyCache?: Promise<string> = undefined;
|
|
10
6
|
|
|
11
7
|
constructor(
|
|
12
8
|
client: ccc.Client,
|
|
13
9
|
public readonly provider: Provider,
|
|
14
|
-
private readonly connectionsRepo: ConnectionsRepo = new ConnectionsRepoLocalStorage(),
|
|
15
10
|
) {
|
|
16
11
|
super(client);
|
|
17
12
|
}
|
|
18
13
|
|
|
19
|
-
async replaceClient(client: ccc.Client): Promise<boolean> {
|
|
20
|
-
return super.replaceClient(client);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
async getNostrPublicKey(): Promise<ccc.Hex> {
|
|
24
|
-
if (this.
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
29
|
-
if (!this.publicKey) {
|
|
30
|
-
throw new Error("Not connected");
|
|
15
|
+
if (!this.publicKeyCache) {
|
|
16
|
+
this.publicKeyCache = this.provider.getPublicKey();
|
|
31
17
|
}
|
|
32
18
|
|
|
33
|
-
return this.
|
|
19
|
+
return ccc.hexFrom(await this.publicKeyCache);
|
|
34
20
|
}
|
|
35
21
|
|
|
36
22
|
async signNostrEvent(
|
|
37
23
|
event: ccc.NostrEvent,
|
|
38
24
|
): Promise<Required<ccc.NostrEvent>> {
|
|
39
|
-
return this.provider.signEvent(
|
|
25
|
+
return this.provider.signEvent({
|
|
26
|
+
...event,
|
|
27
|
+
pubkey: await this.publicKeyCache,
|
|
28
|
+
});
|
|
40
29
|
}
|
|
41
30
|
|
|
42
31
|
async connect(): Promise<void> {
|
|
43
|
-
|
|
44
|
-
await this.connectionsRepo.set({ publicKey: this.publicKey });
|
|
32
|
+
return;
|
|
45
33
|
}
|
|
46
34
|
|
|
47
35
|
async isConnected(): Promise<boolean> {
|
|
48
|
-
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.publicKey = (await this.connectionsRepo.get())?.publicKey;
|
|
53
|
-
return this.publicKey !== undefined;
|
|
36
|
+
return true;
|
|
54
37
|
}
|
|
55
38
|
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Type representing a connection with public key.
|
|
4
|
-
* @typedef {Object} Connection
|
|
5
|
-
* @property {ccc.Hex} publicKey - The public key of the connection.
|
|
6
|
-
*/
|
|
7
|
-
export type Connection = {
|
|
8
|
-
readonly publicKey: ccc.Hex;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Interface representing a repository for managing connections.
|
|
12
|
-
* @interface
|
|
13
|
-
*/
|
|
14
|
-
export interface ConnectionsRepo {
|
|
15
|
-
/**
|
|
16
|
-
* Gets a connection.
|
|
17
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
18
|
-
*/
|
|
19
|
-
get(): Promise<Connection | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Sets a connection.
|
|
22
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
23
|
-
* @returns {Promise<void>} A promise that resolves when the connection is set.
|
|
24
|
-
*/
|
|
25
|
-
set(connection: Connection | undefined): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Class representing a local storage-based repository for managing connections.
|
|
29
|
-
* @class
|
|
30
|
-
* @implements {ConnectionsRepo}
|
|
31
|
-
*/
|
|
32
|
-
export declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
33
|
-
private readonly storageKey;
|
|
34
|
-
/**
|
|
35
|
-
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
36
|
-
* @param {string} [storageKey="ccc-nip07-signer"] - The local storage key.
|
|
37
|
-
*/
|
|
38
|
-
constructor(storageKey?: string);
|
|
39
|
-
/**
|
|
40
|
-
* Gets a connection.
|
|
41
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
42
|
-
*/
|
|
43
|
-
get(): Promise<Connection | undefined>;
|
|
44
|
-
/**
|
|
45
|
-
* Sets a connection.
|
|
46
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
47
|
-
* @returns {Promise<void>}
|
|
48
|
-
*/
|
|
49
|
-
set(connection: Connection | undefined): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=connectionsRepo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectionsRepo.d.ts","sourceRoot":"","sources":["../src/connectionsRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAEvC;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IAKrD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC;;;OAGG;gBAC0B,UAAU,SAAqB;IAE5D;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAK5C;;;;OAIG;IACG,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7D"}
|
package/dist/connectionsRepo.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class representing a local storage-based repository for managing connections.
|
|
3
|
-
* @class
|
|
4
|
-
* @implements {ConnectionsRepo}
|
|
5
|
-
*/
|
|
6
|
-
export class ConnectionsRepoLocalStorage {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
9
|
-
* @param {string} [storageKey="ccc-nip07-signer"] - The local storage key.
|
|
10
|
-
*/
|
|
11
|
-
constructor(storageKey = "ccc-nip07-signer") {
|
|
12
|
-
this.storageKey = storageKey;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Gets a connection.
|
|
16
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
17
|
-
*/
|
|
18
|
-
async get() {
|
|
19
|
-
const got = window.localStorage.getItem(this.storageKey);
|
|
20
|
-
return got ? JSON.parse(got) : undefined;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Sets a connection.
|
|
24
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
25
|
-
* @returns {Promise<void>}
|
|
26
|
-
*/
|
|
27
|
-
async set(connection) {
|
|
28
|
-
if (connection === undefined) {
|
|
29
|
-
window.localStorage.removeItem(this.storageKey);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
window.localStorage.setItem(this.storageKey, JSON.stringify(connection));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Type representing a connection with public key.
|
|
4
|
-
* @typedef {Object} Connection
|
|
5
|
-
* @property {ccc.Hex} publicKey - The public key of the connection.
|
|
6
|
-
*/
|
|
7
|
-
export type Connection = {
|
|
8
|
-
readonly publicKey: ccc.Hex;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Interface representing a repository for managing connections.
|
|
12
|
-
* @interface
|
|
13
|
-
*/
|
|
14
|
-
export interface ConnectionsRepo {
|
|
15
|
-
/**
|
|
16
|
-
* Gets a connection.
|
|
17
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
18
|
-
*/
|
|
19
|
-
get(): Promise<Connection | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Sets a connection.
|
|
22
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
23
|
-
* @returns {Promise<void>} A promise that resolves when the connection is set.
|
|
24
|
-
*/
|
|
25
|
-
set(connection: Connection | undefined): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Class representing a local storage-based repository for managing connections.
|
|
29
|
-
* @class
|
|
30
|
-
* @implements {ConnectionsRepo}
|
|
31
|
-
*/
|
|
32
|
-
export declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
33
|
-
private readonly storageKey;
|
|
34
|
-
/**
|
|
35
|
-
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
36
|
-
* @param {string} [storageKey="ccc-nip07-signer"] - The local storage key.
|
|
37
|
-
*/
|
|
38
|
-
constructor(storageKey?: string);
|
|
39
|
-
/**
|
|
40
|
-
* Gets a connection.
|
|
41
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
42
|
-
*/
|
|
43
|
-
get(): Promise<Connection | undefined>;
|
|
44
|
-
/**
|
|
45
|
-
* Sets a connection.
|
|
46
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
47
|
-
* @returns {Promise<void>}
|
|
48
|
-
*/
|
|
49
|
-
set(connection: Connection | undefined): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=connectionsRepo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectionsRepo.d.ts","sourceRoot":"","sources":["../src/connectionsRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAEvC;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IAKrD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC;;;OAGG;gBAC0B,UAAU,SAAqB;IAE5D;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAK5C;;;;OAIG;IACG,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7D"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConnectionsRepoLocalStorage = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a local storage-based repository for managing connections.
|
|
6
|
-
* @class
|
|
7
|
-
* @implements {ConnectionsRepo}
|
|
8
|
-
*/
|
|
9
|
-
class ConnectionsRepoLocalStorage {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
12
|
-
* @param {string} [storageKey="ccc-nip07-signer"] - The local storage key.
|
|
13
|
-
*/
|
|
14
|
-
constructor(storageKey = "ccc-nip07-signer") {
|
|
15
|
-
this.storageKey = storageKey;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Gets a connection.
|
|
19
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
20
|
-
*/
|
|
21
|
-
async get() {
|
|
22
|
-
const got = window.localStorage.getItem(this.storageKey);
|
|
23
|
-
return got ? JSON.parse(got) : undefined;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Sets a connection.
|
|
27
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
async set(connection) {
|
|
31
|
-
if (connection === undefined) {
|
|
32
|
-
window.localStorage.removeItem(this.storageKey);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
window.localStorage.setItem(this.storageKey, JSON.stringify(connection));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.ConnectionsRepoLocalStorage = ConnectionsRepoLocalStorage;
|
package/src/connectionsRepo.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Type representing a connection with public key.
|
|
5
|
-
* @typedef {Object} Connection
|
|
6
|
-
* @property {ccc.Hex} publicKey - The public key of the connection.
|
|
7
|
-
*/
|
|
8
|
-
export type Connection = {
|
|
9
|
-
readonly publicKey: ccc.Hex;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Interface representing a repository for managing connections.
|
|
14
|
-
* @interface
|
|
15
|
-
*/
|
|
16
|
-
export interface ConnectionsRepo {
|
|
17
|
-
/**
|
|
18
|
-
* Gets a connection.
|
|
19
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
20
|
-
*/
|
|
21
|
-
get(): Promise<Connection | undefined>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Sets a connection.
|
|
25
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
26
|
-
* @returns {Promise<void>} A promise that resolves when the connection is set.
|
|
27
|
-
*/
|
|
28
|
-
set(connection: Connection | undefined): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Class representing a local storage-based repository for managing connections.
|
|
33
|
-
* @class
|
|
34
|
-
* @implements {ConnectionsRepo}
|
|
35
|
-
*/
|
|
36
|
-
export class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
37
|
-
/**
|
|
38
|
-
* Creates an instance of ConnectionsRepoLocalStorage.
|
|
39
|
-
* @param {string} [storageKey="ccc-nip07-signer"] - The local storage key.
|
|
40
|
-
*/
|
|
41
|
-
constructor(private readonly storageKey = "ccc-nip07-signer") {}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Gets a connection.
|
|
45
|
-
* @returns {Promise<Connection | undefined>} A promise that resolves to the connection, if found.
|
|
46
|
-
*/
|
|
47
|
-
async get(): Promise<Connection | undefined> {
|
|
48
|
-
const got = window.localStorage.getItem(this.storageKey);
|
|
49
|
-
return got ? JSON.parse(got) : undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Sets a connection.
|
|
54
|
-
* @param {Connection | undefined} connection - The connection to set.
|
|
55
|
-
* @returns {Promise<void>}
|
|
56
|
-
*/
|
|
57
|
-
async set(connection: Connection | undefined): Promise<void> {
|
|
58
|
-
if (connection === undefined) {
|
|
59
|
-
window.localStorage.removeItem(this.storageKey);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
window.localStorage.setItem(this.storageKey, JSON.stringify(connection));
|
|
64
|
-
}
|
|
65
|
-
}
|