mppx 0.9.1 → 0.9.3
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/CHANGELOG.md +28 -0
- package/README.md +26 -0
- package/dist/Method.d.ts +2 -0
- package/dist/cli/Extension.d.ts +20 -0
- package/dist/cli/Extension.js +5 -0
- package/dist/cli/cli.d.ts +1 -0
- package/dist/cli/cli.js +135 -135
- package/dist/cli/config.d.ts +4 -0
- package/dist/cli/config.js +1 -0
- package/dist/cli/internal.d.ts +3 -0
- package/dist/cli/internal.js +15 -2
- package/dist/cli/plugins/evm.js +2 -0
- package/dist/cli/plugins/index.d.ts +1 -0
- package/dist/cli/plugins/index.js +13 -13
- package/dist/cli/plugins/plugin.d.ts +2 -2
- package/dist/cli/plugins/x402.d.ts +3 -0
- package/dist/cli/plugins/x402.js +61 -0
- package/dist/cli/sessions/request.d.ts +1 -0
- package/dist/cli/sessions/request.js +1 -0
- package/dist/cli/validate/payment.js +14 -8
- package/dist/evm/client/Charge.d.ts +2 -2
- package/dist/evm/client/Charge.js +1 -1
- package/dist/evm/server/Charge.d.ts +7 -2
- package/dist/evm/server/Charge.js +28 -2
- package/dist/evm/server/Methods.d.ts +1 -1
- package/dist/internal/version.d.ts +5 -0
- package/dist/internal/version.js +6 -0
- package/dist/middlewares/internal/mppx.js +17 -3
- package/dist/server/Mppx.d.ts +7 -6
- package/dist/server/Mppx.js +84 -2
- package/dist/server/internal/html/config.js +1 -3
- package/dist/stripe/Methods.d.ts +24 -5
- package/dist/stripe/Methods.js +14 -11
- package/dist/stripe/client/Charge.d.ts +23 -5
- package/dist/stripe/client/Methods.d.ts +23 -5
- package/dist/stripe/internal/constants.d.ts +4 -0
- package/dist/stripe/internal/constants.js +2 -0
- package/dist/stripe/internal/parse-units.d.ts +8 -0
- package/dist/stripe/internal/parse-units.js +20 -0
- package/dist/stripe/internal/payment-intent.d.ts +39 -1
- package/dist/stripe/internal/payment-intent.js +16 -1
- package/dist/stripe/internal/types.d.ts +4 -0
- package/dist/stripe/server/Charge.d.ts +25 -5
- package/dist/stripe/server/Charge.js +35 -23
- package/dist/stripe/server/Methods.d.ts +8 -0
- package/dist/stripe/server/Methods.js +54 -9
- package/dist/stripe/server/internal/analytics.d.ts +6 -0
- package/dist/stripe/server/internal/analytics.js +16 -0
- package/dist/stripe/server/internal/hosted-fee-payer.d.ts +10 -0
- package/dist/stripe/server/internal/hosted-fee-payer.js +54 -0
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +4 -1
- package/dist/stripe/server/internal/record-payment.js +35 -5
- package/dist/tempo/client/Subscription.js +6 -2
- package/dist/tempo/internal/account.d.ts +1 -0
- package/dist/tempo/internal/fee-payer.d.ts +2 -0
- package/dist/tempo/internal/fee-payer.js +4 -0
- package/dist/tempo/internal/remote-fee-payer.d.ts +2 -0
- package/dist/tempo/server/Subscription.js +1 -0
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/session/client/SessionManager.d.ts +5 -0
- package/dist/tempo/session/client/SessionManager.js +16 -2
- package/dist/tempo/session/precompile/Chain.js +3 -0
- package/dist/tempo/subscription/KeyAuthorization.d.ts +7 -1
- package/dist/tempo/subscription/KeyAuthorization.js +21 -3
- package/dist/viem/Client.js +1 -0
- package/dist/x402/client/Exact.d.ts +2 -2
- package/dist/x402/client/Exact.js +1 -1
- package/dist/x402/server/EvmCharge.d.ts +2 -0
- package/dist/x402/server/EvmCharge.js +34 -26
- package/package.json +1 -1
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { resolveAccount } from './account.js';
|
|
2
|
+
export * as Extension from './Extension.js';
|
|
2
3
|
import type * as Mppx from '../client/Mppx.js';
|
|
4
|
+
import type * as Extension from './Extension.js';
|
|
3
5
|
import type { Plugin } from './plugins/plugin.js';
|
|
4
6
|
/**
|
|
5
7
|
* Define mppx configuration file
|
|
@@ -35,6 +37,8 @@ export declare namespace defineConfig {
|
|
|
35
37
|
paymentPreferences?: methods extends Mppx.Methods ? Mppx.create.Config<methods>['paymentPreferences'] : undefined;
|
|
36
38
|
/** Array of plugins to use. */
|
|
37
39
|
plugins?: Plugin[] | undefined;
|
|
40
|
+
/** Ordered, method-agnostic payment lifecycle extensions. */
|
|
41
|
+
extensions?: readonly Extension.Extension[] | undefined;
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
export type Config = defineConfig.Config<Mppx.Methods>;
|
package/dist/cli/config.js
CHANGED
package/dist/cli/internal.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type * as Challenge from '../Challenge.js';
|
|
2
2
|
import type * as Method from '../Method.js';
|
|
3
3
|
import type { Config } from './config.js';
|
|
4
|
+
import type * as Extension from './Extension.js';
|
|
4
5
|
import type { Plugin } from './plugins/plugin.js';
|
|
6
|
+
/** Runs configured payment extensions in order and threads credential context between them. */
|
|
7
|
+
export declare function preparePayment(challenge: Challenge.Challenge, extensions: readonly Extension.Extension[] | undefined, credentialContext?: unknown): Promise<unknown>;
|
|
5
8
|
export declare function resolvePlugin(challenge: Challenge.Challenge, config?: {
|
|
6
9
|
plugins?: Plugin[] | undefined;
|
|
7
10
|
methods?: any;
|
package/dist/cli/internal.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import * as AcceptPayment from '../internal/AcceptPayment.js';
|
|
4
|
-
import { evm as evmPlugin, stripe as stripePlugin, tempo as tempoPlugin } from './plugins/index.js';
|
|
5
|
-
const builtinPlugins = [tempoPlugin(), stripePlugin(), evmPlugin()];
|
|
4
|
+
import { evm as evmPlugin, stripe as stripePlugin, tempo as tempoPlugin, x402 as x402Plugin, } from './plugins/index.js';
|
|
5
|
+
const builtinPlugins = [tempoPlugin(), stripePlugin(), evmPlugin(), x402Plugin()];
|
|
6
|
+
/** Runs configured payment extensions in order and threads credential context between them. */
|
|
7
|
+
export async function preparePayment(challenge, extensions, credentialContext) {
|
|
8
|
+
let current = credentialContext;
|
|
9
|
+
for (const extension of extensions ?? []) {
|
|
10
|
+
const result = await extension.preparePayment?.({
|
|
11
|
+
challenge,
|
|
12
|
+
...(current !== undefined ? { credentialContext: current } : {}),
|
|
13
|
+
});
|
|
14
|
+
if (result && 'credentialContext' in result)
|
|
15
|
+
current = result.credentialContext;
|
|
16
|
+
}
|
|
17
|
+
return current;
|
|
18
|
+
}
|
|
6
19
|
export function resolvePlugin(challenge, config) {
|
|
7
20
|
const configPlugin = config?.plugins?.find((p) => supportsPlugin(p, challenge));
|
|
8
21
|
if (configPlugin)
|
package/dist/cli/plugins/evm.js
CHANGED
|
@@ -2,11 +2,13 @@ import { createClient, erc20Abi, http } from 'viem';
|
|
|
2
2
|
import { readContract } from 'viem/actions';
|
|
3
3
|
import * as viemChains from 'viem/chains';
|
|
4
4
|
import { evm as evmMethods, assets as evmAssets } from '../../evm/client/index.js';
|
|
5
|
+
import * as x402_ChallengeBrand from '../../x402/internal/ChallengeBrand.js';
|
|
5
6
|
import { resolveAccount } from '../account.js';
|
|
6
7
|
import { createPlugin } from './plugin.js';
|
|
7
8
|
export function evm() {
|
|
8
9
|
return createPlugin({
|
|
9
10
|
method: 'evm',
|
|
11
|
+
supports: (challenge) => challenge.method === 'evm' && !x402_ChallengeBrand.is(challenge),
|
|
10
12
|
async setup({ challenge }) {
|
|
11
13
|
const request = challenge.request;
|
|
12
14
|
const methodDetails = request.methodDetails;
|