@djb25/digit-ui-module-ws 1.0.68 → 1.0.70
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/dist/index.js +178 -45
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +178 -45
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -17411,18 +17411,28 @@ const UploadFileDigiLocker = props => {
|
|
|
17411
17411
|
const _useState4 = useState(null),
|
|
17412
17412
|
showToast = _useState4[0],
|
|
17413
17413
|
setShowToast = _useState4[1];
|
|
17414
|
+
const _useState5 = useState(null),
|
|
17415
|
+
digiLockerFilename = _useState5[0],
|
|
17416
|
+
setDigiLockerFilename = _useState5[1];
|
|
17414
17417
|
const user_type = Digit.SessionStorage.get("userType");
|
|
17415
17418
|
const _Digit$Hooks$createTo = Digit.Hooks.createTokenAPI("document");
|
|
17416
17419
|
let extraStyles = {};
|
|
17417
17420
|
const handleChange = () => {
|
|
17418
|
-
if (inpRef.current.files[0]) {
|
|
17421
|
+
if (inpRef.current.files && inpRef.current.files[0]) {
|
|
17419
17422
|
setHasFile(true);
|
|
17420
17423
|
setprevSate(inpRef.current.files[0]);
|
|
17421
|
-
} else
|
|
17424
|
+
} else if (!digiLockerFilename) {
|
|
17425
|
+
setHasFile(false);
|
|
17426
|
+
}
|
|
17422
17427
|
};
|
|
17423
17428
|
extraStyles = getCitizenStyles("OBPS");
|
|
17424
17429
|
const handleDelete = () => {
|
|
17425
17430
|
inpRef.current.value = "";
|
|
17431
|
+
setDigiLockerFilename(null);
|
|
17432
|
+
setHasFile(false);
|
|
17433
|
+
if (props.onDocumentNumber) {
|
|
17434
|
+
props.onDocumentNumber("");
|
|
17435
|
+
}
|
|
17426
17436
|
props.onDelete();
|
|
17427
17437
|
};
|
|
17428
17438
|
const handleEmpty = () => {
|
|
@@ -17437,8 +17447,14 @@ const UploadFileDigiLocker = props => {
|
|
|
17437
17447
|
}
|
|
17438
17448
|
useEffect(() => handleEmpty(), [inpRef === null || inpRef === void 0 ? void 0 : (_inpRef$current = inpRef.current) === null || _inpRef$current === void 0 ? void 0 : _inpRef$current.files]);
|
|
17439
17449
|
useEffect(() => handleChange(), [props.message]);
|
|
17450
|
+
useEffect(() => {
|
|
17451
|
+
return () => {
|
|
17452
|
+
if (digiLockerPreviewUrl) URL.revokeObjectURL(digiLockerPreviewUrl);
|
|
17453
|
+
};
|
|
17454
|
+
}, [digiLockerPreviewUrl]);
|
|
17440
17455
|
const dataURItoBlob = dataURI => {
|
|
17441
|
-
var
|
|
17456
|
+
var b64Data = dataURI.split(",")[1].replace(/\s/g, "");
|
|
17457
|
+
var binary = atob(b64Data);
|
|
17442
17458
|
var array = [];
|
|
17443
17459
|
for (var i = 0; i < binary.length; i++) {
|
|
17444
17460
|
array.push(binary.charCodeAt(i));
|
|
@@ -17486,7 +17502,7 @@ const UploadFileDigiLocker = props => {
|
|
|
17486
17502
|
};
|
|
17487
17503
|
const aliases = DOCTYPE_ALIASES[doctype] || [doctype];
|
|
17488
17504
|
let uri = res1.IssuedDoc.filter(item => aliases.some(alias => item.doctype === alias));
|
|
17489
|
-
const
|
|
17505
|
+
const _temp1 = function () {
|
|
17490
17506
|
if ((uri === null || uri === void 0 ? void 0 : uri.length) > 0) {
|
|
17491
17507
|
const uriStr = uri[0].uri || "";
|
|
17492
17508
|
const parts = uriStr.split("-");
|
|
@@ -17499,57 +17515,166 @@ const UploadFileDigiLocker = props => {
|
|
|
17499
17515
|
id: uriStr
|
|
17500
17516
|
};
|
|
17501
17517
|
const tenantId = Digit.ULBService.getCurrentTenantId() || "dl.djb";
|
|
17502
|
-
return Promise.resolve(Digit.DigiLockerService.
|
|
17518
|
+
return Promise.resolve(Digit.DigiLockerService.uriFile({
|
|
17503
17519
|
TokenReq: TokenReqNew
|
|
17504
17520
|
}, tenantId)).then(function (res2) {
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
const
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17521
|
+
var _res2$headers;
|
|
17522
|
+
console.log("[DigiLocker] uriFile response:", res2);
|
|
17523
|
+
let blobData = null;
|
|
17524
|
+
let contentType = (res2 === null || res2 === void 0 ? void 0 : (_res2$headers = res2.headers) === null || _res2$headers === void 0 ? void 0 : _res2$headers["content-type"]) || "";
|
|
17525
|
+
let isJsonString = contentType.includes("application/json");
|
|
17526
|
+
const _temp0 = function () {
|
|
17527
|
+
if (res2 !== null && res2 !== void 0 && res2.data) {
|
|
17528
|
+
function _temp9() {
|
|
17529
|
+
const filename = doctype + "_" + (uri[0].name || "document") + ".pdf";
|
|
17530
|
+
if (blobData && blobData.size > 0) convertToFile(e, blobData, filename);else setShowToast({
|
|
17531
|
+
error: true,
|
|
17532
|
+
label: "Failed to read document from DigiLocker."
|
|
17533
|
+
});
|
|
17534
|
+
}
|
|
17535
|
+
const _temp8 = function () {
|
|
17536
|
+
if (res2 !== null && res2 !== void 0 && res2.data) {
|
|
17537
|
+
const rawBytes = new Uint8Array(res2.data);
|
|
17538
|
+
const _temp7 = function () {
|
|
17539
|
+
if (rawBytes.length > 5 && rawBytes[0] === 0x22 && rawBytes[1] === 0x25 && rawBytes[2] === 0x50 && rawBytes[3] === 0x44 && rawBytes[4] === 0x46) {
|
|
17540
|
+
console.log("[DigiLocker] Response is a JSON-encoded binary PDF string. Unescaping bytes...");
|
|
17541
|
+
const unescaped = new Uint8Array(rawBytes.length);
|
|
17542
|
+
let outIdx = 0;
|
|
17543
|
+
for (let i = 1; i < rawBytes.length - 1; i++) {
|
|
17544
|
+
if (rawBytes[i] === 0x5c) {
|
|
17545
|
+
i++;
|
|
17546
|
+
const next = rawBytes[i];
|
|
17547
|
+
if (next === 0x6e) unescaped[outIdx++] = 0x0a;else if (next === 0x72) unescaped[outIdx++] = 0x0d;else if (next === 0x74) unescaped[outIdx++] = 0x09;else if (next === 0x22) unescaped[outIdx++] = 0x22;else if (next === 0x5c) unescaped[outIdx++] = 0x5c;else if (next === 0x62) unescaped[outIdx++] = 0x08;else if (next === 0x66) unescaped[outIdx++] = 0x0c;else unescaped[outIdx++] = next;
|
|
17548
|
+
} else {
|
|
17549
|
+
unescaped[outIdx++] = rawBytes[i];
|
|
17529
17550
|
}
|
|
17530
|
-
}
|
|
17531
|
-
|
|
17532
|
-
blobData = new Blob([JSON.stringify(res2)], {
|
|
17551
|
+
}
|
|
17552
|
+
blobData = new Blob([unescaped.slice(0, outIdx)], {
|
|
17533
17553
|
type: "application/pdf"
|
|
17534
17554
|
});
|
|
17555
|
+
} else {
|
|
17556
|
+
const _temp6 = function () {
|
|
17557
|
+
if (rawBytes.length > 4 && rawBytes[0] === 0x25 && rawBytes[1] === 0x50 && rawBytes[2] === 0x44 && rawBytes[3] === 0x46) {
|
|
17558
|
+
console.log("[DigiLocker] Response is a raw binary PDF.");
|
|
17559
|
+
blobData = new Blob([res2.data], {
|
|
17560
|
+
type: "application/pdf"
|
|
17561
|
+
});
|
|
17562
|
+
} else {
|
|
17563
|
+
const decoder = new TextDecoder("utf-8");
|
|
17564
|
+
const textStr = decoder.decode(res2.data);
|
|
17565
|
+
let parsedJson = null;
|
|
17566
|
+
try {
|
|
17567
|
+
parsedJson = JSON.parse(textStr);
|
|
17568
|
+
} catch (e) {}
|
|
17569
|
+
const _temp5 = function () {
|
|
17570
|
+
if (parsedJson) {
|
|
17571
|
+
const _temp4 = function () {
|
|
17572
|
+
if (Array.isArray(parsedJson)) {
|
|
17573
|
+
console.log("[DigiLocker] Response is a JSON array of bytes.");
|
|
17574
|
+
const arr = new Uint8Array(parsedJson);
|
|
17575
|
+
blobData = new Blob([arr], {
|
|
17576
|
+
type: "application/pdf"
|
|
17577
|
+
});
|
|
17578
|
+
} else {
|
|
17579
|
+
const _temp3 = function () {
|
|
17580
|
+
if (typeof parsedJson === "string") {
|
|
17581
|
+
console.log("[DigiLocker] Response is a base64 string in JSON.");
|
|
17582
|
+
const dataUri = parsedJson.startsWith("data:") ? parsedJson : "data:application/pdf;base64," + parsedJson;
|
|
17583
|
+
try {
|
|
17584
|
+
blobData = dataURItoBlob(dataUri);
|
|
17585
|
+
} catch (e) {
|
|
17586
|
+
console.error("Failed to parse JSON string as base64", e);
|
|
17587
|
+
}
|
|
17588
|
+
} else {
|
|
17589
|
+
const _temp2 = function () {
|
|
17590
|
+
if (typeof parsedJson === "object") {
|
|
17591
|
+
const findFileStoreId = obj => {
|
|
17592
|
+
if (!obj || typeof obj !== "object") return null;
|
|
17593
|
+
for (let key in obj) {
|
|
17594
|
+
if (key.toLowerCase() === "filestoreid") return obj[key];
|
|
17595
|
+
const found = findFileStoreId(obj[key]);
|
|
17596
|
+
if (found) return found;
|
|
17597
|
+
}
|
|
17598
|
+
return null;
|
|
17599
|
+
};
|
|
17600
|
+
const findBase64 = obj => {
|
|
17601
|
+
if (!obj || typeof obj !== "object") return null;
|
|
17602
|
+
for (let key in obj) {
|
|
17603
|
+
if (["doccontent", "filecontent", "base64"].includes(key.toLowerCase())) return obj[key];
|
|
17604
|
+
const found = findBase64(obj[key]);
|
|
17605
|
+
if (found && typeof found === "string") return found;
|
|
17606
|
+
}
|
|
17607
|
+
return null;
|
|
17608
|
+
};
|
|
17609
|
+
const fsId = findFileStoreId(parsedJson);
|
|
17610
|
+
const _temp = function () {
|
|
17611
|
+
if (fsId) {
|
|
17612
|
+
console.log("[DigiLocker] Got fileStoreId from JSON:", fsId);
|
|
17613
|
+
return Promise.resolve(Digit.UploadServices.FileFetchbyid(fsId, Digit.ULBService.getStateId())).then(function (fileRes) {
|
|
17614
|
+
var _fileRes$headers;
|
|
17615
|
+
blobData = (fileRes === null || fileRes === void 0 ? void 0 : fileRes.data) instanceof Blob ? fileRes.data : new Blob([(fileRes === null || fileRes === void 0 ? void 0 : fileRes.data) || ""], {
|
|
17616
|
+
type: (fileRes === null || fileRes === void 0 ? void 0 : (_fileRes$headers = fileRes.headers) === null || _fileRes$headers === void 0 ? void 0 : _fileRes$headers["content-type"]) || "application/pdf"
|
|
17617
|
+
});
|
|
17618
|
+
});
|
|
17619
|
+
} else {
|
|
17620
|
+
const b64 = findBase64(parsedJson);
|
|
17621
|
+
if (b64 && typeof b64 === "string") {
|
|
17622
|
+
console.log("[DigiLocker] Got base64 content from JSON field");
|
|
17623
|
+
const dataUri = b64.startsWith("data:") ? b64 : "data:application/pdf;base64," + b64;
|
|
17624
|
+
blobData = dataURItoBlob(dataUri);
|
|
17625
|
+
} else {
|
|
17626
|
+
console.log("[DigiLocker] JSON did not contain filestoreid or base64.");
|
|
17627
|
+
}
|
|
17628
|
+
}
|
|
17629
|
+
}();
|
|
17630
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
17631
|
+
}
|
|
17632
|
+
}();
|
|
17633
|
+
if (_temp2 && _temp2.then) return _temp2.then(function () {});
|
|
17634
|
+
}
|
|
17635
|
+
}();
|
|
17636
|
+
if (_temp3 && _temp3.then) return _temp3.then(function () {});
|
|
17637
|
+
}
|
|
17638
|
+
}();
|
|
17639
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
17640
|
+
} else {
|
|
17641
|
+
if (textStr.startsWith("JVBERi0x")) {
|
|
17642
|
+
console.log("[DigiLocker] Response is a raw base64 string.");
|
|
17643
|
+
try {
|
|
17644
|
+
blobData = dataURItoBlob("data:application/pdf;base64," + textStr);
|
|
17645
|
+
} catch (e) {
|
|
17646
|
+
console.error("Failed to parse raw text as base64", e);
|
|
17647
|
+
}
|
|
17648
|
+
} else {
|
|
17649
|
+
console.log("[DigiLocker] Response is unknown format, attempting binary PDF fallback.");
|
|
17650
|
+
blobData = new Blob([res2.data], {
|
|
17651
|
+
type: "application/pdf"
|
|
17652
|
+
});
|
|
17653
|
+
}
|
|
17654
|
+
}
|
|
17655
|
+
}();
|
|
17656
|
+
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
|
17657
|
+
}
|
|
17658
|
+
}();
|
|
17659
|
+
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
17535
17660
|
}
|
|
17536
17661
|
}();
|
|
17537
|
-
if (
|
|
17662
|
+
if (_temp7 && _temp7.then) return _temp7.then(function () {});
|
|
17538
17663
|
}
|
|
17539
17664
|
}();
|
|
17540
|
-
|
|
17665
|
+
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
|
|
17666
|
+
} else {
|
|
17667
|
+
setShowToast({
|
|
17668
|
+
error: true,
|
|
17669
|
+
label: "Selected document (" + ((props === null || props === void 0 ? void 0 : props.documentType) || doctype) + ") is not available in your DigiLocker."
|
|
17670
|
+
});
|
|
17541
17671
|
}
|
|
17542
17672
|
}();
|
|
17543
|
-
|
|
17544
|
-
});
|
|
17545
|
-
} else {
|
|
17546
|
-
setShowToast({
|
|
17547
|
-
error: true,
|
|
17548
|
-
label: "Selected document (" + ((props === null || props === void 0 ? void 0 : props.documentType) || doctype) + ") is not available in your DigiLocker."
|
|
17673
|
+
if (_temp0 && _temp0.then) return _temp0.then(function () {});
|
|
17549
17674
|
});
|
|
17550
17675
|
}
|
|
17551
17676
|
}();
|
|
17552
|
-
if (
|
|
17677
|
+
if (_temp1 && _temp1.then) return _temp1.then(function () {});
|
|
17553
17678
|
});
|
|
17554
17679
|
}, function (error) {
|
|
17555
17680
|
console.error("DigiLocker Fetch Error:", error);
|
|
@@ -17574,6 +17699,8 @@ const UploadFileDigiLocker = props => {
|
|
|
17574
17699
|
let newFile = new File([blobData], filename, {
|
|
17575
17700
|
type: "application/pdf"
|
|
17576
17701
|
});
|
|
17702
|
+
setDigiLockerFilename(filename);
|
|
17703
|
+
setHasFile(true);
|
|
17577
17704
|
props.onUpload(e, newFile);
|
|
17578
17705
|
};
|
|
17579
17706
|
};
|
|
@@ -17650,7 +17777,7 @@ const UploadFileDigiLocker = props => {
|
|
|
17650
17777
|
text: file[0],
|
|
17651
17778
|
onClick: e => props === null || props === void 0 ? void 0 : props.removeTargetedFile(fileDetailsData, e)
|
|
17652
17779
|
}));
|
|
17653
|
-
}), !hasFile || props.error ? /*#__PURE__*/React.createElement("h2", {
|
|
17780
|
+
}), !hasFile && !props.file || props.error ? /*#__PURE__*/React.createElement("h2", {
|
|
17654
17781
|
className: "file-upload-status"
|
|
17655
17782
|
}, props.message) : /*#__PURE__*/React.createElement("div", {
|
|
17656
17783
|
className: "tag-container",
|
|
@@ -17661,7 +17788,7 @@ const UploadFileDigiLocker = props => {
|
|
|
17661
17788
|
}, /*#__PURE__*/React.createElement("span", {
|
|
17662
17789
|
className: "text",
|
|
17663
17790
|
style: extraStyles ? (_extraStyles6 = extraStyles) === null || _extraStyles6 === void 0 ? void 0 : _extraStyles6.textStyles : null
|
|
17664
|
-
}, typeof ((_inpRef$current$files = inpRef.current.files[0]) === null || _inpRef$current$files === void 0 ? void 0 : _inpRef$current$files.name) !== "undefined" && !(props !== null && props !== void 0 && props.file) ? (_inpRef$current$files2 = inpRef.current.files[0]) === null || _inpRef$current$files2 === void 0 ? void 0 : _inpRef$current$files2.name : (_props$file = props.file) === null || _props$file === void 0 ? void 0 : _props$file.name), /*#__PURE__*/React.createElement("span", {
|
|
17791
|
+
}, digiLockerFilename ? digiLockerFilename : typeof ((_inpRef$current$files = inpRef.current.files[0]) === null || _inpRef$current$files === void 0 ? void 0 : _inpRef$current$files.name) !== "undefined" && !(props !== null && props !== void 0 && props.file) ? (_inpRef$current$files2 = inpRef.current.files[0]) === null || _inpRef$current$files2 === void 0 ? void 0 : _inpRef$current$files2.name : (_props$file = props.file) === null || _props$file === void 0 ? void 0 : _props$file.name), /*#__PURE__*/React.createElement("span", {
|
|
17665
17792
|
onClick: () => handleDelete(),
|
|
17666
17793
|
style: extraStyles ? (_extraStyles7 = extraStyles) === null || _extraStyles7 === void 0 ? void 0 : _extraStyles7.closeIconStyles : null
|
|
17667
17794
|
}, /*#__PURE__*/React.createElement(Close, {
|
|
@@ -18132,6 +18259,7 @@ function SelectDocument(_ref2) {
|
|
|
18132
18259
|
setFile(null);
|
|
18133
18260
|
setIsCameraFile(false);
|
|
18134
18261
|
setIsDocumentUidLocked(false);
|
|
18262
|
+
setDocumentUid("");
|
|
18135
18263
|
},
|
|
18136
18264
|
id: id,
|
|
18137
18265
|
message: uploadedFile ? "1 " + t("CS_ACTION_FILEUPLOADED") : t("CS_ACTION_NO_FILEUPLOADED"),
|
|
@@ -18149,6 +18277,7 @@ function SelectDocument(_ref2) {
|
|
|
18149
18277
|
setFile(null);
|
|
18150
18278
|
setIsCameraFile(false);
|
|
18151
18279
|
setIsDocumentUidLocked(false);
|
|
18280
|
+
setDocumentUid("");
|
|
18152
18281
|
},
|
|
18153
18282
|
documentType: selectedDocument === null || selectedDocument === void 0 ? void 0 : selectedDocument.code,
|
|
18154
18283
|
onDocumentNumber: num => {
|
|
@@ -18161,6 +18290,8 @@ function SelectDocument(_ref2) {
|
|
|
18161
18290
|
setUploadedFile(null);
|
|
18162
18291
|
setFile(null);
|
|
18163
18292
|
setIsCameraFile(false);
|
|
18293
|
+
setIsDocumentUidLocked(false);
|
|
18294
|
+
setDocumentUid("");
|
|
18164
18295
|
},
|
|
18165
18296
|
id: id,
|
|
18166
18297
|
message: uploadedFile ? "1 " + t("CS_ACTION_FILEUPLOADED") : t("CS_ACTION_NO_FILEUPLOADED"),
|
|
@@ -18177,6 +18308,8 @@ function SelectDocument(_ref2) {
|
|
|
18177
18308
|
setUploadedFile(null);
|
|
18178
18309
|
setFile(null);
|
|
18179
18310
|
setIsCameraFile(false);
|
|
18311
|
+
setIsDocumentUidLocked(false);
|
|
18312
|
+
setDocumentUid("");
|
|
18180
18313
|
}
|
|
18181
18314
|
})), uploadedFile && /*#__PURE__*/React.createElement("div", {
|
|
18182
18315
|
onClick: viewDocument,
|
|
@@ -18254,6 +18387,7 @@ function SelectDocument(_ref2) {
|
|
|
18254
18387
|
center: true,
|
|
18255
18388
|
actionCancelOnSubmit: () => setShowDocModal(false),
|
|
18256
18389
|
actionCancelLabel: t("CS_COMMON_CLOSE") || "Close",
|
|
18390
|
+
hideSubmit: true,
|
|
18257
18391
|
popupStyles: {
|
|
18258
18392
|
width: "80%",
|
|
18259
18393
|
maxWidth: "800px"
|
|
@@ -48034,8 +48168,7 @@ const ApplicationDetails$1 = () => {
|
|
|
48034
48168
|
})), /*#__PURE__*/React.createElement("div", {
|
|
48035
48169
|
style: {
|
|
48036
48170
|
flex: "2 1 500px",
|
|
48037
|
-
minWidth: "300px"
|
|
48038
|
-
overflowY: "auto"
|
|
48171
|
+
minWidth: "300px"
|
|
48039
48172
|
}
|
|
48040
48173
|
}, /*#__PURE__*/React.createElement(ApplicationDetails, {
|
|
48041
48174
|
applicationDetails: applicationDetails,
|