@zadq/x402 0.1.0 → 0.2.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/README.md +4 -0
- package/dist/brand.d.ts +1 -0
- package/dist/brand.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/verdict.d.ts +32 -7
- package/dist/verdict.js +39 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ import { withIdentityPolicy } from '@zadq/x402/extension';
|
|
|
26
26
|
import { resolveSignal } from '@zadq/x402/explorer';
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
When the service serves its own statement about the seller's guarantee deposit
|
|
30
|
+
beside the verdict, `readDepositDeclaration(verdict)` returns it — a state and
|
|
31
|
+
a level band, never an amount — and `null` otherwise.
|
|
32
|
+
|
|
29
33
|
Subpath exports: `verdict`, `extension`, `header`, `receipt`, `explorer`,
|
|
30
34
|
`keys`, `webhook`, `holder` (Node only) — or everything from the root. The
|
|
31
35
|
contracts each module honours are documented at
|
package/dist/brand.d.ts
CHANGED
package/dist/brand.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
// Single brand constant: a rename is an edit here plus DNS. No brand string
|
|
2
2
|
// appears anywhere else in src/ (scripts/check-brand.mjs enforces it).
|
|
3
3
|
export const BRAND = 'ZadQ';
|
|
4
|
+
// The verifying party's own extension key beside the verdict (the service's
|
|
5
|
+
// deposit declaration): the brand in lower case, as the API names it.
|
|
6
|
+
export const VERDICT_EXTENSION_KEY = BRAND.toLowerCase();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { BRAND } from './brand.js';
|
|
2
|
-
export { CHAINS, DEFAULT_TIMEOUT_MS, canonicalPayTo, canonicalSubject, canonicalVerdictPayload, fetchVerdict, freshness, isChain, keyIdFor, verifyVerdictSignature, type Chain, type Freshness, type SignatureCheck, type Verdict, type VerdictOutcome, type VerdictReason, type VerdictSubject, } from './verdict.js';
|
|
1
|
+
export { BRAND, VERDICT_EXTENSION_KEY } from './brand.js';
|
|
2
|
+
export { CHAINS, DEFAULT_TIMEOUT_MS, DEPOSIT_DECLARATION_STATES, DEPOSIT_LEVELS, canonicalPayTo, canonicalSubject, canonicalVerdictPayload, fetchVerdict, freshness, isChain, keyIdFor, readDepositDeclaration, verifyVerdictSignature, type Chain, type DepositDeclaration, type DepositDeclarationState, type DepositLevel, type Freshness, type SignatureCheck, type Verdict, type VerdictOutcome, type VerdictReason, type VerdictSubject, } from './verdict.js';
|
|
3
3
|
export { IDENTITY_POLICY_EXTENSION, MINTID_IDENTITY_EXTENSION, PERIMETER_EXTENSION, readIdentityPolicy, readMintidIdentity, readPerimeterInvitation, withIdentityPolicy, withMintidIdentity, withPerimeterInvitation, withSellerIdentity, type ClaimPolicyEntry, type CredentialState, type IdentityPolicy, type MintidIdentityPolicy, type PaymentRequiredBody, type PerimeterInvitation, type SellerIdentity, } from './extension.js';
|
|
4
4
|
export { X_PAYMENT_HEADER, X_PAYMENT_IDENTITY_HEADER, attachIdentityProof, readIdentityProof, type IdentityProof, } from './header.js';
|
|
5
5
|
export { ATTESTATION_RECEIPT_FORMAT, attestationReceiptProof, canonicalJson, isReceipt, readAttestationReceipt, receiptSigningInput, verifyAttestationReceipt, type AttestationReceipt, type ReceiptCheck, } from './receipt.js';
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// Transport follows the bIP-0002 x402 profile of the MintID identity network
|
|
7
7
|
// (cited by name): identity policy in a `PaymentRequired` extension, proof alongside
|
|
8
8
|
// the `X-PAYMENT` header.
|
|
9
|
-
export { BRAND } from "./brand.js";
|
|
10
|
-
export { CHAINS, DEFAULT_TIMEOUT_MS, canonicalPayTo, canonicalSubject, canonicalVerdictPayload, fetchVerdict, freshness, isChain, keyIdFor, verifyVerdictSignature, } from "./verdict.js";
|
|
9
|
+
export { BRAND, VERDICT_EXTENSION_KEY } from "./brand.js";
|
|
10
|
+
export { CHAINS, DEFAULT_TIMEOUT_MS, DEPOSIT_DECLARATION_STATES, DEPOSIT_LEVELS, canonicalPayTo, canonicalSubject, canonicalVerdictPayload, fetchVerdict, freshness, isChain, keyIdFor, readDepositDeclaration, verifyVerdictSignature, } from "./verdict.js";
|
|
11
11
|
export { IDENTITY_POLICY_EXTENSION, MINTID_IDENTITY_EXTENSION, PERIMETER_EXTENSION, readIdentityPolicy, readMintidIdentity, readPerimeterInvitation, withIdentityPolicy, withMintidIdentity, withPerimeterInvitation, withSellerIdentity, } from "./extension.js";
|
|
12
12
|
export { X_PAYMENT_HEADER, X_PAYMENT_IDENTITY_HEADER, attachIdentityProof, readIdentityProof, } from "./header.js";
|
|
13
13
|
export { ATTESTATION_RECEIPT_FORMAT, attestationReceiptProof, canonicalJson, isReceipt, readAttestationReceipt, receiptSigningInput, verifyAttestationReceipt, } from "./receipt.js";
|
package/dist/verdict.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The payment rails the seller rail covers (Platform Decision 14): USDC on
|
|
3
|
-
* Base (`base`, an EVM address) or on Solana (`solana`). The contract is a
|
|
4
|
-
* closed enumeration — the service answers a 400 problem to any other value,
|
|
5
|
-
* and other EVM chains are not declared until a seller needs one — so the
|
|
6
|
-
* type is the same closed union, not a string.
|
|
7
|
-
*/
|
|
8
1
|
export type Chain = 'base' | 'solana';
|
|
9
2
|
/** The declared rails, in the order the contract lists them. */
|
|
10
3
|
export declare const CHAINS: readonly Chain[];
|
|
@@ -52,7 +45,39 @@ export type Verdict = {
|
|
|
52
45
|
keyId?: string;
|
|
53
46
|
/** Present on every non-positive outcome, from the closed vocabulary; absent on `human_backed`. */
|
|
54
47
|
reason?: VerdictReason;
|
|
48
|
+
/**
|
|
49
|
+
* The verifying party's own statements beside the canonical verdict, keyed
|
|
50
|
+
* by its brand in lower case (`VERDICT_EXTENSION_KEY`). Outside the signed
|
|
51
|
+
* bytes; absent on most verdicts. Read with `readDepositDeclaration`.
|
|
52
|
+
*/
|
|
53
|
+
extensions?: Record<string, {
|
|
54
|
+
deposit?: DepositDeclaration;
|
|
55
|
+
} | undefined>;
|
|
55
56
|
};
|
|
57
|
+
/** The declaration's public states — one code per label of the seller's deposit, as the service publishes them. */
|
|
58
|
+
export declare const DEPOSIT_DECLARATION_STATES: readonly ["required", "awaiting_funds", "held", "below_level", "claim_pending", "released_partial", "returning", "returned"];
|
|
59
|
+
export type DepositDeclarationState = (typeof DEPOSIT_DECLARATION_STATES)[number];
|
|
60
|
+
/** The band of the deposit, named by the schedule tier; the amount is never carried. */
|
|
61
|
+
export declare const DEPOSIT_LEVELS: readonly ["attested_vendor", "regulated_compliance"];
|
|
62
|
+
export type DepositLevel = (typeof DEPOSIT_LEVELS)[number];
|
|
63
|
+
/**
|
|
64
|
+
* The service's own statement about the seller's guarantee deposit under its
|
|
65
|
+
* Terms, beside the verdict: a state and a level band read from the service's
|
|
66
|
+
* record at `verifiedAt` — never an amount, a balance or a holder reference.
|
|
67
|
+
* The identity network carries no fact about this deposit; the statement is
|
|
68
|
+
* the service's and sits outside the verdict's signed bytes.
|
|
69
|
+
*/
|
|
70
|
+
export type DepositDeclaration = {
|
|
71
|
+
state: DepositDeclarationState;
|
|
72
|
+
level: DepositLevel;
|
|
73
|
+
verifiedAt: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The deposit declaration a verdict carries, or `null` when it carries none
|
|
77
|
+
* (the deposit rail off, no deposit owed, or a reader that was served the
|
|
78
|
+
* verdict alone). Malformed content reads as none — nothing throws.
|
|
79
|
+
*/
|
|
80
|
+
export declare function readDepositDeclaration(verdict: Verdict | undefined | null): DepositDeclaration | null;
|
|
56
81
|
export declare const DEFAULT_TIMEOUT_MS = 3000;
|
|
57
82
|
/**
|
|
58
83
|
* Fetches the current verdict for an endpoint from the free verification path.
|
package/dist/verdict.js
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
// or an absent verdict as "no signal". Nothing here throws on network failure
|
|
11
11
|
// and nothing blocks your payment flow — your integration keeps working
|
|
12
12
|
// unchanged when no verification response is available.
|
|
13
|
+
/**
|
|
14
|
+
* The payment rails the seller rail covers (Platform Decision 14): USDC on
|
|
15
|
+
* Base (`base`, an EVM address) or on Solana (`solana`). The contract is a
|
|
16
|
+
* closed enumeration — the service answers a 400 problem to any other value,
|
|
17
|
+
* and other EVM chains are not declared until a seller needs one — so the
|
|
18
|
+
* type is the same closed union, not a string.
|
|
19
|
+
*/
|
|
20
|
+
import { VERDICT_EXTENSION_KEY } from "./brand.js";
|
|
13
21
|
/** The declared rails, in the order the contract lists them. */
|
|
14
22
|
export const CHAINS = ['base', 'solana'];
|
|
15
23
|
/** Runtime guard for the `Chain` enumeration (input from a wire, an agent or an env var). */
|
|
@@ -33,6 +41,37 @@ export function canonicalPayTo(chain, payTo) {
|
|
|
33
41
|
export function canonicalSubject(subject) {
|
|
34
42
|
return { ...subject, payTo: canonicalPayTo(subject.chain, subject.payTo) };
|
|
35
43
|
}
|
|
44
|
+
/** The declaration's public states — one code per label of the seller's deposit, as the service publishes them. */
|
|
45
|
+
export const DEPOSIT_DECLARATION_STATES = [
|
|
46
|
+
'required',
|
|
47
|
+
'awaiting_funds',
|
|
48
|
+
'held',
|
|
49
|
+
'below_level',
|
|
50
|
+
'claim_pending',
|
|
51
|
+
'released_partial',
|
|
52
|
+
'returning',
|
|
53
|
+
'returned',
|
|
54
|
+
];
|
|
55
|
+
/** The band of the deposit, named by the schedule tier; the amount is never carried. */
|
|
56
|
+
export const DEPOSIT_LEVELS = ['attested_vendor', 'regulated_compliance'];
|
|
57
|
+
/**
|
|
58
|
+
* The deposit declaration a verdict carries, or `null` when it carries none
|
|
59
|
+
* (the deposit rail off, no deposit owed, or a reader that was served the
|
|
60
|
+
* verdict alone). Malformed content reads as none — nothing throws.
|
|
61
|
+
*/
|
|
62
|
+
export function readDepositDeclaration(verdict) {
|
|
63
|
+
const d = verdict?.extensions?.[VERDICT_EXTENSION_KEY]?.deposit;
|
|
64
|
+
if (typeof d !== 'object' || d === null)
|
|
65
|
+
return null;
|
|
66
|
+
const { state, level, verifiedAt } = d;
|
|
67
|
+
if (!DEPOSIT_DECLARATION_STATES.includes(String(state)))
|
|
68
|
+
return null;
|
|
69
|
+
if (!DEPOSIT_LEVELS.includes(String(level)))
|
|
70
|
+
return null;
|
|
71
|
+
if (typeof verifiedAt !== 'string' || Number.isNaN(Date.parse(verifiedAt)))
|
|
72
|
+
return null;
|
|
73
|
+
return { state: state, level: level, verifiedAt };
|
|
74
|
+
}
|
|
36
75
|
export const DEFAULT_TIMEOUT_MS = 3000;
|
|
37
76
|
/**
|
|
38
77
|
* Fetches the current verdict for an endpoint from the free verification path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zadq/x402",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Client helpers for the free seller-verification path of x402 endpoints: the signed verdict and its local Ed25519 check, the HTTP 402 identity-policy extension and companion header, the issuer receipt, the explorer client, the webhook receiver and the seller holder driver. Zero runtime dependencies; every helper degrades to \"unknown\".",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|