@medialane/sdk 0.39.0 → 0.40.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 +145 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -1
- package/dist/index.d.ts +128 -1
- package/dist/index.js +136 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1731,6 +1731,133 @@ declare class MedialaneClient {
|
|
|
1731
1731
|
get marketplaceContract(): string;
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
|
+
declare const ADMIN_SCOPE = "admin-api";
|
|
1735
|
+
/** The wallet-signed authorization for a session key. */
|
|
1736
|
+
interface AdminGrant {
|
|
1737
|
+
wallet: string;
|
|
1738
|
+
chain: string;
|
|
1739
|
+
sessionPublicKey: string;
|
|
1740
|
+
sessionKeyHash: string;
|
|
1741
|
+
scope: string;
|
|
1742
|
+
issuedAt: number;
|
|
1743
|
+
expiresAt: number;
|
|
1744
|
+
walletSig: string[];
|
|
1745
|
+
}
|
|
1746
|
+
interface AdminSession {
|
|
1747
|
+
grant: AdminGrant;
|
|
1748
|
+
sessionPrivateKey: string;
|
|
1749
|
+
}
|
|
1750
|
+
interface AdminRequest {
|
|
1751
|
+
method: string;
|
|
1752
|
+
path: string;
|
|
1753
|
+
body: string;
|
|
1754
|
+
nonce: string;
|
|
1755
|
+
ts: number;
|
|
1756
|
+
}
|
|
1757
|
+
/** Compact session-key signature over adminRequestDigest. */
|
|
1758
|
+
type AdminRequestSig = string;
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Canonical felt digest of a request — the SINGLE definition shared by signer
|
|
1762
|
+
* (portal/agent) and verifier (backend). Binds method+path+query+body+nonce+ts,
|
|
1763
|
+
* so a captured request cannot be retargeted or mutated without invalidating it.
|
|
1764
|
+
*/
|
|
1765
|
+
declare function adminRequestDigest(req: AdminRequest): string;
|
|
1766
|
+
|
|
1767
|
+
/** Sign a request with the session private key. */
|
|
1768
|
+
declare function signAdminRequest(sessionPrivateKey: string, req: AdminRequest): AdminRequestSig;
|
|
1769
|
+
/** Verify a request signature against the full session public key. */
|
|
1770
|
+
declare function verifyAdminRequestSig(sessionPublicKey: string, req: AdminRequest, sig: AdminRequestSig): boolean;
|
|
1771
|
+
|
|
1772
|
+
interface AdminSessionTypedDataInput {
|
|
1773
|
+
sessionKeyHash: string;
|
|
1774
|
+
scope: string;
|
|
1775
|
+
issuedAt: number;
|
|
1776
|
+
expiresAt: number;
|
|
1777
|
+
chainId?: string;
|
|
1778
|
+
}
|
|
1779
|
+
/** The SNIP-12 typed data the wallet signs — rebuilt identically on the backend. */
|
|
1780
|
+
declare function buildAdminSessionTypedData(p: AdminSessionTypedDataInput): {
|
|
1781
|
+
readonly types: {
|
|
1782
|
+
readonly StarknetDomain: readonly [{
|
|
1783
|
+
readonly name: "name";
|
|
1784
|
+
readonly type: "shortstring";
|
|
1785
|
+
}, {
|
|
1786
|
+
readonly name: "version";
|
|
1787
|
+
readonly type: "shortstring";
|
|
1788
|
+
}, {
|
|
1789
|
+
readonly name: "chainId";
|
|
1790
|
+
readonly type: "shortstring";
|
|
1791
|
+
}, {
|
|
1792
|
+
readonly name: "revision";
|
|
1793
|
+
readonly type: "shortstring";
|
|
1794
|
+
}];
|
|
1795
|
+
readonly AdminSession: readonly [{
|
|
1796
|
+
readonly name: "sessionKeyHash";
|
|
1797
|
+
readonly type: "felt";
|
|
1798
|
+
}, {
|
|
1799
|
+
readonly name: "scope";
|
|
1800
|
+
readonly type: "shortstring";
|
|
1801
|
+
}, {
|
|
1802
|
+
readonly name: "issuedAt";
|
|
1803
|
+
readonly type: "felt";
|
|
1804
|
+
}, {
|
|
1805
|
+
readonly name: "expiresAt";
|
|
1806
|
+
readonly type: "felt";
|
|
1807
|
+
}];
|
|
1808
|
+
};
|
|
1809
|
+
readonly primaryType: "AdminSession";
|
|
1810
|
+
readonly domain: {
|
|
1811
|
+
readonly name: "Medialane Admin";
|
|
1812
|
+
readonly version: "1";
|
|
1813
|
+
readonly chainId: string;
|
|
1814
|
+
readonly revision: "1";
|
|
1815
|
+
};
|
|
1816
|
+
readonly message: {
|
|
1817
|
+
readonly sessionKeyHash: string;
|
|
1818
|
+
readonly scope: string;
|
|
1819
|
+
readonly issuedAt: string;
|
|
1820
|
+
readonly expiresAt: string;
|
|
1821
|
+
};
|
|
1822
|
+
};
|
|
1823
|
+
/** felt commitment to a full session public key (fits in the signed message). */
|
|
1824
|
+
declare function sessionKeyHashOf(sessionPublicKey: string): string;
|
|
1825
|
+
interface CreateGrantOpts {
|
|
1826
|
+
wallet: string;
|
|
1827
|
+
chain?: string;
|
|
1828
|
+
chainId?: string;
|
|
1829
|
+
ttlSeconds?: number;
|
|
1830
|
+
now?: () => number;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Generate an ephemeral session keypair and have `signTypedData` (the connected
|
|
1834
|
+
* wallet's signMessage) sign the grant. The private key never leaves the caller.
|
|
1835
|
+
*/
|
|
1836
|
+
declare function createAdminSessionGrant(signTypedData: (data: ReturnType<typeof buildAdminSessionTypedData>) => Promise<string[]>, opts: CreateGrantOpts): Promise<AdminSession>;
|
|
1837
|
+
|
|
1838
|
+
declare const ADMIN_HEADERS: {
|
|
1839
|
+
readonly grant: "x-ml-admin-grant";
|
|
1840
|
+
readonly sig: "x-ml-admin-sig";
|
|
1841
|
+
readonly nonce: "x-ml-admin-nonce";
|
|
1842
|
+
readonly ts: "x-ml-admin-ts";
|
|
1843
|
+
};
|
|
1844
|
+
declare function randomNonce(): string;
|
|
1845
|
+
/** Build the four request headers from a session + (method, path, body). */
|
|
1846
|
+
declare function encodeAdminHeaders(session: AdminSession, reqInit: {
|
|
1847
|
+
method: string;
|
|
1848
|
+
path: string;
|
|
1849
|
+
body?: string;
|
|
1850
|
+
now?: () => number;
|
|
1851
|
+
}): Record<string, string>;
|
|
1852
|
+
interface ParsedAdminHeaders {
|
|
1853
|
+
grant: AdminGrant;
|
|
1854
|
+
sig: string;
|
|
1855
|
+
nonce: string;
|
|
1856
|
+
ts: number;
|
|
1857
|
+
}
|
|
1858
|
+
/** Parse + shape-check the headers on the backend. Returns null if malformed. */
|
|
1859
|
+
declare function parseAdminHeaders(get: (name: string) => string | null | undefined): ParsedAdminHeaders | null;
|
|
1860
|
+
|
|
1734
1861
|
/** Medialane721 marketplace venue — immutable, ownerless (redesign, deployed 2026-05-31). */
|
|
1735
1862
|
declare const MARKETPLACE_721_CONTRACT_MAINNET: string;
|
|
1736
1863
|
/** Class hash of the Medialane721 venue. */
|
|
@@ -6110,4 +6237,4 @@ declare function build1155OrderTypedData(message: Record<string, unknown>, chain
|
|
|
6110
6237
|
declare function buildCancellationTypedData(message: Record<string, unknown>, chainId: constants.StarknetChainId | string): TypedData;
|
|
6111
6238
|
declare function build1155CancellationTypedData(message: Record<string, unknown>, chainId: constants.StarknetChainId | string): TypedData;
|
|
6112
6239
|
|
|
6113
|
-
export { type ActivityType, type AddSupplyParams, type ApiActivitiesQuery, type ApiActivity, type ApiActivityPrice, type ApiAdminCollectionClaim, type ApiAppSource, type ApiChain, ApiClient, type ApiCoin, type ApiCoinsQuery, type ApiCollection, type ApiCollectionClaim, type ApiCollectionProfile, type ApiCollectionSlugClaim, type ApiCollectionsQuery, type ApiComment, type ApiCounterOffersQuery, type ApiCreatorListResult, type ApiCreatorProfile, type ApiIntent, type ApiIntentCreated, type ApiKeyStatus, type ApiMeta, type ApiMetadataSignedUrl, type ApiMetadataUpload, type ApiOrder, type ApiOrderConsideration, type ApiOrderOffer, type ApiOrderPrice, type ApiOrderTokenMeta, type ApiOrderTxHash, type ApiOrdersQuery, type ApiPortalKey, type ApiPortalKeyCreated, type ApiPortalMe, type ApiPublicRemix, type ApiRemixOffer, type ApiRemixOfferPrice, type ApiRemixOffersQuery, type ApiResponse, type ApiSearchCollectionResult, type ApiSearchCreatorResult, type ApiSearchResult, type ApiSearchTokenResult, type ApiToken, type ApiTokenBalance, type ApiTokenMetadata, type ApiUsageDay, type ApiUserWallet, type ApiWalletType, type ApiWebhookCreated, type ApiWebhookEndpoint, type AutoRemixOfferParams, type BatchMintEditionParams, type BuildFeeCallParams, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, type CancelOrder1155Params, type CancelOrderIntentParams, type CancelOrderParams, type Cancelation, type CartItem, type Chain, type ChainCoordinates, type ClaimConditions, CollectionRegistryABI, type CollectionSort, type ConfirmRemixOfferParams, type ConfirmSelfRemixParams, type ConsiderationItem, type CreateCollectionIntentParams, type CreateCollectionParams, type CreateCounterOfferIntentParams, type CreateCreatorCoinParams, type CreateDropParams, type CreateListing1155Params, type CreateListingIntentParams, type CreateListingParams, type CreateMintIntentParams, type CreatePopCollectionParams, type CreateRemixOfferParams, type CreateWebhookParams, CreatorCoinFactoryABI, type CreatorCoinPrice, type CreatorCoinReceiptLike, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, type DeployCollectionParams, DropCollectionABI, DropFactoryABI, type DropMintStatus, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, type EkuboLaunchParams, type EkuboPoolParams, type EnforcementDeclaration, type FailoverFetchOptions, type FeeConfig, FeeConfigSchema, type FeeSurface, type FulfillOrder1155Params, type FulfillOrderIntentParams, type FulfillOrderParams, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, type IPType, type IntentCall, type IntentStatus, type IntentType, type IpAttribute, type IpNftMetadata, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, type MakeOffer1155Params, type MakeOfferIntentParams, type MakeOfferParams, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, type MedialaneConfig, MedialaneError, type MedialaneErrorCode, type MintEditionParams, type MintParams, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, type OfferItem, type OpenLicense, type Order, type OrderDetails, type OrderParameters, type OrderStatus, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, type PopBatchEligibilityItem, type PopClaimStatus, type PopEventType, PopService, type RemixOfferStatus, type ResolvedConfig, type ResolvedFeeConfig, type RetryOptions, SUPPORTED_TOKENS, type ServiceCapability, type ServiceDefinition, type ServiceEventDeclaration, type ServiceId, type SortOrder, type SupportedToken, type SupportedTokenSymbol, type TenantPlan, type TxResult, VALIDATED_EKUBO_PARAMS, type WebhookEventType, type WebhookStatus, build1155CancellationTypedData, build1155OrderTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createFailoverFetch, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, parseCreatorCoinCreated, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol };
|
|
6240
|
+
export { ADMIN_HEADERS, ADMIN_SCOPE, type ActivityType, type AddSupplyParams, type AdminGrant, type AdminRequest, type AdminRequestSig, type AdminSession, type AdminSessionTypedDataInput, type ApiActivitiesQuery, type ApiActivity, type ApiActivityPrice, type ApiAdminCollectionClaim, type ApiAppSource, type ApiChain, ApiClient, type ApiCoin, type ApiCoinsQuery, type ApiCollection, type ApiCollectionClaim, type ApiCollectionProfile, type ApiCollectionSlugClaim, type ApiCollectionsQuery, type ApiComment, type ApiCounterOffersQuery, type ApiCreatorListResult, type ApiCreatorProfile, type ApiIntent, type ApiIntentCreated, type ApiKeyStatus, type ApiMeta, type ApiMetadataSignedUrl, type ApiMetadataUpload, type ApiOrder, type ApiOrderConsideration, type ApiOrderOffer, type ApiOrderPrice, type ApiOrderTokenMeta, type ApiOrderTxHash, type ApiOrdersQuery, type ApiPortalKey, type ApiPortalKeyCreated, type ApiPortalMe, type ApiPublicRemix, type ApiRemixOffer, type ApiRemixOfferPrice, type ApiRemixOffersQuery, type ApiResponse, type ApiSearchCollectionResult, type ApiSearchCreatorResult, type ApiSearchResult, type ApiSearchTokenResult, type ApiToken, type ApiTokenBalance, type ApiTokenMetadata, type ApiUsageDay, type ApiUserWallet, type ApiWalletType, type ApiWebhookCreated, type ApiWebhookEndpoint, type AutoRemixOfferParams, type BatchMintEditionParams, type BuildFeeCallParams, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, type CancelOrder1155Params, type CancelOrderIntentParams, type CancelOrderParams, type Cancelation, type CartItem, type Chain, type ChainCoordinates, type ClaimConditions, CollectionRegistryABI, type CollectionSort, type ConfirmRemixOfferParams, type ConfirmSelfRemixParams, type ConsiderationItem, type CreateCollectionIntentParams, type CreateCollectionParams, type CreateCounterOfferIntentParams, type CreateCreatorCoinParams, type CreateDropParams, type CreateGrantOpts, type CreateListing1155Params, type CreateListingIntentParams, type CreateListingParams, type CreateMintIntentParams, type CreatePopCollectionParams, type CreateRemixOfferParams, type CreateWebhookParams, CreatorCoinFactoryABI, type CreatorCoinPrice, type CreatorCoinReceiptLike, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, type DeployCollectionParams, DropCollectionABI, DropFactoryABI, type DropMintStatus, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, type EkuboLaunchParams, type EkuboPoolParams, type EnforcementDeclaration, type FailoverFetchOptions, type FeeConfig, FeeConfigSchema, type FeeSurface, type FulfillOrder1155Params, type FulfillOrderIntentParams, type FulfillOrderParams, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, type IPType, type IntentCall, type IntentStatus, type IntentType, type IpAttribute, type IpNftMetadata, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, type MakeOffer1155Params, type MakeOfferIntentParams, type MakeOfferParams, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, type MedialaneConfig, MedialaneError, type MedialaneErrorCode, type MintEditionParams, type MintParams, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, type OfferItem, type OpenLicense, type Order, type OrderDetails, type OrderParameters, type OrderStatus, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, type ParsedAdminHeaders, type PopBatchEligibilityItem, type PopClaimStatus, type PopEventType, PopService, type RemixOfferStatus, type ResolvedConfig, type ResolvedFeeConfig, type RetryOptions, SUPPORTED_TOKENS, type ServiceCapability, type ServiceDefinition, type ServiceEventDeclaration, type ServiceId, type SortOrder, type SupportedToken, type SupportedTokenSymbol, type TenantPlan, type TxResult, VALIDATED_EKUBO_PARAMS, type WebhookEventType, type WebhookStatus, adminRequestDigest, build1155CancellationTypedData, build1155OrderTypedData, buildAdminSessionTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createAdminSessionGrant, createFailoverFetch, encodeAdminHeaders, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAdminHeaders, parseAmount, parseCreatorCoinCreated, randomNonce, resolveConfig, resolveFeeConfig, sessionKeyHashOf, shortenAddress, signAdminRequest, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol, verifyAdminRequestSig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1731,6 +1731,133 @@ declare class MedialaneClient {
|
|
|
1731
1731
|
get marketplaceContract(): string;
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
|
+
declare const ADMIN_SCOPE = "admin-api";
|
|
1735
|
+
/** The wallet-signed authorization for a session key. */
|
|
1736
|
+
interface AdminGrant {
|
|
1737
|
+
wallet: string;
|
|
1738
|
+
chain: string;
|
|
1739
|
+
sessionPublicKey: string;
|
|
1740
|
+
sessionKeyHash: string;
|
|
1741
|
+
scope: string;
|
|
1742
|
+
issuedAt: number;
|
|
1743
|
+
expiresAt: number;
|
|
1744
|
+
walletSig: string[];
|
|
1745
|
+
}
|
|
1746
|
+
interface AdminSession {
|
|
1747
|
+
grant: AdminGrant;
|
|
1748
|
+
sessionPrivateKey: string;
|
|
1749
|
+
}
|
|
1750
|
+
interface AdminRequest {
|
|
1751
|
+
method: string;
|
|
1752
|
+
path: string;
|
|
1753
|
+
body: string;
|
|
1754
|
+
nonce: string;
|
|
1755
|
+
ts: number;
|
|
1756
|
+
}
|
|
1757
|
+
/** Compact session-key signature over adminRequestDigest. */
|
|
1758
|
+
type AdminRequestSig = string;
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Canonical felt digest of a request — the SINGLE definition shared by signer
|
|
1762
|
+
* (portal/agent) and verifier (backend). Binds method+path+query+body+nonce+ts,
|
|
1763
|
+
* so a captured request cannot be retargeted or mutated without invalidating it.
|
|
1764
|
+
*/
|
|
1765
|
+
declare function adminRequestDigest(req: AdminRequest): string;
|
|
1766
|
+
|
|
1767
|
+
/** Sign a request with the session private key. */
|
|
1768
|
+
declare function signAdminRequest(sessionPrivateKey: string, req: AdminRequest): AdminRequestSig;
|
|
1769
|
+
/** Verify a request signature against the full session public key. */
|
|
1770
|
+
declare function verifyAdminRequestSig(sessionPublicKey: string, req: AdminRequest, sig: AdminRequestSig): boolean;
|
|
1771
|
+
|
|
1772
|
+
interface AdminSessionTypedDataInput {
|
|
1773
|
+
sessionKeyHash: string;
|
|
1774
|
+
scope: string;
|
|
1775
|
+
issuedAt: number;
|
|
1776
|
+
expiresAt: number;
|
|
1777
|
+
chainId?: string;
|
|
1778
|
+
}
|
|
1779
|
+
/** The SNIP-12 typed data the wallet signs — rebuilt identically on the backend. */
|
|
1780
|
+
declare function buildAdminSessionTypedData(p: AdminSessionTypedDataInput): {
|
|
1781
|
+
readonly types: {
|
|
1782
|
+
readonly StarknetDomain: readonly [{
|
|
1783
|
+
readonly name: "name";
|
|
1784
|
+
readonly type: "shortstring";
|
|
1785
|
+
}, {
|
|
1786
|
+
readonly name: "version";
|
|
1787
|
+
readonly type: "shortstring";
|
|
1788
|
+
}, {
|
|
1789
|
+
readonly name: "chainId";
|
|
1790
|
+
readonly type: "shortstring";
|
|
1791
|
+
}, {
|
|
1792
|
+
readonly name: "revision";
|
|
1793
|
+
readonly type: "shortstring";
|
|
1794
|
+
}];
|
|
1795
|
+
readonly AdminSession: readonly [{
|
|
1796
|
+
readonly name: "sessionKeyHash";
|
|
1797
|
+
readonly type: "felt";
|
|
1798
|
+
}, {
|
|
1799
|
+
readonly name: "scope";
|
|
1800
|
+
readonly type: "shortstring";
|
|
1801
|
+
}, {
|
|
1802
|
+
readonly name: "issuedAt";
|
|
1803
|
+
readonly type: "felt";
|
|
1804
|
+
}, {
|
|
1805
|
+
readonly name: "expiresAt";
|
|
1806
|
+
readonly type: "felt";
|
|
1807
|
+
}];
|
|
1808
|
+
};
|
|
1809
|
+
readonly primaryType: "AdminSession";
|
|
1810
|
+
readonly domain: {
|
|
1811
|
+
readonly name: "Medialane Admin";
|
|
1812
|
+
readonly version: "1";
|
|
1813
|
+
readonly chainId: string;
|
|
1814
|
+
readonly revision: "1";
|
|
1815
|
+
};
|
|
1816
|
+
readonly message: {
|
|
1817
|
+
readonly sessionKeyHash: string;
|
|
1818
|
+
readonly scope: string;
|
|
1819
|
+
readonly issuedAt: string;
|
|
1820
|
+
readonly expiresAt: string;
|
|
1821
|
+
};
|
|
1822
|
+
};
|
|
1823
|
+
/** felt commitment to a full session public key (fits in the signed message). */
|
|
1824
|
+
declare function sessionKeyHashOf(sessionPublicKey: string): string;
|
|
1825
|
+
interface CreateGrantOpts {
|
|
1826
|
+
wallet: string;
|
|
1827
|
+
chain?: string;
|
|
1828
|
+
chainId?: string;
|
|
1829
|
+
ttlSeconds?: number;
|
|
1830
|
+
now?: () => number;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Generate an ephemeral session keypair and have `signTypedData` (the connected
|
|
1834
|
+
* wallet's signMessage) sign the grant. The private key never leaves the caller.
|
|
1835
|
+
*/
|
|
1836
|
+
declare function createAdminSessionGrant(signTypedData: (data: ReturnType<typeof buildAdminSessionTypedData>) => Promise<string[]>, opts: CreateGrantOpts): Promise<AdminSession>;
|
|
1837
|
+
|
|
1838
|
+
declare const ADMIN_HEADERS: {
|
|
1839
|
+
readonly grant: "x-ml-admin-grant";
|
|
1840
|
+
readonly sig: "x-ml-admin-sig";
|
|
1841
|
+
readonly nonce: "x-ml-admin-nonce";
|
|
1842
|
+
readonly ts: "x-ml-admin-ts";
|
|
1843
|
+
};
|
|
1844
|
+
declare function randomNonce(): string;
|
|
1845
|
+
/** Build the four request headers from a session + (method, path, body). */
|
|
1846
|
+
declare function encodeAdminHeaders(session: AdminSession, reqInit: {
|
|
1847
|
+
method: string;
|
|
1848
|
+
path: string;
|
|
1849
|
+
body?: string;
|
|
1850
|
+
now?: () => number;
|
|
1851
|
+
}): Record<string, string>;
|
|
1852
|
+
interface ParsedAdminHeaders {
|
|
1853
|
+
grant: AdminGrant;
|
|
1854
|
+
sig: string;
|
|
1855
|
+
nonce: string;
|
|
1856
|
+
ts: number;
|
|
1857
|
+
}
|
|
1858
|
+
/** Parse + shape-check the headers on the backend. Returns null if malformed. */
|
|
1859
|
+
declare function parseAdminHeaders(get: (name: string) => string | null | undefined): ParsedAdminHeaders | null;
|
|
1860
|
+
|
|
1734
1861
|
/** Medialane721 marketplace venue — immutable, ownerless (redesign, deployed 2026-05-31). */
|
|
1735
1862
|
declare const MARKETPLACE_721_CONTRACT_MAINNET: string;
|
|
1736
1863
|
/** Class hash of the Medialane721 venue. */
|
|
@@ -6110,4 +6237,4 @@ declare function build1155OrderTypedData(message: Record<string, unknown>, chain
|
|
|
6110
6237
|
declare function buildCancellationTypedData(message: Record<string, unknown>, chainId: constants.StarknetChainId | string): TypedData;
|
|
6111
6238
|
declare function build1155CancellationTypedData(message: Record<string, unknown>, chainId: constants.StarknetChainId | string): TypedData;
|
|
6112
6239
|
|
|
6113
|
-
export { type ActivityType, type AddSupplyParams, type ApiActivitiesQuery, type ApiActivity, type ApiActivityPrice, type ApiAdminCollectionClaim, type ApiAppSource, type ApiChain, ApiClient, type ApiCoin, type ApiCoinsQuery, type ApiCollection, type ApiCollectionClaim, type ApiCollectionProfile, type ApiCollectionSlugClaim, type ApiCollectionsQuery, type ApiComment, type ApiCounterOffersQuery, type ApiCreatorListResult, type ApiCreatorProfile, type ApiIntent, type ApiIntentCreated, type ApiKeyStatus, type ApiMeta, type ApiMetadataSignedUrl, type ApiMetadataUpload, type ApiOrder, type ApiOrderConsideration, type ApiOrderOffer, type ApiOrderPrice, type ApiOrderTokenMeta, type ApiOrderTxHash, type ApiOrdersQuery, type ApiPortalKey, type ApiPortalKeyCreated, type ApiPortalMe, type ApiPublicRemix, type ApiRemixOffer, type ApiRemixOfferPrice, type ApiRemixOffersQuery, type ApiResponse, type ApiSearchCollectionResult, type ApiSearchCreatorResult, type ApiSearchResult, type ApiSearchTokenResult, type ApiToken, type ApiTokenBalance, type ApiTokenMetadata, type ApiUsageDay, type ApiUserWallet, type ApiWalletType, type ApiWebhookCreated, type ApiWebhookEndpoint, type AutoRemixOfferParams, type BatchMintEditionParams, type BuildFeeCallParams, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, type CancelOrder1155Params, type CancelOrderIntentParams, type CancelOrderParams, type Cancelation, type CartItem, type Chain, type ChainCoordinates, type ClaimConditions, CollectionRegistryABI, type CollectionSort, type ConfirmRemixOfferParams, type ConfirmSelfRemixParams, type ConsiderationItem, type CreateCollectionIntentParams, type CreateCollectionParams, type CreateCounterOfferIntentParams, type CreateCreatorCoinParams, type CreateDropParams, type CreateListing1155Params, type CreateListingIntentParams, type CreateListingParams, type CreateMintIntentParams, type CreatePopCollectionParams, type CreateRemixOfferParams, type CreateWebhookParams, CreatorCoinFactoryABI, type CreatorCoinPrice, type CreatorCoinReceiptLike, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, type DeployCollectionParams, DropCollectionABI, DropFactoryABI, type DropMintStatus, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, type EkuboLaunchParams, type EkuboPoolParams, type EnforcementDeclaration, type FailoverFetchOptions, type FeeConfig, FeeConfigSchema, type FeeSurface, type FulfillOrder1155Params, type FulfillOrderIntentParams, type FulfillOrderParams, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, type IPType, type IntentCall, type IntentStatus, type IntentType, type IpAttribute, type IpNftMetadata, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, type MakeOffer1155Params, type MakeOfferIntentParams, type MakeOfferParams, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, type MedialaneConfig, MedialaneError, type MedialaneErrorCode, type MintEditionParams, type MintParams, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, type OfferItem, type OpenLicense, type Order, type OrderDetails, type OrderParameters, type OrderStatus, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, type PopBatchEligibilityItem, type PopClaimStatus, type PopEventType, PopService, type RemixOfferStatus, type ResolvedConfig, type ResolvedFeeConfig, type RetryOptions, SUPPORTED_TOKENS, type ServiceCapability, type ServiceDefinition, type ServiceEventDeclaration, type ServiceId, type SortOrder, type SupportedToken, type SupportedTokenSymbol, type TenantPlan, type TxResult, VALIDATED_EKUBO_PARAMS, type WebhookEventType, type WebhookStatus, build1155CancellationTypedData, build1155OrderTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createFailoverFetch, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, parseCreatorCoinCreated, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol };
|
|
6240
|
+
export { ADMIN_HEADERS, ADMIN_SCOPE, type ActivityType, type AddSupplyParams, type AdminGrant, type AdminRequest, type AdminRequestSig, type AdminSession, type AdminSessionTypedDataInput, type ApiActivitiesQuery, type ApiActivity, type ApiActivityPrice, type ApiAdminCollectionClaim, type ApiAppSource, type ApiChain, ApiClient, type ApiCoin, type ApiCoinsQuery, type ApiCollection, type ApiCollectionClaim, type ApiCollectionProfile, type ApiCollectionSlugClaim, type ApiCollectionsQuery, type ApiComment, type ApiCounterOffersQuery, type ApiCreatorListResult, type ApiCreatorProfile, type ApiIntent, type ApiIntentCreated, type ApiKeyStatus, type ApiMeta, type ApiMetadataSignedUrl, type ApiMetadataUpload, type ApiOrder, type ApiOrderConsideration, type ApiOrderOffer, type ApiOrderPrice, type ApiOrderTokenMeta, type ApiOrderTxHash, type ApiOrdersQuery, type ApiPortalKey, type ApiPortalKeyCreated, type ApiPortalMe, type ApiPublicRemix, type ApiRemixOffer, type ApiRemixOfferPrice, type ApiRemixOffersQuery, type ApiResponse, type ApiSearchCollectionResult, type ApiSearchCreatorResult, type ApiSearchResult, type ApiSearchTokenResult, type ApiToken, type ApiTokenBalance, type ApiTokenMetadata, type ApiUsageDay, type ApiUserWallet, type ApiWalletType, type ApiWebhookCreated, type ApiWebhookEndpoint, type AutoRemixOfferParams, type BatchMintEditionParams, type BuildFeeCallParams, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, type CancelOrder1155Params, type CancelOrderIntentParams, type CancelOrderParams, type Cancelation, type CartItem, type Chain, type ChainCoordinates, type ClaimConditions, CollectionRegistryABI, type CollectionSort, type ConfirmRemixOfferParams, type ConfirmSelfRemixParams, type ConsiderationItem, type CreateCollectionIntentParams, type CreateCollectionParams, type CreateCounterOfferIntentParams, type CreateCreatorCoinParams, type CreateDropParams, type CreateGrantOpts, type CreateListing1155Params, type CreateListingIntentParams, type CreateListingParams, type CreateMintIntentParams, type CreatePopCollectionParams, type CreateRemixOfferParams, type CreateWebhookParams, CreatorCoinFactoryABI, type CreatorCoinPrice, type CreatorCoinReceiptLike, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, type DeployCollectionParams, DropCollectionABI, DropFactoryABI, type DropMintStatus, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, type EkuboLaunchParams, type EkuboPoolParams, type EnforcementDeclaration, type FailoverFetchOptions, type FeeConfig, FeeConfigSchema, type FeeSurface, type FulfillOrder1155Params, type FulfillOrderIntentParams, type FulfillOrderParams, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, type IPType, type IntentCall, type IntentStatus, type IntentType, type IpAttribute, type IpNftMetadata, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, type MakeOffer1155Params, type MakeOfferIntentParams, type MakeOfferParams, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, type MedialaneConfig, MedialaneError, type MedialaneErrorCode, type MintEditionParams, type MintParams, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, type OfferItem, type OpenLicense, type Order, type OrderDetails, type OrderParameters, type OrderStatus, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, type ParsedAdminHeaders, type PopBatchEligibilityItem, type PopClaimStatus, type PopEventType, PopService, type RemixOfferStatus, type ResolvedConfig, type ResolvedFeeConfig, type RetryOptions, SUPPORTED_TOKENS, type ServiceCapability, type ServiceDefinition, type ServiceEventDeclaration, type ServiceId, type SortOrder, type SupportedToken, type SupportedTokenSymbol, type TenantPlan, type TxResult, VALIDATED_EKUBO_PARAMS, type WebhookEventType, type WebhookStatus, adminRequestDigest, build1155CancellationTypedData, build1155OrderTypedData, buildAdminSessionTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createAdminSessionGrant, createFailoverFetch, encodeAdminHeaders, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAdminHeaders, parseAmount, parseCreatorCoinCreated, randomNonce, resolveConfig, resolveFeeConfig, sessionKeyHashOf, shortenAddress, signAdminRequest, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol, verifyAdminRequestSig };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { hash, cairo, num, Contract, uint256, RpcProvider, TypedDataRevision, shortString, constants } from 'starknet';
|
|
2
|
+
import { hash, cairo, num, Contract, uint256, RpcProvider, ec, encode, TypedDataRevision, shortString, constants } from 'starknet';
|
|
3
3
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
|
|
@@ -5623,10 +5623,10 @@ function normalizeEvm(address) {
|
|
|
5623
5623
|
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
5624
5624
|
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
5625
5625
|
const lower = m[1].toLowerCase();
|
|
5626
|
-
const
|
|
5626
|
+
const hash4 = keccak_256(new TextEncoder().encode(lower));
|
|
5627
5627
|
let out = "0x";
|
|
5628
5628
|
for (let i = 0; i < 40; i++) {
|
|
5629
|
-
const nibble =
|
|
5629
|
+
const nibble = hash4[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
5630
5630
|
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
5631
5631
|
}
|
|
5632
5632
|
return out;
|
|
@@ -5640,12 +5640,12 @@ function normalizeSolana(address) {
|
|
|
5640
5640
|
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
5641
5641
|
}
|
|
5642
5642
|
}
|
|
5643
|
-
function normalizeHash(
|
|
5643
|
+
function normalizeHash(hash4) {
|
|
5644
5644
|
try {
|
|
5645
|
-
const hex = num.toHex(BigInt(
|
|
5645
|
+
const hex = num.toHex(BigInt(hash4));
|
|
5646
5646
|
return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
|
|
5647
5647
|
} catch {
|
|
5648
|
-
throw new Error(`Invalid hash: "${
|
|
5648
|
+
throw new Error(`Invalid hash: "${hash4}"`);
|
|
5649
5649
|
}
|
|
5650
5650
|
}
|
|
5651
5651
|
function shortenAddress(chain, address, chars = 4) {
|
|
@@ -6728,6 +6728,135 @@ var MedialaneClient = class {
|
|
|
6728
6728
|
}
|
|
6729
6729
|
};
|
|
6730
6730
|
|
|
6731
|
+
// src/admin-auth/types.ts
|
|
6732
|
+
var ADMIN_SCOPE = "admin-api";
|
|
6733
|
+
function adminRequestDigest(req) {
|
|
6734
|
+
return hash.computePoseidonHashOnElements([
|
|
6735
|
+
hash.starknetKeccak(req.method.toUpperCase()),
|
|
6736
|
+
hash.starknetKeccak(req.path),
|
|
6737
|
+
hash.starknetKeccak(req.body ?? ""),
|
|
6738
|
+
num.toBigInt(req.nonce),
|
|
6739
|
+
BigInt(req.ts)
|
|
6740
|
+
]);
|
|
6741
|
+
}
|
|
6742
|
+
function signAdminRequest(sessionPrivateKey, req) {
|
|
6743
|
+
const digest = adminRequestDigest(req);
|
|
6744
|
+
return ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
6745
|
+
}
|
|
6746
|
+
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
6747
|
+
try {
|
|
6748
|
+
return ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
6749
|
+
} catch {
|
|
6750
|
+
return false;
|
|
6751
|
+
}
|
|
6752
|
+
}
|
|
6753
|
+
function buildAdminSessionTypedData(p) {
|
|
6754
|
+
return {
|
|
6755
|
+
types: {
|
|
6756
|
+
StarknetDomain: [
|
|
6757
|
+
{ name: "name", type: "shortstring" },
|
|
6758
|
+
{ name: "version", type: "shortstring" },
|
|
6759
|
+
{ name: "chainId", type: "shortstring" },
|
|
6760
|
+
{ name: "revision", type: "shortstring" }
|
|
6761
|
+
],
|
|
6762
|
+
AdminSession: [
|
|
6763
|
+
{ name: "sessionKeyHash", type: "felt" },
|
|
6764
|
+
{ name: "scope", type: "shortstring" },
|
|
6765
|
+
{ name: "issuedAt", type: "felt" },
|
|
6766
|
+
{ name: "expiresAt", type: "felt" }
|
|
6767
|
+
]
|
|
6768
|
+
},
|
|
6769
|
+
primaryType: "AdminSession",
|
|
6770
|
+
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
6771
|
+
message: {
|
|
6772
|
+
sessionKeyHash: p.sessionKeyHash,
|
|
6773
|
+
scope: p.scope,
|
|
6774
|
+
issuedAt: String(p.issuedAt),
|
|
6775
|
+
expiresAt: String(p.expiresAt)
|
|
6776
|
+
}
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
function sessionKeyHashOf(sessionPublicKey) {
|
|
6780
|
+
return num.toHex(hash.starknetKeccak(sessionPublicKey));
|
|
6781
|
+
}
|
|
6782
|
+
async function createAdminSessionGrant(signTypedData, opts) {
|
|
6783
|
+
const priv = ec.starkCurve.utils.randomPrivateKey();
|
|
6784
|
+
const sessionPrivateKey = "0x" + encode.buf2hex(priv);
|
|
6785
|
+
const sessionPublicKey = "0x" + encode.buf2hex(ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
6786
|
+
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
6787
|
+
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
6788
|
+
const issuedAt = nowSec;
|
|
6789
|
+
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
6790
|
+
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
6791
|
+
const walletSig = await signTypedData(data);
|
|
6792
|
+
const grant = {
|
|
6793
|
+
wallet: opts.wallet,
|
|
6794
|
+
chain: opts.chain ?? "STARKNET",
|
|
6795
|
+
sessionPublicKey,
|
|
6796
|
+
sessionKeyHash,
|
|
6797
|
+
scope: ADMIN_SCOPE,
|
|
6798
|
+
issuedAt,
|
|
6799
|
+
expiresAt,
|
|
6800
|
+
walletSig
|
|
6801
|
+
};
|
|
6802
|
+
return { grant, sessionPrivateKey };
|
|
6803
|
+
}
|
|
6804
|
+
|
|
6805
|
+
// src/admin-auth/headers.ts
|
|
6806
|
+
var ADMIN_HEADERS = {
|
|
6807
|
+
grant: "x-ml-admin-grant",
|
|
6808
|
+
sig: "x-ml-admin-sig",
|
|
6809
|
+
nonce: "x-ml-admin-nonce",
|
|
6810
|
+
ts: "x-ml-admin-ts"
|
|
6811
|
+
};
|
|
6812
|
+
function b64urlEncode(s) {
|
|
6813
|
+
const bytes = new TextEncoder().encode(s);
|
|
6814
|
+
let bin = "";
|
|
6815
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
6816
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6817
|
+
}
|
|
6818
|
+
function b64urlDecode(s) {
|
|
6819
|
+
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
6820
|
+
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
6821
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
6822
|
+
return new TextDecoder().decode(bytes);
|
|
6823
|
+
}
|
|
6824
|
+
function randomNonce() {
|
|
6825
|
+
const b = new Uint8Array(16);
|
|
6826
|
+
crypto.getRandomValues(b);
|
|
6827
|
+
let hex = "";
|
|
6828
|
+
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
6829
|
+
return "0x" + hex;
|
|
6830
|
+
}
|
|
6831
|
+
function encodeAdminHeaders(session, reqInit) {
|
|
6832
|
+
const nonce = randomNonce();
|
|
6833
|
+
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
6834
|
+
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
6835
|
+
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
6836
|
+
return {
|
|
6837
|
+
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
6838
|
+
[ADMIN_HEADERS.sig]: sig,
|
|
6839
|
+
[ADMIN_HEADERS.nonce]: nonce,
|
|
6840
|
+
[ADMIN_HEADERS.ts]: String(ts)
|
|
6841
|
+
};
|
|
6842
|
+
}
|
|
6843
|
+
function parseAdminHeaders(get) {
|
|
6844
|
+
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
6845
|
+
const sig = get(ADMIN_HEADERS.sig);
|
|
6846
|
+
const nonce = get(ADMIN_HEADERS.nonce);
|
|
6847
|
+
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
6848
|
+
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
6849
|
+
try {
|
|
6850
|
+
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
6851
|
+
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
6852
|
+
const ts = Number(tsRaw);
|
|
6853
|
+
if (!Number.isFinite(ts)) return null;
|
|
6854
|
+
return { grant, sig, nonce, ts };
|
|
6855
|
+
} catch {
|
|
6856
|
+
return null;
|
|
6857
|
+
}
|
|
6858
|
+
}
|
|
6859
|
+
|
|
6731
6860
|
// src/types/api.ts
|
|
6732
6861
|
var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
|
|
6733
6862
|
|
|
@@ -6977,6 +7106,6 @@ function getServicesByCapability(cap) {
|
|
|
6977
7106
|
);
|
|
6978
7107
|
}
|
|
6979
7108
|
|
|
6980
|
-
export { ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, CollectionRegistryABI, CreatorCoinFactoryABI, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, PopService, SUPPORTED_TOKENS, VALIDATED_EKUBO_PARAMS, build1155CancellationTypedData, build1155OrderTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createFailoverFetch, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, parseCreatorCoinCreated, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol };
|
|
7109
|
+
export { ADMIN_HEADERS, ADMIN_SCOPE, ApiClient, CHAINS, MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET, COLLECTION_1155_START_BLOCK_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_721_START_BLOCK_MAINNET, CREATOR_COIN_CLASS_HASH_MAINNET, CREATOR_COIN_EKUBO_LAUNCHER_MAINNET, CREATOR_COIN_FACTORY_CLASS_HASH_MAINNET, CREATOR_COIN_FACTORY_CONTRACT_MAINNET, CREATOR_COIN_START_BLOCK_MAINNET, CollectionRegistryABI, CreatorCoinFactoryABI, CreatorCoinService, DEFAULT_CHAIN, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, EKUBO_CORE_MAINNET, ERC1155CollectionService, FeeConfigSchema, IPCOLLECTION_CLASS_HASH_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPMarketplaceABI, IPNFT_CLASS_HASH_MAINNET, IPNftABI, LAUNCH_PRICE_QUOTE_PER_COIN, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PUBLIC_RPC_FALLBACKS, PopService, SUPPORTED_TOKENS, VALIDATED_EKUBO_PARAMS, adminRequestDigest, build1155CancellationTypedData, build1155OrderTypedData, buildAdminSessionTypedData, buildCancellationTypedData, buildCreateCreatorCoinCall, buildFeeCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buybackQuoteRaw, toRaw as coinToRaw, createAdminSessionGrant, createFailoverFetch, encodeAdminHeaders, encodeByteArray, fdvHuman, formatAmount, getCoordinates, getCreatorCoinPrice, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAdminHeaders, parseAmount, parseCreatorCoinCreated, randomNonce, resolveConfig, resolveFeeConfig, sessionKeyHashOf, shortenAddress, signAdminRequest, stringifyBigInts, teamCoinsRaw, u256ToBigInt, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol, verifyAdminRequestSig };
|
|
6981
7110
|
//# sourceMappingURL=index.js.map
|
|
6982
7111
|
//# sourceMappingURL=index.js.map
|