Socket
Socket
Sign inDemoInstall

@juno0424/hapi

Package Overview
Dependencies
6
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.6.2

2

dist/hapi.min.js
(()=>{var nt=Object.create;var N=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var ut=t=>N(t,"__esModule",{value:!0});var l=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var lt=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of st(e))!ot.call(t,i)&&i!=="default"&&N(t,i,{get:()=>e[i],enumerable:!(r=it(e,i))||r.enumerable});return t},ft=t=>lt(ut(N(t!=null?nt(at(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var B=l((sr,Y)=>{"use strict";Y.exports=function(e,r){return function(){for(var n=new Array(arguments.length),s=0;s<n.length;s++)n[s]=arguments[s];return e.apply(r,n)}}});var p=l((ar,ee)=>{"use strict";var ct=B(),E=Object.prototype.toString;function P(t){return E.call(t)==="[object Array]"}function F(t){return typeof t=="undefined"}function dt(t){return t!==null&&!F(t)&&t.constructor!==null&&!F(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function pt(t){return E.call(t)==="[object ArrayBuffer]"}function ht(t){return typeof FormData!="undefined"&&t instanceof FormData}function mt(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function vt(t){return typeof t=="string"}function yt(t){return typeof t=="number"}function Q(t){return t!==null&&typeof t=="object"}function C(t){if(E.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function wt(t){return E.call(t)==="[object Date]"}function Et(t){return E.call(t)==="[object File]"}function xt(t){return E.call(t)==="[object Blob]"}function Z(t){return E.call(t)==="[object Function]"}function bt(t){return Q(t)&&Z(t.pipe)}function qt(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Rt(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function Ct(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function D(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),P(t))for(var r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}function j(){var t={};function e(n,s){C(t[s])&&C(n)?t[s]=j(t[s],n):C(n)?t[s]=j({},n):P(n)?t[s]=n.slice():t[s]=n}for(var r=0,i=arguments.length;r<i;r++)D(arguments[r],e);return t}function Ut(t,e,r){return D(e,function(n,s){r&&typeof n=="function"?t[s]=ct(n,r):t[s]=n}),t}function St(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}ee.exports={isArray:P,isArrayBuffer:pt,isBuffer:dt,isFormData:ht,isArrayBufferView:mt,isString:vt,isNumber:yt,isObject:Q,isPlainObject:C,isUndefined:F,isDate:wt,isFile:Et,isBlob:xt,isFunction:Z,isStream:bt,isURLSearchParams:qt,isStandardBrowserEnv:Ct,forEach:D,merge:j,extend:Ut,trim:Rt,stripBOM:St}});var H=l((or,re)=>{"use strict";var x=p();function te(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}re.exports=function(e,r,i){if(!r)return e;var n;if(i)n=i(r);else if(x.isURLSearchParams(r))n=r.toString();else{var s=[];x.forEach(r,function(f,w){f===null||typeof f=="undefined"||(x.isArray(f)?w=w+"[]":f=[f],x.forEach(f,function(m){x.isDate(m)?m=m.toISOString():x.isObject(m)&&(m=JSON.stringify(m)),s.push(te(w)+"="+te(m))}))}),n=s.join("&")}if(n){var u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e}});var ie=l((ur,ne)=>{"use strict";var At=p();function U(){this.handlers=[]}U.prototype.use=function(e,r){return this.handlers.push({fulfilled:e,rejected:r}),this.handlers.length-1};U.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};U.prototype.forEach=function(e){At.forEach(this.handlers,function(i){i!==null&&e(i)})};ne.exports=U});var ae=l((lr,se)=>{"use strict";var gt=p();se.exports=function(e,r,i){return gt.forEach(i,function(s){e=s(e,r)}),e}});var M=l((fr,oe)=>{"use strict";oe.exports=function(e){return!!(e&&e.__CANCEL__)}});var le=l((cr,ue)=>{"use strict";var Ot=p();ue.exports=function(e,r){Ot.forEach(e,function(n,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=n,delete e[s])})}});var ce=l((dr,fe)=>{"use strict";fe.exports=function(e,r,i,n,s){return e.config=r,i&&(e.code=i),e.request=n,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}});var k=l((pr,de)=>{"use strict";var Lt=ce();de.exports=function(e,r,i,n,s){var u=new Error(e);return Lt(u,r,i,n,s)}});var he=l((hr,pe)=>{"use strict";var Tt=k();pe.exports=function(e,r,i){var n=i.config.validateStatus;!i.status||!n||n(i.status)?e(i):r(Tt("Request failed with status code "+i.status,i.config,null,i.request,i))}});var ve=l((mr,me)=>{"use strict";var S=p();me.exports=S.isStandardBrowserEnv()?function(){return{write:function(r,i,n,s,u,a){var f=[];f.push(r+"="+encodeURIComponent(i)),S.isNumber(n)&&f.push("expires="+new Date(n).toGMTString()),S.isString(s)&&f.push("path="+s),S.isString(u)&&f.push("domain="+u),a===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){var i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var we=l((vr,ye)=>{"use strict";ye.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var xe=l((yr,Ee)=>{"use strict";Ee.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var qe=l((wr,be)=>{"use strict";var Nt=we(),Bt=xe();be.exports=function(e,r){return e&&!Nt(r)?Bt(e,r):r}});var Ce=l((Er,Re)=>{"use strict";var I=p(),Pt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];Re.exports=function(e){var r={},i,n,s;return e&&I.forEach(e.split(`
`),function(a){if(s=a.indexOf(":"),i=I.trim(a.substr(0,s)).toLowerCase(),n=I.trim(a.substr(s+1)),i){if(r[i]&&Pt.indexOf(i)>=0)return;i==="set-cookie"?r[i]=(r[i]?r[i]:[]).concat([n]):r[i]=r[i]?r[i]+", "+n:n}}),r}});var Ae=l((xr,Se)=>{"use strict";var Ue=p();Se.exports=Ue.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),i;function n(s){var u=s;return e&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return i=n(window.location.href),function(u){var a=Ue.isString(u)?n(u):u;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}()});var $=l((br,ge)=>{"use strict";var A=p(),Ft=he(),Dt=ve(),jt=H(),Ht=qe(),Mt=Ce(),kt=Ae(),_=k();ge.exports=function(e){return new Promise(function(i,n){var s=e.data,u=e.headers;A.isFormData(s)&&delete u["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";u.Authorization="Basic "+btoa(f+":"+w)}var b=Ht(e.baseURL,e.url);if(a.open(e.method.toUpperCase(),jt(b,e.params,e.paramsSerializer),!0),a.timeout=e.timeout,a.onreadystatechange=function(){if(!(!a||a.readyState!==4)&&!(a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0))){var o="getAllResponseHeaders"in a?Mt(a.getAllResponseHeaders()):null,q=!e.responseType||e.responseType==="text"?a.responseText:a.response,rt={data:q,status:a.status,statusText:a.statusText,headers:o,config:e,request:a};Ft(i,n,rt),a=null}},a.onabort=function(){!a||(n(_("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(_("Network Error",e,null,a)),a=null},a.ontimeout=function(){var o="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(o=e.timeoutErrorMessage),n(_(o,e,"ECONNABORTED",a)),a=null},A.isStandardBrowserEnv()){var m=(e.withCredentials||kt(b))&&e.xsrfCookieName?Dt.read(e.xsrfCookieName):void 0;m&&(u[e.xsrfHeaderName]=m)}if("setRequestHeader"in a&&A.forEach(u,function(o,q){typeof s=="undefined"&&q.toLowerCase()==="content-type"?delete u[q]:a.setRequestHeader(q,o)}),A.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),e.responseType)try{a.responseType=e.responseType}catch(c){if(e.responseType!=="json")throw c}typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(o){!a||(a.abort(),n(o),a=null)}),s||(s=null),a.send(s)})}});var z=l((qr,Te)=>{"use strict";var h=p(),Oe=le(),It={"Content-Type":"application/x-www-form-urlencoded"};function Le(t,e){!h.isUndefined(t)&&h.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function _t(){var t;return typeof XMLHttpRequest!="undefined"?t=$():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=$()),t}var g={adapter:_t(),transformRequest:[function(e,r){return Oe(r,"Accept"),Oe(r,"Content-Type"),h.isFormData(e)||h.isArrayBuffer(e)||h.isBuffer(e)||h.isStream(e)||h.isFile(e)||h.isBlob(e)?e:h.isArrayBufferView(e)?e.buffer:h.isURLSearchParams(e)?(Le(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):h.isObject(e)?(Le(r,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};g.headers={common:{Accept:"application/json, text/plain, */*"}};h.forEach(["delete","get","head"],function(e){g.headers[e]={}});h.forEach(["post","put","patch"],function(e){g.headers[e]=h.merge(It)});Te.exports=g});var Pe=l((Rr,Be)=>{"use strict";var Ne=p(),K=ae(),$t=M(),zt=z();function V(t){t.cancelToken&&t.cancelToken.throwIfRequested()}Be.exports=function(e){V(e),e.headers=e.headers||{},e.data=K(e.data,e.headers,e.transformRequest),e.headers=Ne.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ne.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var r=e.adapter||zt.adapter;return r(e).then(function(n){return V(e),n.data=K(n.data,n.headers,e.transformResponse),n},function(n){return $t(n)||(V(e),n&&n.response&&(n.response.data=K(n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})}});var X=l((Cr,Fe)=>{"use strict";var d=p();Fe.exports=function(e,r){r=r||{};var i={},n=["url","method","data"],s=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function f(c,o){return d.isPlainObject(c)&&d.isPlainObject(o)?d.merge(c,o):d.isPlainObject(o)?d.merge({},o):d.isArray(o)?o.slice():o}function w(c){d.isUndefined(r[c])?d.isUndefined(e[c])||(i[c]=f(void 0,e[c])):i[c]=f(e[c],r[c])}d.forEach(n,function(o){d.isUndefined(r[o])||(i[o]=f(void 0,r[o]))}),d.forEach(s,w),d.forEach(u,function(o){d.isUndefined(r[o])?d.isUndefined(e[o])||(i[o]=f(void 0,e[o])):i[o]=f(void 0,r[o])}),d.forEach(a,function(o){o in r?i[o]=f(e[o],r[o]):o in e&&(i[o]=f(void 0,e[o]))});var b=n.concat(s).concat(u).concat(a),m=Object.keys(e).concat(Object.keys(r)).filter(function(o){return b.indexOf(o)===-1});return d.forEach(m,w),i}});var Me=l((Ur,He)=>{"use strict";var De=p(),Kt=H(),je=ie(),Vt=Pe(),O=X();function R(t){this.defaults=t,this.interceptors={request:new je,response:new je}}R.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=O(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=[Vt,void 0],i=Promise.resolve(e);for(this.interceptors.request.forEach(function(s){r.unshift(s.fulfilled,s.rejected)}),this.interceptors.response.forEach(function(s){r.push(s.fulfilled,s.rejected)});r.length;)i=i.then(r.shift(),r.shift());return i};R.prototype.getUri=function(e){return e=O(this.defaults,e),Kt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};De.forEach(["delete","get","head","options"],function(e){R.prototype[e]=function(r,i){return this.request(O(i||{},{method:e,url:r,data:(i||{}).data}))}});De.forEach(["post","put","patch"],function(e){R.prototype[e]=function(r,i,n){return this.request(O(n||{},{method:e,url:r,data:i}))}});He.exports=R});var W=l((Sr,ke)=>{"use strict";function J(t){this.message=t}J.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};J.prototype.__CANCEL__=!0;ke.exports=J});var _e=l((Ar,Ie)=>{"use strict";var Xt=W();function L(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var r=this;t(function(n){r.reason||(r.reason=new Xt(n),e(r.reason))})}L.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};L.source=function(){var e,r=new L(function(n){e=n});return{token:r,cancel:e}};Ie.exports=L});var ze=l((gr,$e)=>{"use strict";$e.exports=function(e){return function(i){return e.apply(null,i)}}});var Ve=l((Or,Ke)=>{"use strict";Ke.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var We=l((Lr,G)=>{"use strict";var Xe=p(),Jt=B(),T=Me(),Wt=X(),Gt=z();function Je(t){var e=new T(t),r=Jt(T.prototype.request,e);return Xe.extend(r,T.prototype,e),Xe.extend(r,e),r}var v=Je(Gt);v.Axios=T;v.create=function(e){return Je(Wt(v.defaults,e))};v.Cancel=W();v.CancelToken=_e();v.isCancel=M();v.all=function(e){return Promise.all(e)};v.spread=ze();v.isAxiosError=Ve();G.exports=v;G.exports.default=v});var Ye=l((Tr,Ge)=>{Ge.exports=We()});var Qe=ft(Ye());"use strict";var y={fields:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(t){},onFailed(t){}};function Ze(t){let e=Object.assign({},y,t);Yt(e)}function Yt(t){document.addEventListener("alpine:init",()=>{if(Alpine.data(t.name,()=>({fields:{},errors:{},busy:!1,init(){this.fields=Object.assign({},t.fields),this.$watch("busy",e=>{let r=document.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');e?r.forEach(i=>{i.disabled=!0}):r.forEach(i=>{i.disabled=!1})})},submit(){this.busy=!0,this.errors={};let e=new FormData;if(Object.keys(this.fields).forEach((n,s)=>{typeof this.fields[n]=="object"?this.fields[n].forEach((u,a)=>{e.append(`${n}[${a}]`,u)}):e.append(n,this.fields[n])}),t.fileUpload.filepond)t.fileUpload.filepond.getFiles().forEach((n,s)=>{e.append(`files[${s}]`,n.file,n.name)});else if(t.fileUpload.el){let s=document.querySelector(t.fileUpload.el).files;for(let u=0;u<s.length;u++)e.append(`files[${u}]`,s[u],s[u].name)}let i=new URL(window.location.href);e.append("x_origin",i.origin+i.pathname),Qe.default.post(nr(t.endpoint),e).then(n=>{t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),Qt(),this.resetFields(),t.onSuccess(n),tr()}).catch(n=>{this.errors=n.response.data.errors,this.busy=!1,t.onFailed(n.response),rr()})},resetFields(){this.errors={},this.fields=t.fields,this.busy=!1}})),y.redirectTo&&y.endpoint&&new URL(y.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+y.redirectTo),y.endpoint){let e=new URL(y.endpoint),r=y.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);e.host==="hapiform.sg"&&console.log(`\u{1F680} ${e.origin}/${r}`)}})}function Qt(){Zt(),er()}function Zt(){try{y.fileUpload.filepond.removeFiles()}catch(t){}}function er(){try{let t=document.querySelector(y.fileUpload.el);t.value=""}catch(t){}}function tr(){et("hapi:success")}function rr(){et("hapi:error")}function et(t){let e=new Event(t);document.dispatchEvent(e)}function nr(t){let e=new URL(t);return(window.location.hostname=="localhost"||window.location.hostname=="127.0.0.1")&&e.searchParams.set("test",1),e.href}var tt={form:Ze},Pr=tt;window.Hapi=tt;})();
`),function(a){if(s=a.indexOf(":"),i=I.trim(a.substr(0,s)).toLowerCase(),n=I.trim(a.substr(s+1)),i){if(r[i]&&Pt.indexOf(i)>=0)return;i==="set-cookie"?r[i]=(r[i]?r[i]:[]).concat([n]):r[i]=r[i]?r[i]+", "+n:n}}),r}});var Ae=l((xr,Se)=>{"use strict";var Ue=p();Se.exports=Ue.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),i;function n(s){var u=s;return e&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return i=n(window.location.href),function(u){var a=Ue.isString(u)?n(u):u;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}()});var $=l((br,ge)=>{"use strict";var A=p(),Ft=he(),Dt=ve(),jt=H(),Ht=qe(),Mt=Ce(),kt=Ae(),_=k();ge.exports=function(e){return new Promise(function(i,n){var s=e.data,u=e.headers;A.isFormData(s)&&delete u["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";u.Authorization="Basic "+btoa(f+":"+w)}var b=Ht(e.baseURL,e.url);if(a.open(e.method.toUpperCase(),jt(b,e.params,e.paramsSerializer),!0),a.timeout=e.timeout,a.onreadystatechange=function(){if(!(!a||a.readyState!==4)&&!(a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0))){var o="getAllResponseHeaders"in a?Mt(a.getAllResponseHeaders()):null,q=!e.responseType||e.responseType==="text"?a.responseText:a.response,rt={data:q,status:a.status,statusText:a.statusText,headers:o,config:e,request:a};Ft(i,n,rt),a=null}},a.onabort=function(){!a||(n(_("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(_("Network Error",e,null,a)),a=null},a.ontimeout=function(){var o="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(o=e.timeoutErrorMessage),n(_(o,e,"ECONNABORTED",a)),a=null},A.isStandardBrowserEnv()){var m=(e.withCredentials||kt(b))&&e.xsrfCookieName?Dt.read(e.xsrfCookieName):void 0;m&&(u[e.xsrfHeaderName]=m)}if("setRequestHeader"in a&&A.forEach(u,function(o,q){typeof s=="undefined"&&q.toLowerCase()==="content-type"?delete u[q]:a.setRequestHeader(q,o)}),A.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),e.responseType)try{a.responseType=e.responseType}catch(c){if(e.responseType!=="json")throw c}typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(o){!a||(a.abort(),n(o),a=null)}),s||(s=null),a.send(s)})}});var z=l((qr,Te)=>{"use strict";var h=p(),Oe=le(),It={"Content-Type":"application/x-www-form-urlencoded"};function Le(t,e){!h.isUndefined(t)&&h.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function _t(){var t;return typeof XMLHttpRequest!="undefined"?t=$():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=$()),t}var g={adapter:_t(),transformRequest:[function(e,r){return Oe(r,"Accept"),Oe(r,"Content-Type"),h.isFormData(e)||h.isArrayBuffer(e)||h.isBuffer(e)||h.isStream(e)||h.isFile(e)||h.isBlob(e)?e:h.isArrayBufferView(e)?e.buffer:h.isURLSearchParams(e)?(Le(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):h.isObject(e)?(Le(r,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};g.headers={common:{Accept:"application/json, text/plain, */*"}};h.forEach(["delete","get","head"],function(e){g.headers[e]={}});h.forEach(["post","put","patch"],function(e){g.headers[e]=h.merge(It)});Te.exports=g});var Pe=l((Rr,Be)=>{"use strict";var Ne=p(),K=ae(),$t=M(),zt=z();function V(t){t.cancelToken&&t.cancelToken.throwIfRequested()}Be.exports=function(e){V(e),e.headers=e.headers||{},e.data=K(e.data,e.headers,e.transformRequest),e.headers=Ne.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ne.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var r=e.adapter||zt.adapter;return r(e).then(function(n){return V(e),n.data=K(n.data,n.headers,e.transformResponse),n},function(n){return $t(n)||(V(e),n&&n.response&&(n.response.data=K(n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})}});var X=l((Cr,Fe)=>{"use strict";var d=p();Fe.exports=function(e,r){r=r||{};var i={},n=["url","method","data"],s=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function f(c,o){return d.isPlainObject(c)&&d.isPlainObject(o)?d.merge(c,o):d.isPlainObject(o)?d.merge({},o):d.isArray(o)?o.slice():o}function w(c){d.isUndefined(r[c])?d.isUndefined(e[c])||(i[c]=f(void 0,e[c])):i[c]=f(e[c],r[c])}d.forEach(n,function(o){d.isUndefined(r[o])||(i[o]=f(void 0,r[o]))}),d.forEach(s,w),d.forEach(u,function(o){d.isUndefined(r[o])?d.isUndefined(e[o])||(i[o]=f(void 0,e[o])):i[o]=f(void 0,r[o])}),d.forEach(a,function(o){o in r?i[o]=f(e[o],r[o]):o in e&&(i[o]=f(void 0,e[o]))});var b=n.concat(s).concat(u).concat(a),m=Object.keys(e).concat(Object.keys(r)).filter(function(o){return b.indexOf(o)===-1});return d.forEach(m,w),i}});var Me=l((Ur,He)=>{"use strict";var De=p(),Kt=H(),je=ie(),Vt=Pe(),O=X();function R(t){this.defaults=t,this.interceptors={request:new je,response:new je}}R.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=O(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=[Vt,void 0],i=Promise.resolve(e);for(this.interceptors.request.forEach(function(s){r.unshift(s.fulfilled,s.rejected)}),this.interceptors.response.forEach(function(s){r.push(s.fulfilled,s.rejected)});r.length;)i=i.then(r.shift(),r.shift());return i};R.prototype.getUri=function(e){return e=O(this.defaults,e),Kt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};De.forEach(["delete","get","head","options"],function(e){R.prototype[e]=function(r,i){return this.request(O(i||{},{method:e,url:r,data:(i||{}).data}))}});De.forEach(["post","put","patch"],function(e){R.prototype[e]=function(r,i,n){return this.request(O(n||{},{method:e,url:r,data:i}))}});He.exports=R});var W=l((Sr,ke)=>{"use strict";function J(t){this.message=t}J.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};J.prototype.__CANCEL__=!0;ke.exports=J});var _e=l((Ar,Ie)=>{"use strict";var Xt=W();function L(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var r=this;t(function(n){r.reason||(r.reason=new Xt(n),e(r.reason))})}L.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};L.source=function(){var e,r=new L(function(n){e=n});return{token:r,cancel:e}};Ie.exports=L});var ze=l((gr,$e)=>{"use strict";$e.exports=function(e){return function(i){return e.apply(null,i)}}});var Ve=l((Or,Ke)=>{"use strict";Ke.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var We=l((Lr,G)=>{"use strict";var Xe=p(),Jt=B(),T=Me(),Wt=X(),Gt=z();function Je(t){var e=new T(t),r=Jt(T.prototype.request,e);return Xe.extend(r,T.prototype,e),Xe.extend(r,e),r}var v=Je(Gt);v.Axios=T;v.create=function(e){return Je(Wt(v.defaults,e))};v.Cancel=W();v.CancelToken=_e();v.isCancel=M();v.all=function(e){return Promise.all(e)};v.spread=ze();v.isAxiosError=Ve();G.exports=v;G.exports.default=v});var Ye=l((Tr,Ge)=>{Ge.exports=We()});var Qe=ft(Ye());"use strict";var y={fields:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(t){},onFailed(t){}};function Ze(t){let e=Object.assign({},y,t);Yt(e)}function Yt(t){document.addEventListener("alpine:init",()=>{if(Alpine.data(t.name,()=>({fields:{},errors:{},busy:!1,init(){this.fields=Object.assign({},t.fields),this.$watch("busy",e=>{let r=document.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');e?r.forEach(i=>{i.disabled=!0}):r.forEach(i=>{i.disabled=!1})})},submit(){this.busy=!0,this.errors={};let e=new FormData;if(Object.keys(this.fields).forEach((n,s)=>{typeof this.fields[n]=="object"?this.fields[n].forEach((u,a)=>{e.append(`${n}[${a}]`,u)}):e.append(n,this.fields[n])}),t.fileUpload.filepond)t.fileUpload.filepond.getFiles().forEach((n,s)=>{e.append(`files[${s}]`,n.file,n.name)});else if(t.fileUpload.el){let s=document.querySelector(t.fileUpload.el).files;for(let u=0;u<s.length;u++)e.append(`files[${u}]`,s[u],s[u].name)}let i=new URL(window.top.location.href);e.append("x_origin",i.origin+i.pathname),Qe.default.post(nr(t.endpoint),e).then(n=>{t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),Qt(),this.resetFields(),t.onSuccess(n),tr()}).catch(n=>{this.errors=n.response.data.errors,this.busy=!1,t.onFailed(n.response),rr()})},resetFields(){this.errors={},this.fields=t.fields,this.busy=!1}})),y.redirectTo&&y.endpoint&&new URL(y.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+y.redirectTo),y.endpoint){let e=new URL(y.endpoint),r=y.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);e.host==="hapiform.sg"&&console.log(`\u{1F680} ${e.origin}/${r}`)}})}function Qt(){Zt(),er()}function Zt(){try{y.fileUpload.filepond.removeFiles()}catch(t){}}function er(){try{let t=document.querySelector(y.fileUpload.el);t.value=""}catch(t){}}function tr(){et("hapi:success")}function rr(){et("hapi:error")}function et(t){let e=new Event(t);document.dispatchEvent(e)}function nr(t){let e=new URL(t);return(window.location.hostname=="localhost"||window.location.hostname=="127.0.0.1")&&e.searchParams.set("test",1),e.href}var tt={form:Ze},Pr=tt;window.Hapi=tt;})();
{
"name": "@juno0424/hapi",
"version": "0.6.1",
"version": " 0.6.2",
"main": "index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -89,3 +89,3 @@ "use strict";

// Append x_origin to formData
let currentUrl = new URL(window.location.href);
let currentUrl = new URL(window.top.location.href);

@@ -92,0 +92,0 @@ formData.append("x_origin", currentUrl.origin + currentUrl.pathname);

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc