@medialane/sdk 0.130.0 → 0.132.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-Dc-g0mMr.d.ts → errors-HTG0DcWa.d.ts} +24 -12
- package/dist/{errors-C_zqe9TI.d.cts → errors-JkeKc3cu.d.cts} +24 -12
- package/dist/index.cjs +21 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -13
- package/dist/index.d.ts +3 -13
- package/dist/index.js +22 -73
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +21 -7
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +2 -2
- package/dist/starknet/index.d.ts +2 -2
- package/dist/starknet/index.js +21 -7
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -973,9 +973,9 @@ interface ApiBusinessProvisioning {
|
|
|
973
973
|
walletAddress: string;
|
|
974
974
|
recipientScheme: string;
|
|
975
975
|
recipientValue: string;
|
|
976
|
-
interimOwnerPubkey: string;
|
|
976
|
+
interimOwnerPubkey: string | null;
|
|
977
977
|
newOwnerPubkey: string | null;
|
|
978
|
-
status: "DEPLOYED" | "
|
|
978
|
+
status: "DEPLOYED" | "REUSED" | "TRANSFERRED";
|
|
979
979
|
}
|
|
980
980
|
interface ApiWalletActivity {
|
|
981
981
|
id: string;
|
|
@@ -1206,20 +1206,12 @@ declare class ApiClient {
|
|
|
1206
1206
|
claim: ApiCollectionClaim;
|
|
1207
1207
|
}>;
|
|
1208
1208
|
registerBusinessProvisioning(params: {
|
|
1209
|
-
chain
|
|
1209
|
+
chain?: "STARKNET";
|
|
1210
1210
|
recipientScheme: string;
|
|
1211
1211
|
recipientValue: string;
|
|
1212
|
-
interimOwnerPubkey: string;
|
|
1213
|
-
derivationSalt: string;
|
|
1214
|
-
deployment: {
|
|
1215
|
-
typedData: unknown;
|
|
1216
|
-
signature: string[];
|
|
1217
|
-
deployment: unknown;
|
|
1218
|
-
};
|
|
1219
1212
|
}): Promise<ApiResponse<ApiBusinessProvisioning> & {
|
|
1220
1213
|
reusedExistingWallet?: boolean;
|
|
1221
1214
|
}>;
|
|
1222
|
-
completeBusinessProvisioning(id: string): Promise<ApiResponse<ApiBusinessProvisioning>>;
|
|
1223
1215
|
getCollectionProfile(contractAddress: string): Promise<ApiCollectionProfile | null>;
|
|
1224
1216
|
updateCollectionProfile(contractAddress: string, data: UpdateCollectionProfileInput, siwsToken: string): Promise<ApiCollectionProfile>;
|
|
1225
1217
|
getWalletActivity(address: string, chain?: "STARKNET"): Promise<ApiResponse<ApiWalletActivity[]>>;
|
|
@@ -1269,7 +1261,27 @@ declare class ApiClient {
|
|
|
1269
1261
|
email?: string;
|
|
1270
1262
|
accountToken?: string;
|
|
1271
1263
|
}): Promise<ApiUserWallet>;
|
|
1272
|
-
|
|
1264
|
+
checkEmail(email: string): Promise<{
|
|
1265
|
+
exists: boolean;
|
|
1266
|
+
walletWaiting: boolean;
|
|
1267
|
+
}>;
|
|
1268
|
+
requestEmailCode(email: string): Promise<void>;
|
|
1269
|
+
registerEmailAccount(email: string): Promise<void>;
|
|
1270
|
+
verifyEmailCode(email: string, code: string): Promise<{
|
|
1271
|
+
token: string;
|
|
1272
|
+
waitingWallets: string[];
|
|
1273
|
+
}>;
|
|
1274
|
+
claimWallet(params: {
|
|
1275
|
+
newOwnerPubkey: string;
|
|
1276
|
+
proofs: {
|
|
1277
|
+
walletAddress: string;
|
|
1278
|
+
signature: string[];
|
|
1279
|
+
expiration: number;
|
|
1280
|
+
}[];
|
|
1281
|
+
}): Promise<{
|
|
1282
|
+
claimed: string[];
|
|
1283
|
+
}>;
|
|
1284
|
+
getSessionWallet(): Promise<string | null>;
|
|
1273
1285
|
getMyWallet(siwsToken: string): Promise<ApiUserWallet | null>;
|
|
1274
1286
|
changeMyEmail(email: string, siwsToken: string): Promise<{
|
|
1275
1287
|
email: string;
|
|
@@ -973,9 +973,9 @@ interface ApiBusinessProvisioning {
|
|
|
973
973
|
walletAddress: string;
|
|
974
974
|
recipientScheme: string;
|
|
975
975
|
recipientValue: string;
|
|
976
|
-
interimOwnerPubkey: string;
|
|
976
|
+
interimOwnerPubkey: string | null;
|
|
977
977
|
newOwnerPubkey: string | null;
|
|
978
|
-
status: "DEPLOYED" | "
|
|
978
|
+
status: "DEPLOYED" | "REUSED" | "TRANSFERRED";
|
|
979
979
|
}
|
|
980
980
|
interface ApiWalletActivity {
|
|
981
981
|
id: string;
|
|
@@ -1206,20 +1206,12 @@ declare class ApiClient {
|
|
|
1206
1206
|
claim: ApiCollectionClaim;
|
|
1207
1207
|
}>;
|
|
1208
1208
|
registerBusinessProvisioning(params: {
|
|
1209
|
-
chain
|
|
1209
|
+
chain?: "STARKNET";
|
|
1210
1210
|
recipientScheme: string;
|
|
1211
1211
|
recipientValue: string;
|
|
1212
|
-
interimOwnerPubkey: string;
|
|
1213
|
-
derivationSalt: string;
|
|
1214
|
-
deployment: {
|
|
1215
|
-
typedData: unknown;
|
|
1216
|
-
signature: string[];
|
|
1217
|
-
deployment: unknown;
|
|
1218
|
-
};
|
|
1219
1212
|
}): Promise<ApiResponse<ApiBusinessProvisioning> & {
|
|
1220
1213
|
reusedExistingWallet?: boolean;
|
|
1221
1214
|
}>;
|
|
1222
|
-
completeBusinessProvisioning(id: string): Promise<ApiResponse<ApiBusinessProvisioning>>;
|
|
1223
1215
|
getCollectionProfile(contractAddress: string): Promise<ApiCollectionProfile | null>;
|
|
1224
1216
|
updateCollectionProfile(contractAddress: string, data: UpdateCollectionProfileInput, siwsToken: string): Promise<ApiCollectionProfile>;
|
|
1225
1217
|
getWalletActivity(address: string, chain?: "STARKNET"): Promise<ApiResponse<ApiWalletActivity[]>>;
|
|
@@ -1269,7 +1261,27 @@ declare class ApiClient {
|
|
|
1269
1261
|
email?: string;
|
|
1270
1262
|
accountToken?: string;
|
|
1271
1263
|
}): Promise<ApiUserWallet>;
|
|
1272
|
-
|
|
1264
|
+
checkEmail(email: string): Promise<{
|
|
1265
|
+
exists: boolean;
|
|
1266
|
+
walletWaiting: boolean;
|
|
1267
|
+
}>;
|
|
1268
|
+
requestEmailCode(email: string): Promise<void>;
|
|
1269
|
+
registerEmailAccount(email: string): Promise<void>;
|
|
1270
|
+
verifyEmailCode(email: string, code: string): Promise<{
|
|
1271
|
+
token: string;
|
|
1272
|
+
waitingWallets: string[];
|
|
1273
|
+
}>;
|
|
1274
|
+
claimWallet(params: {
|
|
1275
|
+
newOwnerPubkey: string;
|
|
1276
|
+
proofs: {
|
|
1277
|
+
walletAddress: string;
|
|
1278
|
+
signature: string[];
|
|
1279
|
+
expiration: number;
|
|
1280
|
+
}[];
|
|
1281
|
+
}): Promise<{
|
|
1282
|
+
claimed: string[];
|
|
1283
|
+
}>;
|
|
1284
|
+
getSessionWallet(): Promise<string | null>;
|
|
1273
1285
|
getMyWallet(siwsToken: string): Promise<ApiUserWallet | null>;
|
|
1274
1286
|
changeMyEmail(email: string, siwsToken: string): Promise<{
|
|
1275
1287
|
email: string;
|
package/dist/index.cjs
CHANGED
|
@@ -674,12 +674,9 @@ var ApiClient = class {
|
|
|
674
674
|
registerBusinessProvisioning(params) {
|
|
675
675
|
return this.post(
|
|
676
676
|
"/v1/business/provisioning",
|
|
677
|
-
params
|
|
677
|
+
{ chain: params.chain ?? "STARKNET", recipientScheme: params.recipientScheme, recipientValue: params.recipientValue }
|
|
678
678
|
);
|
|
679
679
|
}
|
|
680
|
-
completeBusinessProvisioning(id) {
|
|
681
|
-
return this.post(`/v1/business/provisioning/${id}/complete`, {});
|
|
682
|
-
}
|
|
683
680
|
getCollectionProfile(contractAddress) {
|
|
684
681
|
return this.request(
|
|
685
682
|
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
@@ -776,11 +773,28 @@ var ApiClient = class {
|
|
|
776
773
|
headers: this.bearer(siwsToken)
|
|
777
774
|
});
|
|
778
775
|
}
|
|
779
|
-
async
|
|
780
|
-
const
|
|
776
|
+
async checkEmail(email) {
|
|
777
|
+
const body = await this.get(
|
|
781
778
|
`/v1/auth/email/exists?email=${encodeURIComponent(email)}`
|
|
782
779
|
);
|
|
783
|
-
return exists;
|
|
780
|
+
return { exists: body.exists, walletWaiting: body.walletWaiting === true };
|
|
781
|
+
}
|
|
782
|
+
async requestEmailCode(email) {
|
|
783
|
+
await this.post("/v1/auth/email/request-code", { email });
|
|
784
|
+
}
|
|
785
|
+
async registerEmailAccount(email) {
|
|
786
|
+
await this.post("/v1/auth/email/register-account", { email });
|
|
787
|
+
}
|
|
788
|
+
async verifyEmailCode(email, code) {
|
|
789
|
+
const body = await this.post("/v1/auth/email/verify-code", { email, code });
|
|
790
|
+
return { token: body.token, waitingWallets: body.waitingWallets ?? [] };
|
|
791
|
+
}
|
|
792
|
+
claimWallet(params) {
|
|
793
|
+
return this.post("/v1/users/me/claim-wallet", params);
|
|
794
|
+
}
|
|
795
|
+
async getSessionWallet() {
|
|
796
|
+
const body = await this.post("/v1/users/me/wallet", {});
|
|
797
|
+
return body.walletAddress ?? null;
|
|
784
798
|
}
|
|
785
799
|
getMyWallet(siwsToken) {
|
|
786
800
|
return this.request(
|
|
@@ -1492,41 +1506,6 @@ function createFailoverFetch(urls, options = {}) {
|
|
|
1492
1506
|
return failover;
|
|
1493
1507
|
}
|
|
1494
1508
|
|
|
1495
|
-
// src/server/rate-limit.ts
|
|
1496
|
-
function createRateLimiter(windowMs, max) {
|
|
1497
|
-
const counts = /* @__PURE__ */ new Map();
|
|
1498
|
-
let nextSweepAt = Date.now() + windowMs;
|
|
1499
|
-
return function checkRateLimit(key) {
|
|
1500
|
-
const now = Date.now();
|
|
1501
|
-
if (now >= nextSweepAt) {
|
|
1502
|
-
for (const [k, entry2] of counts) {
|
|
1503
|
-
if (now >= entry2.resetAt) counts.delete(k);
|
|
1504
|
-
}
|
|
1505
|
-
nextSweepAt = now + windowMs;
|
|
1506
|
-
}
|
|
1507
|
-
const entry = counts.get(key);
|
|
1508
|
-
if (!entry || now >= entry.resetAt) {
|
|
1509
|
-
counts.set(key, { count: 1, resetAt: now + windowMs });
|
|
1510
|
-
return true;
|
|
1511
|
-
}
|
|
1512
|
-
if (entry.count >= max) return false;
|
|
1513
|
-
entry.count += 1;
|
|
1514
|
-
return true;
|
|
1515
|
-
};
|
|
1516
|
-
}
|
|
1517
|
-
var TRUSTED_APP_IP_HEADER = "x-medialane-client-ip";
|
|
1518
|
-
function requestIp(req) {
|
|
1519
|
-
const fromEdge = req.headers.get("x-vercel-forwarded-for")?.split(",")[0]?.trim();
|
|
1520
|
-
if (fromEdge) return fromEdge;
|
|
1521
|
-
const forwarded = req.headers.get("x-forwarded-for");
|
|
1522
|
-
if (forwarded) {
|
|
1523
|
-
const hops = forwarded.split(",").map((hop) => hop.trim()).filter(Boolean);
|
|
1524
|
-
const nearest = hops[hops.length - 1];
|
|
1525
|
-
if (nearest) return nearest;
|
|
1526
|
-
}
|
|
1527
|
-
return "unknown";
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
1509
|
// src/server/origin.ts
|
|
1531
1510
|
function isSameOrigin(req) {
|
|
1532
1511
|
const origin = req.headers.get("origin");
|
|
@@ -1560,9 +1539,6 @@ function createBackendProxyHandler(config) {
|
|
|
1560
1539
|
if (!isSameOrigin(req)) {
|
|
1561
1540
|
return proxyError(-32600, "Cross-origin requests are not allowed", 403);
|
|
1562
1541
|
}
|
|
1563
|
-
if (!config.checkRateLimit(requestIp(req))) {
|
|
1564
|
-
return proxyError(-32005, "Too many requests", 429);
|
|
1565
|
-
}
|
|
1566
1542
|
if (!config.apiKey) {
|
|
1567
1543
|
return proxyError(-32003, "No API key configured \u2014 request not forwarded", 402);
|
|
1568
1544
|
}
|
|
@@ -1820,9 +1796,6 @@ function createImageProxyHandler(config) {
|
|
|
1820
1796
|
return res;
|
|
1821
1797
|
}
|
|
1822
1798
|
return async function handleImageProxy(req) {
|
|
1823
|
-
if (!config.checkRateLimit(requestIp(req))) {
|
|
1824
|
-
return jsonError("Too many requests", 429);
|
|
1825
|
-
}
|
|
1826
1799
|
const raw = new URL(req.url).searchParams.get("url");
|
|
1827
1800
|
if (!raw) return jsonError("Missing url", 400);
|
|
1828
1801
|
const validated = validateUrl(raw);
|
|
@@ -1904,30 +1877,6 @@ async function getBackendSignedUrl(config, kind = "image") {
|
|
|
1904
1877
|
if (!res.ok || !data.data) throw new Error(data.error ?? "Failed to create upload URL");
|
|
1905
1878
|
return data.data.url;
|
|
1906
1879
|
}
|
|
1907
|
-
|
|
1908
|
-
// src/server/trusted-client-ip.ts
|
|
1909
|
-
var SPOOFABLE_FORWARDING_HEADERS = [
|
|
1910
|
-
"x-forwarded-for",
|
|
1911
|
-
"x-real-ip",
|
|
1912
|
-
"x-client-ip",
|
|
1913
|
-
"true-client-ip",
|
|
1914
|
-
"cf-connecting-ip",
|
|
1915
|
-
TRUSTED_APP_IP_HEADER
|
|
1916
|
-
];
|
|
1917
|
-
function isSpoofableForwardingHeader(name) {
|
|
1918
|
-
return SPOOFABLE_FORWARDING_HEADERS.includes(name.toLowerCase());
|
|
1919
|
-
}
|
|
1920
|
-
function trustedClientIp(req) {
|
|
1921
|
-
const vercel = req.headers.get("x-vercel-forwarded-for")?.split(",")[0]?.trim();
|
|
1922
|
-
if (vercel) return vercel;
|
|
1923
|
-
const forwarded = req.headers.get("x-forwarded-for");
|
|
1924
|
-
if (forwarded) {
|
|
1925
|
-
const hops = forwarded.split(",").map((hop) => hop.trim()).filter(Boolean);
|
|
1926
|
-
const nearest = hops[hops.length - 1];
|
|
1927
|
-
if (nearest) return nearest;
|
|
1928
|
-
}
|
|
1929
|
-
return "unknown";
|
|
1930
|
-
}
|
|
1931
1880
|
var IDENTITY_PREFIX = "siws_";
|
|
1932
1881
|
var ACCOUNT_SESSION_PREFIX = "account_session_";
|
|
1933
1882
|
var IDENTITY_DOMAIN = "siws-identity-v1";
|
|
@@ -2158,7 +2107,6 @@ exports.STARKNET_POP_COLLECTION_CLASS_HASH = STARKNET_POP_COLLECTION_CLASS_HASH;
|
|
|
2158
2107
|
exports.STARKNET_POP_FACTORY_CONTRACT = STARKNET_POP_FACTORY_CONTRACT;
|
|
2159
2108
|
exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
|
|
2160
2109
|
exports.SUPPORTED_URL_CHAINS = SUPPORTED_URL_CHAINS;
|
|
2161
|
-
exports.TRUSTED_APP_IP_HEADER = TRUSTED_APP_IP_HEADER;
|
|
2162
2110
|
exports.UserFacingError = UserFacingError;
|
|
2163
2111
|
exports.assetHref = assetHref;
|
|
2164
2112
|
exports.buildAssetMetadata = buildAssetMetadata;
|
|
@@ -2169,7 +2117,6 @@ exports.collectionHref = collectionHref;
|
|
|
2169
2117
|
exports.createBackendProxyHandler = createBackendProxyHandler;
|
|
2170
2118
|
exports.createFailoverFetch = createFailoverFetch;
|
|
2171
2119
|
exports.createImageProxyHandler = createImageProxyHandler;
|
|
2172
|
-
exports.createRateLimiter = createRateLimiter;
|
|
2173
2120
|
exports.createRpcProxyHandler = createRpcProxyHandler;
|
|
2174
2121
|
exports.encodeU256 = encodeU256;
|
|
2175
2122
|
exports.formatAmount = formatAmount;
|
|
@@ -2188,7 +2135,6 @@ exports.isPrivateHost = isPrivateHost;
|
|
|
2188
2135
|
exports.isPrivateOrInsecureUrl = isPrivateOrInsecureUrl;
|
|
2189
2136
|
exports.isSameOrigin = isSameOrigin;
|
|
2190
2137
|
exports.isServiceId = isServiceId;
|
|
2191
|
-
exports.isSpoofableForwardingHeader = isSpoofableForwardingHeader;
|
|
2192
2138
|
exports.isTransientRpcError = isTransientRpcError;
|
|
2193
2139
|
exports.isValidIpfsCidPath = isValidIpfsCidPath;
|
|
2194
2140
|
exports.issueAccountSessionToken = issueAccountSessionToken;
|
|
@@ -2198,7 +2144,6 @@ exports.normalizeAddress = normalizeAddress;
|
|
|
2198
2144
|
exports.normalizeHash = normalizeHash;
|
|
2199
2145
|
exports.parseAmount = parseAmount;
|
|
2200
2146
|
exports.readBodyWithCap = readBodyWithCap;
|
|
2201
|
-
exports.requestIp = requestIp;
|
|
2202
2147
|
exports.resolveAppFeeConfig = resolveAppFeeConfig;
|
|
2203
2148
|
exports.resolveConfig = resolveConfig;
|
|
2204
2149
|
exports.resolveFeeConfig = resolveFeeConfig;
|
|
@@ -2206,7 +2151,6 @@ exports.resolveRemixPolicy = resolveRemixPolicy;
|
|
|
2206
2151
|
exports.resolveSafeImageContentType = resolveSafeImageContentType;
|
|
2207
2152
|
exports.shortenAddress = shortenAddress;
|
|
2208
2153
|
exports.stringifyBigInts = stringifyBigInts;
|
|
2209
|
-
exports.trustedClientIp = trustedClientIp;
|
|
2210
2154
|
exports.u256ToBigInt = u256ToBigInt;
|
|
2211
2155
|
exports.uploadDirectoryToBackend = uploadDirectoryToBackend;
|
|
2212
2156
|
exports.uploadFileToBackend = uploadFileToBackend;
|