@ckb-ccc/nip07 0.0.8-alpha.3 → 0.0.9-alpha.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/dist/signer.d.ts CHANGED
@@ -6,7 +6,6 @@ export declare class Signer extends ccc.SignerNostr {
6
6
  private readonly connectionsRepo;
7
7
  private publicKey;
8
8
  constructor(client: ccc.Client, provider: Provider, connectionsRepo?: ConnectionsRepo);
9
- static isValidClient(client: ccc.Client): boolean;
10
9
  replaceClient(client: ccc.Client): Promise<boolean>;
11
10
  getNostrPublicKey(): Promise<ccc.Hex>;
12
11
  signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
@@ -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,EACL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe;IALlC,OAAO,CAAC,SAAS,CAAkC;gBAGjD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,eAAe,GAAE,eAAmD;IAKvF,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO;IAI3C,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAarC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAQtC"}
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe;IALlC,OAAO,CAAC,SAAS,CAAkC;gBAGjD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,eAAe,GAAE,eAAmD;IAKjF,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAarC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAQtC"}
package/dist/signer.js CHANGED
@@ -7,13 +7,7 @@ export class Signer extends ccc.SignerNostr {
7
7
  this.connectionsRepo = connectionsRepo;
8
8
  this.publicKey = undefined;
9
9
  }
10
- static isValidClient(client) {
11
- return client.addressPrefix === "ckt";
12
- }
13
10
  async replaceClient(client) {
14
- if (!Signer.isValidClient(client)) {
15
- return false;
16
- }
17
11
  return super.replaceClient(client);
18
12
  }
19
13
  async getNostrPublicKey() {
@@ -1,7 +1,7 @@
1
1
  import { Signer } from "./signer";
2
2
  export function getNip07Signer(client) {
3
3
  const windowRef = window;
4
- if (typeof windowRef.nostr === "undefined" || !Signer.isValidClient(client)) {
4
+ if (typeof windowRef.nostr === "undefined") {
5
5
  return;
6
6
  }
7
7
  return new Signer(client, windowRef.nostr);
@@ -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,48 +1,27 @@
1
1
  "use strict";
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) {
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 (mod) {
37
19
  if (mod && mod.__esModule) return mod;
38
20
  var result = {};
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);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
22
  __setModuleDefault(result, mod);
44
23
  return result;
45
- };
24
+ };
46
25
  Object.defineProperty(exports, "__esModule", { value: true });
47
26
  exports.Nip07A = void 0;
48
27
  exports.Nip07A = __importStar(require("./nip07.advanced"));
@@ -1,3 +1,3 @@
1
1
  export * from "./signer";
2
2
  export * from "./signersFactory";
3
- //# sourceMappingURL=barrel.d.ts.map
3
+ //# sourceMappingURL=barrel.d.ts.map
@@ -1,34 +1,18 @@
1
1
  "use strict";
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
- };
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 __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
+ };
32
16
  Object.defineProperty(exports, "__esModule", { value: true });
33
17
  __exportStar(require("./signer"), exports);
34
18
  __exportStar(require("./signersFactory"), exports);
@@ -5,24 +5,24 @@ import { ccc } from "@ckb-ccc/core";
5
5
  * @property {ccc.Hex} publicKey - The public key of the connection.
6
6
  */
7
7
  export type Connection = {
8
- readonly publicKey: ccc.Hex;
8
+ readonly publicKey: ccc.Hex;
9
9
  };
10
10
  /**
11
11
  * Interface representing a repository for managing connections.
12
12
  * @interface
13
13
  */
14
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>;
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
26
  }
27
27
  /**
28
28
  * Class representing a local storage-based repository for managing connections.
@@ -30,22 +30,22 @@ export interface ConnectionsRepo {
30
30
  * @implements {ConnectionsRepo}
31
31
  */
32
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>;
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
50
  }
51
- //# sourceMappingURL=connectionsRepo.d.ts.map
51
+ //# sourceMappingURL=connectionsRepo.d.ts.map
@@ -7,32 +7,32 @@ exports.ConnectionsRepoLocalStorage = void 0;
7
7
  * @implements {ConnectionsRepo}
8
8
  */
9
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;
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));
34
36
  }
35
- window.localStorage.setItem(this.storageKey, JSON.stringify(connection));
36
- }
37
37
  }
38
38
  exports.ConnectionsRepoLocalStorage = ConnectionsRepoLocalStorage;
@@ -1,2 +1,2 @@
1
1
  export * as Nip07 from "./barrel";
2
- //# sourceMappingURL=index.d.ts.map
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1,48 +1,27 @@
1
1
  "use strict";
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) {
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 (mod) {
37
19
  if (mod && mod.__esModule) return mod;
38
20
  var result = {};
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);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
22
  __setModuleDefault(result, mod);
44
23
  return result;
45
- };
24
+ };
46
25
  Object.defineProperty(exports, "__esModule", { value: true });
47
26
  exports.Nip07 = void 0;
48
27
  exports.Nip07 = __importStar(require("./barrel"));
@@ -1,6 +1,6 @@
1
1
  import { ccc } from "@ckb-ccc/core";
2
2
  export interface Provider {
3
- getPublicKey(): Promise<string>;
4
- signEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
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
@@ -2,19 +2,14 @@ import { ccc } from "@ckb-ccc/core";
2
2
  import { ConnectionsRepo } from "./connectionsRepo";
3
3
  import { Provider } from "./nip07.advanced";
4
4
  export declare class Signer extends ccc.SignerNostr {
5
- readonly provider: Provider;
6
- private readonly connectionsRepo;
7
- private publicKey;
8
- constructor(
9
- client: ccc.Client,
10
- provider: Provider,
11
- connectionsRepo?: ConnectionsRepo,
12
- );
13
- static isValidClient(client: ccc.Client): boolean;
14
- replaceClient(client: ccc.Client): Promise<boolean>;
15
- getNostrPublicKey(): Promise<ccc.Hex>;
16
- signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
17
- connect(): Promise<void>;
18
- isConnected(): Promise<boolean>;
5
+ readonly provider: Provider;
6
+ private readonly connectionsRepo;
7
+ private publicKey;
8
+ constructor(client: ccc.Client, provider: Provider, connectionsRepo?: ConnectionsRepo);
9
+ replaceClient(client: ccc.Client): Promise<boolean>;
10
+ getNostrPublicKey(): Promise<ccc.Hex>;
11
+ signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
12
+ connect(): Promise<void>;
13
+ isConnected(): Promise<boolean>;
19
14
  }
20
- //# sourceMappingURL=signer.d.ts.map
15
+ //# 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,EACL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe;IALlC,OAAO,CAAC,SAAS,CAAkC;gBAGjD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,eAAe,GAAE,eAAmD;IAKvF,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO;IAI3C,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAarC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAQtC"}
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,MAAO,SAAQ,GAAG,CAAC,WAAW;aAKvB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe;IALlC,OAAO,CAAC,SAAS,CAAkC;gBAGjD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,eAAe,GAAE,eAAmD;IAKjF,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAarC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAQtC"}
@@ -4,48 +4,38 @@ exports.Signer = void 0;
4
4
  const core_1 = require("@ckb-ccc/core");
5
5
  const connectionsRepo_1 = require("./connectionsRepo");
6
6
  class Signer extends core_1.ccc.SignerNostr {
7
- constructor(
8
- client,
9
- provider,
10
- connectionsRepo = new connectionsRepo_1.ConnectionsRepoLocalStorage(),
11
- ) {
12
- super(client);
13
- this.provider = provider;
14
- this.connectionsRepo = connectionsRepo;
15
- this.publicKey = undefined;
16
- }
17
- static isValidClient(client) {
18
- return client.addressPrefix === "ckt";
19
- }
20
- async replaceClient(client) {
21
- if (!Signer.isValidClient(client)) {
22
- return false;
7
+ constructor(client, provider, connectionsRepo = new connectionsRepo_1.ConnectionsRepoLocalStorage()) {
8
+ super(client);
9
+ this.provider = provider;
10
+ this.connectionsRepo = connectionsRepo;
11
+ this.publicKey = undefined;
23
12
  }
24
- return super.replaceClient(client);
25
- }
26
- async getNostrPublicKey() {
27
- if (this.publicKey) {
28
- return this.publicKey;
13
+ async replaceClient(client) {
14
+ return super.replaceClient(client);
29
15
  }
30
- this.publicKey = (await this.connectionsRepo.get())?.publicKey;
31
- if (!this.publicKey) {
32
- throw new Error("Not connected");
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;
33
25
  }
34
- return this.publicKey;
35
- }
36
- async signNostrEvent(event) {
37
- return this.provider.signEvent(event);
38
- }
39
- async connect() {
40
- this.publicKey = core_1.ccc.hexFrom(await this.provider.getPublicKey());
41
- await this.connectionsRepo.set({ publicKey: this.publicKey });
42
- }
43
- async isConnected() {
44
- if (this.publicKey) {
45
- return true;
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;
46
39
  }
47
- this.publicKey = (await this.connectionsRepo.get())?.publicKey;
48
- return this.publicKey !== undefined;
49
- }
50
40
  }
51
41
  exports.Signer = Signer;
@@ -1,4 +1,4 @@
1
1
  import { ccc } from "@ckb-ccc/core";
2
2
  import { Signer } from "./signer";
3
3
  export declare function getNip07Signer(client: ccc.Client): Signer | undefined;
4
- //# sourceMappingURL=signersFactory.d.ts.map
4
+ //# sourceMappingURL=signersFactory.d.ts.map
@@ -3,13 +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
- const windowRef = window;
7
- if (
8
- typeof windowRef.nostr === "undefined" ||
9
- !signer_1.Signer.isValidClient(client)
10
- ) {
11
- return;
12
- }
13
- return new signer_1.Signer(client, windowRef.nostr);
6
+ const windowRef = window;
7
+ if (typeof windowRef.nostr === "undefined") {
8
+ return;
9
+ }
10
+ return new signer_1.Signer(client, windowRef.nostr);
14
11
  }
15
12
  exports.getNip07Signer = getNip07Signer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ckb-ccc/nip07",
3
- "version": "0.0.8-alpha.3",
4
- "description": "Common Chains Connector's support for NIP07",
3
+ "version": "0.0.9-alpha.0",
4
+ "description": "CCC - CKBer's Codebase. Common Chains Connector's support for NIP07",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@ckb-ccc/core": "0.0.8-alpha.3"
45
+ "@ckb-ccc/core": "0.0.9-alpha.0"
46
46
  },
47
- "gitHead": "bddfa3e5631252194dfde32b79ee589703f18afb"
47
+ "gitHead": "ac4435006da9c9e48b3b66fc329e6f539156b252"
48
48
  }
package/src/signer.ts CHANGED
@@ -16,14 +16,7 @@ export class Signer extends ccc.SignerNostr {
16
16
  super(client);
17
17
  }
18
18
 
19
- static isValidClient(client: ccc.Client): boolean {
20
- return client.addressPrefix === "ckt";
21
- }
22
-
23
19
  async replaceClient(client: ccc.Client): Promise<boolean> {
24
- if (!Signer.isValidClient(client)) {
25
- return false;
26
- }
27
20
  return super.replaceClient(client);
28
21
  }
29
22
 
@@ -5,7 +5,7 @@ import { Signer } from "./signer";
5
5
  export function getNip07Signer(client: ccc.Client): Signer | undefined {
6
6
  const windowRef = window as { nostr?: Provider };
7
7
 
8
- if (typeof windowRef.nostr === "undefined" || !Signer.isValidClient(client)) {
8
+ if (typeof windowRef.nostr === "undefined") {
9
9
  return;
10
10
  }
11
11