@sheerid/jslib-nightly
Version:
SheerID JavaScript Library
284 lines (282 loc) • 10.6 kB
JavaScript
/**
* VERSION: 2.130.0-alpha.4
* BUILD_TIMESTAMP: 1759000305348
* BUILD_DATE: Sat Sep 27 2025 19:11:45 GMT+0000 (Coordinated Universal Time)
* BUILD_COMMIT: be6ef87ab40e8747994d32363389cf39e36a4326
*/
import { l as b, j as e, ag as I, b as n, K as L, R as h, ah as R, A as v, ai as M, V as S, m as T, Z as u } from "../sheerid.js";
import { S as w } from "./index-Cu25bQnA.js";
const U = async (s, i, o) => {
b.info(`uploading files to ${s}`);
const t = new FormData();
return t.append("frontImage", i), t.append("backImage", o), fetch(s, {
method: "POST",
body: t
});
}, j = ({ fileToUpload: s, onRemove: i, setImage: o }) => {
var d;
const t = (d = s.file) == null ? void 0 : d.name;
return /* @__PURE__ */ e.jsxs("div", { className: "sid-step-id-check-loop__thumbnail-main-wrapper", children: [
/* @__PURE__ */ e.jsx("div", { className: "sid-step-id-check-loop__thumbnail-wrapper", children: /* @__PURE__ */ e.jsx(
"img",
{
className: "sid-step-id-check-loop__file-thumbnail",
src: s.url,
alt: "File thumbnail"
}
) }),
/* @__PURE__ */ e.jsxs("div", { className: "sid-step-id-check-loop__file-name-wrapper", children: [
/* @__PURE__ */ e.jsx("div", { className: "sid-step-id-check-loop__file-name", title: t, children: t }),
/* @__PURE__ */ e.jsx(
"div",
{
role: "button",
tabIndex: 0,
"aria-label": `Remove file ${t}`,
className: "sid-step-id-check-loop__remove-btn",
onClick: () => o(void 0),
onKeyDown: (c) => i(c, o)
}
)
] })
] });
};
var f = /* @__PURE__ */ ((s) => (s.FRONT = "FRONT", s.BACK = "BACK", s))(f || {});
const x = ({ addFile: s, upload: i, imageSide: o }) => {
const t = o === "FRONT", d = t ? "addFileFront" : "addFileBack", c = t ? "sid-font-photo-input" : "sid-back-photo-input", r = t ? "add front file" : "add back file", m = t ? "sid-font-photo-input" : "sid-back-photo-input";
return /* @__PURE__ */ e.jsx("div", { className: "sid-step-id-check-loop__file-upload-container", children: /* @__PURE__ */ e.jsx("label", { className: "sid-step-id-check-loop__label", htmlFor: c, "aria-label": r, children: /* @__PURE__ */ e.jsxs(
"div",
{
className: "sid-step-id-check-loop__upload-photo-container",
tabIndex: 0,
role: "button",
onKeyDown: (p) => s(p, d),
children: [
/* @__PURE__ */ e.jsx(I, { className: "sid-step-id-check-loop__icon" }),
/* @__PURE__ */ e.jsx("p", { className: "sid-step-id-check-loop__instructions", children: o === "FRONT" ? /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.addFontImage",
defaultMessage: "Add front of ID"
}
) : /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.addBackImage",
defaultMessage: "Add back of ID"
}
) }),
/* @__PURE__ */ e.jsx(
"input",
{
onChange: i,
type: "file",
id: m,
"data-testId": "photo-input",
hidden: !0,
accept: "image/jpeg,image/png",
multiple: !0,
ref: (p) => L(d, p)
}
)
]
}
) }) });
}, D = ({ verificationService: s }) => {
const i = s.verificationResponse, { uploadUrl: o, errorIds: t } = i, [d, c] = h.useState(), [r, m] = h.useState(), [p, y] = h.useState(!1), C = () => {
y(!p), U(o, d.file, r.file).then((a) => {
a.ok && s.submitStep(
S.idCheckLoop,
s.viewModel,
s.verificationResponse
);
}).catch((a) => {
b.error(`IdCheckLoop step failed to upload files to: ${o}. ${a}`);
});
}, g = (a, l) => {
const F = M(l);
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), a.stopPropagation(), F.click());
}, k = (a, l) => {
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), a.stopPropagation(), l(void 0));
}, _ = (a) => {
const l = a.target.files[0];
c({ file: l, url: URL.createObjectURL(l) });
}, N = (a) => {
const l = a.target.files[0];
m({ file: l, url: URL.createObjectURL(l) });
};
return p ? /* @__PURE__ */ e.jsx(R, { step: "idCheckLoop" }) : /* @__PURE__ */ e.jsxs("div", { className: "sid-step-id-check-loop__upload-wrapper", children: [
/* @__PURE__ */ e.jsx(v, { align: "center", children: /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.uploadTitle",
defaultMessage: "Upload government issued ID"
}
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-header__subtitle sid-l-horz-center sid-l-space-btm-md", children: /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.uploadSubtitle",
defaultMessage: "Make sure information on the document can be easily read. Avoid glares."
}
) }),
t && t.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "sid-step-id-check-loop__error-container", children: /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.uploadFileError",
defaultMessage: "There was an error uploading your files. Please try again."
}
) }),
/* @__PURE__ */ e.jsxs("div", { className: "sid-step-id-check-loop__upload-container", children: [
d ? /* @__PURE__ */ e.jsx(
j,
{
fileToUpload: d,
onRemove: k,
setImage: c
}
) : /* @__PURE__ */ e.jsx(
x,
{
addFile: g,
upload: _,
imageSide: f.FRONT
}
),
r ? /* @__PURE__ */ e.jsx(
j,
{
fileToUpload: r,
onRemove: k,
setImage: m
}
) : /* @__PURE__ */ e.jsx(
x,
{
addFile: g,
upload: N,
imageSide: f.BACK
}
)
] }),
/* @__PURE__ */ e.jsx("div", { className: "sid-submit sid-l-horz-center sid-l-space-top-md sid-l-space-btm-md", children: /* @__PURE__ */ e.jsx(
"button",
{
onClick: C,
type: "button",
className: "sid-btn sid-btn--dark",
"data-testId": "id-check-submit-button",
"aria-label": "submit",
disabled: !d || !r,
children: /* @__PURE__ */ e.jsx(n, { id: "step.idCheckLoop.regula.submit", defaultMessage: "Submit" })
}
) })
] });
}, O = D, P = ({ verificationService: s }) => /* @__PURE__ */ e.jsx(T, { verificationService: s, children: /* @__PURE__ */ e.jsxs("div", { children: [
/* @__PURE__ */ e.jsx("p", { children: /* @__PURE__ */ e.jsx(
u,
{
id: "step.idCheckLoop.regula.terms",
defaultMessage: 'By clicking "Continue", you agree you have read, understand, and accept the {privacyPolicyLink} and {termsOfService}.',
values: {
privacyPolicyLink: /* @__PURE__ */ e.jsx(
"a",
{
href: "https://regulaforensics.com/privacy/",
target: "_blank",
rel: "noopener noreferrer",
className: "sid-link",
children: /* @__PURE__ */ e.jsx(
u,
{
id: "step.idCheckLoop.privacyPolicy",
defaultMessage: "Privacy Policy"
}
)
}
),
termsOfService: /* @__PURE__ */ e.jsx(
"a",
{
href: "https://regulaforensics.com/terms-of-use/",
target: "_blank",
rel: "noopener noreferrer",
className: "sid-link",
children: /* @__PURE__ */ e.jsx(
u,
{
id: "step.idCheckLoop.termsOfService",
defaultMessage: "Terms of Service"
}
)
}
)
}
}
) }),
/* @__PURE__ */ e.jsx("p", { children: /* @__PURE__ */ e.jsx(u, { id: "companyName", defaultMessage: "{Company}", children: (i) => /* @__PURE__ */ e.jsx(
u,
{
id: "step.idCheckLoop.disclaimer",
defaultMessage: "SheerID, {companyName}'s trusted partner, use a third party, {serviceType}, to process our identity check.",
values: {
serviceType: "Regula",
companyName: i
}
}
) }) })
] }) }), K = ({ verificationService: s }) => {
const i = s.verificationResponse, [o, t] = h.useState(!1);
return h.useEffect(() => {
var d;
i && ((d = i == null ? void 0 : i.errorIds) == null ? void 0 : d.length) > 0 && t(!0);
}, [i]), /* @__PURE__ */ e.jsx("div", { id: "sid-step-id-check-loop", className: "sid-l-container", children: o ? /* @__PURE__ */ e.jsx("div", { role: "main", children: /* @__PURE__ */ e.jsx(O, { verificationService: s }) }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
/* @__PURE__ */ e.jsxs("div", { role: "main", children: [
/* @__PURE__ */ e.jsx(v, { align: "center", children: /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.regula.title",
defaultMessage: "To continue, we need to verify your identity."
}
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-header__subtitle sid-l-horz-center sid-l-space-btm-md", children: /* @__PURE__ */ e.jsx(
n,
{
id: "step.idCheckLoop.subtitle",
defaultMessage: "To complete the verification process, we ask that you provide us with:"
}
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-identity-check-steps", children: /* @__PURE__ */ e.jsx(
w,
{
title: "Photo of a government-issued ID",
subtitle: "Drivers license, state ID, passport, or residence permit.",
icon: /* @__PURE__ */ e.jsx(
"img",
{
className: "sid-identity-check-steps__icon",
alt: "",
src: "https://assets-resources.sheerid.com/common/images/2018/icons/upload-proof.svg"
}
),
isHighlighted: !0
},
""
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-submit sid-l-horz-center sid-l-space-top-md sid-l-space-btm-md", children: /* @__PURE__ */ e.jsx(
"button",
{
onClick: () => t(!o),
type: "button",
className: "sid-btn sid-btn--dark",
"aria-label": "submit",
children: /* @__PURE__ */ e.jsx(n, { id: "step.idCheckLoop.continue", defaultMessage: "Continue" })
}
) })
] }),
/* @__PURE__ */ e.jsx(P, { verificationService: s })
] }) });
};
export {
K as default
};