@keyringnetwork/keyring-connect-sdk 2.0.0 → 2.0.2

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
@@ -18,6 +18,7 @@ export declare class KeyringConnect {
18
18
  */
19
19
  static getExtensionState(): Promise<ExtensionState>;
20
20
  private static validateClientConfig;
21
+ private static validateCredentialConfig;
21
22
  private static validateProofConfig;
22
23
  private static validateDatasource;
23
24
  private static validateConfigData;
package/dist/main.js CHANGED
@@ -89,6 +89,22 @@ class KeyringConnect {
89
89
  throw new Error("Policy ID is required");
90
90
  }
91
91
  }
92
+ static validateCredentialConfig(config) {
93
+ if (!config.credential_config) {
94
+ return config;
95
+ }
96
+ if (!config.credential_config.chain_id) {
97
+ throw new Error("Chain ID is required");
98
+ }
99
+ if (!config.credential_config.wallet_address) {
100
+ throw new Error("Wallet address is required");
101
+ }
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)) {
104
+ throw new Error("Invalid chain ID");
105
+ }
106
+ return config;
107
+ }
92
108
  static validateProofConfig(config) {
93
109
  var _a;
94
110
  if ((_a = config.proof_config) === null || _a === void 0 ? void 0 : _a.datasource) {
@@ -121,6 +137,7 @@ class KeyringConnect {
121
137
  const validatedConfig = this.validateDatasource(config);
122
138
  this.validateClientConfig(validatedConfig);
123
139
  this.validateProofConfig(validatedConfig);
140
+ this.validateCredentialConfig(validatedConfig);
124
141
  return validatedConfig;
125
142
  }
126
143
  static convertToLaunchConfig(config) {
@@ -132,7 +149,8 @@ class KeyringConnect {
132
149
  client_logo_url: config.logo_url,
133
150
  client_policy_id: config.policy_id,
134
151
  client_entity_id: (_a = config.krn_config) === null || _a === void 0 ? void 0 : _a.entity_id,
135
- isolate_proving: config.isolate_proving,
152
+ isolate_proving: !!config.credential_config,
153
+ credential_config: config.credential_config,
136
154
  },
137
155
  krn_config: config.krn_config
138
156
  ? {
package/dist/types.d.ts CHANGED
@@ -27,9 +27,12 @@ export type ExtensionSDKConfig = {
27
27
  */
28
28
  policy_id: number;
29
29
  /**
30
- * Whether to isolate the proving process. If true, will skip wallet interaction and on-chain credential creation
30
+ * If configured, will skip wallet interaction and on-chain credential creation and return calldata instead.
31
31
  */
32
- isolate_proving?: boolean;
32
+ credential_config?: {
33
+ chain_id: SupportedChainId;
34
+ wallet_address: string;
35
+ };
33
36
  /**
34
37
  * Additional configuration to customize the extension's verification process.
35
38
  * @note should be used with caution as strict validation is applied to the proof config.
@@ -52,6 +55,28 @@ export type ExtensionSDKConfig = {
52
55
  websocketProxyUrl?: string;
53
56
  };
54
57
  };
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;
55
80
  export type ExtensionLaunchConfig = {
56
81
  client: {
57
82
  client_name: string;
@@ -60,6 +85,10 @@ export type ExtensionLaunchConfig = {
60
85
  client_policy_id: number;
61
86
  client_entity_id?: string;
62
87
  isolate_proving?: boolean;
88
+ credential_config?: {
89
+ chain_id: SupportedChainId;
90
+ wallet_address: string;
91
+ };
63
92
  };
64
93
  proof_config?: {
65
94
  datasource?: DataSource;
@@ -76,7 +105,7 @@ export type ExtensionLaunchConfig = {
76
105
  access_token?: string;
77
106
  };
78
107
  };
79
- export type ExtensionStatus = "idle" | "mounted" | "proving" | "prove_success" | "error";
108
+ export type ExtensionStatus = "idle" | "mounted" | "proving" | "prove_error" | "prove_success" | "error";
80
109
  export type AttestationStatus = "onboarding_required" | "onboarding_pending" | "attestation_ready" | "non_compliant";
81
110
  export type CredentialStatus = "expired" | "valid" | "none";
82
111
  export type User = {
@@ -107,6 +136,7 @@ export interface ExtensionState {
107
136
  error?: string;
108
137
  user?: User;
109
138
  tlsn_proof?: string;
139
+ credentialData?: CredentialData;
110
140
  }
111
141
  export interface DataSource {
112
142
  id: string;
@@ -149,3 +179,13 @@ export interface DisclosableField {
149
179
  path: string;
150
180
  key: string;
151
181
  }
182
+ export interface CredentialData {
183
+ trader: `0x${string}`;
184
+ policyId: number;
185
+ chainId: number;
186
+ validUntil: number;
187
+ cost: number;
188
+ key: string;
189
+ signature: string;
190
+ backdoor: string;
191
+ }
package/dist/types.js CHANGED
@@ -1,9 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVENT_ACTIONS = void 0;
3
+ exports.CHAIN_IDS = exports.CHAIN_FAMILY = 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.0",
3
+ "version": "2.0.2",
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",
@@ -21,4 +21,4 @@
21
21
  "typescript": "^5.6.3"
22
22
  },
23
23
  "dependencies": {}
24
- }
24
+ }
package/readme.md CHANGED
@@ -41,8 +41,6 @@ const extensionConfig = {
41
41
  app_url: "https://myapp.com",
42
42
  logo_url: "https://myapp.com/logo.png",
43
43
  policy_id: 123,
44
- // Optional: Enable isolated proving mode
45
- // isolate_proving: true,
46
44
  };
47
45
 
48
46
  // This method handles both launching the extension if installed
@@ -96,8 +94,6 @@ function KeyringConnectButton() {
96
94
  name: "My App",
97
95
  logo_url: "https://myapp.com/logo.png",
98
96
  policy_id: 7,
99
- // For verification without credential creation:
100
- // isolate_proving: true,
101
97
  };
102
98
 
103
99
  // Launch the extension (handles both installed and not installed cases)
@@ -117,12 +113,6 @@ function KeyringConnectButton() {
117
113
  }
118
114
  ```
119
115
 
120
- With isolated proving mode enabled, the extension will:
121
- - Focus solely on the verification process
122
- - Skip wallet connection and credential creation
123
- - Redirect back to your app when verification is complete
124
- - Provide simplified UI with no tabs or credential options
125
-
126
116
  ## API Reference
127
117
 
128
118
  #### Core Types Overview
@@ -133,7 +123,7 @@ With isolated proving mode enabled, the extension will:
133
123
 
134
124
  #### Status Types
135
125
 
136
- - `ExtensionStatus`: Extension states (`idle`, `mounted`, `proving`, `prove_success`, `error`)
126
+ - `ExtensionStatus`: Extension states (`idle`, `mounted`, `proving`, `prove_error`, `prove_success`, `error`)
137
127
  - `AttestationStatus`: Off-chain verification status (`onboarding_required`, `onboarding_pending`, `attestation_ready`, `non_compliant`)
138
128
  - `CredentialStatus`: On-chain credential status (`expired`, `valid`, `none`)
139
129