@medialane/sdk 0.191.0 → 0.193.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/index.cjs +29 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -837,6 +837,7 @@ declare const MAX_IPFS_GATEWAY_RESPONSE_BYTES: number;
|
|
|
837
837
|
type UploadKind = "image" | "document" | "media";
|
|
838
838
|
interface UploadLimit {
|
|
839
839
|
mimeTypes: readonly string[];
|
|
840
|
+
extensions: readonly string[];
|
|
840
841
|
}
|
|
841
842
|
declare const MAX_UPLOAD_BYTES: number;
|
|
842
843
|
declare const UPLOAD_LIMITS: Record<UploadKind, UploadLimit>;
|
|
@@ -844,5 +845,11 @@ declare function formatFileSize(bytes: number): string;
|
|
|
844
845
|
declare function uploadSizeError(file: {
|
|
845
846
|
size: number;
|
|
846
847
|
}, kind?: UploadKind): string | null;
|
|
848
|
+
declare function acceptFor(kind: UploadKind): string;
|
|
849
|
+
declare function uploadError(file: {
|
|
850
|
+
size: number;
|
|
851
|
+
type: string;
|
|
852
|
+
name?: string;
|
|
853
|
+
}, kind?: UploadKind): string | null;
|
|
847
854
|
|
|
848
|
-
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type AppGatewayConfig, type AppSessionConfig, type AssetAttribute, type AssetMetadata, type BackendMetadataConfig, type BackendUploadResult, type BuildAssetMetadataInput, type BuildCollectionMetadataInput, type CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type CollectionMetadata, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FeeEnv, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, type ImageProxyConfig, type LaunchpadRun, type LaunchpadRunsClient, type LaunchpadRunsClientOptions, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, type NextStep, RESERVED_TRAITS, type RemixPolicy, type RemixPolicyInput, ResolvedFeeConfig, type RunQuote, type RunQuoteLine, RunRequestError, type RunStatus, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DATA_TOKENIZATION_721_CONTRACT, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_DROP_FACTORY_START_BLOCK, STARKNET_EKUBO_CORE, STARKNET_GENESIS_MINT_CONTRACT, STARKNET_GENESIS_NFT_URI, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, STARKNET_POP_FACTORY_START_BLOCK, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SiwsIdentity, type SupportedToken, type SupportedTokenSymbol, type TicketingNextStep, type TicketingRun, UPLOAD_LIMITS, type UploadKind, type UploadLimit, type WalletRequest, assetHref, buildAssetMetadata, buildCollectionMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, formatFileSize, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, profileHref, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
|
855
|
+
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type AppGatewayConfig, type AppSessionConfig, type AssetAttribute, type AssetMetadata, type BackendMetadataConfig, type BackendUploadResult, type BuildAssetMetadataInput, type BuildCollectionMetadataInput, type CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type CollectionMetadata, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FeeEnv, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, type ImageProxyConfig, type LaunchpadRun, type LaunchpadRunsClient, type LaunchpadRunsClientOptions, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, type NextStep, RESERVED_TRAITS, type RemixPolicy, type RemixPolicyInput, ResolvedFeeConfig, type RunQuote, type RunQuoteLine, RunRequestError, type RunStatus, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DATA_TOKENIZATION_721_CONTRACT, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_DROP_FACTORY_START_BLOCK, STARKNET_EKUBO_CORE, STARKNET_GENESIS_MINT_CONTRACT, STARKNET_GENESIS_NFT_URI, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, STARKNET_POP_FACTORY_START_BLOCK, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SiwsIdentity, type SupportedToken, type SupportedTokenSymbol, type TicketingNextStep, type TicketingRun, UPLOAD_LIMITS, type UploadKind, type UploadLimit, type WalletRequest, acceptFor, assetHref, buildAssetMetadata, buildCollectionMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, formatFileSize, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, profileHref, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadError, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -837,6 +837,7 @@ declare const MAX_IPFS_GATEWAY_RESPONSE_BYTES: number;
|
|
|
837
837
|
type UploadKind = "image" | "document" | "media";
|
|
838
838
|
interface UploadLimit {
|
|
839
839
|
mimeTypes: readonly string[];
|
|
840
|
+
extensions: readonly string[];
|
|
840
841
|
}
|
|
841
842
|
declare const MAX_UPLOAD_BYTES: number;
|
|
842
843
|
declare const UPLOAD_LIMITS: Record<UploadKind, UploadLimit>;
|
|
@@ -844,5 +845,11 @@ declare function formatFileSize(bytes: number): string;
|
|
|
844
845
|
declare function uploadSizeError(file: {
|
|
845
846
|
size: number;
|
|
846
847
|
}, kind?: UploadKind): string | null;
|
|
848
|
+
declare function acceptFor(kind: UploadKind): string;
|
|
849
|
+
declare function uploadError(file: {
|
|
850
|
+
size: number;
|
|
851
|
+
type: string;
|
|
852
|
+
name?: string;
|
|
853
|
+
}, kind?: UploadKind): string | null;
|
|
847
854
|
|
|
848
|
-
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type AppGatewayConfig, type AppSessionConfig, type AssetAttribute, type AssetMetadata, type BackendMetadataConfig, type BackendUploadResult, type BuildAssetMetadataInput, type BuildCollectionMetadataInput, type CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type CollectionMetadata, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FeeEnv, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, type ImageProxyConfig, type LaunchpadRun, type LaunchpadRunsClient, type LaunchpadRunsClientOptions, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, type NextStep, RESERVED_TRAITS, type RemixPolicy, type RemixPolicyInput, ResolvedFeeConfig, type RunQuote, type RunQuoteLine, RunRequestError, type RunStatus, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DATA_TOKENIZATION_721_CONTRACT, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_DROP_FACTORY_START_BLOCK, STARKNET_EKUBO_CORE, STARKNET_GENESIS_MINT_CONTRACT, STARKNET_GENESIS_NFT_URI, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, STARKNET_POP_FACTORY_START_BLOCK, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SiwsIdentity, type SupportedToken, type SupportedTokenSymbol, type TicketingNextStep, type TicketingRun, UPLOAD_LIMITS, type UploadKind, type UploadLimit, type WalletRequest, assetHref, buildAssetMetadata, buildCollectionMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, formatFileSize, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, profileHref, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
|
855
|
+
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type AppGatewayConfig, type AppSessionConfig, type AssetAttribute, type AssetMetadata, type BackendMetadataConfig, type BackendUploadResult, type BuildAssetMetadataInput, type BuildCollectionMetadataInput, type CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type CollectionMetadata, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FeeEnv, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, type ImageProxyConfig, type LaunchpadRun, type LaunchpadRunsClient, type LaunchpadRunsClientOptions, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, type NextStep, RESERVED_TRAITS, type RemixPolicy, type RemixPolicyInput, ResolvedFeeConfig, type RunQuote, type RunQuoteLine, RunRequestError, type RunStatus, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DATA_TOKENIZATION_721_CONTRACT, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_DROP_FACTORY_START_BLOCK, STARKNET_EKUBO_CORE, STARKNET_GENESIS_MINT_CONTRACT, STARKNET_GENESIS_NFT_URI, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, STARKNET_POP_FACTORY_START_BLOCK, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SiwsIdentity, type SupportedToken, type SupportedTokenSymbol, type TicketingNextStep, type TicketingRun, UPLOAD_LIMITS, type UploadKind, type UploadLimit, type WalletRequest, acceptFor, assetHref, buildAssetMetadata, buildCollectionMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, formatFileSize, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, profileHref, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadError, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
package/dist/index.js
CHANGED
|
@@ -495,7 +495,11 @@ function createImageProxyHandler(config) {
|
|
|
495
495
|
if ("error" in validated) return jsonError(validated.error, validated.status);
|
|
496
496
|
let upstream;
|
|
497
497
|
try {
|
|
498
|
-
|
|
498
|
+
const isBackendImage = backendOrigin && /^\/media\/[^/]+\/[^/]+\/[^/]+\/image$/.test(validated.url.pathname);
|
|
499
|
+
upstream = await safeFetch(
|
|
500
|
+
isBackendImage ? new URL(validated.url.pathname, backendOrigin) : validated.url,
|
|
501
|
+
MAX_IMAGE_REDIRECTS
|
|
502
|
+
);
|
|
499
503
|
} catch {
|
|
500
504
|
return jsonError("Failed to fetch image", 502);
|
|
501
505
|
}
|
|
@@ -821,9 +825,11 @@ var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
|
|
|
821
825
|
// src/uploads.ts
|
|
822
826
|
var MB = 1024 * 1024;
|
|
823
827
|
var MAX_UPLOAD_BYTES = 90 * MB;
|
|
828
|
+
var IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp", ".avif"];
|
|
824
829
|
var UPLOAD_LIMITS = {
|
|
825
830
|
image: {
|
|
826
|
-
mimeTypes: ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/webp"]
|
|
831
|
+
mimeTypes: ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/webp", "image/avif"],
|
|
832
|
+
extensions: IMAGE_EXTENSIONS
|
|
827
833
|
},
|
|
828
834
|
document: {
|
|
829
835
|
mimeTypes: [
|
|
@@ -835,7 +841,8 @@ var UPLOAD_LIMITS = {
|
|
|
835
841
|
"text/plain",
|
|
836
842
|
"text/markdown",
|
|
837
843
|
"application/octet-stream"
|
|
838
|
-
]
|
|
844
|
+
],
|
|
845
|
+
extensions: [".pdf", ".doc", ".docx", ".odt", ".rtf", ".txt", ".md"]
|
|
839
846
|
},
|
|
840
847
|
media: {
|
|
841
848
|
mimeTypes: [
|
|
@@ -854,7 +861,8 @@ var UPLOAD_LIMITS = {
|
|
|
854
861
|
"audio/webm",
|
|
855
862
|
"audio/flac",
|
|
856
863
|
"application/pdf"
|
|
857
|
-
]
|
|
864
|
+
],
|
|
865
|
+
extensions: [...IMAGE_EXTENSIONS, ".mp4", ".webm", ".ogv", ".ogg", ".mp3", ".wav", ".flac", ".pdf"]
|
|
858
866
|
}
|
|
859
867
|
};
|
|
860
868
|
function formatFileSize(bytes) {
|
|
@@ -866,7 +874,22 @@ function uploadSizeError(file, kind = "image") {
|
|
|
866
874
|
const noun = kind === "image" ? "image" : "file";
|
|
867
875
|
return `That ${noun} is ${formatFileSize(file.size)}. Please choose one under ${formatFileSize(MAX_UPLOAD_BYTES)}.`;
|
|
868
876
|
}
|
|
877
|
+
function acceptFor(kind) {
|
|
878
|
+
const { mimeTypes, extensions } = UPLOAD_LIMITS[kind];
|
|
879
|
+
return [...mimeTypes, ...extensions].join(",");
|
|
880
|
+
}
|
|
881
|
+
function typeList(extensions) {
|
|
882
|
+
const names = extensions.map((ext) => ext.slice(1).toUpperCase());
|
|
883
|
+
return names.length > 1 ? `${names.slice(0, -1).join(", ")} or ${names[names.length - 1]}` : names.join("");
|
|
884
|
+
}
|
|
885
|
+
function uploadError(file, kind = "image") {
|
|
886
|
+
const { mimeTypes, extensions } = UPLOAD_LIMITS[kind];
|
|
887
|
+
const name = (file.name ?? "").toLowerCase();
|
|
888
|
+
const allowed = mimeTypes.includes(file.type) || file.type === "" && extensions.some((ext) => name.endsWith(ext));
|
|
889
|
+
if (!allowed) return `Choose ${kind === "image" ? "an image" : "a file"} in ${typeList(extensions)}.`;
|
|
890
|
+
return uploadSizeError(file, kind);
|
|
891
|
+
}
|
|
869
892
|
|
|
870
|
-
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, OPEN_LICENSES, RESERVED_TRAITS, RunRequestError, UPLOAD_LIMITS, buildAssetMetadata, buildCollectionMetadata, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, formatFileSize, getBackendSignedUrl, getDerivativesTerm, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, readBodyWithCap, resolveRemixPolicy, resolveSafeImageContentType, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
|
893
|
+
export { ACCOUNT_SESSION_COOKIE, ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, IDENTITY_TTL_SECONDS, IPFS_SAFE_CONTENT_TYPE_PREFIXES, MAX_IMAGE_PROXY_BYTES, MAX_IMAGE_REDIRECTS, MAX_IPFS_GATEWAY_RESPONSE_BYTES, MAX_UPLOAD_BYTES, OPEN_LICENSES, RESERVED_TRAITS, RunRequestError, UPLOAD_LIMITS, acceptFor, buildAssetMetadata, buildCollectionMetadata, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, formatFileSize, getBackendSignedUrl, getDerivativesTerm, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, readBodyWithCap, resolveRemixPolicy, resolveSafeImageContentType, uploadDirectoryToBackend, uploadError, uploadFileToBackend, uploadJsonToBackend, uploadSizeError, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
|
871
894
|
//# sourceMappingURL=index.js.map
|
|
872
895
|
//# sourceMappingURL=index.js.map
|