@btps/sdk 1.1.3 → 1.2.0-rc.2
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 +461 -0
- package/bin/verify-evidence-bundle.mjs +96 -0
- package/dist/client/btpsAgent.d.ts +10 -1
- package/dist/client/btpsAgent.js +116 -18
- package/dist/client/btpsClient.d.ts +53 -7
- package/dist/client/btpsClient.js +265 -147
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/libs/schema.js +78 -13
- package/dist/client/libs/timeouts.d.ts +6 -0
- package/dist/client/libs/timeouts.js +2 -1
- package/dist/client/types/index.d.ts +54 -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 +12 -0
- package/dist/core/crypto/index.js +7 -1
- 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 +39 -0
- package/dist/core/error/constant.js +55 -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 +18 -0
- package/dist/core/server/constants/limits.js +19 -1
- 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 +99 -12
- package/dist/core/server/schemas/bounded.js +2 -2
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +36009 -1083
- package/dist/core/server/schemas/btpsDocsSchema.js +305 -42
- package/dist/core/server/schemas/helpers.d.ts +10090 -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 +52 -9
- package/dist/core/server/schemas/schema.js +3 -1
- 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 +312 -2
- package/dist/core/trust/verification.d.ts +52 -0
- package/dist/core/trust/verification.js +55 -0
- package/dist/server/btpsServer.d.ts +79 -5
- package/dist/server/btpsServer.js +297 -145
- 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 +103 -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,18 @@ 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: what each of this server's identities is, as its platform says. */
|
|
32
|
+
private readonly entityTypeOf?;
|
|
33
|
+
/** Since 1.2: how a sender's, a delegator's and an attestor's key is checked against its key chain. */
|
|
34
|
+
private readonly keyChains;
|
|
35
|
+
/** Since 1.2: what `on(…)` tells its listeners, apart from the artifact handlers. */
|
|
36
|
+
private readonly events;
|
|
37
|
+
/** With signAnswers: each connection's last answer, which the next waits for. */
|
|
38
|
+
private readonly answersOnSocket;
|
|
28
39
|
private readonly dependencies;
|
|
29
40
|
private readonly port;
|
|
30
41
|
private server;
|
|
@@ -99,6 +110,19 @@ export declare class BtpsServer {
|
|
|
99
110
|
* Core agent trust verification (non-negotiable)
|
|
100
111
|
*/
|
|
101
112
|
private verifyAgentTrust;
|
|
113
|
+
/**
|
|
114
|
+
* Since 1.2: a device's send checked by its own provider before it goes, as
|
|
115
|
+
* its receiver will check it: under a trust with permissions it names a
|
|
116
|
+
* documentType the receiver granted. A trust without them, or none, adds nothing here.
|
|
117
|
+
*/
|
|
118
|
+
private verifyDocumentSend;
|
|
119
|
+
/**
|
|
120
|
+
* Since 1.2: a details refresh a device sends, checked by its own provider
|
|
121
|
+
* before it goes, as its receiver will check it: from the user's own record
|
|
122
|
+
* of the trust, where what the user shares is what the receiver holds. A
|
|
123
|
+
* response answers a request the user received from that receiver.
|
|
124
|
+
*/
|
|
125
|
+
private verifyDetailsSend;
|
|
102
126
|
/**
|
|
103
127
|
* Verifies attestation signatures for delegated artifacts
|
|
104
128
|
*
|
|
@@ -170,10 +194,43 @@ export declare class BtpsServer {
|
|
|
170
194
|
* too. Other artifacts pass.
|
|
171
195
|
*/
|
|
172
196
|
private verifyEventRelation;
|
|
197
|
+
/**
|
|
198
|
+
* Since 1.2: a details refresh, on an active trust in either direction, read
|
|
199
|
+
* from the receiver's own record of it: its names against what each side
|
|
200
|
+
* holds, and a response against a request it knows. Nothing is decrypted.
|
|
201
|
+
*/
|
|
202
|
+
private verifyDetailsTrust;
|
|
203
|
+
/**
|
|
204
|
+
* Since 1.2: tell listeners of a details refresh only once every check has
|
|
205
|
+
* passed, the platform's own middleware included: a request that arrived,
|
|
206
|
+
* or a response one of this provider's devices sends.
|
|
207
|
+
*/
|
|
208
|
+
private tellDetails;
|
|
209
|
+
/**
|
|
210
|
+
* Since 1.2: tell every listener, each on its own: one that throws is warned
|
|
211
|
+
* about and never stops the others or the artifact.
|
|
212
|
+
*/
|
|
213
|
+
private tell;
|
|
214
|
+
/**
|
|
215
|
+
* Since 1.2: listen for `detailsRequested`, emitted when a details request
|
|
216
|
+
* arrives and passes its checks, and `detailsShared`, emitted when one of
|
|
217
|
+
* this provider's devices sends a details response that passes them: who
|
|
218
|
+
* asked or gave whom which details, and when.
|
|
219
|
+
*/
|
|
220
|
+
on<K extends keyof BtpsServerEvents>(event: K, listener: BtpsServerEvents[K]): void;
|
|
221
|
+
/** Since 1.2: stop listening. */
|
|
222
|
+
off<K extends keyof BtpsServerEvents>(event: K, listener: BtpsServerEvents[K]): void;
|
|
173
223
|
/**
|
|
174
224
|
* Core trust verification (non-negotiable)
|
|
175
225
|
*/
|
|
176
226
|
private verifyTrust;
|
|
227
|
+
/**
|
|
228
|
+
* Since 1.2: a person's trust request that asks for details without giving its own. It is
|
|
229
|
+
* refused unless its receiver is an organisation, as `entityTypeOf` says: a person asking an
|
|
230
|
+
* organisation gives nothing in return. A receiver this server cannot say is held to be a
|
|
231
|
+
* person. An organisation's request is held to it by the schema, whoever receives it.
|
|
232
|
+
*/
|
|
233
|
+
private detailsOwedByPerson;
|
|
177
234
|
/**
|
|
178
235
|
* A trust records how its artifacts are sent: 'encrypted' refuses one sent in
|
|
179
236
|
* the clear, 'unencrypted' one the receiver did not agree to decrypt, and
|
|
@@ -208,6 +265,12 @@ export declare class BtpsServer {
|
|
|
208
265
|
* metrics do, so it takes nothing.
|
|
209
266
|
*/
|
|
210
267
|
private acceptsArtifacts;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the implementor takes errors into its own logs, through the
|
|
270
|
+
* onError option or onError middleware. Then the server does not also write
|
|
271
|
+
* them to console.error.
|
|
272
|
+
*/
|
|
273
|
+
private takesErrors;
|
|
211
274
|
private noHandlerWarning;
|
|
212
275
|
/**
|
|
213
276
|
* Core message processing (non-negotiable)
|
|
@@ -240,12 +303,16 @@ export declare class BtpsServer {
|
|
|
240
303
|
* Sends a BTPS error response to the client
|
|
241
304
|
*/
|
|
242
305
|
/**
|
|
243
|
-
* What a sender is told about an error. A BTPS error
|
|
244
|
-
* its code; a numeric code
|
|
245
|
-
*
|
|
246
|
-
*
|
|
306
|
+
* What a sender is told about an error. A BTPS error, from its constant,
|
|
307
|
+
* carries its status and its code; a numeric code middleware sends with
|
|
308
|
+
* `res.sendError` goes as given. Anything else, a thrown error with a code
|
|
309
|
+
* of its own included, is internal: a generic 500, so no internal detail
|
|
310
|
+
* ever reaches the wire. The full error stays with the server, keyed by the
|
|
311
|
+
* response id. Since 1.2, a 429 also carries its meta.retryAfter, in whole
|
|
312
|
+
* seconds; nothing else from meta, and never cause.
|
|
247
313
|
*/
|
|
248
314
|
private wireStatus;
|
|
315
|
+
private errorStatus;
|
|
249
316
|
private sendBtpsError;
|
|
250
317
|
/**
|
|
251
318
|
* Sends a BTPS response to the client
|
|
@@ -253,6 +320,13 @@ export declare class BtpsServer {
|
|
|
253
320
|
* @param artifact - The artifact to send
|
|
254
321
|
*/
|
|
255
322
|
private sendBtpsResponse;
|
|
323
|
+
/**
|
|
324
|
+
* The answer signed as this server, under its own selector, so a device that
|
|
325
|
+
* requires its server's signature can read it, a refusal included. Unsigned
|
|
326
|
+
* when signing fails, which the failure reports to onError.
|
|
327
|
+
*/
|
|
328
|
+
private signAnswer;
|
|
329
|
+
private writeAnswer;
|
|
256
330
|
/**
|
|
257
331
|
* Returns the BTPS protocol version
|
|
258
332
|
*/
|