@armory-sh/base 0.2.33 → 0.2.34
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/dist/index.js +3 -4
- package/dist/payment-client.d.ts +1 -1
- package/dist/types/api.d.ts +3 -3
- package/dist/types/protocol.d.ts +3 -3
- package/package.json +1 -1
- package/src/payment-client.ts +5 -8
- package/src/types/api.ts +3 -3
- package/src/types/protocol.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -622,11 +622,10 @@ function toJsonSafe(data) {
|
|
|
622
622
|
function resolveUrl(config) {
|
|
623
623
|
return config?.url ?? DEFAULT_FACILITATOR_URL;
|
|
624
624
|
}
|
|
625
|
-
|
|
625
|
+
function resolveHeaders(config) {
|
|
626
626
|
const base = { "Content-Type": "application/json" };
|
|
627
|
-
if (!config?.
|
|
628
|
-
|
|
629
|
-
return { ...base, ...extra };
|
|
627
|
+
if (!config?.headers) return base;
|
|
628
|
+
return { ...base, ...config.headers };
|
|
630
629
|
}
|
|
631
630
|
async function verifyPayment(payload, requirements, config) {
|
|
632
631
|
const url = resolveUrl(config);
|
package/dist/payment-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PaymentPayload, PaymentRequirements, SettlementResponse, VerifyResponse } from "./types/x402";
|
|
2
2
|
export interface FacilitatorClientConfig {
|
|
3
3
|
url: string;
|
|
4
|
-
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
5
|
}
|
|
6
6
|
export declare function verifyPayment(payload: PaymentPayload, requirements: PaymentRequirements, config?: FacilitatorClientConfig): Promise<VerifyResponse>;
|
|
7
7
|
export declare function settlePayment(payload: PaymentPayload, requirements: PaymentRequirements, config?: FacilitatorClientConfig): Promise<SettlementResponse>;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface FacilitatorConfig {
|
|
|
25
25
|
/** Facilitator URL for verification/settlement */
|
|
26
26
|
url: string;
|
|
27
27
|
/** Optional authentication headers */
|
|
28
|
-
headers?:
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
29
|
/** Networks this facilitator supports (auto-detected if not provided) */
|
|
30
30
|
networks?: NetworkId[];
|
|
31
31
|
/** Tokens this facilitator supports (optional) */
|
|
@@ -50,9 +50,9 @@ export interface FacilitatorSettleResult {
|
|
|
50
50
|
error?: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Settlement mode - verify only
|
|
53
|
+
* Settlement mode - verify only or settle
|
|
54
54
|
*/
|
|
55
|
-
export type SettlementMode = "verify" | "settle"
|
|
55
|
+
export type SettlementMode = "verify" | "settle";
|
|
56
56
|
/**
|
|
57
57
|
* CAIP-2 chain ID type (e.g., eip155:8453)
|
|
58
58
|
*/
|
package/dist/types/protocol.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type PaymentRequired = PaymentRequiredV2;
|
|
|
13
13
|
*/
|
|
14
14
|
export interface FacilitatorConfig {
|
|
15
15
|
url: string;
|
|
16
|
-
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Result from facilitator verification
|
|
@@ -34,9 +34,9 @@ export interface FacilitatorSettleResult {
|
|
|
34
34
|
error?: string;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Settlement mode - verify only
|
|
37
|
+
* Settlement mode - verify only or settle
|
|
38
38
|
*/
|
|
39
|
-
export type SettlementMode = "verify" | "settle"
|
|
39
|
+
export type SettlementMode = "verify" | "settle";
|
|
40
40
|
/**
|
|
41
41
|
* Payment destination - address, CAIP-2 chain ID, or CAIP asset ID
|
|
42
42
|
*/
|
package/package.json
CHANGED
package/src/payment-client.ts
CHANGED
|
@@ -9,9 +9,7 @@ import { decodeBase64ToUtf8 } from "./utils/base64";
|
|
|
9
9
|
|
|
10
10
|
export interface FacilitatorClientConfig {
|
|
11
11
|
url: string;
|
|
12
|
-
|
|
13
|
-
| Record<string, string>
|
|
14
|
-
| Promise<Record<string, string>>;
|
|
12
|
+
headers?: Record<string, string>;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
const DEFAULT_FACILITATOR_URL = "https://facilitator.payai.network";
|
|
@@ -38,13 +36,12 @@ function resolveUrl(config?: FacilitatorClientConfig): string {
|
|
|
38
36
|
return config?.url ?? DEFAULT_FACILITATOR_URL;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
function resolveHeaders(
|
|
42
40
|
config?: FacilitatorClientConfig,
|
|
43
|
-
):
|
|
41
|
+
): Record<string, string> {
|
|
44
42
|
const base: Record<string, string> = { "Content-Type": "application/json" };
|
|
45
|
-
if (!config?.
|
|
46
|
-
|
|
47
|
-
return { ...base, ...extra };
|
|
43
|
+
if (!config?.headers) return base;
|
|
44
|
+
return { ...base, ...config.headers };
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
export async function verifyPayment(
|
package/src/types/api.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface FacilitatorConfig {
|
|
|
33
33
|
/** Facilitator URL for verification/settlement */
|
|
34
34
|
url: string;
|
|
35
35
|
/** Optional authentication headers */
|
|
36
|
-
headers?:
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
37
|
/** Networks this facilitator supports (auto-detected if not provided) */
|
|
38
38
|
networks?: NetworkId[];
|
|
39
39
|
/** Tokens this facilitator supports (optional) */
|
|
@@ -61,9 +61,9 @@ export interface FacilitatorSettleResult {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Settlement mode - verify only
|
|
64
|
+
* Settlement mode - verify only or settle
|
|
65
65
|
*/
|
|
66
|
-
export type SettlementMode = "verify" | "settle"
|
|
66
|
+
export type SettlementMode = "verify" | "settle";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* CAIP-2 chain ID type (e.g., eip155:8453)
|
package/src/types/protocol.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type PaymentRequired = PaymentRequiredV2;
|
|
|
30
30
|
*/
|
|
31
31
|
export interface FacilitatorConfig {
|
|
32
32
|
url: string;
|
|
33
|
-
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -54,9 +54,9 @@ export interface FacilitatorSettleResult {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Settlement mode - verify only
|
|
57
|
+
* Settlement mode - verify only or settle
|
|
58
58
|
*/
|
|
59
|
-
export type SettlementMode = "verify" | "settle"
|
|
59
|
+
export type SettlementMode = "verify" | "settle";
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Payment destination - address, CAIP-2 chain ID, or CAIP asset ID
|