skyflow-js 2.5.0-beta.8 → 2.5.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 +142 -1
- package/dist/sdkNodeBuild/index.js +1 -1
- package/dist/sdkNodeBuild/index.js.gz +0 -0
- package/package.json +1 -1
- package/types/client/index.d.ts +9 -7
- package/types/core/constants.d.ts +2 -26
- package/types/core/external/collect/collect-container.d.ts +29 -3
- package/types/core/external/collect/collect-element.d.ts +5 -2
- package/types/core/external/collect/compose-collect-container.d.ts +8 -3
- package/types/core/external/collect/compose-collect-element.d.ts +3 -3
- package/types/core/external/common/iframe.d.ts +5 -3
- package/types/core/external/common/skyflow-element.d.ts +7 -7
- package/types/core/external/reveal/reveal-container.d.ts +3 -2
- package/types/core/external/reveal/reveal-element.d.ts +2 -1
- package/types/core/external/skyflow-container.d.ts +4 -2
- package/types/core/internal/frame-element-init.d.ts +0 -11
- package/types/core/internal/iframe-form/index.d.ts +0 -5
- package/types/core/internal/index.d.ts +1 -2
- package/types/core/internal/internal-types/index.d.ts +72 -0
- package/types/core/internal/reveal/reveal-frame.d.ts +1 -6
- package/types/core/internal/skyflow-frame/skyflow-frame-controller.d.ts +11 -8
- package/types/core-utils/collect.d.ts +10 -7
- package/types/core-utils/delete.d.ts +2 -2
- package/types/core-utils/reveal.d.ts +4 -31
- package/types/index-node.d.ts +1 -1
- package/types/libs/element-options.d.ts +4 -2
- package/types/libs/jss-styles.d.ts +1 -1
- package/types/skyflow.d.ts +11 -6
- package/types/utils/bus-events/index.d.ts +1 -1
- package/types/utils/common/index.d.ts +22 -21
- package/types/utils/constants.d.ts +44 -8
- package/types/utils/helpers/index.d.ts +8 -8
- package/types/utils/logs.d.ts +14 -5
- package/types/utils/validators/index.d.ts +4 -3
- package/types/core/external/reveal/composable-reveal-container.d.ts +0 -14
- package/types/core/external/reveal/composable-reveal-element.d.ts +0 -12
- package/types/core/external/reveal/composable-reveal-internal.d.ts +0 -29
- package/types/core/internal/composable-frame-element-init.d.ts +0 -21
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Skyflow’s JavaScript SDK can be used to securely collect, tokenize, and reveal
|
|
|
25
25
|
Using script tag
|
|
26
26
|
|
|
27
27
|
```html
|
|
28
|
-
<script src="https://js.skyflow.com/
|
|
28
|
+
<script src="https://js.skyflow.com/v2/index.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
|
|
@@ -134,6 +134,7 @@ For `env` parameter, there are 2 accepted values in Skyflow.Env
|
|
|
134
134
|
- [**Insert data into the vault**](#insert-data-into-the-vault)
|
|
135
135
|
- [**Using Skyflow Elements to collect data**](#using-skyflow-elements-to-collect-data)
|
|
136
136
|
- [**Using Skyflow Elements to update data**](#using-skyflow-elements-to-update-data)
|
|
137
|
+
- [**Bin lookup**](#bin-lookup)
|
|
137
138
|
- [**Using validations on Collect Elements**](#validations)
|
|
138
139
|
- [**Event Listener on Collect Elements**](#event-listener-on-collect-elements)
|
|
139
140
|
- [**UI Error for Collect Elements**](#ui-error-for-collect-elements)
|
|
@@ -203,6 +204,55 @@ The sample response:
|
|
|
203
204
|
}
|
|
204
205
|
```
|
|
205
206
|
|
|
207
|
+
## Update data in the vault
|
|
208
|
+
|
|
209
|
+
To update data in the vault by skyflowID, use the `update(request, options?)` method of the Skyflow client. The request object is a JSON object describing the data to update, including the `table`, `fields`, and the `skyflowID` of the record to update. The options parameter takes an object of optional parameters for the update and includes an option to return tokenized data for the updated fields.
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
const updateRecord = {
|
|
213
|
+
table: 'string', // Table in which record should be updated.
|
|
214
|
+
fields: {
|
|
215
|
+
column1: 'value', // Fields to update. Column names should match vault column names.
|
|
216
|
+
//...additional fields here
|
|
217
|
+
},
|
|
218
|
+
skyflowID: 'string', // The skyflow_id of the record to update.
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const options = {
|
|
222
|
+
tokens: true, // Indicates whether or not tokens should be returned for the updated data. Defaults to 'true'
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
skyflowClient.update(updateRecord, options);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
An [example](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/pure-update.html) of update call:
|
|
229
|
+
```javascript
|
|
230
|
+
skyflowClient.update({
|
|
231
|
+
table: 'cards',
|
|
232
|
+
fields: {
|
|
233
|
+
cardNumber: '41111111111',
|
|
234
|
+
cvv: '123',
|
|
235
|
+
},
|
|
236
|
+
skyflowID: '43127a6c-5c15-4513-aa15-29f50bb37182'
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The sample response:
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
{
|
|
244
|
+
"updatedField": {
|
|
245
|
+
"skyflowID": "43127a6c-5c15-4513-aa15-29f50bb37182",
|
|
246
|
+
"cardNumber": "f390186-e7e2-466f-91e5-48e12c2bcbc1",
|
|
247
|
+
"cvv": "1989cb56-63da-4482-a2df-1f74cd0d1a5"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Note**:
|
|
253
|
+
- The `skyflowID` field is required and should be the Skyflow ID of the record you want to update.
|
|
254
|
+
- If tokens is set to true, the response will include tokens for the updated fields.
|
|
255
|
+
|
|
206
256
|
## Using Skyflow Elements to collect data
|
|
207
257
|
|
|
208
258
|
**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.
|
|
@@ -745,6 +795,97 @@ cvvElement.mount('#cvv'); //Assumes there is a div with id='#cvv' in the webpage
|
|
|
745
795
|
]
|
|
746
796
|
}
|
|
747
797
|
```
|
|
798
|
+
|
|
799
|
+
## BIN Lookup
|
|
800
|
+
|
|
801
|
+
Skyflow supports BIN (Bank Identification Number) lookup to help identify co-badged cards and enable card network selection.
|
|
802
|
+
|
|
803
|
+
**What is BIN Lookup?**
|
|
804
|
+
A Bank Identification Number (BIN) represents the first 8 digits of a card number and identifies the issuing bank, card scheme, and country.
|
|
805
|
+
For co-badged cards, merchants are required to offer consumers a choice of which network to process the payment through.
|
|
806
|
+
You can use Skyflow’s BIN Lookup API to detect such cards and provide the appropriate options to users.
|
|
807
|
+
|
|
808
|
+
### Example: Calling the BIN Lookup API
|
|
809
|
+
```javascript
|
|
810
|
+
// Function to call Skyflow's BIN Lookup API
|
|
811
|
+
const binLookup = (bin) => {
|
|
812
|
+
const myHeaders = new Headers();
|
|
813
|
+
myHeaders.append("X-skyflow-authorization", "<BEARER_TOKEN>"); // TODO: replace bearer token
|
|
814
|
+
myHeaders.append("Content-Type", "application/json");
|
|
815
|
+
|
|
816
|
+
const raw = JSON.stringify({
|
|
817
|
+
"BIN": bin
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
const requestOptions = {
|
|
821
|
+
method: "POST",
|
|
822
|
+
headers: myHeaders,
|
|
823
|
+
body: raw,
|
|
824
|
+
redirect: "follow"
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// TODO: replace <VAULT_URL> with your Skyflow vault URL
|
|
828
|
+
return fetch(`${VAULT_URL}/v1/card_lookup`, requestOptions);
|
|
829
|
+
};
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
**Sample Response :**
|
|
833
|
+
```javascript
|
|
834
|
+
{
|
|
835
|
+
"cards_data": [
|
|
836
|
+
{
|
|
837
|
+
"BIN": "54284800",
|
|
838
|
+
"issuer_name": "CREDIT MUTUEL ARKEA",
|
|
839
|
+
"country_code": "FR",
|
|
840
|
+
"currency": "",
|
|
841
|
+
"card_type": "Credit",
|
|
842
|
+
"card_category": "",
|
|
843
|
+
"card_scheme": "CARTES BANCAIRES"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"BIN": "54284800",
|
|
847
|
+
"issuer_name": "Credit Mutuel Arkea",
|
|
848
|
+
"country_code": "FR",
|
|
849
|
+
"currency": "",
|
|
850
|
+
"card_type": "Credit",
|
|
851
|
+
"card_category": "Mastercard Standard",
|
|
852
|
+
"card_scheme": "MASTERCARD"
|
|
853
|
+
}
|
|
854
|
+
]
|
|
855
|
+
}
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
### Updating the Card Element with Network Schemes
|
|
859
|
+
```javascript
|
|
860
|
+
const options = {
|
|
861
|
+
required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
|
|
862
|
+
enableCardIcon: true, // Optional, indicates whether a card icon should be enabled (only applicable for CARD_NUMBER ElementType).
|
|
863
|
+
enableCopy: false, // Optional, enables the copy icon to collect elements to copy text to clipboard. Defaults to 'false').
|
|
864
|
+
format: String, // Optional, format for the element
|
|
865
|
+
translation: {}, // Optional, indicates the allowed data type value for format.
|
|
866
|
+
cardMetadata: {}, // Optional, metadata to control card number element behavior. (only applicable for CARD_NUMBER ElementType).
|
|
867
|
+
masking: true, // Optional, indicates whether the input should be masked. Defaults to 'false'.
|
|
868
|
+
maskingChar: '*', // Optional, character used for masking input when masking is enabled. Defaults to '*'.
|
|
869
|
+
};
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
`cardMetadata`: An object of metadata keys to control card number element behavior. It supports an optional key called `scheme`, which accepts an array of Skyflow accept card types based on which SDK will display card brand choice dropdown in the card number element. `Skyflow.CardType` is an enum with all skyflow supported card schemes.
|
|
873
|
+
|
|
874
|
+
```javascript
|
|
875
|
+
import Skyflow from 'skyflow-js'
|
|
876
|
+
|
|
877
|
+
const cardMetadata = {
|
|
878
|
+
scheme: Skyflow.CardType [] // Optional, array of skyflow supported card types.
|
|
879
|
+
}
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
- By default, SDK will populate its own auto-detected card scheme.
|
|
883
|
+
|
|
884
|
+
### Samples
|
|
885
|
+
|
|
886
|
+
- [Card brand choice](https://github.com/skyflowapi/skyflow-js/blob/main/samples/using-script-tag/card-brand-choice.html):
|
|
887
|
+
This sample illustrates how to use Bin Lookup API and display the available card schemes.
|
|
888
|
+
|
|
748
889
|
## Using Skyflow Elements to update data
|
|
749
890
|
|
|
750
891
|
You can update the data in a vault with Skyflow Elements. Use the following steps to securely update data.
|