protocol

package
v0.0.0-...-0d745bf Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package protocol contains the shared wire types and cryptographic helpers used by both the BitBoxSync client and server implementations.

Index

Constants

View Source
const (
	IdentityKindKeystore = "keystore"

	NamespaceKindDefault = "default"
	NamespaceKindShared  = "shared"

	SpamControlKindNone        = "none"
	SpamControlKindAttestation = "attestation"

	ChallengePurposeLogin           = "login"
	ChallengePurposeRefresh         = "refresh"
	ChallengePurposeSensitiveAction = "sensitive-action"

	SensitiveActionRevokeAllTokens       = "revoke-all-tokens"
	SensitiveActionCreateNamespaceInvite = "create-namespace-invite"
	NamespaceJoinRequestStatusPending    = "pending"
	NamespaceJoinRequestVersion          = 1
	MaxActiveInvitesPerNamespace         = 5
	MaxPendingJoinRequestsPerInvite      = 20
	MaxAcceptedJoinRequestsPerInvite     = 10
	MaxPendingJoinRequestsPerRequester   = 20
	MaxInviteTTL                         = time.Hour
	DefaultInviteTTL                     = 10 * time.Minute
	MaxJoinRequestTTL                    = 10 * time.Minute

	KeyIDLength                   = 32
	NamespaceIDLength             = 16
	InviteIDLength                = 16
	InviteSecretLength            = 32
	InviteServerSecretLength      = 32
	InviteServerSecretHashLength  = 32
	InviteProofLength             = 32
	JoinRequestHashLength         = 32
	ServerOriginHashLength        = 32
	MaxServerOriginLength         = 128
	ItemIDLength                  = 32
	NamespaceDEKLen               = 32
	ItemNonceLength               = chacha20poly1305.NonceSizeX
	MaxItemCiphertextSize         = 64 * 1024
	MaxItemsPerNamespace          = 10000
	MaxNamespacesPerKey           = 32
	MaxMembersPerNamespace        = 32
	MaxActiveTokensPerKey         = 32
	MaxKeysPerDevice              = 100
	MaxNamespacesCreatedPerDevice = 100
	MaxNamespaceStoredBytes       = 64 * 1024 * 1024
	WrappedDEKLenV1               = 1 + 32 + NamespaceIDLength + NamespaceDEKLen + 16
)

Variables

View Source
var (
	ErrInvalidKind        = errors.New("invalid kind")
	ErrInvalidNamespaceID = errors.New("invalid namespace id")
	ErrInvalidKeyID       = errors.New("invalid key id")
	ErrInvalidItemID      = errors.New("invalid item id")
	ErrAADMismatch        = errors.New("aad mismatch")
	ErrNamespaceMismatch  = errors.New("namespace mismatch")
	ErrInvalidWrappedDEK  = errors.New("invalid wrapped dek")
	ErrKeyIDMismatch      = errors.New("key id does not match auth public key")
	ErrUnsupportedVersion = errors.New("unsupported version")
)

Functions

func BuildItemAAD

func BuildItemAAD(namespaceIDHex, itemIDHex string, version uint64) ([]byte, error)

BuildItemAAD constructs the canonical AAD for an item using hex-encoded IDs.

func BuildItemAADFromBytes

func BuildItemAADFromBytes(namespaceID, itemID []byte, version uint64) []byte

BuildItemAADFromBytes constructs the canonical AAD for an item using binary IDs.

func CanonicalServerOrigin

func CanonicalServerOrigin(value string) (string, error)

CanonicalServerOrigin validates and canonicalizes a BitBoxSync server origin.

func CreateNamespaceInviteActionFields

func CreateNamespaceInviteActionFields(namespaceID, inviteID, inviteServerSecretHash []byte, expiresAt uint64, maxAccepted uint32) ([]byte, error)

CreateNamespaceInviteActionFields builds the canonical sensitive-action action fields for namespace invite creation.

func DecodeBase64

func DecodeBase64(name, value string) ([]byte, error)

DecodeBase64 decodes a base64 string.

func DecodeBase64Exact

func DecodeBase64Exact(name, value string, size int) ([]byte, error)

DecodeBase64Exact decodes a base64 string and checks that it has the expected length.

func DecodeBase64URLExact

func DecodeBase64URLExact(name, value string, size int) ([]byte, error)

DecodeBase64URLExact decodes an unpadded base64url string and checks that it has the expected length.

func DecodeHexExact

func DecodeHexExact(name, value string, size int) ([]byte, error)

DecodeHexExact decodes a hex string and checks that it has the expected length.

func DecodeLowerHexExact

func DecodeLowerHexExact(name, value string, size int) ([]byte, error)

DecodeLowerHexExact decodes a lowercase hex string and checks that it has the expected length.

func DecryptItem

func DecryptItem(namespaceDEK, nonce, aad, ciphertext []byte) ([]byte, error)

DecryptItem decrypts one encrypted item payload.

func DeriveInviteProofKey

func DeriveInviteProofKey(inviteSecret []byte) ([]byte, error)

DeriveInviteProofKey derives the requester-to-approver proof key from the raw QR invite secret. This key must not be sent to the server.

func DeriveInviteServerSecret

func DeriveInviteServerSecret(inviteSecret []byte) ([]byte, error)

DeriveInviteServerSecret derives the server admission credential from the raw QR invite secret.

func EncodeBase64

func EncodeBase64(value []byte) string

EncodeBase64 encodes bytes with standard base64.

func EncodeBase64URL

func EncodeBase64URL(value []byte) string

EncodeBase64URL encodes bytes with unpadded base64url.

func EncodeEd25519PublicKey

func EncodeEd25519PublicKey(authPublicKey ed25519.PublicKey) string

EncodeEd25519PublicKey returns the hex encoding used on the wire for an Ed25519 public key.

func EncodeNamespaceInviteToken

func EncodeNamespaceInviteToken(token NamespaceInviteToken) (string, error)

EncodeNamespaceInviteToken encodes invite material into the canonical QR URI.

func EncodeX25519PublicKey

func EncodeX25519PublicKey(wrapPublicKey *ecdh.PublicKey) string

EncodeX25519PublicKey returns the hex encoding used on the wire for an X25519 public key.

func EncryptItem

func EncryptItem(namespaceIDHex, itemIDHex string, version uint64, namespaceDEK, plaintext []byte) (nonce, aad, ciphertext []byte, err error)

EncryptItem encrypts one item payload and returns the nonce, AAD, and ciphertext to send to the server.

func InviteProof

func InviteProof(inviteSecret, joinRequestPayload []byte) ([]byte, error)

InviteProof computes the end-to-end proof that a join requester knew the raw QR invite secret.

func ItemID

func ItemID(namespaceDEK []byte, logicalKey string) (string, error)

ItemID derives the opaque item ID for a logical key within a namespace.

func JoinRequestHash

func JoinRequestHash(joinRequestPayload []byte) []byte

JoinRequestHash returns the stable identifier for one canonical join request payload.

func JoinRequestPayload

func JoinRequestPayload(kind string, namespaceID, inviteID, serverOriginHash, keyID []byte, authPublicKey ed25519.PublicKey, wrapPublicKey *ecdh.PublicKey, expiresAt uint64) ([]byte, error)

JoinRequestPayload builds the canonical byte payload signed by a prospective namespace member.

func KeyIDFromAuthPublicKey

func KeyIDFromAuthPublicKey(authPublicKey ed25519.PublicKey) [KeyIDLength]byte

KeyIDFromAuthPublicKey derives the canonical key ID from an auth public key.

func LoginIntent

func LoginIntent(challenge []byte, kind string, keyID []byte, authPublicKey ed25519.PublicKey, wrapPublicKey *ecdh.PublicKey) ([]byte, error)

LoginIntent builds the canonical byte payload that must be signed for login.

func NamespaceBlobKey

func NamespaceBlobKey(namespaceDEK []byte) ([]byte, error)

NamespaceBlobKey derives the AEAD key used to encrypt item payloads for a namespace.

func NamespaceMapKey

func NamespaceMapKey(namespaceDEK []byte) ([]byte, error)

NamespaceMapKey derives the HMAC key used to map logical keys to opaque item IDs.

func ParseEd25519PublicKeyHex

func ParseEd25519PublicKeyHex(name, value string) (ed25519.PublicKey, error)

ParseEd25519PublicKeyHex decodes a lowercase-hex Ed25519 public key into the standard library key type.

func ParseIfMatch

func ParseIfMatch(value string) (uint64, bool, error)

ParseIfMatch parses an HTTP If-Match version header.

func ParseX25519PublicKeyHex

func ParseX25519PublicKeyHex(name, value string) (*ecdh.PublicKey, error)

ParseX25519PublicKeyHex decodes a lowercase-hex X25519 public key into the standard library key type.

func QuoteETag

func QuoteETag(version uint64) string

QuoteETag formats an item version as a quoted ETag header value.

func RandomInviteID

func RandomInviteID() ([]byte, error)

RandomInviteID returns a freshly generated public invite ID.

func RandomInviteSecret

func RandomInviteSecret() ([]byte, error)

RandomInviteSecret returns a freshly generated QR invite secret.

func RandomNamespaceDEK

func RandomNamespaceDEK() ([]byte, error)

RandomNamespaceDEK returns a freshly generated namespace DEK.

func RandomNamespaceID

func RandomNamespaceID() ([]byte, error)

RandomNamespaceID returns a freshly generated random namespace ID.

func RefreshIntent

func RefreshIntent(challenge []byte, kind string, keyID []byte) ([]byte, error)

RefreshIntent builds the canonical byte payload that must be signed for token refresh.

func SensitiveActionIntent

func SensitiveActionIntent(challenge []byte, action, kind string, keyID, actionFields []byte) ([]byte, error)

SensitiveActionIntent builds the canonical byte payload that must be signed for a fresh sensitive action authorization.

func ServerOriginHash

func ServerOriginHash(origin string) ([]byte, error)

ServerOriginHash returns the canonical join-request hash for a server origin.

func UnwrapNamespaceDEK

func UnwrapNamespaceDEK(recipientWrapPrivateKey, expectedNamespaceID, wrappedDEK []byte) ([]byte, error)

UnwrapNamespaceDEK unwraps a wrapped namespace DEK and verifies its namespace binding.

func ValidateInviteID

func ValidateInviteID(value string) error

ValidateInviteID checks that value is a valid lowercase-hex invite ID.

func ValidateItemID

func ValidateItemID(value string) error

ValidateItemID checks that value is a valid lowercase-hex item ID.

func ValidateJoinRequestHash

func ValidateJoinRequestHash(value string) error

ValidateJoinRequestHash checks that value is a valid lowercase-hex join request hash.

func ValidateKeyID

func ValidateKeyID(value string) error

ValidateKeyID checks that value is a valid lowercase-hex key ID.

func ValidateNamespaceID

func ValidateNamespaceID(value string) error

ValidateNamespaceID checks that value is a valid lowercase-hex namespace ID.

func ValidateWrappedDEK

func ValidateWrappedDEK(wrappedDEK []byte) error

ValidateWrappedDEK checks that a wrapped DEK uses a supported version and has the exact raw length required by that version.

func VerifyAAD

func VerifyAAD(namespaceIDHex, itemIDHex string, version uint64, aad []byte) error

VerifyAAD checks that aad matches the canonical AAD for the supplied item coordinates.

func VerifyInviteProof

func VerifyInviteProof(inviteSecret, joinRequestPayload, inviteProof []byte) error

VerifyInviteProof verifies the HMAC proof against the raw QR invite secret.

func VerifyKeyIDMatchesAuthPublicKey

func VerifyKeyIDMatchesAuthPublicKey(keyIDHex string, authPublicKey ed25519.PublicKey) error

VerifyKeyIDMatchesAuthPublicKey checks that the supplied key ID matches the hash of the auth public key.

func WrapNamespaceDEK

func WrapNamespaceDEK(recipientWrapPublicKey *ecdh.PublicKey, namespaceID, namespaceDEK []byte) ([]byte, error)

WrapNamespaceDEK HPKE-wraps a namespace DEK for one recipient and binds it to the namespace ID.

func WrappedDEKLengthForVersion

func WrappedDEKLengthForVersion(version byte) (int, error)

WrappedDEKLengthForVersion returns the exact raw wrapped-DEK length expected for one wrapped-DEK wire-format version byte.

Types

type ApproveNamespaceJoinRequestRequest

type ApproveNamespaceJoinRequestRequest struct {
	InviteServerSecret string `json:"inviteServerSecret"`
	WrappedDEK         string `json:"wrappedDek"`
}

ApproveNamespaceJoinRequestRequest approves a pending join request.

type ApproveNamespaceJoinRequestResponse

type ApproveNamespaceJoinRequestResponse struct {
	NamespaceID     string `json:"namespaceId"`
	MemberKind      string `json:"memberKind"`
	MemberKeyID     string `json:"memberKeyId"`
	JoinRequestHash string `json:"joinRequestHash"`
}

ApproveNamespaceJoinRequestResponse reports the membership created by approval.

type ChallengeRequest

type ChallengeRequest struct {
	// Purpose selects the auth flow the challenge is for, such as login or
	// refresh.
	Purpose string `json:"purpose"`
	// Kind identifies the auth-key kind requesting the challenge.
	Kind string `json:"kind"`
	// Action optionally binds a sensitive-action challenge to one action name.
	Action string `json:"action,omitempty"`
	// ActionFieldsHash is the optional lowercase-hex SHA-256 hash of the
	// canonical sensitive-action fields.
	ActionFieldsHash string `json:"actionFieldsHash,omitempty"`
}

ChallengeRequest asks the server to mint a challenge for one auth purpose.

type ChallengeResponse

type ChallengeResponse struct {
	// Challenge is the base64-encoded random challenge payload to sign.
	Challenge string `json:"challenge"`
	// ExpiresAt is when the challenge becomes invalid server-side.
	ExpiresAt time.Time `json:"expiresAt"`
	// SpamControl tells the client what additional proof to attach.
	SpamControl SpamControl `json:"spamControl"`
}

ChallengeResponse returns a fresh challenge and its spam-control policy.

type CreateNamespaceInviteRequest

type CreateNamespaceInviteRequest struct {
	Kind                   string `json:"kind"`
	KeyID                  string `json:"keyId"`
	InviteID               string `json:"inviteId"`
	InviteServerSecretHash string `json:"inviteServerSecretHash"`
	Challenge              string `json:"challenge"`
	IntentSignature        string `json:"intentSignature"`
	ExpiresAt              int64  `json:"expiresAt"`
	MaxAccepted            int    `json:"maxAccepted"`
}

CreateNamespaceInviteRequest creates a short-lived invite for one shared namespace.

type CreateNamespaceInviteResponse

type CreateNamespaceInviteResponse struct {
	NamespaceID string `json:"namespaceId"`
	InviteID    string `json:"inviteId"`
	ExpiresAt   int64  `json:"expiresAt"`
	MaxAccepted int    `json:"maxAccepted"`
}

CreateNamespaceInviteResponse reports the stored invite metadata.

type CreateSharedNamespaceRequest

type CreateSharedNamespaceRequest struct {
	// NamespaceID is the caller-chosen hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// WrappedDEK is the base64-encoded namespace DEK wrapped for the caller.
	WrappedDEK string `json:"wrappedDek"`
}

CreateSharedNamespaceRequest creates a new shared namespace with the caller's wrapped DEK.

type CreateSharedNamespaceResponse

type CreateSharedNamespaceResponse struct {
	// NamespaceID is the hex-encoded identifier of the created namespace.
	NamespaceID string `json:"namespaceId"`
	// Kind is the namespace kind and is expected to be "shared".
	Kind string `json:"kind"`
	// Created reports whether the namespace was created by this call.
	Created bool `json:"created"`
}

CreateSharedNamespaceResponse returns metadata for a newly created shared namespace.

type DefaultNamespaceResponse

type DefaultNamespaceResponse struct {
	// NamespaceID is the hex-encoded identifier of the default namespace.
	NamespaceID string `json:"namespaceId"`
	// Kind is the namespace kind and is expected to be "default".
	Kind string `json:"kind"`
}

DefaultNamespaceResponse returns the authenticated identity's default namespace metadata.

type EnsureDefaultNamespaceRequest

type EnsureDefaultNamespaceRequest struct {
	// ProposedNamespaceID is the caller-chosen namespace ID to create if the
	// default namespace does not already exist.
	ProposedNamespaceID string `json:"proposedNamespaceId"`
	// WrappedDEK is the base64-encoded namespace DEK wrapped for the caller.
	WrappedDEK string `json:"wrappedDek"`
}

EnsureDefaultNamespaceRequest proposes and wraps a default namespace for the authenticated identity.

type EnsureDefaultNamespaceResponse

type EnsureDefaultNamespaceResponse struct {
	// NamespaceID is the hex-encoded identifier of the default namespace.
	NamespaceID string `json:"namespaceId"`
	// Kind is the namespace kind and is expected to be "default".
	Kind string `json:"kind"`
	// WrappedDEK is the base64-encoded namespace DEK wrapped for the caller.
	WrappedDEK string `json:"wrappedDek"`
	// Created reports whether the namespace was created by this call.
	Created bool `json:"created"`
}

EnsureDefaultNamespaceResponse returns the final default namespace assignment.

type GetItemResponse

type GetItemResponse struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// ItemID is the hex-encoded item identifier.
	ItemID string `json:"itemId"`
	// Version is the current stored version of the item.
	Version uint64 `json:"version"`
	// Nonce is the base64-encoded AEAD nonce used for Ciphertext.
	Nonce string `json:"nonce"`
	// AAD is the base64-encoded associated data bound to NamespaceID, ItemID, and
	// Version.
	AAD string `json:"aad"`
	// Ciphertext is the base64-encoded encrypted item payload.
	Ciphertext string `json:"ciphertext"`
}

GetItemResponse returns one encrypted item and its current version.

type GetNamespaceItemsResponse

type GetNamespaceItemsResponse struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// NamespaceHead is the current namespace change counter.
	NamespaceHead uint64 `json:"namespaceHead"`
	// Items maps each hex-encoded item ID to its current version metadata.
	Items map[string]NamespaceItemVersion `json:"items"`
}

GetNamespaceItemsResponse returns the authoritative item/version snapshot for a namespace.

type GetNamespaceMembersResponse

type GetNamespaceMembersResponse struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// Members lists all current namespace members.
	Members []NamespaceMember `json:"members"`
}

GetNamespaceMembersResponse returns the membership list for a namespace.

type GetWrappedDEKResponse

type GetWrappedDEKResponse struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// KeyID is the hex-encoded member key identifier.
	KeyID string `json:"keyId"`
	// WrappedDEK is the base64-encoded namespace DEK wrapped for KeyID.
	WrappedDEK string `json:"wrappedDek"`
}

GetWrappedDEKResponse returns the wrapped namespace DEK for one member.

type HealthResponse

type HealthResponse struct {
	// Status is the process health string. The server returns "ok" when ready.
	Status string `json:"status"`
}

HealthResponse reports basic process health.

type ListNamespaceInvitesResponse

type ListNamespaceInvitesResponse struct {
	NamespaceID string                   `json:"namespaceId"`
	Invites     []NamespaceInviteSummary `json:"invites"`
}

ListNamespaceInvitesResponse returns invite-management rows for a namespace.

type ListNamespaceJoinRequestsResponse

type ListNamespaceJoinRequestsResponse struct {
	NamespaceID string                      `json:"namespaceId"`
	Requests    []NamespaceJoinRequestEntry `json:"requests"`
}

ListNamespaceJoinRequestsResponse lists pending namespace join requests.

type ListNamespacesResponse

type ListNamespacesResponse struct {
	// Namespaces contains one summary per namespace visible to the caller.
	Namespaces []NamespaceSummary `json:"namespaces"`
}

ListNamespacesResponse returns all namespaces visible to an identity.

type LoginRequest

type LoginRequest struct {
	// Kind identifies the auth-key kind being used to log in.
	Kind string `json:"kind"`
	// KeyID is the hex-encoded key identifier derived from AuthPublicKey.
	KeyID string `json:"keyId"`
	// AuthPublicKey is the hex-encoded Ed25519 public key for auth intents.
	AuthPublicKey string `json:"authPublicKey"`
	// WrapPublicKey is the hex-encoded X25519 public key for namespace DEK
	// wrapping.
	WrapPublicKey string `json:"wrapPublicKey"`
	// Challenge is the base64-encoded challenge received from Challenge.
	Challenge string `json:"challenge"`
	// IntentSignature is the hex-encoded signature over the canonical login
	// intent.
	IntentSignature string `json:"intentSignature"`
	// Attestation is an optional base64-encoded anti-abuse proof required when
	// spam control is set to attestation.
	Attestation string `json:"attestation,omitempty"`
}

LoginRequest carries the signed login payload for a device identity.

type LoginResponse

type LoginResponse struct {
	// Kind echoes the authenticated auth-key kind.
	Kind string `json:"kind"`
	// AccessToken is the opaque bearer token to use for authenticated API calls.
	AccessToken string `json:"accessToken"`
	// ExpiresAt is when AccessToken expires server-side.
	ExpiresAt time.Time `json:"expiresAt"`
	// DefaultNamespaceID, when non-nil, names the caller's default namespace.
	DefaultNamespaceID *string `json:"defaultNamespaceId"`
}

LoginResponse returns the bearer token and default-namespace hint after successful login.

type NamespaceInviteSummary

type NamespaceInviteSummary struct {
	InviteID           string     `json:"inviteId"`
	CreatedByKeyID     string     `json:"createdByKeyId"`
	CreatedAt          time.Time  `json:"createdAt"`
	ExpiresAt          int64      `json:"expiresAt"`
	MaxAccepted        int        `json:"maxAccepted"`
	ActiveRequestCount int        `json:"activeRequestCount"`
	AcceptedCount      int        `json:"acceptedCount"`
	RevokedAt          *time.Time `json:"revokedAt"`
}

NamespaceInviteSummary describes one namespace invite visible to members.

type NamespaceInviteToken

type NamespaceInviteToken struct {
	Version      int
	ServerOrigin string
	NamespaceID  string
	InviteID     string
	ExpiresAt    int64
	InviteSecret string
}

NamespaceInviteToken is the app-visible invite material encoded into a QR code or copyable URI. InviteSecret must never be sent to the server directly.

func ParseNamespaceInviteToken

func ParseNamespaceInviteToken(value string) (NamespaceInviteToken, error)

ParseNamespaceInviteToken parses and validates the canonical QR invite URI.

type NamespaceItemVersion

type NamespaceItemVersion struct {
	// Version is the current monotonically increasing version of the item.
	Version uint64 `json:"version"`
}

NamespaceItemVersion describes the current version metadata for one item in a namespace snapshot.

type NamespaceJoinRequest

type NamespaceJoinRequest struct {
	Version       int    `json:"version"`
	NamespaceID   string `json:"namespaceId"`
	InviteID      string `json:"inviteId"`
	ServerOrigin  string `json:"serverOrigin"`
	Kind          string `json:"kind"`
	KeyID         string `json:"keyId"`
	AuthPublicKey string `json:"authPublicKey"`
	WrapPublicKey string `json:"wrapPublicKey"`
	ExpiresAt     int64  `json:"expiresAt"`
	Signature     string `json:"signature"`
	InviteProof   string `json:"inviteProof"`
}

NamespaceJoinRequest is the signed request material submitted by a prospective member and later verified by an approver.

type NamespaceJoinRequestEntry

type NamespaceJoinRequestEntry struct {
	InviteID        string               `json:"inviteId"`
	JoinRequestHash string               `json:"joinRequestHash"`
	CreatedAt       time.Time            `json:"createdAt"`
	Status          string               `json:"status"`
	JoinRequest     NamespaceJoinRequest `json:"joinRequest"`
}

NamespaceJoinRequestEntry is one pending request visible to namespace members.

type NamespaceMember

type NamespaceMember struct {
	// Kind is the member's auth-key kind.
	Kind string `json:"kind"`
	// KeyID is the member's hex-encoded key identifier.
	KeyID string `json:"keyId"`
}

NamespaceMember identifies one namespace member.

type NamespaceSummary

type NamespaceSummary struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// Kind is the namespace kind, such as "default" or "shared".
	Kind string `json:"kind"`
	// NamespaceHead is the current namespace change counter.
	NamespaceHead uint64 `json:"namespaceHead"`
}

NamespaceSummary describes one namespace visible to an identity.

type PutItemRequest

type PutItemRequest struct {
	// Nonce is the base64-encoded AEAD nonce used for Ciphertext.
	Nonce string `json:"nonce"`
	// AAD is the base64-encoded associated data bound to the target version.
	AAD string `json:"aad"`
	// Ciphertext is the base64-encoded encrypted item payload.
	Ciphertext string `json:"ciphertext"`
}

PutItemRequest carries one encrypted item write.

type PutItemResponse

type PutItemResponse struct {
	// NamespaceID is the hex-encoded namespace identifier.
	NamespaceID string `json:"namespaceId"`
	// ItemID is the hex-encoded item identifier.
	ItemID string `json:"itemId"`
	// Version is the version stored by the server after the write.
	Version uint64 `json:"version"`
}

PutItemResponse reports the stored version of one encrypted item write.

type RefreshRequest

type RefreshRequest struct {
	// Kind identifies the auth-key kind being refreshed.
	Kind string `json:"kind"`
	// KeyID is the hex-encoded key identifier derived from the auth public key.
	KeyID string `json:"keyId"`
	// Challenge is the base64-encoded challenge received from Challenge.
	Challenge string `json:"challenge"`
	// IntentSignature is the hex-encoded signature over the canonical refresh
	// intent.
	IntentSignature string `json:"intentSignature"`
	// Attestation is an optional base64-encoded anti-abuse proof required when
	// spam control is set to attestation.
	Attestation string `json:"attestation,omitempty"`
}

RefreshRequest carries the signed refresh payload for a device identity.

type RefreshResponse

type RefreshResponse struct {
	// Kind echoes the authenticated auth-key kind.
	Kind string `json:"kind"`
	// AccessToken is the new opaque bearer token.
	AccessToken string `json:"accessToken"`
	// ExpiresAt is when AccessToken expires server-side.
	ExpiresAt time.Time `json:"expiresAt"`
}

RefreshResponse returns a replacement bearer token after refresh.

type RejectNamespaceJoinRequestResponse

type RejectNamespaceJoinRequestResponse struct {
	NamespaceID     string `json:"namespaceId"`
	RequesterKeyID  string `json:"requesterKeyId"`
	JoinRequestHash string `json:"joinRequestHash"`
	Rejected        bool   `json:"rejected"`
}

RejectNamespaceJoinRequestResponse reports request rejection.

type RevokeAllTokensRequest

type RevokeAllTokensRequest struct {
	// Kind identifies the auth-key kind authorizing token revocation.
	Kind string `json:"kind"`
	// KeyID is the hex-encoded key identifier of the authenticated identity.
	KeyID string `json:"keyId"`
	// Challenge is the base64-encoded sensitive-action challenge.
	Challenge string `json:"challenge"`
	// IntentSignature is the hex-encoded signature over the canonical sensitive
	// action intent for revoke-all-tokens.
	IntentSignature string `json:"intentSignature"`
}

RevokeAllTokensRequest carries the signed sensitive-action payload required to revoke every bearer token for the current identity.

type RevokeNamespaceInviteResponse

type RevokeNamespaceInviteResponse struct {
	NamespaceID string `json:"namespaceId"`
	InviteID    string `json:"inviteId"`
	Revoked     bool   `json:"revoked"`
}

RevokeNamespaceInviteResponse reports invite revocation.

type SpamControl

type SpamControl struct {
	// Kind names the anti-abuse mode, such as "none" or "attestation".
	Kind string `json:"kind"`
}

SpamControl describes the anti-abuse proof the client must provide.

type SubmitNamespaceJoinRequestRequest

type SubmitNamespaceJoinRequestRequest struct {
	InviteServerSecret string               `json:"inviteServerSecret"`
	JoinRequest        NamespaceJoinRequest `json:"joinRequest"`
}

SubmitNamespaceJoinRequestRequest submits one signed join request through an invite.

type SubmitNamespaceJoinRequestResponse

type SubmitNamespaceJoinRequestResponse struct {
	NamespaceID     string `json:"namespaceId"`
	InviteID        string `json:"inviteId"`
	RequesterKind   string `json:"requesterKind"`
	RequesterKeyID  string `json:"requesterKeyId"`
	JoinRequestHash string `json:"joinRequestHash"`
	Status          string `json:"status"`
}

SubmitNamespaceJoinRequestResponse reports the stored pending join request.

type VersionResponse

type VersionResponse struct {
	// GitCommit is the git commit hash the server binary was built from.
	GitCommit string `json:"gitCommit"`
}

VersionResponse reports build metadata for deployment verification.

type WatchNamespacesRequest

type WatchNamespacesRequest struct {
	// KnownHeads maps namespace IDs to the latest namespaceHead value the
	// client has already reconciled. Visible namespaces missing from this map are
	// treated as changed and are returned immediately.
	KnownHeads map[string]uint64 `json:"knownHeads"`
}

WatchNamespacesRequest asks the server to wait until one of the caller's visible namespaces differs from the supplied namespace-head checkpoint.

type WatchNamespacesResponse

type WatchNamespacesResponse struct {
	// Namespaces contains visible namespaces whose namespaceHead differs from
	// the request's knownHeads map, including newly visible namespaces.
	Namespaces []NamespaceSummary `json:"namespaces"`
	// TimedOut reports that the long poll reached the server-side timeout
	// without observing a relevant change.
	TimedOut bool `json:"timedOut"`
}

WatchNamespacesResponse returns namespaces whose current head differs from the request checkpoint, or an empty list when the server-side wait timed out.

Jump to

Keyboard shortcuts

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