skyflow-js 1.7.0 → 1.8.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 +19 -0
- package/README.md +155 -13
- package/dist/sdkNodeBuild/index.js +1 -1
- package/dist/sdkNodeBuild/index.js.gz +0 -0
- package/package.json +1 -1
- package/types/Skyflow.d.ts +2 -2
- package/types/container/constants.d.ts +74 -13
- package/types/container/external/element/index.d.ts +4 -0
- package/types/container/external/reveal/RevealElement.d.ts +8 -0
- package/types/container/internal/iFrameForm/index.d.ts +4 -0
- package/types/container/internal/index.d.ts +2 -0
- package/types/container/internal/reveal/RevealFrame.d.ts +3 -0
- package/types/core/collect.d.ts +2 -1
- package/types/libs/element-options.d.ts +1 -0
- package/types/utils/constants.d.ts +214 -22
- package/types/utils/helpers/index.d.ts +2 -0
- package/types/utils/logs.d.ts +79 -37
- package/types/utils/validators/index.d.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.8.0] - 2021-12-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `setError(error: string)` method to set custom UI error to be displayed on the collect and reveal Elements
|
|
9
|
+
- `resetError()` method is used to clear the custom UI error message set through setError
|
|
10
|
+
- `format` parameter in `collectElementOptions` to support different type of date formats for `EXPIRATION_DATE` element
|
|
11
|
+
- `setValue(value: string)` and `clearValue()` method in DEV env, to set/clear the value of a collect element.
|
|
12
|
+
- `setToken(value: string)` method to set the token for a reveal element.
|
|
13
|
+
- `setAltText(value: string)` and `clearAltText()` method to set/clear the altText for a reveal
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Changed error messages in the logs and callback errors.
|
|
17
|
+
- `altText` support has been deprecated for collect element
|
|
18
|
+
- `vaultID` and `vaultURL` are now optional parameters in Configuration constructor
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Updating UI error messages
|
|
22
|
+
|
|
4
23
|
## [1.7.0] - 2021-11-24
|
|
5
24
|
### Added
|
|
6
25
|
- `validations` option in `CollectElementInput` that takes an array of validation rules
|
package/README.md
CHANGED
|
@@ -127,6 +127,8 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
|
|
|
127
127
|
- [**Using Skyflow Elements to collect data**](#using-skyflow-elements-to-collect-data)
|
|
128
128
|
- [**Using validations on Collect Elements**](#validations)
|
|
129
129
|
- [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
|
|
130
|
+
- [**UI Error for Collect Eements**](#ui-error-for-collect-elements)
|
|
131
|
+
- [**Set and Clear value for Collect Elements (DEV ENV ONLY)**](#set-and-clear-value-for-collect-elements-dev-env-only)
|
|
130
132
|
## Inserting data into the vault
|
|
131
133
|
|
|
132
134
|
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:
|
|
@@ -209,11 +211,13 @@ const collectElement = {
|
|
|
209
211
|
errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
|
|
210
212
|
label: "string", //optional label for the form element
|
|
211
213
|
placeholder: "string", //optional placeholder for the form element
|
|
212
|
-
altText: "string" //
|
|
214
|
+
altText: "string" //(DEPRECATED) string that acts as an initial value for the collect element
|
|
213
215
|
validations:[] // optional array of validation rules
|
|
214
216
|
}
|
|
215
217
|
```
|
|
216
|
-
The `table` and `column` fields indicate which table and column in the vault the Element corresponds to.
|
|
218
|
+
The `table` and `column` fields indicate which table and column in the vault the Element corresponds to.
|
|
219
|
+
|
|
220
|
+
**Note**:
|
|
217
221
|
- Use dot delimited strings to specify columns nested inside JSON fields (e.g. `address.street.line1`)
|
|
218
222
|
- `table` and `column` are optional only if the element is being used in invokeConnection()
|
|
219
223
|
|
|
@@ -284,7 +288,31 @@ Finally, the `type` field takes a Skyflow ElementType. Each type applies the app
|
|
|
284
288
|
|
|
285
289
|
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.
|
|
286
290
|
|
|
287
|
-
|
|
291
|
+
Along with CollectElement we can define other options which takes a dictionary of optional parameters as described below:
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
const options = {
|
|
295
|
+
required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
|
|
296
|
+
enableCardIcon: true // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
|
|
297
|
+
format: String //optinal, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`required` parameter indicates whether the field is marked as required or not. If not provided, it defaults to false
|
|
302
|
+
|
|
303
|
+
`enableCardIcon` paramenter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
|
|
304
|
+
|
|
305
|
+
`format` parameter takes string value and indicates the format pattern applicable to the element type. It is currently applicable to EXPIRATION_DATE element type only, the values that are accepted are
|
|
306
|
+
|
|
307
|
+
- `MM/YY`
|
|
308
|
+
- `MM/YYYY`
|
|
309
|
+
- `YY/MM`
|
|
310
|
+
- `YYYY/MM`
|
|
311
|
+
|
|
312
|
+
`NOTE` : If not specified or invalid value is passed to the format for EXPIRATION_DATE element, then it defaults to MM/YY format.
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
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:
|
|
288
316
|
|
|
289
317
|
```javascript
|
|
290
318
|
const collectElement = {
|
|
@@ -296,13 +324,14 @@ const collectElement = {
|
|
|
296
324
|
errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
|
|
297
325
|
label: "string", //optional label for the form element
|
|
298
326
|
placeholder: "string", //optional placeholder for the form element
|
|
299
|
-
altText: "string" //
|
|
327
|
+
altText: "string" //(DEPRECATED) string that acts as an initial value for the collect element
|
|
300
328
|
validations:[] // optional array of validation rules
|
|
301
329
|
}
|
|
302
330
|
|
|
303
331
|
const options = {
|
|
304
|
-
required: false, //indicates whether the field is marked as required. Defaults to 'false'
|
|
305
|
-
enableCardIcon: true // indicates whether card icon should be enabled (only for CARD_NUMBER
|
|
332
|
+
required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
|
|
333
|
+
enableCardIcon: true // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
|
|
334
|
+
format: String //optinal, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
|
|
306
335
|
}
|
|
307
336
|
|
|
308
337
|
const element = container.create(collectElement, options)
|
|
@@ -441,7 +470,7 @@ Every Collect Element except of type `INPUT_FIELD` has a set of default validati
|
|
|
441
470
|
- `CARD_NUMBER`: Card number validation with checkSum algorithm(Luhn algorithm), available card lengths for defined card types
|
|
442
471
|
- `CARD_HOLDER_NAME`: Name should be 2 or more symbols, valid characters should match pattern - `^([a-zA-Z\\ \\,\\.\\-\\']{2,})$`
|
|
443
472
|
- `CVV`: Card CVV can have 3-4 digits
|
|
444
|
-
- `EXPIRATION_DATE`: Any date starting from current month. By default valid expiration date should be in short year format - `MM/
|
|
473
|
+
- `EXPIRATION_DATE`: Any date starting from current month. By default valid expiration date should be in short year format - `MM/YY`
|
|
445
474
|
- `PIN`: Can have 4-12 digits
|
|
446
475
|
|
|
447
476
|
#### 2. Custom Validations:
|
|
@@ -591,7 +620,7 @@ values of SkyflowElements will be returned in elementstate object only when `env
|
|
|
591
620
|
|
|
592
621
|
##### Sample code snippet for using listeners
|
|
593
622
|
```javascript
|
|
594
|
-
//create skyflow client
|
|
623
|
+
//create skyflow client
|
|
595
624
|
const skyflowClient = Skyflow.init({
|
|
596
625
|
vaultID: <VAULT_ID>,
|
|
597
626
|
vaultURL: <VAULT_URL>,
|
|
@@ -641,12 +670,70 @@ cardNumber.on(Skyflow.EventName.CHANGE,(state) => {
|
|
|
641
670
|
}
|
|
642
671
|
```
|
|
643
672
|
|
|
673
|
+
### UI Error for Collect Elements
|
|
674
|
+
|
|
675
|
+
Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
|
|
676
|
+
|
|
677
|
+
`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.
|
|
678
|
+
|
|
679
|
+
`resetError()` method is used to clear the custom error message that is set using `setError`.
|
|
680
|
+
|
|
681
|
+
##### Sample code snippet for setError and resetError
|
|
682
|
+
|
|
683
|
+
```javascript
|
|
684
|
+
|
|
685
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
686
|
+
|
|
687
|
+
const cardNumber = container.create({
|
|
688
|
+
table: "pii_fields",
|
|
689
|
+
column: "primary_card.card_number",
|
|
690
|
+
type: Skyflow.ElementType.CARD_NUMBER,
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
//Set custom error
|
|
694
|
+
cardNumber.setError("custom error");
|
|
695
|
+
|
|
696
|
+
//reset custom error
|
|
697
|
+
cardNumber.resetError();
|
|
698
|
+
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### Set and Clear value for Collect Elements (DEV ENV ONLY)
|
|
702
|
+
|
|
703
|
+
`setValue(value: string)` method is used to set the value of the element. This method will override any previous value present in the element.
|
|
704
|
+
|
|
705
|
+
`clearValue()` method is used to reset the value of the element.
|
|
706
|
+
|
|
707
|
+
`Note:` This methods are only available in DEV env for testing/developmental purposes and MUST NOT be used in PROD env.
|
|
708
|
+
|
|
709
|
+
##### Sample code snippet for setValue and clearValue
|
|
710
|
+
|
|
711
|
+
```javascript
|
|
712
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
713
|
+
|
|
714
|
+
const cardNumber = container.create({
|
|
715
|
+
table: "pii_fields",
|
|
716
|
+
column: "primary_card.card_number",
|
|
717
|
+
type: Skyflow.ElementType.CARD_NUMBER,
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// Set a value programatically
|
|
721
|
+
cardNumber.setValue("4111111111111111");
|
|
722
|
+
|
|
723
|
+
// Clear the value
|
|
724
|
+
cardNumber.clearValue();
|
|
725
|
+
|
|
726
|
+
```
|
|
727
|
+
|
|
644
728
|
---
|
|
645
729
|
|
|
646
730
|
|
|
647
731
|
# Securely revealing data client-side
|
|
648
732
|
- [**Retrieving data from the vault**](#retrieving-data-from-the-vault)
|
|
649
733
|
- [**Using Skyflow Elements to reveal data**](#using-skyflow-elements-to-reveal-data)
|
|
734
|
+
- [**UI Error for Reveal Elements**](#ui-error-for-reveal-elements)
|
|
735
|
+
- [**Set token for Reveal Elements**](#set-token-for-reveal-elements)
|
|
736
|
+
- [**Set and clear altText for Reveal Elements**](#set-and-clear-alttext-for-reveal-elements)
|
|
650
737
|
|
|
651
738
|
## Retrieving data from the vault
|
|
652
739
|
|
|
@@ -780,7 +867,7 @@ const revealElement = {
|
|
|
780
867
|
inputStyles: {}, //optional styles to be applied to the element
|
|
781
868
|
labelStyles: {}, //optional, styles to be applied to the label of the reveal element
|
|
782
869
|
errorTextStyles: {}, //optional styles that will be applied to the errorText of the reveal element
|
|
783
|
-
label: "string",
|
|
870
|
+
label: "string", //optional, label for the form element
|
|
784
871
|
altText: "string" //optional, string that is shown before reveal, will show token if altText is not provided
|
|
785
872
|
}
|
|
786
873
|
```
|
|
@@ -922,6 +1009,65 @@ The response below shows that some tokens assigned to the reveal elements get re
|
|
|
922
1009
|
}
|
|
923
1010
|
```
|
|
924
1011
|
|
|
1012
|
+
### UI Error for Reveal Elements
|
|
1013
|
+
Helps to display custom error messages on the Skyflow Elements through the methods `setError` and `resetError` on the elements.
|
|
1014
|
+
|
|
1015
|
+
`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.
|
|
1016
|
+
|
|
1017
|
+
`resetError()` method is used to clear the custom error message that is set using `setError`.
|
|
1018
|
+
|
|
1019
|
+
##### Sample code snippet for setError and resetError
|
|
1020
|
+
|
|
1021
|
+
```javascript
|
|
1022
|
+
|
|
1023
|
+
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|
|
1024
|
+
|
|
1025
|
+
const cardNumber = container.create({
|
|
1026
|
+
token: "89024714-6a26-4256-b9d4-55ad69aa4047",
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
//Set custom error
|
|
1030
|
+
cardNumber.setError("custom error");
|
|
1031
|
+
|
|
1032
|
+
//reset custom error
|
|
1033
|
+
cardNumber.resetError();
|
|
1034
|
+
|
|
1035
|
+
```
|
|
1036
|
+
### Set token for Reveal Elements
|
|
1037
|
+
|
|
1038
|
+
The `setToken(value: string)` method can be used to set the token of the Reveal Element. If no altText is set, the set token will be displayed on the UI as well. If altText is set, then there will be no change in the UI but the token of the element will be internally updated.
|
|
1039
|
+
|
|
1040
|
+
##### Sample code snippet for setToken
|
|
1041
|
+
```javascript
|
|
1042
|
+
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|
|
1043
|
+
|
|
1044
|
+
const cardNumber = container.create({
|
|
1045
|
+
altText:"Card Number",
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
// set token
|
|
1049
|
+
cardNumber.setToken("89024714-6a26-4256-b9d4-55ad69aa4047");
|
|
1050
|
+
|
|
1051
|
+
```
|
|
1052
|
+
### Set and Clear altText for Reveal Elements
|
|
1053
|
+
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.
|
|
1054
|
+
|
|
1055
|
+
`clearAltText()` method can be used to clear the altText, this will cause the element to display the token or actual value of the element. If the element has no token, the element will be empty.
|
|
1056
|
+
##### Sample code snippet for setAltText and clearAltText
|
|
1057
|
+
|
|
1058
|
+
```javascript
|
|
1059
|
+
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|
|
1060
|
+
|
|
1061
|
+
const cardNumber = container.create({
|
|
1062
|
+
token:"89024714-6a26-4256-b9d4-55ad69aa4047",
|
|
1063
|
+
});
|
|
1064
|
+
|
|
1065
|
+
// set altText
|
|
1066
|
+
cardNumber.setAltText("Card Number");
|
|
1067
|
+
|
|
1068
|
+
//clear altText
|
|
1069
|
+
cardNumber.clearAltText();
|
|
1070
|
+
```
|
|
925
1071
|
# Securely invoking Connections client-side
|
|
926
1072
|
Using Skyflow Connections, 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 Connections, use the `invokeConnection(connectionConfig)` method of the Skyflow client.
|
|
927
1073
|
|
|
@@ -962,8 +1108,6 @@ Merchant acceptance - customers should be able to complete payment checkout with
|
|
|
962
1108
|
```javascript
|
|
963
1109
|
// step 1
|
|
964
1110
|
const skyflowClient = skyflow.init({
|
|
965
|
-
vaultID: <vault_Id>,
|
|
966
|
-
vaultURL: <vault_url>,
|
|
967
1111
|
getBearerToken: <helperFunc>
|
|
968
1112
|
});
|
|
969
1113
|
|
|
@@ -1013,8 +1157,6 @@ In the above example, CVV is being collected from the user input at the time of
|
|
|
1013
1157
|
```javascript
|
|
1014
1158
|
// step 1
|
|
1015
1159
|
const skyflowClient = skyflow.init({
|
|
1016
|
-
vaultID: <vault_Id>,
|
|
1017
|
-
vaultURL: <vault_url>,
|
|
1018
1160
|
getBearerToken: <helperFunc>
|
|
1019
1161
|
});
|
|
1020
1162
|
|