@bdking71/spsignature 1.1.0 → 1.2.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/OtpService.js +45 -5
- package/package.json +1 -1
package/lib/OtpService.js
CHANGED
|
@@ -15,7 +15,7 @@ const DEFAULT_OTP_LIST_NAME = "PendingVerifications";
|
|
|
15
15
|
* Queues an OTP dispatch request in SharePoint to notify the user via Email/Teams.
|
|
16
16
|
*/
|
|
17
17
|
async function dispatchOtpPasscode(context, request, listTitle = DEFAULT_OTP_LIST_NAME) {
|
|
18
|
-
var _a, _b, _c, _d
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
19
|
try {
|
|
20
20
|
if (!context) {
|
|
21
21
|
throw new Error("Execution restricted: Valid WebPartContext is required.");
|
|
@@ -32,11 +32,49 @@ async function dispatchOtpPasscode(context, request, listTitle = DEFAULT_OTP_LIS
|
|
|
32
32
|
Passcode: request.passcode.trim(),
|
|
33
33
|
Channel: request.channel || "email",
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// DEBUG: Log the entire response structure
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
const debugItem = addedItem;
|
|
38
|
+
console.log("=== PnPjs Add Item Response ===");
|
|
39
|
+
console.log("Full Response:", debugItem);
|
|
40
|
+
console.log("Response Keys:", Object.keys(debugItem || {}));
|
|
41
|
+
if (debugItem === null || debugItem === void 0 ? void 0 : debugItem.data) {
|
|
42
|
+
console.log("Data Object:", debugItem.data);
|
|
43
|
+
console.log("Data Keys:", Object.keys(debugItem.data));
|
|
39
44
|
}
|
|
45
|
+
// Try multiple extraction paths
|
|
46
|
+
let itemId;
|
|
47
|
+
// Path 1: addedItem.data.Id (most common in PnPjs v3/v4)
|
|
48
|
+
if ((_c = addedItem === null || addedItem === void 0 ? void 0 : addedItem.data) === null || _c === void 0 ? void 0 : _c.Id) {
|
|
49
|
+
itemId = addedItem.data.Id;
|
|
50
|
+
console.log("✓ Found ID in addedItem.data.Id:", itemId);
|
|
51
|
+
}
|
|
52
|
+
// Path 2: addedItem.data.ID (alternative casing)
|
|
53
|
+
else if ((_d = addedItem === null || addedItem === void 0 ? void 0 : addedItem.data) === null || _d === void 0 ? void 0 : _d.ID) {
|
|
54
|
+
itemId = addedItem.data.ID;
|
|
55
|
+
console.log("✓ Found ID in addedItem.data.ID:", itemId);
|
|
56
|
+
}
|
|
57
|
+
// Path 3: addedItem.Id (direct property)
|
|
58
|
+
else if (debugItem === null || debugItem === void 0 ? void 0 : debugItem.Id) {
|
|
59
|
+
itemId = debugItem.Id;
|
|
60
|
+
console.log("✓ Found ID in addedItem.Id:", itemId);
|
|
61
|
+
}
|
|
62
|
+
// Path 4: addedItem.ID (direct property, alternate casing)
|
|
63
|
+
else if (debugItem === null || debugItem === void 0 ? void 0 : debugItem.ID) {
|
|
64
|
+
itemId = debugItem.ID;
|
|
65
|
+
console.log("✓ Found ID in addedItem.ID:", itemId);
|
|
66
|
+
}
|
|
67
|
+
// Path 5: addedItem.id (lowercase)
|
|
68
|
+
else if (debugItem === null || debugItem === void 0 ? void 0 : debugItem.id) {
|
|
69
|
+
itemId = debugItem.id;
|
|
70
|
+
console.log("✓ Found ID in addedItem.id:", itemId);
|
|
71
|
+
}
|
|
72
|
+
// Validate the extracted ID
|
|
73
|
+
if (!itemId || typeof itemId !== "number" || itemId <= 0) {
|
|
74
|
+
console.error("❌ Item ID extraction failed. Extracted value:", itemId);
|
|
75
|
+
throw new Error(`Item created but ID extraction failed. Got: ${JSON.stringify(itemId)}`);
|
|
76
|
+
}
|
|
77
|
+
console.log(`✓ OTP Record created successfully with ID: ${itemId}`);
|
|
40
78
|
return {
|
|
41
79
|
success: true,
|
|
42
80
|
itemId,
|
|
@@ -44,6 +82,8 @@ async function dispatchOtpPasscode(context, request, listTitle = DEFAULT_OTP_LIS
|
|
|
44
82
|
}
|
|
45
83
|
catch (error) {
|
|
46
84
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
85
|
+
console.error("❌ dispatchOtpPasscode Error:", errorMsg);
|
|
86
|
+
console.error("Full Error Object:", error);
|
|
47
87
|
return {
|
|
48
88
|
success: false,
|
|
49
89
|
error: errorMsg,
|
package/package.json
CHANGED