skyflow-js 1.1.1 → 1.2.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +154 -5
  3. package/dist/sdkNodeBuild/index.js +2 -1
  4. package/dist/sdkNodeBuild/index.js.LICENSE.txt +27 -0
  5. package/dist/sdkNodeBuild/index.js.LICENSE.txt.gz +0 -0
  6. package/dist/sdkNodeBuild/index.js.gz +0 -0
  7. package/package.json +7 -1
  8. package/types/Skyflow.d.ts +23 -5
  9. package/types/client/index.d.ts +2 -3
  10. package/types/container/constants.d.ts +10 -5
  11. package/types/container/external/CollectContainer.d.ts +5 -5
  12. package/types/container/external/PureJsController.d.ts +5 -4
  13. package/types/container/external/RevealContainer.d.ts +4 -5
  14. package/types/container/external/element/index.d.ts +3 -0
  15. package/types/container/external/reveal/RevealElement.d.ts +4 -1
  16. package/types/container/internal/iFrameForm/index.d.ts +15 -15
  17. package/types/container/internal/index.d.ts +2 -2
  18. package/types/container/internal/pureJs/PureJsFrameController.d.ts +2 -0
  19. package/types/container/internal/reveal/RevealFrameController.d.ts +1 -1
  20. package/types/core/collect.d.ts +1 -1
  21. package/types/core/reveal.d.ts +5 -5
  22. package/types/event-emitter/index.d.ts +1 -1
  23. package/types/iframe-libs/iframer.d.ts +3 -3
  24. package/types/index-internal.d.ts +1 -2
  25. package/types/index-node.d.ts +1 -1
  26. package/types/index.d.ts +1 -1
  27. package/types/libs/Bus.d.ts +3 -3
  28. package/types/libs/element-options.d.ts +1 -1
  29. package/types/libs/jss-styles.d.ts +1 -1
  30. package/types/libs/objectParse.d.ts +2 -0
  31. package/types/libs/regex.d.ts +2 -1
  32. package/types/libs/strings.d.ts +1 -1
  33. package/types/libs/styles.d.ts +2 -2
  34. package/types/properties.d.ts +2 -1
  35. package/types/utils/busEvents/index.d.ts +3 -0
  36. package/types/utils/helpers/index.d.ts +5 -0
  37. package/types/utils/jwtUtils/index.d.ts +2 -1
  38. package/types/utils/validators/index.d.ts +4 -1
  39. package/types/libs/NewBus.d.ts +0 -13
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.0] - 2021-10-05
6
+
7
+ ### Added
8
+
9
+ - invokeGateway method to work with inbound/outbound integrations using Skyflow Gateway
10
+
11
+ ### Changed
12
+ - `table` and `column` are optional in CollectElementInput, when using invokeGateway
13
+ - `token` and `redaction` are optional in RevealElementInput, when using invokeGateway
14
+
15
+
5
16
  ## [1.1.0] - 2021-09-22
6
17
 
7
18
  ### Fixed:
package/README.md CHANGED
@@ -8,6 +8,7 @@ Skyflow’s Javascript SDK can be used to securely collect, tokenize, and reveal
8
8
  - [**Initializing Skyflow.js**](#Initializing-Skyflowjs)
9
9
  - [**Securely collecting data client-side**](#Securely-collecting-data-client-side)
10
10
  - [**Securely revealing data client-side**](#Securely-revealing-data-client-side)
11
+ - [**Securely invoking gateway client-side**](#Securely-invoking-gateway-client-side)
11
12
 
12
13
  ---
13
14
 
@@ -160,8 +161,8 @@ A Skyflow collect Element is defined as shown below:
160
161
 
161
162
  ```javascript
162
163
  var collectElement = {
163
- table: "string", //the table this data belongs to
164
- column: "string", //the column into which this data should be inserted
164
+ table: "string", //optional, the table this data belongs to
165
+ column: "string", //optional, the column into which this data should be inserted
165
166
  type: Skyflow.ElementType, //Skyflow.ElementType enum
166
167
  inputStyles: {}, //optional styles that should be applied to the form element
167
168
  labelStyles: {}, //optional styles that will be applied to the label of the collect element
@@ -171,7 +172,9 @@ var collectElement = {
171
172
  altText: "string" //optional string that acts as an initial value for the collect element
172
173
  }
173
174
  ```
174
- The `table` and `column` fields indicate which table and column in the vault the Element corresponds to. **Note**: Use dot delimited strings to specify columns nested inside JSON fields (e.g. `address.street.line1`).
175
+ The `table` and `column` fields indicate which table and column in the vault the Element corresponds to. **Note**:
176
+ - Use dot delimited strings to specify columns nested inside JSON fields (e.g. `address.street.line1`)
177
+ - `table` and `column` are optional only if the element is being used in invokeGateway()
175
178
 
176
179
  The `inputStyles` field accepts a style object which consists of CSS properties that should be applied to the form element in the following states:
177
180
  - `base`: all other variants inherit from these styles
@@ -517,7 +520,7 @@ Then define a Skyflow Element to reveal data as shown below.
517
520
 
518
521
  ```javascript
519
522
  var revealElement = {
520
- token: "string", //token of the data being revealed
523
+ token: "string", //optional, token of the data being revealed
521
524
  redaction: Skyflow.RedactionType, //redaction type to be applied to the data when revealed
522
525
  inputStyles: {}, //optional styles to be applied to the element
523
526
  labelStyles: {}, //optional, styles to be applied to the label of the reveal element
@@ -526,6 +529,8 @@ var revealElement = {
526
529
  altText: "string" //optional, string that is shown before reveal, will show token if altText is not provided
527
530
  }
528
531
  ```
532
+ `Note`:
533
+ - `token` is optional only if it is being used in invokeGateway()
529
534
 
530
535
  For a list of acceptable RedactionTypes, see the [section above](#Retrieving-data-from-the-vault).
531
536
 
@@ -664,4 +669,148 @@ The response below shows that some tokens assigned to the reveal elements get re
664
669
  }
665
670
  ]
666
671
  }
667
- ```
672
+ ```
673
+
674
+ # Securely invoking gateway client-side
675
+ Using Skyflow gateway, end-user applications can integrate checkout/card issuance flow without any of their apps/systems touching the PCI compliant fields like cvv, card number. To invoke gateway, use the `invokeGateway(gatewayConfig)` method of the Skyflow client.
676
+
677
+ ```javascript
678
+ const gatewayConfig = {
679
+ gatewayURL: string, // gateway url recevied when creating a skyflow gateway integration
680
+ methodName: Skyflow.RequestMethod,
681
+ pathParams: any, // optional
682
+ queryParams: any, // optional
683
+ requestHeader: any, // optional
684
+ requestBody: any, // optional
685
+ responseBody: any // optional
686
+ }
687
+
688
+ const response = skyflowClient.invokeGateway(gatewayConfig);
689
+ ```
690
+ `methodName` supports the following methods:
691
+
692
+ - GET
693
+ - POST
694
+ - PUT
695
+ - PATCH
696
+ - DELETE
697
+
698
+ **pathParams, queryParams, requestHeader, requestBody** are the JSON objects that will be sent through the gateway integration url.
699
+
700
+ The values in the above parameters can contain collect elements, reveal elements or actual values. When elements are provided inplace of values, they get replaced with the value entered in the collect elements or value present in the reveal elements
701
+
702
+ **responseBody**:
703
+ It is a JSON object that specifies where to render the response in the UI. The values in the responseBody can contain collect elements or reveal elements.
704
+
705
+ Sample use-cases on using invokeGateway():
706
+
707
+ ### Sample use-case 1:
708
+
709
+ Merchant acceptance - customers should be able to complete payment checkout without cvv touching their application. This means that the merchant should be able to receive a CVV and process a payment without exposing their front-end to any PCI data
710
+
711
+ ```javascript
712
+ // step 1
713
+ const skyflowClient = skyflow.init({
714
+ vaultID: <vault_Id>,
715
+ vaultURL: <vault_url>,
716
+ getBearerToken: <helperFunc>
717
+ });
718
+
719
+ // step 2
720
+ const collectContainer = skyflowClient.container(Skyflow.ContainerType.COLLECT)
721
+
722
+ // step 3
723
+ const cardNumberElement = collectContainer.create({
724
+ type: skyflow.ElementType.CARD_NUMBER
725
+ })
726
+ cardNumberElement.mount("#cardNumber")
727
+
728
+ const cvvElement = collectContainer.create({
729
+ type: skyflow.ElementType.CVV
730
+ })
731
+ cvvElement.mount("#cvv")
732
+
733
+ // step 4
734
+ const gatewayConfig = {
735
+ gatewayURL: "https://area51.gateway.skyflow.com/v1/gateway/inboundRoutes/abc-1213/v2/pay”,
736
+ methodName: Skyflow.RequestMethod.POST,
737
+ requestBody: {
738
+ card_number: cardNumberElement, //it can be skyflow element(collect or reveal) or actual value
739
+ cvv: cvvElement,
740
+ }
741
+ }
742
+
743
+ const response = skyflowClient.invokeGateway(gatewayConfig);
744
+ ```
745
+
746
+ Sample Response:
747
+ ```javascript
748
+ {
749
+ "receivedTimestamp": "2019-05-29 21:49:56.625",
750
+ "processingTimeinMs": 116
751
+ }
752
+ ```
753
+ In the above example, CVV is being collected from the user input at the time of checkout and not stored anywhere in the vault
754
+
755
+ `Note:`
756
+ - card_number can be either container element or plain text value (tokens or actual value)
757
+ - `table` and `column` names are not required for creating collect element, if it is used for invokeGateway method, since they will not be stored in the vault
758
+
759
+ ### Sample use-case 2:
760
+
761
+ Card issuance - customers want to issue cards from card issuer service and should generate the CVV dynamically without increasing their PCI scope.
762
+ ```javascript
763
+ // step 1
764
+ const skyflowClient = skyflow.init({
765
+ vaultID: <vault_Id>,
766
+ vaultURL: <vault_url>,
767
+ getBearerToken: <helperFunc>
768
+ });
769
+
770
+ // step 2
771
+ const revealContainer = skyflowClient.container(Skyflow.ContainerType.REVEAL)
772
+ const collectContainer = skyflowClient.container(Skyflow.ContainerType.COLLECT)
773
+
774
+ // step 3
775
+ const cvvElement = revealContainer.create({
776
+ type: skyflow.RedactionType.PLAIN_TEXT,
777
+ })
778
+ cvvElement.mount("#cvv")
779
+
780
+ const expiryDateElement = collectContainer.create({
781
+ type: skyflow.ElementType.EXPIRATION_DATE
782
+ })
783
+ expiryDateElement.mount("#expirationDate")
784
+
785
+ //step 4
786
+ const gatewayConfig = {
787
+ gatewayURL: "https://area51.gateway.skyflow.com/v1/gateway/inboundRoutes/abc-1213/cards/{card_number}/cvv2generation",
788
+ methodName: Skyflow.RequestMethod.POST,
789
+ pathParams: {
790
+ card_number: "0905-8672-0773-0628" //it can be skyflow element(collect/reveal) or token or actual value
791
+ },
792
+ requestBody: {
793
+ expirationDate: expiryDateElement //it can be skyflow element(collect/reveal) or token or actual value
794
+ },
795
+ responseBody: {
796
+ resource: {
797
+ cvv2: cvvElement // pass the element where the cvv response from the gateway will be mounted
798
+ }
799
+ }
800
+ }
801
+ }
802
+
803
+ const response = skyflowClient.invokeGateway(gatewayConfig);
804
+ ```
805
+
806
+ Sample Response:
807
+ ```javascript
808
+ {
809
+ "receivedTimestamp": "2019-05-29 21:49:56.625",
810
+ "processingTimeinMs": 116
811
+ }
812
+ ```
813
+
814
+ `Note`:
815
+ - `token` and `redaction` are optional for creating reveal element, if it is used for invokeGateway
816
+ - responseBody contains collect or reveal elements to render the response from the gateway on UI