Documentation
¶
Index ¶
- Variables
- func AP2PublicJWKS() ([]map[string]interface{}, error)
- func AP2VerificationKey(kid string) (*ecdsa.PublicKey, bool)
- func ActiveAP2SigningKey() (kid string, priv *ecdsa.PrivateKey, err error)
- func LooksLikeMandateJWT(token string) bool
- func MerchantAuthorizationJWS(checkout map[string]interface{}) (string, error)
- func RotateAP2SigningKey() (newKid string, err error)
- func SetStore(get func(key string) string, set func(key, value string) error)
- func VerifyMerchantAuthorizationJWS(checkout map[string]interface{}, detached string) error
- func VerifyPaymentMandate(token, checkoutJWT string, opts MandateVerifyOpts) error
- type AP2KeySummary
- type MandateResult
- type MandateVerifyOpts
Constants ¶
This section is empty.
Variables ¶
var ( ErrMandateRequired = errors.New("mandate_required") ErrMandateInvalidSignature = errors.New("mandate_invalid_signature") ErrMandateExpired = errors.New("mandate_expired") ErrMandateScopeMismatch = errors.New("mandate_scope_mismatch") ErrMerchantAuthorizationInvalid = errors.New("merchant_authorization_invalid") ErrAgentMissingKey = errors.New("agent_missing_key") ErrMandateMalformed = errors.New("mandate_malformed") )
UCP / AP2 error codes, surfaced verbatim (the Error string IS the code).
Functions ¶
func AP2PublicJWKS ¶
AP2PublicJWKS returns every currently-usable public key for JWKS output.
func AP2VerificationKey ¶
AP2VerificationKey resolves one of this tenant's own public keys by kid, including a recently-retired one still inside the rotation overlap. Used to check a merchant_authorization this store produced.
func ActiveAP2SigningKey ¶
func ActiveAP2SigningKey() (kid string, priv *ecdsa.PrivateKey, err error)
ActiveAP2SigningKey returns the current signing key, generating the very first one on demand. The returned kid is what goes in the JWS header.
func LooksLikeMandateJWT ¶
LooksLikeMandateJWT reports whether a payment credential token is itself a (SD-)JWT that must be verified, as opposed to an opaque gateway token that is simply forwarded to the charger.
func MerchantAuthorizationJWS ¶
MerchantAuthorizationJWS returns the detached-JWS ap2.merchant_authorization for a checkout object: "<b64url header>..<b64url signature>", the JCS canonical form of the checkout WITH ITS ap2 FIELD REMOVED transmitted separately as the response body itself (RFC 7515 Appendix F).
func RotateAP2SigningKey ¶
RotateAP2SigningKey retires every currently-active key (keeping it verifiable for the overlap window) and mints a fresh active one.
func VerifyMerchantAuthorizationJWS ¶
VerifyMerchantAuthorizationJWS checks a detached merchant_authorization against this tenant's own JWKS over the JCS form of the given checkout (ap2 field excluded). Used to re-check the authorization a checkout mandate embeds, and by tools/ap2verify.
func VerifyPaymentMandate ¶
func VerifyPaymentMandate(token, checkoutJWT string, opts MandateVerifyOpts) error
VerifyPaymentMandate verifies a payment mandate token and that it is bound to the given checkout JWT (sha-256 of the compact checkout JWT), per the UCP AP2 Mandates Extension. A token that is not a JWT is treated as an opaque gateway token by the caller and never reaches here.
Types ¶
type AP2KeySummary ¶
type AP2KeySummary struct {
Kid string `json:"kid"`
CreatedAt time.Time `json:"created_at"`
RetiredAt *time.Time `json:"retired_at,omitempty"`
Active bool `json:"active"`
}
AP2KeySummary is the read-only view the controller dashboard shows.
func AP2KeySummaries ¶
func AP2KeySummaries() ([]AP2KeySummary, error)
type MandateResult ¶
type MandateResult struct {
Claims map[string]interface{}
IssuerJWT string
HolderJWK map[string]interface{}
KeySource string
}
func VerifyCheckoutMandate ¶
func VerifyCheckoutMandate(sdjwt string, opts MandateVerifyOpts) (*MandateResult, error)
VerifyCheckoutMandate verifies an SD-JWT+kb checkout mandate. It does NOT do the AP2 terms match against the live cart - the caller does that with the returned Claims, because only the caller has the recomputed checkout.