Versions in this module Expand all Collapse all v0 v0.2.0 Oct 10, 2026 Changes in this version + var ErrSignatureEncoding = errors.New("snap: signature is not Base64 (or hex) of the expected size") v0.1.2 Sep 13, 2026 Changes in this version + const DefaultTimestampLayout + const DefaultTimestampWindow + const DisableTimestampFreshnessCheck + var ErrBadRequest = errors.New("snap: bad request") + var ErrEmptyClientSecret = errors.New("snap: verify: KeyStore.ClientSecret returned an empty string") + var ErrForbidden = errors.New("snap: forbidden") + var ErrInternalServerError = errors.New("snap: internal server error") + var ErrNoKeyStore = errors.New("snap: verify: KeyStore is not set") + var ErrNoPEMBlock = errors.New("snap: no PEM block found") + var ErrNotFound = errors.New("snap: not found") + var ErrNotRSAKey = errors.New("snap: not an RSA key") + var ErrNotRSASigner = errors.New("snap: not an RSA signer") + var ErrServiceUnavailable = errors.New("snap: service unavailable") + var ErrSignatureMismatch = errors.New("snap: signature mismatch") + var ErrTimeout = errors.New("snap: timeout") + var ErrUnauthorized = errors.New("snap: unauthorized") + var ErrUnmappedResponseCode = errors.New("snap: unmapped response code class") + var ErrWeakRSAKey = errors.New("snap: RSA key smaller than minimum size") + func BuildStringToSignAccessToken(clientID, timestamp string) string + func BuildStringToSignTransaction(method, endpointURL, accessToken string, body []byte, timestamp string, ...) string + func CheckResponseStatus(responseCode string, httpStatus int) error + func ParseRSAPrivateKeyPEM(pemBytes []byte) (crypto.Signer, error) + func ParseResponseCode(code string) (httpStatus int, serviceCode, caseCode string, err error) + func ResponseCodeError(code string) error + func SignAsymmetric(signer crypto.Signer, stringToSign string) (string, error) + func SignSymmetric(clientSecret, stringToSign string) string + func TruncateForError(s string) string + func VerifyAsymmetric(pub crypto.PublicKey, stringToSign, signature string) error + func VerifySymmetric(clientSecret, stringToSign, signature string) bool + type DefaultProfile struct + Domain string + Version string + func (p DefaultProfile) BuildPath(serviceGroup, productType string) string + func (p DefaultProfile) TimestampLayout() string + type Envelope struct + Raw json.RawMessage + ResponseCode string + ResponseMessage string + StatusCode int + type GrantType string + const GrantTypeAuthorizationCode + const GrantTypeClientCredentials + const GrantTypeRefreshToken + type HeaderBuilder struct + AccessToken string + AuthorizationCustomer string + B2B2C bool + Body []byte + ChannelID string + ClientKey string + ClientSecret string + DeviceID string + EndpointURL string + ExternalID string + IPAddress string + Latitude string + Longitude string + Method string + Origin string + PartnerID string + Profile Profile + Signer crypto.Signer + Symmetric bool + func (b HeaderBuilder) Build() (http.Header, error) + type IncomingRequest struct + AccessToken string + Body []byte + ClientKey string + EndpointURL string + ExternalID string + Method string + Signature string + Timestamp string + type KeyStore interface + ClientSecret func(clientKey string) (string, error) + PublicKey func(clientKey string) (crypto.PublicKey, error) + type Money struct + Currency string + Value string + type Profile interface + BuildPath func(serviceGroup, productType string) string + TimestampLayout func() string + type ServerVerifier struct + KeyStore KeyStore + Mode SignatureMode + Now func() time.Time + Profile Profile + TimestampWindow time.Duration + func (v *ServerVerifier) VerifyAccessTokenRequest(req IncomingRequest) error + func (v *ServerVerifier) VerifyTransactionRequest(req IncomingRequest) error + type SignatureMode int + const SignatureModeAsymmetric + const SignatureModeSymmetric + type Token struct + AccessToken string + ExpiresIn time.Duration + RefreshToken string + TokenType string + type TokenManager struct + BaseURL string + ClientKey string + HTTPClient *http.Client + Now func() time.Time + Profile Profile + Signer crypto.Signer + func (m *TokenManager) AccessTokenB2B(ctx context.Context) (string, error) + func (m *TokenManager) AccessTokenB2B2C(ctx context.Context, grantType GrantType, code string) (Token, error) + type Transport struct + HTTPClient *http.Client + func (t *Transport) Do(ctx context.Context, hb HeaderBuilder) (Envelope, error)