@0xpolygonid/js-sdk 1.18.4 → 1.19.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.
@@ -20577,14 +20577,26 @@ var PolygonIdSdk = (function (exports) {
20577
20577
  * Returns profile DID based on did and profile nonce
20578
20578
  *
20579
20579
  * @param {DID} [did] - did from which profile will be derived
20580
- * @param {number} [profileNonce] - profile nonce
20580
+ * @param {number | string} [profileNonce] - profile nonce
20581
20581
  * @returns {DID}
20582
20582
  */
20583
20583
  const generateProfileDID = (did, profileNonce) => {
20584
20584
  const id = Z$2.idFromDID(did);
20585
- const profile = H$2.profileId(id, BigInt(profileNonce ?? 0));
20585
+ profileNonce = profileNonce ?? 0;
20586
+ if (!isBigInt(profileNonce)) {
20587
+ throw new Error('profile must be number or decimal string');
20588
+ }
20589
+ const profile = H$2.profileId(id, BigInt(profileNonce));
20586
20590
  return Z$2.parseFromId(profile);
20587
20591
  };
20592
+ const isBigInt = (x) => {
20593
+ try {
20594
+ return BigInt(x).toString() === x.toString();
20595
+ }
20596
+ catch {
20597
+ return false; // conversion to BigInt failed, surely it is not a BigInt
20598
+ }
20599
+ };
20588
20600
 
20589
20601
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
20590
20602
  // require the crypto API and do not support built-in fallback to lower quality random number