@onefootprint/footprint-js
Advanced tools
Comparing version 3.12.1 to 3.12.2
@@ -97,2 +97,5 @@ import * as CSS from 'csstype'; | ||
radioSelectBg: CSS.Property.Background; | ||
radioSelectColor: CSS.Property.Color; | ||
radioSelectHoverColor: CSS.Property.Color; | ||
radioSelectSelectedColor: CSS.Property.Color; | ||
radioSelectBorderRadius: CSS.Property.BorderRadius; | ||
@@ -109,3 +112,2 @@ radioSelectBorderWidth: CSS.Property.BorderWidth; | ||
}>; | ||
type AppearanceTheme = 'light' | 'dark'; | ||
type AppearanceRules = Partial<{ | ||
@@ -138,3 +140,2 @@ button: CSS.Properties; | ||
rules?: AppearanceRules; | ||
theme?: AppearanceTheme; | ||
variables?: AppearanceVariables; | ||
@@ -171,14 +172,5 @@ }; | ||
}; | ||
type Business_BeneficialOwners = { | ||
email: string; | ||
first_name: string; | ||
last_name: string; | ||
middle_name: string; | ||
ownership_stake: number; | ||
phone_number: string; | ||
}; | ||
type BusinessProps = { | ||
'business.address_line1': string; | ||
'business.address_line2': string; | ||
'business.beneficial_owners': Partial<Business_BeneficialOwners>[]; | ||
'business.city': string; | ||
@@ -188,5 +180,2 @@ 'business.corporation_type': string; | ||
'business.dba': string; | ||
'business.formation_date': string; | ||
'business.formation_state': string; | ||
'business.kyced_beneficial_owners': Partial<Business_BeneficialOwners>[]; | ||
'business.name': string; | ||
@@ -254,2 +243,8 @@ 'business.phone_number': string; | ||
type VerifyDataKeys = BootstrapKeys | 'publicKey' | 'options' | 'authToken' | 'l10n'; | ||
type OverallOutcome = 'pass' | 'fail' | 'manual_review' | 'use_rules_outcome' | 'step_up'; | ||
type IdDocOutcome = 'pass' | 'fail' | 'real'; | ||
type SandboxOutcome = { | ||
readonly overallOutcome?: OverallOutcome; | ||
readonly documentOutcome?: IdDocOutcome; | ||
}; | ||
type VerifyPropsBase<TAuth> = PropsBase & { | ||
@@ -262,2 +257,3 @@ readonly bootstrapData?: BootstrapData; | ||
readonly options?: Options; | ||
readonly sandboxOutcome?: SandboxOutcome; | ||
/** @deprecated use bootstrapData instead */ | ||
@@ -272,2 +268,4 @@ readonly userData?: FootprintUserData; | ||
isComponentsSdk?: boolean; | ||
fixtureResult?: OverallOutcome; | ||
documentFixtureResult?: IdDocOutcome; | ||
}; | ||
@@ -385,2 +383,2 @@ /** Components SDK. Just a subset of Verify */ | ||
export { Footprint, Appearance as FootprintAppearance, AppearanceRules as FootprintAppearanceRules, AppearanceTheme as FootprintAppearanceTheme, AppearanceVariables as FootprintAppearanceVariables, AuthDataProps as FootprintAuthDataProps, AuthProps as FootprintAuthProps, BootstrapData as FootprintBootstrapData, Component as FootprintComponent, ComponentKind as FootprintComponentKind, FormDataProps as FootprintFormDataProps, FormOptions as FootprintFormOptions, FormProps as FootprintFormProps, FormRef as FootprintFormRef, IdentifyRequest as FootprintIdentifyRequest, Options as FootprintOptions, PrivateEvent as FootprintPrivateEvent, Props as FootprintProps, PropsBase as FootprintPropsBase, PublicEvent as FootprintPublicEvent, RenderDataProps as FootprintRenderDataProps, RenderProps as FootprintRenderProps, UpdateLoginMethodsDataProps as FootprintUpdateLoginMethodsDataProps, UpdateLoginMethodsProps as FootprintUpdateLoginMethodsProps, FootprintUserData, Variant as FootprintVariant, VerifyAuthToken as FootprintVerifyAuthToken, VerifyButtonDataProps as FootprintVerifyButtonDataProps, VerifyButtonProps as FootprintVerifyButtonProps, VerifyDataProps as FootprintVerifyDataProps, VerifyProps as FootprintVerifyProps, VerifyPublicKey as FootprintVerifyPublicKey, L10n, SupportedLocale, footprint as default, identifyUser as identifyFootprintUser }; | ||
export { Footprint, Appearance as FootprintAppearance, AppearanceRules as FootprintAppearanceRules, AppearanceVariables as FootprintAppearanceVariables, AuthDataProps as FootprintAuthDataProps, AuthProps as FootprintAuthProps, BootstrapData as FootprintBootstrapData, Component as FootprintComponent, ComponentKind as FootprintComponentKind, FormDataProps as FootprintFormDataProps, FormOptions as FootprintFormOptions, FormProps as FootprintFormProps, FormRef as FootprintFormRef, IdentifyRequest as FootprintIdentifyRequest, Options as FootprintOptions, PrivateEvent as FootprintPrivateEvent, Props as FootprintProps, PropsBase as FootprintPropsBase, PublicEvent as FootprintPublicEvent, RenderDataProps as FootprintRenderDataProps, RenderProps as FootprintRenderProps, UpdateLoginMethodsDataProps as FootprintUpdateLoginMethodsDataProps, UpdateLoginMethodsProps as FootprintUpdateLoginMethodsProps, FootprintUserData, Variant as FootprintVariant, VerifyAuthToken as FootprintVerifyAuthToken, VerifyButtonDataProps as FootprintVerifyButtonDataProps, VerifyButtonProps as FootprintVerifyButtonProps, VerifyDataProps as FootprintVerifyDataProps, VerifyProps as FootprintVerifyProps, VerifyPublicKey as FootprintVerifyPublicKey, L10n, SandboxOutcome, SupportedLocale, footprint as default, identifyUser as identifyFootprintUser }; |
@@ -1,5 +0,5 @@ | ||
import yt from '@onefootprint/postmate'; | ||
import lt from '@onefootprint/postmate'; | ||
var je=Object.defineProperty,qe=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var re=(e,t,o)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&re(e,o,t[o]);if(I)for(var o of I(t))ie.call(t,o)&&re(e,o,t[o]);return e},P=(e,t)=>qe(e,He(t));var se=(e,t)=>{var o={};for(var n in e)ae.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};var y=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{s(o.next(p));}catch(a){r(a);}},i=p=>{try{s(o.throw(p));}catch(a){r(a);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,i);s((o=o.apply(e,t)).next());});var K="3.12.1";var R=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(R||{});var x=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(x||{}),E=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(E||{});var de="footprint-inline-container",pe="footprint-body-locked",le="footprint-overlay",Je="footprint-overlay-container",ce=de,me=le,ye="footprint-loading-indicator",L=e=>`${Je}-${e}`,w=(e,t)=>`${e}-${t}`,fe=e=>y(void 0,null,function*(){q(e),Xe(e),yield We(e);}),ue=e=>{let t=L(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},We=e=>y(void 0,null,function*(){let t=L(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let d=w(me,e),i=document.getElementById(d);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(pe));}),ge=(e,t)=>{let o=w(ce,e),n=document.createElement("div");return n.classList.add(de),n.setAttribute("id",o),t.appendChild(n),n},Xe=e=>{let t=w(ce,e),o=document.getElementById(t);o&&o.remove();},q=e=>{let t=w(ye,e),o=document.getElementById(t);o&&o.remove();},H=(e,t)=>{let o=w(ye,t),n=Ye(o);e.appendChild(n);},he=(e,t)=>{document.body.classList.add(pe);let o=document.createElement("div"),n=w(me,t);return o.setAttribute("id",n),o.classList.add(le),e.appendChild(o),o},Ye=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Pe=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="1",t.style.display="block");},ke=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="0",t.style.display="none");};var Ge=()=>Math.random().toString(36).substring(2),T=Ge;var B="https://api.onefootprint.com",U=K,_="footprint-js";var S={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var Ze=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),z=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(z(e)):Object(r)===r?d=z(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},Qe=z(Ze),M=Qe;var et=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:_,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${B}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M(r))});}catch(d){}},J=et;var W=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},ve=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"error",n);}return o};var be={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Ve={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var we={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},tt=Object.values(x),ot=(...e)=>{},C=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),X=e=>C(e)&&Object.keys(e).length>0,nt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},$=(e,t)=>{var r;if(!t)return;let o=(r=we[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},F=e=>{var o;let t=(o=we[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},N=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Se=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:i,label:s,containerId:p}=t,a=se(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(f({},a),{variant:d,kind:"verify"})}};var Fe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ot,Y=(e,t,o)=>{var s;let{kind:n}=e,r=(s=be[n])!=null?s:{},d={},i=Se(e);return Object.entries(r).forEach(([p,a])=>{let l=p;if(!tt.includes(l))return;let k=Fe(e,a),A=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{k(h),A&&(t==null||t()),m&&i&&(o==null||o(i));};}),d},D=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||F(t);return N(t),$(t,o),nt(r,n),X(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(f({},e),{variant:r})},v=e=>X(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:X(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ae=e=>e==="auth",rt=e=>e==="verify",xe=e=>e==="update_login_methods",at=e=>e==="components",G=e=>e.kind==="components",Z=e=>[Ae,rt,at,xe].some(t=>t(e)),Q=e=>typeof e=="string"&&e.length>0,j=e=>Ae(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),it=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),O=e=>[j,it].some(t=>t(e));var st=3,dt=!1,pt=e=>O(e)?"update_auth_methods_v1":S[e.kind],lt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(f({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return j(e)?P(f({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&dt?P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(f({},v(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(f({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},De=(e,t)=>y(void 0,null,function*(){return fetch(`${B}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${_} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return De(e,t-1)})}),ct=e=>y(void 0,null,function*(){let t=lt(e);if(!t)return;let o=yield De({data:M(t),kind:pt(e)},st);return o?o.token:void 0}),Oe=ct;var Ie=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},Ke=()=>{let e=window.footprintAppearance;return !e||!C(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Ee=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Re=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:i,rules:s,variables:p}=Ie(o),a=new URLSearchParams;return p&&a.append("variables",p),s&&a.append("rules",s),i&&a.append("font_src",i),r!=null&&r.language&&a.append("lng",r.language),a.append("variant",d||F(n)),`${a.toString()}#${t}`},mt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=O(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(Q(n))return Z(o)?`${n}?${Re(e,t)}`.trim():`${n}/${o}?${Re(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Le=mt;var ft=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:i,formSaveFailed:s,started:p}=E,a=D(e),{variant:l,containerId:k}=a,A=l==="modal"||l==="drawer",m=T(),h=(c,u)=>{var V;let g=ve(S[a.kind],c);(V=a.onError)==null||V.call(a,g),o&&u&&(n(),o=!1);},Me=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Y(a,n,r);Object.entries(c).forEach(([u,g])=>{t==null||t.on(u,g),t==null||t.on(`${m}:${u}`,g);});},$e=()=>{if(A)return ue(m);if(!k){h("containerId is required when rendering inline");return}let c=document.getElementById(k);if(!c){h(`Could not find container with id ${k} while rendering footprint`);return}return ge(m,c)},oe=(c,u)=>{if(!u){q(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(A){let g=he(c,m);H(g,m);}else H(c,m);},ne=()=>{var u;if(!t){h("Footprint should be initialized in order to set up refs");return}if(a.kind!=="form"||!a.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((g,V)=>{t==null||t.on(d,()=>{g();}),t==null||t.on(s,Ne=>{V(Ne);}),t==null||t.on(`${m}:${d}`,g),t==null||t.on(`${m}:${s}`,V),t==null||t.call(i);}))};(u=a.getRef)==null||u.call(a,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Pe(m));},props:a,isRendered:o,render:()=>y(void 0,null,function*(){if(o){W(S[a.kind],"Footprint component is already rendered");return}let c=$e();if(!c){W(S[a.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,oe(c,!0);let u=yield Oe(a);if(!u){h("Unable to get SDK args token.",!0);return}let g=Le(a,u||"");try{t=yield new yt({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:g,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:a.authToken,initId:m,sdkUrl:Ee(),sdkVersion:K||""}});}catch(V){h(`Initializing iframe failed with error ${V}`,!0);return}oe(c,!1),Me(),t==null||t.on(p,()=>ne()),t==null||t.on(`${m}:${p}`,ne),a.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{ke(m);}));}),destroy:()=>y(void 0,null,function*(){o&&(o=!1,yield fe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ee=ft;var b=e=>{let t=D(e);return JSON.stringify(t)},ut=()=>{let e=Object.create(null);return {getOrCreate:d=>{let i=b(d.props),s=Object.values(e).find(p=>b(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:a}=e[s],l=Object.values(a).find(k=>b(k.props)===p);return l||(a[p]=i,i)},remove:d=>{let i=b(d.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:a}=e[s],l=a[p];l&&(l.destroy(),delete a[p]);}}},Te=ut;var gt=()=>{let e=Te();return {init:o=>{let n=ee(o),r=()=>y(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=a=>y(void 0,null,function*(){e.removeSecondary(n,a),yield a.destroy();}),i=a=>y(void 0,null,function*(){let l=ee(a);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),s=()=>y(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return G(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),f({render:s,destroy:r},p)}}},ht=gt(),te=ht;var Pt=e=>{window.setTimeout(e,0);},kt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let d=(s=window.footprintCallbacks)!=null?s:{};if(!C(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ve[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");N(d);let i=(m=r.getAttribute("data-variant"))!=null?m:F(d);$(d,i);let s=Ke(),p=t(d),a=r.getAttribute("data-props")||"",l;try{l=JSON.parse(a);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!C(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let k=T();r.setAttribute("id",k),e.init(f(f({kind:d,variant:i,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>Pt(n));},Be=kt;var Ct="http://test",Ue=e=>y(void 0,null,function*(){let t=yield fetch(`${Ct}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),vt=e=>y(void 0,null,function*(){if(!C(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Ue({email:t}))?!0:o?yield Ue({phone_number:o}):!1}),_e=vt;var Yo=te;Be(te); | ||
var Ue=Object.defineProperty,Me=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var ne=(e,t,o)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))re.call(t,o)&&ne(e,o,t[o]);if(A)for(var o of A(t))ae.call(t,o)&&ne(e,o,t[o]);return e},P=(e,t)=>Me(e,$e(t));var ie=(e,t)=>{var o={};for(var n in e)re.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&A)for(var n of A(e))t.indexOf(n)<0&&ae.call(e,n)&&(o[n]=e[n]);return o};var y=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{s(o.next(p));}catch(a){r(a);}},i=p=>{try{s(o.throw(p));}catch(a){r(a);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,i);s((o=o.apply(e,t)).next());});var I="3.12.2";var R=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(R||{});var F=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(F||{}),K=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(K||{});var se="footprint-inline-container",de="footprint-body-locked",pe="footprint-overlay",je="footprint-overlay-container",le=se,ce=pe,me="footprint-loading-indicator",E=e=>`${je}-${e}`,S=(e,t)=>`${e}-${t}`,ye=e=>y(void 0,null,function*(){j(e),He(e),yield qe(e);}),fe=e=>{let t=E(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},qe=e=>y(void 0,null,function*(){let t=E(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let d=S(ce,e),i=document.getElementById(d);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(de));}),ue=(e,t)=>{let o=S(le,e),n=document.createElement("div");return n.classList.add(se),n.setAttribute("id",o),t.appendChild(n),n},He=e=>{let t=S(le,e),o=document.getElementById(t);o&&o.remove();},j=e=>{let t=S(me,e),o=document.getElementById(t);o&&o.remove();},q=(e,t)=>{let o=S(me,t),n=ze(o);e.appendChild(n);},ge=(e,t)=>{document.body.classList.add(de);let o=document.createElement("div"),n=S(ce,t);return o.setAttribute("id",n),o.classList.add(pe),e.appendChild(o),o},ze=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},he=e=>{let t=document.getElementById(E(e));t&&(t.style.opacity="1",t.style.display="block");},Pe=e=>{let t=document.getElementById(E(e));t&&(t.style.opacity="0",t.style.display="none");};var Je=()=>Math.random().toString(36).substring(2),L=Je;var T="https://api.onefootprint.com",B=I,_="footprint-js";var w={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var We=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),H=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(H(e)):Object(r)===r?d=H(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},Xe=H(We),U=Xe;var Ye=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:_,sdkVersion:B,logLevel:o,logMessage:t};try{fetch(`${T}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U(r))});}catch(d){}},z=Ye;var J=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"warn",n);}return o},Ce=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"error",n);}return o};var ve={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},be={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Ve={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},Ge=Object.values(F),Ze=(...e)=>{},C=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),W=e=>C(e)&&Object.keys(e).length>0,Qe=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},M=(e,t)=>{var r;if(!t)return;let o=(r=Ve[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},O=e=>{var o;let t=(o=Ve[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},$=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Se=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:i,label:s,containerId:p}=t,a=ie(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(f({},a),{variant:d,kind:"verify"})}};var we=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Ze,X=(e,t,o)=>{var s;let{kind:n}=e,r=(s=ve[n])!=null?s:{},d={},i=Se(e);return Object.entries(r).forEach(([p,a])=>{let l=p;if(!Ge.includes(l))return;let k=we(e,a),x=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{k(h),x&&(t==null||t()),m&&i&&(o==null||o(i));};}),d},D=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||O(t);return $(t),M(t,o),Qe(r,n),W(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(f({},e),{variant:r})},v=e=>W(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:W(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var et=e=>e==="auth";var tt=e=>e==="update_login_methods";var Y=e=>e.kind==="components";var G=e=>typeof e=="string"&&e.length>0,N=e=>et(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),ot=e=>tt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),Z=e=>[N,ot].some(t=>t(e));var nt=3,rt=!1,at=e=>Z(e)?"update_auth_methods_v1":w[e.kind],it=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return P(f({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return N(e)?P(f({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&rt?P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(f({},v(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(f({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Oe=(e,t)=>y(void 0,null,function*(){return fetch(`${T}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${_} ${B} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Oe(e,t-1)})}),st=e=>y(void 0,null,function*(){let t=it(e);if(!t)return;let o=yield Oe({data:U(t),kind:at(e)},nt);return o?o.token:void 0}),xe=st;var Fe=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},De=()=>{let e=window.footprintAppearance;return !e||!C(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Ae=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},dt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:i,rules:s,variables:p}=Fe(o),a=new URLSearchParams;return p&&a.append("variables",p),s&&a.append("rules",s),i&&a.append("font_src",i),r!=null&&r.language&&a.append("lng",r.language),a.append("variant",d||O(n)),`${a.toString()}#${t}`},pt=(e,t)=>{let{kind:o}=e,n=dt(e,t),r=`https://components.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com"),!G(r))throw new Error(`${o}_URL environment variable is not defined.`);return `${r}?${n}`.trim()},Ie=pt;var ct=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:i,formSaveFailed:s,started:p}=K,a=D(e),{variant:l,containerId:k}=a,x=l==="modal"||l==="drawer",m=L(),h=(c,u)=>{var V;let g=Ce(w[a.kind],c);(V=a.onError)==null||V.call(a,g),o&&u&&(n(),o=!1);},Te=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=X(a,n,r);Object.entries(c).forEach(([u,g])=>{t==null||t.on(u,g),t==null||t.on(`${m}:${u}`,g);});},Be=()=>{if(x)return fe(m);if(!k){h("containerId is required when rendering inline");return}let c=document.getElementById(k);if(!c){h(`Could not find container with id ${k} while rendering footprint`);return}return ue(m,c)},te=(c,u)=>{if(!u){j(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(x){let g=ge(c,m);q(g,m);}else q(c,m);},oe=()=>{var u;if(!t){h("Footprint should be initialized in order to set up refs");return}if(a.kind!=="form"||!a.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((g,V)=>{t==null||t.on(d,()=>{g();}),t==null||t.on(s,_e=>{V(_e);}),t==null||t.on(`${m}:${d}`,g),t==null||t.on(`${m}:${s}`,V),t==null||t.call(i);}))};(u=a.getRef)==null||u.call(a,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),he(m));},props:a,isRendered:o,render:()=>y(void 0,null,function*(){if(o){J(w[a.kind],"Footprint component is already rendered");return}let c=Be();if(!c){J(w[a.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,te(c,!0);let u=yield xe(a);if(!u){h("Unable to get SDK args token.",!0);return}let g=Ie(a,u||"");try{t=yield new lt({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:g,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:a.authToken,initId:m,sdkUrl:Ae(),sdkVersion:I||""}});}catch(V){h(`Initializing iframe failed with error ${V}`,!0);return}te(c,!1),Te(),t==null||t.on(p,()=>oe()),t==null||t.on(`${m}:${p}`,oe),a.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Pe(m);}));}),destroy:()=>y(void 0,null,function*(){o&&(o=!1,yield ye(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},Q=ct;var b=e=>{let t=D(e);return JSON.stringify(t)},mt=()=>{let e=Object.create(null);return {getOrCreate:d=>{let i=b(d.props),s=Object.values(e).find(p=>b(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:a}=e[s],l=Object.values(a).find(k=>b(k.props)===p);return l||(a[p]=i,i)},remove:d=>{let i=b(d.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:a}=e[s],l=a[p];l&&(l.destroy(),delete a[p]);}}},Re=mt;var yt=()=>{let e=Re();return {init:o=>{let n=Q(o),r=()=>y(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=a=>y(void 0,null,function*(){e.removeSecondary(n,a),yield a.destroy();}),i=a=>y(void 0,null,function*(){let l=Q(a);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),s=()=>y(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return Y(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),f({render:s,destroy:r},p)}}},ft=yt(),ee=ft;var ut=e=>{window.setTimeout(e,0);},gt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let d=(s=window.footprintCallbacks)!=null?s:{};if(!C(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return be[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");$(d);let i=(m=r.getAttribute("data-variant"))!=null?m:O(d);M(d,i);let s=De(),p=t(d),a=r.getAttribute("data-props")||"",l;try{l=JSON.parse(a);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!C(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let k=L();r.setAttribute("id",k),e.init(f(f({kind:d,variant:i,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>ut(n));},Ke=gt;var ht="http://test",Ee=e=>y(void 0,null,function*(){let t=yield fetch(`${ht}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Pt=e=>y(void 0,null,function*(){if(!C(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Ee({email:t}))?!0:o?yield Ee({phone_number:o}):!1}),Le=Pt;var Wo=ee;Ke(ee); | ||
export { R as FootprintComponentKind, E as FootprintPrivateEvent, x as FootprintPublicEvent, Yo as default, _e as identifyFootprintUser }; | ||
export { R as FootprintComponentKind, K as FootprintPrivateEvent, F as FootprintPublicEvent, Wo as default, Le as identifyFootprintUser }; |
(function (exports) { | ||
'use strict'; | ||
var We=Object.defineProperty,Je=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,u=(e,t)=>{for(var o in t||(t={}))de.call(t,o)&&se(e,o,t[o]);if(R)for(var o of R(t))pe.call(t,o)&&se(e,o,t[o]);return e},P=(e,t)=>Je(e,Xe(t));var le=(e,t)=>{var o={};for(var n in e)de.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&pe.call(e,n)&&(o[n]=e[n]);return o};var f=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{i(o.next(p));}catch(s){r(s);}},a=p=>{try{i(o.throw(p));}catch(s){r(s);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,a);i((o=o.apply(e,t)).next());});var E="application/x-postmate-v1+json",Ye=5,Ge=0,Ze=function(){return ++Ge};var Qe=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},et={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},z=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!et[t.data.postmate])},tt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},ot=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!z(r,n.childOrigin))return !1;var d=((r||{}).data||{}).value||{},a=d.data,i=d.name;r.data.postmate==="emit"&&i in n.events&&n.events[i].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new O.Promise(function(d){var a=Ze(),i=function p(s){s.data.uid===a&&s.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),d(s.data.value));};r.parent.addEventListener("message",i,!1),r.child.postMessage({postmate:"request",type:E,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:E,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),nt=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(z(r,n.parentOrigin)){var d=r.data,a=d.property,i=d.uid,p=d.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}tt(n.model,a).then(function(s){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:i,value:s},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:r}},this.parentOrigin);},e}(),O=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,d=o.model,a=o.url,i=o.name,p=i===void 0?"":i,s=o.allow,l=o.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=d||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,d=Qe(n),a=0,i;return new e.Promise(function(p,s){var l=function m(h){return z(h,d)?h.data.postmate==="handshake-reply"?(clearInterval(i),r.parent.removeEventListener("message",m,!1),r.childOrigin=h.origin,p(new ot(r))):s("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var y=function(){a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},d),a===Ye&&clearInterval(i);},C=function(){y(),i=setInterval(y,500);};r.frame.attachEvent?r.frame.attachEvent("onload",C):r.frame.addEventListener("load",C),r.frame.src=n;})},e}();O.debug=!1;O.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();O.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new O.Promise(function(r,d){var a=function i(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",i,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var s=p.data.model;return s&&Object.keys(s).forEach(function(l){n.model[l]=s[l];}),r(new nt(n))}return d("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var ce=O;var L="3.12.1";var K=(i=>(i.Auth="auth",i.Components="components",i.Form="form",i.Render="render",i.UpdateLoginMethods="update_login_methods",i.Verify="verify",i.VerifyButton="verify-button",i))(K||{});var I=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(I||{}),_=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(_||{});var me="footprint-inline-container",fe="footprint-body-locked",ue="footprint-overlay",at="footprint-overlay-container",ye=me,he=ue,ge="footprint-loading-indicator",T=e=>`${at}-${e}`,S=(e,t)=>`${e}-${t}`,ve=e=>f(void 0,null,function*(){W(e),st(e),yield it(e);}),Pe=e=>{let t=T(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},it=e=>f(void 0,null,function*(){let t=T(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(i=>{setTimeout(i,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(i=>{setTimeout(i,100);}));let d=S(he,e),a=document.getElementById(d);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),a.remove(),document.body.classList.remove(fe));}),ke=(e,t)=>{let o=S(ye,e),n=document.createElement("div");return n.classList.add(me),n.setAttribute("id",o),t.appendChild(n),n},st=e=>{let t=S(ye,e),o=document.getElementById(t);o&&o.remove();},W=e=>{let t=S(ge,e),o=document.getElementById(t);o&&o.remove();},J=(e,t)=>{let o=S(ge,t),n=dt(o);e.appendChild(n);},Ce=(e,t)=>{document.body.classList.add(fe);let o=document.createElement("div"),n=S(he,t);return o.setAttribute("id",n),o.classList.add(ue),e.appendChild(o),o},dt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ve=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="1",t.style.display="block");},be=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="0",t.style.display="none");};var pt=()=>Math.random().toString(36).substring(2),B=pt;var M="https://api.onefootprint.com",U=L,N="footprint-js";var D={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var lt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),X=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(X(e)):Object(r)===r?d=X(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},ct=X(lt),$=ct;var mt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:N,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${M}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($(r))});}catch(d){}},Y=mt;var G=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"warn",n);}return o},Ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"error",n);}return o};var Oe={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Se={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var De={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},ft=Object.values(I),ut=(...e)=>{},k=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Z=e=>k(e)&&Object.keys(e).length>0,yt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},H=(e,t)=>{var r;if(!t)return;let o=(r=De[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=De[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},j=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Ae=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:a,label:i,containerId:p}=t,s=le(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(u({},s),{variant:d,kind:"verify"})}};var Ie=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ut,Q=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Oe[n])!=null?i:{},d={},a=Ae(e);return Object.entries(r).forEach(([p,s])=>{let l=p;if(!ft.includes(l))return;let y=Ie(e,s),C=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{y(h),C&&(t==null||t()),m&&a&&(o==null||o(a));};}),d},F=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return j(t),H(t,o),yt(r,n),Z(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(u({},e),{variant:r})},V=e=>Z(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:Z(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Fe=e=>e==="auth",ht=e=>e==="verify",xe=e=>e==="update_login_methods",gt=e=>e==="components",ee=e=>e.kind==="components",te=e=>[Fe,ht,gt,xe].some(t=>t(e)),oe=e=>typeof e=="string"&&e.length>0,q=e=>Fe(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),vt=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),x=e=>[q,vt].some(t=>t(e));var Pt=3,kt=!1,Ct=e=>x(e)?"update_auth_methods_v1":D[e.kind],Vt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(u({},V(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return q(e)?P(u({},V(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&kt?P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(u({},V(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(u({},V(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Re=(e,t)=>f(void 0,null,function*(){return fetch(`${M}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${N} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Re(e,t-1)})}),bt=e=>f(void 0,null,function*(){let t=Vt(e);if(!t)return;let o=yield Re({data:$(t),kind:Ct(e)},Pt);return o?o.token:void 0}),Le=bt;var Ke=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},_e=()=>{let e=window.footprintAppearance;return !e||!k(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Be=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Te=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:a,rules:i,variables:p}=Ke(o),s=new URLSearchParams;return p&&s.append("variables",p),i&&s.append("rules",i),a&&s.append("font_src",a),r!=null&&r.language&&s.append("lng",r.language),s.append("variant",d||A(n)),`${s.toString()}#${t}`},wt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=x(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(oe(n))return te(o)?`${n}?${Te(e,t)}`.trim():`${n}/${o}?${Te(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Me=wt;var Et=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:a,formSaveFailed:i,started:p}=_,s=F(e),{variant:l,containerId:y}=s,C=l==="modal"||l==="drawer",m=B(),h=(c,g)=>{var w;let v=Ee(D[s.kind],c);(w=s.onError)==null||w.call(s,v),o&&g&&(n(),o=!1);},je=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Q(s,n,r);Object.entries(c).forEach(([g,v])=>{t==null||t.on(g,v),t==null||t.on(`${m}:${g}`,v);});},qe=()=>{if(C)return Pe(m);if(!y){h("containerId is required when rendering inline");return}let c=document.getElementById(y);if(!c){h(`Could not find container with id ${y} while rendering footprint`);return}return ke(m,c)},ae=(c,g)=>{if(!g){W(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(C){let v=Ce(c,m);J(v,m);}else J(c,m);},ie=()=>{var g;if(!t){h("Footprint should be initialized in order to set up refs");return}if(s.kind!=="form"||!s.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((v,w)=>{t==null||t.on(d,()=>{v();}),t==null||t.on(i,ze=>{w(ze);}),t==null||t.on(`${m}:${d}`,v),t==null||t.on(`${m}:${i}`,w),t==null||t.call(a);}))};(g=s.getRef)==null||g.call(s,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ve(m));},props:s,isRendered:o,render:()=>f(void 0,null,function*(){if(o){G(D[s.kind],"Footprint component is already rendered");return}let c=qe();if(!c){G(D[s.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,ae(c,!0);let g=yield Le(s);if(!g){h("Unable to get SDK args token.",!0);return}let v=Me(s,g||"");try{t=yield new ce({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:v,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:s.authToken,initId:m,sdkUrl:Be(),sdkVersion:L||""}});}catch(w){h(`Initializing iframe failed with error ${w}`,!0);return}ae(c,!1),je(),t==null||t.on(p,()=>ie()),t==null||t.on(`${m}:${p}`,ie),s.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{be(m);}));}),destroy:()=>f(void 0,null,function*(){o&&(o=!1,yield ve(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ne=Et;var b=e=>{let t=F(e);return JSON.stringify(t)},Ot=()=>{let e=Object.create(null);return {getOrCreate:d=>{let a=b(d.props),i=Object.values(e).find(p=>b(p.iframe.props)===a);return i?i.iframe:(e[a]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[i],l=Object.values(s).find(y=>b(y.props)===p);return l||(s[p]=a,a)},remove:d=>{let a=b(d.props),i=e[a];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[i],l=s[p];l&&(l.destroy(),delete s[p]);}}},Ue=Ot;var St=()=>{let e=Ue();return {init:o=>{let n=ne(o),r=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=s=>f(void 0,null,function*(){e.removeSecondary(n,s),yield s.destroy();}),a=s=>f(void 0,null,function*(){let l=ne(s);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),i=()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ee(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),u({render:i,destroy:r},p)}}},Dt=St(),re=Dt;var At=e=>{window.setTimeout(e,0);},It=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let d=(i=window.footprintCallbacks)!=null?i:{};if(!k(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Se[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");j(d);let a=(m=r.getAttribute("data-variant"))!=null?m:A(d);H(d,a);let i=_e(),p=t(d),s=r.getAttribute("data-props")||"",l;try{l=JSON.parse(s);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!k(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let y=B();r.setAttribute("id",y),e.init(u(u({kind:d,variant:a,appearance:i,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>At(n));},Ne=It;var Ft="http://test",$e=e=>f(void 0,null,function*(){let t=yield fetch(`${Ft}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),xt=e=>f(void 0,null,function*(){if(!k(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield $e({email:t}))?!0:o?yield $e({phone_number:o}):!1}),He=xt;var pn=re;Ne(re);/*! Bundled license information: | ||
var He=Object.defineProperty,je=Object.defineProperties;var qe=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var ie=(e,t,o)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,u=(e,t)=>{for(var o in t||(t={}))se.call(t,o)&&ie(e,o,t[o]);if(R)for(var o of R(t))de.call(t,o)&&ie(e,o,t[o]);return e},P=(e,t)=>je(e,qe(t));var pe=(e,t)=>{var o={};for(var n in e)se.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&de.call(e,n)&&(o[n]=e[n]);return o};var f=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{i(o.next(p));}catch(s){r(s);}},a=p=>{try{i(o.throw(p));}catch(s){r(s);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,a);i((o=o.apply(e,t)).next());});var O="application/x-postmate-v1+json",ze=5,We=0,Je=function(){return ++We};var Xe=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},Ye={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},q=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==O||!Ye[t.data.postmate])},Ge=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return E.Promise.resolve(n)},Ze=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!q(r,n.childOrigin))return !1;var d=((r||{}).data||{}).value||{},a=d.data,i=d.name;r.data.postmate==="emit"&&i in n.events&&n.events[i].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new E.Promise(function(d){var a=Je(),i=function p(s){s.data.uid===a&&s.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),d(s.data.value));};r.parent.addEventListener("message",i,!1),r.child.postMessage({postmate:"request",type:O,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:O,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),Qe=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(q(r,n.parentOrigin)){var d=r.data,a=d.property,i=d.uid,p=d.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}Ge(n.model,a).then(function(s){return r.source.postMessage({property:a,postmate:"reply",type:O,uid:i,value:s},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:O,value:{name:n,data:r}},this.parentOrigin);},e}(),E=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,d=o.model,a=o.url,i=o.name,p=i===void 0?"":i,s=o.allow,l=o.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=d||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,d=Xe(n),a=0,i;return new e.Promise(function(p,s){var l=function m(g){return q(g,d)?g.data.postmate==="handshake-reply"?(clearInterval(i),r.parent.removeEventListener("message",m,!1),r.childOrigin=g.origin,p(new Ze(r))):s("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var y=function(){a++,r.child.postMessage({postmate:"handshake",type:O,model:r.model},d),a===ze&&clearInterval(i);},C=function(){y(),i=setInterval(y,500);};r.frame.attachEvent?r.frame.attachEvent("onload",C):r.frame.addEventListener("load",C),r.frame.src=n;})},e}();E.debug=!1;E.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();E.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new E.Promise(function(r,d){var a=function i(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",i,!1),p.source.postMessage({postmate:"handshake-reply",type:O},p.origin),n.parentOrigin=p.origin;var s=p.data.model;return s&&Object.keys(s).forEach(function(l){n.model[l]=s[l];}),r(new Qe(n))}return d("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var le=E;var F="3.12.2";var L=(i=>(i.Auth="auth",i.Components="components",i.Form="form",i.Render="render",i.UpdateLoginMethods="update_login_methods",i.Verify="verify",i.VerifyButton="verify-button",i))(L||{});var I=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(I||{}),K=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(K||{});var ce="footprint-inline-container",me="footprint-body-locked",fe="footprint-overlay",tt="footprint-overlay-container",ue=ce,ye=fe,ge="footprint-loading-indicator",_=e=>`${tt}-${e}`,S=(e,t)=>`${e}-${t}`,he=e=>f(void 0,null,function*(){z(e),nt(e),yield ot(e);}),ve=e=>{let t=_(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},ot=e=>f(void 0,null,function*(){let t=_(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(i=>{setTimeout(i,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(i=>{setTimeout(i,100);}));let d=S(ye,e),a=document.getElementById(d);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),a.remove(),document.body.classList.remove(me));}),Pe=(e,t)=>{let o=S(ue,e),n=document.createElement("div");return n.classList.add(ce),n.setAttribute("id",o),t.appendChild(n),n},nt=e=>{let t=S(ue,e),o=document.getElementById(t);o&&o.remove();},z=e=>{let t=S(ge,e),o=document.getElementById(t);o&&o.remove();},W=(e,t)=>{let o=S(ge,t),n=rt(o);e.appendChild(n);},ke=(e,t)=>{document.body.classList.add(me);let o=document.createElement("div"),n=S(ye,t);return o.setAttribute("id",n),o.classList.add(fe),e.appendChild(o),o},rt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ce=e=>{let t=document.getElementById(_(e));t&&(t.style.opacity="1",t.style.display="block");},Ve=e=>{let t=document.getElementById(_(e));t&&(t.style.opacity="0",t.style.display="none");};var at=()=>Math.random().toString(36).substring(2),T=at;var B="https://api.onefootprint.com",M=F,U="footprint-js";var D={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var it=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),J=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(J(e)):Object(r)===r?d=J(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},st=J(it),N=st;var dt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:U,sdkVersion:M,logLevel:o,logMessage:t};try{fetch(`${B}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N(r))});}catch(d){}},X=dt;var Y=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}X(e,t,"warn",n);}return o},we=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}X(e,t,"error",n);}return o};var Oe={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Ee={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Se={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},pt=Object.values(I),lt=(...e)=>{},k=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),G=e=>k(e)&&Object.keys(e).length>0,ct=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},$=(e,t)=>{var r;if(!t)return;let o=(r=Se[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},x=e=>{var o;let t=(o=Se[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},H=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(L);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},De=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:a,label:i,containerId:p}=t,s=pe(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(u({},s),{variant:d,kind:"verify"})}};var xe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||lt,Z=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Oe[n])!=null?i:{},d={},a=De(e);return Object.entries(r).forEach(([p,s])=>{let l=p;if(!pt.includes(l))return;let y=xe(e,s),C=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=g=>{y(g),C&&(t==null||t()),m&&a&&(o==null||o(a));};}),d},A=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||x(t);return H(t),$(t,o),ct(r,n),G(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(u({},e),{variant:r})},V=e=>G(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:G(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var mt=e=>e==="auth";var ft=e=>e==="update_login_methods";var Q=e=>e.kind==="components";var ee=e=>typeof e=="string"&&e.length>0,j=e=>mt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),ut=e=>ft(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),te=e=>[j,ut].some(t=>t(e));var yt=3,gt=!1,ht=e=>te(e)?"update_auth_methods_v1":D[e.kind],vt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return P(u({},V(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return j(e)?P(u({},V(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&>?P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(u({},V(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(u({},V(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Ie=(e,t)=>f(void 0,null,function*(){return fetch(`${B}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${U} ${M} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Ie(e,t-1)})}),Pt=e=>f(void 0,null,function*(){let t=vt(e);if(!t)return;let o=yield Ie({data:N(t),kind:ht(e)},yt);return o?o.token:void 0}),Ae=Pt;var Re=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},Fe=()=>{let e=window.footprintAppearance;return !e||!k(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Le=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},kt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:a,rules:i,variables:p}=Re(o),s=new URLSearchParams;return p&&s.append("variables",p),i&&s.append("rules",i),a&&s.append("font_src",a),r!=null&&r.language&&s.append("lng",r.language),s.append("variant",d||x(n)),`${s.toString()}#${t}`},Ct=(e,t)=>{let{kind:o}=e,n=kt(e,t),r=`https://components.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com"),!ee(r))throw new Error(`${o}_URL environment variable is not defined.`);return `${r}?${n}`.trim()},Ke=Ct;var Vt=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:a,formSaveFailed:i,started:p}=K,s=A(e),{variant:l,containerId:y}=s,C=l==="modal"||l==="drawer",m=T(),g=(c,h)=>{var w;let v=we(D[s.kind],c);(w=s.onError)==null||w.call(s,v),o&&h&&(n(),o=!1);},Ue=()=>{if(!t){g("Footprint should be initialized in order to register callback props");return}let c=Z(s,n,r);Object.entries(c).forEach(([h,v])=>{t==null||t.on(h,v),t==null||t.on(`${m}:${h}`,v);});},Ne=()=>{if(C)return ve(m);if(!y){g("containerId is required when rendering inline");return}let c=document.getElementById(y);if(!c){g(`Could not find container with id ${y} while rendering footprint`);return}return Pe(m,c)},re=(c,h)=>{if(!h){z(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(C){let v=ke(c,m);W(v,m);}else W(c,m);},ae=()=>{var h;if(!t){g("Footprint should be initialized in order to set up refs");return}if(s.kind!=="form"||!s.getRef)return;let c={save:()=>(t||g("Footprint should be initialized to call ref methods"),new Promise((v,w)=>{t==null||t.on(d,()=>{v();}),t==null||t.on(i,$e=>{w($e);}),t==null||t.on(`${m}:${d}`,v),t==null||t.on(`${m}:${i}`,w),t==null||t.call(a);}))};(h=s.getRef)==null||h.call(s,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ce(m));},props:s,isRendered:o,render:()=>f(void 0,null,function*(){if(o){Y(D[s.kind],"Footprint component is already rendered");return}let c=Ne();if(!c){Y(D[s.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,re(c,!0);let h=yield Ae(s);if(!h){g("Unable to get SDK args token.",!0);return}let v=Ke(s,h||"");try{t=yield new le({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:v,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:s.authToken,initId:m,sdkUrl:Le(),sdkVersion:F||""}});}catch(w){g(`Initializing iframe failed with error ${w}`,!0);return}re(c,!1),Ue(),t==null||t.on(p,()=>ae()),t==null||t.on(`${m}:${p}`,ae),s.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Ve(m);}));}),destroy:()=>f(void 0,null,function*(){o&&(o=!1,yield he(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},oe=Vt;var b=e=>{let t=A(e);return JSON.stringify(t)},bt=()=>{let e=Object.create(null);return {getOrCreate:d=>{let a=b(d.props),i=Object.values(e).find(p=>b(p.iframe.props)===a);return i?i.iframe:(e[a]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[i],l=Object.values(s).find(y=>b(y.props)===p);return l||(s[p]=a,a)},remove:d=>{let a=b(d.props),i=e[a];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[i],l=s[p];l&&(l.destroy(),delete s[p]);}}},_e=bt;var wt=()=>{let e=_e();return {init:o=>{let n=oe(o),r=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=s=>f(void 0,null,function*(){e.removeSecondary(n,s),yield s.destroy();}),a=s=>f(void 0,null,function*(){let l=oe(s);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),i=()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return Q(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),u({render:i,destroy:r},p)}}},Ot=wt(),ne=Ot;var Et=e=>{window.setTimeout(e,0);},St=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let d=(i=window.footprintCallbacks)!=null?i:{};if(!k(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ee[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");H(d);let a=(m=r.getAttribute("data-variant"))!=null?m:x(d);$(d,a);let i=Fe(),p=t(d),s=r.getAttribute("data-props")||"",l;try{l=JSON.parse(s);}catch(g){throw Error("Could not parse `data-props` for footprint.")}if(!k(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let y=T();r.setAttribute("id",y),e.init(u(u({kind:d,variant:a,appearance:i,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>Et(n));},Te=St;var Dt="http://test",Be=e=>f(void 0,null,function*(){let t=yield fetch(`${Dt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),xt=e=>f(void 0,null,function*(){if(!k(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Be({email:t}))?!0:o?yield Be({phone_number:o}):!1}),Me=xt;var sn=ne;Te(ne);/*! Bundled license information: | ||
@@ -16,7 +16,7 @@ @onefootprint/postmate/build/postmate.es.js: | ||
exports.FootprintComponentKind = K; | ||
exports.FootprintPrivateEvent = _; | ||
exports.FootprintComponentKind = L; | ||
exports.FootprintPrivateEvent = K; | ||
exports.FootprintPublicEvent = I; | ||
exports.default = pn; | ||
exports.identifyFootprintUser = He; | ||
exports.default = sn; | ||
exports.identifyFootprintUser = Me; | ||
@@ -23,0 +23,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "3.12.1", | ||
"version": "3.12.2", | ||
"main": "./dist/footprint-js.cjs", | ||
@@ -14,4 +14,9 @@ "module": "./dist/footprint-js.js", | ||
"license": "MIT", | ||
"files": ["dist"], | ||
"keywords": ["kyc", "identity verification"], | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"kyc", | ||
"identity verification" | ||
], | ||
"scripts": { | ||
@@ -18,0 +23,0 @@ "build": "tsup", |
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
72310