a402
Version:
Decentralized Infrastructure to buy and sell any internet native resources on Aptos
96 lines (92 loc) • 2.25 kB
TypeScript
import { Account } from '@aptos-labs/ts-sdk';
declare global {
namespace Express {
interface Request {
a402?: {
user: {
address: string;
account: Account;
};
payment: {
txHash: string;
resourceId: string;
amount: number;
currency: string;
};
};
}
}
}
interface A402Config {
network: "testnet" | "mainnet";
}
interface A402PaymentInfo {
user: {
address: string;
account: Account;
};
payment: {
txHash: string;
resourceId: string;
amount: number;
currency: string;
};
}
declare global {
namespace Express {
interface Request {
a402?: A402PaymentInfo;
}
}
}
interface A402Request extends Request {
a402: {
user: {
address: string;
account: Account;
};
payment: {
txHash: string;
resourceId: string;
amount: number;
currency: string;
};
};
}
declare class A402SDK {
private aptos;
private config;
private networkConfig;
constructor(config: A402Config);
private getNetworkConfig;
/**
* Main middleware function for protecting endpoints
*/
/**
* Main middleware function for protecting endpoints
*/
protect(): (req: any, res: any, next: any) => Promise<void>;
private handleMiddleware;
private extractApiKey;
private getEndpointInfoFromRequest;
private sendPaymentRequiredResponse;
/**
* Get buyer's payment balance
*/
getBuyerBalance(buyerAddress: string): Promise<{
balance: number;
currency: string;
backendAddress: string;
}>;
/**
* Fund buyer account (testnet only)
*/
fundBuyerAccount(buyerAddress: string, amount?: number): Promise<string>;
private validateAccessToken;
private getBuyerData;
private getBuyerAccount;
private makePaymentForEndpoint;
private recordAnalytics;
}
declare function createA402Middleware(config: A402Config): A402SDK;
export { type A402Config, type A402PaymentInfo, type A402Request, A402SDK, createA402Middleware, A402SDK as default };