@btps/sdk 1.2.0-rc.1 → 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 +39 -0
- package/dist/core/server/schemas/artifacts/transporterSchema.js +16 -9
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +1840 -15
- package/dist/core/server/schemas/btpsDocsSchema.js +16 -11
- package/dist/core/server/schemas/helpers.d.ts +514 -4
- package/dist/core/trust/types.d.ts +11 -1
- package/dist/server/btpsServer.d.ts +9 -0
- package/dist/server/btpsServer.js +35 -3
- package/dist/server/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -154,15 +154,13 @@ const {
|
|
|
154
154
|
]), isPlainText = (text) => [...text].every((char) => {
|
|
155
155
|
const code = char.codePointAt(0) ?? 0;
|
|
156
156
|
return code >= 32 && code !== 127 && char !== "<" && char !== ">" && !HIDDEN.has(code);
|
|
157
|
-
}), signatureText = z.string().min(1).max(signature.text).refine(isPlainText, "must be plain text"),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
163
|
-
}).strict().superRefine(({ strokes }, ctx) => {
|
|
157
|
+
}), signatureText = z.string().min(1).max(signature.text).refine(isPlainText, "must be plain text"), strokes = boundedArray(
|
|
158
|
+
boundedArray(z.number().int().min(0), signature.strokePoints * 2, 2),
|
|
159
|
+
signature.strokes,
|
|
160
|
+
1
|
|
161
|
+
), strokesOnCanvas = ({ strokes: strokes2 }, ctx) => {
|
|
164
162
|
let points = 0;
|
|
165
|
-
|
|
163
|
+
strokes2.forEach((stroke, index) => {
|
|
166
164
|
points += stroke.length / 2;
|
|
167
165
|
const onCanvas = stroke.every(
|
|
168
166
|
(value, at) => at % 2 === 0 ? value <= signature.width : value <= signature.height
|
|
@@ -177,7 +175,10 @@ const {
|
|
|
177
175
|
message: `a drawn signature has at most ${signature.points} points`,
|
|
178
176
|
path: ["strokes"]
|
|
179
177
|
});
|
|
180
|
-
}
|
|
178
|
+
}, drawnSignature = z.object({ strokes }).strict().superRefine(strokesOnCanvas), BtpVisualSignatureSchema = z.union([
|
|
179
|
+
z.object({ type: z.literal("typed"), text: signatureText }).strict(),
|
|
180
|
+
z.object({ type: z.literal("drawn"), strokes }).strict().superRefine(strokesOnCanvas)
|
|
181
|
+
]), BtpTemplateValuesSchema = z.object({
|
|
181
182
|
"signature.typed": signatureText.optional(),
|
|
182
183
|
"signature.name": signatureText.optional(),
|
|
183
184
|
"signature.title": signatureText.optional(),
|
|
@@ -399,8 +400,12 @@ const {
|
|
|
399
400
|
signer: identitySchema,
|
|
400
401
|
decision: z.enum(["accepted", "declined"]),
|
|
401
402
|
signedAt: z.string().datetime(),
|
|
402
|
-
previous: sha256Hex.optional()
|
|
403
|
-
|
|
403
|
+
previous: sha256Hex.optional(),
|
|
404
|
+
visualSignature: BtpVisualSignatureSchema.optional()
|
|
405
|
+
}).strict().refine((s) => s.visualSignature === void 0 || s.decision === "accepted", {
|
|
406
|
+
message: "only an acceptance carries a visualSignature",
|
|
407
|
+
path: ["visualSignature"]
|
|
408
|
+
}), BtpStatementRecordSchema = z.object({
|
|
404
409
|
statement: BtpAgreementStatementSchema,
|
|
405
410
|
signature: BtpSignatureSchema,
|
|
406
411
|
selector: z.string().min(1).optional(),
|