swan

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 16 Imported by: 7

README

Secured Web Addressability Network

Secured Web Addressability Network (SWAN) - Go Access Layer

Secure Web Addressability Network (SWAN) - an open source secure and privacy supporting cross domain identity network implemented in Go.

Introduction

This project contains all the server side components that are needed to implement SWAN in Go for a publisher, Consent Management Platform (CMP) or OpenRTB party.

The project wraps calls to SWAN API endpoints in a simple to use data model. A connection is used to configure the mandatory parameters such as the host domain for the SWAN Operator access node, access keys and default optional parameters such as the message to display to the user when performing multiple node storage operations.

Once the connection is created functions prefixed New are used to initiate storage operations to fetch and update SWAN data. Methods to decrypt SWAN data are provided directly by the swan.Connection structure.

Prerequisites

The reader should be familiar with the SWAN concepts.

Connection

An instance of a swan.Connection is created via a call to swan.NewConnection. The default values to use for operations are provided to this method. These values can be overridden for each fetch and update storage operation.

The following code shows how this would be achieved where an instance of the structure swan.Operation provides the default values to use.

connection := swan.NewConnection(swan.Operation{
    Client: swan.Client{
        SWAN: swan.SWAN{
            AccessKey: "AccessKey",
            Operator:  "swan-access-node.org",
            Scheme:    "https"}},
    BackgroundColor:       "white",
    Message:               "Hello. SWAN operation in progress",
    MessageColor:          "Green",
    ProgressColor:         "Blue",
    NodeCount:             10,
    DisplayUserInterface:  true,
    PostMessageOnComplete: false,
    JavaScript:            false,
    UseHomeNode:           true})

See the Go source code for the meaning of the different parameters.

Operations

Once the connection is created with the defaults to be used for all requests to SWAN the following operations are supported.

In describing the operations available the following common variables and used and have the following meaning type.

Name Type Description
encrypted string base 64 encoded encrypted data returned from a SWAN storage operation
request *http.Request http request associated with a user's web browser - used to set the home node
returnUrl *url.URL the URL to return to after the browser has been directed to the URL provided by the GetURL function
Fetch

Provides a URL that the browser should be immediately directed to. The return URL will have the encrypted SWAN data appended ready to be used with the decrypt functions.

url := connection.NewFetch(request, returnUrl).GetURL()
Update

Provides a URL that the browser should be immediately directed to. The return URL will have the encrypted SWAN data appended ready to be used with the decrypt functions.

Note: The return URL and optional Access Node could have been passed by the publisher to the User Interface Provider in the state array of the original Fetch operation. See the SWAN demo for passing data between different parties via the Operation.State array parameter.

The members Pref, Email, Salt and RID should be set to the values provided by the user before the GetURL function is called. If they are left blank the existing values are removed from SWAN.


// Get the OWID signer which is needed to sign the raw SWAN data. The User
// Interface Provider will be responsible for obtaining their OWID signer.
signer, err := YourMethodToGetOWIDSigner()
if err != nil { return err }

// Create a new Update operation with the request from the web browser and the
// return URL.
u := connection.NewUpdate(request, returnUrl)

// Set the raw SWAN data from the form associated with the request. Pass the 
// OWID signer to each of the methods that generates the OWID signed data 
// structure. 
// Check the err indicator incase there was a problem generating the OWID from 
// the input data or if the input data did not pass validation.
if err != nil { return err }
u.Pref = NewPreferences(signer, r.Form.Get("pref") == "on")
if err != nil { return err }
u.Email, err = NewEmail(signer, r.Form.Get("email"))
if err != nil { return err }
u.Salt, err = NewSaltFromString(signer, r.Form.Get("salt"))
if err != nil { return err }
u.RID, err = IdentifierFromBase64(r.Form.Get("rid"))
if err != nil { return err }

// Get the storage operation URL to redirect the web browser to.
url := u.GetURL()
Stop

Provides a URL that the browser should be immediately directed to. The return URL will have the encrypted SWAN data appended ready to be used with the decrypt functions.

The host parameter is the host domain associated with the advert that should be stopped.

host := r.Form.Get("host")
url := connection.NewSWANStop(r, returnUrl, host).GetURL()
Decrypt

Returns the decrypted SWAN data from the base 64 encoded encrypted data provided.

swanPairs := connection.Decrypt(encrypted)

Example result in JSON format prior to conversion to SWAN pairs.

[
    {
        "Key": "pref",
        "Created": "2021-05-10T00:00:00Z",
        "Expires": "2021-08-05T00:00:00Z",
        "Value": "AmNtcC...m23avB"
    },
    {
        "Key": "sid",
        "Created": "2021-05-07T00:00:00Z",
        "Expires": "2021-08-05T00:00:00Z",
        "Value": "AjUxZG...2an7jM"
    },
    {
        "Key": "stop",
        "Created": "2021-05-10T00:00:00Z",
        "Expires": "2086-08-03T00:00:00Z",
        "Value": "cool-creams.uk cool-bikes.uk"
    },
    {
        "Key": "rid",
        "Created": "2021-05-10T00:00:00Z",
        "Expires": "2021-08-05T00:00:00Z",
        "Value": "AjUxZGI...xjtRBQ"
    },
    {
        "Key": "val",
        "Created": "2021-05-10T09:15:42.7843197Z",
        "Expires": "2086-08-03T00:00:00Z",
        "Value": "2021-05-10T09:31:42Z"
    }
]

The returned keys map to the SWAN data.

The keys rid, sid and pref have related OWIDs.

The key val contains the time when the caller should revalidate the SWAN data with SWAN via a call to Fetch. It is possible another tab in the same web browser has been used to update the SWAN data and the current domain will not be aware of these changes until it validates the data is still current.

DecryptRaw

Returns the decrypted raw SWAN data as a map of string keys to values from the base 64 encoded encrypted data provided. Must only be used by User Interface Providers to update SWAN data.

raw := connection.DecryptRaw(encrypted)

Example result.

{
    "backgroundColor": "#f5f5f5",
    "email": "test@test.com",
    "message": "Hang tight. We're getting things ready.",
    "messageColor": "darkslategray",
    "pref": "off",
    "progressColor": "darkgreen",
    "salt": "qqo",
    "state": [
        "Example state"
    ],
    "rid": "AjUxZGIudWsAgdMK...TaK/AWD4tDXxjtRBQ",
    "title": "SWAN Demo"
}
CreateRID

Returns a new RID with an OWID from from the SWAN Operator. Only SWAN operators can create RIDs.

rid := connection.CreateRID()
HomeNode

Returns the domain of the home node for the web browser associated with the request.

homeNode := connection.HomeNode(request)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSWANCookie

func IsSWANCookie(c *http.Cookie) bool

IsSWANCookie returns true if a SWAN cookie.

Types

type Base added in v0.1.5

type Base struct {
	Version byte       `json:"version"` // Used to indicate the version encoding of the type.
	OWID    *owid.OWID `json:"source"`  // OWID related to the structure
}

Base used with any SWAN field.

type Bid

type Bid struct {
	Response
	MediaURL      string `json:"mediaUrl"`      // The URL of the content of the advert provided in response
	AdvertiserURL string `json:"advertiserURL"` // The URL to direct the browser to if the advert is selected
}

Bid contains the information about the advert to be displayed.

func BidFromBase64 added in v0.1.5

func BidFromBase64(value string) (*Bid, error)

func BidFromJson added in v0.1.5

func BidFromJson(j []byte) (*Bid, error)

func NewBid added in v0.1.5

func NewBid(s *owid.Signer, mediaUrl string, advertiserUrl string) (*Bid, error)

func (*Bid) MarshalBinary added in v0.1.5

func (a *Bid) MarshalBinary() ([]byte, error)

func (*Bid) MarshalOwid added in v0.1.5

func (a *Bid) MarshalOwid() ([]byte, error)

func (*Bid) ToBase64 added in v0.1.5

func (a *Bid) ToBase64() (string, error)

func (*Bid) UnmarshalBinary added in v0.1.5

func (a *Bid) UnmarshalBinary(data []byte) error

type ByteArray added in v0.1.5

type ByteArray struct {
	Base
	Data []byte `json:"data"`
}

ByteArray used for general purpose data storage.

func ByteArrayFromBase64 added in v0.1.5

func ByteArrayFromBase64(value string) (*ByteArray, error)

func ByteArrayFromJson added in v0.1.5

func ByteArrayFromJson(j []byte) (*ByteArray, error)

func NewByteArray added in v0.1.5

func NewByteArray(s *owid.Signer, data []byte) (*ByteArray, error)

func NewSID added in v0.1.8

func NewSID(signer *owid.Signer, email *Email, salt *Salt) (*ByteArray, error)

NewSID generates the SID by hashing the salt and the email to create a sha256 hash. If the email address is empty an empty byte array is returned.

func (*ByteArray) FromBase64 added in v0.1.9

func (a *ByteArray) FromBase64(value string) error

func (*ByteArray) MarshalBinary added in v0.1.5

func (a *ByteArray) MarshalBinary() ([]byte, error)

func (*ByteArray) MarshalOwid added in v0.1.5

func (a *ByteArray) MarshalOwid() ([]byte, error)

func (*ByteArray) ToBase64 added in v0.1.5

func (a *ByteArray) ToBase64() (string, error)

func (*ByteArray) UnmarshalBinary added in v0.1.5

func (a *ByteArray) UnmarshalBinary(data []byte) error

type Client

type Client struct {
	SWAN
	Request *http.Request // The HTTP request from the web browser
}

Client is used for actions where a request from a web browser is available. It is mainly used to set the home node from the public IP address of the web browser.

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection stores the static details that are used when creating a new swan request.

func NewConnection

func NewConnection(operation Operation) *Connection

NewConnection creates a new SWAN connection based on the operation provided.

func (*Connection) CreateRID added in v0.1.6

func (c *Connection) CreateRID() (*Identifier, *Error)

CreateRID returns a new RID in OWID format from the SWAN Operator. Only SWAN Operators can create legitimate RIDs.

func (*Connection) Decrypt

func (c *Connection) Decrypt(encrypted string) ([]*Pair, *Error)

Decrypt returns SWAN key value pairs for the data contained in the encrypted string.

func (*Connection) DecryptRaw

func (c *Connection) DecryptRaw(
	encrypted string) (map[string]interface{}, *Error)

DecryptRaw returns key value pairs for the raw SWAN data contained in the encrypted string. Must only be used by User Interface Providers.

func (*Connection) HomeNode

func (c *Connection) HomeNode(r *http.Request) (string, *Error)

HomeNode returns the SWAN home node associated with the web browser.

func (*Connection) NewClient

func (c *Connection) NewClient(request *http.Request) *Client

NewClient creates a new request.

request http request from a web browser

func (*Connection) NewDecrypt

func (c *Connection) NewDecrypt(encrypted string) *Decrypt

NewDecrypt creates a new decrypt request using the default in the connection.

encrypted the base 64 encoded SWAN data to be decrypted

func (*Connection) NewFetch

func (c *Connection) NewFetch(
	request *http.Request,
	returnUrl string,
	existing []*Pair) *Fetch

NewFetch creates a new fetch operation using the default in the connection.

request http request from a web browser

returnUrl return URL after the operation completes

existing if any values already exist then use these if none are available in SWAN

func (*Connection) NewSWAN

func (c *Connection) NewSWAN() *SWAN

NewSWAN creates a new request using the default in the connection.

func (*Connection) NewStop

func (c *Connection) NewStop(
	request *http.Request,
	returnUrl string,
	host string) *Stop

NewStop creates a new stop operation using the default in the connection.

request http request from a web browser

returnUrl return URL after the operation completes

host associated with the advert to stop

func (*Connection) NewUpdate

func (c *Connection) NewUpdate(
	request *http.Request,
	returnUrl string) *Update

NewUpdate creates a new fetch operation using the default in the connection.

request http request from a web browser

returnUrl return URL after the operation completes

type Decrypt

type Decrypt struct {
	SWAN
	Encrypted string // The encrypted string to be decrypted by SWAN
}

Decrypt contains the string to be decrypted via the call to SWAN.

type Email added in v0.1.5

type Email struct {
	Base
	Email string `json:"email"`
}

Email used to represent an email address.

func EmailFromBase64 added in v0.1.5

func EmailFromBase64(value string) (*Email, error)

func EmailFromJson added in v0.1.5

func EmailFromJson(j []byte) (*Email, error)

func NewEmail added in v0.1.5

func NewEmail(s *owid.Signer, email string) (*Email, error)

func (*Email) FromBase64 added in v0.1.9

func (e *Email) FromBase64(value string) error

func (*Email) MarshalBinary added in v0.1.5

func (e *Email) MarshalBinary() ([]byte, error)

func (*Email) MarshalOwid added in v0.1.5

func (e *Email) MarshalOwid() ([]byte, error)

func (*Email) ToBase64 added in v0.1.5

func (e *Email) ToBase64() (string, error)

func (*Email) UnmarshalBinary added in v0.1.5

func (e *Email) UnmarshalBinary(data []byte) error

type Empty

type Empty struct {
	Response
}

Empty contains nothing. Used for most OWIDs that just sign the root and themselves.

func EmptyFromBase64 added in v0.1.5

func EmptyFromBase64(value string) (*Empty, error)

func EmptyFromJson added in v0.1.5

func EmptyFromJson(j []byte) (*Empty, error)

func NewEmpty added in v0.1.5

func NewEmpty(s *owid.Signer) (*Empty, error)

func (*Empty) MarshalBinary added in v0.1.5

func (a *Empty) MarshalBinary() ([]byte, error)

func (*Empty) MarshalOwid added in v0.1.5

func (a *Empty) MarshalOwid() ([]byte, error)

func (*Empty) ToBase64 added in v0.1.5

func (a *Empty) ToBase64() (string, error)

func (*Empty) UnmarshalBinary added in v0.1.5

func (a *Empty) UnmarshalBinary(data []byte) error

type Error

type Error struct {
	Err      error          // The underlying error message.
	Response *http.Response // The HTTP response that caused the error.
}

Error is used to pass back errors from methods that call APIs. If the Response member is set then the called method can use this information in its response. If it is not set then an internal server error can be assumed.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string from an HTTPError reference.

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the status code of the response.

type Failed

type Failed struct {
	Response
	Host  string `json:"host"`  // The domain that did not respond.
	Error string `json:"error"` // The error message to add to the tree.
}

Failed contains details about the request that was not signed by the recipient.

func FailedFromBase64 added in v0.1.5

func FailedFromBase64(value string) (*Failed, error)

func FailedFromJson added in v0.1.5

func FailedFromJson(j []byte) (*Failed, error)

func NewFailed added in v0.1.5

func NewFailed(s *owid.Signer, host string, message string) (*Failed, error)

func (*Failed) MarshalBinary added in v0.1.5

func (f *Failed) MarshalBinary() ([]byte, error)

func (*Failed) MarshalOwid added in v0.1.5

func (f *Failed) MarshalOwid() ([]byte, error)

func (*Failed) ToBase64 added in v0.1.5

func (f *Failed) ToBase64() (string, error)

func (*Failed) UnmarshalBinary added in v0.1.5

func (f *Failed) UnmarshalBinary(data []byte) error

type Fetch

type Fetch struct {
	Operation
	Existing []*Pair // Existing SWAN data pairs
}

Fetch operation to retrieve the SWAN data for use with a call to Decrypt or DecryptRaw.

func (*Fetch) GetURL

func (f *Fetch) GetURL() (string, *Error)

GetURL contacts the SWAN operator domain with the access key and returns a URL string that the web browser should be immediately directed to.

type Field added in v0.1.5

type Field interface {

	// Returns the field value as a base64 string.
	ToBase64() (string, error)

	// Populates the field values from the base64 string.
	FromBase64(string) error
}

Field type used with swan.Pair.

type Identifier added in v0.1.5

type Identifier struct {
	Base
	IdType    string    `json:"type"`  // Type of identifier
	Value     uuid.UUID `json:"value"` // In practice the value is a UUID so store it as one
	Persisted bool      // True if the value has been stored.
}

Identifier represents a OneKey compatible random identifier. https://github.com/OneKey-Network/addressability-framework/blob/main/mvp-spec/model/identifier.md

func IdentifierFromBase64 added in v0.1.5

func IdentifierFromBase64(value string) (*Identifier, error)

func IdentifierFromJson added in v0.1.5

func IdentifierFromJson(j []byte) (*Identifier, error)

func NewIdentifier added in v0.1.5

func NewIdentifier(
	s *owid.Signer,
	idType string,
	value uuid.UUID) (*Identifier, error)

func (*Identifier) FromBase64 added in v0.1.9

func (i *Identifier) FromBase64(value string) error

func (*Identifier) MarshalBinary added in v0.1.5

func (i *Identifier) MarshalBinary() ([]byte, error)

func (*Identifier) MarshalOwid added in v0.1.5

func (i *Identifier) MarshalOwid() ([]byte, error)

func (*Identifier) ToBase64 added in v0.1.5

func (i *Identifier) ToBase64() (string, error)

func (*Identifier) UnmarshalBinary added in v0.1.5

func (i *Identifier) UnmarshalBinary(data []byte) error

type Operation

type Operation struct {
	Client
	// The URL to return to with the encrypted data appended to it.
	ReturnUrl string
	// The access node that will be used to decrypt the result of the storage
	// operation. Defaults to the access node that started the storage
	// operation.
	AccessNode      string
	Title           string // The title of the progress UI page.
	Message         string // The text of the message in the progress UI.
	ProgressColor   string // The HTML color for the progress indicator.
	BackgroundColor string // The HTML color for the progress UI background.
	MessageColor    string // The HTML color for the message text.
	NodeCount       int    // Number of storage nodes to use for operations.
	// DisplayUserInterface true if a progress UI should be displayed during the
	// storage operation, otherwise false.
	DisplayUserInterface bool
	// PostMessageOnComplete true if at the end of the operation the resulting
	// data should be returned to the parent using JavaScript postMessage,
	// otherwise false. Default false.
	PostMessageOnComplete bool
	// UseHomeNode true if the home node can be used if it contains current
	// data. False if the SWAN network should be consulted irrespective of the
	// state of data held on the home node. Default true.
	UseHomeNode bool
	// JavaScript true if the response for storage operations should be
	// JavaScript include that will continue the operation. This feature
	// requires cookies to be sent for DOM inserted JavaScript elements. Default
	// false.
	JavaScript bool
	// Optional array of strings that can be used to pass state information to
	// the party that retrieves the results of the storage operation. For
	// example; passing information between a Publisher and User Interface
	// Provider such as a CMP in the storage operation.
	State []string
}

Operation has members for all the parameters for a storage operation involving a URL that is requested by the web browser.

type Pair

type Pair struct {
	Key     string    // The name of the key associated with the value
	Created time.Time // The UTC time when the value was created
	// The UTC time when the value will expire and should not be used
	Expires time.Time
	Value   Field // The value associated with the key
}

Pair represents a key value pair stored in SWAN. The created and expiry times for the value are also available.

func NewPairFromCookie

func NewPairFromCookie(cookie *http.Cookie, value Field) (*Pair, error)

NewPairFromCookie creates a new SWAN pair from the cookie. cookie as source for the pair. value instance to be assigned to the pair.

func (*Pair) AsCookie

func (p *Pair) AsCookie(host string, secure bool) (*http.Cookie, error)

AsCookie returns the pair as a cookie to be used in an HTTP response. host to use for the domain of the cookie. secure

func (*Pair) CookieName

func (p *Pair) CookieName() string

CookieName name for any cookie associated with the SWAN pair.

type Preferences added in v0.1.5

type Preferences struct {
	Base
	Data PreferencesData `json:"data"`
}

Preferences https://github.com/OneKey-Network/addressability-framework/blob/main/mvp-spec/model/preferences.md

func NewPreferences added in v0.1.5

func NewPreferences(s *owid.Signer, personalizedMarketing bool) (*Preferences, error)

func PreferencesFromBase64 added in v0.1.5

func PreferencesFromBase64(value string) (*Preferences, error)

func PreferencesFromJson added in v0.1.5

func PreferencesFromJson(j []byte) (*Preferences, error)

func (*Preferences) FromBase64 added in v0.1.9

func (p *Preferences) FromBase64(value string) error

func (*Preferences) MarshalBinary added in v0.1.5

func (p *Preferences) MarshalBinary() ([]byte, error)

func (*Preferences) MarshalOwid added in v0.1.5

func (p *Preferences) MarshalOwid() ([]byte, error)

func (*Preferences) ToBase64 added in v0.1.5

func (p *Preferences) ToBase64() (string, error)

func (*Preferences) UnmarshalBinary added in v0.1.5

func (p *Preferences) UnmarshalBinary(data []byte) error

type PreferencesData added in v0.1.5

type PreferencesData struct {
	UseBrowsingForPersonalization bool `json:"use_browsing_for_personalization"`
}

PreferencesData https://github.com/OneKey-Network/addressability-framework/blob/main/mvp-spec/model/preferences-data.md

func (*PreferencesData) MarshalBinary added in v0.1.5

func (p *PreferencesData) MarshalBinary() ([]byte, error)

func (*PreferencesData) MarshalJSON added in v0.1.5

func (p *PreferencesData) MarshalJSON() ([]byte, error)

func (*PreferencesData) UnmarshalBinary added in v0.1.5

func (p *PreferencesData) UnmarshalBinary(data []byte) error

type Response added in v0.1.5

type Response struct {
	Base
	StructType byte `json:"type"` // The type of structure the response relates to
}

Response from an OpenRTB transation.

type SWAN

type SWAN struct {
	Scheme    string // The HTTP or HTTPS scheme to use for SWAN requests
	Operator  string // Domain name of the SWAN Operator access node
	AccessKey string // SWAN access key provided by the SWAN Operator
}

SWAN is the base structure for all actions. It includes the scheme for the SWAN Operator URLs, the Operator domain and the access key needed by the SWAN Operator.

type Salt added in v0.1.6

type Salt struct {
	Base
	Salt uint32 `json:"salt"`
}

Salt used to store the integer used as salt when hashing the email address to form the Signed in Id (SID).

func NewSalt added in v0.1.6

func NewSalt(s *owid.Signer, data uint32) (*Salt, error)

func NewSaltFromString added in v0.1.6

func NewSaltFromString(s *owid.Signer, data string) (*Salt, error)

func SaltFromBase64 added in v0.1.6

func SaltFromBase64(value string) (*Salt, error)

func SaltFromJson added in v0.1.6

func SaltFromJson(j []byte) (*Salt, error)

func (*Salt) AsByteArray added in v0.1.7

func (s *Salt) AsByteArray() ([]byte, error)

func (*Salt) FromBase64 added in v0.1.9

func (a *Salt) FromBase64(value string) error

func (*Salt) MarshalBinary added in v0.1.6

func (a *Salt) MarshalBinary() ([]byte, error)

func (*Salt) MarshalOwid added in v0.1.6

func (a *Salt) MarshalOwid() ([]byte, error)

func (*Salt) ToBase64 added in v0.1.6

func (a *Salt) ToBase64() (string, error)

func (*Salt) UnmarshalBinary added in v0.1.6

func (a *Salt) UnmarshalBinary(data []byte) error

type Seed added in v0.1.5

type Seed struct {
	Base
	PubDomain   string       `json:"pubDomain"`   // The domain that the advertisements will appear on
	UUID        uuid.UUID    `json:"uuid"`        // A unique identifier for this Id
	RID         *Identifier  `json:"rid"`         // The Random [browser] Id
	SID         *ByteArray   `json:"sid"`         // The Signed in Id
	Preferences *Preferences `json:"preferences"` // The privacy preferences
	Stopped     []string     `json:"stopped"`     // List of domains or advert IDs that should not be shown
}

Seed contains the information about the opportunity to advertise with a publisher. It is created and signed by the SWAN Root Party, typically the publisher or an agent acting on their behalf.

func NewSeed added in v0.1.5

func NewSeed() (*Seed, error)

Returns a new swan.Seed with the correct version and a random uuid ready to have the other values added and then signed.

func SeedFromBase64 added in v0.1.5

func SeedFromBase64(value string) (*Seed, error)

func SeedFromJson added in v0.1.5

func SeedFromJson(j []byte) (*Seed, error)

func (*Seed) IsStopped added in v0.1.5

func (s *Seed) IsStopped(u string) bool

IsStopped returns true if the URL provided is stopped.

func (*Seed) MarshalBinary added in v0.1.5

func (s *Seed) MarshalBinary() ([]byte, error)

func (*Seed) MarshalOwid added in v0.1.5

func (s *Seed) MarshalOwid() ([]byte, error)

func (*Seed) Sign added in v0.1.5

func (s *Seed) Sign(signer *owid.Signer) error

Sign the seed including all the fields included.

func (*Seed) ToBase64 added in v0.1.5

func (s *Seed) ToBase64() (string, error)

func (*Seed) UnmarshalBinary added in v0.1.5

func (s *Seed) UnmarshalBinary(data []byte) error

type Stop

type Stop struct {
	Operation
	Host string // Advert host to block
}

Stop operation to block an advert domain or identifier.

func (*Stop) GetURL

func (s *Stop) GetURL() (string, *Error)

GetURL contacts the SWAN operator domain with the access key and returns a URL string that the web browser should be directed to.

type Update

type Update struct {
	Operation
	RID   *Identifier  // Random [browser] Id - see CreateRID
	Pref  *Preferences // Preference for marketing - see CreatePreferences
	Email *Email       // Email address - see CreateEmail
	Salt  *ByteArray   // Salt for SID - see CreateByteArray
}

Update operation from a User Interface Provider where the preferences, email and salt have been captured. The RID is returned from a previous call to swan.CreateRID.

func (*Update) GetURL

func (u *Update) GetURL() (string, *Error)

GetURL contacts the SWAN operator domain with the access key and returns a URL string that the web browser should be directed to.

func (*Update) GetValues

func (u *Update) GetValues() (url.Values, error)

GetValues returns the values that can be used to configure a web browser with the information contained in the Update operation. Ensure the access key and other values that are specific to an operation are not included in the resulting values.

Jump to

Keyboard shortcuts

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