pipwave-ekyc-uikit 1.1.1 → 1.1.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/dist/pw-bundle.js +1 -1
- package/package.json +1 -1
package/dist/pw-bundle.js
CHANGED
|
@@ -3759,7 +3759,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3759
3759
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3760
3760
|
|
|
3761
3761
|
"use strict";
|
|
3762
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst face_camera_1 = __importDefault(__webpack_require__(/*! ../plugins/face-camera */ \"./src/plugins/face-camera.ts\"));\nconst uisdk_1 = __webpack_require__(/*! ../uisdk */ \"./src/uisdk.ts\");\nconst getGoogleIcon_1 = __webpack_require__(/*! ../helper/getGoogleIcon */ \"./src/helper/getGoogleIcon.ts\");\n// assets\nconst icon_selfie_png_1 = __importDefault(__webpack_require__(/*! ../assets/img/icon-selfie.png */ \"./src/assets/img/icon-selfie.png\"));\n// pages\nconst MainPage_1 = __importDefault(__webpack_require__(/*! ../classes/MainPage */ \"./src/classes/MainPage.ts\"));\nconst ReviewEkyc_1 = __importDefault(__webpack_require__(/*! ./ReviewEkyc */ \"./src/pageClass/ReviewEkyc.ts\"));\nconst StartPage_1 = __importDefault(__webpack_require__(/*! ./StartPage */ \"./src/pageClass/StartPage.ts\"));\nconst LoadingPage_1 = __importDefault(__webpack_require__(/*! ./LoadingPage */ \"./src/pageClass/LoadingPage.ts\"));\nconst SelfieError_1 = __importDefault(__webpack_require__(/*! ./SelfieError */ \"./src/pageClass/SelfieError.ts\"));\n// components\nconst components_1 = __webpack_require__(/*! ../components/components */ \"./src/components/components.ts\");\nconst stepper_1 = __importDefault(__webpack_require__(/*! ../components/stepper */ \"./src/components/stepper.ts\"));\nclass StartSelfie extends MainPage_1.default {\n constructor(mainScreenId, displayMode) {\n super(mainScreenId, displayMode);\n this.cameraId = \"pw-camera-container\";\n }\n render() {\n this.renderContent(this.createPage());\n }\n createPage() {\n const selfiePageDiv = document.createElement(\"div\");\n selfiePageDiv.classList.add(\"pw-flex\", \"pw-flex-col\", \"pw-justify-between\", \"pw-h-full\");\n const startSelfieDiv = document.createElement(\"div\");\n const navigationDiv = document.createElement(\"div\");\n navigationDiv.classList.add(\"pw-relative\", \"pw-text-center\", \"pw-mb-16\");\n const stepper = new stepper_1.default();\n const stepperElement = stepper.render(4, 5);\n navigationDiv.classList.add(\"pw-pt-3\");\n navigationDiv.appendChild(stepperElement);\n const closeButtonDiv = document.createElement(\"div\");\n closeButtonDiv.classList.add(\"pw-absolute\", \"pw-right-0\", \"pw-top-0\");\n const closeButton = (0, getGoogleIcon_1.getGoogleIcon)(\"close\");\n closeButton.addEventListener(\"click\", () => this.closeMainPage());\n closeButtonDiv.appendChild(closeButton);\n navigationDiv.appendChild(closeButtonDiv);\n startSelfieDiv.appendChild(navigationDiv);\n const iconDiv = document.createElement(\"div\");\n iconDiv.classList.add(\"pw-text-center\", \"pw-mb-9\");\n const icon = document.createElement(\"img\");\n icon.setAttribute(\"src\", icon_selfie_png_1.default);\n icon.setAttribute(\"alt\", \"eKYC Verification\");\n iconDiv.appendChild(icon);\n startSelfieDiv.appendChild(iconDiv);\n const wordingDiv = document.createElement(\"div\");\n wordingDiv.classList.add(\"pw-text-center\", \"pw-mb-4\");\n const titleDiv = document.createElement(\"div\");\n titleDiv.classList.add(\"pw-text-3xl\", \"pw-font-medium\", \"pw-mb-4\");\n titleDiv.innerHTML = \"Take a selfie\";\n wordingDiv.appendChild(titleDiv);\n const descriptionDiv = document.createElement(\"div\");\n descriptionDiv.innerHTML =\n \"Position your face in the frame and follow the instructions given. Do not wear sunglasses, hat or accessories. Background must be light and neutral.\";\n wordingDiv.appendChild(descriptionDiv);\n startSelfieDiv.appendChild(wordingDiv);\n selfiePageDiv.appendChild(startSelfieDiv);\n const startSelfieButton = (0, components_1.createPrimaryButton)(\"Start selfie\");\n startSelfieButton.addEventListener(\"click\", () => __awaiter(this, void 0, void 0, function* () {\n this.onClickSelfie();\n }));\n selfiePageDiv.appendChild(startSelfieButton);\n return selfiePageDiv;\n }\n createCameraDiv() {\n const screen = document.getElementById(this.mainScreenId);\n const cameraDiv = document.createElement(\"div\");\n cameraDiv.setAttribute(\"id\", this.cameraId);\n screen === null || screen === void 0 ? void 0 : screen.appendChild(cameraDiv);\n }\n uploadSelfie(detail) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n // show loading spinner in full pg\n (0, components_1.createFullLoading)(this.cameraId);\n const { image, livenessScore } = detail;\n yield uisdk_1.pwInstance.uploadSelfie({\n selfie_base64: image,\n liveness_score: livenessScore,\n });\n }\n finally {\n // hide loading spinner in full pg\n (0, components_1.hideFullLoading)(this.cameraId);\n }\n });\n }\n createEkycErrorPage() {\n var _a;\n const errorPage = this.openErrorPage(\"Submission error\", \"Unable to verify your documents. Please check your documents and resubmit again.\");\n const proceedButton = (0, components_1.createPrimaryButton)(\"Retry\");\n proceedButton.addEventListener(\"click\", () => {\n this.clearScreen();\n const firstPage = new StartPage_1.default(this.mainScreenId, this.displayMode, uisdk_1.pwInstance.verificationTypes);\n firstPage.render();\n });\n const proceedBtnDiv = document.createElement(\"div\");\n proceedBtnDiv.classList.add(\"pw-p-5\");\n proceedBtnDiv.appendChild(proceedButton);\n (_a = errorPage.querySelector(\"slot[name='footer']\")) === null || _a === void 0 ? void 0 : _a.appendChild(proceedBtnDiv);\n }\n viewEkycResult() {\n return __awaiter(this, void 0, void 0, function* () {\n // show loading page\n const loadingPage = new LoadingPage_1.default(this.mainScreenId, this.displayMode);\n // 1. first desc in loading screen\n this.clearScreen();\n loadingPage.render(\"Securely uploading the pictures to server\", \"Please do not close your browser, this may take a moment.\");\n // 2. after 3 seconds\n // update desc in loading screen, and call sdk\n yield new Promise((resolve) => setTimeout(resolve, 3000));\n loadingPage.title = \"Analysing the pictures\";\n const payload = yield uisdk_1.pwInstance.viewResult();\n const { status, is_retriable, id_status, selfie_status, id_type, result, filepaths, } = payload;\n // 3. Redirect to page\n this.clearScreen();\n // redirect to thank you page and show update btn\n if (status === \"approved\" || status === \"review\") {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n reviewEkyc.render({\n id_type,\n result,\n filepaths,\n });\n }\n // (fail: pending status / not able to retry)\n // redirect to thank you page and show ntg\n else if (!is_retriable || status === \"pending\") {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n reviewEkyc.render({\n id_type,\n result,\n filepaths,\n });\n }\n // (fail: rejected status - able to retry)\n // Pending: redirect to review error pg (tell user to redo)\n else\n this.createEkycErrorPage();\n return true;\n });\n }\n onClickSelfie() {\n this.createCameraDiv();\n const faceCamera = new face_camera_1.default(this.cameraId, this.mainScreenId);\n faceCamera.init();\n faceCamera.listenToSelfieCapture((e) => __awaiter(this, void 0, void 0, function* () {\n var _a, _b;\n try {\n faceCamera.pauseSmileFace();\n yield this.uploadSelfie(e.detail);\n faceCamera.stopVideoStream();\n yield this.viewEkycResult();\n }\n catch (err) {\n console.error(err);\n this.clearScreen();\n // 1. when exceed max attempt, redirect to thank you page\n if (err.type &&\n [\n \"openApi/max-selfie-attempt\",\n \"openApi/max-session-attempt\",\n \"openApi/limit-exceed\",\n \"openApi/session-id-expired\",\n \"attempt-exceeded\",\n \"session-id-expired\",\n ].includes(err.type)) {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n return reviewEkyc.render();\n }\n // 2. when selfie is exposed, redirect to selfie error page\n else if (err.type && err.type === \"openApi/img-exposed\") {\n // redirect to selfie error page\n let isRetake = false;\n const pwErrorPayload = (_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.payload;\n if (!!pwErrorPayload)\n isRetake = !!pwErrorPayload.is_retriable;\n const selfieError = new SelfieError_1.default(this.mainScreenId, this.displayMode);\n return selfieError.render(isRetake);\n }\n // 3. when view ekyc result fail due to doc upload not verified, redirect to review error page\n else if (err.type &&\n [\n \"openApi/verification-type-invalid\",\n \"openApi/issuing-country-invalid\",\n \"openApi/doc-type-invalid\",\n \"openApi/doc-unpair\",\n \"openApi/doc-empty\",\n \"openApi/doc-blur\",\n \"openApi/doc-front-back-img-unsimilar\",\n \"openApi/doc-not-positioned-proper\",\n ].includes(err.type)) {\n // redirect to review error pg (tell user to redo)\n this.createEkycErrorPage();\n }\n this.openErrorPage();\n }\n }));\n }\n}\nexports[\"default\"] = StartSelfie;\n\n\n//# sourceURL=webpack://PWUISDK/./src/pageClass/StartSelfie.ts?");
|
|
3762
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst face_camera_1 = __importDefault(__webpack_require__(/*! ../plugins/face-camera */ \"./src/plugins/face-camera.ts\"));\nconst uisdk_1 = __webpack_require__(/*! ../uisdk */ \"./src/uisdk.ts\");\nconst getGoogleIcon_1 = __webpack_require__(/*! ../helper/getGoogleIcon */ \"./src/helper/getGoogleIcon.ts\");\n// assets\nconst icon_selfie_png_1 = __importDefault(__webpack_require__(/*! ../assets/img/icon-selfie.png */ \"./src/assets/img/icon-selfie.png\"));\n// pages\nconst MainPage_1 = __importDefault(__webpack_require__(/*! ../classes/MainPage */ \"./src/classes/MainPage.ts\"));\nconst ReviewEkyc_1 = __importDefault(__webpack_require__(/*! ./ReviewEkyc */ \"./src/pageClass/ReviewEkyc.ts\"));\nconst StartPage_1 = __importDefault(__webpack_require__(/*! ./StartPage */ \"./src/pageClass/StartPage.ts\"));\nconst LoadingPage_1 = __importDefault(__webpack_require__(/*! ./LoadingPage */ \"./src/pageClass/LoadingPage.ts\"));\nconst SelfieError_1 = __importDefault(__webpack_require__(/*! ./SelfieError */ \"./src/pageClass/SelfieError.ts\"));\n// components\nconst components_1 = __webpack_require__(/*! ../components/components */ \"./src/components/components.ts\");\nconst stepper_1 = __importDefault(__webpack_require__(/*! ../components/stepper */ \"./src/components/stepper.ts\"));\nclass StartSelfie extends MainPage_1.default {\n constructor(mainScreenId, displayMode) {\n super(mainScreenId, displayMode);\n this.cameraId = \"pw-camera-container\";\n }\n render() {\n this.renderContent(this.createPage());\n }\n createPage() {\n const selfiePageDiv = document.createElement(\"div\");\n selfiePageDiv.classList.add(\"pw-flex\", \"pw-flex-col\", \"pw-justify-between\", \"pw-h-full\");\n const startSelfieDiv = document.createElement(\"div\");\n const navigationDiv = document.createElement(\"div\");\n navigationDiv.classList.add(\"pw-relative\", \"pw-text-center\", \"pw-mb-16\");\n const stepper = new stepper_1.default();\n const stepperElement = stepper.render(4, 5);\n navigationDiv.classList.add(\"pw-pt-3\");\n navigationDiv.appendChild(stepperElement);\n const closeButtonDiv = document.createElement(\"div\");\n closeButtonDiv.classList.add(\"pw-absolute\", \"pw-right-0\", \"pw-top-0\");\n const closeButton = (0, getGoogleIcon_1.getGoogleIcon)(\"close\");\n closeButton.addEventListener(\"click\", () => this.closeMainPage());\n closeButtonDiv.appendChild(closeButton);\n navigationDiv.appendChild(closeButtonDiv);\n startSelfieDiv.appendChild(navigationDiv);\n const iconDiv = document.createElement(\"div\");\n iconDiv.classList.add(\"pw-text-center\", \"pw-mb-9\");\n const icon = document.createElement(\"img\");\n icon.setAttribute(\"src\", icon_selfie_png_1.default);\n icon.setAttribute(\"alt\", \"eKYC Verification\");\n iconDiv.appendChild(icon);\n startSelfieDiv.appendChild(iconDiv);\n const wordingDiv = document.createElement(\"div\");\n wordingDiv.classList.add(\"pw-text-center\", \"pw-mb-4\");\n const titleDiv = document.createElement(\"div\");\n titleDiv.classList.add(\"pw-text-3xl\", \"pw-font-medium\", \"pw-mb-4\");\n titleDiv.innerHTML = \"Take a selfie\";\n wordingDiv.appendChild(titleDiv);\n const descriptionDiv = document.createElement(\"div\");\n descriptionDiv.innerHTML =\n \"Position your face in the frame and follow the instructions given. Do not wear sunglasses, hat or accessories. Background must be light and neutral.\";\n wordingDiv.appendChild(descriptionDiv);\n startSelfieDiv.appendChild(wordingDiv);\n selfiePageDiv.appendChild(startSelfieDiv);\n const startSelfieButton = (0, components_1.createPrimaryButton)(\"Start selfie\");\n startSelfieButton.addEventListener(\"click\", () => __awaiter(this, void 0, void 0, function* () {\n this.onClickSelfie();\n }));\n selfiePageDiv.appendChild(startSelfieButton);\n return selfiePageDiv;\n }\n createCameraDiv() {\n const screen = document.getElementById(this.mainScreenId);\n const cameraDiv = document.createElement(\"div\");\n cameraDiv.setAttribute(\"id\", this.cameraId);\n screen === null || screen === void 0 ? void 0 : screen.appendChild(cameraDiv);\n }\n uploadSelfie(detail) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n // show loading spinner in full pg\n (0, components_1.createFullLoading)(this.cameraId);\n const { image, livenessScore } = detail;\n yield uisdk_1.pwInstance.uploadSelfie({\n selfie_base64: image,\n liveness_score: livenessScore,\n });\n }\n finally {\n // hide loading spinner in full pg\n (0, components_1.hideFullLoading)(this.cameraId);\n }\n });\n }\n createEkycErrorPage() {\n var _a;\n const errorPage = this.openErrorPage(\"Submission error\", \"Unable to verify your documents. Please check your documents and resubmit again.\");\n const proceedButton = (0, components_1.createPrimaryButton)(\"Retry\");\n proceedButton.addEventListener(\"click\", () => {\n this.clearScreen();\n const firstPage = new StartPage_1.default(this.mainScreenId, this.displayMode, uisdk_1.pwInstance.verificationTypes);\n firstPage.render();\n });\n const proceedBtnDiv = document.createElement(\"div\");\n proceedBtnDiv.classList.add(\"pw-p-5\");\n proceedBtnDiv.appendChild(proceedButton);\n (_a = errorPage.querySelector(\"slot[name='footer']\")) === null || _a === void 0 ? void 0 : _a.appendChild(proceedBtnDiv);\n }\n viewEkycResult() {\n return __awaiter(this, void 0, void 0, function* () {\n // show loading page\n const loadingPage = new LoadingPage_1.default(this.mainScreenId, this.displayMode);\n // 1. first desc in loading screen\n this.clearScreen();\n loadingPage.render(\"Securely uploading the pictures to server\", \"Please do not close your browser, this may take a moment.\");\n // 2. after 3 seconds\n // update desc in loading screen, and call sdk\n yield new Promise((resolve) => setTimeout(resolve, 3000));\n loadingPage.title = \"Analysing the pictures\";\n const payload = yield uisdk_1.pwInstance.viewResult();\n const { status, is_retriable, id_status, selfie_status, id_type, result, filepaths, } = payload;\n // 3. Redirect to page\n this.clearScreen();\n // redirect to thank you page and show update btn\n if (status === \"approved\" || status === \"review\") {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n reviewEkyc.render({\n id_type,\n result,\n filepaths,\n });\n }\n // (fail: pending status / not able to retry)\n // redirect to thank you page and show ntg\n else if (!is_retriable || status === \"pending\") {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n reviewEkyc.render({\n id_type,\n filepaths,\n });\n }\n // (fail: rejected status - able to retry)\n // Pending: redirect to review error pg (tell user to redo)\n else\n this.createEkycErrorPage();\n return true;\n });\n }\n onClickSelfie() {\n this.createCameraDiv();\n const faceCamera = new face_camera_1.default(this.cameraId, this.mainScreenId);\n faceCamera.init();\n faceCamera.listenToSelfieCapture((e) => __awaiter(this, void 0, void 0, function* () {\n var _a, _b;\n try {\n faceCamera.pauseSmileFace();\n yield this.uploadSelfie(e.detail);\n faceCamera.stopVideoStream();\n yield this.viewEkycResult();\n }\n catch (err) {\n console.error(err);\n this.clearScreen();\n // 1. when exceed max attempt, redirect to thank you page\n if (err.type &&\n [\n \"openApi/max-selfie-attempt\",\n \"openApi/max-session-attempt\",\n \"openApi/limit-exceed\",\n \"openApi/session-id-expired\",\n \"attempt-exceeded\",\n \"session-id-expired\",\n ].includes(err.type)) {\n const reviewEkyc = new ReviewEkyc_1.default(this.mainScreenId, this.displayMode);\n return reviewEkyc.render();\n }\n // 2. when selfie is exposed, redirect to selfie error page\n else if (err.type && err.type === \"openApi/img-exposed\") {\n // redirect to selfie error page\n let isRetake = false;\n const pwErrorPayload = (_b = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.payload;\n if (!!pwErrorPayload)\n isRetake = !!pwErrorPayload.is_retriable;\n const selfieError = new SelfieError_1.default(this.mainScreenId, this.displayMode);\n return selfieError.render(isRetake);\n }\n // 3. when view ekyc result fail due to doc upload not verified, redirect to review error page\n else if (err.type &&\n [\n \"openApi/verification-type-invalid\",\n \"openApi/issuing-country-invalid\",\n \"openApi/doc-type-invalid\",\n \"openApi/doc-unpair\",\n \"openApi/doc-empty\",\n \"openApi/doc-blur\",\n \"openApi/doc-front-back-img-unsimilar\",\n \"openApi/doc-not-positioned-proper\",\n ].includes(err.type)) {\n // redirect to review error pg (tell user to redo)\n this.createEkycErrorPage();\n }\n this.openErrorPage();\n }\n }));\n }\n}\nexports[\"default\"] = StartSelfie;\n\n\n//# sourceURL=webpack://PWUISDK/./src/pageClass/StartSelfie.ts?");
|
|
3763
3763
|
|
|
3764
3764
|
/***/ }),
|
|
3765
3765
|
|