@vinaystwt/xmpp-payment-adapters 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xMPP contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,49 @@
1
+ export declare const config: {
2
+ readonly nodeEnv: string;
3
+ readonly network: string;
4
+ readonly paymentExecutionMode: "mock" | "testnet";
5
+ readonly rpcUrl: string;
6
+ readonly networkPassphrase: string;
7
+ readonly gatewayPort: number;
8
+ readonly dashboardPort: number;
9
+ readonly dashboardGatewayUrl: string | undefined;
10
+ readonly dailyBudgetUsd: number;
11
+ readonly facilitatorUrl: string;
12
+ readonly wallet: {
13
+ readonly agentSecretKey: string | undefined;
14
+ readonly smartAccountContractId: string | undefined;
15
+ readonly smartAccountWasmHash: string;
16
+ readonly webauthnVerifierAddress: string;
17
+ readonly ed25519VerifierAddress: string;
18
+ readonly spendingLimitPolicyAddress: string;
19
+ readonly thresholdPolicyAddress: string;
20
+ };
21
+ readonly x402: {
22
+ readonly facilitatorUrl: string;
23
+ readonly facilitatorApiKey: string | undefined;
24
+ readonly maxTransactionFeeStroops: number;
25
+ readonly facilitatorPrivateKey: string | undefined;
26
+ readonly recipientAddress: string | undefined;
27
+ };
28
+ readonly mpp: {
29
+ readonly secretKey: string | undefined;
30
+ readonly recipientAddress: string | undefined;
31
+ readonly channelContractId: string | undefined;
32
+ readonly feeSponsorshipEnabled: boolean;
33
+ readonly feeSponsorship: {
34
+ readonly chargeEnabled: boolean;
35
+ readonly sessionEnabled: boolean;
36
+ };
37
+ readonly feeSponsorSecretKey: string | undefined;
38
+ readonly feeBumpSecretKey: string | undefined;
39
+ };
40
+ readonly services: {
41
+ readonly research: string;
42
+ readonly market: string;
43
+ readonly stream: string;
44
+ };
45
+ readonly contracts: {
46
+ readonly policyContractId: string | undefined;
47
+ readonly sessionRegistryContractId: string | undefined;
48
+ };
49
+ };
@@ -0,0 +1,117 @@
1
+ import { config as loadEnv } from 'dotenv';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { z } from 'zod';
5
+ const moduleDir = dirname(fileURLToPath(import.meta.url));
6
+ const repoRoot = resolve(moduleDir, '../../../');
7
+ loadEnv({ path: resolve(repoRoot, '.env') });
8
+ loadEnv({ path: resolve(repoRoot, '.env.local'), override: true });
9
+ loadEnv();
10
+ const envSchema = z.object({
11
+ NODE_ENV: z.string().default('development'),
12
+ XMPP_NETWORK: z.string().default('stellar:testnet'),
13
+ XMPP_PAYMENT_EXECUTION_MODE: z.enum(['mock', 'testnet']).default('mock'),
14
+ XMPP_RPC_URL: z.string().default('https://soroban-testnet.stellar.org'),
15
+ XMPP_NETWORK_PASSPHRASE: z.string().default('Test SDF Network ; September 2015'),
16
+ XMPP_GATEWAY_PORT: z.coerce.number().default(4300),
17
+ XMPP_DASHBOARD_PORT: z.coerce.number().default(4310),
18
+ XMPP_DASHBOARD_GATEWAY_URL: z.string().optional(),
19
+ XMPP_DAILY_BUDGET_USD: z.coerce.number().default(0.5),
20
+ XMPP_AGENT_SECRET_KEY: z.string().optional(),
21
+ XMPP_SMART_ACCOUNT_CONTRACT_ID: z.string().optional(),
22
+ XMPP_SMART_ACCOUNT_WASM_HASH: z
23
+ .string()
24
+ .default('3e51f5b222dec74650f0b33367acb42a41ce497f72639230463070e666abba2c'),
25
+ XMPP_WEBAUTHN_VERIFIER_ADDRESS: z
26
+ .string()
27
+ .default('CATPTBRWVMH5ZCIKO5HN2F4FMPXVZEXC56RKGHRXCM7EEZGGXK7PICEH'),
28
+ XMPP_ED25519_VERIFIER_ADDRESS: z
29
+ .string()
30
+ .default('CAIKK32K3BZJYTWVTXHZFPIEEDBR6YCVTGPABH4UQUQ4XFA3OLYXG27G'),
31
+ XMPP_SPENDING_LIMIT_POLICY_ADDRESS: z
32
+ .string()
33
+ .default('CBYLPYZGLQ6JVY2IQ5P23QLQPR3KAMMKMZLNWG6RUUKJDNYGPLVHK7U4'),
34
+ XMPP_THRESHOLD_POLICY_ADDRESS: z
35
+ .string()
36
+ .default('CDDQLFG7CV74QHWPSP6NZIPNBR2PPCMTUVYCJF4P3ONDYHODRFGR7LWC'),
37
+ X402_FACILITATOR_URL: z.string().default('http://localhost:4022'),
38
+ X402_FACILITATOR_API_KEY: z.string().optional(),
39
+ X402_MAX_TRANSACTION_FEE_STROOPS: z.coerce.number().default(2000000),
40
+ X402_RECIPIENT_ADDRESS: z.string().optional(),
41
+ FACILITATOR_STELLAR_PRIVATE_KEY: z.string().optional(),
42
+ MPP_SECRET_KEY: z.string().optional(),
43
+ MPP_RECIPIENT_ADDRESS: z.string().optional(),
44
+ MPP_CHANNEL_CONTRACT_ID: z.string().optional(),
45
+ XMPP_ENABLE_MPP_FEE_SPONSORSHIP: z
46
+ .enum(['true', 'false'])
47
+ .default('false')
48
+ .transform((value) => value === 'true'),
49
+ XMPP_ENABLE_MPP_CHARGE_FEE_SPONSORSHIP: z
50
+ .enum(['true', 'false'])
51
+ .optional()
52
+ .transform((value) => value === 'true'),
53
+ XMPP_ENABLE_MPP_SESSION_FEE_SPONSORSHIP: z
54
+ .enum(['true', 'false'])
55
+ .optional()
56
+ .transform((value) => value === 'true'),
57
+ XMPP_MPP_FEE_SPONSOR_SECRET_KEY: z.string().optional(),
58
+ XMPP_MPP_FEE_BUMP_SECRET_KEY: z.string().optional(),
59
+ XMPP_RESEARCH_API_URL: z.string().default('http://localhost:4101'),
60
+ XMPP_MARKET_API_URL: z.string().default('http://localhost:4102'),
61
+ XMPP_STREAM_API_URL: z.string().default('http://localhost:4103'),
62
+ XMPP_POLICY_CONTRACT_ID: z.string().optional(),
63
+ XMPP_SESSION_REGISTRY_CONTRACT_ID: z.string().optional(),
64
+ });
65
+ const env = envSchema.parse(process.env);
66
+ const mppFeeSponsorshipEnabled = env.XMPP_ENABLE_MPP_FEE_SPONSORSHIP;
67
+ const mppChargeFeeSponsorshipEnabled = env.XMPP_ENABLE_MPP_CHARGE_FEE_SPONSORSHIP ?? mppFeeSponsorshipEnabled;
68
+ const mppSessionFeeSponsorshipEnabled = env.XMPP_ENABLE_MPP_SESSION_FEE_SPONSORSHIP ?? mppFeeSponsorshipEnabled;
69
+ export const config = {
70
+ nodeEnv: env.NODE_ENV,
71
+ network: env.XMPP_NETWORK,
72
+ paymentExecutionMode: env.XMPP_PAYMENT_EXECUTION_MODE,
73
+ rpcUrl: env.XMPP_RPC_URL,
74
+ networkPassphrase: env.XMPP_NETWORK_PASSPHRASE,
75
+ gatewayPort: env.XMPP_GATEWAY_PORT,
76
+ dashboardPort: env.XMPP_DASHBOARD_PORT,
77
+ dashboardGatewayUrl: env.XMPP_DASHBOARD_GATEWAY_URL,
78
+ dailyBudgetUsd: env.XMPP_DAILY_BUDGET_USD,
79
+ facilitatorUrl: env.X402_FACILITATOR_URL,
80
+ wallet: {
81
+ agentSecretKey: env.XMPP_AGENT_SECRET_KEY,
82
+ smartAccountContractId: env.XMPP_SMART_ACCOUNT_CONTRACT_ID,
83
+ smartAccountWasmHash: env.XMPP_SMART_ACCOUNT_WASM_HASH,
84
+ webauthnVerifierAddress: env.XMPP_WEBAUTHN_VERIFIER_ADDRESS,
85
+ ed25519VerifierAddress: env.XMPP_ED25519_VERIFIER_ADDRESS,
86
+ spendingLimitPolicyAddress: env.XMPP_SPENDING_LIMIT_POLICY_ADDRESS,
87
+ thresholdPolicyAddress: env.XMPP_THRESHOLD_POLICY_ADDRESS,
88
+ },
89
+ x402: {
90
+ facilitatorUrl: env.X402_FACILITATOR_URL,
91
+ facilitatorApiKey: env.X402_FACILITATOR_API_KEY,
92
+ maxTransactionFeeStroops: env.X402_MAX_TRANSACTION_FEE_STROOPS,
93
+ facilitatorPrivateKey: env.FACILITATOR_STELLAR_PRIVATE_KEY,
94
+ recipientAddress: env.X402_RECIPIENT_ADDRESS,
95
+ },
96
+ mpp: {
97
+ secretKey: env.MPP_SECRET_KEY,
98
+ recipientAddress: env.MPP_RECIPIENT_ADDRESS,
99
+ channelContractId: env.MPP_CHANNEL_CONTRACT_ID,
100
+ feeSponsorshipEnabled: mppFeeSponsorshipEnabled,
101
+ feeSponsorship: {
102
+ chargeEnabled: mppChargeFeeSponsorshipEnabled,
103
+ sessionEnabled: mppSessionFeeSponsorshipEnabled,
104
+ },
105
+ feeSponsorSecretKey: env.XMPP_MPP_FEE_SPONSOR_SECRET_KEY,
106
+ feeBumpSecretKey: env.XMPP_MPP_FEE_BUMP_SECRET_KEY,
107
+ },
108
+ services: {
109
+ research: env.XMPP_RESEARCH_API_URL,
110
+ market: env.XMPP_MARKET_API_URL,
111
+ stream: env.XMPP_STREAM_API_URL,
112
+ },
113
+ contracts: {
114
+ policyContractId: env.XMPP_POLICY_CONTRACT_ID,
115
+ sessionRegistryContractId: env.XMPP_SESSION_REGISTRY_CONTRACT_ID,
116
+ },
117
+ };
@@ -0,0 +1,27 @@
1
+ import { Keypair, xdr } from '@stellar/stellar-sdk';
2
+ import type { PaymentChallenge, PaymentExecutionMetadata, PaymentExecutionResult, RouteKind } from '@xmpp/types';
3
+ import { XLM_SAC_TESTNET } from '@stellar/mpp';
4
+ declare function createClassicSignatureScVal(keypair: Keypair, payload: Buffer): xdr.ScVal;
5
+ declare function createDelegatedSignerScVal(publicKey: string): xdr.ScVal;
6
+ declare function createDelegatedAuthPayload(publicKey: string, contextRuleIds: number[]): xdr.ScVal;
7
+ declare function buildSmartAccountSignaturePayload(entry: xdr.SorobanAuthorizationEntry, networkPassphrase: string): Buffer<ArrayBufferLike>;
8
+ declare function buildSmartAccountAuthDigest(signaturePayload: Buffer, contextRuleIds: number[]): Buffer<ArrayBufferLike>;
9
+ declare function signDelegatedSmartAccountAuth(authEntries: xdr.SorobanAuthorizationEntry[], smartAccountContractId: string, delegatedSigner: Keypair, expiration: number, networkPassphrase: string, contextRuleIds?: number[]): xdr.SorobanAuthorizationEntry[];
10
+ export declare const __smartAccountTestUtils: {
11
+ createClassicSignatureScVal: typeof createClassicSignatureScVal;
12
+ createDelegatedSignerScVal: typeof createDelegatedSignerScVal;
13
+ createDelegatedAuthPayload: typeof createDelegatedAuthPayload;
14
+ buildSmartAccountSignaturePayload: typeof buildSmartAccountSignaturePayload;
15
+ buildSmartAccountAuthDigest: typeof buildSmartAccountAuthDigest;
16
+ signDelegatedSmartAccountAuth: typeof signDelegatedSmartAccountAuth;
17
+ };
18
+ export declare function buildRetryHeaders(challenge: PaymentChallenge, route: RouteKind): {
19
+ [challenge.retryHeaderName]: string;
20
+ 'x-xmpp-route': RouteKind;
21
+ };
22
+ export declare function preparePaymentExecution(challenge: PaymentChallenge, route: RouteKind): {
23
+ headers: Record<string, string>;
24
+ metadata: PaymentExecutionMetadata;
25
+ };
26
+ export declare function executePaymentRoute(route: RouteKind, input: RequestInfo | URL, init?: RequestInit): Promise<PaymentExecutionResult>;
27
+ export { XLM_SAC_TESTNET };