@medialane/sdk 0.140.0 → 0.142.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/dist/{errors-CMjZp66y.d.cts → errors-BRCRmVep.d.cts} +15 -3
- package/dist/{errors-CtXjdRsL.d.ts → errors-DP-VnOWP.d.ts} +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +52 -10
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +21 -5
- package/dist/starknet/index.d.ts +21 -5
- package/dist/starknet/index.js +48 -10
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -12721,12 +12721,38 @@ function parseAccountAddress(input) {
|
|
|
12721
12721
|
}
|
|
12722
12722
|
|
|
12723
12723
|
// src/wallet/recovery-key.ts
|
|
12724
|
-
|
|
12724
|
+
var PREFIX = "medialane-recovery:v1:";
|
|
12725
|
+
var ADDRESS = /^0x[0-9a-fA-F]{1,64}$/;
|
|
12726
|
+
var InvalidRecoveryKeyError = class extends Error {
|
|
12727
|
+
constructor(message = "This is not a valid recovery key.") {
|
|
12728
|
+
super(message);
|
|
12729
|
+
this.name = "InvalidRecoveryKeyError";
|
|
12730
|
+
}
|
|
12731
|
+
};
|
|
12732
|
+
var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
|
|
12733
|
+
function keyPair(privateKey) {
|
|
12725
12734
|
try {
|
|
12726
|
-
return
|
|
12735
|
+
return starkKeyPairFromPrivateKey(privateKey);
|
|
12727
12736
|
} catch {
|
|
12728
|
-
|
|
12737
|
+
throw new InvalidRecoveryKeyError();
|
|
12738
|
+
}
|
|
12739
|
+
}
|
|
12740
|
+
function encodeRecoveryKey(key) {
|
|
12741
|
+
if (!ADDRESS.test(key.walletAddress) || BigInt(key.walletAddress) === 0n) throw new InvalidRecoveryKeyError();
|
|
12742
|
+
return `${PREFIX}${canonicalAddress(key.walletAddress)}:${keyPair(key.privateKey).privateKeyHex}`;
|
|
12743
|
+
}
|
|
12744
|
+
function parseRecoveryKey(input) {
|
|
12745
|
+
const trimmed = input.trim();
|
|
12746
|
+
if (!trimmed.startsWith(PREFIX)) {
|
|
12747
|
+
const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
|
|
12748
|
+
return { walletAddress: computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
|
|
12749
|
+
}
|
|
12750
|
+
const parts = trimmed.slice(PREFIX.length).split(":");
|
|
12751
|
+
const [walletAddress, privateKey] = parts;
|
|
12752
|
+
if (parts.length !== 2 || !walletAddress || !privateKey || !ADDRESS.test(walletAddress) || BigInt(walletAddress) === 0n) {
|
|
12753
|
+
throw new InvalidRecoveryKeyError();
|
|
12729
12754
|
}
|
|
12755
|
+
return { walletAddress: canonicalAddress(walletAddress), privateKey: keyPair(privateKey).privateKeyHex };
|
|
12730
12756
|
}
|
|
12731
12757
|
|
|
12732
12758
|
// src/wallet/guardian-status.ts
|
|
@@ -12894,21 +12920,18 @@ function createPasskeyOwner(config) {
|
|
|
12894
12920
|
const aes = await deriveAesKey(secret, config.hkdfInfo);
|
|
12895
12921
|
return unsealPrivateKey(aes, decodeBase64(sealed.iv), decodeBase64(sealed.ciphertext));
|
|
12896
12922
|
},
|
|
12897
|
-
async sealImportedOwnerKey(
|
|
12898
|
-
const { privateKeyHex, publicKeyHex } = starkKeyPairFromPrivateKey(
|
|
12923
|
+
async sealImportedOwnerKey(recovery) {
|
|
12924
|
+
const { privateKeyHex, publicKeyHex } = starkKeyPairFromPrivateKey(recovery.privateKey);
|
|
12899
12925
|
const registration = await registerPasskey();
|
|
12900
12926
|
const secret = await secretFromRegistration(registration);
|
|
12901
12927
|
const { iv, ciphertext } = await seal(secret, privateKeyHex);
|
|
12902
12928
|
return {
|
|
12903
12929
|
credentialId: registration.credentialId,
|
|
12904
12930
|
ownerPubKey: publicKeyHex,
|
|
12905
|
-
address:
|
|
12931
|
+
address: recovery.walletAddress,
|
|
12906
12932
|
iv,
|
|
12907
12933
|
ciphertext
|
|
12908
12934
|
};
|
|
12909
|
-
},
|
|
12910
|
-
walletAddressForPrivateKey(privateKeyInput) {
|
|
12911
|
-
return computeAccountAddress(starkKeyPairFromPrivateKey(privateKeyInput).publicKeyHex, 0);
|
|
12912
12935
|
}
|
|
12913
12936
|
};
|
|
12914
12937
|
}
|
|
@@ -13182,6 +13205,21 @@ function createMediaWallet(config) {
|
|
|
13182
13205
|
}
|
|
13183
13206
|
};
|
|
13184
13207
|
}
|
|
13208
|
+
async function adoptSessionWallet(api, saveAddress) {
|
|
13209
|
+
const wallet = await api.getSessionWallet();
|
|
13210
|
+
if (wallet) saveAddress(wallet.walletAddress);
|
|
13211
|
+
return wallet;
|
|
13212
|
+
}
|
|
13213
|
+
var PROOF_TTL_SECONDS = 600;
|
|
13214
|
+
async function setupSessionWalletKey(api, walletAddress, deps) {
|
|
13215
|
+
const { sealed, privateKeyHex } = await deps.createOwnerKey();
|
|
13216
|
+
const now = deps.now?.() ?? Math.floor(Date.now() / 1e3);
|
|
13217
|
+
const expiration = now + PROOF_TTL_SECONDS;
|
|
13218
|
+
const message = ownerAliveTypedData(computeOwnerGuid(sealed.ownerPubKey), expiration, "SN_MAIN");
|
|
13219
|
+
const signature = signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(message, walletAddress));
|
|
13220
|
+
const result = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey, signature, expiration });
|
|
13221
|
+
deps.saveOwner({ ...sealed, address: result.walletAddress });
|
|
13222
|
+
}
|
|
13185
13223
|
|
|
13186
13224
|
exports.ADMIN_HEADERS = ADMIN_HEADERS;
|
|
13187
13225
|
exports.ADMIN_SCOPE = ADMIN_SCOPE;
|
|
@@ -13207,6 +13245,7 @@ exports.IPSponsorshipABI = IPSponsorshipABI;
|
|
|
13207
13245
|
exports.IPTicketCollectionABI = IPTicketCollectionABI;
|
|
13208
13246
|
exports.IPTicketCollectionFactoryABI = IPTicketCollectionFactoryABI;
|
|
13209
13247
|
exports.InvalidPairingPayloadError = InvalidPairingPayloadError;
|
|
13248
|
+
exports.InvalidRecoveryKeyError = InvalidRecoveryKeyError;
|
|
13210
13249
|
exports.InvalidStarkPrivateKeyError = InvalidStarkPrivateKeyError;
|
|
13211
13250
|
exports.MAX_HOLDERS_AT_LAUNCH = MAX_HOLDERS_AT_LAUNCH;
|
|
13212
13251
|
exports.MAX_TEAM_ALLOCATION_PERCENT = MAX_TEAM_ALLOCATION_PERCENT;
|
|
@@ -13226,6 +13265,7 @@ exports.UserFacingError = UserFacingError;
|
|
|
13226
13265
|
exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
|
|
13227
13266
|
exports.accountFor = accountFor;
|
|
13228
13267
|
exports.adminRequestDigest = adminRequestDigest;
|
|
13268
|
+
exports.adoptSessionWallet = adoptSessionWallet;
|
|
13229
13269
|
exports.allowsFallbackFunding = allowsFallbackFunding;
|
|
13230
13270
|
exports.assertTransactionSucceeded = assertTransactionSucceeded;
|
|
13231
13271
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
@@ -13271,6 +13311,7 @@ exports.describeRecoveryAction = describeRecoveryAction;
|
|
|
13271
13311
|
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
13272
13312
|
exports.encodeByteArray = encodeByteArray;
|
|
13273
13313
|
exports.encodePairingPayload = encodePairingPayload;
|
|
13314
|
+
exports.encodeRecoveryKey = encodeRecoveryKey;
|
|
13274
13315
|
exports.estimateSelfFundedFee = estimateSelfFundedFee;
|
|
13275
13316
|
exports.executeIntent = executeIntent;
|
|
13276
13317
|
exports.executeIntents = executeIntents;
|
|
@@ -13291,7 +13332,6 @@ exports.getOwners = getOwners;
|
|
|
13291
13332
|
exports.getSiwsStorageKey = getSiwsStorageKey;
|
|
13292
13333
|
exports.getStoredSiwsToken = getStoredSiwsToken;
|
|
13293
13334
|
exports.isDeployed = isDeployed;
|
|
13294
|
-
exports.isRecoveryKeyForWallet = isRecoveryKeyForWallet;
|
|
13295
13335
|
exports.isSiwsTokenValid = isSiwsTokenValid;
|
|
13296
13336
|
exports.isValidStarknetAddress = isValidStarknetAddress;
|
|
13297
13337
|
exports.mintedTokenIdFromReceipt = mintedTokenIdFromReceipt;
|
|
@@ -13303,12 +13343,14 @@ exports.parseAccountAddress = parseAccountAddress;
|
|
|
13303
13343
|
exports.parseAdminHeaders = parseAdminHeaders;
|
|
13304
13344
|
exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
|
|
13305
13345
|
exports.parsePairingPayload = parsePairingPayload;
|
|
13346
|
+
exports.parseRecoveryKey = parseRecoveryKey;
|
|
13306
13347
|
exports.priceToEkuboParams = priceToEkuboParams;
|
|
13307
13348
|
exports.randomNonce = randomNonce;
|
|
13308
13349
|
exports.requestSiwsToken = requestSiwsToken;
|
|
13309
13350
|
exports.sealPrivateKey = sealPrivateKey;
|
|
13310
13351
|
exports.selfFundedExecutor = selfFundedExecutor;
|
|
13311
13352
|
exports.sessionKeyHashOf = sessionKeyHashOf;
|
|
13353
|
+
exports.setupSessionWalletKey = setupSessionWalletKey;
|
|
13312
13354
|
exports.signAdminRequest = signAdminRequest;
|
|
13313
13355
|
exports.signWithPrivateKey = signWithPrivateKey;
|
|
13314
13356
|
exports.sponsoredExecutor = sponsoredExecutor;
|