skyflow-js 1.22.0 → 1.23.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/README.md CHANGED
@@ -34,17 +34,17 @@ npm install skyflow-js
34
34
  # Initializing Skyflow.js
35
35
  Use the `init()` method to initialize a Skyflow client as shown below.
36
36
  ```javascript
37
- import Skyflow from "skyflow-js" // If using script tag, this line is not required
37
+ import Skyflow from 'skyflow-js' // If using script tag, this line is not required.
38
38
 
39
39
  const skyflowClient = Skyflow.init({
40
- vaultID: "string", //Id of the vault that the client should connect to
41
- vaultURL: "string", //URL of the vault that the client should connect to
42
- getBearerToken: helperFunc, //helper function that retrieves a Skyflow bearer token from your backend
43
- options:{
44
- logLevel: Skyflow.LogLevel, // optional, if not specified default is ERROR
45
- env: Skyflow.Env // optional, if not specified default is PROD
46
- }
47
- })
40
+ vaultID: 'string', // Id of the vault that the client should connect to.
41
+ vaultURL: 'string', // URL of the vault that the client should connect to.
42
+ getBearerToken: helperFunc, // Helper function that retrieves a Skyflow bearer token from your backend.
43
+ options: {
44
+ logLevel: Skyflow.LogLevel, // Optional, if not specified default is ERROR.
45
+ env: Skyflow.Env // Optional, if not specified default is PROD.
46
+ }
47
+ });
48
48
  ```
49
49
  For the `getBearerToken` parameter, pass in a helper function that retrieves a Skyflow bearer token from your backend. This function will be invoked when the SDK needs to insert or retrieve data from the vault. A sample implementation is shown below:
50
50
 
@@ -52,39 +52,38 @@ For example, if the response of the consumer tokenAPI is in the below format
52
52
 
53
53
  ```
54
54
  {
55
- "accessToken": string,
56
- "tokenType": string
55
+ "accessToken": string,
56
+ "tokenType": string
57
57
  }
58
58
 
59
59
  ```
60
60
  then, your getBearerToken Implementation should be as below
61
61
 
62
62
  ```javascript
63
- getBearerToken: () => {
63
+ const getBearerToken = () => {
64
64
  return new Promise((resolve, reject) => {
65
65
  const Http = new XMLHttpRequest();
66
66
 
67
67
  Http.onreadystatechange = () => {
68
- if (Http.readyState == 4) {
69
- if (Http.status == 200) {
68
+ if (Http.readyState === 4) {
69
+ if (Http.status === 200) {
70
70
  const response = JSON.parse(Http.responseText);
71
71
  resolve(response.accessToken);
72
72
  } else {
73
- reject("Error occured");
73
+ reject('Error occured');
74
74
  }
75
75
  }
76
76
  };
77
77
 
78
- Http.onerror = (error) => {
79
- reject("Error occured");
78
+ Http.onerror = error => {
79
+ reject('Error occured');
80
80
  };
81
81
 
82
- const url = "https://api.acmecorp.com/skyflowToken";
83
- Http.open("GET", url);
82
+ const url = 'https://api.acmecorp.com/skyflowToken';
83
+ Http.open('GET', url);
84
84
  Http.send();
85
- })
86
-
87
- }
85
+ });
86
+ };
88
87
 
89
88
  ```
90
89
  For `logLevel` parameter, there are 4 accepted values in Skyflow.LogLevel
@@ -126,57 +125,56 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
126
125
  ---
127
126
 
128
127
  # Securely collecting data client-side
129
- - [**Inserting data into the vault**](#inserting-data-into-the-vault)
128
+ - [**Insert data into the vault**](#insert-data-into-the-vault)
130
129
  - [**Using Skyflow Elements to collect data**](#using-skyflow-elements-to-collect-data)
131
130
  - [**Using validations on Collect Elements**](#validations)
132
131
  - [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
133
132
  - [**UI Error for Collect Eements**](#ui-error-for-collect-elements)
134
133
  - [**Set and Clear value for Collect Elements (DEV ENV ONLY)**](#set-and-clear-value-for-collect-elements-dev-env-only)
135
134
  - [**Using Skyflow File Element to upload a file**](#using-skyflow-file-element-to-upload-a-file)
136
- ## Inserting data into the vault
135
+ ## Insert data into the vault
137
136
 
138
- To insert data into the vault from the browser, use the `insert(records, options?)` method of the Skyflow client. The `records` parameter takes a JSON object of the records to be inserted in the below format. The `options` parameter takes a dictionary of optional parameters for the insertion. `insert` method also support upsert operations. See below:
137
+ To insert data into the vault, use the `insert(records, options?)` method of the Skyflow client. The `records` parameter takes a JSON object of the records to insert into the below format. The `options` parameter takes a dictionary of optional parameters for the insertion. The `insert` method also supports upsert operations.
139
138
 
140
139
  ```javascript
141
140
  const records = {
142
- "records": [
143
- {
144
- table: "string", //table into which record should be inserted
141
+ records: [
142
+ {
143
+ table: 'string', // Table into which record should be inserted.
145
144
  fields: {
146
- column1: "value", //column names should match vault column names
145
+ column1: 'value', // Column names should match vault column names.
147
146
  //...additional fields here
148
- }
149
- }
150
- //...additional records here
151
- ]
152
- }
147
+ },
148
+ },
149
+ // ...additional records here.
150
+ ],
151
+ };
153
152
 
154
153
  const options = {
155
- tokens: true, //indicates whether or not tokens should be returned for the inserted data. Defaults to 'true'
156
- upsert: [ // upsert operations support in the vault
154
+ tokens: true, // Indicates whether or not tokens should be returned for the inserted data. Defaults to 'true'
155
+ upsert: [ // Upsert operations support in the vault
157
156
  {
158
- table: "string", // table name
159
- column: "value ", // unique column in the table
157
+ table: 'string', // Table name
158
+ column: 'value', // Unique column in the table
160
159
  }
161
160
  ]
162
161
  }
163
162
 
164
- skyflowClient.insert(records, options)
163
+ skyflowClient.insert(records, options);
165
164
  ```
166
165
 
167
-
168
-
169
- An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/purejs.html) of an insert call:
166
+ An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/pure-js.html) of an insert call:
170
167
  ```javascript
171
168
  skyflowClient.insert({
172
- "records": [
173
- {
174
- "table": "cards",
175
- "fields": {
176
- "cardNumber": "41111111111",
177
- "cvv": "123",
178
- }
179
- }]
169
+ records: [
170
+ {
171
+ table: 'cards',
172
+ fields: {
173
+ cardNumber: '41111111111',
174
+ cvv: '123',
175
+ },
176
+ },
177
+ ],
180
178
  });
181
179
  ```
182
180
 
@@ -212,17 +210,17 @@ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
212
210
  A Skyflow collect Element is defined as shown below:
213
211
 
214
212
  ```javascript
215
- const collectElement = {
216
- table: "string", //optional, the table this data belongs to
217
- column: "string", //optional, the column into which this data should be inserted
218
- type: Skyflow.ElementType, //Skyflow.ElementType enum
219
- inputStyles: {}, //optional styles that should be applied to the form element
220
- labelStyles: {}, //optional styles that will be applied to the label of the collect element
221
- errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
222
- label: "string", //optional label for the form element
223
- placeholder: "string", //optional placeholder for the form element
224
- altText: "string" //(DEPRECATED) string that acts as an initial value for the collect element
225
- validations:[] // optional array of validation rules
213
+ const collectElement = {
214
+ table: 'string', // Required, the table this data belongs to.
215
+ column: 'string', // Required, the column into which this data should be inserted.
216
+ type: Skyflow.ElementType, // Skyflow.ElementType enum.
217
+ inputStyles: {}, // Optional, styles that should be applied to the form element.
218
+ labelStyles: {}, // Optional, styles that will be applied to the label of the collect element.
219
+ errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the collect element.
220
+ label: 'string', // Optional, label for the form element.
221
+ placeholder: 'string', // Optional, placeholder for the form element.
222
+ altText: 'string', // (DEPRECATED) string that acts as an initial value for the collect element.
223
+ validations: [], // Optional, array of validation rules.
226
224
  }
227
225
  ```
228
226
  The `table` and `column` fields indicate which table and column in the vault the Element corresponds to.
@@ -243,31 +241,31 @@ Styles are specified with [JSS](https://cssinjs.org/?v=v10.7.1).
243
241
 
244
242
  An example of a inputStyles object:
245
243
  ```javascript
246
- inputStyles:{
247
- base: {
248
- border: "1px solid #eae8ee",
249
- padding: "10px 16px",
250
- borderRadius: "4px",
251
- color: "#1d1d1d",
252
- },
253
- complete: {
254
- color: "#4caf50",
255
- },
256
- empty: {},
257
- focus: {},
258
- invalid: {
259
- color: "#f44336",
260
- },
261
- cardIcon:{
262
- position: "absolute",
263
- left:"8px",
264
- bottom:"calc(50% - 12px)"
265
- },
266
- copyIcon:{
267
- position: "absolute",
268
- right:"8px",
269
- }
270
- }
244
+ inputStyles: {
245
+ base: {
246
+ border: '1px solid #eae8ee',
247
+ padding: '10px 16px',
248
+ borderRadius: '4px',
249
+ color: '#1d1d1d',
250
+ },
251
+ complete: {
252
+ color: '#4caf50',
253
+ },
254
+ empty: {},
255
+ focus: {},
256
+ invalid: {
257
+ color: '#f44336',
258
+ },
259
+ cardIcon: {
260
+ position: 'absolute',
261
+ left: '8px',
262
+ bottom: 'calc(50% - 12px)',
263
+ },
264
+ copyIcon: {
265
+ position: 'absolute',
266
+ right: '8px',
267
+ },
268
+ },
271
269
  ```
272
270
  The states that are available for `labelStyles` are `base` and `focus`.
273
271
 
@@ -275,14 +273,14 @@ An example of a labelStyles object:
275
273
 
276
274
  ```javascript
277
275
  labelStyles: {
278
- base: {
279
- fontSize: "12px",
280
- fontWeight: "bold"
281
- },
282
- focus: {
283
- color: "#1d1d1d"
284
- }
285
- }
276
+ base: {
277
+ fontSize: '12px',
278
+ fontWeight: 'bold',
279
+ },
280
+ focus: {
281
+ color: '#1d1d1d',
282
+ },
283
+ },
286
284
  ```
287
285
 
288
286
  The state that is available for `errorTextStyles` is only the `base` state, it shows up when there is some error in the collect element.
@@ -291,10 +289,10 @@ An example of a errorTextStyles object:
291
289
 
292
290
  ```javascript
293
291
  errorTextStyles: {
294
- base: {
295
- color: "#f44336"
296
- }
297
- }
292
+ base: {
293
+ color: '#f44336',
294
+ },
295
+ },
298
296
  ```
299
297
 
300
298
  Finally, the `type` field takes a Skyflow ElementType. Each type applies the appropriate regex and validations to the form element. There are currently 8 types:
@@ -315,11 +313,11 @@ Along with CollectElement we can define other options which takes a object of op
315
313
 
316
314
  ```javascript
317
315
  const options = {
318
- required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
319
- enableCardIcon: true, // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
320
- format: String, //optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType),
321
- enableCopy: false // optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false')
322
- }
316
+ required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
317
+ enableCardIcon: true, // Optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType).
318
+ format: String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
319
+ enableCopy: false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
320
+ };
323
321
  ```
324
322
 
325
323
  `required` parameter indicates whether the field is marked as required or not. If not provided, it defaults to false
@@ -345,27 +343,27 @@ The values that are accepted for `EXPIRATION_YEAR` are
345
343
  Once the Element object and options has been defined, add it to the container using the `create(element, options)` method as shown below. The `element` param takes a Skyflow Element object and options as defined above:
346
344
 
347
345
  ```javascript
348
- const collectElement = {
349
- table: "string", //the table this data belongs to
350
- column: "string", //the column into which this data should be inserted
351
- type: Skyflow.ElementType, //Skyflow.ElementType enum
352
- inputStyles: {}, //optional styles that should be applied to the form element
353
- labelStyles: {}, //optional styles that will be applied to the label of the collect element
354
- errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
355
- label: "string", //optional label for the form element
356
- placeholder: "string", //optional placeholder for the form element
357
- altText: "string" //(DEPRECATED) string that acts as an initial value for the collect element
358
- validations:[] // optional array of validation rules
346
+ const collectElement = {
347
+ table: 'string', // Required, the table this data belongs to.
348
+ column: 'string', // Required, the column into which this data should be inserted.
349
+ type: Skyflow.ElementType, // Skyflow.ElementType enum.
350
+ inputStyles: {}, // Optional, styles that should be applied to the form element.
351
+ labelStyles: {}, // Optional, styles that will be applied to the label of the collect element.
352
+ errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the collect element.
353
+ label: 'string', // Optional, label for the form element.
354
+ placeholder: 'string', // Optional, placeholder for the form element.
355
+ altText: 'string', // (DEPRECATED) string that acts as an initial value for the collect element.
356
+ validations: [], // Optional, array of validation rules.
359
357
  }
360
358
 
361
359
  const options = {
362
- required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
363
- enableCardIcon: true, // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
364
- format: String, //optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
365
- enableCopy: false // optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false')
366
- }
360
+ required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
361
+ enableCardIcon: true, // Optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType).
362
+ format: String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
363
+ enableCopy: false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
364
+ };
367
365
 
368
- const element = container.create(collectElement, options)
366
+ const element = container.create(collectElement, options);
369
367
  ```
370
368
 
371
369
  ### Step 3: Mount Elements to the DOM
@@ -388,7 +386,7 @@ To specify where the Elements will be rendered on your page, create placeholder
388
386
  Now, when the `mount(domElement)` method of the Element is called, the Element will be inserted in the specified div. For instance, the call below will insert the Element into the div with the id "#cardNumber".
389
387
 
390
388
  ```javascript
391
- element.mount("#cardNumber")
389
+ element.mount('#cardNumber');
392
390
  ```
393
391
  you can use the `unmount` method to reset any collect element to it's initial state.
394
392
  ```javascript
@@ -400,33 +398,27 @@ element.unmount();
400
398
  When the form is ready to be submitted, call the `collect(options?)` method on the container object. The `options` parameter takes a object of optional parameters as shown below:
401
399
 
402
400
  - `tokens`: indicates whether tokens for the collected data should be returned or not. Defaults to 'true'
403
- - `additionalFields`: Non-PCI elements data to be inserted into the vault which should be in the `records` object format as described in the above [Inserting data into vault](#inserting-data-into-the-vault) section.
404
- - `upsert`: To support upsert operations while collecting the data from skyflow elements, pass the table and column that have been marked as unique in the table.
401
+ - `additionalFields`: Non-PCI elements data to be inserted into the vault which should be in the `records` object format as described in the above [Insert data into vault](#insert-data-into-the-vault) section.
402
+ - `upsert`: To support upsert operations while collecting data from Skyflow elements, pass the table and column marked as unique in the table.
405
403
 
406
404
  ```javascript
407
405
  const options = {
408
- tokens: true //optional, indicates whether tokens for the collected data should be returned. Defaults to 'true'
409
- additionalFields: {
406
+ tokens: true, // Optional, indicates whether tokens for the collected data should be returned. Defaults to 'true'.
407
+ additionalFields: {
410
408
  records: [
411
409
  {
412
- table: "string", //table into which record should be inserted
410
+ table: 'string', // Table into which record should be inserted.
413
411
  fields: {
414
- column1: "value", //column names should match vault column names
415
- //...additional fields here
416
- }
417
- }
418
- //...additional records here
419
- ]
420
- }, //optional
421
- upsert: [ //optional, upsert operations support in the vault
422
- {
423
- table: "string", // table name
424
- column: "value ", // unique column in the table
425
- }
426
- ]
427
- }
412
+ column1: 'value', // Column names should match vault column names.
413
+ // ...additional fields here.
414
+ },
415
+ },
416
+ // ...additional records here.
417
+ ],
418
+ }, // Optional
419
+ };
428
420
 
429
- container.collect(options)
421
+ container.collect(options);
430
422
  ```
431
423
 
432
424
  ### End to end example of collecting data with Skyflow Elements
@@ -435,58 +427,59 @@ container.collect(options)
435
427
 
436
428
  ```javascript
437
429
  //Step 1
438
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
430
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
439
431
 
440
432
  //Step 2
441
- const element = container.create({
442
- table: "cards",
443
- column: "cardNumber",
433
+ const element = container.create({
434
+ table: 'cards',
435
+ column: 'cardNumber',
444
436
  inputstyles: {
445
- base: {
446
- color: "#1d1d1d",
447
- },
448
- cardIcon:{
449
- position: "absolute",
450
- left:"8px",
451
- bottom:"calc(50% - 12px)"
437
+ base: {
438
+ color: '#1d1d1d',
439
+ },
440
+ cardIcon: {
441
+ position: 'absolute',
442
+ left: '8px',
443
+ bottom: 'calc(50% - 12px)',
452
444
  },
453
445
  },
454
446
  labelStyles: {
455
- base: {
456
- fontSize: "12px",
457
- fontWeight: "bold"
458
- }
447
+ base: {
448
+ fontSize: '12px',
449
+ fontWeight: 'bold',
450
+ },
459
451
  },
460
452
  errorTextStyles: {
461
- base: {
462
- color: "#f44336"
463
- }
453
+ base: {
454
+ color: '#f44336',
455
+ },
464
456
  },
465
- placeholder: "Card Number",
466
- label: "card_number",
467
- type: Skyflow.ElementType.CARD_NUMBER
468
- })
457
+ placeholder: 'Card Number',
458
+ label: 'card_number',
459
+ type: Skyflow.ElementType.CARD_NUMBER,
460
+ });
469
461
 
470
462
  // Step 3
471
- element.mount("#cardNumber") //assumes there is a div with id="#cardNumber" in the webpage
463
+ element.mount('#cardNumber'); // Assumes there is a div with id='#cardNumber' in the webpage.
472
464
 
473
465
  // Step 4
474
466
 
475
467
  const nonPCIRecords = {
476
- "records": [
477
- {
478
- "table": "cards",
479
- "fields": {
480
- "gender": "MALE"
481
- }
482
- }
483
- ]
484
- }
468
+ records: [
469
+ {
470
+ table: 'cards',
471
+ fields: {
472
+ gender: 'MALE',
473
+ },
474
+ },
475
+ ],
476
+ };
485
477
 
486
478
  container.collect({
487
479
  tokens: true,
488
- additionalFields: nonPCIRecords
489
- })
480
+ additionalFields: nonPCIRecords,
481
+ });
482
+
490
483
  ```
491
484
 
492
485
  **Sample Response :**
@@ -503,20 +496,18 @@ container.collect({
503
496
  ]
504
497
  }
505
498
  ```
499
+ ### Insert call example with upsert support
500
+ **Sample Code**
506
501
 
507
- ### End to end example of `upsert` support with Skyflow Elements
508
-
509
- **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/upsert-support.html)**
510
-
511
- ```javascript
502
+ ```javascript
512
503
  //Step 1
513
504
  const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
514
-
505
+
515
506
  //Step 2
516
507
  const cardNumberElement = container.create({
517
508
  table: "cards",
518
509
  column: "card_number",
519
- inputstyles: {
510
+ inputStyles: {
520
511
  base: {
521
512
  color: "#1d1d1d",
522
513
  },
@@ -541,11 +532,11 @@ const cardNumberElement = container.create({
541
532
  label: "card_number",
542
533
  type: Skyflow.ElementType.CARD_NUMBER
543
534
  })
544
-
535
+
545
536
  const cvvElement = container.create({
546
537
  table: "cards",
547
538
  column: "cvv",
548
- inputstyles: {
539
+ inputStyles: {
549
540
  base: {
550
541
  color: "#1d1d1d",
551
542
  },
@@ -572,12 +563,11 @@ const cvvElement = container.create({
572
563
  })
573
564
 
574
565
  // Step 3
575
- cardNumberElement.mount("#cardNumber") //assumes there is a div with id="#cardNumber" in the webpage
576
- cvvElement.mount("#cvv"); //assumes there is a div with id="#cvv" in the webpage
577
-
566
+ cardNumberElement.mount("#cardNumber") //Assumes there is a div with id="#cardNumber" in the webpage.
567
+ cvvElement.mount("#cvv"); //Assumes there is a div with id="#cvv" in the webpage.
568
+
578
569
  // Step 4
579
-
580
- container.collect({
570
+ container.collect({
581
571
  tokens: true,
582
572
  upsert: [
583
573
  {
@@ -586,17 +576,17 @@ container.collect({
586
576
  }
587
577
  ]
588
578
  })
589
- ```
590
579
 
591
- **Sample Response :**
580
+ ```
581
+ **Skyflow returns tokens for the record you just inserted.**
592
582
  ```javascript
593
583
  {
594
584
  "records": [
595
585
  {
596
586
  "table": "cards",
597
587
  "fields": {
598
- "card_number": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
599
- "cvv": "12f670af-6c7d-4837-83fb-30365fbc0b1e"
588
+ "cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
589
+ "gender": "12f670af-6c7d-4837-83fb-30365fbc0b1e"
600
590
  }
601
591
  }
602
592
  ]
@@ -626,7 +616,7 @@ const regexMatchRule = {
626
616
  type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
627
617
  params: {
628
618
  regex: RegExp,
629
- error: string // optional, default error is "VALIDATION FAILED"
619
+ error: string // Optional, default error is 'VALIDATION FAILED'.
630
620
  }
631
621
  }
632
622
  ```
@@ -637,9 +627,9 @@ const regexMatchRule = {
637
627
  const lengthMatchRule = {
638
628
  type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
639
629
  params: {
640
- min : number, // optional
641
- max : number, // optional
642
- error: string // optional, default error is "VALIDATION FAILED"
630
+ min : number, // Optional.
631
+ max : number, // Optional.
632
+ error: string // Optional, default error is 'VALIDATION FAILED'.
643
633
  }
644
634
  }
645
635
  ```
@@ -651,12 +641,12 @@ const elementValueMatchRule = {
651
641
  type: Skyflow.ValidationRuleType.ELEMENT_VALUE_MATCH_RULE,
652
642
  params: {
653
643
  element: CollectElement,
654
- error: string // optional, default error is "VALIDATION FAILED"
644
+ error: string // Optional, default error is 'VALIDATION FAILED'.
655
645
  }
656
646
  }
657
647
  ```
658
648
 
659
- The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/CustomValidations.html) for using custom validations:
649
+ The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/custom-validations.html) for using custom validations:
660
650
 
661
651
  ```javascript
662
652
  /*
@@ -664,71 +654,72 @@ The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/s
664
654
  Adding REGEX_MATCH_RULE , LENGTH_MATCH_RULE to collect element.
665
655
  */
666
656
 
667
- // this rule allows 1 or more alphabets
657
+ // This rule allows 1 or more alphabets.
668
658
  const alphabetsOnlyRegexRule = {
669
659
  type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
670
- params:{
660
+ params: {
671
661
  regex: /^[A-Za-z]+$/,
672
- error: "Only alphabets are allowed"
673
- }
674
- };
662
+ error: 'Only alphabets are allowed',
663
+ },
664
+ };
675
665
 
676
- // this rule allows input length between 4 and 6 characters
666
+ // This rule allows input length between 4 and 6 characters.
677
667
  const lengthRule = {
678
668
  type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
679
- params:{
669
+ params: {
680
670
  min: 4,
681
671
  max: 6,
682
- error: "Must be between 4 and 6 alphabets"
683
- }
684
- };
685
-
686
- const cardHolderNameElement = collectContainer.create({
687
- table: "pii_fields",
688
- column: "first_name",
689
- ...collectStylesOptions,
690
- label: "Card Holder Name",
691
- placeholder: "cardholder name",
692
- type: Skyflow.ElementType.INPUT_FIELD,
693
- validations: [alphabetsOnlyRegexRule, lengthRule]
694
- });
672
+ error: 'Must be between 4 and 6 alphabets',
673
+ },
674
+ };
675
+
676
+ const cardHolderNameElement = collectContainer.create({
677
+ table: 'pii_fields',
678
+ column: 'first_name',
679
+ ...collectStylesOptions,
680
+ label: 'Card Holder Name',
681
+ placeholder: 'cardholder name',
682
+ type: Skyflow.ElementType.INPUT_FIELD,
683
+ validations: [alphabetsOnlyRegexRule, lengthRule],
684
+ });
695
685
 
696
686
  /*
697
687
  Reset PIN - A simple example that illustrates custom validations.
698
688
  The below code shows an example of ELEMENT_VALUE_MATCH_RULE
699
689
  */
700
690
 
701
- // for the PIN element
691
+ // For the PIN element
702
692
  const pinElement = collectContainer.create({
703
- label: "PIN",
704
- placeholder: "****",
693
+ label: 'PIN',
694
+ placeholder: '****',
705
695
  type: Skyflow.ElementType.PIN,
706
696
  });
707
697
 
708
- // this rule allows to match the value with pinElement
709
- let elementMatchRule = {
698
+ // This rule allows to match the value with pinElement.
699
+ const elementMatchRule = {
710
700
  type: Skyflow.ValidationRuleType.ELEMENT_VALUE_MATCH_RULE,
711
- params:{
701
+ params: {
712
702
  element: pinElement,
713
- error: "PIN doesn't match"
714
- }
715
- }
703
+ error: "PIN doesn't match",
704
+ },
705
+ };
706
+
716
707
  const confirmPinElement = collectContainer.create({
717
- label: "Confirm PIN",
718
- placeholder: "****",
708
+ label: 'Confirm PIN',
709
+ placeholder: '****',
719
710
  type: Skyflow.ElementType.PIN,
720
- validations: [elementMatchRule]
711
+ validations: [elementMatchRule],
721
712
  });
722
713
 
723
- // mount elements on screen - errors will be shown if any of the validaitons fail
724
- pinElement.mount("#collectPIN");
725
- confirmPinElement.mount("#collectConfirmPIN");
714
+ // Mount elements on screen - errors will be shown if any of the validaitons fail.
715
+ pinElement.mount('#collectPIN');
716
+ confirmPinElement.mount('#collectConfirmPIN');
726
717
 
727
718
  ```
728
719
  ### Event Listener on Collect Elements
729
720
 
730
721
 
731
- Helps to communicate with skyflow elements / iframes by listening to an event
722
+ Helps to communicate with Skyflow elements / iframes by listening to an event
732
723
 
733
724
  ```javascript
734
725
  element.on(Skyflow.EventName,handler:function)
@@ -762,84 +753,82 @@ state : {
762
753
  `Note:`
763
754
  values of SkyflowElements will be returned in elementstate object only when `env` is `DEV`, else it is empty string i.e, ''
764
755
 
765
- ##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/CollectElementListeners.html) for using listeners
756
+ ##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/collect-element-listeners.html) for using listeners
766
757
  ```javascript
767
- //create skyflow client
758
+ // Create Skyflow client.
768
759
  const skyflowClient = Skyflow.init({
769
- vaultID: <VAULT_ID>,
770
- vaultURL: <VAULT_URL>,
771
- getBearerToken: ()=>{},
772
- options: {
773
- env: Skyflow.Env.DEV
774
- }
775
- })
760
+ vaultID: '<VAULT_ID>',
761
+ vaultURL: '<VAULT_URL>',
762
+ getBearerToken: () => {},
763
+ options: {
764
+ env: Skyflow.Env.DEV,
765
+ },
766
+ });
776
767
 
777
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
768
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
778
769
 
779
770
  const cardNumber = container.create({
780
- table: "pii_fields",
781
- column: "primary_card.card_number",
782
- type: Skyflow.ElementType.CARD_NUMBER,
783
- });
771
+ table: 'pii_fields',
772
+ column: 'primary_card.card_number',
773
+ type: Skyflow.ElementType.CARD_NUMBER,
774
+ });
784
775
 
785
- cardNumber.mount("#cardNumberContainer");
776
+ cardNumber.mount('#cardNumberContainer');
786
777
 
787
- //subscribing to CHANGE event, which gets triggered when element changes
788
- cardNumber.on(Skyflow.EventName.CHANGE,(state) => {
789
- // Your implementation when Change event occurs
790
- console.log(state)
778
+ // Subscribing to CHANGE event, which gets triggered when element changes.
779
+ cardNumber.on(Skyflow.EventName.CHANGE, state => {
780
+ // Your implementation when Change event occurs.
781
+ console.log(state);
791
782
  });
783
+
792
784
  ```
793
785
  ##### Sample Element state object when `env` is `DEV`
794
786
 
795
787
  ```javascript
796
788
  {
797
- elementType: "CARD_NUMBER"
798
- isEmpty: false
799
- isFocused: true
800
- isValid: false
801
- value: "411"
802
- }
803
-
789
+ elementType: 'CARD_NUMBER',
790
+ isEmpty: false,
791
+ isFocused: true,
792
+ isValid: false,
793
+ value: '411',
794
+ };
804
795
  ```
805
796
  ##### Sample Element state object when `env` is `PROD`
806
797
 
807
798
  ```javascript
808
799
  {
809
- elementType: "CARD_NUMBER"
810
- isEmpty: false
811
- isFocused: true
812
- isValid: false
813
- value: ''
814
- }
800
+ elementType: 'CARD_NUMBER',
801
+ isEmpty: false,
802
+ isFocused: true,
803
+ isValid: false,
804
+ value: '',
805
+ };
815
806
  ```
816
807
 
817
808
  ### UI Error for Collect Elements
818
809
 
819
810
  Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
820
811
 
821
- `setError(error: string)` method is used to set the error text for the element, when this method is trigerred, all the current errors present on the element will be overridden with the custom error message passed. This error will be displayed on the element until `resetError()` is trigerred on the same element.
812
+ `setError(error: string)` method is used to set the error text for the element, when this method is triggered, all the current errors present on the element will be overridden with the custom error message passed. This error will be displayed on the element until `resetError()` is triggered on the same element.
822
813
 
823
814
  `resetError()` method is used to clear the custom error message that is set using `setError`.
824
815
 
825
816
  ##### Sample code snippet for setError and resetError
826
817
 
827
818
  ```javascript
828
-
829
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
819
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
830
820
 
831
821
  const cardNumber = container.create({
832
- table: "pii_fields",
833
- column: "primary_card.card_number",
834
- type: Skyflow.ElementType.CARD_NUMBER,
822
+ table: 'pii_fields',
823
+ column: 'primary_card.card_number',
824
+ type: Skyflow.ElementType.CARD_NUMBER,
835
825
  });
836
826
 
837
- //Set custom error
838
- cardNumber.setError("custom error");
827
+ // Set custom error.
828
+ cardNumber.setError('custom error');
839
829
 
840
- //reset custom error
830
+ // Reset custom error.
841
831
  cardNumber.resetError();
842
-
843
832
  ```
844
833
 
845
834
  ### Set and Clear value for Collect Elements (DEV ENV ONLY)
@@ -853,18 +842,18 @@ cardNumber.resetError();
853
842
  ##### Sample code snippet for setValue and clearValue
854
843
 
855
844
  ```javascript
856
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
845
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
857
846
 
858
847
  const cardNumber = container.create({
859
- table: "pii_fields",
860
- column: "primary_card.card_number",
861
- type: Skyflow.ElementType.CARD_NUMBER,
848
+ table: 'pii_fields',
849
+ column: 'primary_card.card_number',
850
+ type: Skyflow.ElementType.CARD_NUMBER,
862
851
  });
863
852
 
864
- // Set a value programatically
865
- cardNumber.setValue("4111111111111111");
853
+ // Set a value programatically.
854
+ cardNumber.setValue('4111111111111111');
866
855
 
867
- // Clear the value
856
+ // Clear the value.
868
857
  cardNumber.clearValue();
869
858
 
870
859
  ```
@@ -888,25 +877,25 @@ For non-PCI use-cases, retrieving data from the vault and revealing it in the br
888
877
 
889
878
  ```javascript
890
879
  const records = {
891
- "records": [
892
- {
893
- token: "string", // token for the record to be fetched
894
- }
895
- ]
896
- }
880
+ records: [
881
+ {
882
+ token: 'string', // Token for the record to be fetched.
883
+ },
884
+ ],
885
+ };
897
886
 
898
- skyflow.detokenize(records)
887
+ skyflow.detokenize(records);
899
888
  ```
900
- An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/purejs.html) of a detokenize call:
889
+ An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/pure-js.html) of a detokenize call:
901
890
 
902
891
  ```javascript
903
892
  skyflow.detokenize({
904
- "records": [
893
+ records: [
905
894
  {
906
- token: "131e70dc-6f76-4319-bdd3-96281e051051"
907
- }
908
- ]
909
- })
895
+ token: '131e70dc-6f76-4319-bdd3-96281e051051',
896
+ },
897
+ ],
898
+ });
910
899
  ```
911
900
 
912
901
  The sample response:
@@ -926,11 +915,11 @@ The sample response:
926
915
 
927
916
  ```javascript
928
917
  {
929
- "records": [
918
+ records: [
930
919
  {
931
- ids: string[], // array of SkyflowID's of the records to be fetched
932
- table: string // table holding the above skyflow_id's
933
- redaction: Skyflow.RedactionType // redaction to be applied to retrieved data
920
+ ids: string[], // Array of SkyflowID's of the records to be fetched.
921
+ table: string, // Table holding the above skyflow_id's.
922
+ redaction: Skyflow.RedactionType, // Redaction to be applied to retrieved data.
934
923
  }
935
924
  ]
936
925
  }
@@ -945,17 +934,16 @@ There are 4 accepted values in Skyflow.RedactionTypes:
945
934
  An example of getById call:
946
935
 
947
936
  ```javascript
948
-
949
937
  skyflow.getById({
950
938
  records: [
951
939
  {
952
- ids: ["f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9"],
953
- table: "cards",
940
+ ids: ['f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9'],
941
+ table: 'cards',
954
942
  redaction: Skyflow.RedactionType.PLAIN_TEXT,
955
943
  },
956
944
  {
957
- ids: ["da26de53-95d5-4bdb-99db-8d8c66a35ff9"],
958
- table: "contacts",
945
+ ids: ['da26de53-95d5-4bdb-99db-8d8c66a35ff9'],
946
+ table: 'contacts',
959
947
  redaction: Skyflow.RedactionType.PLAIN_TEXT,
960
948
  },
961
949
  ],
@@ -1007,14 +995,13 @@ Then define a Skyflow Element to reveal data as shown below.
1007
995
 
1008
996
  ```javascript
1009
997
  const revealElement = {
1010
- token: "string", //optional, token of the data being revealed
1011
- inputStyles: {}, //optional styles to be applied to the element
1012
- labelStyles: {}, //optional, styles to be applied to the label of the reveal element
1013
- errorTextStyles: {}, //optional styles that will be applied to the errorText of the reveal element
1014
- label: "string", //optional, label for the form element
1015
- altText: "string" //optional, string that is shown before reveal, will show token if altText is not provided
1016
- }
1017
-
998
+ token: 'string', // Required, token of the data being revealed.
999
+ inputStyles: {}, // Optional, styles to be applied to the element.
1000
+ labelStyles: {}, // Optional, styles to be applied to the label of the reveal element.
1001
+ errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the reveal element.
1002
+ label: 'string', // Optional, label for the form element.
1003
+ altText: 'string', // Optional, string that is shown before reveal, will show token if altText is not provided.
1004
+ };
1018
1005
  ```
1019
1006
 
1020
1007
  The `inputStyles`, `labelStyles` and `errorTextStyles` parameters accepts a styles object as described in the [previous section](#step-2-create-a-collect-element) for collecting data. But for reveal element, `inputStyles` accepts only `base` variant and `copyIcon` style object.
@@ -1023,36 +1010,36 @@ An example of a inputStyles object:
1023
1010
 
1024
1011
  ```javascript
1025
1012
  inputStyles: {
1026
- base: {
1027
- color: "#1d1d1d"
1028
- },
1029
- copyIcon:{
1030
- position: "absolute",
1031
- right:"8px",
1032
- top: "calc(50% - 10px)",
1033
- }
1034
- }
1013
+ base: {
1014
+ color: '#1d1d1d',
1015
+ },
1016
+ copyIcon: {
1017
+ position: 'absolute',
1018
+ right: '8px',
1019
+ top: 'calc(50% - 10px)',
1020
+ },
1021
+ },
1035
1022
  ```
1036
1023
 
1037
1024
  An example of a labelStyles object:
1038
1025
 
1039
1026
  ```javascript
1040
1027
  labelStyles: {
1041
- base: {
1042
- fontSize: "12px",
1043
- fontWeight: "bold"
1044
- }
1045
- }
1028
+ base: {
1029
+ fontSize: '12px',
1030
+ fontWeight: 'bold',
1031
+ },
1032
+ },
1046
1033
  ```
1047
1034
 
1048
1035
  An example of a errorTextStyles object:
1049
1036
 
1050
1037
  ```javascript
1051
1038
  errorTextStyles: {
1052
- base: {
1053
- color: "#f44336"
1054
- }
1055
- }
1039
+ base: {
1040
+ color: '#f44336',
1041
+ },
1042
+ },
1056
1043
  ```
1057
1044
 
1058
1045
  Once you've defined a Skyflow Element, you can use the `create(element)` method of the container to create the Element as shown below:
@@ -1070,13 +1057,14 @@ Elements used for revealing data are mounted to the DOM the same way as Elements
1070
1057
  When the sensitive data is ready to be retrieved and revealed, call the `reveal()` method on the container as shown below:
1071
1058
 
1072
1059
  ```javascript
1073
- container.reveal()
1074
- .then((data) => {
1075
- //handle success
1076
- })
1077
- .catch((err) => {
1078
- //handle error
1060
+ container
1061
+ .reveal()
1062
+ .then(data => {
1063
+ // Handle success.
1079
1064
  })
1065
+ .catch(err => {
1066
+ // Handle error.
1067
+ });
1080
1068
  ```
1081
1069
 
1082
1070
 
@@ -1084,55 +1072,55 @@ container.reveal()
1084
1072
 
1085
1073
  **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
1086
1074
  ```javascript
1087
- //Step 1
1088
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1075
+ // Step 1.
1076
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1089
1077
 
1090
- //Step 2
1091
- const cardNumberElement = container.create({
1092
- token: "b63ec4e0-bbad-4e43-96e6-6bd50f483f75",
1078
+ // Step 2.
1079
+ const cardNumberElement = container.create({
1080
+ token: 'b63ec4e0-bbad-4e43-96e6-6bd50f483f75',
1093
1081
  inputStyles: {
1094
- base: {
1095
- color: "#1d1d1d",
1096
- },
1082
+ base: {
1083
+ color: '#1d1d1d',
1084
+ },
1097
1085
  },
1098
1086
  labelStyles: {
1099
1087
  base: {
1100
- fontSize: "12px",
1101
- }
1088
+ fontSize: '12px',
1089
+ },
1102
1090
  },
1103
1091
  errorTextStyles: {
1104
1092
  base: {
1105
- color: "#f44336"
1106
- }
1107
- },
1108
- label: "card_number",
1109
- altText: "XXXX XXXX XXXX XXXX"
1110
- })
1093
+ color: '#f44336',
1094
+ },
1095
+ },
1096
+ label: 'card_number',
1097
+ altText: 'XXXX XXXX XXXX XXXX',
1098
+ });
1111
1099
 
1112
- const cvvElement = container.create({
1113
- token: "89024714-6a26-4256-b9d4-55ad69aa4047",
1100
+ const cvvElement = container.create({
1101
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1114
1102
  inputStyles: {
1115
- base: {
1116
- color: "#1d1d1d",
1117
- },
1103
+ base: {
1104
+ color: '#1d1d1d',
1118
1105
  },
1119
- label: "cvv",
1120
- altText: "XXX"
1121
- })
1106
+ },
1107
+ label: 'cvv',
1108
+ altText: 'XXX',
1109
+ });
1122
1110
 
1123
- //Step 3
1124
- cardNumberElement.mount("#cardNumber") //assumes there is a placeholder div with id="#cardNumber" on the page
1125
- cvvElement.mount("#cvv") //assumes there is a placeholder div with id="#cvv" on the page
1126
-
1127
- //Step 4
1128
- container
1129
- .reveal()
1130
- .then((data) => {
1131
- //handle success
1132
- })
1133
- .catch((err) => {
1134
- //handle error
1135
- });
1111
+ // Step 3.
1112
+ cardNumberElement.mount('#cardNumber'); // Assumes there is a placeholder div with id='cardNumber' on the page
1113
+ cvvElement.mount('#cvv'); // Assumes there is a placeholder div with id='cvv' on the page
1114
+
1115
+ // Step 4.
1116
+ container
1117
+ .reveal()
1118
+ .then(data => {
1119
+ // Handle success.
1120
+ })
1121
+ .catch(err => {
1122
+ // Handle error.
1123
+ });
1136
1124
  ```
1137
1125
 
1138
1126
  The response below shows that some tokens assigned to the reveal elements get revealed successfully, while others fail and remain unrevealed.
@@ -1161,26 +1149,24 @@ The response below shows that some tokens assigned to the reveal elements get re
1161
1149
  ### UI Error for Reveal Elements
1162
1150
  Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
1163
1151
 
1164
- `setError(error: string)` method is used to set the error text for the element, when this method is trigerred, all the current errors present on the element will be overridden with the custom error message passed. This error will be displayed on the element until `resetError()` is trigerred on the same element.
1152
+ `setError(error: string)` method is used to set the error text for the element, when this method is triggered, all the current errors present on the element will be overridden with the custom error message passed. This error will be displayed on the element until `resetError()` is triggered on the same element.
1165
1153
 
1166
1154
  `resetError()` method is used to clear the custom error message that is set using `setError`.
1167
1155
 
1168
1156
  ##### Sample code snippet for setError and resetError
1169
1157
 
1170
1158
  ```javascript
1171
-
1172
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1159
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1173
1160
 
1174
1161
  const cardNumber = container.create({
1175
- token: "89024714-6a26-4256-b9d4-55ad69aa4047",
1162
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1176
1163
  });
1177
1164
 
1178
- //Set custom error
1179
- cardNumber.setError("custom error");
1165
+ // Set custom error.
1166
+ cardNumber.setError('custom error');
1180
1167
 
1181
- //reset custom error
1168
+ // Reset custom error.
1182
1169
  cardNumber.resetError();
1183
-
1184
1170
  ```
1185
1171
  ### Set token for Reveal Elements
1186
1172
 
@@ -1188,15 +1174,14 @@ The `setToken(value: string)` method can be used to set the token of the Reveal
1188
1174
 
1189
1175
  ##### Sample code snippet for setToken
1190
1176
  ```javascript
1191
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1177
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1192
1178
 
1193
1179
  const cardNumber = container.create({
1194
- altText:"Card Number",
1180
+ altText: 'Card Number',
1195
1181
  });
1196
1182
 
1197
- // set token
1198
- cardNumber.setToken("89024714-6a26-4256-b9d4-55ad69aa4047");
1199
-
1183
+ // Set token.
1184
+ cardNumber.setToken('89024714-6a26-4256-b9d4-55ad69aa4047');
1200
1185
  ```
1201
1186
  ### Set and Clear altText for Reveal Elements
1202
1187
  The `setAltText(value: string)` method can be used to set the altText of the Reveal Element. This will cause the altText to be displayed in the UI regardless of whether the token or value is currently being displayed.
@@ -1205,17 +1190,18 @@ The `setAltText(value: string)` method can be used to set the altText of the Rev
1205
1190
  ##### Sample code snippet for setAltText and clearAltText
1206
1191
 
1207
1192
  ```javascript
1208
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1193
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1209
1194
 
1210
1195
  const cardNumber = container.create({
1211
- token:"89024714-6a26-4256-b9d4-55ad69aa4047",
1196
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1212
1197
  });
1213
1198
 
1214
- // set altText
1215
- cardNumber.setAltText("Card Number");
1199
+ // Set altText.
1200
+ cardNumber.setAltText('Card Number');
1201
+
1202
+ // Clear altText.
1203
+ cardNumber.clearAltText();
1216
1204
 
1217
- //clear altText
1218
- cardNumber.clearAltText();
1219
1205
  ```
1220
1206
 
1221
1207
  ## Using Skyflow File Element to upload a file
@@ -1235,13 +1221,13 @@ Skyflow Collect Elements are defined as follows:
1235
1221
 
1236
1222
  ```javascript
1237
1223
  const collectElement = {
1238
- table: "string", //the table this data belongs to
1239
- column: "string", //the column into which this data should be inserted
1240
- skyflowID: "string", // the skyflow_id of the record
1241
- type: Skyflow.ElementType.FILE_INPUT, //Skyflow.ElementType enum
1242
- inputStyles: {}, //optional styles that should be applied to the form element
1243
- labelStyles: {}, //optional styles that will be applied to the label of the collect element
1244
- errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
1224
+ type: Skyflow.ElementType.FILE_INPUT, // Skyflow.ElementType enum.
1225
+ table: 'string', // The table this data belongs to.
1226
+ column: 'string', // The column into which this data should be inserted.
1227
+ skyflowID: 'string', // The skyflow_id of the record.
1228
+ inputStyles: {}, // Optional, styles that should be applied to the form element.
1229
+ labelStyles: {}, // Optional, styles that will be applied to the label of the collect element.
1230
+ errorTextStyles:{}, // Optional, styles that will be applied to the errorText of the collect element.
1245
1231
  }
1246
1232
  ```
1247
1233
  The `table` and `column` fields indicate which table and column the Element corresponds to.
@@ -1267,7 +1253,7 @@ To specify where to render Elements on your page, create placeholder `<div>` ele
1267
1253
  Now, when the `mount(domElement)` method of the Element is called, the Element is inserted in the specified div. For instance, the call below inserts the Element into the div with the id "#file".
1268
1254
 
1269
1255
  ```javascript
1270
- element.mount("#file")
1256
+ element.mount('#file');
1271
1257
  ```
1272
1258
  Use the `unmount` method to reset a Collect Element to its initial state.
1273
1259
 
@@ -1279,7 +1265,7 @@ element.unmount();
1279
1265
  When the file is ready to be uploaded, call the `uploadFiles()` method on the container object.
1280
1266
 
1281
1267
  ```javascript
1282
- container.uploadFiles()
1268
+ container.uploadFiles();
1283
1269
  ```
1284
1270
  ### File upload limitations:
1285
1271
 
@@ -1292,38 +1278,38 @@ container.uploadFiles()
1292
1278
  ### End-to-end file upload
1293
1279
 
1294
1280
  ```javascript
1295
- //Step 1
1296
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
1281
+ // Step 1.
1282
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
1297
1283
 
1298
- //Step 2
1299
- const element = container.create({
1300
- table: "pii_fields",
1301
- column: "file",
1302
- skyflowID:"431eaa6c-5c15-4513-aa15-29f50babe882",
1284
+ // Step 2.
1285
+ const element = container.create({
1286
+ table: 'pii_fields',
1287
+ column: 'file',
1288
+ skyflowID: '431eaa6c-5c15-4513-aa15-29f50babe882',
1303
1289
  inputstyles: {
1304
- base: {
1305
- color: "#1d1d1d",
1306
- },
1290
+ base: {
1291
+ color: '#1d1d1d',
1292
+ },
1307
1293
  },
1308
1294
  labelStyles: {
1309
- base: {
1310
- fontSize: "12px",
1311
- fontWeight: "bold"
1312
- }
1295
+ base: {
1296
+ fontSize: '12px',
1297
+ fontWeight: 'bold',
1298
+ },
1313
1299
  },
1314
1300
  errorTextStyles: {
1315
- base: {
1316
- color: "#f44336"
1317
- }
1301
+ base: {
1302
+ color: '#f44336',
1303
+ },
1318
1304
  },
1319
- type: Skyflow.ElementType.FILE_INPUT
1320
- })
1305
+ type: Skyflow.ElementType.FILE_INPUT,
1306
+ });
1321
1307
 
1322
- // Step 3
1323
- element.mount("#file") //assumes there is a div with id="#file" in the webpage
1308
+ // Step 3.
1309
+ element.mount('#file'); // Assumes there is a div with id='#file' in the webpage.
1324
1310
 
1325
- // Step 4
1326
- container.uploadFiles()
1311
+ // Step 4.
1312
+ container.uploadFiles();
1327
1313
  ```
1328
1314
 
1329
1315
  **Sample Response :**
@@ -1339,69 +1325,64 @@ container.uploadFiles()
1339
1325
  #### File upload with additional elements
1340
1326
 
1341
1327
  ```javascript
1342
- // Create collect Container
1343
-
1328
+ // Create collect Container.
1344
1329
  const collectContainer = skyflow.container(Skyflow.ContainerType.COLLECT);
1345
1330
 
1346
-
1347
- // Create collect elements
1348
-
1331
+ // Create collect elements.
1349
1332
  const cardNumberElement = collectContainer.create({
1350
- table: "newTable",
1351
- column: "card_number",
1333
+ table: 'newTable',
1334
+ column: 'card_number',
1352
1335
  inputstyles: {
1353
- base: {
1354
- color: "#1d1d1d",
1355
- },
1336
+ base: {
1337
+ color: '#1d1d1d',
1338
+ },
1356
1339
  },
1357
1340
  labelStyles: {
1358
- base: {
1359
- fontSize: "12px",
1360
- fontWeight: "bold"
1361
- }
1341
+ base: {
1342
+ fontSize: '12px',
1343
+ fontWeight: 'bold',
1344
+ },
1362
1345
  },
1363
1346
  errorTextStyles: {
1364
- base: {
1365
- color: "#f44336"
1366
- }
1367
- },,
1368
- placeholder: "card number",
1369
- label: "Card Number",
1347
+ base: {
1348
+ color: '#f44336',
1349
+ },
1350
+ },
1351
+ placeholder: 'card number',
1352
+ label: 'Card Number',
1370
1353
  type: Skyflow.ElementType.CARD_NUMBER,
1371
1354
  });
1372
1355
 
1373
1356
  const fileElement = collectContainer.create({
1374
- table: "newTable",
1375
- column: "file",
1357
+ table: 'newTable',
1358
+ column: 'file',
1376
1359
  skyflowID: '431eaa6c-5c15-4513-aa15-29f50babe882',
1377
1360
  inputstyles: {
1378
- base: {
1379
- color: "#1d1d1d",
1380
- },
1361
+ base: {
1362
+ color: '#1d1d1d',
1363
+ },
1381
1364
  },
1382
1365
  labelStyles: {
1383
- base: {
1384
- fontSize: "12px",
1385
- fontWeight: "bold"
1386
- }
1366
+ base: {
1367
+ fontSize: '12px',
1368
+ fontWeight: 'bold',
1369
+ },
1387
1370
  },
1388
1371
  errorTextStyles: {
1389
- base: {
1390
- color: "#f44336"
1391
- }
1392
- },,
1372
+ base: {
1373
+ color: '#f44336',
1374
+ },
1375
+ },
1393
1376
  type: Skyflow.ElementType.FILE_INPUT,
1394
1377
  });
1395
1378
 
1396
- // Mount the elements
1397
-
1398
- cardNumberElement.mount("#collectCardNumber");
1399
- fileElement.mount("#collectFile");
1400
-
1401
- // Collect and upload methods
1379
+ // Mount the elements.
1380
+ cardNumberElement.mount('#collectCardNumber');
1381
+ fileElement.mount('#collectFile');
1402
1382
 
1403
- container.collect(options={})
1404
- container.uploadFiles()
1383
+ // Collect and upload methods.
1384
+ container.collect({});
1385
+ container.uploadFiles();
1405
1386
 
1406
1387
  ```
1407
1388
  **Sample Response for collect():**