@experian-ecs/connected-api-sdk 1.0.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.
package/LICENSE.md ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright © 2025 EXPERIAN. All rights reserved.
3
+ *
4
+ * This code is provided for inclusion in a website and is intended solely for execution by end
5
+ * users in web browsers or on an application server. Unauthorized modification, redistribution, or any other use is prohibited. This
6
+ * notice should be included with any use of this code.
7
+ *
8
+ * THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
9
+ * BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
10
+ * IN NO EVENT SHALL CSIDENTITY CORPORATION OR ITS AFFILIATES BE LIABLE FOR ANY CLAIM, DAMAGES, OR
11
+ * OTHER LIABILITY ARISING FROM OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE.
12
+ */
package/LICENSE.txt ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright © 2025 EXPERIAN. All rights reserved.
3
+ *
4
+ * This code is provided for inclusion in a website and is intended solely for execution by end
5
+ * users in web browsers or on an application server. Unauthorized modification, redistribution, or any other use is prohibited. This
6
+ * notice should be included with any use of this code.
7
+ *
8
+ * THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
9
+ * BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
10
+ * IN NO EVENT SHALL CSIDENTITY CORPORATION OR ITS AFFILIATES BE LIABLE FOR ANY CLAIM, DAMAGES, OR
11
+ * OTHER LIABILITY ARISING FROM OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE.
12
+ */
package/README.md ADDED
@@ -0,0 +1,606 @@
1
+ # Connected Solutions Experience API SDK
2
+
3
+ 1. [Authentication](#authentication)
4
+ 1. [NodeJS](#nodejs)
5
+ 2. [Browser](#browser)
6
+ 2. [Usage](#usage)
7
+ 1. [Response format](#response-format)
8
+ 2. [Alerts](#alerts)
9
+ 3. [Credit Reports](#credit-reports)
10
+ 4. [Credit Attributes](#credit-attributes)
11
+ 5. [Credit Scores](#credit-scores)
12
+ 6. [Credit Score Planner](#credit-score-planner)
13
+ 7. [Credit Score Simulator](#credit-score-simulator)
14
+ 8. [Customer Auth](#customer-auth)
15
+ 9. [Customers](#customers)
16
+ 10. [Entitlements](#entitlements)
17
+ 11. [Product Configs](#product-configs)
18
+ 12. [Registrations](#registrations)
19
+ 3. [Utilities](#utilities)
20
+ 1. [Type Guards](#type-guards)
21
+
22
+ ## Authentication
23
+
24
+ ### NodeJs
25
+
26
+ * #### Instantiate the sdk
27
+
28
+ ```tsx
29
+ import { createSDK } from '@experian-ecs/connected-api-sdk'
30
+
31
+ // environment can either be 'PRODUCTION' or 'SANDBOX'
32
+ const sdk = createSDK({ environment: 'PRODUCTION' })
33
+ ```
34
+
35
+ * #### Retrieve an access token
36
+
37
+ ```tsx
38
+ const tokenRequest = await sdk.auth.getAccessToken({
39
+ grantType: 'trusted_partner',
40
+ clientId: process.env.SDK_CLIENT_ID!,
41
+ clientSecret: process.env.SDK_CLIENT_SECRET!,
42
+ customerId: 'cus_01'
43
+ });
44
+ ```
45
+
46
+ * #### Set the authentication token on the sdk instance
47
+
48
+ ```tsx
49
+ sdk.setConfig({
50
+ token: tokenRequest.data?.access_token
51
+ });
52
+ ```
53
+
54
+ ### Browser
55
+
56
+ If using the sdk in the browser the `auth.getAccessToken` method will throw an error to prevent the user from exposing their client id and client secret in the public browser environment. Because of this, the user will need to retrieve a valid oauth token outside of the sdk and provide it to the configuration object passed to `createSDK`.
57
+
58
+ * #### Instantiate the sdk with a token
59
+
60
+ ```tsx
61
+ import { createSDK } from '@experian-ecs/connected-api-sdk'
62
+
63
+ // environment can either be 'PRODUCTION' or 'SANDBOX'
64
+ const sdk = createSDK({
65
+ environment: 'PRODUCTION',
66
+ token: 'your-oauth-token'
67
+ })
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Response format
73
+
74
+ * All calls to sdk methods return a single object with `data`, `error`, `meta` keys.
75
+
76
+ ```tsx
77
+ const { data, error, meta } = await sdk.creditScores.getCreditScores();
78
+ ```
79
+
80
+ * Success example
81
+
82
+ ```tsx
83
+ {
84
+ data: [ {...}, {...} ],
85
+ error: undefined,
86
+ meta: {
87
+ status: 200,
88
+ statusText: 'OK'
89
+ }
90
+ }
91
+ ```
92
+
93
+ * Error example
94
+
95
+ ```tsx
96
+ {
97
+ data: undefined,
98
+ error: [ConnectedSolutionsClientAuthError]: User Not Authorized
99
+ at ft.St [as generateError] (file:/stack/trace/path)
100
+ at k.fetchRequest (file:/stack/trace/path)
101
+ at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
102
+ at async k.fetchWithAuth (file:/stack/trace/path)
103
+ at async file:/stack/trace/path {
104
+ data: {
105
+ dev_url: 'https://experian.com/unity/docs/UNAUTHORIZED',
106
+ code: 'UNAUTHORIZED',
107
+ message: 'User Not Authorized'
108
+ },
109
+ status: 401
110
+ },
111
+ meta: {
112
+ status: 401,
113
+ statusText: 'User Not Authorized'
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Alerts
119
+
120
+ * #### Retrieve all alerts
121
+
122
+ ```tsx
123
+ await sdk.alerts.getAlerts();
124
+ ```
125
+
126
+ * #### Retrieve a single alert
127
+
128
+ ```tsx
129
+ await sdk.alerts.getAlertById({ id: 'alr_01' });
130
+ ```
131
+
132
+ * #### Retrieve counts for all alerts
133
+
134
+ ```tsx
135
+ await sdk.alerts.getAlertCounts();
136
+ ```
137
+
138
+ * #### Mark an alert as read
139
+
140
+ ```tsx
141
+ await sdk.alerts.markAlertAsRead({ id: 'alr_01' });
142
+ ```
143
+
144
+ ### Credit Attributes
145
+
146
+ * #### Retrieve attribute data for all historical reports
147
+
148
+ ```tsx
149
+ await sdk.creditAttributes.getCreditAttributes();
150
+ ```
151
+
152
+ ### Credit Reports
153
+
154
+ * #### Retrieve all historical reports
155
+
156
+ ```tsx
157
+ await sdk.creditReports.getReports({
158
+ product_config_id: 'procfg_01',
159
+ include_fields: 'report_display',
160
+ })
161
+ ```
162
+
163
+ * #### Retrieve a single report
164
+
165
+ ```tsx
166
+ await sdk.creditReports.getReportById({
167
+ id: '',
168
+ include_fields: 'report_display',
169
+ });
170
+ ```
171
+
172
+ * #### Retrieve all historical report summaries
173
+
174
+ ```tsx
175
+ await sdk.creditReports.getReportMeta();
176
+ ```
177
+
178
+ * #### Retrieve a single report summary
179
+
180
+ ```tsx
181
+ await sdk.creditReports.getReportMetaById({ id: '' });
182
+ ```
183
+
184
+ * #### Order a new report
185
+
186
+ ```tsx
187
+ await sdk.creditReports.orderReport({
188
+ product_config_id: 'procfg_01',
189
+ include_fields: 'report_display',
190
+ });
191
+ ```
192
+
193
+ * #### Mark a report as read
194
+
195
+ ```tsx
196
+ await sdk.creditReports.markReportAsRead({
197
+ id: '',
198
+ include_fields: 'report_display',
199
+ });
200
+ ```
201
+
202
+ ### Credit Scores
203
+
204
+ * #### Retrieve all historical scores
205
+
206
+ ```tsx
207
+ await sdk.creditScores.getCreditScores();
208
+ ```
209
+
210
+ * #### Retrieve all historical scores with factors information
211
+
212
+ ```tsx
213
+ await sdk.creditScores.getCreditScores({ include_factors: true });
214
+ ```
215
+
216
+ * #### Retrieve all historical scores with ingredients information - FICO Only
217
+
218
+ ```tsx
219
+ await sdk.creditScores.getCreditScores({ include_ingredients: true });
220
+ ```
221
+
222
+ * #### Order a new score
223
+
224
+ ```tsx
225
+ await sdk.creditScores.orderCreditScore({
226
+ product_config_id: 'procfg_01'
227
+ });
228
+ ```
229
+
230
+ ### Credit Score Planner
231
+
232
+ * #### Get current plan
233
+
234
+ ```tsx
235
+ await sdk.creditScorePlanner.getCreditScorePlan({
236
+ product_config_id: 'procfg_01'
237
+ });
238
+ ```
239
+
240
+ * #### Get timeline options for creating a plan
241
+
242
+ ```tsx
243
+ // FICO
244
+ await sdk.creditScorePlanner.getCreditScorePlanRevisions({
245
+ product_config_id: 'procfg_01',
246
+ target_score: 800
247
+ });
248
+
249
+ // VANTAGE
250
+ await sdk.creditScorePlanner.getCreditScorePlanRevisions({
251
+ product_config_id: 'procfg_01',
252
+ max_actions_per_plan: 5
253
+ });
254
+ ```
255
+
256
+ * #### Create a new plan
257
+
258
+ ```tsx
259
+ const { data, error } = await sdk.creditScorePlanner.getCreditScorePlanRevisions({
260
+ product_config_id: 'procfg_01',
261
+ target_score: 800,
262
+ })
263
+
264
+ if(data) {
265
+ const [ selectedRevision, ...revisions ] = data;
266
+
267
+ await sdk.creditScorePlanner.createCreditScorePlan({
268
+ product_config_id: 'procfg_01',
269
+ ...selectedRevision
270
+ });
271
+
272
+ } else {
273
+ console.error(error)
274
+ }
275
+ ```
276
+
277
+ * #### Delete your current plan
278
+
279
+ ```tsx
280
+ await sdk.creditScorePlanner.deleteCreditScorePlan({
281
+ product_config_id: 'procfg_01'
282
+ });
283
+ ```
284
+
285
+ ### Credit Score Simulator
286
+
287
+ * #### Get all scenarios available for simulation
288
+
289
+ Vantage will return both the simulations and their simulated results from this method.
290
+
291
+ FICO will return only the possible simulations, and will require an additional call to `simulateScenario` to get the results of the selected simulation. Example below.
292
+
293
+ ```tsx
294
+ await sdk.creditScoreSimulator.getSimulations({
295
+ product_config_id: 'procfg_01'
296
+ });
297
+ ```
298
+
299
+ * #### Simulate a scenario - FICO Only
300
+
301
+ ```tsx
302
+ import { isFicoScenario } from '@experian-ecs/connected-api-sdk'
303
+
304
+ const { data, error } = await sdk.creditScoreSimulator.getSimulations({
305
+ product_config_id: 'procfg_01'
306
+ })
307
+
308
+ if(data){
309
+ const {
310
+ simulations: [ selectedScenario, ...simulations ]
311
+ } = data;
312
+
313
+ if(isFicoScenario(selectedScenario)){
314
+ const { scenario, variations } = selectedScenario;
315
+
316
+ const simulationResult = await sdk.creditScoreSimulator.simulateScenario({
317
+ product_config_id: 'procfg_01',
318
+ scenario,
319
+ variations
320
+ })
321
+ }
322
+ } else {
323
+ console.error(error)
324
+ }
325
+ ```
326
+
327
+ ### Customer Auth
328
+
329
+ * #### Retrieve knowledge based authentication questions
330
+
331
+ ```tsx
332
+ const questionsRequest = await sdk.customerAuth.getAuthQuestions();
333
+ ```
334
+
335
+ * #### Submit answers to knowledge based authentication questions
336
+
337
+ ```tsx
338
+ await sdk.customerAuth.submitAuthAnswers({
339
+ answers: [
340
+ {
341
+ answer_order: 1,
342
+ choice_id: '1',
343
+ },
344
+ {
345
+ answer_order: 2,
346
+ choice_id: '2',
347
+
348
+ },
349
+ ],
350
+ authentication_id: questionsRequest.authentication_id,
351
+ authentication_session_id: questionsRequest.authentication_session_id
352
+ })
353
+ ```
354
+
355
+ ### Customers
356
+
357
+ * #### Retrieve a customer
358
+
359
+ ```tsx
360
+ await sdk.customers.getCustomerById({ customer_id: 'cus_01' });
361
+ ```
362
+
363
+ * #### Update a customer
364
+
365
+ ```tsx
366
+ await sdk.customers.updateCustomer({
367
+ customer_id: 'cus_01',
368
+ first_name: '';
369
+ // any other customer fields
370
+ });
371
+ ```
372
+
373
+ * #### Delete a customer
374
+
375
+ ```tsx
376
+ await sdk.customers.deleteCustomer({ customer_id: 'cus_01' });
377
+ ```
378
+
379
+ * #### Search customers by fields
380
+
381
+ ```tsx
382
+ await sdk.customers.searchCustomers({
383
+ count: 10,
384
+ name: { first_name: 'John' },
385
+ });
386
+ ```
387
+
388
+ * #### Create a new customer
389
+
390
+ ```tsx
391
+ await sdk.customers.createCustomer({
392
+ people_id: '',
393
+ reference_id: '',
394
+ first_name: '',
395
+ middle_initial: '',
396
+ last_name: '',
397
+ suffix: '',
398
+ addresses: [
399
+ {
400
+ address_type: 'CURRENT_RESIDENTIAL',
401
+ address1: '',
402
+ address2: '',
403
+ city: '',
404
+ state: '',
405
+ zip: '',
406
+ country_code: 'US',
407
+ },
408
+ ],
409
+ phones: [
410
+ {
411
+ phone_type: 'HOME',
412
+ phone_country_code: '001',
413
+ phone_number: '123-494-3566',
414
+ },
415
+ ],
416
+ emails: [
417
+ {
418
+ email_type: 'PERSONAL',
419
+ email_address: 'test@experian.com',
420
+ },
421
+ ],
422
+ social_security_number: '',
423
+ date_of_birth: 'yyy-mm-dd',
424
+ outside_auth: false,
425
+ disclosure: {
426
+ accepted_at: 'yyy-mm-ddT00:00:00.000+00:00',
427
+ },
428
+ });
429
+ ```
430
+
431
+ ### Entitlements
432
+
433
+ * #### Retrieve all entitlements for a customer
434
+
435
+ ```tsx
436
+ await sdk.entitlements.getEntitlements({ customer_id: 'cus_01' })
437
+ ```
438
+
439
+ * #### Retrieve an entitlement by id
440
+
441
+ ```tsx
442
+ await sdk.entitlements.getEntitlementById({ entitlement_id: 'ent_01' })
443
+ ```
444
+
445
+ * #### Create a new entitlement for a customer with one or more products
446
+
447
+ ```tsx
448
+ await sdk.entitlements.createEntitlement({
449
+ name: '',
450
+ description: '',
451
+ product_config_ids: [
452
+ 'procfg_01'
453
+ ];
454
+ customer_id: 'cus_01';
455
+ })
456
+ ```
457
+
458
+ * #### Update an existing entitlement for a customer
459
+
460
+ ```tsx
461
+ await sdk.entitlements.updateEntitlement({
462
+ entitlement_id: 'ent_01',
463
+ product_config_ids: [
464
+ 'procfg_01'
465
+ ];
466
+ customer_id: 'cus_01';
467
+ });
468
+ ```
469
+
470
+ * #### Delete an entitlement
471
+
472
+ ```tsx
473
+ await sdk.entitlements.deleteEntitlement({ entitlement_id: '' });
474
+ ```
475
+
476
+ * #### Activate an exisiting entitlement
477
+
478
+ ```tsx
479
+ await sdk.entitlements.activateEntitlement({ entitlement_id: '' });
480
+ ```
481
+
482
+ * #### Entitle customer to a new product
483
+
484
+ ```tsx
485
+ await sdk.entitlements.entitleCustomerToNewProduct({
486
+ entitlement_id: 'ent_01',
487
+ product_config_id: 'procfg_01',
488
+ customer_id: 'cus_01'
489
+ });
490
+ ```
491
+
492
+ * #### Activate a product already entitled to a customer
493
+
494
+ ```tsx
495
+ await sdk.entitlements.activateProduct({
496
+ product_config_id: 'procfg_01',
497
+ entitlement_id: 'ent_01'
498
+ });
499
+ ```
500
+
501
+ * #### Get the eligibility status for an existing product entitled to a customer
502
+
503
+ ```tsx
504
+ await sdk.entitlements.getProductEligibility({
505
+ product_config_id: 'procfg_01',
506
+ customer_id: 'cus_01'
507
+ });
508
+ ```
509
+
510
+ ### Product Configs
511
+
512
+ * #### Retrieve product configurations for a tenant
513
+
514
+ ```tsx
515
+ await sdk.productConfigs.getProductConfigs();
516
+ ```
517
+
518
+ * #### Retrieve a single product configuration for a tenant
519
+
520
+ ```tsx
521
+ await sdk.productConfigs.getProductConfigById({
522
+ product_config_id: 'procfg_01'
523
+ });
524
+ ```
525
+
526
+ ### Registrations
527
+
528
+ * #### Create a customer, create an entitlement, and activate product(s) in a single request
529
+
530
+ ```tsx
531
+ await sdk.registrations.createRegistration({
532
+ customer: {
533
+ phones: [
534
+ {
535
+ phone_type: 'HOME',
536
+ phone_country_code: '',
537
+ phone_number: '',
538
+ },
539
+ ],
540
+ date_of_birth: '',
541
+ last_name: '',
542
+ suffix: '',
543
+ social_security_number: '',
544
+ disclosure: {
545
+ accepted_at: 'yyyy-mm-ddT00:00:00.000+00:00',
546
+ },
547
+ emails: [
548
+ {
549
+ email_type: '',
550
+ email_address: '',
551
+ },
552
+ ],
553
+ outside_auth: boolean,
554
+ middle_initial: '',
555
+ people_id: '',
556
+ addresses: [
557
+ {
558
+ address_type: '',
559
+ address1: '',
560
+ address2: '',
561
+ city: '',
562
+ state: '',
563
+ zip: '',
564
+ country_code: '',
565
+ },
566
+ ],
567
+ reference_id: '',
568
+ first_name: '',
569
+ },
570
+ entitlement: {
571
+ name: '',
572
+ description: '',
573
+ available_at: 'yyyy-mm-ddT00:00:00.000+00:00',
574
+ product_config_ids: ['procfg_01'],
575
+ },
576
+ });
577
+ ```
578
+
579
+ ## Utilities
580
+
581
+ ### Type Guards
582
+
583
+ For typescript users, helper utility functions are exported in order to aid with type narrowing response types that return variable response models. An example use case can be viewed for [simulating a credit score](#simulate-a-scenario---fico-only)
584
+
585
+ * Credit Score Planner
586
+
587
+ ```tsx
588
+ function isPlanCompleted(plan: CreditScorePlan): plan is FicoCreditScorePlanCompleted | VantageCreditScorePlanCompleted;
589
+ function isPlanSet(plan: CreditScorePlan): plan is FicoCreditScorePlanCompleted | FicoCreditScorePlanSet | VantageCreditScorePlanCompleted | VantageCreditScorePlanSet;
590
+ function isVantagePlan(plan: CreditScorePlan): plan is VantageCreditScorePlan;
591
+ function isFicoPlan(plan: CreditScorePlan): plan is FicoCreditScorePlan;
592
+ function isFicoRevisionsRequest(request: ScorePlanRevisionsRequest): request is FicoScorePlanRevisionsRequest;
593
+ function isVantageRevisionsRequest(request: ScorePlanRevisionsRequest): request is VantageScorePlanRevisionsRequest;
594
+ function isFicoRevision(revision: ScorePlanRevision): revision is FicoScorePlanRevision;
595
+ function isVantageRevision(revision: ScorePlanRevision): revision is VantageScorePlanRevision;
596
+ ```
597
+
598
+ * Credit Score Simulator
599
+
600
+ ```tsx
601
+ function isFicoSimulator(data?: CreditScoreSimulator): data is FicoScoreSimulator;
602
+ function isVantageScenario(scenario?: Scenario): scenario is VantageScenario;
603
+ function isFicoScenario(scenario: Scenario): scenario is FicoScenario;
604
+ function isFicoScenarioVariation(variation?: ScenarioVariation): variation is FicoScenarioVariation;
605
+ function isVantageScenarioVariation(variation?: ScenarioVariation): variation is VantageScenarioVariation;
606
+ ```