skyflow-js 1.21.4 → 1.23.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.23.0] - 2022-12-27
6
+ ### Added
7
+ - Added new `get` interface.
8
+
9
+ ## [1.22.0] - 2022-11-15
10
+ ### Added
11
+ - `upsert` support while collecting data through skyflow elements.
12
+ - `upsert` support for pure js `insert` method.
5
13
  ## [1.21.3] - 2022-10-18
6
14
  ### Added
7
15
  - `cardIcon` and `copyIcon` style objects for collect and reveal elements.
package/README.md CHANGED
@@ -126,16 +126,16 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
126
126
  ---
127
127
 
128
128
  # Securely collecting data client-side
129
- - [**Inserting data into the vault**](#inserting-data-into-the-vault)
129
+ - [**Insert data into the vault**](#insert-data-into-the-vault)
130
130
  - [**Using Skyflow Elements to collect data**](#using-skyflow-elements-to-collect-data)
131
131
  - [**Using validations on Collect Elements**](#validations)
132
132
  - [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
133
133
  - [**UI Error for Collect Eements**](#ui-error-for-collect-elements)
134
134
  - [**Set and Clear value for Collect Elements (DEV ENV ONLY)**](#set-and-clear-value-for-collect-elements-dev-env-only)
135
135
  - [**Using Skyflow File Element to upload a file**](#using-skyflow-file-element-to-upload-a-file)
136
- ## Inserting data into the vault
136
+ ## Insert data into the vault
137
137
 
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. See below:
138
+ 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
139
 
140
140
  ```javascript
141
141
  const records = {
@@ -152,15 +152,19 @@ const records = {
152
152
  }
153
153
 
154
154
  const options = {
155
- tokens: true //indicates whether or not tokens should be returned for the inserted data. Defaults to 'true'
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
157
+ {
158
+ table: "string", // table name
159
+ column: "value ", // unique column in the table
160
+ }
161
+ ]
156
162
  }
157
163
 
158
- skyflowClient.insert(records, options={})
164
+ skyflowClient.insert(records, options)
159
165
  ```
160
166
 
161
-
162
-
163
- An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/purejs.html) of an insert call:
167
+ An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/pure-js.html) of an insert call:
164
168
  ```javascript
165
169
  skyflowClient.insert({
166
170
  "records": [
@@ -207,8 +211,8 @@ A Skyflow collect Element is defined as shown below:
207
211
 
208
212
  ```javascript
209
213
  const collectElement = {
210
- table: "string", //optional, the table this data belongs to
211
- column: "string", //optional, the column into which this data should be inserted
214
+ table: "string", //required, the table this data belongs to
215
+ column: "string", //required, the column into which this data should be inserted
212
216
  type: Skyflow.ElementType, //Skyflow.ElementType enum
213
217
  inputStyles: {}, //optional styles that should be applied to the form element
214
218
  labelStyles: {}, //optional styles that will be applied to the label of the collect element
@@ -305,7 +309,7 @@ Finally, the `type` field takes a Skyflow ElementType. Each type applies the app
305
309
 
306
310
  The `INPUT_FIELD` type is a custom UI element without any built-in validations. See the section on [validations](#validations) for more information on validations.
307
311
 
308
- Along with CollectElement we can define other options which takes a dictionary of optional parameters as described below:
312
+ Along with CollectElement we can define other options which takes a object of optional parameters as described below:
309
313
 
310
314
  ```javascript
311
315
  const options = {
@@ -391,10 +395,11 @@ element.unmount();
391
395
 
392
396
  ### Step 4: Collect data from Elements
393
397
 
394
- When the form is ready to be submitted, call the `collect(options?)` method on the container object. The `options` parameter takes a dictionary of optional parameters as shown below:
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:
395
399
 
396
400
  - `tokens`: indicates whether tokens for the collected data should be returned or not. Defaults to 'true'
397
- - `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.
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.
398
403
 
399
404
  ```javascript
400
405
  const options = {
@@ -410,15 +415,15 @@ const options = {
410
415
  }
411
416
  //...additional records here
412
417
  ]
413
- } //optional
418
+ }, //optional
414
419
  }
415
420
 
416
- container.collect(options={})
421
+ container.collect(options)
417
422
  ```
418
423
 
419
424
  ### End to end example of collecting data with Skyflow Elements
420
425
 
421
- **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/skyflowElements.html)**
426
+ **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
422
427
 
423
428
  ```javascript
424
429
  //Step 1
@@ -490,6 +495,102 @@ container.collect({
490
495
  ]
491
496
  }
492
497
  ```
498
+ ### Insert call example with upsert support
499
+ **Sample Code**
500
+
501
+ ```javascript
502
+ //Step 1
503
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
504
+
505
+ //Step 2
506
+ const cardNumberElement = container.create({
507
+ table: "cards",
508
+ column: "card_number",
509
+ inputStyles: {
510
+ base: {
511
+ color: "#1d1d1d",
512
+ },
513
+ cardIcon:{
514
+ position: "absolute",
515
+ left:"8px",
516
+ bottom:"calc(50% - 12px)"
517
+ },
518
+ },
519
+ labelStyles: {
520
+ base: {
521
+ fontSize: "12px",
522
+ fontWeight: "bold"
523
+ }
524
+ },
525
+ errorTextStyles: {
526
+ base: {
527
+ color: "#f44336"
528
+ }
529
+ },
530
+ placeholder: "Card Number",
531
+ label: "card_number",
532
+ type: Skyflow.ElementType.CARD_NUMBER
533
+ })
534
+
535
+ const cvvElement = container.create({
536
+ table: "cards",
537
+ column: "cvv",
538
+ inputStyles: {
539
+ base: {
540
+ color: "#1d1d1d",
541
+ },
542
+ cardIcon:{
543
+ position: "absolute",
544
+ left:"8px",
545
+ bottom:"calc(50% - 12px)"
546
+ },
547
+ },
548
+ labelStyles: {
549
+ base: {
550
+ fontSize: "12px",
551
+ fontWeight: "bold"
552
+ }
553
+ },
554
+ errorTextStyles: {
555
+ base: {
556
+ color: "#f44336"
557
+ }
558
+ },
559
+ placeholder: "CVV",
560
+ label: "cvv",
561
+ type: Skyflow.ElementType.CVV
562
+ })
563
+
564
+ // Step 3
565
+ 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.
567
+
568
+ // Step 4
569
+ container.collect({
570
+ tokens: true,
571
+ upsert: [
572
+ {
573
+ table: "cards",
574
+ column: "card_number",
575
+ }
576
+ ]
577
+ })
578
+
579
+ ```
580
+ **Skyflow returns tokens for the record you just inserted.**
581
+ ```javascript
582
+ {
583
+ "records": [
584
+ {
585
+ "table": "cards",
586
+ "fields": {
587
+ "cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
588
+ "gender": "12f670af-6c7d-4837-83fb-30365fbc0b1e"
589
+ }
590
+ }
591
+ ]
592
+ }
593
+ ```
493
594
 
494
595
  ### Validations
495
596
 
@@ -544,7 +645,7 @@ const elementValueMatchRule = {
544
645
  }
545
646
  ```
546
647
 
547
- The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/CustomValidations.html) for using custom validations:
648
+ The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/custom-validations.html) for using custom validations:
548
649
 
549
650
  ```javascript
550
651
  /*
@@ -650,7 +751,7 @@ state : {
650
751
  `Note:`
651
752
  values of SkyflowElements will be returned in elementstate object only when `env` is `DEV`, else it is empty string i.e, ''
652
753
 
653
- ##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/CollectElementListeners.html) for using listeners
754
+ ##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/collect-element-listeners.html) for using listeners
654
755
  ```javascript
655
756
  //create skyflow client
656
757
  const skyflowClient = Skyflow.init({
@@ -785,7 +886,7 @@ const records = {
785
886
 
786
887
  skyflow.detokenize(records)
787
888
  ```
788
- An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/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:
789
890
 
790
891
  ```javascript
791
892
  skyflow.detokenize({
@@ -895,7 +996,7 @@ Then define a Skyflow Element to reveal data as shown below.
895
996
 
896
997
  ```javascript
897
998
  const revealElement = {
898
- token: "string", //optional, token of the data being revealed
999
+ token: "string", //required, token of the data being revealed
899
1000
  inputStyles: {}, //optional styles to be applied to the element
900
1001
  labelStyles: {}, //optional, styles to be applied to the label of the reveal element
901
1002
  errorTextStyles: {}, //optional styles that will be applied to the errorText of the reveal element
@@ -970,7 +1071,7 @@ container.reveal()
970
1071
 
971
1072
  ### End to end example of all steps
972
1073
 
973
- **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/skyflowElements.html)**
1074
+ **[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/skyflow-elements.html)**
974
1075
  ```javascript
975
1076
  //Step 1
976
1077
  const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)