2024-01-16 18:32:47 +00:00
|
|
|
package s5
|
|
|
|
|
2024-01-24 17:29:25 +00:00
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
|
|
|
|
"git.lumeweb.com/LumeWeb/libs5-go/types"
|
|
|
|
"git.lumeweb.com/LumeWeb/portal/db/models"
|
|
|
|
"github.com/vmihailenco/msgpack/v5"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ msgpack.CustomEncoder = (*AccountPinResponse)(nil)
|
|
|
|
)
|
|
|
|
|
2024-01-16 18:32:47 +00:00
|
|
|
type AccountRegisterRequest struct {
|
|
|
|
Pubkey string `json:"pubkey"`
|
|
|
|
Response string `json:"response"`
|
|
|
|
Signature string `json:"signature"`
|
2024-01-16 21:15:50 +00:00
|
|
|
Email string `json:"email,omitempty"`
|
2024-01-16 18:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SmallUploadResponse struct {
|
|
|
|
CID string `json:"cid"`
|
|
|
|
}
|
|
|
|
type AccountRegisterChallengeResponse struct {
|
|
|
|
Challenge string `json:"challenge"`
|
|
|
|
}
|
2024-01-16 18:51:03 +00:00
|
|
|
|
|
|
|
type AccountLoginRequest struct {
|
|
|
|
Pubkey string `json:"pubkey"`
|
|
|
|
Response string `json:"response"`
|
|
|
|
Signature string `json:"signature"`
|
|
|
|
}
|
|
|
|
type AccountLoginChallengeResponse struct {
|
|
|
|
Challenge string `json:"challenge"`
|
|
|
|
}
|
2024-01-17 16:52:54 +00:00
|
|
|
type AccountInfoResponse struct {
|
2024-01-17 17:38:52 +00:00
|
|
|
Email string `json:"email"`
|
|
|
|
QuotaExceeded bool `json:"quotaExceeded"`
|
|
|
|
EmailConfirmed bool `json:"emailConfirmed"`
|
|
|
|
IsRestricted bool `json:"isRestricted"`
|
|
|
|
Tier AccountTier `json:"tier"`
|
2024-01-17 16:52:54 +00:00
|
|
|
}
|
2024-01-17 17:03:08 +00:00
|
|
|
|
|
|
|
type AccountStatsResponse struct {
|
|
|
|
AccountInfoResponse
|
|
|
|
Stats AccountStats `json:"stats"`
|
|
|
|
}
|
|
|
|
|
2024-01-17 17:38:52 +00:00
|
|
|
type AccountTier struct {
|
|
|
|
Id uint64 `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
UploadBandwidth uint64 `json:"uploadBandwidth"`
|
|
|
|
StorageLimit uint64 `json:"storageLimit"`
|
|
|
|
Scopes []interface{} `json:"scopes"`
|
|
|
|
}
|
|
|
|
|
2024-01-17 17:03:08 +00:00
|
|
|
type AccountStats struct {
|
|
|
|
Total AccountStatsTotal `json:"total"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AccountStatsTotal struct {
|
|
|
|
UsedStorage uint64 `json:"usedStorage"`
|
|
|
|
}
|
2024-01-17 19:46:37 +00:00
|
|
|
type AppUploadResponse struct {
|
|
|
|
CID string `json:"cid"`
|
|
|
|
}
|
2024-01-17 21:05:11 +00:00
|
|
|
type RegistryQueryResponse struct {
|
|
|
|
Pk string `json:"pk"`
|
|
|
|
Revision uint64 `json:"revision"`
|
|
|
|
Data string `json:"data"`
|
|
|
|
Signature string `json:"signature"`
|
|
|
|
}
|
2024-01-17 21:20:51 +00:00
|
|
|
|
|
|
|
type RegistrySetRequest struct {
|
|
|
|
Pk string `json:"pk"`
|
|
|
|
Revision uint64 `json:"revision"`
|
|
|
|
Data string `json:"data"`
|
|
|
|
Signature string `json:"signature"`
|
|
|
|
}
|
2024-01-18 02:59:27 +00:00
|
|
|
|
|
|
|
type DebugStorageLocation struct {
|
|
|
|
Type int `json:"type"`
|
|
|
|
Parts []string `json:"parts"`
|
|
|
|
Expiry int64 `json:"expiry"`
|
|
|
|
NodeId string `json:"nodeId"`
|
|
|
|
Score float64 `json:"score"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DebugStorageLocationsResponse struct {
|
|
|
|
Locations []DebugStorageLocation `json:"locations"`
|
|
|
|
}
|
2024-01-24 17:29:25 +00:00
|
|
|
|
|
|
|
type AccountPinResponse struct {
|
|
|
|
Pins []models.Pin
|
|
|
|
Cursor uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a AccountPinResponse) EncodeMsgpack(enc *msgpack.Encoder) error {
|
|
|
|
err := enc.EncodeInt(0)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = enc.EncodeInt(int64(a.Cursor))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pinsList := make([][]byte, len(a.Pins))
|
|
|
|
|
|
|
|
for i, pin := range a.Pins {
|
|
|
|
hash, err := hex.DecodeString(pin.Upload.Hash)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pinsList[i] = encoding.MultihashFromBytes(hash, types.HashTypeBlake3).FullBytes()
|
|
|
|
}
|
|
|
|
|
|
|
|
err = enc.Encode(pinsList)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|