@evervault/react
Advanced tools
Comparing version 2.13.0 to 2.14.0
@@ -6,2 +6,202 @@ import { events } from 'events'; | ||
declare class ApplePay { | ||
#private; | ||
constructor(client: EvervaultClient, transaction: Transaction, options: ApplePayOptions); | ||
get config(): { | ||
config: { | ||
type: ApplePayButtonType | undefined; | ||
style: ApplePayButtonStyle | undefined; | ||
locale: ApplePayButtonLocale | undefined; | ||
borderRadius: number | undefined; | ||
allowedCardNetworks: ApplePayCardNetwork[] | undefined; | ||
transaction: TransactionDetails; | ||
paymentRequest: ApplePayPaymentRequest | undefined; | ||
}; | ||
}; | ||
mount(selector: SelectorType): this; | ||
update(options?: ApplePayOptions): this; | ||
unmount(): this; | ||
on<T extends keyof ApplePayEvents>(event: T, callback: ApplePayEvents[T]): () => void; | ||
} | ||
declare type ApplePayAutomaticReloadPaymentRequest = BaseApplePayPaymentRequest & { | ||
automaticReloadPaymentRequest: ApplePayJS.ApplePayAutomaticReloadPaymentRequest; | ||
multiTokenContexts?: never; | ||
recurringPaymentRequest?: never; | ||
deferredPaymentRequest?: never; | ||
}; | ||
export declare type ApplePayButtonLocale = | ||
| "ar-AB" | ||
| "ca-ES" | ||
| "cs-CZ" | ||
| "da-DK" | ||
| "de-DE" | ||
| "el-GR" | ||
| "en-AU" | ||
| "en-GB" | ||
| "en-US" | ||
| "es-ES" | ||
| "es-MX" | ||
| "fi-FI" | ||
| "fr-CA" | ||
| "fr-FR" | ||
| "he-IL" | ||
| "hi-IN" | ||
| "hr-HR" | ||
| "hu-HU" | ||
| "id-ID" | ||
| "it-IT" | ||
| "ja-JP" | ||
| "ko-KR" | ||
| "ms-MY" | ||
| "nb-NO" | ||
| "nl-NL" | ||
| "pl-PL" | ||
| "pt-BR" | ||
| "pt-PT" | ||
| "ro-RO" | ||
| "ru-RU" | ||
| "sk-SK" | ||
| "sv-SE" | ||
| "th-TH" | ||
| "tr-TR" | ||
| "uk-UA" | ||
| "vi-VN" | ||
| "zh-CN" | ||
| "zh-HK" | ||
| "zh-TW"; | ||
export declare type ApplePayButtonStyle = "black" | "white" | "white-outline"; | ||
export declare type ApplePayButtonType = | ||
| "add-money" | ||
| "book" | ||
| "buy" | ||
| "check-out" | ||
| "continue" | ||
| "contribute" | ||
| "donate" | ||
| "order" | ||
| "pay" | ||
| "plain" | ||
| "reload" | ||
| "rent" | ||
| "set-up" | ||
| "subscribe" | ||
| "support" | ||
| "tip" | ||
| "top-up"; | ||
export declare type ApplePayCardNetwork = | ||
| "amex" | ||
| "bancomat" | ||
| "bancontact" | ||
| "cartesBancaires" | ||
| "chinaUnionPay" | ||
| "dankort" | ||
| "discover" | ||
| "eftpos" | ||
| "electron" | ||
| "elo" | ||
| "girocard" | ||
| "interac" | ||
| "jcb" | ||
| "mada" | ||
| "maestro" | ||
| "masterCard" | ||
| "mir" | ||
| "privateLabel" | ||
| "visa" | ||
| "vPay"; | ||
export declare interface ApplePayClientMessages extends EvervaultFrameClientMessages { | ||
EV_APPLE_PAY_AUTH: EncryptedApplePayData; | ||
EV_APPLE_PAY_CANCELLED: undefined; | ||
EV_APPLE_PAY_ERROR: string; | ||
EV_APPLE_PAY_SUCCESS: undefined; | ||
} | ||
declare type ApplePayDeferredPaymentRequest = BaseApplePayPaymentRequest & { | ||
deferredPaymentRequest: ApplePayJS.ApplePayDeferredPaymentRequest; | ||
recurringPaymentRequest?: never; | ||
automaticReloadPaymentRequest?: never; | ||
}; | ||
export declare interface ApplePayErrorMessage { | ||
message: string | ||
code?: ApplePayJS.ApplePayErrorCode; | ||
contactField?: ApplePayJS.ApplePayErrorContactField; | ||
} | ||
declare interface ApplePayEvents { | ||
ready: () => void; | ||
success: () => void; | ||
error: (error: string) => void; | ||
cancel: () => void; | ||
} | ||
export declare interface ApplePayHostMessages extends EvervaultFrameHostMessages { | ||
EV_APPLE_PAY_COMPLETION: undefined; | ||
EV_APPLE_PAY_AUTH_ERROR: ApplePayErrorMessage; | ||
EV_APPLE_PAY_SUCCESS: undefined; | ||
} | ||
export declare interface ApplePayOptions { | ||
process: ( | ||
data: EncryptedApplePayData, | ||
helpers: { | ||
fail: (error: ApplePayErrorMessage) => void; | ||
} | ||
) => Promise<void>; | ||
type?: ApplePayButtonType; | ||
style?: ApplePayButtonStyle; | ||
locale?: ApplePayButtonLocale; | ||
padding?: string; | ||
borderRadius?: number; | ||
size?: { width: WalletDimension; height: WalletDimension }; | ||
allowedCardNetworks?: ApplePayCardNetwork[]; | ||
paymentRequest?: ApplePayPaymentRequest; | ||
} | ||
export declare interface ApplePayPaymentDataRequest { | ||
encryptedCredentials: ApplePayToken; | ||
} | ||
export declare type ApplePayPaymentRequest = | ||
| ApplePayRecurringPaymentRequest | ||
| ApplePayDeferredPaymentRequest | ||
| ApplePayAutomaticReloadPaymentRequest | ||
| ApplePayStandardPaymentRequest; | ||
declare type ApplePayRecurringPaymentRequest = BaseApplePayPaymentRequest & { | ||
recurringPaymentRequest: ApplePayJS.ApplePayRecurringPaymentRequest; | ||
deferredPaymentRequest?: never; | ||
automaticReloadPaymentRequest?: never; | ||
}; | ||
declare type ApplePayStandardPaymentRequest = BaseApplePayPaymentRequest & { | ||
recurringPaymentRequest?: never; | ||
multiTokenContexts?: never; | ||
deferredPaymentRequest?: never; | ||
automaticReloadPaymentRequest?: never; | ||
}; | ||
export declare interface ApplePayToken { | ||
version: string; | ||
data: string; | ||
signature: string; | ||
header: { | ||
ephemeralPublicKey?: string; | ||
wrappedKey?: string; | ||
publicKeyHash: string; | ||
transactionId: string; | ||
applicatoinData?: string; | ||
}; | ||
} | ||
declare type BaseApplePayPaymentRequest = { | ||
lineItems?: ApplePayJS.ApplePayLineItem[]; | ||
}; | ||
declare interface CageKey { | ||
@@ -17,3 +217,3 @@ teamUuid: string; | ||
export declare function Card({ theme, icons, fields, autoFocus, translations, onSwipe, onReady, onError, onChange, onComplete, autoComplete, autoProgress, acceptedBrands, defaultValues, }: CardProps): React_2.JSX.Element; | ||
export declare function Card({ theme, icons, fields, autoFocus, translations, onSwipe, onReady, onError, onChange, onComplete, onFocus, onBlur, onKeyUp, onKeyDown, autoComplete, autoProgress, acceptedBrands, defaultValues, }: CardProps): React_2.JSX.Element; | ||
@@ -75,2 +275,6 @@ declare class Card_2 { | ||
validate: (payload: CardPayload) => void; | ||
focus: (event: FieldEvent) => void; | ||
blur: (event: FieldEvent) => void; | ||
keydown: (event: FieldEvent) => void; | ||
keyup: (event: FieldEvent) => void; | ||
} | ||
@@ -97,2 +301,6 @@ | ||
EV_VALIDATED: CardPayload; | ||
EV_FOCUS: CardField; | ||
EV_BLUR: CardField; | ||
EV_KEYDOWN: CardField; | ||
EV_KEYUP: CardField; | ||
} | ||
@@ -164,2 +372,6 @@ | ||
}; | ||
onFocus?: (event: FieldEvent) => void; | ||
onBlur?: (event: FieldEvent) => void; | ||
onKeyUp?: (event: FieldEvent) => void; | ||
onKeyDown?: (event: FieldEvent) => void; | ||
} | ||
@@ -373,2 +585,33 @@ | ||
export declare type EncryptedApplePayData = EncryptedDPAN<"apple">; | ||
export declare interface EncryptedDPAN<P> { | ||
token: { | ||
tokenServiceProvider: P; | ||
number: string; | ||
expiry: { | ||
month: string; | ||
year: string; | ||
}; | ||
}; | ||
card: { | ||
brand: string; | ||
}; | ||
cryptogram: string; | ||
eci: string; | ||
} | ||
export declare interface EncryptedFPAN { | ||
card: { | ||
brand: string; | ||
number: string; | ||
expiry: { | ||
month: string; | ||
year: string; | ||
}; | ||
}; | ||
} | ||
export declare type EncryptedGooglePayData = EncryptedDPAN<"google"> | EncryptedFPAN; | ||
declare const encryptionConstants: { | ||
@@ -469,2 +712,5 @@ cipherAlgorithm: "aes-256-gcm"; | ||
isInDebugMode(): boolean; | ||
get transactions(): { | ||
create: (details: TransactionDetails) => Transaction; | ||
}; | ||
} | ||
@@ -474,3 +720,3 @@ | ||
EV_ERROR: ComponentError | undefined; | ||
EV_RESIZE: { height: number }; | ||
EV_RESIZE: { height: number; width?: number }; | ||
EV_FRAME_READY: undefined; | ||
@@ -532,2 +778,7 @@ EV_FRAME_HANDSHAKE: undefined; | ||
export declare interface FieldEvent { | ||
field: CardField; | ||
data: CardPayload; | ||
} | ||
declare class Form { | ||
@@ -566,2 +817,110 @@ #private; | ||
declare class GooglePay { | ||
#private; | ||
constructor(client: EvervaultClient, transaction: Transaction, options: GooglePayOptions); | ||
get config(): { | ||
config: { | ||
transaction: TransactionDetails; | ||
type: GooglePayButtonType | undefined; | ||
color: GooglePayButtonColor | undefined; | ||
locale: GooglePayButtonLocale | undefined; | ||
borderRadius: number | undefined; | ||
environment: "TEST" | "PRODUCTION" | undefined; | ||
allowedAuthMethods: google.payments.api.CardAuthMethod[] | undefined; | ||
allowedCardNetworks: google.payments.api.CardNetwork[] | undefined; | ||
}; | ||
}; | ||
mount(selector: SelectorType): this; | ||
unmount(): this; | ||
on<T extends keyof GooglePayEvents>(event: T, callback: GooglePayEvents[T]): () => void; | ||
} | ||
export declare type GooglePayButtonColor = "black" | "white"; | ||
export declare type GooglePayButtonLocale = | ||
| "en" | ||
| "ar" | ||
| "bg" | ||
| "ca" | ||
| "cs" | ||
| "da" | ||
| "de" | ||
| "el" | ||
| "es" | ||
| "et" | ||
| "fi" | ||
| "fr" | ||
| "hr" | ||
| "id" | ||
| "it" | ||
| "ja" | ||
| "ko" | ||
| "ms" | ||
| "nl" | ||
| "no" | ||
| "pl" | ||
| "pt" | ||
| "ru" | ||
| "sk" | ||
| "sl" | ||
| "sr" | ||
| "sv" | ||
| "th" | ||
| "tr" | ||
| "uk" | ||
| "zh"; | ||
export declare type GooglePayButtonType = | ||
| "book" | ||
| "buy" | ||
| "checkout" | ||
| "donate" | ||
| "order" | ||
| "pay" | ||
| "plain" | ||
| "subscribe"; | ||
export declare interface GooglePayClientMessages extends EvervaultFrameClientMessages { | ||
EV_GOOGLE_PAY_AUTH: EncryptedGooglePayData; | ||
EV_GOOGLE_PAY_CANCELLED: undefined; | ||
EV_GOOGLE_PAY_ERROR: string; | ||
EV_GOOGLE_PAY_SUCCESS: undefined; | ||
} | ||
export declare interface GooglePayErrorMessage { | ||
message: string; | ||
reason?: google.payments.api.ErrorReason; | ||
intent?: google.payments.api.CallbackIntent; | ||
} | ||
declare interface GooglePayEvents { | ||
ready: () => void; | ||
success: () => void; | ||
error: (error: string) => void; | ||
cancel: () => void; | ||
} | ||
export declare interface GooglePayHostMessages extends EvervaultFrameHostMessages { | ||
EV_GOOGLE_PAY_AUTH_COMPLETE: undefined; | ||
EV_GOOGLE_PAY_AUTH_ERROR: GooglePayErrorMessage; | ||
EV_GOOGLE_PAY_SUCCESS: undefined; | ||
} | ||
export declare interface GooglePayOptions { | ||
process: ( | ||
data: EncryptedGooglePayData, | ||
helpers: { | ||
fail: (error: GooglePayErrorMessage) => void; | ||
} | ||
) => Promise<void>; | ||
type?: GooglePayButtonType; | ||
color?: GooglePayButtonColor; | ||
locale?: GooglePayButtonLocale; | ||
borderRadius?: number; | ||
size?: { width: WalletDimension; height: WalletDimension }; | ||
allowedAuthMethods?: google.payments.api.CardAuthMethod[]; | ||
allowedCardNetworks?: google.payments.api.CardNetwork[]; | ||
environment?: "TEST" | "PRODUCTION"; | ||
} | ||
declare interface HttpConfig { | ||
@@ -1182,2 +1541,24 @@ keysUrl: string; | ||
declare class Transaction { | ||
details: TransactionDetails; | ||
constructor(details: TransactionDetails); | ||
} | ||
export declare interface TransactionDetails { | ||
amount: number; | ||
currency: string; | ||
country: string; | ||
merchant: { | ||
id: string; | ||
name: string; | ||
applePayIdentifier?: string; | ||
}; | ||
lineItems?: TransactionLineItem[]; | ||
} | ||
export declare interface TransactionLineItem { | ||
amount: number; | ||
label: string; | ||
} | ||
export declare interface TranslationsObject { | ||
@@ -1201,2 +1582,4 @@ [key: string]: string | TranslationsObject | undefined; | ||
threeDSecure(session: string, opts?: ThreeDSecureOptions): ThreeDSecure_2; | ||
googlePay(tx: Transaction, opts: GooglePayOptions): GooglePay; | ||
applePay(tx: Transaction, opts: ApplePayOptions): ApplePay; | ||
} | ||
@@ -1226,2 +1609,4 @@ | ||
export declare type WalletDimension = string | number; | ||
export { } |
"use client"; | ||
import * as u from "react"; | ||
import { createContext as I, useContext as Y, useState as L, useRef as h, useLayoutEffect as R, useEffect as g, useMemo as T, useCallback as P } from "react"; | ||
function U(o) { | ||
import * as d from "react"; | ||
import { createContext as _, useContext as q, useState as C, useRef as b, useLayoutEffect as S, useEffect as h, useMemo as M, useCallback as j } from "react"; | ||
function G(o) { | ||
return (n) => ({ | ||
@@ -103,3 +103,3 @@ styles: { | ||
} | ||
function A(o) { | ||
function J(o) { | ||
return (n) => ({ | ||
@@ -207,3 +207,3 @@ styles: { | ||
} | ||
function H(o) { | ||
function N(o) { | ||
return (n) => ({ | ||
@@ -357,16 +357,16 @@ styles: { | ||
} | ||
const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
__proto__: null, | ||
clean: U, | ||
material: A, | ||
minimal: H | ||
}, Symbol.toStringTag, { value: "Module" })), z = I(null); | ||
clean: G, | ||
material: J, | ||
minimal: N | ||
}, Symbol.toStringTag, { value: "Module" })), L = _(null); | ||
function E() { | ||
if (typeof window > "u") | ||
return null; | ||
if (typeof u.useContext != "function") | ||
if (typeof d.useContext != "function") | ||
throw new Error( | ||
"You must use React >= 18.0 in order to use useEvervault()" | ||
); | ||
const o = u.useContext(z); | ||
const o = d.useContext(L); | ||
if (!o) | ||
@@ -378,7 +378,7 @@ throw new Error( | ||
} | ||
const j = I( | ||
const O = _( | ||
void 0 | ||
); | ||
function _() { | ||
const o = Y(j); | ||
function Y() { | ||
const o = q(O); | ||
if (!o) | ||
@@ -388,3 +388,3 @@ throw new Error("Reveal consumers must be used within a Reveal component"); | ||
} | ||
function V({ | ||
function Q({ | ||
path: o, | ||
@@ -394,17 +394,17 @@ onCopy: n, | ||
}) { | ||
const [i, l] = L(null), d = h(null), { reveal: e } = _(); | ||
return u.useEffect(() => { | ||
if (!(!i || !n)) | ||
return i == null ? void 0 : i.on("copy", n); | ||
}, [i, n]), R(() => { | ||
if ((!d.current || i) ?? !e) | ||
const [u, l] = C(null), f = b(null), { reveal: e } = Y(); | ||
return d.useEffect(() => { | ||
if (!(!u || !n)) | ||
return u == null ? void 0 : u.on("copy", n); | ||
}, [u, n]), S(() => { | ||
if ((!f.current || u) ?? !e) | ||
return; | ||
const a = e == null ? void 0 : e.copyButton(o, r); | ||
a.mount(d.current), l(a); | ||
}, [e, o, r, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
a.mount(f.current), l(a); | ||
}, [e, o, r, u]), /* @__PURE__ */ d.createElement("div", { ref: f }); | ||
} | ||
function q({ path: o, theme: n, format: r }) { | ||
const [i, l] = L(null), d = h(null), { reveal: e } = _(); | ||
return R(() => { | ||
if ((!d.current || i) ?? !e) | ||
function U({ path: o, theme: n, format: r }) { | ||
const [u, l] = C(null), f = b(null), { reveal: e } = Y(); | ||
return S(() => { | ||
if ((!f.current || u) ?? !e) | ||
return; | ||
@@ -415,14 +415,14 @@ const a = e.text(o, { | ||
}); | ||
a.mount(d.current), l(a); | ||
}, [e, o, n, r, i]), /* @__PURE__ */ u.createElement("div", { ref: d }); | ||
a.mount(f.current), l(a); | ||
}, [e, o, n, r, u]), /* @__PURE__ */ d.createElement("div", { ref: f }); | ||
} | ||
function D({ request: o, children: n, onReady: r, onError: i }) { | ||
const l = h(!1), d = E(), [e, a] = L(null), c = h(null); | ||
return u.useEffect(() => { | ||
function D({ request: o, children: n, onReady: r, onError: u }) { | ||
const l = b(!1), f = E(), [e, a] = C(null), c = b(null); | ||
return d.useEffect(() => { | ||
if (!(!e || !r)) | ||
return e == null ? void 0 : e.on("ready", r); | ||
}, [e, r]), u.useEffect(() => { | ||
if (!(!e || !i)) | ||
return e == null ? void 0 : e.on("error", i); | ||
}, [e, i]), g(() => { | ||
}, [e, r]), d.useEffect(() => { | ||
if (!(!e || !u)) | ||
return e == null ? void 0 : e.on("error", u); | ||
}, [e, u]), h(() => { | ||
if (!c.current || l.current) | ||
@@ -432,3 +432,3 @@ return; | ||
l.current = !0; | ||
const t = await d; | ||
const t = await f; | ||
if (!t) | ||
@@ -440,13 +440,13 @@ return; | ||
s().catch(console.error); | ||
}, [e, o, d]), /* @__PURE__ */ u.createElement(j.Provider, { value: { reveal: e } }, /* @__PURE__ */ u.createElement(u.Fragment, null, /* @__PURE__ */ u.createElement("div", { ref: c }), n)); | ||
}, [e, o, f]), /* @__PURE__ */ d.createElement(O.Provider, { value: { reveal: e } }, /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement("div", { ref: c }), n)); | ||
} | ||
D.Text = q; | ||
D.CopyButton = V; | ||
function X({ | ||
D.Text = U; | ||
D.CopyButton = Q; | ||
function ee({ | ||
theme: o, | ||
icons: n, | ||
fields: r, | ||
autoFocus: i, | ||
autoFocus: u, | ||
translations: l, | ||
onSwipe: d, | ||
onSwipe: f, | ||
onReady: e, | ||
@@ -456,25 +456,41 @@ onError: a, | ||
onComplete: s, | ||
autoComplete: t, | ||
autoProgress: v, | ||
acceptedBrands: p, | ||
defaultValues: m | ||
onFocus: t, | ||
onBlur: v, | ||
onKeyUp: p, | ||
onKeyDown: m, | ||
autoComplete: g, | ||
autoProgress: x, | ||
acceptedBrands: w, | ||
defaultValues: P | ||
}) { | ||
const w = E(), b = h(!1), x = h(null), [f, M] = u.useState(null); | ||
g(() => { | ||
if (!(!f || !e)) | ||
return f == null ? void 0 : f.on("ready", e); | ||
}, [f, e]), g(() => { | ||
if (!(!f || !a)) | ||
return f == null ? void 0 : f.on("error", a); | ||
}, [f, a]), g(() => { | ||
if (!(!f || !d)) | ||
return f == null ? void 0 : f.on("swipe", d); | ||
}, [f, d]), g(() => { | ||
if (!(!f || !c)) | ||
return f == null ? void 0 : f.on("change", c); | ||
}, [f, c]), g(() => { | ||
if (!(!f || !s)) | ||
return f == null ? void 0 : f.on("complete", s); | ||
}, [f, s]); | ||
const S = T( | ||
const A = E(), B = b(!1), y = b(null), [i, H] = d.useState(null); | ||
h(() => { | ||
if (!(!i || !e)) | ||
return i == null ? void 0 : i.on("ready", e); | ||
}, [i, e]), h(() => { | ||
if (!(!i || !a)) | ||
return i == null ? void 0 : i.on("error", a); | ||
}, [i, a]), h(() => { | ||
if (!(!i || !f)) | ||
return i == null ? void 0 : i.on("swipe", f); | ||
}, [i, f]), h(() => { | ||
if (!(!i || !c)) | ||
return i == null ? void 0 : i.on("change", c); | ||
}, [i, c]), h(() => { | ||
if (!(!i || !s)) | ||
return i == null ? void 0 : i.on("complete", s); | ||
}, [i, s]), h(() => { | ||
if (!(!i || !t)) | ||
return i == null ? void 0 : i.on("focus", t); | ||
}, [i, t]), h(() => { | ||
if (!(!i || !v)) | ||
return i == null ? void 0 : i.on("blur", v); | ||
}, [i, v]), h(() => { | ||
if (!(!i || !p)) | ||
return i == null ? void 0 : i.on("keyup", p); | ||
}, [i, p]), h(() => { | ||
if (!(!i || !m)) | ||
return i == null ? void 0 : i.on("keydown", m); | ||
}, [i, m]); | ||
const z = M( | ||
() => ({ | ||
@@ -484,8 +500,8 @@ theme: o, | ||
fields: r, | ||
autoFocus: i, | ||
autoFocus: u, | ||
translations: l, | ||
autoComplete: t, | ||
autoProgress: v, | ||
acceptedBrands: p, | ||
defaultValues: m | ||
autoComplete: g, | ||
autoProgress: x, | ||
acceptedBrands: w, | ||
defaultValues: P | ||
}), | ||
@@ -497,47 +513,47 @@ [ | ||
r, | ||
i, | ||
t, | ||
v, | ||
p, | ||
m | ||
u, | ||
g, | ||
x, | ||
w, | ||
P | ||
] | ||
); | ||
return R(() => { | ||
if (!x.current) | ||
return S(() => { | ||
if (!y.current) | ||
return; | ||
async function O() { | ||
if (b.current || !x.current) | ||
async function V() { | ||
if (B.current || !y.current) | ||
return; | ||
b.current = !0; | ||
const C = await w; | ||
if (!C) | ||
B.current = !0; | ||
const I = await A; | ||
if (!I) | ||
return; | ||
const B = C.ui.card(S); | ||
B.mount(x.current), M(B); | ||
const T = I.ui.card(z); | ||
T.mount(y.current), H(T); | ||
} | ||
f ? f.update(S) : O().catch(console.error); | ||
}, [S, f]), /* @__PURE__ */ u.createElement("div", { ref: x }); | ||
i ? i.update(z) : V().catch(console.error); | ||
}, [z, i]), /* @__PURE__ */ d.createElement("div", { ref: y }); | ||
} | ||
function Z({ | ||
function re({ | ||
theme: o, | ||
autoFocus: n, | ||
mode: r, | ||
inputType: i, | ||
inputType: u, | ||
length: l, | ||
onReady: d, | ||
onReady: f, | ||
onChange: e, | ||
onError: a | ||
}) { | ||
const c = E(), s = h(!1), [t, v] = u.useState(null), p = h(null); | ||
u.useEffect(() => { | ||
if (!(!t || !d)) | ||
return t == null ? void 0 : t.on("ready", d); | ||
}, [t, d]), u.useEffect(() => { | ||
const c = E(), s = b(!1), [t, v] = d.useState(null), p = b(null); | ||
d.useEffect(() => { | ||
if (!(!t || !f)) | ||
return t == null ? void 0 : t.on("ready", f); | ||
}, [t, f]), d.useEffect(() => { | ||
if (!(!t || !a)) | ||
return t == null ? void 0 : t.on("error", a); | ||
}, [t, a]), u.useEffect(() => { | ||
}, [t, a]), d.useEffect(() => { | ||
if (!(!t || !e)) | ||
return t == null ? void 0 : t.on("change", e); | ||
}, [t, e]); | ||
const m = T( | ||
const m = M( | ||
() => ({ | ||
@@ -548,48 +564,48 @@ theme: o, | ||
mode: r, | ||
inputType: i | ||
inputType: u | ||
}), | ||
[o, l, n, r, i] | ||
[o, l, n, r, u] | ||
); | ||
return R(() => { | ||
return S(() => { | ||
if (!p.current) | ||
return; | ||
async function w() { | ||
async function g() { | ||
if (s.current || !p.current) | ||
return; | ||
s.current = !0; | ||
const b = await c; | ||
if (!b) | ||
const x = await c; | ||
if (!x) | ||
return; | ||
const x = b.ui.pin(m); | ||
x.mount(p.current), v(x); | ||
const w = x.ui.pin(m); | ||
w.mount(p.current), v(w); | ||
} | ||
t ? t.update(m) : w().catch(console.error); | ||
}, [t, m]), /* @__PURE__ */ u.createElement("div", { ref: p }); | ||
t ? t.update(m) : g().catch(console.error); | ||
}, [t, m]), /* @__PURE__ */ d.createElement("div", { ref: p }); | ||
} | ||
function $({ | ||
function te({ | ||
session: o, | ||
theme: n, | ||
size: r, | ||
onReady: i, | ||
onReady: u, | ||
onError: l, | ||
onSuccess: d, | ||
onSuccess: f, | ||
onFailure: e | ||
}) { | ||
const a = E(), c = u.useRef(!1), s = u.useRef(null), [t, v] = u.useState( | ||
const a = E(), c = d.useRef(!1), s = d.useRef(null), [t, v] = d.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(() => { | ||
d.useEffect(() => { | ||
if (!(!t || !u)) | ||
return t == null ? void 0 : t.on("ready", u); | ||
}, [t, u]), d.useEffect(() => { | ||
if (!(!t || !f)) | ||
return t == null ? void 0 : t.on("success", f); | ||
}, [t, f]), d.useEffect(() => { | ||
if (!(!t || !e)) | ||
return t == null ? void 0 : t.on("failure", e); | ||
}, [t, e]), u.useEffect(() => { | ||
}, [t, e]), d.useEffect(() => { | ||
if (!(!t || !l)) | ||
return t == null ? void 0 : t.on("error", l); | ||
}, [t, l]); | ||
const p = u.useMemo( | ||
const p = d.useMemo( | ||
() => ({ | ||
@@ -601,3 +617,3 @@ theme: n, | ||
); | ||
return u.useLayoutEffect(() => { | ||
return d.useLayoutEffect(() => { | ||
async function m() { | ||
@@ -607,14 +623,14 @@ if (c.current) | ||
c.current = !0; | ||
const w = await a; | ||
if (!w) | ||
const g = await a; | ||
if (!g) | ||
return; | ||
const b = w.ui.threeDSecure(o, p); | ||
b.mount(s.current), v(b); | ||
const x = g.ui.threeDSecure(o, p); | ||
x.mount(s.current), v(x); | ||
} | ||
t ? t.update(p) : m().catch(console.error); | ||
}, [t, o, p]), /* @__PURE__ */ u.createElement("div", { ref: s }); | ||
}, [t, o, p]), /* @__PURE__ */ d.createElement("div", { ref: s }); | ||
} | ||
function k(o) { | ||
const n = E(), r = h(null), i = P( | ||
(d, e) => { | ||
function oe(o) { | ||
const n = E(), r = b(null), u = j( | ||
(f, e) => { | ||
r.current && (r.current.unmount(), r.current = null); | ||
@@ -625,3 +641,3 @@ async function a() { | ||
try { | ||
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(); | ||
r.current = c.ui.threeDSecure(f, 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(); | ||
} catch (s) { | ||
@@ -635,14 +651,14 @@ r.current = null, e != null && e.onError && e.onError(s); | ||
); | ||
g(() => () => { | ||
h(() => () => { | ||
r.current && (r.current.unmount(), r.current = null); | ||
}, []); | ||
const l = P((d) => { | ||
r.current && r.current.update(d); | ||
const l = j((f) => { | ||
r.current && r.current.update(f); | ||
}, []); | ||
return { | ||
start: i, | ||
start: u, | ||
update: l | ||
}; | ||
} | ||
class F extends Promise { | ||
class W extends Promise { | ||
async encrypt(n) { | ||
@@ -655,6 +671,6 @@ return (await this).encrypt(n); | ||
} | ||
const G = "https://js.evervault.com/v2"; | ||
function J(o) { | ||
const X = "https://js.evervault.com/v2"; | ||
function Z(o) { | ||
const n = document.createElement("script"); | ||
o ? n.src = o : n.src = G; | ||
o ? n.src = o : n.src = X; | ||
const r = document.head || document.body; | ||
@@ -667,5 +683,5 @@ if (!r) | ||
} | ||
let y = null; | ||
function K(o) { | ||
return y !== null || (y = new Promise((n, r) => { | ||
let R = null; | ||
function $(o) { | ||
return R !== null || (R = new Promise((n, r) => { | ||
if (typeof window > "u") { | ||
@@ -680,32 +696,32 @@ n(void 0); | ||
try { | ||
const i = J(o); | ||
i.addEventListener("load", () => { | ||
const u = Z(o); | ||
u.addEventListener("load", () => { | ||
window.Evervault ? n(window.Evervault) : r(new Error("Evervault.js not available")); | ||
}), i.addEventListener("error", () => { | ||
}), u.addEventListener("error", () => { | ||
r(new Error("Failed to load Evervault.js")); | ||
}); | ||
} catch (i) { | ||
r(i); | ||
} catch (u) { | ||
r(u); | ||
} | ||
})), y; | ||
})), R; | ||
} | ||
function N(o) { | ||
const n = Promise.resolve().then(() => K(o)); | ||
function F(o) { | ||
const n = Promise.resolve().then(() => $(o)); | ||
let r = !1; | ||
return n.catch((i) => { | ||
r || console.warn(i); | ||
}), r = !0, n.then((i) => typeof window < "u" ? window.Evervault : i ?? void 0); | ||
return n.catch((u) => { | ||
r || console.warn(u); | ||
}), r = !0, n.then((u) => typeof window < "u" ? window.Evervault : u ?? void 0); | ||
} | ||
const ee = ({ | ||
const ne = ({ | ||
teamId: o, | ||
appId: n, | ||
customConfig: r, | ||
children: i, | ||
children: u, | ||
...l | ||
}) => { | ||
if (typeof window > "u") | ||
return /* @__PURE__ */ u.createElement(z.Provider, { value: null }, i); | ||
const d = u.useMemo( | ||
() => new F((e, a) => { | ||
N(r == null ? void 0 : r.jsSdkUrl).then((c) => { | ||
return /* @__PURE__ */ d.createElement(L.Provider, { value: null }, u); | ||
const f = d.useMemo( | ||
() => new W((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")); | ||
@@ -716,5 +732,5 @@ }).catch((c) => a(c)); | ||
); | ||
return /* @__PURE__ */ u.createElement(z.Provider, { ...l, value: d }, i); | ||
return /* @__PURE__ */ d.createElement(L.Provider, { ...l, value: f }, u); | ||
}; | ||
function re({ | ||
function ie({ | ||
onChange: o, | ||
@@ -724,9 +740,9 @@ config: n, | ||
}) { | ||
const i = u.useId(); | ||
const u = d.useId(); | ||
if (typeof window > "u") | ||
return /* @__PURE__ */ u.createElement("div", { id: i }); | ||
const l = E(), { height: d = "auto", ...e } = n ?? {}, a = e ? { height: d, ...e } : { height: d }; | ||
return u.useEffect(() => { | ||
return /* @__PURE__ */ d.createElement("div", { id: u }); | ||
const l = E(), { height: f = "auto", ...e } = n ?? {}, a = e ? { height: f, ...e } : { height: f }; | ||
return d.useEffect(() => { | ||
l == null || l.then((c) => { | ||
const s = c.inputs(i, a); | ||
const s = c.inputs(u, a); | ||
s == null || s.on("change", (t) => { | ||
@@ -736,20 +752,20 @@ typeof o == "function" && o(t); | ||
}); | ||
}, [l]), /* @__PURE__ */ u.createElement("div", { id: i }); | ||
}, [l]), /* @__PURE__ */ d.createElement("div", { id: u }); | ||
} | ||
function te({ | ||
function ue({ | ||
request: o, | ||
config: n, | ||
onCopy: r, | ||
onRevealLoad: i, | ||
onRevealLoad: u, | ||
onRevealError: l | ||
}) { | ||
const d = u.useId(); | ||
const f = d.useId(); | ||
if (typeof window > "u") | ||
return /* @__PURE__ */ u.createElement("div", { id: d }); | ||
return /* @__PURE__ */ d.createElement("div", { id: f }); | ||
const e = E(), { height: a = "auto", ...c } = n ?? {}, s = c ? { height: a, ...c } : { height: a }; | ||
return u.useEffect(() => { | ||
return d.useEffect(() => { | ||
e == null || e.then((t) => { | ||
const v = t.reveal(d, o, s, r); | ||
const v = t.reveal(f, o, s, r); | ||
(v == null ? void 0 : v.isRevealLoaded) != null && v.isRevealLoaded instanceof Promise && v.isRevealLoaded.then(() => { | ||
i && i(); | ||
u && u(); | ||
}).catch((p) => { | ||
@@ -759,16 +775,16 @@ l && l(p); | ||
}); | ||
}, [e]), /* @__PURE__ */ u.createElement("div", { id: d }); | ||
}, [e]), /* @__PURE__ */ d.createElement("div", { id: f }); | ||
} | ||
export { | ||
X as Card, | ||
re as EvervaultInput, | ||
ee as EvervaultProvider, | ||
te as EvervaultReveal, | ||
Z as Pin, | ||
F as PromisifiedEvervaultClient, | ||
ee as Card, | ||
ie as EvervaultInput, | ||
ne as EvervaultProvider, | ||
ue as EvervaultReveal, | ||
re as Pin, | ||
W as PromisifiedEvervaultClient, | ||
D as Reveal, | ||
$ as ThreeDSecure, | ||
W as themes, | ||
te as ThreeDSecure, | ||
k as themes, | ||
E as useEvervault, | ||
k as useThreeDSecure | ||
oe as useThreeDSecure | ||
}; |
{ | ||
"private": false, | ||
"name": "@evervault/react", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"description": "React package for the Evervault SDK", | ||
@@ -37,6 +37,6 @@ "license": "MIT", | ||
"vite-plugin-dts": "^3.6.3", | ||
"types": "^0.3.0", | ||
"themes": "^0.1.3", | ||
"@evervault/browser": "^2.32.0", | ||
"tsconfig": "^0.0.1" | ||
"@evervault/browser": "^2.35.0", | ||
"themes": "^0.1.5", | ||
"tsconfig": "^0.0.1", | ||
"types": "^0.5.0" | ||
}, | ||
@@ -43,0 +43,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
95818
2234