Documentation ¶
Index ¶
- func IsSWANCookie(c *http.Cookie) bool
- type Base
- type Bid
- type ByteArray
- type Client
- type Connection
- func (c *Connection) CreateRID() (*Identifier, *Error)
- func (c *Connection) Decrypt(encrypted string) ([]*Pair, *Error)
- func (c *Connection) DecryptRaw(encrypted string) (map[string]interface{}, *Error)
- func (c *Connection) HomeNode(r *http.Request) (string, *Error)
- func (c *Connection) NewClient(request *http.Request) *Client
- func (c *Connection) NewDecrypt(encrypted string) *Decrypt
- func (c *Connection) NewFetch(request *http.Request, returnUrl string, existing []*Pair) *Fetch
- func (c *Connection) NewSWAN() *SWAN
- func (c *Connection) NewStop(request *http.Request, returnUrl string, host string) *Stop
- func (c *Connection) NewUpdate(request *http.Request, returnUrl string) *Update
- type Decrypt
- type Email
- type Empty
- type Error
- type Failed
- type Fetch
- type Field
- type Identifier
- type Operation
- type Pair
- type Preferences
- type PreferencesData
- type Response
- type SWAN
- type Salt
- type Seed
- type Stop
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSWANCookie ¶
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 BidFromJson ¶ added in v0.1.5
func (*Bid) MarshalBinary ¶ added in v0.1.5
func (*Bid) MarshalOwid ¶ added in v0.1.5
func (*Bid) UnmarshalBinary ¶ added in v0.1.5
type ByteArray ¶ added in v0.1.5
ByteArray used for general purpose data storage.
func ByteArrayFromBase64 ¶ added in v0.1.5
func ByteArrayFromJson ¶ added in v0.1.5
func NewByteArray ¶ added in v0.1.5
func NewSID ¶ added in v0.1.8
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 (*ByteArray) MarshalBinary ¶ added in v0.1.5
func (*ByteArray) MarshalOwid ¶ added in v0.1.5
func (*ByteArray) UnmarshalBinary ¶ added in v0.1.5
type Client ¶
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 ¶
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.
type Email ¶ added in v0.1.5
Email used to represent an email address.
func EmailFromBase64 ¶ added in v0.1.5
func EmailFromJson ¶ added in v0.1.5
func (*Email) FromBase64 ¶ added in v0.1.9
func (*Email) MarshalBinary ¶ added in v0.1.5
func (*Email) MarshalOwid ¶ added in v0.1.5
func (*Email) UnmarshalBinary ¶ added in v0.1.5
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 EmptyFromJson ¶ added in v0.1.5
func (*Empty) MarshalBinary ¶ added in v0.1.5
func (*Empty) MarshalOwid ¶ added in v0.1.5
func (*Empty) UnmarshalBinary ¶ added in v0.1.5
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) StatusCode ¶
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 FailedFromJson ¶ added in v0.1.5
func (*Failed) MarshalBinary ¶ added in v0.1.5
func (*Failed) MarshalOwid ¶ added in v0.1.5
func (*Failed) UnmarshalBinary ¶ added in v0.1.5
type Fetch ¶
Fetch operation to retrieve the SWAN data for use with a call to Decrypt or DecryptRaw.
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 ¶
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 ¶
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 ¶
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
Salt used to store the integer used as salt when hashing the email address to form the Signed in Id (SID).
func NewSaltFromString ¶ added in v0.1.6
func SaltFromBase64 ¶ added in v0.1.6
func SaltFromJson ¶ added in v0.1.6
func (*Salt) AsByteArray ¶ added in v0.1.7
func (*Salt) FromBase64 ¶ added in v0.1.9
func (*Salt) MarshalBinary ¶ added in v0.1.6
func (*Salt) MarshalOwid ¶ added in v0.1.6
func (*Salt) UnmarshalBinary ¶ added in v0.1.6
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
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 SeedFromJson ¶ added in v0.1.5
func (*Seed) MarshalBinary ¶ added in v0.1.5
func (*Seed) MarshalOwid ¶ added in v0.1.5
func (*Seed) UnmarshalBinary ¶ added in v0.1.5
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 ¶
GetURL contacts the SWAN operator domain with the access key and returns a URL string that the web browser should be directed to.