@btps/sdk 1.1.1 → 1.1.3
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 +77 -0
- package/dist/client/btpsAgent.js +1 -1
- package/dist/client/btpsClient.d.ts +33 -20
- package/dist/client/btpsClient.js +97 -72
- package/dist/client/btpsTransporter.js +2 -1
- package/dist/client/libs/schema.js +17 -5
- package/dist/client/types/index.d.ts +6 -0
- package/dist/core/crypto/index.d.ts +16 -3
- package/dist/core/crypto/index.js +27 -19
- package/dist/core/error/constant.d.ts +2 -0
- package/dist/core/error/constant.js +5 -0
- package/dist/core/server/constants/limits.d.ts +23 -1
- package/dist/core/server/constants/limits.js +26 -1
- package/dist/core/server/schemas/bounded.js +41 -0
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +545 -545
- package/dist/core/server/schemas/btpsDocsSchema.js +56 -27
- package/dist/core/server/schemas/responseSchema.js +37 -4
- package/dist/core/server/schemas/schema.js +3 -1
- package/dist/server/btpsServer.d.ts +2 -1
- package/dist/server/btpsServer.js +17 -14
- package/package.json +1 -1
|
@@ -59,6 +59,8 @@ export declare const BTP_ERROR_ARTIFACT_TOO_LARGE: BTPError;
|
|
|
59
59
|
export declare const BTP_ERROR_VERSION_UNSUPPORTED: BTPError;
|
|
60
60
|
export declare const BTP_ERROR_PRIVACY_TYPE: BTPError;
|
|
61
61
|
export declare const BTP_ERROR_ARTIFACT_NOT_ACCEPTED: BTPError;
|
|
62
|
+
/** For a store (trust, identity) to throw when it is briefly unreachable: the sender may send again later. */
|
|
63
|
+
export declare const BTP_ERROR_TEMPORARILY_UNAVAILABLE: BTPError;
|
|
62
64
|
export declare const BTP_ERROR_SOCKET_TIMEOUT: BTPError;
|
|
63
65
|
export declare const BTP_ERROR_AUTHENTICATION_INVALID: BTPError;
|
|
64
66
|
export declare const BTP_ERROR_TIMEOUT: BTPError;
|
|
@@ -134,6 +134,10 @@ const BTP_ERROR_SOCKET_CLOSED = {
|
|
|
134
134
|
code: "BTP_ERROR_ARTIFACT_NOT_ACCEPTED",
|
|
135
135
|
message: "This server does not accept this kind of artifact",
|
|
136
136
|
status: 503
|
|
137
|
+
}, BTP_ERROR_TEMPORARILY_UNAVAILABLE = {
|
|
138
|
+
code: "BTP_ERROR_TEMPORARILY_UNAVAILABLE",
|
|
139
|
+
message: "The server cannot take this artifact right now. Send it again later",
|
|
140
|
+
status: 503
|
|
137
141
|
}, BTP_ERROR_SOCKET_TIMEOUT = {
|
|
138
142
|
code: "BTP_ERROR_SOCKET_TIMEOUT",
|
|
139
143
|
message: "Socket timeout. Connection closed",
|
|
@@ -180,6 +184,7 @@ export {
|
|
|
180
184
|
BTP_ERROR_SIG_VERIFICATION,
|
|
181
185
|
BTP_ERROR_SOCKET_CLOSED,
|
|
182
186
|
BTP_ERROR_SOCKET_TIMEOUT,
|
|
187
|
+
BTP_ERROR_TEMPORARILY_UNAVAILABLE,
|
|
183
188
|
BTP_ERROR_TIMEOUT,
|
|
184
189
|
BTP_ERROR_TRUST_ALREADY_ACTIVE,
|
|
185
190
|
BTP_ERROR_TRUST_BLOCKED,
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* The longest each field may be
|
|
8
|
+
* The longest each field may be: a text in characters, a list in entries, a
|
|
9
|
+
* record in keys. The protocol fixes these,
|
|
9
10
|
* so every provider accepts the same documents: a provider may be stricter
|
|
10
11
|
* in its own middleware, but cannot raise them. They are raised only by a
|
|
11
12
|
* protocol version.
|
|
@@ -38,6 +39,10 @@ export declare const BTPS_FIELD_LIMITS: {
|
|
|
38
39
|
};
|
|
39
40
|
readonly payslip: {
|
|
40
41
|
readonly code: 64;
|
|
42
|
+
readonly earnings: 200;
|
|
43
|
+
readonly deductions: 200;
|
|
44
|
+
readonly contributions: 200;
|
|
45
|
+
readonly leave: 200;
|
|
41
46
|
};
|
|
42
47
|
readonly letter: {
|
|
43
48
|
readonly title: 200;
|
|
@@ -45,6 +50,23 @@ export declare const BTPS_FIELD_LIMITS: {
|
|
|
45
50
|
readonly attachments: 10;
|
|
46
51
|
readonly references: 20;
|
|
47
52
|
};
|
|
53
|
+
readonly attachments: 10;
|
|
54
|
+
readonly references: 20;
|
|
55
|
+
readonly lineItems: {
|
|
56
|
+
readonly rows: 10000;
|
|
57
|
+
readonly columns: 50;
|
|
58
|
+
};
|
|
59
|
+
readonly query: {
|
|
60
|
+
readonly in: 1000;
|
|
61
|
+
readonly notIn: 1000;
|
|
62
|
+
readonly results: 1000;
|
|
63
|
+
};
|
|
64
|
+
readonly ids: 1000;
|
|
65
|
+
readonly agentInfoValues: 50;
|
|
66
|
+
readonly trustRecord: {
|
|
67
|
+
readonly keyHistory: 1000;
|
|
68
|
+
};
|
|
69
|
+
readonly recordKeys: 100;
|
|
48
70
|
readonly documentId: 100;
|
|
49
71
|
readonly referenceType: 64;
|
|
50
72
|
};
|
|
@@ -33,7 +33,11 @@ const BTPS_FIELD_LIMITS = {
|
|
|
33
33
|
},
|
|
34
34
|
payslip: {
|
|
35
35
|
|
|
36
|
-
code: 64
|
|
36
|
+
code: 64,
|
|
37
|
+
earnings: 200,
|
|
38
|
+
deductions: 200,
|
|
39
|
+
contributions: 200,
|
|
40
|
+
leave: 200
|
|
37
41
|
},
|
|
38
42
|
letter: {
|
|
39
43
|
title: 200,
|
|
@@ -42,6 +46,27 @@ const BTPS_FIELD_LIMITS = {
|
|
|
42
46
|
references: 20
|
|
43
47
|
},
|
|
44
48
|
|
|
49
|
+
attachments: 10,
|
|
50
|
+
references: 20,
|
|
51
|
+
|
|
52
|
+
lineItems: {
|
|
53
|
+
rows: 1e4,
|
|
54
|
+
columns: 50
|
|
55
|
+
},
|
|
56
|
+
query: {
|
|
57
|
+
in: 1e3,
|
|
58
|
+
notIn: 1e3,
|
|
59
|
+
results: 1e3
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
ids: 1e3,
|
|
63
|
+
agentInfoValues: 50,
|
|
64
|
+
trustRecord: {
|
|
65
|
+
keyHistory: 1e3
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
recordKeys: 100,
|
|
69
|
+
|
|
45
70
|
documentId: 100,
|
|
46
71
|
referenceType: 64
|
|
47
72
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2025 Bhupendra Tamang
|
|
4
|
+
* Licensed under the Apache License, Version 2.0
|
|
5
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
const PRECHECK_THRESHOLD = 100, tooMany = (ctx, max, unit) => ctx.addIssue({
|
|
10
|
+
code: z.ZodIssueCode.custom,
|
|
11
|
+
message: `must have at most ${max} ${unit}`,
|
|
12
|
+
params: { maximum: max },
|
|
13
|
+
fatal: !0
|
|
14
|
+
}), boundedArray = (element, max) => z.preprocess((value, ctx) => {
|
|
15
|
+
if (!Array.isArray(value)) return value;
|
|
16
|
+
if (value.length > max)
|
|
17
|
+
return tooMany(ctx, max, "entries"), value;
|
|
18
|
+
if (value.length <= PRECHECK_THRESHOLD) return value;
|
|
19
|
+
for (let i = 0; i < value.length; i++) {
|
|
20
|
+
const result = element.safeParse(value[i]);
|
|
21
|
+
if (!result.success) {
|
|
22
|
+
const [issue] = result.error.issues;
|
|
23
|
+
ctx.addIssue({
|
|
24
|
+
code: z.ZodIssueCode.custom,
|
|
25
|
+
path: [i, ...issue?.path ?? []],
|
|
26
|
+
message: issue?.message ?? "Invalid",
|
|
27
|
+
fatal: !0
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}, z.array(element)), boundedRecord = (valueSchema, max, keySchema = z.string()) => z.preprocess(
|
|
34
|
+
(value, ctx) => (typeof value != "object" || value === null || Array.isArray(value) || Object.keys(value).length > max && tooMany(ctx, max, "keys"), value),
|
|
35
|
+
z.record(keySchema, valueSchema)
|
|
36
|
+
);
|
|
37
|
+
export {
|
|
38
|
+
PRECHECK_THRESHOLD,
|
|
39
|
+
boundedArray,
|
|
40
|
+
boundedRecord
|
|
41
|
+
};
|