Categorygithub.com/SWAN-community/swift-go
modulepackage
0.1.6
Repository: https://github.com/swan-community/swift-go.git
Documentation: pkg.go.dev

# README

Shared Web InFormaTion

Shared Web InFormaTion (SWIFT) - Go

Shared Web InFormaTion (SWIFT) - an open source cryptographically secure web solution for sharing information across domains implemented in Go

Storage Implementation

See the [https://github.com/SWAN-community/swift/blob/main/storage.md](SWIFT storage explainer) in the SWIFT repo for how node details are stored.

Storage Setup

See the [https://github.com/SWAN-community/swan-demo-go/blob/main/README.md](SWAN Demo Go) repo for instructions on how to configure storage.

# Functions

AddHandlers to the http default mux for shared web state.
Create creates a storage operation URL from the parameters passed to the method for the node associated with the host.
DecodeResults turns a byte array into a results data structure.
HandlerCreate takes a Services pointer and returns a HTTP handler used by an Access Node to obtain the initial URL for a storage operation.
HandlerDecodeAsJSON returns the incoming request as JSON data.
HandlerDecrypt takes a Services pointer and returns a HTTP handler used to decrypt the result of a storage operation provided in the raw query parameter to the return URL.
HandlerEncrypt takes a Services pointer and returns a HTTP handler used to encrypt the result of a storage operation ready to be provided to the return URL.
HandlerNodes is a handler that returns a list of all the known nodes, each node is converted into a NodeView item which is then used to populate an HTML template.
HandlerNodesJSON is a handler that returns a list of all the alive nodes which is then used to serialize to JSON.
HandlerRegister takes a Services pointer and returns a HTTP handler used to register a domain as an Access Node or a Storage Node.
HandlerShare returns an encrypted json document which contains details for all known active nodes.
HandlerStore takes a Services pointer and returns a HTTP handler used to respond to a storage operation.
NewAWS creates a new instance of the AWS structure.
NewAzure creates a new client for accessing table storage with the credentials supplied.
NewBrowserRegexes creates a new implementation of sws.BrowserDetector configured with default regular expressions and messages.
NewConfig creates a new instance of configuration from the file provided.
NewFirebase creates a new instance of the Firebase structure.
NewLocalStore creates a new instance of Local and configures the path for the persistent JSON file.
NewServices a set of services to use with SWIFT.
NewStorageService creates a new instance of storageService and creates the initial instance of storageManager, a go routine is then started which will periodically refresh the storageManager reference with a new instance.
NewStore returns a work implementation of the Store interface for the configuration supplied.
SetHomeNodeHeaders adds the HTTP headers from the request that are relevant to the calculation of the home node to the values collection.
SetURL take the value of key s, validates the value is a URL, and the sets the value of key d to the validated value.
ValidateURL confirms that the parameter is a valid URL and then returns the URL ready for use with SWIFT if valid.

# Structs

AWS is a implementation of sws.Store for AWS DynamoDB.
Azure is a implementation of sws.Store for Microsoft's Azure table storage.
BrowserRegexes is a concrete implementation of the interface sws.BrowserDetector.
Configuration maps to the appsettings.json settings file.
Firebase is a implementation of owid.Store for GCP's Firebase.
HTML parameters that control the function and display of the user interface.
Local store implementation for SWIFT - data is stored in maps in memory and persisted on disk in JSON files.
NodeItem is the dynamodb table item representation of a node.
NodeView is a struct containing the node fields to display in the nodes swiftNodesTemplate.
NodeViews is a struct which contains an array of NodeView which is used to display a list of nodes using the swiftNodesTemplate.
Pair from a storage operation.
Register contains HTML template data used to register a node with the network.
Results from a storage operation.
SecretItem is the dynamodb table item representation of a secret.
Services references all the information needed for every method.
Volatile localstorage implementation.

# Interfaces

BrowserDetector is used to identify the browser and return an HTML snippet that can be used to provide a warning to the user about the browsers support for shared web state.
Store interface for persistent data shared across instances operated.