@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.
@@ -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"), drawnSignature = z.object({
158
- strokes: boundedArray(
159
- boundedArray(z.number().int().min(0), signature.strokePoints * 2, 2),
160
- signature.strokes,
161
- 1
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
- strokes.forEach((stroke, index) => {
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
- }), BtpTemplateValuesSchema = z.object({
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
- }).strict(), BtpStatementRecordSchema = z.object({
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(),