@btps/sdk 1.2.0-rc.2 → 1.2.0-rc.3.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 +87 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +7 -1
- package/dist/core/crypto/decryptVerify.js +6 -2
- package/dist/core/crypto/types.d.ts +3 -0
- package/dist/core/server/constants/btps-protocol.js +4 -2
- package/dist/core/server/constants/currency.d.ts +6 -0
- package/dist/core/server/constants/currency.js +27 -2
- package/dist/core/server/constants/limits.d.ts +25 -0
- package/dist/core/server/constants/limits.js +27 -0
- package/dist/core/server/constants/permissions.d.ts +1 -1
- package/dist/core/server/schemas/boundView.d.ts +9 -0
- package/dist/core/server/schemas/boundView.js +28 -0
- package/dist/core/server/schemas/boundViewBindings.d.ts +40 -0
- package/dist/core/server/schemas/boundViewBindings.js +128 -0
- package/dist/core/server/schemas/boundViewChecks.d.ts +49 -0
- package/dist/core/server/schemas/boundViewChecks.js +344 -0
- package/dist/core/server/schemas/boundViewSchema.d.ts +1637 -0
- package/dist/core/server/schemas/boundViewSchema.js +186 -0
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +36528 -9259
- package/dist/core/server/schemas/btpsDocsSchema.js +48 -35
- package/dist/core/server/schemas/helpers.d.ts +11119 -2337
- package/dist/server/btpsServer.d.ts +2 -1
- package/dist/server/btpsServer.js +10 -2
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +9 -1
- package/dist/server/types.d.ts +23 -26
- package/package.json +14 -1
|
@@ -6,6 +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 BTPBoundViewResult } from '../core/server/schemas/boundViewChecks.js';
|
|
9
10
|
import type { BtpsServerEvents, BtpsServerOptions, ProcessedArtifact, ArtifactResCtx } from './types.js';
|
|
10
11
|
import type { AbstractTrustStore } from '../core/trust/storage/AbstractTrustStore.js';
|
|
11
12
|
import type { BTPIdentityRecord } from '../core/storage/types.js';
|
|
@@ -350,7 +351,7 @@ export declare class BtpsServer {
|
|
|
350
351
|
onIncomingArtifact(type: 'Agent', handler: (artifact: BTPAgentArtifact & {
|
|
351
352
|
respondNow: boolean;
|
|
352
353
|
}, resCtx: ArtifactResCtx) => void): void;
|
|
353
|
-
onIncomingArtifact(type: 'Transporter', handler: (artifact: BTPTransporterArtifact) => void | Promise<void>): void;
|
|
354
|
+
onIncomingArtifact(type: 'Transporter', handler: (artifact: BTPTransporterArtifact, boundView?: BTPBoundViewResult) => void | Promise<void>): void;
|
|
354
355
|
/**
|
|
355
356
|
* The server's identity and, when it is configured with a PEM key pair, its
|
|
356
357
|
* public key. Never the private key: middleware is handed this server, and the
|
|
@@ -61,6 +61,9 @@ import {
|
|
|
61
61
|
isValidIdentity
|
|
62
62
|
} from "../core/utils/index.js";
|
|
63
63
|
import { detailsOwed } from "../core/server/schemas/artifacts/transporterSchema.js";
|
|
64
|
+
import {
|
|
65
|
+
boundViewResultOf
|
|
66
|
+
} from "../core/server/schemas/boundViewChecks.js";
|
|
64
67
|
import { BTPErrorException, transformToBTPErrorException } from "../core/error/index.js";
|
|
65
68
|
import {
|
|
66
69
|
AGENT_TRANSPORTER_ACTIONS,
|
|
@@ -788,8 +791,10 @@ class BtpsServer {
|
|
|
788
791
|
respondNow
|
|
789
792
|
}), this.isResponseSent(resCtx)) return !0;
|
|
790
793
|
} else {
|
|
794
|
+
const boundView = artifact.type === "BTPS_DOC" ? boundViewResultOf(artifact.document) : void 0;
|
|
795
|
+
boundView && (data = { ...data, boundView });
|
|
791
796
|
const listeners = this.emitter.listeners("transporterArtifact");
|
|
792
|
-
await Promise.all(listeners.map(async (listener) => listener(artifact)));
|
|
797
|
+
await Promise.all(listeners.map(async (listener) => listener(artifact, boundView)));
|
|
793
798
|
}
|
|
794
799
|
return await this._forwardArtifact(data), !1;
|
|
795
800
|
}
|
|
@@ -967,7 +972,10 @@ class BtpsServer {
|
|
|
967
972
|
type === "Agent" ? this.emitter.on(
|
|
968
973
|
"agentArtifact",
|
|
969
974
|
handler
|
|
970
|
-
) : this.emitter.on(
|
|
975
|
+
) : this.emitter.on(
|
|
976
|
+
"transporterArtifact",
|
|
977
|
+
handler
|
|
978
|
+
);
|
|
971
979
|
}
|
|
972
980
|
getServerIdentity() {
|
|
973
981
|
const { identity } = this.serverIdentity;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from '../core/server/constants/index.js';
|
|
|
9
9
|
export * from '../core/server/helpers/index.js';
|
|
10
10
|
export { BtpsServer } from './btpsServer.js';
|
|
11
11
|
export { lifecycleEventChainProblem, lifecycleEventChainReference, lifecycleEventSenderProblem, trustRequestProblem, trustResponseProblem, } from '../core/server/schemas/helpers.js';
|
|
12
|
+
export { checkBoundView, writtenValue, CONTRAST_WORK_LIMIT, type BTPBoundViewResult, type BTPBoundViewProblem, type BTPBoundViewCheck, } from '../core/server/schemas/boundViewChecks.js';
|
|
12
13
|
export { wrapForAgent } from './libs/wrapForAgent.js';
|
|
13
14
|
export { verifyTransporterSignature } from '../core/delegation/verifyTransporterSignature.js';
|
|
14
15
|
export * from './types.js';
|
package/dist/server/index.js
CHANGED
|
@@ -16,16 +16,24 @@ import {
|
|
|
16
16
|
trustRequestProblem,
|
|
17
17
|
trustResponseProblem
|
|
18
18
|
} from "../core/server/schemas/helpers.js";
|
|
19
|
+
import {
|
|
20
|
+
checkBoundView,
|
|
21
|
+
writtenValue,
|
|
22
|
+
CONTRAST_WORK_LIMIT
|
|
23
|
+
} from "../core/server/schemas/boundViewChecks.js";
|
|
19
24
|
import { wrapForAgent } from "./libs/wrapForAgent.js";
|
|
20
25
|
import { verifyTransporterSignature } from "../core/delegation/verifyTransporterSignature.js";
|
|
21
26
|
export * from "./types.js";
|
|
22
27
|
export {
|
|
23
28
|
BtpsServer,
|
|
29
|
+
CONTRAST_WORK_LIMIT,
|
|
30
|
+
checkBoundView,
|
|
24
31
|
lifecycleEventChainProblem,
|
|
25
32
|
lifecycleEventChainReference,
|
|
26
33
|
lifecycleEventSenderProblem,
|
|
27
34
|
trustRequestProblem,
|
|
28
35
|
trustResponseProblem,
|
|
29
36
|
verifyTransporterSignature,
|
|
30
|
-
wrapForAgent
|
|
37
|
+
wrapForAgent,
|
|
38
|
+
writtenValue
|
|
31
39
|
};
|
package/dist/server/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ import type { Signer } from '../core/crypto/signer-interface.js';
|
|
|
16
16
|
import type { BtpsKeyResolver } from '../core/crypto/keyResolver.js';
|
|
17
17
|
import type { z } from 'zod';
|
|
18
18
|
import type { BtpAgreementDocSchema, BtpLetterDocSchema, BtpPayslipDocSchema } from '../core/server/schemas/btpsDocsSchema.js';
|
|
19
|
+
import type { BTPBoundView } from '../core/server/schemas/boundViewSchema.js';
|
|
20
|
+
import type { BTPBoundViewResult } from '../core/server/schemas/boundViewChecks.js';
|
|
19
21
|
import type { BTPEntityType } from '../core/server/types.js';
|
|
20
22
|
export interface BtpsTlsOptions extends TlsOptions {
|
|
21
23
|
cert: string;
|
|
@@ -135,6 +137,10 @@ type WithRespondNow<K extends string, T> = K extends 'agent' ? {
|
|
|
135
137
|
artifact: T;
|
|
136
138
|
type: K;
|
|
137
139
|
respondNow: boolean;
|
|
140
|
+
} : K extends 'transporter' ? {
|
|
141
|
+
artifact: T;
|
|
142
|
+
type: K;
|
|
143
|
+
boundView?: BTPBoundViewResult;
|
|
138
144
|
} : {
|
|
139
145
|
artifact: T;
|
|
140
146
|
type: K;
|
|
@@ -242,8 +248,12 @@ export interface BTPInvoiceDoc {
|
|
|
242
248
|
amount: number;
|
|
243
249
|
currency: CurrencyCode;
|
|
244
250
|
};
|
|
251
|
+
/** Since 1.2: the total before tax, and the tax, in the currency of `totalAmount` */
|
|
252
|
+
subtotalAmount?: BTPInvoiceDoc['totalAmount'];
|
|
253
|
+
taxAmount?: BTPInvoiceDoc['totalAmount'];
|
|
245
254
|
lineItems: {
|
|
246
255
|
columns: string[];
|
|
256
|
+
roles?: Record<string, BTPLineRole>;
|
|
247
257
|
rows: Array<Record<string, string | number>>;
|
|
248
258
|
};
|
|
249
259
|
issuer?: {
|
|
@@ -253,6 +263,10 @@ export interface BTPInvoiceDoc {
|
|
|
253
263
|
address?: string;
|
|
254
264
|
identifiers?: Record<string, string>;
|
|
255
265
|
};
|
|
266
|
+
/** Since 1.2: who the document is for, as the sender names them */
|
|
267
|
+
recipient?: {
|
|
268
|
+
name: string;
|
|
269
|
+
};
|
|
256
270
|
paymentLink?: {
|
|
257
271
|
linkText: string;
|
|
258
272
|
url: string;
|
|
@@ -263,6 +277,8 @@ export interface BTPInvoiceDoc {
|
|
|
263
277
|
attachments?: BTPAttachment[];
|
|
264
278
|
references?: BTPDocReference[];
|
|
265
279
|
template?: BTPTemplate;
|
|
280
|
+
/** Since 1.2: its BoundView, a signed canvas whose facts are drawn from these fields */
|
|
281
|
+
boundView?: BTPBoundView;
|
|
266
282
|
metadata?: Record<string, unknown>;
|
|
267
283
|
}
|
|
268
284
|
/**
|
|
@@ -280,34 +296,16 @@ export type BTPDiscount = {
|
|
|
280
296
|
} | {
|
|
281
297
|
percent: number;
|
|
282
298
|
};
|
|
283
|
-
/** A template by
|
|
299
|
+
/** A template by name, with free data: the 1.1 form, in any version. A receiver draws nothing from it. */
|
|
284
300
|
export interface BTPTemplate {
|
|
285
301
|
name: string;
|
|
286
|
-
data:
|
|
287
|
-
version?: string;
|
|
288
|
-
sha256?: string;
|
|
289
|
-
source?: string;
|
|
290
|
-
logo?: {
|
|
291
|
-
sha256: string;
|
|
292
|
-
source: string;
|
|
293
|
-
};
|
|
294
|
-
values?: BTPTemplateValues;
|
|
295
|
-
[key: string]: unknown;
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Since 1.2: what a letter template's signature slots show, from the sender and
|
|
300
|
-
* signed with the document. A drawn signature is integer strokes, `[x, y, x, y, …]`,
|
|
301
|
-
* on a canvas 1000 by 300: data a receiver draws itself, never markup.
|
|
302
|
-
*/
|
|
303
|
-
export interface BTPTemplateValues {
|
|
304
|
-
'signature.typed'?: string;
|
|
305
|
-
'signature.name'?: string;
|
|
306
|
-
'signature.title'?: string;
|
|
307
|
-
'signature.drawn'?: {
|
|
308
|
-
strokes: number[][];
|
|
309
|
-
};
|
|
302
|
+
data: Record<string, unknown>;
|
|
310
303
|
}
|
|
304
|
+
/** Since 1.2: what a line-item column holds. */
|
|
305
|
+
export type BTPLineRole = 'description' | 'quantity' | 'unitPrice' | 'discount' | 'tax' | 'lineTotal';
|
|
306
|
+
/** Since 1.2: a letter's or an agreement's sign-off. Decoration: it proves no agreement. */
|
|
307
|
+
export type BTPSignatory = NonNullable<BTPLetterDoc['signatory']>;
|
|
308
|
+
export type { BTPBoundView, BTPBoundViewElement, BTPBoundViewFont, } from '../core/server/schemas/boundViewSchema.js';
|
|
311
309
|
/** Proof of a payment: the invoice without what asks for payment, plus `payment`. */
|
|
312
310
|
export interface BTPReceiptDoc extends Omit<BTPInvoiceDoc, 'type' | 'dueAt' | 'paymentLink' | 'lineItems'> {
|
|
313
311
|
type: 'receipt';
|
|
@@ -327,4 +325,3 @@ export type BTPLetterDoc = z.infer<typeof BtpLetterDocSchema>;
|
|
|
327
325
|
export type BTPAgreementDoc = z.infer<typeof BtpAgreementDocSchema>;
|
|
328
326
|
/** What a `BTPS_DOC` carries. */
|
|
329
327
|
export type BTPDocument = BTPInvoiceDoc | BTPReceiptDoc | BTPPayslipDoc | BTPLetterDoc | BTPAgreementDoc;
|
|
330
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btps/sdk",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.3.1",
|
|
4
4
|
"description": "The reference implementation of BTPS, the Billing Trust Protocol Secure: signed, encrypted, trust-first delivery of invoices and documents between organisations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"btps",
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
},
|
|
64
64
|
"./storage": {
|
|
65
65
|
"import": "./dist/core/storage/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./boundview": {
|
|
68
|
+
"import": "./dist/core/server/schemas/boundView.js"
|
|
66
69
|
}
|
|
67
70
|
},
|
|
68
71
|
"bin": {
|
|
@@ -94,6 +97,13 @@
|
|
|
94
97
|
"build:strip-comments": "node build/stripComments.mjs"
|
|
95
98
|
},
|
|
96
99
|
"devDependencies": {
|
|
100
|
+
"@fontsource/arimo": "^5.3.0",
|
|
101
|
+
"@fontsource/caladea": "^5.3.0",
|
|
102
|
+
"@fontsource/carlito": "^5.3.0",
|
|
103
|
+
"@fontsource/caveat": "^5.3.0",
|
|
104
|
+
"@fontsource/cousine": "^5.3.0",
|
|
105
|
+
"@fontsource/tinos": "^5.3.0",
|
|
106
|
+
"@resvg/resvg-wasm": "2.6.2",
|
|
97
107
|
"@types/lodash": "^4",
|
|
98
108
|
"@types/proper-lockfile": "^4",
|
|
99
109
|
"@types/split2": "^4",
|
|
@@ -114,7 +124,9 @@
|
|
|
114
124
|
"eslint-plugin-import": "^2.29.0",
|
|
115
125
|
"fast-glob": "^3.3.3",
|
|
116
126
|
"nodemon": "^3.0.0",
|
|
127
|
+
"opentype.js": "^2.0.0",
|
|
117
128
|
"ora": "^8.2.0",
|
|
129
|
+
"playwright-core": "^1.56.0",
|
|
118
130
|
"prettier": "^3.0.0",
|
|
119
131
|
"rimraf": "^6.0.1",
|
|
120
132
|
"strip-comments": "^2.0.1",
|
|
@@ -128,6 +140,7 @@
|
|
|
128
140
|
"@humanwhocodes/momoa": "^3.3.13",
|
|
129
141
|
"asn1js": "^4.0.0",
|
|
130
142
|
"canonicalize": "^5.1.0",
|
|
143
|
+
"fflate": "^0.8.3",
|
|
131
144
|
"lodash": "^4.17.21",
|
|
132
145
|
"pkijs": "^4.0.1",
|
|
133
146
|
"proper-lockfile": "^4.1.2",
|