Documentation
¶
Overview ¶
Postman providers helper functionality for managing TRISA and TRP transfers and sorting them and storing them in the database. This package is intended to unify the functionality across the TRISA node, the TRP node, and the Web API/UI.
On every single travel rule transaction, no matter if it's TRISA or TRP, no matter if it's sent from the node or received into the node, whether or not it's a new transaction or an update to an old transaction the following things must happen:
1. The message(s) must be validated 2. The transfer packet must be associated with a transaction 3. The transaction status must be updated, and potentially other parts of the transaction 4. The counterparty must be identified 5. Error envelopes have to be handled correctly 6. The keys for the envelope must be loaded for decryption 7. Sealed envelopes need to be decrypted 8. HMAC signatures need to be checked 9. The outgoing envelope must be resealed with internal keys 10. The envelopes and all changes must be saved to the database 11. The audit log must be updated
Index ¶
- Variables
- func FindAccount(person any) (account string)
- func FindName(persons ...*ivms101.Person) (name string)
- func TransactionFromPayload(in *api.Payload) *models.Transaction
- type Direction
- type Incoming
- func (i *Incoming) Model() *models.SecureEnvelope
- func (i *Incoming) Open() (reject *trisa.Error, err error)
- func (i *Incoming) Proto() *trisa.SecureEnvelope
- func (i *Incoming) PublicKeySignature() string
- func (i *Incoming) StatusFromTransferState() string
- func (i *Incoming) TransferState() trisa.TransferState
- func (i *Incoming) UpdateTransaction() (err error)
- func (i *Incoming) WebhookRequest() *webhook.Request
- type Outgoing
- func (o *Outgoing) Model() *models.SecureEnvelope
- func (o *Outgoing) Proto() *api.SecureEnvelope
- func (o *Outgoing) PublicKeySignature() string
- func (o *Outgoing) Seal() (reject *api.Error, err error)
- func (o *Outgoing) StatusFromTransferState() string
- func (o *Outgoing) UpdateTransaction() (err error)
- type Packet
- func Receive(in *api.SecureEnvelope, log zerolog.Logger, peer peers.Peer) (packet *Packet, err error)
- func Send(payload *api.Payload, envelopeID uuid.UUID, transferState api.TransferState, ...) (packet *Packet, err error)
- func SendReject(reject *api.Error, envelopeID uuid.UUID, log zerolog.Logger) (packet *Packet, err error)
- func (p *Packet) EnvelopeID() string
- func (p *Packet) Error(reject *api.Error, opts ...envelope.Option) (err error)
- func (p *Packet) Receive(in *api.SecureEnvelope) (err error)
- func (p *Packet) RefreshTransaction() (err error)
- func (p *Packet) Reject(code api.Error_Code, message string, retry bool) error
- func (p *Packet) ResolveCounterparty() (err error)
- func (p *Packet) Send(payload *api.Payload, state api.TransferState) (err error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FindAccount ¶
func TransactionFromPayload ¶
func TransactionFromPayload(in *api.Payload) *models.Transaction
Types ¶
type Incoming ¶
type Incoming struct {
Envelope *envelope.Envelope
UnsealingKey keys.PrivateKey
// contains filtered or unexported fields
}
Incoming messages are received from the remote; they can be replies to transfers initiated by the local node or they can be incoming messages that require a reply from the local node (e.g. received by the TRISA or TRP servers).
Incoming messages imply that they are sealed for decryption by the local host.
func (*Incoming) Model ¶
func (i *Incoming) Model() *models.SecureEnvelope
Creates a secure envelope model to store in the database with all of the information that is in the envelope and in the packet. Note that the PeerInfo is expected to be on the packet; and if this is an incoming reply to an outgoing transaction, the outgoing model must already have been created and have an ID.
TODO: we need to store public key information about the key that was actually used to decrypt the model, so that we can decrypt the model in the future.
func (*Incoming) Proto ¶
func (i *Incoming) Proto() *trisa.SecureEnvelope
Returns the original protocol buffers that was wrapped by the incoming message.
func (*Incoming) PublicKeySignature ¶
Returns the public key signature from the original message.
func (*Incoming) StatusFromTransferState ¶
StatusFromTransferState determines what the status should be based on the incoming message transfer state. For example, if the incoming transfer state is accepted, then the Transfer can be marked as completed.
func (*Incoming) TransferState ¶ added in v0.24.0
func (i *Incoming) TransferState() trisa.TransferState
Returns the original transfer state on the envelope.
func (*Incoming) UpdateTransaction ¶
Updates the transaction info and status based on the incoming envelope.
func (*Incoming) WebhookRequest ¶ added in v0.24.0
Creates a webhook callback request from the incoming envelope. Note that the packet must have the counterparty set and that the envelope UUID has been validated.
type Outgoing ¶
type Outgoing struct {
Envelope *envelope.Envelope
StorageKey keys.PublicKey
SealingKey keys.PublicKey
// contains filtered or unexported fields
}
Outgoing messages are sent to the remote party, either replies to transfers coming into the TRISA or TRP server or original messages if the transfer is initiated by a user or the API.
Outgoing messages imply that they need to be resealed for decryption by the local host.
func (*Outgoing) Model ¶
func (o *Outgoing) Model() *models.SecureEnvelope
Creates a secure envelope model to store in the database with all of the information that is is in the envelope and in the packet. Note that the PeerInfo is expected to be on the packet; and if this is an outgoing reply to an incoming transaction, the incoming model must already have been created and have an ID.
This method will Reseal the envelope if it is not an error envelope, encrypting it for local storage and requiring the StorageKey in order to reseal.
func (*Outgoing) Proto ¶
func (o *Outgoing) Proto() *api.SecureEnvelope
Returns the protocol buffers of the prepared envelope (seal first!)
func (*Outgoing) PublicKeySignature ¶
Returns the public key signature from the sealing key to send to the remote.
func (*Outgoing) Seal ¶
Seals the outgoing envelope in preparation for sending or returning to remote.
func (*Outgoing) StatusFromTransferState ¶
StatusFromTransferState determines what the status should be based on the outgoing message transfer state. For example, if the outgiong transfer state is pending, then the Transfer should be marked as needing review.
func (*Outgoing) UpdateTransaction ¶
Updates the transaction info and status based on the outgoing envelope.
type Packet ¶
type Packet struct {
DB models.PreparedTransaction // Database interaction methods
In *Incoming // The incoming message that needs to be decrypted
Out *Outgoing // The outgoing message that needs to be encrypted
Log zerolog.Logger // The log context for more effective logging
Counterparty *models.Counterparty // The remote identified counterparty
Transaction *models.Transaction // The associated transaction with the packet
Peer peers.Peer // The remote peer the transfer is being conducted with
PeerInfo *peers.Info // The peer info for finding the counterparty
User *models.User // The user that created the request, if any
APIKey *models.APIKey // The api key that created the request, if any
Request Direction // Determines if the initial message was incoming or outgoing
Reply Direction // Determines if the reply was incoming or outgoing
}
Packets contain both an incoming and an outgoing message and are used to ensure that an entire tranfer packet can be correctly constructed for both envelopes.
func SendReject ¶
func (*Packet) EnvelopeID ¶
Returns the envelopeID from the request envelope (e.g. the first envelope in the packet)
func (*Packet) Error ¶
Creates a TRISA error envelope from the TRISA error message and sets it as the outgoing message (e.g. in the case where an incoming message is being handled).
func (*Packet) Receive ¶
func (p *Packet) Receive(in *api.SecureEnvelope) (err error)
Receive updates the incoming message with the specified secure envelope, e.g. in the case where the outgoing message has been sent and this is the reply that was received from the remote server.
func (*Packet) RefreshTransaction ¶
func (*Packet) Reject ¶
Reject creates an outgoing message with a TRISA error that contains the specified TRISA rejection error, e.g. in the case where an incoming message is being handled.