skyflow-js 1.33.3 → 1.33.4

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,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.33.3] - 2023-11-15
6
+ ## Fixed
7
+ - Patch fix for reverting changes for internal jQuery dependency changes.
8
+
9
+ ## [1.33.2] - 2023-11-13
10
+ ## Changed
11
+ - Replace internal jQuery dependency with custom implementation.
12
+
13
+ ## [1.33.1] - 2023-11-10
14
+ ### Added
15
+ - file render internal code change
16
+
17
+ ## [1.33.0] - 2023-11-07
18
+ ### Added
19
+ - Added file render elements
20
+
5
21
  ## [1.32.0] - 2023-10-26
6
22
  ### Added
7
23
  - `tokens` support in Get interface
package/README.md CHANGED
@@ -361,12 +361,12 @@ Only applicable to EXPIRATION_DATE, CARD_NUMBER, EXPIRATION_YEAR, and INPUT_FIEL
361
361
 
362
362
  Accepted values by element type:
363
363
 
364
- | Element type | `format`and `translation` values | Examples |
365
- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
366
- | EXPIRATION_DATE | <li>`format`</li> <ul><li>`mm/yy` (default)</li><li>`mm/yyyy`</li><li>`yy/mm`</li><li>`yyyy/mm`</li></ul> | <ul><li>12/27</li><li>12/2027</li> <li>27/12</li> <li> 2027/12</li></ul></ul> |
367
- | EXPIRATION_YEAR | <li>`format`</li> <ul><li>`yy` (default)</li><li>`yyyy`</li></ul> | <ul><li>27</li><li>2027</li></ul> |
368
- | CARD_NUMBER | <li>`format`</li> <ul><li>`XXXX XXXX XXXX XXXX` (default)</li><li>`XXXX-XXXX-XXXX-XXXX`</li></ul> | <ul><li>1234 5678 9012 3456</li><li>1234-5678-9012-3456</li></ul> |
369
- | INPUT_FIELD | <li>`format`: A string that matches the desired output, with placeholder characters of your choice.</li><li>`translation`: An object of key/value pairs. Defaults to `{"X": "[0-9]"}`</li> | With a `format` of `+91 XXXX-XX-XXXX` and a `translation` of `[ "X": "[0-9]"]`, user input of "1234121234" displays as "+91 1234-12-1234". |
364
+ | Element type | `format`and `translation` values | Examples |
365
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
366
+ | EXPIRATION_DATE | <li>`format`</li> <ul><li>`mm/yy` (default)</li><li>`mm/yyyy`</li><li>`yy/mm`</li><li>`yyyy/mm`</li></ul> | <ul><li>12/27</li><li>12/2027</li> <li>27/12</li> <li> 2027/12</li></ul></ul> |
367
+ | EXPIRATION_YEAR | <li>`format`</li> <ul><li>`yy` (default)</li><li>`yyyy`</li></ul> | <ul><li>27</li><li>2027</li></ul> |
368
+ | CARD_NUMBER | <li>`format`</li> <ul><li>`XXXX XXXX XXXX XXXX` (default)</li><li>`XXXX-XXXX-XXXX-XXXX`</li></ul> | <ul><li>1234 5678 9012 3456</li><li>1234-5678-9012-3456</li></ul> |
369
+ | INPUT_FIELD | <li>`format`: A string that matches the desired output, with placeholder characters of your choice.</li><li>`translation`: An object of key/value pairs. Defaults to `{"X": "[0-9]"}`</li> | With a `format` of `+91 XXXX-XX-XXXX` and a `translation` of `[ "X": "[0-9]"]`, user input of "1234121234" displays as "+91 1234-12-1234". |
370
370
 
371
371
  **Collect Element Options examples for INPUT_FIELD**
372
372
  Example 1
@@ -1744,7 +1744,6 @@ composableContainer.on(Skyflow.EventName.SUBMIT, ()=> {
1744
1744
  });
1745
1745
  ```
1746
1746
 
1747
-
1748
1747
  ---
1749
1748
  # Securely revealing data client-side
1750
1749
  - [**Retrieving data from the vault**](#retrieving-data-from-the-vault)
@@ -1752,6 +1751,7 @@ composableContainer.on(Skyflow.EventName.SUBMIT, ()=> {
1752
1751
  - [**UI Error for Reveal Elements**](#ui-error-for-reveal-elements)
1753
1752
  - [**Set token for Reveal Elements**](#set-token-for-reveal-elements)
1754
1753
  - [**Set and clear altText for Reveal Elements**](#set-and-clear-alttext-for-reveal-elements)
1754
+ - [**Render a file with a File Element**](#render-a-file-with-a-file-element)
1755
1755
 
1756
1756
  ## Retrieving data from the vault
1757
1757
 
@@ -2596,6 +2596,142 @@ collectContainer.uploadFiles();
2596
2596
  }
2597
2597
  ```
2598
2598
 
2599
+ ## Render a file with a File Element
2600
+
2601
+ You can render files using the Skyflow File Element. Use the following steps to securely render a file.
2602
+
2603
+ ## Step 1: Create a container
2604
+ Create a container for the form elements using the container(Skyflow.ContainerType) method of the Skyflow client:
2605
+
2606
+ ```javascript
2607
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
2608
+ ```
2609
+
2610
+ ## Step 2: Create a File Element
2611
+ Define a Skyflow Element to render the file as shown below.
2612
+
2613
+ ```javascript
2614
+ const fileElement = {
2615
+ inputStyles: {}, // Optional, styles to be applied to the element.
2616
+ errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the render element.
2617
+ altText: 'string', // Optional, string that is shown before file render call
2618
+ skyflowID: 'string', // Required, skyflow id of the file to be render
2619
+ column: 'string', // Required, column name of the file to be render
2620
+ table: 'string', // Required, table name of the file to be render
2621
+ };
2622
+ ```
2623
+ The inputStyles and errorTextStyles parameters accept a styles object as described in the [previous section](https://github.com/skyflowapi/skyflow-js#step-2-create-a-collect-element) for collecting data. But for render file elements, inputStyles accepts only base variant, global style objects.
2624
+
2625
+ An example of a inputStyles object:
2626
+
2627
+ ```javascript
2628
+ inputStyles: {
2629
+ base: {
2630
+ height: '400px',
2631
+ width: '300px',
2632
+ },
2633
+ global: {
2634
+ '@import' :'url("https://fonts.googleapis.com/css2?family=Roboto&display=swap")',
2635
+ }
2636
+ }
2637
+ ```
2638
+ An example of a errorTextStyles object:
2639
+ ```javascript
2640
+ errorTextStyles: {
2641
+ base: {
2642
+ color: '#f44336',
2643
+ },
2644
+ global: {
2645
+ '@import' :'url("https://fonts.googleapis.com/css2?family=Roboto&display=swap")',
2646
+ }
2647
+ }
2648
+ ```
2649
+ ## Step 3: Mount Elements to the DOM
2650
+ Elements used for rendering files are mounted to the DOM the same way as Elements used for collecting data. Refer to Step 3 of the [section above](https://github.com/skyflowapi/skyflow-js#step-3-mount-elements-to-the-dom).
2651
+
2652
+ ## Step 4: Render File
2653
+ When the element is created and mounted, call the renderFile() method on the element as shown below:
2654
+ ```javascript
2655
+ fileElement
2656
+ .renderFile()
2657
+ .then(data => {
2658
+ // Handle success.
2659
+ })
2660
+ .catch(err => {
2661
+ // Handle error.
2662
+ });
2663
+ ```
2664
+
2665
+ ## End to end example of file render
2666
+ ```javascript
2667
+ // Step 1.
2668
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
2669
+
2670
+ // REPLACE with your custom implementation to fetch skyflow_id from backend service.
2671
+ // Sample implementation
2672
+ fetch("<BACKEND_URL>")
2673
+ .then((response) => {
2674
+
2675
+ // on successful fetch skyflow_id
2676
+ const skyflowID = response.skyflow_id;
2677
+
2678
+ // Step 2.
2679
+ const fileElement = container.create({
2680
+ skyflowID: "b63ec4e0-bbad-4e43-96e6-6bd50f483f75",
2681
+ column: "file",
2682
+ table: "table",
2683
+ inputStyles: {
2684
+ base: {
2685
+ height: "400px",
2686
+ width: "300px",
2687
+ },
2688
+ },
2689
+ errorTextStyles: {
2690
+ base: {
2691
+ color: "#f44336",
2692
+ },
2693
+ },
2694
+ altText: "This is an altText",
2695
+ });
2696
+ // Step 3.
2697
+ fileElement.mount("#renderFile"); // Assumes there is a placeholder div with id=renderFile on the page
2698
+
2699
+ const renderButton = document.getElementById("renderFiles"); // button to call render file
2700
+
2701
+ if (renderButton) {
2702
+ renderButton.addEventListener("click", () => {
2703
+
2704
+ // Step 4.
2705
+ fileElement
2706
+ .renderFile()
2707
+ .then((data) => {
2708
+ // Handle success.
2709
+ })
2710
+ .catch((err) => {
2711
+ // Handle error.
2712
+ });
2713
+ });
2714
+ }
2715
+ })
2716
+ .catch((err) => {
2717
+ // failed to fetch skyflow_id
2718
+ console.log(err);
2719
+ });
2720
+
2721
+ ```
2722
+
2723
+ ## Sample Success Response
2724
+ ```json
2725
+ {
2726
+ "success": [
2727
+ {
2728
+ "skyflow_id": "b63ec4e0-bbad-4e43-96e6-6bd50f483f75",
2729
+ "column": "file"
2730
+ },
2731
+ ]
2732
+ }
2733
+ ```
2734
+
2599
2735
  ---
2600
2736
  # Securely deleting data client-side
2601
2737
  - [**Deleting data from the vault**](#deleting-data-from-the-vault)