Documentation
¶
Overview ¶
Package space provides pure value types and cryptographic primitives for atproto Spaces.
Index ¶
- Constants
- Variables
- func CIDForCBOR(data []byte) (cid.Cid, error)
- func CommitMAC(ikm, ctx, hash []byte) []byte
- func ComputeCommitMAC(ikm, ctx, hash []byte) ([]byte, error)
- func CreateClientAttestation(opts CreateSpaceTokenOptions, signer Signer) (string, error)
- func CreateCredential(opts CreateSpaceTokenOptions, signer Signer) (string, error)
- func CreateDPoPProof(signer DPoPSigner, opts CreateDpopProofOptions) (string, error)
- func CreateDelegationToken(opts CreateSpaceTokenOptions, signer Signer) (string, error)
- func CreateDpopProof(signer DPoPSigner, opts CreateDpopProofOptions) (string, error)
- func CreateSpaceCredential(opts CreateSpaceTokenOptions, signer Signer) (string, error)
- func CreateSpaceToken(kind TokenType, opts CreateSpaceTokenOptions, signer Signer) (string, error)
- func DPoPJKTForKey(key *ecdsa.PublicKey) (string, error)
- func DpopJKTForKey(key *ecdsa.PublicKey) (string, error)
- func EncodeCommitContext(ctx CommitContext, ikm []byte) ([]byte, error)
- func EncodeCommitCtx(ctx CommitContext, ikm []byte) ([]byte, error)
- func EncodeRepoIndex(index RepoIndex) ([]byte, error)
- func EncodeSignedCommit(c SignedCommit) ([]byte, error)
- func ExpandElement(element string) []byte
- func FormatElement(collection, rkey, cid string) string
- func FormatSetHashElement(collection, rkey, cid string) string
- func NormalizeDpopHTU(raw string) (string, error)
- func NormalizeHTU(raw string) (string, error)
- func SerializeRepo(commit SignedCommit, records []SerializedRecord, opts ...SerializeRepoOptions) ([]byte, error)
- func SerializeRepoCAR(commit SignedCommit, records []SerializedRecord, opts ...SerializeRepoOptions) ([]byte, error)
- func VerifyCommit(commit SignedCommit, ctx CommitContext, didKey string) bool
- func VerifyCommitError(commit SignedCommit, ctx CommitContext, didKey string) error
- func VerifyCommitWithPublicKey(commit SignedCommit, ctx CommitContext, verifier CommitVerifier) bool
- func VerifyCommitWithVerifier(commit SignedCommit, ctx CommitContext, verifier CommitVerifier) bool
- func WriteRepoCAR(w io.Writer, commit SignedCommit, records []SerializedRecord, ...) error
- type AtprotoSigner
- type AtprotoVerifier
- type BatchReplayStore
- type CAROptions
- type CommitContext
- type CommitCtx
- type CommitSignOptions
- type CommitSigner
- type CommitVerifier
- type CreateDpopProofOptions
- type CreateSpaceTokenOptions
- type DPoPSigner
- type DpopProof
- type ECDSASigner
- type ECDSAVerifier
- type GORMReplayStore
- type KeyResolutionRequest
- type KeyResolver
- type LtHash
- type MemoryReplayStore
- type RecordRef
- type RecordURI
- type ReplayArtifact
- type ReplayStore
- type RepoCommit
- func (r *RepoCommit) Add(collection, rkey string, recordCID interface{ ... }) *RepoCommit
- func (r *RepoCommit) Hash() []byte
- func (r *RepoCommit) Matches(commit SignedCommit) bool
- func (r *RepoCommit) Remove(collection, rkey string, recordCID interface{ ... }) *RepoCommit
- func (r *RepoCommit) Sign(ctx CommitContext, signer CommitSigner, opts ...SignOptions) (SignedCommit, error)
- type RepoIndex
- type SerializeRepoOptions
- type SerializedRecord
- type SignOptions
- type SignedCommit
- type Signer
- type SignerFunc
- type SigningKeyResolver
- type SigningKeyResolverFunc
- type SpaceAuthError
- type SpaceRef
- type SpaceToken
- func ParseSpaceToken(kind TokenType, raw string) (SpaceToken, error)
- func VerifyClientAttestation(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
- func VerifyCredential(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
- func VerifyDelegationToken(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
- func VerifySpaceCredential(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
- func VerifySpaceToken(ctx context.Context, kind TokenType, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
- type SpaceTokenClaims
- type SpaceTokenConfirmation
- type SpaceTokenHeader
- type SpaceTokenType
- type SpaceURI
- type TokenType
- type VerifiedRecord
- type VerifiedRepo
- func ParseRepoCAR(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
- func VerifyRepoCAR(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
- func VerifyRepoCARFull(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
- func VerifyRepoCar(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
- type Verifier
- type VerifierFunc
- type VerifyDpopProofOptions
- type VerifyRepoParams
- type VerifySpaceTokenOptions
Constants ¶
const ( DelegationTokenType = "atproto-space-delegation+jwt" ClientAttestationTokenType = "atproto-client-attestation+jwt" CredentialTokenType = "atproto-space-credential+jwt" SpaceHostAudienceSuffix = "#atproto_space_host" DelegationSigningKeyID = "#atproto" SpaceSigningKeyID = "#atproto_space" FallbackSigningKeyID = "#atproto" ClockSkew = 5 * time.Second DelegationLifetime = 60 * time.Second ClientAttestationLifetime = 60 * time.Second CredentialLifetime = 2 * time.Hour )
const ( // AlphaReferenceCommit is the immutable atproto reference snapshot targeted // by this experimental implementation. AlphaReferenceCommit = "89deb9faca20e56fa2a262fe9746ed52bc1095ba" // AlphaCompatibilityVersion changes whenever the pinned wire contract or // local persistence representation changes incompatibly. AlphaCompatibilityVersion = 1 )
const ( DPOPProofType = "dpop+jwt" DPOPPProofType = DPOPProofType // compatibility spelling for callers DPOP_PROOF_TYP = DPOPProofType MaxDpopProofAge = 60 * time.Second MAX_PROOF_AGE_SEC = 60 )
const ( // LtHashLanes is the number of uint16 lanes in an LtHash state. LtHashLanes = 1024 // LtHashStateBytes is the serialized state size. LtHashStateBytes = LtHashLanes * 2 // LTHASH_STATE_BYTES is retained as a name matching the reference package. LTHASH_STATE_BYTES = LtHashStateBytes // StateBytes is a concise alias for LtHashStateBytes. StateBytes = LtHashStateBytes )
const ( // CommitVersion is the signedCommit format version. CommitVersion uint64 = 1 // COMMIT_VERSION is retained as a reference-compatible spelling. COMMIT_VERSION = CommitVersion CommitHashBytes = sha256.Size CommitIKMBytes = sha256.Size CommitMACBytes = sha256.Size // MaxCommitContextFieldBytes is the largest value representable by a u16 // context length prefix. MaxCommitContextFieldBytes = int(^uint16(0)) // @atproto/crypto and Indigo use compact secp256k1 r||s signatures. MaxCommitSignatureBytes = 64 )
Variables ¶
var ( ErrReplay = errors.New("replay detected") ErrNilReplayStore = errors.New("nil replay store") )
Functions ¶
func CIDForCBOR ¶
CIDForCBOR computes the CID used for commit, index, and canonical DAG-CBOR record blocks.
func ComputeCommitMAC ¶
ComputeCommitMAC follows the pinned @atproto/crypto helper exactly: hkdfSha256(ikm, ctx) is HKDF-Expand-only with ikm directly as the SHA-256 PRK and ctx as info, followed by HMAC-SHA256(key, hash). It intentionally does not use x/crypto/hkdf, which performs an Extract step first.
func CreateClientAttestation ¶
func CreateClientAttestation(opts CreateSpaceTokenOptions, signer Signer) (string, error)
func CreateCredential ¶
func CreateCredential(opts CreateSpaceTokenOptions, signer Signer) (string, error)
func CreateDPoPProof ¶
func CreateDPoPProof(signer DPoPSigner, opts CreateDpopProofOptions) (string, error)
func CreateDelegationToken ¶
func CreateDelegationToken(opts CreateSpaceTokenOptions, signer Signer) (string, error)
func CreateDpopProof ¶
func CreateDpopProof(signer DPoPSigner, opts CreateDpopProofOptions) (string, error)
CreateDpopProof creates an RFC 9449 proof. The issuance form omits ath; set CredentialPresent (or Credential) when proving possession for a credential request.
func CreateSpaceCredential ¶
func CreateSpaceCredential(opts CreateSpaceTokenOptions, signer Signer) (string, error)
func CreateSpaceToken ¶
func CreateSpaceToken(kind TokenType, opts CreateSpaceTokenOptions, signer Signer) (string, error)
func EncodeCommitContext ¶
func EncodeCommitContext(ctx CommitContext, ikm []byte) ([]byte, error)
EncodeCommitContext implements the pinned context encoding:
"atproto-space-v1" || u16be(len(space)) || space || u16be(len(author)) || author || u16be(len(rev)) || rev || u16be(len(ikm)) || ikm
Lengths are UTF-8 byte lengths.
func EncodeCommitCtx ¶
func EncodeCommitCtx(ctx CommitContext, ikm []byte) ([]byte, error)
func EncodeRepoIndex ¶
EncodeRepoIndex returns canonical DAG-CBOR bytes for an index. The CBOR encoder emits CID values as IPLD link tag 42 and sorts text keys by the canonical shortest-then-bytewise order.
func EncodeSignedCommit ¶
func EncodeSignedCommit(c SignedCommit) ([]byte, error)
EncodeSignedCommit returns canonical DAG-CBOR bytes for c.
func ExpandElement ¶
ExpandElement expands an element to the exact 2048-byte BLAKE3 XOF output used as the lane vector by LtHash. The returned bytes are independent of any internal hash state.
func FormatElement ¶
FormatElement formats a record identity for inclusion in an LtHash: {collection}/{rkey}/{cid}.
func FormatSetHashElement ¶
FormatSetHashElement is an alias matching the reference helper's name.
func NormalizeDpopHTU ¶
NormalizeDpopHTU implements the common WHATWG URL serialization needed by RFC 9449 htu: absolute HTTP(S), lower-case scheme/host, default ports removed, literal dot segments resolved, and query/fragment removed. Raw percent-encoded path octets are preserved and are never treated as dots.
func NormalizeHTU ¶
func SerializeRepo ¶
func SerializeRepo(commit SignedCommit, records []SerializedRecord, opts ...SerializeRepoOptions) ([]byte, error)
SerializeRepo emits a CAR whose roots are [signedCommit, index], followed by commit/index blocks and then one value block per index entry in canonical path order. Duplicate paths follow the reference provider's last-write-wins behavior. ExcludeValues emits only the two roots' blocks.
func SerializeRepoCAR ¶
func SerializeRepoCAR(commit SignedCommit, records []SerializedRecord, opts ...SerializeRepoOptions) ([]byte, error)
func VerifyCommit ¶
func VerifyCommit(commit SignedCommit, ctx CommitContext, didKey string) bool
VerifyCommit verifies version/revision, MAC, and an atproto DID-key signature. It returns false for malformed or unauthenticated commits.
func VerifyCommitError ¶
func VerifyCommitError(commit SignedCommit, ctx CommitContext, didKey string) error
VerifyCommitError is an error-returning companion for trust boundaries.
func VerifyCommitWithPublicKey ¶
func VerifyCommitWithPublicKey(commit SignedCommit, ctx CommitContext, verifier CommitVerifier) bool
func VerifyCommitWithVerifier ¶
func VerifyCommitWithVerifier(commit SignedCommit, ctx CommitContext, verifier CommitVerifier) bool
func WriteRepoCAR ¶
func WriteRepoCAR(w io.Writer, commit SignedCommit, records []SerializedRecord, opts ...SerializeRepoOptions) error
WriteRepoCAR is the streaming form of SerializeRepo.
Types ¶
type AtprotoSigner ¶
type AtprotoSigner struct {
// contains filtered or unexported fields
}
AtprotoSigner adapts the account ES256K implementation used by Cocoon.
func NewAtprotoSigner ¶
func NewAtprotoSigner(key *atcrypto.PrivateKeyK256) (*AtprotoSigner, error)
func (*AtprotoSigner) Algorithm ¶
func (s *AtprotoSigner) Algorithm() string
type AtprotoVerifier ¶
type AtprotoVerifier struct {
// contains filtered or unexported fields
}
func NewAtprotoVerifier ¶
func NewAtprotoVerifier(key atcrypto.PublicKey) (*AtprotoVerifier, error)
func (*AtprotoVerifier) Algorithm ¶
func (v *AtprotoVerifier) Algorithm() string
func (*AtprotoVerifier) Verify ¶
func (v *AtprotoVerifier) Verify(input, sig []byte) error
type BatchReplayStore ¶
type BatchReplayStore interface {
ReplayStore
ConsumeBatch(ctx context.Context, artifacts []ReplayArtifact) error
}
BatchReplayStore extends ReplayStore with all-or-nothing batch consumption. Production exchange paths must require this interface rather than falling back to sequential Consume calls.
type CAROptions ¶
type CAROptions = SerializeRepoOptions
type CommitContext ¶
CommitContext is the data bound into a signed commit. Author is the author's DID and Space is the canonical space URI.
type CommitCtx ¶
type CommitCtx = CommitContext
CommitCtx is the short spelling used by the pinned TypeScript reference.
type CommitSignOptions ¶
type CommitSignOptions = SignOptions
type CommitSigner ¶
CommitSigner and CommitVerifier are small adapters satisfied by Indigo's atcrypto.PrivateKey and atcrypto.PublicKey. They also allow callers to adapt a persistence model without importing that model into this package.
type CommitVerifier ¶
type CreateDpopProofOptions ¶
type CreateSpaceTokenOptions ¶
type DPoPSigner ¶
DPoPSigner must expose its bare public P-256 JWK. Embedded key material is part of the proof header and is verified before any claim is trusted.
type DpopProof ¶
func VerifyDPoPProof ¶
func VerifyDpopProof ¶
func VerifyDpopProof(ctx context.Context, raw string, opts VerifyDpopProofOptions) (DpopProof, error)
VerifyDpopProof checks signature, method, normalized URL, age, embedded-key thumbprint, and ath. Replay is consumed atomically after every other check.
type ECDSASigner ¶
type ECDSASigner struct {
// contains filtered or unexported fields
}
func NewECDSASigner ¶
func NewECDSASigner(key *ecdsa.PrivateKey, alg string, random io.Reader) (*ECDSASigner, error)
func (*ECDSASigner) Algorithm ¶
func (s *ECDSASigner) Algorithm() string
func (*ECDSASigner) PublicJWK ¶
func (s *ECDSASigner) PublicJWK() ([]byte, error)
func (*ECDSASigner) PublicKey ¶
func (s *ECDSASigner) PublicKey() *ecdsa.PublicKey
type ECDSAVerifier ¶
type ECDSAVerifier struct {
// contains filtered or unexported fields
}
func NewECDSAVerifier ¶
func NewECDSAVerifier(key *ecdsa.PublicKey, alg string) (*ECDSAVerifier, error)
func (*ECDSAVerifier) Algorithm ¶
func (v *ECDSAVerifier) Algorithm() string
func (*ECDSAVerifier) Verify ¶
func (v *ECDSAVerifier) Verify(input, sig []byte) error
type GORMReplayStore ¶
GORMReplayStore persists replay consumption in models.SpaceReplayJTI. The schema is included by models.SpaceModels; migrations remain the server's responsibility. A unique primary-key insert gives the required atomicity.
func NewGORMReplayStore ¶
func NewGORMReplayStore(db *gorm.DB) *GORMReplayStore
func (*GORMReplayStore) ConsumeBatch ¶
func (s *GORMReplayStore) ConsumeBatch(ctx context.Context, artifacts []ReplayArtifact) error
ConsumeBatch inserts all replay rows in one database transaction. Any duplicate or other error rolls the transaction back, so no earlier artifact in the batch is burned.
func (*GORMReplayStore) DeleteExpired ¶
DeleteExpired removes at most limit replay rows whose deadline has passed. The strict comparison preserves a replay row at its exact deadline, matching MemoryReplayStore; it is removed on the first cleanup after that boundary.
type KeyResolutionRequest ¶
KeyResolutionRequest is the typed request passed to resolvers that can refresh a cached DID/JWKS lookup after a signature failure. ForceRefresh is false for the initial lookup and true only for the single retry.
type LtHash ¶
type LtHash struct {
// contains filtered or unexported fields
}
LtHash is a homomorphic set hash. Each element expands to 1024 little-endian uint16 lanes, which are summed into the state modulo 2^16. Consequently, addition and subtraction commute and the state depends only on the current set (assuming each set member is added at most once).
func LtHashFromState ¶
LtHashFromState is an alias for NewLtHashFromState.
func NewLtHash ¶
NewLtHash creates an empty hash, or copies one serialized state. A nil state is equivalent to an omitted state; a non-nil state must be exactly 2048 bytes. The variadic form permits both NewLtHash() and NewLtHash(state).
func NewLtHashFromState ¶
NewLtHashFromState is an explicit spelling for constructing from serialized state.
func (*LtHash) Add ¶
Add incorporates element into the state and returns h for convenient chaining. Lane arithmetic wraps modulo 2^16.
type MemoryReplayStore ¶
type MemoryReplayStore struct {
// contains filtered or unexported fields
}
MemoryReplayStore is concurrency-safe and useful for tests or explicitly ephemeral deployments. It is not durable across process restarts.
func NewMemoryReplayStore ¶
func NewMemoryReplayStore() *MemoryReplayStore
func NewMemoryReplayStoreWithClock ¶
func NewMemoryReplayStoreWithClock(now func() time.Time) *MemoryReplayStore
NewMemoryReplayStoreWithClock makes expiry deterministic in tests.
func (*MemoryReplayStore) ConsumeBatch ¶
func (s *MemoryReplayStore) ConsumeBatch(_ context.Context, artifacts []ReplayArtifact) error
ConsumeBatch checks every artifact and inserts every fresh artifact while holding the same mutex. If validation or replay detection fails, the map is unchanged.
type RecordRef ¶
type RecordRef = RecordURI
func ParseRecordRef ¶
ParseRecordRef is an alias for ParseRecordURI.
type RecordURI ¶
type RecordURI struct {
AuthorityDID syntax.DID
SpaceType syntax.NSID
SKey syntax.RecordKey
AuthorDID syntax.DID
Collection syntax.NSID
RKey syntax.RecordKey
}
RecordURI identifies a record in a space.
Its canonical form is at://{authorityDid}/space/{spaceType}/{skey}/{authorDid}/{collection}/{rkey}.
func NewRecordURI ¶
func NewRecordURI(authorityDID, spaceType, skey, authorDID, collection, rkey string) (RecordURI, error)
NewRecordURI validates components and returns a canonical record URI value.
func ParseRecord ¶
ParseRecord is an alias for ParseRecordURI.
func ParseRecordURI ¶
ParseRecordURI parses exactly the canonical space record URI grammar.
func (RecordURI) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*RecordURI) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type ReplayArtifact ¶
ReplayArtifact is one validated, single-use token/proof replay entry. A batch must be committed all at once: no artifact may be persisted if any artifact in the batch is already consumed.
type ReplayStore ¶
type ReplayStore interface {
Consume(ctx context.Context, jti, tokenType string, expiresAt time.Time) error
}
ReplayStore consumes a globally unique JTI exactly once. Implementations must make the check-and-insert atomic; callers invoke it only after a token or proof has passed signature and semantic validation.
type RepoCommit ¶
type RepoCommit struct {
SetHash *LtHash
}
RepoCommit tracks the LtHash of a repo's collection/rkey/CID set.
func NewRepoCommit ¶
func NewRepoCommit() *RepoCommit
func RepoCommitFromIndex ¶
func RepoCommitFromIndex(index RepoIndex) (*RepoCommit, error)
RepoCommitFromIndex computes the LtHash represented by every index path/CID.
func RepoCommitFromRecords ¶
func RepoCommitFromRecords(records []SerializedRecord) (*RepoCommit, error)
RepoCommitFromRecords computes a set hash from serialized records.
func (*RepoCommit) Add ¶
func (r *RepoCommit) Add(collection, rkey string, recordCID interface{ String() string }) *RepoCommit
Add incorporates a record identity. The interface permits cid.Cid and other CID adapters without coupling the value helper to one concrete CID type.
func (*RepoCommit) Hash ¶
func (r *RepoCommit) Hash() []byte
func (*RepoCommit) Matches ¶
func (r *RepoCommit) Matches(commit SignedCommit) bool
Matches only compares the set hash; authenticate the commit first.
func (*RepoCommit) Remove ¶
func (r *RepoCommit) Remove(collection, rkey string, recordCID interface{ String() string }) *RepoCommit
func (*RepoCommit) Sign ¶
func (r *RepoCommit) Sign(ctx CommitContext, signer CommitSigner, opts ...SignOptions) (SignedCommit, error)
Sign signs only the encoded context, then MACs the current repo hash.
type RepoIndex ¶
RepoIndex maps collection/rkey paths to record CIDs.
func DecodeRepoIndex ¶
DecodeRepoIndex parses a canonical DAG-CBOR index.
type SerializeRepoOptions ¶
type SerializeRepoOptions struct {
ExcludeValues bool
}
SerializeRepoOptions controls CAR serialization.
type SerializedRecord ¶
type SerializedRecord struct {
Collection string
RKey string
// Rkey is accepted as a compatibility spelling; RKey takes precedence.
Rkey string
CID cid.Cid
Bytes []byte
}
SerializedRecord is one record block to be placed after the two CAR roots.
func NewSerializedRecord ¶
func NewSerializedRecord(collection, rkey string, record interface{}) (SerializedRecord, error)
NewSerializedRecord is an alias for SerializeRecord.
func SerializeRecord ¶
func SerializeRecord(collection, rkey string, record interface{}) (SerializedRecord, error)
SerializeRecord canonicalizes a Go value as DAG-CBOR and computes its CID.
func SerializeRecordBytes ¶
func SerializeRecordBytes(collection, rkey string, recordCID cid.Cid, data []byte) (SerializedRecord, error)
SerializeRecordBytes constructs a record from already canonical bytes. A supplied CID is checked against those bytes; an undefined CID is computed.
type SignOptions ¶
SignOptions makes signing deterministic in tests. IKM must be exactly 32 bytes when supplied. Otherwise Rand is read for a fresh IKM; nil uses crypto/rand.Reader.
type SignedCommit ¶
type SignedCommit struct {
Ver uint64 `json:"ver"`
Hash []byte `json:"hash"`
IKM []byte `json:"ikm"`
Sig []byte `json:"sig"`
MAC []byte `json:"mac"`
Rev string `json:"rev"`
}
SignedCommit is the signedCommit Lexicon object. It is serialized as a canonical DAG-CBOR map with keys ver/hash/ikm/sig/mac/rev.
func DecodeSignedCommit ¶
func DecodeSignedCommit(data []byte) (SignedCommit, error)
DecodeSignedCommit parses and validates canonical DAG-CBOR bytes. Re-encoding rejects non-canonical map encodings and unknown fields.
func SignCommit ¶
func SignCommit(hash []byte, ctx CommitContext, signer CommitSigner, opts ...SignOptions) (SignedCommit, error)
SignCommit signs a precomputed repo hash. RepoCommit.Sign is preferred when the caller has the record set available.
func (SignedCommit) MarshalJSON ¶
func (c SignedCommit) MarshalJSON() ([]byte, error)
MarshalJSON uses the atproto Lexicon bytes encoding. JSON bytes are {$bytes:<raw-base64url>}, not encoding/json's default base64 string.
func (*SignedCommit) UnmarshalJSON ¶
func (c *SignedCommit) UnmarshalJSON(data []byte) error
func (SignedCommit) Validate ¶
func (c SignedCommit) Validate() error
type Signer ¶
Signer and Verifier make account-key and DID/JWKS integrations independent from this package. ECDSA signatures are JOSE's fixed-width R || S format.
type SignerFunc ¶
func (SignerFunc) Algorithm ¶
func (s SignerFunc) Algorithm() string
type SigningKeyResolver ¶
type SigningKeyResolver interface {
ResolveSigningKey(context.Context, KeyResolutionRequest) (Verifier, error)
}
SigningKeyResolver is the refresh-capable resolver contract. A resolver must not silently fall back to an unrelated key when ForceRefresh is true.
type SigningKeyResolverFunc ¶
type SigningKeyResolverFunc func(context.Context, KeyResolutionRequest) (Verifier, error)
SigningKeyResolverFunc adapts a typed resolver function to the interface.
func (SigningKeyResolverFunc) ResolveSigningKey ¶
func (f SigningKeyResolverFunc) ResolveSigningKey(ctx context.Context, req KeyResolutionRequest) (Verifier, error)
type SpaceAuthError ¶
func (*SpaceAuthError) Error ¶
func (e *SpaceAuthError) Error() string
func (*SpaceAuthError) Unwrap ¶
func (e *SpaceAuthError) Unwrap() error
type SpaceRef ¶
type SpaceRef = SpaceURI
SpaceRef and RecordRef are descriptive aliases for the URI value types.
func ParseSpaceRef ¶
ParseSpaceRef is an alias for ParseSpaceURI.
type SpaceToken ¶
type SpaceToken struct {
Header SpaceTokenHeader
Claims SpaceTokenClaims
SigningInput []byte
Signature []byte
}
func ParseSpaceToken ¶
func ParseSpaceToken(kind TokenType, raw string) (SpaceToken, error)
ParseSpaceToken validates the complete JWT structure and all typed claims, but not its signature. It is intended solely to choose a separately resolved verification key before VerifySpaceToken performs mandatory verification.
func VerifyClientAttestation ¶
func VerifyClientAttestation(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
func VerifyCredential ¶
func VerifyCredential(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
func VerifyDelegationToken ¶
func VerifyDelegationToken(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
func VerifySpaceCredential ¶
func VerifySpaceCredential(ctx context.Context, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
func VerifySpaceToken ¶
func VerifySpaceToken(ctx context.Context, kind TokenType, raw string, opts VerifySpaceTokenOptions) (SpaceToken, error)
type SpaceTokenClaims ¶
type SpaceTokenConfirmation ¶
type SpaceTokenConfirmation struct {
JKT string `json:"jkt"`
}
type SpaceTokenHeader ¶
type SpaceTokenType ¶
type SpaceTokenType = TokenType
SpaceTokenType is the terminology used by the reference implementation.
type SpaceURI ¶
SpaceURI identifies a space hosted by an authority.
Its canonical form is at://{authorityDid}/space/{spaceType}/{skey}.
func NewSpaceURI ¶
NewSpaceURI validates components and returns a canonical space URI value.
func ParseSpace ¶
ParseSpace is an alias for ParseSpaceURI.
func ParseSpaceURI ¶
ParseSpaceURI parses exactly the canonical space URI grammar.
func (SpaceURI) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (SpaceURI) SpaceScopeComponents ¶
SpaceScopeComponents returns the authority, space type, and space key used by OAuth space-scope matching.
func (*SpaceURI) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type TokenType ¶
type TokenType string
const ( TokenDelegation TokenType = DelegationTokenType TokenClientAttestation TokenType = ClientAttestationTokenType TokenCredential TokenType = CredentialTokenType )
type VerifiedRecord ¶
VerifiedRecord is a value block proven to match its index path and CID.
type VerifiedRepo ¶
type VerifiedRepo struct {
Roots []cid.Cid
Commit SignedCommit
Index RepoIndex
Records []VerifiedRecord
Repo *RepoCommit
}
VerifiedRepo is the result of VerifyRepoCAR.
func ParseRepoCAR ¶
func ParseRepoCAR(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
ParseRepoCAR is a descriptive alias for VerifyRepoCAR.
func VerifyRepoCAR ¶
func VerifyRepoCAR(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
VerifyRepoCAR verifies roots, block CIDs, commit signature/MAC, index hash, and (when ExpectValues is true) every value block in index order.
func VerifyRepoCARFull ¶
func VerifyRepoCARFull(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
func VerifyRepoCar ¶
func VerifyRepoCar(data []byte, params VerifyRepoParams) (VerifiedRepo, error)
type VerifierFunc ¶
func (VerifierFunc) Algorithm ¶
func (v VerifierFunc) Algorithm() string
func (VerifierFunc) Verify ¶
func (v VerifierFunc) Verify(b, sig []byte) error
type VerifyDpopProofOptions ¶
type VerifyRepoParams ¶
VerifyRepoParams are the context values and public key needed to verify a repo CAR. ExpectValues may be bool, *bool, or nil: nil defaults to true, matching the reference verifier's optional expectValues parameter. A false value verifies an index-only CAR produced with ExcludeValues.
type VerifySpaceTokenOptions ¶
type VerifySpaceTokenOptions struct {
Resolver KeyResolver
KeyResolver KeyResolver
SigningKeyResolver SigningKeyResolver
Verifier Verifier
Audience string
Subject string
Issuer string
Now func() time.Time
ClockSkew time.Duration
Replay ReplayStore
Context context.Context
}