@medialane/sdk 0.172.0 → 0.174.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/{chunk-BC2L2H6A.cjs → chunk-46LSYJEM.cjs} +25 -2
- package/dist/chunk-46LSYJEM.cjs.map +1 -0
- package/dist/{chunk-DDZJFN65.js → chunk-BGURLH5G.js} +25 -2
- package/dist/chunk-BGURLH5G.js.map +1 -0
- package/dist/{errors-DvSfHOZu.d.cts → errors-Bf4s_b14.d.cts} +216 -42
- package/dist/{errors-5C3YHsDE.d.ts → errors-D3wtOrcq.d.ts} +216 -42
- package/dist/index.cjs +270 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -14
- package/dist/index.d.ts +19 -14
- package/dist/index.js +193 -46
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +94 -71
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +10 -157
- package/dist/starknet/index.d.ts +10 -157
- package/dist/starknet/index.js +25 -3
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BC2L2H6A.cjs.map +0 -1
- package/dist/chunk-DDZJFN65.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { R as ResolvedFeeConfig, S as ServiceDefinition, a as ServiceCapability } from './errors-
|
|
2
|
-
export { A as AcceptSponsorshipBidIntentParams, b as AcceptSponsorshipProposalIntentParams, c as ActivityType, d as ApiActivitiesQuery, e as ApiActivity, f as ApiActivityPrice, g as ApiAdminCollectionClaim, h as ApiBusinessProvisioning, i as ApiChain, j as ApiCheckoutIntentResult, k as ApiClient, l as ApiCoin, m as ApiCoinClaimResult, n as ApiCoinPrice, o as ApiCoinPrices, p as ApiCoinsQuery, q as ApiCollection, r as ApiCollectionClaim, s as ApiCollectionProfile, t as ApiCollectionSlugClaim, u as ApiCollectionsListQuery, v as ApiCollectionsQuery, w as ApiComment, x as ApiCounterOffersQuery, y as ApiCreatorListResult, z as ApiCreatorProfile, B as ApiCreditPayment, C as ApiDrop, D as ApiDropFee, E as ApiDropListStatus, F as ApiDropMint, G as ApiEmissionCall, H as ApiEmissionResult, I as ApiFundingInstructions, J as ApiFundingIntent, K as ApiFundingMethod, L as ApiFundingStatus, M as ApiFundingSubmit, N as ApiIntent, O as ApiIntentCreated, P as ApiIpNftTokenData, Q as ApiMeta, T as ApiMetadataSignedUrl, U as ApiMetadataUpload, V as ApiOrder, W as ApiOrderConsideration, X as ApiOrderOffer, Y as ApiOrderPrice, Z as ApiOrderTokenMeta, _ as ApiOrderTxHash, $ as ApiOrdersQuery, a0 as ApiPlatformStats, a1 as ApiPointEvent, a2 as ApiPortalKey, a3 as ApiPortalKeyCreated, a4 as ApiPortalMe, a5 as ApiPortalSpend, a6 as ApiPricing, a7 as ApiPricingRule, a8 as ApiPublicRemix, a9 as ApiRemixOffer, aa as ApiRemixOfferPrice, ab as ApiRemixOffersQuery, ac as ApiReportTargetType, ad as ApiResponse, ae as ApiRewardsBadge, af as ApiRewardsBatchEntry, ag as ApiRewardsConfig, ah as ApiRewardsLeaderboardEntry, ai as ApiRewardsLevel, aj as ApiSearchCollectionResult, ak as ApiSearchCreatorResult, al as ApiSearchResult, am as ApiSearchTokenResult, an as ApiSession, ao as ApiSpendByAction, ap as ApiSponsorshipBid, aq as ApiSponsorshipLicense, ar as ApiSponsorshipLicensesQuery, as as ApiSponsorshipOffer, at as ApiSponsorshipOffersQuery, au as ApiSponsorshipProposal, av as ApiSponsorshipProposalsQuery, aw as ApiSubmitReport, ax as
|
|
1
|
+
import { R as ResolvedFeeConfig, S as ServiceDefinition, a as ServiceCapability } from './errors-Bf4s_b14.cjs';
|
|
2
|
+
export { A as AcceptSponsorshipBidIntentParams, b as AcceptSponsorshipProposalIntentParams, c as ActivityType, d as ApiActivitiesQuery, e as ApiActivity, f as ApiActivityPrice, g as ApiAdminCollectionClaim, h as ApiBusinessProvisioning, i as ApiChain, j as ApiCheckoutIntentResult, k as ApiClient, l as ApiCoin, m as ApiCoinClaimResult, n as ApiCoinPrice, o as ApiCoinPrices, p as ApiCoinsQuery, q as ApiCollection, r as ApiCollectionClaim, s as ApiCollectionProfile, t as ApiCollectionSlugClaim, u as ApiCollectionsListQuery, v as ApiCollectionsQuery, w as ApiComment, x as ApiCounterOffersQuery, y as ApiCreatorListResult, z as ApiCreatorProfile, B as ApiCreditPayment, C as ApiDrop, D as ApiDropFee, E as ApiDropListStatus, F as ApiDropMint, G as ApiEmissionCall, H as ApiEmissionResult, I as ApiFundingInstructions, J as ApiFundingIntent, K as ApiFundingMethod, L as ApiFundingStatus, M as ApiFundingSubmit, N as ApiIntent, O as ApiIntentCreated, P as ApiIpNftTokenData, Q as ApiMeta, T as ApiMetadataSignedUrl, U as ApiMetadataUpload, V as ApiOrder, W as ApiOrderConsideration, X as ApiOrderOffer, Y as ApiOrderPrice, Z as ApiOrderTokenMeta, _ as ApiOrderTxHash, $ as ApiOrdersQuery, a0 as ApiPlatformStats, a1 as ApiPointEvent, a2 as ApiPortalKey, a3 as ApiPortalKeyCreated, a4 as ApiPortalMe, a5 as ApiPortalSpend, a6 as ApiPricing, a7 as ApiPricingRule, a8 as ApiPublicRemix, a9 as ApiRemixOffer, aa as ApiRemixOfferPrice, ab as ApiRemixOffersQuery, ac as ApiReportTargetType, ad as ApiResponse, ae as ApiRewardsBadge, af as ApiRewardsBatchEntry, ag as ApiRewardsConfig, ah as ApiRewardsLeaderboardEntry, ai as ApiRewardsLevel, aj as ApiSearchCollectionResult, ak as ApiSearchCreatorResult, al as ApiSearchResult, am as ApiSearchTokenResult, an as ApiSession, ao as ApiSpendByAction, ap as ApiSponsorshipBid, aq as ApiSponsorshipLicense, ar as ApiSponsorshipLicensesQuery, as as ApiSponsorshipOffer, at as ApiSponsorshipOffersQuery, au as ApiSponsorshipProposal, av as ApiSponsorshipProposalsQuery, aw as ApiSubmitReport, ax as ApiSwapQuote, ay as ApiSwapQuoteRequest, az as ApiTierOnchain, aA as ApiToken, aB as ApiTokenBalance, aC as ApiTokenMetadata, aD as ApiTokensQuery, aE as ApiTxSyncResult, aF as ApiUserRewards, aG as ApiUserWallet, aH as ApiUsernameClaim, aI as ApiWalletActivity, aJ as AutoRemixOfferParams, aK as CancelOrderIntentParams, aL as ChainFilter, aM as CheckoutIntentItem, aN as CollectionServiceId, aO as CollectionSort, aP as CollectionTokensSort, aQ as ConfirmRemixOfferParams, aR as ConfirmSelfRemixParams, aS as ConsiderationItem, aT as CreateCheckoutIntentParams, aU as CreateCoinIntentParams, aV as CreateCollectionIntentParams, aW as CreateCommentIntentParams, aX as CreateCounterOfferIntentParams, aY as CreateDropClaimIntentParams, aZ as CreateDropManageIntentParams, a_ as CreateDropParams, a$ as CreateFundingTransferIntentParams, b0 as CreateGenesisMintIntentParams, b1 as CreateListingIntentParams, b2 as CreateMembershipParams, b3 as CreateMintIntentParams, b4 as CreatePopBurnIntentParams, b5 as CreatePopClaimIntentParams, b6 as CreatePopCollectionParams, b7 as CreatePopManageIntentParams, b8 as CreateRemixOfferParams, b9 as CreateSponsorshipOfferIntentParams, ba as CreateSponsorshipOfferParams, bb as CreateSponsorshipProposalIntentParams, bc as CreateSwapIntentParams, bd as CreateTicketParams, be as CreateTierIntentParams, bf as CreateTransferCollectionOwnershipIntentParams, bg as CreateTransferNftIntentParams, bh as CreateTransferTokenIntentParams, bi as CreateWalletManageIntentParams, bj as DropManageAction, bk as DropTerms, bl as DropTermsBody, bm as EmissionParams, bn as EnforcementDeclaration, bo as FactoryFamilyServiceId, bp as FeeConfig, bq as FeeConfigSchema, br as FulfillOrderIntentParams, bs as IPType, bt as IntentCall, bu as IntentStatus, bv as IntentType, bw as IpAttribute, bx as IpNftMetadata, by as LaunchCoinIntentParams, bz as MakeOfferIntentParams, bA as MedialaneApiError, bB as MedialaneConfig, bC as MedialaneErrorCode, bD as MintMembershipsParams, bE as MintTicketsParams, bF as OPEN_LICENSES, bG as OfferItem, bH as OpenLicense, bI as Order, bJ as OrderDetails, bK as OrderParameters, bL as OrderStatus, bM as PasskeyCancelledError, bN as PasskeyUnsupportedError, bO as PasskeyUnsupportedReason, bP as PlaceSponsorshipBidIntentParams, bQ as PopManageAction, bR as ProposeSponsorshipParams, bS as RejectSponsorshipProposalIntentParams, bT as RemixOfferStatus, bU as ResolvedConfig, bV as RetractSponsorshipBidIntentParams, bW as RetryOptions, bX as ServiceEventDeclaration, bY as SetSponsorshipOfferOpenIntentParams, bZ as SortOrder, b_ as TierServiceId, b$ as TxResult, c0 as UpdateCollectionProfileInput, c1 as UserFacingError, c2 as WalletManageAction, c3 as WithdrawSponsorshipProposalIntentParams, c4 as resolveConfig, c5 as resolveFeeConfig } from './errors-Bf4s_b14.cjs';
|
|
3
3
|
import { C as Chain } from './types-BTNjkUst.cjs';
|
|
4
4
|
export { A as AdapterTxResult, a as AssetRef, b as CHAINS, c as ChainCoordinates, d as CoordinatesByChain, e as CreateCollectionInput, D as DEFAULT_CHAIN, E as EvmCoordinates, I as IssuanceAdapter, M as MintInput, O as OrderRef, R as RegisterOrderParams, S as SolanaCoordinates, f as StarknetCoordinates, g as StellarCoordinates, V as VenueAdapter, h as getCoordinates, i as getStarknetCoordinates } from './types-BTNjkUst.cjs';
|
|
5
|
-
import 'zod';
|
|
6
5
|
import 'starknet';
|
|
6
|
+
import 'zod';
|
|
7
7
|
|
|
8
8
|
interface FeeEnv {
|
|
9
9
|
NEXT_PUBLIC_FEE_ENABLED?: string;
|
|
@@ -691,25 +691,28 @@ interface FailoverFetchOptions {
|
|
|
691
691
|
}
|
|
692
692
|
declare function createFailoverFetch(urls: string[], options?: FailoverFetchOptions): typeof fetch;
|
|
693
693
|
|
|
694
|
-
|
|
694
|
+
declare const ACCOUNT_SESSION_COOKIE = "ml_account_session";
|
|
695
|
+
interface AppGatewayConfig {
|
|
696
|
+
appId: string;
|
|
695
697
|
backendUrl: string;
|
|
696
698
|
apiKey: string | undefined;
|
|
699
|
+
allow: Record<string, RegExp[]>;
|
|
700
|
+
cacheableGets?: RegExp[];
|
|
701
|
+
timeoutMs?: number;
|
|
697
702
|
fetchImpl?: typeof fetch;
|
|
698
703
|
}
|
|
699
|
-
declare function
|
|
704
|
+
declare function createAppGateway(config: AppGatewayConfig): (req: Request, path: string[]) => Promise<Response>;
|
|
700
705
|
|
|
701
|
-
interface
|
|
702
|
-
|
|
706
|
+
interface AppSessionConfig {
|
|
707
|
+
appId: string;
|
|
703
708
|
backendUrl: string;
|
|
704
709
|
apiKey: string | undefined;
|
|
705
710
|
fetchImpl?: typeof fetch;
|
|
706
|
-
forwardCookie?: {
|
|
707
|
-
name: string;
|
|
708
|
-
header: string;
|
|
709
|
-
};
|
|
710
|
-
forwardAuthorization?: boolean;
|
|
711
711
|
}
|
|
712
|
-
declare function
|
|
712
|
+
declare function createAppSessionHandler(config: AppSessionConfig): {
|
|
713
|
+
GET(req: Request): Promise<Response>;
|
|
714
|
+
DELETE(req: Request): Promise<Response>;
|
|
715
|
+
};
|
|
713
716
|
|
|
714
717
|
declare const ALLOWED_IMAGE_CONTENT_TYPES: Set<string>;
|
|
715
718
|
declare const MAX_IMAGE_REDIRECTS = 5;
|
|
@@ -761,6 +764,8 @@ declare function getBackendSignedUrl(config: BackendMetadataConfig, kind?: "imag
|
|
|
761
764
|
|
|
762
765
|
declare function isSameOrigin(req: Request): boolean;
|
|
763
766
|
|
|
767
|
+
declare function isPublicAppRoute(method: string, path: string): boolean;
|
|
768
|
+
|
|
764
769
|
declare const IDENTITY_TTL_SECONDS = 86400;
|
|
765
770
|
declare const ACCOUNT_SESSION_TTL_SECONDS: number;
|
|
766
771
|
interface SiwsIdentity {
|
|
@@ -828,4 +833,4 @@ declare const IPFS_SAFE_CONTENT_TYPE_PREFIXES: readonly ["image/jpeg", "image/pn
|
|
|
828
833
|
declare function resolveSafeImageContentType(contentType: string): string;
|
|
829
834
|
declare const MAX_IPFS_GATEWAY_RESPONSE_BYTES: number;
|
|
830
835
|
|
|
831
|
-
export { ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type
|
|
836
|
+
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 CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FailoverFetchOptions, 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, type NextStep, POLICY_REFUSAL_CODES, 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, type TokenSource, type WalletRequest, assetHref, buildAssetMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createFailoverFetch, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPolicyRefusal, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isTransientRpcError, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { R as ResolvedFeeConfig, S as ServiceDefinition, a as ServiceCapability } from './errors-
|
|
2
|
-
export { A as AcceptSponsorshipBidIntentParams, b as AcceptSponsorshipProposalIntentParams, c as ActivityType, d as ApiActivitiesQuery, e as ApiActivity, f as ApiActivityPrice, g as ApiAdminCollectionClaim, h as ApiBusinessProvisioning, i as ApiChain, j as ApiCheckoutIntentResult, k as ApiClient, l as ApiCoin, m as ApiCoinClaimResult, n as ApiCoinPrice, o as ApiCoinPrices, p as ApiCoinsQuery, q as ApiCollection, r as ApiCollectionClaim, s as ApiCollectionProfile, t as ApiCollectionSlugClaim, u as ApiCollectionsListQuery, v as ApiCollectionsQuery, w as ApiComment, x as ApiCounterOffersQuery, y as ApiCreatorListResult, z as ApiCreatorProfile, B as ApiCreditPayment, C as ApiDrop, D as ApiDropFee, E as ApiDropListStatus, F as ApiDropMint, G as ApiEmissionCall, H as ApiEmissionResult, I as ApiFundingInstructions, J as ApiFundingIntent, K as ApiFundingMethod, L as ApiFundingStatus, M as ApiFundingSubmit, N as ApiIntent, O as ApiIntentCreated, P as ApiIpNftTokenData, Q as ApiMeta, T as ApiMetadataSignedUrl, U as ApiMetadataUpload, V as ApiOrder, W as ApiOrderConsideration, X as ApiOrderOffer, Y as ApiOrderPrice, Z as ApiOrderTokenMeta, _ as ApiOrderTxHash, $ as ApiOrdersQuery, a0 as ApiPlatformStats, a1 as ApiPointEvent, a2 as ApiPortalKey, a3 as ApiPortalKeyCreated, a4 as ApiPortalMe, a5 as ApiPortalSpend, a6 as ApiPricing, a7 as ApiPricingRule, a8 as ApiPublicRemix, a9 as ApiRemixOffer, aa as ApiRemixOfferPrice, ab as ApiRemixOffersQuery, ac as ApiReportTargetType, ad as ApiResponse, ae as ApiRewardsBadge, af as ApiRewardsBatchEntry, ag as ApiRewardsConfig, ah as ApiRewardsLeaderboardEntry, ai as ApiRewardsLevel, aj as ApiSearchCollectionResult, ak as ApiSearchCreatorResult, al as ApiSearchResult, am as ApiSearchTokenResult, an as ApiSession, ao as ApiSpendByAction, ap as ApiSponsorshipBid, aq as ApiSponsorshipLicense, ar as ApiSponsorshipLicensesQuery, as as ApiSponsorshipOffer, at as ApiSponsorshipOffersQuery, au as ApiSponsorshipProposal, av as ApiSponsorshipProposalsQuery, aw as ApiSubmitReport, ax as
|
|
1
|
+
import { R as ResolvedFeeConfig, S as ServiceDefinition, a as ServiceCapability } from './errors-D3wtOrcq.js';
|
|
2
|
+
export { A as AcceptSponsorshipBidIntentParams, b as AcceptSponsorshipProposalIntentParams, c as ActivityType, d as ApiActivitiesQuery, e as ApiActivity, f as ApiActivityPrice, g as ApiAdminCollectionClaim, h as ApiBusinessProvisioning, i as ApiChain, j as ApiCheckoutIntentResult, k as ApiClient, l as ApiCoin, m as ApiCoinClaimResult, n as ApiCoinPrice, o as ApiCoinPrices, p as ApiCoinsQuery, q as ApiCollection, r as ApiCollectionClaim, s as ApiCollectionProfile, t as ApiCollectionSlugClaim, u as ApiCollectionsListQuery, v as ApiCollectionsQuery, w as ApiComment, x as ApiCounterOffersQuery, y as ApiCreatorListResult, z as ApiCreatorProfile, B as ApiCreditPayment, C as ApiDrop, D as ApiDropFee, E as ApiDropListStatus, F as ApiDropMint, G as ApiEmissionCall, H as ApiEmissionResult, I as ApiFundingInstructions, J as ApiFundingIntent, K as ApiFundingMethod, L as ApiFundingStatus, M as ApiFundingSubmit, N as ApiIntent, O as ApiIntentCreated, P as ApiIpNftTokenData, Q as ApiMeta, T as ApiMetadataSignedUrl, U as ApiMetadataUpload, V as ApiOrder, W as ApiOrderConsideration, X as ApiOrderOffer, Y as ApiOrderPrice, Z as ApiOrderTokenMeta, _ as ApiOrderTxHash, $ as ApiOrdersQuery, a0 as ApiPlatformStats, a1 as ApiPointEvent, a2 as ApiPortalKey, a3 as ApiPortalKeyCreated, a4 as ApiPortalMe, a5 as ApiPortalSpend, a6 as ApiPricing, a7 as ApiPricingRule, a8 as ApiPublicRemix, a9 as ApiRemixOffer, aa as ApiRemixOfferPrice, ab as ApiRemixOffersQuery, ac as ApiReportTargetType, ad as ApiResponse, ae as ApiRewardsBadge, af as ApiRewardsBatchEntry, ag as ApiRewardsConfig, ah as ApiRewardsLeaderboardEntry, ai as ApiRewardsLevel, aj as ApiSearchCollectionResult, ak as ApiSearchCreatorResult, al as ApiSearchResult, am as ApiSearchTokenResult, an as ApiSession, ao as ApiSpendByAction, ap as ApiSponsorshipBid, aq as ApiSponsorshipLicense, ar as ApiSponsorshipLicensesQuery, as as ApiSponsorshipOffer, at as ApiSponsorshipOffersQuery, au as ApiSponsorshipProposal, av as ApiSponsorshipProposalsQuery, aw as ApiSubmitReport, ax as ApiSwapQuote, ay as ApiSwapQuoteRequest, az as ApiTierOnchain, aA as ApiToken, aB as ApiTokenBalance, aC as ApiTokenMetadata, aD as ApiTokensQuery, aE as ApiTxSyncResult, aF as ApiUserRewards, aG as ApiUserWallet, aH as ApiUsernameClaim, aI as ApiWalletActivity, aJ as AutoRemixOfferParams, aK as CancelOrderIntentParams, aL as ChainFilter, aM as CheckoutIntentItem, aN as CollectionServiceId, aO as CollectionSort, aP as CollectionTokensSort, aQ as ConfirmRemixOfferParams, aR as ConfirmSelfRemixParams, aS as ConsiderationItem, aT as CreateCheckoutIntentParams, aU as CreateCoinIntentParams, aV as CreateCollectionIntentParams, aW as CreateCommentIntentParams, aX as CreateCounterOfferIntentParams, aY as CreateDropClaimIntentParams, aZ as CreateDropManageIntentParams, a_ as CreateDropParams, a$ as CreateFundingTransferIntentParams, b0 as CreateGenesisMintIntentParams, b1 as CreateListingIntentParams, b2 as CreateMembershipParams, b3 as CreateMintIntentParams, b4 as CreatePopBurnIntentParams, b5 as CreatePopClaimIntentParams, b6 as CreatePopCollectionParams, b7 as CreatePopManageIntentParams, b8 as CreateRemixOfferParams, b9 as CreateSponsorshipOfferIntentParams, ba as CreateSponsorshipOfferParams, bb as CreateSponsorshipProposalIntentParams, bc as CreateSwapIntentParams, bd as CreateTicketParams, be as CreateTierIntentParams, bf as CreateTransferCollectionOwnershipIntentParams, bg as CreateTransferNftIntentParams, bh as CreateTransferTokenIntentParams, bi as CreateWalletManageIntentParams, bj as DropManageAction, bk as DropTerms, bl as DropTermsBody, bm as EmissionParams, bn as EnforcementDeclaration, bo as FactoryFamilyServiceId, bp as FeeConfig, bq as FeeConfigSchema, br as FulfillOrderIntentParams, bs as IPType, bt as IntentCall, bu as IntentStatus, bv as IntentType, bw as IpAttribute, bx as IpNftMetadata, by as LaunchCoinIntentParams, bz as MakeOfferIntentParams, bA as MedialaneApiError, bB as MedialaneConfig, bC as MedialaneErrorCode, bD as MintMembershipsParams, bE as MintTicketsParams, bF as OPEN_LICENSES, bG as OfferItem, bH as OpenLicense, bI as Order, bJ as OrderDetails, bK as OrderParameters, bL as OrderStatus, bM as PasskeyCancelledError, bN as PasskeyUnsupportedError, bO as PasskeyUnsupportedReason, bP as PlaceSponsorshipBidIntentParams, bQ as PopManageAction, bR as ProposeSponsorshipParams, bS as RejectSponsorshipProposalIntentParams, bT as RemixOfferStatus, bU as ResolvedConfig, bV as RetractSponsorshipBidIntentParams, bW as RetryOptions, bX as ServiceEventDeclaration, bY as SetSponsorshipOfferOpenIntentParams, bZ as SortOrder, b_ as TierServiceId, b$ as TxResult, c0 as UpdateCollectionProfileInput, c1 as UserFacingError, c2 as WalletManageAction, c3 as WithdrawSponsorshipProposalIntentParams, c4 as resolveConfig, c5 as resolveFeeConfig } from './errors-D3wtOrcq.js';
|
|
3
3
|
import { C as Chain } from './types-BTNjkUst.js';
|
|
4
4
|
export { A as AdapterTxResult, a as AssetRef, b as CHAINS, c as ChainCoordinates, d as CoordinatesByChain, e as CreateCollectionInput, D as DEFAULT_CHAIN, E as EvmCoordinates, I as IssuanceAdapter, M as MintInput, O as OrderRef, R as RegisterOrderParams, S as SolanaCoordinates, f as StarknetCoordinates, g as StellarCoordinates, V as VenueAdapter, h as getCoordinates, i as getStarknetCoordinates } from './types-BTNjkUst.js';
|
|
5
|
-
import 'zod';
|
|
6
5
|
import 'starknet';
|
|
6
|
+
import 'zod';
|
|
7
7
|
|
|
8
8
|
interface FeeEnv {
|
|
9
9
|
NEXT_PUBLIC_FEE_ENABLED?: string;
|
|
@@ -691,25 +691,28 @@ interface FailoverFetchOptions {
|
|
|
691
691
|
}
|
|
692
692
|
declare function createFailoverFetch(urls: string[], options?: FailoverFetchOptions): typeof fetch;
|
|
693
693
|
|
|
694
|
-
|
|
694
|
+
declare const ACCOUNT_SESSION_COOKIE = "ml_account_session";
|
|
695
|
+
interface AppGatewayConfig {
|
|
696
|
+
appId: string;
|
|
695
697
|
backendUrl: string;
|
|
696
698
|
apiKey: string | undefined;
|
|
699
|
+
allow: Record<string, RegExp[]>;
|
|
700
|
+
cacheableGets?: RegExp[];
|
|
701
|
+
timeoutMs?: number;
|
|
697
702
|
fetchImpl?: typeof fetch;
|
|
698
703
|
}
|
|
699
|
-
declare function
|
|
704
|
+
declare function createAppGateway(config: AppGatewayConfig): (req: Request, path: string[]) => Promise<Response>;
|
|
700
705
|
|
|
701
|
-
interface
|
|
702
|
-
|
|
706
|
+
interface AppSessionConfig {
|
|
707
|
+
appId: string;
|
|
703
708
|
backendUrl: string;
|
|
704
709
|
apiKey: string | undefined;
|
|
705
710
|
fetchImpl?: typeof fetch;
|
|
706
|
-
forwardCookie?: {
|
|
707
|
-
name: string;
|
|
708
|
-
header: string;
|
|
709
|
-
};
|
|
710
|
-
forwardAuthorization?: boolean;
|
|
711
711
|
}
|
|
712
|
-
declare function
|
|
712
|
+
declare function createAppSessionHandler(config: AppSessionConfig): {
|
|
713
|
+
GET(req: Request): Promise<Response>;
|
|
714
|
+
DELETE(req: Request): Promise<Response>;
|
|
715
|
+
};
|
|
713
716
|
|
|
714
717
|
declare const ALLOWED_IMAGE_CONTENT_TYPES: Set<string>;
|
|
715
718
|
declare const MAX_IMAGE_REDIRECTS = 5;
|
|
@@ -761,6 +764,8 @@ declare function getBackendSignedUrl(config: BackendMetadataConfig, kind?: "imag
|
|
|
761
764
|
|
|
762
765
|
declare function isSameOrigin(req: Request): boolean;
|
|
763
766
|
|
|
767
|
+
declare function isPublicAppRoute(method: string, path: string): boolean;
|
|
768
|
+
|
|
764
769
|
declare const IDENTITY_TTL_SECONDS = 86400;
|
|
765
770
|
declare const ACCOUNT_SESSION_TTL_SECONDS: number;
|
|
766
771
|
interface SiwsIdentity {
|
|
@@ -828,4 +833,4 @@ declare const IPFS_SAFE_CONTENT_TYPE_PREFIXES: readonly ["image/jpeg", "image/pn
|
|
|
828
833
|
declare function resolveSafeImageContentType(contentType: string): string;
|
|
829
834
|
declare const MAX_IPFS_GATEWAY_RESPONSE_BYTES: number;
|
|
830
835
|
|
|
831
|
-
export { ACCOUNT_SESSION_TTL_SECONDS, ALLOWED_IMAGE_CONTENT_TYPES, type
|
|
836
|
+
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 CanonicalHash, type CappedBody, type CertificateEmissionNextStep, type CertificateEmissionRun, Chain, type ConfirmResult, DEFAULT_CURRENCY, type DataTokenizationRun, type FailoverFetchOptions, 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, type NextStep, POLICY_REFUSAL_CODES, 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, type TokenSource, type WalletRequest, assetHref, buildAssetMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createAppGateway, createAppSessionHandler, createFailoverFetch, createImageProxyHandler, createLaunchpadRunsClient, dropHref, encodeU256, formatAmount, getBackendSignedUrl, getDerivativesTerm, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isCertificateEmissionRun, isDataTokenizationRun, isPolicyRefusal, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isServiceId, isTicketingRun, isTransientRpcError, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, listServices, normalizeAddress, normalizeHash, parseAmount, readBodyWithCap, resolveAppFeeConfig, resolveRemixPolicy, resolveSafeImageContentType, shortenAddress, stringifyBigInts, u256ToBigInt, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ApiClient, DEFAULT_CURRENCY, FeeConfigSchema, MedialaneApiError, POLICY_REFUSAL_CODES, PasskeyCancelledError, PasskeyUnsupportedError, 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, UserFacingError, assetHref, chainFromSlug, chainSlug, coinHref, collectionHref, createFailoverFetch, dropHref, encodeU256, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isPolicyRefusal, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, resolveAppFeeConfig, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, u256ToBigInt } from './chunk-
|
|
1
|
+
export { ApiClient, DEFAULT_CURRENCY, FeeConfigSchema, MedialaneApiError, POLICY_REFUSAL_CODES, PasskeyCancelledError, PasskeyUnsupportedError, 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, UserFacingError, assetHref, chainFromSlug, chainSlug, coinHref, collectionHref, createFailoverFetch, dropHref, encodeU256, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isPolicyRefusal, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, resolveAppFeeConfig, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, u256ToBigInt } from './chunk-BGURLH5G.js';
|
|
2
2
|
export { CHAINS, DEFAULT_CHAIN, getCoordinates, getStarknetCoordinates } from './chunk-WYKCGQPN.js';
|
|
3
3
|
import { hmac } from '@noble/hashes/hmac.js';
|
|
4
4
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
@@ -110,65 +110,144 @@ function isSameOrigin(req) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// src/server/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
// src/server/app-gateway.ts
|
|
114
|
+
var ACCOUNT_SESSION_COOKIE = "ml_account_session";
|
|
115
|
+
var SESSION_MAX_AGE_SECONDS = 30 * 24 * 60 * 60;
|
|
116
|
+
var SIGN_IN_PATHS = /* @__PURE__ */ new Set(["auth/email/register-account", "auth/email/verify-code", "auth/siws/verify"]);
|
|
117
|
+
var EDGE_CACHE_CONTROL = "public, s-maxage=30, stale-while-revalidate=120";
|
|
118
|
+
var DROPPED_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
119
|
+
"connection",
|
|
120
|
+
"keep-alive",
|
|
121
|
+
"proxy-authenticate",
|
|
122
|
+
"proxy-authorization",
|
|
123
|
+
"te",
|
|
124
|
+
"trailers",
|
|
125
|
+
"transfer-encoding",
|
|
126
|
+
"upgrade",
|
|
127
|
+
"host",
|
|
128
|
+
"content-length",
|
|
129
|
+
"accept-encoding",
|
|
130
|
+
"cookie",
|
|
131
|
+
"x-api-key",
|
|
132
|
+
"x-app-id",
|
|
133
|
+
"x-account-session",
|
|
134
|
+
"authorization"
|
|
135
|
+
]);
|
|
136
|
+
var DROPPED_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
|
|
137
|
+
"connection",
|
|
138
|
+
"keep-alive",
|
|
139
|
+
"transfer-encoding",
|
|
140
|
+
"content-length",
|
|
141
|
+
"content-encoding",
|
|
142
|
+
"set-cookie"
|
|
143
|
+
]);
|
|
117
144
|
function readCookie(req, name) {
|
|
118
145
|
const raw = req.headers.get("cookie");
|
|
119
146
|
if (!raw) return null;
|
|
120
147
|
for (const part of raw.split(";")) {
|
|
121
148
|
const eq = part.indexOf("=");
|
|
122
|
-
if (eq
|
|
123
|
-
if (part.slice(0, eq).trim() === name) return part.slice(eq + 1).trim();
|
|
149
|
+
if (eq !== -1 && part.slice(0, eq).trim() === name) return part.slice(eq + 1).trim() || null;
|
|
124
150
|
}
|
|
125
151
|
return null;
|
|
126
152
|
}
|
|
127
|
-
function
|
|
153
|
+
function sessionCookie(value, maxAge = SESSION_MAX_AGE_SECONDS) {
|
|
154
|
+
const secure = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
155
|
+
return `${ACCOUNT_SESSION_COOKIE}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${maxAge}${secure}`;
|
|
156
|
+
}
|
|
157
|
+
function json(body, status) {
|
|
158
|
+
return Response.json(body, { status });
|
|
159
|
+
}
|
|
160
|
+
function createAppGateway(config) {
|
|
128
161
|
const doFetch = config.fetchImpl ?? fetch;
|
|
129
|
-
const
|
|
130
|
-
return async function
|
|
131
|
-
if (!isSameOrigin(req)) {
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
body = await req.json();
|
|
140
|
-
} catch {
|
|
141
|
-
return proxyError(-32700, "Parse error", 400);
|
|
142
|
-
}
|
|
143
|
-
const headers2 = { "Content-Type": "application/json", "x-api-key": config.apiKey };
|
|
144
|
-
if (config.forwardCookie) {
|
|
145
|
-
const value = readCookie(req, config.forwardCookie.name);
|
|
146
|
-
if (value) headers2[config.forwardCookie.header] = value;
|
|
147
|
-
}
|
|
148
|
-
if (config.forwardAuthorization) {
|
|
149
|
-
const authorization = req.headers.get("authorization");
|
|
150
|
-
if (authorization) headers2.authorization = authorization;
|
|
162
|
+
const base = config.backendUrl.replace(/\/$/, "");
|
|
163
|
+
return async function appGateway(req, path) {
|
|
164
|
+
if (!isSameOrigin(req)) return json({ error: "Cross-origin requests are not allowed" }, 403);
|
|
165
|
+
if (!config.apiKey) return json({ error: "Service unavailable" }, 500);
|
|
166
|
+
if (path.some((s) => s === "." || s === ".." || s === "")) return json({ error: "Invalid path" }, 400);
|
|
167
|
+
const joined = path.join("/");
|
|
168
|
+
const method = req.method.toUpperCase();
|
|
169
|
+
if (!(config.allow[method] ?? []).some((re) => re.test(joined))) {
|
|
170
|
+
return json({ error: `Path not allowed: ${method} /v1/${joined}` }, 403);
|
|
151
171
|
}
|
|
172
|
+
const headers2 = new Headers();
|
|
173
|
+
req.headers.forEach((v, k) => {
|
|
174
|
+
if (!DROPPED_REQUEST_HEADERS.has(k.toLowerCase())) headers2.set(k, v);
|
|
175
|
+
});
|
|
176
|
+
headers2.set("x-api-key", config.apiKey);
|
|
177
|
+
headers2.set("x-app-id", config.appId);
|
|
178
|
+
const session = readCookie(req, ACCOUNT_SESSION_COOKIE);
|
|
179
|
+
if (session) headers2.set("x-account-session", session);
|
|
180
|
+
const search = new URL(req.url).search;
|
|
181
|
+
const target = `${base}/v1/${path.map(encodeURIComponent).join("/")}${search}`;
|
|
182
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
183
|
+
let res;
|
|
152
184
|
try {
|
|
153
|
-
|
|
154
|
-
method
|
|
185
|
+
res = await doFetch(target, {
|
|
186
|
+
method,
|
|
155
187
|
headers: headers2,
|
|
156
|
-
body:
|
|
188
|
+
body: hasBody ? await req.arrayBuffer() : void 0,
|
|
189
|
+
cache: "no-store",
|
|
190
|
+
redirect: "manual",
|
|
191
|
+
signal: AbortSignal.timeout(config.timeoutMs ?? 55e3)
|
|
157
192
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
} catch {
|
|
164
|
-
return proxyError(-32603, "Backend unreachable", 502);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
if (e instanceof DOMException && e.name === "TimeoutError") {
|
|
195
|
+
return json({ error: "The service took too long to respond" }, 504);
|
|
196
|
+
}
|
|
197
|
+
return json({ error: "Service unavailable" }, 502);
|
|
165
198
|
}
|
|
199
|
+
const out = new Headers();
|
|
200
|
+
res.headers.forEach((v, k) => {
|
|
201
|
+
if (!DROPPED_RESPONSE_HEADERS.has(k.toLowerCase())) out.set(k, v);
|
|
202
|
+
});
|
|
203
|
+
if (method === "POST" && res.ok && SIGN_IN_PATHS.has(joined)) {
|
|
204
|
+
const text = await res.text();
|
|
205
|
+
let body = null;
|
|
206
|
+
try {
|
|
207
|
+
body = JSON.parse(text);
|
|
208
|
+
} catch {
|
|
209
|
+
body = null;
|
|
210
|
+
}
|
|
211
|
+
if (!body) return new Response(text, { status: res.status, headers: out });
|
|
212
|
+
const token = typeof body.accountToken === "string" ? body.accountToken : null;
|
|
213
|
+
delete body.accountToken;
|
|
214
|
+
delete body.token;
|
|
215
|
+
out.set("content-type", "application/json");
|
|
216
|
+
if (token) out.append("set-cookie", sessionCookie(token));
|
|
217
|
+
return new Response(JSON.stringify(body), { status: res.status, headers: out });
|
|
218
|
+
}
|
|
219
|
+
if (method === "GET" && res.ok && !session && (config.cacheableGets ?? []).some((re) => re.test(joined))) {
|
|
220
|
+
out.set("cache-control", EDGE_CACHE_CONTROL);
|
|
221
|
+
}
|
|
222
|
+
return new Response(res.body, { status: res.status, headers: out });
|
|
166
223
|
};
|
|
167
224
|
}
|
|
168
225
|
|
|
169
|
-
// src/server/
|
|
170
|
-
function
|
|
171
|
-
|
|
226
|
+
// src/server/app-session.ts
|
|
227
|
+
function signedOut() {
|
|
228
|
+
const res = Response.json(null);
|
|
229
|
+
res.headers.append("set-cookie", sessionCookie("", 0));
|
|
230
|
+
return res;
|
|
231
|
+
}
|
|
232
|
+
function createAppSessionHandler(config) {
|
|
233
|
+
const doFetch = config.fetchImpl ?? fetch;
|
|
234
|
+
const base = config.backendUrl.replace(/\/$/, "");
|
|
235
|
+
return {
|
|
236
|
+
async GET(req) {
|
|
237
|
+
const session = readCookie(req, ACCOUNT_SESSION_COOKIE);
|
|
238
|
+
if (!session) return Response.json(null);
|
|
239
|
+
const res = await doFetch(`${base}/v1/users/me`, {
|
|
240
|
+
headers: { "x-api-key": config.apiKey ?? "", "x-app-id": config.appId, "x-account-session": session },
|
|
241
|
+
cache: "no-store"
|
|
242
|
+
});
|
|
243
|
+
if (res.status === 401 || res.status === 403) return signedOut();
|
|
244
|
+
if (!res.ok) return Response.json({ error: "Session check failed" }, { status: 502 });
|
|
245
|
+
return Response.json(await res.json());
|
|
246
|
+
},
|
|
247
|
+
async DELETE() {
|
|
248
|
+
return signedOut();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
172
251
|
}
|
|
173
252
|
|
|
174
253
|
// src/server/ssrf-guard.ts
|
|
@@ -439,11 +518,11 @@ function endpoint(config, path) {
|
|
|
439
518
|
function headers(config, extra) {
|
|
440
519
|
return { "x-api-key": config.apiKey, ...extra };
|
|
441
520
|
}
|
|
442
|
-
async function uploadJsonToBackend(config,
|
|
521
|
+
async function uploadJsonToBackend(config, json2) {
|
|
443
522
|
const res = await (config.fetchImpl ?? fetch)(endpoint(config, "upload"), {
|
|
444
523
|
method: "POST",
|
|
445
524
|
headers: headers(config, { "Content-Type": "application/json" }),
|
|
446
|
-
body: JSON.stringify(
|
|
525
|
+
body: JSON.stringify(json2)
|
|
447
526
|
});
|
|
448
527
|
const data = await res.json().catch(() => ({}));
|
|
449
528
|
if (!res.ok || !data.data) throw new Error(data.error ?? "Metadata upload failed");
|
|
@@ -480,6 +559,74 @@ async function getBackendSignedUrl(config, kind = "image") {
|
|
|
480
559
|
if (!res.ok || !data.data) throw new Error(data.error ?? "Failed to create upload URL");
|
|
481
560
|
return data.data.url;
|
|
482
561
|
}
|
|
562
|
+
|
|
563
|
+
// src/server/app-routes.ts
|
|
564
|
+
var SEG = "[^/]+";
|
|
565
|
+
var PUBLIC_ROUTES = {
|
|
566
|
+
GET: [
|
|
567
|
+
"orders",
|
|
568
|
+
`orders/${SEG}`,
|
|
569
|
+
`orders/token/${SEG}/${SEG}`,
|
|
570
|
+
`orders/user/${SEG}`,
|
|
571
|
+
`orders/received/${SEG}`,
|
|
572
|
+
"orders/counter-offers",
|
|
573
|
+
"tokens",
|
|
574
|
+
`tokens/owned/${SEG}`,
|
|
575
|
+
`tokens/${SEG}/${SEG}`,
|
|
576
|
+
`tokens/${SEG}/${SEG}/(history|comments|remixes)`,
|
|
577
|
+
"collections",
|
|
578
|
+
`collections/${SEG}`,
|
|
579
|
+
`collections/${SEG}/tokens`,
|
|
580
|
+
`collections/${SEG}/profile`,
|
|
581
|
+
"activities",
|
|
582
|
+
`activities/${SEG}`,
|
|
583
|
+
"search",
|
|
584
|
+
"metadata/resolve",
|
|
585
|
+
"creators",
|
|
586
|
+
`creators/${SEG}/profile`,
|
|
587
|
+
`creators/by-username/${SEG}`,
|
|
588
|
+
`creators/${SEG}/hidden`,
|
|
589
|
+
"coins",
|
|
590
|
+
"coins/prices",
|
|
591
|
+
"coins/claims",
|
|
592
|
+
`coins/${SEG}`,
|
|
593
|
+
`coins/${SEG}/guarantees`,
|
|
594
|
+
`pop/${SEG}/claim-info`,
|
|
595
|
+
"drops",
|
|
596
|
+
`drops/${SEG}`,
|
|
597
|
+
`drops/${SEG}/mints`,
|
|
598
|
+
`drops/${SEG}/state`,
|
|
599
|
+
"rewards",
|
|
600
|
+
"rewards/config",
|
|
601
|
+
"rewards/batch",
|
|
602
|
+
`rewards/${SEG}`,
|
|
603
|
+
`rewards/${SEG}/events`,
|
|
604
|
+
`club/${SEG}/${SEG}`,
|
|
605
|
+
`club/${SEG}/${SEG}/member/${SEG}`,
|
|
606
|
+
`tickets/${SEG}/${SEG}`,
|
|
607
|
+
`tickets/${SEG}/count`,
|
|
608
|
+
`ipnft/${SEG}/${SEG}`,
|
|
609
|
+
"stats",
|
|
610
|
+
"prices",
|
|
611
|
+
`remix-offers/${SEG}`,
|
|
612
|
+
"sponsorship/offers",
|
|
613
|
+
`sponsorship/offers/${SEG}`,
|
|
614
|
+
`sponsorship/offers/${SEG}/bids`,
|
|
615
|
+
"sponsorship/proposals",
|
|
616
|
+
`sponsorship/proposals/${SEG}`,
|
|
617
|
+
"sponsorship/licenses",
|
|
618
|
+
`sponsorship/licenses/${SEG}`,
|
|
619
|
+
"auth/email/exists"
|
|
620
|
+
].map((p) => new RegExp(`^${p}$`)),
|
|
621
|
+
POST: [
|
|
622
|
+
"auth/email/(request-code|verify-code|register-account|confirm)",
|
|
623
|
+
"auth/siws/(nonce|verify)"
|
|
624
|
+
].map((p) => new RegExp(`^${p}$`))
|
|
625
|
+
};
|
|
626
|
+
function isPublicAppRoute(method, path) {
|
|
627
|
+
if (path.split("/").some((s) => s === "." || s === ".." || s === "")) return false;
|
|
628
|
+
return (PUBLIC_ROUTES[method.toUpperCase()] ?? []).some((re) => re.test(path));
|
|
629
|
+
}
|
|
483
630
|
var IDENTITY_PREFIX = "siws_";
|
|
484
631
|
var ACCOUNT_SESSION_PREFIX = "account_session_";
|
|
485
632
|
var IDENTITY_DOMAIN = "siws-identity-v1";
|
|
@@ -648,6 +795,6 @@ function resolveSafeImageContentType(contentType) {
|
|
|
648
795
|
}
|
|
649
796
|
var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
|
|
650
797
|
|
|
651
|
-
export { 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, OPEN_LICENSES, RESERVED_TRAITS, RunRequestError, buildAssetMetadata,
|
|
798
|
+
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, OPEN_LICENSES, RESERVED_TRAITS, RunRequestError, buildAssetMetadata, createAppGateway, createAppSessionHandler, createImageProxyHandler, createLaunchpadRunsClient, getBackendSignedUrl, getDerivativesTerm, isCertificateEmissionRun, isDataTokenizationRun, isPrivateHost, isPrivateOrInsecureUrl, isPublicAppRoute, isSameOrigin, isTicketingRun, isValidIpfsCidPath, issueAccountSessionToken, issueSiwsToken, readBodyWithCap, resolveRemixPolicy, resolveSafeImageContentType, uploadDirectoryToBackend, uploadFileToBackend, uploadJsonToBackend, validateUrl, verifyAccountSessionToken, verifySiwsToken };
|
|
652
799
|
//# sourceMappingURL=index.js.map
|
|
653
800
|
//# sourceMappingURL=index.js.map
|