@keyringnetwork/keyring-connect-sdk 2.0.2 → 2.1.1

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.
@@ -272,7 +272,7 @@
272
272
  "label": "Profile information from Kraken"
273
273
  }
274
274
  ],
275
- "target_url": null,
275
+ "target_url": "https://www.kraken.com/",
276
276
  "user_actions": [
277
277
  "Log in",
278
278
  "Navigate to your Profile page",
@@ -597,7 +597,8 @@
597
597
  "headers": [
598
598
  "Cookie",
599
599
  "User-Agent",
600
- "x-device-id"
600
+ "x-device-id",
601
+ "x-client-version"
601
602
  ],
602
603
  "method": "GET",
603
604
  "required_cookies": null,
@@ -607,7 +608,7 @@
607
608
  "label": "User information from revolut"
608
609
  }
609
610
  ],
610
- "target_url": "https://app.revolut.com/api/retail/user/current/wallet",
611
+ "target_url": null,
611
612
  "user_actions": [
612
613
  "Login",
613
614
  "Navigate to your profile page",
@@ -653,7 +654,7 @@
653
654
  "label": "KYC from Keyring Connect"
654
655
  }
655
656
  ],
656
- "target_url": null,
657
+ "target_url": "https://app.keyringdev.network/",
657
658
  "user_actions": [
658
659
  "Make sure you have logged in",
659
660
  "Navigate to the marketplace"
@@ -0,0 +1 @@
1
+ export declare const EXTENSION_TIMEOUT = 2000;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXTENSION_TIMEOUT = void 0;
4
+ exports.EXTENSION_TIMEOUT = 2000;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { KeyringConnect } from './main';
2
- export * from './types';
1
+ export { KeyringConnect } from "./main";
2
+ export * from "./types";
package/dist/main.d.ts CHANGED
@@ -5,18 +5,21 @@ import { ExtensionSDKConfig, ExtensionState } from "./types";
5
5
  export declare class KeyringConnect {
6
6
  private static keyringConnectUrl;
7
7
  /**
8
- * Launch the Keyring Connect Extension with the provided configuration
9
- * @note This will redirect to the Keyring Connect page if it is not installed
8
+ * Tries to launch the Keyring Connect Extension with the provided configuration.
9
+ * If the extension is not installed, it will redirect to the Keyring Connect page.
10
+ * @param data - The configuration for the extension
10
11
  */
11
12
  static launchExtension(data: ExtensionSDKConfig): Promise<void>;
12
13
  /**
13
14
  * Check if Keyring Connect Extension is installed and ready to use
15
+ * @returns Promise that resolves with true if extension is installed and ready to use, false otherwise
14
16
  */
15
17
  static isKeyringConnectInstalled(): Promise<boolean>;
16
18
  /**
17
- * Get the current state of the Keyring Connect Extension to allow for UI updates
19
+ * Get the current state of the Keyring Connect Extension
20
+ * @returns Promise that resolves with extension state or null if unavailable
18
21
  */
19
- static getExtensionState(): Promise<ExtensionState>;
22
+ static getExtensionState(): Promise<ExtensionState | null>;
20
23
  private static validateClientConfig;
21
24
  private static validateCredentialConfig;
22
25
  private static validateProofConfig;
package/dist/main.js CHANGED
@@ -13,6 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.KeyringConnect = void 0;
16
+ const contracts_abi_1 = require("@keyringnetwork/contracts-abi");
17
+ const constants_1 = require("./constants");
16
18
  const datasources_json_1 = __importDefault(require("./constants/datasources.json"));
17
19
  const types_1 = require("./types");
18
20
  /**
@@ -20,8 +22,9 @@ const types_1 = require("./types");
20
22
  */
21
23
  class KeyringConnect {
22
24
  /**
23
- * Launch the Keyring Connect Extension with the provided configuration
24
- * @note This will redirect to the Keyring Connect page if it is not installed
25
+ * Tries to launch the Keyring Connect Extension with the provided configuration.
26
+ * If the extension is not installed, it will redirect to the Keyring Connect page.
27
+ * @param data - The configuration for the extension
25
28
  */
26
29
  static launchExtension(data) {
27
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -45,15 +48,12 @@ class KeyringConnect {
45
48
  }
46
49
  /**
47
50
  * Check if Keyring Connect Extension is installed and ready to use
51
+ * @returns Promise that resolves with true if extension is installed and ready to use, false otherwise
48
52
  */
49
53
  static isKeyringConnectInstalled() {
50
54
  return __awaiter(this, void 0, void 0, function* () {
51
55
  try {
52
- const timeout = new Promise((resolve) => {
53
- setTimeout(() => resolve(false), 2000);
54
- });
55
- const checkExtension = this.getExtensionState().then((state) => Boolean(state.manifest));
56
- return Promise.race([timeout, checkExtension]);
56
+ return this.getExtensionState().then((state) => state ? Boolean(state.manifest) : false);
57
57
  }
58
58
  catch (error) {
59
59
  return false;
@@ -61,11 +61,15 @@ class KeyringConnect {
61
61
  });
62
62
  }
63
63
  /**
64
- * Get the current state of the Keyring Connect Extension to allow for UI updates
64
+ * Get the current state of the Keyring Connect Extension
65
+ * @returns Promise that resolves with extension state or null if unavailable
65
66
  */
66
67
  static getExtensionState() {
67
68
  return __awaiter(this, void 0, void 0, function* () {
68
- return new Promise((resolve) => {
69
+ const timeout = new Promise((resolve) => {
70
+ setTimeout(() => resolve(null), constants_1.EXTENSION_TIMEOUT);
71
+ });
72
+ const extensionResponse = new Promise((resolve) => {
69
73
  window.addEventListener("message", (event) => {
70
74
  if (event.data.type === types_1.EVENT_ACTIONS.KEYRING_CONNECT_STATUS) {
71
75
  resolve(event.data.data);
@@ -73,6 +77,7 @@ class KeyringConnect {
73
77
  });
74
78
  window.postMessage({ type: types_1.EVENT_ACTIONS.GET_STATUS }, "*");
75
79
  });
80
+ return Promise.race([timeout, extensionResponse]);
76
81
  });
77
82
  }
78
83
  static validateClientConfig(config) {
@@ -99,8 +104,7 @@ class KeyringConnect {
99
104
  if (!config.credential_config.wallet_address) {
100
105
  throw new Error("Wallet address is required");
101
106
  }
102
- const validChainIds = Object.keys(types_1.CHAIN_IDS[types_1.CHAIN_FAMILY.EVM]).map((key) => types_1.CHAIN_IDS[types_1.CHAIN_FAMILY.EVM][key]);
103
- if (!validChainIds.includes(config.credential_config.chain_id)) {
107
+ if (!(config.credential_config.chain_id in contracts_abi_1.SupportedChainIds)) {
104
108
  throw new Error("Invalid chain ID");
105
109
  }
106
110
  return config;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { KrnSupportedChainId as SupportedChainId } from "@keyringnetwork/contracts-abi";
1
2
  export declare enum EVENT_ACTIONS {
2
3
  LAUNCH_KEYRING_CONNECT = "LAUNCH_KEYRING_CONNECT",
3
4
  GET_STATUS = "GET_STATUS",
@@ -23,7 +24,7 @@ export type ExtensionSDKConfig = {
23
24
  */
24
25
  logo_url: string;
25
26
  /**
26
- * The policy ID of the client.
27
+ * The onchain policy ID of the client.
27
28
  */
28
29
  policy_id: number;
29
30
  /**
@@ -55,28 +56,6 @@ export type ExtensionSDKConfig = {
55
56
  websocketProxyUrl?: string;
56
57
  };
57
58
  };
58
- export declare enum CHAIN_FAMILY {
59
- EVM = "EVM",
60
- SOLANA = "SOLANA"
61
- }
62
- export declare const CHAIN_IDS: {
63
- readonly EVM: {
64
- readonly MAINNET: 1;
65
- readonly OPTIMISM: 10;
66
- readonly SEPOLIA: 11155111;
67
- readonly ARBITRUM: 42161;
68
- readonly BASE: 8453;
69
- readonly ZKSYNC: 324;
70
- readonly AVALANCHE: 43114;
71
- readonly POLYGON: 137;
72
- readonly HOLESKY: 17000;
73
- };
74
- readonly SOLANA: {
75
- readonly MAINNET: 1915121141;
76
- };
77
- };
78
- export type EVMChainId = (typeof CHAIN_IDS)[typeof CHAIN_FAMILY.EVM][keyof (typeof CHAIN_IDS)[typeof CHAIN_FAMILY.EVM]];
79
- export type SupportedChainId = EVMChainId;
80
59
  export type ExtensionLaunchConfig = {
81
60
  client: {
82
61
  client_name: string;
package/dist/types.js CHANGED
@@ -1,31 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHAIN_IDS = exports.CHAIN_FAMILY = exports.EVENT_ACTIONS = void 0;
3
+ exports.EVENT_ACTIONS = void 0;
4
4
  var EVENT_ACTIONS;
5
5
  (function (EVENT_ACTIONS) {
6
6
  EVENT_ACTIONS["LAUNCH_KEYRING_CONNECT"] = "LAUNCH_KEYRING_CONNECT";
7
7
  EVENT_ACTIONS["GET_STATUS"] = "GET_STATUS";
8
8
  EVENT_ACTIONS["KEYRING_CONNECT_STATUS"] = "KEYRING_CONNECT_STATUS";
9
9
  })(EVENT_ACTIONS || (exports.EVENT_ACTIONS = EVENT_ACTIONS = {}));
10
- var CHAIN_FAMILY;
11
- (function (CHAIN_FAMILY) {
12
- CHAIN_FAMILY["EVM"] = "EVM";
13
- CHAIN_FAMILY["SOLANA"] = "SOLANA";
14
- })(CHAIN_FAMILY || (exports.CHAIN_FAMILY = CHAIN_FAMILY = {}));
15
- // Define chain IDs by family
16
- exports.CHAIN_IDS = {
17
- [CHAIN_FAMILY.EVM]: {
18
- MAINNET: 1,
19
- OPTIMISM: 10,
20
- SEPOLIA: 11155111,
21
- ARBITRUM: 42161,
22
- BASE: 8453,
23
- ZKSYNC: 324,
24
- AVALANCHE: 43114,
25
- POLYGON: 137,
26
- HOLESKY: 17000,
27
- },
28
- [CHAIN_FAMILY.SOLANA]: {
29
- MAINNET: 1915121141,
30
- },
31
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyringnetwork/keyring-connect-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.1.1",
4
4
  "description": "An SDK for interacting with Keyring Connect browser extension",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,9 +16,11 @@
16
16
  "keywords": [],
17
17
  "author": "",
18
18
  "license": "ISC",
19
+ "dependencies": {
20
+ "@keyringnetwork/contracts-abi": "2.2.0"
21
+ },
19
22
  "devDependencies": {
20
23
  "ts-node": "^10.9.2",
21
24
  "typescript": "^5.6.3"
22
- },
23
- "dependencies": {}
25
+ }
24
26
  }