skyflow-js 1.29.1 → 1.29.3

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,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.29.1] - 2023-06-22
6
+ ### Fixed
7
+ - Patch fix for autofill and iframe loading issue
8
+
9
+ ## [1.29.0] - 2023-06-22
10
+ ### Added
11
+ - Added new `delete` interface
12
+ - Added input formatting for collect and reveal elements
13
+
5
14
  ## [1.28.0] - 2023-03-29
6
15
  ### Added
7
16
  - Update data through collect element using skyflow id
package/README.md CHANGED
@@ -13,6 +13,7 @@ Skyflow’s JavaScript SDK can be used to securely collect, tokenize, and reveal
13
13
  - [**Securely collecting data client-side**](#Securely-collecting-data-client-side)
14
14
  - [**Securely collecting data client-side using Composable Elements**](#Securely-collecting-data-client-side-using-Composable-Elements)
15
15
  - [**Securely revealing data client-side**](#Securely-revealing-data-client-side)
16
+ - [**Securely deleting data cleint-side**](#Securely-deleting-data-client-side)
16
17
 
17
18
  ---
18
19
 
@@ -320,31 +321,62 @@ Along with CollectElement we can define other options which takes a object of op
320
321
  ```javascript
321
322
  const options = {
322
323
  required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
323
- enableCardIcon: true, // Optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType).
324
- format: String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
325
- enableCopy: false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
324
+ enableCardIcon: true, // Optional, indicates whether a card icon should be enabled (only applicable for CARD_NUMBER ElementType).
325
+ enableCopy: false, // Optional, enables the copy icon to collect elements to copy text to clipboard. Defaults to 'false').
326
+ format: String, // Optional, format for the element
327
+ translation: {} // Optional, indicates the allowed data type value for format.
326
328
  };
327
329
  ```
328
330
 
329
- `required` parameter indicates whether the field is marked as required or not. If not provided, it defaults to false
331
+ `required`: Indicates whether the field is marked as required or not. If not provided, it defaults to false.
330
332
 
331
- `enableCardIcon` parameter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
333
+ `enableCardIcon` : Indicates whether the icon is visible for the CARD_NUMBER element. Defaults to true.
332
334
 
333
- `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.
335
+ `enableCopy` : Indicates whether the copy icon is visible in collect and reveal elements.
334
336
 
335
- `enableCopy` parameter indicates whether the copy icon is visible in collect and reveal elements.
337
+ `format`: A string value that indicates the format pattern applicable to the element type.
338
+ Only applicable to EXPIRATION_DATE, CARD_NUMBER, EXPIRATION_YEAR, and INPUT_FIELD elements.
339
+ - For INPUT_FIELD elements,
340
+ - the length of `format` determines the expected length of the user input.
341
+ - if `translation` isn't specified, the `format` value is considered a string literal.
336
342
 
337
- The values that are accepted for `EXPIRATION_DATE` are
338
- - `MM/YY` (default)
339
- - `MM/YYYY`
340
- - `YY/MM`
341
- - `YYYY/MM`
343
+ `translation`: An object of key value pairs, where the key is a character that appears in `format` and the value is a simple regex pattern of acceptable inputs for that character. Each key can only appear once. Only applicable for INPUT_FIELD elements.
342
344
 
343
- The values that are accepted for `EXPIRATION_YEAR` are
344
- - `YY` (default)
345
- - `YYYY`
345
+ Accepted values by element type:
346
346
 
347
- `NOTE`: If not specified or invalid value is passed to the `format` then it takes default value.
347
+ | Element type | `format`and `translation` values | Examples |
348
+ | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
349
+ | EXPIRATION_DATE | <li>`format`</li> <ul><li>`mm/yy` (default)</li><li>`mm/yyyy`</li><li>`yy/mm`</li><li>`yyyy/mm`</li></ul> | <ul><li>12/27</li><li>12/2027</li> <li>27/12</li> <li> 2027/12</li></ul></ul> |
350
+ | EXPIRATION_YEAR | <li>`format`</li> <ul><li>`yy` (default)</li><li>`yyyy`</li></ul> | <ul><li>27</li><li>2027</li></ul> |
351
+ | CARD_NUMBER | <li>`format`</li> <ul><li>`XXXX XXXX XXXX XXXX` (default)</li><li>`XXXX-XXXX-XXXX-XXXX`</li></ul> | <ul><li>1234 5678 9012 3456</li><li>1234-5678-9012-3456</li></ul> |
352
+ | INPUT_FIELD | <li>`format`: A string that matches the desired output, with placeholder characters of your choice.</li><li>`translation`: An object of key/value pairs. Defaults to `{"X": "[0-9]"}`</li> | With a `format` of `+91 XXXX-XX-XXXX` and a `translation` of `[ "X": "[0-9]"]`, user input of "1234121234" displays as "+91 1234-12-1234". |
353
+
354
+ **Collect Element Options examples for INPUT_FIELD**
355
+ Example 1
356
+ ```js
357
+ const options = {
358
+ required: true,
359
+ enableCardIcon: true,
360
+ format:'+91 XXXX-XX-XXXX',
361
+ translation: { 'X': '[0-9]' }
362
+ }
363
+ ```
364
+
365
+ User input: "1234121234"
366
+ Value displayed in INPUT_FIELD: "+91 1234-12-1234"
367
+
368
+ Example 2
369
+ ```js
370
+ const options = {
371
+ required: true,
372
+ enableCardIcon: true,
373
+ format: 'AY XX-XXX-XXXX',
374
+ translation: { 'X': '[0-9]', 'Y': '[A-Z]' }
375
+ }
376
+ ```
377
+
378
+ User input: "B1234121234"
379
+ Value displayed in INPUT_FIELD: "AB 12-341-2123"
348
380
 
349
381
  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:
350
382
 
@@ -365,8 +397,9 @@ const collectElement = {
365
397
  const options = {
366
398
  required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
367
399
  enableCardIcon: true, // Optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType).
368
- format: String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
369
400
  enableCopy: false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
401
+ format: String, // Optional, format for the element
402
+ translation: {}, // Optional, indicates the allowed data type value for format.
370
403
  };
371
404
 
372
405
  const element = container.create(collectElement, options);
@@ -637,8 +670,9 @@ const collectElement = {
637
670
  const options = {
638
671
  required: false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
639
672
  enableCardIcon: true, // Optional, indicates whether the element needs a card icon (only applicable for CARD_NUMBER ElementType).
640
- format: String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
641
673
  enableCopy: false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
674
+ format: String, // Optional, format for the element
675
+ translation: {}, // Optional, indicates the allowed data type value for format.
642
676
  };
643
677
  const element = container.create(collectElement, options);
644
678
  ```
@@ -1949,6 +1983,54 @@ errorTextStyles: {
1949
1983
  },
1950
1984
  ```
1951
1985
 
1986
+ Along with RevealElementInput, you can define other options in the RevealElementOptions object as described below:
1987
+ ```js
1988
+ const options = {
1989
+ enableCopy: false, // Optional, enables the copy icon to reveal elements to copy text to clipboard. Defaults to 'false').
1990
+ format: String, // Optional, format for the element
1991
+ translation: {} // Optional, indicates the allowed data type value for format.
1992
+ }
1993
+ ```
1994
+
1995
+ `format`: A string value that indicates how the reveal element should display the value, including placeholder characters that map to keys `translation` If `translation` isn't specified to any character in the `format` value is considered as a string literal.
1996
+
1997
+ `translation`: An object of key value pairs, where the key is a character that appears in `format` and the value is a simple regex pattern of acceptable inputs for that character. Each key can only appear once. Defaults to `{ ‘X’: ‘[0-9]’ }`.
1998
+
1999
+ **Reveal Element Options examples:**
2000
+ Example 1
2001
+ ```js
2002
+ const revealElementInput = {
2003
+ token: '<token>'
2004
+ };
2005
+
2006
+ const options = {
2007
+ format: '(XXX) XXX-XXXX',
2008
+ translation: { 'X': '[0-9]'}
2009
+ };
2010
+
2011
+ const revealElement = revealContainer.create(revealElementInput,options);
2012
+ ```
2013
+
2014
+ Value from vault: "1234121234"
2015
+ Revealed Value displayed in element: "(123) 412-1234"
2016
+
2017
+ Example 2:
2018
+ ```js
2019
+ const revealElementInput = {
2020
+ token: '<token>'
2021
+ };
2022
+
2023
+ const options = {
2024
+ format: 'XXXX-XXXXXX-XXXXX',
2025
+ translation: { 'X': '[0-9]' }
2026
+ };
2027
+
2028
+ const revealElement = revealContainer.create(revealElementInput,options);
2029
+ ```
2030
+
2031
+ Value from vault: "374200000000004"
2032
+ Revealed Value displayed in element: "3742-000000-00004"
2033
+
1952
2034
  Once you've defined a Skyflow Element, you can use the `create(element)` method of the container to create the Element as shown below:
1953
2035
 
1954
2036
  ```javascript
@@ -2333,6 +2415,62 @@ collectContainer.uploadFiles();
2333
2415
  }
2334
2416
  ```
2335
2417
 
2418
+ ---
2419
+ # Securely deleting data client-side
2420
+ - [**Deleting data from the vault**](#deleting-data-from-the-vault)
2421
+
2422
+ ## Deleting data from the vault
2423
+
2424
+ To delete data from the vault, use the `delete(records, options?)` method of the Skyflow client. The `records` parameter takes an array of records to delete in the following format. The `options` parameter is optional and takes an object of deletion parameters. Currently, there are no supported deletion parameters.
2425
+
2426
+ ```javascript
2427
+ const records = [
2428
+ {
2429
+ id: "<SKYFLOW_ID_1>", // skyflow id of the record to delete
2430
+ table: "<TABLE_NAME>" // Table from which the record is to be deleted
2431
+ },
2432
+ {
2433
+ // ...additional records here
2434
+ },
2435
+ ],
2436
+
2437
+ skyflowClient.delete(records);
2438
+ ```
2439
+
2440
+ An [example](https://github.com/skyflowapi/skyflow-js/blob/master/samples/using-script-tag/delete-pure-js.html) of delete call:
2441
+
2442
+ ```javascript
2443
+ skyflowClient.delete({
2444
+ records: [
2445
+ {
2446
+ id: "29ebda8d-5272-4063-af58-15cc674e332b",
2447
+ table: "cards",
2448
+ },
2449
+ {
2450
+ id: "d5f4b926-7b1a-41df-8fac-7950d2cbd923",
2451
+ table: "cards",
2452
+ }
2453
+ ],
2454
+ });
2455
+ ```
2456
+
2457
+ A sample response:
2458
+
2459
+ ```json
2460
+ {
2461
+ "records": [
2462
+ {
2463
+ "skyflow_id": "29ebda8d-5272-4063-af58-15cc674e332b",
2464
+ "deleted": true,
2465
+ },
2466
+ {
2467
+ "skyflow_id": "29ebda8d-5272-4063-af58-15cc674e332b",
2468
+ "deleted": true,
2469
+ }
2470
+ ]
2471
+ }
2472
+ ```
2473
+
2336
2474
 
2337
2475
  ## Reporting a Vulnerability
2338
2476