@keyringnetwork/keyring-connect-sdk 1.0.4 → 1.0.6

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
@@ -3,9 +3,10 @@ import { ExtensionSDKConfig, ExtensionState } from './types';
3
3
  * Class for interacting with the Keyring Connect browser extension
4
4
  */
5
5
  export declare class KeyringConnect {
6
+ private static keyringConnectUrl;
6
7
  /**
7
8
  * Launch the Keyring Connect Extension with the provided configuration
8
- * @note This will throw an error if the extension is not installed
9
+ * @note This will redirect to the Keyring Connect page if it is not installed
9
10
  */
10
11
  static launchExtension(data: ExtensionSDKConfig): Promise<void>;
11
12
  /**
package/dist/main.js CHANGED
@@ -18,14 +18,22 @@ const types_1 = require("./types");
18
18
  class KeyringConnect {
19
19
  /**
20
20
  * Launch the Keyring Connect Extension with the provided configuration
21
- * @note This will throw an error if the extension is not installed
21
+ * @note This will redirect to the Keyring Connect page if it is not installed
22
22
  */
23
23
  static launchExtension(data) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  var _a;
26
26
  const keyringConnectAvailable = yield this.isKeyringConnectInstalled();
27
27
  if (!keyringConnectAvailable) {
28
- throw new Error('Keyring Connect is not installed');
28
+ if (typeof window !== "undefined") {
29
+ const url = new URL(this.keyringConnectUrl);
30
+ url.searchParams.set("ref", window.location.href);
31
+ window.location.href = url.toString();
32
+ }
33
+ else {
34
+ throw new Error("Keyring Connect is not installed");
35
+ }
36
+ return;
29
37
  }
30
38
  this.validateClientConfig(data);
31
39
  this.validateProofConfig(data);
@@ -34,16 +42,16 @@ class KeyringConnect {
34
42
  try {
35
43
  const decodedJwt = (0, jwt_decode_1.jwtDecode)(data.krn_config.auth0_id_token);
36
44
  if (!decodedJwt) {
37
- throw new Error('Failed to decode auth token');
45
+ throw new Error("Failed to decode auth token");
38
46
  }
39
47
  launchConfig.auth_user = Object.assign(Object.assign({}, decodedJwt), { id_token: data.krn_config.auth0_id_token });
40
48
  }
41
49
  catch (error) {
42
- throw new Error('Invalid auth token provided');
50
+ throw new Error("Invalid auth token provided");
43
51
  }
44
52
  }
45
- console.log('launching keyring connect');
46
- window.postMessage({ type: types_1.EVENT_ACTIONS.LAUNCH_KEYRING_CONNECT, data: launchConfig }, '*');
53
+ console.log("launching keyring connect");
54
+ window.postMessage({ type: types_1.EVENT_ACTIONS.LAUNCH_KEYRING_CONNECT, data: launchConfig }, "*");
47
55
  });
48
56
  }
49
57
  /**
@@ -69,37 +77,37 @@ class KeyringConnect {
69
77
  static getExtensionState() {
70
78
  return __awaiter(this, void 0, void 0, function* () {
71
79
  return new Promise((resolve) => {
72
- window.addEventListener('message', (event) => {
80
+ window.addEventListener("message", (event) => {
73
81
  if (event.data.type === types_1.EVENT_ACTIONS.KEYRING_CONNECT_STATUS) {
74
82
  resolve(event.data.data);
75
83
  }
76
84
  });
77
- window.postMessage({ type: types_1.EVENT_ACTIONS.GET_STATUS }, '*');
85
+ window.postMessage({ type: types_1.EVENT_ACTIONS.GET_STATUS }, "*");
78
86
  });
79
87
  });
80
88
  }
81
89
  static validateClientConfig(config) {
82
90
  if (!config.name) {
83
- throw new Error('Name is required');
91
+ throw new Error("Name is required");
84
92
  }
85
93
  if (!config.app_url) {
86
- throw new Error('App URL is required');
94
+ throw new Error("App URL is required");
87
95
  }
88
96
  if (!config.logo_url) {
89
- throw new Error('Logo URL is required');
97
+ throw new Error("Logo URL is required");
90
98
  }
91
99
  if (!config.policy_id) {
92
- throw new Error('Policy ID is required');
100
+ throw new Error("Policy ID is required");
93
101
  }
94
102
  }
95
103
  static validateProofConfig(config) {
96
104
  var _a;
97
105
  if ((_a = config.proof_config) === null || _a === void 0 ? void 0 : _a.datasource) {
98
106
  if (config.proof_config.datasource.proof_sources.length === 0) {
99
- throw new Error('At least one proof source is required');
107
+ throw new Error("At least one proof source is required");
100
108
  }
101
109
  if (!config.proof_config.datasource.proof_sources.some((source) => source.claims.length > 0)) {
102
- throw new Error('At least one claim is required per proof source');
110
+ throw new Error("At least one claim is required per proof source");
103
111
  }
104
112
  }
105
113
  }
@@ -118,6 +126,10 @@ class KeyringConnect {
118
126
  onboarding_api_url: config.krn_config.onboarding_api_url,
119
127
  datastore_api_url: config.krn_config.datastore_api_url,
120
128
  analytics_api_url: config.krn_config.analytics_api_url,
129
+ isolate_proving: config.krn_config.isolate_proving,
130
+ notaryUrl: config.krn_config.notaryUrl,
131
+ notaryWebsocketUrl: config.krn_config.notaryWebsocketUrl,
132
+ websocketProxyUrl: config.krn_config.websocketProxyUrl,
121
133
  }
122
134
  : undefined,
123
135
  proof_config: config.proof_config,
@@ -126,3 +138,4 @@ class KeyringConnect {
126
138
  }
127
139
  }
128
140
  exports.KeyringConnect = KeyringConnect;
141
+ KeyringConnect.keyringConnectUrl = "https://app.keyring.network/connect";
package/dist/types.d.ts CHANGED
@@ -38,6 +38,10 @@ export type ExtensionSDKConfig = {
38
38
  analytics_api_url?: string;
39
39
  auth0_id_token?: string;
40
40
  entity_id?: string;
41
+ isolate_proving?: boolean;
42
+ notaryUrl?: string;
43
+ notaryWebsocketUrl?: string;
44
+ websocketProxyUrl?: string;
41
45
  };
42
46
  };
43
47
  export type ExtensionLaunchConfig = {
@@ -56,6 +60,10 @@ export type ExtensionLaunchConfig = {
56
60
  onboarding_api_url?: string;
57
61
  datastore_api_url?: string;
58
62
  analytics_api_url?: string;
63
+ isolate_proving?: boolean;
64
+ notaryUrl?: string;
65
+ notaryWebsocketUrl?: string;
66
+ websocketProxyUrl?: string;
59
67
  };
60
68
  auth_user?: any;
61
69
  };
@@ -89,6 +97,7 @@ export interface ExtensionState {
89
97
  manifest?: any;
90
98
  error?: string;
91
99
  user?: User;
100
+ tlsn_proof?: string;
92
101
  }
93
102
  export interface DataSource {
94
103
  id: string;
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@keyringnetwork/keyring-connect-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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
+ "publish": "pnpm build && npm publish"
11
+ },
7
12
  "files": [
8
13
  "dist"
9
14
  ],
@@ -16,9 +21,5 @@
16
21
  },
17
22
  "dependencies": {
18
23
  "jwt-decode": "^4.0.0"
19
- },
20
- "scripts": {
21
- "build": "tsc",
22
- "dev": "tsc --watch"
23
24
  }
24
25
  }