@medialane/sdk 0.106.0 → 0.107.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.
@@ -11811,6 +11811,24 @@ function generateStarkKeyPair() {
11811
11811
  const privateKeyHex = "0x" + Array.from(starknet.ec.starkCurve.utils.randomPrivateKey()).map((b) => b.toString(16).padStart(2, "0")).join("");
11812
11812
  return { privateKeyHex, publicKeyHex: starknet.ec.starkCurve.getStarkKey(privateKeyHex) };
11813
11813
  }
11814
+ var InvalidStarkPrivateKeyError = class extends Error {
11815
+ constructor(reason) {
11816
+ super(`Not a valid Starknet private key: ${reason}`);
11817
+ this.name = "InvalidStarkPrivateKeyError";
11818
+ }
11819
+ };
11820
+ function starkKeyPairFromPrivateKey(input) {
11821
+ const trimmed = input.trim().replace(/\s+/g, "");
11822
+ const body = trimmed.startsWith("0x") || trimmed.startsWith("0X") ? trimmed.slice(2) : trimmed;
11823
+ if (body.length === 0) throw new InvalidStarkPrivateKeyError("it is empty");
11824
+ if (!/^[0-9a-fA-F]+$/.test(body)) throw new InvalidStarkPrivateKeyError("it is not hexadecimal");
11825
+ if (body.length > 64) throw new InvalidStarkPrivateKeyError("it is too long");
11826
+ const value = BigInt("0x" + body);
11827
+ if (value === 0n) throw new InvalidStarkPrivateKeyError("it is zero");
11828
+ if (value >= starknet.ec.starkCurve.CURVE.n) throw new InvalidStarkPrivateKeyError("it is outside the curve order");
11829
+ const privateKeyHex = "0x" + value.toString(16).padStart(64, "0");
11830
+ return { privateKeyHex, publicKeyHex: starknet.ec.starkCurve.getStarkKey(privateKeyHex) };
11831
+ }
11814
11832
  async function sealPrivateKey(aesKey, iv, privateKeyHex) {
11815
11833
  return crypto.subtle.encrypt(
11816
11834
  { name: "AES-GCM", iv },
@@ -11849,6 +11867,7 @@ exports.IPNftABI = IPNftABI;
11849
11867
  exports.IPSponsorshipABI = IPSponsorshipABI;
11850
11868
  exports.IPTicketCollectionABI = IPTicketCollectionABI;
11851
11869
  exports.IPTicketCollectionFactoryABI = IPTicketCollectionFactoryABI;
11870
+ exports.InvalidStarkPrivateKeyError = InvalidStarkPrivateKeyError;
11852
11871
  exports.MAX_HOLDERS_AT_LAUNCH = MAX_HOLDERS_AT_LAUNCH;
11853
11872
  exports.MAX_TEAM_ALLOCATION_PERCENT = MAX_TEAM_ALLOCATION_PERCENT;
11854
11873
  exports.Medialane1155ABI = Medialane1155ABI;
@@ -11918,6 +11937,7 @@ exports.sealPrivateKey = sealPrivateKey;
11918
11937
  exports.sessionKeyHashOf = sessionKeyHashOf;
11919
11938
  exports.signAdminRequest = signAdminRequest;
11920
11939
  exports.signWithPrivateKey = signWithPrivateKey;
11940
+ exports.starkKeyPairFromPrivateKey = starkKeyPairFromPrivateKey;
11921
11941
  exports.storeSiwsToken = storeSiwsToken;
11922
11942
  exports.teamCoinsRaw = teamCoinsRaw;
11923
11943
  exports.toDropContractConditions = toContractConditions;