@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.
@@ -20438,14 +20438,26 @@ const defineMerklizedRootPosition = (metadata, position) => {
20438
20438
  * Returns profile DID based on did and profile nonce
20439
20439
  *
20440
20440
  * @param {DID} [did] - did from which profile will be derived
20441
- * @param {number} [profileNonce] - profile nonce
20441
+ * @param {number | string} [profileNonce] - profile nonce
20442
20442
  * @returns {DID}
20443
20443
  */
20444
20444
  const generateProfileDID = (did, profileNonce) => {
20445
20445
  const id = DID.idFromDID(did);
20446
- const profile = Id$1.profileId(id, BigInt(profileNonce ?? 0));
20446
+ profileNonce = profileNonce ?? 0;
20447
+ if (!isBigInt(profileNonce)) {
20448
+ throw new Error('profile must be number or decimal string');
20449
+ }
20450
+ const profile = Id$1.profileId(id, BigInt(profileNonce));
20447
20451
  return DID.parseFromId(profile);
20448
20452
  };
20453
+ const isBigInt = (x) => {
20454
+ try {
20455
+ return BigInt(x).toString() === x.toString();
20456
+ }
20457
+ catch {
20458
+ return false; // conversion to BigInt failed, surely it is not a BigInt
20459
+ }
20460
+ };
20449
20461
 
20450
20462
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
20451
20463
  // require the crypto API and do not support built-in fallback to lower quality random number