Documentation ¶
Overview ¶
Package sns provides helper functions for verifying and processing Amazon AWS SNS HTTP POST payloads. Based on https://github.com/robbiet480/go.sns with updates for Go 1.21+
Index ¶
- type ConfirmSubscriptionResponse
- type Payload
- func (payload *Payload) BuildSignature() []byte
- func (payload *Payload) SignatureAlgorithm() x509.SignatureAlgorithm
- func (payload *Payload) Subscribe() (ConfirmSubscriptionResponse, error)
- func (payload *Payload) Unsubscribe() (UnsubscribeResponse, error)
- func (payload *Payload) VerifyPayload() error
- type UnsubscribeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfirmSubscriptionResponse ¶
type ConfirmSubscriptionResponse struct { XMLName xml.Name `xml:"ConfirmSubscriptionResponse"` SubscriptionArn string `xml:"ConfirmSubscriptionResult>SubscriptionArn"` RequestId string `xml:"ResponseMetadata>RequestId"` }
ConfirmSubscriptionResponse contains the XML response of accessing a SubscribeURL
type Payload ¶
type Payload struct { Message string `json:"Message"` MessageId string `json:"MessageId"` Signature string `json:"Signature"` SignatureVersion string `json:"SignatureVersion"` SigningCertURL string `json:"SigningCertURL"` SubscribeURL string `json:"SubscribeURL"` Subject string `json:"Subject"` Timestamp string `json:"Timestamp"` Token string `json:"Token"` TopicArn string `json:"TopicArn"` Type string `json:"Type"` UnsubscribeURL string `json:"UnsubscribeURL"` }
Payload contains a single POST from SNS
func (*Payload) BuildSignature ¶
BuildSignature returns a byte array containing a signature usable for SNS verification
func (*Payload) SignatureAlgorithm ¶
func (payload *Payload) SignatureAlgorithm() x509.SignatureAlgorithm
SignatureAlgorithm returns properly Algorithm for AWS Signature Version.
func (*Payload) Subscribe ¶
func (payload *Payload) Subscribe() (ConfirmSubscriptionResponse, error)
Subscribe will use the SubscribeURL in a payload to confirm a subscription and return a ConfirmSubscriptionResponse
func (*Payload) Unsubscribe ¶
func (payload *Payload) Unsubscribe() (UnsubscribeResponse, error)
Unsubscribe will use the UnsubscribeURL in a payload to confirm a subscription and return a UnsubscribeResponse
func (*Payload) VerifyPayload ¶
VerifyPayload will verify that a payload came from SNS
type UnsubscribeResponse ¶
type UnsubscribeResponse struct { XMLName xml.Name `xml:"UnsubscribeResponse"` RequestId string `xml:"ResponseMetadata>RequestId"` }
UnsubscribeResponse contains the XML response of accessing an UnsubscribeURL