skyflow-js 1.36.1 → 1.36.3
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 +18 -0
- package/README.md +78 -11
- package/dist/sdkNodeBuild/index.js +1 -1
- package/dist/sdkNodeBuild/index.js.gz +0 -0
- package/package.json +1 -1
- package/types/core/constants.d.ts +1 -0
- package/types/core/external/collect/collect-element.d.ts +1 -0
- package/types/core/external/common/skyflow-element.d.ts +1 -0
- package/types/core/external/reveal/reveal-element.d.ts +1 -0
- package/types/core/internal/iframe-form/index.d.ts +1 -0
- package/types/libs/element-options.d.ts +1 -2
- package/types/skyflow.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.36.3] - 2024-08-12
|
|
6
|
+
### Fixed
|
|
7
|
+
- `update` method not working while updating custom validation rules.
|
|
8
|
+
|
|
9
|
+
## [1.36.2] - 2024-07-31
|
|
10
|
+
### Added
|
|
11
|
+
- Custom error message support for prebuilt collect elements.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Input error for card number when pasting a valid VISA card number by clearing the existing AMEX card number
|
|
15
|
+
- Remove format from copy text in card number element in JS SDK
|
|
16
|
+
- Hide copy icon when data is invalid in collect elements in JS SDK
|
|
17
|
+
- Change MasterCard to Mastercard in card brand choice dropdown
|
|
18
|
+
|
|
19
|
+
## [1.36.1] - 2024-07-02
|
|
20
|
+
### Fixed
|
|
21
|
+
- Restrict file types to upload
|
|
22
|
+
|
|
5
23
|
## [1.36.0] - 2024-05-08
|
|
6
24
|
### Added
|
|
7
25
|
- card brand choice support for card number element.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Skyflow’s JavaScript SDK can be used to securely collect, tokenize, and reveal
|
|
|
5
5
|
|
|
6
6
|
[](https://github.com/skyflowapi/skyflow-js/actions)
|
|
7
7
|
[](https://www.npmjs.com/package/skyflow-js)
|
|
8
|
-
[](https://github.com/skyflowapi/skyflow-js/blob/
|
|
8
|
+
[](https://github.com/skyflowapi/skyflow-js/blob/main/LICENSE)
|
|
9
9
|
|
|
10
10
|
# Table of Contents
|
|
11
11
|
- [**Including Skyflow.js**](#including-skyflowjs)
|
|
@@ -168,7 +168,7 @@ const options = {
|
|
|
168
168
|
skyflowClient.insert(records, options);
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
An [example](https://github.com/skyflowapi/skyflow-js/blob/
|
|
171
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/pure-js.html) of an insert call:
|
|
172
172
|
```javascript
|
|
173
173
|
skyflowClient.insert({
|
|
174
174
|
records: [
|
|
@@ -487,7 +487,7 @@ container.collect(options);
|
|
|
487
487
|
|
|
488
488
|
### End to end example of collecting data with Skyflow Elements
|
|
489
489
|
|
|
490
|
-
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/
|
|
490
|
+
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/skyflow-elements.html)**
|
|
491
491
|
|
|
492
492
|
```javascript
|
|
493
493
|
//Step 1
|
|
@@ -918,7 +918,7 @@ const elementValueMatchRule = {
|
|
|
918
918
|
}
|
|
919
919
|
```
|
|
920
920
|
|
|
921
|
-
The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/
|
|
921
|
+
The Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/custom-validations.html) for using custom validations:
|
|
922
922
|
|
|
923
923
|
```javascript
|
|
924
924
|
/*
|
|
@@ -1025,7 +1025,7 @@ state : {
|
|
|
1025
1025
|
`Note:`
|
|
1026
1026
|
values of SkyflowElements will be returned in element state object only when `env` is `DEV`, else it is empty string i.e, '', but in case of CARD_NUMBER type element when the `env` is `PROD` for all the card types except AMEX, it will return first eight digits, for AMEX it will return first six digits and rest all digits in masked format.
|
|
1027
1027
|
|
|
1028
|
-
##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/
|
|
1028
|
+
##### Sample [code snippet](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/collect-element-listeners.html) for using listeners
|
|
1029
1029
|
```javascript
|
|
1030
1030
|
// Create Skyflow client.
|
|
1031
1031
|
const skyflowClient = Skyflow.init({
|
|
@@ -1130,6 +1130,48 @@ cardNumber.setError('custom error');
|
|
|
1130
1130
|
cardNumber.resetError();
|
|
1131
1131
|
```
|
|
1132
1132
|
|
|
1133
|
+
### Override default error Messages
|
|
1134
|
+
|
|
1135
|
+
You can override the default error messages with custom ones by using `setErrorOverride`. This is especially useful to override default error messages in non-English languages.
|
|
1136
|
+
|
|
1137
|
+
`setErrorOverride(message: string)`
|
|
1138
|
+
|
|
1139
|
+
`setErrorOverride` overrides the default error message. When the value is invalid, the error resets automatically when the value becomes valid.
|
|
1140
|
+
|
|
1141
|
+
##### Sample code snippet for setErrorOverride
|
|
1142
|
+
|
|
1143
|
+
```javascript
|
|
1144
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
|
|
1145
|
+
|
|
1146
|
+
const cardNumber = container.create({
|
|
1147
|
+
table: 'pii_fields',
|
|
1148
|
+
column: 'primary_card.card_number',
|
|
1149
|
+
type: Skyflow.ElementType.CARD_NUMBER,
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
// override default error.
|
|
1153
|
+
cardHolderNameElement.on(Skyflow.EventName.BLUR, state=>{
|
|
1154
|
+
if(state.isEmpty) {
|
|
1155
|
+
//can override the message when the field is required and empty
|
|
1156
|
+
cardHolderNameElement.setErrorOverride('custom error for required');
|
|
1157
|
+
} else if(!state.isValid) {
|
|
1158
|
+
//can override the message when the input is invalid
|
|
1159
|
+
cardHolderName.setErrorOverride('custom error for invalid');
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
##### Difference between setError and setErrorOverride:
|
|
1165
|
+
|
|
1166
|
+
- `setError` sets the error state on the collect element, regardless of the element's state and value (valid or invalid). Once you call `setError`, the element remains in the error state until you call `resetError`. Use `setError` to set the error state on collect element based on server-side validations.
|
|
1167
|
+
|
|
1168
|
+
- `setErrorOverride` overrides the default error message. The error message resets automatically once the value becomes valid. Use `setErrorOverride` to change the default error message for a collect element.
|
|
1169
|
+
|
|
1170
|
+
**Note**:
|
|
1171
|
+
- `setErrorOverride` can only override default error messages.
|
|
1172
|
+
- `setErrorOverride` can only be used in BLUR event listener as shown in the earlier example.
|
|
1173
|
+
|
|
1174
|
+
|
|
1133
1175
|
### Set and Clear value for Collect Elements (DEV ENV ONLY)
|
|
1134
1176
|
|
|
1135
1177
|
`setValue(value: string)` method is used to set the value of the element. This method will override any previous value present in the element.
|
|
@@ -1886,7 +1928,7 @@ Note: If you do not provide a redaction type, RedactionType.PLAIN_TEXT is the de
|
|
|
1886
1928
|
|
|
1887
1929
|
skyflow.detokenize(records);
|
|
1888
1930
|
```
|
|
1889
|
-
An [example](https://github.com/skyflowapi/skyflow-js/blob/
|
|
1931
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/pure-js.html) of a detokenize call:
|
|
1890
1932
|
|
|
1891
1933
|
```javascript
|
|
1892
1934
|
skyflow.detokenize({
|
|
@@ -1973,7 +2015,7 @@ data = {
|
|
|
1973
2015
|
],
|
|
1974
2016
|
};
|
|
1975
2017
|
```
|
|
1976
|
-
[Example usage (Skyflow IDs)](https://github.com/skyflowapi/skyflow-js/blob/
|
|
2018
|
+
[Example usage (Skyflow IDs)](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/get-pure-js.html)
|
|
1977
2019
|
|
|
1978
2020
|
```javascript
|
|
1979
2021
|
skyflow.get({
|
|
@@ -2018,7 +2060,7 @@ Example response
|
|
|
2018
2060
|
]
|
|
2019
2061
|
}
|
|
2020
2062
|
```
|
|
2021
|
-
[Example usage (Unique column values)](https://github.com/skyflowapi/skyflow-js/blob/
|
|
2063
|
+
[Example usage (Unique column values)](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/get-pure-js.html)
|
|
2022
2064
|
|
|
2023
2065
|
```javascript
|
|
2024
2066
|
skyflow.get({
|
|
@@ -2058,7 +2100,7 @@ Sample response:
|
|
|
2058
2100
|
}
|
|
2059
2101
|
```
|
|
2060
2102
|
|
|
2061
|
-
[Example usage (Fetch tokens using Skyflow IDs)](https://github.com/skyflowapi/skyflow-js/blob/
|
|
2103
|
+
[Example usage (Fetch tokens using Skyflow IDs)](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/get-pure-js.html)
|
|
2062
2104
|
```javascript
|
|
2063
2105
|
skyflow.get({
|
|
2064
2106
|
records: [
|
|
@@ -2250,7 +2292,7 @@ container
|
|
|
2250
2292
|
|
|
2251
2293
|
### End to end example of all steps
|
|
2252
2294
|
|
|
2253
|
-
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/
|
|
2295
|
+
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/skyflow-elements.html)**
|
|
2254
2296
|
```javascript
|
|
2255
2297
|
// Step 1.
|
|
2256
2298
|
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
|
|
@@ -2367,6 +2409,31 @@ cardNumber.setError('custom error');
|
|
|
2367
2409
|
// Reset custom error.
|
|
2368
2410
|
cardNumber.resetError();
|
|
2369
2411
|
```
|
|
2412
|
+
|
|
2413
|
+
### Override default error messages
|
|
2414
|
+
|
|
2415
|
+
You can override the default error messages with custom ones by using `setErrorOverride`. This is especially useful to override default error messages in non-English languages.
|
|
2416
|
+
|
|
2417
|
+
```javascript
|
|
2418
|
+
const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
|
|
2419
|
+
|
|
2420
|
+
const cardNumber = container.create({
|
|
2421
|
+
token: '89024714-6a26-4256-b9d4-55ad69aa4047',
|
|
2422
|
+
});
|
|
2423
|
+
|
|
2424
|
+
const revealButton = document.getElementById('revealPCIData');
|
|
2425
|
+
|
|
2426
|
+
if (revealButton) {
|
|
2427
|
+
revealButton.addEventListener('click', () => {
|
|
2428
|
+
revealContainer.reveal().then((res) => {
|
|
2429
|
+
//handle reveal response
|
|
2430
|
+
}).catch((err) => {
|
|
2431
|
+
cardNumber.setErrorOverride("custom error")
|
|
2432
|
+
});
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
```
|
|
2436
|
+
|
|
2370
2437
|
### Set token for Reveal Elements
|
|
2371
2438
|
|
|
2372
2439
|
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.
|
|
@@ -2966,7 +3033,7 @@ const records = [
|
|
|
2966
3033
|
skyflowClient.delete(records);
|
|
2967
3034
|
```
|
|
2968
3035
|
|
|
2969
|
-
An [example](https://github.com/skyflowapi/skyflow-js/blob/
|
|
3036
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/delete-pure-js.html) of delete call:
|
|
2970
3037
|
|
|
2971
3038
|
```javascript
|
|
2972
3039
|
skyflowClient.delete({
|