@evervault/react
Advanced tools
Comparing version 2.8.0 to 2.9.0
@@ -16,3 +16,3 @@ import { events } from 'events'; | ||
export declare function Card({ theme, fields, autoFocus, translations, onSwipe, onReady, onError, onChange, onComplete, autoComplete, }: CardProps): React_2.JSX.Element; | ||
export declare function Card({ theme, fields, autoFocus, translations, onSwipe, onReady, onError, onChange, onComplete, autoComplete, autoProgress, }: CardProps): React_2.JSX.Element; | ||
@@ -37,2 +37,3 @@ declare class Card_2 { | ||
} | undefined; | ||
autoProgress: boolean | undefined; | ||
}; | ||
@@ -101,2 +102,3 @@ }; | ||
translations?: Partial<CardTranslations>; | ||
autoProgress?: boolean; | ||
autoComplete?: { | ||
@@ -141,2 +143,3 @@ name?: boolean; | ||
autoComplete?: CardOptions["autoComplete"]; | ||
autoProgress?: boolean; | ||
} | ||
@@ -143,0 +146,0 @@ |
"use client"; | ||
import * as u from "react"; | ||
import { createContext as C, useContext as _, useState as S, useRef as m, useLayoutEffect as y, useEffect as g, useMemo as P, useCallback as B } from "react"; | ||
function D(o) { | ||
import { createContext as C, useContext as D, useState as S, useRef as m, useLayoutEffect as y, useEffect as E, useMemo as P, useCallback as B } from "react"; | ||
function M(o) { | ||
return (n) => ({ | ||
@@ -86,3 +86,3 @@ styles: { | ||
} | ||
function M(o) { | ||
function O(o) { | ||
return (n) => ({ | ||
@@ -173,3 +173,3 @@ styles: { | ||
} | ||
function O(o) { | ||
function Y(o) { | ||
return (n) => ({ | ||
@@ -309,9 +309,9 @@ styles: { | ||
} | ||
const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
__proto__: null, | ||
clean: D, | ||
material: M, | ||
minimal: O | ||
clean: M, | ||
material: O, | ||
minimal: Y | ||
}, Symbol.toStringTag, { value: "Module" })), R = C(null); | ||
function b() { | ||
function x() { | ||
if (typeof window > "u") | ||
@@ -334,3 +334,3 @@ return null; | ||
function T() { | ||
const o = _(I); | ||
const o = D(I); | ||
if (!o) | ||
@@ -340,6 +340,6 @@ throw new Error("Reveal consumers must be used within a Reveal component"); | ||
} | ||
function Y({ | ||
function U({ | ||
path: o, | ||
onCopy: n, | ||
...r | ||
...t | ||
}) { | ||
@@ -353,7 +353,7 @@ const [i, f] = S(null), d = m(null), { reveal: e } = T(); | ||
return; | ||
const a = e == null ? void 0 : e.copyButton(o, r); | ||
const a = e == null ? void 0 : e.copyButton(o, t); | ||
a.mount(d.current), f(a); | ||
}, [e, o, r, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
}, [e, o, t, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
} | ||
function U({ path: o, theme: n, format: r }) { | ||
function V({ path: o, theme: n, format: t }) { | ||
const [i, f] = S(null), d = m(null), { reveal: e } = T(); | ||
@@ -365,16 +365,16 @@ return y(() => { | ||
theme: n, | ||
format: r | ||
format: t | ||
}); | ||
a.mount(d.current), f(a); | ||
}, [e, o, n, r, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
}, [e, o, n, t, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
} | ||
function j({ request: o, children: n, onReady: r, onError: i }) { | ||
const f = m(!1), d = b(), [e, a] = S(null), c = m(null); | ||
function j({ request: o, children: n, onReady: t, onError: i }) { | ||
const f = m(!1), d = x(), [e, a] = S(null), c = m(null); | ||
return u.useEffect(() => { | ||
if (!(!e || !r)) | ||
return e == null ? void 0 : e.on("ready", r); | ||
}, [e, r]), u.useEffect(() => { | ||
if (!(!e || !t)) | ||
return e == null ? void 0 : e.on("ready", t); | ||
}, [e, t]), u.useEffect(() => { | ||
if (!(!e || !i)) | ||
return e == null ? void 0 : e.on("error", i); | ||
}, [e, i]), g(() => { | ||
}, [e, i]), E(() => { | ||
if (!c.current || f.current) | ||
@@ -384,7 +384,7 @@ return; | ||
f.current = !0; | ||
const t = await d; | ||
if (!t) | ||
const r = await d; | ||
if (!r) | ||
return; | ||
const p = t.ui.reveal(o); | ||
a(p); | ||
const v = r.ui.reveal(o); | ||
a(v); | ||
} | ||
@@ -394,8 +394,8 @@ s().catch(console.error); | ||
} | ||
j.Text = U; | ||
j.CopyButton = Y; | ||
function K({ | ||
j.Text = V; | ||
j.CopyButton = U; | ||
function N({ | ||
theme: o, | ||
fields: n, | ||
autoFocus: r, | ||
autoFocus: t, | ||
translations: i, | ||
@@ -407,51 +407,53 @@ onSwipe: f, | ||
onComplete: c, | ||
autoComplete: s | ||
autoComplete: s, | ||
autoProgress: r | ||
}) { | ||
const t = b(), p = m(!1), v = m(null), [l, x] = u.useState(null); | ||
g(() => { | ||
const v = x(), p = m(!1), h = m(null), [l, b] = u.useState(null); | ||
E(() => { | ||
if (!(!l || !d)) | ||
return l == null ? void 0 : l.on("ready", d); | ||
}, [l, d]), g(() => { | ||
}, [l, d]), E(() => { | ||
if (!(!l || !e)) | ||
return l == null ? void 0 : l.on("error", e); | ||
}, [l, e]), g(() => { | ||
}, [l, e]), E(() => { | ||
if (!(!l || !f)) | ||
return l == null ? void 0 : l.on("swipe", f); | ||
}, [l, f]), g(() => { | ||
}, [l, f]), E(() => { | ||
if (!(!l || !a)) | ||
return l == null ? void 0 : l.on("change", a); | ||
}, [l, a]), g(() => { | ||
}, [l, a]), E(() => { | ||
if (!(!l || !c)) | ||
return l == null ? void 0 : l.on("complete", c); | ||
}, [l, c]); | ||
const h = P( | ||
const g = P( | ||
() => ({ | ||
theme: o, | ||
fields: n, | ||
autoFocus: r, | ||
autoFocus: t, | ||
translations: i, | ||
autoComplete: s | ||
autoComplete: s, | ||
autoProgress: r | ||
}), | ||
[o, i, n, r, s] | ||
[o, i, n, t, s, r] | ||
); | ||
return y(() => { | ||
if (!v.current) | ||
if (!h.current) | ||
return; | ||
async function E() { | ||
if (p.current || !v.current) | ||
async function _() { | ||
if (p.current || !h.current) | ||
return; | ||
p.current = !0; | ||
const z = await t; | ||
const z = await v; | ||
if (!z) | ||
return; | ||
const L = z.ui.card(h); | ||
L.mount(v.current), x(L); | ||
const L = z.ui.card(g); | ||
L.mount(h.current), b(L); | ||
} | ||
l ? l.update(h) : E().catch(console.error); | ||
}, [h, l]), /* @__PURE__ */ u.createElement("div", { ref: v }); | ||
l ? l.update(g) : _().catch(console.error); | ||
}, [g, l]), /* @__PURE__ */ u.createElement("div", { ref: h }); | ||
} | ||
function N({ | ||
function Q({ | ||
theme: o, | ||
autoFocus: n, | ||
mode: r, | ||
mode: t, | ||
inputType: i, | ||
@@ -463,14 +465,14 @@ length: f, | ||
}) { | ||
const c = b(), s = m(!1), [t, p] = u.useState(null), v = m(null); | ||
const c = x(), s = m(!1), [r, v] = u.useState(null), p = m(null); | ||
u.useEffect(() => { | ||
if (!(!t || !d)) | ||
return t == null ? void 0 : t.on("ready", d); | ||
}, [t, d]), u.useEffect(() => { | ||
if (!(!t || !a)) | ||
return t == null ? void 0 : t.on("error", a); | ||
}, [t, a]), u.useEffect(() => { | ||
if (!(!t || !e)) | ||
return t == null ? void 0 : t.on("change", e); | ||
}, [t, e]); | ||
const l = P( | ||
if (!(!r || !d)) | ||
return r == null ? void 0 : r.on("ready", d); | ||
}, [r, d]), u.useEffect(() => { | ||
if (!(!r || !a)) | ||
return r == null ? void 0 : r.on("error", a); | ||
}, [r, a]), u.useEffect(() => { | ||
if (!(!r || !e)) | ||
return r == null ? void 0 : r.on("change", e); | ||
}, [r, e]); | ||
const h = P( | ||
() => ({ | ||
@@ -480,27 +482,27 @@ theme: o, | ||
autoFocus: n, | ||
mode: r, | ||
mode: t, | ||
inputType: i | ||
}), | ||
[o, f, n, r, i] | ||
[o, f, n, t, i] | ||
); | ||
return y(() => { | ||
if (!v.current) | ||
if (!p.current) | ||
return; | ||
async function x() { | ||
if (s.current || !v.current) | ||
async function l() { | ||
if (s.current || !p.current) | ||
return; | ||
s.current = !0; | ||
const h = await c; | ||
if (!h) | ||
const b = await c; | ||
if (!b) | ||
return; | ||
const E = h.ui.pin(l); | ||
E.mount(v.current), p(E); | ||
const g = b.ui.pin(h); | ||
g.mount(p.current), v(g); | ||
} | ||
t ? t.update(l) : x().catch(console.error); | ||
}, [t, l]), /* @__PURE__ */ u.createElement("div", { ref: v }); | ||
r ? r.update(h) : l().catch(console.error); | ||
}, [r, h]), /* @__PURE__ */ u.createElement("div", { ref: p }); | ||
} | ||
function Q({ | ||
function W({ | ||
session: o, | ||
theme: n, | ||
size: r, | ||
size: t, | ||
onReady: i, | ||
@@ -511,47 +513,47 @@ onError: f, | ||
}) { | ||
const a = b(), c = u.useRef(!1), s = u.useRef(null), [t, p] = u.useState( | ||
const a = x(), c = u.useRef(!1), s = u.useRef(null), [r, v] = u.useState( | ||
null | ||
); | ||
u.useEffect(() => { | ||
if (!(!t || !i)) | ||
return t == null ? void 0 : t.on("ready", i); | ||
}, [t, i]), u.useEffect(() => { | ||
if (!(!t || !d)) | ||
return t == null ? void 0 : t.on("success", d); | ||
}, [t, d]), u.useEffect(() => { | ||
if (!(!t || !e)) | ||
return t == null ? void 0 : t.on("failure", e); | ||
}, [t, e]), u.useEffect(() => { | ||
if (!(!t || !f)) | ||
return t == null ? void 0 : t.on("error", f); | ||
}, [t, f]); | ||
const v = u.useMemo( | ||
if (!(!r || !i)) | ||
return r == null ? void 0 : r.on("ready", i); | ||
}, [r, i]), u.useEffect(() => { | ||
if (!(!r || !d)) | ||
return r == null ? void 0 : r.on("success", d); | ||
}, [r, d]), u.useEffect(() => { | ||
if (!(!r || !e)) | ||
return r == null ? void 0 : r.on("failure", e); | ||
}, [r, e]), u.useEffect(() => { | ||
if (!(!r || !f)) | ||
return r == null ? void 0 : r.on("error", f); | ||
}, [r, f]); | ||
const p = u.useMemo( | ||
() => ({ | ||
theme: n, | ||
size: r | ||
size: t | ||
}), | ||
[n, r] | ||
[n, t] | ||
); | ||
return u.useLayoutEffect(() => { | ||
async function l() { | ||
async function h() { | ||
if (c.current) | ||
return; | ||
c.current = !0; | ||
const x = await a; | ||
if (!x) | ||
const l = await a; | ||
if (!l) | ||
return; | ||
const h = x.ui.threeDSecure(o, v); | ||
h.mount(s.current), p(h); | ||
const b = l.ui.threeDSecure(o, p); | ||
b.mount(s.current), v(b); | ||
} | ||
t ? t.update(v) : l().catch(console.error); | ||
}, [t, o, v]), /* @__PURE__ */ u.createElement("div", { ref: s }); | ||
r ? r.update(p) : h().catch(console.error); | ||
}, [r, o, p]), /* @__PURE__ */ u.createElement("div", { ref: s }); | ||
} | ||
function W(o) { | ||
const n = b(), r = m(null), i = B( | ||
function X(o) { | ||
const n = x(), t = m(null), i = B( | ||
(d, e) => { | ||
if (r.current) | ||
if (t.current) | ||
return; | ||
async function a() { | ||
const c = await n; | ||
c && (r.current = c.ui.threeDSecure(d, o), e != null && e.onReady && r.current.on("ready", e.onReady), e != null && e.onSuccess && r.current.on("success", e.onSuccess), e != null && e.onFailure && r.current.on("failure", e.onFailure), e != null && e.onError && r.current.on("error", e.onError), r.current.mount()); | ||
c && (t.current = c.ui.threeDSecure(d, o), e != null && e.onReady && t.current.on("ready", e.onReady), e != null && e.onSuccess && t.current.on("success", e.onSuccess), e != null && e.onFailure && t.current.on("failure", e.onFailure), e != null && e.onError && t.current.on("error", e.onError), t.current.mount()); | ||
} | ||
@@ -562,3 +564,3 @@ a(); | ||
), f = B((d) => { | ||
r.current && r.current.update(d); | ||
t.current && t.current.update(d); | ||
}, []); | ||
@@ -570,24 +572,24 @@ return { | ||
} | ||
class V extends Promise { | ||
class A extends Promise { | ||
async encrypt(n) { | ||
return (await this).encrypt(n); | ||
} | ||
async decrypt(n, r) { | ||
return (await this).decrypt(n, r); | ||
async decrypt(n, t) { | ||
return (await this).decrypt(n, t); | ||
} | ||
} | ||
const A = "https://js.evervault.com/v2"; | ||
function H(o) { | ||
const H = "https://js.evervault.com/v2"; | ||
function q(o) { | ||
const n = document.createElement("script"); | ||
o ? n.src = o : n.src = A; | ||
const r = document.head || document.body; | ||
if (!r) | ||
o ? n.src = o : n.src = H; | ||
const t = document.head || document.body; | ||
if (!t) | ||
throw new Error( | ||
"Expected document.body not to be null. Evervault.js requires a <body> element." | ||
); | ||
return r.appendChild(n), n; | ||
return t.appendChild(n), n; | ||
} | ||
let w = null; | ||
function q(o) { | ||
return w !== null || (w = new Promise((n, r) => { | ||
function F(o) { | ||
return w !== null || (w = new Promise((n, t) => { | ||
if (typeof window > "u") { | ||
@@ -602,24 +604,24 @@ n(void 0); | ||
try { | ||
const i = H(o); | ||
const i = q(o); | ||
i.addEventListener("load", () => { | ||
window.Evervault ? n(window.Evervault) : r(new Error("Evervault.js not available")); | ||
window.Evervault ? n(window.Evervault) : t(new Error("Evervault.js not available")); | ||
}), i.addEventListener("error", () => { | ||
r(new Error("Failed to load Evervault.js")); | ||
t(new Error("Failed to load Evervault.js")); | ||
}); | ||
} catch (i) { | ||
r(i); | ||
t(i); | ||
} | ||
})), w; | ||
} | ||
function F(o) { | ||
const n = Promise.resolve().then(() => q(o)); | ||
let r = !1; | ||
function G(o) { | ||
const n = Promise.resolve().then(() => F(o)); | ||
let t = !1; | ||
return n.catch((i) => { | ||
r || console.warn(i); | ||
}), r = !0, n.then((i) => typeof window < "u" ? window.Evervault : i ?? void 0); | ||
t || console.warn(i); | ||
}), t = !0, n.then((i) => typeof window < "u" ? window.Evervault : i ?? void 0); | ||
} | ||
const X = ({ | ||
const Z = ({ | ||
teamId: o, | ||
appId: n, | ||
customConfig: r, | ||
customConfig: t, | ||
children: i, | ||
@@ -631,5 +633,5 @@ ...f | ||
const d = u.useMemo( | ||
() => new V((e, a) => { | ||
F(r == null ? void 0 : r.jsSdkUrl).then((c) => { | ||
c !== void 0 ? e(new c(o, n, r)) : (console.error("Evervault.js not available"), a("Evervault.js not available")); | ||
() => new A((e, a) => { | ||
G(t == null ? void 0 : t.jsSdkUrl).then((c) => { | ||
c !== void 0 ? e(new c(o, n, t)) : (console.error("Evervault.js not available"), a("Evervault.js not available")); | ||
}).catch((c) => a(c)); | ||
@@ -641,6 +643,6 @@ }), | ||
}; | ||
function Z({ | ||
function $({ | ||
onChange: o, | ||
config: n, | ||
onInputsLoad: r | ||
onInputsLoad: t | ||
}) { | ||
@@ -650,16 +652,16 @@ const i = u.useId(); | ||
return /* @__PURE__ */ u.createElement("div", { id: i }); | ||
const f = b(), { height: d = "auto", ...e } = n ?? {}, a = e ? { height: d, ...e } : { height: d }; | ||
const f = x(), { height: d = "auto", ...e } = n ?? {}, a = e ? { height: d, ...e } : { height: d }; | ||
return u.useEffect(() => { | ||
f == null || f.then((c) => { | ||
const s = c.inputs(i, a); | ||
s == null || s.on("change", (t) => { | ||
typeof o == "function" && o(t); | ||
}), r && (s == null ? void 0 : s.isInputsLoaded) != null && s.isInputsLoaded instanceof Promise && s.isInputsLoaded.then(() => r()); | ||
s == null || s.on("change", (r) => { | ||
typeof o == "function" && o(r); | ||
}), t && (s == null ? void 0 : s.isInputsLoaded) != null && s.isInputsLoaded instanceof Promise && s.isInputsLoaded.then(() => t()); | ||
}); | ||
}, [f]), /* @__PURE__ */ u.createElement("div", { id: i }); | ||
} | ||
function $({ | ||
function k({ | ||
request: o, | ||
config: n, | ||
onCopy: r, | ||
onCopy: t, | ||
onRevealLoad: i, | ||
@@ -671,10 +673,10 @@ onRevealError: f | ||
return /* @__PURE__ */ u.createElement("div", { id: d }); | ||
const e = b(), { height: a = "auto", ...c } = n ?? {}, s = c ? { height: a, ...c } : { height: a }; | ||
const e = x(), { height: a = "auto", ...c } = n ?? {}, s = c ? { height: a, ...c } : { height: a }; | ||
return u.useEffect(() => { | ||
e == null || e.then((t) => { | ||
const p = t.reveal(d, o, s, r); | ||
(p == null ? void 0 : p.isRevealLoaded) != null && p.isRevealLoaded instanceof Promise && p.isRevealLoaded.then(() => { | ||
e == null || e.then((r) => { | ||
const v = r.reveal(d, o, s, t); | ||
(v == null ? void 0 : v.isRevealLoaded) != null && v.isRevealLoaded instanceof Promise && v.isRevealLoaded.then(() => { | ||
i && i(); | ||
}).catch((v) => { | ||
f && f(v); | ||
}).catch((p) => { | ||
f && f(p); | ||
}); | ||
@@ -685,13 +687,13 @@ }); | ||
export { | ||
K as Card, | ||
Z as EvervaultInput, | ||
X as EvervaultProvider, | ||
$ as EvervaultReveal, | ||
N as Pin, | ||
V as PromisifiedEvervaultClient, | ||
N as Card, | ||
$ as EvervaultInput, | ||
Z as EvervaultProvider, | ||
k as EvervaultReveal, | ||
Q as Pin, | ||
A as PromisifiedEvervaultClient, | ||
j as Reveal, | ||
Q as ThreeDSecure, | ||
J as themes, | ||
b as useEvervault, | ||
W as useThreeDSecure | ||
W as ThreeDSecure, | ||
K as themes, | ||
x as useEvervault, | ||
X as useThreeDSecure | ||
}; |
{ | ||
"private": false, | ||
"name": "@evervault/react", | ||
"version": "2.8.0", | ||
"version": "2.9.0", | ||
"description": "React package for the Evervault SDK", | ||
@@ -36,6 +36,6 @@ "license": "MIT", | ||
"vite-plugin-dts": "^3.6.3", | ||
"types": "^0.2.0", | ||
"themes": "^0.1.2", | ||
"tsconfig": "^0.0.1", | ||
"@evervault/browser": "^2.27.0" | ||
"themes": "^0.1.3", | ||
"@evervault/browser": "^2.28.0", | ||
"types": "^0.3.0", | ||
"tsconfig": "^0.0.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80448
1725