@serve.zone/interfaces 32.113.0 → 32.115.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.
- package/changelog.md +22 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/backup/index.d.ts +2 -0
- package/dist_ts/data/backup/index.js +3 -0
- package/dist_ts/data/coremail/index.d.ts +2 -0
- package/dist_ts/data/coremail/index.js +3 -0
- package/dist_ts/data/corestorereplication.d.ts +90 -0
- package/dist_ts/data/corestorereplication.js +129 -0
- package/dist_ts/data/dcstorage.d.ts +206 -0
- package/dist_ts/data/dcstorage.js +322 -0
- package/dist_ts/data/delegatedadmintoken.d.ts +4 -2
- package/dist_ts/data/delegatedadmintoken.js +9 -3
- package/dist_ts/data/gateway.d.ts +15 -0
- package/dist_ts/data/gateway.js +6 -2
- package/dist_ts/data/gatewayarearows.d.ts +17 -11
- package/dist_ts/data/gatewayarearows.js +27 -11
- package/dist_ts/data/gatewayareas.d.ts +12 -2
- package/dist_ts/data/gatewayareas.js +5 -2
- package/dist_ts/data/gatewayareas.validation.js +11 -5
- package/dist_ts/data/index.d.ts +3 -0
- package/dist_ts/data/index.js +4 -1
- package/dist_ts/data/preparedimages.d.ts +80 -0
- package/dist_ts/data/preparedimages.js +154 -0
- package/dist_ts/index.d.ts +8 -2
- package/dist_ts/index.js +9 -3
- package/dist_ts/requests/backup.d.ts +1 -1
- package/dist_ts/requests/backup.js +2 -2
- package/dist_ts/requests/corestore.d.ts +1 -1
- package/dist_ts/requests/corestore.js +1 -2
- package/dist_ts/requests/corestorereplication.d.ts +108 -0
- package/dist_ts/requests/corestorereplication.js +2 -0
- package/dist_ts/requests/dcstorage.d.ts +204 -0
- package/dist_ts/requests/dcstorage.js +2 -0
- package/dist_ts/requests/gateway.d.ts +1 -1
- package/dist_ts/requests/gateway.js +2 -2
- package/dist_ts/requests/gatewaycertificatestore.d.ts +208 -0
- package/dist_ts/requests/gatewaycertificatestore.js +240 -0
- package/dist_ts/requests/gatewayconnector.d.ts +1 -1
- package/dist_ts/requests/gatewayconnector.js +2 -2
- package/dist_ts/requests/gatewayhealth.d.ts +65 -0
- package/dist_ts/requests/gatewayhealth.js +72 -0
- package/dist_ts/requests/gatewayremoteingress.d.ts +10 -2
- package/dist_ts/requests/gatewayremoteingress.js +7 -2
- package/dist_ts/requests/index.d.ts +5 -0
- package/dist_ts/requests/index.js +6 -1
- package/dist_ts/requests/mail.d.ts +1 -1
- package/dist_ts/requests/mail.js +2 -2
- package/dist_ts/requests/preparedimages.d.ts +24 -0
- package/dist_ts/requests/preparedimages.js +2 -0
- package/package.json +105 -1
- package/readme.md +96 -9
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/backup/index.ts +2 -0
- package/ts/data/coremail/index.ts +2 -0
- package/ts/data/corestorereplication.ts +223 -0
- package/ts/data/dcstorage.ts +505 -0
- package/ts/data/delegatedadmintoken.ts +9 -3
- package/ts/data/gateway.ts +20 -1
- package/ts/data/gatewayarearows.ts +32 -13
- package/ts/data/gatewayareas.ts +15 -3
- package/ts/data/gatewayareas.validation.ts +10 -4
- package/ts/data/index.ts +3 -0
- package/ts/data/preparedimages.ts +231 -0
- package/ts/index.ts +9 -2
- package/ts/requests/backup.ts +1 -1
- package/ts/requests/corestore.ts +1 -1
- package/ts/requests/corestorereplication.ts +123 -0
- package/ts/requests/dcstorage.ts +208 -0
- package/ts/requests/gateway.ts +1 -1
- package/ts/requests/gatewaycertificatestore.ts +411 -0
- package/ts/requests/gatewayconnector.ts +1 -1
- package/ts/requests/gatewayhealth.ts +135 -0
- package/ts/requests/gatewayremoteingress.ts +15 -3
- package/ts/requests/index.ts +5 -0
- package/ts/requests/mail.ts +1 -1
- package/ts/requests/preparedimages.ts +39 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import type { IControllerPeerSet } from '../data/controller.js';
|
|
3
|
+
import type {
|
|
4
|
+
IDcStorageFailureDomain,
|
|
5
|
+
IDcStorageFilesystemIdentity,
|
|
6
|
+
IDcStorageNode,
|
|
7
|
+
IDcStorageNodeTelemetryReport,
|
|
8
|
+
IDcStoragePool,
|
|
9
|
+
IDcStoragePoolProfile,
|
|
10
|
+
IDcStorageSessionFence,
|
|
11
|
+
IDcStorageVolumeAssignment,
|
|
12
|
+
IDcStorageVolumeStatus,
|
|
13
|
+
IEnrollDcStorageNodeRequest,
|
|
14
|
+
IRegisterDcStorageNodeSessionRequest,
|
|
15
|
+
TDcStorageRefusal,
|
|
16
|
+
} from '../data/dcstorage.js';
|
|
17
|
+
import type { TOutcomeUnknownCode } from '../data/outcomeunknown.js';
|
|
18
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
19
|
+
import type { IProtocolOffer } from '../protocol.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The admin router requires an administrator and fresh sign-in for mutations. The node router
|
|
23
|
+
* accepts bootstrap and registration separately from session-scoped traffic. Either router uses
|
|
24
|
+
* TypedResponseError.errorData ({ code, retryable: false }); readers use readDcStorageRefusalErrorData.
|
|
25
|
+
* A missing mutation answer or outcome-unknown requires inspection before taking further action.
|
|
26
|
+
*/
|
|
27
|
+
interface IDcStorageAdminRequest { identity: IIdentityCredential }
|
|
28
|
+
|
|
29
|
+
interface IDcStorageAdminMutation extends IDcStorageAdminRequest {
|
|
30
|
+
/** Durable key for recovering the exact admitted intent. Reuse with another body is refused. */
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
controllerEpoch: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface IDcStorageNodeMutation extends IDcStorageAdminMutation {
|
|
36
|
+
nodeId: string;
|
|
37
|
+
nodeRevision: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface IDcStorageMemberMutation extends IDcStorageAdminMutation {
|
|
41
|
+
poolId: string;
|
|
42
|
+
poolRevision: number;
|
|
43
|
+
slot: number;
|
|
44
|
+
memberGeneration: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IDcStorageVolumeReference {
|
|
48
|
+
volumeId: string;
|
|
49
|
+
volumeGeneration: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type TDcStorageType = plugins.typedrequestInterfaces.ITypedRequest;
|
|
53
|
+
|
|
54
|
+
/** A durable admission receipt. Read getDcStorageOperation for progress or completion. */
|
|
55
|
+
export interface IDcStorageOperationReceipt { operationId: string }
|
|
56
|
+
|
|
57
|
+
export type TDcStorageOperationStatus =
|
|
58
|
+
| { state: 'accepted' | 'running' | 'completed'; pool: IDcStoragePool }
|
|
59
|
+
| { state: 'refused'; reason: Exclude<TDcStorageRefusal, TOutcomeUnknownCode>; pool: IDcStoragePool };
|
|
60
|
+
|
|
61
|
+
/** Discovery for administrators. The node still negotiates the release and its own capabilities. */
|
|
62
|
+
export interface IReq_Admin_Cloudly_GetDcStorageCapabilities extends
|
|
63
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageCapabilities> {
|
|
64
|
+
method: 'getDcStorageCapabilities';
|
|
65
|
+
request: IDcStorageAdminRequest;
|
|
66
|
+
response: {
|
|
67
|
+
controllerEpoch: number;
|
|
68
|
+
protocol: IProtocolOffer;
|
|
69
|
+
nodeEnrollment: boolean;
|
|
70
|
+
filesystemVolumes: boolean;
|
|
71
|
+
poolAdmission: boolean;
|
|
72
|
+
poolDrain: boolean;
|
|
73
|
+
poolReplacement: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Creates a pending node. The administrator's enrollment client keeps the random code. */
|
|
78
|
+
export interface IReq_Admin_Cloudly_CreateDcStorageEnrollment extends
|
|
79
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_CreateDcStorageEnrollment> {
|
|
80
|
+
method: 'createDcStorageEnrollment';
|
|
81
|
+
/** Suppress the request body from logs, including the code verifier. */
|
|
82
|
+
request: IDcStorageAdminMutation & { locationId: string; failureDomain: IDcStorageFailureDomain; pairingCodeSha256: string };
|
|
83
|
+
response: { node: IDcStorageNode; expiresAt: number };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Consumes the code and installs the bearer digest atomically. The request carries a secret. */
|
|
87
|
+
export interface IReq_DcStorage_Cloudly_EnrollDcStorageNode extends
|
|
88
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_EnrollDcStorageNode> {
|
|
89
|
+
method: 'enrollDcStorageNode';
|
|
90
|
+
request: IEnrollDcStorageNodeRequest;
|
|
91
|
+
response: { node: IDcStorageNode; controller: IControllerPeerSet; protocol: IProtocolOffer };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Authenticates a node on this socket. The request carries a secret. */
|
|
95
|
+
export interface IReq_DcStorage_Cloudly_RegisterDcStorageNodeSession extends
|
|
96
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_RegisterDcStorageNodeSession> {
|
|
97
|
+
method: 'registerDcStorageNodeSession';
|
|
98
|
+
request: IRegisterDcStorageNodeSessionRequest;
|
|
99
|
+
response: { controller: IControllerPeerSet; protocol: IProtocolOffer; fence: IDcStorageSessionFence };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Revokes control identity, closes its sessions and stops issuing grants. Ownership is retained. */
|
|
103
|
+
export interface IReq_Admin_Cloudly_RevokeDcStorageNode extends
|
|
104
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_RevokeDcStorageNode> {
|
|
105
|
+
method: 'revokeDcStorageNode';
|
|
106
|
+
request: IDcStorageNodeMutation;
|
|
107
|
+
response: IDcStorageNode;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface IReq_Admin_Cloudly_GetDcStorageNode extends
|
|
111
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageNode> {
|
|
112
|
+
method: 'getDcStorageNode';
|
|
113
|
+
request: IDcStorageAdminRequest & { nodeId: string };
|
|
114
|
+
response: {
|
|
115
|
+
node: IDcStorageNode;
|
|
116
|
+
assignments: IDcStorageVolumeAssignment[];
|
|
117
|
+
/** Last accepted observation. Read freshness from the node record and the session fence. */
|
|
118
|
+
telemetry: IDcStorageNodeTelemetryReport | null;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Reserves an explicitly provisioned identity. Assignment alone gives no write authority. */
|
|
123
|
+
export interface IReq_Admin_Cloudly_AssignDcStorageVolume extends
|
|
124
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_AssignDcStorageVolume> {
|
|
125
|
+
method: 'assignDcStorageVolume';
|
|
126
|
+
request: IDcStorageNodeMutation & { volumeId: string; expected: IDcStorageFilesystemIdentity };
|
|
127
|
+
response: { assignment: IDcStorageVolumeAssignment; nodeRevision: number };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Releases only the named generation after dependent members and writers are fenced. */
|
|
131
|
+
export interface IReq_Admin_Cloudly_UnassignDcStorageVolume extends
|
|
132
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_UnassignDcStorageVolume> {
|
|
133
|
+
method: 'unassignDcStorageVolume';
|
|
134
|
+
request: IDcStorageNodeMutation & IDcStorageVolumeReference;
|
|
135
|
+
response: { nodeRevision: number };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Fresh private verification on the authenticated owner session. */
|
|
139
|
+
export interface IReq_Admin_Cloudly_VerifyDcStorageVolume extends
|
|
140
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_VerifyDcStorageVolume> {
|
|
141
|
+
method: 'verifyDcStorageVolume';
|
|
142
|
+
request: IDcStorageAdminRequest & IDcStorageVolumeReference & { nodeId: string };
|
|
143
|
+
response: IDcStorageVolumeStatus;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Cloudly requests a read-only probe. The assignment and session fence must match on return. */
|
|
147
|
+
export interface IReq_Cloudly_DcStorage_ProbeDcStorageVolume extends
|
|
148
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Cloudly_DcStorage_ProbeDcStorageVolume> {
|
|
149
|
+
method: 'probeDcStorageVolume';
|
|
150
|
+
request: { assignment: IDcStorageVolumeAssignment; fence: IDcStorageSessionFence };
|
|
151
|
+
response: IDcStorageVolumeStatus;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface IReq_Admin_Cloudly_CreateDcStoragePool extends
|
|
155
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_CreateDcStoragePool> {
|
|
156
|
+
method: 'createDcStoragePool';
|
|
157
|
+
request: IDcStorageAdminMutation & { locationId: string; profile: IDcStoragePoolProfile };
|
|
158
|
+
response: IDcStoragePool;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface IReq_Admin_Cloudly_GetDcStoragePool extends
|
|
162
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStoragePool> {
|
|
163
|
+
method: 'getDcStoragePool';
|
|
164
|
+
request: IDcStorageAdminRequest & { poolId: string };
|
|
165
|
+
response: IDcStoragePool;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface IReq_Admin_Cloudly_AdmitDcStoragePoolMember extends
|
|
169
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_AdmitDcStoragePoolMember> {
|
|
170
|
+
method: 'admitDcStoragePoolMember';
|
|
171
|
+
request: Omit<IDcStorageMemberMutation, 'memberGeneration'> & IDcStorageVolumeReference & {
|
|
172
|
+
nodeId: string;
|
|
173
|
+
/** Null for a never-allocated slot. Otherwise match the pending slot's current generation. */
|
|
174
|
+
memberGeneration: number | null;
|
|
175
|
+
};
|
|
176
|
+
response: IDcStorageOperationReceipt;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface IReq_Admin_Cloudly_DrainDcStoragePoolMember extends
|
|
180
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_DrainDcStoragePoolMember> {
|
|
181
|
+
method: 'drainDcStoragePoolMember';
|
|
182
|
+
request: IDcStorageMemberMutation;
|
|
183
|
+
response: IDcStorageOperationReceipt;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface IReq_Admin_Cloudly_ReplaceDcStoragePoolMember extends
|
|
187
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_ReplaceDcStoragePoolMember> {
|
|
188
|
+
method: 'replaceDcStoragePoolMember';
|
|
189
|
+
request: IDcStorageMemberMutation & {
|
|
190
|
+
replacement: IDcStorageVolumeReference & { nodeId: string };
|
|
191
|
+
};
|
|
192
|
+
response: IDcStorageOperationReceipt;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface IReq_Admin_Cloudly_GetDcStorageOperation extends
|
|
196
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_Admin_Cloudly_GetDcStorageOperation> {
|
|
197
|
+
method: 'getDcStorageOperation';
|
|
198
|
+
request: IDcStorageAdminRequest & { operationId: string };
|
|
199
|
+
response: TDcStorageOperationStatus;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Authenticated reverse session only. Acceptance acknowledges observation, never ownership. */
|
|
203
|
+
export interface IReq_DcStorage_Cloudly_ReportDcStorageNodeTelemetry extends
|
|
204
|
+
plugins.typedrequestInterfaces.implementsTR<TDcStorageType, IReq_DcStorage_Cloudly_ReportDcStorageNodeTelemetry> {
|
|
205
|
+
method: 'reportDcStorageNodeTelemetry';
|
|
206
|
+
request: IDcStorageNodeTelemetryReport;
|
|
207
|
+
response: { acceptedSequence: number };
|
|
208
|
+
}
|
package/ts/requests/gateway.ts
CHANGED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import type { ITypedRequest, implementsTR } from '@api.global/typedrequest-interfaces';
|
|
2
|
+
import type * as plugins from '../plugins.js';
|
|
3
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
4
|
+
import { isGatewayAreaRowId } from '../data/gatewayareas.js';
|
|
5
|
+
import { isSha256Digest, type TSha256Digest } from '../data/immutableimage.js';
|
|
6
|
+
import { compareWireTokens } from '../private/canonicaljson.js';
|
|
7
|
+
import { hasExactKeys, readDataElements, readDataProperties, readExactDataRecord } from '../private/dataproperties.js';
|
|
8
|
+
|
|
9
|
+
type ICert = plugins.tsclass.network.ICert;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A stored legacy selector, never an exact-issuance record. The gateway issues the ID and changes
|
|
13
|
+
* it on recreation. Content revision covers every selected backing document, including secrets;
|
|
14
|
+
* usage revision covers all current consumers and the selection's effects on shared base domains.
|
|
15
|
+
* Neither revision reveals its inputs. Both are compared again inside the gateway's mutation lock.
|
|
16
|
+
*/
|
|
17
|
+
export interface IGatewayCertificateStoreEntry {
|
|
18
|
+
id: string;
|
|
19
|
+
/** Display-safe preview. Export by ID to obtain the original legacy domain string. */
|
|
20
|
+
domainName: string;
|
|
21
|
+
domainNameAltered: boolean;
|
|
22
|
+
backingKinds: ('legacy-acme' | 'proxy')[];
|
|
23
|
+
created: number;
|
|
24
|
+
validUntil: number;
|
|
25
|
+
exportable: boolean;
|
|
26
|
+
contentRevision: TSha256Digest;
|
|
27
|
+
usageRevision: TSha256Digest;
|
|
28
|
+
/** Counts cover the complete consumer set, including members omitted from the display sample. */
|
|
29
|
+
consumerCounts: IGatewayCertificateStoreConsumerCounts;
|
|
30
|
+
consumersTruncated: boolean;
|
|
31
|
+
consumers: IGatewayCertificateStoreConsumer[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IGatewayCertificateStoreConsumer {
|
|
35
|
+
kind: 'route' | 'smtp' | 'remoteIngress';
|
|
36
|
+
id: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IGatewayCertificateStoreConsumerCounts {
|
|
40
|
+
routes: number;
|
|
41
|
+
smtp: number;
|
|
42
|
+
remoteIngress: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IGatewayCertificateStorePage {
|
|
46
|
+
entries: IGatewayCertificateStoreEntry[];
|
|
47
|
+
/** The last returned ID, only when a later entry exists. */
|
|
48
|
+
nextAfter?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const gatewayCertificateStoreBounds = Object.freeze({
|
|
52
|
+
page: 8,
|
|
53
|
+
/** One extra row from a storage query proves whether another page exists. */
|
|
54
|
+
storageWindow: 9,
|
|
55
|
+
consumersPerEntry: 64,
|
|
56
|
+
domainNamePreview: 253,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/** The boolean flags explicitly acknowledge stored-only effects on the named consumer classes. */
|
|
60
|
+
export interface IGatewayCertificateStoreImpactConfirmation {
|
|
61
|
+
routes: boolean;
|
|
62
|
+
smtp: boolean;
|
|
63
|
+
remoteIngress: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Plain creation has no observed backing. Related creation observes a different legacy selector;
|
|
68
|
+
* exact replacement observes the target itself. The gateway must compare both revisions and
|
|
69
|
+
* complete target-union impact in the same authorizing transaction as its write.
|
|
70
|
+
* The projector validates those three wire forms; keep this published interface extensible.
|
|
71
|
+
*/
|
|
72
|
+
export interface IGatewayCertificateStoreImport {
|
|
73
|
+
certificate: ICert;
|
|
74
|
+
/** Null creates; an observed gateway-issued selector ID replaces. */
|
|
75
|
+
id: string | null;
|
|
76
|
+
/** Related creation only, gated by certificates.storeRelatedImport. */
|
|
77
|
+
relatedSelectorId?: string;
|
|
78
|
+
expectedContentRevision: TSha256Digest | null;
|
|
79
|
+
expectedUsageRevision: TSha256Digest | null;
|
|
80
|
+
confirmImpact: IGatewayCertificateStoreImpactConfirmation;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IGatewayCertificateStoreTarget {
|
|
84
|
+
id: string;
|
|
85
|
+
expectedContentRevision: TSha256Digest;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface IGatewayCertificateStoreDelete extends IGatewayCertificateStoreTarget {
|
|
89
|
+
expectedUsageRevision: TSha256Digest;
|
|
90
|
+
confirmImpact: IGatewayCertificateStoreImpactConfirmation;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type TGatewayCertificateStoreCommonRefusal = 'invalid-request' | 'store-unavailable';
|
|
94
|
+
type TGatewayCertificateStoreMutationRefusal = TGatewayCertificateStoreCommonRefusal
|
|
95
|
+
| 'stale-content' | 'stale-usage' | 'impact-confirmation-required' | 'outcome-unknown';
|
|
96
|
+
type TGatewayCertificateStoreExportRefusal = TGatewayCertificateStoreCommonRefusal
|
|
97
|
+
| 'not-found' | 'not-exportable' | 'stale-content';
|
|
98
|
+
type TGatewayCertificateStoreAdminRefusal = 'administrator-required' | 'gateway-disconnected'
|
|
99
|
+
| 'gateway-unavailable' | 'gateway-unsupported';
|
|
100
|
+
export type TGatewayCertificateStoreInventoryRefusal = TGatewayCertificateStoreCommonRefusal;
|
|
101
|
+
export type TGatewayCertificateStoreImportRefusal = TGatewayCertificateStoreMutationRefusal;
|
|
102
|
+
export type TGatewayCertificateStoreDeleteRefusal = TGatewayCertificateStoreMutationRefusal;
|
|
103
|
+
export type TGatewayCertificateStorePrivateExportRefusal = TGatewayCertificateStoreExportRefusal;
|
|
104
|
+
export type TGatewayCertificateStoreAdminInventoryRefusal = TGatewayCertificateStoreInventoryRefusal
|
|
105
|
+
| TGatewayCertificateStoreAdminRefusal;
|
|
106
|
+
export type TGatewayCertificateStoreAdminMutationRefusal = TGatewayCertificateStoreMutationRefusal
|
|
107
|
+
| TGatewayCertificateStoreAdminRefusal | 'fresh-sign-in-required';
|
|
108
|
+
export type TGatewayCertificateStoreAdminExportRefusal = TGatewayCertificateStoreExportRefusal
|
|
109
|
+
| TGatewayCertificateStoreAdminRefusal | 'fresh-sign-in-required';
|
|
110
|
+
export type TGatewayCertificateStoreWriteResult<TRefusal extends string> =
|
|
111
|
+
| { ok: true; outcome: 'written' | 'unchanged'; id: string; contentRevision: TSha256Digest; usageRevision: TSha256Digest }
|
|
112
|
+
| { ok: false; reason: TRefusal };
|
|
113
|
+
export type TGatewayCertificateStoreDeleteResult<TRefusal extends string> =
|
|
114
|
+
| { ok: true; outcome: 'deleted' | 'unchanged' }
|
|
115
|
+
| { ok: false; reason: TRefusal };
|
|
116
|
+
export type TGatewayCertificateStoreExportResult<TRefusal extends string> =
|
|
117
|
+
| { ok: true; certificate: ICert }
|
|
118
|
+
| { ok: false; reason: TRefusal };
|
|
119
|
+
export type TGatewayCertificateStoreInventoryResult<TRefusal extends string> =
|
|
120
|
+
| { ok: true; page: IGatewayCertificateStorePage }
|
|
121
|
+
| { ok: false; reason: TRefusal };
|
|
122
|
+
|
|
123
|
+
interface IAdminTarget { gatewayId: string; identity: IIdentityCredential }
|
|
124
|
+
|
|
125
|
+
/** Only the adopted controller session can inspect the gateway's legacy stores. */
|
|
126
|
+
export interface IReq_Cloudly_Gateway_ReadCertificateStore extends implementsTR<ITypedRequest, IReq_Cloudly_Gateway_ReadCertificateStore> {
|
|
127
|
+
method: 'readGatewayCertificateStore';
|
|
128
|
+
request: { after?: string };
|
|
129
|
+
response: TGatewayCertificateStoreInventoryResult<TGatewayCertificateStoreInventoryRefusal>;
|
|
130
|
+
}
|
|
131
|
+
export interface IReq_Admin_Cloudly_GetCertificateStore extends implementsTR<ITypedRequest, IReq_Admin_Cloudly_GetCertificateStore> {
|
|
132
|
+
method: 'getGatewayCertificateStore';
|
|
133
|
+
request: IAdminTarget & { after?: string };
|
|
134
|
+
response: TGatewayCertificateStoreInventoryResult<TGatewayCertificateStoreAdminInventoryRefusal>;
|
|
135
|
+
}
|
|
136
|
+
/** Credential-bearing connector request; Cloudly's HTTP leg requires credential-safe transport. */
|
|
137
|
+
export interface IReq_Cloudly_Gateway_ImportStoredCertificate extends implementsTR<ITypedRequest, IReq_Cloudly_Gateway_ImportStoredCertificate> {
|
|
138
|
+
method: 'importGatewayStoredCertificate';
|
|
139
|
+
request: IGatewayCertificateStoreImport;
|
|
140
|
+
response: TGatewayCertificateStoreWriteResult<TGatewayCertificateStoreImportRefusal>;
|
|
141
|
+
}
|
|
142
|
+
export interface IReq_Admin_Cloudly_ImportStoredCertificate extends implementsTR<ITypedRequest, IReq_Admin_Cloudly_ImportStoredCertificate> {
|
|
143
|
+
method: 'importGatewayStoredCertificateForAdmin';
|
|
144
|
+
request: IAdminTarget & IGatewayCertificateStoreImport;
|
|
145
|
+
response: TGatewayCertificateStoreWriteResult<TGatewayCertificateStoreAdminMutationRefusal>;
|
|
146
|
+
}
|
|
147
|
+
/** Credential-bearing answer: never log, cache, or put it into browser storage. */
|
|
148
|
+
export interface IReq_Cloudly_Gateway_ExportStoredCertificate extends implementsTR<ITypedRequest, IReq_Cloudly_Gateway_ExportStoredCertificate> {
|
|
149
|
+
method: 'exportGatewayStoredCertificate';
|
|
150
|
+
request: IGatewayCertificateStoreTarget;
|
|
151
|
+
response: TGatewayCertificateStoreExportResult<TGatewayCertificateStorePrivateExportRefusal>;
|
|
152
|
+
}
|
|
153
|
+
export interface IReq_Admin_Cloudly_ExportStoredCertificate extends implementsTR<ITypedRequest, IReq_Admin_Cloudly_ExportStoredCertificate> {
|
|
154
|
+
method: 'exportGatewayStoredCertificateForAdmin';
|
|
155
|
+
request: IAdminTarget & IGatewayCertificateStoreTarget;
|
|
156
|
+
response: TGatewayCertificateStoreExportResult<TGatewayCertificateStoreAdminExportRefusal>;
|
|
157
|
+
}
|
|
158
|
+
export interface IReq_Cloudly_Gateway_DeleteStoredCertificate extends implementsTR<ITypedRequest, IReq_Cloudly_Gateway_DeleteStoredCertificate> {
|
|
159
|
+
method: 'deleteGatewayStoredCertificate';
|
|
160
|
+
request: IGatewayCertificateStoreDelete;
|
|
161
|
+
response: TGatewayCertificateStoreDeleteResult<TGatewayCertificateStoreDeleteRefusal>;
|
|
162
|
+
}
|
|
163
|
+
export interface IReq_Admin_Cloudly_DeleteStoredCertificate extends implementsTR<ITypedRequest, IReq_Admin_Cloudly_DeleteStoredCertificate> {
|
|
164
|
+
method: 'deleteGatewayStoredCertificateForAdmin';
|
|
165
|
+
request: IAdminTarget & IGatewayCertificateStoreDelete;
|
|
166
|
+
response: TGatewayCertificateStoreDeleteResult<TGatewayCertificateStoreAdminMutationRefusal>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const isRevision = (value: unknown): value is TSha256Digest =>
|
|
170
|
+
typeof value === 'string' && isSha256Digest(value);
|
|
171
|
+
// Legacy ICert imports did not restrict the two numeric timestamps beyond JSON number syntax.
|
|
172
|
+
const isTime = (value: unknown): value is number =>
|
|
173
|
+
typeof value === 'number' && Number.isFinite(value);
|
|
174
|
+
const isDomainPreview = (value: unknown): value is string =>
|
|
175
|
+
typeof value === 'string' && value.length > 0 && value.length <= gatewayCertificateStoreBounds.domainNamePreview
|
|
176
|
+
&& !/[\u0000-\u001f\u007f]/.test(value);
|
|
177
|
+
const isCount = (value: unknown): value is number =>
|
|
178
|
+
typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
179
|
+
|
|
180
|
+
/** A legacy domain can be arbitrarily long or contain controls; keep it exportable by ID. */
|
|
181
|
+
export const previewLegacyCertificateDomainName = (value: string): { domainName: string; domainNameAltered: boolean } => {
|
|
182
|
+
let domainName = '';
|
|
183
|
+
let domainNameAltered = false;
|
|
184
|
+
for (const character of value) {
|
|
185
|
+
const code = character.charCodeAt(0);
|
|
186
|
+
const safeCharacter = code < 32 || code === 127 || (character.length === 1 && code >= 0xd800 && code <= 0xdfff)
|
|
187
|
+
? '\ufffd' : character;
|
|
188
|
+
if (domainName.length + safeCharacter.length > gatewayCertificateStoreBounds.domainNamePreview) {
|
|
189
|
+
domainNameAltered = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (safeCharacter !== character) domainNameAltered = true;
|
|
193
|
+
domainName += safeCharacter;
|
|
194
|
+
}
|
|
195
|
+
return domainName.length > 0 ? { domainName, domainNameAltered }
|
|
196
|
+
: { domainName: '[empty domain]', domainNameAltered: true };
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const isGatewayCertificateStorePageRequest = (value: unknown): value is { after?: string } => {
|
|
200
|
+
const record = readDataProperties(value);
|
|
201
|
+
return record !== null && Object.keys(record).every((key) => key === 'after')
|
|
202
|
+
&& (!Object.hasOwn(record, 'after') || isGatewayAreaRowId(record.after));
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/** Select from a storage query ordered by ID, strictly after the cursor, limited to page + 1. */
|
|
206
|
+
export const selectGatewayCertificateStorePage = <T extends { id: string }>(
|
|
207
|
+
storageWindow: readonly T[], request: unknown,
|
|
208
|
+
): { entries: T[]; nextAfter?: string } | null => {
|
|
209
|
+
if (!isGatewayCertificateStorePageRequest(request) || !Array.isArray(storageWindow)
|
|
210
|
+
|| storageWindow.length > gatewayCertificateStoreBounds.storageWindow) return null;
|
|
211
|
+
let previous: string | null = request.after ?? null;
|
|
212
|
+
for (const entry of storageWindow) {
|
|
213
|
+
const row = readDataProperties(entry);
|
|
214
|
+
if (!row || !isGatewayAreaRowId(row.id)
|
|
215
|
+
|| (previous !== null && compareWireTokens(previous, row.id) >= 0)) return null;
|
|
216
|
+
previous = row.id;
|
|
217
|
+
}
|
|
218
|
+
const entries = storageWindow.slice(0, gatewayCertificateStoreBounds.page);
|
|
219
|
+
return storageWindow.length > entries.length ? { entries, nextAfter: entries[entries.length - 1].id } : { entries };
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/** Rebuilds a metadata-only page; unknown members, including a stray PEM or key, refuse whole. */
|
|
223
|
+
export const projectGatewayCertificateStorePage = (value: unknown, request: unknown): IGatewayCertificateStorePage | null => {
|
|
224
|
+
if (!isGatewayCertificateStorePageRequest(request)) return null;
|
|
225
|
+
const page = readDataProperties(value);
|
|
226
|
+
if (!page || Object.keys(page).some((key) => key !== 'entries' && key !== 'nextAfter')) return null;
|
|
227
|
+
const rows = readDataElements(page.entries, gatewayCertificateStoreBounds.page);
|
|
228
|
+
if (!rows || (Object.hasOwn(page, 'nextAfter') && (rows.length === 0 || !isGatewayAreaRowId(page.nextAfter)))) return null;
|
|
229
|
+
const entries: IGatewayCertificateStoreEntry[] = [];
|
|
230
|
+
let previous: string | null = request.after ?? null;
|
|
231
|
+
for (const rowArg of rows) {
|
|
232
|
+
const row = readExactDataRecord(rowArg, [
|
|
233
|
+
'id', 'domainName', 'domainNameAltered', 'backingKinds', 'created', 'validUntil', 'exportable',
|
|
234
|
+
'contentRevision', 'usageRevision', 'consumerCounts', 'consumersTruncated', 'consumers',
|
|
235
|
+
]);
|
|
236
|
+
if (!row || !isGatewayAreaRowId(row.id) || (previous && compareWireTokens(previous, row.id) >= 0)
|
|
237
|
+
|| !isDomainPreview(row.domainName) || typeof row.domainNameAltered !== 'boolean'
|
|
238
|
+
|| !isTime(row.created) || !isTime(row.validUntil)
|
|
239
|
+
|| typeof row.exportable !== 'boolean' || !isRevision(row.contentRevision)
|
|
240
|
+
|| !isRevision(row.usageRevision) || typeof row.consumersTruncated !== 'boolean') return null;
|
|
241
|
+
const kinds = readDataElements(row.backingKinds, 2);
|
|
242
|
+
if (!kinds || !((kinds.length === 1 && (kinds[0] === 'legacy-acme' || kinds[0] === 'proxy'))
|
|
243
|
+
|| (kinds.length === 2 && kinds[0] === 'legacy-acme' && kinds[1] === 'proxy'))) return null;
|
|
244
|
+
const consumersArg = readDataElements(row.consumers, gatewayCertificateStoreBounds.consumersPerEntry);
|
|
245
|
+
if (!consumersArg) return null;
|
|
246
|
+
const counts = readExactDataRecord(row.consumerCounts, ['routes', 'smtp', 'remoteIngress']);
|
|
247
|
+
if (!counts || !isCount(counts.routes) || !isCount(counts.smtp)
|
|
248
|
+
|| !isCount(counts.remoteIngress)) return null;
|
|
249
|
+
const consumers: IGatewayCertificateStoreConsumer[] = [];
|
|
250
|
+
const sampledCounts = { routes: 0, smtp: 0, remoteIngress: 0 };
|
|
251
|
+
let previousConsumer: string | null = null;
|
|
252
|
+
for (const consumerArg of consumersArg) {
|
|
253
|
+
const consumer = readExactDataRecord(consumerArg, ['kind', 'id']);
|
|
254
|
+
if (!consumer || (consumer.kind !== 'route' && consumer.kind !== 'smtp' && consumer.kind !== 'remoteIngress')
|
|
255
|
+
|| !isGatewayAreaRowId(consumer.id)) return null;
|
|
256
|
+
const key = `${consumer.kind}\u0000${consumer.id}`;
|
|
257
|
+
if (previousConsumer !== null && compareWireTokens(previousConsumer, key) >= 0) return null;
|
|
258
|
+
previousConsumer = key;
|
|
259
|
+
consumers.push({ kind: consumer.kind, id: consumer.id });
|
|
260
|
+
if (consumer.kind === 'route') sampledCounts.routes++;
|
|
261
|
+
else if (consumer.kind === 'smtp') sampledCounts.smtp++;
|
|
262
|
+
else sampledCounts.remoteIngress++;
|
|
263
|
+
}
|
|
264
|
+
if (counts.routes < sampledCounts.routes || counts.smtp < sampledCounts.smtp
|
|
265
|
+
|| counts.remoteIngress < sampledCounts.remoteIngress
|
|
266
|
+
|| row.consumersTruncated !== (counts.routes + counts.smtp + counts.remoteIngress > consumers.length)) return null;
|
|
267
|
+
entries.push({ id: row.id, domainName: row.domainName, domainNameAltered: row.domainNameAltered,
|
|
268
|
+
backingKinds: kinds as IGatewayCertificateStoreEntry['backingKinds'],
|
|
269
|
+
created: row.created, validUntil: row.validUntil, exportable: row.exportable,
|
|
270
|
+
contentRevision: row.contentRevision, usageRevision: row.usageRevision,
|
|
271
|
+
consumerCounts: { routes: counts.routes, smtp: counts.smtp, remoteIngress: counts.remoteIngress },
|
|
272
|
+
consumersTruncated: row.consumersTruncated, consumers });
|
|
273
|
+
previous = row.id;
|
|
274
|
+
}
|
|
275
|
+
if (Object.hasOwn(page, 'nextAfter') && page.nextAfter !== entries[entries.length - 1]?.id) return null;
|
|
276
|
+
return Object.hasOwn(page, 'nextAfter') ? { entries, nextAfter: page.nextAfter as string } : { entries };
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const readConfirmation = (value: unknown): IGatewayCertificateStoreImpactConfirmation | null => {
|
|
280
|
+
const confirmation = readExactDataRecord(value, ['routes', 'smtp', 'remoteIngress']);
|
|
281
|
+
return confirmation && typeof confirmation.routes === 'boolean' && typeof confirmation.smtp === 'boolean'
|
|
282
|
+
&& typeof confirmation.remoteIngress === 'boolean'
|
|
283
|
+
? { routes: confirmation.routes, smtp: confirmation.smtp, remoteIngress: confirmation.remoteIngress } : null;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/** The old ICert file's required fields are copied without extra fields; legacy PEM checks stay in the gateway. */
|
|
287
|
+
export const projectLegacyCertificateFile = (value: unknown): ICert | null => {
|
|
288
|
+
const file = readDataProperties(value);
|
|
289
|
+
if (!file || typeof file.id !== 'string' || typeof file.domainName !== 'string'
|
|
290
|
+
|| !isTime(file.created) || !isTime(file.validUntil)
|
|
291
|
+
|| typeof file.privateKey !== 'string' || typeof file.publicKey !== 'string'
|
|
292
|
+
|| (file.csr !== undefined && typeof file.csr !== 'string')) return null;
|
|
293
|
+
return { id: file.id, domainName: file.domainName, created: file.created,
|
|
294
|
+
validUntil: file.validUntil, privateKey: file.privateKey, publicKey: file.publicKey,
|
|
295
|
+
csr: file.csr ?? '' };
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/** The exact legacy backing for raw D; no trim, domain normalization, or preview is involved. */
|
|
299
|
+
export const deriveGatewayCertificateStoreRelatedDomainName = (rawDomainName: string): string | null =>
|
|
300
|
+
rawDomainName.startsWith('*') ? rawDomainName.replace(/^\*\.?/, '') : null;
|
|
301
|
+
|
|
302
|
+
export const projectGatewayCertificateStoreImport = (value: unknown): IGatewayCertificateStoreImport | null => {
|
|
303
|
+
const input = readDataProperties(value);
|
|
304
|
+
if (!input || !hasExactKeys(input, [
|
|
305
|
+
'certificate', 'id', 'expectedContentRevision', 'expectedUsageRevision', 'confirmImpact',
|
|
306
|
+
], ['relatedSelectorId'])) return null;
|
|
307
|
+
const hasRelatedSelectorId = Object.hasOwn(input, 'relatedSelectorId');
|
|
308
|
+
const certificate = projectLegacyCertificateFile(input.certificate);
|
|
309
|
+
const confirmImpact = readConfirmation(input.confirmImpact);
|
|
310
|
+
if (!certificate || !confirmImpact) return null;
|
|
311
|
+
if (input.id === null && !hasRelatedSelectorId
|
|
312
|
+
&& input.expectedContentRevision === null && input.expectedUsageRevision === null) {
|
|
313
|
+
return { certificate, id: null, expectedContentRevision: null, expectedUsageRevision: null, confirmImpact };
|
|
314
|
+
}
|
|
315
|
+
if (!isRevision(input.expectedContentRevision) || !isRevision(input.expectedUsageRevision)) return null;
|
|
316
|
+
if (input.id === null && hasRelatedSelectorId && isGatewayAreaRowId(input.relatedSelectorId)
|
|
317
|
+
&& deriveGatewayCertificateStoreRelatedDomainName(certificate.domainName) !== null) {
|
|
318
|
+
return { certificate, id: null, relatedSelectorId: input.relatedSelectorId,
|
|
319
|
+
expectedContentRevision: input.expectedContentRevision, expectedUsageRevision: input.expectedUsageRevision,
|
|
320
|
+
confirmImpact };
|
|
321
|
+
}
|
|
322
|
+
if (isGatewayAreaRowId(input.id) && !hasRelatedSelectorId) {
|
|
323
|
+
return { certificate, id: input.id, expectedContentRevision: input.expectedContentRevision,
|
|
324
|
+
expectedUsageRevision: input.expectedUsageRevision, confirmImpact };
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export const projectGatewayCertificateStoreTarget = (value: unknown): IGatewayCertificateStoreTarget | null => {
|
|
330
|
+
const target = readExactDataRecord(value, ['id', 'expectedContentRevision']);
|
|
331
|
+
return target && isGatewayAreaRowId(target.id) && isRevision(target.expectedContentRevision)
|
|
332
|
+
? { id: target.id, expectedContentRevision: target.expectedContentRevision } : null;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export const projectGatewayCertificateStoreDelete = (value: unknown): IGatewayCertificateStoreDelete | null => {
|
|
336
|
+
const target = readExactDataRecord(value, ['id', 'expectedContentRevision', 'expectedUsageRevision', 'confirmImpact']);
|
|
337
|
+
const confirmImpact = readConfirmation(target?.confirmImpact);
|
|
338
|
+
return target && isGatewayAreaRowId(target.id) && isRevision(target.expectedContentRevision)
|
|
339
|
+
&& isRevision(target.expectedUsageRevision) && confirmImpact
|
|
340
|
+
? { id: target.id, expectedContentRevision: target.expectedContentRevision,
|
|
341
|
+
expectedUsageRevision: target.expectedUsageRevision, confirmImpact } : null;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/** A revision fence is not a substitute for visible acknowledgement of each affected consumer. */
|
|
345
|
+
export const confirmsGatewayCertificateStoreImpact = (
|
|
346
|
+
counts: IGatewayCertificateStoreConsumerCounts, confirmation: IGatewayCertificateStoreImpactConfirmation,
|
|
347
|
+
): boolean => (counts.routes === 0 || confirmation.routes)
|
|
348
|
+
&& (counts.smtp === 0 || confirmation.smtp)
|
|
349
|
+
&& (counts.remoteIngress === 0 || confirmation.remoteIngress);
|
|
350
|
+
|
|
351
|
+
export const isGatewayCertificateStoreInventoryRefusal = (value: unknown): value is TGatewayCertificateStoreInventoryRefusal =>
|
|
352
|
+
value === 'invalid-request' || value === 'store-unavailable';
|
|
353
|
+
export const isGatewayCertificateStoreImportRefusal = (value: unknown): value is TGatewayCertificateStoreImportRefusal =>
|
|
354
|
+
isGatewayCertificateStoreInventoryRefusal(value) || value === 'stale-content' || value === 'stale-usage'
|
|
355
|
+
|| value === 'impact-confirmation-required' || value === 'outcome-unknown';
|
|
356
|
+
export const isGatewayCertificateStoreDeleteRefusal = isGatewayCertificateStoreImportRefusal;
|
|
357
|
+
export const isGatewayCertificateStorePrivateExportRefusal = (value: unknown): value is TGatewayCertificateStorePrivateExportRefusal =>
|
|
358
|
+
isGatewayCertificateStoreInventoryRefusal(value) || value === 'not-found'
|
|
359
|
+
|| value === 'not-exportable' || value === 'stale-content';
|
|
360
|
+
|
|
361
|
+
export const projectGatewayCertificateStoreInventoryResult = (
|
|
362
|
+
value: unknown, request: unknown,
|
|
363
|
+
): TGatewayCertificateStoreInventoryResult<TGatewayCertificateStoreInventoryRefusal> | null => {
|
|
364
|
+
const refusal = readExactDataRecord(value, ['ok', 'reason']);
|
|
365
|
+
if (refusal?.ok === false && isGatewayCertificateStoreInventoryRefusal(refusal.reason)) {
|
|
366
|
+
return { ok: false, reason: refusal.reason };
|
|
367
|
+
}
|
|
368
|
+
const result = readExactDataRecord(value, ['ok', 'page']);
|
|
369
|
+
const page = projectGatewayCertificateStorePage(result?.page, request);
|
|
370
|
+
return result?.ok === true && page ? { ok: true, page } : null;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/** Read a gateway write verdict without accepting credentials in a refusal. */
|
|
374
|
+
export const projectGatewayCertificateStoreWriteResult = (
|
|
375
|
+
value: unknown,
|
|
376
|
+
): TGatewayCertificateStoreWriteResult<TGatewayCertificateStoreImportRefusal> | null => {
|
|
377
|
+
const refusal = readExactDataRecord(value, ['ok', 'reason']);
|
|
378
|
+
if (refusal?.ok === false && isGatewayCertificateStoreImportRefusal(refusal.reason)) {
|
|
379
|
+
return { ok: false, reason: refusal.reason };
|
|
380
|
+
}
|
|
381
|
+
const result = readExactDataRecord(value, ['ok', 'outcome', 'id', 'contentRevision', 'usageRevision']);
|
|
382
|
+
return result?.ok === true && (result.outcome === 'written' || result.outcome === 'unchanged')
|
|
383
|
+
&& isGatewayAreaRowId(result.id) && isRevision(result.contentRevision) && isRevision(result.usageRevision)
|
|
384
|
+
? { ok: true, outcome: result.outcome, id: result.id,
|
|
385
|
+
contentRevision: result.contentRevision, usageRevision: result.usageRevision } : null;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export const projectGatewayCertificateStoreDeleteResult = (
|
|
389
|
+
value: unknown,
|
|
390
|
+
): TGatewayCertificateStoreDeleteResult<TGatewayCertificateStoreDeleteRefusal> | null => {
|
|
391
|
+
const refusal = readExactDataRecord(value, ['ok', 'reason']);
|
|
392
|
+
if (refusal?.ok === false && isGatewayCertificateStoreDeleteRefusal(refusal.reason)) {
|
|
393
|
+
return { ok: false, reason: refusal.reason };
|
|
394
|
+
}
|
|
395
|
+
const result = readExactDataRecord(value, ['ok', 'outcome']);
|
|
396
|
+
return result?.ok === true && (result.outcome === 'deleted' || result.outcome === 'unchanged')
|
|
397
|
+
? { ok: true, outcome: result.outcome } : null;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/** Credential-bearing answer: a malformed file or any extra result member is refused whole. */
|
|
401
|
+
export const projectGatewayCertificateStoreExportResult = (
|
|
402
|
+
value: unknown,
|
|
403
|
+
): TGatewayCertificateStoreExportResult<TGatewayCertificateStorePrivateExportRefusal> | null => {
|
|
404
|
+
const refusal = readExactDataRecord(value, ['ok', 'reason']);
|
|
405
|
+
if (refusal?.ok === false && isGatewayCertificateStorePrivateExportRefusal(refusal.reason)) {
|
|
406
|
+
return { ok: false, reason: refusal.reason };
|
|
407
|
+
}
|
|
408
|
+
const result = readExactDataRecord(value, ['ok', 'certificate']);
|
|
409
|
+
const certificate = projectLegacyCertificateFile(result?.certificate);
|
|
410
|
+
return result?.ok === true && certificate ? { ok: true, certificate } : null;
|
|
411
|
+
};
|