github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/protocol/introduce/models.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package introduce
     8  
     9  import "github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/decorator"
    10  
    11  // Proposal defines proposal request.
    12  type Proposal struct {
    13  	Type     string            `json:"@type,omitempty"`
    14  	ID       string            `json:"@id,omitempty"`
    15  	To       *To               `json:"to,omitempty"`
    16  	NWise    bool              `json:"nwise,omitempty"`
    17  	Thread   *decorator.Thread `json:"~thread,omitempty"`
    18  	Timing   *decorator.Timing `json:"~timing,omitempty"`
    19  	Goal     string            `json:"goal,omitempty"`
    20  	GoalCode string            `json:"goal_code,omitempty"`
    21  }
    22  
    23  // To introducee descriptor keeps information about the introduction
    24  // e.g introducer wants to introduce Bot to introducee { "name": "Bob" }.
    25  type To struct {
    26  	Name            string          `json:"name,omitempty"`
    27  	Description     string          `json:"description,omitempty"`
    28  	DescriptionL10N DescriptionL10N `json:"description~l10n,omitempty"`
    29  	Where           string          `json:"where,omitempty"`
    30  	ImgAttach       ImgAttach       `json:"img~attach,omitempty"`
    31  	Proposed        bool            `json:"proposed,omitempty"`
    32  }
    33  
    34  // DescriptionL10N may contain locale field and key->val pair for translation
    35  // e.g { "locale": "en", "es": "Donde se toma el MRI; no en el centro"},
    36  // where locale field tells that field Description form To struct has en translation.
    37  type DescriptionL10N map[string]string
    38  
    39  // Locale returns locale for the specified description (To.Description).
    40  func (d DescriptionL10N) Locale() string {
    41  	if d == nil {
    42  		return ""
    43  	}
    44  	// TODO: clarify whether it should be default locale e.g "en" or empty string
    45  	return d["locale"]
    46  }
    47  
    48  // ImgAttach represent information about the image.
    49  type ImgAttach struct {
    50  	Description string  `json:"description,omitempty"`
    51  	MimeType    string  `json:"mime-type,omitempty"`
    52  	Filename    string  `json:"filename,omitempty"`
    53  	Content     Content `json:"content,omitempty"`
    54  }
    55  
    56  // Content keeps image data.
    57  type Content struct {
    58  	Link      string `json:"link,omitempty"`
    59  	ByteCount int    `json:"byte_count,omitempty"`
    60  	Sha256    string `json:"sha256,omitempty"`
    61  }
    62  
    63  // PleaseIntroduceTo includes all field from To structure
    64  // also it has Discovered the field which should be provided by help-me-discover protocol.
    65  type PleaseIntroduceTo struct {
    66  	// nolint: staticcheck
    67  	To `json:",squash"`
    68  	// Discovered    Discovered `json:"discovered,omitempty"`
    69  }
    70  
    71  // Request is not part of any state machine, it can be sent at any time,
    72  // and when it is received, the recipient can choose whether or not to honor it in their own way
    73  // TODO: need to clarify about decorator ~please_ack and problem_report
    74  // 		 should Request contain those fields? What type it should be for each field?
    75  type Request struct {
    76  	Type              string             `json:"@type,omitempty"`
    77  	ID                string             `json:"@id,omitempty"`
    78  	PleaseIntroduceTo *PleaseIntroduceTo `json:"please_introduce_to,omitempty"`
    79  	NWise             bool               `json:"nwise,omitempty"`
    80  	Timing            *decorator.Timing  `json:"~timing,omitempty"`
    81  }
    82  
    83  // Response message that introducee usually sends in response to an introduction proposal.
    84  type Response struct {
    85  	Type        string                  `json:"@type,omitempty"`
    86  	ID          string                  `json:"@id,omitempty"`
    87  	Thread      *decorator.Thread       `json:"~thread,omitempty"`
    88  	Approve     bool                    `json:"approve,omitempty"`
    89  	OOBMessage  map[string]interface{}  `json:"oob-message,omitempty"`
    90  	Attachments []*decorator.Attachment `json:"~attach,omitempty"`
    91  }