skyflow-js 1.23.0 → 1.24.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.
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
@@ -139,42 +138,43 @@ To insert data into the vault, use the `insert(records, options?)` method of the
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
166
  An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/pure-js.html) of an insert call:
168
167
  ```javascript
169
168
  skyflowClient.insert({
170
- "records": [
171
- {
172
- "table": "cards",
173
- "fields": {
174
- "cardNumber": "41111111111",
175
- "cvv": "123",
176
- }
177
- }]
169
+ records: [
170
+ {
171
+ table: 'cards',
172
+ fields: {
173
+ cardNumber: '41111111111',
174
+ cvv: '123',
175
+ },
176
+ },
177
+ ],
178
178
  });
179
179
  ```
180
180
 
@@ -210,17 +210,17 @@ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
210
210
  A Skyflow collect Element is defined as shown below:
211
211
 
212
212
  ```javascript
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
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.
224
224
  }
225
225
  ```
226
226
  The `table` and `column` fields indicate which table and column in the vault the Element corresponds to.
@@ -241,31 +241,31 @@ Styles are specified with [JSS](https://cssinjs.org/?v=v10.7.1).
241
241
 
242
242
  An example of a inputStyles object:
243
243
  ```javascript
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
- }
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
+ },
269
269
  ```
270
270
  The states that are available for `labelStyles` are `base` and `focus`.
271
271
 
@@ -273,14 +273,14 @@ An example of a labelStyles object:
273
273
 
274
274
  ```javascript
275
275
  labelStyles: {
276
- base: {
277
- fontSize: "12px",
278
- fontWeight: "bold"
279
- },
280
- focus: {
281
- color: "#1d1d1d"
282
- }
283
- }
276
+ base: {
277
+ fontSize: '12px',
278
+ fontWeight: 'bold',
279
+ },
280
+ focus: {
281
+ color: '#1d1d1d',
282
+ },
283
+ },
284
284
  ```
285
285
 
286
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.
@@ -289,10 +289,10 @@ An example of a errorTextStyles object:
289
289
 
290
290
  ```javascript
291
291
  errorTextStyles: {
292
- base: {
293
- color: "#f44336"
294
- }
295
- }
292
+ base: {
293
+ color: '#f44336',
294
+ },
295
+ },
296
296
  ```
297
297
 
298
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:
@@ -313,11 +313,11 @@ Along with CollectElement we can define other options which takes a object of op
313
313
 
314
314
  ```javascript
315
315
  const options = {
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
- }
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
+ };
321
321
  ```
322
322
 
323
323
  `required` parameter indicates whether the field is marked as required or not. If not provided, it defaults to false
@@ -343,27 +343,27 @@ The values that are accepted for `EXPIRATION_YEAR` are
343
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:
344
344
 
345
345
  ```javascript
346
- const collectElement = {
347
- table: "string", //the table this data belongs to
348
- column: "string", //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
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.
357
357
  }
358
358
 
359
359
  const options = {
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
- }
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
+ };
365
365
 
366
- const element = container.create(collectElement, options)
366
+ const element = container.create(collectElement, options);
367
367
  ```
368
368
 
369
369
  ### Step 3: Mount Elements to the DOM
@@ -386,7 +386,7 @@ To specify where the Elements will be rendered on your page, create placeholder
386
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".
387
387
 
388
388
  ```javascript
389
- element.mount("#cardNumber")
389
+ element.mount('#cardNumber');
390
390
  ```
391
391
  you can use the `unmount` method to reset any collect element to it's initial state.
392
392
  ```javascript
@@ -403,22 +403,29 @@ When the form is ready to be submitted, call the `collect(options?)` method on t
403
403
 
404
404
  ```javascript
405
405
  const options = {
406
- tokens: true //optional, indicates whether tokens for the collected data should be returned. Defaults to 'true'
407
- additionalFields: {
406
+ tokens: true, // Optional, indicates whether tokens for the collected data should be returned. Defaults to 'true'.
407
+ additionalFields: {
408
408
  records: [
409
409
  {
410
- table: "string", //table into which record should be inserted
410
+ table: 'string', // Table into which record should be inserted.
411
411
  fields: {
412
- column1: "value", //column names should match vault column names
413
- //...additional fields here
414
- }
415
- }
416
- //...additional records here
417
- ]
418
- }, //optional
419
- }
412
+ column1: 'value', // Column names should match vault column names.
413
+ // ...additional fields here.
414
+ },
415
+ },
416
+ // ...additional records here.
417
+ ],
418
+ }, // Optional
419
+ upsert: [
420
+ // Upsert operations support in the vault
421
+ {
422
+ table: 'string', // Table name
423
+ column: 'value', // Unique column in the table
424
+ },
425
+ ], // Optional
426
+ };
420
427
 
421
- container.collect(options)
428
+ container.collect(options);
422
429
  ```
423
430
 
424
431
  ### End to end example of collecting data with Skyflow Elements
@@ -427,58 +434,59 @@ container.collect(options)
427
434
 
428
435
  ```javascript
429
436
  //Step 1
430
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
437
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
431
438
 
432
439
  //Step 2
433
- const element = container.create({
434
- table: "cards",
435
- column: "cardNumber",
440
+ const element = container.create({
441
+ table: 'cards',
442
+ column: 'cardNumber',
436
443
  inputstyles: {
437
- base: {
438
- color: "#1d1d1d",
439
- },
440
- cardIcon:{
441
- position: "absolute",
442
- left:"8px",
443
- bottom:"calc(50% - 12px)"
444
+ base: {
445
+ color: '#1d1d1d',
446
+ },
447
+ cardIcon: {
448
+ position: 'absolute',
449
+ left: '8px',
450
+ bottom: 'calc(50% - 12px)',
444
451
  },
445
452
  },
446
453
  labelStyles: {
447
- base: {
448
- fontSize: "12px",
449
- fontWeight: "bold"
450
- }
454
+ base: {
455
+ fontSize: '12px',
456
+ fontWeight: 'bold',
457
+ },
451
458
  },
452
459
  errorTextStyles: {
453
- base: {
454
- color: "#f44336"
455
- }
460
+ base: {
461
+ color: '#f44336',
462
+ },
456
463
  },
457
- placeholder: "Card Number",
458
- label: "card_number",
459
- type: Skyflow.ElementType.CARD_NUMBER
460
- })
464
+ placeholder: 'Card Number',
465
+ label: 'card_number',
466
+ type: Skyflow.ElementType.CARD_NUMBER,
467
+ });
461
468
 
462
469
  // Step 3
463
- element.mount("#cardNumber") //assumes there is a div with id="#cardNumber" in the webpage
470
+ element.mount('#cardNumber'); // Assumes there is a div with id='#cardNumber' in the webpage.
464
471
 
465
472
  // Step 4
466
473
 
467
474
  const nonPCIRecords = {
468
- "records": [
469
- {
470
- "table": "cards",
471
- "fields": {
472
- "gender": "MALE"
473
- }
474
- }
475
- ]
476
- }
475
+ records: [
476
+ {
477
+ table: 'cards',
478
+ fields: {
479
+ gender: 'MALE',
480
+ },
481
+ },
482
+ ],
483
+ };
477
484
 
478
485
  container.collect({
479
486
  tokens: true,
480
- additionalFields: nonPCIRecords
481
- })
487
+ additionalFields: nonPCIRecords,
488
+ });
489
+
482
490
  ```
483
491
 
484
492
  **Sample Response :**
@@ -563,7 +571,7 @@ const cvvElement = container.create({
563
571
 
564
572
  // Step 3
565
573
  cardNumberElement.mount("#cardNumber") //Assumes there is a div with id="#cardNumber" in the webpage.
566
- cvvElement.mount("#cvv"); //Aassumes there is a div with id="#cvv" in the webpage.
574
+ cvvElement.mount("#cvv"); //Assumes there is a div with id="#cvv" in the webpage.
567
575
 
568
576
  // Step 4
569
577
  container.collect({
@@ -615,7 +623,7 @@ const regexMatchRule = {
615
623
  type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
616
624
  params: {
617
625
  regex: RegExp,
618
- error: string // optional, default error is "VALIDATION FAILED"
626
+ error: string // Optional, default error is 'VALIDATION FAILED'.
619
627
  }
620
628
  }
621
629
  ```
@@ -626,9 +634,9 @@ const regexMatchRule = {
626
634
  const lengthMatchRule = {
627
635
  type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
628
636
  params: {
629
- min : number, // optional
630
- max : number, // optional
631
- error: string // optional, default error is "VALIDATION FAILED"
637
+ min : number, // Optional.
638
+ max : number, // Optional.
639
+ error: string // Optional, default error is 'VALIDATION FAILED'.
632
640
  }
633
641
  }
634
642
  ```
@@ -640,7 +648,7 @@ const elementValueMatchRule = {
640
648
  type: Skyflow.ValidationRuleType.ELEMENT_VALUE_MATCH_RULE,
641
649
  params: {
642
650
  element: CollectElement,
643
- error: string // optional, default error is "VALIDATION FAILED"
651
+ error: string // Optional, default error is 'VALIDATION FAILED'.
644
652
  }
645
653
  }
646
654
  ```
@@ -653,71 +661,72 @@ The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/s
653
661
  Adding REGEX_MATCH_RULE , LENGTH_MATCH_RULE to collect element.
654
662
  */
655
663
 
656
- // this rule allows 1 or more alphabets
664
+ // This rule allows 1 or more alphabets.
657
665
  const alphabetsOnlyRegexRule = {
658
666
  type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
659
- params:{
667
+ params: {
660
668
  regex: /^[A-Za-z]+$/,
661
- error: "Only alphabets are allowed"
662
- }
663
- };
669
+ error: 'Only alphabets are allowed',
670
+ },
671
+ };
664
672
 
665
- // this rule allows input length between 4 and 6 characters
673
+ // This rule allows input length between 4 and 6 characters.
666
674
  const lengthRule = {
667
675
  type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
668
- params:{
676
+ params: {
669
677
  min: 4,
670
678
  max: 6,
671
- error: "Must be between 4 and 6 alphabets"
672
- }
673
- };
674
-
675
- const cardHolderNameElement = collectContainer.create({
676
- table: "pii_fields",
677
- column: "first_name",
678
- ...collectStylesOptions,
679
- label: "Card Holder Name",
680
- placeholder: "cardholder name",
681
- type: Skyflow.ElementType.INPUT_FIELD,
682
- validations: [alphabetsOnlyRegexRule, lengthRule]
683
- });
679
+ error: 'Must be between 4 and 6 alphabets',
680
+ },
681
+ };
682
+
683
+ const cardHolderNameElement = collectContainer.create({
684
+ table: 'pii_fields',
685
+ column: 'first_name',
686
+ ...collectStylesOptions,
687
+ label: 'Card Holder Name',
688
+ placeholder: 'cardholder name',
689
+ type: Skyflow.ElementType.INPUT_FIELD,
690
+ validations: [alphabetsOnlyRegexRule, lengthRule],
691
+ });
684
692
 
685
693
  /*
686
694
  Reset PIN - A simple example that illustrates custom validations.
687
695
  The below code shows an example of ELEMENT_VALUE_MATCH_RULE
688
696
  */
689
697
 
690
- // for the PIN element
698
+ // For the PIN element
691
699
  const pinElement = collectContainer.create({
692
- label: "PIN",
693
- placeholder: "****",
700
+ label: 'PIN',
701
+ placeholder: '****',
694
702
  type: Skyflow.ElementType.PIN,
695
703
  });
696
704
 
697
- // this rule allows to match the value with pinElement
698
- let elementMatchRule = {
705
+ // This rule allows to match the value with pinElement.
706
+ const elementMatchRule = {
699
707
  type: Skyflow.ValidationRuleType.ELEMENT_VALUE_MATCH_RULE,
700
- params:{
708
+ params: {
701
709
  element: pinElement,
702
- error: "PIN doesn't match"
703
- }
704
- }
710
+ error: "PIN doesn't match",
711
+ },
712
+ };
713
+
705
714
  const confirmPinElement = collectContainer.create({
706
- label: "Confirm PIN",
707
- placeholder: "****",
715
+ label: 'Confirm PIN',
716
+ placeholder: '****',
708
717
  type: Skyflow.ElementType.PIN,
709
- validations: [elementMatchRule]
718
+ validations: [elementMatchRule],
710
719
  });
711
720
 
712
- // mount elements on screen - errors will be shown if any of the validaitons fail
713
- pinElement.mount("#collectPIN");
714
- confirmPinElement.mount("#collectConfirmPIN");
721
+ // Mount elements on screen - errors will be shown if any of the validaitons fail.
722
+ pinElement.mount('#collectPIN');
723
+ confirmPinElement.mount('#collectConfirmPIN');
715
724
 
716
725
  ```
717
726
  ### Event Listener on Collect Elements
718
727
 
719
728
 
720
- Helps to communicate with skyflow elements / iframes by listening to an event
729
+ Helps to communicate with Skyflow elements / iframes by listening to an event
721
730
 
722
731
  ```javascript
723
732
  element.on(Skyflow.EventName,handler:function)
@@ -753,82 +762,80 @@ values of SkyflowElements will be returned in elementstate object only when `env
753
762
 
754
763
  ##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/collect-element-listeners.html) for using listeners
755
764
  ```javascript
756
- //create skyflow client
765
+ // Create Skyflow client.
757
766
  const skyflowClient = Skyflow.init({
758
- vaultID: <VAULT_ID>,
759
- vaultURL: <VAULT_URL>,
760
- getBearerToken: ()=>{},
761
- options: {
762
- env: Skyflow.Env.DEV
763
- }
764
- })
767
+ vaultID: '<VAULT_ID>',
768
+ vaultURL: '<VAULT_URL>',
769
+ getBearerToken: () => {},
770
+ options: {
771
+ env: Skyflow.Env.DEV,
772
+ },
773
+ });
765
774
 
766
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
775
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
767
776
 
768
777
  const cardNumber = container.create({
769
- table: "pii_fields",
770
- column: "primary_card.card_number",
771
- type: Skyflow.ElementType.CARD_NUMBER,
772
- });
778
+ table: 'pii_fields',
779
+ column: 'primary_card.card_number',
780
+ type: Skyflow.ElementType.CARD_NUMBER,
781
+ });
773
782
 
774
- cardNumber.mount("#cardNumberContainer");
783
+ cardNumber.mount('#cardNumberContainer');
775
784
 
776
- //subscribing to CHANGE event, which gets triggered when element changes
777
- cardNumber.on(Skyflow.EventName.CHANGE,(state) => {
778
- // Your implementation when Change event occurs
779
- console.log(state)
785
+ // Subscribing to CHANGE event, which gets triggered when element changes.
786
+ cardNumber.on(Skyflow.EventName.CHANGE, state => {
787
+ // Your implementation when Change event occurs.
788
+ console.log(state);
780
789
  });
790
+
781
791
  ```
782
792
  ##### Sample Element state object when `env` is `DEV`
783
793
 
784
794
  ```javascript
785
795
  {
786
- elementType: "CARD_NUMBER"
787
- isEmpty: false
788
- isFocused: true
789
- isValid: false
790
- value: "411"
791
- }
792
-
796
+ elementType: 'CARD_NUMBER',
797
+ isEmpty: false,
798
+ isFocused: true,
799
+ isValid: false,
800
+ value: '411',
801
+ };
793
802
  ```
794
803
  ##### Sample Element state object when `env` is `PROD`
795
804
 
796
805
  ```javascript
797
806
  {
798
- elementType: "CARD_NUMBER"
799
- isEmpty: false
800
- isFocused: true
801
- isValid: false
802
- value: ''
803
- }
807
+ elementType: 'CARD_NUMBER',
808
+ isEmpty: false,
809
+ isFocused: true,
810
+ isValid: false,
811
+ value: '',
812
+ };
804
813
  ```
805
814
 
806
815
  ### UI Error for Collect Elements
807
816
 
808
817
  Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
809
818
 
810
- `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.
819
+ `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.
811
820
 
812
821
  `resetError()` method is used to clear the custom error message that is set using `setError`.
813
822
 
814
823
  ##### Sample code snippet for setError and resetError
815
824
 
816
825
  ```javascript
817
-
818
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
826
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
819
827
 
820
828
  const cardNumber = container.create({
821
- table: "pii_fields",
822
- column: "primary_card.card_number",
823
- type: Skyflow.ElementType.CARD_NUMBER,
829
+ table: 'pii_fields',
830
+ column: 'primary_card.card_number',
831
+ type: Skyflow.ElementType.CARD_NUMBER,
824
832
  });
825
833
 
826
- //Set custom error
827
- cardNumber.setError("custom error");
834
+ // Set custom error.
835
+ cardNumber.setError('custom error');
828
836
 
829
- //reset custom error
837
+ // Reset custom error.
830
838
  cardNumber.resetError();
831
-
832
839
  ```
833
840
 
834
841
  ### Set and Clear value for Collect Elements (DEV ENV ONLY)
@@ -842,18 +849,18 @@ cardNumber.resetError();
842
849
  ##### Sample code snippet for setValue and clearValue
843
850
 
844
851
  ```javascript
845
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
852
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
846
853
 
847
854
  const cardNumber = container.create({
848
- table: "pii_fields",
849
- column: "primary_card.card_number",
850
- type: Skyflow.ElementType.CARD_NUMBER,
855
+ table: 'pii_fields',
856
+ column: 'primary_card.card_number',
857
+ type: Skyflow.ElementType.CARD_NUMBER,
851
858
  });
852
859
 
853
- // Set a value programatically
854
- cardNumber.setValue("4111111111111111");
860
+ // Set a value programatically.
861
+ cardNumber.setValue('4111111111111111');
855
862
 
856
- // Clear the value
863
+ // Clear the value.
857
864
  cardNumber.clearValue();
858
865
 
859
866
  ```
@@ -877,25 +884,25 @@ For non-PCI use-cases, retrieving data from the vault and revealing it in the br
877
884
 
878
885
  ```javascript
879
886
  const records = {
880
- "records": [
881
- {
882
- token: "string", // token for the record to be fetched
883
- }
884
- ]
885
- }
887
+ records: [
888
+ {
889
+ token: 'string', // Token for the record to be fetched.
890
+ },
891
+ ],
892
+ };
886
893
 
887
- skyflow.detokenize(records)
894
+ skyflow.detokenize(records);
888
895
  ```
889
896
  An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/pure-js.html) of a detokenize call:
890
897
 
891
898
  ```javascript
892
899
  skyflow.detokenize({
893
- "records": [
900
+ records: [
894
901
  {
895
- token: "131e70dc-6f76-4319-bdd3-96281e051051"
896
- }
897
- ]
898
- })
902
+ token: '131e70dc-6f76-4319-bdd3-96281e051051',
903
+ },
904
+ ],
905
+ });
899
906
  ```
900
907
 
901
908
  The sample response:
@@ -915,11 +922,11 @@ The sample response:
915
922
 
916
923
  ```javascript
917
924
  {
918
- "records": [
925
+ records: [
919
926
  {
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
927
+ ids: string[], // Array of SkyflowID's of the records to be fetched.
928
+ table: string, // Table holding the above skyflow_id's.
929
+ redaction: Skyflow.RedactionType, // Redaction to be applied to retrieved data.
923
930
  }
924
931
  ]
925
932
  }
@@ -934,17 +941,16 @@ There are 4 accepted values in Skyflow.RedactionTypes:
934
941
  An example of getById call:
935
942
 
936
943
  ```javascript
937
-
938
944
  skyflow.getById({
939
945
  records: [
940
946
  {
941
- ids: ["f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9"],
942
- table: "cards",
947
+ ids: ['f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9'],
948
+ table: 'cards',
943
949
  redaction: Skyflow.RedactionType.PLAIN_TEXT,
944
950
  },
945
951
  {
946
- ids: ["da26de53-95d5-4bdb-99db-8d8c66a35ff9"],
947
- table: "contacts",
952
+ ids: ['da26de53-95d5-4bdb-99db-8d8c66a35ff9'],
953
+ table: 'contacts',
948
954
  redaction: Skyflow.RedactionType.PLAIN_TEXT,
949
955
  },
950
956
  ],
@@ -996,14 +1002,13 @@ Then define a Skyflow Element to reveal data as shown below.
996
1002
 
997
1003
  ```javascript
998
1004
  const revealElement = {
999
- token: "string", //required, token of the data being revealed
1000
- inputStyles: {}, //optional styles to be applied to the element
1001
- labelStyles: {}, //optional, styles to be applied to the label of the reveal element
1002
- errorTextStyles: {}, //optional styles that will be applied to the errorText of the reveal element
1003
- label: "string", //optional, label for the form element
1004
- altText: "string" //optional, string that is shown before reveal, will show token if altText is not provided
1005
- }
1006
-
1005
+ token: 'string', // Required, token of the data being revealed.
1006
+ inputStyles: {}, // Optional, styles to be applied to the element.
1007
+ labelStyles: {}, // Optional, styles to be applied to the label of the reveal element.
1008
+ errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the reveal element.
1009
+ label: 'string', // Optional, label for the form element.
1010
+ altText: 'string', // Optional, string that is shown before reveal, will show token if altText is not provided.
1011
+ };
1007
1012
  ```
1008
1013
 
1009
1014
  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.
@@ -1012,36 +1017,36 @@ An example of a inputStyles object:
1012
1017
 
1013
1018
  ```javascript
1014
1019
  inputStyles: {
1015
- base: {
1016
- color: "#1d1d1d"
1017
- },
1018
- copyIcon:{
1019
- position: "absolute",
1020
- right:"8px",
1021
- top: "calc(50% - 10px)",
1022
- }
1023
- }
1020
+ base: {
1021
+ color: '#1d1d1d',
1022
+ },
1023
+ copyIcon: {
1024
+ position: 'absolute',
1025
+ right: '8px',
1026
+ top: 'calc(50% - 10px)',
1027
+ },
1028
+ },
1024
1029
  ```
1025
1030
 
1026
1031
  An example of a labelStyles object:
1027
1032
 
1028
1033
  ```javascript
1029
1034
  labelStyles: {
1030
- base: {
1031
- fontSize: "12px",
1032
- fontWeight: "bold"
1033
- }
1034
- }
1035
+ base: {
1036
+ fontSize: '12px',
1037
+ fontWeight: 'bold',
1038
+ },
1039
+ },
1035
1040
  ```
1036
1041
 
1037
1042
  An example of a errorTextStyles object:
1038
1043
 
1039
1044
  ```javascript
1040
1045
  errorTextStyles: {
1041
- base: {
1042
- color: "#f44336"
1043
- }
1044
- }
1046
+ base: {
1047
+ color: '#f44336',
1048
+ },
1049
+ },
1045
1050
  ```
1046
1051
 
1047
1052
  Once you've defined a Skyflow Element, you can use the `create(element)` method of the container to create the Element as shown below:
@@ -1059,13 +1064,14 @@ Elements used for revealing data are mounted to the DOM the same way as Elements
1059
1064
  When the sensitive data is ready to be retrieved and revealed, call the `reveal()` method on the container as shown below:
1060
1065
 
1061
1066
  ```javascript
1062
- container.reveal()
1063
- .then((data) => {
1064
- //handle success
1065
- })
1066
- .catch((err) => {
1067
- //handle error
1067
+ container
1068
+ .reveal()
1069
+ .then(data => {
1070
+ // Handle success.
1068
1071
  })
1072
+ .catch(err => {
1073
+ // Handle error.
1074
+ });
1069
1075
  ```
1070
1076
 
1071
1077
 
@@ -1073,55 +1079,55 @@ container.reveal()
1073
1079
 
1074
1080
  **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
1075
1081
  ```javascript
1076
- //Step 1
1077
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1082
+ // Step 1.
1083
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1078
1084
 
1079
- //Step 2
1080
- const cardNumberElement = container.create({
1081
- token: "b63ec4e0-bbad-4e43-96e6-6bd50f483f75",
1085
+ // Step 2.
1086
+ const cardNumberElement = container.create({
1087
+ token: 'b63ec4e0-bbad-4e43-96e6-6bd50f483f75',
1082
1088
  inputStyles: {
1083
- base: {
1084
- color: "#1d1d1d",
1085
- },
1089
+ base: {
1090
+ color: '#1d1d1d',
1091
+ },
1086
1092
  },
1087
1093
  labelStyles: {
1088
1094
  base: {
1089
- fontSize: "12px",
1090
- }
1095
+ fontSize: '12px',
1096
+ },
1091
1097
  },
1092
1098
  errorTextStyles: {
1093
1099
  base: {
1094
- color: "#f44336"
1095
- }
1096
- },
1097
- label: "card_number",
1098
- altText: "XXXX XXXX XXXX XXXX"
1099
- })
1100
+ color: '#f44336',
1101
+ },
1102
+ },
1103
+ label: 'card_number',
1104
+ altText: 'XXXX XXXX XXXX XXXX',
1105
+ });
1100
1106
 
1101
- const cvvElement = container.create({
1102
- token: "89024714-6a26-4256-b9d4-55ad69aa4047",
1107
+ const cvvElement = container.create({
1108
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1103
1109
  inputStyles: {
1104
- base: {
1105
- color: "#1d1d1d",
1106
- },
1110
+ base: {
1111
+ color: '#1d1d1d',
1107
1112
  },
1108
- label: "cvv",
1109
- altText: "XXX"
1110
- })
1113
+ },
1114
+ label: 'cvv',
1115
+ altText: 'XXX',
1116
+ });
1111
1117
 
1112
- //Step 3
1113
- cardNumberElement.mount("#cardNumber") //assumes there is a placeholder div with id="#cardNumber" on the page
1114
- cvvElement.mount("#cvv") //assumes there is a placeholder div with id="#cvv" on the page
1115
-
1116
- //Step 4
1117
- container
1118
- .reveal()
1119
- .then((data) => {
1120
- //handle success
1121
- })
1122
- .catch((err) => {
1123
- //handle error
1124
- });
1118
+ // Step 3.
1119
+ cardNumberElement.mount('#cardNumber'); // Assumes there is a placeholder div with id='cardNumber' on the page
1120
+ cvvElement.mount('#cvv'); // Assumes there is a placeholder div with id='cvv' on the page
1121
+
1122
+ // Step 4.
1123
+ container
1124
+ .reveal()
1125
+ .then(data => {
1126
+ // Handle success.
1127
+ })
1128
+ .catch(err => {
1129
+ // Handle error.
1130
+ });
1125
1131
  ```
1126
1132
 
1127
1133
  The response below shows that some tokens assigned to the reveal elements get revealed successfully, while others fail and remain unrevealed.
@@ -1150,26 +1156,24 @@ The response below shows that some tokens assigned to the reveal elements get re
1150
1156
  ### UI Error for Reveal Elements
1151
1157
  Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
1152
1158
 
1153
- `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.
1159
+ `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.
1154
1160
 
1155
1161
  `resetError()` method is used to clear the custom error message that is set using `setError`.
1156
1162
 
1157
1163
  ##### Sample code snippet for setError and resetError
1158
1164
 
1159
1165
  ```javascript
1160
-
1161
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1166
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1162
1167
 
1163
1168
  const cardNumber = container.create({
1164
- token: "89024714-6a26-4256-b9d4-55ad69aa4047",
1169
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1165
1170
  });
1166
1171
 
1167
- //Set custom error
1168
- cardNumber.setError("custom error");
1172
+ // Set custom error.
1173
+ cardNumber.setError('custom error');
1169
1174
 
1170
- //reset custom error
1175
+ // Reset custom error.
1171
1176
  cardNumber.resetError();
1172
-
1173
1177
  ```
1174
1178
  ### Set token for Reveal Elements
1175
1179
 
@@ -1177,15 +1181,14 @@ The `setToken(value: string)` method can be used to set the token of the Reveal
1177
1181
 
1178
1182
  ##### Sample code snippet for setToken
1179
1183
  ```javascript
1180
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1184
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1181
1185
 
1182
1186
  const cardNumber = container.create({
1183
- altText:"Card Number",
1187
+ altText: 'Card Number',
1184
1188
  });
1185
1189
 
1186
- // set token
1187
- cardNumber.setToken("89024714-6a26-4256-b9d4-55ad69aa4047");
1188
-
1190
+ // Set token.
1191
+ cardNumber.setToken('89024714-6a26-4256-b9d4-55ad69aa4047');
1189
1192
  ```
1190
1193
  ### Set and Clear altText for Reveal Elements
1191
1194
  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.
@@ -1194,17 +1197,18 @@ The `setAltText(value: string)` method can be used to set the altText of the Rev
1194
1197
  ##### Sample code snippet for setAltText and clearAltText
1195
1198
 
1196
1199
  ```javascript
1197
- const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
1200
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
1198
1201
 
1199
1202
  const cardNumber = container.create({
1200
- token:"89024714-6a26-4256-b9d4-55ad69aa4047",
1203
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
1201
1204
  });
1202
1205
 
1203
- // set altText
1204
- cardNumber.setAltText("Card Number");
1206
+ // Set altText.
1207
+ cardNumber.setAltText('Card Number');
1208
+
1209
+ // Clear altText.
1210
+ cardNumber.clearAltText();
1205
1211
 
1206
- //clear altText
1207
- cardNumber.clearAltText();
1208
1212
  ```
1209
1213
 
1210
1214
  ## Using Skyflow File Element to upload a file
@@ -1224,13 +1228,13 @@ Skyflow Collect Elements are defined as follows:
1224
1228
 
1225
1229
  ```javascript
1226
1230
  const collectElement = {
1227
- table: "string", //the table this data belongs to
1228
- column: "string", //the column into which this data should be inserted
1229
- skyflowID: "string", // the skyflow_id of the record
1230
- type: Skyflow.ElementType.FILE_INPUT, //Skyflow.ElementType enum
1231
- inputStyles: {}, //optional styles that should be applied to the form element
1232
- labelStyles: {}, //optional styles that will be applied to the label of the collect element
1233
- errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
1231
+ type: Skyflow.ElementType.FILE_INPUT, // Skyflow.ElementType enum.
1232
+ table: 'string', // The table this data belongs to.
1233
+ column: 'string', // The column into which this data should be inserted.
1234
+ skyflowID: 'string', // The skyflow_id of the record.
1235
+ inputStyles: {}, // Optional, styles that should be applied to the form element.
1236
+ labelStyles: {}, // Optional, styles that will be applied to the label of the collect element.
1237
+ errorTextStyles:{}, // Optional, styles that will be applied to the errorText of the collect element.
1234
1238
  }
1235
1239
  ```
1236
1240
  The `table` and `column` fields indicate which table and column the Element corresponds to.
@@ -1256,7 +1260,7 @@ To specify where to render Elements on your page, create placeholder `<div>` ele
1256
1260
  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".
1257
1261
 
1258
1262
  ```javascript
1259
- element.mount("#file")
1263
+ element.mount('#file');
1260
1264
  ```
1261
1265
  Use the `unmount` method to reset a Collect Element to its initial state.
1262
1266
 
@@ -1268,7 +1272,7 @@ element.unmount();
1268
1272
  When the file is ready to be uploaded, call the `uploadFiles()` method on the container object.
1269
1273
 
1270
1274
  ```javascript
1271
- container.uploadFiles()
1275
+ container.uploadFiles();
1272
1276
  ```
1273
1277
  ### File upload limitations:
1274
1278
 
@@ -1281,38 +1285,38 @@ container.uploadFiles()
1281
1285
  ### End-to-end file upload
1282
1286
 
1283
1287
  ```javascript
1284
- //Step 1
1285
- const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
1288
+ // Step 1.
1289
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
1286
1290
 
1287
- //Step 2
1288
- const element = container.create({
1289
- table: "pii_fields",
1290
- column: "file",
1291
- skyflowID:"431eaa6c-5c15-4513-aa15-29f50babe882",
1291
+ // Step 2.
1292
+ const element = container.create({
1293
+ table: 'pii_fields',
1294
+ column: 'file',
1295
+ skyflowID: '431eaa6c-5c15-4513-aa15-29f50babe882',
1292
1296
  inputstyles: {
1293
- base: {
1294
- color: "#1d1d1d",
1295
- },
1297
+ base: {
1298
+ color: '#1d1d1d',
1299
+ },
1296
1300
  },
1297
1301
  labelStyles: {
1298
- base: {
1299
- fontSize: "12px",
1300
- fontWeight: "bold"
1301
- }
1302
+ base: {
1303
+ fontSize: '12px',
1304
+ fontWeight: 'bold',
1305
+ },
1302
1306
  },
1303
1307
  errorTextStyles: {
1304
- base: {
1305
- color: "#f44336"
1306
- }
1308
+ base: {
1309
+ color: '#f44336',
1310
+ },
1307
1311
  },
1308
- type: Skyflow.ElementType.FILE_INPUT
1309
- })
1312
+ type: Skyflow.ElementType.FILE_INPUT,
1313
+ });
1310
1314
 
1311
- // Step 3
1312
- element.mount("#file") //assumes there is a div with id="#file" in the webpage
1315
+ // Step 3.
1316
+ element.mount('#file'); // Assumes there is a div with id='#file' in the webpage.
1313
1317
 
1314
- // Step 4
1315
- container.uploadFiles()
1318
+ // Step 4.
1319
+ container.uploadFiles();
1316
1320
  ```
1317
1321
 
1318
1322
  **Sample Response :**
@@ -1328,69 +1332,64 @@ container.uploadFiles()
1328
1332
  #### File upload with additional elements
1329
1333
 
1330
1334
  ```javascript
1331
- // Create collect Container
1332
-
1335
+ // Create collect Container.
1333
1336
  const collectContainer = skyflow.container(Skyflow.ContainerType.COLLECT);
1334
1337
 
1335
-
1336
- // Create collect elements
1337
-
1338
+ // Create collect elements.
1338
1339
  const cardNumberElement = collectContainer.create({
1339
- table: "newTable",
1340
- column: "card_number",
1340
+ table: 'newTable',
1341
+ column: 'card_number',
1341
1342
  inputstyles: {
1342
- base: {
1343
- color: "#1d1d1d",
1344
- },
1343
+ base: {
1344
+ color: '#1d1d1d',
1345
+ },
1345
1346
  },
1346
1347
  labelStyles: {
1347
- base: {
1348
- fontSize: "12px",
1349
- fontWeight: "bold"
1350
- }
1348
+ base: {
1349
+ fontSize: '12px',
1350
+ fontWeight: 'bold',
1351
+ },
1351
1352
  },
1352
1353
  errorTextStyles: {
1353
- base: {
1354
- color: "#f44336"
1355
- }
1356
- },,
1357
- placeholder: "card number",
1358
- label: "Card Number",
1354
+ base: {
1355
+ color: '#f44336',
1356
+ },
1357
+ },
1358
+ placeholder: 'card number',
1359
+ label: 'Card Number',
1359
1360
  type: Skyflow.ElementType.CARD_NUMBER,
1360
1361
  });
1361
1362
 
1362
1363
  const fileElement = collectContainer.create({
1363
- table: "newTable",
1364
- column: "file",
1364
+ table: 'newTable',
1365
+ column: 'file',
1365
1366
  skyflowID: '431eaa6c-5c15-4513-aa15-29f50babe882',
1366
1367
  inputstyles: {
1367
- base: {
1368
- color: "#1d1d1d",
1369
- },
1368
+ base: {
1369
+ color: '#1d1d1d',
1370
+ },
1370
1371
  },
1371
1372
  labelStyles: {
1372
- base: {
1373
- fontSize: "12px",
1374
- fontWeight: "bold"
1375
- }
1373
+ base: {
1374
+ fontSize: '12px',
1375
+ fontWeight: 'bold',
1376
+ },
1376
1377
  },
1377
1378
  errorTextStyles: {
1378
- base: {
1379
- color: "#f44336"
1380
- }
1381
- },,
1379
+ base: {
1380
+ color: '#f44336',
1381
+ },
1382
+ },
1382
1383
  type: Skyflow.ElementType.FILE_INPUT,
1383
1384
  });
1384
1385
 
1385
- // Mount the elements
1386
-
1387
- cardNumberElement.mount("#collectCardNumber");
1388
- fileElement.mount("#collectFile");
1389
-
1390
- // Collect and upload methods
1386
+ // Mount the elements.
1387
+ cardNumberElement.mount('#collectCardNumber');
1388
+ fileElement.mount('#collectFile');
1391
1389
 
1392
- container.collect(options={})
1393
- container.uploadFiles()
1390
+ // Collect and upload methods.
1391
+ container.collect({});
1392
+ container.uploadFiles();
1394
1393
 
1395
1394
  ```
1396
1395
  **Sample Response for collect():**