@atxp/client 0.2.5 → 0.2.7
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/package.json +3 -3
- package/dist/src/atxpClient.d.ts +0 -14
- package/dist/src/atxpClient.d.ts.map +0 -1
- package/dist/src/atxpClient.js +0 -62
- package/dist/src/atxpClient.js.map +0 -1
- package/dist/src/atxpFetcher.d.ts +0 -71
- package/dist/src/atxpFetcher.d.ts.map +0 -1
- package/dist/src/atxpFetcher.js +0 -347
- package/dist/src/atxpFetcher.js.map +0 -1
- package/dist/src/clientTestHelpers.d.ts +0 -6
- package/dist/src/clientTestHelpers.d.ts.map +0 -1
- package/dist/src/clientTestHelpers.js +0 -94
- package/dist/src/clientTestHelpers.js.map +0 -1
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +0 -1
- package/dist/src/oAuth.d.ts +0 -44
- package/dist/src/oAuth.d.ts.map +0 -1
- package/dist/src/oAuth.js +0 -274
- package/dist/src/oAuth.js.map +0 -1
- package/dist/src/setup.expo.d.ts +0 -2
- package/dist/src/setup.expo.d.ts.map +0 -1
- package/dist/src/setup.expo.js +0 -42
- package/dist/src/setup.expo.js.map +0 -1
- package/dist/src/solanaAccount.d.ts +0 -9
- package/dist/src/solanaAccount.d.ts.map +0 -1
- package/dist/src/solanaAccount.js +0 -19
- package/dist/src/solanaAccount.js.map +0 -1
- package/dist/src/solanaPaymentMaker.d.ts +0 -17
- package/dist/src/solanaPaymentMaker.d.ts.map +0 -1
- package/dist/src/solanaPaymentMaker.js +0 -62
- package/dist/src/solanaPaymentMaker.js.map +0 -1
- package/dist/src/types.d.ts +0 -58
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Keypair, Connection, PublicKey, ComputeBudgetProgram, sendAndConfirmTransaction } from "@solana/web3.js";
|
|
2
|
-
import { createTransfer, ValidateTransferError as _ValidateTransferError } from "@solana/pay";
|
|
3
|
-
import bs58 from "bs58";
|
|
4
|
-
import { generateJWT } from '@longrun/atxp-common';
|
|
5
|
-
import { importJWK } from 'jose';
|
|
6
|
-
import { ConsoleLogger } from '@longrun/atxp-common';
|
|
7
|
-
// this is a global public key for USDC on the solana mainnet
|
|
8
|
-
const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
9
|
-
export const ValidateTransferError = _ValidateTransferError;
|
|
10
|
-
export class SolanaPaymentMaker {
|
|
11
|
-
constructor(solanaEndpoint, sourceSecretKey, logger) {
|
|
12
|
-
this.generateJWT = async ({ paymentRequestId, codeChallenge }) => {
|
|
13
|
-
// Solana/Web3.js secretKey is 64 bytes:
|
|
14
|
-
// first 32 bytes are the private scalar, last 32 are the public key.
|
|
15
|
-
// JWK expects only the 32-byte private scalar for 'd'
|
|
16
|
-
const jwk = {
|
|
17
|
-
kty: 'OKP',
|
|
18
|
-
crv: 'Ed25519',
|
|
19
|
-
d: Buffer.from(this.source.secretKey.slice(0, 32)).toString('base64url'),
|
|
20
|
-
x: Buffer.from(this.source.publicKey.toBytes()).toString('base64url'),
|
|
21
|
-
};
|
|
22
|
-
const privateKey = await importJWK(jwk, 'EdDSA');
|
|
23
|
-
if (!(privateKey instanceof CryptoKey)) {
|
|
24
|
-
throw new Error('Expected CryptoKey from importJWK');
|
|
25
|
-
}
|
|
26
|
-
return generateJWT(this.source.publicKey.toBase58(), privateKey, paymentRequestId || '', codeChallenge || '');
|
|
27
|
-
};
|
|
28
|
-
this.makePayment = async (amount, currency, receiver) => {
|
|
29
|
-
currency = currency.toLowerCase();
|
|
30
|
-
if (currency !== 'usdc') {
|
|
31
|
-
throw new Error('Only usdc currency is supported; received ' + currency);
|
|
32
|
-
}
|
|
33
|
-
const receiverKey = new PublicKey(receiver);
|
|
34
|
-
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
|
|
35
|
-
units: 10000,
|
|
36
|
-
});
|
|
37
|
-
const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
|
|
38
|
-
microLamports: 20000,
|
|
39
|
-
});
|
|
40
|
-
this.logger.info(`Making payment of ${amount} ${currency} to ${receiver}`);
|
|
41
|
-
const transaction = await createTransfer(this.connection, this.source.publicKey, {
|
|
42
|
-
amount: amount,
|
|
43
|
-
recipient: receiverKey,
|
|
44
|
-
splToken: USDC_MINT,
|
|
45
|
-
});
|
|
46
|
-
transaction.add(modifyComputeUnits);
|
|
47
|
-
transaction.add(addPriorityFee);
|
|
48
|
-
const transactionHash = await sendAndConfirmTransaction(this.connection, transaction, [this.source]);
|
|
49
|
-
return transactionHash;
|
|
50
|
-
};
|
|
51
|
-
if (!solanaEndpoint) {
|
|
52
|
-
throw new Error('Solana endpoint is required');
|
|
53
|
-
}
|
|
54
|
-
if (!sourceSecretKey) {
|
|
55
|
-
throw new Error('Source secret key is required');
|
|
56
|
-
}
|
|
57
|
-
this.connection = new Connection(solanaEndpoint, { commitment: 'confirmed' });
|
|
58
|
-
this.source = Keypair.fromSecretKey(bs58.decode(sourceSecretKey));
|
|
59
|
-
this.logger = logger ?? new ConsoleLogger();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=solanaPaymentMaker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solanaPaymentMaker.js","sourceRoot":"","sources":["../../src/solanaPaymentMaker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,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AI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;IAC9C,CAAC;CAyDF"}
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { AuthorizationServerUrl, Currency, Logger, Network, OAuthDb, FetchLike } from "@longrun/atxp-common";
|
|
2
|
-
import { ClientOptions } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
-
import { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
type AccountPrefix = Network;
|
|
5
|
-
export type AccountIdString = `${AccountPrefix}${string}`;
|
|
6
|
-
export type Account = {
|
|
7
|
-
accountId: string;
|
|
8
|
-
paymentMakers: {
|
|
9
|
-
[key: string]: PaymentMaker;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export type ProspectivePayment = {
|
|
13
|
-
accountId: string;
|
|
14
|
-
resourceUrl: string;
|
|
15
|
-
resourceName: string;
|
|
16
|
-
network: Network;
|
|
17
|
-
currency: Currency;
|
|
18
|
-
amount: BigNumber;
|
|
19
|
-
iss: string;
|
|
20
|
-
};
|
|
21
|
-
export type ClientConfig = {
|
|
22
|
-
mcpServer: string;
|
|
23
|
-
account: Account;
|
|
24
|
-
allowedAuthorizationServers: AuthorizationServerUrl[];
|
|
25
|
-
approvePayment: (payment: ProspectivePayment) => Promise<boolean>;
|
|
26
|
-
oAuthDb: OAuthDb;
|
|
27
|
-
fetchFn: FetchLike;
|
|
28
|
-
oAuthChannelFetch: FetchLike;
|
|
29
|
-
allowHttp: boolean;
|
|
30
|
-
logger: Logger;
|
|
31
|
-
clientInfo: Implementation;
|
|
32
|
-
clientOptions: ClientOptions;
|
|
33
|
-
onAuthorize: (args: {
|
|
34
|
-
authorizationServer: AuthorizationServerUrl;
|
|
35
|
-
userId: string;
|
|
36
|
-
}) => Promise<void>;
|
|
37
|
-
onAuthorizeFailure: (args: {
|
|
38
|
-
authorizationServer: AuthorizationServerUrl;
|
|
39
|
-
userId: string;
|
|
40
|
-
error: Error;
|
|
41
|
-
}) => Promise<void>;
|
|
42
|
-
onPayment: (args: {
|
|
43
|
-
payment: ProspectivePayment;
|
|
44
|
-
}) => Promise<void>;
|
|
45
|
-
onPaymentFailure: (args: {
|
|
46
|
-
payment: ProspectivePayment;
|
|
47
|
-
error: Error;
|
|
48
|
-
}) => Promise<void>;
|
|
49
|
-
};
|
|
50
|
-
export interface PaymentMaker {
|
|
51
|
-
makePayment: (amount: BigNumber, currency: string, receiver: string, memo: string) => Promise<string>;
|
|
52
|
-
generateJWT: (params: {
|
|
53
|
-
paymentRequestId: string;
|
|
54
|
-
codeChallenge: string;
|
|
55
|
-
}) => Promise<string>;
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,KAAK,aAAa,GAAG,OAAO,CAAC;AAC7B,MAAM,MAAM,eAAe,GAAG,GAAG,aAAa,GAAG,MAAM,EAAE,CAAC;AAE1D,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE;QAAC,CAA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