@sesamy/sesamy-js 1.40.5 → 1.41.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 CHANGED
@@ -431,14 +431,14 @@ The following example demonstrates how to check if a user is currently authentic
431
431
  import { isAuthenticated } from '@sesamy/sesamy-js';
432
432
 
433
433
  isAuthenticated()
434
- .then(isAuth => {
434
+ .then((isAuth) => {
435
435
  if (isAuth) {
436
436
  console.log('User is authenticated.');
437
437
  } else {
438
438
  console.log('User is not authenticated.');
439
439
  }
440
440
  })
441
- .catch(error => {
441
+ .catch((error) => {
442
442
  console.error('Error checking authentication status:', error);
443
443
  });
444
444
  ```
@@ -485,7 +485,7 @@ login(loginOptions)
485
485
  .then(() => {
486
486
  console.log('Login initiated successfully');
487
487
  })
488
- .catch(error => {
488
+ .catch((error) => {
489
489
  console.error('Login failed:', error);
490
490
  });
491
491
  ```
@@ -571,7 +571,7 @@ The following example demonstrates how to use `loginWithPopup` and prevent the a
571
571
  import { loginWithPopup } from '@sesamy/sesamy-js';
572
572
 
573
573
  // Listen for authentication event to prevent page refresh
574
- window.addEventListener('sesamyJsAuthenticated', event => {
574
+ window.addEventListener('sesamyJsAuthenticated', (event) => {
575
575
  // Prevent the automatic page refresh
576
576
  event.preventDefault();
577
577
 
@@ -593,7 +593,7 @@ loginWithPopup(loginOptions)
593
593
  .then(() => {
594
594
  console.log('Popup login completed');
595
595
  })
596
- .catch(error => {
596
+ .catch((error) => {
597
597
  console.error('Popup login failed:', error);
598
598
  });
599
599
  ```
@@ -632,14 +632,13 @@ const logoutOptions = {
632
632
  logout(logoutOptions);
633
633
  ```
634
634
 
635
- ## `setToken(accessToken: string, expiresIn?: number)`
635
+ ## `setToken(accessToken: string)`
636
636
 
637
- Stores the provided access token in local storage and optionally sets an expiration time for it. Additionally, this function parses the access token to extract user information and triggers an authentication event.
637
+ Stores the provided access token in local storage. This function parses the access token to extract user information and triggers an authentication event.
638
638
 
639
639
  ### Parameters
640
640
 
641
641
  - `accessToken` (string): The access token to store and use for session management.
642
- - `expiresIn` (optional, number): The time in seconds from now when the token should expire.
643
642
 
644
643
  ### Returns
645
644
 
@@ -647,20 +646,19 @@ This function does not return a value but triggers an event indicating that a us
647
646
 
648
647
  ### Example
649
648
 
650
- The following example demonstrates how to store an access token and set an expiration time:
649
+ The following example demonstrates how to store an access token:
651
650
 
652
651
  ```javascript
653
652
  import { setToken } from '@sesamy/sesamy-js';
654
653
 
655
- // Example access token and expiration period
654
+ // Example access token
656
655
  const accessToken = 'your.access.token';
657
- const expiresIn = 3600; // 1 hour in seconds
658
656
 
659
- setToken(accessToken, expiresIn)
657
+ setToken(accessToken)
660
658
  .then(() => {
661
659
  console.log('Token set successfully and user authenticated.');
662
660
  })
663
- .catch(error => {
661
+ .catch((error) => {
664
662
  console.error('Failed to set token:', error);
665
663
  });
666
664
  ```
@@ -685,14 +683,14 @@ import { getTokenSilently } from '@sesamy/sesamy-js';
685
683
 
686
684
  // Get the current access token
687
685
  getTokenSilently()
688
- .then(token => {
686
+ .then((token) => {
689
687
  if (token) {
690
688
  console.log('Access token:', token);
691
689
  } else {
692
690
  console.log('No access token available');
693
691
  }
694
692
  })
695
- .catch(error => {
693
+ .catch((error) => {
696
694
  console.error('Error retrieving token:', error);
697
695
  });
698
696
  ```
@@ -723,14 +721,14 @@ Fetches a specific entitlement by its ID.
723
721
  // Fetch a specific entitlement by its ID
724
722
  window.sesamy.entitlements
725
723
  .get('entitlement-id')
726
- .then(entitlement => {
724
+ .then((entitlement) => {
727
725
  if (entitlement) {
728
726
  console.log('Entitlement:', entitlement);
729
727
  } else {
730
728
  console.log('Entitlement not found');
731
729
  }
732
730
  })
733
- .catch(error => {
731
+ .catch((error) => {
734
732
  console.error('Error fetching entitlement:', error);
735
733
  });
736
734
  ```
@@ -757,10 +755,10 @@ Fetches the list of entitlements, with optional filters and inclusion of signed
757
755
  // Fetch all entitlements, including signed links
758
756
  window.sesamy.entitlements
759
757
  .list({ includeSignedLinks: true })
760
- .then(entitlements => {
758
+ .then((entitlements) => {
761
759
  console.log('Entitlements:', entitlements);
762
760
  })
763
- .catch(error => {
761
+ .catch((error) => {
764
762
  console.error('Error fetching entitlements:', error);
765
763
  });
766
764
  ```
@@ -785,10 +783,10 @@ Fetches the access details for a specific entitlement by its ID.
785
783
  // Fetch access details for a specific entitlement
786
784
  window.sesamy.entitlements
787
785
  .access('entitlement-id')
788
- .then(access => {
786
+ .then((access) => {
789
787
  console.log('Access details:', access);
790
788
  })
791
- .catch(error => {
789
+ .catch((error) => {
792
790
  console.error('Error fetching entitlement access:', error);
793
791
  });
794
792
  ```
@@ -848,14 +846,14 @@ import { getProfile } from '@sesamy/sesamy-js';
848
846
 
849
847
  // Fetch the user's profile information
850
848
  getProfile()
851
- .then(profile => {
849
+ .then((profile) => {
852
850
  if (profile) {
853
851
  console.log('User profile:', profile);
854
852
  } else {
855
853
  console.log('User is not authenticated');
856
854
  }
857
855
  })
858
- .catch(error => {
856
+ .catch((error) => {
859
857
  console.error('Error fetching profile:', error);
860
858
  });
861
859
  ```
@@ -924,14 +922,14 @@ const updatedProfile = {
924
922
 
925
923
  // Update the user's profile information
926
924
  updateProfile(updatedProfile)
927
- .then(success => {
925
+ .then((success) => {
928
926
  if (success) {
929
927
  console.log('Profile updated successfully');
930
928
  } else {
931
929
  console.log('Profile update failed');
932
930
  }
933
931
  })
934
- .catch(error => {
932
+ .catch((error) => {
935
933
  console.error('Error updating profile:', error);
936
934
  });
937
935
  ```
@@ -1020,10 +1018,10 @@ const linkParams = {
1020
1018
  };
1021
1019
 
1022
1020
  generateLink(linkParams)
1023
- .then(link => {
1021
+ .then((link) => {
1024
1022
  console.log('Generated link:', link);
1025
1023
  })
1026
- .catch(error => {
1024
+ .catch((error) => {
1027
1025
  console.error('Error generating link:', error);
1028
1026
  });
1029
1027
  ```
@@ -1044,10 +1042,10 @@ const linkParams = {
1044
1042
  };
1045
1043
 
1046
1044
  generateLink(linkParams)
1047
- .then(link => {
1045
+ .then((link) => {
1048
1046
  console.log('Generated link:', link);
1049
1047
  })
1050
- .catch(error => {
1048
+ .catch((error) => {
1051
1049
  console.error('Error generating link:', error);
1052
1050
  });
1053
1051
  ```
@@ -1063,16 +1061,18 @@ Creates a checkout session with Sesamy. This function initializes a checkout pro
1063
1061
  - sku (string): The SKU of the product to be purchased.
1064
1062
  - purchaseOptionsId (string, optional): The ID of the purchase options for the product.
1065
1063
  - language (string, optional): The language for the checkout session. If not set, it will be automatically fetched from the HTML element's `lang` attribute.
1066
- - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
1064
+ - redirectUrl (string): The URL to redirect to after the checkout process is completed.
1065
+ - givenName (string, optional): The given name of the customer.
1066
+ - familyName (string, optional): The family name of the customer.
1067
+ - email (string, optional): The email address of the customer.
1068
+ - phoneNumber (string, optional): The phone number of the customer.
1069
+ - birthDate (string, optional): The birth date of the customer.
1070
+ - country (string, optional): The country of the customer.
1067
1071
  - address (Address, optional): The address for the checkout session.
1068
- - givenName: (string): The given name.
1069
- - familyName: (string): The family name.
1070
- - street (string): The street address.
1071
- - city (string): The city.
1072
- - zip (string): The postal code.
1073
- - country (string): The country.
1074
- - phoneNumber (string, optional): The phone number.
1075
- - email (string, optional): The email address.
1072
+ - street (string, optional): The street address.
1073
+ - city (string, optional): The city.
1074
+ - zip (string, optional): The postal code.
1075
+ - country (string, optional): The country.
1076
1076
  - isBusiness (boolean, optional): Indicates if the checkout is for a business.
1077
1077
  - paymentMethodsFilter (Array of objects, optional): The payment methods to be available in the checkout. The payment methods are an object with a provider and a method property, where the method is an optional array.
1078
1078
 
@@ -1087,10 +1087,10 @@ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object
1087
1087
  - status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
1088
1088
  - createdAt (string): The creation timestamp of the checkout session.
1089
1089
  - modifiedAt (string): The last modified timestamp of the checkout session.
1090
- - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
1090
+ - type (enum): The type of checkout session, can be 'RECURRING' or 'SINGLE'.
1091
1091
  - currency (string): The currency used for the checkout session.
1092
1092
  - country (string): The country associated with the checkout session.
1093
- - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
1093
+ - redirectUrl (string): The URL to redirect to after the checkout process is completed.
1094
1094
  - email (string, optional): The email address for the checkout session.
1095
1095
  - language (string): The language used for the checkout session.
1096
1096
  - items (Array of objects): The items included in the checkout session.
@@ -1123,10 +1123,10 @@ const checkoutParams = {
1123
1123
  };
1124
1124
 
1125
1125
  createCheckout(checkoutParams)
1126
- .then(response => {
1126
+ .then((response) => {
1127
1127
  console.log('Checkout session created:', response);
1128
1128
  })
1129
- .catch(error => {
1129
+ .catch((error) => {
1130
1130
  console.error('Error creating checkout session:', error);
1131
1131
  });
1132
1132
  ```
@@ -1151,17 +1151,18 @@ Updates a checkout session with Sesamy.
1151
1151
  - sku (string): The SKU of the product to be purchased.
1152
1152
  - purchaseOptionsId (string, optional): The ID of the purchase options for the product.
1153
1153
  - language (string, optional): The language for the checkout session.
1154
- - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
1154
+ - redirectUrl (string): The URL to redirect to after the checkout process is completed.
1155
+ - givenName (string, optional): The given name of the customer.
1156
+ - familyName (string, optional): The family name of the customer.
1155
1157
  - email (string, optional): The email address for the checkout session.
1158
+ - phoneNumber (string, optional): The phone number of the customer.
1159
+ - birthDate (string, optional): The birth date of the customer.
1160
+ - country (string, optional): The country of the customer.
1156
1161
  - address (Address, optional): The address for the checkout session.
1157
- - givenName: (string): The given name.
1158
- - familyName: (string): The family name.
1159
- - street (string): The street address.
1160
- - city (string): The city.
1161
- - zip (string): The postal code.
1162
- - country (string): The country.
1163
- - phoneNumber (string, optional): The phone number.
1164
- - email (string, optional): The email address.
1162
+ - street (string, optional): The street address.
1163
+ - city (string, optional): The city.
1164
+ - zip (string, optional): The postal code.
1165
+ - country (string, optional): The country.
1165
1166
  - isBusiness (boolean, optional): Indicates if the checkout is for a business.
1166
1167
 
1167
1168
  ### Returns
@@ -1175,7 +1176,7 @@ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object
1175
1176
  - status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
1176
1177
  - createdAt (string): The creation timestamp of the checkout session.
1177
1178
  - modifiedAt (string): The last modified timestamp of the checkout session.
1178
- - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
1179
+ - type (enum): The type of checkout session, can be 'RECURRING' or 'SINGLE'.
1179
1180
  - currency (string): The currency used for the checkout session.
1180
1181
  - country (string): The country associated with the checkout session.
1181
1182
  - language (string): The language used for the checkout session.
@@ -1203,10 +1204,10 @@ const checkoutParams = {
1203
1204
  };
1204
1205
 
1205
1206
  updateCheckout('checkoutId', checkoutParams)
1206
- .then(response => {
1207
+ .then((response) => {
1207
1208
  console.log('Checkout session updated:', response);
1208
1209
  })
1209
- .catch(error => {
1210
+ .catch((error) => {
1210
1211
  console.error('Error updating checkout session:', error);
1211
1212
  });
1212
1213
  ```
@@ -1239,7 +1240,7 @@ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object
1239
1240
  - status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
1240
1241
  - createdAt (string): The creation timestamp of the checkout session.
1241
1242
  - modifiedAt (string): The last modified timestamp of the checkout session.
1242
- - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
1243
+ - type (enum): The type of checkout session, can be 'RECURRING' or 'SINGLE'.
1243
1244
  - currency (string): The currency used for the checkout session.
1244
1245
  - country (string): The country associated with the checkout session.
1245
1246
  - language (string): The language used for the checkout session.
@@ -1265,10 +1266,10 @@ import { getCheckout } from '@sesamy/sesamy-js';
1265
1266
  const checkoutId = 'checkout-session-id';
1266
1267
 
1267
1268
  getCheckout(checkoutId)
1268
- .then(response => {
1269
+ .then((response) => {
1269
1270
  console.log('Checkout session details:', response);
1270
1271
  })
1271
- .catch(error => {
1272
+ .catch((error) => {
1272
1273
  console.error('Error retrieving checkout session:', error);
1273
1274
  });
1274
1275
  ```
@@ -1304,14 +1305,14 @@ import { detectAdblock } from '@sesamy/sesamy-js';
1304
1305
 
1305
1306
  // Detect if an ad blocker is enabled
1306
1307
  detectAdblock()
1307
- .then(isAdblockEnabled => {
1308
+ .then((isAdblockEnabled) => {
1308
1309
  if (isAdblockEnabled) {
1309
1310
  console.log('Adblocker is enabled');
1310
1311
  } else {
1311
1312
  console.log('Adblocker is not enabled');
1312
1313
  }
1313
1314
  })
1314
- .catch(error => {
1315
+ .catch((error) => {
1315
1316
  console.error('Error detecting adblock:', error);
1316
1317
  });
1317
1318
  ```
@@ -1373,7 +1374,7 @@ The following example demonstrates how to use the `detectAndCacheIncognito` func
1373
1374
  import { detectAndCacheIncognito, isIncognito } from '@sesamy/sesamy-js';
1374
1375
 
1375
1376
  // Detect and cache incognito status (typically called once during app initialization)
1376
- detectAndCacheIncognito().then(isIncognitoEnabled => {
1377
+ detectAndCacheIncognito().then((isIncognitoEnabled) => {
1377
1378
  if (isIncognitoEnabled) {
1378
1379
  console.log('Incognito mode detected and cached');
1379
1380
  } else {
@@ -1706,7 +1707,7 @@ Retrieves the value of a specific feature flag.
1706
1707
 
1707
1708
  ```javascript
1708
1709
  // Check if a specific feature flag is enabled
1709
- window.sesamy.flags.get('my-feature-flag').then(value => {
1710
+ window.sesamy.flags.get('my-feature-flag').then((value) => {
1710
1711
  if (value === true) {
1711
1712
  console.log('Feature is enabled');
1712
1713
  } else {
@@ -1754,7 +1755,7 @@ Retrieves all feature flags.
1754
1755
 
1755
1756
  ```javascript
1756
1757
  // List all feature flags
1757
- window.sesamy.flags.list().then(flags => {
1758
+ window.sesamy.flags.list().then((flags) => {
1758
1759
  console.log('All feature flags:', flags);
1759
1760
  });
1760
1761
  ```
@@ -1809,10 +1810,10 @@ window.sesamy.amendments
1809
1810
  discountCode: 'SUMMER2023',
1810
1811
  amendmentType: 'DISCOUNT',
1811
1812
  })
1812
- .then(amendment => {
1813
+ .then((amendment) => {
1813
1814
  console.log('Amendment created:', amendment);
1814
1815
  })
1815
- .catch(error => {
1816
+ .catch((error) => {
1816
1817
  console.error('Error creating amendment:', error);
1817
1818
  });
1818
1819
  ```
@@ -1835,12 +1836,12 @@ Confirms a previously created amendment.
1835
1836
  // Confirm an amendment
1836
1837
  window.sesamy.amendments
1837
1838
  .confirm('amendment-123')
1838
- .then(success => {
1839
+ .then((success) => {
1839
1840
  if (success) {
1840
1841
  console.log('Amendment confirmed successfully');
1841
1842
  }
1842
1843
  })
1843
- .catch(error => {
1844
+ .catch((error) => {
1844
1845
  console.error('Error confirming amendment:', error);
1845
1846
  });
1846
1847
  ```
@@ -1867,12 +1868,12 @@ Retrieves detailed information about a product by its SKU.
1867
1868
  // Get product information by SKU
1868
1869
  window.sesamy.products
1869
1870
  .get('sid:eUv45QXTrcGNhMJpaCQNe')
1870
- .then(product => {
1871
+ .then((product) => {
1871
1872
  console.log('Product details:', product);
1872
1873
  console.log('Product name:', product.name);
1873
1874
  console.log('Product price:', product.price);
1874
1875
  })
1875
- .catch(error => {
1876
+ .catch((error) => {
1876
1877
  console.error('Error fetching product:', error);
1877
1878
  });
1878
1879
  ```
@@ -1895,12 +1896,12 @@ Triggers the auto-onboarding process for a product by SKU, which helps users get
1895
1896
  // Trigger auto-onboarding for a product
1896
1897
  window.sesamy.products
1897
1898
  .autoOnboard('sid:eUv45QXTrcGNhMJpaCQNe')
1898
- .then(success => {
1899
+ .then((success) => {
1899
1900
  if (success) {
1900
1901
  console.log('Auto-onboarding process initiated successfully');
1901
1902
  }
1902
1903
  })
1903
- .catch(error => {
1904
+ .catch((error) => {
1904
1905
  console.error('Error triggering auto-onboarding:', error);
1905
1906
  });
1906
1907
  ```
@@ -1919,12 +1920,12 @@ Links a user's Spotify account to enable Sesamy products that integrate with Spo
1919
1920
  // Link the user's Spotify account
1920
1921
  window.sesamy.products
1921
1922
  .linkSpotify()
1922
- .then(success => {
1923
+ .then((success) => {
1923
1924
  if (success) {
1924
1925
  console.log('Spotify account linked successfully');
1925
1926
  }
1926
1927
  })
1927
- .catch(error => {
1928
+ .catch((error) => {
1928
1929
  console.error('Error linking Spotify account:', error);
1929
1930
  });
1930
1931
  ```
@@ -1947,10 +1948,10 @@ Fetches all tags associated with the current user.
1947
1948
  // Get all tags for the current user
1948
1949
  window.sesamy.tags
1949
1950
  .list()
1950
- .then(tags => {
1951
+ .then((tags) => {
1951
1952
  console.log('User tags:', tags);
1952
1953
  })
1953
- .catch(error => {
1954
+ .catch((error) => {
1954
1955
  console.error('Error fetching tags:', error);
1955
1956
  });
1956
1957
  ```
@@ -1973,12 +1974,12 @@ Sets a tag for the current user. If the tag already exists, it won't create a du
1973
1974
  // Set a tag for the current user
1974
1975
  window.sesamy.tags
1975
1976
  .set('premium-subscriber')
1976
- .then(success => {
1977
+ .then((success) => {
1977
1978
  if (success) {
1978
1979
  console.log('Tag set successfully');
1979
1980
  }
1980
1981
  })
1981
- .catch(error => {
1982
+ .catch((error) => {
1982
1983
  console.error('Error setting tag:', error);
1983
1984
  });
1984
1985
  ```
@@ -2001,12 +2002,12 @@ Deletes a specific tag from the current user.
2001
2002
  // Delete a tag from the current user
2002
2003
  window.sesamy.tags
2003
2004
  .delete('trial-user')
2004
- .then(success => {
2005
+ .then((success) => {
2005
2006
  if (success) {
2006
2007
  console.log('Tag deleted successfully');
2007
2008
  }
2008
2009
  })
2009
- .catch(error => {
2010
+ .catch((error) => {
2010
2011
  console.error('Error deleting tag:', error);
2011
2012
  });
2012
2013
  ```
@@ -2029,10 +2030,10 @@ Lists all tallies for the current user.
2029
2030
  // List all tallies for the current user
2030
2031
  window.sesamy.tallies
2031
2032
  .list()
2032
- .then(tallies => {
2033
+ .then((tallies) => {
2033
2034
  console.log('User tallies:', tallies);
2034
2035
  })
2035
- .catch(error => {
2036
+ .catch((error) => {
2036
2037
  console.error('Error listing tallies:', error);
2037
2038
  });
2038
2039
  ```
@@ -2055,11 +2056,11 @@ Retrieves a specific tally by its ID.
2055
2056
  // Get a specific tally by ID
2056
2057
  window.sesamy.tallies
2057
2058
  .get('article-views')
2058
- .then(tally => {
2059
+ .then((tally) => {
2059
2060
  console.log('Tally:', tally);
2060
2061
  console.log('Current count:', tally.count);
2061
2062
  })
2062
- .catch(error => {
2063
+ .catch((error) => {
2063
2064
  console.error('Error getting tally:', error);
2064
2065
  });
2065
2066
  ```
@@ -2083,11 +2084,11 @@ Adds an item to a specific tally, incrementing its count.
2083
2084
  // Increment an article view tally
2084
2085
  window.sesamy.tallies
2085
2086
  .push('article-views', { articleId: 'sid:eUv45QXTrcGNhMJpaCQNe', timestamp: new Date() })
2086
- .then(updatedTally => {
2087
+ .then((updatedTally) => {
2087
2088
  console.log('Updated tally:', updatedTally);
2088
2089
  console.log('New count:', updatedTally.count);
2089
2090
  })
2090
- .catch(error => {
2091
+ .catch((error) => {
2091
2092
  console.error('Error updating tally:', error);
2092
2093
  });
2093
2094
  ```
@@ -2110,12 +2111,12 @@ Deletes a specific tally by its ID.
2110
2111
  // Delete a specific tally
2111
2112
  window.sesamy.tallies
2112
2113
  .delete('article-views')
2113
- .then(success => {
2114
+ .then((success) => {
2114
2115
  if (success) {
2115
2116
  console.log('Tally deleted successfully');
2116
2117
  }
2117
2118
  })
2118
- .catch(error => {
2119
+ .catch((error) => {
2119
2120
  console.error('Error deleting tally:', error);
2120
2121
  });
2121
2122
  ```
@@ -2138,10 +2139,10 @@ Lists all metadata items for the current user.
2138
2139
  // List all user metadata
2139
2140
  window.sesamy.userMetadata
2140
2141
  .list()
2141
- .then(metadata => {
2142
+ .then((metadata) => {
2142
2143
  console.log('User metadata:', metadata);
2143
2144
  })
2144
- .catch(error => {
2145
+ .catch((error) => {
2145
2146
  console.error('Error listing user metadata:', error);
2146
2147
  });
2147
2148
  ```
@@ -2164,10 +2165,10 @@ Retrieves a specific metadata item by its ID.
2164
2165
  // Get a specific metadata item
2165
2166
  window.sesamy.userMetadata
2166
2167
  .get('preferences')
2167
- .then(value => {
2168
+ .then((value) => {
2168
2169
  console.log('User preferences:', value);
2169
2170
  })
2170
- .catch(error => {
2171
+ .catch((error) => {
2171
2172
  console.error('Error getting metadata:', error);
2172
2173
  });
2173
2174
  ```
@@ -2191,12 +2192,12 @@ Sets a metadata item for the current user.
2191
2192
  // Set a user preference metadata item
2192
2193
  window.sesamy.userMetadata
2193
2194
  .set('preferences', { theme: 'dark', fontSize: 'large' })
2194
- .then(success => {
2195
+ .then((success) => {
2195
2196
  if (success) {
2196
2197
  console.log('User preferences saved successfully');
2197
2198
  }
2198
2199
  })
2199
- .catch(error => {
2200
+ .catch((error) => {
2200
2201
  console.error('Error setting metadata:', error);
2201
2202
  });
2202
2203
  ```
@@ -2219,12 +2220,12 @@ Deletes a specific metadata item by its ID.
2219
2220
  // Delete a metadata item
2220
2221
  window.sesamy.userMetadata
2221
2222
  .delete('temporary-setting')
2222
- .then(success => {
2223
+ .then((success) => {
2223
2224
  if (success) {
2224
2225
  console.log('Metadata item deleted successfully');
2225
2226
  }
2226
2227
  })
2227
- .catch(error => {
2228
+ .catch((error) => {
2228
2229
  console.error('Error deleting metadata:', error);
2229
2230
  });
2230
2231
  ```
@@ -2247,12 +2248,12 @@ Fetches settings for the current vendor based on the authenticated user context.
2247
2248
  // Get current vendor settings
2248
2249
  window.sesamy.vendors
2249
2250
  .get()
2250
- .then(settings => {
2251
+ .then((settings) => {
2251
2252
  console.log('Vendor settings:', settings);
2252
2253
  console.log('Vendor name:', settings.name);
2253
2254
  console.log('Vendor currency:', settings.currency);
2254
2255
  })
2255
- .catch(error => {
2256
+ .catch((error) => {
2256
2257
  console.error('Error fetching vendor settings:', error);
2257
2258
  });
2258
2259
  ```
@@ -2271,14 +2272,14 @@ Lists all publishers connected to the user. This method is not available for pub
2271
2272
  // List all vendors connected to the user
2272
2273
  window.sesamy.vendors
2273
2274
  .list()
2274
- .then(vendors => {
2275
+ .then((vendors) => {
2275
2276
  console.log('Connected vendors:', vendors);
2276
- vendors.forEach(vendor => {
2277
+ vendors.forEach((vendor) => {
2277
2278
  console.log('Vendor name:', vendor.name);
2278
2279
  console.log('Vendor ID:', vendor.id);
2279
2280
  });
2280
2281
  })
2281
- .catch(error => {
2282
+ .catch((error) => {
2282
2283
  console.error('Error listing vendors:', error);
2283
2284
  });
2284
2285
  ```
@@ -2301,15 +2302,15 @@ Lists all contracts associated with the current user.
2301
2302
  // List all user contracts
2302
2303
  window.sesamy.contracts
2303
2304
  .list()
2304
- .then(contracts => {
2305
+ .then((contracts) => {
2305
2306
  console.log('User contracts:', contracts);
2306
- contracts.forEach(contract => {
2307
+ contracts.forEach((contract) => {
2307
2308
  console.log('Contract ID:', contract.id);
2308
2309
  console.log('Contract status:', contract.status);
2309
2310
  console.log('Contract start date:', contract.startDate);
2310
2311
  });
2311
2312
  })
2312
- .catch(error => {
2313
+ .catch((error) => {
2313
2314
  console.error('Error listing contracts:', error);
2314
2315
  });
2315
2316
  ```
@@ -2332,12 +2333,12 @@ Retrieves a specific contract by its ID.
2332
2333
  // Get a specific contract by ID
2333
2334
  window.sesamy.contracts
2334
2335
  .get('contract-123')
2335
- .then(contract => {
2336
+ .then((contract) => {
2336
2337
  console.log('Contract details:', contract);
2337
2338
  console.log('Contract status:', contract.status);
2338
2339
  console.log('Contract type:', contract.type);
2339
2340
  })
2340
- .catch(error => {
2341
+ .catch((error) => {
2341
2342
  console.error('Error fetching contract:', error);
2342
2343
  });
2343
2344
  ```
@@ -2360,11 +2361,11 @@ Cancels a specific contract by its ID.
2360
2361
  // Cancel a contract
2361
2362
  window.sesamy.contracts
2362
2363
  .cancel('contract-123')
2363
- .then(contract => {
2364
+ .then((contract) => {
2364
2365
  console.log('Contract canceled successfully');
2365
2366
  console.log('Updated contract status:', contract.status);
2366
2367
  })
2367
- .catch(error => {
2368
+ .catch((error) => {
2368
2369
  console.error('Error canceling contract:', error);
2369
2370
  });
2370
2371
  ```
@@ -2387,16 +2388,16 @@ Lists all bills associated with the current user.
2387
2388
  // List all user bills
2388
2389
  window.sesamy.bills
2389
2390
  .list()
2390
- .then(bills => {
2391
+ .then((bills) => {
2391
2392
  console.log('User bills:', bills);
2392
- bills.forEach(bill => {
2393
+ bills.forEach((bill) => {
2393
2394
  console.log('Bill ID:', bill.id);
2394
2395
  console.log('Amount:', bill.amount);
2395
2396
  console.log('Due date:', bill.dueDate);
2396
2397
  console.log('Status:', bill.status);
2397
2398
  });
2398
2399
  })
2399
- .catch(error => {
2400
+ .catch((error) => {
2400
2401
  console.error('Error listing bills:', error);
2401
2402
  });
2402
2403
  ```
@@ -2419,13 +2420,13 @@ Retrieves a specific bill by its ID.
2419
2420
  // Get a specific bill by ID
2420
2421
  window.sesamy.bills
2421
2422
  .get('bill-123')
2422
- .then(bill => {
2423
+ .then((bill) => {
2423
2424
  console.log('Bill details:', bill);
2424
2425
  console.log('Amount:', bill.amount);
2425
2426
  console.log('Status:', bill.status);
2426
2427
  console.log('Due date:', bill.dueDate);
2427
2428
  })
2428
- .catch(error => {
2429
+ .catch((error) => {
2429
2430
  console.error('Error fetching bill:', error);
2430
2431
  });
2431
2432
  ```
@@ -2448,16 +2449,16 @@ Lists all transactions associated with the current user.
2448
2449
  // List all user transactions
2449
2450
  window.sesamy.transactions
2450
2451
  .list()
2451
- .then(transactions => {
2452
+ .then((transactions) => {
2452
2453
  console.log('User transactions:', transactions);
2453
- transactions.forEach(transaction => {
2454
+ transactions.forEach((transaction) => {
2454
2455
  console.log('Transaction ID:', transaction.id);
2455
2456
  console.log('Amount:', transaction.amount);
2456
2457
  console.log('Date:', transaction.createdAt);
2457
2458
  console.log('Status:', transaction.status);
2458
2459
  });
2459
2460
  })
2460
- .catch(error => {
2461
+ .catch((error) => {
2461
2462
  console.error('Error listing transactions:', error);
2462
2463
  });
2463
2464
  ```
@@ -2480,13 +2481,13 @@ Retrieves a specific transaction by its ID.
2480
2481
  // Get a specific transaction by ID
2481
2482
  window.sesamy.transactions
2482
2483
  .get('transaction-123')
2483
- .then(transaction => {
2484
+ .then((transaction) => {
2484
2485
  console.log('Transaction details:', transaction);
2485
2486
  console.log('Amount:', transaction.amount);
2486
2487
  console.log('Status:', transaction.status);
2487
2488
  console.log('Date:', transaction.createdAt);
2488
2489
  })
2489
- .catch(error => {
2490
+ .catch((error) => {
2490
2491
  console.error('Error fetching transaction:', error);
2491
2492
  });
2492
2493
  ```
@@ -2571,7 +2572,7 @@ Cancels an event with an optional message explaining the reason.
2571
2572
 
2572
2573
  ```javascript
2573
2574
  // Listen for a cancelable event
2574
- window.addEventListener('purchase-initiated', event => {
2575
+ window.addEventListener('purchase-initiated', (event) => {
2575
2576
  // Check if user already owns the product
2576
2577
  if (userOwnsProduct(event.detail.data.productId)) {
2577
2578
  // Cancel the event with a message