import { type TransactionPartialSigner } from '@solana/kit'; import { Method, Store } from 'mppx'; /** * Creates a Solana `subscription` method for usage on the server. * * The server publishes a `Plan` on-chain out of band; the 402 challenge * pins the `planId` along with the period and amount. On activation the * client signs a transaction containing `subscribe` + `transfer_subscription` * (and optionally `initialize_subscription_authority`), the server * (optionally co-signing as fee payer) broadcasts, and on confirmation the * server verifies the on-chain `SubscriptionDelegation` matches the * challenge before returning the receipt. * * Subsequent renewal charges are server-driven on-chain transactions; this * handler is only concerned with activation. * * @example * ```ts * import { Mppx, solana } from '@solana/mpp/server' * * const mppx = Mppx.create({ * methods: [solana.subscription({ * planId: '8tWbqLkUJoYy7zXc5h2EvCRoaQEv2xnQjUuYhc3rzCgT', * mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', * decimals: 6, * tokenProgram: TOKEN_PROGRAM, * puller: '5fKb5cF22cFybZB1H4hLDydFhwoQy9JzKzRWaSbMkB6h', * recipient: '9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin', * periodUnit: 'day', * periodCount: 30, * network: 'devnet', * })], * }) * ``` */ export declare function subscription(parameters: subscription.Parameters): Method.Server<{ readonly intent: "subscription"; readonly name: "solana"; readonly schema: { readonly credential: { readonly payload: import("zod/mini").ZodMiniObject<{ signature: import("zod/mini").ZodMiniOptional>; transaction: import("zod/mini").ZodMiniOptional>; type: import("zod/mini").ZodMiniString; }, import("zod/v4/core").$strip>; }; readonly request: import("zod/mini").ZodMiniObject<{ amount: import("zod/mini").ZodMiniString; currency: import("zod/mini").ZodMiniString; description: import("zod/mini").ZodMiniOptional>; externalId: import("zod/mini").ZodMiniOptional>; methodDetails: import("zod/mini").ZodMiniObject<{ decimals: import("zod/mini").ZodMiniNumber; feePayer: import("zod/mini").ZodMiniOptional>; feePayerKey: import("zod/mini").ZodMiniOptional>; mint: import("zod/mini").ZodMiniString; network: import("zod/mini").ZodMiniOptional>; planId: import("zod/mini").ZodMiniString; programId: import("zod/mini").ZodMiniOptional>; puller: import("zod/mini").ZodMiniString; recentBlockhash: import("zod/mini").ZodMiniOptional>; splits: import("zod/mini").ZodMiniOptional; recipient: import("zod/mini").ZodMiniString; }, import("zod/v4/core").$strip>>>; tokenProgram: import("zod/mini").ZodMiniString; }, import("zod/v4/core").$strip>; periodCount: import("zod/mini").ZodMiniString; periodUnit: import("zod/mini").ZodMiniEnum<{ day: "day"; week: "week"; }>; recipient: import("zod/mini").ZodMiniString; subscriptionExpires: import("zod/mini").ZodMiniOptional>; }, import("zod/v4/core").$strip>; }; }, { readonly amount: "0"; readonly currency: string; readonly methodDetails: { readonly decimals: number; readonly mint: string; readonly planId: string; readonly puller: string; readonly tokenProgram: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" | "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; }; readonly periodCount: string; readonly periodUnit: "day" | "week"; readonly recipient: string; }, undefined>; declare function extractSubscriberFromTransaction(clientTxBase64: string, challenge: ChallengeRequest): string; declare function validateActivationInstructions(clientTxBase64: string, challenge: ChallengeRequest): void; type SubscriptionDelegation = { amountPerPeriod: string; amountPulledInPeriod: string; currentPeriodStartTs: number; mint: string; periodHours: number; planPda: string; subscriber: string; }; declare function decodeSubscriptionDelegation(data: Uint8Array): SubscriptionDelegation; declare function encodeBase58(bytes: Uint8Array): string; declare function decodeBase58(s: string): Uint8Array; declare function base64UrlEncodeNoPadding(bytes: Uint8Array): string; type ChallengeRequest = { amount: string; currency: string; description?: string; externalId?: string; methodDetails: { decimals: number; feePayer?: boolean; feePayerKey?: string; mint: string; network?: string; planId: string; programId?: string; puller: string; recentBlockhash?: string; splits?: Array<{ bps: number; recipient: string; }>; tokenProgram: string; }; periodCount: string; periodUnit: 'day' | 'week'; recipient: string; subscriptionExpires?: string; }; export declare const __testing: { base64UrlEncodeNoPadding: typeof base64UrlEncodeNoPadding; decodeBase58: typeof decodeBase58; decodeSubscriptionDelegation: typeof decodeSubscriptionDelegation; encodeBase58: typeof encodeBase58; extractSubscriberFromTransaction: typeof extractSubscriberFromTransaction; validateActivationInstructions: typeof validateActivationInstructions; }; export declare namespace subscription { type Parameters = { /** Token decimals for the mint. */ decimals: number; /** Base58 of the SPL token mint. MUST match the on-chain plan.mint. */ mint: string; /** Solana network. Defaults to `mainnet-beta`. */ network?: 'devnet' | 'localnet' | 'mainnet-beta' | 'testnet' | (string & {}); /** Positive integer count of `periodUnit` values per billing period (1..365 for day, 1..52 for week). */ periodCount: number; /** Billing period unit. The Solana profile supports `day` and `week` only. */ periodUnit: 'day' | 'week'; /** Base58 of the on-chain Plan PDA. */ planId: string; /** Base58 of the subscriptions program ID. Defaults to the canonical deployment. */ programId?: string; /** Base58 of the server's puller pubkey (must be in plan.pullers or plan.owner). */ puller: string; /** Base58 of the primary recipient wallet. MUST match what plan.destinations resolves to. */ recipient: string; /** Custom RPC URL. Defaults to the public RPC for the selected network. */ rpcUrl?: string; /** Optional fee-payer signer. When set, the server co-signs activation as fee payer. */ signer?: TransactionPartialSigner; /** Advisory distribution splits. The on-chain split is governed by plan.destinations. */ splits?: Array<{ bps: number; recipient: string; }>; /** Pluggable key-value store for replay protection. Defaults to in-memory. */ store?: Store.Store; /** Optional {@link https://datatracker.ietf.org/doc/html/rfc3339 | RFC3339} expiry of the recurring authorization. */ subscriptionExpires?: string; /** Base58 of the SPL Token or Token-2022 program ID. */ tokenProgram: string; }; } export {}; //# sourceMappingURL=Subscription.d.ts.map