skyflow-js 1.33.4 → 1.34.1
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 +12 -0
- package/README.md +219 -9
- 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 +2 -0
- package/types/core/external/collect/collect-element.d.ts +4 -1
- package/types/core/external/reveal/reveal-element.d.ts +1 -0
- package/types/core/internal/iframe-form/index.d.ts +2 -0
- package/types/core/internal/index.d.ts +1 -0
- package/types/core/internal/reveal/reveal-frame.d.ts +1 -0
- package/types/utils/constants.d.ts +4 -0
- package/types/utils/helpers/index.d.ts +1 -0
- package/types/utils/logs.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.34.0] - 2023-12-15
|
|
6
|
+
### Added
|
|
7
|
+
- Ability to update Collect and Reveal element properties dynamically.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- iFrame height resize issue
|
|
11
|
+
- ExpiryMonth Element's invalid input styles issue
|
|
12
|
+
|
|
13
|
+
## [1.33.4] - 2023-12-07
|
|
14
|
+
## Fixed
|
|
15
|
+
- jQuery dependency replacement changes.
|
|
16
|
+
|
|
5
17
|
## [1.33.3] - 2023-11-15
|
|
6
18
|
## Fixed
|
|
7
19
|
- Patch fix for reverting changes for internal jQuery dependency changes.
|
package/README.md
CHANGED
|
@@ -127,14 +127,16 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
|
|
|
127
127
|
---
|
|
128
128
|
|
|
129
129
|
# Securely collecting data client-side
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
130
|
+
- [**Insert data into the vault**](#insert-data-into-the-vault)
|
|
131
|
+
- [**Using Skyflow Elements to collect data**](#using-skyflow-elements-to-collect-data)
|
|
132
|
+
- [**Using Skyflow Elements to update data**](#using-skyflow-elements-to-update-data)
|
|
133
|
+
- [**Using validations on Collect Elements**](#validations)
|
|
134
|
+
- [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
|
|
135
|
+
- [**UI Error for Collect Elements**](#ui-error-for-collect-elements)
|
|
136
136
|
- [**Set and Clear value for Collect Elements (DEV ENV ONLY)**](#set-and-clear-value-for-collect-elements-dev-env-only)
|
|
137
|
+
- [**Update Collect Elements**](#update-collect-elements)
|
|
137
138
|
- [**Using Skyflow File Element to upload a file**](#using-skyflow-file-element-to-upload-a-file)
|
|
139
|
+
|
|
138
140
|
## Insert data into the vault
|
|
139
141
|
|
|
140
142
|
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 an object of optional parameters for the insertion. The `insert` method also supports upsert operations.
|
|
@@ -1155,6 +1157,115 @@ cardNumber.clearValue();
|
|
|
1155
1157
|
|
|
1156
1158
|
```
|
|
1157
1159
|
|
|
1160
|
+
### Update Collect Elements
|
|
1161
|
+
|
|
1162
|
+
You can update collect element properties with the `update` interface.
|
|
1163
|
+
|
|
1164
|
+
The `update` interface takes the below object:
|
|
1165
|
+
|
|
1166
|
+
```javascript
|
|
1167
|
+
const updateElement = {
|
|
1168
|
+
table: 'string', // Optional. The table this data belongs to.
|
|
1169
|
+
column: 'string', // Optional. The column this data belongs to.
|
|
1170
|
+
inputStyles: {}, // Optional. Styles applied to the form element.
|
|
1171
|
+
labelStyles: {}, // Optional. Styles for the label of the element.
|
|
1172
|
+
errorTextStyles: {}, // Optional. Styles for the errorText of element.
|
|
1173
|
+
label: 'string', // Optional. Label for the form element.
|
|
1174
|
+
placeholder: 'string', // Optional. Placeholder for the form element.
|
|
1175
|
+
validations: [], // Optional. Array of validation rules.
|
|
1176
|
+
skyflowID: 'string' // Optional. SkyflowID of the record.
|
|
1177
|
+
};
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
Only include the properties that you want to update for the specified collect element.
|
|
1181
|
+
|
|
1182
|
+
Properties your provided when you created the element remain the same until you explicitly update them.
|
|
1183
|
+
|
|
1184
|
+
`Note`: You can't update the `type` property of an element.
|
|
1185
|
+
|
|
1186
|
+
### End to end example
|
|
1187
|
+
```javascript
|
|
1188
|
+
// Create a collect container.
|
|
1189
|
+
const collectContainer = skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
1190
|
+
|
|
1191
|
+
const stylesOptions = {
|
|
1192
|
+
inputStyles: {
|
|
1193
|
+
base: {
|
|
1194
|
+
fontFamily: 'Inter',
|
|
1195
|
+
fontStyle: 'normal',
|
|
1196
|
+
fontWeight: 400,
|
|
1197
|
+
fontSize: '14px',
|
|
1198
|
+
lineHeight: '21px',
|
|
1199
|
+
width: '294px',
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
labelStyles: {},
|
|
1203
|
+
errorTextStyles: {
|
|
1204
|
+
base: {},
|
|
1205
|
+
},
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// Create collect elements
|
|
1209
|
+
const cardHolderNameElement = collectContainer.create({
|
|
1210
|
+
table: 'pii_fields',
|
|
1211
|
+
column: 'first_name',
|
|
1212
|
+
...stylesOptions,
|
|
1213
|
+
placeholder: 'Cardholder Name',
|
|
1214
|
+
type: Skyflow.ElementType.CARDHOLDER_NAME,
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
const cardNumberElement = collectContainer.create({
|
|
1218
|
+
table: 'pii_fields',
|
|
1219
|
+
column: 'card_number',
|
|
1220
|
+
...stylesOptions,
|
|
1221
|
+
placeholder: 'Card Number',
|
|
1222
|
+
type: Skyflow.ElementType.CARD_NUMBER,
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
const cvvElement = collectContainer.create({
|
|
1226
|
+
table: 'pii_fields',
|
|
1227
|
+
column: 'cvv',
|
|
1228
|
+
...stylesOptions,
|
|
1229
|
+
placeholder: 'CVV',
|
|
1230
|
+
type: Skyflow.ElementType.CVV,
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
// Mount the collect elements.
|
|
1234
|
+
cardHolderNameElement.mount('#cardHolderNameElement'); // Assumes there is a div with id='#cardHolderNameElement' in the webpage.
|
|
1235
|
+
cardNumberElement.mount('#cardNumberElement'); // Assumes there is a div with id='#cardNumberElement' in the webpage.
|
|
1236
|
+
cvvElement.mount('#cvvElement'); // Assumes there is a div with id='#cvvElement' in the webpage.
|
|
1237
|
+
|
|
1238
|
+
// ...
|
|
1239
|
+
|
|
1240
|
+
// Update validations property on cvvElement.
|
|
1241
|
+
cvvElement.update({
|
|
1242
|
+
validations: [{
|
|
1243
|
+
type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
|
|
1244
|
+
params: {
|
|
1245
|
+
max: 3,
|
|
1246
|
+
error: 'cvv must be 3 digits',
|
|
1247
|
+
},
|
|
1248
|
+
}]
|
|
1249
|
+
})
|
|
1250
|
+
|
|
1251
|
+
// Update label, placeholder properties on cardHolderNameElement.
|
|
1252
|
+
cardHolderNameElement.update({
|
|
1253
|
+
label: 'CARDHOLDER NAME',
|
|
1254
|
+
placeholder: 'Eg: John'
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
// Update table, column, inputStyles properties on cardNumberElement.
|
|
1258
|
+
cardNumberElement.update({
|
|
1259
|
+
table:'cards',
|
|
1260
|
+
column:'card_number',
|
|
1261
|
+
inputStyles:{
|
|
1262
|
+
base:{
|
|
1263
|
+
color:'blue'
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
```
|
|
1268
|
+
|
|
1158
1269
|
---
|
|
1159
1270
|
|
|
1160
1271
|
# Securely collecting data client-side using Composable Elements
|
|
@@ -1752,6 +1863,7 @@ composableContainer.on(Skyflow.EventName.SUBMIT, ()=> {
|
|
|
1752
1863
|
- [**Set token for Reveal Elements**](#set-token-for-reveal-elements)
|
|
1753
1864
|
- [**Set and clear altText for Reveal Elements**](#set-and-clear-alttext-for-reveal-elements)
|
|
1754
1865
|
- [**Render a file with a File Element**](#render-a-file-with-a-file-element)
|
|
1866
|
+
- [**Update Reveal Elements**](#update-reveal-elements)
|
|
1755
1867
|
|
|
1756
1868
|
## Retrieving data from the vault
|
|
1757
1869
|
|
|
@@ -2615,9 +2727,9 @@ const fileElement = {
|
|
|
2615
2727
|
inputStyles: {}, // Optional, styles to be applied to the element.
|
|
2616
2728
|
errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the render element.
|
|
2617
2729
|
altText: 'string', // Optional, string that is shown before file render call
|
|
2618
|
-
skyflowID: 'string', // Required, skyflow id of the file to
|
|
2619
|
-
column: 'string', // Required, column name of the file to
|
|
2620
|
-
table: 'string', // Required, table name of the file to
|
|
2730
|
+
skyflowID: 'string', // Required, skyflow id of the file to render
|
|
2731
|
+
column: 'string', // Required, column name of the file to render
|
|
2732
|
+
table: 'string', // Required, table name of the file to render
|
|
2621
2733
|
};
|
|
2622
2734
|
```
|
|
2623
2735
|
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.
|
|
@@ -2732,6 +2844,104 @@ fetch("<BACKEND_URL>")
|
|
|
2732
2844
|
}
|
|
2733
2845
|
```
|
|
2734
2846
|
|
|
2847
|
+
### Update Reveal Elements
|
|
2848
|
+
|
|
2849
|
+
You can update reveal element properties with the `update` interface.
|
|
2850
|
+
|
|
2851
|
+
The `update` interface takes the below object:
|
|
2852
|
+
```javascript
|
|
2853
|
+
const updateElement = {
|
|
2854
|
+
token: 'string', // Optional, token of the data being revealed.
|
|
2855
|
+
inputStyles: {}, // Optional, styles to be applied to the element.
|
|
2856
|
+
labelStyles: {}, // Optional, styles to be applied to the label of the reveal element.
|
|
2857
|
+
errorTextStyles: {}, // Optional, styles that will be applied to the errorText of the reveal element.
|
|
2858
|
+
label: 'string', // Optional, label for the form element.
|
|
2859
|
+
altText: 'string', // Optional, string that is shown before reveal, will show token if altText is not provided.
|
|
2860
|
+
redaction: RedactionType, // Optional, Redaction Type to be applied to data.
|
|
2861
|
+
skyflowID: 'string', // Optional, Skyflow ID of the file to render.
|
|
2862
|
+
table: 'string', // Optional, table name of the file to render.
|
|
2863
|
+
column: 'string' // Optional, column name of the file to render.
|
|
2864
|
+
};
|
|
2865
|
+
```
|
|
2866
|
+
|
|
2867
|
+
Only include the properties that you want to update for the specified reveal element.
|
|
2868
|
+
|
|
2869
|
+
Properties your provided when you created the element remain the same until you explicitly update them.
|
|
2870
|
+
|
|
2871
|
+
### End to end example
|
|
2872
|
+
```javascript
|
|
2873
|
+
// Create a reveal container.
|
|
2874
|
+
const revealContainer = skyflow.container(Skyflow.ContainerType.REVEAL);
|
|
2875
|
+
|
|
2876
|
+
const stylesOptions = {
|
|
2877
|
+
inputStyles: {
|
|
2878
|
+
base: {
|
|
2879
|
+
fontFamily: 'Inter',
|
|
2880
|
+
fontStyle: 'normal',
|
|
2881
|
+
fontWeight: 400,
|
|
2882
|
+
fontSize: '14px',
|
|
2883
|
+
lineHeight: '21px',
|
|
2884
|
+
width: '294px',
|
|
2885
|
+
},
|
|
2886
|
+
},
|
|
2887
|
+
labelStyles: {},
|
|
2888
|
+
errorTextStyles: {
|
|
2889
|
+
base: {
|
|
2890
|
+
color: '#f44336'
|
|
2891
|
+
},
|
|
2892
|
+
},
|
|
2893
|
+
};
|
|
2894
|
+
|
|
2895
|
+
// Create reveal elements
|
|
2896
|
+
const cardHolderNameRevealElement = revealContainer.create({
|
|
2897
|
+
token: 'ed5fdd1f-5009-435c-a06b-3417ce76d2c8',
|
|
2898
|
+
altText: 'first name',
|
|
2899
|
+
...stylesOptions,
|
|
2900
|
+
label: 'Card Holder Name',
|
|
2901
|
+
});
|
|
2902
|
+
|
|
2903
|
+
const cardNumberRevealElement = revealContainer.create({
|
|
2904
|
+
token: '8ee84061-7107-4faf-bb25-e044f3d191fe',
|
|
2905
|
+
altText: 'xxxx',
|
|
2906
|
+
...stylesOptions,
|
|
2907
|
+
label: 'Card Number',
|
|
2908
|
+
redaction: 'RedactionType.CARD_NUMBER'
|
|
2909
|
+
});
|
|
2910
|
+
|
|
2911
|
+
// Mount the reveal elements.
|
|
2912
|
+
cardHolderNameRevealElement.mount('#cardHolderNameRevealElement'); // Assumes there is a div with id='#cardHolderNameRevealElement' in the webpage.
|
|
2913
|
+
cardNumberRevealElement.mount('#cardNumberRevealElement'); // Assumes there is a div with id='#cardNumberRevealElement' in the webpage.
|
|
2914
|
+
|
|
2915
|
+
// ...
|
|
2916
|
+
|
|
2917
|
+
// Update label, labelStyles properties on cardHolderNameRevealElement.
|
|
2918
|
+
cardHolderNameRevealElement.update({
|
|
2919
|
+
label: 'CARDHOLDER NAME',
|
|
2920
|
+
labelStyles: {
|
|
2921
|
+
base: {
|
|
2922
|
+
color: '#aa11aa'
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
|
|
2927
|
+
// Update inputStyles, errorTextStyles properties on cardNumberRevealElement.
|
|
2928
|
+
cardNumberRevealElement.update({
|
|
2929
|
+
inputStyles: {
|
|
2930
|
+
base: {
|
|
2931
|
+
color: '#fff',
|
|
2932
|
+
backgroundColor: '#000',
|
|
2933
|
+
borderColor: '#f00',
|
|
2934
|
+
borderWidth: '5px'
|
|
2935
|
+
}
|
|
2936
|
+
},
|
|
2937
|
+
errorTextStyles: {
|
|
2938
|
+
base: {
|
|
2939
|
+
backgroundColor: '#000',
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
});
|
|
2943
|
+
```
|
|
2944
|
+
|
|
2735
2945
|
---
|
|
2736
2946
|
# Securely deleting data client-side
|
|
2737
2947
|
- [**Deleting data from the vault**](#deleting-data-from-the-vault)
|