The official Self SDK for Go.
This SDK provides access to the following self services:
- Authentication: For authenticating users
- Identity: For looking up identities, apps, devices, public keys
- Fact: For requesting information from identities or intemediaries
- Messaging: For building services to interact with other entities
- Go 1.13 or later
- Self OMEMO
End-to-end encryption protocol. Refer to the Installing a released version for installation instructions on different OSS.
go get github.com/joinself/self-go-sdk
Before the SDK can be used you must first register an application on the Self Developer Portal. Once registered, the portal will generate credentials for the application that the SDK will use to authenticate against the Self network.
Self provides two isolated networks:
Developer Portal (production network) - Suitable for production services
Developer Portal (sandbox network) - Suitable for testing and experimentation
Register your application using one of the links above (further information).
import "github.com/joinself/self-go-sdk"
func main() {
cfg := selfsdk.Config{
SelfAppID: "<application-id>",
SelfAppDeviceSecret: "<application-secret-key>",
StorageDir: "/data",
StorageKey: "random-secret-string",
Environment: "sandbox", // optional (defaults to production)
}
client, err := selfsdk.New(cfg)
client.Start()
}
The identities service provides functionality for looking up identities, devices and public keys.
To query an identity:
import "github.com/joinself/self-go-sdk"
func main() {
svc := client.IdentityService()
identity, err := svc.GetIdentity("<self-id>")
...
}
The fact service can be used to ask for specific attested facts from an identity. These requests can be sent to the identity directly, or via an intermediary if you would prefer not to see the users personal information directly, but would like to know it satisfies a given criteria.
For detailed examples of fact requests:
To directly ask an identity for facts:
import (
"github.com/joinself/self-go-sdk"
"github.com/joinself/self-go-sdk/fact"
)
func main() {
svc := client.FactService()
req := fact.FactRequest{
...
}
resp, err := svc.Request(&req)
...
}
The authentication service can be used to send an authentication challenge to a users device. The response the user sends will be signed by their identity and can be validated. You can authenticate a client by two means; If you know the self id of the user you wish to authenticate, you can do it directly. Alternatively, if you do not know the identity of the user, you can generate and display a qr code that can be read by the users device.
For detailed examples of authentication requests:
To authenticate a user directly:
import (
"github.com/joinself/self-go-sdk"
)
func main() {
svc := client.AuthenticationService()
err = svc.Request("<self-id>")
...
}
Looking for help? Reach out to us at support@joinself.com
See Contributing.
See License.