1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package gateway
import (
"context"
"encoding/json"
)
type WebUser struct {
DID string
Handle string
PDS string
}
type WebCaller struct {
WebUser
Token string
}
type SignInStart struct {
AuthorizationURL string
State string
}
type SignInCompleteParams struct {
State string
Code string
ISS string
}
type SignInGrant struct {
WebUser
Token string
LeaseSeconds int64
}
type SignOutResult struct {
Revoked bool
RevokeError string
}
type RecordRef struct {
URI string
CID string
}
type Record struct {
URI string
CID string
Value map[string]any
}
type Write struct {
Action string
Collection string
Rkey string
Record map[string]any
}
type WebAccountAgent interface {
GetServiceAuth(ctx context.Context, aud, lxm string) (string, error)
ListRecords(ctx context.Context, did, collection string, limit int) ([]Record, error)
CreateRecord(ctx context.Context, did, collection, rkey string, record map[string]any) (RecordRef, error)
ApplyWrites(ctx context.Context, did string, writes []Write) error
}
type WebSignIn interface {
ClientMetadata(ctx context.Context) (json.RawMessage, error)
Start(ctx context.Context, identifier, redirectURI string) (SignInStart, error)
Complete(ctx context.Context, params SignInCompleteParams) (SignInGrant, error)
Identify(ctx context.Context, token string) (*WebUser, error)
SignOut(ctx context.Context, caller *WebCaller) (SignOutResult, error)
AgentFor(caller *WebCaller) WebAccountAgent
}