@derec-alliance/nodejs 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright (c) DeRec Alliance and its Contributors.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ syntax = "proto3";
7
+
8
+ package org.derecalliance.derec.protobuf;
9
+
10
+ /// Enumeration of supported transport protocols.
11
+ ///
12
+ /// Additional values MAY be introduced in future versions of the protocol.
13
+ enum Protocol {
14
+ /// HTTPS-based transport.
15
+ ///
16
+ /// Messages are delivered via HTTP(S) requests, typically using a
17
+ /// request/response pattern where the Owner acts as client and the
18
+ /// Helper acts as server.
19
+ ///
20
+ /// This is the default transport.
21
+ HTTPS = 0;
22
+
23
+ /// gRPC-based transport.
24
+ ///
25
+ /// Messages are delivered as unary `DeRecTransport.Send` calls carrying a
26
+ /// `DeRecMessage` directly. Delivery is push-only: the call returns
27
+ /// `google.protobuf.Empty`, and every response is a fresh `Send` to the
28
+ /// peer's own endpoint, so both parties must run a reachable server.
29
+ ///
30
+ /// URI forms:
31
+ ///
32
+ /// - `grpcs://host:port` — gRPC over TLS
33
+ /// - `grpc://host:port` — plaintext, development only
34
+ GRPC = 1;
35
+ }
36
+
37
+ /// TransportProtocol defines how a DeRec participant (Owner or Helper)
38
+ /// can be reached over the network.
39
+ ///
40
+ /// This message encapsulates the transport-layer endpoint and the protocol
41
+ /// required to deliver DeRec messages to that endpoint. It is typically
42
+ /// exchanged during pairing (via ContactMessage) so that both parties know
43
+ /// how to establish communication channels.
44
+ ///
45
+ /// A TransportProtocol does not itself provide security guarantees.
46
+ /// All DeRec protocol messages MUST still be signed and encrypted at the
47
+ /// application layer, regardless of the underlying transport.
48
+ ///
49
+ /// # Semantics
50
+ ///
51
+ /// - The `uri` identifies the remote endpoint (e.g., HTTPS URL, message queue).
52
+ /// - The `protocol` specifies how the URI should be interpreted and how
53
+ /// messages must be transmitted.
54
+ /// - The combination of (`protocol`, `uri`) MUST be sufficient for the sender
55
+ /// to deliver a DeRec message to the receiver.
56
+ ///
57
+ /// # Usage
58
+ ///
59
+ /// - Included in ContactMessage during pairing to advertise reachable endpoints.
60
+ /// - May be stored by peers as part of the communication channel state.
61
+ /// - Used by the sender to select the correct transport mechanism when
62
+ /// delivering protocol messages.
63
+ ///
64
+ /// # Extensibility
65
+ ///
66
+ /// The Protocol enum is expected to grow as new transport mechanisms are
67
+ /// supported (e.g., message queues, peer-to-peer transports). Implementations
68
+ /// MUST ignore unknown enum values unless explicitly required otherwise.
69
+ ///
70
+ /// # Reliability
71
+ ///
72
+ /// Transport protocols may be:
73
+ /// - request/response (e.g., HTTPS)
74
+ /// - store-and-forward (e.g., message queues)
75
+ ///
76
+ /// Implementations MUST handle retries and idempotency at the protocol layer,
77
+ /// independent of transport guarantees.
78
+ message TransportProtocol {
79
+ /// URI endpoint used to contact the peer.
80
+ ///
81
+ /// The format of this field depends on the selected `protocol`.
82
+ /// Examples:
83
+ ///
84
+ /// - HTTPS: "https://example.com/derec" or "http://example.com/derec"
85
+ /// - gRPC: "grpcs://example.com:443" or "grpc://example.com:50051"
86
+ /// - Future protocols MAY define other URI schemes.
87
+ ///
88
+ /// The URI MUST be sufficient to route messages to the intended recipient.
89
+ string uri = 1;
90
+
91
+ /// Transport protocol associated with the URI.
92
+ ///
93
+ /// This determines:
94
+ /// - how the `uri` should be interpreted
95
+ /// - how messages are serialized and delivered
96
+ /// - what communication pattern is expected (e.g., synchronous vs async)
97
+ ///
98
+ /// Implementations MUST support all mandatory protocol types defined here.
99
+ Protocol protocol = 2;
100
+ }
@@ -0,0 +1,140 @@
1
+ /*
2
+ * Copyright (c) DeRec Alliance and its Contributors.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ syntax = "proto3";
7
+
8
+ import "google/protobuf/timestamp.proto";
9
+ import "result.proto";
10
+ import "transportprotocol.proto";
11
+
12
+ package org.derecalliance.derec.protobuf;
13
+
14
+ // UnpairRequestMessage requests termination of the DeRec relationship
15
+ // between two parties (Owner and Helper).
16
+ //
17
+ // # Context
18
+ //
19
+ // This message is used when:
20
+ //
21
+ // - the Owner no longer wants a Helper to store shares
22
+ // - the Helper chooses to stop acting as a Helper
23
+ // - the relationship must be terminated due to policy, failure, or user action
24
+ //
25
+ // # Semantics
26
+ //
27
+ // Upon receiving this message, the recipient MUST:
28
+ //
29
+ // - stop acting as a Helper for the corresponding channel
30
+ // - cease all protocol interactions for that channel
31
+ //
32
+ // The recipient SHOULD:
33
+ //
34
+ // - delete all stored shares and related state for the Owner
35
+ //
36
+ // However, deletion MAY be subject to:
37
+ //
38
+ // - regulatory requirements
39
+ // - contractual obligations
40
+ // - service-specific retention policies
41
+ //
42
+ // # Effects on Protocol State
43
+ //
44
+ // After a successful unpair:
45
+ //
46
+ // - the channel is considered permanently closed
47
+ // - the Owner MUST NOT rely on this Helper for recovery
48
+ // - the Owner SHOULD reshare secrets with remaining Helpers if necessary
49
+ //
50
+ // # Idempotency
51
+ //
52
+ // This message is idempotent. Repeated unpair requests SHOULD result in
53
+ // the same final state.
54
+ message UnpairRequestMessage {
55
+
56
+ // Optional human-readable explanation for the unpairing.
57
+ //
58
+ // This field is intended for logging, debugging, or user display.
59
+ // It MUST NOT be relied upon for protocol behavior.
60
+ string memo = 1;
61
+
62
+ // Timestamp indicating when this message was created.
63
+ //
64
+ // This value is expressed in UTC and can be used for:
65
+ //
66
+ // - observability and logging
67
+ // - replay detection (in combination with sequence numbers)
68
+ // - timeout handling
69
+ google.protobuf.Timestamp timestamp = 2;
70
+
71
+ // Ephemeral transport endpoint at which the requester wants to receive
72
+ // the response to *this exchange*, overriding the channel's stored peer
73
+ // endpoint for this round-trip only.
74
+ //
75
+ // See `StoreShareRequestMessage.replyTo` for full semantics.
76
+ //
77
+ // Superseded by `replyToTransports`, which carries every endpoint rather
78
+ // than one. Kept, and still populated with the list's first entry, so
79
+ // implementations predating that field still receive a reply.
80
+ // **Scheduled for removal in v0.0.5.** Reading this field directly is now
81
+ // incorrect — resolve it against `replyToTransports`.
82
+ optional TransportProtocol replyTo = 3 [deprecated = true];
83
+
84
+ // Every ephemeral endpoint the requester wants this exchange's response
85
+ // delivered to, in its own preference order.
86
+ //
87
+ // See `StoreShareRequestMessage.replyToTransports` for full semantics,
88
+ // including why this is a new tag rather than a widened `replyTo`.
89
+ repeated TransportProtocol replyToTransports = 5;
90
+
91
+ // Identity of the replica-group member that initiated this unpair.
92
+ //
93
+ // A replica-originated unpair MUST carry it; an owner-originated one MUST
94
+ // NOT. Its presence is what tells the receiver which path the message
95
+ // belongs to, exactly as on `StoreShareRequestMessage`. Asserted on send
96
+ // and on receive; a violation is a protocol error.
97
+ //
98
+ // Removing a replica is not the same operation as unpairing a helper. A
99
+ // helper channel serves exactly one peer, so unpairing deletes it. Every
100
+ // member of a replica group shares one channel, so deleting it would sever
101
+ // the whole group — replica removal edits a member row instead, and this
102
+ // field says which row.
103
+ optional uint64 replicaId = 4;
104
+ }
105
+
106
+ // UnpairResponseMessage is the response to an UnpairRequestMessage.
107
+ //
108
+ // # Semantics
109
+ //
110
+ // This message indicates whether the recipient successfully processed
111
+ // the unpair request.
112
+ //
113
+ // On success:
114
+ //
115
+ // - the relationship is considered terminated
116
+ // - the recipient has ceased participation in the protocol for this channel
117
+ //
118
+ // On failure:
119
+ //
120
+ // - the relationship state is undefined and SHOULD be handled by the
121
+ // application (e.g., retry or escalate)
122
+ //
123
+ // # Idempotency
124
+ //
125
+ // Multiple identical unpair requests SHOULD produce consistent responses.
126
+ message UnpairResponseMessage {
127
+ // Result of processing the unpair request.
128
+ //
129
+ // Indicates whether the unpair operation was successfully completed.
130
+ DeRecResult result = 1;
131
+
132
+ // Timestamp indicating when this message was created.
133
+ //
134
+ // This value is expressed in UTC and can be used for:
135
+ //
136
+ // - observability and logging
137
+ // - replay detection (in combination with sequence numbers)
138
+ // - timeout handling
139
+ google.protobuf.Timestamp timestamp = 2;
140
+ }
@@ -0,0 +1,129 @@
1
+ /*
2
+ * Copyright (c) DeRec Alliance and its Contributors.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ syntax = "proto3";
7
+
8
+ import "google/protobuf/timestamp.proto";
9
+ import "communicationinfo.proto";
10
+ import "result.proto";
11
+ import "transportprotocol.proto";
12
+
13
+ package org.derecalliance.derec.protobuf;
14
+
15
+ // UpdateChannelInfoRequestMessage notifies the peer that the sender's
16
+ // communication metadata and/or transport endpoint have changed.
17
+ //
18
+ // # Context
19
+ //
20
+ // Both `communication_info` and `transport_protocol` are exchanged at pairing
21
+ // time only. This message lets either party (Owner or Helper) propagate
22
+ // post-pairing changes without re-pairing.
23
+ //
24
+ // # Semantics
25
+ //
26
+ // Both fields are optional and independent:
27
+ //
28
+ // - `communication_info` absent (no `CommunicationInfo` set) means "do not
29
+ // modify the communication info stored for the sender." Presence — even
30
+ // with an empty `communication_info_entries` list — means "replace the
31
+ // stored map with the supplied one." Updates, additions, and deletions
32
+ // are all expressed by the difference between the receiver's current map
33
+ // and the supplied one.
34
+ // - `transport_protocol` absent means "do not modify the transport endpoint
35
+ // stored for the sender." Presence means "the sender's transport endpoint
36
+ // is now this value." The receiver MUST route subsequent messages on this
37
+ // channel to the new endpoint, including the
38
+ // UpdateChannelInfoResponseMessage for this request.
39
+ //
40
+ // # Endpoint changeover
41
+ //
42
+ // When `transport_protocol` is updated, the receiver sends its response to
43
+ // the new endpoint. The sender's application is therefore responsible for
44
+ // ensuring the new endpoint is reachable BEFORE this request is issued, and
45
+ // for keeping the old endpoint operational long enough for in-flight
46
+ // messages from other peers (and any concurrent operations) to drain.
47
+ message UpdateChannelInfoRequestMessage {
48
+
49
+ // Updated communication info for the sender, or absent to leave unchanged.
50
+ //
51
+ // Presence (even with an empty entries list) replaces the receiver's
52
+ // stored map for this channel. Absence leaves it untouched.
53
+ optional CommunicationInfo communicationInfo = 1;
54
+
55
+ // Updated transport endpoint for the sender, or absent to leave unchanged.
56
+ //
57
+ // Presence updates both the URI and protocol enum. The receiver routes
58
+ // the response to this new endpoint.
59
+ //
60
+ // Deprecated: superseded by `supportedTransports`, which carries every
61
+ // endpoint rather than one.
62
+ //
63
+ // **Reading this field directly is now incorrect.** Its meaning narrowed
64
+ // from "the endpoint" to "one entry of a list, and possibly absent": a
65
+ // sender that has moved past this field announces only
66
+ // `supportedTransports`. A reader that was correct before this release is
67
+ // a bug now — it records the wrong address, or none, for a peer that
68
+ // announced a perfectly good one. Resolve both spellings instead of
69
+ // reading either: `advertised_endpoints()` (Rust and TypeScript),
70
+ // `AdvertisedEndpoints()` (Go), `AdvertisedEndpoints()` (.NET).
71
+ //
72
+ // Senders still populate it: a sender that sets `supportedTransports`
73
+ // MUST also set this to a single best-compatibility choice, so
74
+ // implementations predating the list still learn the new address.
75
+ //
76
+ // **Scheduled for removal in v0.0.5.**
77
+ optional TransportProtocol transportProtocol = 2 [deprecated = true];
78
+
79
+ // Every transport endpoint the sender can now be reached on, in its own
80
+ // preference order, replacing the receiver's stored set for this channel.
81
+ //
82
+ // # Semantics
83
+ //
84
+ // - Empty, and `transportProtocol` absent: the sender's endpoints are
85
+ // left unchanged. An update that changes only `communicationInfo` says
86
+ // nothing about transports.
87
+ // - Non-empty: replaces the stored set outright. Unlike a request's
88
+ // `replyTo`, this **is** persisted — it is how a peer announces it has
89
+ // moved.
90
+ //
91
+ // # Compatibility
92
+ //
93
+ // Empty with `transportProtocol` present means "only that one endpoint is
94
+ // offered", which is how every implementation predating this field
95
+ // behaves. A sender populating this list MUST also set
96
+ // `transportProtocol` to a single best-compatibility choice so those
97
+ // implementations still learn the new address.
98
+ repeated TransportProtocol supportedTransports = 4;
99
+
100
+ // Timestamp indicating when this message was created.
101
+ //
102
+ // This value is expressed in UTC and is used for envelope-vs-body
103
+ // timestamp validation, replay detection, and observability.
104
+ google.protobuf.Timestamp timestamp = 3;
105
+ }
106
+
107
+ // UpdateChannelInfoResponseMessage is the response to an
108
+ // UpdateChannelInfoRequestMessage.
109
+ //
110
+ // # Semantics
111
+ //
112
+ // On success (`result.status == OK`):
113
+ //
114
+ // - the receiver has persisted the supplied updates
115
+ // - subsequent messages from the receiver MUST use the new endpoint, if
116
+ // `transport_protocol` was updated
117
+ //
118
+ // On failure:
119
+ //
120
+ // - the receiver's stored state is unchanged
121
+ // - the sender SHOULD inspect `result.memo` for diagnostic context
122
+ message UpdateChannelInfoResponseMessage {
123
+
124
+ // Result of processing the update.
125
+ DeRecResult result = 1;
126
+
127
+ // Timestamp indicating when this message was created.
128
+ google.protobuf.Timestamp timestamp = 2;
129
+ }
@@ -0,0 +1,170 @@
1
+ /*
2
+ * Copyright (c) DeRec Alliance and its Contributors.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ syntax = "proto3";
7
+
8
+ import "google/protobuf/timestamp.proto";
9
+ import "result.proto";
10
+ import "transportprotocol.proto";
11
+
12
+ package org.derecalliance.derec.protobuf;
13
+
14
+
15
+ // VerifyShareRequestMessage initiates a verification challenge from the Owner
16
+ // to a Helper to confirm that the Helper still retains a specific share.
17
+ //
18
+ // # Context
19
+ //
20
+ // This message is part of the verification flow, which allows the Owner to:
21
+ //
22
+ // - periodically check Helper liveness
23
+ // - detect data loss or corruption of stored shares
24
+ // - identify Helpers that are no longer reliable for recovery
25
+ //
26
+ // # Semantics
27
+ //
28
+ // The Owner challenges the Helper by providing:
29
+ //
30
+ // - a `version` identifying the share to verify
31
+ // - a fresh `nonce` to ensure the response is unique and not replayable
32
+ //
33
+ // The Helper MUST compute a cryptographic hash over:
34
+ //
35
+ // committedDeRecShare || nonce
36
+ //
37
+ // and return the result in a VerifyShareResponseMessage.
38
+ //
39
+ // # Security Properties
40
+ //
41
+ // - The nonce ensures freshness and prevents replay attacks
42
+ // - The hash proves possession of the exact share bytes
43
+ // - The Helper cannot produce a valid response without holding the share
44
+ //
45
+ // # Idempotency
46
+ //
47
+ // Each request is uniquely identified by the nonce. Reusing a nonce SHOULD
48
+ // be avoided, as it weakens replay protection guarantees.
49
+ message VerifyShareRequestMessage {
50
+ // Secret id being challenged.
51
+ //
52
+ // This identifies which stored share for a secret the Helper must use to compute
53
+ // the verification proof.
54
+ uint64 secretId = 1;
55
+
56
+ // Share version being challenged.
57
+ //
58
+ // This identifies which stored share version the Helper must use to compute
59
+ // the verification proof.
60
+ uint32 version = 2;
61
+
62
+ // Random challenge nonce generated by the Owner.
63
+ //
64
+ // This value MUST be unpredictable and unique per request to ensure
65
+ // freshness and prevent replay of previous responses.
66
+ uint64 nonce = 3;
67
+
68
+ // Timestamp indicating when this message was created.
69
+ //
70
+ // This value is expressed in UTC and can be used for:
71
+ //
72
+ // - observability and logging
73
+ // - replay detection (in combination with sequence numbers)
74
+ // - timeout handling
75
+ google.protobuf.Timestamp timestamp = 4;
76
+
77
+ // Ephemeral transport endpoint at which the requester wants to receive
78
+ // the response to *this exchange*, overriding the channel's stored peer
79
+ // endpoint for this round-trip only.
80
+ //
81
+ // See `StoreShareRequestMessage.replyTo` for full semantics.
82
+ //
83
+ // Superseded by `replyToTransports`, which carries every endpoint rather
84
+ // than one. Kept, and still populated with the list's first entry, so
85
+ // implementations predating that field still receive a reply.
86
+ // **Scheduled for removal in v0.0.5.** Reading this field directly is now
87
+ // incorrect — resolve it against `replyToTransports`.
88
+ optional TransportProtocol replyTo = 5 [deprecated = true];
89
+
90
+ // Every ephemeral endpoint the requester wants this exchange's response
91
+ // delivered to, in its own preference order.
92
+ //
93
+ // See `StoreShareRequestMessage.replyToTransports` for full semantics,
94
+ // including why this is a new tag rather than a widened `replyTo`.
95
+ repeated TransportProtocol replyToTransports = 6;
96
+ }
97
+
98
+ // VerifyShareResponseMessage contains the result of a verification challenge
99
+ // and, on success, provides a proof of share possession.
100
+ //
101
+ // # Semantics
102
+ //
103
+ // In response to a VerifyShareRequestMessage, the Helper:
104
+ //
105
+ // - retrieves the requested share version
106
+ // - computes the hash over (committedDeRecShare || nonce)
107
+ // - returns the result along with the echoed version and nonce
108
+ //
109
+ // The Owner verifies the response by recomputing the expected hash and
110
+ // comparing it with the received value.
111
+ //
112
+ // # Failure Handling
113
+ //
114
+ // If the verification fails (e.g., incorrect hash or error result), the Owner:
115
+ //
116
+ // - MAY retry the verification
117
+ // - MAY resend the correct share to the Helper
118
+ // - MAY mark the Helper as unreliable after repeated failures
119
+ //
120
+ // # Security Considerations
121
+ //
122
+ // - The hash MUST be computed using SHA-384 as defined by the protocol
123
+ // - The nonce MUST match the request to ensure the response is not replayed
124
+ // - The response MUST be sent over an authenticated and encrypted channel
125
+ //
126
+ // # Idempotency
127
+ //
128
+ // Responses are tied to a specific (version, nonce) pair. Replaying a response
129
+ // with a stale nonce SHOULD be rejected by the Owner.
130
+ message VerifyShareResponseMessage {
131
+ // Result of processing the verification request.
132
+ //
133
+ // Indicates whether the Helper successfully computed the proof or
134
+ // encountered an error (e.g., share not found).
135
+ DeRecResult result = 1;
136
+
137
+ // Secret id this response refers to.
138
+ //
139
+ // MUST match the version provided in the request.
140
+ uint64 secretId = 2;
141
+
142
+ // Share version this response refers to.
143
+ //
144
+ // MUST match the version provided in the request.
145
+ uint32 version = 3;
146
+
147
+ // Challenge nonce echoed from the request.
148
+ //
149
+ // MUST exactly match the nonce provided in the request.
150
+ uint64 nonce = 4;
151
+
152
+ // Verification proof.
153
+ //
154
+ // This is the SHA-384 hash of:
155
+ //
156
+ // committedDeRecShare || nonce
157
+ //
158
+ // where `committedDeRecShare` is the exact byte sequence originally
159
+ // stored by the Helper.
160
+ bytes hash = 5;
161
+
162
+ // Timestamp indicating when this message was created.
163
+ //
164
+ // This value is expressed in UTC and can be used for:
165
+ //
166
+ // - observability and logging
167
+ // - replay detection (in combination with sequence numbers)
168
+ // - timeout handling
169
+ google.protobuf.Timestamp timestamp = 6;
170
+ }