@medialane/sdk 0.131.0 → 0.133.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-JkeKc3cu.d.cts → errors-DEz42hh5.d.cts} +0 -6
- package/dist/{errors-HTG0DcWa.d.ts → errors-DxBa5Wne.d.ts} +0 -6
- package/dist/index.cjs +2 -74
- 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 +3 -70
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +2 -4
- 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 +2 -4
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -947,7 +947,6 @@ interface ApiUserWallet {
|
|
|
947
947
|
walletAddress: string;
|
|
948
948
|
email?: string | null;
|
|
949
949
|
emailVerified?: boolean;
|
|
950
|
-
requiresEmailVerification?: boolean;
|
|
951
950
|
}
|
|
952
951
|
interface ApiCollectionClaim {
|
|
953
952
|
id: string;
|
|
@@ -1155,7 +1154,6 @@ declare class ApiClient {
|
|
|
1155
1154
|
getApiKeys(siwsToken?: string): Promise<ApiResponse<ApiPortalKey[]>>;
|
|
1156
1155
|
createApiKey(input?: {
|
|
1157
1156
|
label?: string;
|
|
1158
|
-
appSource?: string;
|
|
1159
1157
|
}, siwsToken?: string): Promise<ApiResponse<ApiPortalKeyCreated>>;
|
|
1160
1158
|
deleteApiKey(id: string, siwsToken?: string): Promise<ApiResponse<{
|
|
1161
1159
|
id: string;
|
|
@@ -1242,7 +1240,6 @@ declare class ApiClient {
|
|
|
1242
1240
|
registerUser(params: {
|
|
1243
1241
|
walletAddress: string;
|
|
1244
1242
|
walletType?: string;
|
|
1245
|
-
appSource?: ApiAppSource;
|
|
1246
1243
|
chain?: ApiChain;
|
|
1247
1244
|
}): Promise<{
|
|
1248
1245
|
accountId: string;
|
|
@@ -1255,9 +1252,7 @@ declare class ApiClient {
|
|
|
1255
1252
|
}>;
|
|
1256
1253
|
upsertMyWallet(siwsToken: string, options?: {
|
|
1257
1254
|
walletType?: string;
|
|
1258
|
-
appSource?: ApiAppSource;
|
|
1259
1255
|
chain?: ApiChain;
|
|
1260
|
-
emailVerificationToken?: string;
|
|
1261
1256
|
email?: string;
|
|
1262
1257
|
accountToken?: string;
|
|
1263
1258
|
}): Promise<ApiUserWallet>;
|
|
@@ -1268,7 +1263,6 @@ declare class ApiClient {
|
|
|
1268
1263
|
requestEmailCode(email: string): Promise<void>;
|
|
1269
1264
|
registerEmailAccount(email: string): Promise<void>;
|
|
1270
1265
|
verifyEmailCode(email: string, code: string): Promise<{
|
|
1271
|
-
token: string;
|
|
1272
1266
|
waitingWallets: string[];
|
|
1273
1267
|
}>;
|
|
1274
1268
|
claimWallet(params: {
|
|
@@ -947,7 +947,6 @@ interface ApiUserWallet {
|
|
|
947
947
|
walletAddress: string;
|
|
948
948
|
email?: string | null;
|
|
949
949
|
emailVerified?: boolean;
|
|
950
|
-
requiresEmailVerification?: boolean;
|
|
951
950
|
}
|
|
952
951
|
interface ApiCollectionClaim {
|
|
953
952
|
id: string;
|
|
@@ -1155,7 +1154,6 @@ declare class ApiClient {
|
|
|
1155
1154
|
getApiKeys(siwsToken?: string): Promise<ApiResponse<ApiPortalKey[]>>;
|
|
1156
1155
|
createApiKey(input?: {
|
|
1157
1156
|
label?: string;
|
|
1158
|
-
appSource?: string;
|
|
1159
1157
|
}, siwsToken?: string): Promise<ApiResponse<ApiPortalKeyCreated>>;
|
|
1160
1158
|
deleteApiKey(id: string, siwsToken?: string): Promise<ApiResponse<{
|
|
1161
1159
|
id: string;
|
|
@@ -1242,7 +1240,6 @@ declare class ApiClient {
|
|
|
1242
1240
|
registerUser(params: {
|
|
1243
1241
|
walletAddress: string;
|
|
1244
1242
|
walletType?: string;
|
|
1245
|
-
appSource?: ApiAppSource;
|
|
1246
1243
|
chain?: ApiChain;
|
|
1247
1244
|
}): Promise<{
|
|
1248
1245
|
accountId: string;
|
|
@@ -1255,9 +1252,7 @@ declare class ApiClient {
|
|
|
1255
1252
|
}>;
|
|
1256
1253
|
upsertMyWallet(siwsToken: string, options?: {
|
|
1257
1254
|
walletType?: string;
|
|
1258
|
-
appSource?: ApiAppSource;
|
|
1259
1255
|
chain?: ApiChain;
|
|
1260
|
-
emailVerificationToken?: string;
|
|
1261
1256
|
email?: string;
|
|
1262
1257
|
accountToken?: string;
|
|
1263
1258
|
}): Promise<ApiUserWallet>;
|
|
@@ -1268,7 +1263,6 @@ declare class ApiClient {
|
|
|
1268
1263
|
requestEmailCode(email: string): Promise<void>;
|
|
1269
1264
|
registerEmailAccount(email: string): Promise<void>;
|
|
1270
1265
|
verifyEmailCode(email: string, code: string): Promise<{
|
|
1271
|
-
token: string;
|
|
1272
1266
|
waitingWallets: string[];
|
|
1273
1267
|
}>;
|
|
1274
1268
|
claimWallet(params: {
|
package/dist/index.cjs
CHANGED
|
@@ -760,11 +760,9 @@ var ApiClient = class {
|
|
|
760
760
|
}
|
|
761
761
|
async upsertMyWallet(siwsToken, options = {}) {
|
|
762
762
|
const body = {
|
|
763
|
-
walletType: options.walletType ?? "UNKNOWN"
|
|
764
|
-
appSource: options.appSource ?? "MEDIALANE_SDK"
|
|
763
|
+
walletType: options.walletType ?? "UNKNOWN"
|
|
765
764
|
};
|
|
766
765
|
if (options.chain) body.chain = options.chain;
|
|
767
|
-
if (options.emailVerificationToken) body.emailVerificationToken = options.emailVerificationToken;
|
|
768
766
|
if (options.email) body.email = options.email;
|
|
769
767
|
if (options.accountToken) body.accountToken = options.accountToken;
|
|
770
768
|
return this.request("/v1/users/me", {
|
|
@@ -787,7 +785,7 @@ var ApiClient = class {
|
|
|
787
785
|
}
|
|
788
786
|
async verifyEmailCode(email, code) {
|
|
789
787
|
const body = await this.post("/v1/auth/email/verify-code", { email, code });
|
|
790
|
-
return {
|
|
788
|
+
return { waitingWallets: body.waitingWallets ?? [] };
|
|
791
789
|
}
|
|
792
790
|
claimWallet(params) {
|
|
793
791
|
return this.post("/v1/users/me/claim-wallet", params);
|
|
@@ -1506,41 +1504,6 @@ function createFailoverFetch(urls, options = {}) {
|
|
|
1506
1504
|
return failover;
|
|
1507
1505
|
}
|
|
1508
1506
|
|
|
1509
|
-
// src/server/rate-limit.ts
|
|
1510
|
-
function createRateLimiter(windowMs, max) {
|
|
1511
|
-
const counts = /* @__PURE__ */ new Map();
|
|
1512
|
-
let nextSweepAt = Date.now() + windowMs;
|
|
1513
|
-
return function checkRateLimit(key) {
|
|
1514
|
-
const now = Date.now();
|
|
1515
|
-
if (now >= nextSweepAt) {
|
|
1516
|
-
for (const [k, entry2] of counts) {
|
|
1517
|
-
if (now >= entry2.resetAt) counts.delete(k);
|
|
1518
|
-
}
|
|
1519
|
-
nextSweepAt = now + windowMs;
|
|
1520
|
-
}
|
|
1521
|
-
const entry = counts.get(key);
|
|
1522
|
-
if (!entry || now >= entry.resetAt) {
|
|
1523
|
-
counts.set(key, { count: 1, resetAt: now + windowMs });
|
|
1524
|
-
return true;
|
|
1525
|
-
}
|
|
1526
|
-
if (entry.count >= max) return false;
|
|
1527
|
-
entry.count += 1;
|
|
1528
|
-
return true;
|
|
1529
|
-
};
|
|
1530
|
-
}
|
|
1531
|
-
var TRUSTED_APP_IP_HEADER = "x-medialane-client-ip";
|
|
1532
|
-
function requestIp(req) {
|
|
1533
|
-
const fromEdge = req.headers.get("x-vercel-forwarded-for")?.split(",")[0]?.trim();
|
|
1534
|
-
if (fromEdge) return fromEdge;
|
|
1535
|
-
const forwarded = req.headers.get("x-forwarded-for");
|
|
1536
|
-
if (forwarded) {
|
|
1537
|
-
const hops = forwarded.split(",").map((hop) => hop.trim()).filter(Boolean);
|
|
1538
|
-
const nearest = hops[hops.length - 1];
|
|
1539
|
-
if (nearest) return nearest;
|
|
1540
|
-
}
|
|
1541
|
-
return "unknown";
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
1507
|
// src/server/origin.ts
|
|
1545
1508
|
function isSameOrigin(req) {
|
|
1546
1509
|
const origin = req.headers.get("origin");
|
|
@@ -1574,9 +1537,6 @@ function createBackendProxyHandler(config) {
|
|
|
1574
1537
|
if (!isSameOrigin(req)) {
|
|
1575
1538
|
return proxyError(-32600, "Cross-origin requests are not allowed", 403);
|
|
1576
1539
|
}
|
|
1577
|
-
if (!config.checkRateLimit(requestIp(req))) {
|
|
1578
|
-
return proxyError(-32005, "Too many requests", 429);
|
|
1579
|
-
}
|
|
1580
1540
|
if (!config.apiKey) {
|
|
1581
1541
|
return proxyError(-32003, "No API key configured \u2014 request not forwarded", 402);
|
|
1582
1542
|
}
|
|
@@ -1834,9 +1794,6 @@ function createImageProxyHandler(config) {
|
|
|
1834
1794
|
return res;
|
|
1835
1795
|
}
|
|
1836
1796
|
return async function handleImageProxy(req) {
|
|
1837
|
-
if (!config.checkRateLimit(requestIp(req))) {
|
|
1838
|
-
return jsonError("Too many requests", 429);
|
|
1839
|
-
}
|
|
1840
1797
|
const raw = new URL(req.url).searchParams.get("url");
|
|
1841
1798
|
if (!raw) return jsonError("Missing url", 400);
|
|
1842
1799
|
const validated = validateUrl(raw);
|
|
@@ -1918,30 +1875,6 @@ async function getBackendSignedUrl(config, kind = "image") {
|
|
|
1918
1875
|
if (!res.ok || !data.data) throw new Error(data.error ?? "Failed to create upload URL");
|
|
1919
1876
|
return data.data.url;
|
|
1920
1877
|
}
|
|
1921
|
-
|
|
1922
|
-
// src/server/trusted-client-ip.ts
|
|
1923
|
-
var SPOOFABLE_FORWARDING_HEADERS = [
|
|
1924
|
-
"x-forwarded-for",
|
|
1925
|
-
"x-real-ip",
|
|
1926
|
-
"x-client-ip",
|
|
1927
|
-
"true-client-ip",
|
|
1928
|
-
"cf-connecting-ip",
|
|
1929
|
-
TRUSTED_APP_IP_HEADER
|
|
1930
|
-
];
|
|
1931
|
-
function isSpoofableForwardingHeader(name) {
|
|
1932
|
-
return SPOOFABLE_FORWARDING_HEADERS.includes(name.toLowerCase());
|
|
1933
|
-
}
|
|
1934
|
-
function trustedClientIp(req) {
|
|
1935
|
-
const vercel = req.headers.get("x-vercel-forwarded-for")?.split(",")[0]?.trim();
|
|
1936
|
-
if (vercel) return vercel;
|
|
1937
|
-
const forwarded = req.headers.get("x-forwarded-for");
|
|
1938
|
-
if (forwarded) {
|
|
1939
|
-
const hops = forwarded.split(",").map((hop) => hop.trim()).filter(Boolean);
|
|
1940
|
-
const nearest = hops[hops.length - 1];
|
|
1941
|
-
if (nearest) return nearest;
|
|
1942
|
-
}
|
|
1943
|
-
return "unknown";
|
|
1944
|
-
}
|
|
1945
1878
|
var IDENTITY_PREFIX = "siws_";
|
|
1946
1879
|
var ACCOUNT_SESSION_PREFIX = "account_session_";
|
|
1947
1880
|
var IDENTITY_DOMAIN = "siws-identity-v1";
|
|
@@ -2172,7 +2105,6 @@ exports.STARKNET_POP_COLLECTION_CLASS_HASH = STARKNET_POP_COLLECTION_CLASS_HASH;
|
|
|
2172
2105
|
exports.STARKNET_POP_FACTORY_CONTRACT = STARKNET_POP_FACTORY_CONTRACT;
|
|
2173
2106
|
exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
|
|
2174
2107
|
exports.SUPPORTED_URL_CHAINS = SUPPORTED_URL_CHAINS;
|
|
2175
|
-
exports.TRUSTED_APP_IP_HEADER = TRUSTED_APP_IP_HEADER;
|
|
2176
2108
|
exports.UserFacingError = UserFacingError;
|
|
2177
2109
|
exports.assetHref = assetHref;
|
|
2178
2110
|
exports.buildAssetMetadata = buildAssetMetadata;
|
|
@@ -2183,7 +2115,6 @@ exports.collectionHref = collectionHref;
|
|
|
2183
2115
|
exports.createBackendProxyHandler = createBackendProxyHandler;
|
|
2184
2116
|
exports.createFailoverFetch = createFailoverFetch;
|
|
2185
2117
|
exports.createImageProxyHandler = createImageProxyHandler;
|
|
2186
|
-
exports.createRateLimiter = createRateLimiter;
|
|
2187
2118
|
exports.createRpcProxyHandler = createRpcProxyHandler;
|
|
2188
2119
|
exports.encodeU256 = encodeU256;
|
|
2189
2120
|
exports.formatAmount = formatAmount;
|
|
@@ -2202,7 +2133,6 @@ exports.isPrivateHost = isPrivateHost;
|
|
|
2202
2133
|
exports.isPrivateOrInsecureUrl = isPrivateOrInsecureUrl;
|
|
2203
2134
|
exports.isSameOrigin = isSameOrigin;
|
|
2204
2135
|
exports.isServiceId = isServiceId;
|
|
2205
|
-
exports.isSpoofableForwardingHeader = isSpoofableForwardingHeader;
|
|
2206
2136
|
exports.isTransientRpcError = isTransientRpcError;
|
|
2207
2137
|
exports.isValidIpfsCidPath = isValidIpfsCidPath;
|
|
2208
2138
|
exports.issueAccountSessionToken = issueAccountSessionToken;
|
|
@@ -2212,7 +2142,6 @@ exports.normalizeAddress = normalizeAddress;
|
|
|
2212
2142
|
exports.normalizeHash = normalizeHash;
|
|
2213
2143
|
exports.parseAmount = parseAmount;
|
|
2214
2144
|
exports.readBodyWithCap = readBodyWithCap;
|
|
2215
|
-
exports.requestIp = requestIp;
|
|
2216
2145
|
exports.resolveAppFeeConfig = resolveAppFeeConfig;
|
|
2217
2146
|
exports.resolveConfig = resolveConfig;
|
|
2218
2147
|
exports.resolveFeeConfig = resolveFeeConfig;
|
|
@@ -2220,7 +2149,6 @@ exports.resolveRemixPolicy = resolveRemixPolicy;
|
|
|
2220
2149
|
exports.resolveSafeImageContentType = resolveSafeImageContentType;
|
|
2221
2150
|
exports.shortenAddress = shortenAddress;
|
|
2222
2151
|
exports.stringifyBigInts = stringifyBigInts;
|
|
2223
|
-
exports.trustedClientIp = trustedClientIp;
|
|
2224
2152
|
exports.u256ToBigInt = u256ToBigInt;
|
|
2225
2153
|
exports.uploadDirectoryToBackend = uploadDirectoryToBackend;
|
|
2226
2154
|
exports.uploadFileToBackend = uploadFileToBackend;
|