skyflow-js 1.17.1 → 1.20.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 CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.20.0] - 2022-09-13
6
+
7
+ ### Changed
8
+ - Update custom validation samples in JS SDK
9
+ - Update Log Level log
10
+
11
+ ## [1.19.0] - 2022-08-30
12
+
13
+ ### Added
14
+ - `FILE_INPUT` element type
15
+
16
+ ## [1.18.0] - 2022-07-05
17
+
18
+ ### Added
19
+ - Copy icon in collect and reveal elements
20
+
5
21
  ## [1.17.1] - 2022-06-28
6
22
 
7
23
  ### Added
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:
@@ -190,7 +191,7 @@ The sample response:
190
191
 
191
192
  ## Using Skyflow Elements to collect data
192
193
 
193
- **Skyflow Elements** provide developers with pre-built form elements to securely collect sensitive data client-side. These elements are hosted by Skyflow and injected into your web page as iframes. This reduces your PCI compliance scope by not exposing your front-end application to sensitive data. Follow the steps below to securely collect data with Skyflow Elements on your web page.
194
+ **Skyflow Elements** provide developers with pre-built form elements to securely collect sensitive data client-side. These elements are hosted by Skyflow and injected into your web page as iFrames. This reduces your PCI compliance scope by not exposing your front-end application to sensitive data. Follow the steps below to securely collect data with Skyflow Elements on your web page.
194
195
 
195
196
  ### Step 1: Create a container
196
197
 
@@ -281,7 +282,7 @@ errorTextStyles: {
281
282
  }
282
283
  ```
283
284
 
284
- Finally, the `type` field takes a Skyflow ElementType. Each type applies the appropriate regex and validations to the form element. There are currently 5 types:
285
+ Finally, the `type` field takes a Skyflow ElementType. Each type applies the appropriate regex and validations to the form element. There are currently 8 types:
285
286
  - `CARDHOLDER_NAME`
286
287
  - `CARD_NUMBER`
287
288
  - `EXPIRATION_DATE`
@@ -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
 
@@ -298,17 +301,20 @@ Along with CollectElement we can define other options which takes a dictionary o
298
301
  ```javascript
299
302
  const options = {
300
303
  required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
301
- enableCardIcon: true // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
302
- format: String //optinal, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
304
+ enableCardIcon: true, // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
305
+ format: String, //optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType),
306
+ enableCopy: false // optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false')
303
307
  }
304
308
  ```
305
309
 
306
310
  `required` parameter indicates whether the field is marked as required or not. If not provided, it defaults to false
307
311
 
308
- `enableCardIcon` paramenter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
312
+ `enableCardIcon` parameter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
309
313
 
310
314
  `format` parameter takes string value and indicates the format pattern applicable to the element type, It's currently only applicable to `EXPIRATION_DATE` and `EXPIRATION_YEAR` element types.
311
315
 
316
+ `enableCopy` parameter indicates whether the copy icon is visible in collect and reveal elements.
317
+
312
318
  The values that are accepted for `EXPIRATION_DATE` are
313
319
  - `MM/YY` (default)
314
320
  - `MM/YYYY`
@@ -339,8 +345,9 @@ const collectElement = {
339
345
 
340
346
  const options = {
341
347
  required: false, //optional, indicates whether the field is marked as required. Defaults to 'false'
342
- enableCardIcon: true // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
343
- format: String //optinal, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
348
+ enableCardIcon: true, // optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType)
349
+ format: String, //optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType)
350
+ enableCopy: false // optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false')
344
351
  }
345
352
 
346
353
  const element = container.create(collectElement, options)
@@ -476,7 +483,9 @@ Skyflow-JS provides two types of validations on Collect Elements
476
483
 
477
484
  #### 1. Default Validations:
478
485
  Every Collect Element except of type `INPUT_FIELD` has a set of default validations listed below:
479
- - `CARD_NUMBER`: Card number validation with checkSum algorithm(Luhn algorithm), available card lengths for defined card types
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`
480
489
  - `CARD_HOLDER_NAME`: Name should be 2 or more symbols, valid characters should match pattern - `^([a-zA-Z\\ \\,\\.\\-\\']{2,})$`
481
490
  - `CVV`: Card CVV can have 3-4 digits
482
491
  - `EXPIRATION_DATE`: Any date starting from current month. By default valid expiration date should be in short year format - `MM/YY`
@@ -1079,6 +1088,218 @@ cardNumber.setAltText("Card Number");
1079
1088
  //clear altText
1080
1089
  cardNumber.clearAltText();
1081
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
+
1082
1303
  ## Reporting a Vulnerability
1083
1304
 
1084
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.