@serve.zone/interfaces 32.76.0 → 32.78.0

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.
@@ -1,6 +1,7 @@
1
1
  import * as plugins from '../plugins.js';
2
2
  import type { IControllerPeerSet } from '../data/controller.js';
3
3
  import type {
4
+ IAdoptGatewayResponse,
4
5
  IGateway,
5
6
  IGatewayAdoptionFacts,
6
7
  IGatewayAreaExport,
@@ -17,7 +18,9 @@ import type { IIdentityCredential } from '../data/user.js';
17
18
  * The gateway connector (AGL-1182). A gateway dials its controller on the controller's typedsocket
18
19
  * server; the controller never dials an adopted gateway. `Gateway_Cloudly` requests travel from the
19
20
  * gateway to the controller, `Cloudly_Gateway` requests from the controller to the gateway over
20
- * the socket the gateway opened, and `Admin_Cloudly` requests are an administrator's.
21
+ * the socket the gateway opened, and `Admin_Cloudly` requests are an administrator's. Either side
22
+ * refuses a request by one of `data.gatewayConnectorRefusals`, as a `TypedResponseError` whose
23
+ * `errorData` is `data.IGatewayConnectorRefusalErrorData`.
21
24
  */
22
25
 
23
26
  /**
@@ -26,6 +29,10 @@ import type { IIdentityCredential } from '../data/user.js';
26
29
  * answers the gateway's credential once; adopting again with a new code raises the credential
27
30
  * generation and the previous generation stops authenticating. Exclude bodies from logs: the
28
31
  * request carries the code and the answer the bearer.
32
+ *
33
+ * The controller checks the code first (`adoption-code-unknown`, `adoption-code-expired`,
34
+ * `adoption-code-used`) and then the facts' `adoptedAs` against it in the same transaction
35
+ * (`controller-mismatch`, `gateway-mismatch`), refusing with the code left unconsumed.
29
36
  */
30
37
  export interface IReq_Gateway_Cloudly_AdoptGateway extends plugins.typedrequestInterfaces.implementsTR<
31
38
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -37,18 +44,8 @@ export interface IReq_Gateway_Cloudly_AdoptGateway extends plugins.typedrequestI
37
44
  /** `data.validateGatewayAdoptionFacts`. */
38
45
  facts: IGatewayAdoptionFacts;
39
46
  };
40
- response: {
41
- gatewayId: string;
42
- /** The gateway stores it and refuses any other controller and any older epoch from then on. */
43
- controller: IControllerPeerSet;
44
- /** Answered once; the gateway authenticates its socket as `userId` with `bearer`. */
45
- credential: { userId: string; generation: number; bearer: string };
46
- /**
47
- * The gateway client the controller's existing `requests.gateway` and `requests.mail` calls are
48
- * bound to once they run over the connector socket; `null` when the controller binds none.
49
- */
50
- controllerGatewayClientId: string | null;
51
- };
47
+ /** `data.validateAdoptGatewayResponse`; the gateway checks it before it writes anything. */
48
+ response: IAdoptGatewayResponse;
52
49
  }
53
50
 
54
51
  /**
@@ -85,7 +82,14 @@ export interface IReq_Gateway_Cloudly_PushGatewayStatus extends plugins.typedreq
85
82
 
86
83
  /**
87
84
  * The controller pushes a gateway's whole desired state; the gateway answers what it applied.
85
+ *
88
86
  * A document equal by `(epoch, revision)` to the one applied is answered with the stored report.
87
+ * The gateway refuses a whole document on the request and never stores the refusal in its report:
88
+ * `request-invalid` when `data.validateGatewayDesiredState` fails, `controller-mismatch` for another
89
+ * controller's document, `gateway-mismatch` for another gateway's, `controller-epoch-ahead` for one
90
+ * whose epoch is above the controller epoch the gateway stored, and `desired-state-stale` for an
91
+ * older one, whose text names the applied epoch and revision. An area of an accepted document is
92
+ * refused per area in the report (`data.gatewayApplyRefusals`).
89
93
  */
90
94
  export interface IReq_Cloudly_Gateway_ApplyDesiredState extends plugins.typedrequestInterfaces.implementsTR<
91
95
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -104,6 +108,8 @@ export interface IReq_Cloudly_Gateway_ApplyDesiredState extends plugins.typedreq
104
108
  /**
105
109
  * The controller reads one gateway-owned area table, the first step of taking the area over: it
106
110
  * writes an import revision of it and pushes it back with `takeover.localDigest` set to `digest`.
111
+ * An area the gateway does not take from a controller (`controllerAreas`) is refused
112
+ * `unsupported-area` (`data.gatewayConnectorRefusals`).
107
113
  */
108
114
  export interface IReq_Cloudly_Gateway_ExportGatewayArea extends plugins.typedrequestInterfaces.implementsTR<
109
115
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -5,6 +5,7 @@ import type { IActiveSecretRecipientMetadata } from '../data/secret.js';
5
5
  import type { ICloudlySettings, IExternalGatewayEnrollmentState } from '../data/settings.js';
6
6
  import type { IIdentity, IIdentityCredential } from '../data/user.js';
7
7
  import { readDataProperties, hasExactKeys } from '../private/dataproperties.js';
8
+ import { isGatewayClientIdText } from '../private/gatewayclientid.js';
8
9
 
9
10
  // Get Settings
10
11
  export interface IRequest_GetSettings extends plugins.typedrequestInterfaces.ITypedRequest {
@@ -151,10 +152,7 @@ const validateExpectedGatewayTarget = (urlArg: unknown, clientIdArg: unknown): s
151
152
  || url.hash !== '') {
152
153
  errors.push('bootstrap expectedGatewayUrl must be an HTTPS URL without credentials, query or fragment');
153
154
  }
154
- if (typeof clientIdArg !== 'string'
155
- || clientIdArg.length === 0
156
- || clientIdArg.length > settingsData.externalGatewayBootstrapContract.maximumGatewayClientIdLength
157
- || !/^[\x21-\x7e]+$/.test(clientIdArg)) {
155
+ if (!isGatewayClientIdText(clientIdArg)) {
158
156
  errors.push('bootstrap expectedGatewayClientId must be a bounded identifier without whitespace');
159
157
  }
160
158
  return errors;