(ctx context.Context, req *createGraphSaltRequest)
| 582 | } |
| 583 | |
| 584 | func (s *server) createGraphSalt(ctx context.Context, req *createGraphSaltRequest) (*createGraphSaltResponse, error) { |
| 585 | _, err := s.db.Graph(ctx, db.GraphID(req.GraphUUID)) |
| 586 | if db.IsNotExists(err) { |
| 587 | return nil, httperr.NotFound("graph %q wasn't found", req.GraphUUID) |
| 588 | } else if err != nil { |
| 589 | return nil, httperr.Internal("failed to load graph: %w", err) |
| 590 | } |
| 591 | |
| 592 | b := make([]byte, 64) |
| 593 | if n, err := s.r.Read(b); err != nil { |
| 594 | return nil, httperr.Internal("failed to generate random bytes: %w", err) |
| 595 | } else if n != 64 { |
| 596 | return nil, httperr.Internal("expected to read 64 random bytes, read %d", n) |
| 597 | } |
| 598 | |
| 599 | // Experimentally, these seem to expire about two months into the future? |
| 600 | exp := s.now().AddDate(0, 2, 0) |
| 601 | return &createGraphSaltResponse{ |
| 602 | Value: base64.StdEncoding.EncodeToString(b), |
| 603 | ExpiredAt: exp.UnixMilli(), |
| 604 | }, nil |
| 605 | } |
| 606 | |
| 607 | type getGraphSaltRequest struct { |
| 608 | GraphUUID string `json:"GraphUUID"` |
nothing calls this directly
no test coverage detected