skyflow-js 1.18.0 → 1.19.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/README.md +218 -1
- 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 +10 -1
- package/types/core/external/collect/CollectContainer.d.ts +2 -0
- package/types/core/external/collect/CollectElement.d.ts +1 -1
- package/types/core/internal/iFrameForm/index.d.ts +10 -7
- package/types/core-utils/collect.d.ts +1 -0
- package/types/utils/constants.d.ts +4 -0
- package/types/utils/helpers/index.d.ts +2 -1
- package/types/utils/logs.d.ts +1 -0
- package/types/utils/validators/index.d.ts +1 -1
package/README.md
CHANGED
|
@@ -132,6 +132,7 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
|
|
|
132
132
|
- [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
|
|
133
133
|
- [**UI Error for Collect Eements**](#ui-error-for-collect-elements)
|
|
134
134
|
- [**Set and Clear value for Collect Elements (DEV ENV ONLY)**](#set-and-clear-value-for-collect-elements-dev-env-only)
|
|
135
|
+
- [**Using Skyflow File Element to upload a file**](#using-skyflow-file-element-to-upload-a-file)
|
|
135
136
|
## Inserting data into the vault
|
|
136
137
|
|
|
137
138
|
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:
|
|
@@ -290,6 +291,8 @@ Finally, the `type` field takes a Skyflow ElementType. Each type applies the app
|
|
|
290
291
|
- `CVV`
|
|
291
292
|
- `INPUT_FIELD`
|
|
292
293
|
- `PIN`
|
|
294
|
+
- `FILE_INPUT`
|
|
295
|
+
|
|
293
296
|
|
|
294
297
|
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.
|
|
295
298
|
|
|
@@ -480,7 +483,9 @@ Skyflow-JS provides two types of validations on Collect Elements
|
|
|
480
483
|
|
|
481
484
|
#### 1. Default Validations:
|
|
482
485
|
Every Collect Element except of type `INPUT_FIELD` has a set of default validations listed below:
|
|
483
|
-
- `CARD_NUMBER`: Card number validation with checkSum algorithm(Luhn algorithm)
|
|
486
|
+
- `CARD_NUMBER`: Card number validation with checkSum algorithm(Luhn algorithm).
|
|
487
|
+
Available card lengths for defined card types are [12, 13, 14, 15, 16, 17, 18, 19].
|
|
488
|
+
A valid 16 digit card number will be in the format - `XXXX XXXX XXXX XXXX`
|
|
484
489
|
- `CARD_HOLDER_NAME`: Name should be 2 or more symbols, valid characters should match pattern - `^([a-zA-Z\\ \\,\\.\\-\\']{2,})$`
|
|
485
490
|
- `CVV`: Card CVV can have 3-4 digits
|
|
486
491
|
- `EXPIRATION_DATE`: Any date starting from current month. By default valid expiration date should be in short year format - `MM/YY`
|
|
@@ -1083,6 +1088,218 @@ cardNumber.setAltText("Card Number");
|
|
|
1083
1088
|
//clear altText
|
|
1084
1089
|
cardNumber.clearAltText();
|
|
1085
1090
|
```
|
|
1091
|
+
|
|
1092
|
+
## Using Skyflow File Element to upload a file
|
|
1093
|
+
|
|
1094
|
+
You can upload binary files to a vault using the Skyflow File Element. Use the following steps to securely upload a file.
|
|
1095
|
+
### Step 1: Create a container
|
|
1096
|
+
|
|
1097
|
+
Create a container for the form elements using the container(Skyflow.ContainerType) method of the Skyflow client:
|
|
1098
|
+
|
|
1099
|
+
```javascript
|
|
1100
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
### Step 2: Create a File Element
|
|
1104
|
+
|
|
1105
|
+
Skyflow Collect Elements are defined as follows:
|
|
1106
|
+
|
|
1107
|
+
```javascript
|
|
1108
|
+
const collectElement = {
|
|
1109
|
+
table: "string", //the table this data belongs to
|
|
1110
|
+
column: "string", //the column into which this data should be inserted
|
|
1111
|
+
skyflowID: "string", // the skyflow_id of the record
|
|
1112
|
+
type: Skyflow.ElementType.FILE_INPUT, //Skyflow.ElementType enum
|
|
1113
|
+
inputStyles: {}, //optional styles that should be applied to the form element
|
|
1114
|
+
labelStyles: {}, //optional styles that will be applied to the label of the collect element
|
|
1115
|
+
errorTextStyles:{}, //optional styles that will be applied to the errorText of the collect element
|
|
1116
|
+
}
|
|
1117
|
+
```
|
|
1118
|
+
The `table` and `column` fields indicate which table and column the Element corresponds to.
|
|
1119
|
+
|
|
1120
|
+
`skyflowID` indicates the record that stores the file.
|
|
1121
|
+
|
|
1122
|
+
**Notes**:
|
|
1123
|
+
- `skyflowID` is required while creating File element
|
|
1124
|
+
- Use period-delimited strings to specify columns nested inside JSON fields (e.g. `address.street.line1`).
|
|
1125
|
+
|
|
1126
|
+
## Step 3: Mount elements to the DOM
|
|
1127
|
+
|
|
1128
|
+
To specify where to render Elements on your page, create placeholder `<div>` elements with unique `id` tags. For instance, the form below has an empty div with a unique id as a placeholder for a Skyflow Element.
|
|
1129
|
+
|
|
1130
|
+
```html
|
|
1131
|
+
<form>
|
|
1132
|
+
<div id="file"/>
|
|
1133
|
+
<br/>
|
|
1134
|
+
<button type="submit">Submit</button>
|
|
1135
|
+
</form>
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
Now, when the `mount(domElement)` method of the Element is called, the Element is inserted in the specified div. For instance, the call below inserts the Element into the div with the id "#file".
|
|
1139
|
+
|
|
1140
|
+
```javascript
|
|
1141
|
+
element.mount("#file")
|
|
1142
|
+
```
|
|
1143
|
+
Use the `unmount` method to reset a Collect Element to its initial state.
|
|
1144
|
+
|
|
1145
|
+
```javascript
|
|
1146
|
+
element.unmount();
|
|
1147
|
+
```
|
|
1148
|
+
## Step 4: Collect data from elements
|
|
1149
|
+
|
|
1150
|
+
When the file is ready to be uploaded, call the `uploadFiles()` method on the container object.
|
|
1151
|
+
|
|
1152
|
+
```javascript
|
|
1153
|
+
container.uploadFiles()
|
|
1154
|
+
```
|
|
1155
|
+
### File upload limitations:
|
|
1156
|
+
|
|
1157
|
+
- Only non-executable file are allowed to be uploaded.
|
|
1158
|
+
- Files must have a maximum size of 32 MB
|
|
1159
|
+
- File columns can't enable tokenization, redaction, or arrays.
|
|
1160
|
+
- Re-uploading a file overwrites previously uploaded data.
|
|
1161
|
+
- Partial uploads or resuming a previous upload isn't supported.
|
|
1162
|
+
|
|
1163
|
+
### End-to-end file upload
|
|
1164
|
+
|
|
1165
|
+
```javascript
|
|
1166
|
+
//Step 1
|
|
1167
|
+
const container = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
1168
|
+
|
|
1169
|
+
//Step 2
|
|
1170
|
+
const element = container.create({
|
|
1171
|
+
table: "pii_fields",
|
|
1172
|
+
column: "file",
|
|
1173
|
+
skyflowID:"431eaa6c-5c15-4513-aa15-29f50babe882",
|
|
1174
|
+
inputstyles: {
|
|
1175
|
+
base: {
|
|
1176
|
+
color: "#1d1d1d",
|
|
1177
|
+
},
|
|
1178
|
+
},
|
|
1179
|
+
labelStyles: {
|
|
1180
|
+
base: {
|
|
1181
|
+
fontSize: "12px",
|
|
1182
|
+
fontWeight: "bold"
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
errorTextStyles: {
|
|
1186
|
+
base: {
|
|
1187
|
+
color: "#f44336"
|
|
1188
|
+
}
|
|
1189
|
+
},
|
|
1190
|
+
type: Skyflow.ElementType.FILE_INPUT
|
|
1191
|
+
})
|
|
1192
|
+
|
|
1193
|
+
// Step 3
|
|
1194
|
+
element.mount("#file") //assumes there is a div with id="#file" in the webpage
|
|
1195
|
+
|
|
1196
|
+
// Step 4
|
|
1197
|
+
container.uploadFiles()
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
**Sample Response :**
|
|
1201
|
+
```javascript
|
|
1202
|
+
{
|
|
1203
|
+
fileUploadResponse: [
|
|
1204
|
+
{
|
|
1205
|
+
"skyflow_id": "431eaa6c-5c15-4513-aa15-29f50babe882"
|
|
1206
|
+
}
|
|
1207
|
+
]
|
|
1208
|
+
}
|
|
1209
|
+
```
|
|
1210
|
+
#### File upload with additional elements
|
|
1211
|
+
|
|
1212
|
+
```javascript
|
|
1213
|
+
// Create collect Container
|
|
1214
|
+
|
|
1215
|
+
const collectContainer = skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
// Create collect elements
|
|
1219
|
+
|
|
1220
|
+
const cardNumberElement = collectContainer.create({
|
|
1221
|
+
table: "newTable",
|
|
1222
|
+
column: "card_number",
|
|
1223
|
+
inputstyles: {
|
|
1224
|
+
base: {
|
|
1225
|
+
color: "#1d1d1d",
|
|
1226
|
+
},
|
|
1227
|
+
},
|
|
1228
|
+
labelStyles: {
|
|
1229
|
+
base: {
|
|
1230
|
+
fontSize: "12px",
|
|
1231
|
+
fontWeight: "bold"
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
errorTextStyles: {
|
|
1235
|
+
base: {
|
|
1236
|
+
color: "#f44336"
|
|
1237
|
+
}
|
|
1238
|
+
},,
|
|
1239
|
+
placeholder: "card number",
|
|
1240
|
+
label: "Card Number",
|
|
1241
|
+
type: Skyflow.ElementType.CARD_NUMBER,
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
const fileElement = collectContainer.create({
|
|
1245
|
+
table: "newTable",
|
|
1246
|
+
column: "file",
|
|
1247
|
+
skyflowID: '431eaa6c-5c15-4513-aa15-29f50babe882',
|
|
1248
|
+
inputstyles: {
|
|
1249
|
+
base: {
|
|
1250
|
+
color: "#1d1d1d",
|
|
1251
|
+
},
|
|
1252
|
+
},
|
|
1253
|
+
labelStyles: {
|
|
1254
|
+
base: {
|
|
1255
|
+
fontSize: "12px",
|
|
1256
|
+
fontWeight: "bold"
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1259
|
+
errorTextStyles: {
|
|
1260
|
+
base: {
|
|
1261
|
+
color: "#f44336"
|
|
1262
|
+
}
|
|
1263
|
+
},,
|
|
1264
|
+
type: Skyflow.ElementType.FILE_INPUT,
|
|
1265
|
+
});
|
|
1266
|
+
|
|
1267
|
+
// Mount the elements
|
|
1268
|
+
|
|
1269
|
+
cardNumberElement.mount("#collectCardNumber");
|
|
1270
|
+
fileElement.mount("#collectFile");
|
|
1271
|
+
|
|
1272
|
+
// Collect and upload methods
|
|
1273
|
+
|
|
1274
|
+
container.collect(options={})
|
|
1275
|
+
container.uploadFiles()
|
|
1276
|
+
|
|
1277
|
+
```
|
|
1278
|
+
**Sample Response for collect():**
|
|
1279
|
+
```javascript
|
|
1280
|
+
{
|
|
1281
|
+
"records": [
|
|
1282
|
+
{
|
|
1283
|
+
"table": "newTable",
|
|
1284
|
+
"fields": {
|
|
1285
|
+
"card_number": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
```
|
|
1291
|
+
**Sample Response for file uploadFiles() :**
|
|
1292
|
+
```javascript
|
|
1293
|
+
{
|
|
1294
|
+
"fileUploadResponse": [
|
|
1295
|
+
{
|
|
1296
|
+
"skyflow_id": "431eaa6c-5c15-4513-aa15-29f50babe882"
|
|
1297
|
+
}
|
|
1298
|
+
]
|
|
1299
|
+
}
|
|
1300
|
+
```
|
|
1301
|
+
|
|
1302
|
+
|
|
1086
1303
|
## Reporting a Vulnerability
|
|
1087
1304
|
|
|
1088
1305
|
If you discover a potential security issue in this project, please reach out to us at security@skyflow.com. Please do not create public GitHub issues or Pull Requests, as malicious actors could potentially view them.
|