@btps/sdk 1.1.2 → 1.2.0-rc.1
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 +475 -0
- package/bin/verify-evidence-bundle.mjs +96 -0
- package/dist/client/btpsAgent.d.ts +10 -1
- package/dist/client/btpsAgent.js +117 -19
- package/dist/client/btpsClient.d.ts +53 -7
- package/dist/client/btpsClient.js +266 -137
- package/dist/client/btpsTransporter.js +2 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/libs/schema.js +92 -15
- package/dist/client/libs/timeouts.d.ts +6 -0
- package/dist/client/libs/timeouts.js +2 -1
- package/dist/client/types/index.d.ts +60 -2
- package/dist/core/authentication/BtpsAuthentication.d.ts +43 -1
- package/dist/core/authentication/BtpsAuthentication.js +152 -36
- package/dist/core/authentication/refreshSuccessor.js +47 -0
- package/dist/core/authentication/storage/InMemoryTokenStore.d.ts +17 -1
- package/dist/core/authentication/storage/InMemoryTokenStore.js +16 -4
- package/dist/core/authentication/types.d.ts +82 -0
- package/dist/core/crypto/contentKey.d.ts +34 -0
- package/dist/core/crypto/contentKey.js +64 -0
- package/dist/core/crypto/decryptVerify.d.ts +7 -1
- package/dist/core/crypto/decryptVerify.js +23 -5
- package/dist/core/crypto/decrypter-interface.d.ts +6 -0
- package/dist/core/crypto/index.d.ts +28 -3
- package/dist/core/crypto/index.js +34 -20
- package/dist/core/crypto/keyResolver.d.ts +48 -0
- package/dist/core/crypto/keyResolver.js +46 -0
- package/dist/core/crypto/pem-decrypter.d.ts +2 -0
- package/dist/core/crypto/pem-decrypter.js +13 -8
- package/dist/core/crypto/signEncrypt.d.ts +4 -1
- package/dist/core/crypto/signEncrypt.js +20 -5
- package/dist/core/crypto/types.d.ts +8 -1
- package/dist/core/delegation/BtpsDelegator.d.ts +4 -0
- package/dist/core/delegation/BtpsDelegator.js +3 -2
- package/dist/core/delegation/verifyTransporterSignature.d.ts +104 -0
- package/dist/core/delegation/verifyTransporterSignature.js +224 -0
- package/dist/core/error/constant.d.ts +41 -0
- package/dist/core/error/constant.js +60 -0
- package/dist/core/server/constants/btps-protocol.d.ts +21 -5
- package/dist/core/server/constants/btps-protocol.js +46 -8
- package/dist/core/server/constants/index.d.ts +7 -3
- package/dist/core/server/constants/index.js +19 -4
- package/dist/core/server/constants/limits.d.ts +41 -1
- package/dist/core/server/constants/limits.js +45 -2
- package/dist/core/server/constants/permissions.d.ts +38 -0
- package/dist/core/server/constants/permissions.js +38 -0
- package/dist/core/server/schemas/artifacts/agentSchema.js +2 -1
- package/dist/core/server/schemas/artifacts/artifacts.js +7 -1
- package/dist/core/server/schemas/artifacts/controlSchema.js +1 -1
- package/dist/core/server/schemas/artifacts/identityLookupSchema.js +10 -1
- package/dist/core/server/schemas/artifacts/transporterSchema.js +92 -12
- package/dist/core/server/schemas/bounded.js +41 -0
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +34522 -1421
- package/dist/core/server/schemas/btpsDocsSchema.js +355 -68
- package/dist/core/server/schemas/helpers.d.ts +9580 -0
- package/dist/core/server/schemas/helpers.js +76 -12
- package/dist/core/server/schemas/keyChainSchema.js +53 -0
- package/dist/core/server/schemas/responseSchema.js +88 -12
- package/dist/core/server/schemas/schema.js +6 -2
- package/dist/core/server/schemas/trustValues.d.ts +105 -0
- package/dist/core/server/schemas/trustValues.js +117 -0
- package/dist/core/server/types.d.ts +104 -6
- package/dist/core/storage/AbstractIdentityStore.d.ts +9 -0
- package/dist/core/storage/JsonIdentityStore.d.ts +3 -0
- package/dist/core/storage/JsonIdentityStore.js +3 -0
- package/dist/core/storage/types.d.ts +2 -0
- package/dist/core/trust/agreements.d.ts +107 -0
- package/dist/core/trust/agreements.js +116 -0
- package/dist/core/trust/evidence.d.ts +220 -0
- package/dist/core/trust/evidence.js +334 -0
- package/dist/core/trust/index.d.ts +10 -0
- package/dist/core/trust/index.js +14 -1
- package/dist/core/trust/keyRotation.d.ts +148 -0
- package/dist/core/trust/keyRotation.js +267 -0
- package/dist/core/trust/permissions.d.ts +114 -0
- package/dist/core/trust/permissions.js +115 -0
- package/dist/core/trust/shaping.d.ts +42 -0
- package/dist/core/trust/shaping.js +47 -0
- package/dist/core/trust/storage/AbstractTrustStore.d.ts +2 -1
- package/dist/core/trust/storage/JsonTrustStore.d.ts +3 -2
- package/dist/core/trust/timestamps.d.ts +49 -0
- package/dist/core/trust/timestamps.js +78 -0
- package/dist/core/trust/trustUtils.d.ts +13 -2
- package/dist/core/trust/trustUtils.js +28 -3
- package/dist/core/trust/types.d.ts +302 -2
- package/dist/core/trust/verification.d.ts +52 -0
- package/dist/core/trust/verification.js +55 -0
- package/dist/server/btpsServer.d.ts +72 -6
- package/dist/server/btpsServer.js +280 -157
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +17 -1
- package/dist/server/libs/agreementOrderCheck.d.ts +29 -0
- package/dist/server/libs/agreementOrderCheck.js +29 -0
- package/dist/server/libs/artifactTimeWindow.d.ts +2 -2
- package/dist/server/libs/artifactTimeWindow.js +2 -1
- package/dist/server/libs/detailsRequestLimit.d.ts +27 -0
- package/dist/server/libs/detailsRequestLimit.js +28 -0
- package/dist/server/libs/detailsResponseCheck.d.ts +27 -0
- package/dist/server/libs/detailsResponseCheck.js +27 -0
- package/dist/server/libs/eventChainCheck.d.ts +31 -0
- package/dist/server/libs/eventChainCheck.js +39 -0
- package/dist/server/libs/inFlightLimit.d.ts +10 -0
- package/dist/server/libs/inFlightLimit.js +7 -1
- package/dist/server/libs/index.d.ts +5 -0
- package/dist/server/libs/index.js +10 -0
- package/dist/server/libs/keyChains.d.ts +14 -0
- package/dist/server/libs/keyChains.js +17 -0
- package/dist/server/libs/wrapForAgent.d.ts +20 -0
- package/dist/server/libs/wrapForAgent.js +36 -0
- package/dist/server/types.d.ts +95 -9
- package/package.json +12 -3
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { BTPTrustRecord } from '../core/trust/index.js';
|
|
8
8
|
import type { BTPAgentArtifact, BTPServerResponse, BTPStatus, BTPTransporterArtifact } from '../core/server/types.js';
|
|
9
|
-
import type { BtpsServerOptions, ProcessedArtifact, ArtifactResCtx } from './types.js';
|
|
9
|
+
import type { BtpsServerEvents, BtpsServerOptions, ProcessedArtifact, ArtifactResCtx } from './types.js';
|
|
10
10
|
import type { AbstractTrustStore } from '../core/trust/storage/AbstractTrustStore.js';
|
|
11
11
|
import type { BTPIdentityRecord } from '../core/storage/types.js';
|
|
12
12
|
import type { AbstractIdentityStore } from '../core/storage/AbstractIdentityStore.js';
|
|
@@ -24,7 +24,16 @@ export declare class BtpsServer {
|
|
|
24
24
|
private readonly connectionTimeoutMs;
|
|
25
25
|
private readonly maxArtifactSizeKb;
|
|
26
26
|
private readonly maxInFlightPerConnection;
|
|
27
|
+
private readonly maxConsecutiveInvalidLines;
|
|
27
28
|
private readonly maxArtifactAgeSeconds;
|
|
29
|
+
private readonly signAnswers;
|
|
30
|
+
private readonly keyResolver?;
|
|
31
|
+
/** Since 1.2: how a sender's, a delegator's and an attestor's key is checked against its key chain. */
|
|
32
|
+
private readonly keyChains;
|
|
33
|
+
/** Since 1.2: what `on(…)` tells its listeners, apart from the artifact handlers. */
|
|
34
|
+
private readonly events;
|
|
35
|
+
/** With signAnswers: each connection's last answer, which the next waits for. */
|
|
36
|
+
private readonly answersOnSocket;
|
|
28
37
|
private readonly dependencies;
|
|
29
38
|
private readonly port;
|
|
30
39
|
private server;
|
|
@@ -99,6 +108,19 @@ export declare class BtpsServer {
|
|
|
99
108
|
* Core agent trust verification (non-negotiable)
|
|
100
109
|
*/
|
|
101
110
|
private verifyAgentTrust;
|
|
111
|
+
/**
|
|
112
|
+
* Since 1.2: a device's send checked by its own provider before it goes, as
|
|
113
|
+
* its receiver will check it: under a trust with permissions it names a
|
|
114
|
+
* documentType the receiver granted. A trust without them, or none, adds nothing here.
|
|
115
|
+
*/
|
|
116
|
+
private verifyDocumentSend;
|
|
117
|
+
/**
|
|
118
|
+
* Since 1.2: a details refresh a device sends, checked by its own provider
|
|
119
|
+
* before it goes, as its receiver will check it: from the user's own record
|
|
120
|
+
* of the trust, where what the user shares is what the receiver holds. A
|
|
121
|
+
* response answers a request the user received from that receiver.
|
|
122
|
+
*/
|
|
123
|
+
private verifyDetailsSend;
|
|
102
124
|
/**
|
|
103
125
|
* Verifies attestation signatures for delegated artifacts
|
|
104
126
|
*
|
|
@@ -170,6 +192,32 @@ export declare class BtpsServer {
|
|
|
170
192
|
* too. Other artifacts pass.
|
|
171
193
|
*/
|
|
172
194
|
private verifyEventRelation;
|
|
195
|
+
/**
|
|
196
|
+
* Since 1.2: a details refresh, on an active trust in either direction, read
|
|
197
|
+
* from the receiver's own record of it: its names against what each side
|
|
198
|
+
* holds, and a response against a request it knows. Nothing is decrypted.
|
|
199
|
+
*/
|
|
200
|
+
private verifyDetailsTrust;
|
|
201
|
+
/**
|
|
202
|
+
* Since 1.2: tell listeners of a details refresh only once every check has
|
|
203
|
+
* passed, the platform's own middleware included: a request that arrived,
|
|
204
|
+
* or a response one of this provider's devices sends.
|
|
205
|
+
*/
|
|
206
|
+
private tellDetails;
|
|
207
|
+
/**
|
|
208
|
+
* Since 1.2: tell every listener, each on its own: one that throws is warned
|
|
209
|
+
* about and never stops the others or the artifact.
|
|
210
|
+
*/
|
|
211
|
+
private tell;
|
|
212
|
+
/**
|
|
213
|
+
* Since 1.2: listen for `detailsRequested`, emitted when a details request
|
|
214
|
+
* arrives and passes its checks, and `detailsShared`, emitted when one of
|
|
215
|
+
* this provider's devices sends a details response that passes them: who
|
|
216
|
+
* asked or gave whom which details, and when.
|
|
217
|
+
*/
|
|
218
|
+
on<K extends keyof BtpsServerEvents>(event: K, listener: BtpsServerEvents[K]): void;
|
|
219
|
+
/** Since 1.2: stop listening. */
|
|
220
|
+
off<K extends keyof BtpsServerEvents>(event: K, listener: BtpsServerEvents[K]): void;
|
|
173
221
|
/**
|
|
174
222
|
* Core trust verification (non-negotiable)
|
|
175
223
|
*/
|
|
@@ -208,6 +256,12 @@ export declare class BtpsServer {
|
|
|
208
256
|
* metrics do, so it takes nothing.
|
|
209
257
|
*/
|
|
210
258
|
private acceptsArtifacts;
|
|
259
|
+
/**
|
|
260
|
+
* Whether the implementor takes errors into its own logs, through the
|
|
261
|
+
* onError option or onError middleware. Then the server does not also write
|
|
262
|
+
* them to console.error.
|
|
263
|
+
*/
|
|
264
|
+
private takesErrors;
|
|
211
265
|
private noHandlerWarning;
|
|
212
266
|
/**
|
|
213
267
|
* Core message processing (non-negotiable)
|
|
@@ -232,19 +286,24 @@ export declare class BtpsServer {
|
|
|
232
286
|
*
|
|
233
287
|
* @param error The encountered error
|
|
234
288
|
* @param socket The TLS socket associated with the connection
|
|
235
|
-
* @param action 'destroy' (the default) tears the socket down at once; 'end' sends the error and closes gently
|
|
289
|
+
* @param action 'destroy' (the default) tears the socket down at once; 'end' sends the error and closes gently;
|
|
290
|
+
* 'answer' sends the error and leaves the connection open
|
|
236
291
|
*/
|
|
237
292
|
private handleOnSocketError;
|
|
238
293
|
/**
|
|
239
294
|
* Sends a BTPS error response to the client
|
|
240
295
|
*/
|
|
241
296
|
/**
|
|
242
|
-
* What a sender is told about an error. A BTPS error
|
|
243
|
-
* its code; a numeric code
|
|
244
|
-
*
|
|
245
|
-
*
|
|
297
|
+
* What a sender is told about an error. A BTPS error, from its constant,
|
|
298
|
+
* carries its status and its code; a numeric code middleware sends with
|
|
299
|
+
* `res.sendError` goes as given. Anything else, a thrown error with a code
|
|
300
|
+
* of its own included, is internal: a generic 500, so no internal detail
|
|
301
|
+
* ever reaches the wire. The full error stays with the server, keyed by the
|
|
302
|
+
* response id. Since 1.2, a 429 also carries its meta.retryAfter, in whole
|
|
303
|
+
* seconds; nothing else from meta, and never cause.
|
|
246
304
|
*/
|
|
247
305
|
private wireStatus;
|
|
306
|
+
private errorStatus;
|
|
248
307
|
private sendBtpsError;
|
|
249
308
|
/**
|
|
250
309
|
* Sends a BTPS response to the client
|
|
@@ -252,6 +311,13 @@ export declare class BtpsServer {
|
|
|
252
311
|
* @param artifact - The artifact to send
|
|
253
312
|
*/
|
|
254
313
|
private sendBtpsResponse;
|
|
314
|
+
/**
|
|
315
|
+
* The answer signed as this server, under its own selector, so a device that
|
|
316
|
+
* requires its server's signature can read it, a refusal included. Unsigned
|
|
317
|
+
* when signing fails, which the failure reports to onError.
|
|
318
|
+
*/
|
|
319
|
+
private signAnswer;
|
|
320
|
+
private writeAnswer;
|
|
255
321
|
/**
|
|
256
322
|
* Returns the BTPS protocol version
|
|
257
323
|
*/
|