forked from agntcy/dir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnaming.go
More file actions
45 lines (36 loc) · 1.15 KB
/
naming.go
File metadata and controls
45 lines (36 loc) · 1.15 KB
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
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0
package client
import (
"context"
"errors"
"fmt"
namingv1 "github.com/agntcy/dir/api/naming/v1"
)
// VerifyName performs name verification for a signed record.
// This should be called after signing to verify and store the name ownership proof.
func (c *Client) VerifyName(ctx context.Context, cid string) (*namingv1.VerifyResponse, error) {
if cid == "" {
return nil, errors.New("cid is required")
}
resp, err := c.NamingServiceClient.Verify(ctx, &namingv1.VerifyRequest{
Cid: cid,
})
if err != nil {
return nil, fmt.Errorf("failed to verify name: %w", err)
}
return resp, nil
}
// GetVerificationInfo retrieves the verification info for a record.
func (c *Client) GetVerificationInfo(ctx context.Context, cid string) (*namingv1.GetVerificationInfoResponse, error) {
if cid == "" {
return nil, errors.New("cid is required")
}
resp, err := c.NamingServiceClient.GetVerificationInfo(ctx, &namingv1.GetVerificationInfoRequest{
Cid: cid,
})
if err != nil {
return nil, fmt.Errorf("failed to get verification info: %w", err)
}
return resp, nil
}