@402flow/sdk 0.1.0-alpha.6 → 0.1.0-alpha.8

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/x402-v2.js DELETED
@@ -1,52 +0,0 @@
1
- import { createParsedChallengeFromPaymentRequired, decodeBase64JsonObject, isRecord, isX402PaymentRequired, } from './challenge-types.js';
2
- export function parseX402V2HeaderChallenge(response) {
3
- const paymentRequiredHeader = response.headers.get('payment-required');
4
- if (!paymentRequiredHeader) {
5
- return undefined;
6
- }
7
- try {
8
- const decodedHeader = decodeBase64JsonObject(paymentRequiredHeader);
9
- if (!isX402PaymentRequired(decodedHeader) || decodedHeader.x402Version !== 2) {
10
- return undefined;
11
- }
12
- return createParsedChallengeFromPaymentRequired({
13
- protocol: 'x402',
14
- paymentRequired: decodedHeader,
15
- raw: {
16
- paymentRequiredHeader,
17
- paymentRequired: decodedHeader,
18
- },
19
- });
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- }
25
- export function parseX402V2BodyChallenge(candidate) {
26
- if (!isX402PaymentRequired(candidate) || candidate.x402Version !== 2) {
27
- return undefined;
28
- }
29
- return createParsedChallengeFromPaymentRequired({
30
- protocol: 'x402',
31
- paymentRequired: candidate,
32
- raw: {
33
- paymentRequired: candidate,
34
- },
35
- });
36
- }
37
- export function parseX402V2PaymentResponseHeader(headerValue) {
38
- if (!headerValue) {
39
- return undefined;
40
- }
41
- try {
42
- const decodedHeader = decodeBase64JsonObject(headerValue);
43
- if (!isRecord(decodedHeader)) {
44
- return undefined;
45
- }
46
- return decodedHeader;
47
- }
48
- catch {
49
- return undefined;
50
- }
51
- }
52
- //# sourceMappingURL=x402-v2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"x402-v2.js","sourceRoot":"","sources":["../src/x402-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wCAAwC,EACxC,sBAAsB,EACtB,QAAQ,EACR,qBAAqB,GAEtB,MAAM,sBAAsB,CA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