@corbado/autocapture 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,8 @@ The package observes three kinds of signal:
13
13
 
14
14
  - **WebAuthn ceremonies** — the lifecycle of `navigator.credentials.get`/`create` passkey
15
15
  ceremonies, from invocation to settlement, including silent cancellations.
16
+ - **Federated identity (FedCM) requests** — `navigator.credentials.get({ identity })` calls such
17
+ as Google One Tap on Chromium: the providers requested, the account chosen, or why it failed.
16
18
  - **Network requests and exchanges** — request starts and their eventual outcomes over
17
19
  `XMLHttpRequest` and `fetch`, limited to URLs a caller-provided predicate selects. A page-local
18
20
  request ID correlates both callbacks.
@@ -35,12 +37,22 @@ Every observer follows the platform observer pattern (`MutationObserver`, `Resiz
35
37
  it with a callback, receive events, and call `disconnect()` when finished.
36
38
 
37
39
  ```ts
38
- import { captureWebAuthn, captureNetwork, captureNavigation, composedPath } from "@corbado/autocapture";
40
+ import {
41
+ captureFederatedIdentity,
42
+ captureWebAuthn,
43
+ captureNetwork,
44
+ captureNavigation,
45
+ composedPath,
46
+ } from "@corbado/autocapture";
39
47
 
40
48
  const webauthn = captureWebAuthn({
41
49
  onEvent: (event) => console.log(event.kind, event.mediation, event.phase, event.ceremonyId),
42
50
  });
43
51
 
52
+ const fedcm = captureFederatedIdentity({
53
+ onEvent: (event) => console.log(event.phase, event.requestId),
54
+ });
55
+
44
56
  const network = captureNetwork({
45
57
  match: (url) => url.origin === location.origin && url.pathname.startsWith("/auth-api/"),
46
58
  bodyCapture: {
@@ -70,6 +82,7 @@ document.addEventListener("click", (event) => {
70
82
 
71
83
  // when finished
72
84
  webauthn.disconnect();
85
+ fedcm.disconnect();
73
86
  network.disconnect();
74
87
  navigation.disconnect();
75
88
  ```
@@ -87,6 +100,14 @@ Autocapture deliberately does not infer product concepts such as conditional-UI
87
100
  known-identifier state, enrollment intent, or the user/system actor. Integrations map those facts in
88
101
  their own state context.
89
102
 
103
+ Federated identity events carry the requested providers (`configURL`, `clientId`), `context`,
104
+ `mode` and `mediation` on `started`; the chosen provider's `configURL` and `isAutoSelected` on
105
+ `completed`; `errorName` (plus an `IdentityCredentialError` `code`) on `failed`. Tokens, nonces,
106
+ provider parameters and login hints are never read. `captureWebAuthn` and `captureFederatedIdentity`
107
+ share one attachment to the credential methods and can start and stop in any order; a later capture
108
+ joins at the surface the first one attached to, so pass `attach: "container"` to whichever starts
109
+ first (see `src/federated-identity.contract.md`).
110
+
90
111
  ## Safety invariants
91
112
 
92
113
  The observers run inside application call paths, so their behaviour is defined by what they promise
@@ -106,10 +127,10 @@ never to disturb:
106
127
  still owned by the capture, and later wrappers are never overwritten. A buried wrapper becomes an
107
128
  inert pass-through after disconnect. Locked WebAuthn methods are never bypassed through a container
108
129
  proxy; the entire WebAuthn attachment is rolled back and reported as unavailable.
109
- - **Exactly-once reporting.** Each patched surface holds a single capture wrapper, so one
110
- application action passes through observation once. A later integration that overwrites a wrapped
111
- method without forwarding through it displaces capture for that surface: the application call
112
- still succeeds, telemetry is lost. A package wrapper hidden below an unknown third-party wrapper
130
+ - **Exactly-once reporting.** Each patched surface holds a single capture wrapper, shared by the
131
+ WebAuthn and federated identity captures, so one application action passes through observation
132
+ once. A later integration that overwrites a wrapped method without forwarding through it
133
+ displaces capture for that surface: the application call still succeeds, telemetry is lost. A package wrapper hidden below an unknown third-party wrapper
113
134
  cannot currently be detected by another copy.
114
135
  - **Conditional removal.** `disconnect()` stops delivery immediately, releases active listeners, and
115
136
  restores only slots still owned by the capture. If another integration sits above it, the inert
@@ -1 +1 @@
1
- var pe={log:()=>{}};function _(e){return e?{log:(...r)=>{try{let n=e.log(...r);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:pe}var re=Symbol.for("corbado.autocapture.installed");function U(e){try{return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,re)}catch{return!1}}function X(e,r){var o,a;let n=r;try{Object.defineProperty(e,re,{value:r,configurable:!0})}catch{}try{Object.defineProperty(e,"name",{value:(o=n.name)!=null?o:"",configurable:!0})}catch{}try{Object.defineProperty(e,"length",{value:(a=n.length)!=null?a:0,configurable:!0})}catch{}return e}function k(){return{mode:"unavailable",disconnect:()=>{}}}function Z(e,r){return!!e&&"value"in e&&"value"in r&&e.value===r.value&&e.writable===r.writable&&e.enumerable===r.enumerable&&e.configurable===r.configurable}function V(e,r,n,o,a,p=String(r)){try{let c=Object.getOwnPropertyDescriptor(e,r);Z(c,{...o,value:n})&&Object.defineProperty(e,r,o)}catch(c){a.log(`${p} restoration skipped`,c)}}function z(e,r,n){let o=_(e);return a=>{try{let p=n(a);if(p&&(typeof p=="object"||typeof p=="function"))try{Promise.resolve(p).catch(c=>o.log(`${r} listener failed`,c))}catch(c){o.log(`${r} listener failed`,c)}}catch(p){o.log(`${r} listener failed`,p)}}}var oe=0;function ae(){return oe+=1,`network-${oe}`}function fe(e,r){let n=e.responseType;if(n===""||n==="text")return r(e.responseText);if(n==="json"){let o=e.response;return o==null?void 0:r(o)}}var he=500,se=Symbol("body-read-timeout");function ie(e){return/event-stream|octet-stream/i.test(e)?!1:/json|text|urlencoded/i.test(e)}async function ue(e,r){let n=e.body;if(!n)return;let o=n.getReader(),a;try{let p=new Promise(m=>{a=setTimeout(()=>m(se),he)}),c=new TextDecoder,q=[];for(;;){let m=await Promise.race([o.read(),p]);if(m===se){r.log("body omitted: read timed out"),o.cancel().catch(()=>{});return}if(m.done)break;q.push(c.decode(m.value,{stream:!0}))}return q.push(c.decode()),q.join("")}catch{o.cancel().catch(()=>{});return}finally{a!==void 0&&clearTimeout(a)}}function ee(e){var r;(r=e==null?void 0:e.body)==null||r.cancel().catch(()=>{})}function ve(e){var w,P,te;let{onExchange:r,onRequest:n,match:o}=e;if(typeof r!="function"||typeof o!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let a=_(e.logger),p=(w=e.transports)!=null?w:["xhr","fetch"],c=(P=e.bodyCapture)==null?void 0:P.request,q=(te=e.bodyCapture)==null?void 0:te.response,m=typeof c=="function",H=typeof q=="function",b=!1,L=z(a,"network",d=>{if(b)return r(d)}),$=z(a,"network request",d=>{if(b)return n==null?void 0:n(d)}),D=(d,h,g)=>{if(typeof g=="function")try{return g(d,h)}catch(y){a.log("body projection failed",y);return}},C=(d,h)=>{try{let g=typeof document!="undefined"?document.baseURI:void 0,y=new URL(String(d),g);return o(y,h)===!0?{url:y.href,path:y.pathname}:void 0}catch{return}},M=()=>{if(typeof XMLHttpRequest=="undefined")return a.log("xhr capture unavailable: XMLHttpRequest missing"),null;let d=XMLHttpRequest.prototype,h=Object.getOwnPropertyDescriptor(d,"open"),g=Object.getOwnPropertyDescriptor(d,"send");if(!h||!("value"in h)||typeof h.value!="function"||!g||!("value"in g)||typeof g.value!="function")return a.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let y=h.value,F=g.value;if(U(y)||U(F))return a.log("xhr capture unavailable: an equivalent capture is already active"),null;let N=new WeakMap,f=new Set,R=!1,x={open(...l){var i;let t=Reflect.apply(y,this,l);if(!b||!R)return t;try{let E=N.get(this);E&&(E.reported=!0,(i=E.cleanupListeners)==null||i.call(E));let B=String(l[0]).toUpperCase(),v=C(l[1],B);v?N.set(this,{method:B,url:v.url,path:v.path,reported:!1}):N.delete(this)}catch(E){a.log("xhr open observation failed",E)}return t}}.open,j={send(...l){let t=b&&R?N.get(this):void 0;if(!t||t.reported||t.cleanupListeners)return Reflect.apply(F,this,l);let i=()=>{},E=!1;try{t.requestId=ae();let v={direction:"request",transport:"xhr",method:t.method,url:t.url,path:t.path};t.requestBody=m&&typeof l[0]=="string"?D(l[0],v,c):void 0;let K=()=>{t.outcome===void 0&&(t.outcome="abort")},W=()=>{t.outcome===void 0&&(t.outcome="timeout")},s=()=>{t.outcome===void 0&&(t.outcome="error")},u=()=>{var I;i();try{if(!b||!R||t.reported||!t.requestId)return;t.reported=!0;let O={direction:"response",transport:"xhr",method:t.method,url:t.url,path:t.path},Q=this.status,ne={requestId:t.requestId,transport:"xhr",method:t.method,url:t.url,path:t.path,status:Q,ok:Q>=200&&Q<300,outcome:(I=t.outcome)!=null?I:"load",durationMs:t.startedAt!==void 0?Date.now()-t.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:t.requestBody,responseBody:H?fe(this,le=>D(le,O,q)):void 0};t.requestEmitted?L(ne):t.pendingExchange=ne}catch(O){a.log("xhr exchange observation failed",O)}finally{N.get(this)===t&&N.delete(this)}},S=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&u()}catch(I){a.log("xhr ready-state observation failed",I)}},T=()=>u();i=()=>{for(let[I,O]of[["readystatechange",S],["abort",K],["timeout",W],["error",s],["loadend",T]])this.removeEventListener(I,O);t.cleanupListeners===i&&(t.cleanupListeners=void 0),f.delete(i)},this.addEventListener("readystatechange",S),this.addEventListener("abort",K),this.addEventListener("timeout",W),this.addEventListener("error",s),this.addEventListener("loadend",T),t.cleanupListeners=i,f.add(i),t.startedAt=Date.now(),E=!0}catch(v){a.log("xhr send observation failed",v),i()}let B;try{B=Reflect.apply(F,this,l)}catch(v){throw i(),v}if(E&&t.requestId!==void 0&&t.startedAt!==void 0){t.requestEmitted=!0,$({requestId:t.requestId,transport:"xhr",method:t.method,url:t.url,path:t.path,startedAt:t.startedAt,requestBody:t.requestBody});let v=t.pendingExchange;t.pendingExchange=void 0,v&&L(v)}return B}}.send;return X(x,y),X(j,F),h.writable!==!0||g.writable!==!0?(a.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(d,"open",{...h,value:x}),Object.defineProperty(d,"send",{...g,value:j}),R=!0,()=>{R=!1;for(let l of[...f])l();V(d,"open",x,h,a),V(d,"send",j,g,a)})},G=()=>{let d=globalThis,h=Object.getOwnPropertyDescriptor(d,"fetch");if(!h||!("value"in h))return a.log("fetch capture unavailable: fetch is not an own data property"),null;let g=h.value;if(typeof g!="function")return a.log("fetch capture unavailable: fetch missing"),null;if(U(g))return a.log("fetch capture unavailable: an equivalent capture is already active"),null;let y=!1,F=async(f,R,x,j)=>{try{if(!b||!y){ee(x);return}let[l,t]=await Promise.all([j!=null?j:Promise.resolve(void 0),x?ue(x,a):Promise.resolve(void 0)]);if(!b||!y)return;let i={direction:"request",transport:"fetch",method:f.method,url:f.url,path:f.path},E={...i,direction:"response"},B=f.requestBody;B===void 0&&l!==void 0&&(B=D(l,i,c));let v=t!==void 0?D(t,E,q):void 0;L({requestId:f.requestId,transport:"fetch",method:f.method,url:f.url,path:f.path,status:R.status,ok:R.ok,outcome:"load",durationMs:Date.now()-f.startedAt,responseUrl:R.url||void 0,requestBody:B,responseBody:v})}catch(l){a.log("fetch exchange observation failed",l)}},N={fetch(...f){var B,v,K,W;let R;try{let s=f[0],u=f[1];if(b&&y&&m&&typeof Request!="undefined"&&s instanceof Request&&(u==null?void 0:u.body)===void 0&&s.body){let S=String((B=u==null?void 0:u.method)!=null?B:s.method).toUpperCase(),T=(v=s.headers.get("content-type"))!=null?v:"";C(s.url,S)&&ie(T)&&(R=s.clone())}}catch(s){a.log("fetch observation failed",s)}let x,j=Date.now();try{x=Reflect.apply(g,this,f)}catch(s){throw ee(R),s}let l,t;try{if(b&&y){let s=f[0],u=f[1],S=typeof Request!="undefined"&&s instanceof Request,T=String((K=u==null?void 0:u.method)!=null?K:S?s.method:"GET").toUpperCase(),I=S?s.url:s,O=C(I,T);O&&(l={requestId:ae(),method:T,url:O.url,path:O.path,startedAt:j},t=(W=u==null?void 0:u.signal)!=null?W:S?s.signal:void 0,m&&typeof(u==null?void 0:u.body)=="string"&&(l.requestBody=D(u.body,{direction:"request",transport:"fetch",method:T,url:O.url,path:O.path},c)))}}catch(s){a.log("fetch observation failed",s)}if(!l)return ee(R),x;let i=l;$({requestId:i.requestId,transport:"fetch",method:i.method,url:i.url,path:i.path,startedAt:i.startedAt,requestBody:i.requestBody});let E=R?ue(R,a):void 0;return x.then(s=>{var S;let u;try{if(b&&y&&H){let T=(S=s.headers.get("content-type"))!=null?S:"";ie(T)&&s.body&&(u=s.clone())}}catch{}F(i,s,u,E)},s=>{try{if(!b||!y)return;let u=(t==null?void 0:t.aborted)===!0||(s==null?void 0:s.name)==="AbortError"||typeof DOMException!="undefined"&&s instanceof DOMException&&s.code===DOMException.ABORT_ERR;L({requestId:i.requestId,transport:"fetch",method:i.method,url:i.url,path:i.path,status:0,ok:!1,outcome:u?"abort":"error",durationMs:Date.now()-i.startedAt})}catch(u){a.log("fetch failure observation failed",u)}}),x}}.fetch;return X(N,g),h.writable!==!0?(a.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(d,"fetch",{...h,value:N}),y=!0,()=>{y=!1,V(d,"fetch",N,h,a)})},A=[];if(p.includes("xhr")){let d=M();d&&A.push(d)}if(p.includes("fetch")){let d=G();d&&A.push(d)}return A.length===0?k():(b=!0,{mode:"standard",disconnect:()=>{b=!1;for(let d of A.splice(0))d()}})}function we(e){let r=e.onNavigate;if(typeof r!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=_(e.logger),o,a,p,c,q,m;try{if(o=window,a=o==null?void 0:o.history,!o||!a)return n.log("navigation capture unavailable: window/history missing"),k();if(q=de(a,"pushState"),m=de(a,"replaceState"),!q||!m)return n.log("navigation capture unavailable: history method descriptors missing"),k();if(p=q.descriptor.value,c=m.descriptor.value,typeof p!="function"||typeof c!="function")return n.log("navigation capture unavailable: history methods missing"),k();if(typeof o.addEventListener!="function"||typeof o.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),k()}catch(w){return n.log("navigation capture unavailable: history inspection failed",w),k()}if(U(p)||U(c))return n.log("navigation capture unavailable: an equivalent capture is already active"),k();let H=!1,b=()=>({path:o.location.pathname,search:o.location.search,hash:o.location.hash}),L;try{L=b()}catch(w){return n.log("navigation capture unavailable: location inspection failed",w),k()}let $=z(n,"navigation",w=>{if(H)return r(w)}),D=w=>{if(H)try{let P=b();if(P.path===L.path&&P.search===L.search&&P.hash===L.hash)return;L=P,$({...P,source:w})}catch(P){n.log("navigation observation failed",P)}},C={pushState(...w){let P=Reflect.apply(p,this,w);return D("push"),P}}.pushState,M={replaceState(...w){let P=Reflect.apply(c,this,w);return D("replace"),P}}.replaceState;X(C,p),X(M,c);let G=()=>D("pop"),A=()=>D("hash");try{if(ce(q,C),ce(m,M),a.pushState!==C||a.replaceState!==M)throw new Error("history method replacement did not take effect");o.addEventListener("popstate",G),o.addEventListener("hashchange",A),H=!0}catch(w){return H=!1,J(o,"popstate",G,n),J(o,"hashchange",A,n),Y(m,M,n),Y(q,C,n),n.log("navigation capture unavailable: history methods are not writable",w),r=()=>{},$=()=>{},n=_(),k()}return{mode:"standard",disconnect:()=>{H=!1,r=()=>{},J(o,"popstate",G,n),J(o,"hashchange",A,n),Y(q,C,n),Y(m,M,n),$=()=>{},n=_()}}}function de(e,r){let n=e;for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return!("value"in o)||typeof o.value!="function"?null:{owner:n,key:r,descriptor:o};n=Object.getPrototypeOf(n)}return null}function ce(e,r){if(e.descriptor.writable!==!0)throw new TypeError(`${e.key} is not writable`);let n=Object.getOwnPropertyDescriptor(e.owner,e.key);if(!Z(n,e.descriptor))throw new Error(`${e.key} changed during installation`);Object.defineProperty(e.owner,e.key,{...e.descriptor,value:r})}function Y(e,r,n){V(e.owner,e.key,r,e.descriptor,n,`navigation ${e.key}`)}function J(e,r,n,o){try{e.removeEventListener(r,n)}catch(a){o.log(`navigation ${r} listener removal skipped`,a)}}var qe="1.1.0";export{_ as a,U as b,X as c,k as d,z as e,ve as f,we as g,qe as h};
1
+ var pe={log:()=>{}};function _(e){return e?{log:(...r)=>{try{let n=e.log(...r);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:pe}var re=Symbol.for("corbado.autocapture.installed");function U(e){try{return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,re)}catch{return!1}}function X(e,r){var o,a;let n=r;try{Object.defineProperty(e,re,{value:r,configurable:!0})}catch{}try{Object.defineProperty(e,"name",{value:(o=n.name)!=null?o:"",configurable:!0})}catch{}try{Object.defineProperty(e,"length",{value:(a=n.length)!=null?a:0,configurable:!0})}catch{}return e}function k(){return{mode:"unavailable",disconnect:()=>{}}}function Z(e,r){return!!e&&"value"in e&&"value"in r&&e.value===r.value&&e.writable===r.writable&&e.enumerable===r.enumerable&&e.configurable===r.configurable}function V(e,r,n,o,a,p=String(r)){try{let c=Object.getOwnPropertyDescriptor(e,r);Z(c,{...o,value:n})&&Object.defineProperty(e,r,o)}catch(c){a.log(`${p} restoration skipped`,c)}}function z(e,r,n){let o=_(e);return a=>{try{let p=n(a);if(p&&(typeof p=="object"||typeof p=="function"))try{Promise.resolve(p).catch(c=>o.log(`${r} listener failed`,c))}catch(c){o.log(`${r} listener failed`,c)}}catch(p){o.log(`${r} listener failed`,p)}}}var oe=0;function ae(){return oe+=1,`network-${oe}`}function fe(e,r){let n=e.responseType;if(n===""||n==="text")return r(e.responseText);if(n==="json"){let o=e.response;return o==null?void 0:r(o)}}var he=500,se=Symbol("body-read-timeout");function ie(e){return/event-stream|octet-stream/i.test(e)?!1:/json|text|urlencoded/i.test(e)}async function ue(e,r){let n=e.body;if(!n)return;let o=n.getReader(),a;try{let p=new Promise(m=>{a=setTimeout(()=>m(se),he)}),c=new TextDecoder,q=[];for(;;){let m=await Promise.race([o.read(),p]);if(m===se){r.log("body omitted: read timed out"),o.cancel().catch(()=>{});return}if(m.done)break;q.push(c.decode(m.value,{stream:!0}))}return q.push(c.decode()),q.join("")}catch{o.cancel().catch(()=>{});return}finally{a!==void 0&&clearTimeout(a)}}function ee(e){var r;(r=e==null?void 0:e.body)==null||r.cancel().catch(()=>{})}function ve(e){var w,P,te;let{onExchange:r,onRequest:n,match:o}=e;if(typeof r!="function"||typeof o!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let a=_(e.logger),p=(w=e.transports)!=null?w:["xhr","fetch"],c=(P=e.bodyCapture)==null?void 0:P.request,q=(te=e.bodyCapture)==null?void 0:te.response,m=typeof c=="function",H=typeof q=="function",b=!1,L=z(a,"network",d=>{if(b)return r(d)}),$=z(a,"network request",d=>{if(b)return n==null?void 0:n(d)}),D=(d,h,g)=>{if(typeof g=="function")try{return g(d,h)}catch(y){a.log("body projection failed",y);return}},C=(d,h)=>{try{let g=typeof document!="undefined"?document.baseURI:void 0,y=new URL(String(d),g);return o(y,h)===!0?{url:y.href,path:y.pathname}:void 0}catch{return}},M=()=>{if(typeof XMLHttpRequest=="undefined")return a.log("xhr capture unavailable: XMLHttpRequest missing"),null;let d=XMLHttpRequest.prototype,h=Object.getOwnPropertyDescriptor(d,"open"),g=Object.getOwnPropertyDescriptor(d,"send");if(!h||!("value"in h)||typeof h.value!="function"||!g||!("value"in g)||typeof g.value!="function")return a.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let y=h.value,F=g.value;if(U(y)||U(F))return a.log("xhr capture unavailable: an equivalent capture is already active"),null;let N=new WeakMap,f=new Set,R=!1,x={open(...l){var i;let t=Reflect.apply(y,this,l);if(!b||!R)return t;try{let E=N.get(this);E&&(E.reported=!0,(i=E.cleanupListeners)==null||i.call(E));let B=String(l[0]).toUpperCase(),v=C(l[1],B);v?N.set(this,{method:B,url:v.url,path:v.path,reported:!1}):N.delete(this)}catch(E){a.log("xhr open observation failed",E)}return t}}.open,j={send(...l){let t=b&&R?N.get(this):void 0;if(!t||t.reported||t.cleanupListeners)return Reflect.apply(F,this,l);let i=()=>{},E=!1;try{t.requestId=ae();let v={direction:"request",transport:"xhr",method:t.method,url:t.url,path:t.path};t.requestBody=m&&typeof l[0]=="string"?D(l[0],v,c):void 0;let K=()=>{t.outcome===void 0&&(t.outcome="abort")},W=()=>{t.outcome===void 0&&(t.outcome="timeout")},s=()=>{t.outcome===void 0&&(t.outcome="error")},u=()=>{var I;i();try{if(!b||!R||t.reported||!t.requestId)return;t.reported=!0;let O={direction:"response",transport:"xhr",method:t.method,url:t.url,path:t.path},Q=this.status,ne={requestId:t.requestId,transport:"xhr",method:t.method,url:t.url,path:t.path,status:Q,ok:Q>=200&&Q<300,outcome:(I=t.outcome)!=null?I:"load",durationMs:t.startedAt!==void 0?Date.now()-t.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:t.requestBody,responseBody:H?fe(this,le=>D(le,O,q)):void 0};t.requestEmitted?L(ne):t.pendingExchange=ne}catch(O){a.log("xhr exchange observation failed",O)}finally{N.get(this)===t&&N.delete(this)}},S=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&u()}catch(I){a.log("xhr ready-state observation failed",I)}},T=()=>u();i=()=>{for(let[I,O]of[["readystatechange",S],["abort",K],["timeout",W],["error",s],["loadend",T]])this.removeEventListener(I,O);t.cleanupListeners===i&&(t.cleanupListeners=void 0),f.delete(i)},this.addEventListener("readystatechange",S),this.addEventListener("abort",K),this.addEventListener("timeout",W),this.addEventListener("error",s),this.addEventListener("loadend",T),t.cleanupListeners=i,f.add(i),t.startedAt=Date.now(),E=!0}catch(v){a.log("xhr send observation failed",v),i()}let B;try{B=Reflect.apply(F,this,l)}catch(v){throw i(),v}if(E&&t.requestId!==void 0&&t.startedAt!==void 0){t.requestEmitted=!0,$({requestId:t.requestId,transport:"xhr",method:t.method,url:t.url,path:t.path,startedAt:t.startedAt,requestBody:t.requestBody});let v=t.pendingExchange;t.pendingExchange=void 0,v&&L(v)}return B}}.send;return X(x,y),X(j,F),h.writable!==!0||g.writable!==!0?(a.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(d,"open",{...h,value:x}),Object.defineProperty(d,"send",{...g,value:j}),R=!0,()=>{R=!1;for(let l of[...f])l();V(d,"open",x,h,a),V(d,"send",j,g,a)})},G=()=>{let d=globalThis,h=Object.getOwnPropertyDescriptor(d,"fetch");if(!h||!("value"in h))return a.log("fetch capture unavailable: fetch is not an own data property"),null;let g=h.value;if(typeof g!="function")return a.log("fetch capture unavailable: fetch missing"),null;if(U(g))return a.log("fetch capture unavailable: an equivalent capture is already active"),null;let y=!1,F=async(f,R,x,j)=>{try{if(!b||!y){ee(x);return}let[l,t]=await Promise.all([j!=null?j:Promise.resolve(void 0),x?ue(x,a):Promise.resolve(void 0)]);if(!b||!y)return;let i={direction:"request",transport:"fetch",method:f.method,url:f.url,path:f.path},E={...i,direction:"response"},B=f.requestBody;B===void 0&&l!==void 0&&(B=D(l,i,c));let v=t!==void 0?D(t,E,q):void 0;L({requestId:f.requestId,transport:"fetch",method:f.method,url:f.url,path:f.path,status:R.status,ok:R.ok,outcome:"load",durationMs:Date.now()-f.startedAt,responseUrl:R.url||void 0,requestBody:B,responseBody:v})}catch(l){a.log("fetch exchange observation failed",l)}},N={fetch(...f){var B,v,K,W;let R;try{let s=f[0],u=f[1];if(b&&y&&m&&typeof Request!="undefined"&&s instanceof Request&&(u==null?void 0:u.body)===void 0&&s.body){let S=String((B=u==null?void 0:u.method)!=null?B:s.method).toUpperCase(),T=(v=s.headers.get("content-type"))!=null?v:"";C(s.url,S)&&ie(T)&&(R=s.clone())}}catch(s){a.log("fetch observation failed",s)}let x,j=Date.now();try{x=Reflect.apply(g,this,f)}catch(s){throw ee(R),s}let l,t;try{if(b&&y){let s=f[0],u=f[1],S=typeof Request!="undefined"&&s instanceof Request,T=String((K=u==null?void 0:u.method)!=null?K:S?s.method:"GET").toUpperCase(),I=S?s.url:s,O=C(I,T);O&&(l={requestId:ae(),method:T,url:O.url,path:O.path,startedAt:j},t=(W=u==null?void 0:u.signal)!=null?W:S?s.signal:void 0,m&&typeof(u==null?void 0:u.body)=="string"&&(l.requestBody=D(u.body,{direction:"request",transport:"fetch",method:T,url:O.url,path:O.path},c)))}}catch(s){a.log("fetch observation failed",s)}if(!l)return ee(R),x;let i=l;$({requestId:i.requestId,transport:"fetch",method:i.method,url:i.url,path:i.path,startedAt:i.startedAt,requestBody:i.requestBody});let E=R?ue(R,a):void 0;return x.then(s=>{var S;let u;try{if(b&&y&&H){let T=(S=s.headers.get("content-type"))!=null?S:"";ie(T)&&s.body&&(u=s.clone())}}catch{}F(i,s,u,E)},s=>{try{if(!b||!y)return;let u=(t==null?void 0:t.aborted)===!0||(s==null?void 0:s.name)==="AbortError"||typeof DOMException!="undefined"&&s instanceof DOMException&&s.code===DOMException.ABORT_ERR;L({requestId:i.requestId,transport:"fetch",method:i.method,url:i.url,path:i.path,status:0,ok:!1,outcome:u?"abort":"error",durationMs:Date.now()-i.startedAt})}catch(u){a.log("fetch failure observation failed",u)}}),x}}.fetch;return X(N,g),h.writable!==!0?(a.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(d,"fetch",{...h,value:N}),y=!0,()=>{y=!1,V(d,"fetch",N,h,a)})},A=[];if(p.includes("xhr")){let d=M();d&&A.push(d)}if(p.includes("fetch")){let d=G();d&&A.push(d)}return A.length===0?k():(b=!0,{mode:"standard",disconnect:()=>{b=!1;for(let d of A.splice(0))d()}})}function we(e){let r=e.onNavigate;if(typeof r!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=_(e.logger),o,a,p,c,q,m;try{if(o=window,a=o==null?void 0:o.history,!o||!a)return n.log("navigation capture unavailable: window/history missing"),k();if(q=de(a,"pushState"),m=de(a,"replaceState"),!q||!m)return n.log("navigation capture unavailable: history method descriptors missing"),k();if(p=q.descriptor.value,c=m.descriptor.value,typeof p!="function"||typeof c!="function")return n.log("navigation capture unavailable: history methods missing"),k();if(typeof o.addEventListener!="function"||typeof o.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),k()}catch(w){return n.log("navigation capture unavailable: history inspection failed",w),k()}if(U(p)||U(c))return n.log("navigation capture unavailable: an equivalent capture is already active"),k();let H=!1,b=()=>({path:o.location.pathname,search:o.location.search,hash:o.location.hash}),L;try{L=b()}catch(w){return n.log("navigation capture unavailable: location inspection failed",w),k()}let $=z(n,"navigation",w=>{if(H)return r(w)}),D=w=>{if(H)try{let P=b();if(P.path===L.path&&P.search===L.search&&P.hash===L.hash)return;L=P,$({...P,source:w})}catch(P){n.log("navigation observation failed",P)}},C={pushState(...w){let P=Reflect.apply(p,this,w);return D("push"),P}}.pushState,M={replaceState(...w){let P=Reflect.apply(c,this,w);return D("replace"),P}}.replaceState;X(C,p),X(M,c);let G=()=>D("pop"),A=()=>D("hash");try{if(ce(q,C),ce(m,M),a.pushState!==C||a.replaceState!==M)throw new Error("history method replacement did not take effect");o.addEventListener("popstate",G),o.addEventListener("hashchange",A),H=!0}catch(w){return H=!1,J(o,"popstate",G,n),J(o,"hashchange",A,n),Y(m,M,n),Y(q,C,n),n.log("navigation capture unavailable: history methods are not writable",w),r=()=>{},$=()=>{},n=_(),k()}return{mode:"standard",disconnect:()=>{H=!1,r=()=>{},J(o,"popstate",G,n),J(o,"hashchange",A,n),Y(q,C,n),Y(m,M,n),$=()=>{},n=_()}}}function de(e,r){let n=e;for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return!("value"in o)||typeof o.value!="function"?null:{owner:n,key:r,descriptor:o};n=Object.getPrototypeOf(n)}return null}function ce(e,r){if(e.descriptor.writable!==!0)throw new TypeError(`${e.key} is not writable`);let n=Object.getOwnPropertyDescriptor(e.owner,e.key);if(!Z(n,e.descriptor))throw new Error(`${e.key} changed during installation`);Object.defineProperty(e.owner,e.key,{...e.descriptor,value:r})}function Y(e,r,n){V(e.owner,e.key,r,e.descriptor,n,`navigation ${e.key}`)}function J(e,r,n,o){try{e.removeEventListener(r,n)}catch(a){o.log(`navigation ${r} listener removal skipped`,a)}}var qe="1.2.0";export{_ as a,U as b,X as c,k as d,z as e,ve as f,we as g,qe as h};
@@ -1,4 +1,4 @@
1
- import { g as NetworkBodyProjectionContext, c as HttpRequestStarted, H as HttpExchange, d as NavigationEvent, m as WebAuthnCeremonyEvent } from './types-CXJAj2DU.mjs';
1
+ import { p as NetworkBodyProjectionContext, l as HttpRequestStarted, H as HttpExchange, m as NavigationEvent, v as WebAuthnCeremonyEvent } from './types-lamU1Fd3.mjs';
2
2
 
3
3
  /** Capture depth of a surface. `values` applies the redaction rules; anything no rule names becomes its class. */
4
4
  type ProbeLevel = "off" | "inventory" | "shape" | "values";
@@ -1,4 +1,4 @@
1
- import { g as NetworkBodyProjectionContext, c as HttpRequestStarted, H as HttpExchange, d as NavigationEvent, m as WebAuthnCeremonyEvent } from './types-CXJAj2DU.js';
1
+ import { p as NetworkBodyProjectionContext, l as HttpRequestStarted, H as HttpExchange, m as NavigationEvent, v as WebAuthnCeremonyEvent } from './types-lamU1Fd3.js';
2
2
 
3
3
  /** Capture depth of a surface. `values` applies the redaction rules; anything no rule names becomes its class. */
4
4
  type ProbeLevel = "off" | "inventory" | "shape" | "values";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WebAuthnCaptureOptions, a as WebAuthnCaptureHandle, N as NetworkCaptureOptions, C as CaptureHandle, b as NavigationCaptureOptions } from './types-CXJAj2DU.mjs';
2
- export { H as HttpExchange, c as HttpRequestStarted, L as Logger, d as NavigationEvent, e as NavigationSource, f as NetworkBodyDirection, g as NetworkBodyProjectionContext, h as NetworkBodyProjector, i as NetworkTransport, j as WebAuthnAttachSurface, k as WebAuthnCeremonyCompletedEvent, l as WebAuthnCeremonyContext, m as WebAuthnCeremonyEvent, n as WebAuthnCeremonyFailedEvent, o as WebAuthnCeremonyStartedEvent, p as WebAuthnMediation, q as WebAuthnUiMode } from './types-CXJAj2DU.mjs';
1
+ import { W as WebAuthnCaptureOptions, a as WebAuthnCaptureHandle, F as FederatedIdentityCaptureOptions, b as FederatedIdentityCaptureHandle, N as NetworkCaptureOptions, C as CaptureHandle, c as NavigationCaptureOptions } from './types-lamU1Fd3.mjs';
2
+ export { d as CredentialMediation, e as FederatedIdentityCompletedEvent, f as FederatedIdentityContext, g as FederatedIdentityEvent, h as FederatedIdentityFailedEvent, i as FederatedIdentityMode, j as FederatedIdentityProvider, k as FederatedIdentityStartedEvent, H as HttpExchange, l as HttpRequestStarted, L as Logger, m as NavigationEvent, n as NavigationSource, o as NetworkBodyDirection, p as NetworkBodyProjectionContext, q as NetworkBodyProjector, r as NetworkTransport, s as WebAuthnAttachSurface, t as WebAuthnCeremonyCompletedEvent, u as WebAuthnCeremonyContext, v as WebAuthnCeremonyEvent, w as WebAuthnCeremonyFailedEvent, x as WebAuthnCeremonyStartedEvent, y as WebAuthnMediation, z as WebAuthnUiMode } from './types-lamU1Fd3.mjs';
3
3
  export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions } from '@corbado/observe';
4
4
 
5
5
  /**
@@ -16,7 +16,8 @@ export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAsse
16
16
  * current environment — the API is missing, a capture is already active, or
17
17
  * another integration holds the credential methods in a form that cannot be
18
18
  * shared — nothing is modified and the returned handle reports
19
- * `mode: "unavailable"`.
19
+ * `mode: "unavailable"`. {@link captureFederatedIdentity} shares the same
20
+ * attachment; either capture can run and stop independently.
20
21
  *
21
22
  * Assumptions and limitations:
22
23
  *
@@ -38,6 +39,28 @@ export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAsse
38
39
  */
39
40
  declare function captureWebAuthn(options: WebAuthnCaptureOptions): WebAuthnCaptureHandle;
40
41
 
42
+ /**
43
+ * Observes FedCM requests made through `navigator.credentials.get({ identity })`, such as Google
44
+ * One Tap on Chromium.
45
+ *
46
+ * Each request emits a `started` event followed by a correlated `completed` (an account was
47
+ * chosen) or `failed` event. Calls without `identity` options are not reported. Tokens, nonces,
48
+ * provider parameters and login hints are never read into events. Observation never changes a
49
+ * request's arguments, result, or error; the request is delegated synchronously before anything is
50
+ * observed, so user activation reaches the browser unchanged.
51
+ *
52
+ * Shares one attachment to `navigator.credentials` with {@link captureWebAuthn}; either capture can
53
+ * start first and stop independently, and a later one joins at whatever surface the first attached
54
+ * to. `attach` applies only when this capture attaches first, as in {@link captureWebAuthn}. The
55
+ * handle reports `mode: "unavailable"` when the credential methods cannot be observed or a federated
56
+ * identity capture is already active.
57
+ *
58
+ * @param options Event callback and optional diagnostic logger.
59
+ * @returns A handle used to inspect the capture mode or stop event delivery.
60
+ * @throws TypeError when `onEvent` is not a function.
61
+ */
62
+ declare function captureFederatedIdentity(options: FederatedIdentityCaptureOptions): FederatedIdentityCaptureHandle;
63
+
41
64
  /**
42
65
  * Observes selected requests made through `XMLHttpRequest` and `fetch`.
43
66
  *
@@ -134,4 +157,4 @@ declare function isValidationMessageVisible(element: Element | null): boolean;
134
157
  */
135
158
  declare function captureInputValidation(options: InputValidationCaptureOptions): InputValidationCaptureHandle;
136
159
 
137
- export { CaptureHandle, type InputValidationCaptureHandle, type InputValidationCaptureOptions, type InputValidationError, type InputValidationState, NavigationCaptureOptions, NetworkCaptureOptions, VERSION, WebAuthnCaptureHandle, WebAuthnCaptureOptions, captureInputValidation, captureNavigation, captureNetwork, captureWebAuthn, composedPath, inputValidationCode, isValidationMessageVisible };
160
+ export { CaptureHandle, FederatedIdentityCaptureHandle, FederatedIdentityCaptureOptions, type InputValidationCaptureHandle, type InputValidationCaptureOptions, type InputValidationError, type InputValidationState, NavigationCaptureOptions, NetworkCaptureOptions, VERSION, WebAuthnCaptureHandle, WebAuthnCaptureOptions, captureFederatedIdentity, captureInputValidation, captureNavigation, captureNetwork, captureWebAuthn, composedPath, inputValidationCode, isValidationMessageVisible };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WebAuthnCaptureOptions, a as WebAuthnCaptureHandle, N as NetworkCaptureOptions, C as CaptureHandle, b as NavigationCaptureOptions } from './types-CXJAj2DU.js';
2
- export { H as HttpExchange, c as HttpRequestStarted, L as Logger, d as NavigationEvent, e as NavigationSource, f as NetworkBodyDirection, g as NetworkBodyProjectionContext, h as NetworkBodyProjector, i as NetworkTransport, j as WebAuthnAttachSurface, k as WebAuthnCeremonyCompletedEvent, l as WebAuthnCeremonyContext, m as WebAuthnCeremonyEvent, n as WebAuthnCeremonyFailedEvent, o as WebAuthnCeremonyStartedEvent, p as WebAuthnMediation, q as WebAuthnUiMode } from './types-CXJAj2DU.js';
1
+ import { W as WebAuthnCaptureOptions, a as WebAuthnCaptureHandle, F as FederatedIdentityCaptureOptions, b as FederatedIdentityCaptureHandle, N as NetworkCaptureOptions, C as CaptureHandle, c as NavigationCaptureOptions } from './types-lamU1Fd3.js';
2
+ export { d as CredentialMediation, e as FederatedIdentityCompletedEvent, f as FederatedIdentityContext, g as FederatedIdentityEvent, h as FederatedIdentityFailedEvent, i as FederatedIdentityMode, j as FederatedIdentityProvider, k as FederatedIdentityStartedEvent, H as HttpExchange, l as HttpRequestStarted, L as Logger, m as NavigationEvent, n as NavigationSource, o as NetworkBodyDirection, p as NetworkBodyProjectionContext, q as NetworkBodyProjector, r as NetworkTransport, s as WebAuthnAttachSurface, t as WebAuthnCeremonyCompletedEvent, u as WebAuthnCeremonyContext, v as WebAuthnCeremonyEvent, w as WebAuthnCeremonyFailedEvent, x as WebAuthnCeremonyStartedEvent, y as WebAuthnMediation, z as WebAuthnUiMode } from './types-lamU1Fd3.js';
3
3
  export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAssertionResponse, sanitizeCreationOptions, sanitizeCreationResponse, sanitizeRequestOptions } from '@corbado/observe';
4
4
 
5
5
  /**
@@ -16,7 +16,8 @@ export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAsse
16
16
  * current environment — the API is missing, a capture is already active, or
17
17
  * another integration holds the credential methods in a form that cannot be
18
18
  * shared — nothing is modified and the returned handle reports
19
- * `mode: "unavailable"`.
19
+ * `mode: "unavailable"`. {@link captureFederatedIdentity} shares the same
20
+ * attachment; either capture can run and stop independently.
20
21
  *
21
22
  * Assumptions and limitations:
22
23
  *
@@ -38,6 +39,28 @@ export { WebAuthnIdentifierProjector, WebAuthnIdentifierProjectors, sanitizeAsse
38
39
  */
39
40
  declare function captureWebAuthn(options: WebAuthnCaptureOptions): WebAuthnCaptureHandle;
40
41
 
42
+ /**
43
+ * Observes FedCM requests made through `navigator.credentials.get({ identity })`, such as Google
44
+ * One Tap on Chromium.
45
+ *
46
+ * Each request emits a `started` event followed by a correlated `completed` (an account was
47
+ * chosen) or `failed` event. Calls without `identity` options are not reported. Tokens, nonces,
48
+ * provider parameters and login hints are never read into events. Observation never changes a
49
+ * request's arguments, result, or error; the request is delegated synchronously before anything is
50
+ * observed, so user activation reaches the browser unchanged.
51
+ *
52
+ * Shares one attachment to `navigator.credentials` with {@link captureWebAuthn}; either capture can
53
+ * start first and stop independently, and a later one joins at whatever surface the first attached
54
+ * to. `attach` applies only when this capture attaches first, as in {@link captureWebAuthn}. The
55
+ * handle reports `mode: "unavailable"` when the credential methods cannot be observed or a federated
56
+ * identity capture is already active.
57
+ *
58
+ * @param options Event callback and optional diagnostic logger.
59
+ * @returns A handle used to inspect the capture mode or stop event delivery.
60
+ * @throws TypeError when `onEvent` is not a function.
61
+ */
62
+ declare function captureFederatedIdentity(options: FederatedIdentityCaptureOptions): FederatedIdentityCaptureHandle;
63
+
41
64
  /**
42
65
  * Observes selected requests made through `XMLHttpRequest` and `fetch`.
43
66
  *
@@ -134,4 +157,4 @@ declare function isValidationMessageVisible(element: Element | null): boolean;
134
157
  */
135
158
  declare function captureInputValidation(options: InputValidationCaptureOptions): InputValidationCaptureHandle;
136
159
 
137
- export { CaptureHandle, type InputValidationCaptureHandle, type InputValidationCaptureOptions, type InputValidationError, type InputValidationState, NavigationCaptureOptions, NetworkCaptureOptions, VERSION, WebAuthnCaptureHandle, WebAuthnCaptureOptions, captureInputValidation, captureNavigation, captureNetwork, captureWebAuthn, composedPath, inputValidationCode, isValidationMessageVisible };
160
+ export { CaptureHandle, FederatedIdentityCaptureHandle, FederatedIdentityCaptureOptions, type InputValidationCaptureHandle, type InputValidationCaptureOptions, type InputValidationError, type InputValidationState, NavigationCaptureOptions, NetworkCaptureOptions, VERSION, WebAuthnCaptureHandle, WebAuthnCaptureOptions, captureFederatedIdentity, captureInputValidation, captureNavigation, captureNetwork, captureWebAuthn, composedPath, inputValidationCode, isValidationMessageVisible };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var ne=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xe(t))!Ae.call(e,o)&&o!==n&&ne(e,o,{get:()=>t[o],enumerable:!(i=Oe(t,o))||i.enumerable});return e};var Ie=e=>Pe(ne({},"__esModule",{value:!0}),e);var Ve={};ke(Ve,{VERSION:()=>Re,captureInputValidation:()=>Ee,captureNavigation:()=>be,captureNetwork:()=>ge,captureWebAuthn:()=>ce,composedPath:()=>we,inputValidationCode:()=>ae,isValidationMessageVisible:()=>Ce,sanitizeAssertionResponse:()=>$.sanitizeAssertionResponse,sanitizeCreationOptions:()=>$.sanitizeCreationOptions,sanitizeCreationResponse:()=>$.sanitizeCreationResponse,sanitizeRequestOptions:()=>$.sanitizeRequestOptions});module.exports=Ie(Ve);var z=require("@corbado/observe");var Se={log:()=>{}};function F(e){return e?{log:(...t)=>{try{let n=e.log(...t);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:Se}var ue=Symbol.for("corbado.autocapture.installed");function _(e){try{return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,ue)}catch{return!1}}function K(e,t){var i,o;let n=t;try{Object.defineProperty(e,ue,{value:t,configurable:!0})}catch{}try{Object.defineProperty(e,"name",{value:(i=n.name)!=null?i:"",configurable:!0})}catch{}try{Object.defineProperty(e,"length",{value:(o=n.length)!=null?o:0,configurable:!0})}catch{}return e}function N(){return{mode:"unavailable",disconnect:()=>{}}}function re(e,t){return!!e&&"value"in e&&"value"in t&&e.value===t.value&&e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable}function G(e,t,n,i,o,y=String(t)){try{let f=Object.getOwnPropertyDescriptor(e,t);re(f,{...i,value:n})&&Object.defineProperty(e,t,i)}catch(f){o.log(`${y} restoration skipped`,f)}}function J(e,t,n){let i=F(e);return o=>{try{let y=n(o);if(y&&(typeof y=="object"||typeof y=="function"))try{Promise.resolve(y).catch(f=>i.log(`${t} listener failed`,f))}catch(f){i.log(`${t} listener failed`,f)}}catch(y){i.log(`${t} listener failed`,y)}}}var de=e=>({get:e("get"),create:e("create")});function ce(e){let t=e.onEvent;if(typeof t!="function")throw new TypeError("captureWebAuthn requires an onEvent callback");let n=F(e.logger),i=c=>(n.log(`webauthn capture unavailable: ${c}`),{...N(),surface:"none"}),o=typeof navigator=="undefined"?void 0:navigator,y=o==null?void 0:o.credentials;if(!o||!y)return i("navigator.credentials missing");let f=y,A=de(c=>f[c]);if(typeof A.get!="function"||typeof A.create!="function")return i("credentials methods missing");if(_(A.get)||_(A.create))return i("an equivalent capture is already active");let s=!1,B=0,O=J(n,"webauthn",t),k=(c,h,b)=>{let T={invoke(...d){let g=d[0];if(!s||b!=null&&b()||!oe(g)||!oe(g.publicKey))return h(this,d);let l=g.publicKey,u=`wa-${++B}`,q=h(this,d),x=oe(g.signal)?g.signal:void 0,r=Te(c,g,l),p=m=>{s&&O({...r,ceremonyId:u,...m()})},w=()=>(x==null?void 0:x.aborted)===!0?{aborted:!0}:{};return p(()=>({phase:"started",userActivation:Me(o),...r.kind==="authentication"?{requestOptionsJson:(0,z.sanitizeRequestOptions)(l)}:{creationOptionsJson:(0,z.sanitizeCreationOptions)(l,e.identifierProjectors)}})),Promise.resolve(q).then(m=>(p(()=>({phase:"completed",credentialJson:c==="create"?(0,z.sanitizeCreationResponse)(m,e.identifierProjectors):(0,z.sanitizeAssertionResponse)(m,e.identifierProjectors),...w()})),m),m=>{throw p(()=>({phase:"failed",error:m,errorName:De(m),...w()})),m})}}.invoke;return K(T,{name:c,length:0})},D=c=>{var T;let h=k(c,(d,g)=>Reflect.apply(A[c],d,g)),b=Object.getOwnPropertyDescriptor(y,c);if(b&&(!("value"in b)||b.writable!==!0))return null;try{f[c]=h}catch{return null}if(((T=Object.getOwnPropertyDescriptor(y,c))==null?void 0:T.value)!==h){try{f[c]=A[c]}catch{}return null}return()=>{f[c]===h&&(b?f[c]=b.value:delete f[c])}},L=()=>{let c=de(()=>new WeakMap),h=(l,u)=>{let q=c[l].get(u);if(q)return q;let x=k(l,(r,p)=>Reflect.apply(u,y,p),()=>{try{let r=f[l];return r!==u&&r!==x}catch(r){return n.log("suppress check failed; ceremony unreported",r),!0}});return c[l].set(u,x),x},b=l=>{let u=Object.getOwnPropertyDescriptor(y,l);return u?u.configurable===!0||!("value"in u)||u.writable===!0:!0},T=new WeakMap,d=new Proxy(y,{get(l,u){let q=Reflect.get(y,u,y);if((u==="get"||u==="create")&&b(u))return typeof q!="function"||_(q)?q:h(u,q);if(typeof q!="function"||!b(u)||u==="constructor")return q;let x=T.get(q);if(x)return x;let r=q.bind(y);return T.set(q,r),r},set(l,u,q){return Reflect.set(y,u,q,y)}}),g=Object.getOwnPropertyDescriptor(o,"credentials");if(g&&g.configurable!==!0)return null;try{Object.defineProperty(o,"credentials",{value:d,writable:!0,enumerable:!0,configurable:!0})}catch{return null}return o.credentials!==d?null:()=>{o.credentials===d&&(g?Object.defineProperty(o,"credentials",g):delete o.credentials)}},S=(c,h)=>(s=!0,{mode:"standard",surface:c,disconnect:()=>{s=!1,h()}}),P=D("get"),j=P?D("create"):null;if(P&&j)return S("methods",()=>{P(),j()});if(P==null||P(),e.attach==="container"){let c=L();if(c)return n.log("webauthn capture attached at the credentials container"),S("container",c)}return i("credentials methods cannot be patched safely")}function Te(e,t,n){let i=Le(t.mediation);if(e==="create")return{kind:"registration",mediation:i};let o=n;return{kind:"authentication",mediation:i,uiMode:Be(t.uiMode),credentialSet:Array.isArray(o.allowCredentials)&&o.allowCredentials.length>0?"allowlisted":"discoverable"}}function Le(e){return e===void 0?"optional":e==="silent"||e==="optional"||e==="conditional"||e==="required"?e:"unknown"}function Be(e){return e===void 0?"default":e==="immediate"?"immediate":"unknown"}function Me(e){let t=e.userActivation;return typeof(t==null?void 0:t.isActive)=="boolean"?t.isActive:void 0}function oe(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function De(e){return e instanceof DOMException?e.name:"UnknownError"}var le=0;function pe(){return le+=1,`network-${le}`}function Ne(e,t){let n=e.responseType;if(n===""||n==="text")return t(e.responseText);if(n==="json"){let i=e.response;return i==null?void 0:t(i)}}var He=500,fe=Symbol("body-read-timeout");function he(e){return/event-stream|octet-stream/i.test(e)?!1:/json|text|urlencoded/i.test(e)}async function ye(e,t){let n=e.body;if(!n)return;let i=n.getReader(),o;try{let y=new Promise(s=>{o=setTimeout(()=>s(fe),He)}),f=new TextDecoder,A=[];for(;;){let s=await Promise.race([i.read(),y]);if(s===fe){t.log("body omitted: read timed out"),i.cancel().catch(()=>{});return}if(s.done)break;A.push(f.decode(s.value,{stream:!0}))}return A.push(f.decode()),A.join("")}catch{i.cancel().catch(()=>{});return}finally{o!==void 0&&clearTimeout(o)}}function ie(e){var t;(t=e==null?void 0:e.body)==null||t.cancel().catch(()=>{})}function ge(e){var h,b,T;let{onExchange:t,onRequest:n,match:i}=e;if(typeof t!="function"||typeof i!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let o=F(e.logger),y=(h=e.transports)!=null?h:["xhr","fetch"],f=(b=e.bodyCapture)==null?void 0:b.request,A=(T=e.bodyCapture)==null?void 0:T.response,s=typeof f=="function",B=typeof A=="function",O=!1,k=J(o,"network",d=>{if(O)return t(d)}),D=J(o,"network request",d=>{if(O)return n==null?void 0:n(d)}),L=(d,g,l)=>{if(typeof l=="function")try{return l(d,g)}catch(u){o.log("body projection failed",u);return}},S=(d,g)=>{try{let l=typeof document!="undefined"?document.baseURI:void 0,u=new URL(String(d),l);return i(u,g)===!0?{url:u.href,path:u.pathname}:void 0}catch{return}},P=()=>{if(typeof XMLHttpRequest=="undefined")return o.log("xhr capture unavailable: XMLHttpRequest missing"),null;let d=XMLHttpRequest.prototype,g=Object.getOwnPropertyDescriptor(d,"open"),l=Object.getOwnPropertyDescriptor(d,"send");if(!g||!("value"in g)||typeof g.value!="function"||!l||!("value"in l)||typeof l.value!="function")return o.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let u=g.value,q=l.value;if(_(u)||_(q))return o.log("xhr capture unavailable: an equivalent capture is already active"),null;let x=new WeakMap,r=new Set,p=!1,w={open(...R){var C;let a=Reflect.apply(u,this,R);if(!O||!p)return a;try{let M=x.get(this);M&&(M.reported=!0,(C=M.cleanupListeners)==null||C.call(M));let H=String(R[0]).toUpperCase(),I=S(R[1],H);I?x.set(this,{method:H,url:I.url,path:I.path,reported:!1}):x.delete(this)}catch(M){o.log("xhr open observation failed",M)}return a}}.open,m={send(...R){let a=O&&p?x.get(this):void 0;if(!a||a.reported||a.cleanupListeners)return Reflect.apply(q,this,R);let C=()=>{},M=!1;try{a.requestId=pe();let I={direction:"request",transport:"xhr",method:a.method,url:a.url,path:a.path};a.requestBody=s&&typeof R[0]=="string"?L(R[0],I,f):void 0;let Y=()=>{a.outcome===void 0&&(a.outcome="abort")},Q=()=>{a.outcome===void 0&&(a.outcome="timeout")},v=()=>{a.outcome===void 0&&(a.outcome="error")},E=()=>{var X;C();try{if(!O||!p||a.reported||!a.requestId)return;a.reported=!0;let W={direction:"response",transport:"xhr",method:a.method,url:a.url,path:a.path},te=this.status,se={requestId:a.requestId,transport:"xhr",method:a.method,url:a.url,path:a.path,status:te,ok:te>=200&&te<300,outcome:(X=a.outcome)!=null?X:"load",durationMs:a.startedAt!==void 0?Date.now()-a.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:a.requestBody,responseBody:B?Ne(this,qe=>L(qe,W,A)):void 0};a.requestEmitted?k(se):a.pendingExchange=se}catch(W){o.log("xhr exchange observation failed",W)}finally{x.get(this)===a&&x.delete(this)}},V=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&E()}catch(X){o.log("xhr ready-state observation failed",X)}},U=()=>E();C=()=>{for(let[X,W]of[["readystatechange",V],["abort",Y],["timeout",Q],["error",v],["loadend",U]])this.removeEventListener(X,W);a.cleanupListeners===C&&(a.cleanupListeners=void 0),r.delete(C)},this.addEventListener("readystatechange",V),this.addEventListener("abort",Y),this.addEventListener("timeout",Q),this.addEventListener("error",v),this.addEventListener("loadend",U),a.cleanupListeners=C,r.add(C),a.startedAt=Date.now(),M=!0}catch(I){o.log("xhr send observation failed",I),C()}let H;try{H=Reflect.apply(q,this,R)}catch(I){throw C(),I}if(M&&a.requestId!==void 0&&a.startedAt!==void 0){a.requestEmitted=!0,D({requestId:a.requestId,transport:"xhr",method:a.method,url:a.url,path:a.path,startedAt:a.startedAt,requestBody:a.requestBody});let I=a.pendingExchange;a.pendingExchange=void 0,I&&k(I)}return H}}.send;return K(w,u),K(m,q),g.writable!==!0||l.writable!==!0?(o.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(d,"open",{...g,value:w}),Object.defineProperty(d,"send",{...l,value:m}),p=!0,()=>{p=!1;for(let R of[...r])R();G(d,"open",w,g,o),G(d,"send",m,l,o)})},j=()=>{let d=globalThis,g=Object.getOwnPropertyDescriptor(d,"fetch");if(!g||!("value"in g))return o.log("fetch capture unavailable: fetch is not an own data property"),null;let l=g.value;if(typeof l!="function")return o.log("fetch capture unavailable: fetch missing"),null;if(_(l))return o.log("fetch capture unavailable: an equivalent capture is already active"),null;let u=!1,q=async(r,p,w,m)=>{try{if(!O||!u){ie(w);return}let[R,a]=await Promise.all([m!=null?m:Promise.resolve(void 0),w?ye(w,o):Promise.resolve(void 0)]);if(!O||!u)return;let C={direction:"request",transport:"fetch",method:r.method,url:r.url,path:r.path},M={...C,direction:"response"},H=r.requestBody;H===void 0&&R!==void 0&&(H=L(R,C,f));let I=a!==void 0?L(a,M,A):void 0;k({requestId:r.requestId,transport:"fetch",method:r.method,url:r.url,path:r.path,status:p.status,ok:p.ok,outcome:"load",durationMs:Date.now()-r.startedAt,responseUrl:p.url||void 0,requestBody:H,responseBody:I})}catch(R){o.log("fetch exchange observation failed",R)}},x={fetch(...r){var H,I,Y,Q;let p;try{let v=r[0],E=r[1];if(O&&u&&s&&typeof Request!="undefined"&&v instanceof Request&&(E==null?void 0:E.body)===void 0&&v.body){let V=String((H=E==null?void 0:E.method)!=null?H:v.method).toUpperCase(),U=(I=v.headers.get("content-type"))!=null?I:"";S(v.url,V)&&he(U)&&(p=v.clone())}}catch(v){o.log("fetch observation failed",v)}let w,m=Date.now();try{w=Reflect.apply(l,this,r)}catch(v){throw ie(p),v}let R,a;try{if(O&&u){let v=r[0],E=r[1],V=typeof Request!="undefined"&&v instanceof Request,U=String((Y=E==null?void 0:E.method)!=null?Y:V?v.method:"GET").toUpperCase(),X=V?v.url:v,W=S(X,U);W&&(R={requestId:pe(),method:U,url:W.url,path:W.path,startedAt:m},a=(Q=E==null?void 0:E.signal)!=null?Q:V?v.signal:void 0,s&&typeof(E==null?void 0:E.body)=="string"&&(R.requestBody=L(E.body,{direction:"request",transport:"fetch",method:U,url:W.url,path:W.path},f)))}}catch(v){o.log("fetch observation failed",v)}if(!R)return ie(p),w;let C=R;D({requestId:C.requestId,transport:"fetch",method:C.method,url:C.url,path:C.path,startedAt:C.startedAt,requestBody:C.requestBody});let M=p?ye(p,o):void 0;return w.then(v=>{var V;let E;try{if(O&&u&&B){let U=(V=v.headers.get("content-type"))!=null?V:"";he(U)&&v.body&&(E=v.clone())}}catch{}q(C,v,E,M)},v=>{try{if(!O||!u)return;let E=(a==null?void 0:a.aborted)===!0||(v==null?void 0:v.name)==="AbortError"||typeof DOMException!="undefined"&&v instanceof DOMException&&v.code===DOMException.ABORT_ERR;k({requestId:C.requestId,transport:"fetch",method:C.method,url:C.url,path:C.path,status:0,ok:!1,outcome:E?"abort":"error",durationMs:Date.now()-C.startedAt})}catch(E){o.log("fetch failure observation failed",E)}}),w}}.fetch;return K(x,l),g.writable!==!0?(o.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(d,"fetch",{...g,value:x}),u=!0,()=>{u=!1,G(d,"fetch",x,g,o)})},c=[];if(y.includes("xhr")){let d=P();d&&c.push(d)}if(y.includes("fetch")){let d=j();d&&c.push(d)}return c.length===0?N():(O=!0,{mode:"standard",disconnect:()=>{O=!1;for(let d of c.splice(0))d()}})}function be(e){let t=e.onNavigate;if(typeof t!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=F(e.logger),i,o,y,f,A,s;try{if(i=window,o=i==null?void 0:i.history,!i||!o)return n.log("navigation capture unavailable: window/history missing"),N();if(A=me(o,"pushState"),s=me(o,"replaceState"),!A||!s)return n.log("navigation capture unavailable: history method descriptors missing"),N();if(y=A.descriptor.value,f=s.descriptor.value,typeof y!="function"||typeof f!="function")return n.log("navigation capture unavailable: history methods missing"),N();if(typeof i.addEventListener!="function"||typeof i.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),N()}catch(h){return n.log("navigation capture unavailable: history inspection failed",h),N()}if(_(y)||_(f))return n.log("navigation capture unavailable: an equivalent capture is already active"),N();let B=!1,O=()=>({path:i.location.pathname,search:i.location.search,hash:i.location.hash}),k;try{k=O()}catch(h){return n.log("navigation capture unavailable: location inspection failed",h),N()}let D=J(n,"navigation",h=>{if(B)return t(h)}),L=h=>{if(B)try{let b=O();if(b.path===k.path&&b.search===k.search&&b.hash===k.hash)return;k=b,D({...b,source:h})}catch(b){n.log("navigation observation failed",b)}},S={pushState(...h){let b=Reflect.apply(y,this,h);return L("push"),b}}.pushState,P={replaceState(...h){let b=Reflect.apply(f,this,h);return L("replace"),b}}.replaceState;K(S,y),K(P,f);let j=()=>L("pop"),c=()=>L("hash");try{if(ve(A,S),ve(s,P),o.pushState!==S||o.replaceState!==P)throw new Error("history method replacement did not take effect");i.addEventListener("popstate",j),i.addEventListener("hashchange",c),B=!0}catch(h){return B=!1,ee(i,"popstate",j,n),ee(i,"hashchange",c,n),Z(s,P,n),Z(A,S,n),n.log("navigation capture unavailable: history methods are not writable",h),t=()=>{},D=()=>{},n=F(),N()}return{mode:"standard",disconnect:()=>{B=!1,t=()=>{},ee(i,"popstate",j,n),ee(i,"hashchange",c,n),Z(A,S,n),Z(s,P,n),D=()=>{},n=F()}}}function me(e,t){let n=e;for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return!("value"in i)||typeof i.value!="function"?null:{owner:n,key:t,descriptor:i};n=Object.getPrototypeOf(n)}return null}function ve(e,t){if(e.descriptor.writable!==!0)throw new TypeError(`${e.key} is not writable`);let n=Object.getOwnPropertyDescriptor(e.owner,e.key);if(!re(n,e.descriptor))throw new Error(`${e.key} changed during installation`);Object.defineProperty(e.owner,e.key,{...e.descriptor,value:t})}function Z(e,t,n){G(e.owner,e.key,t,e.descriptor,n,`navigation ${e.key}`)}function ee(e,t,n,i){try{e.removeEventListener(t,n)}catch(o){i.log(`navigation ${t} listener removal skipped`,o)}}function we(e){let t=e.composedPath();return t.length>0?t:e.target?[e.target]:[]}var Re="1.1.0";var je=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"];function ae(e){return je.find(t=>e.validity[t])}function Ce(e){if(!(e!=null&&e.isConnected)||!e.getClientRects().length)return!1;let t=e.ownerDocument.defaultView;if(!t)return!1;for(let n=e;n;n=n.parentElement){let i=t.getComputedStyle(n);if(n.hasAttribute("hidden")||i.display==="none"||i.visibility==="hidden"||i.visibility==="collapse"||i.opacity==="0")return!1}return!0}function Ee(e){var q,x;if(typeof e.readValidation!="function"||typeof e.onError!="function")throw new TypeError("captureInputValidation requires readValidation and onError callbacks");let{form:t}=e,n=[...e.fields],i=(q=e.maxObservationMs)!=null?q:1e4;if(!n.length||!Number.isFinite(i)||i<=0)throw new TypeError("captureInputValidation requires fields and a positive maxObservationMs");let o={mode:"unavailable",disconnect(){},beginAttempt:()=>{},requestStarted(){},refresh(){}},y=(x=t==null?void 0:t.ownerDocument)==null?void 0:x.defaultView;if(!y||!n.every(r=>r.form===t))return o;let f=!0,A=0,s,B=!1,O,k,D,L,S=[],P=()=>t.isConnected&&n.every(r=>r.isConnected&&r.form===t),j=()=>{try{let r=e.readValidation();if(r&&["clear","pending","unknown"].includes(r.status)||(r==null?void 0:r.status)==="invalid"&&typeof r.code=="string"&&["constraint","application"].includes(r.source))return r}catch{}return{status:"unknown"}},c=r=>r.status==="invalid"?JSON.stringify([r.code,r.fieldIndex]):void 0,h=()=>{s=void 0,clearTimeout(k),clearTimeout(D),k=D=void 0},b=()=>{k=void 0;let r=s;if(!f||!(r!=null&&r.confirmed))return;if(!P()){h();return}let p=r.nativeInvalid?(()=>{for(let[m,R]of n.entries()){let a=ae(R);if(a)return{status:"invalid",source:"constraint",code:a,fieldIndex:m}}return{status:"clear"}})():j();if(p.status==="clear"){r.serverBaseline=void 0;return}if(p.status!=="invalid"||p.source==="application"&&r.serverBaseline===c(p))return;let w={attemptId:r.id,startedAt:r.startedAt,timestamp:Date.now(),code:p.code,...p.fieldIndex===void 0?{}:{fieldIndex:p.fieldIndex}};h(),B=!1;try{Promise.resolve(e.onError(w)).catch(()=>{})}catch{}},T=()=>{!f||!s||k!==void 0||(k=setTimeout(b,0))},d=r=>{if(!f||!P())return;h();let p=B?c(j()):void 0;return s={id:++A,startedAt:Date.now(),confirmed:r,nativeInvalid:!1,serverBaseline:p},D=setTimeout(h,i),T(),s.id},g=()=>{O===void 0&&(O=d(!1),L=setTimeout(()=>{s&&s.id===O&&!s.confirmed&&h(),O=void 0},0))},l=(r,p,w)=>{r.addEventListener(p,w,!0),S.push(()=>r.removeEventListener(p,w,!0))},u={mode:"standard",beginAttempt:()=>d(!0),refresh:T,requestStarted(r={}){f&&(r.attemptId!==void 0&&r.attemptId!==(s==null?void 0:s.id)||s&&r.timestamp!==void 0&&r.timestamp<s.startedAt||(h(),B=!0))},disconnect(){if(f){f=!1,h(),clearTimeout(L);for(let r of S.splice(0))r()}}};try{let r=w=>{var a;let m=w.target,R=(a=m==null?void 0:m.closest)==null?void 0:a.call(m,"button,input");(R==null?void 0:R.form)===t&&!R.disabled&&["submit","image"].includes(R.type)&&g()};l(t.ownerDocument,"click",r),l(t,"click",r),l(t,"keydown",w=>{let m=w;m.key==="Enter"&&!m.isComposing&&!m.defaultPrevented&&n.includes(m.target)&&g()}),l(t,"submit",()=>{(s==null?void 0:s.id)===O&&s?(s.confirmed=!0,T()):d(!0),O=void 0}),l(t,"invalid",w=>{!s||!n.includes(w.target)||(s.confirmed=!0,s.nativeInvalid=!0,T())}),l(t,"input",w=>{n.includes(w.target)&&h()});let p=new y.MutationObserver(T);p.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),S.push(()=>p.disconnect())}catch{return u.disconnect(),o}return u}var $=require("@corbado/observe");0&&(module.exports={VERSION,captureInputValidation,captureNavigation,captureNetwork,captureWebAuthn,composedPath,inputValidationCode,isValidationMessageVisible,sanitizeAssertionResponse,sanitizeCreationOptions,sanitizeCreationResponse,sanitizeRequestOptions});
1
+ "use strict";var ue=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var n in t)ue(e,n,{get:t[n],enumerable:!0})},Ne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Le(t))!Me.call(e,o)&&o!==n&&ue(e,o,{get:()=>t[o],enumerable:!(r=Te(t,o))||r.enumerable});return e};var He=e=>Ne(ue({},"__esModule",{value:!0}),e);var Je={};Be(Je,{VERSION:()=>qe,captureFederatedIdentity:()=>me,captureInputValidation:()=>Se,captureNavigation:()=>ke,captureNetwork:()=>Ee,captureWebAuthn:()=>ge,composedPath:()=>Ae,inputValidationCode:()=>le,isValidationMessageVisible:()=>Oe,sanitizeAssertionResponse:()=>G.sanitizeAssertionResponse,sanitizeCreationOptions:()=>G.sanitizeCreationOptions,sanitizeCreationResponse:()=>G.sanitizeCreationResponse,sanitizeRequestOptions:()=>G.sanitizeRequestOptions});module.exports=He(Je);var J=require("@corbado/observe");var De={log:()=>{}};function W(e){return e?{log:(...t)=>{try{let n=e.log(...t);if(n&&(typeof n=="object"||typeof n=="function"))try{Promise.resolve(n).catch(()=>{})}catch{}}catch{}}}:De}var fe=Symbol.for("corbado.autocapture.installed");function U(e){try{return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,fe)}catch{return!1}}function K(e,t){var r,o;let n=t;try{Object.defineProperty(e,fe,{value:t,configurable:!0})}catch{}try{Object.defineProperty(e,"name",{value:(r=n.name)!=null?r:"",configurable:!0})}catch{}try{Object.defineProperty(e,"length",{value:(o=n.length)!=null?o:0,configurable:!0})}catch{}return e}function B(){return{mode:"unavailable",disconnect:()=>{}}}function de(e,t){return!!e&&"value"in e&&"value"in t&&e.value===t.value&&e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable}function Y(e,t,n,r,o,y=String(t)){try{let l=Object.getOwnPropertyDescriptor(e,t);de(l,{...r,value:n})&&Object.defineProperty(e,t,r)}catch(l){o.log(`${y} restoration skipped`,l)}}function z(e,t,n){let r=W(e);return o=>{try{let y=n(o);if(y&&(typeof y=="object"||typeof y=="function"))try{Promise.resolve(y).catch(l=>r.log(`${t} listener failed`,l))}catch(l){r.log(`${t} listener failed`,l)}}catch(y){r.log(`${t} listener failed`,y)}}}var he=e=>({get:e("get"),create:e("create")}),Q;function te(e){if(Q)return[...Q.subscribers].some(n=>n.channel===e.channel)?{attached:!1,reason:"an equivalent capture is already active"}:ye(Q,e);let t=je(e);return typeof t=="string"?{attached:!1,reason:t}:(Q=t,ye(t,e))}function ye(e,t){e.subscribers.add(t);let n=!0;return{attached:!0,surface:e.surface,unsubscribe:()=>{n&&(n=!1,e.subscribers.delete(t),!(e.subscribers.size>0)&&(e.active=!1,e.detach(),Q===e&&(Q=void 0)))}}}function je(e){let t=typeof navigator=="undefined"?void 0:navigator,n=t==null?void 0:t.credentials;if(!t||!n)return"navigator.credentials missing";let r=n,o=he(d=>r[d]);if(typeof o.get!="function"||typeof o.create!="function")return"credentials methods missing";if(U(o.get)||U(o.create))return"an equivalent capture is already active";let y={surface:"methods",subscribers:new Set,active:!1,detach:()=>{}},l=(...d)=>y.subscribers.forEach(f=>f.logger.log(...d)),A=(d,f,g)=>{let b={invoke(...P){let h=P[0];if(!y.active||g!=null&&g()||!$(h))return f(this,P);let E=f(this,P),v=[];for(let p of[...y.subscribers])try{let c=p.onCall(d,h);c&&v.push([p,c])}catch(c){p.logger.log("credentials observation failed",c)}if(v.length===0)return E;let s=p=>{for(let[c,O]of v)try{p(O)}catch(j){c.logger.log("credentials observation failed",j)}};return Promise.resolve(E).then(p=>(s(c=>c.completed(p)),p),p=>{throw s(c=>c.failed(p)),p})}}.invoke;return K(b,{name:d,length:0})},u=d=>{var b;let f=A(d,(P,h)=>Reflect.apply(o[d],P,h)),g=Object.getOwnPropertyDescriptor(n,d);if(g&&(!("value"in g)||g.writable!==!0))return null;try{r[d]=f}catch{return null}if(((b=Object.getOwnPropertyDescriptor(n,d))==null?void 0:b.value)!==f){try{r[d]=o[d]}catch{}return null}return()=>{r[d]===f&&(g?r[d]=g.value:delete r[d])}},q=()=>{let d=he(()=>new WeakMap),f=(E,v)=>{let s=d[E].get(v);if(s)return s;let p=A(E,(c,O)=>Reflect.apply(v,n,O),()=>{try{let c=r[E];return c!==v&&c!==p}catch(c){return l("suppress check failed; ceremony unreported",c),!0}});return d[E].set(v,p),p},g=E=>{let v=Object.getOwnPropertyDescriptor(n,E);return v?v.configurable===!0||!("value"in v)||v.writable===!0:!0},b=new WeakMap,P=new Proxy(n,{get(E,v){let s=Reflect.get(n,v,n);if((v==="get"||v==="create")&&g(v))return typeof s!="function"||U(s)?s:f(v,s);if(typeof s!="function"||!g(v)||v==="constructor")return s;let p=b.get(s);if(p)return p;let c=s.bind(n);return b.set(s,c),c},set(E,v,s){return Reflect.set(n,v,s,n)}}),h=Object.getOwnPropertyDescriptor(t,"credentials");if(h&&h.configurable!==!0)return null;try{Object.defineProperty(t,"credentials",{value:P,writable:!0,enumerable:!0,configurable:!0})}catch{return null}return t.credentials!==P?null:()=>{t.credentials===P&&(h?Object.defineProperty(t,"credentials",h):delete t.credentials)}},m=(d,f)=>(y.surface=d,y.detach=f,y.active=!0,y),R=u("get"),L=R?u("create"):null;if(R&&L)return m("methods",()=>{R(),L()});if(R==null||R(),e.attach==="container"){let d=q();if(d)return m("container",d)}return"credentials methods cannot be patched safely"}function $(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function ne(){let e=navigator.userActivation;return typeof(e==null?void 0:e.isActive)=="boolean"?e.isActive:void 0}function re(e){return e===void 0?"optional":e==="silent"||e==="optional"||e==="conditional"||e==="required"?e:"unknown"}function oe(e){return e instanceof DOMException?e.name:"UnknownError"}function ge(e){var A;let t=e.onEvent;if(typeof t!="function")throw new TypeError("captureWebAuthn requires an onEvent callback");let n=W(e.logger),r=!0,o=0,y=z(n,"webauthn",t),l=te({channel:"webauthn",attach:(A=e.attach)!=null?A:"methods",logger:n,onCall(u,q){if(!r||!$(q.publicKey))return;let m=q.publicKey,R=`wa-${++o}`,L=$(q.signal)?q.signal:void 0,d=Fe(u,q,m),f=b=>{r&&y({...d,ceremonyId:R,...b()})},g=()=>(L==null?void 0:L.aborted)===!0?{aborted:!0}:{};return f(()=>({phase:"started",userActivation:ne(),...d.kind==="authentication"?{requestOptionsJson:(0,J.sanitizeRequestOptions)(m)}:{creationOptionsJson:(0,J.sanitizeCreationOptions)(m,e.identifierProjectors)}})),{completed:b=>f(()=>({phase:"completed",credentialJson:u==="create"?(0,J.sanitizeCreationResponse)(b,e.identifierProjectors):(0,J.sanitizeAssertionResponse)(b,e.identifierProjectors),...g()})),failed:b=>f(()=>({phase:"failed",error:b,errorName:oe(b),...g()}))}}});return l.attached?(l.surface==="container"&&n.log("webauthn capture attached at the credentials container"),{mode:"standard",surface:l.surface,disconnect:()=>{r=!1,l.unsubscribe()}}):(n.log(`webauthn capture unavailable: ${l.reason}`),{...B(),surface:"none"})}function Fe(e,t,n){let r=re(t.mediation);if(e==="create")return{kind:"registration",mediation:r};let o=n;return{kind:"authentication",mediation:r,uiMode:Ve(t.uiMode),credentialSet:Array.isArray(o.allowCredentials)&&o.allowCredentials.length>0?"allowlisted":"discoverable"}}function Ve(e){return e===void 0?"default":e==="immediate"?"immediate":"unknown"}function me(e){var A;let t=e.onEvent;if(typeof t!="function")throw new TypeError("captureFederatedIdentity requires an onEvent callback");let n=W(e.logger),r=!0,o=0,y=z(n,"federated identity",t),l=te({channel:"federated-identity",attach:(A=e.attach)!=null?A:"methods",logger:n,onCall(u,q){let m=q.identity;if(!r||u!=="get"||!$(m))return;let R=`fi-${++o}`,L=$(q.signal)?q.signal:void 0,d=m,f=g=>{r&&y(g)};return f({phase:"started",requestId:R,providers:We(d.providers),context:Ue(d.context),mode:_e(d.mode),mediation:re(q.mediation),userActivation:ne()}),{completed:g=>{if(g===null){f({phase:"failed",requestId:R,errorName:"NoCredential"});return}let b=g;f({phase:"completed",requestId:R,...typeof b.configURL=="string"?{configURL:b.configURL}:{},...typeof b.isAutoSelected=="boolean"?{isAutoSelected:b.isAutoSelected}:{}})},failed:g=>{let b=oe(g),P=b==="IdentityCredentialError"?Ke(g):void 0;f({phase:"failed",requestId:R,errorName:b,...P!==void 0?{code:P}:{},...(L==null?void 0:L.aborted)===!0?{aborted:!0}:{}})}}}});return l.attached?{mode:"standard",surface:l.surface,disconnect:()=>{r=!1,l.unsubscribe()}}:(n.log(`federated identity capture unavailable: ${l.reason}`),{...B(),surface:"none"})}function We(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!$(n))continue;let{configURL:r,clientId:o}=n;typeof r=="string"&&t.push(typeof o=="string"?{configURL:r,clientId:o}:{configURL:r})}return t}function Ue(e){return e===void 0?"signin":e==="signin"||e==="signup"||e==="use"||e==="continue"?e:"unknown"}function _e(e){return e===void 0?"passive":e==="passive"||e==="active"?e:"unknown"}function Ke(e){let{error:t,code:n}=e;return typeof t=="string"&&t!==""?t:typeof n=="string"&&n!==""?n:void 0}var be=0;function ve(){return be+=1,`network-${be}`}function ze(e,t){let n=e.responseType;if(n===""||n==="text")return t(e.responseText);if(n==="json"){let r=e.response;return r==null?void 0:t(r)}}var Xe=500,we=Symbol("body-read-timeout");function Ce(e){return/event-stream|octet-stream/i.test(e)?!1:/json|text|urlencoded/i.test(e)}async function Re(e,t){let n=e.body;if(!n)return;let r=n.getReader(),o;try{let y=new Promise(u=>{o=setTimeout(()=>u(we),Xe)}),l=new TextDecoder,A=[];for(;;){let u=await Promise.race([r.read(),y]);if(u===we){t.log("body omitted: read timed out"),r.cancel().catch(()=>{});return}if(u.done)break;A.push(l.decode(u.value,{stream:!0}))}return A.push(l.decode()),A.join("")}catch{r.cancel().catch(()=>{});return}finally{o!==void 0&&clearTimeout(o)}}function ce(e){var t;(t=e==null?void 0:e.body)==null||t.cancel().catch(()=>{})}function Ee(e){var h,E,v;let{onExchange:t,onRequest:n,match:r}=e;if(typeof t!="function"||typeof r!="function")throw new TypeError("captureNetwork requires onExchange and match callbacks");let o=W(e.logger),y=(h=e.transports)!=null?h:["xhr","fetch"],l=(E=e.bodyCapture)==null?void 0:E.request,A=(v=e.bodyCapture)==null?void 0:v.response,u=typeof l=="function",q=typeof A=="function",m=!1,R=z(o,"network",s=>{if(m)return t(s)}),L=z(o,"network request",s=>{if(m)return n==null?void 0:n(s)}),d=(s,p,c)=>{if(typeof c=="function")try{return c(s,p)}catch(O){o.log("body projection failed",O);return}},f=(s,p)=>{try{let c=typeof document!="undefined"?document.baseURI:void 0,O=new URL(String(s),c);return r(O,p)===!0?{url:O.href,path:O.pathname}:void 0}catch{return}},g=()=>{if(typeof XMLHttpRequest=="undefined")return o.log("xhr capture unavailable: XMLHttpRequest missing"),null;let s=XMLHttpRequest.prototype,p=Object.getOwnPropertyDescriptor(s,"open"),c=Object.getOwnPropertyDescriptor(s,"send");if(!p||!("value"in p)||typeof p.value!="function"||!c||!("value"in c)||typeof c.value!="function")return o.log("xhr capture unavailable: XMLHttpRequest methods missing"),null;let O=p.value,j=c.value;if(U(O)||U(j))return o.log("xhr capture unavailable: an equivalent capture is already active"),null;let H=new WeakMap,a=new Set,C=!1,S={open(...x){var I;let i=Reflect.apply(O,this,x);if(!m||!C)return i;try{let N=H.get(this);N&&(N.reported=!0,(I=N.cleanupListeners)==null||I.call(N));let D=String(x[0]).toUpperCase(),M=f(x[1],D);M?H.set(this,{method:D,url:M.url,path:M.path,reported:!1}):H.delete(this)}catch(N){o.log("xhr open observation failed",N)}return i}}.open,T={send(...x){let i=m&&C?H.get(this):void 0;if(!i||i.reported||i.cleanupListeners)return Reflect.apply(j,this,x);let I=()=>{},N=!1;try{i.requestId=ve();let M={direction:"request",transport:"xhr",method:i.method,url:i.url,path:i.path};i.requestBody=u&&typeof x[0]=="string"?d(x[0],M,l):void 0;let Z=()=>{i.outcome===void 0&&(i.outcome="abort")},ee=()=>{i.outcome===void 0&&(i.outcome="timeout")},w=()=>{i.outcome===void 0&&(i.outcome="error")},k=()=>{var X;I();try{if(!m||!C||i.reported||!i.requestId)return;i.reported=!0;let V={direction:"response",transport:"xhr",method:i.method,url:i.url,path:i.path},se=this.status,pe={requestId:i.requestId,transport:"xhr",method:i.method,url:i.url,path:i.path,status:se,ok:se>=200&&se<300,outcome:(X=i.outcome)!=null?X:"load",durationMs:i.startedAt!==void 0?Date.now()-i.startedAt:void 0,responseUrl:this.responseURL||void 0,requestBody:i.requestBody,responseBody:q?ze(this,Pe=>d(Pe,V,A)):void 0};i.requestEmitted?R(pe):i.pendingExchange=pe}catch(V){o.log("xhr exchange observation failed",V)}finally{H.get(this)===i&&H.delete(this)}},F=()=>{try{this.readyState===XMLHttpRequest.DONE&&this.status!==0&&k()}catch(X){o.log("xhr ready-state observation failed",X)}},_=()=>k();I=()=>{for(let[X,V]of[["readystatechange",F],["abort",Z],["timeout",ee],["error",w],["loadend",_]])this.removeEventListener(X,V);i.cleanupListeners===I&&(i.cleanupListeners=void 0),a.delete(I)},this.addEventListener("readystatechange",F),this.addEventListener("abort",Z),this.addEventListener("timeout",ee),this.addEventListener("error",w),this.addEventListener("loadend",_),i.cleanupListeners=I,a.add(I),i.startedAt=Date.now(),N=!0}catch(M){o.log("xhr send observation failed",M),I()}let D;try{D=Reflect.apply(j,this,x)}catch(M){throw I(),M}if(N&&i.requestId!==void 0&&i.startedAt!==void 0){i.requestEmitted=!0,L({requestId:i.requestId,transport:"xhr",method:i.method,url:i.url,path:i.path,startedAt:i.startedAt,requestBody:i.requestBody});let M=i.pendingExchange;i.pendingExchange=void 0,M&&R(M)}return D}}.send;return K(S,O),K(T,j),p.writable!==!0||c.writable!==!0?(o.log("xhr capture unavailable: XMLHttpRequest methods are not writable"),null):(Object.defineProperty(s,"open",{...p,value:S}),Object.defineProperty(s,"send",{...c,value:T}),C=!0,()=>{C=!1;for(let x of[...a])x();Y(s,"open",S,p,o),Y(s,"send",T,c,o)})},b=()=>{let s=globalThis,p=Object.getOwnPropertyDescriptor(s,"fetch");if(!p||!("value"in p))return o.log("fetch capture unavailable: fetch is not an own data property"),null;let c=p.value;if(typeof c!="function")return o.log("fetch capture unavailable: fetch missing"),null;if(U(c))return o.log("fetch capture unavailable: an equivalent capture is already active"),null;let O=!1,j=async(a,C,S,T)=>{try{if(!m||!O){ce(S);return}let[x,i]=await Promise.all([T!=null?T:Promise.resolve(void 0),S?Re(S,o):Promise.resolve(void 0)]);if(!m||!O)return;let I={direction:"request",transport:"fetch",method:a.method,url:a.url,path:a.path},N={...I,direction:"response"},D=a.requestBody;D===void 0&&x!==void 0&&(D=d(x,I,l));let M=i!==void 0?d(i,N,A):void 0;R({requestId:a.requestId,transport:"fetch",method:a.method,url:a.url,path:a.path,status:C.status,ok:C.ok,outcome:"load",durationMs:Date.now()-a.startedAt,responseUrl:C.url||void 0,requestBody:D,responseBody:M})}catch(x){o.log("fetch exchange observation failed",x)}},H={fetch(...a){var D,M,Z,ee;let C;try{let w=a[0],k=a[1];if(m&&O&&u&&typeof Request!="undefined"&&w instanceof Request&&(k==null?void 0:k.body)===void 0&&w.body){let F=String((D=k==null?void 0:k.method)!=null?D:w.method).toUpperCase(),_=(M=w.headers.get("content-type"))!=null?M:"";f(w.url,F)&&Ce(_)&&(C=w.clone())}}catch(w){o.log("fetch observation failed",w)}let S,T=Date.now();try{S=Reflect.apply(c,this,a)}catch(w){throw ce(C),w}let x,i;try{if(m&&O){let w=a[0],k=a[1],F=typeof Request!="undefined"&&w instanceof Request,_=String((Z=k==null?void 0:k.method)!=null?Z:F?w.method:"GET").toUpperCase(),X=F?w.url:w,V=f(X,_);V&&(x={requestId:ve(),method:_,url:V.url,path:V.path,startedAt:T},i=(ee=k==null?void 0:k.signal)!=null?ee:F?w.signal:void 0,u&&typeof(k==null?void 0:k.body)=="string"&&(x.requestBody=d(k.body,{direction:"request",transport:"fetch",method:_,url:V.url,path:V.path},l)))}}catch(w){o.log("fetch observation failed",w)}if(!x)return ce(C),S;let I=x;L({requestId:I.requestId,transport:"fetch",method:I.method,url:I.url,path:I.path,startedAt:I.startedAt,requestBody:I.requestBody});let N=C?Re(C,o):void 0;return S.then(w=>{var F;let k;try{if(m&&O&&q){let _=(F=w.headers.get("content-type"))!=null?F:"";Ce(_)&&w.body&&(k=w.clone())}}catch{}j(I,w,k,N)},w=>{try{if(!m||!O)return;let k=(i==null?void 0:i.aborted)===!0||(w==null?void 0:w.name)==="AbortError"||typeof DOMException!="undefined"&&w instanceof DOMException&&w.code===DOMException.ABORT_ERR;R({requestId:I.requestId,transport:"fetch",method:I.method,url:I.url,path:I.path,status:0,ok:!1,outcome:k?"abort":"error",durationMs:Date.now()-I.startedAt})}catch(k){o.log("fetch failure observation failed",k)}}),S}}.fetch;return K(H,c),p.writable!==!0?(o.log("fetch capture unavailable: fetch is not writable"),null):(Object.defineProperty(s,"fetch",{...p,value:H}),O=!0,()=>{O=!1,Y(s,"fetch",H,p,o)})},P=[];if(y.includes("xhr")){let s=g();s&&P.push(s)}if(y.includes("fetch")){let s=b();s&&P.push(s)}return P.length===0?B():(m=!0,{mode:"standard",disconnect:()=>{m=!1;for(let s of P.splice(0))s()}})}function ke(e){let t=e.onNavigate;if(typeof t!="function")throw new TypeError("captureNavigation requires an onNavigate callback");let n=W(e.logger),r,o,y,l,A,u;try{if(r=window,o=r==null?void 0:r.history,!r||!o)return n.log("navigation capture unavailable: window/history missing"),B();if(A=xe(o,"pushState"),u=xe(o,"replaceState"),!A||!u)return n.log("navigation capture unavailable: history method descriptors missing"),B();if(y=A.descriptor.value,l=u.descriptor.value,typeof y!="function"||typeof l!="function")return n.log("navigation capture unavailable: history methods missing"),B();if(typeof r.addEventListener!="function"||typeof r.removeEventListener!="function")return n.log("navigation capture unavailable: window event methods missing"),B()}catch(h){return n.log("navigation capture unavailable: history inspection failed",h),B()}if(U(y)||U(l))return n.log("navigation capture unavailable: an equivalent capture is already active"),B();let q=!1,m=()=>({path:r.location.pathname,search:r.location.search,hash:r.location.hash}),R;try{R=m()}catch(h){return n.log("navigation capture unavailable: location inspection failed",h),B()}let L=z(n,"navigation",h=>{if(q)return t(h)}),d=h=>{if(q)try{let E=m();if(E.path===R.path&&E.search===R.search&&E.hash===R.hash)return;R=E,L({...E,source:h})}catch(E){n.log("navigation observation failed",E)}},f={pushState(...h){let E=Reflect.apply(y,this,h);return d("push"),E}}.pushState,g={replaceState(...h){let E=Reflect.apply(l,this,h);return d("replace"),E}}.replaceState;K(f,y),K(g,l);let b=()=>d("pop"),P=()=>d("hash");try{if(Ie(A,f),Ie(u,g),o.pushState!==f||o.replaceState!==g)throw new Error("history method replacement did not take effect");r.addEventListener("popstate",b),r.addEventListener("hashchange",P),q=!0}catch(h){return q=!1,ae(r,"popstate",b,n),ae(r,"hashchange",P,n),ie(u,g,n),ie(A,f,n),n.log("navigation capture unavailable: history methods are not writable",h),t=()=>{},L=()=>{},n=W(),B()}return{mode:"standard",disconnect:()=>{q=!1,t=()=>{},ae(r,"popstate",b,n),ae(r,"hashchange",P,n),ie(A,f,n),ie(u,g,n),L=()=>{},n=W()}}}function xe(e,t){let n=e;for(;n;){let r=Object.getOwnPropertyDescriptor(n,t);if(r)return!("value"in r)||typeof r.value!="function"?null:{owner:n,key:t,descriptor:r};n=Object.getPrototypeOf(n)}return null}function Ie(e,t){if(e.descriptor.writable!==!0)throw new TypeError(`${e.key} is not writable`);let n=Object.getOwnPropertyDescriptor(e.owner,e.key);if(!de(n,e.descriptor))throw new Error(`${e.key} changed during installation`);Object.defineProperty(e.owner,e.key,{...e.descriptor,value:t})}function ie(e,t,n){Y(e.owner,e.key,t,e.descriptor,n,`navigation ${e.key}`)}function ae(e,t,n,r){try{e.removeEventListener(t,n)}catch(o){r.log(`navigation ${t} listener removal skipped`,o)}}function Ae(e){let t=e.composedPath();return t.length>0?t:e.target?[e.target]:[]}var qe="1.2.0";var $e=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"];function le(e){return $e.find(t=>e.validity[t])}function Oe(e){if(!(e!=null&&e.isConnected)||!e.getClientRects().length)return!1;let t=e.ownerDocument.defaultView;if(!t)return!1;for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(n.hasAttribute("hidden")||r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"||r.opacity==="0")return!1}return!0}function Se(e){var j,H;if(typeof e.readValidation!="function"||typeof e.onError!="function")throw new TypeError("captureInputValidation requires readValidation and onError callbacks");let{form:t}=e,n=[...e.fields],r=(j=e.maxObservationMs)!=null?j:1e4;if(!n.length||!Number.isFinite(r)||r<=0)throw new TypeError("captureInputValidation requires fields and a positive maxObservationMs");let o={mode:"unavailable",disconnect(){},beginAttempt:()=>{},requestStarted(){},refresh(){}},y=(H=t==null?void 0:t.ownerDocument)==null?void 0:H.defaultView;if(!y||!n.every(a=>a.form===t))return o;let l=!0,A=0,u,q=!1,m,R,L,d,f=[],g=()=>t.isConnected&&n.every(a=>a.isConnected&&a.form===t),b=()=>{try{let a=e.readValidation();if(a&&["clear","pending","unknown"].includes(a.status)||(a==null?void 0:a.status)==="invalid"&&typeof a.code=="string"&&["constraint","application"].includes(a.source))return a}catch{}return{status:"unknown"}},P=a=>a.status==="invalid"?JSON.stringify([a.code,a.fieldIndex]):void 0,h=()=>{u=void 0,clearTimeout(R),clearTimeout(L),R=L=void 0},E=()=>{R=void 0;let a=u;if(!l||!(a!=null&&a.confirmed))return;if(!g()){h();return}let C=a.nativeInvalid?(()=>{for(let[T,x]of n.entries()){let i=le(x);if(i)return{status:"invalid",source:"constraint",code:i,fieldIndex:T}}return{status:"clear"}})():b();if(C.status==="clear"){a.serverBaseline=void 0;return}if(C.status!=="invalid"||C.source==="application"&&a.serverBaseline===P(C))return;let S={attemptId:a.id,startedAt:a.startedAt,timestamp:Date.now(),code:C.code,...C.fieldIndex===void 0?{}:{fieldIndex:C.fieldIndex}};h(),q=!1;try{Promise.resolve(e.onError(S)).catch(()=>{})}catch{}},v=()=>{!l||!u||R!==void 0||(R=setTimeout(E,0))},s=a=>{if(!l||!g())return;h();let C=q?P(b()):void 0;return u={id:++A,startedAt:Date.now(),confirmed:a,nativeInvalid:!1,serverBaseline:C},L=setTimeout(h,r),v(),u.id},p=()=>{m===void 0&&(m=s(!1),d=setTimeout(()=>{u&&u.id===m&&!u.confirmed&&h(),m=void 0},0))},c=(a,C,S)=>{a.addEventListener(C,S,!0),f.push(()=>a.removeEventListener(C,S,!0))},O={mode:"standard",beginAttempt:()=>s(!0),refresh:v,requestStarted(a={}){l&&(a.attemptId!==void 0&&a.attemptId!==(u==null?void 0:u.id)||u&&a.timestamp!==void 0&&a.timestamp<u.startedAt||(h(),q=!0))},disconnect(){if(l){l=!1,h(),clearTimeout(d);for(let a of f.splice(0))a()}}};try{let a=S=>{var i;let T=S.target,x=(i=T==null?void 0:T.closest)==null?void 0:i.call(T,"button,input");(x==null?void 0:x.form)===t&&!x.disabled&&["submit","image"].includes(x.type)&&p()};c(t.ownerDocument,"click",a),c(t,"click",a),c(t,"keydown",S=>{let T=S;T.key==="Enter"&&!T.isComposing&&!T.defaultPrevented&&n.includes(T.target)&&p()}),c(t,"submit",()=>{(u==null?void 0:u.id)===m&&u?(u.confirmed=!0,v()):s(!0),m=void 0}),c(t,"invalid",S=>{!u||!n.includes(S.target)||(u.confirmed=!0,u.nativeInvalid=!0,v())}),c(t,"input",S=>{n.includes(S.target)&&h()});let C=new y.MutationObserver(v);C.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),f.push(()=>C.disconnect())}catch{return O.disconnect(),o}return O}var G=require("@corbado/observe");0&&(module.exports={VERSION,captureFederatedIdentity,captureInputValidation,captureNavigation,captureNetwork,captureWebAuthn,composedPath,inputValidationCode,isValidationMessageVisible,sanitizeAssertionResponse,sanitizeCreationOptions,sanitizeCreationResponse,sanitizeRequestOptions});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as H,b as R,c as N,d as L,e as j,f as D,g as F,h as z}from"./chunk-7E5QDUX5.mjs";import"./chunk-JR557W27.mjs";import{sanitizeCreationOptions as B,sanitizeCreationResponse as U,sanitizeRequestOptions as J,sanitizeAssertionResponse as _}from"@corbado/observe";var q=t=>({get:t("get"),create:t("create")});function $(t){let n=t.onEvent;if(typeof n!="function")throw new TypeError("captureWebAuthn requires an onEvent callback");let s=H(t.logger),f=r=>(s.log(`webauthn capture unavailable: ${r}`),{...L(),surface:"none"}),p=typeof navigator=="undefined"?void 0:navigator,b=p==null?void 0:p.credentials;if(!p||!b)return f("navigator.credentials missing");let h=b,I=q(r=>h[r]);if(typeof I.get!="function"||typeof I.create!="function")return f("credentials methods missing");if(R(I.get)||R(I.create))return f("an equivalent capture is already active");let i=!1,M=0,E=j(s,"webauthn",n),O=(r,d,v)=>{let g={invoke(...C){let m=C[0];if(!i||v!=null&&v()||!S(m)||!S(m.publicKey))return d(this,C);let c=m.publicKey,o=`wa-${++M}`,l=d(this,C),w=S(m.signal)?m.signal:void 0,e=Q(r,m,c),u=a=>{i&&E({...e,ceremonyId:o,...a()})},y=()=>(w==null?void 0:w.aborted)===!0?{aborted:!0}:{};return u(()=>({phase:"started",userActivation:Z(p),...e.kind==="authentication"?{requestOptionsJson:J(c)}:{creationOptionsJson:B(c,t.identifierProjectors)}})),Promise.resolve(l).then(a=>(u(()=>({phase:"completed",credentialJson:r==="create"?U(a,t.identifierProjectors):_(a,t.identifierProjectors),...y()})),a),a=>{throw u(()=>({phase:"failed",error:a,errorName:G(a),...y()})),a})}}.invoke;return N(g,{name:r,length:0})},k=r=>{var g;let d=O(r,(C,m)=>Reflect.apply(I[r],C,m)),v=Object.getOwnPropertyDescriptor(b,r);if(v&&(!("value"in v)||v.writable!==!0))return null;try{h[r]=d}catch{return null}if(((g=Object.getOwnPropertyDescriptor(b,r))==null?void 0:g.value)!==d){try{h[r]=I[r]}catch{}return null}return()=>{h[r]===d&&(v?h[r]=v.value:delete h[r])}},P=()=>{let r=q(()=>new WeakMap),d=(c,o)=>{let l=r[c].get(o);if(l)return l;let w=O(c,(e,u)=>Reflect.apply(o,b,u),()=>{try{let e=h[c];return e!==o&&e!==w}catch(e){return s.log("suppress check failed; ceremony unreported",e),!0}});return r[c].set(o,w),w},v=c=>{let o=Object.getOwnPropertyDescriptor(b,c);return o?o.configurable===!0||!("value"in o)||o.writable===!0:!0},g=new WeakMap,C=new Proxy(b,{get(c,o){let l=Reflect.get(b,o,b);if((o==="get"||o==="create")&&v(o))return typeof l!="function"||R(l)?l:d(o,l);if(typeof l!="function"||!v(o)||o==="constructor")return l;let w=g.get(l);if(w)return w;let e=l.bind(b);return g.set(l,e),e},set(c,o,l){return Reflect.set(b,o,l,b)}}),m=Object.getOwnPropertyDescriptor(p,"credentials");if(m&&m.configurable!==!0)return null;try{Object.defineProperty(p,"credentials",{value:C,writable:!0,enumerable:!0,configurable:!0})}catch{return null}return p.credentials!==C?null:()=>{p.credentials===C&&(m?Object.defineProperty(p,"credentials",m):delete p.credentials)}},T=(r,d)=>(i=!0,{mode:"standard",surface:r,disconnect:()=>{i=!1,d()}}),A=k("get"),V=A?k("create"):null;if(A&&V)return T("methods",()=>{A(),V()});if(A==null||A(),t.attach==="container"){let r=P();if(r)return s.log("webauthn capture attached at the credentials container"),T("container",r)}return f("credentials methods cannot be patched safely")}function Q(t,n,s){let f=X(n.mediation);if(t==="create")return{kind:"registration",mediation:f};let p=s;return{kind:"authentication",mediation:f,uiMode:Y(n.uiMode),credentialSet:Array.isArray(p.allowCredentials)&&p.allowCredentials.length>0?"allowlisted":"discoverable"}}function X(t){return t===void 0?"optional":t==="silent"||t==="optional"||t==="conditional"||t==="required"?t:"unknown"}function Y(t){return t===void 0?"default":t==="immediate"?"immediate":"unknown"}function Z(t){let n=t.userActivation;return typeof(n==null?void 0:n.isActive)=="boolean"?n.isActive:void 0}function S(t){return t!==null&&(typeof t=="object"||typeof t=="function")}function G(t){return t instanceof DOMException?t.name:"UnknownError"}function ee(t){let n=t.composedPath();return n.length>0?n:t.target?[t.target]:[]}var te=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"];function K(t){return te.find(n=>t.validity[n])}function ne(t){if(!(t!=null&&t.isConnected)||!t.getClientRects().length)return!1;let n=t.ownerDocument.defaultView;if(!n)return!1;for(let s=t;s;s=s.parentElement){let f=n.getComputedStyle(s);if(s.hasAttribute("hidden")||f.display==="none"||f.visibility==="hidden"||f.visibility==="collapse"||f.opacity==="0")return!1}return!0}function re(t){var l,w;if(typeof t.readValidation!="function"||typeof t.onError!="function")throw new TypeError("captureInputValidation requires readValidation and onError callbacks");let{form:n}=t,s=[...t.fields],f=(l=t.maxObservationMs)!=null?l:1e4;if(!s.length||!Number.isFinite(f)||f<=0)throw new TypeError("captureInputValidation requires fields and a positive maxObservationMs");let p={mode:"unavailable",disconnect(){},beginAttempt:()=>{},requestStarted(){},refresh(){}},b=(w=n==null?void 0:n.ownerDocument)==null?void 0:w.defaultView;if(!b||!s.every(e=>e.form===n))return p;let h=!0,I=0,i,M=!1,E,O,k,P,T=[],A=()=>n.isConnected&&s.every(e=>e.isConnected&&e.form===n),V=()=>{try{let e=t.readValidation();if(e&&["clear","pending","unknown"].includes(e.status)||(e==null?void 0:e.status)==="invalid"&&typeof e.code=="string"&&["constraint","application"].includes(e.source))return e}catch{}return{status:"unknown"}},r=e=>e.status==="invalid"?JSON.stringify([e.code,e.fieldIndex]):void 0,d=()=>{i=void 0,clearTimeout(O),clearTimeout(k),O=k=void 0},v=()=>{O=void 0;let e=i;if(!h||!(e!=null&&e.confirmed))return;if(!A()){d();return}let u=e.nativeInvalid?(()=>{for(let[a,x]of s.entries()){let W=K(x);if(W)return{status:"invalid",source:"constraint",code:W,fieldIndex:a}}return{status:"clear"}})():V();if(u.status==="clear"){e.serverBaseline=void 0;return}if(u.status!=="invalid"||u.source==="application"&&e.serverBaseline===r(u))return;let y={attemptId:e.id,startedAt:e.startedAt,timestamp:Date.now(),code:u.code,...u.fieldIndex===void 0?{}:{fieldIndex:u.fieldIndex}};d(),M=!1;try{Promise.resolve(t.onError(y)).catch(()=>{})}catch{}},g=()=>{!h||!i||O!==void 0||(O=setTimeout(v,0))},C=e=>{if(!h||!A())return;d();let u=M?r(V()):void 0;return i={id:++I,startedAt:Date.now(),confirmed:e,nativeInvalid:!1,serverBaseline:u},k=setTimeout(d,f),g(),i.id},m=()=>{E===void 0&&(E=C(!1),P=setTimeout(()=>{i&&i.id===E&&!i.confirmed&&d(),E=void 0},0))},c=(e,u,y)=>{e.addEventListener(u,y,!0),T.push(()=>e.removeEventListener(u,y,!0))},o={mode:"standard",beginAttempt:()=>C(!0),refresh:g,requestStarted(e={}){h&&(e.attemptId!==void 0&&e.attemptId!==(i==null?void 0:i.id)||i&&e.timestamp!==void 0&&e.timestamp<i.startedAt||(d(),M=!0))},disconnect(){if(h){h=!1,d(),clearTimeout(P);for(let e of T.splice(0))e()}}};try{let e=y=>{var W;let a=y.target,x=(W=a==null?void 0:a.closest)==null?void 0:W.call(a,"button,input");(x==null?void 0:x.form)===n&&!x.disabled&&["submit","image"].includes(x.type)&&m()};c(n.ownerDocument,"click",e),c(n,"click",e),c(n,"keydown",y=>{let a=y;a.key==="Enter"&&!a.isComposing&&!a.defaultPrevented&&s.includes(a.target)&&m()}),c(n,"submit",()=>{(i==null?void 0:i.id)===E&&i?(i.confirmed=!0,g()):C(!0),E=void 0}),c(n,"invalid",y=>{!i||!s.includes(y.target)||(i.confirmed=!0,i.nativeInvalid=!0,g())}),c(n,"input",y=>{s.includes(y.target)&&d()});let u=new b.MutationObserver(g);u.observe(n,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),T.push(()=>u.disconnect())}catch{return o.disconnect(),p}return o}import{sanitizeCreationOptions as he,sanitizeCreationResponse as ve,sanitizeRequestOptions as ge,sanitizeAssertionResponse as Ce}from"@corbado/observe";export{z as VERSION,re as captureInputValidation,F as captureNavigation,D as captureNetwork,$ as captureWebAuthn,ee as composedPath,K as inputValidationCode,ne as isValidationMessageVisible,Ce as sanitizeAssertionResponse,he as sanitizeCreationOptions,ve as sanitizeCreationResponse,ge as sanitizeRequestOptions};
1
+ import{a as R,b as P,c as D,d as L,e as H,f as _,g as $,h as Q}from"./chunk-GWLL2VST.mjs";import"./chunk-JR557W27.mjs";import{sanitizeCreationOptions as Y,sanitizeCreationResponse as Z,sanitizeRequestOptions as G,sanitizeAssertionResponse as ee}from"@corbado/observe";var U=e=>({get:e("get"),create:e("create")}),T;function q(e){if(T)return[...T.subscribers].some(n=>n.channel===e.channel)?{attached:!1,reason:"an equivalent capture is already active"}:B(T,e);let t=X(e);return typeof t=="string"?{attached:!1,reason:t}:(T=t,B(t,e))}function B(e,t){e.subscribers.add(t);let n=!0;return{attached:!0,surface:e.surface,unsubscribe:()=>{n&&(n=!1,e.subscribers.delete(t),!(e.subscribers.size>0)&&(e.active=!1,e.detach(),T===e&&(T=void 0)))}}}function X(e){let t=typeof navigator=="undefined"?void 0:navigator,n=t==null?void 0:t.credentials;if(!t||!n)return"navigator.credentials missing";let o=n,b=U(i=>o[i]);if(typeof b.get!="function"||typeof b.create!="function")return"credentials methods missing";if(P(b.get)||P(b.create))return"an equivalent capture is already active";let I={surface:"methods",subscribers:new Set,active:!1,detach:()=>{}},m=(...i)=>I.subscribers.forEach(l=>l.logger.log(...i)),O=(i,l,s)=>{let u={invoke(...C){let h=C[0];if(!I.active||s!=null&&s()||!S(h))return l(this,C);let E=l(this,C),d=[];for(let p of[...I.subscribers])try{let c=p.onCall(i,h);c&&d.push([p,c])}catch(c){p.logger.log("credentials observation failed",c)}if(d.length===0)return E;let f=p=>{for(let[c,F]of d)try{p(F)}catch(W){c.logger.log("credentials observation failed",W)}};return Promise.resolve(E).then(p=>(f(c=>c.completed(p)),p),p=>{throw f(c=>c.failed(p)),p})}}.invoke;return D(u,{name:i,length:0})},a=i=>{var u;let l=O(i,(C,h)=>Reflect.apply(b[i],C,h)),s=Object.getOwnPropertyDescriptor(n,i);if(s&&(!("value"in s)||s.writable!==!0))return null;try{o[i]=l}catch{return null}if(((u=Object.getOwnPropertyDescriptor(n,i))==null?void 0:u.value)!==l){try{o[i]=b[i]}catch{}return null}return()=>{o[i]===l&&(s?o[i]=s.value:delete o[i])}},g=()=>{let i=U(()=>new WeakMap),l=(E,d)=>{let f=i[E].get(d);if(f)return f;let p=O(E,(c,F)=>Reflect.apply(d,n,F),()=>{try{let c=o[E];return c!==d&&c!==p}catch(c){return m("suppress check failed; ceremony unreported",c),!0}});return i[E].set(d,p),p},s=E=>{let d=Object.getOwnPropertyDescriptor(n,E);return d?d.configurable===!0||!("value"in d)||d.writable===!0:!0},u=new WeakMap,C=new Proxy(n,{get(E,d){let f=Reflect.get(n,d,n);if((d==="get"||d==="create")&&s(d))return typeof f!="function"||P(f)?f:l(d,f);if(typeof f!="function"||!s(d)||d==="constructor")return f;let p=u.get(f);if(p)return p;let c=f.bind(n);return u.set(f,c),c},set(E,d,f){return Reflect.set(n,d,f,n)}}),h=Object.getOwnPropertyDescriptor(t,"credentials");if(h&&h.configurable!==!0)return null;try{Object.defineProperty(t,"credentials",{value:C,writable:!0,enumerable:!0,configurable:!0})}catch{return null}return t.credentials!==C?null:()=>{t.credentials===C&&(h?Object.defineProperty(t,"credentials",h):delete t.credentials)}},v=(i,l)=>(I.surface=i,I.detach=l,I.active=!0,I),y=a("get"),A=y?a("create"):null;if(y&&A)return v("methods",()=>{y(),A()});if(y==null||y(),e.attach==="container"){let i=g();if(i)return v("container",i)}return"credentials methods cannot be patched safely"}function S(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function N(){let e=navigator.userActivation;return typeof(e==null?void 0:e.isActive)=="boolean"?e.isActive:void 0}function j(e){return e===void 0?"optional":e==="silent"||e==="optional"||e==="conditional"||e==="required"?e:"unknown"}function K(e){return e instanceof DOMException?e.name:"UnknownError"}function te(e){var O;let t=e.onEvent;if(typeof t!="function")throw new TypeError("captureWebAuthn requires an onEvent callback");let n=R(e.logger),o=!0,b=0,I=H(n,"webauthn",t),m=q({channel:"webauthn",attach:(O=e.attach)!=null?O:"methods",logger:n,onCall(a,g){if(!o||!S(g.publicKey))return;let v=g.publicKey,y=`wa-${++b}`,A=S(g.signal)?g.signal:void 0,i=ne(a,g,v),l=u=>{o&&I({...i,ceremonyId:y,...u()})},s=()=>(A==null?void 0:A.aborted)===!0?{aborted:!0}:{};return l(()=>({phase:"started",userActivation:N(),...i.kind==="authentication"?{requestOptionsJson:G(v)}:{creationOptionsJson:Y(v,e.identifierProjectors)}})),{completed:u=>l(()=>({phase:"completed",credentialJson:a==="create"?Z(u,e.identifierProjectors):ee(u,e.identifierProjectors),...s()})),failed:u=>l(()=>({phase:"failed",error:u,errorName:K(u),...s()}))}}});return m.attached?(m.surface==="container"&&n.log("webauthn capture attached at the credentials container"),{mode:"standard",surface:m.surface,disconnect:()=>{o=!1,m.unsubscribe()}}):(n.log(`webauthn capture unavailable: ${m.reason}`),{...L(),surface:"none"})}function ne(e,t,n){let o=j(t.mediation);if(e==="create")return{kind:"registration",mediation:o};let b=n;return{kind:"authentication",mediation:o,uiMode:re(t.uiMode),credentialSet:Array.isArray(b.allowCredentials)&&b.allowCredentials.length>0?"allowlisted":"discoverable"}}function re(e){return e===void 0?"default":e==="immediate"?"immediate":"unknown"}function ie(e){var O;let t=e.onEvent;if(typeof t!="function")throw new TypeError("captureFederatedIdentity requires an onEvent callback");let n=R(e.logger),o=!0,b=0,I=H(n,"federated identity",t),m=q({channel:"federated-identity",attach:(O=e.attach)!=null?O:"methods",logger:n,onCall(a,g){let v=g.identity;if(!o||a!=="get"||!S(v))return;let y=`fi-${++b}`,A=S(g.signal)?g.signal:void 0,i=v,l=s=>{o&&I(s)};return l({phase:"started",requestId:y,providers:oe(i.providers),context:ae(i.context),mode:de(i.mode),mediation:j(g.mediation),userActivation:N()}),{completed:s=>{if(s===null){l({phase:"failed",requestId:y,errorName:"NoCredential"});return}let u=s;l({phase:"completed",requestId:y,...typeof u.configURL=="string"?{configURL:u.configURL}:{},...typeof u.isAutoSelected=="boolean"?{isAutoSelected:u.isAutoSelected}:{}})},failed:s=>{let u=K(s),C=u==="IdentityCredentialError"?se(s):void 0;l({phase:"failed",requestId:y,errorName:u,...C!==void 0?{code:C}:{},...(A==null?void 0:A.aborted)===!0?{aborted:!0}:{}})}}}});return m.attached?{mode:"standard",surface:m.surface,disconnect:()=>{o=!1,m.unsubscribe()}}:(n.log(`federated identity capture unavailable: ${m.reason}`),{...L(),surface:"none"})}function oe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!S(n))continue;let{configURL:o,clientId:b}=n;typeof o=="string"&&t.push(typeof b=="string"?{configURL:o,clientId:b}:{configURL:o})}return t}function ae(e){return e===void 0?"signin":e==="signin"||e==="signup"||e==="use"||e==="continue"?e:"unknown"}function de(e){return e===void 0?"passive":e==="passive"||e==="active"?e:"unknown"}function se(e){let{error:t,code:n}=e;return typeof t=="string"&&t!==""?t:typeof n=="string"&&n!==""?n:void 0}function ue(e){let t=e.composedPath();return t.length>0?t:e.target?[e.target]:[]}var ce=["valueMissing","typeMismatch","patternMismatch","tooShort","tooLong","rangeUnderflow","rangeOverflow","stepMismatch","badInput","customError"];function J(e){return ce.find(t=>e.validity[t])}function le(e){if(!(e!=null&&e.isConnected)||!e.getClientRects().length)return!1;let t=e.ownerDocument.defaultView;if(!t)return!1;for(let n=e;n;n=n.parentElement){let o=t.getComputedStyle(n);if(n.hasAttribute("hidden")||o.display==="none"||o.visibility==="hidden"||o.visibility==="collapse"||o.opacity==="0")return!1}return!0}function fe(e){var W,z;if(typeof e.readValidation!="function"||typeof e.onError!="function")throw new TypeError("captureInputValidation requires readValidation and onError callbacks");let{form:t}=e,n=[...e.fields],o=(W=e.maxObservationMs)!=null?W:1e4;if(!n.length||!Number.isFinite(o)||o<=0)throw new TypeError("captureInputValidation requires fields and a positive maxObservationMs");let b={mode:"unavailable",disconnect(){},beginAttempt:()=>{},requestStarted(){},refresh(){}},I=(z=t==null?void 0:t.ownerDocument)==null?void 0:z.defaultView;if(!I||!n.every(r=>r.form===t))return b;let m=!0,O=0,a,g=!1,v,y,A,i,l=[],s=()=>t.isConnected&&n.every(r=>r.isConnected&&r.form===t),u=()=>{try{let r=e.readValidation();if(r&&["clear","pending","unknown"].includes(r.status)||(r==null?void 0:r.status)==="invalid"&&typeof r.code=="string"&&["constraint","application"].includes(r.source))return r}catch{}return{status:"unknown"}},C=r=>r.status==="invalid"?JSON.stringify([r.code,r.fieldIndex]):void 0,h=()=>{a=void 0,clearTimeout(y),clearTimeout(A),y=A=void 0},E=()=>{y=void 0;let r=a;if(!m||!(r!=null&&r.confirmed))return;if(!s()){h();return}let w=r.nativeInvalid?(()=>{for(let[x,M]of n.entries()){let V=J(M);if(V)return{status:"invalid",source:"constraint",code:V,fieldIndex:x}}return{status:"clear"}})():u();if(w.status==="clear"){r.serverBaseline=void 0;return}if(w.status!=="invalid"||w.source==="application"&&r.serverBaseline===C(w))return;let k={attemptId:r.id,startedAt:r.startedAt,timestamp:Date.now(),code:w.code,...w.fieldIndex===void 0?{}:{fieldIndex:w.fieldIndex}};h(),g=!1;try{Promise.resolve(e.onError(k)).catch(()=>{})}catch{}},d=()=>{!m||!a||y!==void 0||(y=setTimeout(E,0))},f=r=>{if(!m||!s())return;h();let w=g?C(u()):void 0;return a={id:++O,startedAt:Date.now(),confirmed:r,nativeInvalid:!1,serverBaseline:w},A=setTimeout(h,o),d(),a.id},p=()=>{v===void 0&&(v=f(!1),i=setTimeout(()=>{a&&a.id===v&&!a.confirmed&&h(),v=void 0},0))},c=(r,w,k)=>{r.addEventListener(w,k,!0),l.push(()=>r.removeEventListener(w,k,!0))},F={mode:"standard",beginAttempt:()=>f(!0),refresh:d,requestStarted(r={}){m&&(r.attemptId!==void 0&&r.attemptId!==(a==null?void 0:a.id)||a&&r.timestamp!==void 0&&r.timestamp<a.startedAt||(h(),g=!0))},disconnect(){if(m){m=!1,h(),clearTimeout(i);for(let r of l.splice(0))r()}}};try{let r=k=>{var V;let x=k.target,M=(V=x==null?void 0:x.closest)==null?void 0:V.call(x,"button,input");(M==null?void 0:M.form)===t&&!M.disabled&&["submit","image"].includes(M.type)&&p()};c(t.ownerDocument,"click",r),c(t,"click",r),c(t,"keydown",k=>{let x=k;x.key==="Enter"&&!x.isComposing&&!x.defaultPrevented&&n.includes(x.target)&&p()}),c(t,"submit",()=>{(a==null?void 0:a.id)===v&&a?(a.confirmed=!0,d()):f(!0),v=void 0}),c(t,"invalid",k=>{!a||!n.includes(k.target)||(a.confirmed=!0,a.nativeInvalid=!0,d())}),c(t,"input",k=>{n.includes(k.target)&&h()});let w=new I.MutationObserver(d);w.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),l.push(()=>w.disconnect())}catch{return F.disconnect(),b}return F}import{sanitizeCreationOptions as We,sanitizeCreationResponse as Re,sanitizeRequestOptions as Pe,sanitizeAssertionResponse as Le}from"@corbado/observe";export{Q as VERSION,ie as captureFederatedIdentity,fe as captureInputValidation,$ as captureNavigation,_ as captureNetwork,te as captureWebAuthn,ue as composedPath,J as inputValidationCode,le as isValidationMessageVisible,Le as sanitizeAssertionResponse,We as sanitizeCreationOptions,Re as sanitizeCreationResponse,Pe as sanitizeRequestOptions};
@@ -1,6 +1,6 @@
1
- import { P as ProbeConfig } from '../guards-C1SJi1-7.mjs';
2
- export { E as applyGuards, F as createProbeTaint } from '../guards-C1SJi1-7.mjs';
3
- import '../types-CXJAj2DU.mjs';
1
+ import { P as ProbeConfig } from '../guards-BmrxoYBR.mjs';
2
+ export { E as applyGuards, F as createProbeTaint } from '../guards-BmrxoYBR.mjs';
3
+ import '../types-lamU1Fd3.mjs';
4
4
  import '@corbado/observe';
5
5
 
6
6
  type ProbeGuardFixtureInput = {
@@ -1,6 +1,6 @@
1
- import { P as ProbeConfig } from '../guards-wCMqiGRi.js';
2
- export { E as applyGuards, F as createProbeTaint } from '../guards-wCMqiGRi.js';
3
- import '../types-CXJAj2DU.js';
1
+ import { P as ProbeConfig } from '../guards-Bwsr1zMi.js';
2
+ export { E as applyGuards, F as createProbeTaint } from '../guards-Bwsr1zMi.js';
3
+ import '../types-lamU1Fd3.js';
4
4
  import '@corbado/observe';
5
5
 
6
6
  type ProbeGuardFixtureInput = {
package/dist/probe.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as ProbeConfig, a as ProbeDeps, b as ProbeHandle } from './guards-C1SJi1-7.mjs';
2
- export { c as ProbeAction, d as ProbeBudgets, e as ProbeConsoleSurfaceConfig, f as ProbeCorrelateAction, g as ProbeCountAction, h as ProbeItemContext, i as ProbeLevel, j as ProbeMatch, k as ProbeMethod, l as ProbeMethodOptions, m as ProbeNavigationSource, n as ProbeNetMatch, o as ProbeNetSurfaceConfig, p as ProbeNetworkSource, q as ProbeNetworkSubscriber, r as ProbePathPick, s as ProbeResSurfaceConfig, t as ProbeRule, u as ProbeSinkItem, v as ProbeSnapshotAction, w as ProbeSurface, x as ProbeSurfaceConfig, y as ProbeSurfaces, z as ProbeTaint, A as ProbeTrigger, B as ProbeUiSurfaceConfig, C as ProbeWebAuthnSource, D as ProbeWhen, E as applyGuards, F as createProbeTaint } from './guards-C1SJi1-7.mjs';
3
- import './types-CXJAj2DU.mjs';
1
+ import { P as ProbeConfig, a as ProbeDeps, b as ProbeHandle } from './guards-BmrxoYBR.mjs';
2
+ export { c as ProbeAction, d as ProbeBudgets, e as ProbeConsoleSurfaceConfig, f as ProbeCorrelateAction, g as ProbeCountAction, h as ProbeItemContext, i as ProbeLevel, j as ProbeMatch, k as ProbeMethod, l as ProbeMethodOptions, m as ProbeNavigationSource, n as ProbeNetMatch, o as ProbeNetSurfaceConfig, p as ProbeNetworkSource, q as ProbeNetworkSubscriber, r as ProbePathPick, s as ProbeResSurfaceConfig, t as ProbeRule, u as ProbeSinkItem, v as ProbeSnapshotAction, w as ProbeSurface, x as ProbeSurfaceConfig, y as ProbeSurfaces, z as ProbeTaint, A as ProbeTrigger, B as ProbeUiSurfaceConfig, C as ProbeWebAuthnSource, D as ProbeWhen, E as applyGuards, F as createProbeTaint } from './guards-BmrxoYBR.mjs';
3
+ import './types-lamU1Fd3.mjs';
4
4
  import '@corbado/observe';
5
5
 
6
6
  /**
package/dist/probe.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as ProbeConfig, a as ProbeDeps, b as ProbeHandle } from './guards-wCMqiGRi.js';
2
- export { c as ProbeAction, d as ProbeBudgets, e as ProbeConsoleSurfaceConfig, f as ProbeCorrelateAction, g as ProbeCountAction, h as ProbeItemContext, i as ProbeLevel, j as ProbeMatch, k as ProbeMethod, l as ProbeMethodOptions, m as ProbeNavigationSource, n as ProbeNetMatch, o as ProbeNetSurfaceConfig, p as ProbeNetworkSource, q as ProbeNetworkSubscriber, r as ProbePathPick, s as ProbeResSurfaceConfig, t as ProbeRule, u as ProbeSinkItem, v as ProbeSnapshotAction, w as ProbeSurface, x as ProbeSurfaceConfig, y as ProbeSurfaces, z as ProbeTaint, A as ProbeTrigger, B as ProbeUiSurfaceConfig, C as ProbeWebAuthnSource, D as ProbeWhen, E as applyGuards, F as createProbeTaint } from './guards-wCMqiGRi.js';
3
- import './types-CXJAj2DU.js';
1
+ import { P as ProbeConfig, a as ProbeDeps, b as ProbeHandle } from './guards-Bwsr1zMi.js';
2
+ export { c as ProbeAction, d as ProbeBudgets, e as ProbeConsoleSurfaceConfig, f as ProbeCorrelateAction, g as ProbeCountAction, h as ProbeItemContext, i as ProbeLevel, j as ProbeMatch, k as ProbeMethod, l as ProbeMethodOptions, m as ProbeNavigationSource, n as ProbeNetMatch, o as ProbeNetSurfaceConfig, p as ProbeNetworkSource, q as ProbeNetworkSubscriber, r as ProbePathPick, s as ProbeResSurfaceConfig, t as ProbeRule, u as ProbeSinkItem, v as ProbeSnapshotAction, w as ProbeSurface, x as ProbeSurfaceConfig, y as ProbeSurfaces, z as ProbeTaint, A as ProbeTrigger, B as ProbeUiSurfaceConfig, C as ProbeWebAuthnSource, D as ProbeWhen, E as applyGuards, F as createProbeTaint } from './guards-Bwsr1zMi.js';
3
+ import './types-lamU1Fd3.js';
4
4
  import '@corbado/observe';
5
5
 
6
6
  /**