skyflow-js 1.12.2 → 1.15.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 +23 -1
- package/README.md +12 -322
- package/dist/sdkNodeBuild/index.js +1 -1
- package/dist/sdkNodeBuild/index.js.gz +0 -0
- package/package.json +2 -1
- package/types/client/index.d.ts +1 -1
- package/types/core/constants.d.ts +47 -7
- package/types/core/internal/iFrameForm/index.d.ts +2 -2
- package/types/utils/busEvents/index.d.ts +1 -0
- package/types/utils/helpers/index.d.ts +11 -0
- package/types/utils/logs.d.ts +2 -0
- package/types/utils/validators/index.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.15.0] - 2022-05-24
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Support for generic card types
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Deprecated `invokeConnection()`
|
|
13
|
+
- Deprecated `invokeSoapConnection()`
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [1.14.0] - 2022-04-19
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `EXPIRATION_YEAR` element type
|
|
20
|
+
- `EXPIRATION_MONTH` element type
|
|
21
|
+
|
|
22
|
+
## [1.13.0] - 2022-04-05
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- support for application/x-www-form-urlencoded and multipart/form-data content-type's in connections
|
|
26
|
+
|
|
5
27
|
## [1.12.2] - 2022-03-29
|
|
6
28
|
|
|
7
29
|
### Changed
|
|
8
|
-
- Added validation
|
|
30
|
+
- Added validation of JWT token format from TokenProvider
|
|
9
31
|
|
|
10
32
|
### Fixed
|
|
11
33
|
- Request headers not getting overriden due to case sensitivity
|
package/README.md
CHANGED
|
@@ -12,8 +12,6 @@ Skyflow’s Javascript SDK can be used to securely collect, tokenize, and reveal
|
|
|
12
12
|
- [**Initializing Skyflow.js**](#Initializing-Skyflowjs)
|
|
13
13
|
- [**Securely collecting data client-side**](#Securely-collecting-data-client-side)
|
|
14
14
|
- [**Securely revealing data client-side**](#Securely-revealing-data-client-side)
|
|
15
|
-
- [**Securely invoking Connections client-side**](#Securely-invoking-Connections-client-side)
|
|
16
|
-
- [**Securely invoking Connections client-side using SOAP**](#Securely-invoking-Connections-client-side-using-soap)
|
|
17
15
|
|
|
18
16
|
---
|
|
19
17
|
|
|
@@ -287,6 +285,8 @@ Finally, the `type` field takes a Skyflow ElementType. Each type applies the app
|
|
|
287
285
|
- `CARDHOLDER_NAME`
|
|
288
286
|
- `CARD_NUMBER`
|
|
289
287
|
- `EXPIRATION_DATE`
|
|
288
|
+
- `EXPIRATION_MONTH`
|
|
289
|
+
- `EXPIRATION_YEAR`
|
|
290
290
|
- `CVV`
|
|
291
291
|
- `INPUT_FIELD`
|
|
292
292
|
- `PIN`
|
|
@@ -307,15 +307,19 @@ const options = {
|
|
|
307
307
|
|
|
308
308
|
`enableCardIcon` paramenter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
|
|
309
309
|
|
|
310
|
-
`format` parameter takes string value and indicates the format pattern applicable to the element type
|
|
310
|
+
`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
311
|
|
|
312
|
-
|
|
313
|
-
- `MM/
|
|
314
|
-
- `
|
|
315
|
-
- `
|
|
312
|
+
The values that are accepted for `EXPIRATION_DATE` are
|
|
313
|
+
- `MM/YY` (default)
|
|
314
|
+
- `MM/YYYY`
|
|
315
|
+
- `YY/MM`
|
|
316
|
+
- `YYYY/MM`
|
|
316
317
|
|
|
317
|
-
|
|
318
|
+
The values that are accepted for `EXPIRATION_YEAR` are
|
|
319
|
+
- `YY` (default)
|
|
320
|
+
- `YYYY`
|
|
318
321
|
|
|
322
|
+
`NOTE`: If not specified or invalid value is passed to the `format` then it takes default value.
|
|
319
323
|
|
|
320
324
|
Once the Element object and options has been defined, add it to the container using the `create(element, options)` method as shown below. The `element` param takes a Skyflow Element object and options as defined above:
|
|
321
325
|
|
|
@@ -1075,317 +1079,3 @@ cardNumber.setAltText("Card Number");
|
|
|
1075
1079
|
//clear altText
|
|
1076
1080
|
cardNumber.clearAltText();
|
|
1077
1081
|
```
|
|
1078
|
-
# Securely invoking Connections client-side
|
|
1079
|
-
Using Skyflow Connections, end-user applications can integrate checkout/card issuance flow without any of their apps/systems touching the PCI compliant fields like cvv, card number. To invoke Connections, use the `invokeConnection(connectionConfig)` method of the Skyflow client.
|
|
1080
|
-
|
|
1081
|
-
```javascript
|
|
1082
|
-
const connectionConfig = {
|
|
1083
|
-
connectionURL: string, // connection url recevied when creating a skyflow Connection integration
|
|
1084
|
-
methodName: Skyflow.RequestMethod,
|
|
1085
|
-
pathParams: any, // optional
|
|
1086
|
-
queryParams: any, // optional
|
|
1087
|
-
requestHeader: any, // optional
|
|
1088
|
-
requestBody: any, // optional
|
|
1089
|
-
responseBody: any // optional
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
const response = skyflowClient.invokeConnection(connectionConfig);
|
|
1093
|
-
```
|
|
1094
|
-
`methodName` supports the following methods:
|
|
1095
|
-
|
|
1096
|
-
- GET
|
|
1097
|
-
- POST
|
|
1098
|
-
- PUT
|
|
1099
|
-
- PATCH
|
|
1100
|
-
- DELETE
|
|
1101
|
-
|
|
1102
|
-
**pathParams, queryParams, requestHeader, requestBody** are the JSON objects that will be sent through the Connection integration url.
|
|
1103
|
-
|
|
1104
|
-
The values in the above parameters can contain collect elements, reveal elements or actual values. When elements are provided inplace of values, they get replaced with the value entered in the collect elements or value present in the reveal elements
|
|
1105
|
-
|
|
1106
|
-
**responseBody**:
|
|
1107
|
-
It is a JSON object that specifies where to render the response in the UI. The values in the responseBody can contain collect elements or reveal elements. The actual values corresponding to these elements will be stripped out from the actual response, which is then forwarded from the SDK to the client application.
|
|
1108
|
-
|
|
1109
|
-
Sample use-cases on using invokeConnection():
|
|
1110
|
-
|
|
1111
|
-
### [Sample use-case 1](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/invokeConnection.html):
|
|
1112
|
-
|
|
1113
|
-
Merchant acceptance - customers should be able to complete payment checkout without cvv touching their application. This means that the merchant should be able to receive a CVV and process a payment without exposing their front-end to any PCI data
|
|
1114
|
-
|
|
1115
|
-
```javascript
|
|
1116
|
-
// step 1
|
|
1117
|
-
const skyflowClient = skyflow.init({
|
|
1118
|
-
getBearerToken: <helperFunc>
|
|
1119
|
-
});
|
|
1120
|
-
|
|
1121
|
-
// step 2
|
|
1122
|
-
const collectContainer = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
1123
|
-
|
|
1124
|
-
// step 3
|
|
1125
|
-
const cardNumberElement = collectContainer.create({
|
|
1126
|
-
type: skyflow.ElementType.CARD_NUMBER
|
|
1127
|
-
})
|
|
1128
|
-
cardNumberElement.mount("#cardNumber")
|
|
1129
|
-
|
|
1130
|
-
const cvvElement = collectContainer.create({
|
|
1131
|
-
type: skyflow.ElementType.CVV
|
|
1132
|
-
})
|
|
1133
|
-
cvvElement.mount("#cvv")
|
|
1134
|
-
|
|
1135
|
-
// step 4
|
|
1136
|
-
const connectionConfig = {
|
|
1137
|
-
connectionURL: <connection_url>,
|
|
1138
|
-
methodName: Skyflow.RequestMethod.POST,
|
|
1139
|
-
requestBody: {
|
|
1140
|
-
card_number: cardNumberElement, //it can be skyflow element(collect or reveal) or actual value
|
|
1141
|
-
cvv: cvvElement,
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
const response = skyflowClient.invokeConnection(connectionConfig);
|
|
1146
|
-
```
|
|
1147
|
-
|
|
1148
|
-
Sample Response:
|
|
1149
|
-
```javascript
|
|
1150
|
-
{
|
|
1151
|
-
"receivedTimestamp": "2019-05-29 21:49:56.625",
|
|
1152
|
-
"processingTimeinMs": 116
|
|
1153
|
-
}
|
|
1154
|
-
```
|
|
1155
|
-
In the above example, CVV is being collected from the user input at the time of checkout and not stored anywhere in the vault
|
|
1156
|
-
|
|
1157
|
-
`Note:`
|
|
1158
|
-
- card_number can be either container element or plain text value (tokens or actual value)
|
|
1159
|
-
- `table` and `column` names are not required for creating collect element, if it is used for invokeConnection method, since they will not be stored in the vault
|
|
1160
|
-
|
|
1161
|
-
### [Sample use-case 2](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/invokeConnection.html):
|
|
1162
|
-
|
|
1163
|
-
Card issuance - customers want to issue cards from card issuer service and should generate the CVV dynamically without increasing their PCI scope.
|
|
1164
|
-
```javascript
|
|
1165
|
-
// step 1
|
|
1166
|
-
const skyflowClient = skyflow.init({
|
|
1167
|
-
getBearerToken: <helperFunc>
|
|
1168
|
-
});
|
|
1169
|
-
|
|
1170
|
-
// step 2
|
|
1171
|
-
const revealContainer = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|
|
1172
|
-
const collectContainer = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
1173
|
-
|
|
1174
|
-
// step 3
|
|
1175
|
-
const cvvElement = revealContainer.create({
|
|
1176
|
-
altText: "###",
|
|
1177
|
-
})
|
|
1178
|
-
cvvElement.mount("#cvv")
|
|
1179
|
-
|
|
1180
|
-
const expiryDateElement = collectContainer.create({
|
|
1181
|
-
type: skyflow.ElementType.EXPIRATION_DATE
|
|
1182
|
-
})
|
|
1183
|
-
expiryDateElement.mount("#expirationDate")
|
|
1184
|
-
|
|
1185
|
-
//step 4
|
|
1186
|
-
const connectionConfig = {
|
|
1187
|
-
connectionURL: <connection_url>,
|
|
1188
|
-
methodName: Skyflow.RequestMethod.POST,
|
|
1189
|
-
pathParams: {
|
|
1190
|
-
card_number: "0905-8672-0773-0628" //it can be skyflow element(collect/reveal) or token or actual value
|
|
1191
|
-
},
|
|
1192
|
-
requestBody: {
|
|
1193
|
-
expirationDate: expiryDateElement //it can be skyflow element(collect/reveal) or token or actual value
|
|
1194
|
-
},
|
|
1195
|
-
responseBody: {
|
|
1196
|
-
resource: {
|
|
1197
|
-
cvv2: cvvElement // pass the element where the cvv response from the Connection will be mounted
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
const response = skyflowClient.invokeConnection(connectionConfig);
|
|
1204
|
-
```
|
|
1205
|
-
|
|
1206
|
-
Sample Response:
|
|
1207
|
-
```javascript
|
|
1208
|
-
{
|
|
1209
|
-
"receivedTimestamp": "2019-05-29 21:49:56.625",
|
|
1210
|
-
"processingTimeinMs": 116
|
|
1211
|
-
}
|
|
1212
|
-
```
|
|
1213
|
-
|
|
1214
|
-
`Note`:
|
|
1215
|
-
- `token` is optional for creating reveal element, if it is used for invokeConnection
|
|
1216
|
-
- responseBody contains collect or reveal elements to render the response from the Connection on UI
|
|
1217
|
-
|
|
1218
|
-
# Securely invoking Connections client-side using SOAP
|
|
1219
|
-
|
|
1220
|
-
To invoke Connections using SOAP, use the `invokeSoapConnection(connectionConfig)` method of the Skyflow client as shown below:
|
|
1221
|
-
|
|
1222
|
-
```javascript
|
|
1223
|
-
const connectionConfig = {
|
|
1224
|
-
connectionURL: string, // connection url received when creating a Skyflow Connection
|
|
1225
|
-
httpHeaders: any, // optional
|
|
1226
|
-
requestXML: string,
|
|
1227
|
-
responseXML: string, // optional
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
const response = skyflowClient.invokeSoapConnection(connectionConfig);
|
|
1231
|
-
```
|
|
1232
|
-
|
|
1233
|
-
**httpHeaders** is the JSON object containing key-value pairs that are sent as request headers.
|
|
1234
|
-
|
|
1235
|
-
`Note:` "X-Skyflow-Authorization" key is added in headers by SDK internally. If user specifies it again, it overrides.
|
|
1236
|
-
|
|
1237
|
-
**requestXML** accepts the entire XML request as a string.
|
|
1238
|
-
|
|
1239
|
-
The values in the **requestXML** can contain collect element IDs or reveal element IDs or actual values. When the IDs are provided in place of values, they get replaced with the value entered in the collect elements or value present in the reveal elements.
|
|
1240
|
-
|
|
1241
|
-
**responseXML** accepts the entire XML request as a string. It specifies where to render the response in the UI. The values in the responseXML can contain collect element IDs or reveal element IDs. The actual values corresponding to these IDs will be stripped out from the actual response, which is then forwarded from the SDK to the client application.
|
|
1242
|
-
|
|
1243
|
-
`Note:` If the user needs to use Skyflow Elements in place of values in the requestXML or responseXML, they will pass in an additional tag **Skyflow** containing the ID of the particular element.
|
|
1244
|
-
|
|
1245
|
-
Please ensure that the paths configured in the responseXML are present in the actual response. In case of a misconfigured path, the response from the server will be discarded and an error will be thrown.
|
|
1246
|
-
|
|
1247
|
-
**[Sample Code:](https://github.com/skyflowapi/skyflow-js/blob/master/samples/UsingScriptTag/InvokeSoapConnection.html)**
|
|
1248
|
-
|
|
1249
|
-
```javascript
|
|
1250
|
-
|
|
1251
|
-
// step 1
|
|
1252
|
-
const skyflowClient = skyflow.init({
|
|
1253
|
-
vaultID: '<vault_ID>', // optional
|
|
1254
|
-
vaultURL: '<vault_URL>', // optional
|
|
1255
|
-
getBearerToken: '<helperFunc>'
|
|
1256
|
-
});
|
|
1257
|
-
|
|
1258
|
-
// step 2
|
|
1259
|
-
const revealContainer = skyflowClient.container(Skyflow.ContainerType.REVEAL)
|
|
1260
|
-
const collectContainer = skyflowClient.container(Skyflow.ContainerType.COLLECT)
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
// step 3
|
|
1264
|
-
const cardNumberElement = collectContainer.create({
|
|
1265
|
-
type: skyflow.ElementType.CARD_NUMBER
|
|
1266
|
-
})
|
|
1267
|
-
cardNumberElement.mount("#cardNumber")
|
|
1268
|
-
|
|
1269
|
-
const expiryMonthElement = revealContainer.create({
|
|
1270
|
-
token: "<expiry_month_token>"
|
|
1271
|
-
})
|
|
1272
|
-
expiryMonthElement.mount("#expirationMonth")
|
|
1273
|
-
|
|
1274
|
-
const expiryYearElement = revealContainer.create({
|
|
1275
|
-
token: "<expiry_year_token>"
|
|
1276
|
-
})
|
|
1277
|
-
expiryYearElement.mount("#expirationYear")
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
const cvvElement = revealContainer.create({
|
|
1281
|
-
altText: "###",
|
|
1282
|
-
})
|
|
1283
|
-
cvvElement.mount("#cvv")
|
|
1284
|
-
|
|
1285
|
-
//step 4
|
|
1286
|
-
const cardNumberID = cardNumberElement.getID() // to get element ID
|
|
1287
|
-
const expiryMonthID = expiryDateElement.getID()
|
|
1288
|
-
const expiryYearID = expiryYearElement.getID()
|
|
1289
|
-
const cvvElementID = cvvElement.getID()
|
|
1290
|
-
|
|
1291
|
-
// step 5
|
|
1292
|
-
const requestXML = `<soapenv:Envelope>
|
|
1293
|
-
<soapenv:Header>
|
|
1294
|
-
<ClientID>1234</ClientID>
|
|
1295
|
-
</soapenv:Header>
|
|
1296
|
-
<soapenv:Body>
|
|
1297
|
-
<GenerateCVV>
|
|
1298
|
-
<CardNumber>
|
|
1299
|
-
<Skyflow>${cardNumberID}</Skyflow>
|
|
1300
|
-
</CardNumber>
|
|
1301
|
-
<ExpiryMonth>
|
|
1302
|
-
<Skyflow>${expiryMonthID}</Skyflow>
|
|
1303
|
-
</ExpiryMonth>
|
|
1304
|
-
<ExpiryYear>
|
|
1305
|
-
<Skyflow>${expiryYearID}</Skyflow>
|
|
1306
|
-
</ExpiryYear>
|
|
1307
|
-
</GenerateCVV>
|
|
1308
|
-
</soapenv:Body>
|
|
1309
|
-
</soapenv:Envelope>`
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
const responseXML = `<soapenv:Envelope>
|
|
1313
|
-
<soapenv:Header>
|
|
1314
|
-
<HeaderList>
|
|
1315
|
-
<HeaderItem>
|
|
1316
|
-
<Name>NodeId</Name>
|
|
1317
|
-
<Value>
|
|
1318
|
-
<Skyflow>${revealNodeId}</Skyflow>
|
|
1319
|
-
</Value>
|
|
1320
|
-
</HeaderItem>
|
|
1321
|
-
<HeaderItem>
|
|
1322
|
-
<Name>ProgramId</Name>
|
|
1323
|
-
<Value>
|
|
1324
|
-
<Skyflow>${revealProgramId}</Skyflow>
|
|
1325
|
-
</Value>
|
|
1326
|
-
</HeaderItem>
|
|
1327
|
-
</HeaderList>
|
|
1328
|
-
<ClientID>1234</ClientID>
|
|
1329
|
-
</soapenv:Header>
|
|
1330
|
-
<soapenv:Body>
|
|
1331
|
-
<GenerateCVV>
|
|
1332
|
-
<CVV>
|
|
1333
|
-
<Skyflow>${cvvElementID}</Skyflow>
|
|
1334
|
-
</CVV>
|
|
1335
|
-
</GenerateCVV>
|
|
1336
|
-
</soapenv:Body>
|
|
1337
|
-
</soapenv:Envelope>`
|
|
1338
|
-
|
|
1339
|
-
const headers = {
|
|
1340
|
-
soapAction: '<soap_action>', // any http headers can be added here
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
const connectionConfig = {
|
|
1344
|
-
connectionURL: '<connection_url>',
|
|
1345
|
-
httpHeaders: headers,
|
|
1346
|
-
requestXML: requestXML,
|
|
1347
|
-
responseXML: responseXML,
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
const response = skyflowClient.invokeSoapConnection(connectionConfig);
|
|
1351
|
-
|
|
1352
|
-
```
|
|
1353
|
-
|
|
1354
|
-
Sample Response on success:
|
|
1355
|
-
|
|
1356
|
-
```xml
|
|
1357
|
-
<soapenv:Envelope>
|
|
1358
|
-
<soapenv:Header>
|
|
1359
|
-
<HeaderList>
|
|
1360
|
-
<HeaderItem>
|
|
1361
|
-
<Name>NodeId</Name>
|
|
1362
|
-
</HeaderItem>
|
|
1363
|
-
<HeaderItem>
|
|
1364
|
-
<Name>ProgramId</Name>
|
|
1365
|
-
</HeaderItem>
|
|
1366
|
-
</HeaderList>
|
|
1367
|
-
</soapenv:Header>
|
|
1368
|
-
<soapenv:Body>
|
|
1369
|
-
<GenerateCVV>
|
|
1370
|
-
<ReceivedTimestamp>2019-05-29 21:49:56.625</ReceivedTimestamp>
|
|
1371
|
-
</GenerateCVV>
|
|
1372
|
-
</soapenv:Body>
|
|
1373
|
-
</soapenv:Envelope>
|
|
1374
|
-
```
|
|
1375
|
-
|
|
1376
|
-
Sample Response on failure:
|
|
1377
|
-
|
|
1378
|
-
```javascript
|
|
1379
|
-
{
|
|
1380
|
-
code: '<error_code>',
|
|
1381
|
-
description: '<error_description>',
|
|
1382
|
-
xml: '<xml_received_from_server>'
|
|
1383
|
-
}
|
|
1384
|
-
```
|
|
1385
|
-
|
|
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.
|