@keyringnetwork/keyring-connect-sdk 2.4.0 → 3.0.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/main.d.ts CHANGED
@@ -37,10 +37,7 @@ export declare class KeyringConnect {
37
37
  private static validateConfigData;
38
38
  private static convertToLaunchConfig;
39
39
  private static isChromeRuntimeAvailable;
40
- private static get communicationMethod();
41
40
  private static sendChromeMessage;
42
41
  private static launchExtensionViaChromeAPI;
43
- private static launchExtensionViaPostMessage;
44
42
  private static getExtensionStateViaChromeAPI;
45
- private static getExtensionStateViaPostMessage;
46
43
  }
package/dist/main.js CHANGED
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.KeyringConnect = void 0;
13
- const contracts_abi_1 = require("@keyringnetwork/contracts-abi");
14
13
  const types_1 = require("./types");
15
14
  /**
16
15
  * Class for interacting with the Keyring Connect browser extension
@@ -37,12 +36,7 @@ class KeyringConnect {
37
36
  }
38
37
  const validatedConfig = this.validateConfigData(data);
39
38
  const launchConfig = this.convertToLaunchConfig(validatedConfig);
40
- if (this.communicationMethod === "chromeApi") {
41
- yield this.launchExtensionViaChromeAPI(launchConfig);
42
- }
43
- else {
44
- yield this.launchExtensionViaPostMessage(launchConfig);
45
- }
39
+ yield this.launchExtensionViaChromeAPI(launchConfig);
46
40
  });
47
41
  }
48
42
  /**
@@ -69,12 +63,7 @@ class KeyringConnect {
69
63
  setTimeout(() => resolve(null), this.EXTENSION_TIMEOUT);
70
64
  });
71
65
  let extensionResponse;
72
- if (this.communicationMethod === "chromeApi") {
73
- extensionResponse = this.getExtensionStateViaChromeAPI();
74
- }
75
- else {
76
- extensionResponse = this.getExtensionStateViaPostMessage();
77
- }
66
+ extensionResponse = this.getExtensionStateViaChromeAPI();
78
67
  return Promise.race([timeout, extensionResponse]);
79
68
  });
80
69
  }
@@ -139,18 +128,16 @@ class KeyringConnect {
139
128
  }
140
129
  }
141
130
  static validateCredentialConfig(config) {
142
- if (!config.credential_config) {
143
- return config;
131
+ const { credential_config } = config;
132
+ if (!credential_config) {
133
+ throw new Error("Credential config is required");
144
134
  }
145
- if (!config.credential_config.chain_id) {
135
+ if (!credential_config.chain_id) {
146
136
  throw new Error("Chain ID is required");
147
137
  }
148
- if (!config.credential_config.wallet_address) {
138
+ if (!credential_config.wallet_address) {
149
139
  throw new Error("Wallet address is required");
150
140
  }
151
- if (!(config.credential_config.chain_id in contracts_abi_1.SupportedChainIds)) {
152
- throw new Error("Invalid chain ID");
153
- }
154
141
  return config;
155
142
  }
156
143
  static validateProofConfig(config) {
@@ -179,7 +166,6 @@ class KeyringConnect {
179
166
  client_logo_url: config.logo_url,
180
167
  client_policy_id: config.policy_id,
181
168
  client_entity_id: (_a = config.krn_config) === null || _a === void 0 ? void 0 : _a.entity_id,
182
- isolate_proving: !!config.credential_config,
183
169
  credential_config: config.credential_config,
184
170
  },
185
171
  krn_config: config.krn_config
@@ -202,12 +188,6 @@ class KeyringConnect {
202
188
  var _a;
203
189
  return typeof ((_a = chrome === null || chrome === void 0 ? void 0 : chrome.runtime) === null || _a === void 0 ? void 0 : _a.sendMessage) === "function";
204
190
  }
205
- static get communicationMethod() {
206
- if (this.isChromeRuntimeAvailable()) {
207
- return "chromeApi";
208
- }
209
- return "postMessage";
210
- }
211
191
  static sendChromeMessage(message) {
212
192
  return __awaiter(this, void 0, void 0, function* () {
213
193
  return new Promise((resolve, reject) => {
@@ -254,11 +234,6 @@ class KeyringConnect {
254
234
  });
255
235
  });
256
236
  }
257
- static launchExtensionViaPostMessage(launchConfig) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- window.postMessage({ type: types_1.EVENT_ACTIONS.LAUNCH_KEYRING_CONNECT, data: launchConfig }, "*");
260
- });
261
- }
262
237
  static getExtensionStateViaChromeAPI() {
263
238
  return __awaiter(this, void 0, void 0, function* () {
264
239
  return this.sendChromeMessage({
@@ -266,18 +241,6 @@ class KeyringConnect {
266
241
  });
267
242
  });
268
243
  }
269
- static getExtensionStateViaPostMessage() {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- return new Promise((resolve) => {
272
- window.addEventListener("message", (event) => {
273
- if (event.data.type === types_1.EVENT_ACTIONS.KEYRING_CONNECT_STATUS) {
274
- resolve(event.data.data);
275
- }
276
- });
277
- window.postMessage({ type: types_1.EVENT_ACTIONS.GET_STATUS }, "*");
278
- });
279
- });
280
- }
281
244
  }
282
245
  exports.KeyringConnect = KeyringConnect;
283
246
  KeyringConnect.EXTENSION_TIMEOUT = 2000;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { KrnSupportedChainId as SupportedChainId } from "@keyringnetwork/contracts-abi";
2
1
  export declare enum EVENT_ACTIONS {
3
2
  LAUNCH_KEYRING_CONNECT = "LAUNCH_KEYRING_CONNECT",
4
3
  GET_STATUS = "GET_STATUS",
@@ -25,7 +24,7 @@ export type ExtensionSDKConfig = {
25
24
  * The wallet address and chain ID of the user.
26
25
  */
27
26
  credential_config: {
28
- chain_id: SupportedChainId;
27
+ chain_id: number;
29
28
  wallet_address: string;
30
29
  };
31
30
  /**
@@ -57,9 +56,8 @@ export type ExtensionLaunchConfig = {
57
56
  client_logo_url: string;
58
57
  client_policy_id: number;
59
58
  client_entity_id?: string;
60
- isolate_proving?: boolean;
61
59
  credential_config: {
62
- chain_id: SupportedChainId;
60
+ chain_id: number;
63
61
  wallet_address: string;
64
62
  };
65
63
  };
@@ -78,7 +76,6 @@ export type ExtensionLaunchConfig = {
78
76
  access_token?: string;
79
77
  };
80
78
  };
81
- export type ExtensionCommunicationMethod = "chromeApi" | "postMessage";
82
79
  export type ExtensionStatus = "idle" | "mounted" | "proving" | "prove_error" | "prove_success" | "error";
83
80
  export type AttestationStatus = "onboarding_required" | "onboarding_pending" | "attestation_ready" | "non_compliant";
84
81
  export type CredentialStatus = "expired" | "valid" | "none";
package/package.json CHANGED
@@ -1,26 +1,23 @@
1
1
  {
2
2
  "name": "@keyringnetwork/keyring-connect-sdk",
3
- "version": "2.4.0",
3
+ "version": "3.0.0",
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",
7
+ "scripts": {
8
+ "build": "rm -rf dist && tsc",
9
+ "dev": "tsc --watch",
10
+ "build_and_publish": "pnpm build && npm publish"
11
+ },
7
12
  "files": [
8
13
  "dist"
9
14
  ],
10
15
  "keywords": [],
11
16
  "author": "",
12
17
  "license": "ISC",
13
- "dependencies": {
14
- "@keyringnetwork/contracts-abi": "2.4.0"
15
- },
16
18
  "devDependencies": {
17
19
  "@types/chrome": "^0.0.268",
18
20
  "ts-node": "^10.9.2",
19
21
  "typescript": "^5.6.3"
20
- },
21
- "scripts": {
22
- "build": "rm -rf dist && tsc",
23
- "dev": "tsc --watch",
24
- "build_and_publish": "pnpm build && npm publish"
25
22
  }
26
- }
23
+ }
package/readme.md CHANGED
@@ -17,7 +17,6 @@ pnpm install @keyringnetwork/keyring-connect-sdk
17
17
  - Redirect the user back to the app where they left off after extension installation
18
18
  - Monitor extension status and user state
19
19
  - Full TypeScript support with comprehensive type definitions
20
- - Support for isolated proving mode (verification without credential creation)
21
20
 
22
21
  ## Usage
23
22
 
@@ -41,6 +40,10 @@ const extensionConfig = {
41
40
  app_url: "https://myapp.com",
42
41
  logo_url: "https://myapp.com/logo.png",
43
42
  policy_id: 123,
43
+ credential_config: {
44
+ chain_id: 1,
45
+ wallet_address: '0x123abc'
46
+ }
44
47
  };
45
48
 
46
49
  // This method handles both launching the extension if installed