@keyringnetwork/keyring-connect-sdk 1.0.8 → 1.1.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.
@@ -34,27 +34,33 @@
34
34
  "disclosable_fields": [
35
35
  {
36
36
  "label": "first name",
37
- "path": "data.fillInfo.firstName"
37
+ "path": "data.fillInfo.firstName",
38
+ "key": "first_name"
38
39
  },
39
40
  {
40
41
  "label": "last name",
41
- "path": "data.fillInfo.lastName"
42
+ "path": "data.fillInfo.lastName",
43
+ "key": "last_name"
42
44
  },
43
45
  {
44
46
  "label": "dob",
45
- "path": "data.fillInfo.dob"
47
+ "path": "data.fillInfo.dob",
48
+ "key": "dob"
46
49
  },
47
50
  {
48
51
  "label": "kyc level",
49
- "path": "data.passKycLevel"
52
+ "path": "data.passKycLevel",
53
+ "key": "kyc_level"
50
54
  },
51
55
  {
52
56
  "label": "country of primary address",
53
- "path": "data.fillInfo.residenceCountry"
57
+ "path": "data.fillInfo.residenceCountry",
58
+ "key": "country_of_primary_address"
54
59
  },
55
60
  {
56
61
  "label": "account type",
57
- "path": "data.type"
62
+ "path": "data.type",
63
+ "key": "account_type"
58
64
  }
59
65
  ],
60
66
  "headers": [
@@ -99,23 +105,28 @@
99
105
  "disclosable_fields": [
100
106
  {
101
107
  "label": "kyb status",
102
- "path": "data.kycStatus"
108
+ "path": "data.kycStatus",
109
+ "key": "kyb_status"
103
110
  },
104
111
  {
105
112
  "label": "company name",
106
- "path": "data.fillInfo.companyName"
113
+ "path": "data.fillInfo.companyName",
114
+ "key": "company_name"
107
115
  },
108
116
  {
109
117
  "label": "country of primary address",
110
- "path": "data.fillInfo.residenceCountry"
118
+ "path": "data.fillInfo.residenceCountry",
119
+ "key": "country_of_primary_address"
111
120
  },
112
121
  {
113
122
  "label": "kyb message detail",
114
- "path": "data.frontDisplayLevelMsg"
123
+ "path": "data.frontDisplayLevelMsg",
124
+ "key": "kyb_message_detail"
115
125
  },
116
126
  {
117
127
  "label": "account type",
118
- "path": "data.type"
128
+ "path": "data.type",
129
+ "key": "account_type"
119
130
  }
120
131
  ],
121
132
  "headers": [
@@ -185,23 +196,28 @@
185
196
  "disclosable_fields": [
186
197
  {
187
198
  "label": "user kyc",
188
- "path": "result.access.user_kyc"
199
+ "path": "result.access.user_kyc",
200
+ "key": "user_kyc"
189
201
  },
190
202
  {
191
203
  "label": "first name",
192
- "path": "result.first_name"
204
+ "path": "result.first_name",
205
+ "key": "first_name"
193
206
  },
194
207
  {
195
208
  "label": "country",
196
- "path": "result.country"
209
+ "path": "result.country",
210
+ "key": "country"
197
211
  },
198
212
  {
199
213
  "label": "tier bucket",
200
- "path": "result.tier_bucket"
214
+ "path": "result.tier_bucket",
215
+ "key": "tier_bucket"
201
216
  },
202
217
  {
203
218
  "label": "tier verified",
204
- "path": "result.tier_verified"
219
+ "path": "result.tier_verified",
220
+ "key": "tier_verified"
205
221
  }
206
222
  ],
207
223
  "headers": [
@@ -250,23 +266,28 @@
250
266
  "disclosable_fields": [
251
267
  {
252
268
  "label": "user kyc",
253
- "path": "result.access.user_kyc"
269
+ "path": "result.access.user_kyc",
270
+ "key": "user_kyc"
254
271
  },
255
272
  {
256
273
  "label": "first name",
257
- "path": "result.first_name"
274
+ "path": "result.first_name",
275
+ "key": "first_name"
258
276
  },
259
277
  {
260
278
  "label": "country",
261
- "path": "result.country"
279
+ "path": "result.country",
280
+ "key": "country"
262
281
  },
263
282
  {
264
283
  "label": "tier bucket",
265
- "path": "result.tier_bucket"
284
+ "path": "result.tier_bucket",
285
+ "key": "tier_bucket"
266
286
  },
267
287
  {
268
288
  "label": "tier verified",
269
- "path": "result.tier_verified"
289
+ "path": "result.tier_verified",
290
+ "key": "tier_verified"
270
291
  }
271
292
  ],
272
293
  "headers": [
@@ -331,15 +352,18 @@
331
352
  "disclosable_fields": [
332
353
  {
333
354
  "label": "country",
334
- "path": "data.userDetails.country"
355
+ "path": "data.userDetails.country",
356
+ "key": "country"
335
357
  },
336
358
  {
337
359
  "label": "kyc level",
338
- "path": "data.userKycStatus.kycLevel"
360
+ "path": "data.userKycStatus.kycLevel",
361
+ "key": "kyc_level"
339
362
  },
340
363
  {
341
364
  "label": "kyc type",
342
- "path": "data.userKycStatus.kycType"
365
+ "path": "data.userKycStatus.kycType",
366
+ "key": "kyc_type"
343
367
  }
344
368
  ],
345
369
  "headers": [
@@ -387,15 +411,18 @@
387
411
  "disclosable_fields": [
388
412
  {
389
413
  "label": "country of primary address",
390
- "path": "data.userDetails.country"
414
+ "path": "data.userDetails.country",
415
+ "key": "country_of_primary_address"
391
416
  },
392
417
  {
393
418
  "label": "kyc level",
394
- "path": "data.userKycStatus.kycLevel"
419
+ "path": "data.userKycStatus.kycLevel",
420
+ "key": "kyc_level"
395
421
  },
396
422
  {
397
423
  "label": "kyc type",
398
- "path": "data.userKycStatus.kycType"
424
+ "path": "data.userKycStatus.kycType",
425
+ "key": "kyc_type"
399
426
  }
400
427
  ],
401
428
  "headers": [
@@ -440,11 +467,13 @@
440
467
  "disclosable_fields": [
441
468
  {
442
469
  "label": "full name",
443
- "path": "customer.name"
470
+ "path": "customer.name",
471
+ "key": "full_name"
444
472
  },
445
473
  {
446
474
  "label": "mailing address",
447
- "path": "customer.addresses.mailing"
475
+ "path": "customer.addresses.mailing",
476
+ "key": "mailing_address"
448
477
  }
449
478
  ],
450
479
  "headers": [
@@ -505,11 +534,13 @@
505
534
  "disclosable_fields": [
506
535
  {
507
536
  "label": "next requirement",
508
- "path": "data.viewer.userProperties.nextRequirement"
537
+ "path": "data.viewer.userProperties.nextRequirement",
538
+ "key": "next_requirement"
509
539
  },
510
540
  {
511
541
  "label": "country",
512
- "path": "data.viewer.userProperties.country.code"
542
+ "path": "data.viewer.userProperties.country.code",
543
+ "key": "country"
513
544
  }
514
545
  ],
515
546
  "headers": [
@@ -577,19 +608,23 @@
577
608
  "disclosable_fields": [
578
609
  {
579
610
  "label": "country address",
580
- "path": "user.address.country"
611
+ "path": "user.address.country",
612
+ "key": "country_address"
581
613
  },
582
614
  {
583
615
  "label": "user status",
584
- "path": "user.state"
616
+ "path": "user.state",
617
+ "key": "user_status"
585
618
  },
586
619
  {
587
620
  "label": "kyc verification",
588
- "path": "user.kyc"
621
+ "path": "user.kyc",
622
+ "key": "kyc_verification"
589
623
  },
590
624
  {
591
625
  "label": "under review",
592
- "path": "user.underReview"
626
+ "path": "user.underReview",
627
+ "key": "under_review"
593
628
  }
594
629
  ],
595
630
  "headers": [
package/dist/main.js CHANGED
@@ -13,7 +13,6 @@ 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 jwt_decode_1 = require("jwt-decode");
17
16
  const datasources_json_1 = __importDefault(require("./constants/datasources.json"));
18
17
  const types_1 = require("./types");
19
18
  /**
@@ -26,7 +25,6 @@ class KeyringConnect {
26
25
  */
27
26
  static launchExtension(data) {
28
27
  return __awaiter(this, void 0, void 0, function* () {
29
- var _a;
30
28
  const keyringConnectAvailable = yield this.isKeyringConnectInstalled();
31
29
  if (!keyringConnectAvailable) {
32
30
  if (typeof window !== "undefined") {
@@ -40,19 +38,7 @@ class KeyringConnect {
40
38
  return;
41
39
  }
42
40
  const validatedConfig = this.validateConfigData(data);
43
- let launchConfig = this.convertToLaunchConfig(validatedConfig);
44
- if ((_a = data.krn_config) === null || _a === void 0 ? void 0 : _a.auth0_id_token) {
45
- try {
46
- const decodedJwt = (0, jwt_decode_1.jwtDecode)(data.krn_config.auth0_id_token);
47
- if (!decodedJwt) {
48
- throw new Error("Failed to decode auth token");
49
- }
50
- launchConfig.auth_user = Object.assign(Object.assign({}, decodedJwt), { id_token: data.krn_config.auth0_id_token });
51
- }
52
- catch (error) {
53
- throw new Error("Invalid auth token provided");
54
- }
55
- }
41
+ const launchConfig = this.convertToLaunchConfig(validatedConfig);
56
42
  console.log("launching keyring connect");
57
43
  window.postMessage({ type: types_1.EVENT_ACTIONS.LAUNCH_KEYRING_CONNECT, data: launchConfig }, "*");
58
44
  });
@@ -115,7 +101,10 @@ class KeyringConnect {
115
101
  }
116
102
  }
117
103
  static validateDatasource(config) {
118
- var _a;
104
+ var _a, _b;
105
+ if (!((_a = config.proof_config) === null || _a === void 0 ? void 0 : _a.datasource)) {
106
+ return config;
107
+ }
119
108
  const datasource = datasources_json_1.default.find((datasource) => { var _a, _b; return datasource.id === ((_b = (_a = config.proof_config) === null || _a === void 0 ? void 0 : _a.datasource) === null || _b === void 0 ? void 0 : _b.id); });
120
109
  const knownDatasources = datasources_json_1.default
121
110
  .map((datasource) => datasource.name)
@@ -124,7 +113,7 @@ class KeyringConnect {
124
113
  throw new Error(`Unsupported datasource. Connect to either of the supported datasources: ${knownDatasources}`);
125
114
  }
126
115
  return Object.assign(Object.assign({}, config), { proof_config: {
127
- entity_type: (_a = config.proof_config) === null || _a === void 0 ? void 0 : _a.entity_type,
116
+ entity_type: (_b = config.proof_config) === null || _b === void 0 ? void 0 : _b.entity_type,
128
117
  datasource,
129
118
  } });
130
119
  }
@@ -135,7 +124,7 @@ class KeyringConnect {
135
124
  return validatedConfig;
136
125
  }
137
126
  static convertToLaunchConfig(config) {
138
- var _a;
127
+ var _a, _b;
139
128
  const launchConfig = {
140
129
  client: {
141
130
  client_name: config.name,
@@ -146,8 +135,7 @@ class KeyringConnect {
146
135
  },
147
136
  krn_config: config.krn_config
148
137
  ? {
149
- onboarding_api_url: config.krn_config.onboarding_api_url,
150
- datastore_api_url: config.krn_config.datastore_api_url,
138
+ keyring_api_url: config.krn_config.keyring_api_url,
151
139
  analytics_api_url: config.krn_config.analytics_api_url,
152
140
  isolate_proving: config.krn_config.isolate_proving,
153
141
  notaryUrl: config.krn_config.notaryUrl,
@@ -156,6 +144,9 @@ class KeyringConnect {
156
144
  }
157
145
  : undefined,
158
146
  proof_config: config.proof_config,
147
+ session_info: {
148
+ access_token: (_b = config.krn_config) === null || _b === void 0 ? void 0 : _b.keyring_access_token,
149
+ },
159
150
  };
160
151
  return launchConfig;
161
152
  }
package/dist/types.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare enum EVENT_ACTIONS {
6
6
  export type PartialDataSource = Pick<DataSource, "id"> & Partial<DataSource>;
7
7
  export type ValidatedConfig = ExtensionSDKConfig & {
8
8
  proof_config: {
9
- datasource: DataSource;
9
+ datasource?: DataSource;
10
10
  };
11
11
  };
12
12
  export type ExtensionSDKConfig = {
@@ -31,7 +31,7 @@ export type ExtensionSDKConfig = {
31
31
  * @note should be used with caution as strict validation is applied to the proof config.
32
32
  */
33
33
  proof_config?: {
34
- datasource: PartialDataSource;
34
+ datasource?: PartialDataSource;
35
35
  entity_type?: string;
36
36
  };
37
37
  /**
@@ -39,10 +39,9 @@ export type ExtensionSDKConfig = {
39
39
  * @note this is meant to be used for internal testing and development purposes.
40
40
  */
41
41
  krn_config?: {
42
- onboarding_api_url?: string;
43
- datastore_api_url?: string;
42
+ keyring_api_url?: string;
44
43
  analytics_api_url?: string;
45
- auth0_id_token?: string;
44
+ keyring_access_token?: string;
46
45
  entity_id?: string;
47
46
  isolate_proving?: boolean;
48
47
  notaryUrl?: string;
@@ -59,23 +58,24 @@ export type ExtensionLaunchConfig = {
59
58
  client_entity_id?: string;
60
59
  };
61
60
  proof_config?: {
62
- datasource: DataSource;
61
+ datasource?: DataSource;
63
62
  entity_type?: string;
64
63
  };
65
64
  krn_config?: {
66
- onboarding_api_url?: string;
67
- datastore_api_url?: string;
65
+ keyring_api_url?: string;
68
66
  analytics_api_url?: string;
69
67
  isolate_proving?: boolean;
70
68
  notaryUrl?: string;
71
69
  notaryWebsocketUrl?: string;
72
70
  websocketProxyUrl?: string;
73
71
  };
74
- auth_user?: any;
72
+ session_info?: {
73
+ access_token?: string;
74
+ };
75
75
  };
76
- export type ExtensionStatus = 'idle' | 'mounted' | 'proving' | 'prove_success' | 'error';
77
- export type AttestationStatus = 'onboarding_required' | 'onboarding_pending' | 'attestation_ready' | 'non_compliant';
78
- export type CredentialStatus = 'expired' | 'valid' | 'none';
76
+ export type ExtensionStatus = "idle" | "mounted" | "proving" | "prove_success" | "error";
77
+ export type AttestationStatus = "onboarding_required" | "onboarding_pending" | "attestation_ready" | "non_compliant";
78
+ export type CredentialStatus = "expired" | "valid" | "none";
79
79
  export type User = {
80
80
  /**
81
81
  * Off-chain attestation status.
@@ -109,7 +109,7 @@ export interface DataSource {
109
109
  id: string;
110
110
  name: string;
111
111
  label: string;
112
- user_actions?: string[];
112
+ user_actions: string[];
113
113
  link: string;
114
114
  login_url: string;
115
115
  target_url: string | null;
@@ -127,9 +127,9 @@ export interface TlsnEndpoint {
127
127
  method: string;
128
128
  headers: string[];
129
129
  disclosable_fields: DisclosableField[];
130
- required_cookies?: string[] | null;
131
- data_bounds?: DataBounds | null;
132
- body?: string | null;
130
+ required_cookies: string[] | null;
131
+ data_bounds: DataBounds | null;
132
+ body: string | null;
133
133
  }
134
134
  export interface Claim {
135
135
  id: string;
@@ -144,4 +144,5 @@ export interface DataBounds {
144
144
  export interface DisclosableField {
145
145
  label: string;
146
146
  path: string;
147
+ key: string;
147
148
  }
package/package.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
2
  "name": "@keyringnetwork/keyring-connect-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.1.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 && pnpm get:datasources && tsc",
9
- "dev": "pnpm get:datasources && tsc --watch",
10
- "publish:sdk": "pnpm build && npm publish",
11
- "get:datasources": "node ../../scripts/parseDatasource.js -o src/constants/datasources.json"
12
- },
13
7
  "files": [
14
8
  "dist"
15
9
  ],
@@ -22,5 +16,11 @@
22
16
  },
23
17
  "dependencies": {
24
18
  "jwt-decode": "^4.0.0"
19
+ },
20
+ "scripts": {
21
+ "build": "rm -rf dist && pnpm get:datasources && tsc",
22
+ "dev": "pnpm get:datasources && tsc --watch",
23
+ "build_and_publish": "pnpm build && npm publish",
24
+ "get:datasources": "node ../../scripts/parseDatasource.js -o src/constants/datasources.json"
25
25
  }
26
26
  }