Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onefootprint/footprint-js - npm Package Compare versions

Comparing version 3.2.0-beta.1 to 3.2.0-beta.2

453

dist/footprint-js.d.ts
import * as CSS from 'csstype';
type AppearanceVariables = Partial<{
borderRadius: CSS.Property.BorderRadius;
colorError: CSS.Property.Color;
colorWarning: CSS.Property.Color;
colorSuccess: CSS.Property.Color;
colorAccent: CSS.Property.Color;
borderColorError: CSS.Property.BorderColor;
containerBg: CSS.Property.Background;
containerElevation: CSS.Property.BoxShadow;
containerBorder: CSS.Property.Border;
containerBorderRadius: CSS.Property.BorderRadius;
linkColor: CSS.Property.Color;
fontFamily: CSS.Property.FontFamily;
labelColor: CSS.Property.Color;
labelFont: CSS.Property.Font;
inputBorderRadius: CSS.Property.BorderRadius;
inputBorderWidth: CSS.Property.BorderWidth;
inputFont: CSS.Property.Font;
inputHeight: CSS.Property.Height;
inputPlaceholderColor: CSS.Property.Color;
inputColor: CSS.Property.Color;
inputBg: CSS.Property.Background;
inputBorderColor: CSS.Property.BorderColor;
inputElevation: CSS.Property.BoxShadow;
inputHoverBg: CSS.Property.Background;
inputHoverBorderColor: CSS.Property.BorderColor;
inputHoverElevation: CSS.Property.BoxShadow;
inputFocusBg: CSS.Property.Background;
inputFocusBorderColor: CSS.Property.BorderColor;
inputFocusElevation: CSS.Property.BoxShadow;
inputErrorBg: CSS.Property.Background;
inputErrorBorderColor: CSS.Property.BorderColor;
inputErrorElevation: CSS.Property.BoxShadow;
inputErrorHoverBg: CSS.Property.Background;
inputErrorHoverBorderColor: CSS.Property.BorderColor;
inputErrorHoverElevation: CSS.Property.BoxShadow;
inputErrorFocusBg: CSS.Property.Background;
inputErrorFocusBorderColor: CSS.Property.BorderColor;
inputErrorFocusElevation: CSS.Property.BoxShadow;
hintColor: CSS.Property.Color;
hintErrorColor: CSS.Property.Color;
hintFont: CSS.Property.Font;
linkButtonColor: CSS.Property.Color;
linkButtonHoverColor: CSS.Property.Color;
linkButtonActiveColor: CSS.Property.Color;
linkButtonDestructiveColor: CSS.Property.Color;
linkButtonDestructiveHoverColor: CSS.Property.Color;
linkButtonDestructiveActiveColor: CSS.Property.Color;
buttonBorderRadius: CSS.Property.BorderRadius;
buttonBorderWidth: CSS.Property.BorderWidth;
buttonElevation: CSS.Property.BoxShadow;
buttonElevationHover: CSS.Property.BoxShadow;
buttonElevationActive: CSS.Property.BoxShadow;
buttonOutlineOffset: CSS.Property.OutlineOffset;
buttonPrimaryBg: CSS.Property.Background;
buttonPrimaryColor: CSS.Property.Color;
buttonPrimaryBorderColor: CSS.Property.BorderColor;
buttonPrimaryHoverBg: CSS.Property.Background;
buttonPrimaryHoverColor: CSS.Property.Color;
buttonPrimaryHoverBorderColor: CSS.Property.BorderColor;
buttonPrimaryActiveBg: CSS.Property.Background;
buttonPrimaryActiveColor: CSS.Property.Color;
buttonPrimaryActiveBorderColor: CSS.Property.BorderColor;
buttonPrimaryDisabledBg: CSS.Property.Background;
buttonPrimaryDisabledColor: CSS.Property.Color;
buttonPrimaryDisabledBorderColor: CSS.Property.BorderColor;
buttonPrimaryLoadingBg: CSS.Property.Background;
buttonPrimaryLoadingColor: CSS.Property.Color;
buttonsPrimaryLoadingBorderColor: CSS.Property.BorderColor;
buttonSecondaryBg: CSS.Property.Background;
buttonSecondaryColor: CSS.Property.Color;
buttonSecondaryBorderColor: CSS.Property.BorderColor;
buttonSecondaryHoverBg: CSS.Property.Background;
buttonSecondaryHoverColor: CSS.Property.Color;
buttonSecondaryHoverBorderColor: CSS.Property.BorderColor;
buttonSecondaryActiveBg: CSS.Property.Background;
buttonSecondaryActiveColor: CSS.Property.Color;
buttonSecondaryActiveBorderColor: CSS.Property.BorderColor;
buttonSecondaryDisabledBg: CSS.Property.Background;
buttonSecondaryDisabledColor: CSS.Property.Color;
buttonSecondaryDisabledBorderColor: CSS.Property.BorderColor;
buttonSecondaryLoadingBg: CSS.Property.Background;
buttonSecondaryLoadingColor: CSS.Property.Color;
dropdownBg: CSS.Property.Background;
dropdownHoverBg: CSS.Property.Background;
dropdownBorderColor: CSS.Property.BorderColor;
dropdownBorderWidth: CSS.Property.BorderWidth;
dropdownBorderRadius: CSS.Property.BorderRadius;
dropdownElevation: CSS.Property.BoxShadow;
dropdownColorPrimary: CSS.Property.Color;
dropdownColorSecondary: CSS.Property.Color;
dropdownFooterBg: CSS.Property.Background;
radioSelectBg: CSS.Property.Background;
radioSelectBorderRadius: CSS.Property.BorderRadius;
radioSelectBorderWidth: CSS.Property.BorderWidth;
radioSelectBorderColor: CSS.Property.BorderColor;
radioSelectHoverBg: CSS.Property.Background;
radioSelectHoverBorderColor: CSS.Property.BorderColor;
radioSelectSelectedBg: CSS.Property.Background;
radioSelectSelectedBorderColor: CSS.Property.BorderColor;
radioSelectComponentsIconBg: CSS.Property.Background;
radioSelectComponentsIconHoverBg: CSS.Property.Background;
radioSelectComponentsIconSelectedBg: CSS.Property.Background;
borderRadius: CSS.Property.BorderRadius;
colorError: CSS.Property.Color;
colorWarning: CSS.Property.Color;
colorSuccess: CSS.Property.Color;
colorAccent: CSS.Property.Color;
borderColorError: CSS.Property.BorderColor;
containerBg: CSS.Property.Background;
containerElevation: CSS.Property.BoxShadow;
containerBorder: CSS.Property.Border;
containerBorderRadius: CSS.Property.BorderRadius;
linkColor: CSS.Property.Color;
fontFamily: CSS.Property.FontFamily;
labelColor: CSS.Property.Color;
labelFont: CSS.Property.Font;
inputBorderRadius: CSS.Property.BorderRadius;
inputBorderWidth: CSS.Property.BorderWidth;
inputFont: CSS.Property.Font;
inputHeight: CSS.Property.Height;
inputPlaceholderColor: CSS.Property.Color;
inputColor: CSS.Property.Color;
inputBg: CSS.Property.Background;
inputBorderColor: CSS.Property.BorderColor;
inputElevation: CSS.Property.BoxShadow;
inputHoverBg: CSS.Property.Background;
inputHoverBorderColor: CSS.Property.BorderColor;
inputHoverElevation: CSS.Property.BoxShadow;
inputFocusBg: CSS.Property.Background;
inputFocusBorderColor: CSS.Property.BorderColor;
inputFocusElevation: CSS.Property.BoxShadow;
inputErrorBg: CSS.Property.Background;
inputErrorBorderColor: CSS.Property.BorderColor;
inputErrorElevation: CSS.Property.BoxShadow;
inputErrorHoverBg: CSS.Property.Background;
inputErrorHoverBorderColor: CSS.Property.BorderColor;
inputErrorHoverElevation: CSS.Property.BoxShadow;
inputErrorFocusBg: CSS.Property.Background;
inputErrorFocusBorderColor: CSS.Property.BorderColor;
inputErrorFocusElevation: CSS.Property.BoxShadow;
hintColor: CSS.Property.Color;
hintErrorColor: CSS.Property.Color;
hintFont: CSS.Property.Font;
linkButtonColor: CSS.Property.Color;
linkButtonHoverColor: CSS.Property.Color;
linkButtonActiveColor: CSS.Property.Color;
linkButtonDestructiveColor: CSS.Property.Color;
linkButtonDestructiveHoverColor: CSS.Property.Color;
linkButtonDestructiveActiveColor: CSS.Property.Color;
buttonBorderRadius: CSS.Property.BorderRadius;
buttonBorderWidth: CSS.Property.BorderWidth;
buttonElevation: CSS.Property.BoxShadow;
buttonElevationHover: CSS.Property.BoxShadow;
buttonElevationActive: CSS.Property.BoxShadow;
buttonOutlineOffset: CSS.Property.OutlineOffset;
buttonPrimaryBg: CSS.Property.Background;
buttonPrimaryColor: CSS.Property.Color;
buttonPrimaryBorderColor: CSS.Property.BorderColor;
buttonPrimaryHoverBg: CSS.Property.Background;
buttonPrimaryHoverColor: CSS.Property.Color;
buttonPrimaryHoverBorderColor: CSS.Property.BorderColor;
buttonPrimaryActiveBg: CSS.Property.Background;
buttonPrimaryActiveColor: CSS.Property.Color;
buttonPrimaryActiveBorderColor: CSS.Property.BorderColor;
buttonPrimaryDisabledBg: CSS.Property.Background;
buttonPrimaryDisabledColor: CSS.Property.Color;
buttonPrimaryDisabledBorderColor: CSS.Property.BorderColor;
buttonPrimaryLoadingBg: CSS.Property.Background;
buttonPrimaryLoadingColor: CSS.Property.Color;
buttonsPrimaryLoadingBorderColor: CSS.Property.BorderColor;
buttonSecondaryBg: CSS.Property.Background;
buttonSecondaryColor: CSS.Property.Color;
buttonSecondaryBorderColor: CSS.Property.BorderColor;
buttonSecondaryHoverBg: CSS.Property.Background;
buttonSecondaryHoverColor: CSS.Property.Color;
buttonSecondaryHoverBorderColor: CSS.Property.BorderColor;
buttonSecondaryActiveBg: CSS.Property.Background;
buttonSecondaryActiveColor: CSS.Property.Color;
buttonSecondaryActiveBorderColor: CSS.Property.BorderColor;
buttonSecondaryDisabledBg: CSS.Property.Background;
buttonSecondaryDisabledColor: CSS.Property.Color;
buttonSecondaryDisabledBorderColor: CSS.Property.BorderColor;
buttonSecondaryLoadingBg: CSS.Property.Background;
buttonSecondaryLoadingColor: CSS.Property.Color;
dropdownBg: CSS.Property.Background;
dropdownHoverBg: CSS.Property.Background;
dropdownBorderColor: CSS.Property.BorderColor;
dropdownBorderWidth: CSS.Property.BorderWidth;
dropdownBorderRadius: CSS.Property.BorderRadius;
dropdownElevation: CSS.Property.BoxShadow;
dropdownColorPrimary: CSS.Property.Color;
dropdownColorSecondary: CSS.Property.Color;
dropdownFooterBg: CSS.Property.Background;
radioSelectBg: CSS.Property.Background;
radioSelectBorderRadius: CSS.Property.BorderRadius;
radioSelectBorderWidth: CSS.Property.BorderWidth;
radioSelectBorderColor: CSS.Property.BorderColor;
radioSelectHoverBg: CSS.Property.Background;
radioSelectHoverBorderColor: CSS.Property.BorderColor;
radioSelectSelectedBg: CSS.Property.Background;
radioSelectSelectedBorderColor: CSS.Property.BorderColor;
radioSelectComponentsIconBg: CSS.Property.Background;
radioSelectComponentsIconHoverBg: CSS.Property.Background;
radioSelectComponentsIconSelectedBg: CSS.Property.Background;
}>;
type AppearanceTheme = 'light' | 'dark';
type AppearanceRules = Partial<{
button: CSS.Properties;
'button:hover': CSS.Properties;
'button:focus': CSS.Properties;
'button:active': CSS.Properties;
input: CSS.Properties;
'input:hover': CSS.Properties;
'input:focus': CSS.Properties;
'input:active': CSS.Properties;
pinInput: CSS.Properties;
'pinInput:hover': CSS.Properties;
'pinInput:focus': CSS.Properties;
'pinInput:active': CSS.Properties;
label: CSS.Properties;
hint: CSS.Properties;
link: CSS.Properties;
'link:hover': CSS.Properties;
'link:active': CSS.Properties;
linkButton: CSS.Properties;
'linkButton:hover': CSS.Properties;
'linkButton:focus': CSS.Properties;
'linkButton:active': CSS.Properties;
button: CSS.Properties;
'button:hover': CSS.Properties;
'button:focus': CSS.Properties;
'button:active': CSS.Properties;
input: CSS.Properties;
'input:hover': CSS.Properties;
'input:focus': CSS.Properties;
'input:active': CSS.Properties;
pinInput: CSS.Properties;
'pinInput:hover': CSS.Properties;
'pinInput:focus': CSS.Properties;
'pinInput:active': CSS.Properties;
label: CSS.Properties;
hint: CSS.Properties;
link: CSS.Properties;
'link:hover': CSS.Properties;
'link:active': CSS.Properties;
linkButton: CSS.Properties;
'linkButton:hover': CSS.Properties;
'linkButton:focus': CSS.Properties;
'linkButton:active': CSS.Properties;
}>;
type Appearance = {
variant?: 'modal' | 'drawer' | 'inline';
fontSrc?: string;
rules?: AppearanceRules;
theme?: AppearanceTheme;
variables?: AppearanceVariables;
variant?: 'modal' | 'drawer' | 'inline';
fontSrc?: string;
rules?: AppearanceRules;
theme?: AppearanceTheme;
variables?: AppearanceVariables;
};
type FootprintUserData = Partial<{
'id.email': string;
'id.phone_number': string;
'id.first_name': string;
'id.last_name': string;
'id.dob': string;
'id.address_line1': string;
'id.address_line2': string;
'id.city': string;
'id.state': string;
'id.country': string;
'id.zip': string;
'id.ssn9': string;
'id.ssn4': string;
'id.nationality': string;
'id.email': string;
'id.phone_number': string;
'id.first_name': string;
'id.last_name': string;
'id.dob': string;
'id.address_line1': string;
'id.address_line2': string;
'id.city': string;
'id.state': string;
'id.country': string;
'id.zip': string;
'id.ssn9': string;
'id.ssn4': string;
'id.nationality': string;
}>;
interface Footprint {
init: (props: Props) => Component;
init: (props: Props) => Component;
}
interface Component {
render: () => Promise<void>;
destroy: () => void;
render: () => Promise<void>;
destroy: () => void;
}
type Props = FormProps | VerifyProps | VerifyButtonProps | RenderProps;
declare enum ComponentKind {
Verify = 'verify',
Form = 'form',
Render = 'render',
VerifyButton = 'verify-button',
Verify = "verify",
Form = "form",
Render = "render",
VerifyButton = "verify-button"
}
type Variant = 'modal' | 'drawer' | 'inline';
interface PropsBase {
kind: ComponentKind;
appearance?: Appearance;
variant?: Variant;
containerId?: string;
kind: ComponentKind;
appearance?: Appearance;
variant?: Variant;
containerId?: string;
}
type VerifyOptions = {
showCompletionPage?: boolean;
showLogo?: boolean;
showCompletionPage?: boolean;
showLogo?: boolean;
};
interface VerifyProps extends PropsBase {
kind: ComponentKind.Verify;
variant?: 'modal' | 'drawer';
publicKey: string;
userData?: FootprintUserData;
options?: VerifyOptions;
onComplete?: (validationToken: string) => void;
onCancel?: () => void;
onClose?: () => void;
kind: ComponentKind.Verify;
variant?: 'modal' | 'drawer';
publicKey: string;
userData?: FootprintUserData;
options?: VerifyOptions;
onComplete?: (validationToken: string) => void;
onCancel?: () => void;
onClose?: () => void;
}
interface VerifyButtonProps extends PropsBase {
kind: ComponentKind.VerifyButton;
variant: 'inline';
containerId: string;
dialogVariant?: 'modal' | 'drawer';
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
label?: string;
publicKey?: string;
userData?: FootprintUserData;
options?: VerifyOptions;
onComplete?: (validationToken: string) => void;
onCancel?: () => void;
onClose?: () => void;
kind: ComponentKind.VerifyButton;
variant: 'inline';
containerId: string;
dialogVariant?: 'modal' | 'drawer';
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
label?: string;
publicKey?: string;
userData?: FootprintUserData;
options?: VerifyOptions;
onComplete?: (validationToken: string) => void;
onCancel?: () => void;
onClose?: () => void;
}
interface RenderProps extends PropsBase {
kind: ComponentKind.Render;
authToken: string;
id: string;
label?: string;
canCopy?: boolean;
showHiddenToggle?: boolean;
defaultHidden?: boolean;
variant: 'inline';
containerId: string;
kind: ComponentKind.Render;
authToken: string;
id: string;
label?: string;
canCopy?: boolean;
showHiddenToggle?: boolean;
defaultHidden?: boolean;
variant: 'inline';
containerId: string;
}
declare enum FormType {
cardOnly = 'cardOnly',
cardAndName = 'cardAndName',
cardAndNameAndAddress = 'cardAndNameAndAddress',
cardAndZip = 'cardAndZip',
cardOnly = "cardOnly",
cardAndName = "cardAndName",
cardAndNameAndAddress = "cardAndNameAndAddress",
cardAndZip = "cardAndZip"
}
type FormOptions = {
hideFootprintLogo?: boolean;
hideButtons?: boolean;
hideFootprintLogo?: boolean;
hideButtons?: boolean;
};
type FormRef = {
save: () => void;
save: () => void;
};
interface FormProps extends PropsBase {
kind: ComponentKind.Form;
authToken: string;
title?: string;
type?: FormType;
containerId?: string;
variant?: Variant;
options?: FormOptions;
getRef?: (ref: FormRef) => void;
onComplete?: () => void;
onCancel?: () => void;
onClose?: () => void;
kind: ComponentKind.Form;
authToken: string;
title?: string;
type?: FormType;
containerId?: string;
variant?: Variant;
options?: FormOptions;
getRef?: (ref: FormRef) => void;
onComplete?: () => void;
onCancel?: () => void;
onClose?: () => void;
}

@@ -246,21 +246,19 @@

declare enum PublicEvent {
closed = 'closed',
canceled = 'canceled',
completed = 'completed',
clicked = 'clicked',
closed = "closed",
canceled = "canceled",
completed = "completed",
clicked = "clicked"
}
declare enum PrivateEvent {
propsReceived = 'propsReceived',
started = 'started',
formSaved = 'formSaved',
propsReceived = "propsReceived",
started = "started",
formSaved = "formSaved"
}
type IdentifyRequest = {
identifier:
| {
identifier: {
email: string;
}
| {
} | {
phone_number: string;
};
};
};

@@ -270,27 +268,2 @@

export {
Footprint,
Appearance as FootprintAppearance,
AppearanceRules as FootprintAppearanceRules,
AppearanceTheme as FootprintAppearanceTheme,
AppearanceVariables as FootprintAppearanceVariables,
Component as FootprintComponent,
ComponentKind as FootprintComponentKind,
FormOptions as FootprintFormOptions,
FormProps as FootprintFormProps,
FormRef as FootprintFormRef,
FormType as FootprintFormType,
IdentifyRequest as FootprintIdentifyRequest,
PrivateEvent as FootprintPrivateEvent,
Props as FootprintProps,
PropsBase as FootprintPropsBase,
PublicEvent as FootprintPublicEvent,
RenderProps as FootprintRenderProps,
FootprintUserData,
Variant as FootprintVariant,
VerifyButtonProps as FootprintVerifyButtonProps,
VerifyOptions as FootprintVerifyOptions,
VerifyProps as FootprintVerifyProps,
footprint as default,
identifyUser as identifyFootprintUser,
};
export { Footprint, Appearance as FootprintAppearance, AppearanceRules as FootprintAppearanceRules, AppearanceTheme as FootprintAppearanceTheme, AppearanceVariables as FootprintAppearanceVariables, Component as FootprintComponent, ComponentKind as FootprintComponentKind, FormOptions as FootprintFormOptions, FormProps as FootprintFormProps, FormRef as FootprintFormRef, FormType as FootprintFormType, IdentifyRequest as FootprintIdentifyRequest, PrivateEvent as FootprintPrivateEvent, Props as FootprintProps, PropsBase as FootprintPropsBase, PublicEvent as FootprintPublicEvent, RenderProps as FootprintRenderProps, FootprintUserData, Variant as FootprintVariant, VerifyButtonProps as FootprintVerifyButtonProps, VerifyOptions as FootprintVerifyOptions, VerifyProps as FootprintVerifyProps, footprint as default, identifyUser as identifyFootprintUser };

@@ -1,1134 +0,3 @@

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var ve=Object.defineProperty,ge=Object.defineProperties;var he=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&$(e,r,t[r]);if(V)for(var r of V(t))j.call(t,r)&&$(e,r,t[r]);return e},F=(e,t)=>ge(e,he(t));var x=(e,t)=>{var r={};for(var n in e)U.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&V)for(var n of V(e))t.indexOf(n)<0&&j.call(e,n)&&(r[n]=e[n]);return r};var m=(e,t,r)=>new Promise((n,o)=>{var a=i=>{try{c(r.next(i));}catch(s){o(s);}},d=i=>{try{c(r.throw(i));}catch(s){o(s);}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(a,d);c((r=r.apply(e,t)).next());});var E="application/x-postmate-v1+json",Pe=5,Ee=0,Ce=function(){return ++Ee};var we=function(t){var r=document.createElement("a");r.href=t;var n=r.protocol.length>4?r.protocol:window.location.protocol,o=r.host.length?r.port==="80"||r.port==="443"?r.hostname:r.host:window.location.host;return r.origin||n+"//"+o},Ie={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},L=function(t,r){return !(typeof r=="string"&&t.origin!==r||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!Ie[t.data.postmate])},be=function(t,r){var n=typeof t[r]=="function"?t[r]():t[r];return C.Promise.resolve(n)},Oe=function(){function e(r){var n=this;this.parent=r.parent,this.frame=r.frame,this.child=r.child,this.childOrigin=r.childOrigin,this.events={},this.listener=function(o){if(!L(o,n.childOrigin))return !1;var a=((o||{}).data||{}).value||{},d=a.data,c=a.name;o.data.postmate==="emit"&&c in n.events&&n.events[c].forEach(function(i){i.call(n,d);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var o=this;return new C.Promise(function(a){var d=Ce(),c=function i(s){s.data.uid===d&&s.data.postmate==="reply"&&(o.parent.removeEventListener("message",i,!1),a(s.data.value));};o.parent.addEventListener("message",c,!1),o.child.postMessage({postmate:"request",type:E,property:n,uid:d},o.childOrigin);})},t.call=function(n,o){this.child.postMessage({postmate:"call",type:E,property:n,data:o},this.childOrigin);},t.on=function(n,o){this.events[n]||(this.events[n]=[]),this.events[n].push(o);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),Ve=function(){function e(r){var n=this;this.model=r.model,this.parent=r.parent,this.parentOrigin=r.parentOrigin,this.child=r.child,this.child.addEventListener("message",function(o){if(L(o,n.parentOrigin)){var a=o.data,d=a.property,c=a.uid,i=a.data;if(o.data.postmate==="call"){d in n.model&&typeof n.model[d]=="function"&&n.model[d](i);return}be(n.model,d).then(function(s){return o.source.postMessage({property:d,postmate:"reply",type:E,uid:c,value:s},o.origin)});}});}var t=e.prototype;return t.emit=function(n,o){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:o}},this.parentOrigin);},e}(),C=function(){function e(r){var n=r.container,o=n===void 0?typeof o!="undefined"?o:document.body:n,a=r.model,d=r.url,c=r.name,i=c===void 0?"":c,s=r.allow,p=r.classListArray,f=p===void 0?[]:p;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=i||"",this.frame.classList.add.apply(this.frame.classList,f),s&&(this.frame.allow=s),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(d)}var t=e.prototype;return t.sendHandshake=function(n){var o=this,a=we(n),d=0,c;return new e.Promise(function(i,s){var p=function v(g){return L(g,a)?g.data.postmate==="handshake-reply"?(clearInterval(c),o.parent.removeEventListener("message",v,!1),o.childOrigin=g.origin,i(new Oe(o))):s("Failed handshake"):!1};o.parent.addEventListener("message",p,!1);var f=function(){d++,o.child.postMessage({postmate:"handshake",type:E,model:o.model},a),d===Pe&&clearInterval(c);},y=function(){f(),c=setInterval(f,500);};o.frame.attachEvent?o.frame.attachEvent("onload",y):o.frame.addEventListener("load",y),o.frame.src=n;})},e}();C.debug=!1;C.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();C.Model=function(){function e(r){return this.child=window,this.model=r,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new C.Promise(function(o,a){var d=function c(i){if(i.data.postmate){if(i.data.postmate==="handshake"){n.child.removeEventListener("message",c,!1),i.source.postMessage({postmate:"handshake-reply",type:E},i.origin),n.parentOrigin=i.origin;var s=i.data.model;return s&&Object.keys(s).forEach(function(p){n.model[p]=s[p];}),o(new Ve(n))}return a("Handshake Reply Failed")}};n.child.addEventListener("message",d,!1);})},e}();var q=C;var b=(o=>(o.Verify="verify",o.Form="form",o.Render="render",o.VerifyButton="verify-button",o))(b||{}),H=(o=>(o.cardOnly="cardOnly",o.cardAndName="cardAndName",o.cardAndNameAndAddress="cardAndNameAndAddress",o.cardAndZip="cardAndZip",o))(H||{});var R=(o=>(o.closed="closed",o.canceled="canceled",o.completed="completed",o.clicked="clicked",o))(R||{}),z=(n=>(n.propsReceived="propsReceived",n.started="started",n.formSaved="formSaved",n))(z||{});var J="footprint-inline-container",X="footprint-body-locked",Y="footprint-overlay",Z="footprint-overlay-container",W=J,G=Y,Q="footprint-loading-indicator",h=(e,t)=>`${e}-${t}`,ee=e=>m(void 0,null,function*(){N(e),ke(e),yield Re(e);}),te=e=>{let t=h(Z,e),r=document.getElementById(t);if(r)return r;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Re=e=>m(void 0,null,function*(){let t=h(Z,e),r=document.getElementById(t);if(!r)return;let n=r.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(c=>{setTimeout(c,300);}));let o=r.querySelector("iframe.footprint-modal");o&&(o==null||o.classList.add("footprint-modal-closing"),yield new Promise(c=>{setTimeout(c,100);}));let a=h(G,e),d=document.getElementById(a);d&&(d.classList.add("footprint-overlay-fading"),yield new Promise(c=>{setTimeout(c,200);}),r.remove(),d.remove(),document.body.classList.remove(X));}),re=(e,t)=>{let r=h(W,e),n=document.createElement("div");return n.classList.add(J),n.setAttribute("id",r),t.appendChild(n),n},ke=e=>{let t=h(W,e),r=document.getElementById(t);r&&r.remove();},N=e=>{let t=h(Q,e),r=document.getElementById(t);r&&r.remove();},S=(e,t)=>{let r=h(Q,t),n=Ae(r);e.appendChild(n);},ne=(e,t)=>{document.body.classList.add(X);let r=document.createElement("div"),n=h(G,t);return r.setAttribute("id",n),r.classList.add(Y),e.appendChild(r),r},Ae=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let r=document.createElement("div");r.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 o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(o),r.appendChild(n),t.appendChild(r),t};var Fe=()=>`${Math.floor(Math.random()*1e3)}`,k=Fe;var _={["form"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify-button"]:{["clicked"]:"onClick",["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["render"]:{}},oe={["form"]:[],["verify"]:[],["render"]:[],["verify-button"]:[]};var xe={["form"]:["getRef"],["verify"]:[],["verify-button"]:[],["render"]:[]},ae=xe;var ie={["verify"]:["modal","drawer"],["verify-button"]:["inline"],["form"]:["inline","modal","drawer"],["render"]:["inline"]},D=(e,t)=>{var o;if(!t)return;let r=(o=ie[e])!=null?o:[];if(!r.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${r.join(", ")}`)},I=e=>{var r;let t=(r=ie[e])!=null?r:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},B=e=>{if(!e)throw new Error("Kind is required");if(!Object.values(b).includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${Object.values(b).join(", ")}}`)},Le=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},Ne=e=>{let{kind:t}=e;if(t==="verify-button"){let r=e,{kind:n,appearance:o,variant:a,dialogVariant:d,onClick:c,label:i,containerId:s}=r,p=x(r,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return F(w({},p),{variant:d,kind:"verify"})}},Se=e=>{var n;let{kind:t}=e;return (n=ae[t])!=null?n:[]},se=(e,t,r)=>{var d;let{kind:n}=e,o=(d=_[n])!=null?d:{},a={};return Object.entries(o).forEach(([c,i])=>{let s=c;if(!Object.values(R).includes(s))return;let p=e[i];(!p||typeof p!="function")&&(p=()=>{});let f=s==="closed"||s==="canceled",y=n==="verify-button"&&s==="clicked";a[s]=v=>{p(v),f&&(t==null||t());let g=Ne(e);y&&g&&(r==null||r(g));};}),a},de=e=>{var f;let p=e,{kind:t,appearance:r,containerId:n}=p,o=x(p,["kind","appearance","containerId"]),a=(f=_[t])!=null?f:{},d=Object.values(a),c=Se(e),i=Object.values(c);return Object.fromEntries(Object.entries(o).filter(([y])=>!d.includes(y)&&!i.includes(y)))},A=e=>{let{kind:t,variant:r,containerId:n}=e;B(t),D(t,r);let o=r||I(t);return Le(o,n),F(w({},e),{variant:o})};var _e=e=>typeof e=="object"&&!!e,K=({fontSrc:e,variables:t={},rules:r={},variant:n}={})=>{let o=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(r).length?encodeURIComponent(JSON.stringify(r)):void 0;return {fontSrc:e,variables:o(),rules:a(),variant:n}},ce=()=>{let e=window.footprintAppearance;return !e||!_e(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var De=e=>{let{kind:t}=e;return t==="verify"?Be(e):Ke(e)},Be=e=>{let{appearance:t,publicKey:r,variant:n,kind:o}=e,{fontSrc:a,rules:d,variables:c}=K(t),i="https://id.onefootprint.com",s=new URLSearchParams;r&&s.append("public_key",r),c&&s.append("variables",c),d&&s.append("rules",d),a&&s.append("font_src",a),s.append("variant",n!=null?n:I(o));let p=s.toString();return `${i}?${p}`},Ke=e=>{let{appearance:t,kind:r,variant:n}=e,{fontSrc:o,rules:a,variables:d}=K(t),c="https://components.onefootprint.com",i=new URLSearchParams;d&&i.append("variables",d),a&&i.append("rules",a),o&&i.append("font_src",o),i.append("variant",n!=null?n:I(r));let s=i.toString();return `${c}/${r}?${s}`},pe=De;var Me=e=>{let t=null,r=!1,n=A(e),{variant:o,containerId:a}=n,d=o==="modal"||o==="drawer",c,i,s=k(),p=()=>{if(!t)throw new Error("Footprint should be initialized in order to listen events");let l=se(n,c,i);Object.entries(l).forEach(([u,O])=>{t==null||t.on(u,O);});},f=()=>{if(!t)throw new Error("Footprint should be initialized in order to set up refs");let{kind:l}=n;if(l!=="form")return;let{getRef:u}=n;if(!u)return;u({save:()=>{if(!t)throw new Error("Footprint should be initialized to call ref methods");t==null||t.call("formSaved");}});},y=()=>{if(!t)throw new Error("Footprint should be initialized in order to receive props");let l=de(n);t.call("propsReceived",l);},v=()=>{if(d)return te(s);if(!a)throw new Error("containerId is required when rendering inline");let l=document.getElementById(a);if(!l)throw new Error(`Could not find container with id ${a} while rendering footprint`);return re(s,l)},g=(l,u)=>{if(!u){N(s),t==null||t.frame.classList.remove(`footprint-${o}-loading`),t==null||t.frame.classList.add(`footprint-${o}-loaded`);return}if(d){let O=ne(l,s);S(O,s);}else S(l,s);};return {props:n,isRendered:r,render:()=>m(void 0,null,function*(){if(r)return;let l=v();if(!l)return;l.hasChildNodes()&&(l.innerHTML="");let u=pe(n);r=!0,g(l,!0),t=yield new q({classListArray:[`footprint-${o}`,`footprint-${o}-loading`],container:l,name:`footprint-iframe-${s}`,url:u,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"}),g(l,!1),p(),t.on("started",()=>{y(),f();});}),destroy:()=>m(void 0,null,function*(){r&&(r=!1,yield ee(s),t&&(t.destroy(),t=null));}),registerEvent:(l,u)=>{l==="renderSecondary"&&(i=u),l==="destroy"&&(c=u);}}},M=Me;var P=e=>{let t=A(e);return JSON.stringify(t)},Te=()=>{let e={};return {getOrCreate:a=>{let d=P(a.props),c=Object.values(e).find(i=>P(i.iframe.props)===d);return c?c.iframe:(e[d]={iframe:a,secondaryIframes:{}},a)},remove:a=>{let d=P(a.props),c=e[d];c&&(Object.keys(c.secondaryIframes).forEach(i=>{c.secondaryIframes[i].destroy();}),delete e[d]);},getOrCreateSecondary:(a,d)=>{let c=P(a.props),i=P(d.props);if(!e[c])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[c],p=Object.values(s).find(f=>P(f.props)===i);return p||(s[i]=d,d)},removeSecondary:(a,d)=>{let c=P(a.props),i=P(d.props);if(!e[c])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[c],p=s[i];p&&(p.destroy(),delete s[i]);}}},le=Te;var $e=()=>{let e=le();return {init:r=>{let n=M(r),o=()=>m(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=i=>m(void 0,null,function*(){e.removeSecondary(n,i),yield i.destroy();}),d=i=>m(void 0,null,function*(){let s=M(i);s=e.getOrCreateSecondary(n,s),s.registerEvent("destroy",()=>{a(s);}),s.render();});return {render:()=>m(void 0,null,function*(){n=e.getOrCreate(n),n.registerEvent("destroy",o),n.registerEvent("renderSecondary",d),yield n.render();}),destroy:o}}}},Ue=$e(),T=Ue;var je=e=>{window.setTimeout(e,0);},fe=e=>typeof e=="object"&&!!e,qe=e=>{if(typeof window=="undefined")return;let t=o=>{var c;let a=(c=window.footprintCallbacks)!=null?c:{};if(!fe(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return oe[o].forEach(i=>{if(!a[i])throw Error(`Callback '${i}' must be defined in window.footprintCallbacks`)}),a},r=o=>{var v;let a=o.getAttribute("data-kind");B(a);let d=(v=o.getAttribute("data-variant"))!=null?v:I(a);D(a,d);let c=ce(),i=t(a),s=o.getAttribute("data-props")||"",p;try{p=JSON.parse(s);}catch(g){throw Error("Could not parse `data-props` for footprint.")}if(!fe(p))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let f=k();o.setAttribute("id",f),e.init(w(w({kind:a,variant:d,appearance:c,containerId:o.id},i),p)).render();},n=()=>{let o=document.querySelectorAll("[data-footprint]");o.length&&o.forEach(a=>{r(a);});};document.addEventListener("DOMContentLoaded",()=>je(n));},me=qe;var ue=e=>m(void 0,null,function*(){let t=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),He=e=>m(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],r=e["id.phone_number"];return t&&(yield ue({identifier:{email:t}}))?!0:r?yield ue({identifier:{phone_number:r}}):!1}),ye=He;var Ht=T;me(T);/*! Bundled license information:
// ../../node_modules/@onefootprint/postmate/build/postmate.es.js
var messageType = "application/x-postmate-v1+json";
var maxHandshakeRequests = 5;
var _messageId = 0;
var generateNewMessageId = function generateNewMessageId2() {
return ++_messageId;
};
var log = function log2() {
var _console;
return Postmate.debug ? (_console = console).log.apply(_console, arguments) : null;
};
var resolveOrigin = function resolveOrigin2(url) {
var a = document.createElement("a");
a.href = url;
var protocol = a.protocol.length > 4 ? a.protocol : window.location.protocol;
var host = a.host.length ? a.port === "80" || a.port === "443" ? a.hostname : a.host : window.location.host;
return a.origin || protocol + "//" + host;
};
var messageTypes = {
handshake: 1,
"handshake-reply": 1,
call: 1,
emit: 1,
reply: 1,
request: 1
/**
* Ensures that a message is safe to interpret
* @param {Object} message The postmate message being sent
* @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
* @return {Boolean}
*/
};
var sanitize = function sanitize2(message, allowedOrigin) {
if (typeof allowedOrigin === "string" && message.origin !== allowedOrigin)
return false;
if (!message.data)
return false;
if (typeof message.data === "object" && !("postmate" in message.data))
return false;
if (message.data.type !== messageType)
return false;
if (!messageTypes[message.data.postmate])
return false;
return true;
};
var resolveValue = function resolveValue2(model, property) {
var unwrappedContext = typeof model[property] === "function" ? model[property]() : model[property];
return Postmate.Promise.resolve(unwrappedContext);
};
var ParentAPI = /* @__PURE__ */ function() {
function ParentAPI2(info) {
var _this = this;
this.parent = info.parent;
this.frame = info.frame;
this.child = info.child;
this.childOrigin = info.childOrigin;
this.events = {};
{
log("Parent: Registering API");
log("Parent: Awaiting messages...");
}
this.listener = function(e) {
if (!sanitize(e, _this.childOrigin))
return false;
var _ref = ((e || {}).data || {}).value || {}, data = _ref.data, name = _ref.name;
if (e.data.postmate === "emit") {
{
log("Parent: Received event emission: " + name);
}
if (name in _this.events) {
_this.events[name].forEach(function(callback) {
callback.call(_this, data);
});
}
}
};
this.parent.addEventListener("message", this.listener, false);
{
log("Parent: Awaiting event emissions from Child");
}
}
var _proto = ParentAPI2.prototype;
_proto.get = function get(property) {
var _this2 = this;
return new Postmate.Promise(function(resolve) {
var uid = generateNewMessageId();
var transact = function transact2(e) {
if (e.data.uid === uid && e.data.postmate === "reply") {
_this2.parent.removeEventListener("message", transact2, false);
resolve(e.data.value);
}
};
_this2.parent.addEventListener("message", transact, false);
_this2.child.postMessage({
postmate: "request",
type: messageType,
property,
uid
}, _this2.childOrigin);
});
};
_proto.call = function call(property, data) {
this.child.postMessage({
postmate: "call",
type: messageType,
property,
data
}, this.childOrigin);
};
_proto.on = function on(eventName, callback) {
if (!this.events[eventName]) {
this.events[eventName] = [];
}
this.events[eventName].push(callback);
};
_proto.destroy = function destroy() {
{
log("Parent: Destroying Postmate instance");
}
window.removeEventListener("message", this.listener, false);
this.frame.parentNode.removeChild(this.frame);
};
return ParentAPI2;
}();
var ChildAPI = /* @__PURE__ */ function() {
function ChildAPI2(info) {
var _this3 = this;
this.model = info.model;
this.parent = info.parent;
this.parentOrigin = info.parentOrigin;
this.child = info.child;
{
log("Child: Registering API");
log("Child: Awaiting messages...");
}
this.child.addEventListener("message", function(e) {
if (!sanitize(e, _this3.parentOrigin))
return;
{
log("Child: Received request", e.data);
}
var _e$data = e.data, property = _e$data.property, uid = _e$data.uid, data = _e$data.data;
if (e.data.postmate === "call") {
if (property in _this3.model && typeof _this3.model[property] === "function") {
_this3.model[property](data);
}
return;
}
resolveValue(_this3.model, property).then(function(value) {
return e.source.postMessage({
property,
postmate: "reply",
type: messageType,
uid,
value
}, e.origin);
});
});
}
var _proto2 = ChildAPI2.prototype;
_proto2.emit = function emit(name, data) {
{
log('Child: Emitting Event "' + name + '"', data);
}
this.parent.postMessage({
postmate: "emit",
type: messageType,
value: {
name,
data
}
}, this.parentOrigin);
};
return ChildAPI2;
}();
var Postmate = /* @__PURE__ */ function() {
function Postmate2(_ref2) {
var _ref2$container = _ref2.container, container = _ref2$container === void 0 ? typeof container !== "undefined" ? container : document.body : _ref2$container, model = _ref2.model, url = _ref2.url, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? "" : _ref2$name, allow = _ref2.allow, _ref2$classListArray = _ref2.classListArray, classListArray = _ref2$classListArray === void 0 ? [] : _ref2$classListArray;
this.parent = window;
this.frame = document.createElement("iframe");
this.frame.name = name || "";
this.frame.classList.add.apply(this.frame.classList, classListArray);
if (allow) {
this.frame.allow = allow;
}
container.appendChild(this.frame);
this.child = this.frame.contentWindow || this.frame.contentDocument.parentWindow;
this.model = model || {};
return this.sendHandshake(url);
}
var _proto3 = Postmate2.prototype;
_proto3.sendHandshake = function sendHandshake(url) {
var _this4 = this;
var childOrigin = resolveOrigin(url);
var attempt = 0;
var responseInterval;
return new Postmate2.Promise(function(resolve, reject) {
var reply = function reply2(e) {
if (!sanitize(e, childOrigin))
return false;
if (e.data.postmate === "handshake-reply") {
clearInterval(responseInterval);
{
log("Parent: Received handshake reply from Child");
}
_this4.parent.removeEventListener("message", reply2, false);
_this4.childOrigin = e.origin;
{
log("Parent: Saving Child origin", _this4.childOrigin);
}
return resolve(new ParentAPI(_this4));
}
{
log("Parent: Invalid handshake reply");
}
return reject("Failed handshake");
};
_this4.parent.addEventListener("message", reply, false);
var doSend = function doSend2() {
attempt++;
{
log("Parent: Sending handshake attempt " + attempt, {
childOrigin
});
}
_this4.child.postMessage({
postmate: "handshake",
type: messageType,
model: _this4.model
}, childOrigin);
if (attempt === maxHandshakeRequests) {
clearInterval(responseInterval);
}
};
var loaded = function loaded2() {
doSend();
responseInterval = setInterval(doSend, 500);
};
if (_this4.frame.attachEvent) {
_this4.frame.attachEvent("onload", loaded);
} else {
_this4.frame.addEventListener("load", loaded);
}
{
log("Parent: Loading frame", {
url
});
}
_this4.frame.src = url;
});
};
return Postmate2;
}();
Postmate.debug = false;
Postmate.Promise = function() {
try {
return window ? window.Promise : Promise;
} catch (e) {
return null;
}
}();
Postmate.Model = /* @__PURE__ */ function() {
function Model(model) {
this.child = window;
this.model = model;
this.parent = this.child.parent;
return this.sendHandshakeReply();
}
var _proto4 = Model.prototype;
_proto4.sendHandshakeReply = function sendHandshakeReply() {
var _this5 = this;
return new Postmate.Promise(function(resolve, reject) {
var shake = function shake2(e) {
if (!e.data.postmate) {
return;
}
if (e.data.postmate === "handshake") {
{
log("Child: Received handshake from Parent");
}
_this5.child.removeEventListener("message", shake2, false);
{
log("Child: Sending handshake reply to Parent");
}
e.source.postMessage({
postmate: "handshake-reply",
type: messageType
}, e.origin);
_this5.parentOrigin = e.origin;
var defaults = e.data.model;
if (defaults) {
Object.keys(defaults).forEach(function(key) {
_this5.model[key] = defaults[key];
});
{
log("Child: Inherited and extended model from Parent");
}
}
{
log("Child: Saving Parent origin", _this5.parentOrigin);
}
return resolve(new ChildAPI(_this5));
}
return reject("Handshake Reply Failed");
};
_this5.child.addEventListener("message", shake, false);
});
};
return Model;
}();
var postmate_es_default = Postmate;
// src/types/components.ts
var ComponentKind = /* @__PURE__ */ ((ComponentKind2) => {
ComponentKind2["Verify"] = "verify";
ComponentKind2["Form"] = "form";
ComponentKind2["Render"] = "render";
ComponentKind2["VerifyButton"] = "verify-button";
return ComponentKind2;
})(ComponentKind || {});
var FormType = /* @__PURE__ */ ((FormType2) => {
FormType2["cardOnly"] = "cardOnly";
FormType2["cardAndName"] = "cardAndName";
FormType2["cardAndNameAndAddress"] = "cardAndNameAndAddress";
FormType2["cardAndZip"] = "cardAndZip";
return FormType2;
})(FormType || {});
// src/types/events.ts
var PublicEvent = /* @__PURE__ */ ((PublicEvent2) => {
PublicEvent2["closed"] = "closed";
PublicEvent2["canceled"] = "canceled";
PublicEvent2["completed"] = "completed";
PublicEvent2["clicked"] = "clicked";
return PublicEvent2;
})(PublicEvent || {});
var PrivateEvent = /* @__PURE__ */ ((PrivateEvent2) => {
PrivateEvent2["propsReceived"] = "propsReceived";
PrivateEvent2["started"] = "started";
PrivateEvent2["formSaved"] = "formSaved";
return PrivateEvent2;
})(PrivateEvent || {});
// src/utils/dom-utils.ts
var INLINE_CONTAINER_CLASS = "footprint-inline-container";
var BODY_LOCKED_CLASS = "footprint-body-locked";
var OVERLAY_CLASS = "footprint-overlay";
var OVERLAY_CONTAINER_ID_PREFIX = "footprint-overlay-container";
var INLINE_CONTAINER_ID_PREFIX = INLINE_CONTAINER_CLASS;
var OVERLAY_ID_PREFIX = OVERLAY_CLASS;
var LOADING_INDICATOR_ID_PREFIX = "footprint-loading-indicator";
var getDomElementId = (elementId, uniqueId) => `${elementId}-${uniqueId}`;
var removeDOMElements = (uniqueId) => __async(void 0, null, function* () {
removeLoader(uniqueId);
removeInlineContainer(uniqueId);
yield removeOverlayContainer(uniqueId);
});
var createOverlayContainer = (uniqueId) => {
const id = getDomElementId(OVERLAY_CONTAINER_ID_PREFIX, uniqueId);
const possibleContainer = document.getElementById(id);
if (possibleContainer) {
return possibleContainer;
}
const container = document.createElement("div");
container.setAttribute("id", id);
document.body.appendChild(container);
return container;
};
var removeOverlayContainer = (uniqueId) => __async(void 0, null, function* () {
const id = getDomElementId(OVERLAY_CONTAINER_ID_PREFIX, uniqueId);
const overlayContainer = document.getElementById(id);
if (!overlayContainer) {
return;
}
const drawerIframe = overlayContainer.querySelector(
"iframe.footprint-drawer"
);
if (drawerIframe) {
drawerIframe == null ? void 0 : drawerIframe.classList.add("footprint-drawer-closing");
yield new Promise((resolve) => {
setTimeout(resolve, 300);
});
}
const modalIframe = overlayContainer.querySelector("iframe.footprint-modal");
if (modalIframe) {
modalIframe == null ? void 0 : modalIframe.classList.add("footprint-modal-closing");
yield new Promise((resolve) => {
setTimeout(resolve, 100);
});
}
const overlayId = getDomElementId(OVERLAY_ID_PREFIX, uniqueId);
const overlay = document.getElementById(overlayId);
if (!overlay) {
return;
}
overlay.classList.add("footprint-overlay-fading");
yield new Promise((resolve) => {
setTimeout(resolve, 200);
});
overlayContainer.remove();
overlay.remove();
document.body.classList.remove(BODY_LOCKED_CLASS);
});
var createInlineContainer = (uniqueId, clientParentContainer) => {
const id = getDomElementId(INLINE_CONTAINER_ID_PREFIX, uniqueId);
const inlineContainer = document.createElement("div");
inlineContainer.classList.add(INLINE_CONTAINER_CLASS);
inlineContainer.setAttribute("id", id);
clientParentContainer.appendChild(inlineContainer);
return inlineContainer;
};
var removeInlineContainer = (uniqueId) => {
const id = getDomElementId(INLINE_CONTAINER_ID_PREFIX, uniqueId);
const inlineContainer = document.getElementById(id);
if (inlineContainer) {
inlineContainer.remove();
}
};
var removeLoader = (uniqueId) => {
const id = getDomElementId(LOADING_INDICATOR_ID_PREFIX, uniqueId);
const loader = document.getElementById(id);
if (loader) {
loader.remove();
}
};
var createLoader = (container, uniqueId) => {
const id = getDomElementId(LOADING_INDICATOR_ID_PREFIX, uniqueId);
const loadingIndicator = createLoadingIndicator(id);
container.appendChild(loadingIndicator);
};
var createOverlay = (container, uniqueId) => {
document.body.classList.add(BODY_LOCKED_CLASS);
const overlay = document.createElement("div");
const id = getDomElementId(OVERLAY_ID_PREFIX, uniqueId);
overlay.setAttribute("id", id);
overlay.classList.add(OVERLAY_CLASS);
container.appendChild(overlay);
return overlay;
};
var createLoadingIndicator = (id) => {
const container = document.createElement("div");
container.setAttribute("id", id);
container.classList.add("footprint-loading-indicator");
const inner = document.createElement("div");
inner.classList.add("footprint-loading-spin");
const loader = document.createElementNS("http://www.w3.org/2000/svg", "svg");
loader.setAttribute("width", "24px");
loader.setAttribute("height", "24px");
loader.setAttribute("fill", "none");
loader.setAttribute("aria-hidden", "true");
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", "M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z");
loader.appendChild(path);
inner.appendChild(loader);
container.appendChild(inner);
return container;
};
// src/utils/get-unique-id.ts
var getUniqueId = () => {
const randomSeed = Math.floor(Math.random() * 1e3);
return `${randomSeed}`;
};
var get_unique_id_default = getUniqueId;
// src/constants/callbacks.ts
var ComponentCallbacksByEvent = {
["form" /* Form */]: {
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["verify" /* Verify */]: {
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["verify-button" /* VerifyButton */]: {
["clicked" /* clicked */]: "onClick",
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["render" /* Render */]: {}
};
var RequiredCallbacksByComponent = {
["form" /* Form */]: [],
["verify" /* Verify */]: [],
["render" /* Render */]: [],
["verify-button" /* VerifyButton */]: []
};
// src/constants/refs.ts
var RefsByComponent = {
["form" /* Form */]: ["getRef"],
["verify" /* Verify */]: [],
["verify-button" /* VerifyButton */]: [],
["render" /* Render */]: []
};
var refs_default = RefsByComponent;
// src/utils/prop-utils.ts
var VariantsByKind = {
["verify" /* Verify */]: ["modal", "drawer"],
["verify-button" /* VerifyButton */]: ["inline"],
["form" /* Form */]: ["inline", "modal", "drawer"],
["render" /* Render */]: ["inline"]
};
var checkIsVariantValid = (kind, variant) => {
var _a;
if (!variant) {
return;
}
const supportedVariants = (_a = VariantsByKind[kind]) != null ? _a : [];
const isValid = supportedVariants.includes(variant);
if (!isValid) {
throw new Error(
`Invalid variant: ${JSON.stringify(
variant
)}. Valid variants for ${kind} are ${supportedVariants.join(", ")}`
);
}
};
var getDefaultVariantForKind = (kind) => {
var _a;
const supportedVariants = (_a = VariantsByKind[kind]) != null ? _a : [];
if (!supportedVariants.length) {
throw new Error(`Invalid kind: ${kind}`);
}
return supportedVariants[0];
};
var checkIsKindValid = (kind) => {
if (!kind) {
throw new Error("Kind is required");
}
const isValid = Object.values(ComponentKind).includes(kind);
if (!isValid) {
throw new Error(
`Invalid kind: ${kind}. Valid kinds are: ${Object.values(
ComponentKind
).join(", ")}}`
);
}
};
var checkIsContainerIdValid = (variant, containerId) => {
if (variant === "inline" && !containerId) {
throw new Error(
`Inline component requires a containerId. Received ${containerId}`
);
}
};
var getSecondaryProps = (props) => {
const { kind } = props;
if (kind === "verify-button" /* VerifyButton */) {
const _a = props, {
kind: buttonKind,
appearance,
variant,
dialogVariant,
onClick,
label,
containerId
} = _a, restProps = __objRest(_a, [
"kind",
"appearance",
"variant",
"dialogVariant",
"onClick",
"label",
"containerId"
]);
return __spreadProps(__spreadValues({}, restProps), {
variant: dialogVariant,
kind: "verify" /* Verify */
});
}
return void 0;
};
var getRefProps = (props) => {
var _a;
const { kind } = props;
const refs = (_a = refs_default[kind]) != null ? _a : [];
return refs;
};
var getCallbackProps = (props, onDestroy, onLaunchChild) => {
var _a;
const { kind } = props;
const callbacks = (_a = ComponentCallbacksByEvent[kind]) != null ? _a : {};
const modifiedCallbacks = {};
Object.entries(callbacks).forEach(([event, callbackPropName]) => {
const publicEvent = event;
if (!Object.values(PublicEvent).includes(publicEvent)) {
return;
}
let callback = props[callbackPropName];
if (!callback || typeof callback !== "function") {
callback = () => {
};
}
const shouldDestroy = publicEvent === "closed" /* closed */ || publicEvent === "canceled" /* canceled */;
const shouldLaunchChild = kind === "verify-button" /* VerifyButton */ && publicEvent === "clicked" /* clicked */;
modifiedCallbacks[publicEvent] = (args) => {
callback(args);
if (shouldDestroy) {
onDestroy == null ? void 0 : onDestroy();
}
const secondaryProps = getSecondaryProps(props);
if (shouldLaunchChild && secondaryProps) {
onLaunchChild == null ? void 0 : onLaunchChild(secondaryProps);
}
};
});
return modifiedCallbacks;
};
var getDataProps = (props) => {
var _b;
const _a = props, { kind, appearance, containerId } = _a, customProps = __objRest(_a, ["kind", "appearance", "containerId"]);
const callbacks = (_b = ComponentCallbacksByEvent[kind]) != null ? _b : {};
const callbackPropNames = Object.values(callbacks);
const refs = getRefProps(props);
const refPropNames = Object.values(refs);
const dataProps = Object.fromEntries(
Object.entries(customProps).filter(
([key]) => !callbackPropNames.includes(key) && !refPropNames.includes(key)
)
);
return dataProps;
};
var getSanitizedProps = (props) => {
const { kind, variant: rawVariant, containerId } = props;
checkIsKindValid(kind);
checkIsVariantValid(kind, rawVariant);
const variant = rawVariant || getDefaultVariantForKind(kind);
checkIsContainerIdValid(variant, containerId);
return __spreadProps(__spreadValues({}, props), {
variant
});
};
// src/utils/appearance-utils.ts
var isObject = (obj) => typeof obj === "object" && !!obj;
var getEncodedAppearance = ({
fontSrc,
variables = {},
rules = {},
variant
} = {}) => {
const getVariables = () => Object.keys(variables).length ? encodeURIComponent(JSON.stringify(variables)) : void 0;
const getRules = () => Object.keys(rules).length ? encodeURIComponent(JSON.stringify(rules)) : void 0;
return {
fontSrc,
variables: getVariables(),
rules: getRules(),
variant
};
};
var getAppearanceForVanilla = () => {
const appearance = window.footprintAppearance;
if (!appearance || !isObject(appearance)) {
return {};
}
return {
fontSrc: appearance.fontSrc,
rules: appearance.rules,
theme: appearance.theme,
variables: appearance.variables
};
};
// src/utils/util-utils.ts
var getURL = (props) => {
const { kind } = props;
if (kind === "verify" /* Verify */) {
return getBifrostURL(props);
}
return getComponentsURL(props);
};
var getBifrostURL = (props) => {
const { appearance, publicKey, variant, kind } = props;
const { fontSrc, rules, variables } = getEncodedAppearance(appearance);
const url = "http://localhost:3000";
const searchParams = new URLSearchParams();
if (publicKey) {
searchParams.append("public_key", publicKey);
}
if (variables) {
searchParams.append("variables", variables);
}
if (rules) {
searchParams.append("rules", rules);
}
if (fontSrc) {
searchParams.append("font_src", fontSrc);
}
searchParams.append("variant", variant != null ? variant : getDefaultVariantForKind(kind));
const searchParamsStr = searchParams.toString();
return `${url}?${searchParamsStr}`;
};
var getComponentsURL = (props) => {
const { appearance, kind, variant } = props;
const { fontSrc, rules, variables } = getEncodedAppearance(appearance);
const url = "http://localhost:3010";
const searchParams = new URLSearchParams();
if (variables) {
searchParams.append("variables", variables);
}
if (rules) {
searchParams.append("rules", rules);
}
if (fontSrc) {
searchParams.append("font_src", fontSrc);
}
searchParams.append("variant", variant != null ? variant : getDefaultVariantForKind(kind));
const searchParamsStr = searchParams.toString();
return `${url}/${kind}?${searchParamsStr}`;
};
var util_utils_default = getURL;
// src/utils/iframe-utils/iframe.ts
var initIframe = (rawProps) => {
let child = null;
let isRendered = false;
const props = getSanitizedProps(rawProps);
const { variant, containerId } = props;
const hasOverlay = variant === "modal" || variant === "drawer";
let onDestroy;
let onRenderSecondary;
const id = get_unique_id_default();
const registerCallbackProps = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to listen events"
);
}
const callbackProps = getCallbackProps(props, onDestroy, onRenderSecondary);
Object.entries(callbackProps).forEach(([event, callback]) => {
child == null ? void 0 : child.on(event, callback);
});
};
const setUpRefs = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to set up refs"
);
}
const { kind } = props;
if (kind !== "form" /* Form */) {
return;
}
const { getRef } = props;
if (!getRef) {
return;
}
const formRef = {
save: () => {
if (!child) {
throw new Error(
"Footprint should be initialized to call ref methods"
);
}
child == null ? void 0 : child.call("formSaved" /* formSaved */);
}
};
getRef(formRef);
};
const sendDataProps = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to receive props"
);
}
const dataProps = getDataProps(props);
child.call("propsReceived" /* propsReceived */, dataProps);
};
const getOrCreateContainer = () => {
if (hasOverlay) {
return createOverlayContainer(id);
}
if (!containerId) {
throw new Error("containerId is required when rendering inline");
}
const clientParent = document.getElementById(containerId);
if (!clientParent) {
throw new Error(
`Could not find container with id ${containerId} while rendering footprint`
);
}
return createInlineContainer(id, clientParent);
};
const setLoading = (container, isLoading) => {
if (!isLoading) {
removeLoader(id);
child == null ? void 0 : child.frame.classList.remove(`footprint-${variant}-loading`);
child == null ? void 0 : child.frame.classList.add(`footprint-${variant}-loaded`);
return;
}
if (hasOverlay) {
const overlay = createOverlay(container, id);
createLoader(overlay, id);
} else {
createLoader(container, id);
}
};
const render = () => __async(void 0, null, function* () {
if (isRendered) {
return;
}
const container = getOrCreateContainer();
if (!container) {
return;
}
if (container.hasChildNodes()) {
container.innerHTML = "";
}
const url = util_utils_default(props);
isRendered = true;
setLoading(container, true);
child = yield new postmate_es_default({
classListArray: [`footprint-${variant}`, `footprint-${variant}-loading`],
container,
name: `footprint-iframe-${id}`,
url,
allow: "otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"
});
setLoading(container, false);
registerCallbackProps();
child.on("started" /* started */, () => {
sendDataProps();
setUpRefs();
});
});
const destroy = () => __async(void 0, null, function* () {
if (!isRendered) {
return;
}
isRendered = false;
yield removeDOMElements(id);
if (child) {
child.destroy();
child = null;
}
});
const registerEvent = (event, callback) => {
if (event === "renderSecondary") {
onRenderSecondary = callback;
}
if (event === "destroy") {
onDestroy = callback;
}
};
return {
props,
isRendered,
render,
destroy,
registerEvent
};
};
var iframe_default = initIframe;
// src/utils/iframe-utils/iframe-manager.ts
var getIframeKey = (props) => {
const sanitizedProps = getSanitizedProps(props);
return JSON.stringify(sanitizedProps);
};
var initIframeManager = () => {
const iframes = {};
const getOrCreate = (iframe) => {
const key = getIframeKey(iframe.props);
const existingEntry = Object.values(iframes).find(
(iframeEntry) => getIframeKey(iframeEntry.iframe.props) === key
);
if (existingEntry) {
return existingEntry.iframe;
}
iframes[key] = {
iframe,
secondaryIframes: {}
};
return iframe;
};
const getOrCreateSecondary = (primary, secondary) => {
const primaryKey = getIframeKey(primary.props);
const secondaryKey = getIframeKey(secondary.props);
if (!iframes[primaryKey]) {
throw new Error(
"iframe manager: primary iframe does not exist while adding secondary"
);
}
const { secondaryIframes } = iframes[primaryKey];
const existingEntry = Object.values(secondaryIframes).find(
(iframeEntry) => getIframeKey(iframeEntry.props) === secondaryKey
);
if (existingEntry) {
return existingEntry;
}
secondaryIframes[secondaryKey] = secondary;
return secondary;
};
const remove = (iframe) => {
const key = getIframeKey(iframe.props);
const iframeEntry = iframes[key];
if (!iframeEntry) {
return;
}
Object.keys(iframeEntry.secondaryIframes).forEach((secondaryKey) => {
const secondary = iframeEntry.secondaryIframes[secondaryKey];
secondary.destroy();
});
delete iframes[key];
};
const removeSecondary = (primary, secondary) => {
const primaryKey = getIframeKey(primary.props);
const secondaryKey = getIframeKey(secondary.props);
if (!iframes[primaryKey]) {
throw new Error(
"iframe manager: primary iframe does not exist while removing secondary"
);
}
const { secondaryIframes } = iframes[primaryKey];
const entry = secondaryIframes[secondaryKey];
if (entry) {
entry.destroy();
delete secondaryIframes[secondaryKey];
}
};
return {
getOrCreate,
remove,
getOrCreateSecondary,
removeSecondary
};
};
var iframe_manager_default = initIframeManager;
// src/footprint.ts
var getFootprint = () => {
const manager = iframe_manager_default();
const init = (props) => {
let iframe = iframe_default(props);
const destroy = () => __async(void 0, null, function* () {
manager.remove(iframe);
yield iframe.destroy();
});
const destroySecondary = (secondary) => __async(void 0, null, function* () {
manager.removeSecondary(iframe, secondary);
yield secondary.destroy();
});
const renderSecondary = (secondaryProps) => __async(void 0, null, function* () {
let secondaryIframe = iframe_default(secondaryProps);
secondaryIframe = manager.getOrCreateSecondary(iframe, secondaryIframe);
secondaryIframe.registerEvent("destroy", () => {
destroySecondary(secondaryIframe);
});
secondaryIframe.render();
});
const render = () => __async(void 0, null, function* () {
iframe = manager.getOrCreate(iframe);
iframe.registerEvent("destroy", destroy);
iframe.registerEvent("renderSecondary", renderSecondary);
yield iframe.render();
});
return {
render,
destroy
};
};
return {
init
};
};
var footprint = getFootprint();
var footprint_default = footprint;
// src/vanilla-integration.ts
var defer = (callback) => {
window.setTimeout(callback, 0);
};
var isObject2 = (obj) => typeof obj === "object" && !!obj;
var vanillaIntegration = (footprint2) => {
if (typeof window === "undefined")
return;
const getCallbacks = (kind) => {
var _a;
const callbacks = (_a = window.footprintCallbacks) != null ? _a : {};
if (!isObject2(callbacks)) {
throw Error(
"`window.footprintCallbacks` must be a valid mapping from callback names to functions."
);
}
const requiredCallbacks = RequiredCallbacksByComponent[kind];
requiredCallbacks.forEach((callbackName) => {
if (!callbacks[callbackName]) {
throw Error(
`Callback '${callbackName}' must be defined in window.footprintCallbacks`
);
}
});
return callbacks;
};
const renderComponent = (container) => {
var _a;
const kind = container.getAttribute("data-kind");
checkIsKindValid(kind);
const variant = (_a = container.getAttribute("data-variant")) != null ? _a : getDefaultVariantForKind(kind);
checkIsVariantValid(kind, variant);
const appearance = getAppearanceForVanilla();
const callbacks = getCallbacks(kind);
const propsAttribute = container.getAttribute("data-props") || "";
let props;
try {
props = JSON.parse(propsAttribute);
} catch (_) {
throw Error(`Could not parse \`data-props\` for footprint.`);
}
if (!isObject2(props)) {
throw Error(
"`data-props` on the footprint element has to be a valid JSON object stringified."
);
}
const containerId = get_unique_id_default();
container.setAttribute("id", containerId);
const component = footprint2.init(__spreadValues(__spreadValues({
kind,
variant,
appearance,
containerId: container.id
}, callbacks), props));
component.render();
};
const handlePageLoaded = () => {
const containers = document.querySelectorAll("[data-footprint]");
if (!containers.length) {
return;
}
containers.forEach((container) => {
renderComponent(container);
});
};
document.addEventListener("DOMContentLoaded", () => defer(handlePageLoaded));
};
var vanilla_integration_default = vanillaIntegration;
// src/utils/identify-user/identify-user.ts
var identifyUserRequest = (payload) => __async(void 0, null, function* () {
const response = yield fetch(`${"https://api.dev.onefootprint.com"}/hosted/identify`, {
method: "POST",
body: JSON.stringify(payload)
});
if (!response.ok) {
throw Error(response.statusText);
}
const data = yield response.json();
return data.user_found;
});
var identifyUser = (userData) => __async(void 0, null, function* () {
if (!userData) {
throw new Error("User data must be passed in order to identify an user");
}
const email = userData["id.email"];
const phoneNumber = userData["id.phone_number"];
if (email) {
const result = yield identifyUserRequest({ identifier: { email } });
if (result)
return true;
}
if (phoneNumber) {
const result = yield identifyUserRequest({
identifier: { phone_number: phoneNumber }
});
return result;
}
return false;
});
var identify_user_default = identifyUser;
// src/index.ts
var src_default = footprint_default;
vanilla_integration_default(footprint_default);
/*! Bundled license information:
@onefootprint/postmate/build/postmate.es.js:

@@ -1144,2 +13,2 @@ (**

export { ComponentKind as FootprintComponentKind, FormType as FootprintFormType, PrivateEvent as FootprintPrivateEvent, PublicEvent as FootprintPublicEvent, src_default as default, identify_user_default as identifyFootprintUser };
export { b as FootprintComponentKind, H as FootprintFormType, z as FootprintPrivateEvent, R as FootprintPublicEvent, Ht as default, ye as identifyFootprintUser };
(function (exports) {
'use strict';
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var ve=Object.defineProperty,ge=Object.defineProperties;var he=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&$(e,r,t[r]);if(V)for(var r of V(t))j.call(t,r)&&$(e,r,t[r]);return e},F=(e,t)=>ge(e,he(t));var x=(e,t)=>{var r={};for(var n in e)U.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&V)for(var n of V(e))t.indexOf(n)<0&&j.call(e,n)&&(r[n]=e[n]);return r};var m=(e,t,r)=>new Promise((n,o)=>{var a=i=>{try{c(r.next(i));}catch(s){o(s);}},d=i=>{try{c(r.throw(i));}catch(s){o(s);}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(a,d);c((r=r.apply(e,t)).next());});var E="application/x-postmate-v1+json",Pe=5,Ee=0,Ce=function(){return ++Ee};var we=function(t){var r=document.createElement("a");r.href=t;var n=r.protocol.length>4?r.protocol:window.location.protocol,o=r.host.length?r.port==="80"||r.port==="443"?r.hostname:r.host:window.location.host;return r.origin||n+"//"+o},Ie={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},L=function(t,r){return !(typeof r=="string"&&t.origin!==r||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!Ie[t.data.postmate])},be=function(t,r){var n=typeof t[r]=="function"?t[r]():t[r];return C.Promise.resolve(n)},Oe=function(){function e(r){var n=this;this.parent=r.parent,this.frame=r.frame,this.child=r.child,this.childOrigin=r.childOrigin,this.events={},this.listener=function(o){if(!L(o,n.childOrigin))return !1;var a=((o||{}).data||{}).value||{},d=a.data,c=a.name;o.data.postmate==="emit"&&c in n.events&&n.events[c].forEach(function(i){i.call(n,d);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var o=this;return new C.Promise(function(a){var d=Ce(),c=function i(s){s.data.uid===d&&s.data.postmate==="reply"&&(o.parent.removeEventListener("message",i,!1),a(s.data.value));};o.parent.addEventListener("message",c,!1),o.child.postMessage({postmate:"request",type:E,property:n,uid:d},o.childOrigin);})},t.call=function(n,o){this.child.postMessage({postmate:"call",type:E,property:n,data:o},this.childOrigin);},t.on=function(n,o){this.events[n]||(this.events[n]=[]),this.events[n].push(o);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),Ve=function(){function e(r){var n=this;this.model=r.model,this.parent=r.parent,this.parentOrigin=r.parentOrigin,this.child=r.child,this.child.addEventListener("message",function(o){if(L(o,n.parentOrigin)){var a=o.data,d=a.property,c=a.uid,i=a.data;if(o.data.postmate==="call"){d in n.model&&typeof n.model[d]=="function"&&n.model[d](i);return}be(n.model,d).then(function(s){return o.source.postMessage({property:d,postmate:"reply",type:E,uid:c,value:s},o.origin)});}});}var t=e.prototype;return t.emit=function(n,o){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:o}},this.parentOrigin);},e}(),C=function(){function e(r){var n=r.container,o=n===void 0?typeof o!="undefined"?o:document.body:n,a=r.model,d=r.url,c=r.name,i=c===void 0?"":c,s=r.allow,p=r.classListArray,f=p===void 0?[]:p;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=i||"",this.frame.classList.add.apply(this.frame.classList,f),s&&(this.frame.allow=s),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(d)}var t=e.prototype;return t.sendHandshake=function(n){var o=this,a=we(n),d=0,c;return new e.Promise(function(i,s){var p=function v(g){return L(g,a)?g.data.postmate==="handshake-reply"?(clearInterval(c),o.parent.removeEventListener("message",v,!1),o.childOrigin=g.origin,i(new Oe(o))):s("Failed handshake"):!1};o.parent.addEventListener("message",p,!1);var f=function(){d++,o.child.postMessage({postmate:"handshake",type:E,model:o.model},a),d===Pe&&clearInterval(c);},y=function(){f(),c=setInterval(f,500);};o.frame.attachEvent?o.frame.attachEvent("onload",y):o.frame.addEventListener("load",y),o.frame.src=n;})},e}();C.debug=!1;C.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();C.Model=function(){function e(r){return this.child=window,this.model=r,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new C.Promise(function(o,a){var d=function c(i){if(i.data.postmate){if(i.data.postmate==="handshake"){n.child.removeEventListener("message",c,!1),i.source.postMessage({postmate:"handshake-reply",type:E},i.origin),n.parentOrigin=i.origin;var s=i.data.model;return s&&Object.keys(s).forEach(function(p){n.model[p]=s[p];}),o(new Ve(n))}return a("Handshake Reply Failed")}};n.child.addEventListener("message",d,!1);})},e}();var q=C;var b=(o=>(o.Verify="verify",o.Form="form",o.Render="render",o.VerifyButton="verify-button",o))(b||{}),H=(o=>(o.cardOnly="cardOnly",o.cardAndName="cardAndName",o.cardAndNameAndAddress="cardAndNameAndAddress",o.cardAndZip="cardAndZip",o))(H||{});var R=(o=>(o.closed="closed",o.canceled="canceled",o.completed="completed",o.clicked="clicked",o))(R||{}),z=(n=>(n.propsReceived="propsReceived",n.started="started",n.formSaved="formSaved",n))(z||{});var J="footprint-inline-container",X="footprint-body-locked",Y="footprint-overlay",Z="footprint-overlay-container",W=J,G=Y,Q="footprint-loading-indicator",h=(e,t)=>`${e}-${t}`,ee=e=>m(void 0,null,function*(){N(e),ke(e),yield Re(e);}),te=e=>{let t=h(Z,e),r=document.getElementById(t);if(r)return r;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Re=e=>m(void 0,null,function*(){let t=h(Z,e),r=document.getElementById(t);if(!r)return;let n=r.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(c=>{setTimeout(c,300);}));let o=r.querySelector("iframe.footprint-modal");o&&(o==null||o.classList.add("footprint-modal-closing"),yield new Promise(c=>{setTimeout(c,100);}));let a=h(G,e),d=document.getElementById(a);d&&(d.classList.add("footprint-overlay-fading"),yield new Promise(c=>{setTimeout(c,200);}),r.remove(),d.remove(),document.body.classList.remove(X));}),re=(e,t)=>{let r=h(W,e),n=document.createElement("div");return n.classList.add(J),n.setAttribute("id",r),t.appendChild(n),n},ke=e=>{let t=h(W,e),r=document.getElementById(t);r&&r.remove();},N=e=>{let t=h(Q,e),r=document.getElementById(t);r&&r.remove();},S=(e,t)=>{let r=h(Q,t),n=Ae(r);e.appendChild(n);},ne=(e,t)=>{document.body.classList.add(X);let r=document.createElement("div"),n=h(G,t);return r.setAttribute("id",n),r.classList.add(Y),e.appendChild(r),r},Ae=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let r=document.createElement("div");r.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 o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(o),r.appendChild(n),t.appendChild(r),t};var Fe=()=>`${Math.floor(Math.random()*1e3)}`,k=Fe;var _={["form"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify-button"]:{["clicked"]:"onClick",["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["render"]:{}},oe={["form"]:[],["verify"]:[],["render"]:[],["verify-button"]:[]};var xe={["form"]:["getRef"],["verify"]:[],["verify-button"]:[],["render"]:[]},ae=xe;var ie={["verify"]:["modal","drawer"],["verify-button"]:["inline"],["form"]:["inline","modal","drawer"],["render"]:["inline"]},D=(e,t)=>{var o;if(!t)return;let r=(o=ie[e])!=null?o:[];if(!r.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${r.join(", ")}`)},I=e=>{var r;let t=(r=ie[e])!=null?r:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},B=e=>{if(!e)throw new Error("Kind is required");if(!Object.values(b).includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${Object.values(b).join(", ")}}`)},Le=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},Ne=e=>{let{kind:t}=e;if(t==="verify-button"){let r=e,{kind:n,appearance:o,variant:a,dialogVariant:d,onClick:c,label:i,containerId:s}=r,p=x(r,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return F(w({},p),{variant:d,kind:"verify"})}},Se=e=>{var n;let{kind:t}=e;return (n=ae[t])!=null?n:[]},se=(e,t,r)=>{var d;let{kind:n}=e,o=(d=_[n])!=null?d:{},a={};return Object.entries(o).forEach(([c,i])=>{let s=c;if(!Object.values(R).includes(s))return;let p=e[i];(!p||typeof p!="function")&&(p=()=>{});let f=s==="closed"||s==="canceled",y=n==="verify-button"&&s==="clicked";a[s]=v=>{p(v),f&&(t==null||t());let g=Ne(e);y&&g&&(r==null||r(g));};}),a},de=e=>{var f;let p=e,{kind:t,appearance:r,containerId:n}=p,o=x(p,["kind","appearance","containerId"]),a=(f=_[t])!=null?f:{},d=Object.values(a),c=Se(e),i=Object.values(c);return Object.fromEntries(Object.entries(o).filter(([y])=>!d.includes(y)&&!i.includes(y)))},A=e=>{let{kind:t,variant:r,containerId:n}=e;B(t),D(t,r);let o=r||I(t);return Le(o,n),F(w({},e),{variant:o})};var _e=e=>typeof e=="object"&&!!e,K=({fontSrc:e,variables:t={},rules:r={},variant:n}={})=>{let o=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(r).length?encodeURIComponent(JSON.stringify(r)):void 0;return {fontSrc:e,variables:o(),rules:a(),variant:n}},ce=()=>{let e=window.footprintAppearance;return !e||!_e(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var De=e=>{let{kind:t}=e;return t==="verify"?Be(e):Ke(e)},Be=e=>{let{appearance:t,publicKey:r,variant:n,kind:o}=e,{fontSrc:a,rules:d,variables:c}=K(t),i="https://id.onefootprint.com",s=new URLSearchParams;r&&s.append("public_key",r),c&&s.append("variables",c),d&&s.append("rules",d),a&&s.append("font_src",a),s.append("variant",n!=null?n:I(o));let p=s.toString();return `${i}?${p}`},Ke=e=>{let{appearance:t,kind:r,variant:n}=e,{fontSrc:o,rules:a,variables:d}=K(t),c="https://components.onefootprint.com",i=new URLSearchParams;d&&i.append("variables",d),a&&i.append("rules",a),o&&i.append("font_src",o),i.append("variant",n!=null?n:I(r));let s=i.toString();return `${c}/${r}?${s}`},pe=De;var Me=e=>{let t=null,r=!1,n=A(e),{variant:o,containerId:a}=n,d=o==="modal"||o==="drawer",c,i,s=k(),p=()=>{if(!t)throw new Error("Footprint should be initialized in order to listen events");let l=se(n,c,i);Object.entries(l).forEach(([u,O])=>{t==null||t.on(u,O);});},f=()=>{if(!t)throw new Error("Footprint should be initialized in order to set up refs");let{kind:l}=n;if(l!=="form")return;let{getRef:u}=n;if(!u)return;u({save:()=>{if(!t)throw new Error("Footprint should be initialized to call ref methods");t==null||t.call("formSaved");}});},y=()=>{if(!t)throw new Error("Footprint should be initialized in order to receive props");let l=de(n);t.call("propsReceived",l);},v=()=>{if(d)return te(s);if(!a)throw new Error("containerId is required when rendering inline");let l=document.getElementById(a);if(!l)throw new Error(`Could not find container with id ${a} while rendering footprint`);return re(s,l)},g=(l,u)=>{if(!u){N(s),t==null||t.frame.classList.remove(`footprint-${o}-loading`),t==null||t.frame.classList.add(`footprint-${o}-loaded`);return}if(d){let O=ne(l,s);S(O,s);}else S(l,s);};return {props:n,isRendered:r,render:()=>m(void 0,null,function*(){if(r)return;let l=v();if(!l)return;l.hasChildNodes()&&(l.innerHTML="");let u=pe(n);r=!0,g(l,!0),t=yield new q({classListArray:[`footprint-${o}`,`footprint-${o}-loading`],container:l,name:`footprint-iframe-${s}`,url:u,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"}),g(l,!1),p(),t.on("started",()=>{y(),f();});}),destroy:()=>m(void 0,null,function*(){r&&(r=!1,yield ee(s),t&&(t.destroy(),t=null));}),registerEvent:(l,u)=>{l==="renderSecondary"&&(i=u),l==="destroy"&&(c=u);}}},M=Me;var P=e=>{let t=A(e);return JSON.stringify(t)},Te=()=>{let e={};return {getOrCreate:a=>{let d=P(a.props),c=Object.values(e).find(i=>P(i.iframe.props)===d);return c?c.iframe:(e[d]={iframe:a,secondaryIframes:{}},a)},remove:a=>{let d=P(a.props),c=e[d];c&&(Object.keys(c.secondaryIframes).forEach(i=>{c.secondaryIframes[i].destroy();}),delete e[d]);},getOrCreateSecondary:(a,d)=>{let c=P(a.props),i=P(d.props);if(!e[c])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[c],p=Object.values(s).find(f=>P(f.props)===i);return p||(s[i]=d,d)},removeSecondary:(a,d)=>{let c=P(a.props),i=P(d.props);if(!e[c])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[c],p=s[i];p&&(p.destroy(),delete s[i]);}}},le=Te;var $e=()=>{let e=le();return {init:r=>{let n=M(r),o=()=>m(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=i=>m(void 0,null,function*(){e.removeSecondary(n,i),yield i.destroy();}),d=i=>m(void 0,null,function*(){let s=M(i);s=e.getOrCreateSecondary(n,s),s.registerEvent("destroy",()=>{a(s);}),s.render();});return {render:()=>m(void 0,null,function*(){n=e.getOrCreate(n),n.registerEvent("destroy",o),n.registerEvent("renderSecondary",d),yield n.render();}),destroy:o}}}},Ue=$e(),T=Ue;var je=e=>{window.setTimeout(e,0);},fe=e=>typeof e=="object"&&!!e,qe=e=>{if(typeof window=="undefined")return;let t=o=>{var c;let a=(c=window.footprintCallbacks)!=null?c:{};if(!fe(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return oe[o].forEach(i=>{if(!a[i])throw Error(`Callback '${i}' must be defined in window.footprintCallbacks`)}),a},r=o=>{var v;let a=o.getAttribute("data-kind");B(a);let d=(v=o.getAttribute("data-variant"))!=null?v:I(a);D(a,d);let c=ce(),i=t(a),s=o.getAttribute("data-props")||"",p;try{p=JSON.parse(s);}catch(g){throw Error("Could not parse `data-props` for footprint.")}if(!fe(p))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let f=k();o.setAttribute("id",f),e.init(w(w({kind:a,variant:d,appearance:c,containerId:o.id},i),p)).render();},n=()=>{let o=document.querySelectorAll("[data-footprint]");o.length&&o.forEach(a=>{r(a);});};document.addEventListener("DOMContentLoaded",()=>je(n));},me=qe;var ue=e=>m(void 0,null,function*(){let t=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),He=e=>m(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],r=e["id.phone_number"];return t&&(yield ue({identifier:{email:t}}))?!0:r?yield ue({identifier:{phone_number:r}}):!1}),ye=He;var Ht=T;me(T);/*! Bundled license information:
// ../../node_modules/@onefootprint/postmate/build/postmate.es.js
var messageType = "application/x-postmate-v1+json";
var maxHandshakeRequests = 5;
var _messageId = 0;
var generateNewMessageId = function generateNewMessageId2() {
return ++_messageId;
};
var log = function log2() {
var _console;
return Postmate.debug ? (_console = console).log.apply(_console, arguments) : null;
};
var resolveOrigin = function resolveOrigin2(url) {
var a = document.createElement("a");
a.href = url;
var protocol = a.protocol.length > 4 ? a.protocol : window.location.protocol;
var host = a.host.length ? a.port === "80" || a.port === "443" ? a.hostname : a.host : window.location.host;
return a.origin || protocol + "//" + host;
};
var messageTypes = {
handshake: 1,
"handshake-reply": 1,
call: 1,
emit: 1,
reply: 1,
request: 1
/**
* Ensures that a message is safe to interpret
* @param {Object} message The postmate message being sent
* @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
* @return {Boolean}
*/
};
var sanitize = function sanitize2(message, allowedOrigin) {
if (typeof allowedOrigin === "string" && message.origin !== allowedOrigin)
return false;
if (!message.data)
return false;
if (typeof message.data === "object" && !("postmate" in message.data))
return false;
if (message.data.type !== messageType)
return false;
if (!messageTypes[message.data.postmate])
return false;
return true;
};
var resolveValue = function resolveValue2(model, property) {
var unwrappedContext = typeof model[property] === "function" ? model[property]() : model[property];
return Postmate.Promise.resolve(unwrappedContext);
};
var ParentAPI = /* @__PURE__ */ function() {
function ParentAPI2(info) {
var _this = this;
this.parent = info.parent;
this.frame = info.frame;
this.child = info.child;
this.childOrigin = info.childOrigin;
this.events = {};
{
log("Parent: Registering API");
log("Parent: Awaiting messages...");
}
this.listener = function(e) {
if (!sanitize(e, _this.childOrigin))
return false;
var _ref = ((e || {}).data || {}).value || {}, data = _ref.data, name = _ref.name;
if (e.data.postmate === "emit") {
{
log("Parent: Received event emission: " + name);
}
if (name in _this.events) {
_this.events[name].forEach(function(callback) {
callback.call(_this, data);
});
}
}
};
this.parent.addEventListener("message", this.listener, false);
{
log("Parent: Awaiting event emissions from Child");
}
}
var _proto = ParentAPI2.prototype;
_proto.get = function get(property) {
var _this2 = this;
return new Postmate.Promise(function(resolve) {
var uid = generateNewMessageId();
var transact = function transact2(e) {
if (e.data.uid === uid && e.data.postmate === "reply") {
_this2.parent.removeEventListener("message", transact2, false);
resolve(e.data.value);
}
};
_this2.parent.addEventListener("message", transact, false);
_this2.child.postMessage({
postmate: "request",
type: messageType,
property,
uid
}, _this2.childOrigin);
});
};
_proto.call = function call(property, data) {
this.child.postMessage({
postmate: "call",
type: messageType,
property,
data
}, this.childOrigin);
};
_proto.on = function on(eventName, callback) {
if (!this.events[eventName]) {
this.events[eventName] = [];
}
this.events[eventName].push(callback);
};
_proto.destroy = function destroy() {
{
log("Parent: Destroying Postmate instance");
}
window.removeEventListener("message", this.listener, false);
this.frame.parentNode.removeChild(this.frame);
};
return ParentAPI2;
}();
var ChildAPI = /* @__PURE__ */ function() {
function ChildAPI2(info) {
var _this3 = this;
this.model = info.model;
this.parent = info.parent;
this.parentOrigin = info.parentOrigin;
this.child = info.child;
{
log("Child: Registering API");
log("Child: Awaiting messages...");
}
this.child.addEventListener("message", function(e) {
if (!sanitize(e, _this3.parentOrigin))
return;
{
log("Child: Received request", e.data);
}
var _e$data = e.data, property = _e$data.property, uid = _e$data.uid, data = _e$data.data;
if (e.data.postmate === "call") {
if (property in _this3.model && typeof _this3.model[property] === "function") {
_this3.model[property](data);
}
return;
}
resolveValue(_this3.model, property).then(function(value) {
return e.source.postMessage({
property,
postmate: "reply",
type: messageType,
uid,
value
}, e.origin);
});
});
}
var _proto2 = ChildAPI2.prototype;
_proto2.emit = function emit(name, data) {
{
log('Child: Emitting Event "' + name + '"', data);
}
this.parent.postMessage({
postmate: "emit",
type: messageType,
value: {
name,
data
}
}, this.parentOrigin);
};
return ChildAPI2;
}();
var Postmate = /* @__PURE__ */ function() {
function Postmate2(_ref2) {
var _ref2$container = _ref2.container, container = _ref2$container === void 0 ? typeof container !== "undefined" ? container : document.body : _ref2$container, model = _ref2.model, url = _ref2.url, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? "" : _ref2$name, allow = _ref2.allow, _ref2$classListArray = _ref2.classListArray, classListArray = _ref2$classListArray === void 0 ? [] : _ref2$classListArray;
this.parent = window;
this.frame = document.createElement("iframe");
this.frame.name = name || "";
this.frame.classList.add.apply(this.frame.classList, classListArray);
if (allow) {
this.frame.allow = allow;
}
container.appendChild(this.frame);
this.child = this.frame.contentWindow || this.frame.contentDocument.parentWindow;
this.model = model || {};
return this.sendHandshake(url);
}
var _proto3 = Postmate2.prototype;
_proto3.sendHandshake = function sendHandshake(url) {
var _this4 = this;
var childOrigin = resolveOrigin(url);
var attempt = 0;
var responseInterval;
return new Postmate2.Promise(function(resolve, reject) {
var reply = function reply2(e) {
if (!sanitize(e, childOrigin))
return false;
if (e.data.postmate === "handshake-reply") {
clearInterval(responseInterval);
{
log("Parent: Received handshake reply from Child");
}
_this4.parent.removeEventListener("message", reply2, false);
_this4.childOrigin = e.origin;
{
log("Parent: Saving Child origin", _this4.childOrigin);
}
return resolve(new ParentAPI(_this4));
}
{
log("Parent: Invalid handshake reply");
}
return reject("Failed handshake");
};
_this4.parent.addEventListener("message", reply, false);
var doSend = function doSend2() {
attempt++;
{
log("Parent: Sending handshake attempt " + attempt, {
childOrigin
});
}
_this4.child.postMessage({
postmate: "handshake",
type: messageType,
model: _this4.model
}, childOrigin);
if (attempt === maxHandshakeRequests) {
clearInterval(responseInterval);
}
};
var loaded = function loaded2() {
doSend();
responseInterval = setInterval(doSend, 500);
};
if (_this4.frame.attachEvent) {
_this4.frame.attachEvent("onload", loaded);
} else {
_this4.frame.addEventListener("load", loaded);
}
{
log("Parent: Loading frame", {
url
});
}
_this4.frame.src = url;
});
};
return Postmate2;
}();
Postmate.debug = false;
Postmate.Promise = function() {
try {
return window ? window.Promise : Promise;
} catch (e) {
return null;
}
}();
Postmate.Model = /* @__PURE__ */ function() {
function Model(model) {
this.child = window;
this.model = model;
this.parent = this.child.parent;
return this.sendHandshakeReply();
}
var _proto4 = Model.prototype;
_proto4.sendHandshakeReply = function sendHandshakeReply() {
var _this5 = this;
return new Postmate.Promise(function(resolve, reject) {
var shake = function shake2(e) {
if (!e.data.postmate) {
return;
}
if (e.data.postmate === "handshake") {
{
log("Child: Received handshake from Parent");
}
_this5.child.removeEventListener("message", shake2, false);
{
log("Child: Sending handshake reply to Parent");
}
e.source.postMessage({
postmate: "handshake-reply",
type: messageType
}, e.origin);
_this5.parentOrigin = e.origin;
var defaults = e.data.model;
if (defaults) {
Object.keys(defaults).forEach(function(key) {
_this5.model[key] = defaults[key];
});
{
log("Child: Inherited and extended model from Parent");
}
}
{
log("Child: Saving Parent origin", _this5.parentOrigin);
}
return resolve(new ChildAPI(_this5));
}
return reject("Handshake Reply Failed");
};
_this5.child.addEventListener("message", shake, false);
});
};
return Model;
}();
var postmate_es_default = Postmate;
// src/types/components.ts
var ComponentKind = /* @__PURE__ */ ((ComponentKind2) => {
ComponentKind2["Verify"] = "verify";
ComponentKind2["Form"] = "form";
ComponentKind2["Render"] = "render";
ComponentKind2["VerifyButton"] = "verify-button";
return ComponentKind2;
})(ComponentKind || {});
var FormType = /* @__PURE__ */ ((FormType2) => {
FormType2["cardOnly"] = "cardOnly";
FormType2["cardAndName"] = "cardAndName";
FormType2["cardAndNameAndAddress"] = "cardAndNameAndAddress";
FormType2["cardAndZip"] = "cardAndZip";
return FormType2;
})(FormType || {});
// src/types/events.ts
var PublicEvent = /* @__PURE__ */ ((PublicEvent2) => {
PublicEvent2["closed"] = "closed";
PublicEvent2["canceled"] = "canceled";
PublicEvent2["completed"] = "completed";
PublicEvent2["clicked"] = "clicked";
return PublicEvent2;
})(PublicEvent || {});
var PrivateEvent = /* @__PURE__ */ ((PrivateEvent2) => {
PrivateEvent2["propsReceived"] = "propsReceived";
PrivateEvent2["started"] = "started";
PrivateEvent2["formSaved"] = "formSaved";
return PrivateEvent2;
})(PrivateEvent || {});
// src/utils/dom-utils.ts
var INLINE_CONTAINER_CLASS = "footprint-inline-container";
var BODY_LOCKED_CLASS = "footprint-body-locked";
var OVERLAY_CLASS = "footprint-overlay";
var OVERLAY_CONTAINER_ID_PREFIX = "footprint-overlay-container";
var INLINE_CONTAINER_ID_PREFIX = INLINE_CONTAINER_CLASS;
var OVERLAY_ID_PREFIX = OVERLAY_CLASS;
var LOADING_INDICATOR_ID_PREFIX = "footprint-loading-indicator";
var getDomElementId = (elementId, uniqueId) => `${elementId}-${uniqueId}`;
var removeDOMElements = (uniqueId) => __async(void 0, null, function* () {
removeLoader(uniqueId);
removeInlineContainer(uniqueId);
yield removeOverlayContainer(uniqueId);
});
var createOverlayContainer = (uniqueId) => {
const id = getDomElementId(OVERLAY_CONTAINER_ID_PREFIX, uniqueId);
const possibleContainer = document.getElementById(id);
if (possibleContainer) {
return possibleContainer;
}
const container = document.createElement("div");
container.setAttribute("id", id);
document.body.appendChild(container);
return container;
};
var removeOverlayContainer = (uniqueId) => __async(void 0, null, function* () {
const id = getDomElementId(OVERLAY_CONTAINER_ID_PREFIX, uniqueId);
const overlayContainer = document.getElementById(id);
if (!overlayContainer) {
return;
}
const drawerIframe = overlayContainer.querySelector(
"iframe.footprint-drawer"
);
if (drawerIframe) {
drawerIframe == null ? void 0 : drawerIframe.classList.add("footprint-drawer-closing");
yield new Promise((resolve) => {
setTimeout(resolve, 300);
});
}
const modalIframe = overlayContainer.querySelector("iframe.footprint-modal");
if (modalIframe) {
modalIframe == null ? void 0 : modalIframe.classList.add("footprint-modal-closing");
yield new Promise((resolve) => {
setTimeout(resolve, 100);
});
}
const overlayId = getDomElementId(OVERLAY_ID_PREFIX, uniqueId);
const overlay = document.getElementById(overlayId);
if (!overlay) {
return;
}
overlay.classList.add("footprint-overlay-fading");
yield new Promise((resolve) => {
setTimeout(resolve, 200);
});
overlayContainer.remove();
overlay.remove();
document.body.classList.remove(BODY_LOCKED_CLASS);
});
var createInlineContainer = (uniqueId, clientParentContainer) => {
const id = getDomElementId(INLINE_CONTAINER_ID_PREFIX, uniqueId);
const inlineContainer = document.createElement("div");
inlineContainer.classList.add(INLINE_CONTAINER_CLASS);
inlineContainer.setAttribute("id", id);
clientParentContainer.appendChild(inlineContainer);
return inlineContainer;
};
var removeInlineContainer = (uniqueId) => {
const id = getDomElementId(INLINE_CONTAINER_ID_PREFIX, uniqueId);
const inlineContainer = document.getElementById(id);
if (inlineContainer) {
inlineContainer.remove();
}
};
var removeLoader = (uniqueId) => {
const id = getDomElementId(LOADING_INDICATOR_ID_PREFIX, uniqueId);
const loader = document.getElementById(id);
if (loader) {
loader.remove();
}
};
var createLoader = (container, uniqueId) => {
const id = getDomElementId(LOADING_INDICATOR_ID_PREFIX, uniqueId);
const loadingIndicator = createLoadingIndicator(id);
container.appendChild(loadingIndicator);
};
var createOverlay = (container, uniqueId) => {
document.body.classList.add(BODY_LOCKED_CLASS);
const overlay = document.createElement("div");
const id = getDomElementId(OVERLAY_ID_PREFIX, uniqueId);
overlay.setAttribute("id", id);
overlay.classList.add(OVERLAY_CLASS);
container.appendChild(overlay);
return overlay;
};
var createLoadingIndicator = (id) => {
const container = document.createElement("div");
container.setAttribute("id", id);
container.classList.add("footprint-loading-indicator");
const inner = document.createElement("div");
inner.classList.add("footprint-loading-spin");
const loader = document.createElementNS("http://www.w3.org/2000/svg", "svg");
loader.setAttribute("width", "24px");
loader.setAttribute("height", "24px");
loader.setAttribute("fill", "none");
loader.setAttribute("aria-hidden", "true");
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", "M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z");
loader.appendChild(path);
inner.appendChild(loader);
container.appendChild(inner);
return container;
};
// src/utils/get-unique-id.ts
var getUniqueId = () => {
const randomSeed = Math.floor(Math.random() * 1e3);
return `${randomSeed}`;
};
var get_unique_id_default = getUniqueId;
// src/constants/callbacks.ts
var ComponentCallbacksByEvent = {
["form" /* Form */]: {
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["verify" /* Verify */]: {
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["verify-button" /* VerifyButton */]: {
["clicked" /* clicked */]: "onClick",
["closed" /* closed */]: "onClose",
["canceled" /* canceled */]: "onCancel",
["completed" /* completed */]: "onComplete"
},
["render" /* Render */]: {}
};
var RequiredCallbacksByComponent = {
["form" /* Form */]: [],
["verify" /* Verify */]: [],
["render" /* Render */]: [],
["verify-button" /* VerifyButton */]: []
};
// src/constants/refs.ts
var RefsByComponent = {
["form" /* Form */]: ["getRef"],
["verify" /* Verify */]: [],
["verify-button" /* VerifyButton */]: [],
["render" /* Render */]: []
};
var refs_default = RefsByComponent;
// src/utils/prop-utils.ts
var VariantsByKind = {
["verify" /* Verify */]: ["modal", "drawer"],
["verify-button" /* VerifyButton */]: ["inline"],
["form" /* Form */]: ["inline", "modal", "drawer"],
["render" /* Render */]: ["inline"]
};
var checkIsVariantValid = (kind, variant) => {
var _a;
if (!variant) {
return;
}
const supportedVariants = (_a = VariantsByKind[kind]) != null ? _a : [];
const isValid = supportedVariants.includes(variant);
if (!isValid) {
throw new Error(
`Invalid variant: ${JSON.stringify(
variant
)}. Valid variants for ${kind} are ${supportedVariants.join(", ")}`
);
}
};
var getDefaultVariantForKind = (kind) => {
var _a;
const supportedVariants = (_a = VariantsByKind[kind]) != null ? _a : [];
if (!supportedVariants.length) {
throw new Error(`Invalid kind: ${kind}`);
}
return supportedVariants[0];
};
var checkIsKindValid = (kind) => {
if (!kind) {
throw new Error("Kind is required");
}
const isValid = Object.values(ComponentKind).includes(kind);
if (!isValid) {
throw new Error(
`Invalid kind: ${kind}. Valid kinds are: ${Object.values(
ComponentKind
).join(", ")}}`
);
}
};
var checkIsContainerIdValid = (variant, containerId) => {
if (variant === "inline" && !containerId) {
throw new Error(
`Inline component requires a containerId. Received ${containerId}`
);
}
};
var getSecondaryProps = (props) => {
const { kind } = props;
if (kind === "verify-button" /* VerifyButton */) {
const _a = props, {
kind: buttonKind,
appearance,
variant,
dialogVariant,
onClick,
label,
containerId
} = _a, restProps = __objRest(_a, [
"kind",
"appearance",
"variant",
"dialogVariant",
"onClick",
"label",
"containerId"
]);
return __spreadProps(__spreadValues({}, restProps), {
variant: dialogVariant,
kind: "verify" /* Verify */
});
}
return void 0;
};
var getRefProps = (props) => {
var _a;
const { kind } = props;
const refs = (_a = refs_default[kind]) != null ? _a : [];
return refs;
};
var getCallbackProps = (props, onDestroy, onLaunchChild) => {
var _a;
const { kind } = props;
const callbacks = (_a = ComponentCallbacksByEvent[kind]) != null ? _a : {};
const modifiedCallbacks = {};
Object.entries(callbacks).forEach(([event, callbackPropName]) => {
const publicEvent = event;
if (!Object.values(PublicEvent).includes(publicEvent)) {
return;
}
let callback = props[callbackPropName];
if (!callback || typeof callback !== "function") {
callback = () => {
};
}
const shouldDestroy = publicEvent === "closed" /* closed */ || publicEvent === "canceled" /* canceled */;
const shouldLaunchChild = kind === "verify-button" /* VerifyButton */ && publicEvent === "clicked" /* clicked */;
modifiedCallbacks[publicEvent] = (args) => {
callback(args);
if (shouldDestroy) {
onDestroy == null ? void 0 : onDestroy();
}
const secondaryProps = getSecondaryProps(props);
if (shouldLaunchChild && secondaryProps) {
onLaunchChild == null ? void 0 : onLaunchChild(secondaryProps);
}
};
});
return modifiedCallbacks;
};
var getDataProps = (props) => {
var _b;
const _a = props, { kind, appearance, containerId } = _a, customProps = __objRest(_a, ["kind", "appearance", "containerId"]);
const callbacks = (_b = ComponentCallbacksByEvent[kind]) != null ? _b : {};
const callbackPropNames = Object.values(callbacks);
const refs = getRefProps(props);
const refPropNames = Object.values(refs);
const dataProps = Object.fromEntries(
Object.entries(customProps).filter(
([key]) => !callbackPropNames.includes(key) && !refPropNames.includes(key)
)
);
return dataProps;
};
var getSanitizedProps = (props) => {
const { kind, variant: rawVariant, containerId } = props;
checkIsKindValid(kind);
checkIsVariantValid(kind, rawVariant);
const variant = rawVariant || getDefaultVariantForKind(kind);
checkIsContainerIdValid(variant, containerId);
return __spreadProps(__spreadValues({}, props), {
variant
});
};
// src/utils/appearance-utils.ts
var isObject = (obj) => typeof obj === "object" && !!obj;
var getEncodedAppearance = ({
fontSrc,
variables = {},
rules = {},
variant
} = {}) => {
const getVariables = () => Object.keys(variables).length ? encodeURIComponent(JSON.stringify(variables)) : void 0;
const getRules = () => Object.keys(rules).length ? encodeURIComponent(JSON.stringify(rules)) : void 0;
return {
fontSrc,
variables: getVariables(),
rules: getRules(),
variant
};
};
var getAppearanceForVanilla = () => {
const appearance = window.footprintAppearance;
if (!appearance || !isObject(appearance)) {
return {};
}
return {
fontSrc: appearance.fontSrc,
rules: appearance.rules,
theme: appearance.theme,
variables: appearance.variables
};
};
// src/utils/util-utils.ts
var getURL = (props) => {
const { kind } = props;
if (kind === "verify" /* Verify */) {
return getBifrostURL(props);
}
return getComponentsURL(props);
};
var getBifrostURL = (props) => {
const { appearance, publicKey, variant, kind } = props;
const { fontSrc, rules, variables } = getEncodedAppearance(appearance);
const url = "http://localhost:3000";
const searchParams = new URLSearchParams();
if (publicKey) {
searchParams.append("public_key", publicKey);
}
if (variables) {
searchParams.append("variables", variables);
}
if (rules) {
searchParams.append("rules", rules);
}
if (fontSrc) {
searchParams.append("font_src", fontSrc);
}
searchParams.append("variant", variant != null ? variant : getDefaultVariantForKind(kind));
const searchParamsStr = searchParams.toString();
return `${url}?${searchParamsStr}`;
};
var getComponentsURL = (props) => {
const { appearance, kind, variant } = props;
const { fontSrc, rules, variables } = getEncodedAppearance(appearance);
const url = "http://localhost:3010";
const searchParams = new URLSearchParams();
if (variables) {
searchParams.append("variables", variables);
}
if (rules) {
searchParams.append("rules", rules);
}
if (fontSrc) {
searchParams.append("font_src", fontSrc);
}
searchParams.append("variant", variant != null ? variant : getDefaultVariantForKind(kind));
const searchParamsStr = searchParams.toString();
return `${url}/${kind}?${searchParamsStr}`;
};
var util_utils_default = getURL;
// src/utils/iframe-utils/iframe.ts
var initIframe = (rawProps) => {
let child = null;
let isRendered = false;
const props = getSanitizedProps(rawProps);
const { variant, containerId } = props;
const hasOverlay = variant === "modal" || variant === "drawer";
let onDestroy;
let onRenderSecondary;
const id = get_unique_id_default();
const registerCallbackProps = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to listen events"
);
}
const callbackProps = getCallbackProps(props, onDestroy, onRenderSecondary);
Object.entries(callbackProps).forEach(([event, callback]) => {
child == null ? void 0 : child.on(event, callback);
});
};
const setUpRefs = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to set up refs"
);
}
const { kind } = props;
if (kind !== "form" /* Form */) {
return;
}
const { getRef } = props;
if (!getRef) {
return;
}
const formRef = {
save: () => {
if (!child) {
throw new Error(
"Footprint should be initialized to call ref methods"
);
}
child == null ? void 0 : child.call("formSaved" /* formSaved */);
}
};
getRef(formRef);
};
const sendDataProps = () => {
if (!child) {
throw new Error(
"Footprint should be initialized in order to receive props"
);
}
const dataProps = getDataProps(props);
child.call("propsReceived" /* propsReceived */, dataProps);
};
const getOrCreateContainer = () => {
if (hasOverlay) {
return createOverlayContainer(id);
}
if (!containerId) {
throw new Error("containerId is required when rendering inline");
}
const clientParent = document.getElementById(containerId);
if (!clientParent) {
throw new Error(
`Could not find container with id ${containerId} while rendering footprint`
);
}
return createInlineContainer(id, clientParent);
};
const setLoading = (container, isLoading) => {
if (!isLoading) {
removeLoader(id);
child == null ? void 0 : child.frame.classList.remove(`footprint-${variant}-loading`);
child == null ? void 0 : child.frame.classList.add(`footprint-${variant}-loaded`);
return;
}
if (hasOverlay) {
const overlay = createOverlay(container, id);
createLoader(overlay, id);
} else {
createLoader(container, id);
}
};
const render = () => __async(void 0, null, function* () {
if (isRendered) {
return;
}
const container = getOrCreateContainer();
if (!container) {
return;
}
if (container.hasChildNodes()) {
container.innerHTML = "";
}
const url = util_utils_default(props);
isRendered = true;
setLoading(container, true);
child = yield new postmate_es_default({
classListArray: [`footprint-${variant}`, `footprint-${variant}-loading`],
container,
name: `footprint-iframe-${id}`,
url,
allow: "otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"
});
setLoading(container, false);
registerCallbackProps();
child.on("started" /* started */, () => {
sendDataProps();
setUpRefs();
});
});
const destroy = () => __async(void 0, null, function* () {
if (!isRendered) {
return;
}
isRendered = false;
yield removeDOMElements(id);
if (child) {
child.destroy();
child = null;
}
});
const registerEvent = (event, callback) => {
if (event === "renderSecondary") {
onRenderSecondary = callback;
}
if (event === "destroy") {
onDestroy = callback;
}
};
return {
props,
isRendered,
render,
destroy,
registerEvent
};
};
var iframe_default = initIframe;
// src/utils/iframe-utils/iframe-manager.ts
var getIframeKey = (props) => {
const sanitizedProps = getSanitizedProps(props);
return JSON.stringify(sanitizedProps);
};
var initIframeManager = () => {
const iframes = {};
const getOrCreate = (iframe) => {
const key = getIframeKey(iframe.props);
const existingEntry = Object.values(iframes).find(
(iframeEntry) => getIframeKey(iframeEntry.iframe.props) === key
);
if (existingEntry) {
return existingEntry.iframe;
}
iframes[key] = {
iframe,
secondaryIframes: {}
};
return iframe;
};
const getOrCreateSecondary = (primary, secondary) => {
const primaryKey = getIframeKey(primary.props);
const secondaryKey = getIframeKey(secondary.props);
if (!iframes[primaryKey]) {
throw new Error(
"iframe manager: primary iframe does not exist while adding secondary"
);
}
const { secondaryIframes } = iframes[primaryKey];
const existingEntry = Object.values(secondaryIframes).find(
(iframeEntry) => getIframeKey(iframeEntry.props) === secondaryKey
);
if (existingEntry) {
return existingEntry;
}
secondaryIframes[secondaryKey] = secondary;
return secondary;
};
const remove = (iframe) => {
const key = getIframeKey(iframe.props);
const iframeEntry = iframes[key];
if (!iframeEntry) {
return;
}
Object.keys(iframeEntry.secondaryIframes).forEach((secondaryKey) => {
const secondary = iframeEntry.secondaryIframes[secondaryKey];
secondary.destroy();
});
delete iframes[key];
};
const removeSecondary = (primary, secondary) => {
const primaryKey = getIframeKey(primary.props);
const secondaryKey = getIframeKey(secondary.props);
if (!iframes[primaryKey]) {
throw new Error(
"iframe manager: primary iframe does not exist while removing secondary"
);
}
const { secondaryIframes } = iframes[primaryKey];
const entry = secondaryIframes[secondaryKey];
if (entry) {
entry.destroy();
delete secondaryIframes[secondaryKey];
}
};
return {
getOrCreate,
remove,
getOrCreateSecondary,
removeSecondary
};
};
var iframe_manager_default = initIframeManager;
// src/footprint.ts
var getFootprint = () => {
const manager = iframe_manager_default();
const init = (props) => {
let iframe = iframe_default(props);
const destroy = () => __async(void 0, null, function* () {
manager.remove(iframe);
yield iframe.destroy();
});
const destroySecondary = (secondary) => __async(void 0, null, function* () {
manager.removeSecondary(iframe, secondary);
yield secondary.destroy();
});
const renderSecondary = (secondaryProps) => __async(void 0, null, function* () {
let secondaryIframe = iframe_default(secondaryProps);
secondaryIframe = manager.getOrCreateSecondary(iframe, secondaryIframe);
secondaryIframe.registerEvent("destroy", () => {
destroySecondary(secondaryIframe);
});
secondaryIframe.render();
});
const render = () => __async(void 0, null, function* () {
iframe = manager.getOrCreate(iframe);
iframe.registerEvent("destroy", destroy);
iframe.registerEvent("renderSecondary", renderSecondary);
yield iframe.render();
});
return {
render,
destroy
};
};
return {
init
};
};
var footprint = getFootprint();
var footprint_default = footprint;
// src/vanilla-integration.ts
var defer = (callback) => {
window.setTimeout(callback, 0);
};
var isObject2 = (obj) => typeof obj === "object" && !!obj;
var vanillaIntegration = (footprint2) => {
if (typeof window === "undefined")
return;
const getCallbacks = (kind) => {
var _a;
const callbacks = (_a = window.footprintCallbacks) != null ? _a : {};
if (!isObject2(callbacks)) {
throw Error(
"`window.footprintCallbacks` must be a valid mapping from callback names to functions."
);
}
const requiredCallbacks = RequiredCallbacksByComponent[kind];
requiredCallbacks.forEach((callbackName) => {
if (!callbacks[callbackName]) {
throw Error(
`Callback '${callbackName}' must be defined in window.footprintCallbacks`
);
}
});
return callbacks;
};
const renderComponent = (container) => {
var _a;
const kind = container.getAttribute("data-kind");
checkIsKindValid(kind);
const variant = (_a = container.getAttribute("data-variant")) != null ? _a : getDefaultVariantForKind(kind);
checkIsVariantValid(kind, variant);
const appearance = getAppearanceForVanilla();
const callbacks = getCallbacks(kind);
const propsAttribute = container.getAttribute("data-props") || "";
let props;
try {
props = JSON.parse(propsAttribute);
} catch (_) {
throw Error(`Could not parse \`data-props\` for footprint.`);
}
if (!isObject2(props)) {
throw Error(
"`data-props` on the footprint element has to be a valid JSON object stringified."
);
}
const containerId = get_unique_id_default();
container.setAttribute("id", containerId);
const component = footprint2.init(__spreadValues(__spreadValues({
kind,
variant,
appearance,
containerId: container.id
}, callbacks), props));
component.render();
};
const handlePageLoaded = () => {
const containers = document.querySelectorAll("[data-footprint]");
if (!containers.length) {
return;
}
containers.forEach((container) => {
renderComponent(container);
});
};
document.addEventListener("DOMContentLoaded", () => defer(handlePageLoaded));
};
var vanilla_integration_default = vanillaIntegration;
// src/utils/identify-user/identify-user.ts
var identifyUserRequest = (payload) => __async(void 0, null, function* () {
const response = yield fetch(`${"https://api.dev.onefootprint.com"}/hosted/identify`, {
method: "POST",
body: JSON.stringify(payload)
});
if (!response.ok) {
throw Error(response.statusText);
}
const data = yield response.json();
return data.user_found;
});
var identifyUser = (userData) => __async(void 0, null, function* () {
if (!userData) {
throw new Error("User data must be passed in order to identify an user");
}
const email = userData["id.email"];
const phoneNumber = userData["id.phone_number"];
if (email) {
const result = yield identifyUserRequest({ identifier: { email } });
if (result)
return true;
}
if (phoneNumber) {
const result = yield identifyUserRequest({
identifier: { phone_number: phoneNumber }
});
return result;
}
return false;
});
var identify_user_default = identifyUser;
// src/index.ts
var src_default = footprint_default;
vanilla_integration_default(footprint_default);
/*! Bundled license information:
@onefootprint/postmate/build/postmate.es.js:

@@ -1147,8 +16,8 @@ (**

exports.FootprintComponentKind = ComponentKind;
exports.FootprintFormType = FormType;
exports.FootprintPrivateEvent = PrivateEvent;
exports.FootprintPublicEvent = PublicEvent;
exports.default = src_default;
exports.identifyFootprintUser = identify_user_default;
exports.FootprintComponentKind = b;
exports.FootprintFormType = H;
exports.FootprintPrivateEvent = z;
exports.FootprintPublicEvent = R;
exports.default = Ht;
exports.identifyFootprintUser = ye;

@@ -1155,0 +24,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "3.2.0-beta.1",
"version": "3.2.0-beta.2",
"main": "./dist/footprint-js.cjs",

@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc