@bdking71/spsignature 1.2.0 โ 1.3.0
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/lib/TransactionSigner.js +35 -8
- package/package.json +1 -1
package/lib/TransactionSigner.js
CHANGED
|
@@ -563,35 +563,51 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
563
563
|
*/
|
|
564
564
|
const updateButtonState = () => {
|
|
565
565
|
let isCodeValid = true;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
566
|
+
// Check TFA only if it's required
|
|
567
|
+
if (requireTFA) {
|
|
568
|
+
if (verificationInput) {
|
|
569
|
+
const codeValue = verificationInput.value.trim();
|
|
570
|
+
isCodeValid =
|
|
571
|
+
codeValue.length === 5 && codeValue === generatedPasscode;
|
|
572
|
+
console.log("๐ TFA Check: Code =", codeValue, "Valid =", isCodeValid);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
isCodeValid = false;
|
|
576
|
+
console.log("๐ TFA Check: No input element found");
|
|
577
|
+
}
|
|
570
578
|
}
|
|
579
|
+
else {
|
|
580
|
+
console.log("๐ TFA not required - skipping TFA validation");
|
|
581
|
+
}
|
|
582
|
+
// Check signature validity
|
|
571
583
|
let isSignatureValid = false;
|
|
572
584
|
if (activeMode === "cached") {
|
|
573
585
|
isSignatureValid = hasCachedSignature;
|
|
586
|
+
console.log("โ๏ธ Signature Check (CACHED): Valid =", isSignatureValid);
|
|
574
587
|
}
|
|
575
588
|
else if (activeMode === "draw") {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
!isCanvasEmpty(ctx, canvas.width, canvas.height);
|
|
589
|
+
const canvasHasContent = ctx !== null && !isCanvasEmpty(ctx, canvas.width, canvas.height);
|
|
590
|
+
isSignatureValid = hasDrawnContent && canvasHasContent;
|
|
591
|
+
console.log("โ๏ธ Signature Check (DRAW): hasDrawnContent =", hasDrawnContent, "canvasHasContent =", canvasHasContent, "Valid =", isSignatureValid);
|
|
580
592
|
}
|
|
581
593
|
else {
|
|
582
594
|
isSignatureValid = compressedUploadBase64.trim() !== "";
|
|
595
|
+
console.log("โ๏ธ Signature Check (UPLOAD): compressedSize =", compressedUploadBase64.length, "Valid =", isSignatureValid);
|
|
583
596
|
}
|
|
597
|
+
console.log("๐ FINAL STATE: Code Valid =", isCodeValid, "Sig Valid =", isSignatureValid, "Should Enable =", isCodeValid && isSignatureValid);
|
|
584
598
|
if (isCodeValid && isSignatureValid) {
|
|
585
599
|
signButton.disabled = false;
|
|
586
600
|
signButton.style.backgroundColor = "#0078d4";
|
|
587
601
|
signButton.style.cursor = "pointer";
|
|
588
602
|
signButton.style.opacity = "1";
|
|
603
|
+
console.log("โ
Button ENABLED");
|
|
589
604
|
}
|
|
590
605
|
else {
|
|
591
606
|
signButton.disabled = true;
|
|
592
607
|
signButton.style.backgroundColor = "#c8c6c4";
|
|
593
608
|
signButton.style.cursor = "not-allowed";
|
|
594
609
|
signButton.style.opacity = "0.6";
|
|
610
|
+
console.log("โ Button DISABLED");
|
|
595
611
|
}
|
|
596
612
|
};
|
|
597
613
|
// -----------------------------------------------------------------
|
|
@@ -619,6 +635,7 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
619
635
|
: uploadTabBtn;
|
|
620
636
|
activeBtn.style.color = "#0078d4";
|
|
621
637
|
activeBtn.style.borderBottom = "3px solid #0078d4";
|
|
638
|
+
console.log("Tab switched to:", mode);
|
|
622
639
|
updateButtonState();
|
|
623
640
|
};
|
|
624
641
|
if (hasCachedSignature) {
|
|
@@ -689,8 +706,10 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
689
706
|
});
|
|
690
707
|
if (vResult.success && vResult.itemId) {
|
|
691
708
|
storedVerificationItemId = vResult.itemId;
|
|
709
|
+
console.log("โ
OTP dispatched successfully");
|
|
692
710
|
}
|
|
693
711
|
else {
|
|
712
|
+
console.error("โ OTP dispatch failed:", vResult.error);
|
|
694
713
|
alert("Failed to dispatch verification code. Please try again.");
|
|
695
714
|
}
|
|
696
715
|
}
|
|
@@ -707,10 +726,14 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
707
726
|
await triggerSendCode();
|
|
708
727
|
};
|
|
709
728
|
vInputRef.oninput = () => {
|
|
729
|
+
console.log("๐ TFA input changed, checking button state");
|
|
710
730
|
updateButtonState();
|
|
711
731
|
};
|
|
712
732
|
void triggerSendCode();
|
|
713
733
|
}
|
|
734
|
+
else if (requireTFA && !context.channel) {
|
|
735
|
+
console.warn("โ ๏ธ TFA required but no channel provided");
|
|
736
|
+
}
|
|
714
737
|
// -----------------------------------------------------------------
|
|
715
738
|
// Canvas drawing helpers
|
|
716
739
|
// -----------------------------------------------------------------
|
|
@@ -766,12 +789,14 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
766
789
|
const pos = getPos(e);
|
|
767
790
|
ctx.lineTo(pos.x, pos.y);
|
|
768
791
|
ctx.stroke();
|
|
792
|
+
console.log("โ๏ธ Drawing, updating button state");
|
|
769
793
|
updateButtonState();
|
|
770
794
|
e.preventDefault();
|
|
771
795
|
};
|
|
772
796
|
/** Ends the current drawing stroke. */
|
|
773
797
|
const stopDraw = () => {
|
|
774
798
|
isDrawing = false;
|
|
799
|
+
console.log("โ Drawing stopped, updating button state");
|
|
775
800
|
updateButtonState();
|
|
776
801
|
};
|
|
777
802
|
canvas.addEventListener("mousedown", startDraw);
|
|
@@ -786,6 +811,7 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
786
811
|
ctx.fillStyle = "#ffffff";
|
|
787
812
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
788
813
|
hasDrawnContent = false;
|
|
814
|
+
console.log("๐งน Canvas cleared, updating button state");
|
|
789
815
|
updateButtonState();
|
|
790
816
|
}
|
|
791
817
|
};
|
|
@@ -836,6 +862,7 @@ async function promptAndGenerateSecureAudit(context, modalTitle = "Approve Purch
|
|
|
836
862
|
tempCanvas.toDataURL("image/png");
|
|
837
863
|
uploadPreview.src = compressedUploadBase64;
|
|
838
864
|
uploadPreview.style.display = "block";
|
|
865
|
+
console.log("๐ค File uploaded, updating button state");
|
|
839
866
|
updateButtonState();
|
|
840
867
|
}
|
|
841
868
|
};
|
package/package.json
CHANGED