skyflow-js 1.9.1 → 1.10.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
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
 
6
+ ## [1.10.0] - 2022-01-25
7
+
8
+ ### Added
9
+ - `formatRegex` option for `RevealElement`
6
10
  ## [1.9.1] - 2022-01-11
7
11
 
8
12
  ### Fixed
package/README.md CHANGED
@@ -871,9 +871,15 @@ const revealElement = {
871
871
  label: "string", //optional, label for the form element
872
872
  altText: "string" //optional, string that is shown before reveal, will show token if altText is not provided
873
873
  }
874
+
875
+ const revealElementOptions = {
876
+ formatRegex: RegExp //optional, regex to specify the format on the value that has been revealed
877
+ }
874
878
  ```
875
879
  `Note`:
876
880
  - `token` is optional only if it is being used in invokeConnection()
881
+ - If revealElement has a formatRegex option and on invoking container.reveal() method, it will first reveal the token and then apply the formatRegex match, and then render it in UI
882
+ - If there are multiple matches found with the given formatRegex option, then always the first match is applied to the revealed value
877
883
 
878
884
  The `inputStyles`, `labelStyles` and `errorTextStyles` parameters accepts a styles object as described in the [previous section](#step-2-create-a-collect-element) for collecting data but only a single variant is available i.e. base.
879
885
 
@@ -911,7 +917,7 @@ errorTextStyles: {
911
917
  Once you've defined a Skyflow Element, you can use the `create(element)` method of the container to create the Element as shown below:
912
918
 
913
919
  ```javascript
914
- const element = container.create(revealElement)
920
+ const element = container.create(revealElement, revealElementOptions)
915
921
  ```
916
922
 
917
923
  ### Step 3: Mount Elements to the DOM
@@ -1242,6 +1248,8 @@ Please ensure that the paths configured in the responseXML are present in the ac
1242
1248
 
1243
1249
  // step 1
1244
1250
  const skyflowClient = skyflow.init({
1251
+ vaultID: '<vault_ID>', // optional, required only when a revealElement has formatRegex option set
1252
+ vaultURL: '<vault_URL>', // optional, required only when a revealElement has formatRegex option set
1245
1253
  getBearerToken: '<helperFunc>'
1246
1254
  });
1247
1255
 
@@ -1256,10 +1264,18 @@ const cardNumberElement = collectContainer.create({
1256
1264
  })
1257
1265
  cardNumberElement.mount("#cardNumber")
1258
1266
 
1259
- const expiryDateElement = collectContainer.create({
1260
- type: skyflow.ElementType.EXPIRATION_DATE
1267
+ const expiryMonthElement = revealContainer.create({
1268
+ token: "<expiry_month_token>"
1261
1269
  })
1262
- expiryDateElement.mount("#expirationDate")
1270
+ expiryMonthElement.mount("#expirationMonth")
1271
+
1272
+ const expiryYearElement = revealContainer.create({
1273
+ token: "<expiry_year_token>"
1274
+ }, {
1275
+ formatRegex: /^..$/ // only last 2 characters are sent for invoking connection
1276
+ })
1277
+ expiryYearElement.mount("#expirationYear")
1278
+
1263
1279
 
1264
1280
  const cvvElement = revealContainer.create({
1265
1281
  altText: "###",
@@ -1268,7 +1284,8 @@ cvvElement.mount("#cvv")
1268
1284
 
1269
1285
  //step 4
1270
1286
  const cardNumberID = cardNumberElement.getID() // to get element ID
1271
- const expiryDateID = expiryDateElement.getID()
1287
+ const expiryMonthID = expiryDateElement.getID()
1288
+ const expiryYearID = expiryYearElement.getID()
1272
1289
  const cvvElementID = cvvElement.getID()
1273
1290
 
1274
1291
  // step 5
@@ -1281,9 +1298,12 @@ const requestXML = `<soapenv:Envelope>
1281
1298
  <CardNumber>
1282
1299
  <Skyflow>${cardNumberID}</Skyflow>
1283
1300
  </CardNumber>
1284
- <ExpiryDate>
1285
- <Skyflow>${expiryDateID}</Skyflow>
1286
- </ExpiryDate>
1301
+ <ExpiryMonth>
1302
+ <Skyflow>${expiryMonthID}</Skyflow>
1303
+ </ExpiryMonth>
1304
+ <ExpiryYear>
1305
+ <Skyflow>${expiryYearID}</Skyflow>
1306
+ </ExpiryYear>
1287
1307
  </GenerateCVV>
1288
1308
  </soapenv:Body>
1289
1309
  </soapenv:Envelope>`
@@ -1363,8 +1383,11 @@ Sample Response on failure:
1363
1383
  }
1364
1384
  ```
1365
1385
 
1366
- `Note`: In responseXML we provide the tags that needs to be rendered in UI and stripped out from the actual response.
1367
- 1. For uniquely identifiable tag, we can give the elementID within a skyflow tag directly corresponding to the actual value.
1368
- Please refer to the CVV tag in the above example. Here, we wish to strip the actual value present within the CVV tag.
1369
- 2. For arrays, since we have multiple tags with the same name, we will need to provide identifiers to uniquely identify the required tag.
1370
- Please refer to HeaderItem tag. Here, we have provided NodeId within the Name tag which acts as an identifier and we wish to strip the actual value present in the Value tag.
1386
+ `Note`:
1387
+ - In responseXML we provide the tags that needs to be rendered in UI and stripped out from the actual response.
1388
+ 1. For uniquely identifiable tag, we can give the elementID within a skyflow tag directly corresponding to the actual value.
1389
+ Please refer to the CVV tag in the above example. Here, we wish to strip the actual value present within the CVV tag.
1390
+ 2. For arrays, since we have multiple tags with the same name, we will need to provide identifiers to uniquely identify the required tag.
1391
+ Please refer to HeaderItem tag. Here, we have provided NodeId within the Name tag which acts as an identifier and we wish to strip the actual value present in the Value tag.
1392
+ - In requestXML, if revealElement has a formatRegex option, it will first reveal the token and then apply the formatRegex match, and then sent it to invokeConnections/invokeSoapConnections
1393
+ - In responseXML, if revealElement has a formatRegex option, then value is revealed in the UI according to the match found with respect to the given formatRegex