PageSourceSearch

https://www.listening.com/assets/auth-client-DQCUApNo.js

js listening.com collected 2026-09-24 08:54:16 UTC 32,634 bytes, 4 lines download raw bytes

1import{a as e,n as t}from"./jsx-runtime-D3jfb0Ew.js";var n=Object.create(null),r=e=>({}),i=new Proxy(n,{get(e,t){return r()[t]??n[t]},has(e,t){return t in r()||t in n},set(e,t,n){let i=r(!0);return i[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=r(!0);return delete n[t],!0},ownKeys(){let e=r(!0);return Object.keys(e)}});i.NODE_ENV;function a(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return a(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return a(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return a(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return a(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return a(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return a(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return a(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function o(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}function s(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function c(e){let t=e.split(`
2    at `);return t.length<=1?e:(t.splice(1,1),t.join(`
3    at `))}function l(e,t){class n extends e{#e;constructor(...e){if(s()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=c(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var u={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};l(class extends Error{constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:u[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var d=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},f=47;function p(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===f;)t--;return t===e.length?e:e.slice(0,t)}function m(e){try{return(p(new URL(e).pathname)||`/`)!==`/`}catch{throw new d(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function h(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new d(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof d?t:new d(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function g(e,t=`/api/auth`){if(h(e),m(e))return e;let n=p(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function _(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function v(e,t,n,r,a){if(e)return g(e,t);if(r!==!1){let e=i.BETTER_AUTH_URL||i.NEXT_PUBLIC_BETTER_AUTH_URL||i.PUBLIC_BETTER_AUTH_URL||i.NUXT_PUBLIC_BETTER_AUTH_URL||i.NUXT_PUBLIC_AUTH_URL||(i.BASE_URL===`/`?void 0:i.BASE_URL);if(e)return g(e,t)}let o=n?.headers.get(`x-forwarded-host`),s=n?.headers.get(`x-forwarded-proto`);if(o&&s&&a&&_(s,`proto`)&&_(o,`host`))try{return g(`${s}://${o}`,t)}catch{}if(n){let e=y(n.url);if(!e)throw new d(`Could not get origin from request. Please provide a valid base URL.`);return g(e,t)}if(typeof window<`u`&&window.location)return g(window.location.origin,t)}function y(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var b={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},x=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,S={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},C=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ee(e){return e instanceof Date&&!isNaN(e.getTime())}function te(e){let t=C.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return ee(f)?f:null}function ne(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in S)return S[s];if(!x.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(b).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=te(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function re(e,t={strict:!0}){return ne(e,t)}var ie=[`javascript:`,`data:`,`vbscript:`];function ae(e){let t;try{t=new URL(e)}catch{return!0}return!ie.includes(t.protocol)}var oe={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&ae(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},w=[],T=0,E=null,D=4,se=globalThis.nanostoresGlobal||={epoch:0},ce=()=>{for(T=0;T<w.length;T+=D)w[T](w[T+1].value,w[T+2],w[T+3]);w.length=0},le=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=T+D;t<w.length;)w[t]===e?w.splice(t,D):t+=D;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){se.epoch++;let i=!w.length&&!0;for(let i of t)E?.has(i)||(E?.add(i),w.push(i,n,e,r));i&&ce()},off(){},set(e){let t=n.value;t!==e&&(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},ue=2,de=5,O=6,k=10,fe=(e,t,n,r)=>(e.events=e.events||{}
3,e.events[n+k]||(e.events[n+k]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+k](),delete e.events[n+k])}),pe=(e,t)=>fe(e,t,ue,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),me=1e3,he=(e,t)=>fe(e,n=>{let r=t(n);r&&e.events[O].push(r)},de,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[O]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[O])t();e.events[O]=[]}},me)},()=>{e.listen=n,e.off=r}});function ge(e,t,n){let r=new Set(t);return e.listen((e,i,a)=>{(a===void 0?t.some(t=>e[t]!==i[t]):r.has(a)||r.has(a.split(/\.|\[/)[0]))&&n(e,i,a)})}function _e(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function A(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!A(e[n],t[n]))return!1;return!0}if(_e(e)&&_e(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!A(e[r],t[r]))return!1;return!0}return!1}function ve(e,t){return pe(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var j=Symbol.for(`better-auth:broadcast-channel`),ye=()=>Math.floor(Date.now()/1e3),be=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:ye()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function M(e=`better-auth.message`){return globalThis[j]||(globalThis[j]=new be(e)),globalThis[j]}var N=Symbol.for(`better-auth:focus-manager`),xe=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function Se(){return globalThis[N]||(globalThis[N]=new xe),globalThis[N]}var P=Symbol.for(`better-auth:online-manager`),Ce=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function F(){return globalThis[P]||(globalThis[P]=new Ce),globalThis[P]}var I=()=>Math.floor(Date.now()/1e3),we=5;function Te(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||F().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=I(),t();return}if(e?.event===`visibilitychange`){if(I()-c.lastSessionRequest<we)return;c.lastSessionRequest=I(),t();return}t()}},d=e=>{M().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=M().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=Se().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=F().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=M().setup(),c.cleanupFocusSetup=Se().setup(),c.cleanupOnlineSetup=F().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var Ee=()=>typeof window>`u`;function De(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function L(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function Oe(e){return!e||e.session===null&&e.user===null?null:e}function ke(e,t){return A(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function Ae(e,t){let n=le(!1),r,i=e=>s(e),a=le({data:null,error:null,isPending:!0,isRefetching:!1,refetch:i});ve(a,ke);let o=e=>{if(r!==e)return;let t=a.get();r=void 0,(t.isPending||t.isRefetching)&&a.set({...t,isPending:!1,isRefetching:!1,refetch:i})},s=async t=>{r?.abort();let n=new AbortController;r=n;let s=a.get();a.set({...s,isPending:s.data===null,isRefetching:!0,error:null,refetch:i});try{let r=await e(`/get-session`,{method:`GET`,query:t?.query,signal:n.signal});if(n.signal.aborted){o(n);return}let{data:s,error:c}=L(r);if(s?.needsRefresh)try{let t=await e(`/get-session`,{method:`POST`,signal:n.signal});if(n.signal.aborted){o(n);return}({data:s,error:c}=L(t))}catch{if(n.signal.aborted){o(n);return}}if(c){let e=a.get(),t=c?.status===401;a.set({data:t?null:e.data,error:c,isPending:!1,isRefetching:!1,refetch:i});return}let l=Oe(s),u=a.get(),d=u.data!=null&&l!=null&&A(u.data,l)?u.data:l;a.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:i})}catch(e){if(n.signal.aborted){o(n);return}let t=a.get();a.set({data:t.data,error:e,isPending:!1,isRefetching:!1,refetch:i})}},c=()=>{};return he(a,()=>{let e;
3Ee()||(e=setTimeout(()=>{s()},0));let i=Te({fetchSession:s,shouldPollSession:()=>a.get().data!=null,sessionSignal:n,options:t});return i.init(),c=i.broadcastSessionUpdate,()=>{e&&clearTimeout(e);let t=r;t?.abort(),t&&o(t),i.cleanup()}}),{session:a,$sessionSignal:n,broadcastSessionUpdate:e=>c(e)}}function R(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function z(e,t,n=`.`,r){if(!R(t))return z(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:R(a)&&R(i[t])?z(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function je(e){return(...t)=>t.reduce((t,n)=>z(t,n,``,e),{})}var Me=je(),Ne=Object.defineProperty,Pe=Object.defineProperties,Fe=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,ze=(e,t,n)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||={})Le.call(t,n)&&ze(e,n,t[n]);if(Ie)for(var n of Ie(t))Re.call(t,n)&&ze(e,n,t[n]);return e},V=(e,t)=>Pe(e,Fe(t)),Be=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},Ve=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let r=await i.init?.call(i,e.toString(),t);n=r.options||n,e=r.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},H=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},He=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Ue(e){if(typeof e==`number`)return new H({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new H(e);case`exponential`:return new He(e);default:throw Error(`Invalid retry strategy`)}}var We=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},Ge=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ke(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return Ge.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function qe(e){try{return JSON.parse(e),!0}catch{return!1}}function U(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function W(e){try{return JSON.parse(e)}catch{return e}}function G(e){return typeof e==`function`}function Je(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&G(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&G(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function K(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function Ye(e){let t=new Headers(K(e?.headers,await We(e)));if(!t.has(`content-type`)){let n=Xe(e?.body);n&&t.set(`content-type`,n)}return t}function Xe(e){return U(e)?`application/json`:null}function Ze(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Qe(e,t){let{body:n}=e;return n?!U(n)||typeof n==`string`?n:Ze(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function $e(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return J.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function et(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}
3var tt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function q(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new tt(n.issues);return n.value}var J=[`get`,`post`,`put`,`patch`,`delete`],nt=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){let r=e.plugins?.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1)?.schema||e.schema;if(r){let e=t;r.config?.prefix&&e.startsWith(r.config.prefix)&&(e=e.replace(r.config.prefix,``),r.config.baseURL&&(t=t.replace(r.config.prefix,r.config.baseURL))),r.config?.baseURL&&e.startsWith(r.config.baseURL)&&(e=e.replace(r.config.baseURL,``)),e.startsWith(`/`)&&e.charAt(1)===`@`&&(e=e.substring(1));let i=r.schema[e];if(i){let e=n?.headers;if(i.headers&&!n?.disableValidation){let t={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((e,n)=>{t[n.toLowerCase()]=e});else if(typeof n.headers==`object`)for(let[e,r]of Object.entries(n.headers))r!=null&&(t[e.toLowerCase()]=r)}let r=await q(i.headers,t),a={};for(let[e,t]of Object.entries(r))a[e.toLowerCase()]=t;e=a}let r=V(B({},n),{method:i.method,output:i.output,headers:e});return n?.disableValidation||(r=V(B({},r),{body:i.input?await q(i.input,n?.body):n?.body,params:i.params?await q(i.params,n?.params):n?.params,query:i.query?await q(i.query,n?.query):n?.query})),{url:t,options:r}}}return{url:t,options:n}}}),rt=e=>{async function t(t,n){let r=V(B(B({},e),n),{headers:K(e?.headers,n?.headers),plugins:[...e?.plugins||[],nt(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Y(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await Y(t,r)}return t},it=e=>e===`.`||e===`..`;function at(e,t){let n=e;for(let[e,r]of t)n=n.replace(e,r);if(it(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function ot(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``;if(e.startsWith(`@`)){let t=e.toString().split(`@`)[1].split(`/`)[0];J.includes(t)&&(e=e.replace(`@${t}/`,`/`))}a.endsWith(`/`)||(a+=`/`);let[o,s]=e.replace(a,``).split(`?`),c=new URLSearchParams(s);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)c.append(e,n);continue}else n=JSON.stringify(t);c.set(e,n)}let l=new Map;if(r){if(Array.isArray(r)){let e=o.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];l.set(n,String(e))}}else for(let[e,t]of Object.entries(r))l.set(`:${e}`,String(t))}o=o.split(`/`).map(e=>at(e,l)).join(`/`),o=o.replace(/^\/+/,``);let u=c.toString();return u=u.length>0?`?${u}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${o}${u}`,a):`${a}${o}${u}`}var Y=async(e,t)=>{let{hooks:n,url:r,options:i}=await Ve(e,t),a=Je(i),o=new AbortController,s=i.signal??o.signal,c=ot(r,i),l=await Ye(i),u=Qe(i,l),d=$e(r,i),f=V(B({},i),{url:c,headers:l,body:u,method:d,signal:s});for(let e of n.onRequest)if(e){let t=await e(f);typeof t==`object`&&t&&Object.assign(f,t)}(`pipeTo`in f&&typeof f.pipeTo==`function`||typeof t?.body?.pipe==`function`)&&(`duplex`in f||(f.duplex=`half`));let{clearTimeout:p}=et(i,o),m=await a(f.url,f);p();let h={response:m,request:f};for(let e of n.onResponse)if(e){let n=await e(V(B({},h),{response:t?.hookOptions?.cloneResponse?m.clone():m}));n instanceof Response?m=n:typeof n==`object`&&n&&(m=n.response)}if(m.ok){if(f.method===`HEAD`)return{data:``,error:null};let e=Ke(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??W)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await q(f.output,r.data));for(let e of n.onSuccess)e&&await e(V(B({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??W,_=await m.text(),v=qe(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:V(B({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(V(B({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=Ue(t.retry),i=t.retryAttempt??0;if(await r.shouldAttemptRetry(i,m)){for(let e of n.onRetry)e&&await e(h);let a=r.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await Y(e,V(B({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new Be(m.status,m.statusText,v?y:_);return{data:null,error:V(B({},y),{status:m.status,statusText:m.statusText})}},st=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},ct=(e,t)=>
3{let n=`credentials`in Request.prototype,r=v(e?.baseURL,e?.basePath,void 0,t)??st(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=rt({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?re(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[oe],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=Ae(d,e),h=!1,g=e=>{h||e===null||(h=!0,De(p,e))},_=e?.plugins||[],y={},b={$sessionSignal:f,session:p},x={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},S=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(b,e.getAtoms?.(d)),e.pathMethods&&Object.assign(x,e.pathMethods),e.atomListeners&&S.push(...e.atomListeners);let C={notify:e=>{b[e].set(!b[e].get())},listen:(e,t)=>{b[e].subscribe(t)},atoms:b};for(let t of _)t.getActions&&(y=Me(t.getActions?.(d,C,e)??{},y));return{get baseURL(){return r},pluginsActions:y,pluginsAtoms:b,pluginPathMethods:x,atomListeners:S,hydrateSession:g,$fetch:d,$store:C}};function lt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function ut(e){return e.charAt(0).toUpperCase()+e.slice(1)}var dt=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,ft=/['\u2019]/g;function pt(e){return e.replace(ft,``).match(dt)??[]}function mt(e){return pt(e).map(e=>e.toLowerCase()).join(`-`)}function ht(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function gt(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||lt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(mt).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=ht(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}var X=e(t(),1);function _t(e,t={}){let n=(0,X.useRef)(e.get()),{keys:r,deps:i=[e,r]}=t,a=(0,X.useCallback)(t=>{let i=e=>{n.current!==e&&(n.current=e,t())};return i(e.value),r?.length?ge(e,r,i):e.listen(i)},i),o=()=>n.current;return(0,X.useSyncExternalStore)(a,o,o)}function vt(e){return`use${ut(e)}`}function yt(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,$store:o,atomListeners:s}=ct(e),c={};for(let[e,t]of Object.entries(r))c[vt(e)]=()=>_t(t);return gt({...n,...c,hydrateSession:i,$fetch:a,$store:o},a,t,r,s)}var Z=`1.7.0-rc.1`,bt=e=>({id:`additional-fields-client`,version:Z,$InferServerPlugin:{}}),xt=o({FAILED_TO_CREATE_USER:`Failed to create user`,USER_ALREADY_EXISTS:`User already exists.`,USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:`User already exists. Use another email.`,YOU_CANNOT_BAN_YOURSELF:`You cannot ban yourself`,YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE:`You are not allowed to change users role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS:`You are not allowed to create users`,YOU_ARE_NOT_ALLOWED_TO_LIST_USERS:`You are not allowed to list users`,YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS:`You are not allowed to list users sessions`,YOU_ARE_NOT_ALLOWED_TO_BAN_USERS:`You are not allowed to ban users`,YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS:`You are not allowed to impersonate users`,YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS:`You are not allowed to revoke users sessions`,YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS:`You are not allowed to delete users`,YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD:`You are not allowed to set users password`,BANNED_USER:`You have been banned from this application`,YOU_ARE_NOT_ALLOWED_TO_GET_USER:`You are not allowed to get user`,NO_DATA_TO_UPDATE:`No data to update`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS:`You are not allowed to update users`,YOU_CANNOT_REMOVE_YOURSELF:`You cannot remove yourself`,YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE:`You are not allowed to set a non-existent role value`,YOU_CANNOT_IMPERSONATE_ADMINS:`You cannot impersonate admins`,INVALID_ROLE_TYPE:`Invalid role type`,YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL:`You are not allowed to update users email`,PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER:`Password cannot be updated through update-user. Use the set-user-password endpoint instead`});function St(e){return{success:!1,error:`You are not allowed to access resource: ${e}`}}function Ct(e){return{success:!1,error:`unauthorized to access resource "${e}"`}}function wt(e){return e===`OR`?`OR`:`AND`}function Tt(e){return Array.isArray(e)}function Et(e){if(Tt(e))return{actions:e,connector:`AND`};if(!e||typeof e!=`object`)throw new d(`Invalid access control request`);let{actions:t,connector:n}=e;return Tt(t)?{actions:t,connector:wt(n)}:{actions:[],connector:wt(n)}}function Dt(e,t){return typeof t==`string`&&e.includes(t)}function Ot(e,{actions:t,connector:n}){return t.length===0?!1:n===`OR`?t.some(t=>Dt(e,t)):t.every(t=>Dt(e,t))}function kt(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return St(i);continue}let o=Ot(t,Et(a));if(o&&(r=!0),o&&n===`OR`)return{success:!0};if(!o&&n===`AND`)return Ct(i)}return r?{success:!0}:{success:!1,error:`Not authorized`}},statements:e}}function At(e){return{newRole(e){return kt(e)},statements:e}}var jt={user:[`create`,`list`,`set-role`,`ban`,`impersonate`,`impersonate-admins`,`delete`,`set-password`,`set-email`,`get`,`update`],session:[`list`,`revoke`,`delete`]},Mt=At(jt),Q=Mt.newRole({user:[`create`,`list`,`set-role`,`ban`,`impersonate`,`delete`,`set-password`,`set-email`,`get`,`update`],session:[`list`,`revoke`,`delete`]}),$=Mt.newRole({user:[],session:[]}),Nt={admin:Q,user:$},Pt=e=>
3{if(e.userId&&e.options?.adminUserIds?.includes(e.userId))return!0;if(!e.permissions)return!1;let t=(e.role||e.options?.defaultRole||`user`).split(`,`),n=e.options?.roles||Nt;for(let r of t)if(n[r]?.authorize(e.permissions)?.success)return!0;return!1},Ft=e=>{let t={admin:Q,user:$,...e?.roles};return{id:`admin-client`,version:Z,$InferServerPlugin:{},getActions:()=>({admin:{checkRolePermission:n=>Pt({role:n.role,options:{ac:e?.ac,roles:t},permissions:n.permissions})}}),pathMethods:{"/admin/list-users":`GET`,"/admin/impersonate-user":`POST`,"/admin/stop-impersonating":`POST`},atomListeners:[{matcher:e=>e===`/admin/impersonate-user`||e===`/admin/stop-impersonating`,signal:`$sessionSignal`}],$ERROR_CODES:xt}},It=()=>({id:`infer-server-plugin`,version:Z,$InferServerPlugin:{}}),Lt=()=>It(),Rt=At(jt),zt={admin:Q,user:$},Bt=yt({plugins:[bt(),Ft({ac:Rt,roles:zt}),Lt()]});export{Bt as t};
4//# sourceMappingURL=auth-client-DQCUApNo.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.