sns

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: MIT Imports: 12 Imported by: 0

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

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

func (payload *Payload) BuildSignature() []byte

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

func (payload *Payload) VerifyPayload() error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL