remote

package
v0.6.1005 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package remote is the client of a registry's knowledge routes: wrap and unwrap a pack's data key, create a pack, upload and download its sealed tree, list and delete, for the account a session token or a personal access token with knowledge:read and knowledge:write speaks for. It implements store.Registry for the CLI and the desktop alike, and, through Shared, store.Shared for an organization's shared packs (the core's /orgs/{org}/knowledge/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is one registry, as one account.

func New

func New(regURL, token string, hc *http.Client) (*Client, error)

New is the client of the registry at regURL (no trailing slash) with token as its bearer credential. hc is the HTTP client every request goes through (nil: http.DefaultClient, which has no timeout; callers pass their own).

func (*Client) Create

func (c *Client) Create(ctx context.Context, name string, wk store.WrappedKey) (store.Remote, error)

Create implements store.Registry: POST /knowledge/packs.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, id string) error

Delete implements store.Registry: DELETE /knowledge/packs/{id}.

func (*Client) GetTree

func (c *Client) GetTree(ctx context.Context, id string) ([]byte, string, error)

GetTree implements store.Registry: GET /knowledge/packs/{id}/tree. The body is read no further than a sealed pack at the size cap can be, so a registry cannot make the client hold more than that.

func (*Client) List

func (c *Client) List(ctx context.Context) ([]store.Remote, error)

List implements store.Registry: GET /knowledge/packs.

func (*Client) PutTree

func (c *Client) PutTree(ctx context.Context, id string, sealed []byte) (store.Remote, error)

PutTree implements store.Registry: PUT /knowledge/packs/{id}/tree.

func (*Client) Shared

func (c *Client) Shared(org string) *OrgClient

Shared is the client of org's shared packs, by the organization's handle.

func (*Client) URL

func (c *Client) URL() string

URL implements store.Registry.

func (*Client) Unwrap

func (c *Client) Unwrap(ctx context.Context, wk store.WrappedKey) ([]byte, error)

Unwrap implements store.Registry: POST /knowledge/keys/unwrap.

func (*Client) Wrap

func (c *Client) Wrap(ctx context.Context, dataKey []byte) (store.WrappedKey, error)

Wrap implements store.Registry: POST /knowledge/keys/wrap.

type OrgClient

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

OrgClient is one organization's shared packs at a registry, as the account a Client speaks for: the registry answers it only while that account is an active member, and 404 to anyone else.

func (*OrgClient) Export

func (o *OrgClient) Export(ctx context.Context, id string) ([]byte, string, error)

Export implements store.Shared: GET /orgs/{org}/knowledge/packs/{id}/export, the tree the registry decrypts: an admin's, or a member's of a pack marked exportable (store.ErrNotExportable otherwise).

func (*OrgClient) GetTree

func (o *OrgClient) GetTree(ctx context.Context, id string) ([]byte, string, error)

GetTree implements store.Shared: GET /orgs/{org}/knowledge/packs/{id}/tree, read no further than a sealed pack at the size cap can be.

func (*OrgClient) List

func (o *OrgClient) List(ctx context.Context) ([]store.Remote, error)

List implements store.Shared: GET /orgs/{org}/knowledge/packs.

func (*OrgClient) Org

func (o *OrgClient) Org() string

Org implements store.Shared.

func (*OrgClient) URL

func (o *OrgClient) URL() string

URL implements store.Shared.

func (*OrgClient) Unwrap

func (o *OrgClient) Unwrap(ctx context.Context, wk store.WrappedKey) ([]byte, error)

Unwrap implements store.Shared: POST /orgs/{org}/knowledge/keys/unwrap, which the registry answers to an active member alone.

Jump to

Keyboard shortcuts

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